@askexenow/exe-os 0.9.138 → 0.9.140

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 (280) hide show
  1. package/dist/{active-agent-EFZ6YZIM.js → active-agent-GFBVE3ES.js} +3 -3
  2. package/dist/{active-agent-DZXEPRY7.js → active-agent-M3ZT74AM.js} +3 -3
  3. package/dist/{agentic-ontology-TU2FNTHI.js → agentic-ontology-QRNPGDIM.js} +1 -1
  4. package/dist/{backfill-metadata-LVUAD6WY.js → backfill-metadata-DI7R3MXV.js} +6 -6
  5. package/dist/{background-jobs-6V4GQ5QT.js → background-jobs-LUEOBAVF.js} +2 -2
  6. package/dist/{behaviors-V3O5YYUK.js → behaviors-KTEEQ3KG.js} +5 -5
  7. package/dist/bin/age-ontology-load.js +2 -2
  8. package/dist/bin/agentic-ontology-backfill.js +8 -8
  9. package/dist/bin/agentic-reflection-backfill.js +9 -9
  10. package/dist/bin/agentic-semantic-label.js +8 -8
  11. package/dist/bin/backfill-conversations.js +8 -8
  12. package/dist/bin/backfill-responses.js +8 -8
  13. package/dist/bin/backfill-vectors.js +10 -10
  14. package/dist/bin/bulk-sync-postgres.js +10 -10
  15. package/dist/bin/cc-doctor.js +3 -3
  16. package/dist/bin/cleanup-stale-review-tasks.js +13 -12
  17. package/dist/bin/cli.js +73 -17
  18. package/dist/bin/exe-agent-config.js +3 -3
  19. package/dist/bin/exe-agent.js +16 -16
  20. package/dist/bin/exe-assign.js +10 -10
  21. package/dist/bin/exe-boot.js +43 -42
  22. package/dist/bin/exe-call.js +7 -7
  23. package/dist/bin/exe-cloud.js +9 -9
  24. package/dist/bin/exe-dispatch.js +14 -15
  25. package/dist/bin/exe-doctor.js +1 -1
  26. package/dist/bin/exe-export-behaviors.js +9 -9
  27. package/dist/bin/exe-forget.js +8 -8
  28. package/dist/bin/exe-gateway.js +112 -11
  29. package/dist/bin/exe-healthcheck.js +3 -3
  30. package/dist/bin/exe-heartbeat.js +13 -12
  31. package/dist/bin/exe-kill.js +8 -8
  32. package/dist/bin/exe-launch-agent.js +39 -16
  33. package/dist/bin/exe-new-employee.js +15 -14
  34. package/dist/bin/exe-pending-messages.js +14 -13
  35. package/dist/bin/exe-pending-notifications.js +13 -12
  36. package/dist/bin/exe-pending-reviews.js +13 -12
  37. package/dist/bin/exe-rename.js +7 -7
  38. package/dist/bin/exe-review.js +63 -9
  39. package/dist/bin/exe-search.js +7 -7
  40. package/dist/bin/exe-session-cleanup.js +44 -30
  41. package/dist/bin/exe-settings.js +9 -9
  42. package/dist/bin/exe-start-codex.js +35 -17
  43. package/dist/bin/exe-start-opencode.js +10 -10
  44. package/dist/bin/exe-status.js +14 -13
  45. package/dist/bin/exe-support.js +3 -3
  46. package/dist/bin/exe-team.js +5 -5
  47. package/dist/bin/git-sweep.js +13 -12
  48. package/dist/bin/graph-backfill.js +7 -7
  49. package/dist/bin/graph-export.js +7 -7
  50. package/dist/bin/install.js +52 -8
  51. package/dist/bin/intercom-check.js +5 -4
  52. package/dist/bin/postgres-agentic-reflection-backfill.js +4 -4
  53. package/dist/bin/postgres-agentic-semantic-backfill.js +3 -3
  54. package/dist/bin/pre-publish.js +38 -8
  55. package/dist/bin/scan-tasks.js +22 -17
  56. package/dist/bin/setup.js +2 -2
  57. package/dist/bin/shard-migrate.js +7 -7
  58. package/dist/bin/stack-update.js +37 -8
  59. package/dist/{branding-JEE7MJF2.js → branding-EKPE6CWW.js} +1 -1
  60. package/dist/{capacity-monitor-56DTRWOS.js → capacity-monitor-HGD2C6CP.js} +14 -13
  61. package/dist/{catchup-brief-6GRGQ2EK.js → catchup-brief-OMDCLETB.js} +15 -14
  62. package/dist/{chunk-7GOVGBBM.js → chunk-2JAEWE7P.js} +6 -6
  63. package/dist/{worktree-4T4BPWPN.js → chunk-2OG5NAO2.js} +27 -6
  64. package/dist/{chunk-VFZTXKQI.js → chunk-2XUXMKX5.js} +44 -0
  65. package/dist/{chunk-BYNEC472.js → chunk-2ZWYALO4.js} +1 -1
  66. package/dist/{chunk-BUHXM7ZL.js → chunk-34O6PRWE.js} +5 -5
  67. package/dist/{chunk-VOA7GHIO.js → chunk-35FFFDS2.js} +1 -1
  68. package/dist/{chunk-ITMXM6GF.js → chunk-3SPQNGRT.js} +1 -1
  69. package/dist/{chunk-PFGFOALA.js → chunk-3TTJPQAE.js} +1 -1
  70. package/dist/{chunk-QCYYXXO5.js → chunk-3WSH4P4Z.js} +2 -2
  71. package/dist/{chunk-EZTYTAVU.js → chunk-4ITOWLHX.js} +4 -4
  72. package/dist/{chunk-TIJYLKNW.js → chunk-4YNGDNDI.js} +2 -2
  73. package/dist/{chunk-ZKOQD4FT.js → chunk-54MB5TNF.js} +12 -12
  74. package/dist/{chunk-R4M6XCMU.js → chunk-57HCNSFO.js} +1 -1
  75. package/dist/{chunk-NFMNO3XE.js → chunk-5K3CCPNX.js} +478 -205
  76. package/dist/{chunk-TT3ND3MM.js → chunk-5LJQSXUG.js} +4 -4
  77. package/dist/{workflow-engine-7W4MSNBF.js → chunk-5PB6BRLA.js} +23 -23
  78. package/dist/{chunk-AHQDWRSM.js → chunk-5WIEDLGY.js} +6 -6
  79. package/dist/{chunk-F63ZHBZY.js → chunk-6EBG7VWN.js} +2 -2
  80. package/dist/{chunk-OZ4SN7ZF.js → chunk-73JE5PVU.js} +189 -4
  81. package/dist/{chunk-2FWMSQWU.js → chunk-762FPANW.js} +1 -1
  82. package/dist/{chunk-JXYZVTBX.js → chunk-7HZFWAIR.js} +1 -1
  83. package/dist/{chunk-KSFOG6FJ.js → chunk-7SVGVGE3.js} +65 -1
  84. package/dist/{chunk-MSFSQSJO.js → chunk-ABCDEJUD.js} +2 -2
  85. package/dist/{chunk-WZ63HFR2.js → chunk-BBVMIH76.js} +36 -4
  86. package/dist/{chunk-37LVIZ3P.js → chunk-BZHXUKVC.js} +2 -2
  87. package/dist/{chunk-JN2RIMLI.js → chunk-CLIW2CES.js} +7 -7
  88. package/dist/{chunk-YTTVKPOQ.js → chunk-CSVYC6HH.js} +1 -1
  89. package/dist/{chunk-WTPYZG4I.js → chunk-CYCRC2KN.js} +60 -33
  90. package/dist/{chunk-BQ5YXRBI.js → chunk-D7BPHQGX.js} +2 -2
  91. package/dist/{chunk-3SYV36U5.js → chunk-DDUIVBH6.js} +1 -1
  92. package/dist/{chunk-TRLP7FHS.js → chunk-DEHYRM3I.js} +1 -1
  93. package/dist/{chunk-N7GFMJSF.js → chunk-DMFM77DV.js} +21 -1
  94. package/dist/{chunk-BU3ID2WT.js → chunk-ECSNSHZ7.js} +1 -2
  95. package/dist/{chunk-PKPW2W33.js → chunk-EWGZPTII.js} +1 -1
  96. package/dist/{chunk-GRLQJ27R.js → chunk-F6PIXTHZ.js} +4 -4
  97. package/dist/{chunk-PB5RHF74.js → chunk-FCO2K73K.js} +2 -2
  98. package/dist/{chunk-2SXMWUOQ.js → chunk-FLVDAA3Z.js} +1 -1
  99. package/dist/{chunk-BPLXSBNM.js → chunk-GUDCQBRY.js} +1 -1
  100. package/dist/{chunk-P6CLMRWJ.js → chunk-H24OVCAN.js} +1 -1
  101. package/dist/{chunk-K7E72WGL.js → chunk-HHV26QTD.js} +1 -1
  102. package/dist/{chunk-R3IILARI.js → chunk-HIOFKHTO.js} +19 -11
  103. package/dist/{chunk-HOKOOBDL.js → chunk-HJMM4QMY.js} +25 -6
  104. package/dist/chunk-HO4C7QMH.js +192 -0
  105. package/dist/{chunk-ISRQKXHM.js → chunk-IG5XFUYJ.js} +1 -1
  106. package/dist/{chunk-OVFU26ZD.js → chunk-IU3CXV4S.js} +30 -11
  107. package/dist/{chunk-SJWW6GRT.js → chunk-KNEH2MGD.js} +1 -1
  108. package/dist/{chunk-UMLRHSAP.js → chunk-KNS5ETKF.js} +1 -1
  109. package/dist/{chunk-T5A4EGUG.js → chunk-LPG22IL5.js} +3 -3
  110. package/dist/{chunk-OMHM3NGK.js → chunk-LUOLBU54.js} +1 -1
  111. package/dist/{chunk-TYLF4LSW.js → chunk-MBRLA4E3.js} +9 -0
  112. package/dist/{chunk-BOPKW4AV.js → chunk-MQV4UKTS.js} +2 -2
  113. package/dist/{chunk-PRRSSHU3.js → chunk-NTIWZFOJ.js} +1 -1
  114. package/dist/{chunk-Z36IJ3XX.js → chunk-NX4WEVG6.js} +3 -3
  115. package/dist/{chunk-LPIY2AUD.js → chunk-O2RVWP3S.js} +1 -1
  116. package/dist/{chunk-EBMHOMN2.js → chunk-OIUPHIN2.js} +21 -19
  117. package/dist/{chunk-VGOFRIAI.js → chunk-OX6D5AF3.js} +2 -2
  118. package/dist/{chunk-KTS6MOE4.js → chunk-OYBQKDV5.js} +1 -1
  119. package/dist/{chunk-KDM3GZ6T.js → chunk-POU4ZLBM.js} +77 -6
  120. package/dist/{chunk-7V3BJHG6.js → chunk-PS4UUDIG.js} +4 -4
  121. package/dist/{chunk-GERMZD6I.js → chunk-Q3MIJPXM.js} +4 -4
  122. package/dist/{chunk-N2ZX27ID.js → chunk-QCJ3Y52V.js} +1 -1
  123. package/dist/{chunk-K7W7UJ6Z.js → chunk-QUG6EMZQ.js} +1 -1
  124. package/dist/{chunk-I2LCIAUC.js → chunk-QVVV6DHI.js} +2 -2
  125. package/dist/{chunk-2ISCJ5PQ.js → chunk-RGKPVKUO.js} +1 -1
  126. package/dist/{chunk-F3MUSAZY.js → chunk-SCGCHM2H.js} +4 -4
  127. package/dist/{chunk-NHLW6DUE.js → chunk-SL47NHTE.js} +1 -1
  128. package/dist/{chunk-XEZ64YCS.js → chunk-SPMZRVXK.js} +2 -2
  129. package/dist/{chunk-7FYOTSJP.js → chunk-SQLEKC4E.js} +1 -1
  130. package/dist/{chunk-UT3OZWST.js → chunk-STVJLWSA.js} +4 -4
  131. package/dist/{chunk-LPGBKR4H.js → chunk-TOR5ZPKF.js} +14 -1
  132. package/dist/{chunk-5QCIPC7Z.js → chunk-UCNCSKGH.js} +3 -3
  133. package/dist/{chunk-7TW5HR4E.js → chunk-UE3BYGWY.js} +5 -5
  134. package/dist/{chunk-2G6QGXVX.js → chunk-UEWGUOXB.js} +192 -11
  135. package/dist/{chunk-LEVPSCVX.js → chunk-UOCQQHZT.js} +261 -40
  136. package/dist/{chunk-BI3COBMQ.js → chunk-VTZ4QOBS.js} +1 -1
  137. package/dist/{chunk-TCOTFMDP.js → chunk-XDJWGR2S.js} +2 -2
  138. package/dist/{chunk-ABIGFAFY.js → chunk-XNWXVGEA.js} +2 -2
  139. package/dist/{chunk-FQZY4M45.js → chunk-YWCPAQBH.js} +832 -89
  140. package/dist/{chunk-SF6H4ZME.js → chunk-YYB6HGEY.js} +11 -2
  141. package/dist/{chunk-MQNM4FW4.js → chunk-Z6BTUUPK.js} +4 -5
  142. package/dist/{chunk-ZKYHW6KY.js → chunk-ZHJNMC4W.js} +1 -1
  143. package/dist/{code-context-index-I7JC7DPM.js → code-context-index-PIC37JSG.js} +4 -4
  144. package/dist/{conversation-wiki-populator-L24LNYDL.js → conversation-wiki-populator-7M5YYPXH.js} +2 -2
  145. package/dist/{core-memory-DUENM2P6.js → core-memory-JOTETVSY.js} +3 -3
  146. package/dist/{crdt-sync-SENINDKP.js → crdt-sync-MDW6THU7.js} +1 -1
  147. package/dist/{crm-webhook-JIXOP3UR.js → crm-webhook-YZKCH7QB.js} +2 -2
  148. package/dist/{cto-delegation-gate-5ETBWFAI.js → cto-delegation-gate-7SQNLKN7.js} +12 -11
  149. package/dist/{daemon-auth-IFWQGMDT.js → daemon-auth-6XMF4JG5.js} +2 -2
  150. package/dist/{daemon-orchestration-6UNZTZHX.js → daemon-orchestration-7YUD2H64.js} +17 -17
  151. package/dist/{db-backup-RZA3JICI.js → db-backup-R4DLUO4C.js} +4 -2
  152. package/dist/{exe-drift-WLMWMSOM.js → exe-drift-HKJONDA5.js} +6 -6
  153. package/dist/{exe-export-3RQMZAR3.js → exe-export-TSZJEMWC.js} +9 -9
  154. package/dist/{exe-import-URXIQGOM.js → exe-import-LAKNLCWI.js} +9 -9
  155. package/dist/{exe-key-47ZUWMGT.js → exe-key-ODHZVEGR.js} +4 -4
  156. package/dist/{exe-org-F56R5P37.js → exe-org-EVOEZY6H.js} +2 -2
  157. package/dist/{fast-db-init-Z67ITX23.js → fast-db-init-6SRLEIFS.js} +1 -1
  158. package/dist/gateway/index.js +19 -18
  159. package/dist/{git-staleness-PP7MPTZS.js → git-staleness-H774CLPX.js} +4 -4
  160. package/dist/{git-task-sweep-TMVL5UUD.js → git-task-sweep-FMRECHV7.js} +13 -12
  161. package/dist/{global-procedures-OQFOUA5G.js → global-procedures-PYYMCJIW.js} +6 -6
  162. package/dist/hook-integrity-S5EUKBL6.js +89 -0
  163. package/dist/hooks/bug-report-worker.js +16 -16
  164. package/dist/hooks/codex-stop-task-finalizer.js +16 -16
  165. package/dist/hooks/commit-complete.js +15 -14
  166. package/dist/hooks/error-recall.js +8 -8
  167. package/dist/hooks/exe-heartbeat-hook.js +4 -4
  168. package/dist/hooks/ingest-worker.js +8 -7
  169. package/dist/hooks/ingest.js +48 -8
  170. package/dist/hooks/instructions-loaded.js +7 -7
  171. package/dist/hooks/notification.js +4 -4
  172. package/dist/hooks/post-compact.js +14 -13
  173. package/dist/hooks/post-tool-combined.js +5 -5
  174. package/dist/hooks/pre-compact.js +19 -18
  175. package/dist/hooks/pre-tool-use.js +33 -17
  176. package/dist/hooks/prompt-submit.js +34 -23
  177. package/dist/hooks/session-end.js +23 -22
  178. package/dist/hooks/session-start.js +8 -8
  179. package/dist/hooks/stop.js +20 -19
  180. package/dist/hooks/subagent-stop.js +14 -13
  181. package/dist/hooks/summary-worker.js +22 -21
  182. package/dist/index.js +23 -22
  183. package/dist/{installer-RVLKWR3X.js → installer-3RTZXZ57.js} +5 -5
  184. package/dist/{installer-V7BGTU55.js → installer-4G4YDLGY.js} +6 -6
  185. package/dist/{installer-RVGGMXQU.js → installer-MIBTZDDM.js} +8 -8
  186. package/dist/{key-backup-status-NMUFOHXW.js → key-backup-status-6BBOUM2S.js} +1 -1
  187. package/dist/lib/agent-config.js +2 -2
  188. package/dist/lib/cloud-sync.js +24 -8
  189. package/dist/lib/config.js +1 -1
  190. package/dist/lib/consolidation.js +7 -7
  191. package/dist/lib/crypto.js +3 -1
  192. package/dist/lib/database.js +4 -4
  193. package/dist/lib/db-daemon-client.js +3 -3
  194. package/dist/lib/db.js +4 -4
  195. package/dist/lib/device-registry.js +1 -1
  196. package/dist/lib/embedder.js +4 -4
  197. package/dist/lib/employee-templates.js +7 -7
  198. package/dist/lib/employees.js +2 -2
  199. package/dist/lib/exe-daemon-client.js +3 -3
  200. package/dist/lib/exe-daemon.js +280 -238
  201. package/dist/lib/file-grep.js +43 -18
  202. package/dist/lib/hybrid-search.js +7 -7
  203. package/dist/lib/identity-templates.js +79 -1
  204. package/dist/lib/identity.js +5 -5
  205. package/dist/lib/license.js +2 -2
  206. package/dist/lib/messaging.js +13 -12
  207. package/dist/lib/post-tool-memory.js +3 -2
  208. package/dist/lib/reminders.js +5 -5
  209. package/dist/lib/schedules.js +7 -7
  210. package/dist/lib/skill-learning.js +6 -6
  211. package/dist/lib/status-brief.js +1 -1
  212. package/dist/lib/store.js +6 -6
  213. package/dist/lib/task-router.js +3 -3
  214. package/dist/lib/tasks.js +20 -21
  215. package/dist/lib/tmux-routing.js +12 -11
  216. package/dist/lib/tmux-transport.js +1 -1
  217. package/dist/lib/token-spend.js +5 -5
  218. package/dist/lib/transport.js +2 -2
  219. package/dist/{license-gate-VMGC326L.js → license-gate-746LFKMY.js} +3 -3
  220. package/dist/mcp/register-tools.js +66 -66
  221. package/dist/mcp/server.js +114 -77
  222. package/dist/mcp/tools/complete-reminder.js +6 -6
  223. package/dist/mcp/tools/create-reminder.js +6 -6
  224. package/dist/mcp/tools/create-task.js +17 -17
  225. package/dist/mcp/tools/deactivate-behavior.js +7 -7
  226. package/dist/mcp/tools/list-reminders.js +6 -6
  227. package/dist/mcp/tools/list-tasks.js +17 -17
  228. package/dist/mcp/tools/send-message.js +15 -14
  229. package/dist/mcp/tools/update-task.js +16 -16
  230. package/dist/mcp-disconnect-tracker-I5WJ4LQ5.js +79 -0
  231. package/dist/{mcp-http-config-WPF5MBSO.js → mcp-http-config-RD5MJYJD.js} +3 -3
  232. package/dist/{memory-cards-H2GNWDF2.js → memory-cards-CS3QQQST.js} +4 -4
  233. package/dist/memory-poisoning-defense-XPM34UJQ.js +229 -0
  234. package/dist/memory-queue-B332RRFX.js +19 -0
  235. package/dist/{memory-queue-client-AG2QB6PK.js → memory-queue-client-MPJ2B7RU.js} +5 -5
  236. package/dist/{memory-reflection-J3LYZM5Y.js → memory-reflection-GH5BOH7A.js} +4 -4
  237. package/dist/{notifications-3ZZS36PK.js → notifications-WWROKWFT.js} +12 -11
  238. package/dist/{orchestration-phase-YKDZDERC.js → orchestration-phase-SBCILK4O.js} +2 -2
  239. package/dist/{orchestrator-W7XYR7EZ.js → orchestrator-V3EMR3AU.js} +14 -14
  240. package/dist/{plan-limits-3FXBGHWT.js → plan-limits-AMJUHUCR.js} +6 -6
  241. package/dist/{project-name-PL2ZDWNU.js → project-name-7G6XPXQ6.js} +2 -1
  242. package/dist/{projection-worker-XGV76EMZ.js → projection-worker-2YXEQRKI.js} +2 -2
  243. package/dist/{push-notifications-S4QIZWJI.js → push-notifications-NYQZGUJT.js} +2 -2
  244. package/dist/{reranker-EEX3UEA2.js → reranker-ZU3GWEBG.js} +2 -2
  245. package/dist/runtime/index.js +15 -15
  246. package/dist/{session-events-27MUL77I.js → session-events-RCAUFPNG.js} +14 -13
  247. package/dist/{session-kill-telemetry-WVFJ4U3A.js → session-kill-telemetry-GUN2M2LJ.js} +5 -5
  248. package/dist/{session-scope-QZTSCYLT.js → session-scope-NGLL42BM.js} +14 -13
  249. package/dist/{setup-wizard-JEYXHYVS.js → setup-wizard-JAFJRWKE.js} +2 -2
  250. package/dist/{shard-manager-4QLCI2RC.js → shard-manager-CIDCCPJ4.js} +2 -2
  251. package/dist/{task-enforcement-337DZI3I.js → task-enforcement-YMGIERU4.js} +40 -14
  252. package/dist/{task-scope-2L5DLU6T.js → task-scope-RMJLXJ7S.js} +12 -11
  253. package/dist/{tasks-crud-MDCY6JHU.js → tasks-crud-ZRXPR3UB.js} +12 -12
  254. package/dist/{tasks-review-QO55FYZI.js → tasks-review-NQUJR52I.js} +12 -11
  255. package/dist/{tool-capability-index-XYEJ57EL.js → tool-capability-index-6EKGND6H.js} +1 -1
  256. package/dist/{tool-telemetry-NW6HQYPA.js → tool-telemetry-4C6LTIPM.js} +1 -1
  257. package/dist/tui/App.js +26 -25
  258. package/dist/{tui-data-6CKBIJJJ.js → tui-data-A4GTAXBL.js} +12 -11
  259. package/dist/webhook-pipe-AFXVZ6YL.js +114 -0
  260. package/dist/{whatsapp-J6QNDBGY.js → whatsapp-4IDUW46W.js} +1 -1
  261. package/dist/{wiki-acl-RVCO4WSP.js → wiki-acl-P7WEIMJV.js} +10 -10
  262. package/dist/{worker-gate-IHFHRPF5.js → worker-gate-H43H32OF.js} +2 -2
  263. package/dist/workflow-engine-EPWKDGHR.js +28 -0
  264. package/dist/worktree-XQM3YNKR.js +21 -0
  265. package/package.json +13 -10
  266. package/release-notes.json +213 -33048
  267. package/src/commands/exe/afk.md +20 -0
  268. package/dist/chunk-2CKP7O4F.js +0 -84
  269. package/dist/chunk-EZ2TJX6O.js +0 -725
  270. package/dist/memory-queue-QX6UY4BP.js +0 -13
  271. /package/deploy/compose/{.env → .env.default} +0 -0
  272. /package/dist/{chunk-ISPV5JR2.js → chunk-3RNNTTBH.js} +0 -0
  273. /package/dist/{chunk-KJMSHBWT.js → chunk-ELXPFTBJ.js} +0 -0
  274. /package/dist/{chunk-GMARURIG.js → chunk-GLGWGMPD.js} +0 -0
  275. /package/dist/{chunk-G3LVAJON.js → chunk-GSI6OPPH.js} +0 -0
  276. /package/dist/{chunk-DLMPVZ4I.js → chunk-OJ6Z2ZS2.js} +0 -0
  277. /package/dist/{chunk-6AJ4KAAB.js → chunk-RCNCUSAF.js} +0 -0
  278. /package/dist/{chunk-N6BE2CUT.js → chunk-VEGDNUBO.js} +0 -0
  279. /package/dist/{entity-boost-CZZVTBSY.js → entity-boost-YQFREESI.js} +0 -0
  280. /package/dist/{wiki-client-ZWA545PZ.js → wiki-client-UFR4R7YH.js} +0 -0
