@agenticmail/enterprise 0.5.325 → 0.5.327

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 (457) hide show
  1. package/dist/{agent-heartbeat-77N4OOQL.js → agent-heartbeat-ZFKA6GMI.js} +2 -2
  2. package/dist/{agent-tools-BNSTIK4P.js → agent-tools-R6RSBDJQ.js} +25 -25
  3. package/dist/{agenticmail-EDO5XOTP.js → agenticmail-QMWQNUY2.js} +1 -1
  4. package/dist/{browser-tool-JF3LNRGX.js → browser-tool-4KWE37RL.js} +4 -4
  5. package/dist/{chunk-JEGYVXYC.js → chunk-CQV7GGHT.js} +1 -1
  6. package/dist/{chunk-VBTHTPZ6.js → chunk-DWHJYAV6.js} +27 -27
  7. package/dist/{chunk-HKCKMCPY.js → chunk-G4YSECQ4.js} +2 -2
  8. package/dist/{chunk-7HBGXW7Z.js → chunk-GNABVGDZ.js} +31 -32
  9. package/dist/{chunk-DMD24UFZ.js → chunk-HTT6LUPP.js} +19 -19
  10. package/dist/{chunk-3FMK32KQ.js → chunk-LHQP7QRX.js} +9 -9
  11. package/dist/{chunk-6C5PKREN.js → chunk-NOAQG5CY.js} +1 -1
  12. package/dist/{chunk-4EKXYIJF.js → chunk-PAHT4ABL.js} +4 -4
  13. package/dist/{chunk-JNMDD7JY.js → chunk-RHO7WRVJ.js} +5 -5
  14. package/dist/{chunk-BQM7MBPS.js → chunk-WYDVMFGJ.js} +5 -5
  15. package/dist/{chunk-TPLVQFXM.js → chunk-X2YL6KSY.js} +13 -13
  16. package/dist/{cli-agent-ZIIFI77N.js → cli-agent-2NBPF3GN.js} +11 -11
  17. package/dist/{cli-recover-XEZ2SKPU.js → cli-recover-TTOR7CJR.js} +2 -2
  18. package/dist/{cli-serve-BDGOOOKQ.js → cli-serve-5VFU4GR4.js} +3 -3
  19. package/dist/{cli-verify-CZIITRED.js → cli-verify-WICBVLAM.js} +2 -2
  20. package/dist/cli.js +5 -5
  21. package/dist/{connection-manager-KAWEUWUR.js → connection-manager-Y7CCQK4X.js} +1 -1
  22. package/dist/dashboard/pages/cluster.js +1 -1
  23. package/dist/{deployer-3YK4RPUL.js → deployer-7NG7LCJW.js} +1 -1
  24. package/dist/{factory-JFWXTAWK.js → factory-4V2W4BSV.js} +1 -1
  25. package/dist/index.js +9 -9
  26. package/dist/{integrations-TF4EBCJ7.js → integrations-V2WXFDIV.js} +13 -13
  27. package/dist/{local-6MLIZDKO.js → local-OXFH4V7E.js} +2 -2
  28. package/dist/{meeting-voice-intelligence-CJLR52YV.js → meeting-voice-intelligence-RZZCAD6G.js} +2 -2
  29. package/dist/{meetings-FJ453ENF.js → meetings-SQNTB6GD.js} +1 -1
  30. package/dist/{microsoft-2IIHDLJB.js → microsoft-2PDVV6HX.js} +3 -3
  31. package/dist/{postgres-WGUVC2S7.js → postgres-USXBPTHX.js} +2 -2
  32. package/dist/{pw-ai-IBEF6HBF.js → pw-ai-NK5GKBDG.js} +1 -1
  33. package/dist/{routes-XYR2RNEC.js → routes-T3CDAQTD.js} +4 -4
  34. package/dist/{runtime-6BULDBR3.js → runtime-X4BTVICL.js} +1 -1
  35. package/dist/{server-7NT4LMSQ.js → server-WQ6LLYGB.js} +5 -5
  36. package/dist/{setup-2JBXMUDS.js → setup-6DRKSOMH.js} +2 -2
  37. package/dist/{skills-FR7I5V7H.js → skills-EL4RTJKK.js} +1 -1
  38. package/logs/cloudflared-error.log +12 -0
  39. package/logs/enterprise-out.log +2 -0
  40. package/package.json +1 -1
  41. package/src/admin/routes.ts +1 -1
  42. package/src/agent-tools/tool-resolver.ts +1 -1
  43. package/src/agent-tools/tools/agenticmail.ts +2 -2
  44. package/src/agent-tools/tools/browser.ts +1 -1
  45. package/src/agent-tools/tools/enterprise-code-sandbox.ts +1 -1
  46. package/src/agent-tools/tools/enterprise-diff.ts +1 -1
  47. package/src/agent-tools/tools/enterprise-http.ts +1 -3
  48. package/src/agent-tools/tools/enterprise-security-scan.ts +1 -1
  49. package/src/agent-tools/tools/google/forms.ts +2 -2
  50. package/src/agent-tools/tools/google/gmail.ts +1 -1
  51. package/src/agent-tools/tools/google/maps.ts +2 -2
  52. package/src/agent-tools/tools/google/meeting-voice.ts +1 -1
  53. package/src/agent-tools/tools/google/meetings.ts +1 -1
  54. package/src/agent-tools/tools/google/slides.ts +2 -2
  55. package/src/agent-tools/tools/grep.ts +1 -1
  56. package/src/agent-tools/tools/knowledge-search.ts +1 -1
  57. package/src/agent-tools/tools/local/coding.ts +5 -5
  58. package/src/agent-tools/tools/microsoft/excel-vba.ts +1 -1
  59. package/src/agent-tools/tools/microsoft/excel.ts +1 -1
  60. package/src/agent-tools/tools/microsoft/powerpoint.ts +1 -1
  61. package/src/agent-tools/tools/visual-memory/index.ts +11 -11
  62. package/src/agent-tools/tools/visual-memory/similarity.ts +2 -2
  63. package/src/agent-tools/tools/visual-memory/storage.ts +1 -1
  64. package/src/agenticmail/providers/imap.ts +2 -2
  65. package/src/browser/enterprise-compat.ts +1 -1
  66. package/src/cli-agent.ts +3 -3
  67. package/src/cli-serve.ts +1 -1
  68. package/src/dashboard/pages/cluster.js +1 -1
  69. package/src/database-access/connection-manager.ts +6 -6
  70. package/src/database-access/routes.ts +0 -1
  71. package/src/db/dynamodb.ts +1 -1
  72. package/src/db/postgres.ts +2 -2
  73. package/src/deploy/fly.ts +4 -4
  74. package/src/deploy/managed.ts +0 -1
  75. package/src/engine/agent-config.ts +1 -1
  76. package/src/engine/agent-heartbeat.ts +1 -1
  77. package/src/engine/agent-hierarchy.ts +1 -1
  78. package/src/engine/agent-memory.ts +1 -1
  79. package/src/engine/agent-routes.ts +2 -2
  80. package/src/engine/chat-poller.ts +1 -1
  81. package/src/engine/community-registry.ts +2 -2
  82. package/src/engine/db-adapter.ts +0 -1
  83. package/src/engine/deployer.ts +8 -8
  84. package/src/engine/email-poller.ts +1 -1
  85. package/src/engine/knowledge-contribution.ts +1 -1
  86. package/src/engine/knowledge-import/import-manager.ts +2 -3
  87. package/src/engine/knowledge-import/processors/extract-github.ts +1 -1
  88. package/src/engine/knowledge-import/processors/extract-sharepoint.ts +1 -1
  89. package/src/engine/knowledge-import/processors/validate.ts +1 -1
  90. package/src/engine/lifecycle.ts +1 -1
  91. package/src/engine/meeting-monitor.ts +2 -2
  92. package/src/engine/meeting-voice-intelligence.ts +3 -3
  93. package/src/engine/messaging-poller.ts +2 -2
  94. package/src/engine/org-integration-routes.ts +2 -2
  95. package/src/engine/org-integrations.ts +1 -1
  96. package/src/engine/routes.ts +2 -2
  97. package/src/engine/skills.ts +1 -1
  98. package/src/engine/tool-catalog.ts +1 -1
  99. package/src/engine/vault-routes.ts +1 -1
  100. package/src/engine/vault.ts +1 -1
  101. package/src/mcp/adapters/adp.adapter.ts +1 -1
  102. package/src/mcp/adapters/auth0.adapter.ts +1 -1
  103. package/src/mcp/adapters/clickup.adapter.ts +1 -1
  104. package/src/mcp/adapters/close.adapter.ts +1 -1
  105. package/src/mcp/adapters/firebase.adapter.ts +1 -1
  106. package/src/mcp/adapters/google-ads.adapter.ts +1 -1
  107. package/src/mcp/adapters/kubernetes.adapter.ts +1 -1
  108. package/src/mcp/adapters/mixpanel.adapter.ts +1 -1
  109. package/src/mcp/adapters/recurly.adapter.ts +1 -1
  110. package/src/mcp/adapters/sap.adapter.ts +2 -2
  111. package/src/mcp/adapters/shortcut.adapter.ts +1 -1
  112. package/src/mcp/adapters/snowflake.adapter.ts +1 -1
  113. package/src/mcp/adapters/stripe.adapter.ts +1 -1
  114. package/src/mcp/adapters/supabase.adapter.ts +1 -1
  115. package/src/mcp/adapters/zuora.adapter.ts +1 -1
  116. package/src/middleware/request-limits.ts +1 -1
  117. package/src/runtime/agent-loop.ts +3 -3
  118. package/src/runtime/compaction.ts +2 -2
  119. package/src/runtime/followup.ts +1 -1
  120. package/src/runtime/hooks.ts +3 -3
  121. package/src/runtime/index.ts +5 -6
  122. package/src/runtime/llm-client.ts +1 -1
  123. package/src/runtime/subagent.ts +0 -1
  124. package/src/runtime/types.ts +2 -0
  125. package/src/security/brute-force.ts +1 -1
  126. package/src/security/csp.ts +1 -1
  127. package/src/security/index.ts +3 -3
  128. package/src/security/input-sanitizer.ts +1 -1
  129. package/src/security/threat-logger.ts +2 -2
  130. package/src/server.ts +2 -2
  131. package/src/setup/database.ts +1 -1
  132. package/src/setup/index.ts +1 -2
  133. package/src/setup/provision.ts +1 -1
  134. package/dist/_seed-data-FQR5PY2W.js +0 -4554
  135. package/dist/agent-heartbeat-3FWNHZFX.js +0 -510
  136. package/dist/agent-heartbeat-4RWHZR7H.js +0 -510
  137. package/dist/agent-heartbeat-6ZGB5ILY.js +0 -510
  138. package/dist/agent-heartbeat-BBINFNL4.js +0 -510
  139. package/dist/agent-heartbeat-BIVHLKFM.js +0 -510
  140. package/dist/agent-heartbeat-HGVIAHS5.js +0 -510
  141. package/dist/agent-heartbeat-HRKVFK2T.js +0 -510
  142. package/dist/agent-heartbeat-JC5GWVXD.js +0 -510
  143. package/dist/agent-heartbeat-K6A4HMHB.js +0 -510
  144. package/dist/agent-heartbeat-LCDXWFVB.js +0 -510
  145. package/dist/agent-heartbeat-P7HZCZAQ.js +0 -510
  146. package/dist/agent-heartbeat-PUIRSNIO.js +0 -510
  147. package/dist/agent-heartbeat-SN5ILQ6Y.js +0 -510
  148. package/dist/agent-heartbeat-TW5YTDYC.js +0 -510
  149. package/dist/agent-heartbeat-UF2RKKS2.js +0 -510
  150. package/dist/agent-heartbeat-YCSWP54H.js +0 -510
  151. package/dist/agent-heartbeat-Z2QQXROL.js +0 -510
  152. package/dist/agent-tools-3W7XLUYA.js +0 -13949
  153. package/dist/agent-tools-54VZGT6L.js +0 -9
  154. package/dist/agent-tools-AYYDPO27.js +0 -13949
  155. package/dist/agent-tools-F2X47FKF.js +0 -13949
  156. package/dist/agent-tools-O6W3QAZL.js +0 -13949
  157. package/dist/agent-tools-OAWVZBMW.js +0 -9
  158. package/dist/agent-tools-QCCU74PN.js +0 -13949
  159. package/dist/agent-tools-QGE26U6R.js +0 -9
  160. package/dist/chunk-2LHUARN6.js +0 -4929
  161. package/dist/chunk-2WVCNCYC.js +0 -5087
  162. package/dist/chunk-3FM6YQUK.js +0 -5087
  163. package/dist/chunk-46GOWZT4.js +0 -5087
  164. package/dist/chunk-4DBWU3P5.js +0 -4929
  165. package/dist/chunk-5KYJAUZV.js +0 -1519
  166. package/dist/chunk-6ZMLNEHB.js +0 -1519
  167. package/dist/chunk-7UCKD25B.js +0 -551
  168. package/dist/chunk-BDCFOP7O.js +0 -537
  169. package/dist/chunk-BPZQT5N5.js +0 -25652
  170. package/dist/chunk-C52OQNNY.js +0 -5087
  171. package/dist/chunk-C7HGQF4Y.js +0 -25652
  172. package/dist/chunk-CAHNZGGK.js +0 -25656
  173. package/dist/chunk-CK7R6UHE.js +0 -4945
  174. package/dist/chunk-CQYLRIQ3.js +0 -25938
  175. package/dist/chunk-D36RPWB7.js +0 -25652
  176. package/dist/chunk-DJK2UPFH.js +0 -4891
  177. package/dist/chunk-DM7FTF7W.js +0 -4929
  178. package/dist/chunk-DXZGPUAF.js +0 -5087
  179. package/dist/chunk-F46WB5IL.js +0 -5087
  180. package/dist/chunk-F5QG5SQH.js +0 -5087
  181. package/dist/chunk-GYB2WHMN.js +0 -5101
  182. package/dist/chunk-H7GP733U.js +0 -5087
  183. package/dist/chunk-HHBXWB5U.js +0 -25640
  184. package/dist/chunk-HS5YWSGM.js +0 -3206
  185. package/dist/chunk-IMXS4N6W.js +0 -1519
  186. package/dist/chunk-JTV5LA47.js +0 -1519
  187. package/dist/chunk-KN3T3CTD.js +0 -4929
  188. package/dist/chunk-KV6G7NZX.js +0 -1519
  189. package/dist/chunk-M6ZIC5H3.js +0 -1370
  190. package/dist/chunk-MU5MEBIK.js +0 -1519
  191. package/dist/chunk-NLT5MC7X.js +0 -465
  192. package/dist/chunk-NVLYIM4J.js +0 -4945
  193. package/dist/chunk-NZY2BIZH.js +0 -4891
  194. package/dist/chunk-O42L6G67.js +0 -1519
  195. package/dist/chunk-OCNERGGM.js +0 -4891
  196. package/dist/chunk-OJSNHONE.js +0 -1519
  197. package/dist/chunk-OWTLNV4Q.js +0 -25623
  198. package/dist/chunk-PCNYEP6T.js +0 -4891
  199. package/dist/chunk-PI4AQ4Z6.js +0 -25652
  200. package/dist/chunk-PN3EGTCA.js +0 -194
  201. package/dist/chunk-PWWV2U5P.js +0 -195
  202. package/dist/chunk-Q37UKNRC.js +0 -1519
  203. package/dist/chunk-QXTC6J7H.js +0 -5087
  204. package/dist/chunk-RF2LGX3E.js +0 -1519
  205. package/dist/chunk-RH7KPWRQ.js +0 -465
  206. package/dist/chunk-RKERL5LZ.js +0 -4925
  207. package/dist/chunk-RVBK2IOX.js +0 -25652
  208. package/dist/chunk-SAKODCZ5.js +0 -4891
  209. package/dist/chunk-SALGFC5L.js +0 -4945
  210. package/dist/chunk-STGWZ2MS.js +0 -1519
  211. package/dist/chunk-SVSLIQYN.js +0 -1519
  212. package/dist/chunk-UY3ZVQDP.js +0 -25652
  213. package/dist/chunk-V6OSD62M.js +0 -5087
  214. package/dist/chunk-VP6YAHX4.js +0 -1519
  215. package/dist/chunk-WD72IOF2.js +0 -5101
  216. package/dist/chunk-WDYJOEAI.js +0 -5087
  217. package/dist/chunk-WEAFQNOS.js +0 -195
  218. package/dist/chunk-XKUSAZGP.js +0 -5087
  219. package/dist/chunk-YCWOCIPH.js +0 -5101
  220. package/dist/chunk-ZGE3XAXY.js +0 -1519
  221. package/dist/chunk-ZGFDTW4H.js +0 -1519
  222. package/dist/cli-agent-33GWIF2D.js +0 -2300
  223. package/dist/cli-agent-4XK6LVQQ.js +0 -2357
  224. package/dist/cli-agent-64EOV3ST.js +0 -2300
  225. package/dist/cli-agent-67WP6KKO.js +0 -2300
  226. package/dist/cli-agent-7RW5Y7C4.js +0 -2294
  227. package/dist/cli-agent-7TB2BWS6.js +0 -2370
  228. package/dist/cli-agent-AKXFFST2.js +0 -2370
  229. package/dist/cli-agent-C3YSECO4.js +0 -2344
  230. package/dist/cli-agent-DZTKLITB.js +0 -2357
  231. package/dist/cli-agent-FNMDJN7T.js +0 -2357
  232. package/dist/cli-agent-FOF7PFEP.js +0 -2357
  233. package/dist/cli-agent-FXZ6DJKP.js +0 -2357
  234. package/dist/cli-agent-H74M2ZYN.js +0 -2357
  235. package/dist/cli-agent-HG4Y657I.js +0 -2300
  236. package/dist/cli-agent-HORWVPHB.js +0 -2370
  237. package/dist/cli-agent-HSZT6SKF.js +0 -2423
  238. package/dist/cli-agent-ION2W5JF.js +0 -2441
  239. package/dist/cli-agent-JLUQ4ZU6.js +0 -2424
  240. package/dist/cli-agent-KBPWY3CB.js +0 -2302
  241. package/dist/cli-agent-MVCDH4HV.js +0 -2370
  242. package/dist/cli-agent-NZXOEPJ2.js +0 -2357
  243. package/dist/cli-agent-OO6H57UQ.js +0 -2300
  244. package/dist/cli-agent-PADN3QRC.js +0 -2357
  245. package/dist/cli-agent-QAYEX3BE.js +0 -2441
  246. package/dist/cli-agent-QT64DT5J.js +0 -2370
  247. package/dist/cli-agent-TCTRKCHN.js +0 -2300
  248. package/dist/cli-agent-TFL2M6UK.js +0 -2424
  249. package/dist/cli-agent-TSOJG7EX.js +0 -2357
  250. package/dist/cli-agent-UIKXATTD.js +0 -2357
  251. package/dist/cli-agent-UJN6FYTO.js +0 -2370
  252. package/dist/cli-agent-USMKX7WN.js +0 -2473
  253. package/dist/cli-agent-VIQAYVY4.js +0 -2357
  254. package/dist/cli-agent-WNWFVOFM.js +0 -2370
  255. package/dist/cli-agent-XBQX67VJ.js +0 -2423
  256. package/dist/cli-agent-ZLSC6FF4.js +0 -2357
  257. package/dist/cli-agent-ZSHUPBBN.js +0 -2357
  258. package/dist/cli-recover-T32NABFA.js +0 -487
  259. package/dist/cli-serve-2IL5DTEY.js +0 -153
  260. package/dist/cli-serve-3NGBX5ER.js +0 -140
  261. package/dist/cli-serve-47N5UKKW.js +0 -153
  262. package/dist/cli-serve-4RS4UDHC.js +0 -140
  263. package/dist/cli-serve-4XGZFUV2.js +0 -140
  264. package/dist/cli-serve-53FVANQK.js +0 -260
  265. package/dist/cli-serve-57225XWV.js +0 -140
  266. package/dist/cli-serve-63BDPSOP.js +0 -140
  267. package/dist/cli-serve-657NRUOX.js +0 -140
  268. package/dist/cli-serve-6ER7QMLR.js +0 -140
  269. package/dist/cli-serve-6OT3UEAN.js +0 -140
  270. package/dist/cli-serve-7JQ4FVUQ.js +0 -260
  271. package/dist/cli-serve-7L6EY5UH.js +0 -153
  272. package/dist/cli-serve-BFNIW2LF.js +0 -153
  273. package/dist/cli-serve-C7MN6U5Q.js +0 -153
  274. package/dist/cli-serve-CQFI3LMK.js +0 -140
  275. package/dist/cli-serve-CR3OY3IM.js +0 -153
  276. package/dist/cli-serve-DAJFRWQ7.js +0 -153
  277. package/dist/cli-serve-DTQLN5UI.js +0 -140
  278. package/dist/cli-serve-EQS2SGT3.js +0 -140
  279. package/dist/cli-serve-FW6FHFW4.js +0 -153
  280. package/dist/cli-serve-GEEOQS77.js +0 -153
  281. package/dist/cli-serve-H562I3ZK.js +0 -153
  282. package/dist/cli-serve-HDQZF4C4.js +0 -153
  283. package/dist/cli-serve-KBJNXWYJ.js +0 -140
  284. package/dist/cli-serve-LICAOMEB.js +0 -140
  285. package/dist/cli-serve-LLGYLWFS.js +0 -153
  286. package/dist/cli-serve-LMZKQ5GX.js +0 -140
  287. package/dist/cli-serve-LNTT73P2.js +0 -140
  288. package/dist/cli-serve-MLR4KAE2.js +0 -260
  289. package/dist/cli-serve-MQKBUZ7X.js +0 -140
  290. package/dist/cli-serve-N3OISDNB.js +0 -153
  291. package/dist/cli-serve-NBFT7B42.js +0 -140
  292. package/dist/cli-serve-RTWO3AWY.js +0 -140
  293. package/dist/cli-serve-SIHTSW5P.js +0 -140
  294. package/dist/cli-serve-SP6TEURE.js +0 -140
  295. package/dist/cli-serve-TDKZA6I5.js +0 -140
  296. package/dist/cli-serve-TF5ZVVXF.js +0 -140
  297. package/dist/cli-serve-TIZ27EVR.js +0 -153
  298. package/dist/cli-serve-TUNI2RCN.js +0 -153
  299. package/dist/cli-serve-WCU66CHX.js +0 -140
  300. package/dist/cli-serve-WNOZMAWD.js +0 -153
  301. package/dist/cli-serve-YCCKRRUY.js +0 -140
  302. package/dist/cli-serve-ZD5V7I6G.js +0 -140
  303. package/dist/cli-validate-6XDDLVVQ.js +0 -150
  304. package/dist/cli-verify-I4WGRQNT.js +0 -149
  305. package/dist/connection-manager-4ZA4XAFA.js +0 -9
  306. package/dist/db-adapter-IK2EDK2N.js +0 -7
  307. package/dist/db-adapter-IRHOUMVC.js +0 -7
  308. package/dist/dependency-manager-G6D2XXNY.js +0 -11
  309. package/dist/dependency-manager-OCUKF72T.js +0 -543
  310. package/dist/dependency-manager-YULUXN34.js +0 -511
  311. package/dist/factory-MQASIPEB.js +0 -11
  312. package/dist/google-W5AYGNUJ.js +0 -33
  313. package/dist/integrations-VWANOHQ4.js +0 -43830
  314. package/dist/local-O2FN57UN.js +0 -1128
  315. package/dist/local-S7SDOQHN.js +0 -1128
  316. package/dist/microsoft-HPLA5ZL5.js +0 -2414
  317. package/dist/microsoft-UFLZBEAC.js +0 -1619
  318. package/dist/microsoft-VREAZ7M2.js +0 -3955
  319. package/dist/microsoft-YUT6EIGP.js +0 -3400
  320. package/dist/postgres-BOTHOPDW.js +0 -875
  321. package/dist/routes-3MMLQTB6.js +0 -90
  322. package/dist/routes-4ZUIJ4HE.js +0 -90
  323. package/dist/routes-5MXHKKH4.js +0 -90
  324. package/dist/routes-64NJFK3B.js +0 -90
  325. package/dist/routes-6AKQ2LBV.js +0 -90
  326. package/dist/routes-CRRBUDO4.js +0 -90
  327. package/dist/routes-D7SMYOLT.js +0 -90
  328. package/dist/routes-DIAF3MC3.js +0 -90
  329. package/dist/routes-IGR6PZCA.js +0 -92
  330. package/dist/routes-KMUNU6CY.js +0 -90
  331. package/dist/routes-LRRLXIZR.js +0 -90
  332. package/dist/routes-N647AJYG.js +0 -90
  333. package/dist/routes-SSSELAAR.js +0 -90
  334. package/dist/routes-STERVGKJ.js +0 -90
  335. package/dist/routes-TZMPYLHJ.js +0 -90
  336. package/dist/routes-XNK2MAVO.js +0 -90
  337. package/dist/routes-ZEZZACZP.js +0 -90
  338. package/dist/runtime-4UVCTFNQ.js +0 -45
  339. package/dist/runtime-5EQN4GFM.js +0 -45
  340. package/dist/runtime-5LP7PUD4.js +0 -45
  341. package/dist/runtime-6YEENDN3.js +0 -45
  342. package/dist/runtime-7LQFRG3B.js +0 -45
  343. package/dist/runtime-AMXJU2MB.js +0 -45
  344. package/dist/runtime-D6WSE7FG.js +0 -45
  345. package/dist/runtime-EAWOE6JZ.js +0 -45
  346. package/dist/runtime-EYVN7NFJ.js +0 -45
  347. package/dist/runtime-F6RPWQVW.js +0 -45
  348. package/dist/runtime-FYMJURFC.js +0 -45
  349. package/dist/runtime-GGF4P55M.js +0 -45
  350. package/dist/runtime-H3SAMWWF.js +0 -45
  351. package/dist/runtime-H7T4I7I7.js +0 -45
  352. package/dist/runtime-HTIM7GZR.js +0 -45
  353. package/dist/runtime-JRNBL4O4.js +0 -45
  354. package/dist/runtime-K4C7NQLW.js +0 -45
  355. package/dist/runtime-MWWZCPC2.js +0 -45
  356. package/dist/runtime-N7CM2DYA.js +0 -45
  357. package/dist/runtime-OM2NIBMI.js +0 -45
  358. package/dist/runtime-OVGSOTAH.js +0 -45
  359. package/dist/runtime-QQ6LAY4U.js +0 -45
  360. package/dist/runtime-QWPVD7CY.js +0 -45
  361. package/dist/runtime-SX3B5MG3.js +0 -45
  362. package/dist/runtime-YLIIPTE4.js +0 -45
  363. package/dist/runtime-YU6P22CG.js +0 -45
  364. package/dist/runtime-ZOC337DD.js +0 -45
  365. package/dist/server-3AVWBRIF.js +0 -28
  366. package/dist/server-5BKJI5OW.js +0 -28
  367. package/dist/server-6NDO2S52.js +0 -28
  368. package/dist/server-7TD3M2BW.js +0 -28
  369. package/dist/server-AMCSXINC.js +0 -28
  370. package/dist/server-B3VJ6MSA.js +0 -28
  371. package/dist/server-BEJ6RAGL.js +0 -28
  372. package/dist/server-BFPYDHBG.js +0 -28
  373. package/dist/server-BKEWXGVX.js +0 -28
  374. package/dist/server-BMEJZGFG.js +0 -28
  375. package/dist/server-CU6LVQS4.js +0 -28
  376. package/dist/server-DFR7FI3Q.js +0 -28
  377. package/dist/server-DFYGH2CV.js +0 -28
  378. package/dist/server-DURRN3GJ.js +0 -28
  379. package/dist/server-EELWOC3X.js +0 -28
  380. package/dist/server-EN5E2OWQ.js +0 -28
  381. package/dist/server-EXZC3OJO.js +0 -28
  382. package/dist/server-GW2HYJYI.js +0 -28
  383. package/dist/server-J25NCRWJ.js +0 -28
  384. package/dist/server-JDGNOTFV.js +0 -28
  385. package/dist/server-KA6U3YNP.js +0 -28
  386. package/dist/server-L52A2ME4.js +0 -28
  387. package/dist/server-NE5HD5DJ.js +0 -28
  388. package/dist/server-NLQAXPOG.js +0 -28
  389. package/dist/server-NQOT7W77.js +0 -28
  390. package/dist/server-OHHAA34U.js +0 -28
  391. package/dist/server-PWE5PQTR.js +0 -28
  392. package/dist/server-Q2Q32H2B.js +0 -28
  393. package/dist/server-Q77ME7TL.js +0 -28
  394. package/dist/server-QDKO6OVO.js +0 -28
  395. package/dist/server-RR6QJIXM.js +0 -28
  396. package/dist/server-T3R6BO6A.js +0 -28
  397. package/dist/server-TRIBAHDV.js +0 -28
  398. package/dist/server-TXV3ZVVR.js +0 -28
  399. package/dist/server-VHSFJP3I.js +0 -28
  400. package/dist/server-VOJF2XGU.js +0 -28
  401. package/dist/server-W76YHPEC.js +0 -28
  402. package/dist/server-WLLH4WST.js +0 -28
  403. package/dist/server-WTUJ2O3F.js +0 -28
  404. package/dist/server-X4CJTHHF.js +0 -28
  405. package/dist/server-XK3ILCJC.js +0 -28
  406. package/dist/server-ZRD3NDJE.js +0 -28
  407. package/dist/setup-2JYXGTW6.js +0 -20
  408. package/dist/setup-3XOSZEW5.js +0 -20
  409. package/dist/setup-44VBAO4J.js +0 -20
  410. package/dist/setup-4OA7QNJW.js +0 -20
  411. package/dist/setup-4ONNQBWB.js +0 -20
  412. package/dist/setup-4OSBXSCL.js +0 -20
  413. package/dist/setup-4QFGRBLZ.js +0 -20
  414. package/dist/setup-52US54Z4.js +0 -20
  415. package/dist/setup-5CY3CKKT.js +0 -20
  416. package/dist/setup-5YRQUOW2.js +0 -20
  417. package/dist/setup-6766SGAR.js +0 -20
  418. package/dist/setup-6NUSB4XO.js +0 -20
  419. package/dist/setup-7FZJEOD4.js +0 -20
  420. package/dist/setup-7LYYXBUL.js +0 -20
  421. package/dist/setup-ADSKKBGV.js +0 -20
  422. package/dist/setup-AMV2WKVH.js +0 -20
  423. package/dist/setup-AYY24DKM.js +0 -20
  424. package/dist/setup-B34N4HPU.js +0 -20
  425. package/dist/setup-CEF4QY4L.js +0 -20
  426. package/dist/setup-E2YLC2EY.js +0 -20
  427. package/dist/setup-ER6NXTY5.js +0 -20
  428. package/dist/setup-FIOAQJ6C.js +0 -20
  429. package/dist/setup-G76S7X44.js +0 -20
  430. package/dist/setup-H2AGCBW5.js +0 -20
  431. package/dist/setup-H4JZUHH5.js +0 -20
  432. package/dist/setup-ICOZRKCX.js +0 -20
  433. package/dist/setup-JFTJH7UF.js +0 -20
  434. package/dist/setup-JJHOT2ZU.js +0 -20
  435. package/dist/setup-KEAM2BCL.js +0 -20
  436. package/dist/setup-LW4MLU2N.js +0 -20
  437. package/dist/setup-NHAZABW4.js +0 -20
  438. package/dist/setup-PRFNI6YW.js +0 -20
  439. package/dist/setup-RAHBMYHE.js +0 -20
  440. package/dist/setup-T6KYFR7O.js +0 -20
  441. package/dist/setup-TGM6L362.js +0 -20
  442. package/dist/setup-TNANAH7C.js +0 -20
  443. package/dist/setup-TXPR5UQX.js +0 -20
  444. package/dist/setup-UJSNSCLM.js +0 -20
  445. package/dist/setup-XCJMELVU.js +0 -20
  446. package/dist/setup-XIYEIFVK.js +0 -20
  447. package/dist/setup-XP2VGBEU.js +0 -20
  448. package/dist/setup-Z4PZSHBI.js +0 -20
  449. package/dist/skills-HCVBA6PK.js +0 -16
  450. package/dist/skills-HFSW74KZ.js +0 -16
  451. package/dist/system-prompts-6OUTAMH6.js +0 -41
  452. package/dist/task-queue-YP2I54IA.js +0 -9
  453. package/dist/transport-encryption-F2NQYACT.js +0 -25
  454. package/god_is_great.html +0 -35
  455. package/seed-data.mjs +0 -455
  456. package/src/agent-tools/tools/integrations/_seed-data.json +0 -4548
  457. package/src/agent-tools/tools/integrations/_seed-data.ts +0 -4563
