@askexenow/exe-os 0.9.384 → 0.9.389

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 (481) hide show
  1. package/deploy/compose/.env.askexe-control-plane.example +6 -0
  2. package/deploy/compose/.env.customer.example +1 -1
  3. package/deploy/compose/.env.example +1 -1
  4. package/deploy/compose/docker-compose.yml +16 -0
  5. package/deploy/compose/generate-env.ts +1 -1
  6. package/deploy/compose/sso-edge/sso-redirect.conf +18 -3
  7. package/deploy/stack-manifests/v0.9.json +1160 -1
  8. package/dist/.dist-verified.json +3 -3
  9. package/dist/{active-agent-F5V4E4UL.js → active-agent-RZ24KSJN.js} +8 -6
  10. package/dist/{active-agent-YTBB4ZQM.js → active-agent-YWSWPIEA.js} +8 -6
  11. package/dist/{agent-defs-generator-7TFISIJQ.js → agent-defs-generator-GY3UBREJ.js} +8 -6
  12. package/dist/{agent-heartbeat-CQPGJIFF.js → agent-heartbeat-GUVUUQVM.js} +1 -1
  13. package/dist/{agent-loop-EZ7LDAGD.js → agent-loop-HPNCH3HK.js} +1 -1
  14. package/dist/{agentic-ontology-XVTUVV7W.js → agentic-ontology-RHYNXEKE.js} +1 -1
  15. package/dist/{artifact-backup-TF6YWQT2.js → artifact-backup-HGUFSIJH.js} +19 -6
  16. package/dist/{backfill-metadata-J6MXIDCW.js → backfill-metadata-XLFASEOD.js} +11 -9
  17. package/dist/{backup-verify-6DVBQMDP.js → backup-verify-TUQEICWA.js} +1 -1
  18. package/dist/{behavior-injection-XDA7ZCYN.js → behavior-injection-GXO7ERGN.js} +14 -12
  19. package/dist/{behavior-promotion-4VLQ7LXK.js → behavior-promotion-V63WIZ4N.js} +13 -11
  20. package/dist/{behaviors-SCCZP7RZ.js → behaviors-RMLDPLOF.js} +18 -11
  21. package/dist/bin/agentic-ontology-backfill.js +12 -10
  22. package/dist/bin/agentic-reflection-backfill.js +13 -11
  23. package/dist/bin/agentic-semantic-label.js +12 -10
  24. package/dist/bin/backfill-conversations.js +11 -9
  25. package/dist/bin/backfill-responses.js +11 -9
  26. package/dist/bin/backfill-vectors.js +13 -11
  27. package/dist/bin/bulk-sync-postgres.js +20 -18
  28. package/dist/bin/cc-doctor.js +15 -13
  29. package/dist/bin/cleanup-stale-review-tasks.js +44 -32
  30. package/dist/bin/cli.js +109 -30
  31. package/dist/bin/customer-readiness.js +55 -25
  32. package/dist/bin/deferred-daemon-restart.js +111 -108
  33. package/dist/bin/exe-actions.js +7 -1
  34. package/dist/bin/exe-agent-config.js +8 -6
  35. package/dist/bin/exe-agent.js +18 -16
  36. package/dist/bin/exe-assign.js +13 -11
  37. package/dist/bin/exe-boot.js +49 -47
  38. package/dist/bin/exe-call.js +9 -7
  39. package/dist/bin/exe-cicd.js +19 -8
  40. package/dist/bin/exe-cloud.js +59 -25
  41. package/dist/bin/exe-config-dump.js +8 -6
  42. package/dist/bin/exe-dispatch.js +23 -21
  43. package/dist/bin/exe-doctor.js +11 -8
  44. package/dist/bin/exe-export-behaviors.js +16 -14
  45. package/dist/bin/exe-forget.js +14 -12
  46. package/dist/bin/exe-gateway.js +12 -10
  47. package/dist/bin/exe-grant.js +6 -6
  48. package/dist/bin/exe-healthcheck.js +15 -13
  49. package/dist/bin/exe-heartbeat.js +28 -26
  50. package/dist/bin/exe-kill.js +28 -26
  51. package/dist/bin/exe-launch-agent.js +35 -33
  52. package/dist/bin/exe-mcp.js +9 -7
  53. package/dist/bin/exe-memory-reads.js +11 -9
  54. package/dist/bin/exe-new-employee.js +13 -11
  55. package/dist/bin/exe-os-mcp-proxy.js +9 -7
  56. package/dist/bin/exe-pending-messages.js +23 -21
  57. package/dist/bin/exe-pending-notifications.js +22 -20
  58. package/dist/bin/exe-pending-reviews.js +23 -21
  59. package/dist/bin/exe-preflight.js +1 -1
  60. package/dist/bin/exe-rename.js +9 -7
  61. package/dist/bin/exe-review.js +59 -55
  62. package/dist/bin/exe-search-quality.js +16 -3
  63. package/dist/bin/exe-search.js +13 -11
  64. package/dist/bin/exe-session-cleanup.js +29 -27
  65. package/dist/bin/exe-settings.js +22 -20
  66. package/dist/bin/exe-start-codex.js +23 -21
  67. package/dist/bin/exe-start-opencode.js +21 -19
  68. package/dist/bin/exe-status.js +24 -22
  69. package/dist/bin/exe-support.js +3 -3
  70. package/dist/bin/exe-team.js +8 -6
  71. package/dist/bin/exe-verify-running-images.js +644 -17
  72. package/dist/bin/git-sweep.js +24 -22
  73. package/dist/bin/graph-backfill.js +12 -10
  74. package/dist/bin/graph-export.js +12 -10
  75. package/dist/bin/hooks-cli.js +4 -4
  76. package/dist/bin/import-history.js +16 -14
  77. package/dist/bin/install.js +113 -110
  78. package/dist/bin/intercom-check.js +5 -5
  79. package/dist/bin/mcp-sessions.js +2 -2
  80. package/dist/bin/orchestration-metrics.js +8 -6
  81. package/dist/bin/postgres-agentic-reflection-backfill.js +2 -2
  82. package/dist/bin/postgres-agentic-semantic-backfill.js +1 -1
  83. package/dist/bin/pre-build-guard.js +55 -16
  84. package/dist/bin/pre-publish.js +1 -1
  85. package/dist/bin/prune-orphan-chunks.js +154 -28
  86. package/dist/bin/reconcile-backlog.js +5 -3
  87. package/dist/bin/registry-proxy.js +1 -1
  88. package/dist/bin/repair-document-chunks.js +11 -9
  89. package/dist/bin/scan-tasks.js +23 -21
  90. package/dist/bin/setup.js +3 -3
  91. package/dist/bin/shard-migrate.js +12 -10
  92. package/dist/bin/stack-update.js +622 -43
  93. package/dist/bin/verify-stack.js +2 -2
  94. package/dist/bin/vps-health-gate.js +1 -1
  95. package/dist/{boot-generation-Q7LGQ3AO.js → boot-generation-VCQXVYGT.js} +7 -5
  96. package/dist/{boot-review-sections-G5774FR5.js → boot-review-sections-3QO6Q7MP.js} +21 -19
  97. package/dist/{branch-hygiene-44WLSOZR.js → branch-hygiene-DDXXI6ZA.js} +59 -21
  98. package/dist/bug-landed-reconciler-TQVNOUCU.js +353 -0
  99. package/dist/build-manifest.json +1269 -1194
  100. package/dist/{capability-cards-I3RHCF4F.js → capability-cards-XPDLT6LU.js} +6 -4
  101. package/dist/{capacity-monitor-7I7GDONU.js → capacity-monitor-N3AW242L.js} +23 -21
  102. package/dist/{catchup-brief-3T5PARIR.js → catchup-brief-3PKX7FUP.js} +29 -27
  103. package/dist/{chunk-C5ISP5FO.js → chunk-2BKJAOO4.js} +11 -1
  104. package/dist/{chunk-JJTPPAZY.js → chunk-2CUQHG6H.js} +1609 -1356
  105. package/dist/{chunk-HU3VD4MQ.js → chunk-2Q2GGYBX.js} +1 -1
  106. package/dist/{chunk-CHIUS5QB.js → chunk-36LMIOVU.js} +9 -9
  107. package/dist/{chunk-46VSBDUW.js → chunk-3DCBDG4T.js} +2 -2
  108. package/dist/{chunk-W3KPQE7H.js → chunk-3GL3E4TD.js} +3 -3
  109. package/dist/{chunk-GL47M7NY.js → chunk-3UD3OF3X.js} +202 -117
  110. package/dist/{chunk-WNBZJSQT.js → chunk-3VW5ZP2F.js} +1 -1
  111. package/dist/{chunk-JDDM6C57.js → chunk-3X74IQBU.js} +1 -1
  112. package/dist/{chunk-NVFNADTX.js → chunk-3ZL4MDQ6.js} +18 -4
  113. package/dist/{chunk-R5E7WNAC.js → chunk-4ESNDGMB.js} +3 -3
  114. package/dist/{chunk-CYCIX7AW.js → chunk-4FLLIQRQ.js} +2 -2
  115. package/dist/{chunk-3RGTLZNO.js → chunk-4GAKF7KR.js} +99 -74
  116. package/dist/{chunk-RVO5O5SR.js → chunk-4S3A52AV.js} +38 -10
  117. package/dist/{chunk-7J2ZQ4XN.js → chunk-4VQ3QR6B.js} +29 -28
  118. package/dist/{chunk-MROSARM5.js → chunk-5BJBTFFQ.js} +7 -1
  119. package/dist/chunk-5LQZABW5.js +6 -0
  120. package/dist/chunk-5ONMHTNI.js +236 -0
  121. package/dist/{chunk-APL7HUE3.js → chunk-5QQJUO3F.js} +200 -31
  122. package/dist/{chunk-UOPCVFVR.js → chunk-5RK75SWH.js} +205 -278
  123. package/dist/{chunk-T5FEAQES.js → chunk-5TYJYGS5.js} +1 -1
  124. package/dist/{chunk-P3QQ52QK.js → chunk-5U6EOTZV.js} +3 -3
  125. package/dist/{chunk-ALRHGEAJ.js → chunk-637FL62O.js} +1 -1
  126. package/dist/{chunk-PUBA5B4M.js → chunk-6L4VIYLZ.js} +33 -19
  127. package/dist/{chunk-VF2KRROX.js → chunk-754P2UXM.js} +1 -1
  128. package/dist/{chunk-CM7N5MBY.js → chunk-7FZG7WP4.js} +5 -5
  129. package/dist/{chunk-NYLJQ2M2.js → chunk-7NEBFB3L.js} +4 -4
  130. package/dist/{chunk-E7C2WNR5.js → chunk-AEIOFFFX.js} +5 -5
  131. package/dist/{chunk-VOVFUKEB.js → chunk-AIB2EWO2.js} +5 -5
  132. package/dist/{chunk-EGOEB42T.js → chunk-AP2C4OGS.js} +3 -3
  133. package/dist/{chunk-MPZ2AVNS.js → chunk-ATNV3BVZ.js} +1 -1
  134. package/dist/{chunk-F4BBMIPG.js → chunk-B4XJQBQB.js} +2 -2
  135. package/dist/{chunk-BPVFZ6Q4.js → chunk-B5EGDNG6.js} +2 -2
  136. package/dist/{chunk-AGC2V7JS.js → chunk-B6CBN6EF.js} +1 -1
  137. package/dist/{chunk-KTKIFXIP.js → chunk-B7FDRN7G.js} +1 -1
  138. package/dist/{chunk-C5HUMAA7.js → chunk-B7WVYLAQ.js} +67 -15
  139. package/dist/chunk-BGVP5RMT.js +185 -0
  140. package/dist/{chunk-FVLNNNH6.js → chunk-BNI4LIU5.js} +35 -4
  141. package/dist/{chunk-P4XLIPB7.js → chunk-BU5JRLZT.js} +1 -1
  142. package/dist/{chunk-PHUHIVD5.js → chunk-C6U7XWOC.js} +34 -5
  143. package/dist/chunk-C7GHNJPW.js +8 -0
  144. package/dist/{chunk-4AR5XKCH.js → chunk-CL2MU3OX.js} +1 -1
  145. package/dist/{chunk-ZPP63JSQ.js → chunk-CL3AB7Z2.js} +1 -1
  146. package/dist/{chunk-FHIFTSPL.js → chunk-CP7XUSOF.js} +8 -3
  147. package/dist/{chunk-3OX34OC3.js → chunk-CUDNRHHT.js} +30 -10
  148. package/dist/chunk-CYUUNIEL.js +21 -0
  149. package/dist/{chunk-P2UY34XE.js → chunk-D4C57S2H.js} +5 -5
  150. package/dist/{chunk-XSUALA32.js → chunk-DDYFNBYV.js} +3 -3
  151. package/dist/{chunk-LSNBTGW4.js → chunk-DPYZW42H.js} +1 -1
  152. package/dist/{chunk-FMIYFHLE.js → chunk-E2PRXEZK.js} +9 -3
  153. package/dist/{chunk-L63V25HS.js → chunk-E54SPUYJ.js} +3 -3
  154. package/dist/{chunk-DMUOTCDN.js → chunk-E5CKRHIZ.js} +1 -1
  155. package/dist/{chunk-BV2IET6B.js → chunk-EVMOKRBC.js} +15 -2
  156. package/dist/{chunk-YLFCH3VA.js → chunk-FDWI3T6I.js} +133 -31
  157. package/dist/{chunk-PWC3C5ME.js → chunk-FNJTCJGY.js} +4 -4
  158. package/dist/{chunk-TNS63ATU.js → chunk-FWRPDSO3.js} +350 -50
  159. package/dist/{chunk-JA3Y5TV6.js → chunk-GDLB6BPM.js} +141 -74
  160. package/dist/{chunk-IGJMS7C5.js → chunk-GOVGG7HU.js} +2 -2
  161. package/dist/{chunk-MB47DRF5.js → chunk-GP7CTIUK.js} +2 -2
  162. package/dist/{chunk-L5EPGGDP.js → chunk-GWAN2BDB.js} +4 -4
  163. package/dist/{chunk-YRQ26MNP.js → chunk-H3YF7X4J.js} +12 -5
  164. package/dist/{chunk-VLBHZ6TF.js → chunk-H6PLIFUE.js} +2 -2
  165. package/dist/{chunk-GSLFH4AI.js → chunk-HRNM3N4Y.js} +6 -15
  166. package/dist/chunk-IG2ISRTF.js +48 -0
  167. package/dist/{chunk-MWEIBVBS.js → chunk-IJCWBYA5.js} +14 -1
  168. package/dist/{chunk-NKEFYE4R.js → chunk-IPTUKX3N.js} +1 -1
  169. package/dist/{chunk-RB3J2WYQ.js → chunk-IVE7H6KA.js} +1 -1
  170. package/dist/{chunk-HA63SH5W.js → chunk-IWY2OGQG.js} +1 -1
  171. package/dist/{chunk-BQEZPRUC.js → chunk-IZWMWJZT.js} +64 -46
  172. package/dist/{chunk-AHESD3KW.js → chunk-J4UVI652.js} +1 -1
  173. package/dist/{chunk-PLII76NJ.js → chunk-JBUCA4OX.js} +33 -6
  174. package/dist/{chunk-2PZTMSMG.js → chunk-JOF4HQDF.js} +5 -5
  175. package/dist/{chunk-OBBO6EJR.js → chunk-JQN3QGSF.js} +1 -1
  176. package/dist/{chunk-P4PIZOL2.js → chunk-JWYIH5DR.js} +3 -3
  177. package/dist/{chunk-3XY57PKT.js → chunk-KZLKE7I3.js} +210 -48
  178. package/dist/{chunk-DYVLEMKS.js → chunk-L3GXMYBK.js} +1 -1
  179. package/dist/{chunk-72V3S44T.js → chunk-LUA4SLJY.js} +46 -19
  180. package/dist/{chunk-ZT4LFTUJ.js → chunk-LW3JCBXP.js} +20 -3
  181. package/dist/{chunk-YLB365YX.js → chunk-M5XHN4OM.js} +3 -3
  182. package/dist/{chunk-VHHX4UCP.js → chunk-MDTWARSF.js} +22 -93
  183. package/dist/{chunk-JFJP6ATJ.js → chunk-MWKXQSF6.js} +3 -2
  184. package/dist/{chunk-VJEJ7JNB.js → chunk-N32DVIKY.js} +1 -1
  185. package/dist/{chunk-MUCNYSJP.js → chunk-NRLJOV7M.js} +32 -4
  186. package/dist/{chunk-PL4CFSQ7.js → chunk-NSXJOSH7.js} +1 -1
  187. package/dist/{chunk-NF5FOSLD.js → chunk-NVTG66CK.js} +1 -1
  188. package/dist/chunk-O45GBJEH.js +1500 -0
  189. package/dist/{chunk-4AAMFWJT.js → chunk-OHZSTZXN.js} +4 -2
  190. package/dist/chunk-OSIS7ZQW.js +344 -0
  191. package/dist/{chunk-E3ZM32LF.js → chunk-P22VFGFK.js} +14 -5
  192. package/dist/{chunk-KILR4FBR.js → chunk-PAFLR7WD.js} +3 -3
  193. package/dist/{chunk-R3CZWFFC.js → chunk-PEYQ6MWO.js} +15 -3
  194. package/dist/{chunk-RDWIKDMY.js → chunk-PZR54BEI.js} +8 -20
  195. package/dist/{chunk-2FKU4ZEO.js → chunk-QDBKMEYY.js} +9 -9
  196. package/dist/{chunk-7UHZBVP3.js → chunk-QDVLVLXP.js} +97 -31
  197. package/dist/{chunk-PRDDPQLC.js → chunk-QLXEQRHD.js} +5 -5
  198. package/dist/{chunk-MUAWCFW6.js → chunk-QNPDXV5V.js} +5 -2
  199. package/dist/{chunk-LR5O2XWZ.js → chunk-QUZYLDNJ.js} +5 -5
  200. package/dist/chunk-RBQUXHYK.js +48 -0
  201. package/dist/{chunk-3SUPEE6H.js → chunk-RDMBSHGG.js} +3 -3
  202. package/dist/{chunk-I5XIW2BP.js → chunk-RGUM474V.js} +7 -7
  203. package/dist/{chunk-OAFENIHN.js → chunk-RJ67XAJU.js} +76 -28
  204. package/dist/{chunk-LFUBEHFW.js → chunk-RT57D7C4.js} +39 -1
  205. package/dist/{chunk-MKM6D7JM.js → chunk-RWG7DLOG.js} +42 -5
  206. package/dist/{chunk-P3UX5EH4.js → chunk-RWKAHHIX.js} +3 -3
  207. package/dist/{chunk-XEBKIWI7.js → chunk-RYNT3HB7.js} +12 -12
  208. package/dist/{chunk-EUGEFBGV.js → chunk-S2V272KJ.js} +3 -3
  209. package/dist/{chunk-W6BZ4UGA.js → chunk-SGYEM2PD.js} +1 -1
  210. package/dist/{chunk-VROK4X2L.js → chunk-SJP57MQM.js} +1 -1
  211. package/dist/{chunk-5MVKTNZP.js → chunk-SL4JWAMQ.js} +54 -4
  212. package/dist/{chunk-MOANZQXF.js → chunk-SLMKLEU6.js} +1 -1
  213. package/dist/{chunk-RZN2LEAK.js → chunk-SQA7XCYI.js} +3 -3
  214. package/dist/{chunk-4YNA3CM6.js → chunk-SSFS4NCH.js} +262 -56
  215. package/dist/{chunk-6FIC57PH.js → chunk-T4P2G3PO.js} +1 -1
  216. package/dist/{chunk-5U2IJBFV.js → chunk-TA3B4N24.js} +1 -1
  217. package/dist/{chunk-ZOTTYCP5.js → chunk-TEWWBVQP.js} +40 -4
  218. package/dist/{chunk-SDYWZRPN.js → chunk-TLSFGXXE.js} +1 -1
  219. package/dist/{chunk-L3VUW5M4.js → chunk-TQS2YHLB.js} +1 -1
  220. package/dist/{chunk-KXYKSLW4.js → chunk-TU4M757W.js} +399 -116
  221. package/dist/{chunk-MC4IM2CC.js → chunk-TYD4F4XU.js} +6 -6
  222. package/dist/{chunk-TKS5GMYA.js → chunk-U44Y7RC7.js} +2 -0
  223. package/dist/{chunk-B7AMNZTC.js → chunk-UKBPEEEQ.js} +2 -2
  224. package/dist/{chunk-ZBPZDADW.js → chunk-UWVXQEQQ.js} +467 -78
  225. package/dist/{chunk-P2VVMGMI.js → chunk-V4WH3FV7.js} +35 -16
  226. package/dist/{worktree-ownership-guard-O6JQF2CL.js → chunk-V6F4I2XY.js} +13 -14
  227. package/dist/{chunk-JFTUAV4J.js → chunk-VBKUESIW.js} +1 -1
  228. package/dist/{chunk-AZSTIAVL.js → chunk-VBPYYJPC.js} +1 -1
  229. package/dist/{chunk-LKTN22L6.js → chunk-VIP4LKLO.js} +57 -24
  230. package/dist/{chunk-L5CGXEZC.js → chunk-WAAGVFFN.js} +63 -71
  231. package/dist/{chunk-D3LXVAIQ.js → chunk-WC7AE3PT.js} +244 -103
  232. package/dist/{chunk-EOTZSAQL.js → chunk-WUCUDHKR.js} +1 -1
  233. package/dist/{chunk-VF3BZOZK.js → chunk-X7HZHKY4.js} +50 -3
  234. package/dist/{chunk-LFBLQE2P.js → chunk-XCAKYVKI.js} +1 -1
  235. package/dist/{chunk-UXN4BICC.js → chunk-XMX5J52Z.js} +1 -1
  236. package/dist/{chunk-6YDY6ZTD.js → chunk-XTCXGWTV.js} +9 -4
  237. package/dist/{chunk-XUZK23V7.js → chunk-XW2FW6LS.js} +2 -2
  238. package/dist/{chunk-CH7BUBP3.js → chunk-XWVHUDEK.js} +5 -4
  239. package/dist/{chunk-S26CV7BE.js → chunk-YA5LK6KB.js} +45 -8
  240. package/dist/{chunk-ELCRJGCH.js → chunk-YMRQIENV.js} +2 -2
  241. package/dist/{chunk-QNZ4562V.js → chunk-Z3LXWCB7.js} +1 -1
  242. package/dist/{chunk-EYMFVITZ.js → chunk-Z7I6NQMA.js} +2 -2
  243. package/dist/{chunk-6BJCDWSM.js → chunk-ZB4FS2EG.js} +1 -1
  244. package/dist/{chunk-ZAEUEDTN.js → chunk-ZD6FZ3WL.js} +1 -1
  245. package/dist/{chunk-FEU6QEEL.js → chunk-ZM6EZAVY.js} +1 -0
  246. package/dist/{chunk-2KY7WZZF.js → chunk-ZPA4R2UI.js} +1 -1
  247. package/dist/chunk-ZPPPHVSU.js +285 -0
  248. package/dist/{chunk-ELEGH4DX.js → chunk-ZUGQPYUY.js} +51 -4
  249. package/dist/{chunk-UX2EO653.js → chunk-ZZWFZ46U.js} +66 -8
  250. package/dist/{cleanup-graph-garbage-VQAJ2RBT.js → cleanup-graph-garbage-HFUD5ZQT.js} +12 -10
  251. package/dist/{cloud-sync-command-J7NEFUY7.js → cloud-sync-command-3JHJJKPN.js} +25 -3
  252. package/dist/{cloud-sync-db-init-KWEMNMGA.js → cloud-sync-db-init-2LHIQOSF.js} +1 -1
  253. package/dist/{cloud-sync-shutdown-P63AUTUI.js → cloud-sync-shutdown-ZXAXA3Z7.js} +6 -4
  254. package/dist/{cloud-sync-state-QF3TMMJ4.js → cloud-sync-state-VSQFGPP6.js} +1 -1
  255. package/dist/{co-activation-7IHRPBZN.js → co-activation-NX4EH4AP.js} +6 -4
  256. package/dist/{co-occurrence-R5AG4OAU.js → co-occurrence-5LBYCW3U.js} +10 -8
  257. package/dist/{consent-passphrase-5ZBDJ5G7.js → consent-passphrase-65W3DJIJ.js} +2 -2
  258. package/dist/{content-extractor-ZLXC6GNR.js → content-extractor-OGXETBOX.js} +2 -2
  259. package/dist/{conversation-entity-extractor-7FRKLLBD.js → conversation-entity-extractor-FQCOAH4F.js} +5 -4
  260. package/dist/conversations-retention-XTBFJBUM.js +166 -0
  261. package/dist/{crdt-sync-IFRZOEIS.js → crdt-sync-7TDUBTLH.js} +4 -4
  262. package/dist/{crm-webhook-L2S63ASV.js → crm-webhook-776JTY55.js} +2 -2
  263. package/dist/{cto-delegation-gate-3WU7OHX7.js → cto-delegation-gate-ZNUWVYCN.js} +25 -23
  264. package/dist/{daemon-orchestration-3VQYKLOR.js → daemon-orchestration-76BOFDEP.js} +30 -24
  265. package/dist/{doc-graph-extractor-YIR5E7OF.js → doc-graph-extractor-F724KZJX.js} +10 -8
  266. package/dist/{documents-QEHPTYIY.js → documents-Q24V4GRD.js} +13 -11
  267. package/dist/{dreaming-LNFE7DTN.js → dreaming-IY6NQTSP.js} +27 -25
  268. package/dist/{employee-boot-brief-ZTXDYNWM.js → employee-boot-brief-CCTXO5DQ.js} +35 -29
  269. package/dist/{entity-boost-R5N6JWXD.js → entity-boost-XGOB7HDM.js} +1 -1
  270. package/dist/{exe-drift-WYSJVZFO.js → exe-drift-NEPXLNGP.js} +7 -5
  271. package/dist/{exe-export-GOLNAEAV.js → exe-export-ZHJQFKR2.js} +14 -12
  272. package/dist/{exe-import-U4BSI6OH.js → exe-import-7SVNI4FW.js} +14 -12
  273. package/dist/{exe-key-V42G3NGO.js → exe-key-QJKU56WZ.js} +119 -108
  274. package/dist/{exe-org-U4GLQ6OP.js → exe-org-SJXHLV6K.js} +76 -51
  275. package/dist/{exe-snapshot-U7ONBYNY.js → exe-snapshot-EFWPXTXE.js} +45 -36
  276. package/dist/{fast-db-init-W3NGKAEU.js → fast-db-init-BQZOQNT3.js} +1 -1
  277. package/dist/{founder-context-ZSIBRVDM.js → founder-context-KG2ZAOXY.js} +2 -2
  278. package/dist/{founder-monitor-envelope-L3IWZLFY.js → founder-monitor-envelope-NYB5LLU4.js} +4 -4
  279. package/dist/gateway/index.js +20 -18
  280. package/dist/{gateway-client-DJFCVIPT.js → gateway-client-ODMUXUL3.js} +1 -1
  281. package/dist/{git-staleness-OF24QXFZ.js → git-staleness-OPGEAJA7.js} +6 -4
  282. package/dist/{global-procedures-WSIOWO43.js → global-procedures-3KXY4LL6.js} +8 -6
  283. package/dist/{graph-auto-extract-IEVVN3L3.js → graph-auto-extract-I7H2F5NJ.js} +10 -8
  284. package/dist/{graph-query-JDZWAVCU.js → graph-query-E7JBSNY5.js} +1 -1
  285. package/dist/{graph-rag-BKAD2XQA.js → graph-rag-H24CMFP2.js} +5 -4
  286. package/dist/{hook-integrity-TPWDGX2M.js → hook-integrity-PGQ3OX4S.js} +1 -1
  287. package/dist/{hook-prefetch-FD6VGJJA.js → hook-prefetch-7AZJER6Z.js} +23 -21
  288. package/dist/hook-registration-liveness-NGQRFKAA.js +11 -0
  289. package/dist/hooks/bug-report-worker.js +26 -24
  290. package/dist/hooks/codex-stop-task-finalizer.js +28 -26
  291. package/dist/hooks/commit-complete.js +26 -24
  292. package/dist/hooks/error-recall.js +16 -14
  293. package/dist/hooks/exe-heartbeat-hook.js +9 -7
  294. package/dist/hooks/ingest-worker.js +12 -10
  295. package/dist/hooks/ingest.js +22 -17
  296. package/dist/hooks/instructions-loaded.js +11 -9
  297. package/dist/hooks/manifest.json +20 -20
  298. package/dist/hooks/notification.js +10 -8
  299. package/dist/hooks/post-compact.js +9 -7
  300. package/dist/hooks/post-tool-combined.js +14 -14
  301. package/dist/hooks/pre-compact.js +26 -24
  302. package/dist/hooks/pre-tool-use.js +2 -2
  303. package/dist/hooks/prompt-submit.js +47 -41
  304. package/dist/hooks/session-end.js +38 -42
  305. package/dist/hooks/session-start.js +26 -18
  306. package/dist/hooks/stop.js +29 -27
  307. package/dist/hooks/subagent-stop.js +29 -27
  308. package/dist/hooks/summary-worker.js +32 -30
  309. package/dist/index.js +37 -35
  310. package/dist/{installer-OTI5SA43.js → installer-2ZS3LHCU.js} +12 -9
  311. package/dist/{installer-NMOBSEZ2.js → installer-NH3A3HWC.js} +14 -9
  312. package/dist/{installer-SRJGE4GU.js → installer-UJ73PGRD.js} +21 -9
  313. package/dist/{intercom-queue-4FFXCBHO.js → intercom-queue-OE25GJF2.js} +21 -19
  314. package/dist/lib/agent-config.js +2 -2
  315. package/dist/lib/cloud-sync.js +24 -18
  316. package/dist/lib/consolidation.js +13 -11
  317. package/dist/lib/crypto.js +3 -3
  318. package/dist/lib/database.js +6 -4
  319. package/dist/lib/db-backup.js +1 -1
  320. package/dist/lib/db-write-worker-client.js +3 -1
  321. package/dist/lib/db-write-worker.js +65 -89
  322. package/dist/lib/db.js +6 -4
  323. package/dist/lib/delivery-truth.js +5 -1
  324. package/dist/lib/device-registry.js +1 -1
  325. package/dist/lib/embedder.js +2 -2
  326. package/dist/lib/employee-templates.js +9 -7
  327. package/dist/lib/employees.js +6 -4
  328. package/dist/lib/exe-daemon.js +425 -314
  329. package/dist/lib/file-grep.js +15 -21
  330. package/dist/lib/hybrid-search.js +19 -13
  331. package/dist/lib/identity-templates.js +1 -1
  332. package/dist/lib/identity.js +6 -4
  333. package/dist/lib/keychain.js +1 -1
  334. package/dist/lib/license.js +22 -6
  335. package/dist/lib/messaging.js +22 -20
  336. package/dist/lib/post-tool-memory.js +10 -8
  337. package/dist/lib/registry-proxy.js +1 -1
  338. package/dist/lib/reminders.js +7 -5
  339. package/dist/lib/runtime-table.js +1 -1
  340. package/dist/lib/schedules.js +12 -10
  341. package/dist/lib/session-registry.js +8 -6
  342. package/dist/lib/skill-learning.js +13 -11
  343. package/dist/lib/status-brief.js +2 -2
  344. package/dist/lib/store.js +17 -9
  345. package/dist/lib/task-router.js +7 -5
  346. package/dist/lib/tasks.js +23 -21
  347. package/dist/lib/tmux-routing.js +21 -19
  348. package/dist/lib/tmux-status.js +4 -1
  349. package/dist/lib/token-spend.js +7 -5
  350. package/dist/lib/ws-client.js +1 -1
  351. package/dist/{license-gate-R4JWTWM4.js → license-gate-XQ2KN5I5.js} +3 -3
  352. package/dist/{license-recheck-3MBJ4IJX.js → license-recheck-IIBKR2V5.js} +1 -1
  353. package/dist/{license-sync-BVSG3WMW.js → license-sync-76JVI2M5.js} +151 -8
  354. package/dist/{local-secret-inventory-JWNBHZZ4.js → local-secret-inventory-MJT7NJLY.js} +2 -2
  355. package/dist/{mailbox-inbox-MTAT4MXX.js → mailbox-inbox-BPZP4GIZ.js} +1 -1
  356. package/dist/maintenance-worker-54VZTFIK.js +371 -0
  357. package/dist/mcp/register-tools.js +110 -107
  358. package/dist/mcp/server.js +113 -110
  359. package/dist/mcp/tools/complete-reminder.js +8 -6
  360. package/dist/mcp/tools/create-reminder.js +8 -6
  361. package/dist/mcp/tools/create-task.js +26 -24
  362. package/dist/mcp/tools/deactivate-behavior.js +15 -13
  363. package/dist/mcp/tools/list-reminders.js +8 -6
  364. package/dist/mcp/tools/list-tasks.js +26 -24
  365. package/dist/mcp/tools/send-message.js +25 -23
  366. package/dist/mcp/tools/update-task.js +24 -22
  367. package/dist/{mcp-child-registry-TIZERM7O.js → mcp-child-registry-5VUG5ATZ.js} +1 -1
  368. package/dist/{mcp-http-config-VUMSFWFH.js → mcp-http-config-SKXESWHA.js} +9 -7
  369. package/dist/{mcp-session-identity-DZHWEJRV.js → mcp-session-identity-HYMLJXXA.js} +21 -19
  370. package/dist/{memory-cards-JVXTMSAT.js → memory-cards-PAZDUQ3B.js} +16 -32
  371. package/dist/{memory-graph-extractor-PPBJMYFJ.js → memory-graph-extractor-BC6QKBY6.js} +11 -9
  372. package/dist/{memory-poisoning-defense-K5Q74XQ4.js → memory-poisoning-defense-BRGIHF6J.js} +9 -7
  373. package/dist/{memory-pressure-watchdog-YMJH5CSA.js → memory-pressure-watchdog-HR6TPOMT.js} +22 -20
  374. package/dist/{memory-reflection-7BZWIHRE.js → memory-reflection-LO7VFBL3.js} +38 -59
  375. package/dist/memory-write-repository-J25USX63.js +16 -0
  376. package/dist/{monitor-grants-Q7X3MYQP.js → monitor-grants-YQTO6NWR.js} +3 -3
  377. package/dist/{monitor-identity-ZQB4IXEE.js → monitor-identity-POVTG76Y.js} +2 -2
  378. package/dist/{notification-ledger-XRAXL5OI.js → notification-ledger-KLD6GZTG.js} +22 -20
  379. package/dist/{notifications-JE3PX55X.js → notifications-3R6HNHDR.js} +21 -19
  380. package/dist/{orchestration-events-JCQ5F5IJ.js → orchestration-events-CHY3GOJD.js} +7 -5
  381. package/dist/{orchestrator-X65INDTR.js → orchestrator-GAL3HOAD.js} +23 -21
  382. package/dist/{org-brief-session-3PQ22UIX.js → org-brief-session-LQ2DBYVF.js} +17 -15
  383. package/dist/{org-consent-policy-VGELJ7K7.js → org-consent-policy-KFUP7QPG.js} +5 -5
  384. package/dist/{org-join-6TO5ZYUZ.js → org-join-MXZCIQWX.js} +8 -8
  385. package/dist/{org-key-admin-XHYVRRAZ.js → org-key-admin-4UK6QUT7.js} +9 -9
  386. package/dist/{org-key-pin-TTTYGTQL.js → org-key-pin-ZOX4OM3O.js} +3 -3
  387. package/dist/{org-membership-Y7T2BS57.js → org-membership-D5TPN45F.js} +4 -4
  388. package/dist/{org-partner-config-OP4NEUNF.js → org-partner-config-3FXSYPQA.js} +7 -7
  389. package/dist/{org-partner-runtime-YNVUNT2R.js → org-partner-runtime-TH3LMPII.js} +20 -16
  390. package/dist/{org-row-visibility-JBBXNYXD.js → org-row-visibility-Y5R33C5U.js} +1 -1
  391. package/dist/{pipeline-router-EIBB7QNG.js → pipeline-router-E2JZLDK6.js} +7 -5
  392. package/dist/{plan-limits-MEWXYLEN.js → plan-limits-NYI6R4IK.js} +9 -7
  393. package/dist/{platform-procedures-Z7ZGBJWN.js → platform-procedures-RTD5E3BD.js} +5 -3
  394. package/dist/{pre-tool-use-impl-C6KJY22W.js → pre-tool-use-impl-LT4FRXBP.js} +127 -83
  395. package/dist/{project-boot-VEYFCCSL.js → project-boot-LIMXQKAF.js} +25 -17
  396. package/dist/{project-name-UYORSNGE.js → project-name-V62GWALX.js} +7 -5
  397. package/dist/{projection-worker-WYFDWS57.js → projection-worker-KLE3IZQ2.js} +5 -2
  398. package/dist/{prospective-memory-E6XBQFJA.js → prospective-memory-HRN7JFT2.js} +6 -4
  399. package/dist/{push-notifications-M7YU63FY.js → push-notifications-XC6EQEXF.js} +22 -20
  400. package/dist/{reproject-worktree-memories-B5XMGJSD.js → reproject-worktree-memories-4CAVZSFE.js} +21 -19
  401. package/dist/{reranker-SRA4BR7N.js → reranker-2RU6IIX2.js} +1 -1
  402. package/dist/{retrieval-health-P2JPZUPV.js → retrieval-health-4Q5TOV2S.js} +1 -1
  403. package/dist/{review-polling-KQPN7IQE.js → review-polling-WOWIMBCL.js} +22 -20
  404. package/dist/runtime/index.js +30 -28
  405. package/dist/{session-events-6LDDKKY3.js → session-events-OPMS2C5F.js} +22 -20
  406. package/dist/{session-kill-telemetry-5DSRGWCL.js → session-kill-telemetry-3GWATSIX.js} +22 -20
  407. package/dist/{session-scope-XG5R3P3D.js → session-scope-TIRGR4MH.js} +21 -19
  408. package/dist/{setup-wizard-7QFLZIKT.js → setup-wizard-B2JBVGNH.js} +3 -3
  409. package/dist/{shard-manager-HHHHV2KZ.js → shard-manager-C7LYX6E4.js} +5 -1
  410. package/dist/{skill-refinement-I5RMAHSC.js → skill-refinement-FWQFYNBI.js} +7 -5
  411. package/dist/skill-retrieval-PPLFC5RY.js +166 -0
  412. package/dist/skill-usage-NDB67PU2.js +25 -0
  413. package/dist/{stack-generate-manifest-AKMZ3AUX.js → stack-generate-manifest-AXI55MEQ.js} +6 -6
  414. package/dist/{stack-promote-34CE2HHF.js → stack-promote-6N23OGZY.js} +6 -6
  415. package/dist/stack-release-2CXFYVWM.js +2770 -0
  416. package/dist/{stack-update-ZQQ5YYPJ.js → stack-update-U53FBVCQ.js} +13 -5
  417. package/dist/{steward-gate-AQJ6KT2C.js → steward-gate-TUA3QCN7.js} +7 -5
  418. package/dist/{subagent-brief-injection-3GU7YAWY.js → subagent-brief-injection-N52RWYFZ.js} +34 -32
  419. package/dist/{subagent-spawn-ledger-52I66CLW.js → subagent-spawn-ledger-OI23OT4I.js} +1 -1
  420. package/dist/support-bug-actions-XWCJI6S5.js +30 -0
  421. package/dist/support-inbox-MMVTCXRX.js +77 -0
  422. package/dist/{support-outbox-KNI3FR3G.js → support-outbox-2TG2UV6J.js} +2 -2
  423. package/dist/{task-enforcement-CAA6D2MH.js → task-enforcement-JDMBAAOY.js} +22 -20
  424. package/dist/{task-request-inbox-QBZVU66E.js → task-request-inbox-PKJCYKJV.js} +9 -5
  425. package/dist/{task-scope-NHXB4ZRN.js → task-scope-32HQEV6W.js} +27 -19
  426. package/dist/{tasks-crud-JHSWL5NM.js → tasks-crud-CYKUKS3F.js} +21 -19
  427. package/dist/{tasks-notify-7PBE4U7T.js → tasks-notify-YND5MKWJ.js} +22 -20
  428. package/dist/{tasks-review-PPPVEE62.js → tasks-review-CG2A5GM3.js} +23 -19
  429. package/dist/{telemetry-upload-YU2VRNHX.js → telemetry-upload-WLUMEFAB.js} +11 -9
  430. package/dist/{token-budget-QCMWKG3K.js → token-budget-3YHAY5LL.js} +7 -5
  431. package/dist/{tool-capability-index-7AWQAJRP.js → tool-capability-index-2ADOWH43.js} +2 -2
  432. package/dist/{tool-gates-5Q3RSQEG.js → tool-gates-7ENOOYMR.js} +5 -3
  433. package/dist/{tool-gates-QD26D2NE.js → tool-gates-EKJTLVGN.js} +1 -1
  434. package/dist/{tool-telemetry-LTOIC64I.js → tool-telemetry-VUP7S6HC.js} +1 -1
  435. package/dist/tui/App.js +59 -35
  436. package/dist/{tui-data-NDBXD6U7.js → tui-data-BOQTOW2G.js} +25 -23
  437. package/dist/{update-support-BMJM4NG7.js → update-support-WT3S3AQ4.js} +21 -21
  438. package/dist/{whatsapp-QQLDAHUX.js → whatsapp-OZGIF2EM.js} +2 -2
  439. package/dist/{wiki-acl-W6WDCVCP.js → wiki-acl-LTEQJVDA.js} +1 -1
  440. package/dist/{work-claims-6DM32MGO.js → work-claims-CMV2GWIW.js} +8 -6
  441. package/dist/{work-state-heartbeat-HG7D4AWJ.js → work-state-heartbeat-S45TXK4M.js} +1 -1
  442. package/dist/{worker-gate-FTMW7GBB.js → worker-gate-7Z6NMM3G.js} +1 -1
  443. package/dist/{workflow-engine-ZWC6CCXE.js → workflow-engine-ZSQDXZQ7.js} +2 -2
  444. package/dist/{worktree-EMQCPGFE.js → worktree-NMWDVT6N.js} +8 -6
  445. package/dist/worktree-ownership-guard-ZVIWJAOP.js +35 -0
  446. package/dist/{worktree-sweep-XVUJZBXV.js → worktree-sweep-Q62ZIT3U.js} +9 -7
  447. package/package.json +14 -8
  448. package/release-notes.json +7 -41
  449. package/src/commands/exe/afk.md +6 -0
  450. package/src/commands/exe/call.md +6 -0
  451. package/src/commands/exe/employee-heartbeat.md +6 -0
  452. package/src/commands/exe/intercom.md +6 -0
  453. package/src/commands/exe/kill.md +6 -0
  454. package/src/commands/exe/launch.md +6 -0
  455. package/src/commands/exe/logs.md +1 -1
  456. package/src/commands/exe/sessions.md +6 -0
  457. package/src/commands/exe/setup.md +7 -3
  458. package/src/commands/exe/status.md +6 -0
  459. package/src/commands/exe-reference.md +25 -36
  460. package/src/commands/exe.md +19 -28
  461. package/stack.release.json +11 -11
  462. package/dist/chunk-3B6FLNLV.js +0 -30
  463. package/dist/chunk-FXU7JOXK.js +0 -6
  464. package/dist/chunk-QFAFKEB5.js +0 -820
  465. package/dist/conversations-retention-C4BLKFEL.js +0 -54
  466. package/dist/stack-release-5PGWV5D4.js +0 -1607
  467. package/dist/support-inbox-NY5TB3FN.js +0 -51
  468. /package/dist/{chunk-U2D6PJ5T.js → chunk-65G7ZTGE.js} +0 -0
  469. /package/dist/{chunk-DN3ZR3UE.js → chunk-CP7Z35MJ.js} +0 -0
  470. /package/dist/{chunk-XDVOGDBC.js → chunk-KBBWALJV.js} +0 -0
  471. /package/dist/{chunk-JRIH6I7D.js → chunk-LZXYPTY4.js} +0 -0
  472. /package/dist/{chunk-GIRD7O5X.js → chunk-MCWEW2SG.js} +0 -0
  473. /package/dist/{chunk-TKAU7IJ2.js → chunk-MQHUJLCA.js} +0 -0
  474. /package/dist/{chunk-M4XY4JRK.js → chunk-O53LTOXK.js} +0 -0
  475. /package/dist/{chunk-DZN7SDY2.js → chunk-OSVTH3SG.js} +0 -0
  476. /package/dist/{chunk-AJK2PVQW.js → chunk-QXXEXGX3.js} +0 -0
  477. /package/dist/{chunk-AWWDKF22.js → chunk-SFWNTO2F.js} +0 -0
  478. /package/dist/{chunk-2Q2CD6CD.js → chunk-WC5HF2FN.js} +0 -0
  479. /package/dist/{core-memory-O6D5UC3T.js → core-memory-MMMW3TF3.js} +0 -0
  480. /package/dist/{memory-isolation-EBFFC6HF.js → memory-isolation-67ACKQ2M.js} +0 -0
  481. /package/dist/{oauth-server-ZKBUHDFI.js → oauth-server-OILIKR7D.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isCrdtSyncEnabled
3
- } from "./chunk-VROK4X2L.js";
3
+ } from "./chunk-SJP57MQM.js";
4
4
  import {
5
5
  compress,
6
6
  decompress
@@ -8,14 +8,14 @@ import {
8
8
  import {
9
9
  orgMembershipsPath,
10
10
  orgModeActive
11
- } from "./chunk-JA3Y5TV6.js";
11
+ } from "./chunk-GDLB6BPM.js";
12
12
  import {
13
13
  activeRecipientPubKeys,
14
14
  grantsPath,
15
15
  isGrantsMacPrimed,
16
16
  primeGrantsMacKey,
17
17
  warnActiveMonitoringOnce
18
- } from "./chunk-HU3VD4MQ.js";
18
+ } from "./chunk-2Q2GGYBX.js";
19
19
  import {
20
20
  assertGateAndGrantsColocated
21
21
  } from "./chunk-NPXIS2RY.js";
