@composio/core 0.6.5 → 0.6.7

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 (382) hide show
  1. package/dist/{buffer-Dy7Xi_sk.cjs → ComposioError-CYaI68Mo.cjs} +1 -63
  2. package/dist/{buffer-C1MwV-7j.mjs → ComposioError-ChkSdxqU.mjs} +3 -35
  3. package/dist/CustomTool-BlpMy_R5.d.cts +75 -0
  4. package/dist/CustomTool-C1q7Y3Nq.mjs +743 -0
  5. package/dist/CustomTool-CZZbiZgh.d.mts +75 -0
  6. package/dist/CustomTool-G2lKa7eb.cjs +1014 -0
  7. package/dist/{Telemetry-DRFfIuVS.cjs → Telemetry-A89k5RTv.cjs} +18 -17
  8. package/dist/{Telemetry-CHfDfthM.mjs → Telemetry-CjVa99gU.mjs} +2 -1
  9. package/dist/buffer-BjWptbNH.cjs +63 -0
  10. package/dist/buffer-yOtEsT4J.mjs +33 -0
  11. package/dist/{composio-BC28OAhR.d.mts → composio-CbZbGwhD.d.mts} +67 -1692
  12. package/dist/{composio-BBswEUus.d.cts → composio-Yl_Y7F6u.d.cts} +67 -1692
  13. package/dist/customTool.types-CEo_oLEU.d.mts +1860 -0
  14. package/dist/customTool.types-CzBEXJw5.d.cts +1860 -0
  15. package/dist/experimental/index.cjs +5 -0
  16. package/dist/experimental/index.d.cts +3 -0
  17. package/dist/experimental/index.d.mts +4 -0
  18. package/dist/experimental/index.mjs +5 -0
  19. package/dist/{fileUtils.node-D1JLL4nZ.mjs → fileUtils.node-BOZnseMe.mjs} +2 -1
  20. package/dist/{fileUtils.node-BUe2eO0j.cjs → fileUtils.node-DF-AY0Td.cjs} +10 -9
  21. package/dist/index.cjs +552 -715
  22. package/dist/index.d.cts +61 -43
  23. package/dist/index.d.mts +61 -43
  24. package/dist/index.mjs +366 -535
  25. package/dist/models/Files.node.cjs +3 -3
  26. package/dist/models/Files.node.d.cts +1 -1
  27. package/dist/models/Files.node.d.mts +1 -1
  28. package/dist/models/Files.node.mjs +4 -4
  29. package/dist/platform/node.d.cts +1 -1
  30. package/dist/platform/node.d.mts +1 -1
  31. package/dist/platform/workerd.d.cts +1 -1
  32. package/dist/platform/workerd.d.mts +1 -1
  33. package/dist/{BaseProvider-SxQ_komh.d.cts → tool.types-BWc7GUrD.d.cts} +10904 -10905
  34. package/dist/{BaseProvider-CaOKzzuo.d.mts → tool.types-bencsexi.d.mts} +10904 -10905
  35. package/dist/{types-DY0bIIqG.d.mts → types-C_HOnR64.d.cts} +2 -2
  36. package/dist/{types-CHz185FL.d.cts → types-e_z7dQdL.d.mts} +2 -2
  37. package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +2 -2
  38. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +4 -3
  39. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +2 -2
  40. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +4 -3
  41. package/dist/utils/modifiers/FileToolModifier.node.cjs +8 -8
  42. package/dist/utils/modifiers/FileToolModifier.node.d.cts +1 -1
  43. package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
  44. package/dist/utils/modifiers/FileToolModifier.node.mjs +4 -4
  45. package/dist/utils/modifiers/FileToolModifier.workerd.cjs +1 -1
  46. package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +1 -1
  47. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  48. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
  49. package/package.json +17 -3
  50. package/generated/ably.ts +0 -20
  51. package/generated/accelo.ts +0 -8
  52. package/generated/acculynx.ts +0 -17
  53. package/generated/active_campaign.ts +0 -30
  54. package/generated/adobe.ts +0 -8
  55. package/generated/adyntel.ts +0 -12
  56. package/generated/aero_workflow.ts +0 -8
  57. package/generated/affinity.ts +0 -29
  58. package/generated/agencyzoom.ts +0 -108
  59. package/generated/ahrefs.ts +0 -49
  60. package/generated/airtable.ts +0 -26
  61. package/generated/alchemy.ts +0 -16
  62. package/generated/algolia.ts +0 -39
  63. package/generated/altoviz.ts +0 -18
  64. package/generated/amazon.ts +0 -8
  65. package/generated/amcards.ts +0 -11
  66. package/generated/amplitude.ts +0 -25
  67. package/generated/anthropic_administrator.ts +0 -13
  68. package/generated/apaleo.ts +0 -38
  69. package/generated/apollo.ts +0 -40
  70. package/generated/appdrag.ts +0 -8
  71. package/generated/appsflyer.ts +0 -8
  72. package/generated/asana.ts +0 -95
  73. package/generated/ashby.ts +0 -8
  74. package/generated/atlassian.ts +0 -8
  75. package/generated/attio.ts +0 -20
  76. package/generated/auth0.ts +0 -8
  77. package/generated/axonaut.ts +0 -8
  78. package/generated/bamboohr.ts +0 -168
  79. package/generated/bannerbear.ts +0 -17
  80. package/generated/baserow.ts +0 -11
  81. package/generated/battlenet.ts +0 -8
  82. package/generated/beeminder.ts +0 -14
  83. package/generated/bigmailer.ts +0 -12
  84. package/generated/bigml.ts +0 -15
  85. package/generated/bill.ts +0 -218
  86. package/generated/bitbucket.ts +0 -25
  87. package/generated/bitwarden.ts +0 -8
  88. package/generated/blackbaud.ts +0 -8
  89. package/generated/blackboard.ts +0 -323
  90. package/generated/boldsign.ts +0 -8
  91. package/generated/bolna.ts +0 -24
  92. package/generated/borneo.ts +0 -162
  93. package/generated/botbaba.ts +0 -8
  94. package/generated/box.ts +0 -282
  95. package/generated/braintree.ts +0 -8
  96. package/generated/brandfetch.ts +0 -15
  97. package/generated/breezy_hr.ts +0 -8
  98. package/generated/brevo.ts +0 -28
  99. package/generated/brex.ts +0 -8
  100. package/generated/brex_staging.ts +0 -8
  101. package/generated/brightpearl.ts +0 -8
  102. package/generated/brilliant_directories.ts +0 -15
  103. package/generated/browseai.ts +0 -18
  104. package/generated/browserbase_tool.ts +0 -10
  105. package/generated/browserhub.ts +0 -8
  106. package/generated/browserless.ts +0 -16
  107. package/generated/bubble.ts +0 -8
  108. package/generated/bugbug.ts +0 -13
  109. package/generated/builtwith.ts +0 -21
  110. package/generated/cal.ts +0 -150
  111. package/generated/calendly.ts +0 -51
  112. package/generated/canva.ts +0 -41
  113. package/generated/canvas.ts +0 -100
  114. package/generated/chatwork.ts +0 -17
  115. package/generated/chmeetings.ts +0 -8
  116. package/generated/clickup.ts +0 -153
  117. package/generated/clockify.ts +0 -23
  118. package/generated/close.ts +0 -15
  119. package/generated/cloudflare.ts +0 -10
  120. package/generated/coda.ts +0 -115
  121. package/generated/codeinterpreter.ts +0 -14
  122. package/generated/coinbase.ts +0 -15
  123. package/generated/coinmarketcal.ts +0 -8
  124. package/generated/composio.ts +0 -34
  125. package/generated/composio_search.ts +0 -22
  126. package/generated/confluence.ts +0 -199
  127. package/generated/contentful.ts +0 -12
  128. package/generated/crustdata.ts +0 -23
  129. package/generated/customer_io.ts +0 -8
  130. package/generated/cutt_ly.ts +0 -10
  131. package/generated/d2lbrightspace.ts +0 -54
  132. package/generated/dailybot.ts +0 -15
  133. package/generated/datadog.ts +0 -47
  134. package/generated/datagma.ts +0 -8
  135. package/generated/datarobot.ts +0 -8
  136. package/generated/deel.ts +0 -8
  137. package/generated/demio.ts +0 -8
  138. package/generated/dialpad.ts +0 -201
  139. package/generated/digicert.ts +0 -15
  140. package/generated/discord.ts +0 -17
  141. package/generated/discordbot.ts +0 -173
  142. package/generated/docmosis.ts +0 -8
  143. package/generated/docusign.ts +0 -351
  144. package/generated/dropbox.ts +0 -20
  145. package/generated/dropbox_sign.ts +0 -8
  146. package/generated/dynamics365.ts +0 -25
  147. package/generated/echtpost.ts +0 -10
  148. package/generated/elevenlabs.ts +0 -70
  149. package/generated/emailoctopus.ts +0 -16
  150. package/generated/enigma.ts +0 -11
  151. package/generated/entelligence.ts +0 -11
  152. package/generated/epic_games.ts +0 -8
  153. package/generated/eventbrite.ts +0 -12
  154. package/generated/exa.ts +0 -13
  155. package/generated/excel.ts +0 -34
  156. package/generated/exist.ts +0 -8
  157. package/generated/facebook.ts +0 -8
  158. package/generated/factorial.ts +0 -8
  159. package/generated/figma.ts +0 -59
  160. package/generated/finage.ts +0 -19
  161. package/generated/firecrawl.ts +0 -16
  162. package/generated/fireflies.ts +0 -21
  163. package/generated/fitbit.ts +0 -8
  164. package/generated/flutterwave.ts +0 -33
  165. package/generated/fomo.ts +0 -10
  166. package/generated/formcarry.ts +0 -10
  167. package/generated/formsite.ts +0 -14
  168. package/generated/foursquare.ts +0 -14
  169. package/generated/freshbooks.ts +0 -11
  170. package/generated/freshdesk.ts +0 -16
  171. package/generated/front.ts +0 -8
  172. package/generated/github.ts +0 -967
  173. package/generated/gitlab.ts +0 -82
  174. package/generated/gmail.d.ts +0 -86
  175. package/generated/gmail.js +0 -13
  176. package/generated/gmail.ts +0 -95
  177. package/generated/go_to_webinar.ts +0 -8
  178. package/generated/gong.ts +0 -63
  179. package/generated/google_analytics.ts +0 -13
  180. package/generated/google_maps.ts +0 -16
  181. package/generated/googleads.ts +0 -14
  182. package/generated/googlebigquery.ts +0 -10
  183. package/generated/googlecalendar.ts +0 -39
  184. package/generated/googledocs.ts +0 -41
  185. package/generated/googledrive.ts +0 -62
  186. package/generated/googlemeet.ts +0 -18
  187. package/generated/googlephotos.ts +0 -22
  188. package/generated/googlesheets.ts +0 -40
  189. package/generated/googleslides.ts +0 -8
  190. package/generated/googlesuper.ts +0 -230
  191. package/generated/googletasks.ts +0 -23
  192. package/generated/gorgias.ts +0 -41
  193. package/generated/gumroad.ts +0 -14
  194. package/generated/guru.ts +0 -8
  195. package/generated/hackernews.ts +0 -15
  196. package/generated/hackerrank_work.ts +0 -8
  197. package/generated/harvest.ts +0 -56
  198. package/generated/helcim.ts +0 -8
  199. package/generated/heygen.ts +0 -44
  200. package/generated/highlevel.ts +0 -8
  201. package/generated/hubspot.ts +0 -252
  202. package/generated/humanloop.ts +0 -13
  203. package/generated/icims_talent_cloud.ts +0 -8
  204. package/generated/idea_scale.ts +0 -8
  205. package/generated/index.ts +0 -151
  206. package/generated/insighto_ai.ts +0 -19
  207. package/generated/intercom.ts +0 -52
  208. package/generated/interzoid.ts +0 -8
  209. package/generated/jira.ts +0 -59
  210. package/generated/jotform.ts +0 -15
  211. package/generated/junglescout.ts +0 -15
  212. package/generated/keap.ts +0 -8
  213. package/generated/kibana.ts +0 -58
  214. package/generated/kit.ts +0 -38
  215. package/generated/klaviyo.ts +0 -240
  216. package/generated/klipfolio.ts +0 -20
  217. package/generated/kommo.ts +0 -24
  218. package/generated/lastpass.ts +0 -8
  219. package/generated/launch_darkly.ts +0 -16
  220. package/generated/leadfeeder.ts +0 -13
  221. package/generated/leadoku.ts +0 -10
  222. package/generated/lever.ts +0 -8
  223. package/generated/lever_sandbox.ts +0 -8
  224. package/generated/lexoffice.ts +0 -8
  225. package/generated/linear.ts +0 -31
  226. package/generated/linkedin.ts +0 -13
  227. package/generated/linkhut.ts +0 -14
  228. package/generated/linkup.ts +0 -11
  229. package/generated/listennotes.ts +0 -35
  230. package/generated/lmnt.ts +0 -16
  231. package/generated/lodgify.ts +0 -10
  232. package/generated/mailchimp.ts +0 -285
  233. package/generated/mailerlite.ts +0 -8
  234. package/generated/maintainx.ts +0 -20
  235. package/generated/make.ts +0 -12
  236. package/generated/mboum.ts +0 -8
  237. package/generated/mem0.ts +0 -52
  238. package/generated/metaads.ts +0 -25
  239. package/generated/metatextai.ts +0 -8
  240. package/generated/microsoft_clarity.ts +0 -10
  241. package/generated/microsoft_teams.ts +0 -22
  242. package/generated/microsoft_tenant.ts +0 -8
  243. package/generated/miro.ts +0 -23
  244. package/generated/mixpanel.ts +0 -30
  245. package/generated/mocean.ts +0 -8
  246. package/generated/monday.ts +0 -30
  247. package/generated/mopinion.ts +0 -8
  248. package/generated/more_trees.ts +0 -10
  249. package/generated/moxie.ts +0 -8
  250. package/generated/moz.ts +0 -8
  251. package/generated/mural.ts +0 -14
  252. package/generated/nasdaq.ts +0 -15
  253. package/generated/ncscale.ts +0 -8
  254. package/generated/neon.ts +0 -78
  255. package/generated/netsuite.ts +0 -8
  256. package/generated/nextdns.ts +0 -11
  257. package/generated/ngrok.ts +0 -18
  258. package/generated/notion.ts +0 -40
  259. package/generated/oncehub.ts +0 -8
  260. package/generated/one_drive.ts +0 -49
  261. package/generated/onepage.ts +0 -11
  262. package/generated/open_sea.ts +0 -33
  263. package/generated/outlook.ts +0 -37
  264. package/generated/pagerduty.ts +0 -362
  265. package/generated/pandadoc.ts +0 -23
  266. package/generated/peopledatalabs.ts +0 -24
  267. package/generated/perplexityai.ts +0 -10
  268. package/generated/piggy.ts +0 -8
  269. package/generated/pipedrive.ts +0 -288
  270. package/generated/placekey.ts +0 -12
  271. package/generated/posthog.ts +0 -367
  272. package/generated/precoro.ts +0 -8
  273. package/generated/printnode.ts +0 -8
  274. package/generated/process_street.ts +0 -14
  275. package/generated/productboard.ts +0 -8
  276. package/generated/qualaroo.ts +0 -8
  277. package/generated/quickbooks.ts +0 -22
  278. package/generated/rafflys.ts +0 -8
  279. package/generated/ragic.ts +0 -10
  280. package/generated/ramp.ts +0 -17
  281. package/generated/ravenseotools.ts +0 -8
  282. package/generated/recallai.ts +0 -17
  283. package/generated/reddit.ts +0 -19
  284. package/generated/resend.ts +0 -27
  285. package/generated/retellai.ts +0 -19
  286. package/generated/retently.ts +0 -24
  287. package/generated/ring_central.ts +0 -8
  288. package/generated/rippling.ts +0 -8
  289. package/generated/rocket_reach.ts +0 -8
  290. package/generated/rocketlane.ts +0 -42
  291. package/generated/rootly.ts +0 -12
  292. package/generated/rosette_text_analytics.ts +0 -12
  293. package/generated/sage.ts +0 -8
  294. package/generated/salesforce.ts +0 -46
  295. package/generated/scrape_do.ts +0 -28
  296. package/generated/scrapingant.ts +0 -14
  297. package/generated/screenshotone.ts +0 -10
  298. package/generated/seismic.ts +0 -8
  299. package/generated/semanticscholar.ts +0 -23
  300. package/generated/semrush.ts +0 -45
  301. package/generated/sendgrid.ts +0 -384
  302. package/generated/sentry.ts +0 -185
  303. package/generated/serpapi.ts +0 -32
  304. package/generated/servicem8.ts +0 -37
  305. package/generated/servicenow.ts +0 -14
  306. package/generated/share_point.ts +0 -15
  307. package/generated/shopify.ts +0 -37
  308. package/generated/shortcut.ts +0 -131
  309. package/generated/simplesat.ts +0 -11
  310. package/generated/slack.d.ts +0 -16
  311. package/generated/slack.js +0 -11
  312. package/generated/slack.ts +0 -24
  313. package/generated/slackbot.ts +0 -205
  314. package/generated/smartrecruiters.ts +0 -8
  315. package/generated/smugmug.ts +0 -14
  316. package/generated/snowflake.ts +0 -15
  317. package/generated/sourcegraph.ts +0 -16
  318. package/generated/square.ts +0 -8
  319. package/generated/stack_exchange.ts +0 -17
  320. package/generated/starton.ts +0 -11
  321. package/generated/storeganise.ts +0 -12
  322. package/generated/stripe.ts +0 -50
  323. package/generated/supabase.ts +0 -86
  324. package/generated/survey_monkey.ts +0 -8
  325. package/generated/tally.ts +0 -25
  326. package/generated/tapfiliate.ts +0 -11
  327. package/generated/tapform.ts +0 -8
  328. package/generated/tavily.ts +0 -10
  329. package/generated/terminus.ts +0 -8
  330. package/generated/text_to_pdf.ts +0 -10
  331. package/generated/textrazor.ts +0 -22
  332. package/generated/timecamp.ts +0 -10
  333. package/generated/timekit.ts +0 -8
  334. package/generated/timely.ts +0 -11
  335. package/generated/tinypng.ts +0 -15
  336. package/generated/tinyurl.ts +0 -10
  337. package/generated/tisane.ts +0 -15
  338. package/generated/todoist.ts +0 -19
  339. package/generated/toneden.ts +0 -8
  340. package/generated/tpscheck.ts +0 -10
  341. package/generated/trello.ts +0 -360
  342. package/generated/twitch.ts +0 -8
  343. package/generated/twitter.ts +0 -82
  344. package/generated/twitter_media.ts +0 -10
  345. package/generated/typefully.ts +0 -14
  346. package/generated/venly.ts +0 -8
  347. package/generated/vero.ts +0 -8
  348. package/generated/visme.ts +0 -8
  349. package/generated/waboxapp.ts +0 -8
  350. package/generated/wakatime.ts +0 -8
  351. package/generated/wave_accounting.ts +0 -8
  352. package/generated/weathermap.ts +0 -10
  353. package/generated/webex.ts +0 -37
  354. package/generated/webflow.ts +0 -30
  355. package/generated/whatsapp.ts +0 -14
  356. package/generated/wiz.ts +0 -8
  357. package/generated/workiom.ts +0 -12
  358. package/generated/wrike.ts +0 -47
  359. package/generated/xero.ts +0 -13
  360. package/generated/yandex.ts +0 -13
  361. package/generated/ynab.ts +0 -8
  362. package/generated/yousearch.ts +0 -10
  363. package/generated/youtube.ts +0 -26
  364. package/generated/zendesk.ts +0 -23
  365. package/generated/zenrows.ts +0 -25
  366. package/generated/zenserp.ts +0 -20
  367. package/generated/zoho.ts +0 -33
  368. package/generated/zoho_bigin.ts +0 -21
  369. package/generated/zoho_books.ts +0 -8
  370. package/generated/zoho_desk.ts +0 -8
  371. package/generated/zoho_inventory.ts +0 -8
  372. package/generated/zoho_invoice.ts +0 -15
  373. package/generated/zoho_mail.ts +0 -8
  374. package/generated/zoom.ts +0 -181
  375. package/generated/zoominfo.ts +0 -26
  376. /package/dist/{FileToolModifier.utils.neutral-BN_L8usp.mjs → FileToolModifier.utils.neutral-BcIR-cVE.mjs} +0 -0
  377. /package/dist/{FileToolModifier.utils.neutral-Bcl7LVf4.cjs → FileToolModifier.utils.neutral-BdMpiyie.cjs} +0 -0
  378. /package/dist/{chunk-Dx2NuYGI.mjs → chunk-CWQeghP5.mjs} +0 -0
  379. /package/dist/{files.types-BDqIUdfP.d.mts → files.types-BXDWA_zS.d.mts} +0 -0
  380. /package/dist/{files.types-nK6eTNnc.d.cts → files.types-lo4zZd87.d.cts} +0 -0
  381. /package/dist/{types-BF2OQZRP.d.cts → types-CXR6l5Sj.d.mts} +0 -0
  382. /package/dist/{types-Cvt_yFsu.d.mts → types-DiL6FAZi.d.cts} +0 -0
