veryfront 0.0.49 → 0.0.51

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 (493) hide show
  1. package/dist/ai/components.js +260 -56
  2. package/dist/ai/components.js.map +4 -4
  3. package/dist/ai/index.d.ts +1 -0
  4. package/dist/ai/index.js +12 -4
  5. package/dist/ai/index.js.map +2 -2
  6. package/dist/ai/primitives.js +55 -10
  7. package/dist/ai/primitives.js.map +3 -3
  8. package/dist/ai/react.js +140 -1
  9. package/dist/ai/react.js.map +3 -3
  10. package/dist/ai/workflow-react.js +458 -0
  11. package/dist/ai/workflow-react.js.map +7 -0
  12. package/dist/ai/workflow.js +5422 -0
  13. package/dist/ai/workflow.js.map +7 -0
  14. package/dist/cli.js +957 -215
  15. package/dist/components.js +12 -4
  16. package/dist/components.js.map +2 -2
  17. package/dist/config.js +12 -4
  18. package/dist/config.js.map +2 -2
  19. package/dist/data.js +12 -4
  20. package/dist/data.js.map +2 -2
  21. package/dist/index.js +12 -4
  22. package/dist/index.js.map +2 -2
  23. package/dist/integrations/_base/files/SETUP.md +667 -98
  24. package/dist/integrations/_base/files/app/api/integrations/status/route.ts +3 -3
  25. package/dist/integrations/_base/files/app/api/integrations/token-storage/route.ts +26 -0
  26. package/dist/integrations/_base/files/app/components/ServiceConnections.tsx +2 -1
  27. package/dist/integrations/_base/files/app/setup/page.tsx +869 -55
  28. package/dist/integrations/_base/files/lib/token-store-examples.ts +435 -0
  29. package/dist/integrations/_base/files/lib/token-store.ts +273 -23
  30. package/dist/integrations/airtable/connector.json +99 -0
  31. package/dist/integrations/airtable/files/ai/tools/create-record.ts +25 -0
  32. package/dist/integrations/airtable/files/ai/tools/get-base.ts +34 -0
  33. package/dist/integrations/airtable/files/ai/tools/get-record.ts +23 -0
  34. package/dist/integrations/airtable/files/ai/tools/list-bases.ts +19 -0
  35. package/dist/integrations/airtable/files/ai/tools/list-records.ts +47 -0
  36. package/dist/integrations/airtable/files/app/api/auth/airtable/callback/route.ts +11 -0
  37. package/dist/integrations/airtable/files/app/api/auth/airtable/route.ts +9 -0
  38. package/dist/integrations/airtable/files/lib/airtable-client.ts +244 -0
  39. package/dist/integrations/anthropic/README.md +181 -0
  40. package/dist/integrations/anthropic/connector.json +88 -0
  41. package/dist/integrations/anthropic/files/_env.example +4 -0
  42. package/dist/integrations/anthropic/files/ai/tools/get-organization.ts +36 -0
  43. package/dist/integrations/anthropic/files/ai/tools/get-usage.ts +100 -0
  44. package/dist/integrations/anthropic/files/ai/tools/list-api-keys.ts +64 -0
  45. package/dist/integrations/anthropic/files/ai/tools/list-members.ts +65 -0
  46. package/dist/integrations/anthropic/files/ai/tools/list-workspaces.ts +35 -0
  47. package/dist/integrations/anthropic/files/lib/anthropic-admin-client.ts +264 -0
  48. package/dist/integrations/asana/connector.json +85 -0
  49. package/dist/integrations/asana/files/_env.example +4 -0
  50. package/dist/integrations/asana/files/ai/tools/create-task.ts +34 -0
  51. package/dist/integrations/asana/files/ai/tools/get-task.ts +26 -0
  52. package/dist/integrations/asana/files/ai/tools/list-projects.ts +26 -0
  53. package/dist/integrations/asana/files/ai/tools/list-tasks.ts +50 -0
  54. package/dist/integrations/asana/files/ai/tools/update-task.ts +36 -0
  55. package/dist/integrations/asana/files/app/api/auth/asana/callback/route.ts +11 -0
  56. package/dist/integrations/asana/files/app/api/auth/asana/route.ts +7 -0
  57. package/dist/integrations/asana/files/lib/asana-client.ts +162 -0
  58. package/dist/integrations/aws/connector.json +72 -0
  59. package/dist/integrations/aws/files/_env.example +10 -0
  60. package/dist/integrations/aws/files/ai/tools/get-s3-object.ts +62 -0
  61. package/dist/integrations/aws/files/ai/tools/list-ec2-instances.ts +56 -0
  62. package/dist/integrations/aws/files/ai/tools/list-lambda-functions.ts +57 -0
  63. package/dist/integrations/aws/files/ai/tools/list-s3-buckets.ts +44 -0
  64. package/dist/integrations/aws/files/ai/tools/list-s3-objects.ts +58 -0
  65. package/dist/integrations/aws/files/lib/aws-client.ts +255 -0
  66. package/dist/integrations/bitbucket/connector.json +85 -0
  67. package/dist/integrations/bitbucket/files/_env.example +9 -0
  68. package/dist/integrations/bitbucket/files/ai/tools/create-pull-request.ts +83 -0
  69. package/dist/integrations/bitbucket/files/ai/tools/list-issues.ts +112 -0
  70. package/dist/integrations/bitbucket/files/ai/tools/list-pull-requests.ts +91 -0
  71. package/dist/integrations/bitbucket/files/ai/tools/list-repositories.ts +78 -0
  72. package/dist/integrations/bitbucket/files/app/api/auth/bitbucket/callback/route.ts +11 -0
  73. package/dist/integrations/bitbucket/files/app/api/auth/bitbucket/route.ts +9 -0
  74. package/dist/integrations/bitbucket/files/lib/bitbucket-client.ts +316 -0
  75. package/dist/integrations/box/connector.json +85 -0
  76. package/dist/integrations/box/files/_env.example +4 -0
  77. package/dist/integrations/box/files/ai/tools/create-folder.ts +28 -0
  78. package/dist/integrations/box/files/ai/tools/get-file.ts +29 -0
  79. package/dist/integrations/box/files/ai/tools/list-files.ts +33 -0
  80. package/dist/integrations/box/files/ai/tools/search-files.ts +35 -0
  81. package/dist/integrations/box/files/ai/tools/upload-file.ts +32 -0
  82. package/dist/integrations/box/files/app/api/auth/box/callback/route.ts +11 -0
  83. package/dist/integrations/box/files/app/api/auth/box/route.ts +7 -0
  84. package/dist/integrations/box/files/lib/box-client.ts +280 -0
  85. package/dist/integrations/calendar/files/app/api/auth/calendar/callback/route.ts +7 -110
  86. package/dist/integrations/calendar/files/app/api/auth/calendar/route.ts +5 -25
  87. package/dist/integrations/clickup/connector.json +85 -0
  88. package/dist/integrations/clickup/files/_env.example +4 -0
  89. package/dist/integrations/clickup/files/ai/tools/create-task.ts +64 -0
  90. package/dist/integrations/clickup/files/ai/tools/get-task.ts +59 -0
  91. package/dist/integrations/clickup/files/ai/tools/list-lists.ts +109 -0
  92. package/dist/integrations/clickup/files/ai/tools/list-tasks.ts +95 -0
  93. package/dist/integrations/clickup/files/ai/tools/update-task.ts +85 -0
  94. package/dist/integrations/clickup/files/app/api/auth/clickup/callback/route.ts +11 -0
  95. package/dist/integrations/clickup/files/app/api/auth/clickup/route.ts +7 -0
  96. package/dist/integrations/clickup/files/lib/clickup-client.ts +439 -0
  97. package/dist/integrations/confluence/README.md +246 -0
  98. package/dist/integrations/confluence/connector.json +104 -0
  99. package/dist/integrations/confluence/files/_env.example +4 -0
  100. package/dist/integrations/confluence/files/ai/tools/create-page.ts +43 -0
  101. package/dist/integrations/confluence/files/ai/tools/get-page.ts +30 -0
  102. package/dist/integrations/confluence/files/ai/tools/list-spaces.ts +31 -0
  103. package/dist/integrations/confluence/files/ai/tools/search-content.ts +38 -0
  104. package/dist/integrations/confluence/files/ai/tools/update-page.ts +45 -0
  105. package/dist/integrations/confluence/files/app/api/auth/confluence/callback/route.ts +11 -0
  106. package/dist/integrations/confluence/files/app/api/auth/confluence/route.ts +9 -0
  107. package/dist/integrations/confluence/files/lib/confluence-client.ts +281 -0
  108. package/dist/integrations/discord/connector.json +100 -0
  109. package/dist/integrations/discord/files/_env.example +12 -0
  110. package/dist/integrations/discord/files/ai/tools/get-messages.ts +55 -0
  111. package/dist/integrations/discord/files/ai/tools/get-user.ts +32 -0
  112. package/dist/integrations/discord/files/ai/tools/list-channels.ts +32 -0
  113. package/dist/integrations/discord/files/ai/tools/list-guilds.ts +24 -0
  114. package/dist/integrations/discord/files/ai/tools/send-message.ts +33 -0
  115. package/dist/integrations/discord/files/app/api/auth/discord/callback/route.ts +11 -0
  116. package/dist/integrations/discord/files/app/api/auth/discord/route.ts +9 -0
  117. package/dist/integrations/discord/files/lib/discord-client.ts +273 -0
  118. package/dist/integrations/docs-google/connector.json +101 -0
  119. package/dist/integrations/docs-google/files/_env.example +8 -0
  120. package/dist/integrations/docs-google/files/ai/tools/create-document.ts +46 -0
  121. package/dist/integrations/docs-google/files/ai/tools/get-document.ts +46 -0
  122. package/dist/integrations/docs-google/files/ai/tools/list-documents.ts +42 -0
  123. package/dist/integrations/docs-google/files/ai/tools/search-documents.ts +38 -0
  124. package/dist/integrations/docs-google/files/ai/tools/update-document.ts +131 -0
  125. package/dist/integrations/docs-google/files/app/api/auth/docs-google/callback/route.ts +11 -0
  126. package/dist/integrations/docs-google/files/app/api/auth/docs-google/route.ts +9 -0
  127. package/dist/integrations/docs-google/files/lib/docs-client.ts +582 -0
  128. package/dist/integrations/drive/connector.json +134 -0
  129. package/dist/integrations/drive/files/_env.example +9 -0
  130. package/dist/integrations/drive/files/ai/tools/create-folder.ts +47 -0
  131. package/dist/integrations/drive/files/ai/tools/get-file.ts +55 -0
  132. package/dist/integrations/drive/files/ai/tools/list-files.ts +78 -0
  133. package/dist/integrations/drive/files/ai/tools/search-files.ts +79 -0
  134. package/dist/integrations/drive/files/ai/tools/upload-file.ts +59 -0
  135. package/dist/integrations/drive/files/app/api/auth/drive/callback/route.ts +11 -0
  136. package/dist/integrations/drive/files/app/api/auth/drive/route.ts +9 -0
  137. package/dist/integrations/drive/files/lib/drive-client.ts +359 -0
  138. package/dist/integrations/dropbox/connector.json +107 -0
  139. package/dist/integrations/dropbox/files/_env.example +24 -0
  140. package/dist/integrations/dropbox/files/ai/tools/get-account.ts +58 -0
  141. package/dist/integrations/dropbox/files/ai/tools/get-file.ts +61 -0
  142. package/dist/integrations/dropbox/files/ai/tools/list-files.ts +56 -0
  143. package/dist/integrations/dropbox/files/ai/tools/search-files.ts +70 -0
  144. package/dist/integrations/dropbox/files/ai/tools/upload-file.ts +48 -0
  145. package/dist/integrations/dropbox/files/app/api/auth/dropbox/callback/route.ts +11 -0
  146. package/dist/integrations/dropbox/files/app/api/auth/dropbox/route.ts +9 -0
  147. package/dist/integrations/dropbox/files/lib/dropbox-client.ts +397 -0
  148. package/dist/integrations/figma/INTEGRATION_SUMMARY.md +436 -0
  149. package/dist/integrations/figma/README.md +287 -0
  150. package/dist/integrations/figma/connector.json +100 -0
  151. package/dist/integrations/figma/files/_env.example +5 -0
  152. package/dist/integrations/figma/files/ai/tools/get-comments.ts +72 -0
  153. package/dist/integrations/figma/files/ai/tools/get-file.ts +54 -0
  154. package/dist/integrations/figma/files/ai/tools/list-files.ts +39 -0
  155. package/dist/integrations/figma/files/ai/tools/list-projects.ts +69 -0
  156. package/dist/integrations/figma/files/ai/tools/post-comment.ts +54 -0
  157. package/dist/integrations/figma/files/app/api/auth/figma/callback/route.ts +11 -0
  158. package/dist/integrations/figma/files/app/api/auth/figma/route.ts +9 -0
  159. package/dist/integrations/figma/files/lib/figma-client.ts +355 -0
  160. package/dist/integrations/figma/files/lib/types.ts +503 -0
  161. package/dist/integrations/freshdesk/connector.json +85 -0
  162. package/dist/integrations/freshdesk/files/_env.example +4 -0
  163. package/dist/integrations/freshdesk/files/ai/tools/create-ticket.ts +60 -0
  164. package/dist/integrations/freshdesk/files/ai/tools/get-ticket.ts +46 -0
  165. package/dist/integrations/freshdesk/files/ai/tools/list-contacts.ts +37 -0
  166. package/dist/integrations/freshdesk/files/ai/tools/list-tickets.ts +59 -0
  167. package/dist/integrations/freshdesk/files/ai/tools/update-ticket.ts +61 -0
  168. package/dist/integrations/freshdesk/files/app/api/auth/freshdesk/callback/route.ts +11 -0
  169. package/dist/integrations/freshdesk/files/app/api/auth/freshdesk/route.ts +7 -0
  170. package/dist/integrations/freshdesk/files/lib/freshdesk-client.ts +178 -0
  171. package/dist/integrations/github/files/app/api/auth/github/callback/route.ts +6 -127
  172. package/dist/integrations/github/files/app/api/auth/github/route.ts +4 -24
  173. package/dist/integrations/gitlab/connector.json +100 -0
  174. package/dist/integrations/gitlab/files/_env.example +7 -0
  175. package/dist/integrations/gitlab/files/ai/tools/create-issue.ts +49 -0
  176. package/dist/integrations/gitlab/files/ai/tools/get-issue.ts +56 -0
  177. package/dist/integrations/gitlab/files/ai/tools/list-merge-requests.ts +75 -0
  178. package/dist/integrations/gitlab/files/ai/tools/list-projects.ts +51 -0
  179. package/dist/integrations/gitlab/files/ai/tools/search-issues.ts +67 -0
  180. package/dist/integrations/gitlab/files/app/api/auth/gitlab/callback/route.ts +11 -0
  181. package/dist/integrations/gitlab/files/app/api/auth/gitlab/route.ts +9 -0
  182. package/dist/integrations/gitlab/files/lib/gitlab-client.ts +366 -0
  183. package/dist/integrations/gmail/files/app/api/auth/gmail/callback/route.ts +7 -108
  184. package/dist/integrations/gmail/files/app/api/auth/gmail/route.ts +5 -23
  185. package/dist/integrations/gmail/files/lib/gmail-client.ts +16 -55
  186. package/dist/integrations/hubspot/connector.json +98 -0
  187. package/dist/integrations/hubspot/files/_env.example +5 -0
  188. package/dist/integrations/hubspot/files/ai/tools/create-contact.ts +41 -0
  189. package/dist/integrations/hubspot/files/ai/tools/create-deal.ts +41 -0
  190. package/dist/integrations/hubspot/files/ai/tools/get-contact.ts +39 -0
  191. package/dist/integrations/hubspot/files/ai/tools/list-contacts.ts +43 -0
  192. package/dist/integrations/hubspot/files/ai/tools/list-deals.ts +41 -0
  193. package/dist/integrations/hubspot/files/app/api/auth/hubspot/callback/route.ts +11 -0
  194. package/dist/integrations/hubspot/files/app/api/auth/hubspot/route.ts +9 -0
  195. package/dist/integrations/hubspot/files/lib/hubspot-client.ts +393 -0
  196. package/dist/integrations/intercom/connector.json +85 -0
  197. package/dist/integrations/intercom/files/_env.example +4 -0
  198. package/dist/integrations/intercom/files/ai/tools/get-contact.ts +35 -0
  199. package/dist/integrations/intercom/files/ai/tools/get-conversation.ts +55 -0
  200. package/dist/integrations/intercom/files/ai/tools/list-contacts.ts +35 -0
  201. package/dist/integrations/intercom/files/ai/tools/list-conversations.ts +49 -0
  202. package/dist/integrations/intercom/files/ai/tools/send-message.ts +34 -0
  203. package/dist/integrations/intercom/files/app/api/auth/intercom/callback/route.ts +11 -0
  204. package/dist/integrations/intercom/files/app/api/auth/intercom/route.ts +7 -0
  205. package/dist/integrations/intercom/files/lib/intercom-client.ts +308 -0
  206. package/dist/integrations/jira/connector.json +109 -0
  207. package/dist/integrations/jira/files/ai/tools/create-issue.ts +47 -0
  208. package/dist/integrations/jira/files/ai/tools/get-issue.ts +57 -0
  209. package/dist/integrations/jira/files/ai/tools/list-projects.ts +30 -0
  210. package/dist/integrations/jira/files/ai/tools/search-issues.ts +49 -0
  211. package/dist/integrations/jira/files/ai/tools/update-issue.ts +81 -0
  212. package/dist/integrations/jira/files/app/api/auth/jira/callback/route.ts +11 -0
  213. package/dist/integrations/jira/files/app/api/auth/jira/route.ts +9 -0
  214. package/dist/integrations/jira/files/lib/jira-client.ts +338 -0
  215. package/dist/integrations/linear/connector.json +100 -0
  216. package/dist/integrations/linear/files/_env.example +6 -0
  217. package/dist/integrations/linear/files/ai/tools/create-issue.ts +71 -0
  218. package/dist/integrations/linear/files/ai/tools/get-issue.ts +55 -0
  219. package/dist/integrations/linear/files/ai/tools/list-projects.ts +43 -0
  220. package/dist/integrations/linear/files/ai/tools/search-issues.ts +54 -0
  221. package/dist/integrations/linear/files/ai/tools/update-issue.ts +71 -0
  222. package/dist/integrations/linear/files/app/api/auth/linear/callback/route.ts +11 -0
  223. package/dist/integrations/linear/files/app/api/auth/linear/route.ts +9 -0
  224. package/dist/integrations/linear/files/lib/linear-client.ts +464 -0
  225. package/dist/integrations/mailchimp/connector.json +85 -0
  226. package/dist/integrations/mailchimp/files/_env.example +4 -0
  227. package/dist/integrations/mailchimp/files/ai/tools/get-campaign.ts +45 -0
  228. package/dist/integrations/mailchimp/files/ai/tools/get-list.ts +51 -0
  229. package/dist/integrations/mailchimp/files/ai/tools/list-campaigns.ts +46 -0
  230. package/dist/integrations/mailchimp/files/ai/tools/list-lists.ts +46 -0
  231. package/dist/integrations/mailchimp/files/ai/tools/list-members.ts +58 -0
  232. package/dist/integrations/mailchimp/files/app/api/auth/mailchimp/callback/route.ts +11 -0
  233. package/dist/integrations/mailchimp/files/app/api/auth/mailchimp/route.ts +7 -0
  234. package/dist/integrations/mailchimp/files/lib/mailchimp-client.ts +267 -0
  235. package/dist/integrations/mixpanel/connector.json +96 -0
  236. package/dist/integrations/mixpanel/files/_env.example +11 -0
  237. package/dist/integrations/mixpanel/files/ai/tools/get-funnel.ts +46 -0
  238. package/dist/integrations/mixpanel/files/ai/tools/get-retention.ts +64 -0
  239. package/dist/integrations/mixpanel/files/ai/tools/list-cohorts.ts +46 -0
  240. package/dist/integrations/mixpanel/files/ai/tools/query-events.ts +43 -0
  241. package/dist/integrations/mixpanel/files/ai/tools/track-event.ts +41 -0
  242. package/dist/integrations/mixpanel/files/lib/mixpanel-client.ts +319 -0
  243. package/dist/integrations/monday/connector.json +85 -0
  244. package/dist/integrations/monday/files/_env.example +4 -0
  245. package/dist/integrations/monday/files/ai/tools/create-item.ts +36 -0
  246. package/dist/integrations/monday/files/ai/tools/get-item.ts +31 -0
  247. package/dist/integrations/monday/files/ai/tools/list-boards.ts +29 -0
  248. package/dist/integrations/monday/files/ai/tools/list-items.ts +36 -0
  249. package/dist/integrations/monday/files/ai/tools/update-item.ts +36 -0
  250. package/dist/integrations/monday/files/app/api/auth/monday/callback/route.ts +11 -0
  251. package/dist/integrations/monday/files/app/api/auth/monday/route.ts +7 -0
  252. package/dist/integrations/monday/files/lib/monday-client.ts +329 -0
  253. package/dist/integrations/neon/connector.json +89 -0
  254. package/dist/integrations/neon/files/_env.example +6 -0
  255. package/dist/integrations/neon/files/ai/tools/describe-table.ts +38 -0
  256. package/dist/integrations/neon/files/ai/tools/list-branches.ts +35 -0
  257. package/dist/integrations/neon/files/ai/tools/list-projects.ts +31 -0
  258. package/dist/integrations/neon/files/ai/tools/list-tables.ts +49 -0
  259. package/dist/integrations/neon/files/ai/tools/query-database.ts +33 -0
  260. package/dist/integrations/neon/files/app/api/auth/neon/route.ts +51 -0
  261. package/dist/integrations/neon/files/lib/neon-client.ts +294 -0
  262. package/dist/integrations/notion/connector.json +87 -0
  263. package/dist/integrations/notion/files/_env.example +6 -0
  264. package/dist/integrations/notion/files/ai/tools/create-page.ts +32 -0
  265. package/dist/integrations/notion/files/ai/tools/query-database.ts +44 -0
  266. package/dist/integrations/notion/files/ai/tools/read-page.ts +34 -0
  267. package/dist/integrations/notion/files/ai/tools/search-notion.ts +51 -0
  268. package/dist/integrations/notion/files/app/api/auth/notion/callback/route.ts +11 -0
  269. package/dist/integrations/notion/files/app/api/auth/notion/route.ts +9 -0
  270. package/dist/integrations/notion/files/lib/notion-client.ts +218 -0
  271. package/dist/integrations/onedrive/connector.json +100 -0
  272. package/dist/integrations/onedrive/files/_env.example +23 -0
  273. package/dist/integrations/onedrive/files/ai/tools/download-file.ts +38 -0
  274. package/dist/integrations/onedrive/files/ai/tools/list-files.ts +63 -0
  275. package/dist/integrations/onedrive/files/ai/tools/search-files.ts +59 -0
  276. package/dist/integrations/onedrive/files/ai/tools/upload-file.ts +43 -0
  277. package/dist/integrations/onedrive/files/app/api/auth/onedrive/callback/route.ts +11 -0
  278. package/dist/integrations/onedrive/files/app/api/auth/onedrive/route.ts +9 -0
  279. package/dist/integrations/onedrive/files/lib/onedrive-client.ts +314 -0
  280. package/dist/integrations/outlook/README.md +308 -0
  281. package/dist/integrations/outlook/connector.json +98 -0
  282. package/dist/integrations/outlook/files/_env.example +8 -0
  283. package/dist/integrations/outlook/files/ai/tools/get-email.ts +47 -0
  284. package/dist/integrations/outlook/files/ai/tools/list-emails.ts +46 -0
  285. package/dist/integrations/outlook/files/ai/tools/list-folders.ts +22 -0
  286. package/dist/integrations/outlook/files/ai/tools/search-emails.ts +41 -0
  287. package/dist/integrations/outlook/files/ai/tools/send-email.ts +41 -0
  288. package/dist/integrations/outlook/files/app/api/auth/outlook/callback/route.ts +11 -0
  289. package/dist/integrations/outlook/files/app/api/auth/outlook/route.ts +9 -0
  290. package/dist/integrations/outlook/files/lib/outlook-client.ts +204 -0
  291. package/dist/integrations/pipedrive/connector.json +85 -0
  292. package/dist/integrations/pipedrive/files/_env.example +4 -0
  293. package/dist/integrations/pipedrive/files/ai/tools/create-deal.ts +44 -0
  294. package/dist/integrations/pipedrive/files/ai/tools/get-deal.ts +34 -0
  295. package/dist/integrations/pipedrive/files/ai/tools/list-deals.ts +40 -0
  296. package/dist/integrations/pipedrive/files/ai/tools/list-persons.ts +33 -0
  297. package/dist/integrations/pipedrive/files/ai/tools/update-deal.ts +46 -0
  298. package/dist/integrations/pipedrive/files/app/api/auth/pipedrive/callback/route.ts +11 -0
  299. package/dist/integrations/pipedrive/files/app/api/auth/pipedrive/route.ts +7 -0
  300. package/dist/integrations/pipedrive/files/lib/pipedrive-client.ts +259 -0
  301. package/dist/integrations/posthog/connector.json +84 -0
  302. package/dist/integrations/posthog/files/_env.example +6 -0
  303. package/dist/integrations/posthog/files/ai/tools/capture-event.ts +37 -0
  304. package/dist/integrations/posthog/files/ai/tools/get-trends.ts +44 -0
  305. package/dist/integrations/posthog/files/ai/tools/list-feature-flags.ts +38 -0
  306. package/dist/integrations/posthog/files/ai/tools/list-persons.ts +32 -0
  307. package/dist/integrations/posthog/files/lib/posthog-client.ts +286 -0
  308. package/dist/integrations/quickbooks/connector.json +85 -0
  309. package/dist/integrations/quickbooks/files/_env.example +4 -0
  310. package/dist/integrations/quickbooks/files/ai/tools/create-invoice.ts +48 -0
  311. package/dist/integrations/quickbooks/files/ai/tools/get-customer.ts +36 -0
  312. package/dist/integrations/quickbooks/files/ai/tools/get-invoice.ts +46 -0
  313. package/dist/integrations/quickbooks/files/ai/tools/list-customers.ts +37 -0
  314. package/dist/integrations/quickbooks/files/ai/tools/list-invoices.ts +40 -0
  315. package/dist/integrations/quickbooks/files/app/api/auth/quickbooks/callback/route.ts +11 -0
  316. package/dist/integrations/quickbooks/files/app/api/auth/quickbooks/route.ts +7 -0
  317. package/dist/integrations/quickbooks/files/lib/quickbooks-client.ts +252 -0
  318. package/dist/integrations/salesforce/connector.json +104 -0
  319. package/dist/integrations/salesforce/files/ai/tools/create-lead.ts +101 -0
  320. package/dist/integrations/salesforce/files/ai/tools/get-account.ts +53 -0
  321. package/dist/integrations/salesforce/files/ai/tools/list-accounts.ts +50 -0
  322. package/dist/integrations/salesforce/files/ai/tools/list-contacts.ts +54 -0
  323. package/dist/integrations/salesforce/files/ai/tools/list-opportunities.ts +55 -0
  324. package/dist/integrations/salesforce/files/app/api/auth/salesforce/callback/route.ts +11 -0
  325. package/dist/integrations/salesforce/files/app/api/auth/salesforce/route.ts +9 -0
  326. package/dist/integrations/salesforce/files/lib/salesforce-client.ts +539 -0
  327. package/dist/integrations/sentry/connector.json +84 -0
  328. package/dist/integrations/sentry/files/_env.example +6 -0
  329. package/dist/integrations/sentry/files/ai/tools/get-issue.ts +66 -0
  330. package/dist/integrations/sentry/files/ai/tools/list-issues.ts +57 -0
  331. package/dist/integrations/sentry/files/ai/tools/list-projects.ts +32 -0
  332. package/dist/integrations/sentry/files/ai/tools/resolve-issue.ts +28 -0
  333. package/dist/integrations/sentry/files/lib/sentry-client.ts +268 -0
  334. package/dist/integrations/servicenow/connector.json +66 -0
  335. package/dist/integrations/servicenow/files/_env.example +5 -0
  336. package/dist/integrations/servicenow/files/ai/tools/create-incident.ts +58 -0
  337. package/dist/integrations/servicenow/files/ai/tools/get-incident.ts +59 -0
  338. package/dist/integrations/servicenow/files/ai/tools/list-incidents.ts +72 -0
  339. package/dist/integrations/servicenow/files/ai/tools/search-knowledge.ts +48 -0
  340. package/dist/integrations/servicenow/files/ai/tools/update-incident.ts +60 -0
  341. package/dist/integrations/servicenow/files/app/api/auth/servicenow/callback/route.ts +89 -0
  342. package/dist/integrations/servicenow/files/app/api/auth/servicenow/route.ts +42 -0
  343. package/dist/integrations/servicenow/files/lib/servicenow-client.ts +239 -0
  344. package/dist/integrations/sharepoint/connector.json +99 -0
  345. package/dist/integrations/sharepoint/files/ai/tools/get-file.ts +93 -0
  346. package/dist/integrations/sharepoint/files/ai/tools/get-site.ts +51 -0
  347. package/dist/integrations/sharepoint/files/ai/tools/list-files.ts +63 -0
  348. package/dist/integrations/sharepoint/files/ai/tools/list-sites.ts +28 -0
  349. package/dist/integrations/sharepoint/files/ai/tools/upload-file.ts +72 -0
  350. package/dist/integrations/sharepoint/files/app/api/auth/sharepoint/callback/route.ts +11 -0
  351. package/dist/integrations/sharepoint/files/app/api/auth/sharepoint/route.ts +9 -0
  352. package/dist/integrations/sharepoint/files/lib/sharepoint-client.ts +420 -0
  353. package/dist/integrations/sheets/README.md +331 -0
  354. package/dist/integrations/sheets/connector.json +99 -0
  355. package/dist/integrations/sheets/files/_env.example +8 -0
  356. package/dist/integrations/sheets/files/ai/tools/create-spreadsheet.ts +85 -0
  357. package/dist/integrations/sheets/files/ai/tools/get-spreadsheet.ts +39 -0
  358. package/dist/integrations/sheets/files/ai/tools/list-spreadsheets.ts +41 -0
  359. package/dist/integrations/sheets/files/ai/tools/read-range.ts +35 -0
  360. package/dist/integrations/sheets/files/ai/tools/write-range.ts +51 -0
  361. package/dist/integrations/sheets/files/app/api/auth/sheets/callback/route.ts +11 -0
  362. package/dist/integrations/sheets/files/app/api/auth/sheets/route.ts +9 -0
  363. package/dist/integrations/sheets/files/lib/sheets-client.ts +425 -0
  364. package/dist/integrations/shopify/connector.json +99 -0
  365. package/dist/integrations/shopify/files/_env.example +5 -0
  366. package/dist/integrations/shopify/files/ai/tools/get-order.ts +49 -0
  367. package/dist/integrations/shopify/files/ai/tools/get-product.ts +39 -0
  368. package/dist/integrations/shopify/files/ai/tools/list-customers.ts +40 -0
  369. package/dist/integrations/shopify/files/ai/tools/list-orders.ts +52 -0
  370. package/dist/integrations/shopify/files/ai/tools/list-products.ts +39 -0
  371. package/dist/integrations/shopify/files/app/api/auth/shopify/callback/route.ts +11 -0
  372. package/dist/integrations/shopify/files/app/api/auth/shopify/route.ts +7 -0
  373. package/dist/integrations/shopify/files/lib/shopify-client.ts +198 -0
  374. package/dist/integrations/slack/files/app/api/auth/slack/callback/route.ts +6 -127
  375. package/dist/integrations/slack/files/app/api/auth/slack/route.ts +4 -24
  376. package/dist/integrations/snowflake/connector.json +151 -0
  377. package/dist/integrations/snowflake/files/_env.example +16 -0
  378. package/dist/integrations/snowflake/files/ai/tools/describe-table.ts +57 -0
  379. package/dist/integrations/snowflake/files/ai/tools/list-databases.ts +34 -0
  380. package/dist/integrations/snowflake/files/ai/tools/list-schemas.ts +40 -0
  381. package/dist/integrations/snowflake/files/ai/tools/list-tables.ts +49 -0
  382. package/dist/integrations/snowflake/files/ai/tools/run-query.ts +119 -0
  383. package/dist/integrations/snowflake/files/lib/snowflake-client.ts +389 -0
  384. package/dist/integrations/stripe/connector.json +97 -0
  385. package/dist/integrations/stripe/files/_env.example +6 -0
  386. package/dist/integrations/stripe/files/ai/tools/get-balance.ts +28 -0
  387. package/dist/integrations/stripe/files/ai/tools/get-customer.ts +26 -0
  388. package/dist/integrations/stripe/files/ai/tools/list-customers.ts +42 -0
  389. package/dist/integrations/stripe/files/ai/tools/list-payments.ts +45 -0
  390. package/dist/integrations/stripe/files/ai/tools/list-subscriptions.ts +67 -0
  391. package/dist/integrations/stripe/files/app/api/auth/stripe/route.ts +71 -0
  392. package/dist/integrations/stripe/files/lib/stripe-client.ts +376 -0
  393. package/dist/integrations/supabase/connector.json +101 -0
  394. package/dist/integrations/supabase/files/_env.example +6 -0
  395. package/dist/integrations/supabase/files/ai/tools/delete-row.ts +77 -0
  396. package/dist/integrations/supabase/files/ai/tools/insert-row.ts +35 -0
  397. package/dist/integrations/supabase/files/ai/tools/list-tables.ts +60 -0
  398. package/dist/integrations/supabase/files/ai/tools/query-table.ts +48 -0
  399. package/dist/integrations/supabase/files/ai/tools/update-row.ts +64 -0
  400. package/dist/integrations/supabase/files/app/api/auth/supabase/route.ts +91 -0
  401. package/dist/integrations/supabase/files/lib/supabase-client.ts +296 -0
  402. package/dist/integrations/teams/README.md +256 -0
  403. package/dist/integrations/teams/connector.json +99 -0
  404. package/dist/integrations/teams/files/ai/tools/get-messages.ts +55 -0
  405. package/dist/integrations/teams/files/ai/tools/list-channels.ts +28 -0
  406. package/dist/integrations/teams/files/ai/tools/list-chats.ts +41 -0
  407. package/dist/integrations/teams/files/ai/tools/list-teams.ts +27 -0
  408. package/dist/integrations/teams/files/ai/tools/send-message.ts +61 -0
  409. package/dist/integrations/teams/files/app/api/auth/teams/callback/route.ts +11 -0
  410. package/dist/integrations/teams/files/app/api/auth/teams/route.ts +9 -0
  411. package/dist/integrations/teams/files/lib/teams-client.ts +345 -0
  412. package/dist/integrations/trello/connector.json +85 -0
  413. package/dist/integrations/trello/files/_env.example +4 -0
  414. package/dist/integrations/trello/files/ai/tools/create-card.ts +54 -0
  415. package/dist/integrations/trello/files/ai/tools/get-card.ts +33 -0
  416. package/dist/integrations/trello/files/ai/tools/list-boards.ts +29 -0
  417. package/dist/integrations/trello/files/ai/tools/list-cards.ts +52 -0
  418. package/dist/integrations/trello/files/ai/tools/update-card.ts +65 -0
  419. package/dist/integrations/trello/files/app/api/auth/trello/callback/route.ts +11 -0
  420. package/dist/integrations/trello/files/app/api/auth/trello/route.ts +7 -0
  421. package/dist/integrations/trello/files/lib/trello-client.ts +202 -0
  422. package/dist/integrations/twilio/connector.json +146 -0
  423. package/dist/integrations/twilio/files/_env.example +14 -0
  424. package/dist/integrations/twilio/files/ai/tools/get-message.ts +58 -0
  425. package/dist/integrations/twilio/files/ai/tools/list-calls.ts +129 -0
  426. package/dist/integrations/twilio/files/ai/tools/list-messages.ts +97 -0
  427. package/dist/integrations/twilio/files/ai/tools/send-sms.ts +75 -0
  428. package/dist/integrations/twilio/files/ai/tools/send-whatsapp.ts +81 -0
  429. package/dist/integrations/twilio/files/lib/twilio-client.ts +375 -0
  430. package/dist/integrations/twitter/connector.json +87 -0
  431. package/dist/integrations/twitter/files/_env.example +6 -0
  432. package/dist/integrations/twitter/files/ai/tools/get-timeline.ts +59 -0
  433. package/dist/integrations/twitter/files/ai/tools/post-tweet.ts +49 -0
  434. package/dist/integrations/twitter/files/ai/tools/search-tweets.ts +71 -0
  435. package/dist/integrations/twitter/files/app/api/auth/twitter/callback/route.ts +11 -0
  436. package/dist/integrations/twitter/files/app/api/auth/twitter/route.ts +9 -0
  437. package/dist/integrations/twitter/files/lib/twitter-client.ts +236 -0
  438. package/dist/integrations/webex/connector.json +85 -0
  439. package/dist/integrations/webex/files/_env.example +4 -0
  440. package/dist/integrations/webex/files/ai/tools/create-meeting.ts +69 -0
  441. package/dist/integrations/webex/files/ai/tools/get-meeting.ts +31 -0
  442. package/dist/integrations/webex/files/ai/tools/list-meetings.ts +44 -0
  443. package/dist/integrations/webex/files/ai/tools/list-rooms.ts +35 -0
  444. package/dist/integrations/webex/files/ai/tools/send-message.ts +51 -0
  445. package/dist/integrations/webex/files/app/api/auth/webex/callback/route.ts +11 -0
  446. package/dist/integrations/webex/files/app/api/auth/webex/route.ts +7 -0
  447. package/dist/integrations/webex/files/lib/webex-client.ts +279 -0
  448. package/dist/integrations/xero/connector.json +85 -0
  449. package/dist/integrations/xero/files/_env.example +4 -0
  450. package/dist/integrations/xero/files/ai/tools/create-invoice.ts +65 -0
  451. package/dist/integrations/xero/files/ai/tools/get-contact.ts +40 -0
  452. package/dist/integrations/xero/files/ai/tools/get-invoice.ts +44 -0
  453. package/dist/integrations/xero/files/ai/tools/list-contacts.ts +54 -0
  454. package/dist/integrations/xero/files/ai/tools/list-invoices.ts +54 -0
  455. package/dist/integrations/xero/files/app/api/auth/xero/callback/route.ts +11 -0
  456. package/dist/integrations/xero/files/app/api/auth/xero/route.ts +7 -0
  457. package/dist/integrations/xero/files/lib/xero-client.ts +292 -0
  458. package/dist/integrations/zendesk/connector.json +61 -0
  459. package/dist/integrations/zendesk/files/_env.example +5 -0
  460. package/dist/integrations/zendesk/files/ai/tools/create-ticket.ts +82 -0
  461. package/dist/integrations/zendesk/files/ai/tools/get-ticket.ts +53 -0
  462. package/dist/integrations/zendesk/files/ai/tools/list-tickets.ts +60 -0
  463. package/dist/integrations/zendesk/files/ai/tools/search-tickets.ts +56 -0
  464. package/dist/integrations/zendesk/files/app/api/auth/zendesk/callback/route.ts +91 -0
  465. package/dist/integrations/zendesk/files/app/api/auth/zendesk/route.ts +41 -0
  466. package/dist/integrations/zendesk/files/lib/zendesk-client.ts +265 -0
  467. package/dist/integrations/zoom/connector.json +85 -0
  468. package/dist/integrations/zoom/files/_env.example +4 -0
  469. package/dist/integrations/zoom/files/ai/tools/create-meeting.ts +106 -0
  470. package/dist/integrations/zoom/files/ai/tools/delete-meeting.ts +32 -0
  471. package/dist/integrations/zoom/files/ai/tools/get-meeting.ts +44 -0
  472. package/dist/integrations/zoom/files/ai/tools/list-meetings.ts +47 -0
  473. package/dist/integrations/zoom/files/ai/tools/update-meeting.ts +111 -0
  474. package/dist/integrations/zoom/files/app/api/auth/zoom/callback/route.ts +11 -0
  475. package/dist/integrations/zoom/files/app/api/auth/zoom/route.ts +7 -0
  476. package/dist/integrations/zoom/files/lib/zoom-client.ts +228 -0
  477. package/dist/oauth/handlers.js +554 -0
  478. package/dist/oauth/handlers.js.map +7 -0
  479. package/dist/oauth/index.js +1157 -0
  480. package/dist/oauth/index.js.map +7 -0
  481. package/dist/oauth/providers.js +927 -0
  482. package/dist/oauth/providers.js.map +7 -0
  483. package/dist/oauth/token-store.js +82 -0
  484. package/dist/oauth/token-store.js.map +7 -0
  485. package/package.json +25 -1
  486. package/dist/integrations/calendar/files/lib/token-store.ts +0 -113
  487. package/dist/integrations/github/files/lib/token-store.ts +0 -113
  488. package/dist/integrations/gmail/files/lib/oauth.ts +0 -145
  489. package/dist/integrations/gmail/files/lib/token-store.ts +0 -113
  490. package/dist/integrations/slack/files/lib/oauth.ts +0 -145
  491. package/dist/integrations/slack/files/lib/token-store.ts +0 -113
  492. /package/dist/integrations/{calendar → docs-google}/files/lib/oauth.ts +0 -0
  493. /package/dist/integrations/{github → drive}/files/lib/oauth.ts +0 -0
