@agenticmail/enterprise 0.5.319 → 0.5.320

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 (321) hide show
  1. package/README.md +118 -38
  2. package/dist/agent-heartbeat-3FWNHZFX.js +510 -0
  3. package/dist/agent-heartbeat-4RWHZR7H.js +510 -0
  4. package/dist/agent-heartbeat-6ZGB5ILY.js +510 -0
  5. package/dist/agent-heartbeat-BIVHLKFM.js +510 -0
  6. package/dist/agent-heartbeat-HRKVFK2T.js +510 -0
  7. package/dist/agent-heartbeat-JC5GWVXD.js +510 -0
  8. package/dist/agent-heartbeat-K6A4HMHB.js +510 -0
  9. package/dist/agent-heartbeat-LCDXWFVB.js +510 -0
  10. package/dist/agent-heartbeat-P7HZCZAQ.js +510 -0
  11. package/dist/agent-heartbeat-PUIRSNIO.js +510 -0
  12. package/dist/agent-heartbeat-SN5ILQ6Y.js +510 -0
  13. package/dist/agent-heartbeat-TW5YTDYC.js +510 -0
  14. package/dist/agent-heartbeat-Z2QQXROL.js +510 -0
  15. package/dist/agent-notify-OEQBCZLN.js +43 -0
  16. package/dist/{agent-tools-263HM5QU.js → agent-tools-3W7XLUYA.js} +1 -1
  17. package/dist/agent-tools-4QK7LLNP.js +9 -0
  18. package/dist/agent-tools-54VZGT6L.js +9 -0
  19. package/dist/{agent-tools-AT4D276V.js → agent-tools-AYYDPO27.js} +7 -7
  20. package/dist/{agent-tools-MSTAPX2I.js → agent-tools-F2X47FKF.js} +7 -7
  21. package/dist/{agent-tools-FA26SY5O.js → agent-tools-O6W3QAZL.js} +11 -6
  22. package/dist/agent-tools-OAWVZBMW.js +9 -0
  23. package/dist/agent-tools-QCCU74PN.js +13949 -0
  24. package/dist/chunk-2LHUARN6.js +4929 -0
  25. package/dist/chunk-2WVCNCYC.js +5087 -0
  26. package/dist/{chunk-6PWDS7KY.js → chunk-3FM6YQUK.js} +20 -20
  27. package/dist/chunk-3UAFHUEC.js +212 -0
  28. package/dist/{chunk-WJO57PMO.js → chunk-46GOWZT4.js} +20 -20
  29. package/dist/{chunk-BNRE7TSX.js → chunk-5KYJAUZV.js} +3 -3
  30. package/dist/chunk-6C5PKREN.js +467 -0
  31. package/dist/{chunk-447MTPZF.js → chunk-6ZMLNEHB.js} +3 -3
  32. package/dist/chunk-BPZQT5N5.js +25652 -0
  33. package/dist/chunk-BQM7MBPS.js +1380 -0
  34. package/dist/{chunk-ZRFKGPIU.js → chunk-C52OQNNY.js} +20 -20
  35. package/dist/chunk-C7HGQF4Y.js +25652 -0
  36. package/dist/chunk-CAHNZGGK.js +25656 -0
  37. package/dist/{chunk-FL3CH3ET.js → chunk-CK7R6UHE.js} +51 -27
  38. package/dist/chunk-D36RPWB7.js +25652 -0
  39. package/dist/{chunk-36NM2B4C.js → chunk-DJK2UPFH.js} +63 -93
  40. package/dist/chunk-DM7FTF7W.js +4929 -0
  41. package/dist/chunk-DMD24UFZ.js +5101 -0
  42. package/dist/{chunk-36XNMIHA.js → chunk-DXZGPUAF.js} +20 -20
  43. package/dist/chunk-F46WB5IL.js +5087 -0
  44. package/dist/chunk-F5QG5SQH.js +5087 -0
  45. package/dist/{chunk-JGEVQZDR.js → chunk-FLQ5FLHW.js} +13 -16
  46. package/dist/chunk-H7GP733U.js +5087 -0
  47. package/dist/{chunk-OZSQLOV6.js → chunk-HHBXWB5U.js} +415 -19
  48. package/dist/{chunk-D24JY75H.js → chunk-IMXS4N6W.js} +3 -3
  49. package/dist/{chunk-6PVBV6ZP.js → chunk-JNMDD7JY.js} +3 -3
  50. package/dist/chunk-JTV5LA47.js +1519 -0
  51. package/dist/chunk-KV6G7NZX.js +1519 -0
  52. package/dist/chunk-MU5MEBIK.js +1519 -0
  53. package/dist/chunk-NLT5MC7X.js +465 -0
  54. package/dist/{chunk-GTFZZUXX.js → chunk-NVLYIM4J.js} +51 -27
  55. package/dist/{chunk-6G5SXLXC.js → chunk-NZY2BIZH.js} +63 -93
  56. package/dist/chunk-O42L6G67.js +1519 -0
  57. package/dist/chunk-OCNERGGM.js +4891 -0
  58. package/dist/chunk-OJSNHONE.js +1519 -0
  59. package/dist/{chunk-2TAZJWJN.js → chunk-OWL3QVH7.js} +18 -0
  60. package/dist/{chunk-P3HVY2HS.js → chunk-OWTLNV4Q.js} +382 -7
  61. package/dist/chunk-PCNYEP6T.js +4891 -0
  62. package/dist/{chunk-YL3Z5KPR.js → chunk-PI4AQ4Z6.js} +438 -15
  63. package/dist/chunk-PN3EGTCA.js +194 -0
  64. package/dist/chunk-Q37UKNRC.js +1519 -0
  65. package/dist/chunk-QXTC6J7H.js +5087 -0
  66. package/dist/{chunk-SPBQVNDI.js → chunk-RKERL5LZ.js} +25 -21
  67. package/dist/chunk-RVBK2IOX.js +25652 -0
  68. package/dist/chunk-SAKODCZ5.js +4891 -0
  69. package/dist/{chunk-XV4TU65E.js → chunk-SALGFC5L.js} +51 -27
  70. package/dist/chunk-STGWZ2MS.js +1519 -0
  71. package/dist/chunk-UY3ZVQDP.js +25652 -0
  72. package/dist/chunk-V6OSD62M.js +5087 -0
  73. package/dist/chunk-VP6YAHX4.js +1519 -0
  74. package/dist/chunk-WDYJOEAI.js +5087 -0
  75. package/dist/chunk-WEAFQNOS.js +195 -0
  76. package/dist/chunk-XKUSAZGP.js +5087 -0
  77. package/dist/chunk-Z6K5FKAB.js +548 -0
  78. package/dist/chunk-ZGE3XAXY.js +1519 -0
  79. package/dist/chunk-ZGYVXYQQ.js +3296 -0
  80. package/dist/cli-agent-7TB2BWS6.js +2370 -0
  81. package/dist/cli-agent-AKXFFST2.js +2370 -0
  82. package/dist/cli-agent-DZTKLITB.js +2357 -0
  83. package/dist/cli-agent-FOF7PFEP.js +2357 -0
  84. package/dist/cli-agent-H74M2ZYN.js +2357 -0
  85. package/dist/cli-agent-HORWVPHB.js +2370 -0
  86. package/dist/cli-agent-HSZT6SKF.js +2423 -0
  87. package/dist/cli-agent-JLUQ4ZU6.js +2424 -0
  88. package/dist/cli-agent-MVCDH4HV.js +2370 -0
  89. package/dist/cli-agent-NZXOEPJ2.js +2357 -0
  90. package/dist/cli-agent-PADN3QRC.js +2357 -0
  91. package/dist/cli-agent-QAYEX3BE.js +2441 -0
  92. package/dist/cli-agent-QT64DT5J.js +2370 -0
  93. package/dist/cli-agent-TFL2M6UK.js +2424 -0
  94. package/dist/cli-agent-UIKXATTD.js +2357 -0
  95. package/dist/cli-agent-UJN6FYTO.js +2370 -0
  96. package/dist/cli-agent-VIQAYVY4.js +2357 -0
  97. package/dist/cli-agent-WNWFVOFM.js +2370 -0
  98. package/dist/cli-agent-XBQX67VJ.js +2423 -0
  99. package/dist/cli-agent-ZLSC6FF4.js +2357 -0
  100. package/dist/cli-serve-2IL5DTEY.js +153 -0
  101. package/dist/cli-serve-47N5UKKW.js +153 -0
  102. package/dist/cli-serve-4XGZFUV2.js +140 -0
  103. package/dist/cli-serve-6OT3UEAN.js +140 -0
  104. package/dist/cli-serve-7L6EY5UH.js +153 -0
  105. package/dist/cli-serve-BDGOOOKQ.js +260 -0
  106. package/dist/cli-serve-BFNIW2LF.js +153 -0
  107. package/dist/cli-serve-C7MN6U5Q.js +153 -0
  108. package/dist/cli-serve-CR3OY3IM.js +153 -0
  109. package/dist/cli-serve-DAJFRWQ7.js +153 -0
  110. package/dist/cli-serve-FW6FHFW4.js +153 -0
  111. package/dist/cli-serve-GEEOQS77.js +153 -0
  112. package/dist/cli-serve-H562I3ZK.js +153 -0
  113. package/dist/cli-serve-HDQZF4C4.js +153 -0
  114. package/dist/cli-serve-LICAOMEB.js +140 -0
  115. package/dist/cli-serve-LLGYLWFS.js +153 -0
  116. package/dist/cli-serve-N3OISDNB.js +153 -0
  117. package/dist/cli-serve-TIZ27EVR.js +153 -0
  118. package/dist/cli-serve-TUNI2RCN.js +153 -0
  119. package/dist/cli-serve-WNOZMAWD.js +153 -0
  120. package/dist/cli-validate-Z726VJCN.js +150 -0
  121. package/dist/cli.js +4 -4
  122. package/dist/connection-manager-KAWEUWUR.js +9 -0
  123. package/dist/dashboard/app.js +9 -3
  124. package/dist/dashboard/components/knowledge-link.js +15 -0
  125. package/dist/dashboard/components/settings-help.js +4 -2
  126. package/dist/dashboard/docs/agent-deployment.html +33 -1
  127. package/dist/dashboard/docs/settings-network.html +321 -0
  128. package/dist/dashboard/docs/settings-security.html +347 -0
  129. package/dist/dashboard/docs/settings-tool-security.html +176 -0
  130. package/dist/dashboard/docs/settings.html +36 -16
  131. package/dist/dashboard/pages/agent-detail/deployment.js +39 -6
  132. package/dist/dashboard/pages/agent-detail/tools.js +10 -0
  133. package/dist/dashboard/pages/database-access.js +4 -3
  134. package/dist/dashboard/pages/settings.js +174 -37
  135. package/dist/dashboard/pages/task-pipeline.js +400 -843
  136. package/dist/db-adapter-2T56ORSD.js +7 -0
  137. package/dist/db-adapter-IRHOUMVC.js +7 -0
  138. package/dist/index.js +41 -41
  139. package/dist/microsoft-VREAZ7M2.js +3955 -0
  140. package/dist/routes-3MMLQTB6.js +90 -0
  141. package/dist/routes-4ZUIJ4HE.js +90 -0
  142. package/dist/routes-5MXHKKH4.js +90 -0
  143. package/dist/routes-64NJFK3B.js +90 -0
  144. package/dist/routes-6AKQ2LBV.js +90 -0
  145. package/dist/routes-CRRBUDO4.js +90 -0
  146. package/dist/routes-DIAF3MC3.js +90 -0
  147. package/dist/routes-KMUNU6CY.js +90 -0
  148. package/dist/routes-LRRLXIZR.js +90 -0
  149. package/dist/routes-N647AJYG.js +90 -0
  150. package/dist/routes-SSSELAAR.js +90 -0
  151. package/dist/routes-STERVGKJ.js +90 -0
  152. package/dist/routes-ZEZZACZP.js +90 -0
  153. package/dist/runtime-5EQN4GFM.js +45 -0
  154. package/dist/runtime-5LP7PUD4.js +45 -0
  155. package/dist/runtime-6BULDBR3.js +45 -0
  156. package/dist/runtime-6YEENDN3.js +45 -0
  157. package/dist/runtime-7LQFRG3B.js +45 -0
  158. package/dist/runtime-AMXJU2MB.js +45 -0
  159. package/dist/runtime-D6WSE7FG.js +45 -0
  160. package/dist/runtime-EYVN7NFJ.js +45 -0
  161. package/dist/runtime-F6RPWQVW.js +45 -0
  162. package/dist/runtime-FYMJURFC.js +45 -0
  163. package/dist/runtime-JRNBL4O4.js +45 -0
  164. package/dist/runtime-OM2NIBMI.js +45 -0
  165. package/dist/runtime-QWPVD7CY.js +45 -0
  166. package/dist/runtime-YLIIPTE4.js +45 -0
  167. package/dist/runtime-YU6P22CG.js +45 -0
  168. package/dist/screen-unlock-4RPZBHOI.js +118 -0
  169. package/dist/server-AMCSXINC.js +28 -0
  170. package/dist/server-CU6LVQS4.js +28 -0
  171. package/dist/server-DFYGH2CV.js +28 -0
  172. package/dist/server-EELWOC3X.js +28 -0
  173. package/dist/server-EN5E2OWQ.js +28 -0
  174. package/dist/server-GW2HYJYI.js +28 -0
  175. package/dist/server-J25NCRWJ.js +28 -0
  176. package/dist/server-JDGNOTFV.js +28 -0
  177. package/dist/server-NE5HD5DJ.js +28 -0
  178. package/dist/server-NQOT7W77.js +28 -0
  179. package/dist/server-PWE5PQTR.js +28 -0
  180. package/dist/server-Q2Q32H2B.js +28 -0
  181. package/dist/server-Q77ME7TL.js +28 -0
  182. package/dist/server-WLLH4WST.js +28 -0
  183. package/dist/server-WTUJ2O3F.js +28 -0
  184. package/dist/server-X4CJTHHF.js +28 -0
  185. package/dist/server-XK3ILCJC.js +28 -0
  186. package/dist/server-ZRD3NDJE.js +28 -0
  187. package/dist/setup-44VBAO4J.js +20 -0
  188. package/dist/setup-4ONNQBWB.js +20 -0
  189. package/dist/setup-4OSBXSCL.js +20 -0
  190. package/dist/setup-4QFGRBLZ.js +20 -0
  191. package/dist/setup-6766SGAR.js +20 -0
  192. package/dist/setup-AYY24DKM.js +20 -0
  193. package/dist/setup-B34N4HPU.js +20 -0
  194. package/dist/setup-E2YLC2EY.js +20 -0
  195. package/dist/setup-ER6NXTY5.js +20 -0
  196. package/dist/setup-H2AGCBW5.js +20 -0
  197. package/dist/setup-ICOZRKCX.js +20 -0
  198. package/dist/setup-JFTJH7UF.js +20 -0
  199. package/dist/setup-PRFNI6YW.js +20 -0
  200. package/dist/setup-RAHBMYHE.js +20 -0
  201. package/dist/setup-TXPR5UQX.js +20 -0
  202. package/dist/setup-XCJMELVU.js +20 -0
  203. package/dist/setup-XIYEIFVK.js +20 -0
  204. package/dist/setup-Z4PZSHBI.js +20 -0
  205. package/dist/skills-FR7I5V7H.js +16 -0
  206. package/dist/skills-HCVBA6PK.js +16 -0
  207. package/dist/system-prompts-TM7OA32C.js +913 -0
  208. package/dist/task-queue-O7IVZYUO.js +9 -0
  209. package/dist/transport-encryption-2T7PIXKG.js +25 -0
  210. package/ecosystem.config.cjs +120 -0
  211. package/logs/cloudflared-error.log +61 -0
  212. package/logs/cloudflared-out.log +0 -0
  213. package/logs/enterprise-error.log +0 -0
  214. package/logs/enterprise-out.log +3 -0
  215. package/logs/fola-error.log +0 -0
  216. package/logs/fola-out.log +0 -0
  217. package/logs/john-error.log +8 -0
  218. package/logs/john-out.log +0 -0
  219. package/package.json +1 -1
  220. package/src/agent-tools/tool-resolver.ts +50 -61
  221. package/src/agent-tools/tools/enterprise-database.ts +5 -5
  222. package/src/agent-tools/tools/local/dependency-manager.ts +2 -2
  223. package/src/agent-tools/tools/microsoft/graph-api.ts +137 -26
  224. package/src/agent-tools/tools/microsoft/outlook-mail.ts +392 -100
  225. package/src/agent-tools/tools/microsoft/teams.ts +267 -48
  226. package/src/auth/routes.ts +4 -4
  227. package/src/cli-agent.ts +108 -8
  228. package/src/cli-serve.ts +140 -0
  229. package/src/dashboard/app.js +9 -3
  230. package/src/dashboard/components/knowledge-link.js +15 -0
  231. package/src/dashboard/components/settings-help.js +4 -2
  232. package/src/dashboard/docs/agent-deployment.html +33 -1
  233. package/src/dashboard/docs/settings-network.html +321 -0
  234. package/src/dashboard/docs/settings-security.html +347 -0
  235. package/src/dashboard/docs/settings-tool-security.html +176 -0
  236. package/src/dashboard/docs/settings.html +36 -16
  237. package/src/dashboard/pages/agent-detail/deployment.js +39 -6
  238. package/src/dashboard/pages/agent-detail/tools.js +10 -0
  239. package/src/dashboard/pages/database-access.js +4 -3
  240. package/src/dashboard/pages/settings.js +174 -37
  241. package/src/dashboard/pages/task-pipeline.js +400 -843
  242. package/src/database-access/agent-tools.ts +78 -63
  243. package/src/database-access/connection-manager.ts +13 -2
  244. package/src/database-access/routes.ts +13 -1
  245. package/src/db/adapter.ts +1 -0
  246. package/src/engine/agent-memory.ts +2 -1
  247. package/src/engine/agent-notify.ts +50 -0
  248. package/src/engine/agent-routes.ts +257 -4
  249. package/src/engine/db-adapter.ts +16 -0
  250. package/src/engine/lifecycle.ts +4 -0
  251. package/src/engine/routes.ts +4 -3
  252. package/src/engine/screen-unlock.ts +136 -0
  253. package/src/engine/skills/database-access.ts +78 -0
  254. package/src/engine/skills/index.ts +3 -2
  255. package/src/engine/skills.ts +2 -0
  256. package/src/engine/task-queue-routes.ts +18 -0
  257. package/src/engine/task-queue.ts +15 -2
  258. package/src/middleware/transport-encryption.ts +1 -4
  259. package/src/runtime/agent-loop.ts +4 -0
  260. package/src/runtime/index.ts +15 -6
  261. package/src/server.ts +14 -1
  262. package/src/system-prompts/google/index.ts +1 -2
  263. package/src/system-prompts/index.ts +1 -1
  264. package/src/system-prompts/microsoft/contacts.ts +34 -0
  265. package/src/system-prompts/microsoft/excel.ts +52 -0
  266. package/src/system-prompts/microsoft/index.ts +31 -0
  267. package/src/system-prompts/microsoft/onedrive.ts +41 -0
  268. package/src/system-prompts/microsoft/onenote.ts +36 -0
  269. package/src/system-prompts/microsoft/outlook-calendar.ts +37 -0
  270. package/src/system-prompts/microsoft/outlook-mail.ts +46 -0
  271. package/src/system-prompts/microsoft/planner.ts +37 -0
  272. package/src/system-prompts/microsoft/powerbi.ts +38 -0
  273. package/src/system-prompts/microsoft/powerpoint.ts +35 -0
  274. package/src/system-prompts/microsoft/sharepoint.ts +44 -0
  275. package/src/system-prompts/microsoft/teams.ts +49 -0
  276. package/src/system-prompts/microsoft/todo.ts +37 -0
  277. package/src/types/hono-env.ts +4 -0
  278. package/dist/agent-tools-LRA7PPXG.js +0 -13922
  279. package/dist/agent-tools-VAU5DOQB.js +0 -13910
  280. package/dist/agent-tools-VWV7OWXU.js +0 -13922
  281. package/dist/chunk-2Z7MWTCX.js +0 -4977
  282. package/dist/chunk-3T4XU3VV.js +0 -5010
  283. package/dist/chunk-445QM4NX.js +0 -5061
  284. package/dist/chunk-5TW3Y7DJ.js +0 -1519
  285. package/dist/chunk-6I7VY3LT.js +0 -5060
  286. package/dist/chunk-6W5EK3UP.js +0 -4977
  287. package/dist/chunk-AQMSHJQT.js +0 -5069
  288. package/dist/chunk-ASSQW7HX.js +0 -5051
  289. package/dist/chunk-CIN27FGC.js +0 -5037
  290. package/dist/chunk-CMXY3NUB.js +0 -4977
  291. package/dist/chunk-DRLMRUDP.js +0 -5052
  292. package/dist/chunk-EHI7Z446.js +0 -1519
  293. package/dist/chunk-FEAILFAQ.js +0 -1519
  294. package/dist/chunk-GA3PYBZL.js +0 -1519
  295. package/dist/chunk-GWX63G5J.js +0 -1519
  296. package/dist/chunk-HHMZ4UY6.js +0 -1519
  297. package/dist/chunk-HVQMNF7E.js +0 -4921
  298. package/dist/chunk-HXM7F3YN.js +0 -1519
  299. package/dist/chunk-K6NGOUXG.js +0 -5060
  300. package/dist/chunk-KPG5WINJ.js +0 -4977
  301. package/dist/chunk-LBCUBYDL.js +0 -1519
  302. package/dist/chunk-LIRQSWLR.js +0 -5014
  303. package/dist/chunk-LRCKO5KE.js +0 -1519
  304. package/dist/chunk-M7XL3DJD.js +0 -5069
  305. package/dist/chunk-MHJULEIQ.js +0 -1519
  306. package/dist/chunk-MJGGW6MC.js +0 -106
  307. package/dist/chunk-MMYBDHDB.js +0 -4921
  308. package/dist/chunk-MQT5FXKD.js +0 -1519
  309. package/dist/chunk-OIMPEQF5.js +0 -4977
  310. package/dist/chunk-OOU7JUYE.js +0 -542
  311. package/dist/chunk-OW4GLBHP.js +0 -1519
  312. package/dist/chunk-Q4K4MMLU.js +0 -4977
  313. package/dist/chunk-RUK4CRPF.js +0 -1519
  314. package/dist/chunk-T7H65XQY.js +0 -1519
  315. package/dist/chunk-TQVFWG57.js +0 -5064
  316. package/dist/chunk-UEPK3IMC.js +0 -1519
  317. package/dist/chunk-VUWTXJH6.js +0 -1519
  318. package/dist/chunk-WCPGGSAD.js +0 -1519
  319. package/dist/chunk-WO63NZOJ.js +0 -1519
  320. package/dist/chunk-YPJDRVUM.js +0 -5064
  321. package/dist/chunk-ZROMH5DL.js +0 -4921