@@ -0,0 +1,743 @@
1
+ import { t as ComposioError$1 } from "./ComposioError-ChkSdxqU.mjs";
2
+ import { APIError } from "@composio/client";
3
+ import { ZodError, z as z$1 } from "zod/v3";
4
+ import * as zodToJsonSchema from "zod-to-json-schema";
5
+
6
+ //#region src/errors/ConnectedAccountsErrors.ts
7
+ const ConnectedAccountErrorCodes = {
8
+ CONNECTED_ACCOUNT_NOT_FOUND: "CONNECTED_ACCOUNT_NOT_FOUND",
9
+ MULTIPLE_CONNECTED_ACCOUNTS: "MULTIPLE_CONNECTED_ACCOUNTS",
10
+ FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK: "FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK"
11
+ };
12
+ var ComposioConnectedAccountNotFoundError = class extends ComposioError$1 {
13
+ constructor(message = "Connected account not found", options = {}) {
14
+ super(message, {
15
+ ...options,
16
+ code: ConnectedAccountErrorCodes.CONNECTED_ACCOUNT_NOT_FOUND,
17
+ statusCode: 404,
18
+ possibleFixes: options.possibleFixes || ["Ensure the connected account exists and is active in your Composio dashboard"]
19
+ });
20
+ this.name = "ComposioConnectedAccountNotFoundError";
21
+ }
22
+ };
23
+ var ComposioMultipleConnectedAccountsError = class extends ComposioError$1 {
24
+ constructor(message = "Multiple connected accounts found", options = {}) {
25
+ super(message, {
26
+ ...options,
27
+ code: ConnectedAccountErrorCodes.MULTIPLE_CONNECTED_ACCOUNTS,
28
+ possibleFixes: options.possibleFixes || ["Use the allowMultiple flag to allow multiple connected accounts per user for an auth config"]
29
+ });
30
+ this.name = "ComposioMultipleConnectedAccountsError";
31
+ }
32
+ };
33
+ var ComposioFailedToCreateConnectedAccountLink = class extends ComposioError$1 {
34
+ constructor(message = "Failed to create connected account link", options = {}) {
35
+ super(message, {
36
+ ...options,
37
+ code: ConnectedAccountErrorCodes.FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK
38
+ });
39
+ this.name = "ComposioFailedToCreateConnectedAccountLink";
40
+ }
41
+ };
42
+
43
+ //#endregion
44
+ //#region src/errors/ToolErrors.ts
45
+ const ToolErrorCodes = {
46
+ TOOLSET_NOT_DEFINED: "TOOLSET_NOT_DEFINED",
47
+ TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
48
+ INVALID_MODIFIER: "INVALID_MODIFIER",
49
+ CUSTOM_TOOLS_NOT_INITIALIZED: "CUSTOM_TOOLS_NOT_INITIALIZED",
50
+ TOOL_EXECUTION_ERROR: "TOOL_EXECUTION_ERROR",
51
+ INVALID_EXECUTE_FUNCTION: "INVALID_EXECUTE_FUNCTION",
52
+ GLOBAL_EXECUTE_TOOL_FN_NOT_SET: "GLOBAL_EXECUTE_TOOL_FN_NOT_SET",
53
+ TOOL_VERSION_REQUIRED: "TOOL_VERSION_REQUIRED"
54
+ };
55
+ var ComposioProviderNotDefinedError = class extends ComposioError$1 {
56
+ constructor(message = "Provider not defined", options = {}) {
57
+ super(message, {
58
+ ...options,
59
+ code: ToolErrorCodes.TOOLSET_NOT_DEFINED,
60
+ possibleFixes: options.possibleFixes || ["Ensure that the provider is defined in the Composio project and passed into the tool instance"]
61
+ });
62
+ this.name = "ComposioProviderNotDefinedError";
63
+ }
64
+ };
65
+ var ComposioToolNotFoundError = class extends ComposioError$1 {
66
+ constructor(message = "Tool not found", options = {}) {
67
+ super(message, {
68
+ ...options,
69
+ code: ToolErrorCodes.TOOL_NOT_FOUND,
70
+ possibleFixes: options.possibleFixes || ["Ensure the tool slug is correct and exists in the Composio project"]
71
+ });
72
+ this.name = "ComposioToolNotFoundError";
73
+ }
74
+ };
75
+ var ComposioInvalidModifierError = class extends ComposioError$1 {
76
+ constructor(message = "Invalid modifier", options = {}) {
77
+ super(message, {
78
+ ...options,
79
+ code: ToolErrorCodes.INVALID_MODIFIER,
80
+ possibleFixes: options.possibleFixes || ["Ensure the modifier is a function and returns a valid result"]
81
+ });
82
+ this.name = "ComposioInvalidModifierError";
83
+ }
84
+ };
85
+ var ComposioCustomToolsNotInitializedError = class extends ComposioError$1 {
86
+ constructor(message = "Custom tools not initialized", options = {}) {
87
+ super(message, {
88
+ ...options,
89
+ code: ToolErrorCodes.CUSTOM_TOOLS_NOT_INITIALIZED,
90
+ possibleFixes: options.possibleFixes || ["Ensure the custom tools class is initialized in the Tools instance"]
91
+ });
92
+ this.name = "ComposioCustomToolsNotInitializedError";
93
+ }
94
+ };
95
+ var ComposioToolExecutionError = class extends ComposioError$1 {
96
+ constructor(message = "Tool execution error", options = {}) {
97
+ super(message, {
98
+ ...options,
99
+ code: options.code || ToolErrorCodes.TOOL_EXECUTION_ERROR,
100
+ cause: options.cause,
101
+ possibleFixes: options.possibleFixes || ["Ensure the tool is correctly configured and the input is valid", "Ensure the userId is correct and has an active connected account for the user in case of non NoAuth toolkits"]
102
+ });
103
+ this.name = "ComposioToolExecutionError";
104
+ }
105
+ };
106
+ var ComposioInvalidExecuteFunctionError = class extends ComposioError$1 {
107
+ constructor(message = "Invalid execute function", options = {}) {
108
+ super(message, {
109
+ ...options,
110
+ code: ToolErrorCodes.INVALID_EXECUTE_FUNCTION,
111
+ possibleFixes: options.possibleFixes || ["Ensure the execute function is a valid function and returns a valid result"]
112
+ });
113
+ this.name = "ComposioInvalidExecuteFunctionError";
114
+ }
115
+ };
116
+ var ComposioGlobalExecuteToolFnNotSetError = class extends ComposioError$1 {
117
+ constructor(message = "Global execute tool function not set", options = {}) {
118
+ super(message, {
119
+ ...options,
120
+ code: ToolErrorCodes.GLOBAL_EXECUTE_TOOL_FN_NOT_SET,
121
+ possibleFixes: options.possibleFixes || ["Ensure the global execute tool function is set in the provider"]
122
+ });
123
+ this.name = "ComposioGlobalExecuteToolFnNotSetError";
124
+ }
125
+ };
126
+ /**
127
+ * Error thrown when toolkit version is not specified for manual tool execution.
128
+ *
129
+ * This error is thrown when attempting to execute a tool manually (via `tools.execute()`)
130
+ * and the resolved version is "latest" without `dangerouslySkipVersionCheck` set to true.
131
+ *
132
+ * **Why this error exists:**
133
+ * Using "latest" version in manual execution can lead to unexpected behavior when new
134
+ * toolkit versions are released, potentially breaking your application. For production
135
+ * use, it's recommended to pin specific toolkit versions.
136
+ *
137
+ * **How to fix:**
138
+ * 1. Specify a concrete version in the execute call
139
+ * 2. Configure toolkit versions at SDK initialization
140
+ * 3. Set toolkit version via environment variable
141
+ * 4. Use dangerouslySkipVersionCheck (not recommended for production)
142
+ *
143
+ * @example ❌ This will throw ComposioToolVersionRequiredError if toolkitVersions is 'latest'
144
+ * ```typescript
145
+ * await composio.tools.execute('GITHUB_GET_REPOS', {
146
+ * userId: 'default',
147
+ * arguments: { owner: 'composio' }
148
+ * });
149
+ * ```
150
+ *
151
+ * @example ✅ Fix 1: Pass specific version in execute call
152
+ * ```typescript
153
+ * await composio.tools.execute('GITHUB_GET_REPOS', {
154
+ * userId: 'default',
155
+ * version: '20250909_00',
156
+ * arguments: { owner: 'composio' }
157
+ * });
158
+ * ```
159
+ *
160
+ * @example ✅ Fix 2: Configure toolkit versions at SDK level
161
+ * ```typescript
162
+ * const composio = new Composio({
163
+ * toolkitVersions: { github: '20250909_00' }
164
+ * });
165
+ * await composio.tools.execute('GITHUB_GET_REPOS', {
166
+ * userId: 'default',
167
+ * arguments: { owner: 'composio' }
168
+ * });
169
+ * ```
170
+ *
171
+ * @example ✅ Fix 3: Use environment variable
172
+ * ```typescript
173
+ * // Set: COMPOSIO_TOOLKIT_VERSION_GITHUB=20250909_00
174
+ * await composio.tools.execute('GITHUB_GET_REPOS', {
175
+ * userId: 'default',
176
+ * arguments: { owner: 'composio' }
177
+ * });
178
+ * ```
179
+ *
180
+ * @example ⚠️ Fix 4: Skip version check (not recommended for production)
181
+ * ```typescript
182
+ * await composio.tools.execute('GITHUB_GET_REPOS', {
183
+ * userId: 'default',
184
+ * dangerouslySkipVersionCheck: true,
185
+ * arguments: { owner: 'composio' }
186
+ * });
187
+ * ```
188
+ */
189
+ var ComposioToolVersionRequiredError = class extends ComposioError$1 {
190
+ constructor(message = "Toolkit version not specified. For manual execution of the tool please pass a specific toolkit version", options = {}) {
191
+ super(message, {
192
+ ...options,
193
+ code: ToolErrorCodes.TOOL_VERSION_REQUIRED,
194
+ possibleFixes: options.possibleFixes || [
195
+ "Pass the toolkit version as a parameter to the execute function (\"latest\" is not supported in manual execution)",
196
+ "Set the toolkit versions in the Composio config (toolkitVersions: { <toolkit-slug>: \"<toolkit-version>\" })",
197
+ "Set the toolkit version in the environment variable (COMPOSIO_TOOLKIT_VERSION_<TOOLKIT_SLUG>)",
198
+ "Set dangerouslySkipVersionCheck to true (this might cause unexpected behavior when new versions of the tools are released)"
199
+ ]
200
+ });
201
+ }
202
+ };
203
+ const ERROR_CODE_HANDLERS = new Map([[1803, (msg) => new ComposioConnectedAccountNotFoundError(msg)]]);
204
+ const handleToolExecutionError = (tool, actualError) => {
205
+ if (actualError instanceof APIError && actualError.error) {
206
+ const errorBody = actualError.error;
207
+ const errorCode = errorBody?.error?.code;
208
+ const errorMessage = errorBody?.error?.message;
209
+ if (errorCode && ERROR_CODE_HANDLERS.has(errorCode)) return ERROR_CODE_HANDLERS.get(errorCode)(errorMessage || "An error occurred");
210
+ }
211
+ return new ComposioToolExecutionError(`Error executing the tool ${tool}`, {
212
+ cause: actualError,
213
+ possibleFixes: ["Ensure the tool slug is correct and the input arguments for the tool is valid"]
214
+ });
215
+ };
216
+
217
+ //#endregion
218
+ //#region src/errors/AuthConfigErrors.ts
219
+ const AuthConfigErrorCodes = { AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND" };
220
+ var ComposioAuthConfigNotFoundError = class extends ComposioError$1 {
221
+ constructor(message = "Auth config not found", options = {}) {
222
+ super(message, {
223
+ ...options,
224
+ code: AuthConfigErrorCodes.AUTH_CONFIG_NOT_FOUND,
225
+ possibleFixes: options.possibleFixes || [
226
+ "Check if the auth config exists",
227
+ "Check if the auth config id is correct",
228
+ "Check if the auth config is enabled"
229
+ ]
230
+ });
231
+ this.name = "ComposioAuthConfigNotFoundError";
232
+ }
233
+ };
234
+
235
+ //#endregion
236
+ //#region src/errors/ConnectionRequestErrors.ts
237
+ const ConnectionRequestErrorCodes = {
238
+ CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
239
+ CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
240
+ };
241
+ var ConnectionRequestTimeoutError = class extends ComposioError$1 {
242
+ constructor(message = "Connection request timed out", options = {}) {
243
+ super(message, {
244
+ ...options,
245
+ code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_TIMEOUT
246
+ });
247
+ this.name = "ConnectionRequestTimeoutError";
248
+ }
249
+ };
250
+ var ConnectionRequestFailedError = class extends ComposioError$1 {
251
+ constructor(message = "Connection request failed", options = {}) {
252
+ super(message, {
253
+ ...options,
254
+ code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_FAILED
255
+ });
256
+ this.name = "ConnectionRequestFailedError";
257
+ }
258
+ };
259
+
260
+ //#endregion
261
+ //#region src/errors/ToolkitErrors.ts
262
+ const ToolkitErrorCodes = { TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND" };
263
+ var ComposioToolkitNotFoundError = class extends ComposioError$1 {
264
+ constructor(message = "Toolkit not found", options = {}) {
265
+ super(message, {
266
+ ...options,
267
+ code: "TOOLKIT_NOT_FOUND",
268
+ possibleFixes: options.possibleFixes || ["Ensure the toolkit is correctly configured and the slug is valid"]
269
+ });
270
+ this.name = "ComposioToolkitNotFoundError";
271
+ }
272
+ };
273
+ var ComposioToolkitFetchError = class extends ComposioError$1 {
274
+ constructor(message = "Failed to fetch toolkit", options = {}) {
275
+ super(message, {
276
+ ...options,
277
+ code: "TOOLKIT_FETCH_ERROR",
278
+ possibleFixes: options.possibleFixes || [
279
+ "Ensure the toolkit slug is valid",
280
+ "Ensure you are using the correct API key",
281
+ "Ensure you are using the correct API endpoint / Base URL and it is working"
282
+ ]
283
+ });
284
+ this.name = "ComposioToolkitFetchError";
285
+ }
286
+ };
287
+
288
+ //#endregion
289
+ //#region src/errors/ValidationErrors.ts
290
+ /**
291
+ * Represents an input validation error using Zod.
292
+ */
293
+ const ValidationErrorCodes = {
294
+ VALIDATION_ERROR: "VALIDATION_ERROR",
295
+ JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
296
+ };
297
+ var ValidationError = class extends ComposioError$1 {
298
+ constructor(message = "Input validation failed", options = {}) {
299
+ const { cause: providedZodError, ...restOptions } = options;
300
+ let zodErrorInstance;
301
+ if (providedZodError instanceof ZodError) zodErrorInstance = providedZodError;
302
+ else zodErrorInstance = new ZodError([{
303
+ path: [],
304
+ message: "Invalid input",
305
+ code: "custom"
306
+ }]);
307
+ const issues = zodErrorInstance.issues.map((issue) => `[${issue.code}] ${issue.path.join(".")} - ${issue.message}`);
308
+ super(message, {
309
+ ...restOptions,
310
+ code: options.code || ValidationErrorCodes.VALIDATION_ERROR,
311
+ possibleFixes: issues,
312
+ cause: zodErrorInstance
313
+ });
314
+ this.name = "ValidationError";
315
+ this.message = `${message}: ${this.generateUserFriendlyMessage()}`;
316
+ }
317
+ generateUserFriendlyMessage() {
318
+ if (this.cause instanceof ZodError && this.cause.issues.length > 0) {
319
+ const issue = this.cause.issues[0];
320
+ const param = issue.path.join(".") || "parameter";
321
+ if (issue.code === "invalid_type") return `The ${param} should be a ${issue.expected}, but you provided a ${issue.received}`;
322
+ return issue.message;
323
+ }
324
+ return "Please check your input parameters";
325
+ }
326
+ };
327
+ var JsonSchemaToZodError = class extends ComposioError$1 {
328
+ constructor(message = "Failed to convert JSON schema to Zod schema", options = {}) {
329
+ super(message, {
330
+ ...options,
331
+ code: options.code || ValidationErrorCodes.JSON_SCHEMA_TO_ZOD_ERROR
332
+ });
333
+ }
334
+ };
335
+
336
+ //#endregion
337
+ //#region src/errors/SDKErrors.ts
338
+ const SDKErrorCodes = { NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED" };
339
+ var ComposioNoAPIKeyError = class extends ComposioError$1 {
340
+ constructor(message = "No Composio API key provided", options = {}) {
341
+ const defaultCause = "Couldn't find an API key in the params, environment variables or in the user config file";
342
+ super(message, {
343
+ ...options,
344
+ code: SDKErrorCodes.NO_API_KEY_PROVIDED,
345
+ cause: options.cause || defaultCause,
346
+ possibleFixes: options.possibleFixes || [
347
+ "Ensure you have an API key passed in the params, or in environment variable (COMPOSIO_API_KEY) or in the user config file",
348
+ "To get an API key, please sign up at https://composio.dev/signup",
349
+ "You can also use the Composio CLI to create a project and get an API key"
350
+ ],
351
+ statusCode: 401
352
+ });
353
+ this.name = "ComposioNoAPIKeyError";
354
+ }
355
+ };
356
+
357
+ //#endregion
358
+ //#region src/errors/TriggerErrors.ts
359
+ const TriggerErrorCodes = {
360
+ TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS: "TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS",
361
+ TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT: "TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT",
362
+ TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL: "TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL",
363
+ TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL: "TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL",
364
+ TRIGGER_TYPE_NOT_FOUND: "TRIGGER_TYPE_NOT_FOUND",
365
+ WEBHOOK_SIGNATURE_VERIFICATION_FAILED: "WEBHOOK_SIGNATURE_VERIFICATION_FAILED",
366
+ WEBHOOK_PAYLOAD_INVALID: "WEBHOOK_PAYLOAD_INVALID"
367
+ };
368
+ var ComposioFailedToGetSDKRealtimeCredentialsError = class extends ComposioError$1 {
369
+ constructor(message = "Failed to get SDK realtime credentials", options = {}) {
370
+ super(message, {
371
+ ...options,
372
+ code: TriggerErrorCodes.TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS,
373
+ possibleFixes: options.possibleFixes || ["Please contact support."]
374
+ });
375
+ this.name = "ComposioFailedToGetSDKRealtimeCredentialsError";
376
+ }
377
+ };
378
+ var ComposioFailedToCreatePusherClientError = class extends ComposioError$1 {
379
+ constructor(message = "Failed to create Pusher client", options = {}) {
380
+ super(message, {
381
+ ...options,
382
+ code: TriggerErrorCodes.TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT,
383
+ possibleFixes: options.possibleFixes || ["Please contact support."]
384
+ });
385
+ this.name = "ComposioFailedToCreatePusherClientError";
386
+ }
387
+ };
388
+ var ComposioFailedToSubscribeToPusherChannelError = class extends ComposioError$1 {
389
+ constructor(message = "Failed to subscribe to Pusher channel", options = {}) {
390
+ super(message, {
391
+ ...options,
392
+ code: TriggerErrorCodes.TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL,
393
+ possibleFixes: options.possibleFixes || ["Please contact support."]
394
+ });
395
+ this.name = "ComposioFailedToSubscribeToPusherChannelError";
396
+ }
397
+ };
398
+ var ComposioFailedToUnsubscribeFromPusherChannelError = class extends ComposioError$1 {
399
+ constructor(message = "Failed to unsubscribe from Pusher channel", options = {}) {
400
+ super(message, {
401
+ ...options,
402
+ code: TriggerErrorCodes.TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL,
403
+ possibleFixes: options.possibleFixes || ["Please contact support."]
404
+ });
405
+ this.name = "ComposioFailedToUnsubscribeFromPusherChannelError";
406
+ }
407
+ };
408
+ var ComposioTriggerTypeNotFoundError = class extends ComposioError$1 {
409
+ constructor(message = "Trigger type not found", options = {}) {
410
+ super(message, {
411
+ ...options,
412
+ code: TriggerErrorCodes.TRIGGER_TYPE_NOT_FOUND,
413
+ statusCode: 404,
414
+ possibleFixes: options.possibleFixes || ["Please contact support."]
415
+ });
416
+ this.name = "ComposioTriggerTypeNotFoundError";
417
+ }
418
+ };
419
+ var ComposioWebhookSignatureVerificationError = class extends ComposioError$1 {
420
+ constructor(message = "Webhook signature verification failed", options = {}) {
421
+ super(message, {
422
+ ...options,
423
+ code: TriggerErrorCodes.WEBHOOK_SIGNATURE_VERIFICATION_FAILED,
424
+ statusCode: 401,
425
+ possibleFixes: options.possibleFixes || [
426
+ "Verify that the webhook secret is correct.",
427
+ "Ensure the raw request body is passed without modifications.",
428
+ "Check that the signature header value is being passed correctly."
429
+ ]
430
+ });
431
+ this.name = "ComposioWebhookSignatureVerificationError";
432
+ }
433
+ };
434
+ var ComposioWebhookPayloadError = class extends ComposioError$1 {
435
+ constructor(message = "Invalid webhook payload", options = {}) {
436
+ super(message, {
437
+ ...options,
438
+ code: TriggerErrorCodes.WEBHOOK_PAYLOAD_INVALID,
439
+ statusCode: 400,
440
+ possibleFixes: options.possibleFixes || ["Ensure the webhook payload is valid JSON.", "Verify the payload structure matches the expected format."]
441
+ });
442
+ this.name = "ComposioWebhookPayloadError";
443
+ }
444
+ };
445
+
446
+ //#endregion
447
+ //#region src/errors/RemoteFileErrors.ts
448
+ const RemoteFileErrorCodes = { DOWNLOAD_FAILED: "REMOTE_FILE_DOWNLOAD_FAILED" };
449
+ /**
450
+ * Error thrown when fetching a remote file from a tool router session mount fails.
451
+ * Includes HTTP status, URL, and file path context for debugging.
452
+ */
453
+ var RemoteFileDownloadError = class extends ComposioError$1 {
454
+ constructor(message = "Failed to download remote file", options = {}) {
455
+ const { statusCode, statusText, downloadUrl, mountRelativePath, filename, meta: optionsMeta, ...rest } = options;
456
+ const meta = {
457
+ ...optionsMeta,
458
+ ...statusCode !== void 0 && { statusCode },
459
+ ...statusText && { statusText },
460
+ ...downloadUrl && { downloadUrl },
461
+ ...mountRelativePath && { mountRelativePath },
462
+ ...filename && { filename }
463
+ };
464
+ super(message, {
465
+ ...rest,
466
+ code: RemoteFileErrorCodes.DOWNLOAD_FAILED,
467
+ statusCode,
468
+ meta: Object.keys(meta).length > 0 ? meta : void 0,
469
+ possibleFixes: options.possibleFixes ?? [
470
+ "Verify the download URL has not expired (check expiresAt)",
471
+ "Ensure the file exists at the specified mount path",
472
+ "Retry the operation; presigned URLs may have transient failures"
473
+ ]
474
+ });
475
+ this.name = "RemoteFileDownloadError";
476
+ }
477
+ };
478
+
479
+ //#endregion
480
+ //#region src/types/customTool.types.ts
481
+ /**
482
+ * Zod schema for validating a custom tool slug.
483
+ * Alphanumeric, underscores, and hyphens only. No `LOCAL_` or `COMPOSIO_` prefix.
484
+ * Length is validated contextually (standalone vs extension vs toolkit) at creation time.
485
+ */
486
+ const CustomToolSlugSchema = z$1.string().min(1, "slug is required").regex(/^[A-Za-z0-9_-]+$/, "slug must only contain alphanumeric characters, underscores, and hyphens").refine((s) => !s.toUpperCase().startsWith("LOCAL_"), { message: "slug must not start with \"LOCAL_\" — this prefix is reserved for internal routing." }).refine((s) => !s.toUpperCase().startsWith("COMPOSIO_"), { message: "slug must not start with \"COMPOSIO_\" — this prefix is reserved for Composio meta tools." });
487
+ /**
488
+ * Zod schema for validating the string/scalar fields of createCustomTool() options.
489
+ * Slug is validated separately as the first argument.
490
+ * Used internally for validation — inputParams, outputParams, and execute are checked manually.
491
+ */
492
+ const CreateCustomToolBaseSchema = z$1.object({
493
+ name: z$1.string().min(1, "createCustomTool: name is required"),
494
+ description: z$1.string().min(1, "createCustomTool: description is required"),
495
+ extendsToolkit: z$1.string().optional()
496
+ });
497
+ /**
498
+ * Zod schema for validating the string/scalar fields of createCustomToolkit() options.
499
+ * Slug is validated separately as the first argument.
500
+ */
501
+ const CreateCustomToolkitBaseSchema = z$1.object({
502
+ name: z$1.string().min(1, "createCustomToolkit: name is required"),
503
+ description: z$1.string().min(1, "createCustomToolkit: description is required")
504
+ });
505
+
506
+ //#endregion
507
+ //#region src/models/CustomTool.ts
508
+ /**
509
+ * @fileoverview Factory functions for creating custom tools and toolkits.
510
+ *
511
+ * Usage:
512
+ * ```typescript
513
+ * import { experimental_createTool, experimental_createToolkit } from '@composio/core';
514
+ *
515
+ * const grep = createCustomTool('GREP', {
516
+ * name: 'Grep Search',
517
+ * description: 'Search for patterns in files',
518
+ * inputParams: z.object({ pattern: z.string() }),
519
+ * execute: async (input) => ({ matches: [] }),
520
+ * });
521
+ *
522
+ * const devTools = createCustomToolkit('DEV_TOOLS', {
523
+ * name: 'Dev Tools',
524
+ * description: 'Local dev utilities',
525
+ * tools: [grep],
526
+ * });
527
+ * ```
528
+ */
529
+ /** Prefix applied by the backend to local tool slugs for disambiguation. */
530
+ const LOCAL_TOOL_PREFIX = "LOCAL_";
531
+ /** Maximum allowed length for the final prefixed slug. */
532
+ const MAX_SLUG_LENGTH = 60;
533
+ /**
534
+ * Compute the final slug length for a tool given its context.
535
+ * Returns the expected length of LOCAL_[TOOLKIT_]SLUG.
536
+ */
537
+ function computeFinalSlugLength(toolSlug, toolkitSlug) {
538
+ return 6 + (toolkitSlug ? toolkitSlug.length + 1 : 0) + toolSlug.length;
539
+ }
540
+ /**
541
+ * Validate that the final slug won't exceed the max length.
542
+ * Called early in createCustomTool/createCustomToolkit for fast feedback.
543
+ */
544
+ function validateSlugLength(toolSlug, toolkitSlug, context) {
545
+ const finalLength = computeFinalSlugLength(toolSlug, toolkitSlug);
546
+ if (finalLength > MAX_SLUG_LENGTH) {
547
+ const prefix = LOCAL_TOOL_PREFIX + (toolkitSlug ? `${toolkitSlug.toUpperCase()}_` : "");
548
+ throw new ValidationError(`${context}: slug "${toolSlug}" is too long. With prefix "${prefix}", the final slug would be ${finalLength} characters (max ${MAX_SLUG_LENGTH}). Shorten the slug to at most ${MAX_SLUG_LENGTH - prefix.length} characters.`);
549
+ }
550
+ }
551
+ /**
552
+ * Create a custom tool for use in tool router sessions.
553
+ *
554
+ * The returned object is a lightweight reference containing the tool's metadata
555
+ * and execute function. Pass it to `composio.create(userId, { experimental: { customTools: [...] } })`
556
+ * to bind it to a session.
557
+ *
558
+ * Just return the result data from `execute`, or throw an error.
559
+ * The SDK wraps it into the standard response format internally.
560
+ *
561
+ * **Slug naming:** The slug you provide is automatically prefixed with `LOCAL_` when
562
+ * exposed to the agent (e.g. `'GREP'` becomes `LOCAL_GREP`). If the tool is inside a
563
+ * custom toolkit, the toolkit slug is also included (e.g. `LOCAL_DEV_TOOLS_GREP`).
564
+ * The `LOCAL_` prefix is reserved and cannot be used in your slug.
565
+ *
566
+ * @param slug - Unique tool identifier (alphanumeric, underscores, hyphens; no LOCAL_ or COMPOSIO_ prefix)
567
+ * @param options - Tool definition including name, schema, and execute function
568
+ * @returns A CustomTool to pass to session creation
569
+ *
570
+ * @example Standalone tool (no auth)
571
+ * ```typescript
572
+ * const grep = createCustomTool('GREP', {
573
+ * name: 'Grep Search',
574
+ * description: 'Search for patterns in files',
575
+ * inputParams: z.object({ pattern: z.string(), path: z.string() }),
576
+ * execute: async (input) => ({ matches: [] }),
577
+ * });
578
+ * ```
579
+ *
580
+ * @example Tool extending a Composio toolkit (inherits auth)
581
+ * ```typescript
582
+ * const getImportant = createCustomTool('GET_IMPORTANT_EMAILS', {
583
+ * name: 'Get Important Emails',
584
+ * description: 'Fetch high-priority emails',
585
+ * extendsToolkit: 'gmail',
586
+ * inputParams: z.object({ limit: z.number().default(10) }),
587
+ * execute: async (input, ctx) => {
588
+ * const result = await ctx.execute('GMAIL_SEARCH', { query: 'is:important' });
589
+ * return { emails: result.data };
590
+ * },
591
+ * });
592
+ * ```
593
+ */
594
+ function createCustomTool(slug, options) {
595
+ const slugResult = CustomToolSlugSchema.safeParse(slug);
596
+ if (!slugResult.success) throw new ValidationError(`createCustomTool: ${slugResult.error.issues[0].message}`, { cause: slugResult.error });
597
+ const validated = CreateCustomToolBaseSchema.parse(options);
598
+ if (!options.inputParams) throw new ValidationError("createCustomTool: inputParams is required");
599
+ if (options.inputParams?._def?.typeName !== "ZodObject") throw new ValidationError("createCustomTool: inputParams must be a z.object() schema. Tool input parameters are always an object with named properties.");
600
+ if (typeof options.execute !== "function") throw new ValidationError("createCustomTool: execute must be a function");
601
+ validateSlugLength(slug, validated.extendsToolkit, "createCustomTool");
602
+ const { inputParams, execute } = options;
603
+ const paramsSchemaJson = zodToJsonSchema.default(inputParams, { name: "input" }).definitions.input;
604
+ const inputSchema = {
605
+ type: "object",
606
+ properties: paramsSchemaJson.properties,
607
+ ...paramsSchemaJson.required ? { required: paramsSchemaJson.required } : {}
608
+ };
609
+ let outputSchema;
610
+ if (options.outputParams) outputSchema = zodToJsonSchema.default(options.outputParams, { name: "output" }).definitions.output;
611
+ return {
612
+ slug: slugResult.data,
613
+ name: validated.name,
614
+ description: validated.description,
615
+ extendsToolkit: validated.extendsToolkit,
616
+ inputSchema,
617
+ outputSchema,
618
+ inputParams,
619
+ execute
620
+ };
621
+ }
622
+ /**
623
+ * Create a custom toolkit that groups related tools.
624
+ *
625
+ * Tools passed here must NOT have `extendsToolkit` set — they inherit the toolkit identity instead.
626
+ *
627
+ * **Slug naming:** The toolkit slug becomes part of the final tool slug exposed to the agent.
628
+ * For example, a toolkit `'DEV_TOOLS'` with a tool `'GREP'` produces `LOCAL_DEV_TOOLS_GREP`.
629
+ * The `LOCAL_` prefix is reserved and cannot be used in your slug.
630
+ *
631
+ * @param slug - Unique toolkit identifier (alphanumeric, underscores, hyphens; no LOCAL_ or COMPOSIO_ prefix)
632
+ * @param options - Toolkit definition including name, description, and tools
633
+ * @returns A CustomToolkit to pass to session creation
634
+ *
635
+ * @example
636
+ * ```typescript
637
+ * const devTools = createCustomToolkit('DEV_TOOLS', {
638
+ * name: 'Dev Tools',
639
+ * description: 'Local dev utilities',
640
+ * tools: [grepTool, sedTool],
641
+ * });
642
+ * ```
643
+ */
644
+ function createCustomToolkit(slug, options) {
645
+ const slugResult = CustomToolSlugSchema.safeParse(slug);
646
+ if (!slugResult.success) throw new ValidationError(`createCustomToolkit: ${slugResult.error.issues[0].message}`, { cause: slugResult.error });
647
+ const validated = CreateCustomToolkitBaseSchema.parse(options);
648
+ if (!options.tools?.length) throw new ValidationError("createCustomToolkit: at least one tool is required");
649
+ for (const tool of options.tools) {
650
+ if (tool.extendsToolkit) throw new ValidationError(`createCustomToolkit: tool "${tool.slug}" has extendsToolkit set. Tools in a custom toolkit must not use extendsToolkit — they inherit the toolkit identity instead.`);
651
+ validateSlugLength(tool.slug, slug, `createCustomToolkit("${slug}")`);
652
+ }
653
+ return {
654
+ slug: slugResult.data,
655
+ name: validated.name,
656
+ description: validated.description,
657
+ tools: options.tools
658
+ };
659
+ }
660
+ /**
661
+ * Serialize custom tools into the format expected by the backend session creation API.
662
+ *
663
+ * Maps `extendsToolkit` → `extends_toolkit` for backend. Omitted for standalone tools.
664
+ *
665
+ * @internal
666
+ * @param tools - The custom tools to serialize
667
+ * @returns Array of CustomToolDefinition for the API payload
668
+ */
669
+ function serializeCustomTools(tools) {
670
+ return tools.map((handle) => ({
671
+ slug: handle.slug,
672
+ name: handle.name,
673
+ description: handle.description,
674
+ input_schema: handle.inputSchema,
675
+ ...handle.outputSchema ? { output_schema: handle.outputSchema } : {},
676
+ ...handle.extendsToolkit ? { extends_toolkit: handle.extendsToolkit } : {}
677
+ }));
678
+ }
679
+ /**
680
+ * Serialize custom toolkits into the format expected by the backend session creation API.
681
+ *
682
+ * @internal
683
+ * @param toolkits - The custom toolkits to serialize
684
+ * @returns Array of CustomToolkitDefinition for the API payload
685
+ */
686
+ function serializeCustomToolkits(toolkits) {
687
+ return toolkits.map((tk) => ({
688
+ slug: tk.slug,
689
+ name: tk.name,
690
+ description: tk.description,
691
+ tools: tk.tools.map((t) => ({
692
+ slug: t.slug,
693
+ name: t.name,
694
+ description: t.description,
695
+ input_schema: t.inputSchema,
696
+ ...t.outputSchema ? { output_schema: t.outputSchema } : {}
697
+ }))
698
+ }));
699
+ }
700
+ /**
701
+ * Build a CustomToolsMap using the slug/original_slug mapping from the session create response.
702
+ * This uses the backend's authoritative prefixed slugs instead of computing them client-side.
703
+ *
704
+ * @internal
705
+ * @param tools - The original custom tools passed to session creation
706
+ * @param toolkits - The original custom toolkits passed to session creation
707
+ * @param experimental - The experimental section from the session create response
708
+ * @returns Maps for O(1) lookup by both final and original slug
709
+ */
710
+ function buildCustomToolsMapFromResponse(tools, toolkits, experimental) {
711
+ const byFinalSlug = /* @__PURE__ */ new Map();
712
+ const byOriginalSlug = /* @__PURE__ */ new Map();
713
+ const handlesByOriginalSlug = /* @__PURE__ */ new Map();
714
+ for (const handle of tools) handlesByOriginalSlug.set(handle.slug.toUpperCase(), {
715
+ handle,
716
+ toolkit: handle.extendsToolkit
717
+ });
718
+ if (toolkits) for (const tk of toolkits) for (const handle of tk.tools) handlesByOriginalSlug.set(handle.slug.toUpperCase(), {
719
+ handle,
720
+ toolkit: tk.slug
721
+ });
722
+ const addEntry = (finalSlug, originalSlug, toolkit) => {
723
+ const match = handlesByOriginalSlug.get(originalSlug.toUpperCase());
724
+ if (!match) return;
725
+ const entry = {
726
+ handle: match.handle,
727
+ finalSlug,
728
+ toolkit: toolkit ?? match.toolkit
729
+ };
730
+ byFinalSlug.set(finalSlug, entry);
731
+ byOriginalSlug.set(originalSlug.toUpperCase(), entry);
732
+ };
733
+ if (experimental?.custom_tools) for (const ct of experimental.custom_tools) addEntry(ct.slug, ct.original_slug, ct.extends_toolkit);
734
+ if (experimental?.custom_toolkits) for (const ctk of experimental.custom_toolkits) for (const ct of ctk.tools) addEntry(ct.slug, ct.original_slug, ctk.slug);
735
+ return {
736
+ byFinalSlug,
737
+ byOriginalSlug,
738
+ toolkits
739
+ };
740
+ }
741
+
742
+ //#endregion
743
+ export { AuthConfigErrorCodes as A, ToolErrorCodes as B, ValidationErrorCodes as C, ConnectionRequestErrorCodes as D, ToolkitErrorCodes as E, ComposioInvalidModifierError as F, ConnectedAccountErrorCodes as G, ComposioConnectedAccountNotFoundError as H, ComposioProviderNotDefinedError as I, ComposioToolExecutionError as L, ComposioCustomToolsNotInitializedError as M, ComposioGlobalExecuteToolFnNotSetError as N, ConnectionRequestFailedError as O, ComposioInvalidExecuteFunctionError as P, ComposioToolNotFoundError as R, ValidationError as S, ComposioToolkitNotFoundError as T, ComposioFailedToCreateConnectedAccountLink as U, handleToolExecutionError as V, ComposioMultipleConnectedAccountsError as W, ComposioWebhookSignatureVerificationError as _, serializeCustomTools as a, SDKErrorCodes as b, CustomToolSlugSchema as c, ComposioFailedToCreatePusherClientError as d, ComposioFailedToGetSDKRealtimeCredentialsError as f, ComposioWebhookPayloadError as g, ComposioTriggerTypeNotFoundError as h, serializeCustomToolkits as i, ComposioAuthConfigNotFoundError as j, ConnectionRequestTimeoutError as k, RemoteFileDownloadError as l, ComposioFailedToUnsubscribeFromPusherChannelError as m, createCustomTool as n, CreateCustomToolBaseSchema as o, ComposioFailedToSubscribeToPusherChannelError as p, createCustomToolkit as r, CreateCustomToolkitBaseSchema as s, buildCustomToolsMapFromResponse as t, RemoteFileErrorCodes as u, TriggerErrorCodes as v, ComposioToolkitFetchError as w, JsonSchemaToZodError as x, ComposioNoAPIKeyError as y, ComposioToolVersionRequiredError as z };