@@ -1,3400 +0,0 @@
1
- import {
2
- errorResult,
3
- jsonResult
4
- } from "./chunk-ZB3VC2MR.js";
5
- import "./chunk-KFQGP6VL.js";
6
-
7
- // src/agent-tools/tools/microsoft/graph-api.ts
8
- var GRAPH_BASE = "https://graph.microsoft.com/v1.0";
9
- async function graph(token, path, opts) {
10
- const method = opts?.method || "GET";
11
- const base = opts?.beta ? "https://graph.microsoft.com/beta" : GRAPH_BASE;
12
- const url = new URL(base + path);
13
- if (opts?.query) {
14
- for (const [k, v] of Object.entries(opts.query)) {
15
- if (v !== void 0 && v !== "") url.searchParams.set(k, v);
16
- }
17
- }
18
- const headers = {
19
- Authorization: `Bearer ${token}`,
20
- ...opts?.headers
21
- };
22
- if (!opts?.rawBody && !opts?.headers?.["Content-Type"]) {
23
- headers["Content-Type"] = "application/json";
24
- }
25
- const res = await fetch(url.toString(), {
26
- method,
27
- headers,
28
- body: opts?.rawBody || (opts?.body ? JSON.stringify(opts.body) : void 0)
29
- });
30
- if (!res.ok) {
31
- const err = await res.text();
32
- throw new Error(`Microsoft Graph ${res.status}: ${err}`);
33
- }
34
- if (res.status === 204) return {};
35
- const ct = res.headers.get("content-type") || "";
36
- if (ct.includes("application/json")) return res.json();
37
- return { content: await res.text() };
38
- }
39
-
40
- // src/agent-tools/tools/microsoft/outlook-mail.ts
41
- function createOutlookMailTools(config, _options) {
42
- const tp = config.tokenProvider;
43
- return [
44
- {
45
- name: "outlook_mail_list",
46
- description: "List messages from Outlook mailbox. Returns recent emails from inbox or specified folder.",
47
- category: "utility",
48
- parameters: {
49
- type: "object",
50
- properties: {
51
- folder: { type: "string", description: "Folder: inbox, sentitems, drafts, deleteditems, junkemail, or folder ID (default: inbox)" },
52
- maxResults: { type: "number", description: "Max messages to return (default: 20, max: 50)" },
53
- filter: { type: "string", description: `OData $filter expression (e.g., "isRead eq false", "from/emailAddress/address eq 'user@example.com'")` },
54
- search: { type: "string", description: "Search query (searches subject, body, sender)" }
55
- },
56
- required: []
57
- },
58
- async execute(_id, params) {
59
- try {
60
- const token = await tp.getAccessToken();
61
- const folder = params.folder || "inbox";
62
- const top = Math.min(params.maxResults || 20, 50);
63
- const query = {
64
- "$top": String(top),
65
- "$orderby": "receivedDateTime desc",
66
- "$select": "id,subject,from,toRecipients,ccRecipients,receivedDateTime,isRead,hasAttachments,importance,bodyPreview,flag,conversationId"
67
- };
68
- if (params.filter) query["$filter"] = params.filter;
69
- if (params.search) query["$search"] = `"${params.search}"`;
70
- const data = await graph(token, `/me/mailFolders/${folder}/messages`, { query });
71
- const messages = (data.value || []).map((m) => ({
72
- id: m.id,
73
- subject: m.subject,
74
- from: m.from?.emailAddress?.address,
75
- fromName: m.from?.emailAddress?.name,
76
- to: m.toRecipients?.map((r) => r.emailAddress?.address),
77
- cc: m.ccRecipients?.map((r) => r.emailAddress?.address),
78
- date: m.receivedDateTime,
79
- isRead: m.isRead,
80
- hasAttachments: m.hasAttachments,
81
- importance: m.importance,
82
- preview: m.bodyPreview,
83
- flagged: m.flag?.flagStatus === "flagged",
84
- conversationId: m.conversationId
85
- }));
86
- return jsonResult({ messages, count: messages.length });
87
- } catch (e) {
88
- return errorResult(e.message);
89
- }
90
- }
91
- },
92
- {
93
- name: "outlook_mail_read",
94
- description: "Read a specific email message by ID. Returns full body, headers, and attachment list.",
95
- category: "utility",
96
- parameters: {
97
- type: "object",
98
- properties: {
99
- messageId: { type: "string", description: "Message ID to read" },
100
- markAsRead: { type: "boolean", description: "Mark as read when opening (default: true)" }
101
- },
102
- required: ["messageId"]
103
- },
104
- async execute(_id, params) {
105
- try {
106
- const token = await tp.getAccessToken();
107
- const msg = await graph(token, `/me/messages/${params.messageId}`, {
108
- query: { "$select": "id,subject,from,toRecipients,ccRecipients,bccRecipients,replyTo,receivedDateTime,sentDateTime,isRead,hasAttachments,importance,body,flag,conversationId,internetMessageId,parentFolderId" }
109
- });
110
- if (params.markAsRead !== false && !msg.isRead) {
111
- graph(token, `/me/messages/${params.messageId}`, { method: "PATCH", body: { isRead: true } }).catch(() => {
112
- });
113
- }
114
- let attachments = [];
115
- if (msg.hasAttachments) {
116
- const att = await graph(token, `/me/messages/${params.messageId}/attachments`, {
117
- query: { "$select": "id,name,contentType,size,isInline" }
118
- });
119
- attachments = (att.value || []).map((a) => ({
120
- id: a.id,
121
- name: a.name,
122
- contentType: a.contentType,
123
- size: a.size,
124
- isInline: a.isInline
125
- }));
126
- }
127
- return jsonResult({
128
- id: msg.id,
129
- subject: msg.subject,
130
- from: msg.from?.emailAddress?.address,
131
- fromName: msg.from?.emailAddress?.name,
132
- to: msg.toRecipients?.map((r) => ({ email: r.emailAddress?.address, name: r.emailAddress?.name })),
133
- cc: msg.ccRecipients?.map((r) => ({ email: r.emailAddress?.address, name: r.emailAddress?.name })),
134
- bcc: msg.bccRecipients?.map((r) => ({ email: r.emailAddress?.address, name: r.emailAddress?.name })),
135
- replyTo: msg.replyTo?.map((r) => r.emailAddress?.address),
136
- date: msg.receivedDateTime,
137
- sentDate: msg.sentDateTime,
138
- body: msg.body?.content,
139
- bodyType: msg.body?.contentType,
140
- isRead: msg.isRead,
141
- importance: msg.importance,
142
- attachments,
143
- conversationId: msg.conversationId,
144
- internetMessageId: msg.internetMessageId
145
- });
146
- } catch (e) {
147
- return errorResult(e.message);
148
- }
149
- }
150
- },
151
- {
152
- name: "outlook_mail_send",
153
- description: "Send an email via Outlook. Supports to, cc, bcc, HTML body, importance, and reply-to.",
154
- category: "utility",
155
- parameters: {
156
- type: "object",
157
- properties: {
158
- to: { type: "string", description: "Recipient email(s), comma-separated" },
159
- subject: { type: "string", description: "Email subject" },
160
- body: { type: "string", description: "Email body (HTML or plain text)" },
161
- cc: { type: "string", description: "CC recipients, comma-separated" },
162
- bcc: { type: "string", description: "BCC recipients, comma-separated" },
163
- importance: { type: "string", description: "low, normal, or high (default: normal)" },
164
- isHtml: { type: "boolean", description: "Whether body is HTML (default: false)" },
165
- replyTo: { type: "string", description: "Reply-to address" },
166
- saveToSent: { type: "boolean", description: "Save to Sent Items (default: true)" }
167
- },
168
- required: ["to", "subject", "body"]
169
- },
170
- async execute(_id, params) {
171
- try {
172
- const token = await tp.getAccessToken();
173
- const toRecipients = params.to.split(",").map((e) => ({
174
- emailAddress: { address: e.trim() }
175
- }));
176
- const message = {
177
- subject: params.subject,
178
- body: { contentType: params.isHtml ? "HTML" : "Text", content: params.body },
179
- toRecipients
180
- };
181
- if (params.cc) message.ccRecipients = params.cc.split(",").map((e) => ({ emailAddress: { address: e.trim() } }));
182
- if (params.bcc) message.bccRecipients = params.bcc.split(",").map((e) => ({ emailAddress: { address: e.trim() } }));
183
- if (params.importance) message.importance = params.importance;
184
- if (params.replyTo) message.replyTo = [{ emailAddress: { address: params.replyTo } }];
185
- await graph(token, "/me/sendMail", {
186
- method: "POST",
187
- body: { message, saveToSentItems: params.saveToSent !== false }
188
- });
189
- return jsonResult({ sent: true, to: params.to, subject: params.subject });
190
- } catch (e) {
191
- return errorResult(e.message);
192
- }
193
- }
194
- },
195
- {
196
- name: "outlook_mail_reply",
197
- description: "Reply to an email message. Can reply to sender only or reply-all.",
198
- category: "utility",
199
- parameters: {
200
- type: "object",
201
- properties: {
202
- messageId: { type: "string", description: "Message ID to reply to" },
203
- body: { type: "string", description: "Reply body text" },
204
- replyAll: { type: "boolean", description: "Reply to all recipients (default: false)" },
205
- isHtml: { type: "boolean", description: "Whether body is HTML (default: false)" }
206
- },
207
- required: ["messageId", "body"]
208
- },
209
- async execute(_id, params) {
210
- try {
211
- const token = await tp.getAccessToken();
212
- const action = params.replyAll ? "replyAll" : "reply";
213
- await graph(token, `/me/messages/${params.messageId}/${action}`, {
214
- method: "POST",
215
- body: { comment: params.body }
216
- });
217
- return jsonResult({ replied: true, messageId: params.messageId, replyAll: !!params.replyAll });
218
- } catch (e) {
219
- return errorResult(e.message);
220
- }
221
- }
222
- },
223
- {
224
- name: "outlook_mail_forward",
225
- description: "Forward an email message to another recipient.",
226
- category: "utility",
227
- parameters: {
228
- type: "object",
229
- properties: {
230
- messageId: { type: "string", description: "Message ID to forward" },
231
- to: { type: "string", description: "Forward recipient email(s), comma-separated" },
232
- comment: { type: "string", description: "Optional comment to add above the forwarded message" }
233
- },
234
- required: ["messageId", "to"]
235
- },
236
- async execute(_id, params) {
237
- try {
238
- const token = await tp.getAccessToken();
239
- const toRecipients = params.to.split(",").map((e) => ({ emailAddress: { address: e.trim() } }));
240
- await graph(token, `/me/messages/${params.messageId}/forward`, {
241
- method: "POST",
242
- body: { comment: params.comment || "", toRecipients }
243
- });
244
- return jsonResult({ forwarded: true, messageId: params.messageId, to: params.to });
245
- } catch (e) {
246
- return errorResult(e.message);
247
- }
248
- }
249
- },
250
- {
251
- name: "outlook_mail_move",
252
- description: "Move a message to another folder.",
253
- category: "utility",
254
- parameters: {
255
- type: "object",
256
- properties: {
257
- messageId: { type: "string", description: "Message ID to move" },
258
- folder: { type: "string", description: "Destination folder: inbox, archive, deleteditems, junkemail, or folder ID" }
259
- },
260
- required: ["messageId", "folder"]
261
- },
262
- async execute(_id, params) {
263
- try {
264
- const token = await tp.getAccessToken();
265
- const folderMap = {
266
- inbox: "inbox",
267
- archive: "archive",
268
- trash: "deleteditems",
269
- deleteditems: "deleteditems",
270
- junk: "junkemail",
271
- junkemail: "junkemail",
272
- sent: "sentitems",
273
- sentitems: "sentitems",
274
- drafts: "drafts"
275
- };
276
- const destId = folderMap[params.folder.toLowerCase()] || params.folder;
277
- const result = await graph(token, `/me/messages/${params.messageId}/move`, {
278
- method: "POST",
279
- body: { destinationId: destId }
280
- });
281
- return jsonResult({ moved: true, newId: result.id, folder: params.folder });
282
- } catch (e) {
283
- return errorResult(e.message);
284
- }
285
- }
286
- },
287
- {
288
- name: "outlook_mail_delete",
289
- description: "Delete an email message (moves to Deleted Items).",
290
- category: "utility",
291
- parameters: {
292
- type: "object",
293
- properties: {
294
- messageId: { type: "string", description: "Message ID to delete" }
295
- },
296
- required: ["messageId"]
297
- },
298
- async execute(_id, params) {
299
- try {
300
- const token = await tp.getAccessToken();
301
- await graph(token, `/me/messages/${params.messageId}`, { method: "DELETE" });
302
- return jsonResult({ deleted: true, messageId: params.messageId });
303
- } catch (e) {
304
- return errorResult(e.message);
305
- }
306
- }
307
- },
308
- {
309
- name: "outlook_mail_update",
310
- description: "Update message properties: mark as read/unread, flag, change importance, add categories.",
311
- category: "utility",
312
- parameters: {
313
- type: "object",
314
- properties: {
315
- messageId: { type: "string", description: "Message ID to update" },
316
- isRead: { type: "boolean", description: "Mark as read or unread" },
317
- importance: { type: "string", description: "low, normal, or high" },
318
- flag: { type: "string", description: "notFlagged, flagged, or complete" },
319
- categories: { type: "array", items: { type: "string" }, description: "Category labels to apply" }
320
- },
321
- required: ["messageId"]
322
- },
323
- async execute(_id, params) {
324
- try {
325
- const token = await tp.getAccessToken();
326
- const body = {};
327
- if (params.isRead !== void 0) body.isRead = params.isRead;
328
- if (params.importance) body.importance = params.importance;
329
- if (params.flag) body.flag = { flagStatus: params.flag };
330
- if (params.categories) body.categories = params.categories;
331
- await graph(token, `/me/messages/${params.messageId}`, { method: "PATCH", body });
332
- return jsonResult({ updated: true, messageId: params.messageId });
333
- } catch (e) {
334
- return errorResult(e.message);
335
- }
336
- }
337
- },
338
- {
339
- name: "outlook_mail_search",
340
- description: "Search emails across all folders using Microsoft Search. Supports natural language queries.",
341
- category: "utility",
342
- parameters: {
343
- type: "object",
344
- properties: {
345
- query: { type: "string", description: 'Search query (natural language or KQL: "from:user@example.com subject:report")' },
346
- maxResults: { type: "number", description: "Max results (default: 10, max: 25)" }
347
- },
348
- required: ["query"]
349
- },
350
- async execute(_id, params) {
351
- try {
352
- const token = await tp.getAccessToken();
353
- const top = Math.min(params.maxResults || 10, 25);
354
- const data = await graph(token, "/me/messages", {
355
- query: {
356
- "$search": `"${params.query}"`,
357
- "$top": String(top),
358
- "$select": "id,subject,from,receivedDateTime,bodyPreview,isRead,hasAttachments,importance"
359
- }
360
- });
361
- const messages = (data.value || []).map((m) => ({
362
- id: m.id,
363
- subject: m.subject,
364
- from: m.from?.emailAddress?.address,
365
- fromName: m.from?.emailAddress?.name,
366
- date: m.receivedDateTime,
367
- preview: m.bodyPreview,
368
- isRead: m.isRead,
369
- hasAttachments: m.hasAttachments
370
- }));
371
- return jsonResult({ messages, count: messages.length, query: params.query });
372
- } catch (e) {
373
- return errorResult(e.message);
374
- }
375
- }
376
- },
377
- {
378
- name: "outlook_mail_draft",
379
- description: "Create a draft email in Outlook. Can be edited and sent later.",
380
- category: "utility",
381
- parameters: {
382
- type: "object",
383
- properties: {
384
- to: { type: "string", description: "Recipient email(s), comma-separated" },
385
- subject: { type: "string", description: "Email subject" },
386
- body: { type: "string", description: "Email body" },
387
- cc: { type: "string", description: "CC recipients" },
388
- isHtml: { type: "boolean", description: "Whether body is HTML" }
389
- },
390
- required: ["to", "subject", "body"]
391
- },
392
- async execute(_id, params) {
393
- try {
394
- const token = await tp.getAccessToken();
395
- const message = {
396
- subject: params.subject,
397
- body: { contentType: params.isHtml ? "HTML" : "Text", content: params.body },
398
- toRecipients: params.to.split(",").map((e) => ({ emailAddress: { address: e.trim() } }))
399
- };
400
- if (params.cc) message.ccRecipients = params.cc.split(",").map((e) => ({ emailAddress: { address: e.trim() } }));
401
- const draft = await graph(token, "/me/messages", { method: "POST", body: message });
402
- return jsonResult({ draftId: draft.id, subject: params.subject, status: "draft_created" });
403
- } catch (e) {
404
- return errorResult(e.message);
405
- }
406
- }
407
- },
408
- {
409
- name: "outlook_mail_send_draft",
410
- description: "Send an existing draft email.",
411
- category: "utility",
412
- parameters: {
413
- type: "object",
414
- properties: {
415
- messageId: { type: "string", description: "Draft message ID to send" }
416
- },
417
- required: ["messageId"]
418
- },
419
- async execute(_id, params) {
420
- try {
421
- const token = await tp.getAccessToken();
422
- await graph(token, `/me/messages/${params.messageId}/send`, { method: "POST" });
423
- return jsonResult({ sent: true, messageId: params.messageId });
424
- } catch (e) {
425
- return errorResult(e.message);
426
- }
427
- }
428
- },
429
- {
430
- name: "outlook_mail_folders",
431
- description: "List mail folders in the mailbox.",
432
- category: "utility",
433
- parameters: { type: "object", properties: {}, required: [] },
434
- async execute(_id) {
435
- try {
436
- const token = await tp.getAccessToken();
437
- const data = await graph(token, "/me/mailFolders", {
438
- query: { "$top": "50", "$select": "id,displayName,totalItemCount,unreadItemCount,parentFolderId" }
439
- });
440
- const folders = (data.value || []).map((f) => ({
441
- id: f.id,
442
- name: f.displayName,
443
- totalItems: f.totalItemCount,
444
- unreadItems: f.unreadItemCount
445
- }));
446
- return jsonResult({ folders, count: folders.length });
447
- } catch (e) {
448
- return errorResult(e.message);
449
- }
450
- }
451
- },
452
- {
453
- name: "outlook_mail_attachment_download",
454
- description: "Download an attachment from an email. Returns the attachment content as base64.",
455
- category: "utility",
456
- parameters: {
457
- type: "object",
458
- properties: {
459
- messageId: { type: "string", description: "Message ID containing the attachment" },
460
- attachmentId: { type: "string", description: "Attachment ID to download" }
461
- },
462
- required: ["messageId", "attachmentId"]
463
- },
464
- async execute(_id, params) {
465
- try {
466
- const token = await tp.getAccessToken();
467
- const att = await graph(token, `/me/messages/${params.messageId}/attachments/${params.attachmentId}`);
468
- return jsonResult({
469
- name: att.name,
470
- contentType: att.contentType,
471
- size: att.size,
472
- content: att.contentBytes
473
- // base64 encoded
474
- });
475
- } catch (e) {
476
- return errorResult(e.message);
477
- }
478
- }
479
- }
480
- ];
481
- }
482
-
483
- // src/agent-tools/tools/microsoft/outlook-calendar.ts
484
- function createOutlookCalendarTools(config, _options) {
485
- const tp = config.tokenProvider;
486
- return [
487
- {
488
- name: "outlook_calendar_list",
489
- description: "List all calendars the agent has access to.",
490
- category: "utility",
491
- parameters: { type: "object", properties: {}, required: [] },
492
- async execute(_id) {
493
- try {
494
- const token = await tp.getAccessToken();
495
- const data = await graph(token, "/me/calendars");
496
- const cals = (data.value || []).map((c) => ({
497
- id: c.id,
498
- name: c.name,
499
- color: c.color,
500
- isDefaultCalendar: c.isDefaultCalendar,
501
- canEdit: c.canEdit,
502
- owner: c.owner?.address
503
- }));
504
- return jsonResult({ calendars: cals, count: cals.length });
505
- } catch (e) {
506
- return errorResult(e.message);
507
- }
508
- }
509
- },
510
- {
511
- name: "outlook_calendar_events",
512
- description: "List upcoming events from a calendar. Defaults to the primary calendar.",
513
- category: "utility",
514
- parameters: {
515
- type: "object",
516
- properties: {
517
- calendarId: { type: "string", description: "Calendar ID (omit for default calendar)" },
518
- timeMin: { type: "string", description: "Start of time range (ISO 8601, default: now)" },
519
- timeMax: { type: "string", description: "End of time range (ISO 8601, default: +7 days)" },
520
- maxResults: { type: "number", description: "Max events (default: 20)" }
521
- },
522
- required: []
523
- },
524
- async execute(_id, params) {
525
- try {
526
- const token = await tp.getAccessToken();
527
- const now = /* @__PURE__ */ new Date();
528
- const timeMin = params.timeMin || now.toISOString();
529
- const weekLater = new Date(now.getTime() + 7 * 864e5);
530
- const timeMax = params.timeMax || weekLater.toISOString();
531
- const top = params.maxResults || 20;
532
- const basePath = params.calendarId ? `/me/calendars/${params.calendarId}/calendarView` : "/me/calendarView";
533
- const data = await graph(token, basePath, {
534
- query: {
535
- startDateTime: timeMin,
536
- endDateTime: timeMax,
537
- "$top": String(top),
538
- "$orderby": "start/dateTime",
539
- "$select": "id,subject,start,end,location,organizer,attendees,isAllDay,isCancelled,showAs,importance,bodyPreview,onlineMeeting,webLink"
540
- }
541
- });
542
- const events = (data.value || []).map((e) => ({
543
- id: e.id,
544
- subject: e.subject,
545
- start: e.start?.dateTime,
546
- startTimeZone: e.start?.timeZone,
547
- end: e.end?.dateTime,
548
- endTimeZone: e.end?.timeZone,
549
- isAllDay: e.isAllDay,
550
- location: e.location?.displayName,
551
- organizer: e.organizer?.emailAddress?.address,
552
- attendees: e.attendees?.map((a) => ({
553
- email: a.emailAddress?.address,
554
- name: a.emailAddress?.name,
555
- status: a.status?.response,
556
- type: a.type
557
- })),
558
- showAs: e.showAs,
559
- isCancelled: e.isCancelled,
560
- preview: e.bodyPreview,
561
- meetingUrl: e.onlineMeeting?.joinUrl,
562
- webLink: e.webLink
563
- }));
564
- return jsonResult({ events, count: events.length });
565
- } catch (e) {
566
- return errorResult(e.message);
567
- }
568
- }
569
- },
570
- {
571
- name: "outlook_calendar_create",
572
- description: "Create a new calendar event. Supports attendees, location, online meeting (Teams), and recurrence.",
573
- category: "utility",
574
- parameters: {
575
- type: "object",
576
- properties: {
577
- subject: { type: "string", description: "Event subject/title" },
578
- start: { type: "string", description: "Start time (ISO 8601)" },
579
- end: { type: "string", description: "End time (ISO 8601)" },
580
- timeZone: { type: "string", description: "Time zone (default: UTC)" },
581
- location: { type: "string", description: "Location name" },
582
- body: { type: "string", description: "Event body/description" },
583
- attendees: { type: "string", description: "Attendee emails, comma-separated" },
584
- isOnlineMeeting: { type: "boolean", description: "Create a Teams meeting link (default: false)" },
585
- isAllDay: { type: "boolean", description: "All-day event" },
586
- importance: { type: "string", description: "low, normal, or high" },
587
- reminderMinutes: { type: "number", description: "Reminder before event in minutes (default: 15)" },
588
- calendarId: { type: "string", description: "Calendar ID (omit for default)" }
589
- },
590
- required: ["subject", "start", "end"]
591
- },
592
- async execute(_id, params) {
593
- try {
594
- const token = await tp.getAccessToken();
595
- const tz = params.timeZone || "UTC";
596
- const event = {
597
- subject: params.subject,
598
- start: { dateTime: params.start, timeZone: tz },
599
- end: { dateTime: params.end, timeZone: tz }
600
- };
601
- if (params.location) event.location = { displayName: params.location };
602
- if (params.body) event.body = { contentType: "HTML", content: params.body };
603
- if (params.attendees) {
604
- event.attendees = params.attendees.split(",").map((e) => ({
605
- emailAddress: { address: e.trim() },
606
- type: "required"
607
- }));
608
- }
609
- if (params.isOnlineMeeting) {
610
- event.isOnlineMeeting = true;
611
- event.onlineMeetingProvider = "teamsForBusiness";
612
- }
613
- if (params.isAllDay) event.isAllDay = true;
614
- if (params.importance) event.importance = params.importance;
615
- if (params.reminderMinutes !== void 0) {
616
- event.isReminderOn = true;
617
- event.reminderMinutesBefore = params.reminderMinutes;
618
- }
619
- const basePath = params.calendarId ? `/me/calendars/${params.calendarId}/events` : "/me/events";
620
- const created = await graph(token, basePath, { method: "POST", body: event });
621
- return jsonResult({
622
- id: created.id,
623
- subject: created.subject,
624
- start: created.start?.dateTime,
625
- end: created.end?.dateTime,
626
- meetingUrl: created.onlineMeeting?.joinUrl,
627
- webLink: created.webLink
628
- });
629
- } catch (e) {
630
- return errorResult(e.message);
631
- }
632
- }
633
- },
634
- {
635
- name: "outlook_calendar_update",
636
- description: "Update an existing calendar event.",
637
- category: "utility",
638
- parameters: {
639
- type: "object",
640
- properties: {
641
- eventId: { type: "string", description: "Event ID to update" },
642
- subject: { type: "string", description: "New subject" },
643
- start: { type: "string", description: "New start time (ISO 8601)" },
644
- end: { type: "string", description: "New end time (ISO 8601)" },
645
- timeZone: { type: "string", description: "Time zone" },
646
- location: { type: "string", description: "New location" },
647
- body: { type: "string", description: "New body content" }
648
- },
649
- required: ["eventId"]
650
- },
651
- async execute(_id, params) {
652
- try {
653
- const token = await tp.getAccessToken();
654
- const update = {};
655
- if (params.subject) update.subject = params.subject;
656
- if (params.start) update.start = { dateTime: params.start, timeZone: params.timeZone || "UTC" };
657
- if (params.end) update.end = { dateTime: params.end, timeZone: params.timeZone || "UTC" };
658
- if (params.location) update.location = { displayName: params.location };
659
- if (params.body) update.body = { contentType: "HTML", content: params.body };
660
- const updated = await graph(token, `/me/events/${params.eventId}`, { method: "PATCH", body: update });
661
- return jsonResult({ id: updated.id, subject: updated.subject, updated: true });
662
- } catch (e) {
663
- return errorResult(e.message);
664
- }
665
- }
666
- },
667
- {
668
- name: "outlook_calendar_delete",
669
- description: "Delete a calendar event.",
670
- category: "utility",
671
- parameters: {
672
- type: "object",
673
- properties: {
674
- eventId: { type: "string", description: "Event ID to delete" }
675
- },
676
- required: ["eventId"]
677
- },
678
- async execute(_id, params) {
679
- try {
680
- const token = await tp.getAccessToken();
681
- await graph(token, `/me/events/${params.eventId}`, { method: "DELETE" });
682
- return jsonResult({ deleted: true, eventId: params.eventId });
683
- } catch (e) {
684
- return errorResult(e.message);
685
- }
686
- }
687
- },
688
- {
689
- name: "outlook_calendar_respond",
690
- description: "Respond to a calendar event invitation (accept, tentatively accept, or decline).",
691
- category: "utility",
692
- parameters: {
693
- type: "object",
694
- properties: {
695
- eventId: { type: "string", description: "Event ID to respond to" },
696
- response: { type: "string", description: "accept, tentativelyAccept, or decline" },
697
- comment: { type: "string", description: "Optional response message" },
698
- sendResponse: { type: "boolean", description: "Send response to organizer (default: true)" }
699
- },
700
- required: ["eventId", "response"]
701
- },
702
- async execute(_id, params) {
703
- try {
704
- const token = await tp.getAccessToken();
705
- const body = { sendResponse: params.sendResponse !== false };
706
- if (params.comment) body.comment = params.comment;
707
- await graph(token, `/me/events/${params.eventId}/${params.response}`, { method: "POST", body });
708
- return jsonResult({ responded: true, eventId: params.eventId, response: params.response });
709
- } catch (e) {
710
- return errorResult(e.message);
711
- }
712
- }
713
- },
714
- {
715
- name: "outlook_calendar_freebusy",
716
- description: "Check free/busy availability for one or more users.",
717
- category: "utility",
718
- parameters: {
719
- type: "object",
720
- properties: {
721
- emails: { type: "string", description: "Email addresses to check, comma-separated" },
722
- start: { type: "string", description: "Start of range (ISO 8601)" },
723
- end: { type: "string", description: "End of range (ISO 8601)" },
724
- timeZone: { type: "string", description: "Time zone (default: UTC)" }
725
- },
726
- required: ["emails", "start", "end"]
727
- },
728
- async execute(_id, params) {
729
- try {
730
- const token = await tp.getAccessToken();
731
- const schedules = params.emails.split(",").map((e) => e.trim());
732
- const data = await graph(token, "/me/calendar/getSchedule", {
733
- method: "POST",
734
- body: {
735
- schedules,
736
- startTime: { dateTime: params.start, timeZone: params.timeZone || "UTC" },
737
- endTime: { dateTime: params.end, timeZone: params.timeZone || "UTC" },
738
- availabilityViewInterval: 30
739
- }
740
- });
741
- const results = (data.value || []).map((s) => ({
742
- email: s.scheduleId,
743
- availability: s.availabilityView,
744
- items: s.scheduleItems?.map((i) => ({
745
- status: i.status,
746
- subject: i.subject,
747
- start: i.start?.dateTime,
748
- end: i.end?.dateTime
749
- }))
750
- }));
751
- return jsonResult({ schedules: results });
752
- } catch (e) {
753
- return errorResult(e.message);
754
- }
755
- }
756
- }
757
- ];
758
- }
759
-
760
- // src/agent-tools/tools/microsoft/onedrive.ts
761
- function createOneDriveTools(config, _options) {
762
- const tp = config.tokenProvider;
763
- return [
764
- {
765
- name: "onedrive_list",
766
- description: "List files and folders in OneDrive. Defaults to root folder.",
767
- category: "utility",
768
- parameters: {
769
- type: "object",
770
- properties: {
771
- path: { type: "string", description: 'Folder path (e.g., "/Documents/Reports") or item ID. Default: root' },
772
- maxResults: { type: "number", description: "Max items to return (default: 50)" }
773
- },
774
- required: []
775
- },
776
- async execute(_id, params) {
777
- try {
778
- const token = await tp.getAccessToken();
779
- const top = params.maxResults || 50;
780
- const basePath = params.path ? `/me/drive/root:${params.path}:/children` : "/me/drive/root/children";
781
- const data = await graph(token, basePath, {
782
- query: { "$top": String(top), "$select": "id,name,size,createdDateTime,lastModifiedDateTime,webUrl,folder,file,parentReference" }
783
- });
784
- const items = (data.value || []).map((i) => ({
785
- id: i.id,
786
- name: i.name,
787
- size: i.size,
788
- type: i.folder ? "folder" : "file",
789
- mimeType: i.file?.mimeType,
790
- childCount: i.folder?.childCount,
791
- created: i.createdDateTime,
792
- modified: i.lastModifiedDateTime,
793
- webUrl: i.webUrl,
794
- path: i.parentReference?.path
795
- }));
796
- return jsonResult({ items, count: items.length });
797
- } catch (e) {
798
- return errorResult(e.message);
799
- }
800
- }
801
- },
802
- {
803
- name: "onedrive_search",
804
- description: "Search for files in OneDrive by name or content.",
805
- category: "utility",
806
- parameters: {
807
- type: "object",
808
- properties: {
809
- query: { type: "string", description: "Search query" },
810
- maxResults: { type: "number", description: "Max results (default: 20)" }
811
- },
812
- required: ["query"]
813
- },
814
- async execute(_id, params) {
815
- try {
816
- const token = await tp.getAccessToken();
817
- const top = params.maxResults || 20;
818
- const data = await graph(token, `/me/drive/root/search(q='${encodeURIComponent(params.query)}')`, {
819
- query: { "$top": String(top), "$select": "id,name,size,webUrl,file,folder,lastModifiedDateTime,parentReference" }
820
- });
821
- const items = (data.value || []).map((i) => ({
822
- id: i.id,
823
- name: i.name,
824
- size: i.size,
825
- type: i.folder ? "folder" : "file",
826
- mimeType: i.file?.mimeType,
827
- modified: i.lastModifiedDateTime,
828
- webUrl: i.webUrl,
829
- path: i.parentReference?.path
830
- }));
831
- return jsonResult({ items, count: items.length, query: params.query });
832
- } catch (e) {
833
- return errorResult(e.message);
834
- }
835
- }
836
- },
837
- {
838
- name: "onedrive_read",
839
- description: "Read/download a file from OneDrive. For text files returns content; for binary returns download URL.",
840
- category: "utility",
841
- parameters: {
842
- type: "object",
843
- properties: {
844
- itemId: { type: "string", description: "File item ID" },
845
- path: { type: "string", description: 'File path (alternative to itemId, e.g., "/Documents/report.txt")' }
846
- },
847
- required: []
848
- },
849
- async execute(_id, params) {
850
- try {
851
- const token = await tp.getAccessToken();
852
- const itemPath4 = params.itemId ? `/me/drive/items/${params.itemId}` : `/me/drive/root:${params.path}:`;
853
- const meta = await graph(token, itemPath4, {
854
- query: { "$select": "id,name,size,file,webUrl,@microsoft.graph.downloadUrl" }
855
- });
856
- const isText = meta.file?.mimeType?.startsWith("text/") || /\.(txt|md|csv|json|xml|html|css|js|ts|py|rb|go|rs|yaml|yml|toml|ini|cfg|log|sh|bat|ps1|sql)$/i.test(meta.name || "");
857
- if (isText && meta.size < 1048576) {
858
- const contentRes = await fetch(meta["@microsoft.graph.downloadUrl"] || `https://graph.microsoft.com/v1.0${itemPath4}/content`, {
859
- headers: { Authorization: `Bearer ${token}` }
860
- });
861
- const content = await contentRes.text();
862
- return jsonResult({ id: meta.id, name: meta.name, size: meta.size, content });
863
- }
864
- return jsonResult({
865
- id: meta.id,
866
- name: meta.name,
867
- size: meta.size,
868
- mimeType: meta.file?.mimeType,
869
- downloadUrl: meta["@microsoft.graph.downloadUrl"],
870
- webUrl: meta.webUrl
871
- });
872
- } catch (e) {
873
- return errorResult(e.message);
874
- }
875
- }
876
- },
877
- {
878
- name: "onedrive_upload",
879
- description: "Upload a text file to OneDrive. For small files (< 4MB).",
880
- category: "utility",
881
- parameters: {
882
- type: "object",
883
- properties: {
884
- path: { type: "string", description: 'Destination path (e.g., "/Documents/report.md")' },
885
- content: { type: "string", description: "File content (text)" },
886
- conflictBehavior: { type: "string", description: "rename, replace, or fail (default: replace)" }
887
- },
888
- required: ["path", "content"]
889
- },
890
- async execute(_id, params) {
891
- try {
892
- const token = await tp.getAccessToken();
893
- const conflict = params.conflictBehavior || "replace";
894
- const res = await fetch(`https://graph.microsoft.com/v1.0/me/drive/root:${params.path}:/content?@microsoft.graph.conflictBehavior=${conflict}`, {
895
- method: "PUT",
896
- headers: { Authorization: `Bearer ${token}`, "Content-Type": "text/plain" },
897
- body: params.content
898
- });
899
- if (!res.ok) throw new Error(`Upload failed: ${res.status} ${await res.text()}`);
900
- const data = await res.json();
901
- return jsonResult({ id: data.id, name: data.name, size: data.size, webUrl: data.webUrl });
902
- } catch (e) {
903
- return errorResult(e.message);
904
- }
905
- }
906
- },
907
- {
908
- name: "onedrive_create_folder",
909
- description: "Create a new folder in OneDrive.",
910
- category: "utility",
911
- parameters: {
912
- type: "object",
913
- properties: {
914
- name: { type: "string", description: "Folder name" },
915
- parentPath: { type: "string", description: "Parent folder path (default: root)" }
916
- },
917
- required: ["name"]
918
- },
919
- async execute(_id, params) {
920
- try {
921
- const token = await tp.getAccessToken();
922
- const parentPath = params.parentPath ? `/me/drive/root:${params.parentPath}:/children` : "/me/drive/root/children";
923
- const folder = await graph(token, parentPath, {
924
- method: "POST",
925
- body: { name: params.name, folder: {}, "@microsoft.graph.conflictBehavior": "rename" }
926
- });
927
- return jsonResult({ id: folder.id, name: folder.name, webUrl: folder.webUrl });
928
- } catch (e) {
929
- return errorResult(e.message);
930
- }
931
- }
932
- },
933
- {
934
- name: "onedrive_delete",
935
- description: "Delete a file or folder from OneDrive.",
936
- category: "utility",
937
- parameters: {
938
- type: "object",
939
- properties: {
940
- itemId: { type: "string", description: "Item ID to delete" }
941
- },
942
- required: ["itemId"]
943
- },
944
- async execute(_id, params) {
945
- try {
946
- const token = await tp.getAccessToken();
947
- await graph(token, `/me/drive/items/${params.itemId}`, { method: "DELETE" });
948
- return jsonResult({ deleted: true, itemId: params.itemId });
949
- } catch (e) {
950
- return errorResult(e.message);
951
- }
952
- }
953
- },
954
- {
955
- name: "onedrive_share",
956
- description: "Create a sharing link for a file or folder.",
957
- category: "utility",
958
- parameters: {
959
- type: "object",
960
- properties: {
961
- itemId: { type: "string", description: "Item ID to share" },
962
- type: { type: "string", description: "view or edit (default: view)" },
963
- scope: { type: "string", description: "anonymous (anyone) or organization (default: organization)" }
964
- },
965
- required: ["itemId"]
966
- },
967
- async execute(_id, params) {
968
- try {
969
- const token = await tp.getAccessToken();
970
- const link = await graph(token, `/me/drive/items/${params.itemId}/createLink`, {
971
- method: "POST",
972
- body: { type: params.type || "view", scope: params.scope || "organization" }
973
- });
974
- return jsonResult({ url: link.link?.webUrl, type: link.link?.type, scope: link.link?.scope });
975
- } catch (e) {
976
- return errorResult(e.message);
977
- }
978
- }
979
- }
980
- ];
981
- }
982
-
983
- // src/agent-tools/tools/microsoft/teams.ts
984
- function createTeamsTools(config, _options) {
985
- const tp = config.tokenProvider;
986
- return [
987
- {
988
- name: "teams_list_teams",
989
- description: "List all Teams the agent is a member of.",
990
- category: "utility",
991
- parameters: { type: "object", properties: {}, required: [] },
992
- async execute(_id) {
993
- try {
994
- const token = await tp.getAccessToken();
995
- const data = await graph(token, "/me/joinedTeams", {
996
- query: { "$select": "id,displayName,description" }
997
- });
998
- const teams = (data.value || []).map((t) => ({
999
- id: t.id,
1000
- name: t.displayName,
1001
- description: t.description
1002
- }));
1003
- return jsonResult({ teams, count: teams.length });
1004
- } catch (e) {
1005
- return errorResult(e.message);
1006
- }
1007
- }
1008
- },
1009
- {
1010
- name: "teams_list_channels",
1011
- description: "List channels in a Team.",
1012
- category: "utility",
1013
- parameters: {
1014
- type: "object",
1015
- properties: {
1016
- teamId: { type: "string", description: "Team ID" }
1017
- },
1018
- required: ["teamId"]
1019
- },
1020
- async execute(_id, params) {
1021
- try {
1022
- const token = await tp.getAccessToken();
1023
- const data = await graph(token, `/teams/${params.teamId}/channels`, {
1024
- query: { "$select": "id,displayName,description,membershipType" }
1025
- });
1026
- const channels = (data.value || []).map((c) => ({
1027
- id: c.id,
1028
- name: c.displayName,
1029
- description: c.description,
1030
- membershipType: c.membershipType
1031
- }));
1032
- return jsonResult({ channels, count: channels.length });
1033
- } catch (e) {
1034
- return errorResult(e.message);
1035
- }
1036
- }
1037
- },
1038
- {
1039
- name: "teams_send_channel_message",
1040
- description: "Send a message to a Teams channel.",
1041
- category: "utility",
1042
- parameters: {
1043
- type: "object",
1044
- properties: {
1045
- teamId: { type: "string", description: "Team ID" },
1046
- channelId: { type: "string", description: "Channel ID" },
1047
- message: { type: "string", description: "Message content (supports HTML)" },
1048
- isHtml: { type: "boolean", description: "Whether message is HTML (default: false)" }
1049
- },
1050
- required: ["teamId", "channelId", "message"]
1051
- },
1052
- async execute(_id, params) {
1053
- try {
1054
- const token = await tp.getAccessToken();
1055
- const msg = await graph(token, `/teams/${params.teamId}/channels/${params.channelId}/messages`, {
1056
- method: "POST",
1057
- body: {
1058
- body: {
1059
- contentType: params.isHtml ? "html" : "text",
1060
- content: params.message
1061
- }
1062
- }
1063
- });
1064
- return jsonResult({ id: msg.id, sent: true });
1065
- } catch (e) {
1066
- return errorResult(e.message);
1067
- }
1068
- }
1069
- },
1070
- {
1071
- name: "teams_read_channel_messages",
1072
- description: "Read recent messages from a Teams channel.",
1073
- category: "utility",
1074
- parameters: {
1075
- type: "object",
1076
- properties: {
1077
- teamId: { type: "string", description: "Team ID" },
1078
- channelId: { type: "string", description: "Channel ID" },
1079
- maxResults: { type: "number", description: "Max messages (default: 20)" }
1080
- },
1081
- required: ["teamId", "channelId"]
1082
- },
1083
- async execute(_id, params) {
1084
- try {
1085
- const token = await tp.getAccessToken();
1086
- const data = await graph(token, `/teams/${params.teamId}/channels/${params.channelId}/messages`, {
1087
- query: { "$top": String(params.maxResults || 20) }
1088
- });
1089
- const messages = (data.value || []).map((m) => ({
1090
- id: m.id,
1091
- from: m.from?.user?.displayName || m.from?.application?.displayName,
1092
- fromEmail: m.from?.user?.email,
1093
- body: m.body?.content,
1094
- bodyType: m.body?.contentType,
1095
- date: m.createdDateTime,
1096
- importance: m.importance,
1097
- replyCount: m.replies?.length
1098
- }));
1099
- return jsonResult({ messages, count: messages.length });
1100
- } catch (e) {
1101
- return errorResult(e.message);
1102
- }
1103
- }
1104
- },
1105
- {
1106
- name: "teams_list_chats",
1107
- description: "List the agent's 1:1 and group chats in Teams.",
1108
- category: "utility",
1109
- parameters: {
1110
- type: "object",
1111
- properties: {
1112
- maxResults: { type: "number", description: "Max chats to return (default: 20)" }
1113
- },
1114
- required: []
1115
- },
1116
- async execute(_id, params) {
1117
- try {
1118
- const token = await tp.getAccessToken();
1119
- const data = await graph(token, "/me/chats", {
1120
- query: {
1121
- "$top": String(params.maxResults || 20),
1122
- "$select": "id,topic,chatType,createdDateTime,lastUpdatedDateTime",
1123
- "$orderby": "lastUpdatedDateTime desc"
1124
- }
1125
- });
1126
- const chats = (data.value || []).map((c) => ({
1127
- id: c.id,
1128
- topic: c.topic,
1129
- type: c.chatType,
1130
- created: c.createdDateTime,
1131
- lastUpdated: c.lastUpdatedDateTime
1132
- }));
1133
- return jsonResult({ chats, count: chats.length });
1134
- } catch (e) {
1135
- return errorResult(e.message);
1136
- }
1137
- }
1138
- },
1139
- {
1140
- name: "teams_send_chat_message",
1141
- description: "Send a message in a Teams 1:1 or group chat.",
1142
- category: "utility",
1143
- parameters: {
1144
- type: "object",
1145
- properties: {
1146
- chatId: { type: "string", description: "Chat ID" },
1147
- message: { type: "string", description: "Message content" },
1148
- isHtml: { type: "boolean", description: "Whether message is HTML (default: false)" }
1149
- },
1150
- required: ["chatId", "message"]
1151
- },
1152
- async execute(_id, params) {
1153
- try {
1154
- const token = await tp.getAccessToken();
1155
- const msg = await graph(token, `/chats/${params.chatId}/messages`, {
1156
- method: "POST",
1157
- body: {
1158
- body: { contentType: params.isHtml ? "html" : "text", content: params.message }
1159
- }
1160
- });
1161
- return jsonResult({ id: msg.id, sent: true });
1162
- } catch (e) {
1163
- return errorResult(e.message);
1164
- }
1165
- }
1166
- },
1167
- {
1168
- name: "teams_read_chat_messages",
1169
- description: "Read recent messages from a Teams chat.",
1170
- category: "utility",
1171
- parameters: {
1172
- type: "object",
1173
- properties: {
1174
- chatId: { type: "string", description: "Chat ID" },
1175
- maxResults: { type: "number", description: "Max messages (default: 20)" }
1176
- },
1177
- required: ["chatId"]
1178
- },
1179
- async execute(_id, params) {
1180
- try {
1181
- const token = await tp.getAccessToken();
1182
- const data = await graph(token, `/chats/${params.chatId}/messages`, {
1183
- query: { "$top": String(params.maxResults || 20), "$orderby": "createdDateTime desc" }
1184
- });
1185
- const messages = (data.value || []).map((m) => ({
1186
- id: m.id,
1187
- from: m.from?.user?.displayName,
1188
- body: m.body?.content,
1189
- bodyType: m.body?.contentType,
1190
- date: m.createdDateTime
1191
- }));
1192
- return jsonResult({ messages, count: messages.length });
1193
- } catch (e) {
1194
- return errorResult(e.message);
1195
- }
1196
- }
1197
- },
1198
- {
1199
- name: "teams_presence",
1200
- description: "Get presence/availability status for users.",
1201
- category: "utility",
1202
- parameters: {
1203
- type: "object",
1204
- properties: {
1205
- userIds: { type: "string", description: 'User IDs, comma-separated (use "me" for self)' }
1206
- },
1207
- required: ["userIds"]
1208
- },
1209
- async execute(_id, params) {
1210
- try {
1211
- const token = await tp.getAccessToken();
1212
- if (params.userIds === "me") {
1213
- const p = await graph(token, "/me/presence");
1214
- return jsonResult({ presence: [{ availability: p.availability, activity: p.activity }] });
1215
- }
1216
- const ids = params.userIds.split(",").map((s) => s.trim());
1217
- const data = await graph(token, "/communications/getPresencesByUserId", {
1218
- method: "POST",
1219
- body: { ids }
1220
- });
1221
- const presence = (data.value || []).map((p) => ({
1222
- userId: p.id,
1223
- availability: p.availability,
1224
- activity: p.activity
1225
- }));
1226
- return jsonResult({ presence });
1227
- } catch (e) {
1228
- return errorResult(e.message);
1229
- }
1230
- }
1231
- }
1232
- ];
1233
- }
1234
-
1235
- // src/agent-tools/tools/microsoft/todo.ts
1236
- function createTodoTools(config, _options) {
1237
- const tp = config.tokenProvider;
1238
- return [
1239
- {
1240
- name: "todo_list_lists",
1241
- description: "List all To Do task lists.",
1242
- category: "utility",
1243
- parameters: { type: "object", properties: {}, required: [] },
1244
- async execute(_id) {
1245
- try {
1246
- const token = await tp.getAccessToken();
1247
- const data = await graph(token, "/me/todo/lists");
1248
- const lists = (data.value || []).map((l) => ({
1249
- id: l.id,
1250
- name: l.displayName,
1251
- isOwner: l.isOwner,
1252
- wellknownName: l.wellknownListName
1253
- }));
1254
- return jsonResult({ lists, count: lists.length });
1255
- } catch (e) {
1256
- return errorResult(e.message);
1257
- }
1258
- }
1259
- },
1260
- {
1261
- name: "todo_list_tasks",
1262
- description: "List tasks in a To Do list.",
1263
- category: "utility",
1264
- parameters: {
1265
- type: "object",
1266
- properties: {
1267
- listId: { type: "string", description: "Task list ID" },
1268
- includeCompleted: { type: "boolean", description: "Include completed tasks (default: false)" },
1269
- maxResults: { type: "number", description: "Max tasks (default: 50)" }
1270
- },
1271
- required: ["listId"]
1272
- },
1273
- async execute(_id, params) {
1274
- try {
1275
- const token = await tp.getAccessToken();
1276
- const query = {
1277
- "$top": String(params.maxResults || 50),
1278
- "$orderby": "importance desc,createdDateTime desc",
1279
- "$select": "id,title,body,status,importance,createdDateTime,lastModifiedDateTime,dueDateTime,completedDateTime,isReminderOn,reminderDateTime"
1280
- };
1281
- if (!params.includeCompleted) query["$filter"] = "status ne 'completed'";
1282
- const data = await graph(token, `/me/todo/lists/${params.listId}/tasks`, { query });
1283
- const tasks = (data.value || []).map((t) => ({
1284
- id: t.id,
1285
- title: t.title,
1286
- body: t.body?.content,
1287
- bodyType: t.body?.contentType,
1288
- status: t.status,
1289
- importance: t.importance,
1290
- created: t.createdDateTime,
1291
- modified: t.lastModifiedDateTime,
1292
- dueDate: t.dueDateTime?.dateTime,
1293
- dueTimeZone: t.dueDateTime?.timeZone,
1294
- completedDate: t.completedDateTime?.dateTime,
1295
- hasReminder: t.isReminderOn
1296
- }));
1297
- return jsonResult({ tasks, count: tasks.length });
1298
- } catch (e) {
1299
- return errorResult(e.message);
1300
- }
1301
- }
1302
- },
1303
- {
1304
- name: "todo_create_task",
1305
- description: "Create a new task in a To Do list.",
1306
- category: "utility",
1307
- parameters: {
1308
- type: "object",
1309
- properties: {
1310
- listId: { type: "string", description: "Task list ID" },
1311
- title: { type: "string", description: "Task title" },
1312
- body: { type: "string", description: "Task notes/description" },
1313
- dueDate: { type: "string", description: 'Due date (ISO 8601 date, e.g., "2026-03-15")' },
1314
- importance: { type: "string", description: "low, normal, or high (default: normal)" },
1315
- reminderDateTime: { type: "string", description: "Reminder date/time (ISO 8601)" }
1316
- },
1317
- required: ["listId", "title"]
1318
- },
1319
- async execute(_id, params) {
1320
- try {
1321
- const token = await tp.getAccessToken();
1322
- const task = { title: params.title };
1323
- if (params.body) task.body = { contentType: "text", content: params.body };
1324
- if (params.dueDate) task.dueDateTime = { dateTime: params.dueDate + "T00:00:00", timeZone: "UTC" };
1325
- if (params.importance) task.importance = params.importance;
1326
- if (params.reminderDateTime) {
1327
- task.isReminderOn = true;
1328
- task.reminderDateTime = { dateTime: params.reminderDateTime, timeZone: "UTC" };
1329
- }
1330
- const created = await graph(token, `/me/todo/lists/${params.listId}/tasks`, { method: "POST", body: task });
1331
- return jsonResult({ id: created.id, title: created.title, status: created.status });
1332
- } catch (e) {
1333
- return errorResult(e.message);
1334
- }
1335
- }
1336
- },
1337
- {
1338
- name: "todo_update_task",
1339
- description: "Update an existing To Do task (title, status, due date, importance).",
1340
- category: "utility",
1341
- parameters: {
1342
- type: "object",
1343
- properties: {
1344
- listId: { type: "string", description: "Task list ID" },
1345
- taskId: { type: "string", description: "Task ID" },
1346
- title: { type: "string", description: "New title" },
1347
- status: { type: "string", description: "notStarted, inProgress, completed, waitingOnOthers, deferred" },
1348
- importance: { type: "string", description: "low, normal, or high" },
1349
- dueDate: { type: "string", description: "New due date (ISO 8601 date)" },
1350
- body: { type: "string", description: "New task notes" }
1351
- },
1352
- required: ["listId", "taskId"]
1353
- },
1354
- async execute(_id, params) {
1355
- try {
1356
- const token = await tp.getAccessToken();
1357
- const update = {};
1358
- if (params.title) update.title = params.title;
1359
- if (params.status) update.status = params.status;
1360
- if (params.importance) update.importance = params.importance;
1361
- if (params.dueDate) update.dueDateTime = { dateTime: params.dueDate + "T00:00:00", timeZone: "UTC" };
1362
- if (params.body) update.body = { contentType: "text", content: params.body };
1363
- const updated = await graph(token, `/me/todo/lists/${params.listId}/tasks/${params.taskId}`, {
1364
- method: "PATCH",
1365
- body: update
1366
- });
1367
- return jsonResult({ id: updated.id, title: updated.title, status: updated.status, updated: true });
1368
- } catch (e) {
1369
- return errorResult(e.message);
1370
- }
1371
- }
1372
- },
1373
- {
1374
- name: "todo_delete_task",
1375
- description: "Delete a To Do task.",
1376
- category: "utility",
1377
- parameters: {
1378
- type: "object",
1379
- properties: {
1380
- listId: { type: "string", description: "Task list ID" },
1381
- taskId: { type: "string", description: "Task ID to delete" }
1382
- },
1383
- required: ["listId", "taskId"]
1384
- },
1385
- async execute(_id, params) {
1386
- try {
1387
- const token = await tp.getAccessToken();
1388
- await graph(token, `/me/todo/lists/${params.listId}/tasks/${params.taskId}`, { method: "DELETE" });
1389
- return jsonResult({ deleted: true, taskId: params.taskId });
1390
- } catch (e) {
1391
- return errorResult(e.message);
1392
- }
1393
- }
1394
- },
1395
- {
1396
- name: "todo_create_list",
1397
- description: "Create a new To Do task list.",
1398
- category: "utility",
1399
- parameters: {
1400
- type: "object",
1401
- properties: {
1402
- name: { type: "string", description: "List name" }
1403
- },
1404
- required: ["name"]
1405
- },
1406
- async execute(_id, params) {
1407
- try {
1408
- const token = await tp.getAccessToken();
1409
- const list = await graph(token, "/me/todo/lists", {
1410
- method: "POST",
1411
- body: { displayName: params.name }
1412
- });
1413
- return jsonResult({ id: list.id, name: list.displayName });
1414
- } catch (e) {
1415
- return errorResult(e.message);
1416
- }
1417
- }
1418
- }
1419
- ];
1420
- }
1421
-
1422
- // src/agent-tools/tools/microsoft/contacts.ts
1423
- function createOutlookContactsTools(config, _options) {
1424
- const tp = config.tokenProvider;
1425
- return [
1426
- {
1427
- name: "outlook_contacts_list",
1428
- description: "List contacts from the Outlook address book.",
1429
- category: "utility",
1430
- parameters: {
1431
- type: "object",
1432
- properties: {
1433
- maxResults: { type: "number", description: "Max contacts (default: 50)" },
1434
- search: { type: "string", description: "Search by name or email" }
1435
- },
1436
- required: []
1437
- },
1438
- async execute(_id, params) {
1439
- try {
1440
- const token = await tp.getAccessToken();
1441
- const query = {
1442
- "$top": String(params.maxResults || 50),
1443
- "$select": "id,displayName,givenName,surname,emailAddresses,mobilePhone,businessPhones,companyName,jobTitle",
1444
- "$orderby": "displayName"
1445
- };
1446
- if (params.search) query["$filter"] = `startswith(displayName,'${params.search}') or startswith(givenName,'${params.search}') or startswith(surname,'${params.search}')`;
1447
- const data = await graph(token, "/me/contacts", { query });
1448
- const contacts = (data.value || []).map((c) => ({
1449
- id: c.id,
1450
- name: c.displayName,
1451
- firstName: c.givenName,
1452
- lastName: c.surname,
1453
- emails: c.emailAddresses?.map((e) => e.address),
1454
- mobile: c.mobilePhone,
1455
- phones: c.businessPhones,
1456
- company: c.companyName,
1457
- jobTitle: c.jobTitle
1458
- }));
1459
- return jsonResult({ contacts, count: contacts.length });
1460
- } catch (e) {
1461
- return errorResult(e.message);
1462
- }
1463
- }
1464
- },
1465
- {
1466
- name: "outlook_contacts_create",
1467
- description: "Create a new contact in Outlook.",
1468
- category: "utility",
1469
- parameters: {
1470
- type: "object",
1471
- properties: {
1472
- firstName: { type: "string", description: "First name" },
1473
- lastName: { type: "string", description: "Last name" },
1474
- email: { type: "string", description: "Email address" },
1475
- mobile: { type: "string", description: "Mobile phone number" },
1476
- company: { type: "string", description: "Company name" },
1477
- jobTitle: { type: "string", description: "Job title" },
1478
- notes: { type: "string", description: "Personal notes" }
1479
- },
1480
- required: ["firstName", "email"]
1481
- },
1482
- async execute(_id, params) {
1483
- try {
1484
- const token = await tp.getAccessToken();
1485
- const contact = {
1486
- givenName: params.firstName,
1487
- emailAddresses: [{ address: params.email, name: `${params.firstName} ${params.lastName || ""}`.trim() }]
1488
- };
1489
- if (params.lastName) contact.surname = params.lastName;
1490
- if (params.mobile) contact.mobilePhone = params.mobile;
1491
- if (params.company) contact.companyName = params.company;
1492
- if (params.jobTitle) contact.jobTitle = params.jobTitle;
1493
- if (params.notes) contact.personalNotes = params.notes;
1494
- const created = await graph(token, "/me/contacts", { method: "POST", body: contact });
1495
- return jsonResult({ id: created.id, name: created.displayName, email: params.email });
1496
- } catch (e) {
1497
- return errorResult(e.message);
1498
- }
1499
- }
1500
- },
1501
- {
1502
- name: "outlook_contacts_update",
1503
- description: "Update an existing contact.",
1504
- category: "utility",
1505
- parameters: {
1506
- type: "object",
1507
- properties: {
1508
- contactId: { type: "string", description: "Contact ID" },
1509
- firstName: { type: "string", description: "First name" },
1510
- lastName: { type: "string", description: "Last name" },
1511
- email: { type: "string", description: "Email address" },
1512
- mobile: { type: "string", description: "Mobile phone" },
1513
- company: { type: "string", description: "Company name" },
1514
- jobTitle: { type: "string", description: "Job title" }
1515
- },
1516
- required: ["contactId"]
1517
- },
1518
- async execute(_id, params) {
1519
- try {
1520
- const token = await tp.getAccessToken();
1521
- const update = {};
1522
- if (params.firstName) update.givenName = params.firstName;
1523
- if (params.lastName) update.surname = params.lastName;
1524
- if (params.email) update.emailAddresses = [{ address: params.email }];
1525
- if (params.mobile) update.mobilePhone = params.mobile;
1526
- if (params.company) update.companyName = params.company;
1527
- if (params.jobTitle) update.jobTitle = params.jobTitle;
1528
- await graph(token, `/me/contacts/${params.contactId}`, { method: "PATCH", body: update });
1529
- return jsonResult({ updated: true, contactId: params.contactId });
1530
- } catch (e) {
1531
- return errorResult(e.message);
1532
- }
1533
- }
1534
- },
1535
- {
1536
- name: "outlook_contacts_delete",
1537
- description: "Delete a contact from Outlook.",
1538
- category: "utility",
1539
- parameters: {
1540
- type: "object",
1541
- properties: {
1542
- contactId: { type: "string", description: "Contact ID to delete" }
1543
- },
1544
- required: ["contactId"]
1545
- },
1546
- async execute(_id, params) {
1547
- try {
1548
- const token = await tp.getAccessToken();
1549
- await graph(token, `/me/contacts/${params.contactId}`, { method: "DELETE" });
1550
- return jsonResult({ deleted: true, contactId: params.contactId });
1551
- } catch (e) {
1552
- return errorResult(e.message);
1553
- }
1554
- }
1555
- },
1556
- {
1557
- name: "outlook_people_search",
1558
- description: "Search for people relevant to the user (contacts, colleagues, recent correspondents).",
1559
- category: "utility",
1560
- parameters: {
1561
- type: "object",
1562
- properties: {
1563
- query: { type: "string", description: "Search query (name or email)" },
1564
- maxResults: { type: "number", description: "Max results (default: 10)" }
1565
- },
1566
- required: ["query"]
1567
- },
1568
- async execute(_id, params) {
1569
- try {
1570
- const token = await tp.getAccessToken();
1571
- const data = await graph(token, "/me/people", {
1572
- query: {
1573
- "$search": `"${params.query}"`,
1574
- "$top": String(params.maxResults || 10),
1575
- "$select": "id,displayName,givenName,surname,emailAddresses,companyName,jobTitle,department"
1576
- }
1577
- });
1578
- const people = (data.value || []).map((p) => ({
1579
- id: p.id,
1580
- name: p.displayName,
1581
- firstName: p.givenName,
1582
- lastName: p.surname,
1583
- emails: p.emailAddresses?.map((e) => e.address),
1584
- company: p.companyName,
1585
- jobTitle: p.jobTitle,
1586
- department: p.department
1587
- }));
1588
- return jsonResult({ people, count: people.length });
1589
- } catch (e) {
1590
- return errorResult(e.message);
1591
- }
1592
- }
1593
- }
1594
- ];
1595
- }
1596
-
1597
- // src/agent-tools/tools/microsoft/excel.ts
1598
- function itemPath(p) {
1599
- if (p.driveId && p.itemId) return `/drives/${p.driveId}/items/${p.itemId}`;
1600
- if (p.itemId) return `/me/drive/items/${p.itemId}`;
1601
- if (p.path) return `/me/drive/root:${p.path}:`;
1602
- throw new Error("Provide itemId or path to the Excel file");
1603
- }
1604
- function createExcelTools(config, _options) {
1605
- const tp = config.tokenProvider;
1606
- return [
1607
- {
1608
- name: "excel_list_worksheets",
1609
- description: "List all worksheets in an Excel workbook.",
1610
- category: "utility",
1611
- parameters: {
1612
- type: "object",
1613
- properties: {
1614
- itemId: { type: "string", description: "OneDrive/SharePoint item ID of the Excel file" },
1615
- path: { type: "string", description: 'File path (alternative to itemId, e.g., "/Documents/Budget.xlsx")' },
1616
- driveId: { type: "string", description: "Drive ID (for SharePoint drives)" }
1617
- },
1618
- required: []
1619
- },
1620
- async execute(_id, params) {
1621
- try {
1622
- const token = await tp.getAccessToken();
1623
- const base = itemPath(params);
1624
- const data = await graph(token, `${base}/workbook/worksheets`);
1625
- const sheets = (data.value || []).map((s) => ({
1626
- id: s.id,
1627
- name: s.name,
1628
- position: s.position,
1629
- visibility: s.visibility
1630
- }));
1631
- return jsonResult({ worksheets: sheets, count: sheets.length });
1632
- } catch (e) {
1633
- return errorResult(e.message);
1634
- }
1635
- }
1636
- },
1637
- {
1638
- name: "excel_read_range",
1639
- description: "Read a range of cells from an Excel worksheet. Returns values, formulas, and formatting.",
1640
- category: "utility",
1641
- parameters: {
1642
- type: "object",
1643
- properties: {
1644
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
1645
- path: { type: "string", description: "File path (alternative to itemId)" },
1646
- driveId: { type: "string", description: "Drive ID (for SharePoint)" },
1647
- worksheet: { type: "string", description: "Worksheet name (default: first sheet)" },
1648
- range: { type: "string", description: 'Cell range (e.g., "A1:D10", "Sheet1!A1:Z100"). Omit for used range.' }
1649
- },
1650
- required: []
1651
- },
1652
- async execute(_id, params) {
1653
- try {
1654
- const token = await tp.getAccessToken();
1655
- const base = itemPath(params);
1656
- let rangePath;
1657
- if (params.range) {
1658
- const ws = params.worksheet ? `/worksheets/${encodeURIComponent(params.worksheet)}` : "/worksheets";
1659
- if (params.range.includes("!")) {
1660
- rangePath = `${base}/workbook/worksheets/${encodeURIComponent(params.range.split("!")[0])}/range(address='${params.range.split("!")[1]}')`;
1661
- } else if (params.worksheet) {
1662
- rangePath = `${base}/workbook/worksheets/${encodeURIComponent(params.worksheet)}/range(address='${params.range}')`;
1663
- } else {
1664
- rangePath = `${base}/workbook/worksheets('Sheet1')/range(address='${params.range}')`;
1665
- }
1666
- } else {
1667
- const ws = params.worksheet || "Sheet1";
1668
- rangePath = `${base}/workbook/worksheets/${encodeURIComponent(ws)}/usedRange`;
1669
- }
1670
- const data = await graph(token, rangePath, {
1671
- query: { "$select": "address,values,text,formulas,numberFormat,rowCount,columnCount" }
1672
- });
1673
- return jsonResult({
1674
- address: data.address,
1675
- values: data.values,
1676
- text: data.text,
1677
- formulas: data.formulas,
1678
- rows: data.rowCount,
1679
- columns: data.columnCount
1680
- });
1681
- } catch (e) {
1682
- return errorResult(e.message);
1683
- }
1684
- }
1685
- },
1686
- {
1687
- name: "excel_write_range",
1688
- description: "Write values to a range of cells in an Excel worksheet.",
1689
- category: "utility",
1690
- parameters: {
1691
- type: "object",
1692
- properties: {
1693
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
1694
- path: { type: "string", description: "File path (alternative to itemId)" },
1695
- driveId: { type: "string", description: "Drive ID (for SharePoint)" },
1696
- worksheet: { type: "string", description: "Worksheet name (default: Sheet1)" },
1697
- range: { type: "string", description: 'Cell range to write to (e.g., "A1:C3")' },
1698
- values: { type: "array", description: 'Array of arrays \u2014 each inner array is a row (e.g., [["Name","Age"],["Alice",30]])' }
1699
- },
1700
- required: ["range", "values"]
1701
- },
1702
- async execute(_id, params) {
1703
- try {
1704
- const token = await tp.getAccessToken();
1705
- const base = itemPath(params);
1706
- const ws = params.worksheet || "Sheet1";
1707
- await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/range(address='${params.range}')`, {
1708
- method: "PATCH",
1709
- body: { values: params.values }
1710
- });
1711
- return jsonResult({ written: true, range: params.range, worksheet: ws });
1712
- } catch (e) {
1713
- return errorResult(e.message);
1714
- }
1715
- }
1716
- },
1717
- {
1718
- name: "excel_add_row",
1719
- description: "Add a row to an Excel table (structured table, not just a range).",
1720
- category: "utility",
1721
- parameters: {
1722
- type: "object",
1723
- properties: {
1724
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
1725
- path: { type: "string", description: "File path" },
1726
- driveId: { type: "string", description: "Drive ID" },
1727
- worksheet: { type: "string", description: "Worksheet name" },
1728
- tableName: { type: "string", description: "Table name (default: first table found)" },
1729
- values: { type: "array", description: 'Row values as array (e.g., ["Alice", 30, "alice@example.com"])' }
1730
- },
1731
- required: ["values"]
1732
- },
1733
- async execute(_id, params) {
1734
- try {
1735
- const token = await tp.getAccessToken();
1736
- const base = itemPath(params);
1737
- let tablePath;
1738
- if (params.tableName) {
1739
- tablePath = params.worksheet ? `${base}/workbook/worksheets/${encodeURIComponent(params.worksheet)}/tables/${encodeURIComponent(params.tableName)}` : `${base}/workbook/tables/${encodeURIComponent(params.tableName)}`;
1740
- } else {
1741
- const ws = params.worksheet || "Sheet1";
1742
- const tables = await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/tables`);
1743
- if (!tables.value?.length) throw new Error("No tables found in worksheet. Create a table first or use excel_write_range.");
1744
- tablePath = `${base}/workbook/tables/${tables.value[0].id}`;
1745
- }
1746
- const row = await graph(token, `${tablePath}/rows/add`, {
1747
- method: "POST",
1748
- body: { values: [params.values] }
1749
- });
1750
- return jsonResult({ added: true, index: row.index });
1751
- } catch (e) {
1752
- return errorResult(e.message);
1753
- }
1754
- }
1755
- },
1756
- {
1757
- name: "excel_list_tables",
1758
- description: "List all tables in an Excel workbook or specific worksheet.",
1759
- category: "utility",
1760
- parameters: {
1761
- type: "object",
1762
- properties: {
1763
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
1764
- path: { type: "string", description: "File path" },
1765
- driveId: { type: "string", description: "Drive ID" },
1766
- worksheet: { type: "string", description: "Worksheet name (omit for all tables in workbook)" }
1767
- },
1768
- required: []
1769
- },
1770
- async execute(_id, params) {
1771
- try {
1772
- const token = await tp.getAccessToken();
1773
- const base = itemPath(params);
1774
- const tablesPath = params.worksheet ? `${base}/workbook/worksheets/${encodeURIComponent(params.worksheet)}/tables` : `${base}/workbook/tables`;
1775
- const data = await graph(token, tablesPath);
1776
- const tables = (data.value || []).map((t) => ({
1777
- id: t.id,
1778
- name: t.name,
1779
- rows: t.rowCount,
1780
- columns: t.columns?.length,
1781
- showHeaders: t.showHeaders,
1782
- style: t.style
1783
- }));
1784
- return jsonResult({ tables, count: tables.length });
1785
- } catch (e) {
1786
- return errorResult(e.message);
1787
- }
1788
- }
1789
- },
1790
- {
1791
- name: "excel_read_table",
1792
- description: "Read all data from an Excel table including headers.",
1793
- category: "utility",
1794
- parameters: {
1795
- type: "object",
1796
- properties: {
1797
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
1798
- path: { type: "string", description: "File path" },
1799
- driveId: { type: "string", description: "Drive ID" },
1800
- tableName: { type: "string", description: "Table name or ID" }
1801
- },
1802
- required: ["tableName"]
1803
- },
1804
- async execute(_id, params) {
1805
- try {
1806
- const token = await tp.getAccessToken();
1807
- const base = itemPath(params);
1808
- const [headerData, bodyData] = await Promise.all([
1809
- graph(token, `${base}/workbook/tables/${encodeURIComponent(params.tableName)}/headerRowRange`),
1810
- graph(token, `${base}/workbook/tables/${encodeURIComponent(params.tableName)}/dataBodyRange`)
1811
- ]);
1812
- return jsonResult({
1813
- headers: headerData.values?.[0],
1814
- rows: bodyData.values,
1815
- rowCount: bodyData.rowCount,
1816
- columnCount: bodyData.columnCount
1817
- });
1818
- } catch (e) {
1819
- return errorResult(e.message);
1820
- }
1821
- }
1822
- },
1823
- {
1824
- name: "excel_create_worksheet",
1825
- description: "Add a new worksheet to an Excel workbook.",
1826
- category: "utility",
1827
- parameters: {
1828
- type: "object",
1829
- properties: {
1830
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
1831
- path: { type: "string", description: "File path" },
1832
- driveId: { type: "string", description: "Drive ID" },
1833
- name: { type: "string", description: "Worksheet name" }
1834
- },
1835
- required: ["name"]
1836
- },
1837
- async execute(_id, params) {
1838
- try {
1839
- const token = await tp.getAccessToken();
1840
- const base = itemPath(params);
1841
- const ws = await graph(token, `${base}/workbook/worksheets/add`, {
1842
- method: "POST",
1843
- body: { name: params.name }
1844
- });
1845
- return jsonResult({ id: ws.id, name: ws.name, position: ws.position });
1846
- } catch (e) {
1847
- return errorResult(e.message);
1848
- }
1849
- }
1850
- }
1851
- ];
1852
- }
1853
-
1854
- // src/agent-tools/tools/microsoft/excel-vba.ts
1855
- function itemPath2(p) {
1856
- if (p.driveId && p.itemId) return `/drives/${p.driveId}/items/${p.itemId}`;
1857
- if (p.itemId) return `/me/drive/items/${p.itemId}`;
1858
- if (p.path) return `/me/drive/root:${p.path}:`;
1859
- throw new Error("Provide itemId or path");
1860
- }
1861
- function createExcelAdvancedTools(config, _options) {
1862
- const tp = config.tokenProvider;
1863
- return [
1864
- {
1865
- name: "excel_create_session",
1866
- description: "Create a workbook session for batch operations. Returns a session ID to use in subsequent calls for atomic transactions.",
1867
- category: "utility",
1868
- parameters: {
1869
- type: "object",
1870
- properties: {
1871
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
1872
- path: { type: "string", description: "File path" },
1873
- driveId: { type: "string", description: "Drive ID" },
1874
- persistChanges: { type: "boolean", description: "Persist changes after session closes (default: true)" }
1875
- },
1876
- required: []
1877
- },
1878
- async execute(_id, params) {
1879
- try {
1880
- const token = await tp.getAccessToken();
1881
- const base = itemPath2(params);
1882
- const session = await graph(token, `${base}/workbook/createSession`, {
1883
- method: "POST",
1884
- body: { persistChanges: params.persistChanges !== false }
1885
- });
1886
- return jsonResult({ sessionId: session.id, persistChanges: session.persistChanges });
1887
- } catch (e) {
1888
- return errorResult(e.message);
1889
- }
1890
- }
1891
- },
1892
- {
1893
- name: "excel_close_session",
1894
- description: "Close a workbook session. Commits or discards changes based on session config.",
1895
- category: "utility",
1896
- parameters: {
1897
- type: "object",
1898
- properties: {
1899
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
1900
- path: { type: "string", description: "File path" },
1901
- driveId: { type: "string", description: "Drive ID" },
1902
- sessionId: { type: "string", description: "Session ID to close" }
1903
- },
1904
- required: ["sessionId"]
1905
- },
1906
- async execute(_id, params) {
1907
- try {
1908
- const token = await tp.getAccessToken();
1909
- const base = itemPath2(params);
1910
- await graph(token, `${base}/workbook/closeSession`, {
1911
- method: "POST",
1912
- headers: { "workbook-session-id": params.sessionId }
1913
- });
1914
- return jsonResult({ closed: true, sessionId: params.sessionId });
1915
- } catch (e) {
1916
- return errorResult(e.message);
1917
- }
1918
- }
1919
- },
1920
- {
1921
- name: "excel_evaluate_formula",
1922
- description: "Evaluate an Excel formula without writing it to a cell. Supports any Excel function (SUM, VLOOKUP, IF, etc.).",
1923
- category: "utility",
1924
- parameters: {
1925
- type: "object",
1926
- properties: {
1927
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
1928
- path: { type: "string", description: "File path" },
1929
- driveId: { type: "string", description: "Drive ID" },
1930
- worksheet: { type: "string", description: "Worksheet name (default: Sheet1)" },
1931
- formula: { type: "string", description: 'Excel formula (e.g., "=SUM(A1:A10)", "=VLOOKUP("Alice",A:C,3,FALSE)")' },
1932
- sessionId: { type: "string", description: "Optional session ID for batch operations" }
1933
- },
1934
- required: ["formula"]
1935
- },
1936
- async execute(_id, params) {
1937
- try {
1938
- const token = await tp.getAccessToken();
1939
- const base = itemPath2(params);
1940
- const ws = params.worksheet || "Sheet1";
1941
- const headers = {};
1942
- if (params.sessionId) headers["workbook-session-id"] = params.sessionId;
1943
- const tempCell = "ZZ9999";
1944
- await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/range(address='${tempCell}')`, {
1945
- method: "PATCH",
1946
- body: { formulas: [[params.formula]] },
1947
- headers
1948
- });
1949
- const result = await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/range(address='${tempCell}')`, {
1950
- query: { "$select": "values,text,formulas" },
1951
- headers
1952
- });
1953
- await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/range(address='${tempCell}')/clear`, {
1954
- method: "POST",
1955
- body: { applyTo: "All" },
1956
- headers
1957
- });
1958
- return jsonResult({
1959
- formula: params.formula,
1960
- result: result.values?.[0]?.[0],
1961
- text: result.text?.[0]?.[0]
1962
- });
1963
- } catch (e) {
1964
- return errorResult(e.message);
1965
- }
1966
- }
1967
- },
1968
- {
1969
- name: "excel_named_ranges",
1970
- description: "List all named ranges in a workbook.",
1971
- category: "utility",
1972
- parameters: {
1973
- type: "object",
1974
- properties: {
1975
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
1976
- path: { type: "string", description: "File path" },
1977
- driveId: { type: "string", description: "Drive ID" }
1978
- },
1979
- required: []
1980
- },
1981
- async execute(_id, params) {
1982
- try {
1983
- const token = await tp.getAccessToken();
1984
- const base = itemPath2(params);
1985
- const data = await graph(token, `${base}/workbook/names`);
1986
- const names = (data.value || []).map((n) => ({
1987
- name: n.name,
1988
- value: n.value,
1989
- type: n.type,
1990
- visible: n.visible,
1991
- comment: n.comment
1992
- }));
1993
- return jsonResult({ namedRanges: names, count: names.length });
1994
- } catch (e) {
1995
- return errorResult(e.message);
1996
- }
1997
- }
1998
- },
1999
- {
2000
- name: "excel_read_named_range",
2001
- description: "Read values from a named range.",
2002
- category: "utility",
2003
- parameters: {
2004
- type: "object",
2005
- properties: {
2006
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
2007
- path: { type: "string", description: "File path" },
2008
- driveId: { type: "string", description: "Drive ID" },
2009
- name: { type: "string", description: "Named range name" }
2010
- },
2011
- required: ["name"]
2012
- },
2013
- async execute(_id, params) {
2014
- try {
2015
- const token = await tp.getAccessToken();
2016
- const base = itemPath2(params);
2017
- const range = await graph(token, `${base}/workbook/names/${encodeURIComponent(params.name)}/range`, {
2018
- query: { "$select": "address,values,text,formulas,rowCount,columnCount" }
2019
- });
2020
- return jsonResult({
2021
- name: params.name,
2022
- address: range.address,
2023
- values: range.values,
2024
- text: range.text,
2025
- rows: range.rowCount,
2026
- columns: range.columnCount
2027
- });
2028
- } catch (e) {
2029
- return errorResult(e.message);
2030
- }
2031
- }
2032
- },
2033
- {
2034
- name: "excel_list_charts",
2035
- description: "List all charts in an Excel worksheet.",
2036
- category: "utility",
2037
- parameters: {
2038
- type: "object",
2039
- properties: {
2040
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
2041
- path: { type: "string", description: "File path" },
2042
- driveId: { type: "string", description: "Drive ID" },
2043
- worksheet: { type: "string", description: "Worksheet name (default: Sheet1)" }
2044
- },
2045
- required: []
2046
- },
2047
- async execute(_id, params) {
2048
- try {
2049
- const token = await tp.getAccessToken();
2050
- const base = itemPath2(params);
2051
- const ws = params.worksheet || "Sheet1";
2052
- const data = await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/charts`);
2053
- const charts = (data.value || []).map((c) => ({
2054
- id: c.id,
2055
- name: c.name,
2056
- height: c.height,
2057
- width: c.width,
2058
- top: c.top,
2059
- left: c.left
2060
- }));
2061
- return jsonResult({ charts, count: charts.length });
2062
- } catch (e) {
2063
- return errorResult(e.message);
2064
- }
2065
- }
2066
- },
2067
- {
2068
- name: "excel_chart_image",
2069
- description: "Get a chart as a base64 PNG image.",
2070
- category: "utility",
2071
- parameters: {
2072
- type: "object",
2073
- properties: {
2074
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
2075
- path: { type: "string", description: "File path" },
2076
- driveId: { type: "string", description: "Drive ID" },
2077
- worksheet: { type: "string", description: "Worksheet name" },
2078
- chartName: { type: "string", description: "Chart name or ID" }
2079
- },
2080
- required: ["chartName"]
2081
- },
2082
- async execute(_id, params) {
2083
- try {
2084
- const token = await tp.getAccessToken();
2085
- const base = itemPath2(params);
2086
- const ws = params.worksheet || "Sheet1";
2087
- const img = await graph(token, `${base}/workbook/worksheets/${encodeURIComponent(ws)}/charts/${encodeURIComponent(params.chartName)}/image`);
2088
- return jsonResult({ chartName: params.chartName, base64Image: img.value, format: "png" });
2089
- } catch (e) {
2090
- return errorResult(e.message);
2091
- }
2092
- }
2093
- },
2094
- {
2095
- name: "excel_pivot_refresh",
2096
- description: "Refresh all pivot tables in a workbook by recalculating the workbook.",
2097
- category: "utility",
2098
- parameters: {
2099
- type: "object",
2100
- properties: {
2101
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
2102
- path: { type: "string", description: "File path" },
2103
- driveId: { type: "string", description: "Drive ID" },
2104
- sessionId: { type: "string", description: "Session ID (recommended for consistency)" }
2105
- },
2106
- required: []
2107
- },
2108
- async execute(_id, params) {
2109
- try {
2110
- const token = await tp.getAccessToken();
2111
- const base = itemPath2(params);
2112
- const headers = {};
2113
- if (params.sessionId) headers["workbook-session-id"] = params.sessionId;
2114
- await graph(token, `${base}/workbook/application/calculate`, {
2115
- method: "POST",
2116
- body: { calculationType: "Full" },
2117
- headers
2118
- });
2119
- return jsonResult({ refreshed: true, calculationType: "Full" });
2120
- } catch (e) {
2121
- return errorResult(e.message);
2122
- }
2123
- }
2124
- },
2125
- {
2126
- name: "excel_set_cell_format",
2127
- description: "Set number format, font, fill, or borders on a cell range.",
2128
- category: "utility",
2129
- parameters: {
2130
- type: "object",
2131
- properties: {
2132
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
2133
- path: { type: "string", description: "File path" },
2134
- driveId: { type: "string", description: "Drive ID" },
2135
- worksheet: { type: "string", description: "Worksheet name" },
2136
- range: { type: "string", description: 'Cell range (e.g., "A1:D10")' },
2137
- numberFormat: { type: "string", description: 'Number format (e.g., "$#,##0.00", "0%", "mm/dd/yyyy")' },
2138
- bold: { type: "boolean", description: "Set font bold" },
2139
- italic: { type: "boolean", description: "Set font italic" },
2140
- fontColor: { type: "string", description: 'Font color (e.g., "#FF0000")' },
2141
- fillColor: { type: "string", description: 'Cell fill color (e.g., "#FFFF00")' },
2142
- horizontalAlignment: { type: "string", description: "Left, Center, Right, Fill, Justify" }
2143
- },
2144
- required: ["range"]
2145
- },
2146
- async execute(_id, params) {
2147
- try {
2148
- const token = await tp.getAccessToken();
2149
- const base = itemPath2(params);
2150
- const ws = params.worksheet || "Sheet1";
2151
- const rangePath = `${base}/workbook/worksheets/${encodeURIComponent(ws)}/range(address='${params.range}')`;
2152
- const format = {};
2153
- if (params.numberFormat) {
2154
- await graph(token, `${rangePath}/format`, { method: "PATCH", body: { columnWidth: null } });
2155
- }
2156
- if (params.bold !== void 0 || params.italic !== void 0 || params.fontColor) {
2157
- const font = {};
2158
- if (params.bold !== void 0) font.bold = params.bold;
2159
- if (params.italic !== void 0) font.italic = params.italic;
2160
- if (params.fontColor) font.color = params.fontColor;
2161
- await graph(token, `${rangePath}/format/font`, { method: "PATCH", body: font });
2162
- }
2163
- if (params.fillColor) {
2164
- await graph(token, `${rangePath}/format/fill`, { method: "PATCH", body: { color: params.fillColor } });
2165
- }
2166
- if (params.horizontalAlignment) {
2167
- await graph(token, `${rangePath}/format`, { method: "PATCH", body: { horizontalAlignment: params.horizontalAlignment } });
2168
- }
2169
- if (params.numberFormat) {
2170
- const rangeInfo = await graph(token, rangePath, { query: { "$select": "rowCount,columnCount" } });
2171
- const fmt = Array(rangeInfo.rowCount).fill(null).map(() => Array(rangeInfo.columnCount).fill(params.numberFormat));
2172
- await graph(token, rangePath, { method: "PATCH", body: { numberFormat: fmt } });
2173
- }
2174
- return jsonResult({ formatted: true, range: params.range });
2175
- } catch (e) {
2176
- return errorResult(e.message);
2177
- }
2178
- }
2179
- }
2180
- ];
2181
- }
2182
-
2183
- // src/agent-tools/tools/microsoft/sharepoint.ts
2184
- function createSharePointTools(config, _options) {
2185
- const tp = config.tokenProvider;
2186
- return [
2187
- {
2188
- name: "sharepoint_list_sites",
2189
- description: "Search or list SharePoint sites the agent has access to.",
2190
- category: "utility",
2191
- parameters: {
2192
- type: "object",
2193
- properties: {
2194
- search: { type: "string", description: "Search query for site name/description" },
2195
- maxResults: { type: "number", description: "Max results (default: 20)" }
2196
- },
2197
- required: []
2198
- },
2199
- async execute(_id, params) {
2200
- try {
2201
- const token = await tp.getAccessToken();
2202
- let path = "/sites";
2203
- const query = { "$top": String(params.maxResults || 20) };
2204
- if (params.search) {
2205
- query["$search"] = `"${params.search}"`;
2206
- }
2207
- const data = await graph(token, path, { query });
2208
- const sites = (data.value || []).map((s) => ({
2209
- id: s.id,
2210
- name: s.displayName,
2211
- description: s.description,
2212
- webUrl: s.webUrl,
2213
- created: s.createdDateTime
2214
- }));
2215
- return jsonResult({ sites, count: sites.length });
2216
- } catch (e) {
2217
- return errorResult(e.message);
2218
- }
2219
- }
2220
- },
2221
- {
2222
- name: "sharepoint_get_site",
2223
- description: "Get details about a SharePoint site by hostname and path, or by site ID.",
2224
- category: "utility",
2225
- parameters: {
2226
- type: "object",
2227
- properties: {
2228
- siteId: { type: "string", description: "Site ID" },
2229
- hostname: { type: "string", description: 'Site hostname (e.g., "contoso.sharepoint.com")' },
2230
- path: { type: "string", description: 'Site path (e.g., "/sites/engineering")' }
2231
- },
2232
- required: []
2233
- },
2234
- async execute(_id, params) {
2235
- try {
2236
- const token = await tp.getAccessToken();
2237
- let sitePath;
2238
- if (params.siteId) {
2239
- sitePath = `/sites/${params.siteId}`;
2240
- } else if (params.hostname) {
2241
- sitePath = `/sites/${params.hostname}:${params.path || "/"}`;
2242
- } else {
2243
- throw new Error("Provide siteId or hostname");
2244
- }
2245
- const site = await graph(token, sitePath);
2246
- return jsonResult({
2247
- id: site.id,
2248
- name: site.displayName,
2249
- description: site.description,
2250
- webUrl: site.webUrl,
2251
- created: site.createdDateTime
2252
- });
2253
- } catch (e) {
2254
- return errorResult(e.message);
2255
- }
2256
- }
2257
- },
2258
- {
2259
- name: "sharepoint_list_drives",
2260
- description: "List document libraries (drives) on a SharePoint site.",
2261
- category: "utility",
2262
- parameters: {
2263
- type: "object",
2264
- properties: {
2265
- siteId: { type: "string", description: "SharePoint site ID" }
2266
- },
2267
- required: ["siteId"]
2268
- },
2269
- async execute(_id, params) {
2270
- try {
2271
- const token = await tp.getAccessToken();
2272
- const data = await graph(token, `/sites/${params.siteId}/drives`);
2273
- const drives = (data.value || []).map((d) => ({
2274
- id: d.id,
2275
- name: d.name,
2276
- description: d.description,
2277
- driveType: d.driveType,
2278
- webUrl: d.webUrl,
2279
- totalSize: d.quota?.total,
2280
- usedSize: d.quota?.used
2281
- }));
2282
- return jsonResult({ drives, count: drives.length });
2283
- } catch (e) {
2284
- return errorResult(e.message);
2285
- }
2286
- }
2287
- },
2288
- {
2289
- name: "sharepoint_list_files",
2290
- description: "List files and folders in a SharePoint document library.",
2291
- category: "utility",
2292
- parameters: {
2293
- type: "object",
2294
- properties: {
2295
- siteId: { type: "string", description: "SharePoint site ID" },
2296
- driveId: { type: "string", description: "Drive (document library) ID" },
2297
- path: { type: "string", description: "Folder path within the drive (default: root)" },
2298
- maxResults: { type: "number", description: "Max items (default: 50)" }
2299
- },
2300
- required: ["siteId", "driveId"]
2301
- },
2302
- async execute(_id, params) {
2303
- try {
2304
- const token = await tp.getAccessToken();
2305
- const basePath = params.path ? `/drives/${params.driveId}/root:${params.path}:/children` : `/drives/${params.driveId}/root/children`;
2306
- const data = await graph(token, basePath, {
2307
- query: {
2308
- "$top": String(params.maxResults || 50),
2309
- "$select": "id,name,size,createdDateTime,lastModifiedDateTime,webUrl,folder,file"
2310
- }
2311
- });
2312
- const items = (data.value || []).map((i) => ({
2313
- id: i.id,
2314
- name: i.name,
2315
- size: i.size,
2316
- type: i.folder ? "folder" : "file",
2317
- mimeType: i.file?.mimeType,
2318
- childCount: i.folder?.childCount,
2319
- created: i.createdDateTime,
2320
- modified: i.lastModifiedDateTime,
2321
- webUrl: i.webUrl
2322
- }));
2323
- return jsonResult({ items, count: items.length });
2324
- } catch (e) {
2325
- return errorResult(e.message);
2326
- }
2327
- }
2328
- },
2329
- {
2330
- name: "sharepoint_upload_file",
2331
- description: "Upload a text file to a SharePoint document library.",
2332
- category: "utility",
2333
- parameters: {
2334
- type: "object",
2335
- properties: {
2336
- driveId: { type: "string", description: "Drive (document library) ID" },
2337
- path: { type: "string", description: 'Destination path (e.g., "/General/report.md")' },
2338
- content: { type: "string", description: "File content (text)" }
2339
- },
2340
- required: ["driveId", "path", "content"]
2341
- },
2342
- async execute(_id, params) {
2343
- try {
2344
- const token = await tp.getAccessToken();
2345
- const res = await fetch(`https://graph.microsoft.com/v1.0/drives/${params.driveId}/root:${params.path}:/content`, {
2346
- method: "PUT",
2347
- headers: { Authorization: `Bearer ${token}`, "Content-Type": "text/plain" },
2348
- body: params.content
2349
- });
2350
- if (!res.ok) throw new Error(`Upload failed: ${res.status} ${await res.text()}`);
2351
- const data = await res.json();
2352
- return jsonResult({ id: data.id, name: data.name, size: data.size, webUrl: data.webUrl });
2353
- } catch (e) {
2354
- return errorResult(e.message);
2355
- }
2356
- }
2357
- },
2358
- {
2359
- name: "sharepoint_list_lists",
2360
- description: "List SharePoint lists on a site.",
2361
- category: "utility",
2362
- parameters: {
2363
- type: "object",
2364
- properties: {
2365
- siteId: { type: "string", description: "SharePoint site ID" }
2366
- },
2367
- required: ["siteId"]
2368
- },
2369
- async execute(_id, params) {
2370
- try {
2371
- const token = await tp.getAccessToken();
2372
- const data = await graph(token, `/sites/${params.siteId}/lists`, {
2373
- query: { "$select": "id,displayName,description,webUrl,list", "$top": "50" }
2374
- });
2375
- const lists = (data.value || []).map((l) => ({
2376
- id: l.id,
2377
- name: l.displayName,
2378
- description: l.description,
2379
- webUrl: l.webUrl,
2380
- template: l.list?.template,
2381
- hidden: l.list?.hidden
2382
- }));
2383
- return jsonResult({ lists: lists.filter((l) => !l.hidden), count: lists.length });
2384
- } catch (e) {
2385
- return errorResult(e.message);
2386
- }
2387
- }
2388
- },
2389
- {
2390
- name: "sharepoint_list_items",
2391
- description: "Read items from a SharePoint list.",
2392
- category: "utility",
2393
- parameters: {
2394
- type: "object",
2395
- properties: {
2396
- siteId: { type: "string", description: "SharePoint site ID" },
2397
- listId: { type: "string", description: "List ID or name" },
2398
- maxResults: { type: "number", description: "Max items (default: 50)" },
2399
- filter: { type: "string", description: "OData $filter expression" },
2400
- expand: { type: "boolean", description: "Expand field values (default: true)" }
2401
- },
2402
- required: ["siteId", "listId"]
2403
- },
2404
- async execute(_id, params) {
2405
- try {
2406
- const token = await tp.getAccessToken();
2407
- const query = {
2408
- "$top": String(params.maxResults || 50)
2409
- };
2410
- if (params.expand !== false) query["$expand"] = "fields";
2411
- if (params.filter) query["$filter"] = params.filter;
2412
- const data = await graph(token, `/sites/${params.siteId}/lists/${params.listId}/items`, { query });
2413
- const items = (data.value || []).map((i) => ({
2414
- id: i.id,
2415
- created: i.createdDateTime,
2416
- modified: i.lastModifiedDateTime,
2417
- webUrl: i.webUrl,
2418
- fields: i.fields
2419
- }));
2420
- return jsonResult({ items, count: items.length });
2421
- } catch (e) {
2422
- return errorResult(e.message);
2423
- }
2424
- }
2425
- },
2426
- {
2427
- name: "sharepoint_create_list_item",
2428
- description: "Create a new item in a SharePoint list.",
2429
- category: "utility",
2430
- parameters: {
2431
- type: "object",
2432
- properties: {
2433
- siteId: { type: "string", description: "SharePoint site ID" },
2434
- listId: { type: "string", description: "List ID or name" },
2435
- fields: { type: "object", description: 'Field values as key-value pairs (e.g., {"Title": "My Item", "Status": "Active"})' }
2436
- },
2437
- required: ["siteId", "listId", "fields"]
2438
- },
2439
- async execute(_id, params) {
2440
- try {
2441
- const token = await tp.getAccessToken();
2442
- const item = await graph(token, `/sites/${params.siteId}/lists/${params.listId}/items`, {
2443
- method: "POST",
2444
- body: { fields: params.fields }
2445
- });
2446
- return jsonResult({ id: item.id, created: true, fields: item.fields });
2447
- } catch (e) {
2448
- return errorResult(e.message);
2449
- }
2450
- }
2451
- },
2452
- {
2453
- name: "sharepoint_update_list_item",
2454
- description: "Update an existing item in a SharePoint list.",
2455
- category: "utility",
2456
- parameters: {
2457
- type: "object",
2458
- properties: {
2459
- siteId: { type: "string", description: "SharePoint site ID" },
2460
- listId: { type: "string", description: "List ID or name" },
2461
- itemId: { type: "string", description: "Item ID to update" },
2462
- fields: { type: "object", description: "Updated field values" }
2463
- },
2464
- required: ["siteId", "listId", "itemId", "fields"]
2465
- },
2466
- async execute(_id, params) {
2467
- try {
2468
- const token = await tp.getAccessToken();
2469
- await graph(token, `/sites/${params.siteId}/lists/${params.listId}/items/${params.itemId}/fields`, {
2470
- method: "PATCH",
2471
- body: params.fields
2472
- });
2473
- return jsonResult({ updated: true, itemId: params.itemId });
2474
- } catch (e) {
2475
- return errorResult(e.message);
2476
- }
2477
- }
2478
- },
2479
- {
2480
- name: "sharepoint_search",
2481
- description: "Search across SharePoint for sites, files, list items, and pages.",
2482
- category: "utility",
2483
- parameters: {
2484
- type: "object",
2485
- properties: {
2486
- query: { type: "string", description: "Search query" },
2487
- entityTypes: { type: "string", description: "Comma-separated: site, drive, driveItem, list, listItem, message (default: driveItem)" },
2488
- maxResults: { type: "number", description: "Max results (default: 10)" }
2489
- },
2490
- required: ["query"]
2491
- },
2492
- async execute(_id, params) {
2493
- try {
2494
- const token = await tp.getAccessToken();
2495
- const types = (params.entityTypes || "driveItem").split(",").map((t) => t.trim());
2496
- const data = await graph(token, "/search/query", {
2497
- method: "POST",
2498
- body: {
2499
- requests: [{
2500
- entityTypes: types,
2501
- query: { queryString: params.query },
2502
- from: 0,
2503
- size: params.maxResults || 10
2504
- }]
2505
- }
2506
- });
2507
- const hits = data.value?.[0]?.hitsContainers?.[0]?.hits || [];
2508
- const results = hits.map((h) => ({
2509
- id: h.resource?.id,
2510
- name: h.resource?.name || h.resource?.displayName,
2511
- summary: h.summary,
2512
- webUrl: h.resource?.webUrl,
2513
- type: h.resource?.["@odata.type"],
2514
- lastModified: h.resource?.lastModifiedDateTime
2515
- }));
2516
- return jsonResult({ results, count: results.length, query: params.query });
2517
- } catch (e) {
2518
- return errorResult(e.message);
2519
- }
2520
- }
2521
- }
2522
- ];
2523
- }
2524
-
2525
- // src/agent-tools/tools/microsoft/onenote.ts
2526
- function createOneNoteTools(config, _options) {
2527
- const tp = config.tokenProvider;
2528
- return [
2529
- {
2530
- name: "onenote_list_notebooks",
2531
- description: "List all OneNote notebooks.",
2532
- category: "utility",
2533
- parameters: { type: "object", properties: {}, required: [] },
2534
- async execute(_id) {
2535
- try {
2536
- const token = await tp.getAccessToken();
2537
- const data = await graph(token, "/me/onenote/notebooks", {
2538
- query: { "$select": "id,displayName,createdDateTime,lastModifiedDateTime,isShared,links", "$orderby": "lastModifiedDateTime desc" }
2539
- });
2540
- const notebooks = (data.value || []).map((n) => ({
2541
- id: n.id,
2542
- name: n.displayName,
2543
- created: n.createdDateTime,
2544
- modified: n.lastModifiedDateTime,
2545
- isShared: n.isShared,
2546
- webUrl: n.links?.oneNoteWebUrl?.href
2547
- }));
2548
- return jsonResult({ notebooks, count: notebooks.length });
2549
- } catch (e) {
2550
- return errorResult(e.message);
2551
- }
2552
- }
2553
- },
2554
- {
2555
- name: "onenote_list_sections",
2556
- description: "List sections in a OneNote notebook.",
2557
- category: "utility",
2558
- parameters: {
2559
- type: "object",
2560
- properties: {
2561
- notebookId: { type: "string", description: "Notebook ID" }
2562
- },
2563
- required: ["notebookId"]
2564
- },
2565
- async execute(_id, params) {
2566
- try {
2567
- const token = await tp.getAccessToken();
2568
- const data = await graph(token, `/me/onenote/notebooks/${params.notebookId}/sections`, {
2569
- query: { "$select": "id,displayName,createdDateTime,lastModifiedDateTime" }
2570
- });
2571
- const sections = (data.value || []).map((s) => ({
2572
- id: s.id,
2573
- name: s.displayName,
2574
- created: s.createdDateTime,
2575
- modified: s.lastModifiedDateTime
2576
- }));
2577
- return jsonResult({ sections, count: sections.length });
2578
- } catch (e) {
2579
- return errorResult(e.message);
2580
- }
2581
- }
2582
- },
2583
- {
2584
- name: "onenote_list_pages",
2585
- description: "List pages in a OneNote section.",
2586
- category: "utility",
2587
- parameters: {
2588
- type: "object",
2589
- properties: {
2590
- sectionId: { type: "string", description: "Section ID" },
2591
- maxResults: { type: "number", description: "Max pages (default: 20)" }
2592
- },
2593
- required: ["sectionId"]
2594
- },
2595
- async execute(_id, params) {
2596
- try {
2597
- const token = await tp.getAccessToken();
2598
- const data = await graph(token, `/me/onenote/sections/${params.sectionId}/pages`, {
2599
- query: {
2600
- "$top": String(params.maxResults || 20),
2601
- "$select": "id,title,createdDateTime,lastModifiedDateTime,links,level,order",
2602
- "$orderby": "lastModifiedDateTime desc"
2603
- }
2604
- });
2605
- const pages = (data.value || []).map((p) => ({
2606
- id: p.id,
2607
- title: p.title,
2608
- created: p.createdDateTime,
2609
- modified: p.lastModifiedDateTime,
2610
- webUrl: p.links?.oneNoteWebUrl?.href
2611
- }));
2612
- return jsonResult({ pages, count: pages.length });
2613
- } catch (e) {
2614
- return errorResult(e.message);
2615
- }
2616
- }
2617
- },
2618
- {
2619
- name: "onenote_read_page",
2620
- description: "Read the HTML content of a OneNote page.",
2621
- category: "utility",
2622
- parameters: {
2623
- type: "object",
2624
- properties: {
2625
- pageId: { type: "string", description: "Page ID" }
2626
- },
2627
- required: ["pageId"]
2628
- },
2629
- async execute(_id, params) {
2630
- try {
2631
- const token = await tp.getAccessToken();
2632
- const res = await fetch(`https://graph.microsoft.com/v1.0/me/onenote/pages/${params.pageId}/content`, {
2633
- headers: { Authorization: `Bearer ${token}` }
2634
- });
2635
- if (!res.ok) throw new Error(`OneNote API ${res.status}: ${await res.text()}`);
2636
- const html = await res.text();
2637
- const text = html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
2638
- return jsonResult({ pageId: params.pageId, html, text: text.substring(0, 1e4) });
2639
- } catch (e) {
2640
- return errorResult(e.message);
2641
- }
2642
- }
2643
- },
2644
- {
2645
- name: "onenote_create_page",
2646
- description: "Create a new page in a OneNote section. Content is HTML.",
2647
- category: "utility",
2648
- parameters: {
2649
- type: "object",
2650
- properties: {
2651
- sectionId: { type: "string", description: "Section ID to create the page in" },
2652
- title: { type: "string", description: "Page title" },
2653
- content: { type: "string", description: "Page content (HTML or plain text)" }
2654
- },
2655
- required: ["sectionId", "title", "content"]
2656
- },
2657
- async execute(_id, params) {
2658
- try {
2659
- const token = await tp.getAccessToken();
2660
- const html = `<!DOCTYPE html><html><head><title>${params.title}</title></head><body>${params.content}</body></html>`;
2661
- const res = await fetch(`https://graph.microsoft.com/v1.0/me/onenote/sections/${params.sectionId}/pages`, {
2662
- method: "POST",
2663
- headers: {
2664
- Authorization: `Bearer ${token}`,
2665
- "Content-Type": "application/xhtml+xml"
2666
- },
2667
- body: html
2668
- });
2669
- if (!res.ok) throw new Error(`OneNote API ${res.status}: ${await res.text()}`);
2670
- const page = await res.json();
2671
- return jsonResult({
2672
- id: page.id,
2673
- title: page.title,
2674
- webUrl: page.links?.oneNoteWebUrl?.href,
2675
- created: true
2676
- });
2677
- } catch (e) {
2678
- return errorResult(e.message);
2679
- }
2680
- }
2681
- },
2682
- {
2683
- name: "onenote_update_page",
2684
- description: "Append content to an existing OneNote page.",
2685
- category: "utility",
2686
- parameters: {
2687
- type: "object",
2688
- properties: {
2689
- pageId: { type: "string", description: "Page ID" },
2690
- content: { type: "string", description: "HTML content to append" },
2691
- position: { type: "string", description: "Where to add: after (end of body) or before (start of body). Default: after" }
2692
- },
2693
- required: ["pageId", "content"]
2694
- },
2695
- async execute(_id, params) {
2696
- try {
2697
- const token = await tp.getAccessToken();
2698
- await graph(token, `/me/onenote/pages/${params.pageId}/content`, {
2699
- method: "PATCH",
2700
- body: [{
2701
- target: "body",
2702
- action: params.position === "before" ? "prepend" : "append",
2703
- content: params.content
2704
- }]
2705
- });
2706
- return jsonResult({ updated: true, pageId: params.pageId });
2707
- } catch (e) {
2708
- return errorResult(e.message);
2709
- }
2710
- }
2711
- }
2712
- ];
2713
- }
2714
-
2715
- // src/agent-tools/tools/microsoft/powerpoint.ts
2716
- function itemPath3(p) {
2717
- if (p.driveId && p.itemId) return `/drives/${p.driveId}/items/${p.itemId}`;
2718
- if (p.itemId) return `/me/drive/items/${p.itemId}`;
2719
- if (p.path) return `/me/drive/root:${p.path}:`;
2720
- throw new Error("Provide itemId or path to the PowerPoint file");
2721
- }
2722
- function createPowerPointTools(config, _options) {
2723
- const tp = config.tokenProvider;
2724
- return [
2725
- {
2726
- name: "powerpoint_get_info",
2727
- description: "Get metadata and slide count of a PowerPoint presentation.",
2728
- category: "utility",
2729
- parameters: {
2730
- type: "object",
2731
- properties: {
2732
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
2733
- path: { type: "string", description: 'File path (e.g., "/Documents/Deck.pptx")' },
2734
- driveId: { type: "string", description: "Drive ID (for SharePoint)" }
2735
- },
2736
- required: []
2737
- },
2738
- async execute(_id, params) {
2739
- try {
2740
- const token = await tp.getAccessToken();
2741
- const base = itemPath3(params);
2742
- const meta = await graph(token, base, {
2743
- query: { "$select": "id,name,size,webUrl,createdDateTime,lastModifiedDateTime,file" }
2744
- });
2745
- let slideCount = null;
2746
- try {
2747
- const preview = await graph(token, `${base}/preview`, { method: "POST", body: {} });
2748
- const thumbs = await graph(token, `${base}/thumbnails`);
2749
- if (thumbs.value?.[0]) slideCount = Object.keys(thumbs.value[0]).filter((k) => k !== "id").length;
2750
- } catch {
2751
- }
2752
- return jsonResult({
2753
- id: meta.id,
2754
- name: meta.name,
2755
- size: meta.size,
2756
- webUrl: meta.webUrl,
2757
- mimeType: meta.file?.mimeType,
2758
- created: meta.createdDateTime,
2759
- modified: meta.lastModifiedDateTime,
2760
- slideCount
2761
- });
2762
- } catch (e) {
2763
- return errorResult(e.message);
2764
- }
2765
- }
2766
- },
2767
- {
2768
- name: "powerpoint_export_pdf",
2769
- description: "Export/convert a PowerPoint presentation to PDF.",
2770
- category: "utility",
2771
- parameters: {
2772
- type: "object",
2773
- properties: {
2774
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
2775
- path: { type: "string", description: "File path" },
2776
- driveId: { type: "string", description: "Drive ID" }
2777
- },
2778
- required: []
2779
- },
2780
- async execute(_id, params) {
2781
- try {
2782
- const token = await tp.getAccessToken();
2783
- const base = itemPath3(params);
2784
- const res = await fetch(`https://graph.microsoft.com/v1.0${base}/content?format=pdf`, {
2785
- headers: { Authorization: `Bearer ${token}` },
2786
- redirect: "follow"
2787
- });
2788
- if (!res.ok) throw new Error(`Export failed: ${res.status}`);
2789
- const buf = Buffer.from(await res.arrayBuffer());
2790
- return jsonResult({
2791
- format: "pdf",
2792
- sizeBytes: buf.length,
2793
- base64: buf.toString("base64"),
2794
- note: "PDF content returned as base64. Save to file or send as attachment."
2795
- });
2796
- } catch (e) {
2797
- return errorResult(e.message);
2798
- }
2799
- }
2800
- },
2801
- {
2802
- name: "powerpoint_get_thumbnails",
2803
- description: "Get thumbnail images of slides in a presentation.",
2804
- category: "utility",
2805
- parameters: {
2806
- type: "object",
2807
- properties: {
2808
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
2809
- path: { type: "string", description: "File path" },
2810
- driveId: { type: "string", description: "Drive ID" },
2811
- size: { type: "string", description: "Thumbnail size: small, medium, large (default: medium)" }
2812
- },
2813
- required: []
2814
- },
2815
- async execute(_id, params) {
2816
- try {
2817
- const token = await tp.getAccessToken();
2818
- const base = itemPath3(params);
2819
- const data = await graph(token, `${base}/thumbnails`);
2820
- const size = params.size || "medium";
2821
- const thumbs = (data.value || []).map((set, i) => {
2822
- const t = set[size] || set.medium || set.large || set.small;
2823
- return { slide: i + 1, url: t?.url, width: t?.width, height: t?.height };
2824
- }).filter((t) => t.url);
2825
- return jsonResult({ thumbnails: thumbs, count: thumbs.length });
2826
- } catch (e) {
2827
- return errorResult(e.message);
2828
- }
2829
- }
2830
- },
2831
- {
2832
- name: "powerpoint_create_from_template",
2833
- description: "Create a new PowerPoint by copying a template file. Returns the new file for editing.",
2834
- category: "utility",
2835
- parameters: {
2836
- type: "object",
2837
- properties: {
2838
- templateItemId: { type: "string", description: "Item ID of the template .pptx" },
2839
- templatePath: { type: "string", description: "Path of the template (alternative to itemId)" },
2840
- newName: { type: "string", description: 'Name for the new file (e.g., "Q1 Report.pptx")' },
2841
- destFolder: { type: "string", description: "Destination folder path (default: same as template)" }
2842
- },
2843
- required: ["newName"]
2844
- },
2845
- async execute(_id, params) {
2846
- try {
2847
- const token = await tp.getAccessToken();
2848
- const base = params.templateItemId ? `/me/drive/items/${params.templateItemId}` : `/me/drive/root:${params.templatePath}:`;
2849
- const parentRef = {};
2850
- if (params.destFolder) parentRef.path = `/drive/root:${params.destFolder}`;
2851
- const copy = await graph(token, `${base}/copy`, {
2852
- method: "POST",
2853
- body: { name: params.newName, ...params.destFolder ? { parentReference: parentRef } : {} }
2854
- });
2855
- return jsonResult({
2856
- status: "copy_initiated",
2857
- monitorUrl: copy["@odata.context"] || null,
2858
- name: params.newName,
2859
- note: "Copy is async. File will appear in OneDrive shortly."
2860
- });
2861
- } catch (e) {
2862
- return errorResult(e.message);
2863
- }
2864
- }
2865
- },
2866
- {
2867
- name: "powerpoint_get_embed_url",
2868
- description: "Get an embeddable preview URL for a PowerPoint presentation.",
2869
- category: "utility",
2870
- parameters: {
2871
- type: "object",
2872
- properties: {
2873
- itemId: { type: "string", description: "OneDrive/SharePoint item ID" },
2874
- path: { type: "string", description: "File path" },
2875
- driveId: { type: "string", description: "Drive ID" }
2876
- },
2877
- required: []
2878
- },
2879
- async execute(_id, params) {
2880
- try {
2881
- const token = await tp.getAccessToken();
2882
- const base = itemPath3(params);
2883
- const preview = await graph(token, `${base}/preview`, { method: "POST", body: {} });
2884
- return jsonResult({
2885
- embedUrl: preview.getUrl,
2886
- editUrl: preview.postUrl
2887
- });
2888
- } catch (e) {
2889
- return errorResult(e.message);
2890
- }
2891
- }
2892
- }
2893
- ];
2894
- }
2895
-
2896
- // src/agent-tools/tools/microsoft/planner.ts
2897
- function createPlannerTools(config, _options) {
2898
- const tp = config.tokenProvider;
2899
- return [
2900
- {
2901
- name: "planner_list_plans",
2902
- description: "List all Planner plans the agent has access to (via group membership).",
2903
- category: "utility",
2904
- parameters: {
2905
- type: "object",
2906
- properties: {
2907
- groupId: { type: "string", description: "Microsoft 365 Group/Team ID to list plans for" }
2908
- },
2909
- required: ["groupId"]
2910
- },
2911
- async execute(_id, params) {
2912
- try {
2913
- const token = await tp.getAccessToken();
2914
- const data = await graph(token, `/groups/${params.groupId}/planner/plans`);
2915
- const plans = (data.value || []).map((p) => ({
2916
- id: p.id,
2917
- title: p.title,
2918
- created: p.createdDateTime,
2919
- owner: p.owner
2920
- }));
2921
- return jsonResult({ plans, count: plans.length });
2922
- } catch (e) {
2923
- return errorResult(e.message);
2924
- }
2925
- }
2926
- },
2927
- {
2928
- name: "planner_list_buckets",
2929
- description: "List buckets (columns) in a Planner plan.",
2930
- category: "utility",
2931
- parameters: {
2932
- type: "object",
2933
- properties: {
2934
- planId: { type: "string", description: "Plan ID" }
2935
- },
2936
- required: ["planId"]
2937
- },
2938
- async execute(_id, params) {
2939
- try {
2940
- const token = await tp.getAccessToken();
2941
- const data = await graph(token, `/planner/plans/${params.planId}/buckets`);
2942
- const buckets = (data.value || []).map((b) => ({
2943
- id: b.id,
2944
- name: b.name,
2945
- orderHint: b.orderHint,
2946
- planId: b.planId
2947
- }));
2948
- return jsonResult({ buckets, count: buckets.length });
2949
- } catch (e) {
2950
- return errorResult(e.message);
2951
- }
2952
- }
2953
- },
2954
- {
2955
- name: "planner_list_tasks",
2956
- description: "List tasks in a Planner plan or bucket.",
2957
- category: "utility",
2958
- parameters: {
2959
- type: "object",
2960
- properties: {
2961
- planId: { type: "string", description: "Plan ID (lists all tasks in plan)" },
2962
- bucketId: { type: "string", description: "Bucket ID (lists tasks in specific bucket)" }
2963
- },
2964
- required: []
2965
- },
2966
- async execute(_id, params) {
2967
- try {
2968
- const token = await tp.getAccessToken();
2969
- const path = params.bucketId ? `/planner/buckets/${params.bucketId}/tasks` : `/planner/plans/${params.planId}/tasks`;
2970
- if (!params.planId && !params.bucketId) throw new Error("Provide planId or bucketId");
2971
- const data = await graph(token, path);
2972
- const tasks = (data.value || []).map((t) => ({
2973
- id: t.id,
2974
- title: t.title,
2975
- bucketId: t.bucketId,
2976
- percentComplete: t.percentComplete,
2977
- priority: t.priority,
2978
- // 0-10, lower = higher
2979
- assignees: t.assignments ? Object.keys(t.assignments) : [],
2980
- dueDate: t.dueDateTime,
2981
- created: t.createdDateTime,
2982
- startDate: t.startDateTime,
2983
- hasDescription: t.hasDescription
2984
- }));
2985
- return jsonResult({ tasks, count: tasks.length });
2986
- } catch (e) {
2987
- return errorResult(e.message);
2988
- }
2989
- }
2990
- },
2991
- {
2992
- name: "planner_create_task",
2993
- description: "Create a new task in a Planner plan.",
2994
- category: "utility",
2995
- parameters: {
2996
- type: "object",
2997
- properties: {
2998
- planId: { type: "string", description: "Plan ID" },
2999
- title: { type: "string", description: "Task title" },
3000
- bucketId: { type: "string", description: "Bucket ID to place the task in" },
3001
- assignees: { type: "string", description: "Comma-separated user IDs to assign" },
3002
- dueDate: { type: "string", description: "Due date (ISO 8601)" },
3003
- startDate: { type: "string", description: "Start date (ISO 8601)" },
3004
- priority: { type: "number", description: "Priority: 1 (urgent), 3 (important), 5 (medium), 9 (low)" },
3005
- percentComplete: { type: "number", description: "0, 50, or 100" }
3006
- },
3007
- required: ["planId", "title"]
3008
- },
3009
- async execute(_id, params) {
3010
- try {
3011
- const token = await tp.getAccessToken();
3012
- const task = { planId: params.planId, title: params.title };
3013
- if (params.bucketId) task.bucketId = params.bucketId;
3014
- if (params.dueDate) task.dueDateTime = params.dueDate;
3015
- if (params.startDate) task.startDateTime = params.startDate;
3016
- if (params.priority !== void 0) task.priority = params.priority;
3017
- if (params.percentComplete !== void 0) task.percentComplete = params.percentComplete;
3018
- if (params.assignees) {
3019
- task.assignments = {};
3020
- params.assignees.split(",").forEach((id) => {
3021
- task.assignments[id.trim()] = { "@odata.type": "#microsoft.graph.plannerAssignment", orderHint: " !" };
3022
- });
3023
- }
3024
- const created = await graph(token, "/planner/tasks", { method: "POST", body: task });
3025
- return jsonResult({ id: created.id, title: created.title, created: true });
3026
- } catch (e) {
3027
- return errorResult(e.message);
3028
- }
3029
- }
3030
- },
3031
- {
3032
- name: "planner_update_task",
3033
- description: "Update a Planner task (title, progress, bucket, priority, assignments).",
3034
- category: "utility",
3035
- parameters: {
3036
- type: "object",
3037
- properties: {
3038
- taskId: { type: "string", description: "Task ID" },
3039
- title: { type: "string", description: "New title" },
3040
- percentComplete: { type: "number", description: "0 (not started), 50 (in progress), 100 (completed)" },
3041
- bucketId: { type: "string", description: "Move to different bucket" },
3042
- priority: { type: "number", description: "1 (urgent), 3 (important), 5 (medium), 9 (low)" },
3043
- dueDate: { type: "string", description: "Due date (ISO 8601)" }
3044
- },
3045
- required: ["taskId"]
3046
- },
3047
- async execute(_id, params) {
3048
- try {
3049
- const token = await tp.getAccessToken();
3050
- const existing = await graph(token, `/planner/tasks/${params.taskId}`, {
3051
- query: { "$select": "id" }
3052
- });
3053
- const etag = existing["@odata.etag"];
3054
- const update = {};
3055
- if (params.title) update.title = params.title;
3056
- if (params.percentComplete !== void 0) update.percentComplete = params.percentComplete;
3057
- if (params.bucketId) update.bucketId = params.bucketId;
3058
- if (params.priority !== void 0) update.priority = params.priority;
3059
- if (params.dueDate) update.dueDateTime = params.dueDate;
3060
- await graph(token, `/planner/tasks/${params.taskId}`, {
3061
- method: "PATCH",
3062
- body: update,
3063
- headers: { "If-Match": etag }
3064
- });
3065
- return jsonResult({ updated: true, taskId: params.taskId });
3066
- } catch (e) {
3067
- return errorResult(e.message);
3068
- }
3069
- }
3070
- },
3071
- {
3072
- name: "planner_delete_task",
3073
- description: "Delete a Planner task.",
3074
- category: "utility",
3075
- parameters: {
3076
- type: "object",
3077
- properties: {
3078
- taskId: { type: "string", description: "Task ID to delete" }
3079
- },
3080
- required: ["taskId"]
3081
- },
3082
- async execute(_id, params) {
3083
- try {
3084
- const token = await tp.getAccessToken();
3085
- const existing = await graph(token, `/planner/tasks/${params.taskId}`, { query: { "$select": "id" } });
3086
- await graph(token, `/planner/tasks/${params.taskId}`, {
3087
- method: "DELETE",
3088
- headers: { "If-Match": existing["@odata.etag"] }
3089
- });
3090
- return jsonResult({ deleted: true, taskId: params.taskId });
3091
- } catch (e) {
3092
- return errorResult(e.message);
3093
- }
3094
- }
3095
- }
3096
- ];
3097
- }
3098
-
3099
- // src/agent-tools/tools/microsoft/powerbi.ts
3100
- var PBI_BASE = "https://api.powerbi.com/v1.0/myorg";
3101
- async function pbi(token, path, opts) {
3102
- const method = opts?.method || "GET";
3103
- const url = new URL(PBI_BASE + path);
3104
- if (opts?.query) for (const [k, v] of Object.entries(opts.query)) {
3105
- if (v) url.searchParams.set(k, v);
3106
- }
3107
- const res = await fetch(url.toString(), {
3108
- method,
3109
- headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
3110
- body: opts?.body ? JSON.stringify(opts.body) : void 0
3111
- });
3112
- if (!res.ok) {
3113
- const err = await res.text();
3114
- throw new Error(`Power BI API ${res.status}: ${err}`);
3115
- }
3116
- if (res.status === 200 || res.status === 201) return res.json().catch(() => ({}));
3117
- return {};
3118
- }
3119
- function createPowerBITools(config, _options) {
3120
- const tp = config.tokenProvider;
3121
- return [
3122
- {
3123
- name: "powerbi_list_workspaces",
3124
- description: "List Power BI workspaces (groups) the agent has access to.",
3125
- category: "utility",
3126
- parameters: { type: "object", properties: {}, required: [] },
3127
- async execute(_id) {
3128
- try {
3129
- const token = await tp.getAccessToken();
3130
- const data = await pbi(token, "/groups");
3131
- const workspaces = (data.value || []).map((w) => ({
3132
- id: w.id,
3133
- name: w.name,
3134
- isOnDedicatedCapacity: w.isOnDedicatedCapacity,
3135
- type: w.type
3136
- }));
3137
- return jsonResult({ workspaces, count: workspaces.length });
3138
- } catch (e) {
3139
- return errorResult(e.message);
3140
- }
3141
- }
3142
- },
3143
- {
3144
- name: "powerbi_list_reports",
3145
- description: "List reports in a Power BI workspace.",
3146
- category: "utility",
3147
- parameters: {
3148
- type: "object",
3149
- properties: {
3150
- workspaceId: { type: "string", description: 'Workspace (group) ID. Omit for "My Workspace".' }
3151
- },
3152
- required: []
3153
- },
3154
- async execute(_id, params) {
3155
- try {
3156
- const token = await tp.getAccessToken();
3157
- const path = params.workspaceId ? `/groups/${params.workspaceId}/reports` : "/reports";
3158
- const data = await pbi(token, path);
3159
- const reports = (data.value || []).map((r) => ({
3160
- id: r.id,
3161
- name: r.name,
3162
- datasetId: r.datasetId,
3163
- webUrl: r.webUrl,
3164
- embedUrl: r.embedUrl,
3165
- reportType: r.reportType
3166
- }));
3167
- return jsonResult({ reports, count: reports.length });
3168
- } catch (e) {
3169
- return errorResult(e.message);
3170
- }
3171
- }
3172
- },
3173
- {
3174
- name: "powerbi_list_dashboards",
3175
- description: "List dashboards in a Power BI workspace.",
3176
- category: "utility",
3177
- parameters: {
3178
- type: "object",
3179
- properties: {
3180
- workspaceId: { type: "string", description: 'Workspace ID. Omit for "My Workspace".' }
3181
- },
3182
- required: []
3183
- },
3184
- async execute(_id, params) {
3185
- try {
3186
- const token = await tp.getAccessToken();
3187
- const path = params.workspaceId ? `/groups/${params.workspaceId}/dashboards` : "/dashboards";
3188
- const data = await pbi(token, path);
3189
- const dashboards = (data.value || []).map((d) => ({
3190
- id: d.id,
3191
- displayName: d.displayName,
3192
- webUrl: d.webUrl,
3193
- embedUrl: d.embedUrl,
3194
- isReadOnly: d.isReadOnly
3195
- }));
3196
- return jsonResult({ dashboards, count: dashboards.length });
3197
- } catch (e) {
3198
- return errorResult(e.message);
3199
- }
3200
- }
3201
- },
3202
- {
3203
- name: "powerbi_list_datasets",
3204
- description: "List datasets in a Power BI workspace.",
3205
- category: "utility",
3206
- parameters: {
3207
- type: "object",
3208
- properties: {
3209
- workspaceId: { type: "string", description: 'Workspace ID. Omit for "My Workspace".' }
3210
- },
3211
- required: []
3212
- },
3213
- async execute(_id, params) {
3214
- try {
3215
- const token = await tp.getAccessToken();
3216
- const path = params.workspaceId ? `/groups/${params.workspaceId}/datasets` : "/datasets";
3217
- const data = await pbi(token, path);
3218
- const datasets = (data.value || []).map((d) => ({
3219
- id: d.id,
3220
- name: d.name,
3221
- configuredBy: d.configuredBy,
3222
- isRefreshable: d.isRefreshable,
3223
- isOnPremGatewayRequired: d.isOnPremGatewayRequired,
3224
- webUrl: d.webUrl
3225
- }));
3226
- return jsonResult({ datasets, count: datasets.length });
3227
- } catch (e) {
3228
- return errorResult(e.message);
3229
- }
3230
- }
3231
- },
3232
- {
3233
- name: "powerbi_refresh_dataset",
3234
- description: "Trigger a data refresh on a Power BI dataset.",
3235
- category: "utility",
3236
- parameters: {
3237
- type: "object",
3238
- properties: {
3239
- datasetId: { type: "string", description: "Dataset ID to refresh" },
3240
- workspaceId: { type: "string", description: "Workspace ID (omit for My Workspace)" },
3241
- notifyOption: { type: "string", description: "NoNotification, MailOnFailure, or MailOnCompletion (default: NoNotification)" }
3242
- },
3243
- required: ["datasetId"]
3244
- },
3245
- async execute(_id, params) {
3246
- try {
3247
- const token = await tp.getAccessToken();
3248
- const path = params.workspaceId ? `/groups/${params.workspaceId}/datasets/${params.datasetId}/refreshes` : `/datasets/${params.datasetId}/refreshes`;
3249
- await pbi(token, path, {
3250
- method: "POST",
3251
- body: { notifyOption: params.notifyOption || "NoNotification" }
3252
- });
3253
- return jsonResult({ refreshTriggered: true, datasetId: params.datasetId });
3254
- } catch (e) {
3255
- return errorResult(e.message);
3256
- }
3257
- }
3258
- },
3259
- {
3260
- name: "powerbi_refresh_history",
3261
- description: "Get refresh history for a dataset.",
3262
- category: "utility",
3263
- parameters: {
3264
- type: "object",
3265
- properties: {
3266
- datasetId: { type: "string", description: "Dataset ID" },
3267
- workspaceId: { type: "string", description: "Workspace ID" },
3268
- maxResults: { type: "number", description: "Max results (default: 10)" }
3269
- },
3270
- required: ["datasetId"]
3271
- },
3272
- async execute(_id, params) {
3273
- try {
3274
- const token = await tp.getAccessToken();
3275
- const path = params.workspaceId ? `/groups/${params.workspaceId}/datasets/${params.datasetId}/refreshes` : `/datasets/${params.datasetId}/refreshes`;
3276
- const data = await pbi(token, path, {
3277
- query: { "$top": String(params.maxResults || 10) }
3278
- });
3279
- const history = (data.value || []).map((r) => ({
3280
- id: r.requestId,
3281
- refreshType: r.refreshType,
3282
- status: r.status,
3283
- startTime: r.startTime,
3284
- endTime: r.endTime,
3285
- serviceExceptionJson: r.serviceExceptionJson
3286
- }));
3287
- return jsonResult({ refreshHistory: history, count: history.length });
3288
- } catch (e) {
3289
- return errorResult(e.message);
3290
- }
3291
- }
3292
- },
3293
- {
3294
- name: "powerbi_execute_query",
3295
- description: "Execute a DAX query against a Power BI dataset. Returns tabular results.",
3296
- category: "utility",
3297
- parameters: {
3298
- type: "object",
3299
- properties: {
3300
- datasetId: { type: "string", description: "Dataset ID" },
3301
- workspaceId: { type: "string", description: "Workspace ID" },
3302
- query: { type: "string", description: `DAX query (e.g., "EVALUATE TOPN(10, 'Sales', 'Sales'[Amount], DESC)")` }
3303
- },
3304
- required: ["datasetId", "query"]
3305
- },
3306
- async execute(_id, params) {
3307
- try {
3308
- const token = await tp.getAccessToken();
3309
- const path = params.workspaceId ? `/groups/${params.workspaceId}/datasets/${params.datasetId}/executeQueries` : `/datasets/${params.datasetId}/executeQueries`;
3310
- const data = await pbi(token, path, {
3311
- method: "POST",
3312
- body: {
3313
- queries: [{ query: params.query }],
3314
- serializerSettings: { includeNulls: true }
3315
- }
3316
- });
3317
- const result = data.results?.[0];
3318
- const tables = result?.tables?.[0];
3319
- return jsonResult({
3320
- columns: tables?.columns?.map((c) => c.name),
3321
- rows: tables?.rows,
3322
- rowCount: tables?.rows?.length || 0
3323
- });
3324
- } catch (e) {
3325
- return errorResult(e.message);
3326
- }
3327
- }
3328
- },
3329
- {
3330
- name: "powerbi_dashboard_tiles",
3331
- description: "List tiles (widgets) on a Power BI dashboard.",
3332
- category: "utility",
3333
- parameters: {
3334
- type: "object",
3335
- properties: {
3336
- dashboardId: { type: "string", description: "Dashboard ID" },
3337
- workspaceId: { type: "string", description: "Workspace ID" }
3338
- },
3339
- required: ["dashboardId"]
3340
- },
3341
- async execute(_id, params) {
3342
- try {
3343
- const token = await tp.getAccessToken();
3344
- const path = params.workspaceId ? `/groups/${params.workspaceId}/dashboards/${params.dashboardId}/tiles` : `/dashboards/${params.dashboardId}/tiles`;
3345
- const data = await pbi(token, path);
3346
- const tiles = (data.value || []).map((t) => ({
3347
- id: t.id,
3348
- title: t.title,
3349
- reportId: t.reportId,
3350
- datasetId: t.datasetId,
3351
- embedUrl: t.embedUrl,
3352
- rowSpan: t.rowSpan,
3353
- colSpan: t.colSpan
3354
- }));
3355
- return jsonResult({ tiles, count: tiles.length });
3356
- } catch (e) {
3357
- return errorResult(e.message);
3358
- }
3359
- }
3360
- }
3361
- ];
3362
- }
3363
-
3364
- // src/agent-tools/tools/microsoft/index.ts
3365
- function createAllMicrosoftTools(config, options) {
3366
- const enabled = options?.enabledMicrosoftServices;
3367
- const has = (s) => enabled ? enabled.includes(s) : false;
3368
- const core = !enabled;
3369
- const tools = [];
3370
- if (core || has("mail")) tools.push(...createOutlookMailTools(config, options));
3371
- if (core || has("calendar")) tools.push(...createOutlookCalendarTools(config, options));
3372
- if (core || has("onedrive")) tools.push(...createOneDriveTools(config, options));
3373
- if (core || has("tasks")) tools.push(...createTodoTools(config, options));
3374
- if (has("teams")) tools.push(...createTeamsTools(config, options));
3375
- if (has("contacts")) tools.push(...createOutlookContactsTools(config, options));
3376
- if (has("excel")) tools.push(...createExcelTools(config, options));
3377
- if (has("excel-advanced")) tools.push(...createExcelAdvancedTools(config, options));
3378
- if (has("sharepoint")) tools.push(...createSharePointTools(config, options));
3379
- if (has("onenote")) tools.push(...createOneNoteTools(config, options));
3380
- if (has("powerpoint")) tools.push(...createPowerPointTools(config, options));
3381
- if (has("planner")) tools.push(...createPlannerTools(config, options));
3382
- if (has("powerbi")) tools.push(...createPowerBITools(config, options));
3383
- return tools;
3384
- }
3385
- export {
3386
- createAllMicrosoftTools,
3387
- createExcelAdvancedTools,
3388
- createExcelTools,
3389
- createOneDriveTools,
3390
- createOneNoteTools,
3391
- createOutlookCalendarTools,
3392
- createOutlookContactsTools,
3393
- createOutlookMailTools,
3394
- createPlannerTools,
3395
- createPowerBITools,
3396
- createPowerPointTools,
3397
- createSharePointTools,
3398
- createTeamsTools,
3399
- createTodoTools
3400
- };