@@ -1,26 +1,19 @@
1
- import {
2
- getToolCapabilityIndex
3
- } from "./chunk-ISPV5JR2.js";
4
- import {
5
- getCachedLicenseGate
6
- } from "./chunk-JXYZVTBX.js";
7
1
  import {
8
2
  getToolUsageStats
9
- } from "./chunk-GMARURIG.js";
3
+ } from "./chunk-GLGWGMPD.js";
10
4
  import {
11
5
  AUTO_WAKE_MAX_RETRIES
12
- } from "./chunk-7TW5HR4E.js";
6
+ } from "./chunk-UE3BYGWY.js";
13
7
  import {
14
- isToolAllowed,
15
- isToolAllowedForPlan
16
- } from "./chunk-E6ORBQHP.js";
8
+ getToolCapabilityIndex
9
+ } from "./chunk-3RNNTTBH.js";
17
10
  import {
18
- listRecentSessionEvents
19
- } from "./chunk-MSFSQSJO.js";
11
+ getCachedLicenseGate
12
+ } from "./chunk-7HZFWAIR.js";
20
13
  import {
21
14
  isRerankerAvailable,
22
15
  rerankWithScores
23
- } from "./chunk-P6CLMRWJ.js";
16
+ } from "./chunk-H24OVCAN.js";
24
17
  import {
25
18
  getEntityByName,
26
19
  getEntityNeighbors,
@@ -29,6 +22,13 @@ import {
29
22
  getRelationships,
30
23
  searchEntities
31
24
  } from "./chunk-6LKDJ5WX.js";
25
+ import {
26
+ isToolAllowed,
27
+ isToolAllowedForPlan
28
+ } from "./chunk-E6ORBQHP.js";
29
+ import {
30
+ listRecentSessionEvents
31
+ } from "./chunk-ABCDEJUD.js";
32
32
  import {
33
33
  analyzeBlastRadius,
34
34
  buildCodeContextIndex,
@@ -37,68 +37,68 @@ import {
37
37
  searchCodeContext,
38
38
  searchCodeContextSemantic,
39
39
  traceCodeSymbol
40
- } from "./chunk-37LVIZ3P.js";
40
+ } from "./chunk-BZHXUKVC.js";
41
+ import {
42
+ runDriftProbes
43
+ } from "./chunk-4YNGDNDI.js";
41
44
  import {
42
45
  exportOrchestration,
43
46
  importOrchestration,
44
47
  validatePackage
45
- } from "./chunk-Z36IJ3XX.js";
46
- import {
47
- runDriftProbes
48
- } from "./chunk-TIJYLKNW.js";
48
+ } from "./chunk-NX4WEVG6.js";
49
49
  import {
50
50
  loadOrchestrationPhase,
51
51
  setOrchestrationPhase
52
- } from "./chunk-SJWW6GRT.js";
52
+ } from "./chunk-KNEH2MGD.js";
53
53
  import {
54
54
  createOrRefreshResumeTask,
55
55
  init_capacity_monitor
56
- } from "./chunk-BUHXM7ZL.js";
56
+ } from "./chunk-34O6PRWE.js";
57
57
  import {
58
58
  registerCompleteReminder
59
- } from "./chunk-2ISCJ5PQ.js";
59
+ } from "./chunk-RGKPVKUO.js";
60
60
  import {
61
61
  registerDeactivateBehavior
62
- } from "./chunk-7V3BJHG6.js";
62
+ } from "./chunk-PS4UUDIG.js";
63
63
  import {
64
64
  registerSendMessage
65
- } from "./chunk-F63ZHBZY.js";
65
+ } from "./chunk-6EBG7VWN.js";
66
66
  import {
67
67
  registerCreateTask
68
- } from "./chunk-7GOVGBBM.js";
68
+ } from "./chunk-2JAEWE7P.js";
69
69
  import {
70
70
  registerListTasks
71
- } from "./chunk-TT3ND3MM.js";
71
+ } from "./chunk-5LJQSXUG.js";
72
72
  import {
73
73
  registerUpdateTask
74
- } from "./chunk-JN2RIMLI.js";
74
+ } from "./chunk-CLIW2CES.js";
75
75
  import {
76
76
  registerCreateReminder
77
- } from "./chunk-VOA7GHIO.js";
77
+ } from "./chunk-35FFFDS2.js";
78
78
  import {
79
79
  registerListReminders
80
- } from "./chunk-LPIY2AUD.js";
80
+ } from "./chunk-O2RVWP3S.js";
81
81
  import {
82
82
  completeReminder,
83
83
  createReminder,
84
84
  listReminders
85
- } from "./chunk-PFGFOALA.js";
85
+ } from "./chunk-3TTJPQAE.js";
86
86
  import {
87
87
  status
88
- } from "./chunk-EZTYTAVU.js";
88
+ } from "./chunk-4ITOWLHX.js";
89
89
  import {
90
90
  TOKENS_PER_IDLE_MINUTE,
91
91
  countKillsSince,
92
92
  init_session_kill_telemetry,
93
93
  sumTokensSavedSince
94
- } from "./chunk-K7W7UJ6Z.js";
94
+ } from "./chunk-QUG6EMZQ.js";
95
95
  import {
96
96
  getAgentSpend
97
- } from "./chunk-BYNEC472.js";
97
+ } from "./chunk-2ZWYALO4.js";
98
98
  import {
99
99
  createSchedule,
100
100
  parseHumanCron
101
- } from "./chunk-VGOFRIAI.js";
101
+ } from "./chunk-OX6D5AF3.js";
102
102
  import {
103
103
  exportGraphHTML,
104
104
  generateGraphReport
@@ -110,87 +110,91 @@ import {
110
110
  import {
111
111
  formatReport,
112
112
  runAudit
113
- } from "./chunk-AHQDWRSM.js";
113
+ } from "./chunk-5WIEDLGY.js";
114
114
  import {
115
115
  runHealthCheck
116
- } from "./chunk-XEZ64YCS.js";
116
+ } from "./chunk-SPMZRVXK.js";
117
117
  import {
118
118
  hasFailures,
119
119
  runHealth,
120
120
  runTest
121
- } from "./chunk-GERMZD6I.js";
121
+ } from "./chunk-Q3MIJPXM.js";
122
122
  import {
123
123
  findSimilarTrajectories,
124
124
  hashSignature,
125
125
  init_skill_learning
126
- } from "./chunk-5QCIPC7Z.js";
126
+ } from "./chunk-UCNCSKGH.js";
127
127
  import {
128
128
  deactivateBehavior,
129
129
  init_behaviors,
130
130
  listBehaviorsByDomain,
131
131
  storeBehavior
132
- } from "./chunk-N2ZX27ID.js";
132
+ } from "./chunk-QCJ3Y52V.js";
133
133
  import {
134
134
  countUnconsolidated,
135
135
  groupMemories,
136
136
  runConsolidation,
137
137
  selectUnconsolidated
138
- } from "./chunk-MQNM4FW4.js";
138
+ } from "./chunk-Z6BTUUPK.js";
139
139
  import {
140
140
  renderClientCOOTemplate
141
- } from "./chunk-7FYOTSJP.js";
141
+ } from "./chunk-SQLEKC4E.js";
142
142
  import {
143
143
  deactivateGlobalProcedure,
144
144
  loadGlobalProcedures,
145
145
  storeGlobalProcedure
146
- } from "./chunk-BQ5YXRBI.js";
146
+ } from "./chunk-D7BPHQGX.js";
147
147
  import {
148
148
  PLATFORM_PROCEDURES
149
- } from "./chunk-N7GFMJSF.js";
149
+ } from "./chunk-DMFM77DV.js";
150
150
  import {
151
151
  clearCloudReuploadRequired,
152
152
  cloudSync,
153
153
  getCloudReuploadRequired,
154
154
  markCloudReuploadRequired
155
- } from "./chunk-LEVPSCVX.js";
155
+ } from "./chunk-UOCQQHZT.js";
156
+ import {
157
+ crypto_exports,
158
+ init_crypto
159
+ } from "./chunk-HJMM4QMY.js";
156
160
  import {
157
161
  createARecord
158
162
  } from "./chunk-X2Z5GT3V.js";
