@askexenow/exe-os 0.9.374 → 0.9.376

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 (455) hide show
  1. package/deploy/compose/.env.customer.example +16 -1
  2. package/deploy/compose/.env.example +16 -1
  3. package/deploy/compose/docker-compose.yml +80 -18
  4. package/deploy/compose/gateway-watchdog.sh +17 -0
  5. package/deploy/compose/generate-env.ts +41 -1
  6. package/deploy/compose/sso-edge/default.conf.template +59 -63
  7. package/deploy/compose/sso-edge/error-pages/404.html +129 -0
  8. package/deploy/compose/sso-edge/error-pages/500.html +129 -0
  9. package/deploy/compose/sso-edge/error-pages/503.html +118 -0
  10. package/deploy/compose/sso-edge/sso-redirect.conf +115 -92
  11. package/dist/.dist-verified.json +3 -3
  12. package/dist/{active-agent-ONPPEWQV.js → active-agent-BOBBUJ74.js} +6 -6
  13. package/dist/{active-agent-UJKMG7LJ.js → active-agent-GFGEGK2U.js} +6 -6
  14. package/dist/{agent-defs-generator-ZWI6DXOE.js → agent-defs-generator-OX6UFPRX.js} +5 -5
  15. package/dist/{agent-loop-OYHJKNYH.js → agent-loop-7ZRH56EX.js} +1 -1
  16. package/dist/{agentic-ontology-WHFJ3QFS.js → agentic-ontology-DT3VOXBT.js} +1 -1
  17. package/dist/{backfill-metadata-3OUSQD5V.js → backfill-metadata-VRP6PTPP.js} +9 -9
  18. package/dist/{backup-verify-ZKTUYLTA.js → backup-verify-LWHKGOOV.js} +1 -1
  19. package/dist/behavior-injection-GMZKZ3BT.js +83 -0
  20. package/dist/behavior-promotion-QPC4AQ24.js +62 -0
  21. package/dist/{behaviors-ZJ45TFBJ.js → behaviors-GPI4BLTC.js} +16 -14
  22. package/dist/bin/agentic-ontology-backfill.js +10 -10
  23. package/dist/bin/agentic-reflection-backfill.js +11 -11
  24. package/dist/bin/agentic-semantic-label.js +10 -10
  25. package/dist/bin/backfill-conversations.js +14 -12
  26. package/dist/bin/backfill-responses.js +14 -12
  27. package/dist/bin/backfill-vectors.js +16 -14
  28. package/dist/bin/bulk-sync-postgres.js +21 -19
  29. package/dist/bin/cc-doctor.js +19 -11
  30. package/dist/bin/cleanup-stale-review-tasks.js +27 -26
  31. package/dist/bin/cli.js +83 -109
  32. package/dist/bin/daemon-restart-handoff.js +2 -1
  33. package/dist/bin/deferred-daemon-restart.js +118 -110
  34. package/dist/bin/exe-actions.js +176 -0
  35. package/dist/bin/exe-agent-config.js +5 -5
  36. package/dist/bin/exe-agent.js +23 -23
  37. package/dist/bin/exe-assign.js +16 -14
  38. package/dist/bin/exe-boot.js +91 -71
  39. package/dist/bin/exe-call.js +8 -8
  40. package/dist/bin/exe-cicd.js +1210 -0
  41. package/dist/bin/exe-cloud.js +70 -37
  42. package/dist/bin/exe-config-dump.js +5 -5
  43. package/dist/bin/exe-dispatch.js +28 -27
  44. package/dist/bin/exe-doctor.js +12 -11
  45. package/dist/bin/exe-export-behaviors.js +20 -18
  46. package/dist/bin/exe-forget.js +11 -11
  47. package/dist/bin/exe-gateway.js +10 -10
  48. package/dist/bin/exe-healthcheck.js +22 -10
  49. package/dist/bin/exe-heartbeat.js +33 -32
  50. package/dist/bin/exe-kill.js +32 -31
  51. package/dist/bin/exe-launch-agent.js +76 -54
  52. package/dist/bin/exe-mcp.js +10 -6
  53. package/dist/bin/exe-memory-reads.js +9 -9
  54. package/dist/bin/exe-model-supervisor.js +138 -0
  55. package/dist/bin/exe-new-employee.js +14 -14
  56. package/dist/bin/exe-os-mcp-proxy.js +10 -6
  57. package/dist/bin/exe-pending-messages.js +28 -27
  58. package/dist/bin/exe-pending-notifications.js +27 -26
  59. package/dist/bin/exe-pending-reviews.js +28 -27
  60. package/dist/bin/exe-rename.js +9 -9
  61. package/dist/bin/exe-repo-truth.js +1 -1
  62. package/dist/bin/exe-review.js +31 -30
  63. package/dist/bin/exe-search.js +10 -10
  64. package/dist/bin/exe-session-cleanup.js +32 -31
  65. package/dist/bin/exe-settings.js +21 -19
  66. package/dist/bin/exe-start-codex.js +31 -25
  67. package/dist/bin/exe-start-opencode.js +24 -22
  68. package/dist/bin/exe-start.sh +11 -2
  69. package/dist/bin/exe-status.js +29 -28
  70. package/dist/bin/exe-support.js +3 -3
  71. package/dist/bin/exe-team.js +7 -7
  72. package/dist/bin/exe-timers.js +2 -1
  73. package/dist/bin/exe-watchdog.js +170 -16
  74. package/dist/bin/generate-hook-manifest.js +8 -41
  75. package/dist/bin/git-sweep.js +28 -27
  76. package/dist/bin/graph-backfill.js +11 -11
  77. package/dist/bin/graph-export.js +10 -10
  78. package/dist/bin/hooks-cli.js +289 -0
  79. package/dist/bin/import-history.js +14 -14
  80. package/dist/bin/install.js +130 -116
  81. package/dist/bin/intercom-check.js +5 -5
  82. package/dist/bin/mcp-sessions.js +2 -2
  83. package/dist/bin/orchestration-metrics.js +7 -7
  84. package/dist/bin/postgres-agentic-reflection-backfill.js +4 -4
  85. package/dist/bin/postgres-agentic-semantic-backfill.js +4 -4
  86. package/dist/bin/pre-publish.js +1 -1
  87. package/dist/bin/reconcile-backlog.js +2 -2
  88. package/dist/bin/registry-proxy.js +2 -2
  89. package/dist/bin/scan-tasks.js +52 -38
  90. package/dist/bin/setup.js +1 -1
  91. package/dist/bin/shard-migrate.js +9 -9
  92. package/dist/bin/stack-update.js +10 -5
  93. package/dist/bin/verify-stack.js +3 -1
  94. package/dist/bin/vps-health-gate.js +1 -1
  95. package/dist/{boot-generation-JKVZ4ZAT.js → boot-generation-BN6GKASY.js} +6 -6
  96. package/dist/{boot-review-sections-2M6BTG73.js → boot-review-sections-OQ5JGSOD.js} +26 -25
  97. package/dist/{branch-hygiene-U5GFRSTP.js → branch-hygiene-QLD77IMJ.js} +1 -1
  98. package/dist/build-manifest.json +1186 -1106
  99. package/dist/{capability-cards-5IMJT6J7.js → capability-cards-EDZ62HKG.js} +5 -5
  100. package/dist/{capacity-monitor-SAXCQK7O.js → capacity-monitor-6GMTVILS.js} +28 -27
  101. package/dist/{catchup-brief-U2TXBLHD.js → catchup-brief-SGGBMDUP.js} +32 -31
  102. package/dist/{cc-binary-detect-6TNIY5JX.js → cc-binary-detect-ZR6WNOUU.js} +1 -3
  103. package/dist/{chunk-NKETJCB5.js → chunk-2ODXCCMR.js} +18 -3
  104. package/dist/{hook-integrity-KGAV6ZC2.js → chunk-3L72UBUH.js} +28 -15
  105. package/dist/chunk-3OX5S7KZ.js +273 -0
  106. package/dist/{chunk-W75GTHR3.js → chunk-3SRZNJKD.js} +1 -1
  107. package/dist/{chunk-I4DNJFDR.js → chunk-42IFYZUN.js} +4 -4
  108. package/dist/{chunk-JHI5WMK5.js → chunk-473JUDCT.js} +5 -5
  109. package/dist/{chunk-ANLFH23R.js → chunk-4F5CNI65.js} +1 -1
  110. package/dist/{chunk-AWWKRZMB.js → chunk-4KVSCQND.js} +87 -14
  111. package/dist/{chunk-ZCERWHY2.js → chunk-4M6RXJEY.js} +33 -23
  112. package/dist/{chunk-YTSXPJUQ.js → chunk-4YJEEOYT.js} +3 -3
  113. package/dist/{chunk-6RKKVPYF.js → chunk-4YUGB637.js} +1 -1
  114. package/dist/{chunk-XXOPG4BW.js → chunk-4ZSOKEDY.js} +3 -3
  115. package/dist/{chunk-55BEFF4V.js → chunk-5DF4Y6EC.js} +1 -1
  116. package/dist/{chunk-4QCFFW2H.js → chunk-5QCIWWFA.js} +46 -0
  117. package/dist/{chunk-3UUX5OY4.js → chunk-5QKLWJ4Z.js} +1 -1
  118. package/dist/{chunk-YSLGFPWX.js → chunk-5UBWBXLF.js} +3 -3
  119. package/dist/chunk-5WA4DG2A.js +117 -0
  120. package/dist/{chunk-4EN3IZ3Q.js → chunk-64ODONK2.js} +67 -1
  121. package/dist/{chunk-TAMDAOCU.js → chunk-66CGXQUA.js} +239 -39
  122. package/dist/{chunk-QHJR7IMX.js → chunk-6F3FQCAQ.js} +3 -3
  123. package/dist/{chunk-WMEYJT4R.js → chunk-6FG34V6D.js} +15 -14
  124. package/dist/{chunk-NMH5ZQPU.js → chunk-6KQ6WMTI.js} +1 -1
  125. package/dist/{chunk-IRVOXUSK.js → chunk-6WKBTZVL.js} +10 -4
  126. package/dist/{chunk-NOKJCF27.js → chunk-7INEFMVU.js} +9 -3
  127. package/dist/{chunk-GSJLB6JI.js → chunk-7THUQU44.js} +34 -8
  128. package/dist/{chunk-HDLAB7W3.js → chunk-7UH2JWBF.js} +1 -1
  129. package/dist/{chunk-KTCXJWJG.js → chunk-7UNMSF5O.js} +1 -1
  130. package/dist/{chunk-JTVIANUB.js → chunk-AEUGIJDO.js} +3 -1
  131. package/dist/{chunk-DSJI76XL.js → chunk-AHNVFBVB.js} +113 -16
  132. package/dist/{chunk-IBS2FAI4.js → chunk-AUKRBHHZ.js} +4 -1
  133. package/dist/{chunk-AKLJ4JH3.js → chunk-BBK2TSK3.js} +1 -1
  134. package/dist/{chunk-ZL4AGWAH.js → chunk-BNWWVYRN.js} +6 -5
  135. package/dist/{chunk-PY3FOMRN.js → chunk-BQEZPRUC.js} +4 -4
  136. package/dist/{chunk-DIXXEE3S.js → chunk-BQXYXJYC.js} +721 -309
  137. package/dist/{chunk-ORM7ZFKC.js → chunk-BZ546I4Q.js} +32 -0
  138. package/dist/{chunk-3KDCORDO.js → chunk-C2UN464N.js} +1 -1
  139. package/dist/{chunk-75H4R62K.js → chunk-CBPNZFSU.js} +0 -2
  140. package/dist/{chunk-YLXTKI6M.js → chunk-CHO5SNWR.js} +1 -1
  141. package/dist/{chunk-MXPNVSXI.js → chunk-CIEVY5TD.js} +11 -11
  142. package/dist/{chunk-UBK7HK3J.js → chunk-CKLJT2DH.js} +2 -2
  143. package/dist/{chunk-MOGA4Q7F.js → chunk-CKOJP7JI.js} +1 -1
  144. package/dist/{chunk-V3W3SATA.js → chunk-CL4J4757.js} +1 -1
  145. package/dist/{chunk-XNNECNDL.js → chunk-CQFWTWC6.js} +13 -13
  146. package/dist/{chunk-PDVXWXTL.js → chunk-CROVXJ4S.js} +3 -3
  147. package/dist/{chunk-WJG344NC.js → chunk-CWSLTSL6.js} +8 -8
  148. package/dist/{chunk-VMTZ4RUW.js → chunk-DDMGQ5Q3.js} +60 -26
  149. package/dist/{chunk-YKC7QDZH.js → chunk-DN24VTS5.js} +31 -6
  150. package/dist/{chunk-IN6CAM4F.js → chunk-EHAN752X.js} +7 -7
  151. package/dist/{chunk-EXTZSNWL.js → chunk-EPHSISMT.js} +2 -2
  152. package/dist/{chunk-6EZQUNE6.js → chunk-FCMQVEVL.js} +36 -3
  153. package/dist/{chunk-3L2QU5ZF.js → chunk-FS7XF7SE.js} +1 -1
  154. package/dist/{chunk-LGS2V2XD.js → chunk-FUKVP54K.js} +66 -19
  155. package/dist/{chunk-44TLJZJ5.js → chunk-FX2QRSRT.js} +1 -1
  156. package/dist/{chunk-PWRC5XZO.js → chunk-FXZ6VGFW.js} +16 -8
  157. package/dist/{chunk-NT7W4RXD.js → chunk-GKDAQL45.js} +1 -1
  158. package/dist/{chunk-EKE37MO4.js → chunk-GOT5ZHPX.js} +3 -3
  159. package/dist/{chunk-SLLLOOEI.js → chunk-GPJIBLP4.js} +1 -0
  160. package/dist/{chunk-EKYYMIVT.js → chunk-GPUOUUHA.js} +10 -1
  161. package/dist/{chunk-PB5S7YOF.js → chunk-GXNBPTPJ.js} +1 -1
  162. package/dist/{chunk-4SJ4LK4V.js → chunk-HE34XVD5.js} +5 -5
  163. package/dist/{chunk-6VHOQ3IM.js → chunk-HHAKXIKX.js} +12 -9
  164. package/dist/{chunk-TFKCERAK.js → chunk-HHT527PV.js} +38 -41
  165. package/dist/{chunk-ZSODLMFV.js → chunk-HIVOLPLD.js} +1 -40
  166. package/dist/{chunk-UCFC2AEI.js → chunk-I3LDTSWU.js} +1 -1
  167. package/dist/{chunk-Q3AXXKDF.js → chunk-IKXH4BFC.js} +5 -5
  168. package/dist/chunk-IMYGYIAI.js +23 -0
  169. package/dist/{chunk-GS7LIT34.js → chunk-IPHLUZ37.js} +1 -1
  170. package/dist/{chunk-M4IRPXSZ.js → chunk-IZA7XW2Q.js} +3 -3
  171. package/dist/{chunk-SEQIPGLU.js → chunk-IZLML47J.js} +1 -1
  172. package/dist/{chunk-4HKTO2SV.js → chunk-JRMHGO5B.js} +1 -1
  173. package/dist/{chunk-U73AC5AN.js → chunk-JSTTPYL3.js} +16 -16
  174. package/dist/{chunk-6SCGLHJ7.js → chunk-JVWLHBAV.js} +4 -4
  175. package/dist/{chunk-OVEQE6YS.js → chunk-K7UNIEB4.js} +254 -48
  176. package/dist/{chunk-HNWS7YHN.js → chunk-KBR5LIWD.js} +1 -1
  177. package/dist/{chunk-AKLQSC6W.js → chunk-KI7O64XV.js} +328 -98
  178. package/dist/{chunk-XXFKSJYA.js → chunk-KK3MIY5C.js} +5 -5
  179. package/dist/{chunk-U6SUKSZR.js → chunk-KO3OHI6V.js} +3 -3
  180. package/dist/{chunk-NJFJWQNN.js → chunk-L5CGXEZC.js} +27 -22
  181. package/dist/{chunk-NBXDXKLC.js → chunk-LK3XQDBP.js} +1 -1
  182. package/dist/{chunk-T3QUKNLI.js → chunk-LM443ORV.js} +1 -1
  183. package/dist/{chunk-BBSIEYF5.js → chunk-LNAFLXL7.js} +12 -4
  184. package/dist/{chunk-32YV32VA.js → chunk-LTUA5EYI.js} +122 -11
  185. package/dist/{chunk-23MVDXLY.js → chunk-MAXD5JQL.js} +11 -10
  186. package/dist/{chunk-GNUAL43X.js → chunk-MFASHRJ6.js} +5 -5
  187. package/dist/chunk-MFYMDGE7.js +37 -0
  188. package/dist/{chunk-VKJGHAZT.js → chunk-MGVILAYU.js} +57 -13
  189. package/dist/{chunk-DB55JZHU.js → chunk-MSLWRWTI.js} +1 -1
  190. package/dist/{chunk-C2L622QJ.js → chunk-NB5IRTC4.js} +52 -44
  191. package/dist/{chunk-2ZOEC4KC.js → chunk-ND75TGPR.js} +2 -2
  192. package/dist/{chunk-VRTCVZND.js → chunk-NE34MWVL.js} +142 -16
  193. package/dist/{chunk-S2WBS6BG.js → chunk-NMOFLWDY.js} +1 -1
  194. package/dist/{chunk-CRCB5S7I.js → chunk-NPXKGBVZ.js} +140 -23
  195. package/dist/{chunk-JSMDRKPJ.js → chunk-NRBGUIPE.js} +1 -1
  196. package/dist/{chunk-4LWBC7CM.js → chunk-NY6SBR4O.js} +1 -1
  197. package/dist/{chunk-UCUOGVDX.js → chunk-O3K2C22L.js} +13 -1
  198. package/dist/{chunk-R522MWAR.js → chunk-OATET4BV.js} +2 -2
  199. package/dist/chunk-OOZU5H3T.js +86 -0
  200. package/dist/{chunk-XFTEX77S.js → chunk-OQ4FNDRG.js} +28 -6
  201. package/dist/{chunk-VYQ7B7DI.js → chunk-OWVX52XF.js} +4 -4
  202. package/dist/{chunk-AETLDRZB.js → chunk-PEAAX6UA.js} +1 -1
  203. package/dist/{chunk-UM3N6VND.js → chunk-PFAVHC5N.js} +5 -5
  204. package/dist/chunk-PMVVUIHH.js +85 -0
  205. package/dist/chunk-PPMGQFLJ.js +2317 -0
  206. package/dist/{chunk-7TSBV3SD.js → chunk-PTY2N23C.js} +310 -2
  207. package/dist/{chunk-UKLN57Q5.js → chunk-PZ5SKYK6.js} +4 -4
  208. package/dist/{chunk-636LKCKE.js → chunk-Q6ZLQMP2.js} +1 -1
  209. package/dist/{chunk-N7VEP5B3.js → chunk-QFR5EKZG.js} +29 -7
  210. package/dist/{chunk-YMP2QSOP.js → chunk-QN56VQ6Z.js} +1 -1
  211. package/dist/{chunk-6YVUR3OU.js → chunk-QR3BUMOS.js} +2 -2
  212. package/dist/{chunk-XZ65ST2I.js → chunk-QV5CQLQH.js} +2 -2
  213. package/dist/{chunk-DJOIMFKV.js → chunk-REZIGNA6.js} +2 -2
  214. package/dist/{chunk-UQGSBM3U.js → chunk-RFPMXR6B.js} +11 -0
  215. package/dist/{chunk-DN4YVV4Z.js → chunk-RSABKW6B.js} +1 -1
  216. package/dist/{chunk-LP4GB656.js → chunk-RZNP35SI.js} +2 -2
  217. package/dist/{chunk-NUTZJZKW.js → chunk-SKTAZGFI.js} +10 -42
  218. package/dist/{chunk-TQAZTRQ3.js → chunk-SVXUT2DN.js} +4 -4
  219. package/dist/{chunk-DJ7YXOTU.js → chunk-T7EF5CQO.js} +3 -3
  220. package/dist/{chunk-QAEWWYHL.js → chunk-TDF2XKLK.js} +5 -1
  221. package/dist/{chunk-ZGYNKA3O.js → chunk-TT5BBVLX.js} +29 -31
  222. package/dist/{chunk-5H47VHB7.js → chunk-UWX6MMCX.js} +1 -1
  223. package/dist/{chunk-XL5MFGMR.js → chunk-V4YNN7PA.js} +10 -3
  224. package/dist/{chunk-SL6KQYDU.js → chunk-V5DDXXMP.js} +7 -7
  225. package/dist/{chunk-DZKPOSFD.js → chunk-VH6SPPNA.js} +1 -1
  226. package/dist/{chunk-LDNYSMPZ.js → chunk-VJUUI2VT.js} +1 -1
  227. package/dist/{chunk-CBCGDEJA.js → chunk-VN5WOOAQ.js} +42 -6
  228. package/dist/{chunk-EXDW3E2R.js → chunk-VPHJ2LUI.js} +165 -15
  229. package/dist/{chunk-GOMQ7PVQ.js → chunk-WJC6AAJN.js} +1 -1
  230. package/dist/{chunk-GJI77VDO.js → chunk-WVBVUVZB.js} +6 -5
  231. package/dist/{chunk-A6PDF4BO.js → chunk-XTQ7R2PA.js} +2 -2
  232. package/dist/{chunk-L6RXG36J.js → chunk-Y2HD2YB7.js} +1 -1
  233. package/dist/{chunk-KTU3EAWK.js → chunk-YAACLBZ7.js} +5 -5
  234. package/dist/{chunk-7GE2EQ23.js → chunk-YGVAKKGJ.js} +11 -6
  235. package/dist/chunk-YLHACCCB.js +166 -0
  236. package/dist/{chunk-PLZSZOZN.js → chunk-YP6UGVEY.js} +3 -3
  237. package/dist/{chunk-ULIBLJ6W.js → chunk-YYC553FO.js} +5 -5
  238. package/dist/{chunk-T35RCQFE.js → chunk-YZPEQW7H.js} +9 -8
  239. package/dist/{chunk-KI5PFRG6.js → chunk-ZKGWHT56.js} +60 -2
  240. package/dist/{chunk-NUK7EEN5.js → chunk-ZKJ5S23O.js} +33 -13
  241. package/dist/chunk-ZLPS3GR7.js +146 -0
  242. package/dist/{chunk-XH7YL7JM.js → chunk-ZMX22HSS.js} +50 -6
  243. package/dist/{chunk-JY5GAZYC.js → chunk-ZQEJ4IX2.js} +4 -0
  244. package/dist/{chunk-R4CBHKZ2.js → chunk-ZS5JO6QV.js} +7 -6
  245. package/dist/{cleanup-graph-garbage-DPJGO52H.js → cleanup-graph-garbage-LAPIZGFX.js} +12 -12
  246. package/dist/{cloud-sync-command-JPNTT4OQ.js → cloud-sync-command-QAZ2NWRA.js} +11 -2
  247. package/dist/{cloud-sync-db-init-V2LWIUQU.js → cloud-sync-db-init-HAGVF32Y.js} +1 -1
  248. package/dist/{cloud-sync-shutdown-BNALPWGX.js → cloud-sync-shutdown-DAEPCFVK.js} +5 -5
  249. package/dist/{co-activation-CMNSWS6B.js → co-activation-523TKQPZ.js} +5 -5
  250. package/dist/{co-occurrence-WRI2NAN6.js → co-occurrence-PQUCTENN.js} +36 -17
  251. package/dist/{code-context-index-NOJSHLPN.js → code-context-index-LIDOFKOR.js} +6 -4
  252. package/dist/{code-context-watcher-VZNZU3BO.js → code-context-watcher-4F7K2N3U.js} +6 -4
  253. package/dist/{content-extractor-NXYNEF5K.js → content-extractor-DJM5EUDA.js} +2 -2
  254. package/dist/{conversation-entity-extractor-74252CAO.js → conversation-entity-extractor-THGKQ5RD.js} +5 -5
  255. package/dist/{crdt-sync-B3JN6AIV.js → crdt-sync-32B55NOJ.js} +1 -1
  256. package/dist/{crm-webhook-GYWQRFET.js → crm-webhook-FHRISFYQ.js} +2 -2
  257. package/dist/{cto-delegation-gate-LQHVLEMW.js → cto-delegation-gate-O6XPGECP.js} +27 -26
  258. package/dist/{daemon-auth-QZHEO7IQ.js → daemon-auth-PNKHERLV.js} +6 -1
  259. package/dist/daemon-drift-N2GKUBAO.js +15 -0
  260. package/dist/{daemon-orchestration-5HIQALZH.js → daemon-orchestration-BWLSJG2X.js} +33 -30
  261. package/dist/{daemon-ready-P2BR2XP5.js → daemon-ready-BN6EZLTQ.js} +1 -1
  262. package/dist/{daemon-ready-signal-CKXPUMJ2.js → daemon-ready-signal-PNDMVKPJ.js} +3 -1
  263. package/dist/{daemon-restart-circuit-breaker-SMTWFX27.js → daemon-restart-circuit-breaker-CD4VMCU7.js} +1 -1
  264. package/dist/daemon-restart-report-FIO5HZTJ.js +15 -0
  265. package/dist/{daemon-timer-report-TNJH5SFY.js → daemon-timer-report-6UK5PSDP.js} +2 -1
  266. package/dist/{db-integrity-events-2DTFO37N.js → db-integrity-events-GYGANKZV.js} +1 -1
  267. package/dist/{destructive-data-guard-BVFWPPIS.js → destructive-data-guard-HHWUBIGS.js} +1 -1
  268. package/dist/{doc-graph-extractor-PQHDHQPQ.js → doc-graph-extractor-HOKOV7BE.js} +10 -10
  269. package/dist/{documents-C4SSPJMC.js → documents-HWEJMONR.js} +16 -14
  270. package/dist/{dreaming-XAO3FCBV.js → dreaming-FMNDODG2.js} +31 -30
  271. package/dist/{employee-boot-brief-W4OHUMRQ.js → employee-boot-brief-DBFROOQJ.js} +35 -34
  272. package/dist/{entity-boost-3UWGXG5O.js → entity-boost-5V4W6NFA.js} +1 -1
  273. package/dist/{exe-drift-AG2KMKD5.js → exe-drift-V55UAYRT.js} +6 -6
  274. package/dist/{exe-export-IC5BT335.js → exe-export-LHN42ZUS.js} +18 -16
  275. package/dist/{exe-import-A35ZLDPG.js → exe-import-M536BEZC.js} +18 -16
  276. package/dist/{exe-key-TCMJNYLA.js → exe-key-37XIR22X.js} +111 -107
  277. package/dist/{exe-org-JXCR3JYZ.js → exe-org-7TDIRNTE.js} +14 -14
  278. package/dist/{exe-snapshot-SV6SRIG6.js → exe-snapshot-EOUBCIQK.js} +34 -33
  279. package/dist/{fast-db-init-L2RGKJWH.js → fast-db-init-GWUZ746B.js} +1 -1
  280. package/dist/{founder-context-D4HFIESJ.js → founder-context-6LQKET4A.js} +2 -2
  281. package/dist/{fts-integrity-4YB34KWX.js → fts-integrity-PLAL6NMG.js} +1 -1
  282. package/dist/gateway/index.js +17 -17
  283. package/dist/{git-main-guard-VTW4N3CM.js → git-main-guard-BGICS25C.js} +1 -1
  284. package/dist/{git-staleness-TN7CYGFG.js → git-staleness-QNNXJK3W.js} +5 -5
  285. package/dist/{global-procedures-YFDEIOG7.js → global-procedures-NMQGF54V.js} +7 -7
  286. package/dist/{gotrue-session-ODZ2ERJX.js → gotrue-session-U4H3UGHL.js} +1 -3
  287. package/dist/{graph-auto-extract-3YR3TYRW.js → graph-auto-extract-7POGAKHM.js} +10 -10
  288. package/dist/{graph-query-AP5R6ZHO.js → graph-query-ZEDO4BDF.js} +1 -1
  289. package/dist/{graph-rag-Z2KCJTPK.js → graph-rag-JA7XN7NO.js} +5 -5
  290. package/dist/hook-integrity-6NLSNTXD.js +15 -0
  291. package/dist/{hook-prefetch-K5DN3TOQ.js → hook-prefetch-4KH3D4YU.js} +28 -26
  292. package/dist/hook-tamper-log-Z4PWC7N4.js +90 -0
  293. package/dist/hooks/bug-report-worker.js +31 -30
  294. package/dist/hooks/codex-stop-task-finalizer.js +33 -32
  295. package/dist/hooks/commit-complete.js +30 -29
  296. package/dist/hooks/error-recall.js +12 -12
  297. package/dist/hooks/exe-heartbeat-hook.js +7 -7
  298. package/dist/hooks/ingest-worker.js +17 -15
  299. package/dist/hooks/ingest.js +20 -20
  300. package/dist/hooks/instructions-loaded.js +9 -9
  301. package/dist/hooks/manifest.json +20 -20
  302. package/dist/hooks/notification.js +8 -8
  303. package/dist/hooks/post-compact.js +7 -7
  304. package/dist/hooks/post-tool-combined.js +14 -14
  305. package/dist/hooks/pre-compact.js +30 -29
  306. package/dist/hooks/pre-tool-use.js +303 -489
  307. package/dist/hooks/prompt-submit.js +61 -54
  308. package/dist/hooks/session-end.js +35 -34
  309. package/dist/hooks/session-start.js +18 -18
  310. package/dist/hooks/stop.js +36 -35
  311. package/dist/hooks/subagent-stop.js +32 -31
  312. package/dist/hooks/summary-worker.js +36 -35
  313. package/dist/index.js +39 -38
  314. package/dist/{installer-LK35OX6R.js → installer-M34Q7LAS.js} +25 -10
  315. package/dist/{installer-54HTN5RE.js → installer-POV6TDQ5.js} +12 -8
  316. package/dist/{installer-LLWKZI2S.js → installer-S624ZOMB.js} +12 -8
  317. package/dist/{intercom-queue-5NOT2RKI.js → intercom-queue-MKDWAEUV.js} +26 -25
  318. package/dist/lib/cloud-sync.js +27 -19
  319. package/dist/lib/consolidation.js +12 -12
  320. package/dist/lib/database.js +5 -5
  321. package/dist/lib/db-backup.js +7 -1
  322. package/dist/lib/db-daemon-client.js +8 -6
  323. package/dist/lib/db-write-worker.js +4 -4
  324. package/dist/lib/db.js +5 -5
  325. package/dist/lib/device-registry.js +1 -1
  326. package/dist/lib/embedder.js +6 -4
  327. package/dist/lib/employee-templates.js +8 -8
  328. package/dist/lib/employees.js +5 -5
  329. package/dist/lib/exe-daemon-client.js +5 -3
  330. package/dist/lib/exe-daemon.js +333 -262
  331. package/dist/lib/hybrid-search.js +10 -10
  332. package/dist/lib/identity-templates.js +1 -1
  333. package/dist/lib/identity.js +17 -7
  334. package/dist/lib/license.js +2 -2
  335. package/dist/lib/messaging.js +27 -26
  336. package/dist/lib/post-tool-memory.js +9 -9
  337. package/dist/lib/registry-proxy.js +3 -1
  338. package/dist/lib/reminders.js +6 -6
  339. package/dist/lib/schedules.js +11 -11
  340. package/dist/lib/session-registry.js +11 -7
  341. package/dist/lib/session-wrappers.js +1 -1
  342. package/dist/lib/skill-learning.js +17 -15
  343. package/dist/lib/status-brief.js +2 -1
  344. package/dist/lib/store.js +9 -9
  345. package/dist/lib/task-router.js +6 -6
  346. package/dist/lib/tasks.js +28 -27
  347. package/dist/lib/tmux-routing.js +26 -25
  348. package/dist/lib/tmux-status.js +5 -1
  349. package/dist/lib/token-spend.js +6 -6
  350. package/dist/{license-gate-JVMB6OFD.js → license-gate-2QNMBAZU.js} +3 -3
  351. package/dist/{license-sync-5VYS2F2W.js → license-sync-FEDKH5MD.js} +2 -2
  352. package/dist/{mailbox-inbox-4MEUOL3J.js → mailbox-inbox-XE72D3AX.js} +2 -2
  353. package/dist/{mailbox-outbox-J6WIF3UY.js → mailbox-outbox-DNDDP2HW.js} +1 -1
  354. package/dist/mcp/register-tools.js +110 -106
  355. package/dist/mcp/server.js +113 -109
  356. package/dist/mcp/tools/complete-reminder.js +7 -7
  357. package/dist/mcp/tools/create-reminder.js +7 -7
  358. package/dist/mcp/tools/create-task.js +30 -29
  359. package/dist/mcp/tools/deactivate-behavior.js +18 -16
  360. package/dist/mcp/tools/list-reminders.js +7 -7
  361. package/dist/mcp/tools/list-tasks.js +30 -29
  362. package/dist/mcp/tools/send-message.js +33 -30
  363. package/dist/mcp/tools/update-task.js +29 -28
  364. package/dist/{mcp-child-registry-OTG4MWO7.js → mcp-child-registry-DVHYAHPW.js} +2 -2
  365. package/dist/{mcp-health-HNVSWKFA.js → mcp-health-B5EKRCZG.js} +2 -2
  366. package/dist/{mcp-http-config-DQWL7U2Z.js → mcp-http-config-ZJ7XHWT7.js} +10 -6
  367. package/dist/{mcp-session-identity-277GASTQ.js → mcp-session-identity-PEVM7VIP.js} +26 -25
  368. package/dist/{memory-cards-3S2ZQPR7.js → memory-cards-VN5DEWPD.js} +9 -9
  369. package/dist/{memory-graph-extractor-A6DFEFIN.js → memory-graph-extractor-TMEB6WLA.js} +11 -11
  370. package/dist/{memory-poisoning-defense-ZVP4H6DY.js → memory-poisoning-defense-DYHARQ2G.js} +5 -5
  371. package/dist/{memory-pressure-watchdog-6W5F6R7H.js → memory-pressure-watchdog-J6Q3SIBL.js} +27 -26
  372. package/dist/{memory-queue-client-ADSDP6OX.js → memory-queue-client-QC2OTMJB.js} +6 -4
  373. package/dist/{memory-reflection-BKB2YOE6.js → memory-reflection-ZYJUOSFX.js} +9 -9
  374. package/dist/{message-queue-client-XQN7QABL.js → message-queue-client-OEQCGSWC.js} +1 -25
  375. package/dist/{notification-ledger-CLGM7ODF.js → notification-ledger-TG6EFYBP.js} +29 -28
  376. package/dist/{notifications-MACUZPYP.js → notifications-LGYY22W5.js} +26 -25
  377. package/dist/{orchestration-events-N7LYMUGA.js → orchestration-events-JPHB6NPY.js} +6 -6
  378. package/dist/{orchestrator-4X24EWHV.js → orchestrator-IC4WGP6L.js} +28 -27
  379. package/dist/{org-brief-session-FZOFMO5U.js → org-brief-session-DEPHWCQR.js} +9 -9
  380. package/dist/{org-consent-policy-O5E6HXBL.js → org-consent-policy-T27AO5OJ.js} +2 -2
  381. package/dist/{org-join-POWUG25F.js → org-join-A3YXC5RB.js} +2 -2
  382. package/dist/{org-key-admin-E7EMDOZZ.js → org-key-admin-SQFHCVP2.js} +3 -3
  383. package/dist/{org-partner-runtime-FODONVTM.js → org-partner-runtime-L7L2WWGN.js} +10 -10
  384. package/dist/{org-row-visibility-VX4AVV5Q.js → org-row-visibility-M54Z6ZH3.js} +1 -1
  385. package/dist/{pipeline-router-6GGT2ZW3.js → pipeline-router-NKYAUR3Y.js} +6 -6
  386. package/dist/{plan-limits-FUN76LYY.js → plan-limits-ISRRGF23.js} +8 -8
  387. package/dist/{platform-procedures-7YSCLF4Z.js → platform-procedures-Z7ZGBJWN.js} +1 -1
  388. package/dist/{project-boot-3Q65LCIP.js → project-boot-BLYGVUJH.js} +4 -1
  389. package/dist/{project-name-LJVFMYTQ.js → project-name-WKSNNKXK.js} +6 -6
  390. package/dist/{projection-worker-4OANGP5K.js → projection-worker-RNYPE46G.js} +2 -2
  391. package/dist/{prospective-memory-KR3P4T6N.js → prospective-memory-GEO6E3UL.js} +5 -5
  392. package/dist/{push-notifications-NCZLH6DI.js → push-notifications-EY6BXZUY.js} +27 -26
  393. package/dist/{reproject-worktree-memories-PWYKPB2U.js → reproject-worktree-memories-DAA5GWMH.js} +28 -27
  394. package/dist/{reranker-6V3C2AO4.js → reranker-7OADQPMG.js} +1 -1
  395. package/dist/{retrieval-health-5D7O6VH6.js → retrieval-health-FCEDWN2P.js} +2 -2
  396. package/dist/{review-polling-QW3LJ4KN.js → review-polling-G52BR4MC.js} +27 -26
  397. package/dist/runtime/index.js +39 -38
  398. package/dist/{session-events-T45SSTMF.js → session-events-P6E2373E.js} +27 -26
  399. package/dist/{session-kill-telemetry-QSPVJGBF.js → session-kill-telemetry-OHNJMIVT.js} +27 -26
  400. package/dist/{session-mcp-config-SC5BLWZG.js → session-mcp-config-WFZAH6R5.js} +2 -1
  401. package/dist/{session-scope-KRWE54C4.js → session-scope-DKOHPQPJ.js} +26 -25
  402. package/dist/{setup-wizard-GP3TBTPF.js → setup-wizard-RNU3RFBE.js} +1 -1
  403. package/dist/{skill-refinement-C7JTMLJG.js → skill-refinement-AKJTHFXC.js} +6 -6
  404. package/dist/{stack-generate-manifest-MFMDWRUP.js → stack-generate-manifest-7WJZWSPK.js} +163 -15
  405. package/dist/{stack-promote-EKSCYY63.js → stack-promote-OP2URGFF.js} +4 -4
  406. package/dist/{stack-release-2GZAAFO4.js → stack-release-MY6U2QIO.js} +31 -8
  407. package/dist/{stack-update-J6JXSTAZ.js → stack-update-QSHSLUTZ.js} +3 -3
  408. package/dist/{steward-gate-BFCCMCSW.js → steward-gate-KMLS5ECC.js} +6 -6
  409. package/dist/{subagent-brief-injection-ED36PLYY.js → subagent-brief-injection-HCKZQZBF.js} +37 -36
  410. package/dist/{support-inbox-YW47SYJF.js → support-inbox-UBXU5RKV.js} +11 -11
  411. package/dist/{support-outbox-HFJWG52M.js → support-outbox-G2NG2U5K.js} +2 -2
  412. package/dist/{sweep-budget-KMPJ7O5Z.js → sweep-budget-YGLCNXZZ.js} +9 -3
  413. package/dist/{task-enforcement-CECTQX4U.js → task-enforcement-2GR7HU6V.js} +27 -26
  414. package/dist/{task-request-inbox-Q5T4N5K7.js → task-request-inbox-ANCVK2VG.js} +2 -2
  415. package/dist/{task-scope-ERVEUEYU.js → task-scope-QANJJXXB.js} +30 -29
  416. package/dist/{tasks-crud-ZRQNJXQ2.js → tasks-crud-45WOIMIM.js} +44 -25
  417. package/dist/{tasks-notify-MIZH4C2O.js → tasks-notify-ZJS4MA3S.js} +29 -26
  418. package/dist/{tasks-review-Z7J2P6DG.js → tasks-review-ZVPKY47Z.js} +26 -25
  419. package/dist/{telemetry-upload-LVQUQYFP.js → telemetry-upload-VY3UWAEL.js} +10 -10
  420. package/dist/{token-budget-BU4NOVZF.js → token-budget-XHX6XFEC.js} +6 -6
  421. package/dist/{tool-capability-index-7F42MOJT.js → tool-capability-index-6HLZU437.js} +1 -1
  422. package/dist/{tool-telemetry-O27EVMBR.js → tool-telemetry-GBDI4AXR.js} +1 -1
  423. package/dist/tui/App.js +36 -35
  424. package/dist/{tui-data-TPWWBIUQ.js → tui-data-IQFE3UW3.js} +30 -29
  425. package/dist/{typed-messages-RCMPEKJN.js → typed-messages-P2HLLA62.js} +1 -1
  426. package/dist/{update-support-F2F5537B.js → update-support-BDN5AK4R.js} +25 -22
  427. package/dist/{work-claims-B73X5NE7.js → work-claims-PDQNLE5K.js} +7 -7
  428. package/dist/{work-state-heartbeat-P4YX6E2R.js → work-state-heartbeat-CH6BLQKV.js} +1 -1
  429. package/dist/{worker-gate-BEEIIVWA.js → worker-gate-NUUSQMBT.js} +1 -3
  430. package/dist/{workflow-engine-5X46PFCW.js → workflow-engine-RZ7QEI3Z.js} +2 -2
  431. package/dist/{worktree-W47CIMJ6.js → worktree-Q25PZST6.js} +11 -7
  432. package/dist/worktree-ownership-guard-4LKMW6PW.js +421 -0
  433. package/dist/{worktree-sweep-BNBD4RFX.js → worktree-sweep-EV5YQ2OB.js} +8 -8
  434. package/package.json +15 -3
  435. package/release-notes.json +5 -5
  436. package/src/commands/exe.md +16 -16
  437. package/stack.release.json +9 -8
  438. package/dist/behavior-injection-M6UYZCMW.js +0 -63
  439. package/dist/chunk-BJ7AVSY6.js +0 -50
  440. package/dist/daemon-restart-report-EIVD6WDJ.js +0 -10
  441. package/dist/worktree-ownership-guard-OUWJROW2.js +0 -88
  442. /package/dist/{chunk-GQOEWNVM.js → chunk-4EG4DT4F.js} +0 -0
  443. /package/dist/{chunk-AISULNGL.js → chunk-BRAIWGMF.js} +0 -0
  444. /package/dist/{chunk-NRG7KZIP.js → chunk-HQEAZDAC.js} +0 -0
  445. /package/dist/{chunk-VZAFWPAY.js → chunk-IK4344V5.js} +0 -0
  446. /package/dist/{chunk-GM7TLYOK.js → chunk-K3VDF6II.js} +0 -0
  447. /package/dist/{chunk-2AJGV5UL.js → chunk-KM7DAG5J.js} +0 -0
  448. /package/dist/{chunk-YO4BO2CL.js → chunk-QIEYJ4KZ.js} +0 -0
  449. /package/dist/{chunk-WSQASFLP.js → chunk-VCTK5HRA.js} +0 -0
  450. /package/dist/{chunk-KQ6RJWRW.js → chunk-VPT6VMBG.js} +0 -0
  451. /package/dist/{chunk-6WIFPD2P.js → chunk-YZ4AEMR7.js} +0 -0
  452. /package/dist/{core-memory-7I7RE2SJ.js → core-memory-UIZKCY4L.js} +0 -0
  453. /package/dist/{memory-isolation-2TUZ7Z4K.js → memory-isolation-3GJ6WLYX.js} +0 -0
  454. /package/dist/{oauth-server-AYM37SQ4.js → oauth-server-ZRHXIRXQ.js} +0 -0
  455. /package/dist/{wiki-acl-IBQLLBTS.js → wiki-acl-MFOYK5F4.js} +0 -0