@@ -3,34 +3,35 @@
3
3
  *
4
4
  * Creates tools that agents can use to query databases they have access to.
5
5
  * Each agent only sees connections they've been granted access to.
6
+ *
7
+ * IMPORTANT: execute() must match AgentTool signature: (toolCallId: string, params: any) => Promise<ToolResult>
8
+ * ToolResult = { content: [{ type: 'text', text: string }] }
6
9
  */
7
10
 
8
11
  import type { DatabaseConnectionManager } from './connection-manager.js';
9
12
  import { DATABASE_LABELS } from './types.js';
10
13
 
11
- interface ToolDefinition {
12
- name: string;
13
- description: string;
14
- parameters: Record<string, any>;
15
- execute: (input: any) => Promise<any>;
16
- category?: string;
17
- sideEffects?: string[];
14
+ function jsonResult(data: any) {
15
+ return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }] };
18
16
  }
19
17
 
20
- export function createDatabaseTools(manager: DatabaseConnectionManager, agentId: string): ToolDefinition[] {
21
- const accessList = manager.getAgentAccess(agentId);
22
- if (accessList.length === 0) return [];
18
+ function errorResult(msg: string) {
19
+ return { content: [{ type: 'text' as const, text: JSON.stringify({ error: msg }) }] };
20
+ }
23
21
 
24
- const tools: ToolDefinition[] = [];
22
+ export function createDatabaseTools(manager: DatabaseConnectionManager, agentId: string): any[] {
23
+ const tools: any[] = [];
25
24
 
26
25
  // Tool 1: List available databases
27
26
  tools.push({
28
27
  name: 'db_list_connections',
29
- description: 'List database connections this agent has access to.',
28
+ description: 'List EXTERNAL database connections (Postgres, MySQL, Supabase, etc.) granted to you by your admin. Use this when asked about any named database like "DateGPT", "production", etc.',
30
29
  category: 'database',
30
+ risk: 'low',
31
31
  parameters: { type: 'object', properties: {}, required: [] },
32
- async execute() {
33
- const connections = accessList.map(a => {
32
+ async execute(_toolCallId: string, _params: any) {
33
+ const accessList = manager.getAgentAccess(agentId);
34
+ const connections = accessList.filter(a => a.enabled).map(a => {
34
35
  const conn = manager.getConnection(a.connectionId);
35
36
  if (!conn) return null;
36
37
  return {
@@ -42,58 +43,69 @@ export function createDatabaseTools(manager: DatabaseConnectionManager, agentId:
42
43
  host: conn.host,
43
44
  status: conn.status,
44
45
  permissions: a.permissions,
45
- description: conn.description,
46
+ description: (conn as any).config?.description || conn.description,
46
47
  };
47
48
  }).filter(Boolean);
48
- return { connections };
49
+
50
+ if (connections.length === 0) {
51
+ return jsonResult({ connections: [], message: 'No external database connections granted. Ask your admin to grant access from the Database Access page.' });
52
+ }
53
+ return jsonResult({ connections });
49
54
  },
50
55
  });
51
56
 
52
57
  // Tool 2: Execute SQL query
53
58
  tools.push({
54
59
  name: 'db_query',
55
- description: 'Execute a SQL query on a connected database. Use db_list_connections first to see available databases.',
60
+ description: 'Execute a SQL query on an EXTERNAL database connection granted by your admin. Use db_list_connections first to see available databases and get the connectionId.',
56
61
  category: 'database',
62
+ risk: 'medium',
57
63
  sideEffects: ['database_write'],
58
64
  parameters: {
59
65
  type: 'object',
60
66
  properties: {
61
- connectionId: { type: 'string', description: 'Database connection ID' },
67
+ connectionId: { type: 'string', description: 'Database connection ID (from db_list_connections)' },
62
68
  sql: { type: 'string', description: 'SQL query to execute' },
63
69
  params: { type: 'array', items: { type: 'string' }, description: 'Query parameters (for parameterized queries)' },
64
70
  },
65
71
  required: ['connectionId', 'sql'],
66
72
  },
67
- async execute(input: { connectionId: string; sql: string; params?: any[] }) {
68
- const result = await manager.executeQuery({
69
- connectionId: input.connectionId,
70
- agentId,
71
- operation: 'read',
72
- sql: input.sql,
73
- params: input.params,
74
- });
75
-
76
- if (!result.success) {
77
- return { error: result.error, queryId: result.queryId };
78
- }
73
+ async execute(_toolCallId: string, input: { connectionId: string; sql: string; params?: any[] }) {
74
+ if (!input?.connectionId || !input?.sql) return errorResult('connectionId and sql are required');
75
+
76
+ try {
77
+ const result = await manager.executeQuery({
78
+ connectionId: input.connectionId,
79
+ agentId,
80
+ operation: 'read',
81
+ sql: input.sql,
82
+ params: input.params,
83
+ });
84
+
85
+ if (!result.success) {
86
+ return errorResult(result.error || 'Query failed');
87
+ }
79
88
 
80
- return {
81
- rows: result.rows,
82
- rowCount: result.rowCount,
83
- affectedRows: result.affectedRows,
84
- fields: result.fields,
85
- executionTimeMs: result.executionTimeMs,
86
- truncated: result.truncated,
87
- queryId: result.queryId,
88
- };
89
+ return jsonResult({
90
+ rows: result.rows,
91
+ rowCount: result.rowCount,
92
+ affectedRows: result.affectedRows,
93
+ fields: result.fields,
94
+ executionTimeMs: result.executionTimeMs,
95
+ truncated: result.truncated,
96
+ });
97
+ } catch (e: any) {
98
+ return errorResult(e.message || 'Query execution failed');
99
+ }
89
100
  },
90
101
  });
91
102
 
92
103
  // Tool 3: Describe table schema
93
104
  tools.push({
94
105
  name: 'db_describe_table',
95
- description: 'Get the schema (columns, types, constraints) of a database table.',
106
+ description: 'Get the schema (columns, types, constraints) of a table in an external database.',
96
107
  category: 'database',
108
+ risk: 'low',
97
109
  parameters: {
98
110
  type: 'object',
99
111
  properties: {
@@ -102,11 +114,12 @@ export function createDatabaseTools(manager: DatabaseConnectionManager, agentId:
102
114
  },
103
115
  required: ['connectionId', 'table'],
104
116
  },
105
- async execute(input: { connectionId: string; table: string }) {
117
+ async execute(_toolCallId: string, input: { connectionId: string; table: string }) {
118
+ if (!input?.connectionId || !input?.table) return errorResult('connectionId and table are required');
119
+
106
120
  const conn = manager.getConnection(input.connectionId);
107
- if (!conn) return { error: 'Connection not found' };
121
+ if (!conn) return errorResult('Connection not found');
108
122
 
109
- // Build describe query based on database type
110
123
  let sql: string;
111
124
  switch (conn.type) {
112
125
  case 'postgresql': case 'cockroachdb': case 'supabase': case 'neon':
@@ -119,23 +132,25 @@ export function createDatabaseTools(manager: DatabaseConnectionManager, agentId:
119
132
  sql = `PRAGMA table_info('${input.table.replace(/'/g, "''")}')`;
120
133
  break;
121
134
  default:
122
- return { error: `Schema inspection not supported for ${conn.type}` };
135
+ return errorResult(`Schema inspection not supported for ${conn.type}`);
123
136
  }
124
137
 
125
- return manager.executeQuery({
126
- connectionId: input.connectionId,
127
- agentId,
128
- operation: 'read',
129
- sql,
130
- });
138
+ try {
139
+ const result = await manager.executeQuery({ connectionId: input.connectionId, agentId, operation: 'read', sql });
140
+ if (!result.success) return errorResult(result.error || 'Query failed');
141
+ return jsonResult({ columns: result.rows, table: input.table });
142
+ } catch (e: any) {
143
+ return errorResult(e.message);
144
+ }
131
145
  },
132
146
  });
133
147
 
134
148
  // Tool 4: List tables
135
149
  tools.push({
136
150
  name: 'db_list_tables',
137
- description: 'List all tables in the connected database.',
151
+ description: 'List all tables in an external database connection.',
138
152
  category: 'database',
153
+ risk: 'low',
139
154
  parameters: {
140
155
  type: 'object',
141
156
  properties: {
@@ -143,9 +158,11 @@ export function createDatabaseTools(manager: DatabaseConnectionManager, agentId:
143
158
  },
144
159
  required: ['connectionId'],
145
160
  },
146
- async execute(input: { connectionId: string }) {
161
+ async execute(_toolCallId: string, input: { connectionId: string }) {
162
+ if (!input?.connectionId) return errorResult('connectionId is required');
163
+
147
164
  const conn = manager.getConnection(input.connectionId);
148
- if (!conn) return { error: 'Connection not found' };
165
+ if (!conn) return errorResult('Connection not found');
149
166
 
150
167
  let sql: string;
151
168
  switch (conn.type) {
@@ -158,19 +175,17 @@ export function createDatabaseTools(manager: DatabaseConnectionManager, agentId:
158
175
  case 'sqlite': case 'turso':
159
176
  sql = `SELECT name, type FROM sqlite_master WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%' ORDER BY name`;
160
177
  break;
161
- case 'mongodb':
162
- sql = JSON.stringify({ collection: 'system.namespaces', operation: 'find', filter: {} });
163
- break;
164
178
  default:
165
- return { error: `Table listing not supported for ${conn.type}` };
179
+ return errorResult(`Table listing not supported for ${conn.type}`);
166
180
  }
167
181
 
168
- return manager.executeQuery({
169
- connectionId: input.connectionId,
170
- agentId,
171
- operation: 'read',
172
- sql,
173
- });
182
+ try {
183
+ const result = await manager.executeQuery({ connectionId: input.connectionId, agentId, operation: 'read', sql });
184
+ if (!result.success) return errorResult(result.error || 'Query failed');
185
+ return jsonResult({ tables: result.rows });
186
+ } catch (e: any) {
187
+ return errorResult(e.message);
188
+ }
174
189
  },
175
190
  });
176
191
 
@@ -115,8 +115,8 @@ export class DatabaseConnectionManager {
115
115
  private async dbAll(sql: string, params?: any[]): Promise<any[]> {
116
116
  if (!this.engineDb) return [];
117
117
  if (this.engineDb.all) return this.engineDb.all(sql, params) as Promise<any[]>;
118
- if (this.engineDb.query) {
119
- const result = await this.engineDb.query(sql, params);
118
+ if ((this.engineDb as any).query) {
119
+ const result = await (this.engineDb as any).query(sql, params);
120
120
  return Array.isArray(result) ? result : (result?.rows || []);
121
121
  }
122
122
  // Fallback: execute returns rows for some adapters
@@ -343,6 +343,17 @@ export class DatabaseConnectionManager {
343
343
  return this.configs.get(id);
344
344
  }
345
345
 
346
+ /** Get a human-readable summary of an agent's database connections for system prompts */
347
+ getAgentConnectionSummary(agentId: string): string[] {
348
+ const accesses = this.getAgentAccess(agentId).filter(a => a.enabled);
349
+ return accesses.map(a => {
350
+ const config = this.configs.get(a.connectionId);
351
+ if (!config) return '';
352
+ const perms = a.permissions?.join(', ') || 'read';
353
+ return `"${config.name}" (${config.type}) — permissions: ${perms}`;
354
+ }).filter(Boolean);
355
+ }
356
+
346
357
  listConnections(orgId: string): DatabaseConnectionConfig[] {
347
358
  return [...this.configs.values()].filter(c => c.orgId === orgId);
348
359
  }
@@ -9,6 +9,13 @@ import { Hono } from 'hono';
9
9
  import type { DatabaseConnectionManager } from './connection-manager.js';
10
10
  import type { DatabasePermission } from './types.js';
11
11
 
12
+ async function notifyAgentReload(agentId: string) {
13
+ try {
14
+ const { notifyAgent } = await import('../engine/agent-notify.js');
15
+ await notifyAgent(agentId, 'db-access');
16
+ } catch { /* non-fatal */ }
17
+ }
18
+
12
19
  export function createDatabaseAccessRoutes(manager: DatabaseConnectionManager) {
13
20
  const router = new Hono();
14
21
 
@@ -149,6 +156,9 @@ export function createDatabaseAccessRoutes(manager: DatabaseConnectionManager) {
149
156
  enabled: true,
150
157
  });
151
158
 
159
+ // Notify agent in real-time
160
+ notifyAgentReload(body.agentId).catch(() => {});
161
+
152
162
  return c.json(access, 201);
153
163
  });
154
164
 
@@ -162,7 +172,9 @@ export function createDatabaseAccessRoutes(manager: DatabaseConnectionManager) {
162
172
 
163
173
  /** Revoke agent access */
164
174
  router.delete('/connections/:connId/agents/:agentId', async (c) => {
165
- await manager.revokeAccess(c.req.param('agentId'), c.req.param('connId'));
175
+ const agentId = c.req.param('agentId');
176
+ await manager.revokeAccess(agentId, c.req.param('connId'));
177
+ notifyAgentReload(agentId).catch(() => {});
166
178
  return c.json({ ok: true });
167
179
  });
168
180
 
package/src/db/adapter.ts CHANGED
@@ -42,6 +42,7 @@ export interface Agent {
42
42
  status: 'active' | 'archived' | 'suspended';
43
43
  metadata: Record<string, unknown>;
44
44
  securityOverrides?: Partial<SecurityConfig>;
45
+ client_org_id?: string;
45
46
  createdAt: Date;
46
47
  updatedAt: Date;
47
48
  createdBy: string;
@@ -40,7 +40,8 @@ export type MemorySource =
40
40
  | 'correction'
41
41
  | 'system'
42
42
  | 'context_compaction'
43
- | 'mcp_server_deletion';
43
+ | 'mcp_server_deletion'
44
+ | 'transfer';
44
45
 
45
46
  export const MEMORY_CATEGORIES: Record<MemoryCategory, { label: string; description: string }> = {
46
47
  org_knowledge: {
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Agent Notification — Push config changes to standalone agent processes in real-time.
3
+ *
4
+ * When any config is changed from the dashboard, call notifyAgent() to tell
5
+ * the agent process to reload from DB immediately.
6
+ */
7
+
8
+ import type { AgentLifecycleManager } from './lifecycle.js';
9
+
10
+ type ReloadScope = 'all' | 'config' | 'permissions' | 'db-access' | 'budget' | 'guardrails';
11
+
12
+ /**
13
+ * Notify a standalone agent process to reload its config.
14
+ * Non-blocking — failures are silently ignored (agent may be offline).
15
+ */
16
+ export async function notifyAgent(agentId: string, scope: ReloadScope, lifecycle?: AgentLifecycleManager): Promise<boolean> {
17
+ const port = resolveAgentPort(agentId, lifecycle);
18
+ if (!port) return false;
19
+
20
+ try {
21
+ const resp = await fetch(`http://127.0.0.1:${port}/reload?scope=${scope}`, {
22
+ method: 'POST',
23
+ signal: AbortSignal.timeout(3000),
24
+ });
25
+ if (resp.ok) {
26
+ const data = await resp.json() as any;
27
+ console.log(`[notify] Agent ${agentId} reloaded: ${data.reloaded?.join(', ') || scope}`);
28
+ return true;
29
+ }
30
+ } catch { /* agent offline or unreachable — that's fine */ }
31
+ return false;
32
+ }
33
+
34
+ /**
35
+ * Notify ALL running standalone agents to reload.
36
+ */
37
+ export async function notifyAllAgents(scope: ReloadScope, lifecycle?: AgentLifecycleManager): Promise<void> {
38
+ if (!lifecycle) return;
39
+ const agents = lifecycle.getAllAgents().filter(a => a.state === 'running');
40
+ await Promise.allSettled(agents.map(a => notifyAgent(a.id, scope, lifecycle)));
41
+ }
42
+
43
+ function resolveAgentPort(agentId: string, lifecycle?: AgentLifecycleManager): number | null {
44
+ if (!lifecycle) return null;
45
+ const agent = lifecycle.getAgent(agentId);
46
+ if (!agent) return null;
47
+
48
+ const dep = agent.config?.deployment;
49
+ return dep?.port || dep?.config?.local?.port || null;
50
+ }