159
163
  import {
160
164
  embed,
161
165
  init_embedder
162
- } from "./chunk-YTTVKPOQ.js";
166
+ } from "./chunk-CSVYC6HH.js";
163
167
  import {
164
168
  readMcpHttpEvents,
165
169
  summarizeMcpTransport,
166
170
  writeMcpTransportSummary
167
- } from "./chunk-OMHM3NGK.js";
171
+ } from "./chunk-LUOLBU54.js";
168
172
  import {
169
173
  init_tasks,
170
174
  updateTask
171
- } from "./chunk-WTPYZG4I.js";
175
+ } from "./chunk-CYCRC2KN.js";
172
176
  import {
173
177
  fastDbInit
174
- } from "./chunk-KJMSHBWT.js";
178
+ } from "./chunk-ELXPFTBJ.js";
175
179
  import {
176
180
  getIdentity,
177
181
  listIdentities,
178
182
  updateIdentity
179
- } from "./chunk-BOPKW4AV.js";
183
+ } from "./chunk-MQV4UKTS.js";
180
184
  import {
181
185
  MAX_CONCURRENT_WORKERS
182
- } from "./chunk-BI3COBMQ.js";
186
+ } from "./chunk-VTZ4QOBS.js";
183
187
  import {
184
188
  getProjectName,
185
189
  init_project_name
186
- } from "./chunk-LPGBKR4H.js";
190
+ } from "./chunk-TOR5ZPKF.js";
187
191
  import {
188
192
  hybridSearch,
189
193
  recentRecords
190
- } from "./chunk-EBMHOMN2.js";
194
+ } from "./chunk-OIUPHIN2.js";
191
195
  import {
192
196
  getActiveAgent
193
- } from "./chunk-TCOTFMDP.js";
197
+ } from "./chunk-XDJWGR2S.js";
194
198
  import {
195
199
  attachDocumentMetadata,
196
200
  flushBatch,
@@ -198,19 +202,19 @@ import {
198
202
  reserveVersions,
199
203
  vectorToBlob,
200
204
  writeMemory
201
- } from "./chunk-OVFU26ZD.js";
202
- import {
203
- resolveTask,
204
- writeCheckpoint
205
- } from "./chunk-EZ2TJX6O.js";
205
+ } from "./chunk-IU3CXV4S.js";
206
206
  import {
207
207
  init_task_scope,
208
+ init_tasks_crud,
208
209
  init_tmux_routing,
209
210
  resolveExeSession,
211
+ resolveTask,
210
212
  sessionScopeFilter,
211
213
  strictSessionScopeFilter,
212
- tmux_routing_exports
213
- } from "./chunk-FQZY4M45.js";
214
+ tmux_routing_exports,
215
+ updateTaskStatus,
216
+ writeCheckpoint
217
+ } from "./chunk-YWCPAQBH.js";
214
218
  import {
215
219
  init_session_registry,
216
220
  listSessions
@@ -223,7 +227,7 @@ import {
223
227
  init_agent_config,
224
228
  loadAgentConfig,
225
229
  setAgentRuntime
226
- } from "./chunk-K7E72WGL.js";
230
+ } from "./chunk-HHV26QTD.js";
227
231
  import {
228
232
  DEFAULT_RUNTIME,
229
233
  init_runtime_table
@@ -234,7 +238,7 @@ import {
234
238
  assertFeature,
235
239
  assertMemoryLimit,
236
240
  init_plan_limits
237
- } from "./chunk-GRLQJ27R.js";
241
+ } from "./chunk-F6PIXTHZ.js";
238
242
  import {
239
243
  getAccountByName,
240
244
  getDefaultAccount
@@ -243,14 +247,14 @@ import {
243
247
  createNewTrigger,
244
248
  isScheduledTrigger,
245
249
  loadTriggers
246
- } from "./chunk-N6BE2CUT.js";
250
+ } from "./chunk-VEGDNUBO.js";
247
251
  import {
248
252
  pushConversationToCRM
249
253
  } from "./chunk-GCNWCYJI.js";