@@ -0,0 +1,63 @@
1
+ import { tool } from "veryfront/ai";
2
+ import { z } from "zod";
3
+ import { listFiles, searchFiles } from "../../lib/sharepoint-client.ts";
4
+
5
+ export default tool({
6
+ id: "list-files",
7
+ description:
8
+ "List files and folders in a SharePoint document library. Can list root level or a specific folder, or search across the entire library.",
9
+ inputSchema: z.object({
10
+ siteId: z.string().describe("The ID of the SharePoint site"),
11
+ driveId: z.string().describe("The ID of the document library (drive)"),
12
+ folderId: z.string().optional().describe(
13
+ "Optional folder ID to list contents from. If not provided, lists root level.",
14
+ ),
15
+ search: z.string().optional().describe(
16
+ "Optional search query to find files by name or content instead of listing",
17
+ ),
18
+ orderBy: z.enum(["name", "lastModifiedDateTime", "size"]).optional().describe(
19
+ "Sort order for results",
20
+ ),
21
+ limit: z.number().min(1).max(100).default(50).describe("Maximum number of items to return"),
22
+ }),
23
+ async execute({ siteId, driveId, folderId, search, orderBy, limit }) {
24
+ let files;
25
+
26
+ if (search) {
27
+ // Use search functionality
28
+ files = await searchFiles(siteId, search, { limit });
29
+ } else {
30
+ // List files in folder
31
+ files = await listFiles(siteId, driveId, folderId, {
32
+ limit,
33
+ orderBy,
34
+ });
35
+ }
36
+
37
+ return files.map((file) => ({
38
+ id: file.id,
39
+ name: file.name,
40
+ type: file.folder ? "folder" : "file",
41
+ size: file.size,
42
+ sizeFormatted: formatBytes(file.size),
43
+ mimeType: file.file?.mimeType,
44
+ url: file.webUrl,
45
+ created: file.createdDateTime,
46
+ lastModified: file.lastModifiedDateTime,
47
+ createdBy: file.createdBy?.user?.displayName,
48
+ lastModifiedBy: file.lastModifiedBy?.user?.displayName,
49
+ parentPath: file.parentReference?.path,
50
+ childCount: file.folder?.childCount,
51
+ }));
52
+ },
53
+ });
54
+
55
+ function formatBytes(bytes: number): string {
56
+ if (bytes === 0) return "0 Bytes";
57
+
58
+ const k = 1024;
59
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
60
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
61
+
62
+ return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + " " + sizes[i];
63
+ }
@@ -0,0 +1,28 @@
1
+ import { tool } from "veryfront/ai";
2
+ import { z } from "zod";
3
+ import { listSites } from "../../lib/sharepoint-client.ts";
4
+
5
+ export default tool({
6
+ id: "list-sites",
7
+ description:
8
+ "List all SharePoint sites the user has access to. Returns site names, URLs, and IDs.",
9
+ inputSchema: z.object({
10
+ search: z.string().optional().describe(
11
+ "Optional search query to filter sites by name or description",
12
+ ),
13
+ limit: z.number().min(1).max(50).default(20).describe("Maximum number of sites to return"),
14
+ }),
15
+ async execute({ search, limit }) {
16
+ const sites = await listSites({ search, limit });
17
+
18
+ return sites.map((site) => ({
19
+ id: site.id,
20
+ name: site.displayName || site.name,
21
+ description: site.description,
22
+ url: site.webUrl,
23
+ hostname: site.siteCollection?.hostname,
24
+ created: site.createdDateTime,
25
+ lastModified: site.lastModifiedDateTime,
26
+ }));
27
+ },
28
+ });
@@ -0,0 +1,72 @@
1
+ import { tool } from "veryfront/ai";
2
+ import { z } from "zod";
3
+ import { createFolder, uploadFile } from "../../lib/sharepoint-client.ts";
4
+
5
+ export default tool({
6
+ id: "upload-file",
7
+ description:
8
+ "Upload a file to a SharePoint document library. Can upload to root or a specific folder.",
9
+ inputSchema: z.object({
10
+ siteId: z.string().describe("The ID of the SharePoint site"),
11
+ driveId: z.string().describe("The ID of the document library (drive) to upload to"),
12
+ fileName: z.string().describe("The name of the file to create (including extension)"),
13
+ content: z.string().describe("The content of the file to upload"),
14
+ folderId: z.string().optional().describe(
15
+ "Optional folder ID to upload into. If not provided, uploads to root.",
16
+ ),
17
+ createFolderIfNeeded: z.boolean().default(false).describe(
18
+ "If true and folderPath is provided, creates the folder if it does not exist",
19
+ ),
20
+ folderPath: z.string().optional().describe(
21
+ 'Optional folder path (e.g., "Documents/Projects") to create if createFolderIfNeeded is true',
22
+ ),
23
+ }),
24
+ async execute(
25
+ { siteId, driveId, fileName, content, folderId, createFolderIfNeeded, folderPath },
26
+ ) {
27
+ let targetFolderId = folderId;
28
+
29
+ // Create folder if needed
30
+ if (createFolderIfNeeded && folderPath && !folderId) {
31
+ const folders = folderPath.split("/").filter(Boolean);
32
+ let currentFolderId: string | undefined;
33
+
34
+ for (const folderName of folders) {
35
+ try {
36
+ const folder = await createFolder(siteId, driveId, folderName, currentFolderId);
37
+ currentFolderId = folder.id;
38
+ } catch (error) {
39
+ // Folder might already exist, try to continue
40
+ console.warn(`Note: Could not create folder "${folderName}":`, error);
41
+ }
42
+ }
43
+
44
+ targetFolderId = currentFolderId;
45
+ }
46
+
47
+ const file = await uploadFile(siteId, driveId, fileName, content, targetFolderId);
48
+
49
+ return {
50
+ id: file.id,
51
+ name: file.name,
52
+ size: file.size,
53
+ sizeFormatted: formatBytes(file.size),
54
+ mimeType: file.file?.mimeType,
55
+ url: file.webUrl,
56
+ created: file.createdDateTime,
57
+ lastModified: file.lastModifiedDateTime,
58
+ parentPath: file.parentReference?.path,
59
+ message: `Successfully uploaded "${fileName}" to SharePoint`,
60
+ };
61
+ },
62
+ });
63
+
64
+ function formatBytes(bytes: number): string {
65
+ if (bytes === 0) return "0 Bytes";
66
+
67
+ const k = 1024;
68
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
69
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
70
+
71
+ return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + " " + sizes[i];
72
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * SharePoint OAuth Callback
3
+ */
4
+
5
+ import { createOAuthCallbackHandler, memoryTokenStore, sharePointConfig } from "veryfront/oauth";
6
+
7
+ export const GET = createOAuthCallbackHandler(sharePointConfig, {
8
+ tokenStore: memoryTokenStore,
9
+ onSuccess: () => "/",
10
+ onError: () => "/",
11
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * SharePoint OAuth Initiation
3
+ */
4
+
5
+ import { createOAuthInitHandler, memoryTokenStore, sharePointConfig } from "veryfront/oauth";
6
+
7
+ export const GET = createOAuthInitHandler(sharePointConfig, {
8
+ tokenStore: memoryTokenStore,
9
+ });
@@ -0,0 +1,420 @@
1
+ import { getAccessToken } from "./token-store.ts";
2
+
3
+ const GRAPH_BASE_URL = "https://graph.microsoft.com/v1.0";
4
+
5
+ // Type definitions for SharePoint responses
6
+ export interface SharePointSite {
7
+ id: string;
8
+ name: string;
9
+ displayName: string;
10
+ description?: string;
11
+ webUrl: string;
12
+ createdDateTime: string;
13
+ lastModifiedDateTime: string;
14
+ siteCollection?: {
15
+ hostname: string;
16
+ };
17
+ }
18
+
19
+ export interface SharePointDrive {
20
+ id: string;
21
+ name: string;
22
+ description?: string;
23
+ driveType: string;
24
+ createdDateTime: string;
25
+ lastModifiedDateTime: string;
26
+ webUrl: string;
27
+ quota?: {
28
+ total: number;
29
+ used: number;
30
+ remaining: number;
31
+ };
32
+ }
33
+
34
+ export interface SharePointFile {
35
+ id: string;
36
+ name: string;
37
+ size: number;
38
+ createdDateTime: string;
39
+ lastModifiedDateTime: string;
40
+ webUrl: string;
41
+ file?: {
42
+ mimeType: string;
43
+ hashes?: {
44
+ sha1Hash?: string;
45
+ quickXorHash?: string;
46
+ };
47
+ };
48
+ folder?: {
49
+ childCount: number;
50
+ };
51
+ parentReference?: {
52
+ driveId: string;
53
+ id: string;
54
+ path: string;
55
+ };
56
+ createdBy?: {
57
+ user?: {
58
+ displayName: string;
59
+ email?: string;
60
+ };
61
+ };
62
+ lastModifiedBy?: {
63
+ user?: {
64
+ displayName: string;
65
+ email?: string;
66
+ };
67
+ };
68
+ }
69
+
70
+ interface GraphResponse<T> {
71
+ value: T[];
72
+ "@odata.nextLink"?: string;
73
+ }
74
+
75
+ async function graphFetch<T>(
76
+ endpoint: string,
77
+ options: RequestInit = {},
78
+ ): Promise<T> {
79
+ const token = await getAccessToken();
80
+ if (!token) {
81
+ throw new Error("Not authenticated with Microsoft. Please connect your account.");
82
+ }
83
+
84
+ const response = await fetch(`${GRAPH_BASE_URL}${endpoint}`, {
85
+ ...options,
86
+ headers: {
87
+ "Authorization": `Bearer ${token}`,
88
+ "Content-Type": "application/json",
89
+ ...options.headers,
90
+ },
91
+ });
92
+
93
+ if (!response.ok) {
94
+ const error = await response.json().catch(() => ({}));
95
+ throw new Error(
96
+ `Microsoft Graph API error: ${response.status} ${
97
+ error.error?.message || response.statusText
98
+ }`,
99
+ );
100
+ }
101
+
102
+ return response.json();
103
+ }
104
+
105
+ /**
106
+ * List all SharePoint sites the user has access to
107
+ */
108
+ export async function listSites(options?: {
109
+ search?: string;
110
+ limit?: number;
111
+ }): Promise<SharePointSite[]> {
112
+ let endpoint = "/sites?search=*";
113
+
114
+ if (options?.search) {
115
+ endpoint = `/sites?search=${encodeURIComponent(options.search)}`;
116
+ }
117
+
118
+ const response = await graphFetch<GraphResponse<SharePointSite>>(endpoint);
119
+ const sites = response.value || [];
120
+
121
+ if (options?.limit) {
122
+ return sites.slice(0, options.limit);
123
+ }
124
+
125
+ return sites;
126
+ }
127
+
128
+ /**
129
+ * Get details about a specific SharePoint site
130
+ */
131
+ export function getSite(siteId: string): Promise<SharePointSite> {
132
+ return graphFetch<SharePointSite>(`/sites/${siteId}`);
133
+ }
134
+
135
+ /**
136
+ * Get a site by hostname and path
137
+ */
138
+ export function getSiteByPath(
139
+ hostname: string,
140
+ sitePath: string,
141
+ ): Promise<SharePointSite> {
142
+ return graphFetch<SharePointSite>(
143
+ `/sites/${hostname}:${sitePath}`,
144
+ );
145
+ }
146
+
147
+ /**
148
+ * List all document libraries (drives) in a site
149
+ */
150
+ export async function listDrives(siteId: string): Promise<SharePointDrive[]> {
151
+ const response = await graphFetch<GraphResponse<SharePointDrive>>(
152
+ `/sites/${siteId}/drives`,
153
+ );
154
+ return response.value || [];
155
+ }
156
+
157
+ /**
158
+ * Get the default document library for a site
159
+ */
160
+ export function getDefaultDrive(siteId: string): Promise<SharePointDrive> {
161
+ return graphFetch<SharePointDrive>(`/sites/${siteId}/drive`);
162
+ }
163
+
164
+ /**
165
+ * List files and folders in a drive or folder
166
+ */
167
+ export async function listFiles(
168
+ siteId: string,
169
+ driveId: string,
170
+ folderId?: string,
171
+ options?: {
172
+ limit?: number;
173
+ orderBy?: string;
174
+ },
175
+ ): Promise<SharePointFile[]> {
176
+ let endpoint = folderId
177
+ ? `/sites/${siteId}/drives/${driveId}/items/${folderId}/children`
178
+ : `/sites/${siteId}/drives/${driveId}/root/children`;
179
+
180
+ if (options?.orderBy) {
181
+ endpoint += `?$orderby=${options.orderBy}`;
182
+ }
183
+
184
+ if (options?.limit) {
185
+ endpoint += `${options.orderBy ? "&" : "?"}$top=${options.limit}`;
186
+ }
187
+
188
+ const response = await graphFetch<GraphResponse<SharePointFile>>(endpoint);
189
+ return response.value || [];
190
+ }
191
+
192
+ /**
193
+ * Get file metadata
194
+ */
195
+ export function getFile(
196
+ siteId: string,
197
+ driveId: string,
198
+ itemId: string,
199
+ ): Promise<SharePointFile> {
200
+ return graphFetch<SharePointFile>(
201
+ `/sites/${siteId}/drives/${driveId}/items/${itemId}`,
202
+ );
203
+ }
204
+
205
+ /**
206
+ * Get file by path
207
+ */
208
+ export function getFileByPath(
209
+ siteId: string,
210
+ driveId: string,
211
+ path: string,
212
+ ): Promise<SharePointFile> {
213
+ const encodedPath = encodeURIComponent(path);
214
+ return graphFetch<SharePointFile>(
215
+ `/sites/${siteId}/drives/${driveId}/root:/${encodedPath}`,
216
+ );
217
+ }
218
+
219
+ /**
220
+ * Download file content
221
+ */
222
+ export async function downloadFile(
223
+ siteId: string,
224
+ driveId: string,
225
+ itemId: string,
226
+ ): Promise<ArrayBuffer> {
227
+ const token = await getAccessToken();
228
+ if (!token) {
229
+ throw new Error("Not authenticated with Microsoft. Please connect your account.");
230
+ }
231
+
232
+ const _metadata = await getFile(siteId, driveId, itemId);
233
+
234
+ // Get download URL
235
+ const downloadUrl = `${GRAPH_BASE_URL}/sites/${siteId}/drives/${driveId}/items/${itemId}/content`;
236
+
237
+ const response = await fetch(downloadUrl, {
238
+ headers: {
239
+ "Authorization": `Bearer ${token}`,
240
+ },
241
+ });
242
+
243
+ if (!response.ok) {
244
+ throw new Error(`Failed to download file: ${response.statusText}`);
245
+ }
246
+
247
+ return response.arrayBuffer();
248
+ }
249
+
250
+ /**
251
+ * Download file content as text
252
+ */
253
+ export async function downloadFileAsText(
254
+ siteId: string,
255
+ driveId: string,
256
+ itemId: string,
257
+ ): Promise<string> {
258
+ const buffer = await downloadFile(siteId, driveId, itemId);
259
+ return new TextDecoder().decode(buffer);
260
+ }
261
+
262
+ /**
263
+ * Upload a file to a folder
264
+ */
265
+ export async function uploadFile(
266
+ siteId: string,
267
+ driveId: string,
268
+ fileName: string,
269
+ content: string | ArrayBuffer | Blob,
270
+ folderId?: string,
271
+ ): Promise<SharePointFile> {
272
+ const token = await getAccessToken();
273
+ if (!token) {
274
+ throw new Error("Not authenticated with Microsoft. Please connect your account.");
275
+ }
276
+
277
+ const encodedFileName = encodeURIComponent(fileName);
278
+ const endpoint = folderId
279
+ ? `/sites/${siteId}/drives/${driveId}/items/${folderId}:/${encodedFileName}:/content`
280
+ : `/sites/${siteId}/drives/${driveId}/root:/${encodedFileName}:/content`;
281
+
282
+ let body: ArrayBuffer;
283
+ if (typeof content === "string") {
284
+ body = new TextEncoder().encode(content);
285
+ } else if (content instanceof Blob) {
286
+ body = await content.arrayBuffer();
287
+ } else {
288
+ body = content;
289
+ }
290
+
291
+ const response = await fetch(`${GRAPH_BASE_URL}${endpoint}`, {
292
+ method: "PUT",
293
+ headers: {
294
+ "Authorization": `Bearer ${token}`,
295
+ "Content-Type": "application/octet-stream",
296
+ },
297
+ body,
298
+ });
299
+
300
+ if (!response.ok) {
301
+ const error = await response.json().catch(() => ({}));
302
+ throw new Error(
303
+ `Failed to upload file: ${error.error?.message || response.statusText}`,
304
+ );
305
+ }
306
+
307
+ return response.json();
308
+ }
309
+
310
+ /**
311
+ * Create a folder
312
+ */
313
+ export function createFolder(
314
+ siteId: string,
315
+ driveId: string,
316
+ folderName: string,
317
+ parentFolderId?: string,
318
+ ): Promise<SharePointFile> {
319
+ const endpoint = parentFolderId
320
+ ? `/sites/${siteId}/drives/${driveId}/items/${parentFolderId}/children`
321
+ : `/sites/${siteId}/drives/${driveId}/root/children`;
322
+
323
+ return graphFetch<SharePointFile>(endpoint, {
324
+ method: "POST",
325
+ body: JSON.stringify({
326
+ name: folderName,
327
+ folder: {},
328
+ "@microsoft.graph.conflictBehavior": "rename",
329
+ }),
330
+ });
331
+ }
332
+
333
+ /**
334
+ * Search for files in a site
335
+ */
336
+ export async function searchFiles(
337
+ siteId: string,
338
+ query: string,
339
+ options?: {
340
+ limit?: number;
341
+ },
342
+ ): Promise<SharePointFile[]> {
343
+ let endpoint = `/sites/${siteId}/drive/root/search(q='${encodeURIComponent(query)}')`;
344
+
345
+ if (options?.limit) {
346
+ endpoint += `?$top=${options.limit}`;
347
+ }
348
+
349
+ const response = await graphFetch<GraphResponse<SharePointFile>>(endpoint);
350
+ return response.value || [];
351
+ }
352
+
353
+ /**
354
+ * Delete a file or folder
355
+ */
356
+ export async function deleteItem(
357
+ siteId: string,
358
+ driveId: string,
359
+ itemId: string,
360
+ ): Promise<void> {
361
+ await graphFetch<void>(
362
+ `/sites/${siteId}/drives/${driveId}/items/${itemId}`,
363
+ { method: "DELETE" },
364
+ );
365
+ }
366
+
367
+ /**
368
+ * Move or rename a file or folder
369
+ */
370
+ export function moveItem(
371
+ siteId: string,
372
+ driveId: string,
373
+ itemId: string,
374
+ newParentId: string,
375
+ newName?: string,
376
+ ): Promise<SharePointFile> {
377
+ const body: { parentReference: { id: string }; name?: string } = {
378
+ parentReference: { id: newParentId },
379
+ };
380
+
381
+ if (newName) {
382
+ body.name = newName;
383
+ }
384
+
385
+ return graphFetch<SharePointFile>(
386
+ `/sites/${siteId}/drives/${driveId}/items/${itemId}`,
387
+ {
388
+ method: "PATCH",
389
+ body: JSON.stringify(body),
390
+ },
391
+ );
392
+ }
393
+
394
+ /**
395
+ * Copy a file or folder
396
+ */
397
+ export async function copyItem(
398
+ siteId: string,
399
+ driveId: string,
400
+ itemId: string,
401
+ newParentId: string,
402
+ newName?: string,
403
+ ): Promise<void> {
404
+ const body: { parentReference: { driveId: string; id: string }; name?: string } = {
405
+ parentReference: { driveId, id: newParentId },
406
+ };
407
+
408
+ if (newName) {
409
+ body.name = newName;
410
+ }
411
+
412
+ // Copy is async, returns 202 Accepted with a Location header
413
+ await graphFetch<void>(
414
+ `/sites/${siteId}/drives/${driveId}/items/${itemId}/copy`,
415
+ {
416
+ method: "POST",
417
+ body: JSON.stringify(body),
418
+ },
419
+ );
420
+ }