@@ -10,7 +10,40 @@ var DEFAULT_RELATIONSHIP_LIMIT = 500;
10
10
  function escapeLikePattern(value) {
11
11
  return value.replace(/[\\%_]/g, (m) => `\\${m}`);
12
12
  }
13
- async function getEntityDegree(client, entityId) {
13
+ function projectScopeExists(entityIdColumn, includeSessionScope) {
14
+ const sessionClause = includeSessionScope ? " AND (m.session_scope = ? OR m.session_scope IS NULL)" : "";
15
+ return `EXISTS (
16
+ SELECT 1 FROM entity_memories em
17
+ JOIN memories m ON m.id = em.memory_id
18
+ WHERE em.entity_id = ${entityIdColumn} AND m.project_name = ?${sessionClause}
19
+ )`;
20
+ }
21
+ async function resolveSessionScopeArg(opts) {
22
+ if (opts?.allowCrossSession) return void 0;
23
+ if (opts?.sessionScope !== void 0) return opts.sessionScope;
24
+ const { resolveExeSession } = await import("./lib/tmux-routing.js");
25
+ return resolveExeSession();
26
+ }
27
+ function relationshipScopeExists(relationshipIdColumn, includeSessionScope) {
28
+ const sessionClause = includeSessionScope ? " AND (rm_m.session_scope = ? OR rm_m.session_scope IS NULL)" : "";
29
+ return `EXISTS (
30
+ SELECT 1 FROM relationship_memories rm
31
+ JOIN memories rm_m ON rm_m.id = rm.memory_id
32
+ WHERE rm.relationship_id = ${relationshipIdColumn} AND rm_m.project_name = ?${sessionClause}
33
+ )`;
34
+ }
35
+ async function getEntityDegree(client, entityId, scope) {
36
+ if (scope) {
37
+ const args = [entityId, entityId, scope.projectName];
38
+ if (scope.includeSession) args.push(scope.sessionScope ?? null);
39
+ const result2 = await client.execute({
40
+ sql: `SELECT COUNT(*) as cnt FROM relationships r
41
+ WHERE (r.source_entity_id = ? OR r.target_entity_id = ?)
42
+ AND ${relationshipScopeExists("r.id", scope.includeSession)}`,
43
+ args
44
+ });
45
+ return Number(result2.rows[0]?.cnt ?? 0);
46
+ }
14
47
  const result = await client.execute({
15
48
  sql: `SELECT COUNT(*) as cnt FROM relationships
16
49
  WHERE source_entity_id = ? OR target_entity_id = ?`,
@@ -18,7 +51,7 @@ async function getEntityDegree(client, entityId) {
18
51
  });
19
52
  return Number(result.rows[0]?.cnt ?? 0);
20
53
  }
21
- async function getEntityByName(client, name, type) {
54
+ async function getEntityByName(client, name, type, projectName, scopeOpts) {
22
55
  let sql;
23
56
  let args;
24
57
  if (type) {
@@ -29,6 +62,13 @@ async function getEntityByName(client, name, type) {
29
62
  sql = `SELECT * FROM entities WHERE LOWER(name) = LOWER(?) LIMIT 1`;
30
63
  args = [name];
31
64
  }
65
+ if (projectName) {
66
+ const sessionScope = await resolveSessionScopeArg(scopeOpts);
67
+ const includeSession = sessionScope !== void 0;
68
+ sql = sql.replace(/ LIMIT 1$/, ` AND ${projectScopeExists("entities.id", includeSession)} LIMIT 1`);
69
+ args.push(projectName);
70
+ if (includeSession) args.push(sessionScope);
71
+ }
32
72
  const result = await client.execute({ sql, args });
33
73
  if (result.rows.length === 0) return null;
34
74
  const row = result.rows[0];
@@ -41,11 +81,19 @@ async function getEntityByName(client, name, type) {
41
81
  properties: JSON.parse(String(row.properties ?? "{}"))
42
82
  };
43
83
  }
44
- async function searchEntities(client, query, limit = 10) {
45
- const result = await client.execute({
46
- sql: `SELECT * FROM entities WHERE LOWER(name) LIKE ? ESCAPE '\\' ORDER BY last_seen DESC LIMIT ?`,
47
- args: [`%${escapeLikePattern(query.toLowerCase())}%`, limit]
48
- });
84
+ async function searchEntities(client, query, limit = 10, projectName, scopeOpts) {
85
+ const args = [`%${escapeLikePattern(query.toLowerCase())}%`];
86
+ let sql = `SELECT * FROM entities WHERE LOWER(name) LIKE ? ESCAPE '\\'`;
87
+ if (projectName) {
88
+ const sessionScope = await resolveSessionScopeArg(scopeOpts);
89
+ const includeSession = sessionScope !== void 0;
90
+ sql += ` AND ${projectScopeExists("entities.id", includeSession)}`;
91
+ args.push(projectName);
92
+ if (includeSession) args.push(sessionScope);
93
+ }
94
+ sql += ` ORDER BY last_seen DESC LIMIT ?`;
95
+ args.push(limit);
96
+ const result = await client.execute({ sql, args });
49
97
  return result.rows.map((row) => ({
50
98
  id: String(row.id),
51
99
  name: String(row.name),
@@ -97,6 +145,13 @@ async function getRelationships(client, entityId, options) {
97
145
  sql += ` AND r.type = ?`;
98
146
  args.push(options.type);
99
147
  }
148
+ if (options?.projectName) {
149
+ const sessionScope = await resolveSessionScopeArg(options.scopeOpts);
150
+ const includeSession = sessionScope !== void 0;
151
+ sql += ` AND ${relationshipScopeExists("r.id", includeSession)}`;
152
+ args.push(options.projectName);
153
+ if (includeSession) args.push(sessionScope);
154
+ }
100
155
  sql += ` ORDER BY r.weight DESC, r.timestamp DESC LIMIT ?`;
101
156
  args.push(DEFAULT_RELATIONSHIP_LIMIT);
102
157
  const result = await client.execute({ sql, args });
@@ -160,9 +215,16 @@ async function traverseChain(client, startEntityId, relationshipType, maxDepth =
160
215
  relationship: String(row.rel_type)
161
216
  }));
162
217
  }
163
- async function getEntityNeighbors(client, entityId, maxHops = 2, asOf) {
218
+ async function getEntityNeighbors(client, entityId, maxHops = 2, asOf, projectName, scopeOpts) {
164
219
  const safeMaxHops = Math.max(1, Math.min(maxHops, MAX_GRAPH_TRAVERSAL_DEPTH));
165
- if (await getEntityDegree(client, entityId) > MAX_HUB_DEGREE_FOR_TRAVERSAL) {
220
+ let includeSession = false;
221
+ let sessionScope;
222
+ if (projectName) {
223
+ sessionScope = await resolveSessionScopeArg(scopeOpts);
224
+ includeSession = sessionScope !== void 0;
225
+ }
226
+ const degree = projectName ? await getEntityDegree(client, entityId, { projectName, sessionScope, includeSession }) : await getEntityDegree(client, entityId);
227
+ if (degree > MAX_HUB_DEGREE_FOR_TRAVERSAL) {
166
228
  return [];
167
229
  }
168
230
  let temporalFilter;
@@ -173,7 +235,19 @@ async function getEntityNeighbors(client, entityId, maxHops = 2, asOf) {
173
235
  } else {
174
236
  temporalFilter = `AND r.valid_until IS NULL`;
175
237
  }
176
- args.push(safeMaxHops, MAX_GRAPH_TRAVERSAL_ROWS);
238
+ let scopeFilter = "";
239
+ if (projectName) {
240
+ scopeFilter = ` AND ${relationshipScopeExists("r.id", includeSession)}`;
241
+ args.push(projectName);
242
+ if (includeSession) args.push(sessionScope ?? null);
243
+ }
244
+ args.push(safeMaxHops);
245
+ const hubGuardClause = projectName ? `(SELECT COUNT(*) FROM relationships rd WHERE (rd.source_entity_id = n.entity_id OR rd.target_entity_id = n.entity_id) AND ${relationshipScopeExists("rd.id", includeSession)}) <= ${MAX_HUB_DEGREE_FOR_TRAVERSAL}` : `(SELECT COUNT(*) FROM relationships rd WHERE rd.source_entity_id = n.entity_id OR rd.target_entity_id = n.entity_id) <= ${MAX_HUB_DEGREE_FOR_TRAVERSAL}`;
246
+ const hubGuardArgs = [];
247
+ if (projectName) {
248
+ hubGuardArgs.push(projectName);
249
+ if (includeSession) hubGuardArgs.push(sessionScope ?? null);
250
+ }
177
251
  const result = await client.execute({
178
252
  sql: `WITH RECURSIVE neighborhood(entity_id, depth, rel_type, rel_confidence, path) AS (
179
253
  SELECT ?, 0, '', 1.0, '|' || ? || '|'
@@ -189,13 +263,13 @@ async function getEntityNeighbors(client, entityId, maxHops = 2, asOf) {
189
263
  FROM neighborhood n
190
264
  JOIN relationships r ON (r.source_entity_id = n.entity_id
191
265
  OR r.target_entity_id = n.entity_id)
192
- ${temporalFilter}
266
+ ${temporalFilter}${scopeFilter}
193
267
  WHERE n.depth < ?
194
268
  AND instr(n.path, '|' || CASE
195
269
  WHEN r.source_entity_id = n.entity_id THEN r.target_entity_id
196
270
  ELSE r.source_entity_id
197
271
  END || '|') = 0
198
- AND (SELECT COUNT(*) FROM relationships rd WHERE rd.source_entity_id = n.entity_id OR rd.target_entity_id = n.entity_id) <= ${MAX_HUB_DEGREE_FOR_TRAVERSAL}
272
+ AND ${hubGuardClause}
199
273
  LIMIT ?
200
274
  )
201
275
  SELECT * FROM (
@@ -210,7 +284,7 @@ async function getEntityNeighbors(client, entityId, maxHops = 2, asOf) {
210
284
  WHERE rn = 1
211
285
  ORDER BY depth ASC, last_seen DESC
212
286
  LIMIT 50`,
213
- args
287
+ args: [...args, ...hubGuardArgs, MAX_GRAPH_TRAVERSAL_ROWS]
214
288
  });
215
289
  return result.rows.map((row) => ({
216
290
  entity: {
@@ -226,12 +300,41 @@ async function getEntityNeighbors(client, entityId, maxHops = 2, asOf) {
226
300
  relConfidence: Number(row.rel_confidence ?? 1)
227
301
  }));
228
302
  }
229
- async function getGraphStats(client) {
230
- const entityCount = await client.execute("SELECT COUNT(*) as cnt FROM entities");
231
- const relCount = await client.execute("SELECT COUNT(*) as cnt FROM relationships");
232
- const typeResult = await client.execute(
233
- "SELECT type, COUNT(*) as cnt FROM entities GROUP BY type ORDER BY cnt DESC"
234
- );
303
+ async function getGraphStats(client, projectName, scopeOpts) {
304
+ if (!projectName) {
305
+ const entityCount2 = await client.execute("SELECT COUNT(*) as cnt FROM entities");
306
+ const relCount2 = await client.execute("SELECT COUNT(*) as cnt FROM relationships");
307
+ const typeResult2 = await client.execute(
308
+ "SELECT type, COUNT(*) as cnt FROM entities GROUP BY type ORDER BY cnt DESC"
309
+ );
310
+ const types2 = {};
311
+ for (const row of typeResult2.rows) {
312
+ types2[String(row.type)] = Number(row.cnt);
313
+ }
314
+ return {
315
+ entities: Number(entityCount2.rows[0]?.cnt ?? 0),
316
+ relationships: Number(relCount2.rows[0]?.cnt ?? 0),
317
+ types: types2
318
+ };
319
+ }
320
+ const sessionScope = await resolveSessionScopeArg(scopeOpts);
321
+ const includeSession = sessionScope !== void 0;
322
+ const entityScope = projectScopeExists("entities.id", includeSession);
323
+ const entityArgs = includeSession ? [projectName, sessionScope] : [projectName];
324
+ const entityCount = await client.execute({
325
+ sql: `SELECT COUNT(*) as cnt FROM entities WHERE ${entityScope}`,
326
+ args: entityArgs
327
+ });
328
+ const relCount = await client.execute({
329
+ sql: `SELECT COUNT(*) as cnt FROM relationships r
330
+ WHERE ${relationshipScopeExists("r.id", includeSession)}`,
331
+ args: entityArgs
332
+ });
333
+ const typeResult = await client.execute({
334
+ sql: `SELECT type, COUNT(*) as cnt FROM entities WHERE ${entityScope}
335
+ GROUP BY type ORDER BY cnt DESC`,
336
+ args: entityArgs
337
+ });
235
338
  const types = {};
236
339
  for (const row of typeResult.rows) {
237
340
  types[String(row.type)] = Number(row.cnt);
@@ -355,20 +458,34 @@ async function getConversationPartners(client, contactEntityId, since) {
355
458
  }
356
459
  return partners;
357
460
  }
358
- async function getHotEntities(client, since, limit = 10) {
461
+ async function getHotEntities(client, since, limit = 10, projectName, scopeOpts) {
359
462
  const safeSince = isNaN(since.getTime()) ? new Date(Date.now() - 7 * 24 * 60 * 60 * 1e3) : since;
360
463
  const sinceISO = safeSince.toISOString();
464
+ const sessionScope = projectName ? await resolveSessionScopeArg(scopeOpts) : void 0;
465
+ const includeSession = sessionScope !== void 0;
466
+ const relClause = projectName ? ` AND ${relationshipScopeExists("r.id", includeSession)}` : "";
467
+ const args = [sinceISO];
468
+ if (projectName) {
469
+ args.push(projectName);
470
+ if (includeSession) args.push(sessionScope);
471
+ }
472
+ args.push(sinceISO);
473
+ if (projectName) {
474
+ args.push(projectName);
475
+ if (includeSession) args.push(sessionScope);
476
+ }
477
+ args.push(limit);
361
478
  const result = await client.execute({
362
479
  sql: `SELECT entity_id, COUNT(*) as rel_count
363
480
  FROM (
364
- SELECT source_entity_id as entity_id FROM relationships WHERE timestamp >= ?
481
+ SELECT source_entity_id as entity_id FROM relationships r WHERE timestamp >= ?${relClause}
365
482
  UNION ALL
366
- SELECT target_entity_id as entity_id FROM relationships WHERE timestamp >= ?
483
+ SELECT target_entity_id as entity_id FROM relationships r WHERE timestamp >= ?${relClause}
367
484
  )
368
485
  GROUP BY entity_id
369
486
  ORDER BY rel_count DESC
370
487
  LIMIT ?`,
371
- args: [sinceISO, sinceISO, limit]
488
+ args
372
489
  });
373
490
  const hotEntities = [];
374
491
  for (const row of result.rows) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isExeSession
3
- } from "./chunk-AKLQSC6W.js";
3
+ } from "./chunk-KI7O64XV.js";
4
4
  import {
5
5
  loadConfigSync
6
6
  } from "./chunk-ZIG7VPJV.js";
@@ -35,7 +35,7 @@ function resolveEndpoint() {
35
35
  }
36
36
  async function loadGoTrueAuthHeader() {
37
37
  try {
38
- const { getAuthHeader } = await import("./gotrue-session-ODZ2ERJX.js");
38
+ const { getAuthHeader } = await import("./gotrue-session-U4H3UGHL.js");
39
39
  return await getAuthHeader();
40
40
  } catch {
41
41
  return null;
@@ -1,3 +1,7 @@
1
+ import {
2
+ isManagementRole
3
+ } from "./chunk-66CGXQUA.js";
4
+
1
5
  // src/lib/transcript-sidechain.ts
2
6
  import { readFileSync } from "fs";
3
7
  function isSidechainTranscript(transcriptPath) {
@@ -36,9 +40,17 @@ function resolveSidechainAgentIdentity(parent, transcriptPath, env = process.env
36
40
  agentRole: agentType
37
41
  };
38
42
  }
43
+ function resolvePreToolUseAgentIdentity(parent, payload, env = process.env) {
44
+ const directType = payload.agent_type?.trim();
45
+ if (directType) {
46
+ const safeRole = isManagementRole(directType) ? "subagent" : directType;
47
+ return { agentId: `subagent:${directType}`, agentRole: safeRole };
48
+ }
49
+ return resolveSidechainAgentIdentity(parent, payload.transcript_path, env);
50
+ }
39
51
 
40
52
  export {
41
53
  isSidechainTranscript,
42
54
  detectSubagentSidechain,
43
- resolveSidechainAgentIdentity
55
+ resolvePreToolUseAgentIdentity
44
56
  };
@@ -219,7 +219,7 @@ function clearSetupState() {
219
219
  }
220
220
  async function probeDaemonHealthAfterInstall() {
221
221
  try {
222
- const { waitForDaemonReady } = await import("./daemon-ready-P2BR2XP5.js");
222
+ const { waitForDaemonReady } = await import("./daemon-ready-BN6EZLTQ.js");
223
223
  return await waitForDaemonReady(4, 500);
224
224
  } catch {
225
225
  return false;
@@ -939,7 +939,7 @@ async function runSetupWizard(opts = {}) {
939
939
  try {
940
940
  const { loadDeviceId } = await import("./lib/license.js");
941
941
  const deviceId = loadDeviceId();
942
- const gotrueAuth = await import("./gotrue-session-ODZ2ERJX.js").then((m) => m.getAuthHeader()).catch(() => null);
942
+ const gotrueAuth = await import("./gotrue-session-U4H3UGHL.js").then((m) => m.getAuthHeader()).catch(() => null);
943
943
  const headers = {
944
944
  "Content-Type": "application/json",
945
945
  ...gotrueAuth ? { Authorization: gotrueAuth.authorization } : {}
@@ -0,0 +1,86 @@
1
+ import {
2
+ sendMessage
3
+ } from "./chunk-V5DDXXMP.js";
4
+ import {
5
+ getActiveAgent
6
+ } from "./chunk-5DF4Y6EC.js";
7
+ import {
8
+ resolveExeSession
9
+ } from "./chunk-KI7O64XV.js";
10
+ import {
11
+ getDispatcherSession
12
+ } from "./chunk-GPUOUUHA.js";
13
+ import {
14
+ getAgentContext
15
+ } from "./chunk-GJV3WDWM.js";
16
+ import {
17
+ getCoordinatorName,
18
+ isCoordinatorName
19
+ } from "./chunk-66CGXQUA.js";
20
+
21
+ // src/mcp/tools/send-message.ts
22
+ import { z } from "zod";
23
+ function resolveMessageTarget(targetAgent) {
24
+ const explicitTarget = targetAgent?.trim();
25
+ if (explicitTarget) return { targetAgent: explicitTarget };
26
+ if (isCoordinatorName(getActiveAgent().agentId)) return null;
27
+ const dispatcherSession = resolveExeSession() ?? (getAgentContext() === void 0 ? getDispatcherSession() : null);
28
+ if (!dispatcherSession) return null;
29
+ return {
30
+ targetAgent: getCoordinatorName(),
31
+ sessionScope: dispatcherSession
32
+ };
33
+ }
34
+ function registerSendMessage(server) {
35
+ server.registerTool(
36
+ "send_message",
37
+ {
38
+ title: "Send Message",
39
+ description: "Send a structured message to another agent. Messages are queued and delivered via intercom. NOTE: messages are fire-and-forget. Use default create_task for checklist tracking; only explicit execution_mode='durable_tmux' performs legacy employee dispatch.",
40
+ inputSchema: {
41
+ target_agent: z.string().optional().describe("Recipient agent name. Omit to reply to the coordinator session that dispatched this agent."),
42
+ content: z.string().describe("Message content"),
43
+ target_project: z.string().optional().describe("Project context (optional)"),
44
+ priority: z.enum(["normal", "urgent"]).default("normal").describe("Message priority (default: normal)"),
45
+ target_device: z.string().optional().describe("Target device ID for cross-machine delivery (default: local)")
46
+ }
47
+ },
48
+ async ({ target_agent, content, target_project, priority, target_device }) => {
49
+ const { agentId } = getActiveAgent();
50
+ const target = resolveMessageTarget(target_agent);
51
+ if (!target) {
52
+ return {
53
+ content: [{
54
+ type: "text",
55
+ text: "target_agent is required when no dispatcher session is available"
56
+ }],
57
+ isError: true
58
+ };
59
+ }
60
+ const msg = await sendMessage({
61
+ fromAgent: agentId,
62
+ targetAgent: target.targetAgent,
63
+ targetProject: target_project,
64
+ targetDevice: target_device,
65
+ sessionScope: target.sessionScope,
66
+ content,
67
+ priority
68
+ });
69
+ const statusText = msg.status === "delivered" ? "delivered" : msg.status === "failed" ? `failed: ${msg.failureReason}` : "queued (pending delivery)";
70
+ return {
71
+ content: [
72
+ {
73
+ type: "text",
74
+ text: `Message sent to ${target.targetAgent}: ${statusText}
75
+ ID: ${msg.id}`
76
+ }
77
+ ]
78
+ };
79
+ }
80
+ );
81
+ }
82
+
83
+ export {
84
+ resolveMessageTarget,
85
+ registerSendMessage
86
+ };
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  NO_DB_INTEGRITY_EVENTS
3
- } from "./chunk-UQGSBM3U.js";
3
+ } from "./chunk-RFPMXR6B.js";
4
4
  import {
5
5
  resolveAnthropicAuth
6
6
  } from "./chunk-VGMACSEV.js";
7
7
 
8
8
  // src/lib/retrieval-health.ts
9
+ import os from "os";
9
10
  async function getRetrievalHealth() {
10
11
  let embedDaemon = "unavailable";
11
12
  try {
12
- const { isDaemonAlive } = await import("./mcp-health-HNVSWKFA.js");
13
+ const { isDaemonAlive } = await import("./mcp-health-B5EKRCZG.js");
13
14
  const { alive } = isDaemonAlive();
14
15
  if (alive) {
15
16
  try {
@@ -39,6 +40,7 @@ async function getRetrievalHealth() {
39
40
  } catch {
40
41
  embedDaemon = "unavailable";
41
42
  }
43
+ const lowMemoryHost = os.totalmem() <= 16 * 1024 ** 3;
42
44
  let configuredSearchMode = "hybrid";
43
45
  let selfQueryRouterEnabled = true;
44
46
  try {
@@ -54,7 +56,7 @@ async function getRetrievalHealth() {
54
56
  } else if (embedDaemon === "running") {
55
57
  actualSearchMode = "hybrid (vector+fts+graph)";
56
58
  } else if (embedDaemon === "disabled") {
57
- actualSearchMode = "fts+graph (embeddings disabled by choice)";
59
+ actualSearchMode = lowMemoryHost ? "fts+graph (local embeddings unavailable: host RAM <= 16 GB)" : "fts+graph (embeddings disabled by choice)";
58
60
  } else {
59
61
  actualSearchMode = "fts+graph (degraded from hybrid)";
60
62
  }
@@ -80,7 +82,7 @@ async function getRetrievalHealth() {
80
82
  totalMemories = Number(totalRes.rows[0]?.cnt ?? 0);
81
83
  memoriesWithVectors = Number(vectorRes.rows[0]?.cnt ?? 0);
82
84
  try {
83
- const { getGraphStats } = await import("./graph-query-AP5R6ZHO.js");
85
+ const { getGraphStats } = await import("./graph-query-ZEDO4BDF.js");
84
86
  const stats = await getGraphStats(client);
85
87
  entities = stats.entities;
86
88
  relationships = stats.relationships;
@@ -98,7 +100,7 @@ async function getRetrievalHealth() {
98
100
  }
99
101
  let dbIntegrity = NO_INTEGRITY_EVENTS;
100
102
  try {
101
- const { getDbIntegrityHealth } = await import("./db-integrity-events-2DTFO37N.js");
103
+ const { getDbIntegrityHealth } = await import("./db-integrity-events-GYGANKZV.js");
102
104
  dbIntegrity = getDbIntegrityHealth();
103
105
  } catch {
104
106
  }
@@ -108,6 +110,7 @@ async function getRetrievalHealth() {
108
110
  configured: configuredSearchMode,
109
111
  actual: actualSearchMode
110
112
  },
113
+ lowMemoryHost,
111
114
  queryRouter,
112
115
  vectorBackfill: {
113
116
  totalMemories,
@@ -132,7 +135,16 @@ function computeDegradations(h) {
132
135
  const out = [];
133
136
  const isEmbeddingsDisabledByChoice = h.embedDaemon === "disabled" || h.searchMode.actual.includes("disabled by choice");
134
137
  const isRuntimeDowngrade = h.searchMode.actual.includes("degraded");
135
- if (isEmbeddingsDisabledByChoice) {
138
+ const noVectorRetrieval = h.embedDaemon === "disabled" || h.searchMode.configured === "fts";
139
+ const isRamForcedOff = (h.lowMemoryHost ?? false) && noVectorRetrieval && !isRuntimeDowngrade;
140
+ if (isRamForcedOff) {
141
+ out.push({
142
+ code: "fts_only_low_memory_default",
143
+ severity: "info",
144
+ message: h.searchMode.configured === "fts" ? "Retrieval is FTS+Graph-only; this machine's RAM is at or below the 16 GB threshold for local embeddings, so vector retrieval is unavailable here regardless of configuration." : `Retrieval is FTS+Graph-only despite searchMode="${h.searchMode.configured}" \u2014 this machine's RAM is at or below the 16 GB threshold, so the daemon never starts local embeddings.`,
145
+ remediation: 'No action needed: keyword + graph retrieval is fully functional. This host cannot run local embeddings regardless of searchMode because of its RAM ceiling \u2014 switching searchMode to "hybrid" will not enable vector retrieval here.'
146
+ });
147
+ } else if (isEmbeddingsDisabledByChoice) {
136
148
  out.push({
137
149
  code: "embeddings_disabled_by_choice",
138
150
  severity: "info",
@@ -196,6 +208,16 @@ function computeDegradations(h) {
196
208
  remediation: "Do NOT trust recent backups. Run `exe-os doctor` to confirm, and restore from the newest backup that carries a `backup-verified` ledger entry."
197
209
  });
198
210
  }
211
+ if (gi.lowDiskSkips > 0 && gi.lastLowDiskSkip) {
212
+ const provenForLowDisk = gi.lastProvenBackupOnDisk;
213
+ const covered = provenForLowDisk !== null && provenForLowDisk.at > gi.lastLowDiskSkip.at;
214
+ out.push({
215
+ code: "backup_skipped_low_disk",
216
+ severity: covered ? "warn" : "critical",
217
+ message: `Backup declined due to low disk space (${gi.lowDiskSkips} skip(s) on record, most recent ${gi.lastLowDiskSkip.at})` + (provenForLowDisk ? ` \u2014 last PROVEN backup still on disk: ${provenForLowDisk.backup ?? "unknown"} at ${provenForLowDisk.at}` + (covered ? " (newer than the most recent skip, so recovery is not gated on it)" : "") : " \u2014 NO backup that is still on disk has been proven readable"),
218
+ remediation: "Free disk space on the backup volume (or its filesystem) immediately \u2014 no new backups can be taken until resolved. Check `~/.exe-os/missed-backups.jsonl` for the full history of misses."
219
+ });
220
+ }
199
221
  const unresolved = gi.unresolvedUnverifiedBackups;
200
222
  const proven = gi.lastProvenBackupOnDisk;
201
223
  if (unresolved > 0) {
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  cleanupCardsForMemories,
3
3
  cleanupGraphLinksForMemories
4
- } from "./chunk-ULIBLJ6W.js";
4
+ } from "./chunk-YYC553FO.js";
5
5
  import {
6
6
  resolveAnthropicAuth
7
7
  } from "./chunk-VGMACSEV.js";
8
8
  import {
9
9
  buildSystemStateExclusionFilter,
10
10
  vectorToBlob
11
- } from "./chunk-MXPNVSXI.js";
11
+ } from "./chunk-CIEVY5TD.js";
12
12
  import {
13
13
  extractKeywords,
14
14
  keywordsToString
15
15
  } from "./chunk-CHCA3ZM2.js";
16
16
  import {
17
17
  isCoordinatorName
18
- } from "./chunk-TAMDAOCU.js";
18
+ } from "./chunk-66CGXQUA.js";
19
19
 
20
20
  // src/lib/consolidation.ts
21
21
  import { randomUUID } from "crypto";
@@ -344,7 +344,7 @@ async function runConsolidation(client, options) {
344
344
  let memoriesConsolidated = 0;
345
345
  let clustersFailed = 0;
346
346
  let attemptedSynthesis = 0;
347
- const { runBudgetedSweep } = await import("./sweep-budget-KMPJ7O5Z.js");
347
+ const { runBudgetedSweep } = await import("./sweep-budget-YGLCNXZZ.js");
348
348
  await runBudgetedSweep(clusters, async (cluster) => {
349
349
  if (clustersProcessed >= options.maxCalls) return false;
350
350
  if (cluster.memories.length < 3) return;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  completeReminder,
3
3
  formatAmbiguousReminder
4
- } from "./chunk-636LKCKE.js";
4
+ } from "./chunk-Q6ZLQMP2.js";
5
5
 
6
6
  // src/mcp/tools/complete-reminder.ts
7
7
  import { z } from "zod";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  buildSystemStateMemoryTypeExclusion
3
- } from "./chunk-MXPNVSXI.js";
3
+ } from "./chunk-CIEVY5TD.js";
4
4
  import {
5
5
  sessionScopeFilter
6
- } from "./chunk-AKLQSC6W.js";
6
+ } from "./chunk-KI7O64XV.js";
7
7
  import {
8
8
  getClient,
9
9
  getIdentity
10
- } from "./chunk-TAMDAOCU.js";
10
+ } from "./chunk-66CGXQUA.js";
11
11
  import {
12
12
  getEmotionalBaseline
13
- } from "./chunk-NJFJWQNN.js";
13
+ } from "./chunk-L5CGXEZC.js";
14
14
 
15
15
  // src/lib/dreaming.ts
16
16
  var DreamingEngine = class {
@@ -646,7 +646,7 @@ var DreamingEngine = class {
646
646
  }
647
647
  let overdueProspective = [];
648
648
  try {
649
- const { getOverdueProspective, completeProspective } = await import("./prospective-memory-KR3P4T6N.js");
649
+ const { getOverdueProspective, completeProspective } = await import("./prospective-memory-GEO6E3UL.js");
650
650
  const overdue = await getOverdueProspective(agentId);
651
651
  overdueProspective = overdue.map((o) => ({
652
652
  id: o.id,
@@ -0,0 +1,85 @@
1
+ // src/lib/daemon-drift.ts
2
+ import { existsSync, readFileSync } from "fs";
3
+ import { execFileSync } from "child_process";
4
+ import path from "path";
5
+ var DAEMON_DRIFT_FAIL_THRESHOLD = 10;
6
+ var DRIFT_GIT_TIMEOUT_MS = 3e3;
7
+ var defaultGitRunner = (args, cwd) => execFileSync("git", args, { cwd, encoding: "utf-8", timeout: DRIFT_GIT_TIMEOUT_MS }).trim();
8
+ function resolveRunningDaemonScript(pidFile) {
9
+ try {
10
+ const pid = parseInt(readFileSync(pidFile, "utf8").trim(), 10);
11
+ if (!Number.isFinite(pid) || pid <= 0) return null;
12
+ const cmdline = execFileSync("ps", ["-p", String(pid), "-o", "command="], {
13
+ encoding: "utf-8",
14
+ timeout: 2e3
15
+ });
16
+ const token = cmdline.trim().split(/\s+/).find((t) => t.endsWith("exe-daemon.js"));
17
+ return token ?? null;
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+ function checkoutRootFromScript(script) {
23
+ const suffix = path.join("dist", "lib", "exe-daemon.js");
24
+ if (script.endsWith(suffix)) {
25
+ return path.resolve(path.dirname(script), "..", "..");
26
+ }
27
+ let dir = path.dirname(path.resolve(script));
28
+ const { root } = path.parse(dir);
29
+ while (dir !== root) {
30
+ if (existsSync(path.join(dir, "package.json"))) return dir;
31
+ dir = path.dirname(dir);
32
+ }
33
+ return null;
34
+ }
35
+ function measureDaemonDrift(opts) {
36
+ const { daemonScript, referenceRoot } = opts;
37
+ const threshold = opts.threshold ?? DAEMON_DRIFT_FAIL_THRESHOLD;
38
+ const run = opts.run ?? defaultGitRunner;
39
+ if (!daemonScript) {
40
+ return { status: "unknown", reason: "no daemon script path resolved (daemon not running and no local dist fallback)" };
41
+ }
42
+ const daemonRoot = checkoutRootFromScript(daemonScript);
43
+ if (!daemonRoot) {
44
+ return { status: "unknown", reason: `cannot find checkout root above ${daemonScript}` };
45
+ }
46
+ let head;
47
+ try {
48
+ head = run(["rev-parse", "HEAD"], daemonRoot);
49
+ } catch (err) {
50
+ return {
51
+ status: "unknown",
52
+ reason: `cannot read daemon checkout HEAD at ${daemonRoot} (${err instanceof Error ? err.message.split("\n")[0] : String(err)})`
53
+ };
54
+ }
55
+ try {
56
+ const base = run(["rev-parse", "origin/main"], referenceRoot);
57
+ const behind = parseInt(run(["rev-list", "--count", `${head}..origin/main`], referenceRoot), 10);
58
+ const ahead = parseInt(run(["rev-list", "--count", `origin/main..${head}`], referenceRoot), 10);
59
+ if (Number.isFinite(behind) && Number.isFinite(ahead)) {
60
+ return { status: behind > threshold ? "stale" : "ok", behind, ahead, head, base, measuredVia: "reference-repo" };
61
+ }
62
+ } catch {
63
+ }
64
+ try {
65
+ const base = run(["rev-parse", "origin/main"], daemonRoot);
66
+ const behind = parseInt(run(["rev-list", "--count", `HEAD..origin/main`], daemonRoot), 10);
67
+ const ahead = parseInt(run(["rev-list", "--count", `origin/main..HEAD`], daemonRoot), 10);
68
+ if (Number.isFinite(behind) && Number.isFinite(ahead)) {
69
+ return { status: behind > threshold ? "stale" : "ok", behind, ahead, head, base, measuredVia: "daemon-repo" };
70
+ }
71
+ } catch {
72
+ }
73
+ return {
74
+ status: "unknown",
75
+ reason: `could not count ${head.slice(0, 8)}..origin/main in either ${referenceRoot} or the daemon checkout (not a git checkout, missing refs, or unrelated history)`
76
+ };
77
+ }
78
+
79
+ export {
80
+ DAEMON_DRIFT_FAIL_THRESHOLD,
81
+ DRIFT_GIT_TIMEOUT_MS,
82
+ defaultGitRunner,
83
+ resolveRunningDaemonScript,
84
+ measureDaemonDrift
85
+ };