250
254
  import {
251
255
  getClient,
252
256
  init_database
253
- } from "./chunk-2G6QGXVX.js";
257
+ } from "./chunk-UEWGUOXB.js";
254
258
  import {
255
259
  EMPLOYEES_PATH,
256
260
  addEmployee,
@@ -263,7 +267,7 @@ import {
263
267
  loadEmployees,
264
268
  loadEmployeesSync,
265
269
  saveEmployees
266
- } from "./chunk-ZKYHW6KY.js";
270
+ } from "./chunk-ZHJNMC4W.js";
267
271
  import {
268
272
  getMasterKey
269
273
  } from "./chunk-XUHFQHGZ.js";
@@ -280,12 +284,12 @@ import {
280
284
  readCachedLicenseToken,
281
285
  saveLicense,
282
286
  validateLicense
283
- } from "./chunk-UMLRHSAP.js";
287
+ } from "./chunk-KNS5ETKF.js";
284
288
  import {
285
289
  EXE_AI_DIR,
286
290
  init_config,
287
291
  loadConfig
288
- } from "./chunk-ISRQKXHM.js";
292
+ } from "./chunk-IG5XFUYJ.js";
289
293
  import {
290
294
  __toCommonJS
291
295
  } from "./chunk-KFQGP6VL.js";
@@ -879,7 +883,7 @@ async function searchConversations(query, limit) {
879
883
  }
