@askexenow/exe-os 0.9.127 → 0.9.129

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 (373) hide show
  1. package/dist/active-agent-3FDJYREJ.js +22 -0
  2. package/dist/active-agent-WC7YK3L5.js +23 -0
  3. package/dist/agent-context-CDWUZEXY.js +11 -0
  4. package/dist/agent-loop-G4VUR5ME.js +10 -0
  5. package/dist/agentic-ontology-2VYNTMNO.js +25 -0
  6. package/dist/backfill-metadata-OJWOCLSZ.js +601 -0
  7. package/dist/background-jobs-LGRDXGXC.js +25 -0
  8. package/dist/bash-Y5PEW5UQ.js +8 -0
  9. package/dist/behaviors-CSB2YLDT.js +22 -0
  10. package/dist/bin/age-ontology-load.js +10 -258
  11. package/dist/bin/agentic-ontology-backfill.js +23 -5296
  12. package/dist/bin/agentic-reflection-backfill.js +19 -4739
  13. package/dist/bin/agentic-semantic-label.js +28 -4723
  14. package/dist/bin/backfill-conversations.js +42 -5543
  15. package/dist/bin/backfill-responses.js +41 -5542
  16. package/dist/bin/backfill-vectors.js +43 -4795
  17. package/dist/bin/bulk-sync-postgres.js +22 -5313
  18. package/dist/bin/cc-doctor.js +10 -602
  19. package/dist/bin/cleanup-stale-review-tasks.js +32 -6803
  20. package/dist/bin/cli.js +169 -38993
  21. package/dist/bin/exe-agent-config.js +21 -253
  22. package/dist/bin/exe-agent.js +63 -2429
  23. package/dist/bin/exe-assign.js +34 -5810
  24. package/dist/bin/exe-boot.js +180 -12726
  25. package/dist/bin/exe-call.js +48 -1409
  26. package/dist/bin/exe-cloud.js +64 -8516
  27. package/dist/bin/exe-dispatch.js +35 -10818
  28. package/dist/bin/exe-doctor.js +24 -7537
  29. package/dist/bin/exe-export-behaviors.js +18 -6122
  30. package/dist/bin/exe-forget.js +22 -6274
  31. package/dist/bin/exe-gateway.js +62 -15286
  32. package/dist/bin/exe-healthcheck.js +9 -602
  33. package/dist/bin/exe-heartbeat.js +51 -6898
  34. package/dist/bin/exe-kill.js +30 -5961
  35. package/dist/bin/exe-launch-agent.js +101 -6788
  36. package/dist/bin/exe-new-employee.js +42 -3774
  37. package/dist/bin/exe-pending-messages.js +28 -6833
  38. package/dist/bin/exe-pending-notifications.js +31 -6869
  39. package/dist/bin/exe-pending-reviews.js +38 -6910
  40. package/dist/bin/exe-rename.js +57 -5766
  41. package/dist/bin/exe-review.js +29 -5948
  42. package/dist/bin/exe-search.js +22 -7692
  43. package/dist/bin/exe-session-cleanup.js +52 -11147
  44. package/dist/bin/exe-settings.js +35 -524
  45. package/dist/bin/exe-start-codex.js +70 -6641
  46. package/dist/bin/exe-start-opencode.js +54 -6584
  47. package/dist/bin/exe-status.js +26 -7081
  48. package/dist/bin/exe-support.js +10 -546
  49. package/dist/bin/exe-team.js +18 -5942
  50. package/dist/bin/git-sweep.js +26 -10909
  51. package/dist/bin/graph-backfill.js +24 -5979
  52. package/dist/bin/graph-export.js +31 -6128
  53. package/dist/bin/graph-layer-benchmark.js +4 -8
  54. package/dist/bin/install.js +47 -2322
  55. package/dist/bin/intercom-check.js +25 -11501
  56. package/dist/bin/list-providers.js +4 -18
  57. package/dist/bin/postgres-agentic-reflection-backfill.js +14 -357
  58. package/dist/bin/postgres-agentic-semantic-backfill.js +14 -404
  59. package/dist/bin/pre-publish.js +4 -298
  60. package/dist/bin/registry-proxy.js +8 -172
  61. package/dist/bin/scan-tasks.js +47 -10881
  62. package/dist/bin/setup.js +6 -9492
  63. package/dist/bin/shard-migrate.js +30 -5149
  64. package/dist/bin/stack-update.js +75 -203
  65. package/dist/bin/update.js +20 -654
  66. package/dist/capacity-monitor-3GZIHLB4.js +46 -0
  67. package/dist/catchup-brief-67QDCINS.js +148 -0
  68. package/dist/chunk-2QD7KBJN.js +664 -0
  69. package/dist/chunk-2WGSIVI4.js +149 -0
  70. package/dist/chunk-35TVNLJI.js +57 -0
  71. package/dist/chunk-3SYV36U5.js +47 -0
  72. package/dist/chunk-46SQTBQW.js +207 -0
  73. package/dist/chunk-4CMVLKEI.js +171 -0
  74. package/dist/chunk-4FLUOZTR.js +116 -0
  75. package/dist/chunk-4NYQAS33.js +17 -0
  76. package/dist/chunk-4QNPADWL.js +902 -0
  77. package/dist/chunk-4Y6QZBEO.js +58 -0
  78. package/dist/chunk-557C2IGL.js +0 -0
  79. package/dist/chunk-55S56YDO.js +305 -0
  80. package/dist/chunk-5BS5ELMC.js +85 -0
  81. package/dist/chunk-5DHM77JE.js +256 -0
  82. package/dist/chunk-5QTWQKNF.js +137 -0
  83. package/dist/chunk-6A7P74QV.js +53 -0
  84. package/dist/chunk-6BFIFI5F.js +45 -0
  85. package/dist/chunk-6KFICEAT.js +20 -0
  86. package/dist/chunk-6LKDJ5WX.js +317 -0
  87. package/dist/chunk-6M5II4EV.js +148 -0
  88. package/dist/chunk-6QEFN3DV.js +302 -0
  89. package/dist/chunk-6WTMJAG3.js +171 -0
  90. package/dist/chunk-6Y4B3QF6.js +19 -0
  91. package/dist/chunk-7RK3AYJE.js +163 -0
  92. package/dist/chunk-7TCP2XTP.js +390 -0
  93. package/dist/chunk-A2NZP64U.js +2307 -0
  94. package/dist/chunk-AFYIYM2K.js +322 -0
  95. package/dist/chunk-AJWFPKQS.js +573 -0
  96. package/dist/chunk-AVE2B4DQ.js +140 -0
  97. package/dist/chunk-B4TT2QQA.js +87 -0
  98. package/dist/chunk-BCMOO4OQ.js +1066 -0
  99. package/dist/chunk-BU3ID2WT.js +432 -0
  100. package/dist/chunk-CFIM43JH.js +862 -0
  101. package/dist/chunk-CURJUF3W.js +66 -0
  102. package/dist/chunk-DC4ZD76Y.js +288 -0
  103. package/dist/chunk-DL52JPGF.js +706 -0
  104. package/dist/chunk-DRSC6ZRA.js +36 -0
  105. package/dist/chunk-E2Q4Y22A.js +86 -0
  106. package/dist/chunk-ECGTESAP.js +236 -0
  107. package/dist/chunk-EHOJUXYG.js +365 -0
  108. package/dist/chunk-EIT6J37V.js +119 -0
  109. package/dist/chunk-ELE2C7L4.js +31 -0
  110. package/dist/chunk-EQSQ4HBW.js +9 -0
  111. package/dist/chunk-FWFFZGSC.js +94 -0
  112. package/dist/chunk-GCNWCYJI.js +249 -0
  113. package/dist/chunk-GGTUUI7J.js +6 -0
  114. package/dist/chunk-GU56L7OY.js +223 -0
  115. package/dist/chunk-HF25XPZE.js +83 -0
  116. package/dist/chunk-HOKOOBDL.js +52 -0
  117. package/dist/chunk-HP43GLZ6.js +89 -0
  118. package/dist/chunk-HSRM6PNM.js +682 -0
  119. package/dist/chunk-HVRTW3OP.js +164 -0
  120. package/dist/chunk-IHDHL5ML.js +125 -0
  121. package/dist/chunk-IHF5RXJM.js +168 -0
  122. package/dist/chunk-IJ73YE73.js +409 -0
  123. package/dist/chunk-INO4ZD5Y.js +162 -0
  124. package/dist/chunk-IRQTM7DY.js +475 -0
  125. package/dist/chunk-JD4FAPYG.js +1208 -0
  126. package/dist/chunk-JN44LQ53.js +316 -0
  127. package/dist/chunk-JQ6TLNIV.js +133 -0
  128. package/dist/chunk-JT76KRZQ.js +35 -0
  129. package/dist/chunk-K6OEWZTB.js +262 -0
  130. package/dist/chunk-KCUYRZSX.js +72 -0
  131. package/dist/chunk-KFQGP6VL.js +33 -0
  132. package/dist/chunk-KRLOFIPI.js +83 -0
  133. package/dist/chunk-KVPG5UT6.js +305 -0
  134. package/dist/chunk-L3TB7CC3.js +170 -0
  135. package/dist/chunk-L4X5EUHR.js +283 -0
  136. package/dist/chunk-LAN26C3W.js +655 -0
  137. package/dist/chunk-LPGBKR4H.js +54 -0
  138. package/dist/chunk-LVNMOVGD.js +132 -0
  139. package/dist/chunk-LX5WEEZ7.js +157 -0
  140. package/dist/chunk-MBH42QNH.js +295 -0
  141. package/dist/chunk-MFO7MNSD.js +102 -0
  142. package/dist/chunk-MILTNDZH.js +736 -0
  143. package/dist/chunk-MJAE4NB7.js +1090 -0
  144. package/dist/chunk-MLCUPTP7.js +132 -0
  145. package/dist/chunk-MPURH6JI.js +445 -0
  146. package/dist/chunk-MVBWW2EO.js +89 -0
  147. package/dist/chunk-MZIGUUDQ.js +42 -0
  148. package/dist/chunk-N3DTSVKE.js +157 -0
  149. package/dist/chunk-N5RRQOAC.js +134 -0
  150. package/dist/chunk-N7L33TED.js +1664 -0
  151. package/dist/chunk-NDYSNVI5.js +122 -0
  152. package/dist/chunk-NEAHEC5G.js +155 -0
  153. package/dist/chunk-NGVOA6ZQ.js +84 -0
  154. package/dist/chunk-NHK5KW6Y.js +193 -0
  155. package/dist/chunk-NMQKGFEP.js +458 -0
  156. package/dist/chunk-NPT4EHZK.js +352 -0
  157. package/dist/chunk-NXFJHTED.js +55 -0
  158. package/dist/chunk-NZLCDI6Y.js +216 -0
  159. package/dist/chunk-O377P7GM.js +100 -0
  160. package/dist/chunk-O4VFZRA5.js +33 -0
  161. package/dist/chunk-O7YD7JYE.js +237 -0
  162. package/dist/chunk-OFK72LTZ.js +81 -0
  163. package/dist/chunk-ORCCI2VV.js +140 -0
  164. package/dist/chunk-OVQR4KMC.js +579 -0
  165. package/dist/chunk-P3CVUMEH.js +54 -0
  166. package/dist/chunk-P4HIF72O.js +30 -0
  167. package/dist/chunk-PEDLSJBL.js +1039 -0
  168. package/dist/chunk-PFICKZZ5.js +219 -0
  169. package/dist/chunk-PGW7TIV6.js +142 -0
  170. package/dist/chunk-PJHHFJAN.js +63 -0
  171. package/dist/chunk-PP4SNOJ5.js +471 -0
  172. package/dist/chunk-PRKVT4KN.js +90 -0
  173. package/dist/chunk-Q2O4VJHH.js +305 -0
  174. package/dist/chunk-Q36CMZIX.js +38 -0
  175. package/dist/chunk-Q3V7K4ME.js +149 -0
  176. package/dist/chunk-QGYPJGHB.js +81 -0
  177. package/dist/chunk-R23EMFJV.js +198 -0
  178. package/dist/chunk-R4M6XCMU.js +39 -0
  179. package/dist/chunk-R4WMF32C.js +81 -0
  180. package/dist/chunk-RJT7H2KR.js +349 -0
  181. package/dist/chunk-RJZMRZNV.js +280 -0
  182. package/dist/chunk-RMFDPCA2.js +72 -0
  183. package/dist/chunk-RUG3N6P4.js +292 -0
  184. package/dist/chunk-RWO327FJ.js +84 -0
  185. package/dist/chunk-SG7EFHQ7.js +108 -0
  186. package/dist/chunk-SH45SJQW.js +0 -0
  187. package/dist/chunk-SPKE5ANC.js +42 -0
  188. package/dist/chunk-SVMFVPBF.js +104 -0
  189. package/dist/chunk-SVXDCELZ.js +163 -0
  190. package/dist/chunk-TMEE7AT7.js +72 -0
  191. package/dist/chunk-TWYEE4FB.js +125 -0
  192. package/dist/chunk-TYLF4LSW.js +110 -0
  193. package/dist/chunk-V4TZI6EO.js +60 -0
  194. package/dist/chunk-VFZTXKQI.js +372 -0
  195. package/dist/chunk-VQ4K2MLM.js +199 -0
  196. package/dist/chunk-VU447UAO.js +173 -0
  197. package/dist/chunk-WMC3TXJF.js +50 -0
  198. package/dist/chunk-WPOA7XAE.js +84 -0
  199. package/dist/chunk-WZQ4CPRG.js +64 -0
  200. package/dist/chunk-X2IMCCM5.js +49 -0
  201. package/dist/chunk-X2Z5GT3V.js +118 -0
  202. package/dist/chunk-XEKO37NM.js +43 -0
  203. package/dist/chunk-XUHFQHGZ.js +505 -0
  204. package/dist/chunk-YGAAZN3E.js +47 -0
  205. package/dist/chunk-YKOW7KMK.js +558 -0
  206. package/dist/chunk-YOQKMB6N.js +145 -0
  207. package/dist/chunk-YZFZDJWZ.js +107 -0
  208. package/dist/chunk-ZBY4AUD4.js +10342 -0
  209. package/dist/chunk-ZOJYPNCM.js +127 -0
  210. package/dist/chunk-ZS7MGQSD.js +1494 -0
  211. package/dist/chunk-ZTZQ5A6B.js +191 -0
  212. package/dist/code-context-index-HXGC4IJL.js +28 -0
  213. package/dist/content-extractor-UVZXRIPC.js +8 -0
  214. package/dist/conversation-entity-extractor-HKSNDF4L.js +113 -0
  215. package/dist/conversation-wiki-populator-NKDAQEZ5.js +105 -0
  216. package/dist/crdt-sync-T7MHVQCS.js +33 -0
  217. package/dist/crm-bridge-Q5JBVJ6P.js +19 -0
  218. package/dist/crm-webhook-OAFTLJYA.js +10 -0
  219. package/dist/cto-delegation-gate-XWHZCUJH.js +208 -0
  220. package/dist/daemon-auth-GWUXTUYO.js +15 -0
  221. package/dist/daemon-orchestration-2C3TVOHO.js +91 -0
  222. package/dist/daemon-protocol-RLH2XM2K.js +19 -0
  223. package/dist/db-backup-CH2KG3JY.js +23 -0
  224. package/dist/devtools-PLJCAU53.js +8 -0
  225. package/dist/discord-G4BQJ2VX.js +7 -0
  226. package/dist/email-XMRNMFXR.js +137 -0
  227. package/dist/entity-boost-IOER4VRR.js +249 -0
  228. package/dist/exe-drift-2IJFQV43.js +68 -0
  229. package/dist/exe-export-Y2RFXGNB.js +71 -0
  230. package/dist/exe-import-LN6PE2YT.js +74 -0
  231. package/dist/exe-key-DHKBWLIT.js +571 -0
  232. package/dist/exe-org-F7LZRHFB.js +73 -0
  233. package/dist/factory-YTD23AW7.js +67 -0
  234. package/dist/fast-db-init-IIP6EGWT.js +7 -0
  235. package/dist/file-edit-FJVEO7XZ.js +8 -0
  236. package/dist/file-read-Q2NH3J35.js +8 -0
  237. package/dist/file-write-UNSFXNH4.js +8 -0
  238. package/dist/gateway/index.js +87 -16563
  239. package/dist/gateway-client-APTYJNCL.js +11 -0
  240. package/dist/git-staleness-I2BUEDE2.js +111 -0
  241. package/dist/git-task-sweep-UEOTXRW4.js +35 -0
  242. package/dist/glob-GRMXLDMB.js +7 -0
  243. package/dist/global-procedures-MFE5LGRF.js +19 -0
  244. package/dist/graph-query-657O5JYJ.js +25 -0
  245. package/dist/graph-rag-ZE5N7C65.js +28 -0
  246. package/dist/grep-NBV6SKYZ.js +7 -0
  247. package/dist/hooks/bug-report-worker.js +41 -10823
  248. package/dist/hooks/codex-stop-task-finalizer.js +38 -9055
  249. package/dist/hooks/commit-complete.js +32 -10914
  250. package/dist/hooks/error-recall.js +35 -7955
  251. package/dist/hooks/exe-heartbeat-hook.js +17 -327
  252. package/dist/hooks/ingest-worker.js +16 -565
  253. package/dist/hooks/ingest.js +98 -11436
  254. package/dist/hooks/instructions-loaded.js +25 -6209
  255. package/dist/hooks/notification.js +16 -6098
  256. package/dist/hooks/post-compact.js +34 -7041
  257. package/dist/hooks/post-tool-combined.js +27 -9751
  258. package/dist/hooks/pre-compact.js +38 -11130
  259. package/dist/hooks/pre-tool-use.js +61 -7233
  260. package/dist/hooks/prompt-submit.js +113 -13358
  261. package/dist/hooks/session-end.js +57 -11503
  262. package/dist/hooks/session-start.js +46 -9423
  263. package/dist/hooks/stop.js +70 -7210
  264. package/dist/hooks/subagent-stop.js +33 -6897
  265. package/dist/hooks/summary-worker.js +86 -8629
  266. package/dist/hooks-KD3N2D7P.js +9 -0
  267. package/dist/imessage-L7WKA2WD.js +7 -0
  268. package/dist/index.js +49 -19391
  269. package/dist/installer-5N24GXFB.js +32 -0
  270. package/dist/installer-QSD76YRY.js +291 -0
  271. package/dist/installer-ZPQUKHU5.js +331 -0
  272. package/dist/intercom-queue-PEEGAJ33.js +19 -0
  273. package/dist/key-backup-status-57UB74DU.js +41 -0
  274. package/dist/lib/agent-config.js +19 -224
  275. package/dist/lib/cloud-sync.js +44 -5398
  276. package/dist/lib/cloudflare-dns.js +7 -111
  277. package/dist/lib/config.js +18 -278
  278. package/dist/lib/consolidation.js +21 -1047
  279. package/dist/lib/crypto.js +7 -45
  280. package/dist/lib/database.js +20 -2932
  281. package/dist/lib/db-daemon-client.js +24 -460
  282. package/dist/lib/db.js +22 -2932
  283. package/dist/lib/device-registry.js +20 -2992
  284. package/dist/lib/embedder.js +14 -822
  285. package/dist/lib/employee-templates.js +21 -1102
  286. package/dist/lib/employees.js +30 -497
  287. package/dist/lib/error-detector.js +9 -149
  288. package/dist/lib/exe-daemon-client.js +16 -570
  289. package/dist/lib/exe-daemon.js +509 -18398
  290. package/dist/lib/file-grep.js +2 -0
  291. package/dist/lib/hybrid-search.js +18 -7674
  292. package/dist/lib/identity-templates.js +2 -0
  293. package/dist/lib/identity.js +13 -309
  294. package/dist/lib/keychain.js +9 -499
  295. package/dist/lib/license.js +21 -549
  296. package/dist/lib/messaging.js +35 -1631
  297. package/dist/lib/post-tool-memory.js +8 -370
  298. package/dist/lib/registry-proxy.js +8 -155
  299. package/dist/lib/reminders.js +11 -231
  300. package/dist/lib/runtime-table.js +7 -20
  301. package/dist/lib/schedules.js +16 -4614
  302. package/dist/lib/session-registry.js +9 -57
  303. package/dist/lib/session-wrappers.js +3 -127
  304. package/dist/lib/skill-learning.js +20 -2101
  305. package/dist/lib/status-brief.js +4 -368
  306. package/dist/lib/store.js +25 -5593
  307. package/dist/lib/task-router.js +12 -254
  308. package/dist/lib/tasks.js +44 -5801
  309. package/dist/lib/tmux-routing.js +45 -5804
  310. package/dist/lib/tmux-status.js +16 -248
  311. package/dist/lib/tmux-transport.js +6 -90
  312. package/dist/lib/token-spend.js +9 -337
  313. package/dist/lib/transport.js +8 -134
  314. package/dist/lib/ws-auth.js +6 -14
  315. package/dist/lib/ws-client.js +4 -22
  316. package/dist/license-gate-NXXDOOAQ.js +14 -0
  317. package/dist/mcp/register-tools.js +90 -32454
  318. package/dist/mcp/server.js +139 -32625
  319. package/dist/mcp/tools/complete-reminder.js +10 -237
  320. package/dist/mcp/tools/create-reminder.js +10 -222
  321. package/dist/mcp/tools/create-task.js +28 -6730
  322. package/dist/mcp/tools/deactivate-behavior.js +13 -476
  323. package/dist/mcp/tools/list-reminders.js +10 -232
  324. package/dist/mcp/tools/list-tasks.js +28 -1571
  325. package/dist/mcp/tools/send-message.js +25 -1672
  326. package/dist/mcp/tools/update-task.js +27 -6123
  327. package/dist/mcp-diagnostics-OOZ3TDPY.js +200 -0
  328. package/dist/memory-cards-RIL5BZHK.js +175 -0
  329. package/dist/memory-queue-JYIJ7TMQ.js +13 -0
  330. package/dist/memory-queue-client-PE7757HU.js +14 -0
  331. package/dist/notifications-CJFULBMN.js +42 -0
  332. package/dist/orchestration-phase-Y2TYNW5H.js +23 -0
  333. package/dist/orchestrator-RXIPT6PZ.js +29 -0
  334. package/dist/permission-presets-WI524OSE.js +25 -0
  335. package/dist/permissions-TYT6YMNZ.js +14 -0
  336. package/dist/pg-ssl-KFHNJPGO.js +7 -0
  337. package/dist/plan-limits-5WY5YK6X.js +27 -0
  338. package/dist/preferences-MW3BYTQ5.js +10 -0
  339. package/dist/project-name-PL2ZDWNU.js +11 -0
  340. package/dist/projection-worker-OY4WYZW6.js +661 -0
  341. package/dist/reranker-LFJ73RRS.js +19 -0
  342. package/dist/review-gate-E6K7QQE5.js +120 -0
  343. package/dist/runtime/index.js +82 -13408
  344. package/dist/self-query-router-IZANO632.js +83 -0
  345. package/dist/session-events-TQ6S5KQN.js +32 -0
  346. package/dist/session-kill-telemetry-46YIJWE2.js +30 -0
  347. package/dist/session-scope-3MYK3YRV.js +34 -0
  348. package/dist/setup-wizard-ZJ7UCRBP.js +12 -0
  349. package/dist/shard-manager-RCFZ6RXY.js +29 -0
  350. package/dist/signal-XN2C7PIG.js +7 -0
  351. package/dist/slack-Z77TFJCK.js +7 -0
  352. package/dist/task-enforcement-337DZI3I.js +252 -0
  353. package/dist/task-scanner-IMIR3T7T.js +11 -0
  354. package/dist/task-scope-MUU4KXE6.js +32 -0
  355. package/dist/tasks-crud-PMLK3MM4.js +53 -0
  356. package/dist/tasks-review-56LVKKNL.js +44 -0
  357. package/dist/telegram-CRPZO7JT.js +7 -0
  358. package/dist/telemetry-SPVGPKU7.js +9 -0
  359. package/dist/tool-capability-index-XNBSDCH3.js +10 -0
  360. package/dist/tool-gates-LGH6CSY4.js +14 -0
  361. package/dist/tool-gates-W7SZCYTX.js +13 -0
  362. package/dist/tool-registry-436LVVLY.js +11 -0
  363. package/dist/tool-telemetry-L77WNAYT.js +15 -0
  364. package/dist/tui/App.js +253 -14668
  365. package/dist/tui-data-SB45REYU.js +161 -0
  366. package/dist/update-check-LZGZISRJ.js +11 -0
  367. package/dist/webhook-VVP7KQVC.js +96 -0
  368. package/dist/whatsapp-J6QNDBGY.js +9 -0
  369. package/dist/whatsapp-accounts-RTJF3LM6.js +15 -0
  370. package/dist/wiki-client-EKCIKCVC.js +136 -0
  371. package/dist/worker-gate-UYNN62GJ.js +19 -0
  372. package/dist/worktree-4T4BPWPN.js +205 -0
  373. package/package.json +1 -1