@@ -25,7 +25,7 @@ import {
25
25
  import {
26
26
  GHOST_BEHAVIOR_SQL,
27
27
  isGhostBehaviorRow
28
- } from "./chunk-S26CV7BE.js";
28
+ } from "./chunk-YA5LK6KB.js";
29
29
  import {
30
30
  retryOnDaemonTransportError
31
31
  } from "./chunk-EIOGV75A.js";
@@ -35,17 +35,17 @@ import {
35
35
  encryptSyncBlob,
36
36
  initSyncCrypto,
37
37
  isSyncCryptoInitialized
38
- } from "./chunk-ZPP63JSQ.js";
38
+ } from "./chunk-CL3AB7Z2.js";
39
39
  import {
40
40
  getClient,
41
41
  isGenuineCorruptionError,
42
42
  loadEmployees,
43
43
  registerBinSymlinks,
44
44
  saveEmployees
45
- } from "./chunk-GL47M7NY.js";
45
+ } from "./chunk-3UD3OF3X.js";
46
46
  import {
47
47
  loadDeviceId
48
- } from "./chunk-TNS63ATU.js";
48
+ } from "./chunk-FWRPDSO3.js";
49
49
  import {
50
50
  EXE_AI_DIR
51
51
  } from "./chunk-MMS2HBRT.js";