880
884
  async function searchWiki(query, limit) {
881
885
  try {
882
- const { createWikiClient, chatInWorkspace, listWorkspaces } = await import("./wiki-client-ZWA545PZ.js");
886
+ const { createWikiClient, chatInWorkspace, listWorkspaces } = await import("./wiki-client-UFR4R7YH.js");
883
887
  const client = await createWikiClient();
884
888
  if (!client) return [];
885
889
  const workspaces = await listWorkspaces(client);
@@ -1424,7 +1428,7 @@ async function handleSupersede(input) {
1424
1428
  }
1425
1429
  try {
1426
1430
  const { getClient: getClient2 } = await import("./lib/database.js");
1427
- const { getActiveAgent: getActiveAgent2 } = await import("./active-agent-EFZ6YZIM.js");
1431
+ const { getActiveAgent: getActiveAgent2 } = await import("./active-agent-GFBVE3ES.js");
1428
1432
  const { writeMemory: writeMemory2, flushBatch: flushBatch2 } = await import("./lib/store.js");
1429
1433
  const { randomUUID: randomUUID2 } = await import("crypto");
1430
1434
  const client = getClient2();
@@ -1442,8 +1446,8 @@ async function handleSupersede(input) {
1442
1446
  });
1443
1447
  const { agentId, agentRole } = getActiveAgent2();
1444
1448
  const sessionId = process.env.SESSION_ID ?? "manual";
1445
- const { getProjectName: getProjectName2 } = await import("./project-name-PL2ZDWNU.js");
1446
- const projectName = input.project_name ?? getProjectName2(process.cwd());
1449
+ const { getProjectName: getProjectName2 } = await import("./project-name-7G6XPXQ6.js");
1450
+ const projectName = input.project_name ?? getProjectName2();
1447
1451
  const newId = randomUUID2();
1448
1452
  await writeMemory2({
1449
1453
  id: newId,
@@ -1533,9 +1537,9 @@ function registerMemory(server) {
1533
1537
  return handleSupersede(input);
1534
1538
  }
1535
1539
  if (action === "core_get" || action === "core_set" || action === "core_delete") {
1536
- const { getActiveAgent: getActiveAgent2 } = await import("./active-agent-EFZ6YZIM.js");
1540
+ const { getActiveAgent: getActiveAgent2 } = await import("./active-agent-GFBVE3ES.js");
1537
1541
  const { agentId } = getActiveAgent2();
1538
- const { getCoreMemory, setCoreMemory, deleteCoreMemory, formatCoreMemoryBlock } = await import("./core-memory-DUENM2P6.js");
1542
+ const { getCoreMemory, setCoreMemory, deleteCoreMemory, formatCoreMemoryBlock } = await import("./core-memory-JOTETVSY.js");
1539
1543
  if (action === "core_get") {
1540
1544
  const entries = await getCoreMemory(agentId);
1541
1545
  const block = formatCoreMemoryBlock(entries);
@@ -1928,6 +1932,36 @@ function registerCloseTask(server) {
1928
1932
  }
1929
1933
  } catch {
1930
1934
  }
1935
+ let mergeWarning = "";
1936
+ try {
1937
+ const { getClient: getClient2 } = await import("./lib/database.js");
1938
+ const client = getClient2();
1939
+ const taskRow = await client.execute({
1940
+ sql: "SELECT assigned_to FROM tasks WHERE id = ? OR task_file LIKE ? OR title LIKE ? LIMIT 1",
1941
+ args: [task_id, `%${task_id}%`, `%${task_id}%`]
1942
+ });
1943
+ const assignee = taskRow.rows[0]?.assigned_to;
1944
+ if (assignee) {
1945
+ const { execSync } = await import("child_process");
1946
+ try {
1947
+ const openPRs = execSync(
1948
+ `gh pr list --state open --json number,title,headRefName --author ${assignee} 2>/dev/null`,
1949
+ { encoding: "utf8", timeout: 5e3 }
1950
+ ).trim();
1951
+ const prs = JSON.parse(openPRs || "[]");
1952
+ if (prs.length > 0) {
1953
+ const prList = prs.map((p) => ` #${p.number}: ${p.title} (${p.headRefName})`).join("\n");
1954
+ mergeWarning = `
1955
+
1956
+ \u26A0\uFE0F MERGE CHECK: ${assignee} has ${prs.length} open PR(s) \u2014 did you merge before closing?
1957
+ ${prList}
1958
+ Run: gh pr merge <number> --squash --delete-branch`;
1959
+ }
1960
+ } catch {
1961
+ }
1962
+ }
1963
+ } catch {
1964
+ }
1931
1965
  const baseDir = process.cwd();
1932
1966
  const task = await updateTask({
1933
1967
  taskId: task_id,
@@ -1938,6 +1972,7 @@ function registerCloseTask(server) {
1938
1972
  });
1939
1973
  let text3 = `Task "${task.title}" marked ${task.status}.
1940
1974
  File: ${task.taskFile}`;
1975
+ if (mergeWarning) text3 += mergeWarning;
1941
1976
  if ((status2 === "done" || status2 === "closed") && task.nextTask) {
1942
1977
  text3 += `
1943
1978
 
@@ -2004,6 +2039,7 @@ function registerCheckpointTask(server) {
2004
2039
  init_capacity_monitor();
2005
2040
  init_database();
2006
2041
  init_task_scope();
2042
+ init_tasks_crud();
2007
2043
  import { z as z15 } from "zod";
2008
2044
  var RESUME_CONTEXT_TASK_LIMIT = 10;
2009
2045
  function registerResumeEmployee(server) {
@@ -2041,15 +2077,23 @@ function registerResumeEmployee(server) {
2041
2077
  };
2042
2078
  }
2043
2079
  try {
2044
- const { isTmuxSessionAlive } = await import("./tasks-crud-MDCY6JHU.js");
2080
+ const { isTmuxSessionAlive } = await import("./tasks-crud-ZRXPR3UB.js");
2045
2081
  const now = (/* @__PURE__ */ new Date()).toISOString();
2046
2082
  for (const row of openTasks.rows) {
2047
2083
  const status2 = String(row.status);
2048
2084
  const assignedTmux = row.assigned_tmux != null ? String(row.assigned_tmux) : null;
2049
2085
  if (status2 === "in_progress" && assignedTmux && !isTmuxSessionAlive(assignedTmux)) {
2086
+ try {
2087
+ await updateTaskStatus({ taskId: String(row.id), status: "open" });
2088
+ } catch {
2089
+ await client.execute({
2090
+ sql: "UPDATE tasks SET status = 'open', updated_at = ? WHERE id = ?",
2091
+ args: [now, String(row.id)]
2092
+ });
2093
+ }
2050
2094
  await client.execute({
2051
- sql: "UPDATE tasks SET status = 'open', assigned_tmux = NULL, updated_at = ? WHERE id = ?",
2052
- args: [now, String(row.id)]
2095
+ sql: "UPDATE tasks SET assigned_tmux = NULL WHERE id = ?",
2096
+ args: [String(row.id)]
2053
2097
  });
2054
2098
  process.stderr.write(
2055
2099
  `[resume_employee] Released dead claim on "${String(row.title)}" (was ${assignedTmux})
@@ -2119,7 +2163,7 @@ var REQUIRED_FIELDS2 = {
2119
2163
  update: ["task_id", "status"],
2120
2164
  close: ["task_id", "result"],
2121
2165
  checkpoint: ["task_id", "step", "context_summary"],
2122
- resume: ["agent_id", "project_name"]
2166
+ resume: ["agent_id"]
2123
2167
  };
2124
2168
  function errorResult2(text3) {
2125
2169
  return {
@@ -2227,7 +2271,20 @@ function registerStoreBehavior(server) {
2227
2271
  }
2228
2272
  },
2229
2273
  async ({ content, domain, priority, agent_id, project_name }) => {
2230
- const resolvedAgent = agent_id ?? getActiveAgent().agentId;
2274
+ const activeAgent = getActiveAgent();
2275
+ const resolvedAgent = agent_id ?? activeAgent.agentId;
2276
+ if (agent_id && agent_id !== activeAgent.agentId) {
2277
+ try {
2278
+ const { canCoordinate: canCoordinate2 } = await import("./lib/employees.js");
2279
+ if (!canCoordinate2(activeAgent.agentId, activeAgent.agentRole ?? "employee")) {
2280
+ return {
2281
+ content: [{ type: "text", text: `Authorization denied: only coordinators can write behaviors for other agents. You (${activeAgent.agentId}) cannot write behaviors for ${agent_id}.` }],
2282
+ isError: true
2283
+ };
2284
+ }
2285
+ } catch {
2286
+ }
2287
+ }
2231
2288
  let resolvedProject;
2232
2289
  if (project_name === "global" || project_name === null) {
2233
2290
  resolvedProject = void 0;
@@ -2864,8 +2921,8 @@ function registerIngestDocument(server) {
2864
2921
  },
2865
2922
  async (input) => {
2866
2923
  try {
2867
- const { assertFeature: assertFeature2 } = await import("./plan-limits-3FXBGHWT.js");
2868
- const { assertMemoryLimit: assertMemoryLimit2 } = await import("./plan-limits-3FXBGHWT.js");
2924
+ const { assertFeature: assertFeature2 } = await import("./plan-limits-AMJUHUCR.js");
2925
+ const { assertMemoryLimit: assertMemoryLimit2 } = await import("./plan-limits-AMJUHUCR.js");
2869
2926
  await assertFeature2("wiki");
2870
2927
  await assertMemoryLimit2();
2871
2928
  const result3 = await ingestDocument(input);
@@ -3335,7 +3392,99 @@ function registerSendWhatsapp(server) {
3335
3392
 
3336
3393
  // src/mcp/tools/query-conversations.ts
3337
3394
  init_database();
3395
+ import { z as z31 } from "zod";
3396
+
3397
+ // src/lib/unified-query.ts
3338
3398
  import { z as z30 } from "zod";
3399
+ var PaginationSchema = {
3400
+ limit: z30.coerce.number().int().min(1).max(100).optional().describe("Max results to return (default 25, max 100)"),
3401
+ offset: z30.coerce.number().int().min(0).optional().describe("Number of results to skip for pagination")
3402
+ };
3403
+ var DateRangeSchema = {
3404
+ date_from: z30.string().optional().describe("Filter records created/updated after this ISO date (inclusive)"),
3405
+ date_to: z30.string().optional().describe("Filter records created/updated before this ISO date (inclusive)")
3406
+ };
3407
+ var TextSearchSchema = {
3408
+ text_search: z30.string().optional().describe("Full-text search across relevant fields")
3409
+ };
3410
+ var SortSchema = {
3411
+ sort_by: z30.string().optional().describe("Field to sort by (tool-specific, default varies)"),
3412
+ sort_order: z30.enum(["asc", "desc"]).optional().describe("Sort direction (default desc)")
3413
+ };
3414
+ var SourceFilterSchema = {
3415
+ source: z30.string().optional().describe("Filter by data source/platform")
3416
+ };
3417
+ var StructuredFiltersSchema = {
3418
+ structured_filters: z30.record(z30.string(), z30.unknown()).optional().describe(
3419
+ "Structured field filters: { field: value } for equality, or { field: { op: 'gt'|'lt'|'gte'|'lte'|'contains'|'neq', value: ... } }"
3420
+ )
3421
+ };
3422
+ var UnifiedQuerySchema = {
3423
+ ...PaginationSchema,
3424
+ ...DateRangeSchema,
3425
+ ...TextSearchSchema,
3426
+ ...SortSchema,
3427
+ ...SourceFilterSchema,
3428
+ ...StructuredFiltersSchema
3429
+ };
3430
+ function formatUnifiedResponse(data, opts) {
3431
+ return {
3432
+ data,
3433
+ total: opts.total ?? data.length,
3434
+ offset: opts.offset ?? 0,
3435
+ limit: opts.limit ?? data.length,
3436
+ source: opts.source
3437
+ };
3438
+ }
3439
+ function buildStructuredFilterClauses(filters, columnMapping) {
3440
+ if (!filters) return [];
3441
+ const clauses = [];
3442
+ for (const [field, value] of Object.entries(filters)) {
3443
+ const column = columnMapping?.[field] ?? field;
3444
+ if (value === null || value === void 0) continue;
3445
+ if (typeof value === "object" && !Array.isArray(value)) {
3446
+ const filter = value;
3447
+ if (!filter.op || filter.value === void 0) continue;
3448
+ switch (filter.op) {
3449
+ case "eq":
3450
+ clauses.push({ sql: `${column} = ?`, args: [filter.value] });
3451
+ break;
3452
+ case "neq":
3453
+ clauses.push({ sql: `${column} != ?`, args: [filter.value] });
3454
+ break;
3455
+ case "gt":
3456
+ clauses.push({ sql: `${column} > ?`, args: [filter.value] });
3457
+ break;
3458
+ case "lt":
3459
+ clauses.push({ sql: `${column} < ?`, args: [filter.value] });
3460
+ break;
3461
+ case "gte":
3462
+ clauses.push({ sql: `${column} >= ?`, args: [filter.value] });
3463
+ break;
3464
+ case "lte":
3465
+ clauses.push({ sql: `${column} <= ?`, args: [filter.value] });
3466
+ break;
3467
+ case "contains":
3468
+ clauses.push({ sql: `${column} LIKE ?`, args: [`%${filter.value}%`] });
3469
+ break;
3470
+ default:
3471
+ break;
3472
+ }
3473
+ } else {
3474
+ clauses.push({ sql: `${column} = ?`, args: [value] });
3475
+ }
3476
+ }
3477
+ return clauses;
3478
+ }
3479
+ function buildSortClause(sortBy, sortOrder, defaultSort = "created_at DESC", allowedColumns) {
3480
+ if (!sortBy) return `ORDER BY ${defaultSort}`;
3481
+ if (allowedColumns && !allowedColumns.has(sortBy)) return `ORDER BY ${defaultSort}`;
3482
+ if (!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(sortBy)) return `ORDER BY ${defaultSort}`;
3483
+ const order = sortOrder === "asc" ? "ASC" : "DESC";
3484
+ return `ORDER BY ${sortBy} ${order}`;
3485
+ }
3486
+
3487
+ // src/mcp/tools/query-conversations.ts
3339
3488
  function registerQueryConversations(server) {
3340
3489
  server.registerTool(
3341
3490
  "query_conversations",
@@ -3343,14 +3492,16 @@ function registerQueryConversations(server) {
3343
3492
  title: "Query Conversations",
3344
3493
  description: "Search across all adapter messages by content, sender, date range, or platform. Returns messages with source attribution (platform, sender, timestamp).",
3345
3494
  inputSchema: {
3346
- query: z30.string().optional().describe("Full-text search query across message content and responses"),
3347
- sender: z30.string().optional().describe("Filter by sender ID or name (partial match)"),
3348
- platform: z30.string().optional().describe("Filter by platform: whatsapp, signal, telegram, discord, imessage, slack, email, webchat"),
3349
- after: z30.string().optional().describe("Filter messages after this ISO 8601 date (e.g. 2026-04-01)"),
3350
- before: z30.string().optional().describe("Filter messages before this ISO 8601 date (e.g. 2026-04-15)"),
3351
- channel_id: z30.string().optional().describe("Filter by channel/chat ID"),
3352
- thread_id: z30.string().optional().describe("Filter by conversation thread ID"),
3353
- limit: z30.number().int().min(1).max(100).optional().default(25).describe("Max results to return (default 25, max 100)")
3495
+ query: z31.string().optional().describe("Full-text search query across message content and responses"),
3496
+ sender: z31.string().optional().describe("Filter by sender ID or name (partial match)"),
3497
+ platform: z31.string().optional().describe("Filter by platform: whatsapp, signal, telegram, discord, imessage, slack, email, webchat"),
3498
+ after: z31.string().optional().describe("Filter messages after this ISO 8601 date (alias for date_from)"),
3499
+ before: z31.string().optional().describe("Filter messages before this ISO 8601 date (alias for date_to)"),
3500
+ channel_id: z31.string().optional().describe("Filter by channel/chat ID"),
3501
+ thread_id: z31.string().optional().describe("Filter by conversation thread ID"),
3502
+ ...DateRangeSchema,
3503
+ ...SortSchema,
3504
+ ...PaginationSchema
3354
3505
  }
3355
3506
  },
3356
3507
  async (params) => {
@@ -3372,13 +3523,15 @@ function registerQueryConversations(server) {
3372
3523
  conditions.push(`c.platform = ?`);
3373
3524
  args.push(params.platform);
3374
3525
  }
3375
- if (params.after) {
3526
+ const dateFrom = params.date_from ?? params.after;
3527
+ const dateTo = params.date_to ?? params.before;
3528
+ if (dateFrom) {
3376
3529
  conditions.push(`c.timestamp >= ?`);
3377
- args.push(params.after);
3530
+ args.push(dateFrom);
3378
3531
  }
3379
- if (params.before) {
3532
+ if (dateTo) {
3380
3533
  conditions.push(`c.timestamp <= ?`);
3381
- args.push(params.before);
3534
+ args.push(dateTo);
3382
3535
  }
3383
3536
  if (params.channel_id) {
3384
3537
  conditions.push(`c.channel_id = ?`);
@@ -3389,16 +3542,19 @@ function registerQueryConversations(server) {
3389
3542
  args.push(params.thread_id);
3390
3543
  }
3391
3544
  const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
3545
+ const ALLOWED_SORT_COLS = /* @__PURE__ */ new Set(["timestamp", "platform", "sender_id", "sender_name", "created_at"]);
3546
+ const orderBy = buildSortClause(params.sort_by, params.sort_order, "c.timestamp DESC", ALLOWED_SORT_COLS);
3392
3547
  const limit = params.limit ?? 25;
3393
- args.push(limit);
3548
+ const offset = params.offset ?? 0;
3549
+ args.push(limit, offset);
3394
3550
  const result3 = await client.execute({
3395
3551
  sql: `SELECT c.id, c.platform, c.sender_id, c.sender_name, c.sender_phone,
3396
3552
  c.sender_email, c.channel_id, c.thread_id, c.content_text,
3397
3553
  c.agent_response, c.agent_name, c.timestamp
3398
3554
  FROM conversations c
3399
3555
  ${whereClause}
3400
- ORDER BY c.timestamp DESC
3401
- LIMIT ?`,
3556
+ ${orderBy}
3557
+ LIMIT ? OFFSET ?`,
3402
3558
  args
3403
3559
  });
3404
3560
  const conversations = result3.rows.map((row) => ({
@@ -3419,8 +3575,8 @@ function registerQueryConversations(server) {
3419
3575
  }));
3420
3576
  const countResult = await client.execute({
3421
3577
  sql: `SELECT COUNT(*) as total FROM conversations c ${whereClause}`,
3422
- args: args.slice(0, -1)
3423
- // exclude limit
3578
+ args: args.slice(0, -2)
3579
+ // exclude limit and offset
3424
3580
  });
3425
3581
  const total = Number(countResult.rows[0]?.total) || 0;
3426
3582
  return {
@@ -3428,11 +3584,7 @@ function registerQueryConversations(server) {
3428
3584
  {
3429
3585
  type: "text",
3430
3586
  text: JSON.stringify(
3431
- {
3432
- total,
3433
- returned: conversations.length,
3434
- conversations
3435
- },
3587
+ formatUnifiedResponse(conversations, { total, offset, limit, source: "conversations" }),
3436
3588
  null,
3437
3589
  2
3438
3590
  )
@@ -3459,84 +3611,8 @@ function registerQueryConversations(server) {
3459
3611
  // src/mcp/tools/query-company-brain.ts
3460
3612
  init_config();
3461
3613
  import { z as z32 } from "zod";
3462
-
3463
- // src/lib/unified-query.ts
3464
- import { z as z31 } from "zod";
3465
- var PaginationSchema = {
3466
- limit: z31.coerce.number().int().min(1).max(100).optional().describe("Max results to return (default 25, max 100)"),
3467
- offset: z31.coerce.number().int().min(0).optional().describe("Number of results to skip for pagination")
3468
- };
3469
- var DateRangeSchema = {
3470
- date_from: z31.string().optional().describe("Filter records created/updated after this ISO date (inclusive)"),
3471
- date_to: z31.string().optional().describe("Filter records created/updated before this ISO date (inclusive)")
3472
- };
3473
- var TextSearchSchema = {
3474
- text_search: z31.string().optional().describe("Full-text search across relevant fields")
3475
- };
3476
- var SortSchema = {
3477
- sort_by: z31.string().optional().describe("Field to sort by (tool-specific, default varies)"),
3478
- sort_order: z31.enum(["asc", "desc"]).optional().describe("Sort direction (default desc)")
3479
- };
3480
- var SourceFilterSchema = {
3481
- source: z31.string().optional().describe("Filter by data source/platform")
3482
- };
3483
- var StructuredFiltersSchema = {
3484
- structured_filters: z31.record(z31.string(), z31.unknown()).optional().describe(
3485
- "Structured field filters: { field: value } for equality, or { field: { op: 'gt'|'lt'|'gte'|'lte'|'contains'|'neq', value: ... } }"
3486
- )
3487
- };
3488
- var UnifiedQuerySchema = {
3489
- ...PaginationSchema,
3490
- ...DateRangeSchema,
3491
- ...TextSearchSchema,
3492
- ...SortSchema,
3493
- ...SourceFilterSchema,
3494
- ...StructuredFiltersSchema
3495
- };
3496
- function buildStructuredFilterClauses(filters, columnMapping) {
3497
- if (!filters) return [];
3498
- const clauses = [];
3499
- for (const [field, value] of Object.entries(filters)) {
3500
- const column = columnMapping?.[field] ?? field;
3501
- if (value === null || value === void 0) continue;
3502
- if (typeof value === "object" && !Array.isArray(value)) {
3503
- const filter = value;
3504
- if (!filter.op || filter.value === void 0) continue;
3505
- switch (filter.op) {
3506
- case "eq":
3507
- clauses.push({ sql: `${column} = ?`, args: [filter.value] });
3508
- break;
3509
- case "neq":
3510
- clauses.push({ sql: `${column} != ?`, args: [filter.value] });
3511
- break;
3512
- case "gt":
3513
- clauses.push({ sql: `${column} > ?`, args: [filter.value] });
3514
- break;
3515
- case "lt":
3516
- clauses.push({ sql: `${column} < ?`, args: [filter.value] });
3517
- break;
3518
- case "gte":
3519
- clauses.push({ sql: `${column} >= ?`, args: [filter.value] });
3520
- break;
3521
- case "lte":
3522
- clauses.push({ sql: `${column} <= ?`, args: [filter.value] });
3523
- break;
3524
- case "contains":
3525
- clauses.push({ sql: `${column} LIKE ?`, args: [`%${filter.value}%`] });
3526
- break;
3527
- default:
3528
- break;
3529
- }
3530
- } else {
3531
- clauses.push({ sql: `${column} = ?`, args: [value] });
3532
- }
3533
- }
3534
- return clauses;
3535
- }
3536
-
3537
- // src/mcp/tools/query-company-brain.ts
3538
3614
  var FETCH_TIMEOUT_MS = 1e4;
3539
- var QUERY_SCOPE = z32.enum(["raw", "crm", "wiki", "memory", "gateway", "all"]);
3615
+ var QUERY_SCOPE = z32.enum(["raw", "crm", "wiki", "memory", "gateway", "all", "cross"]);
3540
3616
  var QUERY_ACTION = z32.enum(["search", "list_sources", "sql"]);
3541
3617
  var LOCAL_GATEWAY_HTTP_HOSTS = /^(localhost|127\.0\.0\.1|::1|exe-gateway|gateway)$/i;
3542
3618
  function assertSecureGatewayUrlForToken(gatewayUrl, authToken) {
@@ -3577,12 +3653,13 @@ function registerQueryCompanyBrain(server) {
3577
3653
  sql: z32.string().optional().describe("Read-only SELECT/WITH SQL. Required for action=sql."),
3578
3654
  scope: QUERY_SCOPE.default("all").describe("Which data scope to search/read (raw, crm, wiki, memory, gateway, all)"),
3579
3655
  source: z32.string().optional().describe("Filter raw events by source (shopify, asana, etc.)"),
3580
- limit: z32.coerce.number().int().min(1).max(100).default(20).describe("Max results per scope"),
3656
+ ...PaginationSchema,
3581
3657
  ...DateRangeSchema,
3582
3658
  ...SortSchema
3583
3659
  }
3584
3660
  },
3585
- async ({ action, query, sql, scope, source, limit, date_from, date_to, sort_by, sort_order }) => {
3661
+ async ({ action, query, sql, scope, source, limit, offset, date_from, date_to, sort_by, sort_order, ...rest }) => {
3662
+ const userContext = rest._userContext;
3586
3663
  const resolvedAction = action ?? "search";
3587
3664
  if (resolvedAction === "search" && !query?.trim()) {
3588
3665
  return {
@@ -3639,11 +3716,14 @@ function registerQueryCompanyBrain(server) {
3639
3716
  isError: true
3640
3717
  };
3641
3718
  }
3719
+ const resolvedLimit = limit ?? 25;
3720
+ const resolvedOffset = offset ?? 0;
3642
3721
  if (resolvedAction === "search") {
3643
3722
  url.searchParams.set("q", query.trim());
3644
3723
  url.searchParams.set("scope", scope);
3645
3724
  if (source) url.searchParams.set("source", source);
3646
- url.searchParams.set("limit", String(limit));
3725
+ url.searchParams.set("limit", String(resolvedLimit));
3726
+ if (resolvedOffset > 0) url.searchParams.set("offset", String(resolvedOffset));
3647
3727
  if (date_from) url.searchParams.set("date_from", date_from);
3648
3728
  if (date_to) url.searchParams.set("date_to", date_to);
3649
3729
  if (sort_by) url.searchParams.set("sort_by", sort_by);
@@ -3654,9 +3734,10 @@ function registerQueryCompanyBrain(server) {
3654
3734
  method: resolvedAction === "sql" ? "POST" : "GET",
3655
3735
  headers: {
3656
3736
  ...authToken ? { Authorization: `Bearer ${authToken}` } : {},
3657
- ...resolvedAction === "sql" ? { "Content-Type": "application/json" } : {}
3737
+ ...resolvedAction === "sql" ? { "Content-Type": "application/json" } : {},
3738
+ ...userContext ? { "X-User-Id": userContext.userId } : {}
3658
3739
  },
3659
- body: resolvedAction === "sql" ? JSON.stringify({ sql: sql.trim(), max_rows: limit }) : void 0,
3740
+ body: resolvedAction === "sql" ? JSON.stringify({ sql: sql.trim(), max_rows: resolvedLimit }) : void 0,
3660
3741
  signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
3661
3742
  });
3662
3743
  if (!response.ok) {
@@ -3696,6 +3777,57 @@ function registerQueryCompanyBrain(server) {
3696
3777
  );
3697
3778
  }
3698
3779
 
3780
+ // src/lib/gotrue-client.ts
3781
+ var GOTRUE_TIMEOUT_MS = 1e4;
3782
+ async function validateGoTrueToken(token, gotrueUrl) {
3783
+ const url = gotrueUrl ?? process.env.GOTRUE_URL ?? process.env.EXE_GOTRUE_URL;
3784
+ if (!url) return null;
3785
+ try {
3786
+ const res = await fetch(`${url}/user`, {
3787
+ headers: {
3788
+ Authorization: `Bearer ${token}`,
3789
+ "Content-Type": "application/json"
3790
+ },
3791
+ signal: AbortSignal.timeout(GOTRUE_TIMEOUT_MS)
3792
+ });
3793
+ if (!res.ok) return null;
3794
+ const user = await res.json();
3795
+ return user;
3796
+ } catch {
3797
+ return null;
3798
+ }
3799
+ }
3800
+ async function getGoTrueUser(userId, gotrueUrl) {
3801
+ const url = gotrueUrl ?? process.env.GOTRUE_URL ?? process.env.EXE_GOTRUE_URL;
3802
+ const adminToken2 = process.env.GOTRUE_ADMIN_TOKEN ?? process.env.EXE_GOTRUE_ADMIN_TOKEN;
3803
+ if (!url || !adminToken2) return null;
3804
+ try {
3805
+ const res = await fetch(`${url}/admin/users/${userId}`, {
3806
+ headers: {
3807
+ Authorization: `Bearer ${adminToken2}`,
3808
+ "Content-Type": "application/json"
3809
+ },
3810
+ signal: AbortSignal.timeout(GOTRUE_TIMEOUT_MS)
3811
+ });
3812
+ if (!res.ok) return null;
3813
+ return await res.json();
3814
+ } catch {
3815
+ return null;
3816
+ }
3817
+ }
3818
+ async function resolveUserContext(params) {
3819
+ if (params.auth_token) {
3820
+ const user = await validateGoTrueToken(params.auth_token);
3821
+ if (user) return { userId: user.id, user };
3822
+ }
3823
+ if (params.user_id) {
3824
+ const user = await getGoTrueUser(params.user_id);
3825
+ if (user) return { userId: user.id, user };
3826
+ return { userId: params.user_id, user: { id: params.user_id } };
3827
+ }
3828
+ return null;
3829
+ }
3830
+
3699
3831
  // src/mcp/tools/gateway.ts
3700
3832
  function errorResult6(text3) {
3701
3833
  return { content: [{ type: "text", text: text3 }], isError: true };
@@ -3729,11 +3861,25 @@ function registerGateway(server) {
3729
3861
  thread_id: z33.string().optional().describe("Conversation thread filter"),
3730
3862
  limit: z33.coerce.number().int().min(1).max(100).optional().describe("Max results"),
3731
3863
  scope: z33.enum(["raw", "wiki", "memory", "gateway", "all"]).optional().describe("Company Brain scope"),
3732
- source: z33.string().optional().describe("Company Brain raw event source filter")
3864
+ source: z33.string().optional().describe("Company Brain raw event source filter"),
3865
+ auth_token: z33.string().optional().describe("GoTrue JWT for user authentication"),
3866
+ user_id: z33.string().optional().describe("GoTrue user ID (admin lookup fallback)")
3733
3867
  }
3734
3868
  }, async (input, extra) => {
3735
3869
  const action = input.action;
3736
- const { action: _action, ...args } = input;
3870
+ const { action: _action, auth_token, user_id, ...args } = input;
3871
+ if (auth_token || user_id) {
3872
+ const userCtx = await resolveUserContext({
3873
+ auth_token,
3874
+ user_id
3875
+ });
3876
+ if (auth_token && !userCtx) {
3877
+ return errorResult6("Authentication failed \u2014 invalid GoTrue token");
3878
+ }
3879
+ if (userCtx) {
3880
+ args._userContext = userCtx;
3881
+ }
3882
+ }
3737
3883
  let toolName;
3738
3884
  if (action === "send_whatsapp") {
3739
3885
  if (!Array.isArray(args.recipients) || args.recipients.length === 0 || !args.message) {
@@ -4906,7 +5052,7 @@ async function getAgentSessionLoad() {
4906
5052
  return { sessions: [], totalLive: 0, busySessions: 0, idleSessions: 0 };
4907
5053
  }
4908
5054
  const { getClient: getClient2 } = await import("./lib/database.js");
4909
- const { sessionScopeFilter: sessionScopeFilter2 } = await import("./task-scope-2L5DLU6T.js");
5055
+ const { sessionScopeFilter: sessionScopeFilter2 } = await import("./task-scope-RMJLXJ7S.js");
4910
5056
  const client = getClient2();
4911
5057
  const scope = sessionScopeFilter2();
4912
5058
  for (const s of liveAgentSessions) {
@@ -6508,7 +6654,7 @@ function registerCreateTrigger(server) {
6508
6654
  }
6509
6655
  },
6510
6656
  async ({ name, event, conditions, actions, project, enabled, schedule, query }) => {
6511
- const { assertFeature: assertFeature2 } = await import("./plan-limits-3FXBGHWT.js");
6657
+ const { assertFeature: assertFeature2 } = await import("./plan-limits-AMJUHUCR.js");
6512
6658
  const gatedActions = {
6513
6659
  send_whatsapp: "external_agents",
6514
6660
  update_wiki: "wiki"
@@ -7272,6 +7418,7 @@ function registerGlobalProcedure(server) {
7272
7418
 
7273
7419
  // src/mcp/tools/config.ts
7274
7420
  var ACTION_TO_TOOL2 = {
7421
+ hire: "hire_employee",
7275
7422
  set_agent_config: "set_agent_config",
7276
7423
  list_employees: "list_employees",
7277
7424
  agent_spend: "get_agent_spend",
@@ -7346,7 +7493,8 @@ function registerConfig(server) {
7346
7493
  description: "Consolidated COO/admin tool for runtime config, system health, licensing, triggers, orchestration import/export, and company procedures.",
7347
7494
  inputSchema: {
7348
7495
  action: z67.enum(Object.keys(ACTION_TO_TOOL2)).describe("Admin/config operation"),
7349
- agent_id: z67.string().optional().describe("Agent id for set_agent_config/agent_spend/session queries"),
7496
+ agent_id: z67.string().optional().describe("Agent id for set_agent_config/agent_spend/session queries/hire"),
7497
+ role: z67.string().optional().describe("Role template for action=hire: coo, cto, cmo, gm, principal-engineer, content-specialist, ai-specialist, staff-code-reviewer"),
7350
7498
  runtime: z67.string().optional().describe("Runtime for set_agent_config"),
7351
7499
  model: z67.string().optional().describe("Model for set_agent_config"),
7352
7500
  reasoning_effort: z67.string().optional().describe("Reasoning effort for Codex agents"),
@@ -7398,6 +7546,70 @@ function registerConfig(server) {
7398
7546
  if (action === "activate_license" && !args.license_key) return errorResult8('config action "activate_license" requires license_key');
7399
7547
  if (action === "create_trigger" && (!args.name || !args.event || !Array.isArray(args.actions))) return errorResult8('config action "create_trigger" requires name, event, and actions');
7400
7548
  if ((action === "company_procedure" || action === "global_procedure") && args.action === "store" && (!args.title || !args.content)) return errorResult8(`config action "${action}" subaction=store requires title and content`);
7549
+ if (action === "hire") {
7550
+ const employeeName = args.agent_id?.toLowerCase().trim();
7551
+ const role = args.role ?? "specialist";
7552
+ if (!employeeName) return errorResult8('config action "hire" requires agent_id (employee name)');
7553
+ try {
7554
+ const { validateEmployeeName, hireEmployee, registerBinSymlinks } = await import("./lib/employees.js");
7555
+ const validation = validateEmployeeName(employeeName);
7556
+ if (!validation.valid) return errorResult8(`Invalid name: ${validation.error}`);
7557
+ const { loadEmployeesSync: loadEmployeesSync2 } = await import("./lib/employees.js");
7558
+ const existing = loadEmployeesSync2();
7559
+ if (existing.some((e) => e.name === employeeName)) return errorResult8(`Employee "${employeeName}" already exists.`);
7560
+ try {
7561
+ const { assertEmployeeLimit: assertEmployeeLimit2 } = await import("./plan-limits-AMJUHUCR.js");
7562
+ await assertEmployeeLimit2();
7563
+ } catch (e) {
7564
+ return errorResult8(e instanceof Error ? e.message : "Employee limit reached.");
7565
+ }
7566
+ await hireEmployee({
7567
+ name: employeeName,
7568
+ role,
7569
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
7570
+ templateName: role,
7571
+ templateVersion: 1
7572
+ });
7573
+ try {
7574
+ const { getTemplate: getIdentityTemplate, getTemplateForTitle } = await import("./lib/identity-templates.js");
7575
+ const { identityPath } = await import("./lib/identity.js");
7576
+ const { existsSync: existsSync10, mkdirSync: mkdirSync4, writeFileSync: writeFileSync5 } = await import("fs");
7577
+ const path18 = await import("path");
7578
+ const template = getIdentityTemplate(role) ?? getTemplateForTitle(role);
7579
+ const idPath = identityPath(employeeName);
7580
+ const dir = path18.dirname(idPath);
7581
+ if (!existsSync10(dir)) mkdirSync4(dir, { recursive: true });
7582
+ if (template) {
7583
+ writeFileSync5(idPath, template.replace(/^agent_id: \w+/m, `agent_id: ${employeeName}`), "utf-8");
7584
+ } else {
7585
+ writeFileSync5(idPath, `---
7586
+ role: ${role}
7587
+ title: ${role}
7588
+ agent_id: ${employeeName}
7589
+ org_level: specialist
7590
+ ---
7591
+
7592
+ You are ${employeeName}. Role: ${role}.`, "utf-8");
7593
+ }
7594
+ } catch {
7595
+ }
7596
+ try {
7597
+ registerBinSymlinks(employeeName);
7598
+ } catch {
7599
+ }
7600
+ try {
7601
+ const { generateSessionWrappers } = await import("./lib/session-wrappers.js");
7602
+ const { resolvePackageRoot } = await import("./installer-3RTZXZ57.js");
7603
+ generateSessionWrappers(resolvePackageRoot());
7604
+ } catch {
7605
+ }
7606
+ return {
7607
+ content: [{ type: "text", text: `\u2705 Hired ${employeeName} (role: ${role}). Identity written, launchers registered. Dispatch work with create_task(assigned_to="${employeeName}").` }]
7608
+ };
7609
+ } catch (e) {
7610
+ return errorResult8(`Hire failed: ${e instanceof Error ? e.message : String(e)}`);
7611
+ }
7612
+ }
7401
7613
  const toolName = ACTION_TO_TOOL2[action];
7402
7614
  const tool = legacy.get(toolName);
7403
7615
  if (!tool) return errorResult8(`Legacy config handler not found for action "${action}" (${toolName})`);
@@ -7423,7 +7635,7 @@ function registerListWikiPages(server) {
7423
7635
  }
7424
7636
  },
7425
7637
  async ({ workspace, folder }) => {
7426
- const { assertFeature: assertFeature2 } = await import("./plan-limits-3FXBGHWT.js");
7638
+ const { assertFeature: assertFeature2 } = await import("./plan-limits-AMJUHUCR.js");
7427
7639
  await assertFeature2("wiki");
7428
7640
  const apiUrl = process.env.EXE_WIKI_API_URL;
7429
7641
  const apiKey = process.env.EXE_WIKI_API_KEY;
@@ -7523,7 +7735,7 @@ function registerGetWikiPage(server) {
7523
7735
  }
7524
7736
  },
7525
7737
  async ({ workspace, document_id, title }) => {
7526
- const { assertFeature: assertFeature2 } = await import("./plan-limits-3FXBGHWT.js");
7738
+ const { assertFeature: assertFeature2 } = await import("./plan-limits-AMJUHUCR.js");
7527
7739
  await assertFeature2("wiki");
7528
7740
  const apiUrl = process.env.EXE_WIKI_API_URL;
7529
7741
  const apiKey = process.env.EXE_WIKI_API_KEY;
@@ -7718,7 +7930,7 @@ function registerWiki(server) {
7718
7930
  if (!legacyToolName) return errorResult9(`Unknown wiki action: ${String(input.action)}`);
7719
7931
  const { action: _action, user_id, ...legacyArgs } = input;
7720
7932
  if (user_id && legacyArgs.workspace) {
7721
- const { checkWikiAccess } = await import("./wiki-acl-RVCO4WSP.js");
7933
+ const { checkWikiAccess } = await import("./wiki-acl-P7WEIMJV.js");
7722
7934
  const { allowed } = await checkWikiAccess(
7723
7935
  String(user_id),
7724
7936
  String(legacyArgs.workspace),
@@ -8569,9 +8781,10 @@ function registerCrm(server) {
8569
8781
  ...PaginationSchema,
8570
8782
  ...DateRangeSchema,
8571
8783
  ...TextSearchSchema,
8572
- ...SortSchema
8784
+ ...SortSchema,
8785
+ ...StructuredFiltersSchema
8573
8786
  }
8574
- }, async ({ action, id, query, table, limit, offset, date_from, date_to, text_search, sort_by, sort_order }) => {
8787
+ }, async ({ action, id, query, table, limit, offset, date_from, date_to, text_search, sort_by, sort_order, structured_filters }) => {
8575
8788
  try {
8576
8789
  if (action === "get_person" && !id && !query) return text('crm action "get_person" requires id or query', true);
8577
8790
  if (action === "describe_table" && !table) return text('crm action "describe_table" requires table', true);
@@ -8625,15 +8838,38 @@ function registerCrm(server) {
8625
8838
  args.push(date_to);
8626
8839
  clauses.push(`p.created_at <= $${args.length}`);
8627
8840
  }
8841
+ if (structured_filters && typeof structured_filters === "object") {
8842
+ const sfClauses = buildStructuredFilterClauses(
8843
+ structured_filters
8844
+ );
8845
+ for (const sf of sfClauses) {
8846
+ args.push(...sf.args);
8847
+ let pgSql = sf.sql;
8848
+ let paramIdx = args.length - sf.args.length;
8849
+ pgSql = pgSql.replace(/\?/g, () => `$${++paramIdx}`);
8850
+ clauses.push(`p.${pgSql}`);
8851
+ }
8852
+ }
8628
8853
  const where = clauses.length > 0 ? `WHERE ${clauses.join(" AND ")}` : "";
8629
8854
  const orderCol = sort_by && /^[a-zA-Z_]+$/.test(sort_by) ? `p.${sort_by}` : "(p.id)::text";
8630
8855
  const orderDir = sort_order === "asc" ? "ASC" : "DESC";
8856
+ const countArgs = [...args];
8857
+ const countRows = await prisma.$queryRawUnsafe(
8858
+ `SELECT COUNT(*)::int AS total FROM ${relation} p ${where}`,
8859
+ ...countArgs
8860
+ );
8861
+ const total = Number(countRows[0]?.total) || 0;
8631
8862
  args.push(lim, off);
8632
8863
  const rows = await prisma.$queryRawUnsafe(
8633
8864
  `SELECT to_jsonb(p) AS person FROM ${relation} p ${where} ORDER BY ${orderCol} ${orderDir} LIMIT $${args.length - 1} OFFSET $${args.length}`,
8634
8865
  ...args
8635
8866
  );
8636
- return text(JSON.stringify({ people: rows.map((r) => r.person ?? r) }, null, 2));
8867
+ const people = rows.map((r) => r.person ?? r);
8868
+ return text(JSON.stringify(
8869
+ formatUnifiedResponse(people, { total, offset: off, limit: lim, source: "crm" }),
8870
+ null,
8871
+ 2
8872
+ ));
8637
8873
  } catch (err) {
8638
8874
  return text(`crm failed: ${err instanceof Error ? err.message : String(err)}`, true);
8639
8875
  }
@@ -8853,7 +9089,7 @@ function registerWorkflowTool(server) {
8853
9089
  getWorkflowInstance,
8854
9090
  listWorkflowInstances,
8855
9091
  approveWorkflowStep
8856
- } = await import("./workflow-engine-7W4MSNBF.js");
9092
+ } = await import("./workflow-engine-EPWKDGHR.js");
8857
9093
  try {
8858
9094
  switch (input.action) {
8859
9095
  case "create_workflow": {
@@ -9083,10 +9319,30 @@ function buildMarkdown(input) {
9083
9319
  section("Local patch diff", input.localPatchDiff)
9084
9320
  ].join("\n");
9085
9321
  }
9322
+ function prepareUpstreamPayload(payload) {
9323
+ const redacted = { ...payload };
9324
+ if (redacted.agent_id) {
9325
+ redacted.agent_id = crypto5.createHash("sha256").update(String(redacted.agent_id)).digest("hex").slice(0, 12);
9326
+ }
9327
+ if (redacted.project_name) {
9328
+ redacted.project_name = crypto5.createHash("sha256").update(String(redacted.project_name)).digest("hex").slice(0, 12);
9329
+ }
9330
+ delete redacted.agent_role;
9331
+ try {
9332
+ const { encryptSyncBlob, isSyncCryptoInitialized } = (init_crypto(), __toCommonJS(crypto_exports));
9333
+ if (isSyncCryptoInitialized()) {
9334
+ const jsonBuf = Buffer.from(JSON.stringify(redacted), "utf-8");
9335
+ const encrypted = encryptSyncBlob(jsonBuf);
9336
+ return { body: JSON.stringify({ encrypted, version: 1 }), contentType: "application/json", encrypted: true };
9337
+ }
9338
+ } catch {
9339
+ }
9340
+ return { body: JSON.stringify(redacted), contentType: "application/json", encrypted: false };
9341
+ }
9086
9342
  async function maybeSendUpstream(payload) {
9087
9343
  const config = await loadConfig();
9088
9344
  const routerUrl = process.env.API_ROUTER_URL?.replace(/\/+$/, "");
9089
- const endpoint2 = config.support?.bugReportEndpoint || process.env.EXE_BUG_REPORT_ENDPOINT || (routerUrl ? `${routerUrl}/v1/support/bug-reports` : "https://askexe.com/v1/support/bug-reports");
9345
+ const endpoint2 = config.support?.bugReportEndpoint || process.env.EXE_BUG_REPORT_ENDPOINT || (routerUrl ? `${routerUrl}/v1/support/bug-reports` : "https://cloud.askexe.com/v1/support/bug-reports");
9090
9346
  const token = config.support?.bugReportToken || process.env.EXE_BUG_REPORT_TOKEN;
9091
9347
  const licenseKey = loadLicense() || process.env.EXE_LICENSE_KEY || config.cloud?.apiKey;
9092
9348
  const licenseToken = readCachedLicenseToken();
@@ -9098,19 +9354,21 @@ async function maybeSendUpstream(payload) {
9098
9354
  if (parsed.protocol !== "https:" && !["localhost", "127.0.0.1", "::1"].includes(parsed.hostname)) {
9099
9355
  return "failed: insecure endpoint rejected";
9100
9356
  }
9357
+ const { body, contentType, encrypted } = prepareUpstreamPayload(payload);
9101
9358
  const response = await fetch(parsed, {
9102
9359
  method: "POST",
9103
9360
  headers: {
9104
- "content-type": "application/json",
9361
+ "content-type": contentType,
9105
9362
  ...token ? { authorization: `Bearer ${token}` } : {},
9106
9363
  ...licenseKey ? { "x-exe-license-key": licenseKey } : {},
9107
- ...licenseToken ? { "x-exe-license-token": licenseToken } : {}
9364
+ ...licenseToken ? { "x-exe-license-token": licenseToken } : {},
9365
+ ...encrypted ? { "x-exe-encrypted": "aes-256-gcm" } : {}
9108
9366
  },
9109
- body: JSON.stringify(payload),
9367
+ body,
9110
9368
  signal: AbortSignal.timeout(1e4)
9111
9369
  });
9112
9370
  if (!response.ok) return `failed: HTTP ${response.status}`;
9113
- return "sent";
9371
+ return encrypted ? "sent (encrypted)" : "sent (redacted)";
9114
9372
  } catch (err) {
9115
9373
  return `failed: ${err instanceof Error ? err.message : String(err)}`;
9116
9374
  }
@@ -9305,7 +9563,7 @@ function buildMarkdown2(input) {
9305
9563
  async function maybeSendUpstream2(payload) {
9306
9564
  const config = await loadConfig();
9307
9565
  const routerUrl = process.env.API_ROUTER_URL?.replace(/\/+$/, "");
9308
- const endpoint2 = config.support?.featureRequestEndpoint || process.env.EXE_FEATURE_REQUEST_ENDPOINT || (routerUrl ? `${routerUrl}/v1/support/feature-requests` : "https://askexe.com/v1/support/feature-requests");
9566
+ const endpoint2 = config.support?.featureRequestEndpoint || process.env.EXE_FEATURE_REQUEST_ENDPOINT || (routerUrl ? `${routerUrl}/v1/support/feature-requests` : "https://cloud.askexe.com/v1/support/feature-requests");
9309
9567
  const token = config.support?.featureRequestToken || process.env.EXE_FEATURE_REQUEST_TOKEN;
9310
9568
  const licenseKey = loadLicense() || process.env.EXE_LICENSE_KEY || config.cloud?.apiKey;
9311
9569
  const licenseToken = readCachedLicenseToken();
@@ -9529,7 +9787,7 @@ function registerSupportTools(server) {
9529
9787
  isError: true
9530
9788
  };
9531
9789
  }
9532
- const endpoint2 = new URL("https://askexe.com/v1/support/my-reports");
9790
+ const endpoint2 = new URL("https://cloud.askexe.com/v1/support/my-reports");
9533
9791
  endpoint2.searchParams.set("status", status2);
9534
9792
  endpoint2.searchParams.set("limit", String(limit));
9535
9793
  const headers = { "content-type": "application/json" };
@@ -9595,7 +9853,7 @@ function registerSupportTools(server) {
9595
9853
  isError: true
9596
9854
  };
9597
9855
  }
9598
- const endpoint2 = new URL("https://askexe.com/v1/support/my-feature-requests");
9856
+ const endpoint2 = new URL("https://cloud.askexe.com/v1/support/my-feature-requests");
9599
9857
  endpoint2.searchParams.set("status", status2);
9600
9858
  endpoint2.searchParams.set("limit", String(limit));
9601
9859
  const headers = { "content-type": "application/json" };
@@ -10002,7 +10260,7 @@ function registerCodeContext(server) {
10002
10260
 
10003
10261
  // src/mcp/tools/support-inbox.ts
10004
10262
  import { z as z89 } from "zod";
10005
- var DEFAULT_ENDPOINT = "https://askexe.com/admin/support/bug-reports";
10263
+ var DEFAULT_ENDPOINT = "https://cloud.askexe.com/admin/support/bug-reports";
10006
10264
  var STATUS = z89.enum(["open", "triaged", "fixed", "closed", "wontfix"]);
10007
10265
  function adminToken() {
10008
10266
  return process.env.ASKEXE_SUPPORT_ADMIN_TOKEN || process.env.EXE_SUPPORT_ADMIN_TOKEN;
@@ -10424,6 +10682,21 @@ function registerDiagnostics(server) {
10424
10682
  if (action === "drift") {
10425
10683
  return handleDrift(input);
10426
10684
  }
10685
+ if (action === "audit_trail") {
10686
+ try {
10687
+ const { getClient: getClient2 } = await import("./lib/database.js");
10688
+ const client = await getClient2();
10689
+ const limit = Number(input.limit ?? 50);
10690
+ const result3 = await client.execute({
10691
+ sql: `SELECT id, agent_id, tool_name, decision, reason, timestamp FROM audit_trail ORDER BY timestamp DESC LIMIT ?`,
10692
+ args: [limit]
10693
+ });
10694
+ const rows = result3.rows.map((r) => `[${r.timestamp}] ${r.agent_id} | ${r.tool_name} \u2192 ${r.decision}${r.reason ? ` (${r.reason})` : ""}`).join("\n");
10695
+ return { content: [{ type: "text", text: rows || "No audit trail entries." }] };
10696
+ } catch (err) {
10697
+ return { content: [{ type: "text", text: `Audit trail query failed: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
10698
+ }
10699
+ }
10427
10700
  const handler = handlers.get(action);
10428
10701
  if (!handler) {
10429
10702
  return {