@@ -0,0 +1,148 @@
1
+ import {
2
+ getClient,
3
+ init_database,
4
+ isInitialized
5
+ } from "./chunk-A2NZP64U.js";
6
+ import {
7
+ EMPLOYEES_PATH,
8
+ init_employees,
9
+ loadEmployees
10
+ } from "./chunk-RUG3N6P4.js";
11
+ import {
12
+ PLAN_LIMITS,
13
+ checkLicense,
14
+ init_license,
15
+ isFeatureAllowed
16
+ } from "./chunk-IRQTM7DY.js";
17
+ import {
18
+ EXE_AI_DIR,
19
+ init_config
20
+ } from "./chunk-KVPG5UT6.js";
21
+ import {
22
+ __esm
23
+ } from "./chunk-KFQGP6VL.js";
24
+
25
+ // src/lib/plan-limits.ts
26
+ import { readFileSync, existsSync } from "fs";
27
+ import path from "path";
28
+ function getLicenseSync() {
29
+ try {
30
+ if (!existsSync(CACHE_PATH)) return freeLicense();
31
+ const raw = JSON.parse(readFileSync(CACHE_PATH, "utf8"));
32
+ if (!raw.token || typeof raw.token !== "string") return freeLicense();
33
+ const parts = raw.token.split(".");
34
+ if (parts.length !== 3) return freeLicense();
35
+ const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString());
36
+ const plan = payload.plan ?? "free";
37
+ const limits = PLAN_LIMITS[plan] ?? PLAN_LIMITS.free;
38
+ return {
39
+ valid: true,
40
+ plan,
41
+ email: payload.sub ?? "",
42
+ expiresAt: payload.exp ? new Date(payload.exp * 1e3).toISOString() : null,
43
+ deviceLimit: limits.devices,
44
+ employeeLimit: limits.employees,
45
+ memoryLimit: limits.memories
46
+ };
47
+ } catch {
48
+ return freeLicense();
49
+ }
50
+ }
51
+ function freeLicense() {
52
+ const limits = PLAN_LIMITS.free;
53
+ return {
54
+ valid: true,
55
+ plan: "free",
56
+ email: "",
57
+ expiresAt: null,
58
+ deviceLimit: limits.devices,
59
+ employeeLimit: limits.employees,
60
+ memoryLimit: limits.memories
61
+ };
62
+ }
63
+ async function countActiveMemories() {
64
+ if (!isInitialized()) return 0;
65
+ const client = getClient();
66
+ const result = await client.execute(
67
+ "SELECT COUNT(*) as cnt FROM memories WHERE status = 'active' OR status IS NULL"
68
+ );
69
+ const row = result.rows[0];
70
+ return Number(row?.cnt ?? 0);
71
+ }
72
+ async function assertMemoryLimit() {
73
+ const license = await checkLicense();
74
+ if (license.memoryLimit < 0) return;
75
+ const count = await countActiveMemories();
76
+ if (count >= license.memoryLimit) {
77
+ throw new PlanLimitError(
78
+ `Memory limit reached: ${count}/${license.memoryLimit} active memories on the ${license.plan} plan. Upgrade at https://askexe.com to store more.`
79
+ );
80
+ }
81
+ }
82
+ async function assertEmployeeLimit(license, rosterPath) {
83
+ const lic = license ?? await checkLicense();
84
+ if (lic.employeeLimit < 0) return;
85
+ const employees = await loadEmployees(rosterPath ?? EMPLOYEES_PATH);
86
+ if (employees.length >= lic.employeeLimit) {
87
+ throw new PlanLimitError(
88
+ `Employee limit reached: ${employees.length}/${lic.employeeLimit} employees on the ${lic.plan} plan. Upgrade at https://askexe.com to add more.`
89
+ );
90
+ }
91
+ }
92
+ function assertEmployeeLimitSync(rosterPath) {
93
+ const license = getLicenseSync();
94
+ if (license.employeeLimit < 0) return;
95
+ const filePath = rosterPath ?? EMPLOYEES_PATH;
96
+ let count = 0;
97
+ try {
98
+ if (existsSync(filePath)) {
99
+ const raw = readFileSync(filePath, "utf8");
100
+ const employees = JSON.parse(raw);
101
+ count = Array.isArray(employees) ? employees.length : 0;
102
+ }
103
+ } catch {
104
+ throw new PlanLimitError(
105
+ `Cannot verify employee count: roster unreadable at ${filePath}. Refusing to proceed. Check file permissions or upgrade plan.`
106
+ );
107
+ }
108
+ if (count >= license.employeeLimit) {
109
+ throw new PlanLimitError(
110
+ `Employee limit reached: ${count}/${license.employeeLimit} employees on the ${license.plan} plan. Upgrade at https://askexe.com to add more.`
111
+ );
112
+ }
113
+ }
114
+ async function assertFeature(feature) {
115
+ const license = await checkLicense();
116
+ if (!isFeatureAllowed(license, feature)) {
117
+ throw new PlanLimitError(
118
+ `Feature "${feature}" requires a paid plan. Current plan: ${license.plan}. Upgrade at https://askexe.com.`
119
+ );
120
+ }
121
+ }
122
+ var PlanLimitError, CACHE_PATH;
123
+ var init_plan_limits = __esm({
124
+ "src/lib/plan-limits.ts"() {
125
+ init_database();
126
+ init_employees();
127
+ init_license();
128
+ init_config();
129
+ PlanLimitError = class extends Error {
130
+ constructor(message) {
131
+ super(message);
132
+ this.name = "PlanLimitError";
133
+ }
134
+ };
135
+ CACHE_PATH = path.join(EXE_AI_DIR, "license-cache.json");
136
+ }
137
+ });
138
+
139
+ export {
140
+ PlanLimitError,
141
+ getLicenseSync,
142
+ countActiveMemories,
143
+ assertMemoryLimit,
144
+ assertEmployeeLimit,
145
+ assertEmployeeLimitSync,
146
+ assertFeature,
147
+ init_plan_limits
148
+ };
@@ -0,0 +1,302 @@
1
+ // src/lib/platform-procedures.ts
2
+ var PLATFORM_PROCEDURES = [
3
+ // --- Foundation: what is exe-os ---
4
+ {
5
+ title: "What is exe-os \u2014 the operating model every agent must understand",
6
+ domain: "architecture",
7
+ priority: "p0",
8
+ content: "Exe OS is an AI employee operating system. A founder runs 5-10 AI agents as a real org: COO, CTO, CMO, engineers, and content production specialists. Each agent has identity, expertise, and experience layers \u2014 persistent memory that makes them better over time. All data is local-first, E2EE, owned by the user. The MCP server is the ONLY data interface \u2014 never access the DB directly."
9
+ },
10
+ {
11
+ title: "Mode 1 \u2014 how exe-os runs inside Claude Code",
12
+ domain: "architecture",
13
+ priority: "p0",
14
+ content: "Mode 1: exe-os runs AS hooks + MCP + skills inside Claude Code, Codex, or OpenCode. The founder picks their default tool at setup. The COO manages employees in tmux sessions. Each coordinator session is a separate window/project. Employees run in their own tmux panes via create_task auto-spawn. The founder talks to the COO; the COO orchestrates the team. The tool is the shell, exe-os is the brain."
15
+ },
16
+ {
17
+ title: "Sessions explained \u2014 coordinator session names and projects",
18
+ domain: "architecture",
19
+ priority: "p0",
20
+ content: "Each coordinator session is an isolated project session. One might be exe-os development, another might be exe-wiki. Each session spawns its own employees using {employee}-{coordinatorSession}. Sessions share the same memory DB but tasks are scoped to the session that created them. A founder can run multiple projects simultaneously. Sessions never interfere with each other."
21
+ },
22
+ {
23
+ title: "Runtime settings \u2014 COO can view and change tools per agent",
24
+ domain: "workflow",
25
+ priority: "p1",
26
+ content: "exe-os supports three tools: Claude Code (Anthropic), Codex (OpenAI), and OpenCode (open source, 75+ providers). Each agent can use a different tool and model. COO uses set_agent_config MCP tool to view or change settings. Call with no args to show all agents. Call with agent_id + runtime + model to change. Users can also run `exe-os settings` from terminal for interactive arrow-key selection."
27
+ },
28
+ // --- Updates and deployment ---
29
+ {
30
+ title: "How to update exe-os \u2014 CLI update + stack update (two steps)",
31
+ domain: "operations",
32
+ priority: "p0",
33
+ content: 'Updating exe-os is a two-step process. Step 1 \u2014 update the CLI: `npm install -g @askexenow/exe-os@latest` (gets bug fixes, new platform procedures, new tools). Step 2 \u2014 update the VPS stack (if applicable): `exe-os stack-update --target <version> --yes` (pulls new Docker images for exed, wiki, CRM, gateway). Step 1 MUST happen before Step 2 \u2014 the stack-update command itself may have bug fixes. After updating, restart the daemon: the deploy script handles this automatically. Check update availability: `exe-os update --check` or config(action="check_update"). Agents should NEVER run npm install or stack-update autonomously \u2014 always confirm with the user first.'
34
+ },
35
+ {
36
+ title: "First install \u2014 setup wizard and license activation",
37
+ domain: "operations",
38
+ priority: "p1",
39
+ content: "Fresh install: `npm install -g @askexenow/exe-os` then run `exe` to start the setup wizard. The wizard prompts for: encryption passphrase (creates master key), license key (exe_sk_* from AskExe team), COO name, and optional team members. No license key = free tier (1 employee, 5K memories). After setup: hooks install automatically, MCP server registers in ~/.claude.json, daemon starts. Verify health: run `exe-os healthcheck` or use mcp_ping() tool."
40
+ },
41
+ // --- Hierarchy and dispatch ---
42
+ {
43
+ title: "Chain of command \u2014 who talks to whom",
44
+ domain: "workflow",
45
+ priority: "p0",
46
+ content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
47
+ },
48
+ {
49
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
50
+ domain: "workflow",
51
+ priority: "p1",
52
+ content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
53
+ },
54
+ {
55
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
56
+ domain: "identity",
57
+ priority: "p0",
58
+ content: "These procedures reference 'COO' as a shorthand for the coordinator role. This is an INTERNAL routing slot used by exe-os code (chain-of-command checks, dispatch logic, session detection). It is NOT your display title. Your actual title comes from your identity file's `title:` field \u2014 that is what you use externally: introductions, sign-offs, team comms, and any user-facing text. If your identity says `title: AI Chief of Staff`, you are the AI Chief of Staff. The internal routing slot stays unchanged for code compatibility \u2014 never rename it, but also never introduce yourself as 'COO' unless your identity file explicitly says so. The founder chose your title; respect it."
59
+ },
60
+ {
61
+ title: "Single dispatch path \u2014 create_task only",
62
+ domain: "workflow",
63
+ priority: "p0",
64
+ content: "create_task is the ONLY way to dispatch work to another agent. No direct ensureEmployee calls, no manual tmux spawns, no send_message for actionable work. create_task \u2192 system auto-spawns \u2192 session correctly named. ONE PATH. No backdoors. No exceptions."
65
+ },
66
+ // --- Session isolation ---
67
+ {
68
+ title: "Session scoping \u2014 stay in your coordinator boundary",
69
+ domain: "security",
70
+ priority: "p0",
71
+ content: "Session scoping is mandatory. Managers dispatch to workers within their own coordinator session ONLY. Employee sessions use {employee}-{coordinatorSession}. Cross-session dispatch is blocked by the system. Verify session names before dispatch. Tasks are scoped to the creating coordinator session."
72
+ },
73
+ {
74
+ title: "Session isolation \u2014 never touch another session's work",
75
+ domain: "workflow",
76
+ priority: "p0",
77
+ content: "Sessions are isolated. A coordinator session owns ONLY tasks it dispatched. (1) Never close/update/cancel tasks from another coordinator session. (2) Never review work from a different session \u2014 report that it belongs to another session and skip. (3) Ignore other sessions' items in list_tasks results. (4) Employees inherit session: employee sessions work ONLY on their parent coordinator session's tasks. Cross-session work is a system violation."
78
+ },
79
+ // --- Engineering: session scoping in code ---
80
+ {
81
+ title: "Three-dimensional scoping \u2014 session, project, role \u2014 enforced in every query",
82
+ domain: "architecture",
83
+ priority: "p0",
84
+ content: "Every DB query, notification, review count, and task operation MUST be scoped on 3 dimensions: (1) Session \u2014 filter by session_scope matching the current coordinator session. (2) Project \u2014 filter by project_name. (3) Role \u2014 agents only see data at their hierarchy level. When writing ANY function that touches tasks, reviews, messages, or notifications: always accept a sessionScope parameter and pass it to the SQL WHERE clause. Unscoped queries are bugs. Test by running 2+ coordinator sessions simultaneously."
85
+ },
86
+ // --- Hard constraints ---
87
+ {
88
+ title: "What you CANNOT do in exe-os \u2014 hard constraints",
89
+ domain: "security",
90
+ priority: "p0",
91
+ content: "NEVER: (1) Access the database directly \u2014 it's SQLCipher encrypted, always fails. Use MCP tools only. (2) Manually spawn tmux sessions \u2014 create_task handles it. (3) Run git checkout main \u2014 agents work in worktrees. (4) Modify another agent's in-progress task. (5) Push to remote \u2014 the COO reviews and pushes. (6) Skip update_task(done) \u2014 it's the ONLY way your work gets reviewed. (7) Run git init."
92
+ },
93
+ {
94
+ title: "Destructive operations \u2014 mandatory reviewer gate",
95
+ domain: "security",
96
+ priority: "p0",
97
+ content: "Before ANY destructive operation (delete, remove, overwrite, drop, reset, force-push, truncate), you MUST: (1) Have your full task spec accessible \u2014 if you cannot read it, STOP and report to your reviewer. Never improvise destructive actions. (2) Confirm with your reviewer (assigned_by or COO) before executing. (3) If the task spec explicitly authorizes the operation, proceed \u2014 but log it. Violation = immediate task failure. This applies to ALL agents regardless of role."
98
+ },
99
+ {
100
+ title: "Customer patch triage \u2014 upstream bug vs customization",
101
+ domain: "support",
102
+ priority: "p0",
103
+ content: "When an agent encounters a suspected Exe OS bug, update breakage, MCP/tool failure, installer issue, memory/orchestration defect, or customer-local patch need, it MUST use create_bug_report. Do this before or alongside any local workaround so the report reaches AskExe support directly via the customer's license. Do NOT ask the founder for permission to file a required bug report. If create_bug_report is deferred/lazy-loaded, load it and call it. If it is unavailable in the live MCP surface, report 'create_bug_report unavailable in this session' and save a local report in exe/output \u2014 never claim the tool does not exist unless the live MCP surface was checked. If upstream delivery fails, call support_test (MCP) and include its result in the local report so AskExe can distinguish customer setup, license provisioning, and server intake issues; only ask the founder to run `exe-os support test` if MCP is disconnected/unavailable. Classify first: upstream_bug = reproducible exe-os/platform defect; customer_customization = identity, behavior, procedure, config, branding, workflow preference that belongs in customer-owned layers; emergency_hotfix = temporary local patch. For upstream bugs/emergency hotfixes include version, repro steps, expected/actual, files changed, workaround, and local diff summary. Avoid permanent platform-code patches unless founder approves; if a hotfix is unavoidable, document it in the bug report and re-check after npm update."
104
+ },
105
+ {
106
+ title: "Bug report status check \u2014 surface available fixes on boot",
107
+ domain: "support",
108
+ priority: "p1",
109
+ content: "Once per session (COO boot only, never repeat), call support(action='list_my_bugs') to check if any previously filed bug reports have been fixed by AskExe. If any report has status 'closed' with a fixed_version, surface it to the founder immediately: '\u{1F527} N bug fix(es) available \u2014 run exe-os update to get version X.Y.Z'. You can also file new bugs with support(action='create_bug') and check status anytime with support(action='list_my_bugs'). This boot check is one-time, not a recurring poll. If the tool is unavailable, skip silently."
110
+ },
111
+ {
112
+ title: "Feature request triage \u2014 upstream feature vs local customization",
113
+ domain: "support",
114
+ priority: "p0",
115
+ content: "When an agent or founder identifies a desired capability that exe-os does not yet provide, the COO (or equivalent coordinator) must decide: is this a local customization (identity, behavior, procedure, config, branding, workflow preference that can be configured in customer-owned layers) or an upstream feature request (a platform capability that requires changes to exe-os code, shipped via npm update)? Local customizations: implement immediately using store_behavior, update_identity, company_procedure, or config changes. Upstream features: use create_feature_request to submit to AskExe. Include use case, business impact, and current workaround. Do NOT ask the founder for permission to file a feature request \u2014 file it proactively when the need is clear."
116
+ },
117
+ {
118
+ title: "Feature request status check \u2014 surface shipped features on boot",
119
+ domain: "support",
120
+ priority: "p1",
121
+ content: "Once per session (COO boot only, never repeat), call support(action='list_my_features') to check if any previously filed feature requests have been shipped by AskExe. If any request has status 'shipped' with a shipped_version, surface it to the founder immediately: '\u{1F680} N feature(s) shipped \u2014 run exe-os update to get version X.Y.Z'. You can also file new requests with support(action='create_feature') and check status anytime with support(action='list_my_features'). This boot check is one-time, not a recurring poll. If the tool is unavailable, skip silently."
122
+ },
123
+ // --- Tool guidance ---
124
+ {
125
+ title: "How to use company_actions \u2014 execute business actions through gateway connectors",
126
+ domain: "tools",
127
+ priority: "p2",
128
+ content: "The company_actions tool executes business actions through gateway connectors (e.g. send WhatsApp, trigger workflows, update CRM). It routes through the exe-gateway on the VPS. Actions are defined by the customer's gateway configuration \u2014 each connector (WhatsApp, Shopify, email, etc.) exposes specific actions. Use query_company_brain to find available data first, then company_actions to act on it. Requires gateway auth token. Read-only founders should NOT use this \u2014 it mutates external state."
129
+ },
130
+ // --- Release awareness ---
131
+ {
132
+ title: "What's New check \u2014 surface new features after update",
133
+ domain: "support",
134
+ priority: "p1",
135
+ content: "Once per session (COO boot only, never repeat), check if the installed exe-os version is newer than the last session. If it is, read the bundled release-notes.json (at the package root) and surface a brief summary to the founder: 'Updated to exe-os vX.Y.Z \u2014 N new features, M fixes.' List the top 3 features by name. This helps the founder know what they got from the update. If release-notes.json doesn't exist or the version hasn't changed, skip silently. Never repeat this check in the same session."
136
+ },
137
+ // --- Platform vs Customer ownership ---
138
+ {
139
+ title: "What the platform provides vs what you customize",
140
+ domain: "architecture",
141
+ priority: "p0",
142
+ content: "Exe OS has two layers. PLATFORM layer (shipped in code, updated via npm): platform procedures, default identity templates, MCP tools, tool gating, schema migrations, daemon behavior. You get improvements automatically on update. CUSTOMER layer (yours, stored locally): agent identities (exe.md files), behaviors, company procedures, config.json, wiki content, CRM data, memory. These are NEVER overwritten by updates. Identity templates are stamped once at /exe-new-employee \u2014 after that the file is yours. If the platform ships a better template, you can compare yours against the default with getTemplate() and merge what you want. Company procedures (company_procedure tool) layer ON TOP of platform procedures \u2014 both are injected, platform first. FIVE LAYERS \u2014 know when to use each: (1) Platform procedures: how exe-os works, shipped to ALL customers, updated via npm. Never put org-specific rules here. (2) Company procedures: your org's workflow rules, stored in DB, injected after platform. Use for internal gates, review checklists, org-specific policies. (3) Identity (exe.md): an agent's permanent role definition \u2014 who they are, what they own, non-negotiable rules. Use for rules that must NEVER be forgotten across sessions. (4) Behaviors: corrections and learned patterns (Layer 2 expertise). Use for 'from now on do X' or 'never do Y again' \u2014 scoped per agent per project, deactivatable. (5) Memory: facts, decisions, context (Layer 3 experience). Use for what happened, what was decided, project state. Searchable, consolidatable. Rule of thumb: platform procedures for product behavior, company procedures for org workflow, identity for permanent role rules, behaviors for per-agent per-project corrections, memory for facts. Behaviors are always yours. Config is always yours. The platform will never modify your local data."
143
+ },
144
+ // --- Updates ---
145
+ {
146
+ title: "How to update exe-os \u2014 CLI first, then stack",
147
+ domain: "operations",
148
+ priority: "p0",
149
+ content: "When bug fixes or features are available (surfaced at boot via list_my_bug_reports/list_my_feature_requests), update in two steps: (1) CLI: `npm install -g @askexenow/exe-os@latest` \u2014 this updates the local tools, MCP server, and bundled stack manifest. Must happen first so the stack-update tool itself has the latest fixes. (2) Stack (VPS only): `exe-os stack-update --target <version> --yes` \u2014 pulls new Docker images and restarts services. The target version comes from the stack manifest bundled with the CLI. Always update CLI before stack. Use `exe-os update --check` to see if a CLI update is available. Use `exe-os stack-update --check` to see stack status. For non-interactive/SSH: use `--yes` or `-y` flag. Never run `npm install -g` inside a tmux agent session \u2014 have the founder or COO do it from the host shell. If stack-update fails with EACCES on /opt/exe-stack, run: `sudo mkdir -p /opt/exe-stack && sudo chown $(whoami) /opt/exe-stack` then retry."
150
+ },
151
+ {
152
+ title: "CLI version vs stack version \u2014 two tracks, both normal",
153
+ domain: "operations",
154
+ priority: "p0",
155
+ content: "exe-os has TWO version numbers that move independently. This is normal \u2014 do not treat a mismatch as an error. (1) CLI version (e.g. 0.9.89, 0.9.90) \u2014 the npm package installed locally. Updates frequently: bug fixes, new MCP tools, platform procedures, search improvements, client-side changes. Update with `npm install -g @askexenow/exe-os@latest`. (2) Stack version (e.g. 0.9.7, 0.9.8) \u2014 the Docker images on the VPS. Updates less frequently: only when server-side daemon, gateway, wiki, or CRM images need rebuilding. Update with `exe-os stack-update --target <version> --yes`. The CLI version will almost always be higher than the stack version. A CLI at 0.9.90 with a stack at 0.9.8 is perfectly normal \u2014 it means the CLI got 12 patches since the last Docker image rebuild. Only update the stack when: (a) the boot brief surfaces a fix that mentions 'stack update required', (b) a new stack manifest version is bundled in the CLI (`exe-os stack-update --check` shows pending changes), or (c) AskExe support explicitly tells you to. Do NOT attempt to make the numbers match \u2014 they are separate tracks."
156
+ },
157
+ {
158
+ title: "Update lifecycle \u2014 what each command does and what picks up new code",
159
+ domain: "operations",
160
+ priority: "p0",
161
+ content: "Three update paths exist \u2014 know which does what. (1) `npm install -g @askexenow/exe-os@latest` \u2014 customer update. Replaces all dist/ files. postinstall copies slash commands AND restarts the daemon automatically. MCP server picks up new code on next `/mcp` reconnect or new Claude Code session. Hooks pick up new code on next session (they spawn fresh processes). (2) `exe-os update` \u2014 interactive update command. Runs `npm install -g` then `install --global` which restarts daemon, regenerates session wrappers, normalizes roster, registers Codex hooks. This is the recommended customer path. (3) `npm run deploy` \u2014 dev-only (COO/CTO on main branch). Builds, installs globally, runs `install --global`, restarts daemon. Never run from a worktree. NEVER confuse `exe-os setup` (first-time setup wizard for new installs) with `exe-os update` (update existing install). Setup creates encryption keys, configures cloud, runs first sync. Update just replaces code and restarts services. They are completely different commands."
162
+ },
163
+ {
164
+ title: "First install \u2014 setup wizard and license activation",
165
+ domain: "operations",
166
+ priority: "p1",
167
+ content: "Fresh install: `npm install -g @askexenow/exe-os` then run `exe` to start the setup wizard. The wizard prompts for: encryption passphrase (creates master key), license key (exe_sk_* from AskExe team), COO name, and optional team members. No license key = free tier (1 employee, 5K memories). After setup: hooks install automatically, MCP server registers in ~/.claude.json, daemon starts. Verify health: run `exe-os healthcheck` or use mcp_ping() tool."
168
+ },
169
+ // --- Operations ---
170
+ {
171
+ title: "Managers must supervise deployed workers",
172
+ domain: "workflow",
173
+ priority: "p0",
174
+ content: `Every manager (COO/CTO/CMO) who dispatches work to a worker MUST actively monitor them. Check tmux capture-pane every 10 minutes. Verify they're working, not stuck. If idle at prompt with in_progress task \u2192 send intercom. If stuck \u2192 unblock or escalate. "Standing by" without checking is negligence.`
175
+ },
176
+ {
177
+ title: "COO boot health check \u2014 memory, cloud sync, daemon on every launch",
178
+ domain: "workflow",
179
+ priority: "p0",
180
+ content: "On every /exe boot, COO MUST check system health BEFORE other work: (1) daemon \u2014 is exed PID alive, (2) cloud sync \u2014 grep workers.log for recent cloud-sync errors, (3) memory count \u2014 total in DB, (4) sync delta \u2014 local vs cloud storage_bytes. Report as 4-line status table. If ANY check fails, surface to founder immediately. Do not proceed to tasks until health confirmed."
181
+ },
182
+ {
183
+ title: "exe-build-adv mandatory for 3+ files",
184
+ domain: "workflow",
185
+ priority: "p0",
186
+ content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
187
+ },
188
+ {
189
+ title: "Code context first for repository orientation",
190
+ domain: "workflow",
191
+ priority: "p1",
192
+ content: "Before broad repo exploration, symbol tracing, blast-radius review, or codebase Q&A, agents should use the consolidated code_context MCP tool instead of manual grep/read loops. Use action=index or stats to refresh/check the index; action=search with query, limit, offset, languages, paths, refresh_index for fresh multi-language code/doc search; action=trace for symbol imports/dependents; action=blast_radius for impact analysis before edits. CLI parity exists via exe-os code-context init|index|status|stats|search|doctor. Keep code_context separate from durable employee memory: promote only validated decisions, procedures, or lessons into store_memory/commit_memory."
193
+ },
194
+ {
195
+ title: "Commit discipline \u2014 never leave verified work floating",
196
+ domain: "workflow",
197
+ priority: "p1",
198
+ content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
199
+ },
200
+ {
201
+ title: "Desktop and TUI are the same product",
202
+ domain: "architecture",
203
+ priority: "p0",
204
+ content: "Desktop and TUI are the SAME product in different renderers. Same data contracts, same interactions, same acceptance criteria. Desktop tab specs in ARCHITECTURE.md ARE the TUI specs. When building TUI, cross-reference Desktop spec. Different tab names, identical behavior. Never treat them as separate products."
205
+ },
206
+ // --- Orchestration golden path ---
207
+ {
208
+ title: "Task lifecycle \u2014 the golden path every agent follows",
209
+ domain: "workflow",
210
+ priority: "p0",
211
+ content: "create_task is dispatch + delivery. Task lifecycle: open \u2192 in_progress (you start) \u2192 done (update_task when finished) \u2192 needs_review (reviewer nudged) \u2192 closed (COO only via close_task). DB is the reliable delivery \u2014 intercom is just a speedup nudge. If you finish a task, self-chain: check for next task immediately (step 7). Never wait for a nudge. Never say 'standing by.'"
212
+ },
213
+ {
214
+ title: "Review chain \u2014 managers must actively pull completed work, never wait for nudges",
215
+ domain: "workflow",
216
+ priority: "p0",
217
+ content: "When you dispatch work, you OWN the review. Check list_tasks(status='needs_review') on EVERY prompt \u2014 don't wait for intercom nudges (they're unreliable). When a task shows needs_review: (1) read the deliverable (git diff in worktree, exe/output/ files, or task result summary), (2) verify it works (tsc, build, run), (3) close_task if good or create a fix task if not. Reviews sitting >30 minutes is a pipeline stall. The whole chain: worker calls update_task(done) \u2192 system flags needs_review \u2192 manager pulls and verifies \u2192 close_task \u2192 COO reviews manager's work \u2192 merge to main. Every level actively pulls \u2014 nobody waits."
218
+ },
219
+ {
220
+ title: "Intercom is a speedup, not delivery \u2014 DB is the source of truth",
221
+ domain: "architecture",
222
+ priority: "p0",
223
+ content: "Tasks live in the DB. Intercom (tmux send-keys) is fire-and-forget \u2014 it may fail, get garbled, or arrive mid-work. Never rely on intercom for task delivery. The UserPromptSubmit hook checks the DB for new tasks on every prompt. Your operating procedures step 7 says check for next work. The daemon nudges idle agents as a speedup. If you have no tasks, you found them all."
224
+ },
225
+ // --- Encryption key + cloud sync ---
226
+ {
227
+ title: "Encryption key lives in Keychain, not on disk \u2014 never expose the recovery phrase",
228
+ domain: "security",
229
+ priority: "p0",
230
+ content: "The master encryption key is stored in macOS Keychain (Secure Enclave) or Linux secret-tool \u2014 NOT as a file. There is no ~/.exe-os/master.key on modern installs. If an older install had one, it was auto-migrated to Keychain and the file deleted. Device linking uses a 24-word BIP39 recovery phrase: Device 1 runs `exe-os cloud link --show-full` in their local Terminal to reveal it, Device 2 runs `exe-os cloud` and pastes the phrase to import the key into its own Keychain, then cloud sync pulls encrypted memories. NEVER display, log, or return the recovery phrase in agent output. MCP tools are hardened \u2014 they cannot reveal it. If the user needs the phrase, tell them: 'Run exe-os cloud link --show-full in your Terminal.' If searching for master.key returns nothing, that is CORRECT \u2014 the key is in Keychain."
231
+ },
232
+ {
233
+ title: "Cloud endpoint is cloud.askexe.com \u2014 not askexe.com/cloud",
234
+ domain: "architecture",
235
+ priority: "p1",
236
+ content: "All cloud API calls (auth, sync, licensing, device registry, WebSocket) go to https://cloud.askexe.com, NOT https://askexe.com/cloud. This is a Cloudflare Workers Custom Domain that bypasses the zone-level managed challenge on askexe.com. Datacenter IPs (Hetzner, AWS, etc.) get HTTP 403 on askexe.com due to Bot Fight Mode, but cloud.askexe.com routes directly to the Worker before WAF rules evaluate. If a customer reports 403/challenge errors on cloud sync: verify they are on the latest exe-os version (cloud.askexe.com endpoint). Fix: `npm install -g @askexenow/exe-os@latest`. The EXE_CLOUD_ENDPOINT env var can override the endpoint if needed."
237
+ },
238
+ // --- MCP is the ONLY data interface ---
239
+ {
240
+ title: "MCP disconnect \u2014 ask the user, never work around it",
241
+ domain: "workflow",
242
+ priority: "p0",
243
+ content: "If MCP tools are unavailable, disconnected, or returning connection errors: STOP. Tell the user clearly: 'MCP server is disconnected. Please run /mcp to reconnect.' Do NOT attempt workarounds \u2014 no raw Node imports, no direct DB access, no CLI hacks, no daemon socket calls. MCP is the ONLY data interface. Working around it wastes time, hits bundling issues, and bypasses the contract boundary. Ask once, wait, proceed when reconnected."
244
+ },
245
+ // --- MCP Tool Catalog (Layer 0 — every agent knows what tools exist) ---
246
+ {
247
+ title: "MCP tool dispatch \u2014 all tools use action parameter",
248
+ domain: "tool-use",
249
+ priority: "p0",
250
+ content: 'exe-os MCP tools use consolidated action-based dispatch by default (19 tools). Call domain tools with an action parameter: memory(action="recall"), task(action="create"), config(action="list_employees"), etc. Legacy mode (108 separate tools like recall_my_memory, create_task) is still available via EXE_MCP_TOOL_SURFACE=legacy but will be removed in a future version. If you see specific tool names, call them directly \u2014 both surfaces are identical. Consolidated is the default and recommended surface.'
251
+ },
252
+ {
253
+ title: "MCP tools \u2014 memory, decision, and search",
254
+ domain: "tool-use",
255
+ priority: "p1",
256
+ content: `memory(action="recall") / recall_my_memory: search memories (semantic + FTS). Params: as_of (bi-temporal \u2014 what did I know at time X?), kind (decision|procedure|observation|raw|conversation|behavior), retrieval_mode (all|decisions_only|procedures_only|operational|recent_high_value). memory(action="ask_team") / ask_team_memory: search a colleague's memories. memory(action="store") / store_memory: persist a memory. Params: kind, procedure_for (domain tag for procedures). memory(action="commit") / commit_memory: high-importance, survives consolidation. Requires summary. memory(action="search") / search_everything: unified search across memories, tasks, entities, conversations. memory(action="session_context") / get_session_context: temporal window. Requires session_id + target_timestamp. memory(action="get_by_id"): fetch one memory by UUID with full untruncated text. memory(action="consolidate") / consolidate_memories: merge duplicate/related memories. memory(action="cardinality") / get_memory_cardinality: count memories per agent. memory(action="supersede"): replace an old memory with a new version (old_id + new text). decision(action="store") / store_decision: record an architectural decision (domain, decision, rationale). decision(action="get") / get_decision: retrieve a past decision by domain or query.`
257
+ },
258
+ {
259
+ title: "MCP tools \u2014 task orchestration",
260
+ domain: "tool-use",
261
+ priority: "p1",
262
+ content: 'task(action="create") / create_task: dispatch work (title, assigned_to, context). The ONLY dispatch path. Auto-spawns session. Params: blocked_by (task ID for dependency), parent_task_id (subtask hierarchy), reviewer, complexity (routine|standard|complex|critical), budget_tokens (max token cap), budget_fallback_model, spawn_runtime (override runtime: claude|codex|opencode), spawn_model (override model). task(action="list") / list_tasks: query tasks by status, assignee, project. task(action="get") / get_task: fetch full task details by task_id. task(action="update") / update_task: change status (in_progress, done, blocked, cancelled) + result summary. task(action="close") / close_task: finalize a reviewed task (COO only). task(action="checkpoint") / checkpoint_task: save progress state for crash recovery. task(action="resume") / resume_employee: re-spawn an employee session for an existing task.'
263
+ },
264
+ {
265
+ title: "MCP tools \u2014 knowledge graph (GraphRAG)",
266
+ domain: "tool-use",
267
+ priority: "p1",
268
+ content: 'graph(action="query_relationships") / query_relationships: find connections between entities. graph(action="entity_neighbors") / get_entity_neighbors: explore direct connections. graph(action="hot_entities") / get_hot_entities: most-referenced entities. graph(action="stats") / get_graph_stats: entity/relationship counts. graph(action="export") / export_graph: export for visualization (output_path, format). graph(action="merge_entities") / merge_entities: deduplicate entities (source_id, target_id). graph(action="similar_trajectories") / find_similar_trajectories: match patterns to past solutions.'
269
+ },
270
+ {
271
+ title: "MCP tools \u2014 identity, behavior, and support",
272
+ domain: "tool-use",
273
+ priority: "p1",
274
+ content: `identity(action="get") / get_identity: read an agent's exe.md (Layer 1 identity). identity(action="update") / update_identity: write an agent's exe.md. Identity > behavior. behavior(action="store") / store_behavior: record a correction or pattern (Layer 2 expertise). behavior(action="list") / list_behaviors: view active behaviors. behavior(action="deactivate") / deactivate_behavior: soft-delete a stale behavior. support(action="create_bug"): file a bug report. Required: title, description, severity (p0-p3). Optional: steps_to_reproduce, expected_behavior, actual_behavior. Auto-delivers to AskExe support. support(action="create_feature"): file a feature request. Required: title, description. Optional: use_case (why you need it), proposed_solution (how it could work). Include business impact if possible \u2014 it helps prioritization. Both create_bug and create_feature accept a 'product' param to file for any AskExe product: exe-os (default), exe-create, exe-wiki, exe-gateway, exe-crm, exe-build. support(action="list_my_bugs"): check status of YOUR filed bug reports \u2014 see which are open, triaged, or fixed with version number. support(action="list_my_features"): check status of YOUR filed feature requests \u2014 see which are open, planned, shipped, or closed with response notes from AskExe. support(action="health"): verify support server is reachable. When a bug shows status='closed' with a fixed_version, tell the founder: 'Bug X fixed in vY \u2014 run exe-os update to get it.' When a feature shows status='shipped' with a shipped_version, tell the founder: 'Feature X shipped in vY \u2014 run exe-os update.' support(action="triage_bug"): AskExe-internal only. CRITICAL: triage uses triage_notes NOT notes.`
275
+ },
276
+ {
277
+ title: "MCP tools \u2014 communication and messaging",
278
+ domain: "tool-use",
279
+ priority: "p1",
280
+ content: 'message(action="send") / send_message: send context to another agent (NOT for actionable work \u2014 use task). message(action="acknowledge") / acknowledge_messages: mark messages as read. reminder(action="create") / create_reminder: set a reminder (text, due_date). Shown in boot brief. reminder(action="list") / list_reminders: view pending reminders. reminder(action="complete") / complete_reminder: mark done (reminder_id). session(action="events") / get_session_events: view session event log (session_id). session(action="last_response") / get_last_assistant_response: get most recent response.'
281
+ },
282
+ {
283
+ title: "MCP tools \u2014 wiki, documents, CRM, and data",
284
+ domain: "tool-use",
285
+ priority: "p1",
286
+ content: 'wiki(action="list") / list_wiki_pages: list wiki pages (workspace). wiki(action="get") / get_wiki_page: read a wiki page (workspace, title or document_id). document(action="ingest") / ingest_document: import a file as memory chunks (workspace_id, filename, chunks). document(action="list") / list_documents: browse documents (workspace_id). document(action="purge") / purge_document: remove a document (document_id). document(action="set_importance") / set_document_importance: adjust chunk scores. document(action="rerank") / rerank_documents: re-score relevance (query, candidates). crm(action="list_people|get_person|list_tables|describe_table"): CRM records from exe-db. raw_data(action="list_sources|query|get"): read raw landing-pad events. gateway(action="send_whatsapp") / send_whatsapp: send WhatsApp message (recipients, message). gateway(action="query_conversations") / query_conversations: search conversations across channels. gateway(action="query_company_brain") / query_company_brain: unified RAG across company knowledge.'
287
+ },
288
+ {
289
+ title: "MCP tools \u2014 admin, config, and operations",
290
+ domain: "tool-use",
291
+ priority: "p1",
292
+ content: 'config(action="list_employees"): view roster. config(action="set_agent_config"): view or change per-agent runtime + model. Call with no args to show all agents. config(action="agent_spend"): token usage per agent. config(action="daemon_health"): check exed status. config(action="license_status"): check license. config(action="cloud_sync"): force sync. Supports cloud_action param: status|sync|reupload. config(action="memory_audit"): health check (dupes, null vectors). config(action="run_consolidation"): trigger memory consolidation. config(action="worker_gate"): check spawn slot availability \u2014 alive/stale/reserved counts vs max. Use before dispatching. config(action="auto_wake_status"): orphaned tasks, blocked tasks, auto-wake retry status. config(action="orchestration_phase"): view/change org phase (phase_1_coo|phase_2_executives|phase_3_parallel_org). config(action="company_procedure", subaction="store|list|deactivate"): manage company procedures. config(action="global_procedure"): list all procedures (platform + company). config(action="create_trigger|list_triggers"): scheduled agent jobs. config(action="export_orchestration|import_orchestration"): portable org state. diagnostics(action="healthcheck|doctor|status_brief|check_update|cloud_status"): system diagnostics. diagnostics(action="pending_work_summary"): pending reviews + messages + notifications in one call. diagnostics(action="rename_employee"): rename an agent across all systems (roster, identity, DB, symlinks). diagnostics(action="tool_search"): semantic tool discovery \u2014 find relevant MCP tools by natural language query. diagnostics(action="drift"): identity drift detection \u2014 score how far an agent has drifted from its role. mcp_ping(): daemon health + license status + tool usage stats.'
293
+ }
294
+ ];
295
+ var PLATFORM_PROCEDURE_TITLES = new Set(
296
+ PLATFORM_PROCEDURES.map((p) => p.title)
297
+ );
298
+
299
+ export {
300
+ PLATFORM_PROCEDURES,
301
+ PLATFORM_PROCEDURE_TITLES
302
+ };
@@ -0,0 +1,171 @@
1
+ import {
2
+ EXE_AI_DIR,
3
+ init_config
4
+ } from "./chunk-KVPG5UT6.js";
5
+
6
+ // src/lib/mcp-transport-health.ts
7
+ init_config();
8
+ import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "fs";
9
+ import path from "path";
10
+ import { fileURLToPath } from "url";
11
+ var MCP_HTTP_EVENTS_PATH = path.join(EXE_AI_DIR, "mcp-http-events.jsonl");
12
+ var MCP_MONITOR_DIR = path.join(EXE_AI_DIR, "monitor");
13
+ var MCP_TRANSPORT_SUMMARY_PATH = path.join(MCP_MONITOR_DIR, "mcp-transport-summary.json");
14
+ var DEFAULT_EVENT_READ_BYTES = 256 * 1024;
15
+ var DEFAULT_EVENT_MAX_BYTES = 1024 * 1024;
16
+ var EVENT_READ_BYTES = parsePositiveInt(process.env.EXE_MCP_HTTP_EVENT_READ_BYTES, DEFAULT_EVENT_READ_BYTES);
17
+ var EVENT_MAX_BYTES = parsePositiveInt(process.env.EXE_MCP_HTTP_EVENT_MAX_BYTES, DEFAULT_EVENT_MAX_BYTES);
18
+ function parsePositiveInt(value, fallback) {
19
+ if (!value) return fallback;
20
+ const parsed = Number.parseInt(value, 10);
21
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
22
+ }
23
+ function readTailText(filePath, maxBytes) {
24
+ const stats = statSync(filePath);
25
+ if (stats.size <= maxBytes) return readFileSync(filePath, "utf8");
26
+ const fd = openSync(filePath, "r");
27
+ try {
28
+ const buffer = Buffer.allocUnsafe(maxBytes);
29
+ readSync(fd, buffer, 0, maxBytes, stats.size - maxBytes);
30
+ const text = buffer.toString("utf8");
31
+ const firstNewline = text.indexOf("\n");
32
+ return firstNewline >= 0 ? text.slice(firstNewline + 1) : text;
33
+ } finally {
34
+ closeSync(fd);
35
+ }
36
+ }
37
+ function rotateMcpHttpEventLogIfNeeded() {
38
+ if (!existsSync(MCP_HTTP_EVENTS_PATH)) return;
39
+ const stats = statSync(MCP_HTTP_EVENTS_PATH);
40
+ if (stats.size <= EVENT_MAX_BYTES) return;
41
+ const keepBytes = Math.min(EVENT_READ_BYTES, EVENT_MAX_BYTES);
42
+ const tail = readTailText(MCP_HTTP_EVENTS_PATH, keepBytes);
43
+ writeFileSync(MCP_HTTP_EVENTS_PATH, tail, "utf8");
44
+ }
45
+ function readPackageVersion() {
46
+ let dir = path.dirname(fileURLToPath(import.meta.url));
47
+ const { root } = path.parse(dir);
48
+ while (dir !== root) {
49
+ const pkgPath = path.join(dir, "package.json");
50
+ if (existsSync(pkgPath)) {
51
+ try {
52
+ const parsed = JSON.parse(readFileSync(pkgPath, "utf8"));
53
+ return parsed.version ?? "unknown";
54
+ } catch {
55
+ return "unknown";
56
+ }
57
+ }
58
+ dir = path.dirname(dir);
59
+ }
60
+ return "unknown";
61
+ }
62
+ function inferMcpRuntime(input) {
63
+ const text = [input.runtimeHeader, input.userAgent, input.agentId, input.clientName].filter(Boolean).join(" ").toLowerCase();
64
+ if (text.includes("codex")) return "Codex";
65
+ if (text.includes("claude")) return "Claude";
66
+ if (text.includes("opencode") || text.includes("open-code")) return "OpenCode";
67
+ return "Unknown";
68
+ }
69
+ function getMcpToolFamily(toolName) {
70
+ if (!toolName) return "unknown";
71
+ if (/task|employee|review|checkpoint|resume/i.test(toolName)) return "task";
72
+ if (/memory|consolidat|document|search_everything|get_session_context/i.test(toolName)) return "memory";
73
+ if (/config|daemon|worker|auto_wake|license|trigger|starter|orchestration|cloud_sync|backup/i.test(toolName)) return "config";
74
+ if (/message|whatsapp|conversation|gateway/i.test(toolName)) return "gateway";
75
+ if (/wiki|crm|raw_data|person|people/i.test(toolName)) return "company-data";
76
+ if (/graph|entity|relationship|trajectory/i.test(toolName)) return "graph";
77
+ if (/identity|behavior|decision|procedure/i.test(toolName)) return "cognition";
78
+ if (/ping|health/i.test(toolName)) return "health";
79
+ return "other";
80
+ }
81
+ function parseMcpHttpEventLines(raw, limit = 200) {
82
+ const lines = raw.trim().split("\n").filter(Boolean).slice(-limit);
83
+ const events = [];
84
+ for (const line of lines) {
85
+ try {
86
+ events.push(JSON.parse(line));
87
+ } catch {
88
+ }
89
+ }
90
+ return events;
91
+ }
92
+ function readMcpHttpEvents(limit = 200) {
93
+ if (!existsSync(MCP_HTTP_EVENTS_PATH)) return [];
94
+ const raw = readTailText(MCP_HTTP_EVENTS_PATH, EVENT_READ_BYTES);
95
+ return parseMcpHttpEventLines(raw, limit);
96
+ }
97
+ function summarizeMcpTransport(events = readMcpHttpEvents()) {
98
+ const lastServerStartIndex = events.map((event) => event.message).lastIndexOf("server_started");
99
+ const scopedEvents = lastServerStartIndex >= 0 ? events.slice(lastServerStartIndex) : events;
100
+ const activeSessionEvent = [...scopedEvents].reverse().find((event) => typeof event.activeSessions === "number");
101
+ const successfulToolCalls = scopedEvents.filter((event) => event.message === "tool_call_ok");
102
+ const lastSuccessfulToolCall = successfulToolCalls.at(-1) ?? null;
103
+ const summary = {
104
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
105
+ version: readPackageVersion(),
106
+ scope: "local",
107
+ privacy: "metadata_only",
108
+ eventLogPath: MCP_HTTP_EVENTS_PATH,
109
+ activeSessions: activeSessionEvent?.activeSessions ?? null,
110
+ sessionsCreated: scopedEvents.filter((event) => event.message === "session_initialized").length,
111
+ sessionsClosed: scopedEvents.filter((event) => event.message === "session_closed").length,
112
+ missingSessionErrors: scopedEvents.filter((event) => event.message?.includes("missing MCP session")).length,
113
+ staleSessionErrors: scopedEvents.filter((event) => event.message?.includes("stale or unknown")).length,
114
+ transportErrors: scopedEvents.filter((event) => event.level === "warn" || event.level === "error").length,
115
+ lastSuccessfulHandshake: scopedEvents.filter((event) => event.message === "session_initialized").at(-1)?.timestamp ?? null,
116
+ lastSuccessfulToolCall: lastSuccessfulToolCall?.timestamp ?? null,
117
+ lastSuccessfulToolCallByRuntime: {},
118
+ lastSuccessfulToolCallByAgent: {},
119
+ lastSuccessfulToolCallByFamily: {},
120
+ activeSessionsByRuntime: {},
121
+ recentWarnings: scopedEvents.filter((event) => event.level === "warn" || event.level === "error").slice(-10),
122
+ remediation: [
123
+ "If MCP tools fail with missing/stale session, reconnect the MCP client (/mcp or restart the runtime).",
124
+ "Do not access the database directly; MCP is the only data interface.",
125
+ "Check get_daemon_health or exe-healthcheck for daemon/MCP endpoint status before retrying work."
126
+ ]
127
+ };
128
+ const createdBySession = /* @__PURE__ */ new Map();
129
+ for (const event of scopedEvents) {
130
+ if (event.message === "session_initialized" && event.sessionId) createdBySession.set(event.sessionId, event);
131
+ if ((event.message === "session_closed" || event.message === "session_expired") && event.sessionId) {
132
+ createdBySession.delete(event.sessionId);
133
+ }
134
+ }
135
+ for (const event of createdBySession.values()) {
136
+ const runtime = event.runtime ?? "Unknown";
137
+ summary.activeSessionsByRuntime[runtime] = (summary.activeSessionsByRuntime[runtime] ?? 0) + 1;
138
+ }
139
+ for (const event of successfulToolCalls) {
140
+ if (event.runtime) summary.lastSuccessfulToolCallByRuntime[event.runtime] = event.timestamp ?? "";
141
+ if (event.agentId) summary.lastSuccessfulToolCallByAgent[event.agentId] = event.timestamp ?? "";
142
+ if (event.toolFamily) summary.lastSuccessfulToolCallByFamily[event.toolFamily] = event.timestamp ?? "";
143
+ }
144
+ return summary;
145
+ }
146
+ function writeMcpTransportSummary(events) {
147
+ try {
148
+ mkdirSync(MCP_MONITOR_DIR, { recursive: true });
149
+ writeFileSync(MCP_TRANSPORT_SUMMARY_PATH, JSON.stringify(summarizeMcpTransport(events), null, 2) + "\n");
150
+ } catch {
151
+ }
152
+ }
153
+ function recordMcpHttpEvent(event) {
154
+ try {
155
+ mkdirSync(EXE_AI_DIR, { recursive: true });
156
+ const enriched = { timestamp: (/* @__PURE__ */ new Date()).toISOString(), ...event };
157
+ appendFileSync(MCP_HTTP_EVENTS_PATH, JSON.stringify(enriched) + "\n");
158
+ rotateMcpHttpEventLogIfNeeded();
159
+ writeMcpTransportSummary(readMcpHttpEvents());
160
+ } catch {
161
+ }
162
+ }
163
+
164
+ export {
165
+ inferMcpRuntime,
166
+ getMcpToolFamily,
167
+ readMcpHttpEvents,
168
+ summarizeMcpTransport,
169
+ writeMcpTransportSummary,
170
+ recordMcpHttpEvent
171
+ };