@@ -71,7 +71,7 @@ var _lastSealOrgMode = null;
71
71
  async function getSyncCipher() {
72
72
  if (_resolved) return _resolved;
73
73
  if (!orgModeActive()) {
74
- const mod = await import("./founder-monitor-envelope-L3IWZLFY.js");
74
+ const mod = await import("./founder-monitor-envelope-NYB5LLU4.js");
75
75
  _monitoredWriter = mod.encryptMonitoredSyncBlob;
76
76
  _founderModuleLinked = true;
77
77
  }
@@ -308,7 +308,7 @@ function partialCloudSyncResult(values) {
308
308
  }
309
309
  async function markCloudSyncSlicePending() {
310
310
  try {
311
- const { writeCloudSyncState, readCloudSyncState } = await import("./cloud-sync-state-QF3TMMJ4.js");
311
+ const { writeCloudSyncState, readCloudSyncState } = await import("./cloud-sync-state-VSQFGPP6.js");
312
312
  const now = (/* @__PURE__ */ new Date()).toISOString();
313
313
  const previous = readCloudSyncState();
314
314
  writeCloudSyncState({
@@ -325,6 +325,47 @@ async function markCloudSyncSlicePending() {
325
325
  logError(`[cloud-sync] pending-slice state write failed: ${err instanceof Error ? err.message : String(err)}`);
326
326
  }
327
327
  }
328
+ var TRANSIENT_PULL_PARTIAL_REASONS = /* @__PURE__ */ new Set([
329
+ "timeout",
330
+ "lost-reply",
331
+ "request-error"
332
+ ]);
333
+ function shouldChasePullRetry(reason, madeForwardProgress) {
334
+ if (madeForwardProgress) return true;
335
+ return reason !== void 0 && TRANSIENT_PULL_PARTIAL_REASONS.has(reason);
336
+ }
337
+ async function markCloudSyncPullIncomplete(reason, pullResultMaxVersion, lastPullVersion) {
338
+ try {
339
+ const { writeCloudSyncState, readCloudSyncState } = await import("./cloud-sync-state-VSQFGPP6.js");
340
+ const now = (/* @__PURE__ */ new Date()).toISOString();
341
+ const previous = readCloudSyncState();
342
+ const previousReach = previous?.pullIncompleteMaxVersion ?? 0;
343
+ const floor = Math.max(lastPullVersion, previousReach);
344
+ const madeForwardProgress = pullResultMaxVersion > floor;
345
+ const newReach = Math.max(pullResultMaxVersion, previousReach);
346
+ const chase = shouldChasePullRetry(reason, madeForwardProgress);
347
+ if (!chase) {
348
+ logError(`[cloud-sync] pull incomplete (${reason ?? "unknown"}) with no forward progress \u2014 retrying at the normal interval rather than in seconds, to avoid re-fetching the same unreadable history in a loop`);
349
+ }
350
+ writeCloudSyncState({
351
+ lastSuccessAt: previous?.lastSuccessAt ?? null,
352
+ lastError: `pull incomplete (${reason ?? "unknown"}) \u2014 remote memory history was not read to the end, so the memory push was skipped to avoid overwriting the part that was not restored. Nothing was lost; local memories remain queued. Retries automatically.`,
353
+ consecutiveFailures: previous?.consecutiveFailures ?? 0,
354
+ paused: previous?.paused ?? false,
355
+ pausedAt: previous?.pausedAt ?? null,
356
+ intervalMs: Number(process.env.EXE_CLOUD_SYNC_INTERVAL_MS) || previous?.intervalMs || 5 * 6e4,
357
+ updatedAt: now,
358
+ // Only claim a slice is pending when the next run has somewhere new to
359
+ // start. Clearing it otherwise also stops a marker left by an earlier,
360
+ // progressing run from keeping the loop hot after progress stopped.
361
+ pendingSliceAt: chase ? now : null,
362
+ pullIncompleteReason: reason ?? "unknown",
363
+ pullIncompleteMaxVersion: newReach
364
+ });
365
+ } catch (err) {
366
+ logError(`[cloud-sync] pull-incomplete state write failed: ${err instanceof Error ? err.message : String(err)}`);
367
+ }
368
+ }
328
369
  async function logResumeClearFailure(err) {
329
370
  const msg = err instanceof Error ? err.message : String(err);
330
371
  logError(`[cloud-sync] resume cursor clear failed: ${msg}`);
@@ -700,6 +741,17 @@ function assertSecureEndpoint(endpoint) {
700
741
  );
701
742
  }
702
743
  }
744
+ var SYNC_PULL_PROTOCOL_VERSION = 2;
745
+ function isPullPartial(result) {
746
+ return result.status === "partial";
747
+ }
748
+ function classifyPullFetchError(err) {
749
+ const name = err instanceof Error ? err.name : "";
750
+ if (name === "TimeoutError" || name === "AbortError") return "timeout";
751
+ const message = err instanceof Error ? err.message : String(err);
752
+ if (/timed? ?out|aborted/i.test(message)) return "timeout";
753
+ return "request-error";
754
+ }
703
755
  async function cloudPush(records, maxVersion, config) {
704
756
  if (records.length === 0) return true;
705
757
  assertSecureEndpoint(config.endpoint);
@@ -754,71 +806,99 @@ async function cloudResetMemoryBlobs(config) {
754
806
  }
755
807
  async function cloudPull(sinceVersion, config) {
756
808
  assertSecureEndpoint(config.endpoint);
757
- const PULL_PAGE_LIMIT = 1e3;
809
+ const PULL_MAX_PAGES = 1e4;
810
+ const allRecords = [];
811
+ let currentSince = sinceVersion;
812
+ let cursor;
813
+ let maxReadableVersion = sinceVersion;
814
+ let pages = 0;
815
+ const partial = (reason) => ({
816
+ records: allRecords,
817
+ maxVersion: maxReadableVersion,
818
+ status: "partial",
819
+ partialReason: reason
820
+ });
758
821
  try {
759
- const allBlobs = [];
760
- let currentSince = sinceVersion;
761
- let maxVersion = sinceVersion;
762
- let hasMore = true;
763
- while (hasMore) {
764
- const response = await fetchWithRetry(`${config.endpoint}/sync/pull`, {
765
- method: "POST",
766
- headers: await cloudAuthHeaders(config),
767
- body: JSON.stringify({ since_version: currentSince, limit: PULL_PAGE_LIMIT })
768
- });
822
+ for (; ; ) {
823
+ if (++pages > PULL_MAX_PAGES) {
824
+ logError(`[cloud-sync] PULL ABORTED after ${PULL_MAX_PAGES} pages at version ${currentSince} \u2014 refusing to treat a runaway pull as a complete history`);
825
+ return partial("page-cap");
826
+ }
827
+ let response;
828
+ try {
829
+ response = await fetchWithRetry(`${config.endpoint}/sync/pull`, {
830
+ method: "POST",
831
+ headers: {
832
+ ...await cloudAuthHeaders(config),
833
+ "X-Sync-Pull-Protocol": String(SYNC_PULL_PROTOCOL_VERSION)
834
+ },
835
+ // `limit` is deliberately NOT sent. The server has never honoured it,
836
+ // and asking for a page size the client then assumes it received is
837
+ // precisely bug 1a2f058f.
838
+ body: JSON.stringify({ since_version: currentSince, ...cursor ? { cursor } : {} })
839
+ });
840
+ } catch (err) {
841
+ const reason = classifyPullFetchError(err);
842
+ logError(`[cloud-sync] PULL INCOMPLETE (${reason}) on page ${pages}: ${err instanceof Error ? err.message : String(err)}`);
843
+ return partial(reason);
844
+ }
769
845
  if (response == null) {
770
- logError("[cloud-sync] PULL FAILED: no response from server");
771
- return { records: [], maxVersion: sinceVersion };
846
+ logError(`[cloud-sync] PULL INCOMPLETE (lost-reply): no response from server on page ${pages}`);
847
+ return partial("lost-reply");
848
+ }
849
+ if (!response.ok) {
850
+ logError(`[cloud-sync] PULL INCOMPLETE (request-error): HTTP ${response.status} on page ${pages}`);
851
+ return partial("request-error");
772
852
  }
773
- if (!response.ok) return { records: [], maxVersion: sinceVersion };
774
853
  const data = await response.json();
775
854
  const pageBlobs = data.blobs ?? [];
776
- allBlobs.push(...pageBlobs);
777
- maxVersion = Math.max(maxVersion, data.max_version ?? 0);
778
- if (pageBlobs.length < PULL_PAGE_LIMIT) {
779
- hasMore = false;
780
- } else {
781
- const lastBlobVersion = pageBlobs[pageBlobs.length - 1]?.version ?? 0;
782
- if (lastBlobVersion <= currentSince) {
783
- hasMore = false;
784
- } else {
785
- currentSince = lastBlobVersion;
855
+ for (const { version, blob } of pageBlobs) {
856
+ try {
857
+ const compressed = decryptSyncBlob(blob);
858
+ const json = decompress(compressed).toString("utf8");
859
+ const records = JSON.parse(json);
860
+ allRecords.push(...records);
861
+ const recordMax = records.reduce((max, rec) => {
862
+ const v = Number(rec.version ?? 0);
863
+ return Number.isFinite(v) ? Math.max(max, v) : max;
864
+ }, 0);
865
+ const blobVersion = Number(version ?? 0);
866
+ maxReadableVersion = Math.max(
867
+ maxReadableVersion,
868
+ Number.isFinite(blobVersion) ? blobVersion : 0,
869
+ recordMax
870
+ );
871
+ } catch (e) {
872
+ process.stderr.write("[cloud-sync] blob decrypt/decompress failed (version " + version + "): " + (e instanceof Error ? e.message : String(e)) + "\n");
873
+ logError(`[cloud-sync] PULL INCOMPLETE (undecryptable-blob) at version ${version} \u2014 history is a PREFIX, not a whole. Stopping rather than skipping the blob.`);
874
+ return partial("undecryptable-blob");
786
875
  }
787
876
  }
788
- }
789
- const allRecords = [];
790
- let maxReadableVersion = sinceVersion;
791
- let skippedBlobs = 0;
792
- for (const { version, blob } of allBlobs) {
793
- try {
794
- const compressed = decryptSyncBlob(blob);
795
- const json = decompress(compressed).toString("utf8");
796
- const records = JSON.parse(json);
797
- allRecords.push(...records);
798
- const recordMax = records.reduce((max, rec) => {
799
- const v = Number(rec.version ?? 0);
800
- return Number.isFinite(v) ? Math.max(max, v) : max;
801
- }, 0);
802
- const blobVersion = Number(version ?? 0);
803
- maxReadableVersion = Math.max(
804
- maxReadableVersion,
805
- Number.isFinite(blobVersion) ? blobVersion : 0,
806
- recordMax
807
- );
808
- } catch (e) {
809
- process.stderr.write("[cloud-sync] blob decrypt/decompress failed (version " + version + "): " + (e instanceof Error ? e.message : String(e)) + "\n");
810
- skippedBlobs++;
877
+ if (data.complete === true) return { records: allRecords, maxVersion: maxReadableVersion, status: "complete" };
878
+ if (data.complete === false) {
879
+ const nextCursor = data.cursor;
880
+ if (typeof nextCursor !== "string" || nextCursor.length === 0 || nextCursor === cursor) {
881
+ logError(`[cloud-sync] PULL INCOMPLETE (cursor-stalled) on page ${pages}: server reported more history past version ${maxReadableVersion} but returned no usable next cursor`);
882
+ return partial("cursor-stalled");
883
+ }
884
+ cursor = nextCursor;
885
+ currentSince = Math.max(currentSince, maxReadableVersion);
811
886
  continue;
812
887
  }
888
+ if (pageBlobs.length === 0) {
889
+ return { records: allRecords, maxVersion: maxReadableVersion, status: "complete" };
890
+ }
891
+ const lastBlobVersion = Number(pageBlobs[pageBlobs.length - 1]?.version ?? 0);
892
+ if (!Number.isFinite(lastBlobVersion) || lastBlobVersion <= currentSince) {
893
+ logError(`[cloud-sync] PULL INCOMPLETE (cursor-stalled): legacy server returned ${pageBlobs.length} blob(s) but no version past ${currentSince}`);
894
+ return partial("cursor-stalled");
895
+ }
896
+ currentSince = lastBlobVersion;
813
897
  }
814
- const finalMaxVersion = maxReadableVersion;
815
- if (skippedBlobs > 0) {
816
- logError(`[cloud-sync] PULL skipped ${skippedBlobs} undecryptable blob(s); cursor advancing to ${finalMaxVersion} (last readable: ${maxReadableVersion})`);
817
- }
818
- return { records: allRecords, maxVersion: finalMaxVersion };
819
898
  } catch (err) {
820
- logError(`[cloud-sync] PULL FAILED: ${err instanceof Error ? err.message : String(err)}`);
821
- return { records: [], maxVersion: sinceVersion };
899
+ const reason = classifyPullFetchError(err);
900
+ logError(`[cloud-sync] PULL FAILED (${reason}): ${err instanceof Error ? err.message : String(err)}`);
901
+ return partial(reason);
822
902
  }
823
903
  }
824
904
  var CLOUD_REUPLOAD_REQUIRED_MESSAGE = "Cloud sync is blocked because this device rotated its memory encryption key. Run `exe-os cloud reupload` first to re-upload the cloud backup with the new key.";
@@ -1027,7 +1107,11 @@ async function cloudPushPendingMemories(client, config, options) {
1027
1107
  if (!pushOk) {
1028
1108
  errors++;
1029
1109
  logError(`[cloud-sync] memory push batch failed at version=${maxVersion}; retrying once after pull`);
1030
- await cloudPull(options.lastPullVersion, config);
1110
+ const refresh = await cloudPull(options.lastPullVersion, config);
1111
+ if (isPullPartial(refresh)) {
1112
+ logError(`[cloud-sync] memory push retry ABANDONED at version=${maxVersion}: the refresh pull was incomplete (${refresh.partialReason}), so the remote head is unknown. Cursor remains ${safeCursor}; nothing was overwritten.`);
1113
+ break;
1114
+ }
1031
1115
  pushOk = await cloudPush(records, maxVersion, config);
1032
1116
  if (!pushOk) {
1033
1117
  errors++;
@@ -1154,6 +1238,9 @@ async function cloudSync(config, options) {
1154
1238
  );
1155
1239
  const lastPullVersion = pullMeta.rows.length > 0 ? Number(pullMeta.rows[0].value) : 0;
1156
1240
  let pulled = 0;
1241
+ let pullApplyTotalFailure = false;
1242
+ let pullIncomplete = false;
1243
+ let pullPartialReason;
1157
1244
  let pullResult = { records: [], maxVersion: lastPullVersion };
1158
1245
  if (!shouldSkip("pull")) {
1159
1246
  onProgress("Cloud sync", "pulling remote changes...");
@@ -1167,7 +1254,7 @@ async function cloudSync(config, options) {
1167
1254
  })
1168
1255
  };
1169
1256
  if (shouldUseCrdtMergeForCloudSync()) {
1170
- const { initCrdtDoc, importExistingMemories, readAllMemories } = await import("./crdt-sync-IFRZOEIS.js");
1257
+ const { initCrdtDoc, importExistingMemories, readAllMemories } = await import("./crdt-sync-7TDUBTLH.js");
1171
1258
  initCrdtDoc();
1172
1259
  importExistingMemories(
1173
1260
  pullResult.records.map((rec) => ({
@@ -1357,6 +1444,7 @@ async function cloudSync(config, options) {
1357
1444
  }
1358
1445
  }
1359
1446
  pulled = stmts.length - syncErrors;
1447
+ if (stmts.length > 0 && syncErrors === stmts.length) pullApplyTotalFailure = true;
1360
1448
  if (syncErrors > 0) {
1361
1449
  process.stderr.write(`[cloud-sync] Pull completed with ${syncErrors} skipped record(s)
1362
1450
  `);
@@ -1370,18 +1458,29 @@ async function cloudSync(config, options) {
1370
1458
  process.stderr.write("[cloud-sync] Postgres push of pulled records failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
1371
1459
  }
1372
1460
  }
1373
- if (pullResult.maxVersion > lastPullVersion) {
1461
+ pullIncomplete = isPullPartial(pullResult);
1462
+ pullPartialReason = pullResult.partialReason;
1463
+ const pullDurable = !pullIncomplete && !pullApplyTotalFailure;
1464
+ if (pullDurable && pullResult.maxVersion > lastPullVersion) {
1374
1465
  await client.execute({
1375
1466
  sql: "INSERT INTO sync_meta (key, value) VALUES ('last_cloud_pull_version', ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",
1376
1467
  args: [String(pullResult.maxVersion)]
1377
1468
  });
1469
+ } else if (!pullDurable) {
1470
+ logError(`[cloud-sync] pull cursor HELD at ${lastPullVersion} (partial=${pullPartialReason ?? "no"}, page landed nothing=${pullApplyTotalFailure}) \u2014 the next run re-pulls from there rather than skipping the gap`);
1471
+ }
1472
+ if (pullDurable) {
1473
+ await stageDone("pull");
1378
1474
  }
1379
- await stageDone("pull");
1380
1475
  }
1381
1476
  let pushed = 0;
1382
1477
  let memoryPushErrors = 0;
1383
1478
  let pendingMemories = 0;
1384
- if (!shouldSkip("memories")) {
1479
+ if (pullIncomplete) {
1480
+ logError(`[cloud-sync] MEMORY PUSH SKIPPED: the pull stopped short of the end of remote history (${pullPartialReason}). Pushing memory blobs now would overwrite the unrestored remainder. Local data is untouched and the rows stay queued; the next sync retries the pull. Other sync stages still run.`);
1481
+ onProgress("Cloud sync", `memory push skipped \u2014 remote history was not fully pulled (${pullPartialReason})`);
1482
+ }
1483
+ if (!shouldSkip("memories") && !pullIncomplete) {
1385
1484
  onProgress("Cloud sync", `pushing memories...`);
1386
1485
  const pushMeta = await client.execute(
1387
1486
  "SELECT value FROM sync_meta WHERE key = 'last_cloud_push_version'"
@@ -1714,7 +1813,7 @@ async function cloudSync(config, options) {
1714
1813
  const artifactResult = { pushed: 0, frozen: false, remaining: 0 };
1715
1814
  if (!shouldSkip("artifacts")) {
1716
1815
  try {
1717
- const { flushArtifactBackups } = await import("./artifact-backup-TF6YWQT2.js");
1816
+ const { flushArtifactBackups } = await import("./artifact-backup-HGUFSIJH.js");
1718
1817
  const flushed = await flushArtifactBackups(cloudArtifactTransport(config));
1719
1818
  artifactResult.pushed = flushed.pushed;
1720
1819
  artifactResult.frozen = flushed.frozen;
@@ -1732,28 +1831,44 @@ async function cloudSync(config, options) {
1732
1831
  await stageDone("artifacts");
1733
1832
  }
1734
1833
  const elapsedSec = ((Date.now() - syncStartTime) / 1e3).toFixed(1);
1735
- onProgress("Cloud sync", `complete (pushed ${pushed}, pulled ${pulled}, elapsed ${elapsedSec}s)`);
1736
- try {
1737
- await clearCloudSyncStageResume(client);
1738
- } catch (err) {
1739
- await logResumeClearFailure(err);
1740
- }
1741
- try {
1742
- const { writeCloudSyncState, readCloudSyncState } = await import("./cloud-sync-state-QF3TMMJ4.js");
1743
- const now = (/* @__PURE__ */ new Date()).toISOString();
1744
- const intervalMs = Number(process.env.EXE_CLOUD_SYNC_INTERVAL_MS) || readCloudSyncState()?.intervalMs || 5 * 6e4;
1745
- writeCloudSyncState({
1746
- lastSuccessAt: now,
1747
- lastError: null,
1748
- consecutiveFailures: 0,
1749
- paused: false,
1750
- pausedAt: null,
1751
- intervalMs,
1752
- updatedAt: now,
1753
- pendingSliceAt: null
1754
- });
1755
- } catch (err) {
1756
- logError(`[cloud-sync] success state write failed: ${err instanceof Error ? err.message : String(err)}`);
1834
+ onProgress(
1835
+ "Cloud sync",
1836
+ pullIncomplete ? `INCOMPLETE \u2014 remote history was not fully pulled (${pullPartialReason}), so the push was skipped (pulled ${pulled}, elapsed ${elapsedSec}s)` : `complete (pushed ${pushed}, pulled ${pulled}, elapsed ${elapsedSec}s)`
1837
+ );
1838
+ if (pullIncomplete) {
1839
+ await markCloudSyncPullIncomplete(pullPartialReason, pullResult.maxVersion, lastPullVersion);
1840
+ } else {
1841
+ try {
1842
+ await clearCloudSyncStageResume(client);
1843
+ } catch (err) {
1844
+ await logResumeClearFailure(err);
1845
+ }
1846
+ try {
1847
+ const { writeCloudSyncState, readCloudSyncState } = await import("./cloud-sync-state-VSQFGPP6.js");
1848
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1849
+ const intervalMs = Number(process.env.EXE_CLOUD_SYNC_INTERVAL_MS) || readCloudSyncState()?.intervalMs || 5 * 6e4;
1850
+ writeCloudSyncState({
1851
+ lastSuccessAt: now,
1852
+ lastError: null,
1853
+ consecutiveFailures: 0,
1854
+ paused: false,
1855
+ pausedAt: null,
1856
+ intervalMs,
1857
+ updatedAt: now,
1858
+ pendingSliceAt: null,
1859
+ // A run that got here read remote history to the end. Clear the partial
1860
+ // marker, or `cloud status` reports "partial" forever on the strength of
1861
+ // a condition that has since cleared.
1862
+ pullIncompleteReason: null,
1863
+ // The held reach only means something while a partial is outstanding —
1864
+ // a completed pull already advanced the durable cursor past it, so
1865
+ // leaving it set would compare the NEXT partial (possibly cycles later)
1866
+ // against a stale high-water mark from a restore that has since finished.
1867
+ pullIncompleteMaxVersion: null
1868
+ });
1869
+ } catch (err) {
1870
+ logError(`[cloud-sync] success state write failed: ${err instanceof Error ? err.message : String(err)}`);
1871
+ }
1757
1872
  }
1758
1873
  return {
1759
1874
  pushed,
@@ -1769,7 +1884,8 @@ async function cloudSync(config, options) {
1769
1884
  codeContext: codeContextResult,
1770
1885
  elapsedMs: Date.now() - syncStartTime,
1771
1886
  memoryPushErrors,
1772
- pendingMemories
1887
+ pendingMemories,
1888
+ ...pullIncomplete ? { pullIncomplete: true, pullPartialReason } : {}
1773
1889
  };
1774
1890
  } finally {
1775
1891
  _cloudSyncInProgress = false;
@@ -1913,11 +2029,20 @@ function mergeConfig(remoteConfig, configPath) {
1913
2029
  const cfgPath = configPath ?? path2.join(EXE_AI_DIR, "config.json");
1914
2030
  let local = {};
1915
2031
  if (existsSync(cfgPath)) {
2032
+ let parsed;
1916
2033
  try {
1917
- local = JSON.parse(readFileSync(cfgPath, "utf-8"));
2034
+ parsed = JSON.parse(readFileSync(cfgPath, "utf-8"));
1918
2035
  } catch (e) {
1919
- process.stderr.write("[cloud-sync] mergeConfig local config parse failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
2036
+ throw new Error(
2037
+ `[cloud-sync] refusing to merge remote config: the local config at ${cfgPath} exists but could not be read (${e instanceof Error ? e.message : String(e)}). Overwriting it here would destroy every local-only key it holds.`
2038
+ );
2039
+ }
2040
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
2041
+ throw new Error(
2042
+ `[cloud-sync] refusing to merge remote config: the local config at ${cfgPath} did not parse to a JSON object, so its keys cannot be preserved across the merge.`
2043
+ );
1920
2044
  }
2045
+ local = parsed;
1921
2046
  }
1922
2047
  const merged = { ...remoteConfig, ...local };
1923
2048
  const dir = path2.dirname(cfgPath);
@@ -2008,19 +2133,7 @@ async function mergeRosterFromRemote(remote, paths) {
2008
2133
  }
2009
2134
  if (remote.agentConfig && Object.keys(remote.agentConfig).length > 0) {
2010
2135
  try {
2011
- const agentConfigPath = path2.join(EXE_AI_DIR, "agent-config.json");
2012
- let local = {};
2013
- if (existsSync(agentConfigPath)) {
2014
- try {
2015
- local = JSON.parse(readFileSync(agentConfigPath, "utf-8"));
2016
- } catch (e) {
2017
- process.stderr.write("[cloud-sync] agent-config.json parse failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
2018
- }
2019
- }
2020
- const merged = { ...remote.agentConfig, ...local };
2021
- ensurePrivateDirSync(path2.dirname(agentConfigPath));
2022
- atomicWriteSync(agentConfigPath, JSON.stringify(merged, null, 2) + "\n");
2023
- enforcePrivateFileSync(agentConfigPath);
2136
+ mergeAgentConfig(remote.agentConfig);
2024
2137
  } catch (e) {
2025
2138
  process.stderr.write("[cloud-sync] agent-config merge failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
2026
2139
  }
@@ -2028,6 +2141,30 @@ async function mergeRosterFromRemote(remote, paths) {
2028
2141
  return { added, identitiesUpdated };
2029
2142
  });
2030
2143
  }
2144
+ function mergeAgentConfig(remoteAgentConfig, agentConfigPath) {
2145
+ const cfgPath = agentConfigPath ?? path2.join(EXE_AI_DIR, "agent-config.json");
2146
+ let local = {};
2147
+ if (existsSync(cfgPath)) {
2148
+ let parsed;
2149
+ try {
2150
+ parsed = JSON.parse(readFileSync(cfgPath, "utf-8"));
2151
+ } catch (e) {
2152
+ throw new Error(
2153
+ `[cloud-sync] refusing to merge remote agent-config: the local file at ${cfgPath} exists but could not be read (${e instanceof Error ? e.message : String(e)}). Overwriting it here would delete every locally-configured agent runtime and model.`
2154
+ );
2155
+ }
2156
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
2157
+ throw new Error(
2158
+ `[cloud-sync] refusing to merge remote agent-config: the local file at ${cfgPath} did not parse to a JSON object, so its per-agent entries cannot be preserved across the merge.`
2159
+ );
2160
+ }
2161
+ local = parsed;
2162
+ }
2163
+ const merged = { ...remoteAgentConfig, ...local };
2164
+ ensurePrivateDirSync(path2.dirname(cfgPath));
2165
+ atomicWriteSync(cfgPath, JSON.stringify(merged, null, 2) + "\n");
2166
+ enforcePrivateFileSync(cfgPath);
2167
+ }
2031
2168
  async function cloudPushBlob(route, data, metaKey, config, clearWhenEmpty = false) {
2032
2169
  if (data.length === 0 && !clearWhenEmpty) return { ok: true };
2033
2170
  assertSecureEndpoint(config.endpoint);
@@ -2624,18 +2761,38 @@ async function cloudPullTasks(config) {
2624
2761
  await batchWriteYielding(client, stmts);
2625
2762
  return { pulled: remoteTasks.length };
2626
2763
  }
2764
+ function isMissingTableError(e, table) {
2765
+ const message = e instanceof Error ? e.message : String(e);
2766
+ return new RegExp(`no such table:\\s*(?:main\\.|temp\\.)?${table}(?![\\w])`, "i").test(message);
2767
+ }
2768
+ async function collectConversationsForPush(client) {
2769
+ const rows = await fetchAllRows(client, "conversations");
2770
+ for (const r of rows) r.archived_at = null;
2771
+ const seen = new Set(rows.map((r) => String(r.id)));
2772
+ try {
2773
+ const archived = await fetchAllRows(client, "conversations_archive");
2774
+ for (const r of archived) {
2775
+ if (seen.has(String(r.id))) continue;
2776
+ seen.add(String(r.id));
2777
+ rows.push(r);
2778
+ }
2779
+ } catch (e) {
2780
+ if (!isMissingTableError(e, "conversations_archive")) throw e;
2781
+ }
2782
+ return rows;
2783
+ }
2627
2784
  async function cloudPushConversations(config) {
2628
2785
  let sweptEmpty = false;
2786
+ const client = getClient();
2629
2787
  try {
2630
- const client = getClient();
2631
2788
  const res = await client.execute("SELECT 1 FROM conversation_deletions LIMIT 1");
2632
2789
  sweptEmpty = res.rows.length > 0;
2633
2790
  } catch {
2634
2791
  }
2635
- const { ok } = await cloudPushVersionedBlob(
2636
- "conversations",
2637
- null,
2792
+ const rows = await collectConversationsForPush(client);
2793
+ const { ok } = await cloudPushBlob(
2638
2794
  "/sync/push-conversations",
2795
+ rows,
2639
2796
  "last_conversations_push_version",
2640
2797
  config,
2641
2798
  sweptEmpty
@@ -2652,9 +2809,28 @@ async function cloudPullConversations(config) {
2652
2809
  const applied = await applyPulledConversations(client, remoteConvos);
2653
2810
  return { pulled: applied };
2654
2811
  }
2812
+ async function lookupExistingIds(client, table, ids) {
2813
+ const found = /* @__PURE__ */ new Set();
2814
+ const CHUNK = 500;
2815
+ try {
2816
+ for (let i = 0; i < ids.length; i += CHUNK) {
2817
+ const chunk = ids.slice(i, i + CHUNK);
2818
+ const placeholders = chunk.map(() => "?").join(",");
2819
+ const res = await client.execute({
2820
+ sql: `SELECT id FROM ${table} WHERE id IN (${placeholders})`,
2821
+ args: chunk
2822
+ });
2823
+ for (const row of res.rows) found.add(String(row.id));
2824
+ }
2825
+ } catch (e) {
2826
+ if (!isMissingTableError(e, table)) throw e;
2827
+ }
2828
+ return found;
2829
+ }
2655
2830
  async function applyPulledConversations(client, remoteConvos) {
2656
2831
  if (!remoteConvos || remoteConvos.length === 0) return 0;
2657
2832
  const tombstoned = /* @__PURE__ */ new Set();
2833
+ let ledgerPresent = true;
2658
2834
  const remoteIds = remoteConvos.map((c) => String(c.id));
2659
2835
  const LOOKUP_CHUNK = 500;
2660
2836
  try {
@@ -2668,15 +2844,111 @@ async function applyPulledConversations(client, remoteConvos) {
2668
2844
  for (const row of res.rows) tombstoned.add(String(row.id));
2669
2845
  }
2670
2846
  } catch {
2847
+ ledgerPresent = false;
2671
2848
  }
2672
2849
  const survivors = tombstoned.size === 0 ? remoteConvos : remoteConvos.filter((c) => !tombstoned.has(String(c.id)));
2673
2850
  if (survivors.length === 0) return 0;
2674
- const stmts = survivors.map((c) => ({
2851
+ const survivorIds = survivors.map((c) => String(c.id));
2852
+ const localArchivedIds = await lookupExistingIds(client, "conversations_archive", survivorIds);
2853
+ const localLiveIds = await lookupExistingIds(client, "conversations", survivorIds);
2854
+ const belongsInArchive = (c) => {
2855
+ const id = String(c.id);
2856
+ if (localLiveIds.has(id)) return false;
2857
+ if (c.archived_at != null) return true;
2858
+ return localArchivedIds.has(id) && !localLiveIds.has(id);
2859
+ };
2860
+ const archivedRows = survivors.filter(belongsInArchive);
2861
+ const liveRows = survivors.filter((c) => !belongsInArchive(c));
2862
+ const tombstoneRecheck = ledgerPresent ? `
2863
+ AND NOT EXISTS (SELECT 1 FROM conversation_deletions d WHERE d.id = ?)` : "";
2864
+ const liveGuard = `WHERE (EXISTS (SELECT 1 FROM conversations lv WHERE lv.id = ?)
2865
+ OR (NOT EXISTS (SELECT 1 FROM conversations_archive ar WHERE ar.id = ?) AND ? IS NULL))${tombstoneRecheck}`;
2866
+ const archiveGuard = `WHERE NOT EXISTS (SELECT 1 FROM conversations lv WHERE lv.id = ?)
2867
+ AND (? IS NOT NULL OR EXISTS (SELECT 1 FROM conversations_archive ar WHERE ar.id = ?))${tombstoneRecheck}`;
2868
+ await client.execute(
2869
+ `CREATE TABLE IF NOT EXISTS conversations_archive AS
2870
+ SELECT *, datetime('now') AS archived_at FROM conversations WHERE 0`
2871
+ );
2872
+ await client.execute(
2873
+ `CREATE UNIQUE INDEX IF NOT EXISTS idx_conversations_archive_id
2874
+ ON conversations_archive(id)`
2875
+ );
2876
+ await client.execute(
2877
+ `CREATE INDEX IF NOT EXISTS idx_conversations_archive_archived_at
2878
+ ON conversations_archive(archived_at)`
2879
+ );
2880
+ await client.execute(
2881
+ `CREATE INDEX IF NOT EXISTS idx_conversations_archive_ingested_at
2882
+ ON conversations_archive(ingested_at)`
2883
+ );
2884
+ await client.execute(
2885
+ `CREATE UNIQUE INDEX IF NOT EXISTS idx_conversations_archive_id
2886
+ ON conversations_archive(id)`
2887
+ );
2888
+ const archiveStmt = (c) => {
2889
+ const archivedAt = c.archived_at != null ? c.archived_at : (/* @__PURE__ */ new Date()).toISOString();
2890
+ return {
2891
+ sql: `INSERT INTO conversations_archive
2892
+ (id, platform, external_id, sender_id, sender_name, sender_phone, sender_email,
2893
+ recipient_id, channel_id, thread_id, reply_to_id, content_text, content_media,
2894
+ content_metadata, agent_response, agent_name, timestamp, ingested_at, archived_at)
2895
+ SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
2896
+ ${archiveGuard}
2897
+ ON CONFLICT(id) DO UPDATE SET
2898
+ platform = excluded.platform,
2899
+ external_id = excluded.external_id,
2900
+ sender_id = excluded.sender_id,
2901
+ sender_name = excluded.sender_name,
2902
+ sender_phone = excluded.sender_phone,
2903
+ sender_email = excluded.sender_email,
2904
+ recipient_id = excluded.recipient_id,
2905
+ channel_id = excluded.channel_id,
2906
+ thread_id = excluded.thread_id,
2907
+ reply_to_id = excluded.reply_to_id,
2908
+ content_text = excluded.content_text,
2909
+ content_media = excluded.content_media,
2910
+ content_metadata = excluded.content_metadata,
2911
+ agent_response = excluded.agent_response,
2912
+ agent_name = excluded.agent_name,
2913
+ timestamp = excluded.timestamp,
2914
+ ingested_at = excluded.ingested_at
2915
+ WHERE COALESCE(excluded.ingested_at, excluded.timestamp, '') > COALESCE(conversations_archive.ingested_at, conversations_archive.timestamp, '')`,
2916
+ args: [
2917
+ sqlSafe(c.id),
2918
+ sqlSafe(c.platform),
2919
+ sqlSafe(c.external_id),
2920
+ sqlSafe(c.sender_id),
2921
+ sqlSafe(c.sender_name),
2922
+ sqlSafe(c.sender_phone),
2923
+ sqlSafe(c.sender_email),
2924
+ sqlSafe(c.recipient_id),
2925
+ sqlSafe(c.channel_id),
2926
+ sqlSafe(c.thread_id),
2927
+ sqlSafe(c.reply_to_id),
2928
+ sqlSafe(c.content_text),
2929
+ sqlSafe(c.content_media),
2930
+ sqlSafe(c.content_metadata),
2931
+ sqlSafe(c.agent_response),
2932
+ sqlSafe(c.agent_name),
2933
+ sqlSafe(c.timestamp),
2934
+ sqlSafe(c.ingested_at),
2935
+ sqlSafe(archivedAt),
2936
+ // guard args, in the order they appear in archiveGuard
2937
+ sqlSafe(c.id),
2938
+ sqlSafe(c.archived_at),
2939
+ sqlSafe(c.id),
2940
+ // the tombstone recheck's `?`, appended last because the clause is
2941
+ ...ledgerPresent ? [sqlSafe(c.id)] : []
2942
+ ]
2943
+ };
2944
+ };
2945
+ const liveStmt = (c) => ({
2675
2946
  sql: `INSERT INTO conversations
2676
2947
  (id, platform, external_id, sender_id, sender_name, sender_phone, sender_email,
2677
2948
  recipient_id, channel_id, thread_id, reply_to_id, content_text, content_media,
2678
2949
  content_metadata, agent_response, agent_name, timestamp, ingested_at)
2679
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2950
+ SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
2951
+ ${liveGuard}
2680
2952
  ON CONFLICT(id) DO UPDATE SET
2681
2953
  platform = excluded.platform,
2682
2954
  external_id = excluded.external_id,
@@ -2714,11 +2986,20 @@ async function applyPulledConversations(client, remoteConvos) {
2714
2986
  sqlSafe(c.agent_response),
2715
2987
  sqlSafe(c.agent_name),
2716
2988
  sqlSafe(c.timestamp),
2717
- sqlSafe(c.ingested_at)
2989
+ sqlSafe(c.ingested_at),
2990
+ // guard args, in the order they appear in liveGuard
2991
+ sqlSafe(c.id),
2992
+ sqlSafe(c.id),
2993
+ sqlSafe(c.archived_at),
2994
+ ...ledgerPresent ? [sqlSafe(c.id)] : []
2718
2995
  ]
2719
- }));
2996
+ });
2997
+ const stmts = [
2998
+ ...archivedRows.flatMap((c) => [archiveStmt(c), liveStmt(c)]),
2999
+ ...liveRows.flatMap((c) => [liveStmt(c), archiveStmt(c)])
3000
+ ];
2720
3001
  await batchWriteYielding(client, stmts);
2721
- return survivors.length;
3002
+ return archivedRows.length + liveRows.length;
2722
3003
  }
2723
3004
  function validPulledPrimaryKeyId(id) {
2724
3005
  return typeof id === "string" && id.trim().length > 0;
@@ -3223,6 +3504,7 @@ export {
3223
3504
  pushToPostgres,
3224
3505
  migrateEndpoint,
3225
3506
  assertSecureEndpoint,
3507
+ SYNC_PULL_PROTOCOL_VERSION,
3226
3508
  cloudPush,
3227
3509
  cloudResetMemoryBlobs,
3228
3510
  cloudPull,
@@ -3243,6 +3525,7 @@ export {
3243
3525
  cloudPullRoster,
3244
3526
  mergeConfig,
3245
3527
  mergeRosterFromRemote,
3528
+ mergeAgentConfig,
3246
3529
  cloudPushBlob,
3247
3530
  cloudArtifactTransport,
3248
3531
  cloudPushVersionedBlob,