@composio/core 0.6.5 → 0.6.6

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-B3_zC62q.mjs +734 -0
  4. package/dist/CustomTool-Bl7vtddU.d.mts +66 -0
  5. package/dist/CustomTool-CMTb-q46.cjs +1005 -0
  6. package/dist/CustomTool-CrOHWVUC.d.cts +66 -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-BBswEUus.d.cts → composio-Cgg0LHCQ.d.cts} +239 -1864
  12. package/dist/{composio-BC28OAhR.d.mts → composio-DyBF5dV-.d.mts} +239 -1864
  13. package/dist/customTool.types-C3S5Q0_6.d.cts +1854 -0
  14. package/dist/customTool.types-CA8_4pl5.d.mts +1854 -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 +549 -714
  22. package/dist/index.d.cts +62 -44
  23. package/dist/index.d.mts +62 -44
  24. package/dist/index.mjs +363 -534
  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-Ci7pnud8.d.cts} +10904 -10905
  34. package/dist/{BaseProvider-CaOKzzuo.d.mts → tool.types-G0Kzw_GF.d.mts} +10904 -10905
  35. package/dist/{types-DY0bIIqG.d.mts → types-CyDYfq9G.d.mts} +2 -2
  36. package/dist/{types-CHz185FL.d.cts → types-DStxAk8G.d.cts} +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
package/dist/index.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  const require_chunk = require('./chunk-CQwRTUmo.cjs');
2
- const require_buffer = require('./buffer-Dy7Xi_sk.cjs');
3
- const require_Telemetry = require('./Telemetry-DRFfIuVS.cjs');
2
+ const require_ComposioError = require('./ComposioError-CYaI68Mo.cjs');
3
+ const require_CustomTool = require('./CustomTool-CMTb-q46.cjs');
4
+ const require_Telemetry = require('./Telemetry-A89k5RTv.cjs');
5
+ const require_buffer = require('./buffer-BjWptbNH.cjs');
4
6
  let _composio_client = require("@composio/client");
5
7
  _composio_client = require_chunk.__toESM(_composio_client);
6
8
  let _file_tool_modifier = require("#file_tool_modifier");
@@ -1003,480 +1005,6 @@ const ToolProxyParamsSchema = zod_v3.z.object({
1003
1005
  customConnectionData: CustomConnectionDataSchema.describe("DEPRECATED: This field is deprecated and will be removed in the future.").optional()
1004
1006
  });
1005
1007
 
1006
- //#endregion
1007
- //#region src/errors/ConnectedAccountsErrors.ts
1008
- const ConnectedAccountErrorCodes = {
1009
- CONNECTED_ACCOUNT_NOT_FOUND: "CONNECTED_ACCOUNT_NOT_FOUND",
1010
- MULTIPLE_CONNECTED_ACCOUNTS: "MULTIPLE_CONNECTED_ACCOUNTS",
1011
- FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK: "FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK"
1012
- };
1013
- var ComposioConnectedAccountNotFoundError = class extends require_buffer.ComposioError {
1014
- constructor(message = "Connected account not found", options = {}) {
1015
- super(message, {
1016
- ...options,
1017
- code: ConnectedAccountErrorCodes.CONNECTED_ACCOUNT_NOT_FOUND,
1018
- statusCode: 404,
1019
- possibleFixes: options.possibleFixes || ["Ensure the connected account exists and is active in your Composio dashboard"]
1020
- });
1021
- this.name = "ComposioConnectedAccountNotFoundError";
1022
- }
1023
- };
1024
- var ComposioMultipleConnectedAccountsError = class extends require_buffer.ComposioError {
1025
- constructor(message = "Multiple connected accounts found", options = {}) {
1026
- super(message, {
1027
- ...options,
1028
- code: ConnectedAccountErrorCodes.MULTIPLE_CONNECTED_ACCOUNTS,
1029
- possibleFixes: options.possibleFixes || ["Use the allowMultiple flag to allow multiple connected accounts per user for an auth config"]
1030
- });
1031
- this.name = "ComposioMultipleConnectedAccountsError";
1032
- }
1033
- };
1034
- var ComposioFailedToCreateConnectedAccountLink = class extends require_buffer.ComposioError {
1035
- constructor(message = "Failed to create connected account link", options = {}) {
1036
- super(message, {
1037
- ...options,
1038
- code: ConnectedAccountErrorCodes.FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK
1039
- });
1040
- this.name = "ComposioFailedToCreateConnectedAccountLink";
1041
- }
1042
- };
1043
-
1044
- //#endregion
1045
- //#region src/errors/ToolErrors.ts
1046
- const ToolErrorCodes = {
1047
- TOOLSET_NOT_DEFINED: "TOOLSET_NOT_DEFINED",
1048
- TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
1049
- INVALID_MODIFIER: "INVALID_MODIFIER",
1050
- CUSTOM_TOOLS_NOT_INITIALIZED: "CUSTOM_TOOLS_NOT_INITIALIZED",
1051
- TOOL_EXECUTION_ERROR: "TOOL_EXECUTION_ERROR",
1052
- INVALID_EXECUTE_FUNCTION: "INVALID_EXECUTE_FUNCTION",
1053
- GLOBAL_EXECUTE_TOOL_FN_NOT_SET: "GLOBAL_EXECUTE_TOOL_FN_NOT_SET",
1054
- TOOL_VERSION_REQUIRED: "TOOL_VERSION_REQUIRED"
1055
- };
1056
- var ComposioProviderNotDefinedError = class extends require_buffer.ComposioError {
1057
- constructor(message = "Provider not defined", options = {}) {
1058
- super(message, {
1059
- ...options,
1060
- code: ToolErrorCodes.TOOLSET_NOT_DEFINED,
1061
- possibleFixes: options.possibleFixes || ["Ensure that the provider is defined in the Composio project and passed into the tool instance"]
1062
- });
1063
- this.name = "ComposioProviderNotDefinedError";
1064
- }
1065
- };
1066
- var ComposioToolNotFoundError = class extends require_buffer.ComposioError {
1067
- constructor(message = "Tool not found", options = {}) {
1068
- super(message, {
1069
- ...options,
1070
- code: ToolErrorCodes.TOOL_NOT_FOUND,
1071
- possibleFixes: options.possibleFixes || ["Ensure the tool slug is correct and exists in the Composio project"]
1072
- });
1073
- this.name = "ComposioToolNotFoundError";
1074
- }
1075
- };
1076
- var ComposioInvalidModifierError = class extends require_buffer.ComposioError {
1077
- constructor(message = "Invalid modifier", options = {}) {
1078
- super(message, {
1079
- ...options,
1080
- code: ToolErrorCodes.INVALID_MODIFIER,
1081
- possibleFixes: options.possibleFixes || ["Ensure the modifier is a function and returns a valid result"]
1082
- });
1083
- this.name = "ComposioInvalidModifierError";
1084
- }
1085
- };
1086
- var ComposioCustomToolsNotInitializedError = class extends require_buffer.ComposioError {
1087
- constructor(message = "Custom tools not initialized", options = {}) {
1088
- super(message, {
1089
- ...options,
1090
- code: ToolErrorCodes.CUSTOM_TOOLS_NOT_INITIALIZED,
1091
- possibleFixes: options.possibleFixes || ["Ensure the custom tools class is initialized in the Tools instance"]
1092
- });
1093
- this.name = "ComposioCustomToolsNotInitializedError";
1094
- }
1095
- };
1096
- var ComposioToolExecutionError = class extends require_buffer.ComposioError {
1097
- constructor(message = "Tool execution error", options = {}) {
1098
- super(message, {
1099
- ...options,
1100
- code: options.code || ToolErrorCodes.TOOL_EXECUTION_ERROR,
1101
- cause: options.cause,
1102
- 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"]
1103
- });
1104
- this.name = "ComposioToolExecutionError";
1105
- }
1106
- };
1107
- var ComposioInvalidExecuteFunctionError = class extends require_buffer.ComposioError {
1108
- constructor(message = "Invalid execute function", options = {}) {
1109
- super(message, {
1110
- ...options,
1111
- code: ToolErrorCodes.INVALID_EXECUTE_FUNCTION,
1112
- possibleFixes: options.possibleFixes || ["Ensure the execute function is a valid function and returns a valid result"]
1113
- });
1114
- this.name = "ComposioInvalidExecuteFunctionError";
1115
- }
1116
- };
1117
- var ComposioGlobalExecuteToolFnNotSetError = class extends require_buffer.ComposioError {
1118
- constructor(message = "Global execute tool function not set", options = {}) {
1119
- super(message, {
1120
- ...options,
1121
- code: ToolErrorCodes.GLOBAL_EXECUTE_TOOL_FN_NOT_SET,
1122
- possibleFixes: options.possibleFixes || ["Ensure the global execute tool function is set in the provider"]
1123
- });
1124
- this.name = "ComposioGlobalExecuteToolFnNotSetError";
1125
- }
1126
- };
1127
- /**
1128
- * Error thrown when toolkit version is not specified for manual tool execution.
1129
- *
1130
- * This error is thrown when attempting to execute a tool manually (via `tools.execute()`)
1131
- * and the resolved version is "latest" without `dangerouslySkipVersionCheck` set to true.
1132
- *
1133
- * **Why this error exists:**
1134
- * Using "latest" version in manual execution can lead to unexpected behavior when new
1135
- * toolkit versions are released, potentially breaking your application. For production
1136
- * use, it's recommended to pin specific toolkit versions.
1137
- *
1138
- * **How to fix:**
1139
- * 1. Specify a concrete version in the execute call
1140
- * 2. Configure toolkit versions at SDK initialization
1141
- * 3. Set toolkit version via environment variable
1142
- * 4. Use dangerouslySkipVersionCheck (not recommended for production)
1143
- *
1144
- * @example ❌ This will throw ComposioToolVersionRequiredError if toolkitVersions is 'latest'
1145
- * ```typescript
1146
- * await composio.tools.execute('GITHUB_GET_REPOS', {
1147
- * userId: 'default',
1148
- * arguments: { owner: 'composio' }
1149
- * });
1150
- * ```
1151
- *
1152
- * @example ✅ Fix 1: Pass specific version in execute call
1153
- * ```typescript
1154
- * await composio.tools.execute('GITHUB_GET_REPOS', {
1155
- * userId: 'default',
1156
- * version: '20250909_00',
1157
- * arguments: { owner: 'composio' }
1158
- * });
1159
- * ```
1160
- *
1161
- * @example ✅ Fix 2: Configure toolkit versions at SDK level
1162
- * ```typescript
1163
- * const composio = new Composio({
1164
- * toolkitVersions: { github: '20250909_00' }
1165
- * });
1166
- * await composio.tools.execute('GITHUB_GET_REPOS', {
1167
- * userId: 'default',
1168
- * arguments: { owner: 'composio' }
1169
- * });
1170
- * ```
1171
- *
1172
- * @example ✅ Fix 3: Use environment variable
1173
- * ```typescript
1174
- * // Set: COMPOSIO_TOOLKIT_VERSION_GITHUB=20250909_00
1175
- * await composio.tools.execute('GITHUB_GET_REPOS', {
1176
- * userId: 'default',
1177
- * arguments: { owner: 'composio' }
1178
- * });
1179
- * ```
1180
- *
1181
- * @example ⚠️ Fix 4: Skip version check (not recommended for production)
1182
- * ```typescript
1183
- * await composio.tools.execute('GITHUB_GET_REPOS', {
1184
- * userId: 'default',
1185
- * dangerouslySkipVersionCheck: true,
1186
- * arguments: { owner: 'composio' }
1187
- * });
1188
- * ```
1189
- */
1190
- var ComposioToolVersionRequiredError = class extends require_buffer.ComposioError {
1191
- constructor(message = "Toolkit version not specified. For manual execution of the tool please pass a specific toolkit version", options = {}) {
1192
- super(message, {
1193
- ...options,
1194
- code: ToolErrorCodes.TOOL_VERSION_REQUIRED,
1195
- possibleFixes: options.possibleFixes || [
1196
- "Pass the toolkit version as a parameter to the execute function (\"latest\" is not supported in manual execution)",
1197
- "Set the toolkit versions in the Composio config (toolkitVersions: { <toolkit-slug>: \"<toolkit-version>\" })",
1198
- "Set the toolkit version in the environment variable (COMPOSIO_TOOLKIT_VERSION_<TOOLKIT_SLUG>)",
1199
- "Set dangerouslySkipVersionCheck to true (this might cause unexpected behavior when new versions of the tools are released)"
1200
- ]
1201
- });
1202
- }
1203
- };
1204
- const ERROR_CODE_HANDLERS = new Map([[1803, (msg) => new ComposioConnectedAccountNotFoundError(msg)]]);
1205
- const handleToolExecutionError = (tool, actualError) => {
1206
- if (actualError instanceof _composio_client.APIError && actualError.error) {
1207
- const errorBody = actualError.error;
1208
- const errorCode = errorBody?.error?.code;
1209
- const errorMessage = errorBody?.error?.message;
1210
- if (errorCode && ERROR_CODE_HANDLERS.has(errorCode)) return ERROR_CODE_HANDLERS.get(errorCode)(errorMessage || "An error occurred");
1211
- }
1212
- return new ComposioToolExecutionError(`Error executing the tool ${tool}`, {
1213
- cause: actualError,
1214
- possibleFixes: ["Ensure the tool slug is correct and the input arguments for the tool is valid"]
1215
- });
1216
- };
1217
-
1218
- //#endregion
1219
- //#region src/errors/AuthConfigErrors.ts
1220
- const AuthConfigErrorCodes = { AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND" };
1221
- var ComposioAuthConfigNotFoundError = class extends require_buffer.ComposioError {
1222
- constructor(message = "Auth config not found", options = {}) {
1223
- super(message, {
1224
- ...options,
1225
- code: AuthConfigErrorCodes.AUTH_CONFIG_NOT_FOUND,
1226
- possibleFixes: options.possibleFixes || [
1227
- "Check if the auth config exists",
1228
- "Check if the auth config id is correct",
1229
- "Check if the auth config is enabled"
1230
- ]
1231
- });
1232
- this.name = "ComposioAuthConfigNotFoundError";
1233
- }
1234
- };
1235
-
1236
- //#endregion
1237
- //#region src/errors/ConnectionRequestErrors.ts
1238
- const ConnectionRequestErrorCodes = {
1239
- CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
1240
- CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
1241
- };
1242
- var ConnectionRequestTimeoutError = class extends require_buffer.ComposioError {
1243
- constructor(message = "Connection request timed out", options = {}) {
1244
- super(message, {
1245
- ...options,
1246
- code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_TIMEOUT
1247
- });
1248
- this.name = "ConnectionRequestTimeoutError";
1249
- }
1250
- };
1251
- var ConnectionRequestFailedError = class extends require_buffer.ComposioError {
1252
- constructor(message = "Connection request failed", options = {}) {
1253
- super(message, {
1254
- ...options,
1255
- code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_FAILED
1256
- });
1257
- this.name = "ConnectionRequestFailedError";
1258
- }
1259
- };
1260
-
1261
- //#endregion
1262
- //#region src/errors/ToolkitErrors.ts
1263
- const ToolkitErrorCodes = { TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND" };
1264
- var ComposioToolkitNotFoundError = class extends require_buffer.ComposioError {
1265
- constructor(message = "Toolkit not found", options = {}) {
1266
- super(message, {
1267
- ...options,
1268
- code: "TOOLKIT_NOT_FOUND",
1269
- possibleFixes: options.possibleFixes || ["Ensure the toolkit is correctly configured and the slug is valid"]
1270
- });
1271
- this.name = "ComposioToolkitNotFoundError";
1272
- }
1273
- };
1274
- var ComposioToolkitFetchError = class extends require_buffer.ComposioError {
1275
- constructor(message = "Failed to fetch toolkit", options = {}) {
1276
- super(message, {
1277
- ...options,
1278
- code: "TOOLKIT_FETCH_ERROR",
1279
- possibleFixes: options.possibleFixes || [
1280
- "Ensure the toolkit slug is valid",
1281
- "Ensure you are using the correct API key",
1282
- "Ensure you are using the correct API endpoint / Base URL and it is working"
1283
- ]
1284
- });
1285
- this.name = "ComposioToolkitFetchError";
1286
- }
1287
- };
1288
-
1289
- //#endregion
1290
- //#region src/errors/ValidationErrors.ts
1291
- /**
1292
- * Represents an input validation error using Zod.
1293
- */
1294
- const ValidationErrorCodes = {
1295
- VALIDATION_ERROR: "VALIDATION_ERROR",
1296
- JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
1297
- };
1298
- var ValidationError = class extends require_buffer.ComposioError {
1299
- constructor(message = "Input validation failed", options = {}) {
1300
- const { cause: providedZodError, ...restOptions } = options;
1301
- let zodErrorInstance;
1302
- if (providedZodError instanceof zod_v3.ZodError) zodErrorInstance = providedZodError;
1303
- else zodErrorInstance = new zod_v3.ZodError([{
1304
- path: [],
1305
- message: "Invalid input",
1306
- code: "custom"
1307
- }]);
1308
- const issues = zodErrorInstance.issues.map((issue) => `[${issue.code}] ${issue.path.join(".")} - ${issue.message}`);
1309
- super(message, {
1310
- ...restOptions,
1311
- code: options.code || ValidationErrorCodes.VALIDATION_ERROR,
1312
- possibleFixes: issues,
1313
- cause: zodErrorInstance
1314
- });
1315
- this.name = "ValidationError";
1316
- this.message = `${message}: ${this.generateUserFriendlyMessage()}`;
1317
- }
1318
- generateUserFriendlyMessage() {
1319
- if (this.cause instanceof zod_v3.ZodError && this.cause.issues.length > 0) {
1320
- const issue = this.cause.issues[0];
1321
- const param = issue.path.join(".") || "parameter";
1322
- if (issue.code === "invalid_type") return `The ${param} should be a ${issue.expected}, but you provided a ${issue.received}`;
1323
- return issue.message;
1324
- }
1325
- return "Please check your input parameters";
1326
- }
1327
- };
1328
- var JsonSchemaToZodError = class extends require_buffer.ComposioError {
1329
- constructor(message = "Failed to convert JSON schema to Zod schema", options = {}) {
1330
- super(message, {
1331
- ...options,
1332
- code: options.code || ValidationErrorCodes.JSON_SCHEMA_TO_ZOD_ERROR
1333
- });
1334
- }
1335
- };
1336
-
1337
- //#endregion
1338
- //#region src/errors/SDKErrors.ts
1339
- const SDKErrorCodes = { NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED" };
1340
- var ComposioNoAPIKeyError = class extends require_buffer.ComposioError {
1341
- constructor(message = "No Composio API key provided", options = {}) {
1342
- const defaultCause = "Couldn't find an API key in the params, environment variables or in the user config file";
1343
- super(message, {
1344
- ...options,
1345
- code: SDKErrorCodes.NO_API_KEY_PROVIDED,
1346
- cause: options.cause || defaultCause,
1347
- possibleFixes: options.possibleFixes || [
1348
- "Ensure you have an API key passed in the params, or in environment variable (COMPOSIO_API_KEY) or in the user config file",
1349
- "To get an API key, please sign up at https://composio.dev/signup",
1350
- "You can also use the Composio CLI to create a project and get an API key"
1351
- ],
1352
- statusCode: 401
1353
- });
1354
- this.name = "ComposioNoAPIKeyError";
1355
- }
1356
- };
1357
-
1358
- //#endregion
1359
- //#region src/errors/TriggerErrors.ts
1360
- const TriggerErrorCodes = {
1361
- TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS: "TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS",
1362
- TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT: "TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT",
1363
- TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL: "TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL",
1364
- TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL: "TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL",
1365
- TRIGGER_TYPE_NOT_FOUND: "TRIGGER_TYPE_NOT_FOUND",
1366
- WEBHOOK_SIGNATURE_VERIFICATION_FAILED: "WEBHOOK_SIGNATURE_VERIFICATION_FAILED",
1367
- WEBHOOK_PAYLOAD_INVALID: "WEBHOOK_PAYLOAD_INVALID"
1368
- };
1369
- var ComposioFailedToGetSDKRealtimeCredentialsError = class extends require_buffer.ComposioError {
1370
- constructor(message = "Failed to get SDK realtime credentials", options = {}) {
1371
- super(message, {
1372
- ...options,
1373
- code: TriggerErrorCodes.TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS,
1374
- possibleFixes: options.possibleFixes || ["Please contact support."]
1375
- });
1376
- this.name = "ComposioFailedToGetSDKRealtimeCredentialsError";
1377
- }
1378
- };
1379
- var ComposioFailedToCreatePusherClientError = class extends require_buffer.ComposioError {
1380
- constructor(message = "Failed to create Pusher client", options = {}) {
1381
- super(message, {
1382
- ...options,
1383
- code: TriggerErrorCodes.TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT,
1384
- possibleFixes: options.possibleFixes || ["Please contact support."]
1385
- });
1386
- this.name = "ComposioFailedToCreatePusherClientError";
1387
- }
1388
- };
1389
- var ComposioFailedToSubscribeToPusherChannelError = class extends require_buffer.ComposioError {
1390
- constructor(message = "Failed to subscribe to Pusher channel", options = {}) {
1391
- super(message, {
1392
- ...options,
1393
- code: TriggerErrorCodes.TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL,
1394
- possibleFixes: options.possibleFixes || ["Please contact support."]
1395
- });
1396
- this.name = "ComposioFailedToSubscribeToPusherChannelError";
1397
- }
1398
- };
1399
- var ComposioFailedToUnsubscribeFromPusherChannelError = class extends require_buffer.ComposioError {
1400
- constructor(message = "Failed to unsubscribe from Pusher channel", options = {}) {
1401
- super(message, {
1402
- ...options,
1403
- code: TriggerErrorCodes.TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL,
1404
- possibleFixes: options.possibleFixes || ["Please contact support."]
1405
- });
1406
- this.name = "ComposioFailedToUnsubscribeFromPusherChannelError";
1407
- }
1408
- };
1409
- var ComposioTriggerTypeNotFoundError = class extends require_buffer.ComposioError {
1410
- constructor(message = "Trigger type not found", options = {}) {
1411
- super(message, {
1412
- ...options,
1413
- code: TriggerErrorCodes.TRIGGER_TYPE_NOT_FOUND,
1414
- statusCode: 404,
1415
- possibleFixes: options.possibleFixes || ["Please contact support."]
1416
- });
1417
- this.name = "ComposioTriggerTypeNotFoundError";
1418
- }
1419
- };
1420
- var ComposioWebhookSignatureVerificationError = class extends require_buffer.ComposioError {
1421
- constructor(message = "Webhook signature verification failed", options = {}) {
1422
- super(message, {
1423
- ...options,
1424
- code: TriggerErrorCodes.WEBHOOK_SIGNATURE_VERIFICATION_FAILED,
1425
- statusCode: 401,
1426
- possibleFixes: options.possibleFixes || [
1427
- "Verify that the webhook secret is correct.",
1428
- "Ensure the raw request body is passed without modifications.",
1429
- "Check that the signature header value is being passed correctly."
1430
- ]
1431
- });
1432
- this.name = "ComposioWebhookSignatureVerificationError";
1433
- }
1434
- };
1435
- var ComposioWebhookPayloadError = class extends require_buffer.ComposioError {
1436
- constructor(message = "Invalid webhook payload", options = {}) {
1437
- super(message, {
1438
- ...options,
1439
- code: TriggerErrorCodes.WEBHOOK_PAYLOAD_INVALID,
1440
- statusCode: 400,
1441
- possibleFixes: options.possibleFixes || ["Ensure the webhook payload is valid JSON.", "Verify the payload structure matches the expected format."]
1442
- });
1443
- this.name = "ComposioWebhookPayloadError";
1444
- }
1445
- };
1446
-
1447
- //#endregion
1448
- //#region src/errors/RemoteFileErrors.ts
1449
- const RemoteFileErrorCodes = { DOWNLOAD_FAILED: "REMOTE_FILE_DOWNLOAD_FAILED" };
1450
- /**
1451
- * Error thrown when fetching a remote file from a tool router session mount fails.
1452
- * Includes HTTP status, URL, and file path context for debugging.
1453
- */
1454
- var RemoteFileDownloadError = class extends require_buffer.ComposioError {
1455
- constructor(message = "Failed to download remote file", options = {}) {
1456
- const { statusCode, statusText, downloadUrl, mountRelativePath, filename, meta: optionsMeta, ...rest } = options;
1457
- const meta = {
1458
- ...optionsMeta,
1459
- ...statusCode !== void 0 && { statusCode },
1460
- ...statusText && { statusText },
1461
- ...downloadUrl && { downloadUrl },
1462
- ...mountRelativePath && { mountRelativePath },
1463
- ...filename && { filename }
1464
- };
1465
- super(message, {
1466
- ...rest,
1467
- code: RemoteFileErrorCodes.DOWNLOAD_FAILED,
1468
- statusCode,
1469
- meta: Object.keys(meta).length > 0 ? meta : void 0,
1470
- possibleFixes: options.possibleFixes ?? [
1471
- "Verify the download URL has not expired (check expiresAt)",
1472
- "Ensure the file exists at the specified mount path",
1473
- "Retry the operation; presigned URLs may have transient failures"
1474
- ]
1475
- });
1476
- this.name = "RemoteFileDownloadError";
1477
- }
1478
- };
1479
-
1480
1008
  //#endregion
1481
1009
  //#region src/types/connectedAccounts.types.ts
1482
1010
  /**
@@ -1577,7 +1105,9 @@ function transform(raw) {
1577
1105
  const transformed = transformer(raw);
1578
1106
  const result = schema.safeParse(transformed);
1579
1107
  if (!result.success) {
1580
- require_buffer.logger_default.error(result.error);
1108
+ const label = options?.label ? ` for ${options.label}` : "";
1109
+ const issues = result.error.issues.map((issue) => ` - ${issue.path.join(".") || "parameter"}: ${issue.message}`).join("\n");
1110
+ require_ComposioError.logger_default.warn(`Transform validation failed${label}:\n${issues}`);
1581
1111
  return transformed;
1582
1112
  }
1583
1113
  return result.data;
@@ -1604,7 +1134,7 @@ function transformConnectedAccountResponse(response) {
1604
1134
  try {
1605
1135
  return state ? ConnectionDataSchema.parse(state) : void 0;
1606
1136
  } catch (error) {
1607
- require_buffer.logger_default.warn("Unsupported auth scheme in connected account state, ignoring state field", { error });
1137
+ require_ComposioError.logger_default.warn("Unsupported auth scheme in connected account state, ignoring state field", { error });
1608
1138
  return;
1609
1139
  }
1610
1140
  };
@@ -1653,7 +1183,7 @@ var CustomTools = class {
1653
1183
  client;
1654
1184
  customToolsRegistry;
1655
1185
  constructor(client) {
1656
- if (!client) throw new require_buffer.ComposioError("ComposioClient is required");
1186
+ if (!client) throw new require_ComposioError.ComposioError("ComposioClient is required");
1657
1187
  this.client = client;
1658
1188
  this.customToolsRegistry = /* @__PURE__ */ new Map();
1659
1189
  require_Telemetry.telemetry.instrument(this, "CustomTools");
@@ -1761,7 +1291,7 @@ var CustomTools = class {
1761
1291
  try {
1762
1292
  return this.customToolsRegistry.get(slug.toLowerCase())?.schema;
1763
1293
  } catch (error) {
1764
- require_buffer.logger_default.error(`Error getting custom tool: ${error}`);
1294
+ require_ComposioError.logger_default.error(`Error getting custom tool: ${error}`);
1765
1295
  return;
1766
1296
  }
1767
1297
  }
@@ -1776,15 +1306,15 @@ var CustomTools = class {
1776
1306
  await this.client.toolkits.retrieve(toolkitSlug);
1777
1307
  if ((await this.client.toolkits.retrieve(toolkitSlug)).auth_config_details?.some((details) => details.mode === AuthSchemeTypes.NO_AUTH)) return null;
1778
1308
  } catch (error) {
1779
- throw new ComposioToolNotFoundError(`Toolkit with slug ${toolkitSlug} not found`, { cause: error });
1309
+ throw new require_CustomTool.ComposioToolNotFoundError(`Toolkit with slug ${toolkitSlug} not found`, { cause: error });
1780
1310
  }
1781
1311
  const connectedAccounts = await this.client.connectedAccounts.list({
1782
1312
  toolkit_slugs: [toolkitSlug],
1783
1313
  user_ids: [userId]
1784
1314
  });
1785
- if (!connectedAccounts.items.length) throw new ComposioConnectedAccountNotFoundError(`No connected accounts found for toolkit ${toolkitSlug}`);
1315
+ if (!connectedAccounts.items.length) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`No connected accounts found for toolkit ${toolkitSlug}`);
1786
1316
  const connectedAccount = connectedAccountId ? connectedAccounts.items.find((item) => item.id === connectedAccountId) : connectedAccounts.items[0];
1787
- if (!connectedAccount) throw new ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${userId}`);
1317
+ if (!connectedAccount) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${userId}`);
1788
1318
  return transformConnectedAccountResponse(connectedAccount);
1789
1319
  }
1790
1320
  /**
@@ -1801,23 +1331,23 @@ var CustomTools = class {
1801
1331
  */
1802
1332
  async executeCustomTool(slug, body) {
1803
1333
  const tool = this.customToolsRegistry.get(slug.toLowerCase());
1804
- if (!tool) throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
1334
+ if (!tool) throw new require_CustomTool.ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
1805
1335
  let connectionConfig = null;
1806
1336
  const { toolkitSlug, execute, inputParams } = tool.options;
1807
1337
  let connectedAccountId = body.connectedAccountId;
1808
1338
  if (toolkitSlug && toolkitSlug !== "custom" && body.userId) {
1809
1339
  const connectedAccount = await this.getConnectedAccountForToolkit(toolkitSlug, body.userId, body.connectedAccountId);
1810
- require_buffer.logger_default.debug(`[CustomTool] Connected account for ${toolkitSlug} found for user ${body.userId}`, JSON.stringify(connectedAccount, null, 2));
1811
- if (!connectedAccount) throw new ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${body.userId}`, { meta: {
1340
+ require_ComposioError.logger_default.debug(`[CustomTool] Connected account for ${toolkitSlug} found for user ${body.userId}`, JSON.stringify(connectedAccount, null, 2));
1341
+ if (!connectedAccount) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${body.userId}`, { meta: {
1812
1342
  toolkitSlug,
1813
1343
  userId: body.userId
1814
1344
  } });
1815
1345
  connectionConfig = connectedAccount.state ?? null;
1816
1346
  connectedAccountId = connectedAccount.id;
1817
1347
  }
1818
- if (typeof execute !== "function") throw new ComposioInvalidExecuteFunctionError("Invalid execute function", { meta: { toolSlug: slug } });
1348
+ if (typeof execute !== "function") throw new require_CustomTool.ComposioInvalidExecuteFunctionError("Invalid execute function", { meta: { toolSlug: slug } });
1819
1349
  const executeToolRequest = async (data) => {
1820
- if (toolkitSlug && toolkitSlug === "custom") throw new ComposioInvalidExecuteFunctionError("Custom tools without a toolkit cannot be executed using the executeToolRequest function", { possibleFixes: ["Please manually execute the tool using your logic.", "Pass a toolkit slug to execute the tool on behalf of a toolkit credentials"] });
1350
+ if (toolkitSlug && toolkitSlug === "custom") throw new require_CustomTool.ComposioInvalidExecuteFunctionError("Custom tools without a toolkit cannot be executed using the executeToolRequest function", { possibleFixes: ["Please manually execute the tool using your logic.", "Pass a toolkit slug to execute the tool on behalf of a toolkit credentials"] });
1821
1351
  const parameters = data.parameters?.map((param) => ({
1822
1352
  name: param.name,
1823
1353
  type: param.in,
@@ -1839,7 +1369,7 @@ var CustomTools = class {
1839
1369
  };
1840
1370
  };
1841
1371
  const parsedInput = inputParams.safeParse(body.arguments);
1842
- if (!parsedInput.success) throw new ValidationError("Invalid input parameters", { cause: parsedInput.error });
1372
+ if (!parsedInput.success) throw new require_CustomTool.ValidationError("Invalid input parameters", { cause: parsedInput.error });
1843
1373
  return execute(parsedInput.data, connectionConfig, executeToolRequest);
1844
1374
  }
1845
1375
  };
@@ -1873,7 +1403,7 @@ var Tools = class {
1873
1403
  toolkitVersions;
1874
1404
  constructor(client, config) {
1875
1405
  if (!client) throw new Error("ComposioClient is required");
1876
- if (!config?.provider) throw new ComposioProviderNotDefinedError("Provider not passed into Tools instance");
1406
+ if (!config?.provider) throw new require_CustomTool.ComposioProviderNotDefinedError("Provider not passed into Tools instance");
1877
1407
  this.client = client;
1878
1408
  this.customTools = new CustomTools(client);
1879
1409
  this.provider = config.provider;
@@ -1957,7 +1487,7 @@ var Tools = class {
1957
1487
  toolkitSlug,
1958
1488
  params: modifiedParams
1959
1489
  });
1960
- else throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
1490
+ else throw new require_CustomTool.ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
1961
1491
  return modifiedParams;
1962
1492
  }
1963
1493
  /**
@@ -1980,7 +1510,7 @@ var Tools = class {
1980
1510
  toolkitSlug,
1981
1511
  result: modifiedResult
1982
1512
  });
1983
- else throw new ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
1513
+ else throw new require_CustomTool.ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
1984
1514
  return modifiedResult;
1985
1515
  }
1986
1516
  /**
@@ -2041,12 +1571,12 @@ var Tools = class {
2041
1571
  * ```
2042
1572
  */
2043
1573
  async getRawComposioTools(query, options) {
2044
- if ("tools" in query && "toolkits" in query) throw new ValidationError("Invalid tool list parameters. You should not use tools and toolkits filter together.");
1574
+ if ("tools" in query && "toolkits" in query) throw new require_CustomTool.ValidationError("Invalid tool list parameters. You should not use tools and toolkits filter together.");
2045
1575
  const queryParams = ToolListParamsSchema.safeParse(query);
2046
- if (queryParams.error) throw new ValidationError("Invalid tool list parameters", { cause: queryParams.error });
1576
+ if (queryParams.error) throw new require_CustomTool.ValidationError("Invalid tool list parameters", { cause: queryParams.error });
2047
1577
  const shouldAutoApplyImportant = "toolkits" in queryParams.data && !("tools" in queryParams.data) && !("tags" in queryParams.data) && !("search" in queryParams.data) && !("limit" in queryParams.data) && queryParams.data.important !== false;
2048
1578
  const effectiveImportant = "important" in queryParams.data ? queryParams.data.important : shouldAutoApplyImportant;
2049
- if (!("tools" in queryParams.data || "toolkits" in queryParams.data || "search" in queryParams.data || "authConfigIds" in queryParams.data)) throw new ValidationError("Invalid tool list parameters, atleast one of the following parameters is required: tools, toolkits, search, authConfigIds");
1579
+ if (!("tools" in queryParams.data || "toolkits" in queryParams.data || "search" in queryParams.data || "authConfigIds" in queryParams.data)) throw new require_CustomTool.ValidationError("Invalid tool list parameters, atleast one of the following parameters is required: tools, toolkits, search, authConfigIds");
2050
1580
  let limit = "limit" in queryParams.data ? queryParams.data.limit : void 0;
2051
1581
  if ("tools" in queryParams.data) limit = 9999;
2052
1582
  const filters = {
@@ -2060,7 +1590,7 @@ var Tools = class {
2060
1590
  ...effectiveImportant ? { important: "true" } : {},
2061
1591
  toolkit_versions: this.toolkitVersions
2062
1592
  };
2063
- require_buffer.logger_default.debug(`Fetching tools with filters: ${JSON.stringify(filters, null, 2)}`);
1593
+ require_ComposioError.logger_default.debug(`Fetching tools with filters: ${JSON.stringify(filters, null, 2)}`);
2064
1594
  const tools = await this.client.tools.list(filters);
2065
1595
  if (!tools) return [];
2066
1596
  const caseTransformedTools = tools.items.map((tool) => this.transformToolCases(tool));
@@ -2075,7 +1605,7 @@ var Tools = class {
2075
1605
  schema: tool
2076
1606
  }));
2077
1607
  modifiedTools = await Promise.all(modifiedPromises);
2078
- } else throw new ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
1608
+ } else throw new require_CustomTool.ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
2079
1609
  }
2080
1610
  return modifiedTools;
2081
1611
  }
@@ -2106,7 +1636,7 @@ var Tools = class {
2106
1636
  schema: tool
2107
1637
  }));
2108
1638
  modifiedTools = await Promise.all(modifiedPromises);
2109
- } else throw new ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
1639
+ } else throw new require_CustomTool.ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
2110
1640
  }
2111
1641
  return modifiedTools;
2112
1642
  }
@@ -2163,15 +1693,15 @@ var Tools = class {
2163
1693
  async getRawComposioToolBySlug(slug, options) {
2164
1694
  const customTool = await this.customTools.getCustomToolBySlug(slug);
2165
1695
  if (customTool) {
2166
- require_buffer.logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
1696
+ require_ComposioError.logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
2167
1697
  return customTool;
2168
- } else require_buffer.logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
1698
+ } else require_ComposioError.logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
2169
1699
  let tool;
2170
1700
  try {
2171
1701
  const retrieveParams = options?.version ? { version: options.version } : { toolkit_versions: this.toolkitVersions };
2172
1702
  tool = await this.client.tools.retrieve(slug, retrieveParams);
2173
1703
  } catch (error) {
2174
- throw new ComposioToolNotFoundError(`Unable to retrieve tool with slug ${slug}`, { cause: error });
1704
+ throw new require_CustomTool.ComposioToolNotFoundError(`Unable to retrieve tool with slug ${slug}`, { cause: error });
2175
1705
  }
2176
1706
  let [modifiedTool] = await this.applyDefaultSchemaModifiers([this.transformToolCases(tool)]);
2177
1707
  if (options?.modifySchema) {
@@ -2181,7 +1711,7 @@ var Tools = class {
2181
1711
  toolkitSlug: modifiedTool.toolkit?.slug ?? "unknown",
2182
1712
  schema: modifiedTool
2183
1713
  });
2184
- else throw new ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
1714
+ else throw new require_CustomTool.ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
2185
1715
  }
2186
1716
  return modifiedTool;
2187
1717
  }
@@ -2292,7 +1822,7 @@ var Tools = class {
2292
1822
  */
2293
1823
  async executeComposioTool(tool, body) {
2294
1824
  const toolkitVersion = body.version ?? getToolkitVersion(tool.toolkit?.slug ?? "unknown", this.toolkitVersions);
2295
- if (toolkitVersion === "latest" && !body.dangerouslySkipVersionCheck) throw new ComposioToolVersionRequiredError();
1825
+ if (toolkitVersion === "latest" && !body.dangerouslySkipVersionCheck) throw new require_CustomTool.ComposioToolVersionRequiredError();
2296
1826
  try {
2297
1827
  const result = await this.client.tools.execute(tool.slug, {
2298
1828
  allow_tracing: body.allowTracing,
@@ -2306,7 +1836,7 @@ var Tools = class {
2306
1836
  });
2307
1837
  return this.transformToolExecuteResponse(result);
2308
1838
  } catch (error) {
2309
- throw handleToolExecutionError(tool.slug, error);
1839
+ throw require_CustomTool.handleToolExecutionError(tool.slug, error);
2310
1840
  }
2311
1841
  }
2312
1842
  /**
@@ -2383,9 +1913,9 @@ var Tools = class {
2383
1913
  * ```
2384
1914
  */
2385
1915
  async execute(slug, body, modifiers) {
2386
- if (!this.customTools) throw new ComposioCustomToolsNotInitializedError("CustomTools not initialized. Make sure Tools class is properly constructed.");
1916
+ if (!this.customTools) throw new require_CustomTool.ComposioCustomToolsNotInitializedError("CustomTools not initialized. Make sure Tools class is properly constructed.");
2387
1917
  const executeParams = ToolExecuteParamsSchema.safeParse(body);
2388
- if (!executeParams.success) throw new ValidationError("Invalid tool execute parameters", { cause: executeParams.error });
1918
+ if (!executeParams.success) throw new require_CustomTool.ValidationError("Invalid tool execute parameters", { cause: executeParams.error });
2389
1919
  const customTool = await this.customTools.getCustomToolBySlug(slug);
2390
1920
  const tool = customTool ?? await this.getRawComposioToolBySlug(slug, { version: body.version });
2391
1921
  const toolkitSlug = tool.toolkit?.slug ?? "unknown";
@@ -2414,7 +1944,7 @@ var Tools = class {
2414
1944
  */
2415
1945
  async executeMetaTool(toolSlug, body, modifiers) {
2416
1946
  const executeMetaParams = ToolExecuteMetaParamsSchema.safeParse(body);
2417
- if (!executeMetaParams.success) throw new ValidationError("Invalid tool execute meta parameters", { cause: executeMetaParams.error });
1947
+ if (!executeMetaParams.success) throw new require_CustomTool.ValidationError("Invalid tool execute meta parameters", { cause: executeMetaParams.error });
2418
1948
  let modifiedParams = body.arguments ?? {};
2419
1949
  if (modifiers?.beforeExecute) modifiedParams = await modifiers.beforeExecute({
2420
1950
  toolSlug,
@@ -2503,7 +2033,7 @@ var Tools = class {
2503
2033
  */
2504
2034
  async proxyExecute(body) {
2505
2035
  const toolProxyParams = ToolProxyParamsSchema.safeParse(body);
2506
- if (!toolProxyParams.success) throw new ValidationError("Invalid tool proxy parameters", { cause: toolProxyParams.error });
2036
+ if (!toolProxyParams.success) throw new require_CustomTool.ValidationError("Invalid tool proxy parameters", { cause: toolProxyParams.error });
2507
2037
  const parameters = [];
2508
2038
  const parameterTypes = {
2509
2039
  header: "header",
@@ -2823,7 +2353,7 @@ var AuthConfigs = class {
2823
2353
  */
2824
2354
  async create(toolkit, options = { type: "use_composio_managed_auth" }) {
2825
2355
  const parsedOptions = CreateAuthConfigParamsSchema.safeParse(options);
2826
- if (parsedOptions.error) throw new ValidationError("Failed to parse auth config create options", { cause: parsedOptions.error });
2356
+ if (parsedOptions.error) throw new require_CustomTool.ValidationError("Failed to parse auth config create options", { cause: parsedOptions.error });
2827
2357
  return transformCreateAuthConfigResponse(await this.client.authConfigs.create({
2828
2358
  toolkit: { slug: toolkit },
2829
2359
  auth_config: parsedOptions.data.type === "use_custom_auth" ? {
@@ -2900,7 +2430,7 @@ var AuthConfigs = class {
2900
2430
  */
2901
2431
  async update(nanoid, data) {
2902
2432
  const parsedData = AuthConfigUpdateParamsSchema.safeParse(data);
2903
- if (parsedData.error) throw new ValidationError("Failed to parse auth config update data", { cause: parsedData.error });
2433
+ if (parsedData.error) throw new require_CustomTool.ValidationError("Failed to parse auth config update data", { cause: parsedData.error });
2904
2434
  return this.client.authConfigs.update(nanoid, parsedData.data.type === "custom" ? {
2905
2435
  type: "custom",
2906
2436
  credentials: parsedData.data.credentials,
@@ -3065,7 +2595,7 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
3065
2595
  return transformConnectedAccountResponse(response);
3066
2596
  }
3067
2597
  } catch (error) {
3068
- if (error instanceof _composio_client.default.NotFoundError) throw new ComposioConnectedAccountNotFoundError(`Connected account with id ${state.id} not found`, { meta: { connectedAccountId: state.id } });
2598
+ if (error instanceof _composio_client.default.NotFoundError) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`Connected account with id ${state.id} not found`, { meta: { connectedAccountId: state.id } });
3069
2599
  else throw error;
3070
2600
  }
3071
2601
  const terminalErrorStates = [ConnectedAccountStatuses.FAILED, ConnectedAccountStatuses.EXPIRED];
@@ -3075,7 +2605,7 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
3075
2605
  const response = await client.connectedAccounts.retrieve(state.id);
3076
2606
  state.status = response.status;
3077
2607
  if (response.status === ConnectedAccountStatuses.ACTIVE) return transformConnectedAccountResponse(response);
3078
- if (terminalErrorStates.includes(response.status)) throw new ConnectionRequestFailedError(`Connection request failed with status: ${response.status}${response.status_reason ? `, reason: ${response.status_reason}` : ""}`, { meta: {
2608
+ if (terminalErrorStates.includes(response.status)) throw new require_CustomTool.ConnectionRequestFailedError(`Connection request failed with status: ${response.status}${response.status_reason ? `, reason: ${response.status_reason}` : ""}`, { meta: {
3079
2609
  connectedAccountId: state.id,
3080
2610
  status: response.status,
3081
2611
  statusReason: response.status_reason
@@ -3084,7 +2614,7 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
3084
2614
  } catch (error) {
3085
2615
  throw error;
3086
2616
  }
3087
- throw new ConnectionRequestTimeoutError(`Connection request timed out for ${state.id}`);
2617
+ throw new require_CustomTool.ConnectionRequestTimeoutError(`Connection request timed out for ${state.id}`);
3088
2618
  }
3089
2619
  return {
3090
2620
  ...state,
@@ -3136,7 +2666,7 @@ var ConnectedAccounts = class {
3136
2666
  let rawQuery = void 0;
3137
2667
  if (query) {
3138
2668
  const parsedQuery = ConnectedAccountListParamsSchema.safeParse(query);
3139
- if (!parsedQuery.success) throw new ValidationError("Failed to parse connected account list query", { cause: parsedQuery.error });
2669
+ if (!parsedQuery.success) throw new require_CustomTool.ValidationError("Failed to parse connected account list query", { cause: parsedQuery.error });
3140
2670
  rawQuery = {
3141
2671
  auth_config_ids: parsedQuery.data.authConfigIds,
3142
2672
  cursor: parsedQuery.data.cursor?.toString(),
@@ -3206,8 +2736,8 @@ var ConnectedAccounts = class {
3206
2736
  authConfigIds: [authConfigId],
3207
2737
  statuses: [ConnectedAccountStatuses.ACTIVE]
3208
2738
  });
3209
- if (connectedAccount.items.length > 0 && !options?.allowMultiple) throw new ComposioMultipleConnectedAccountsError(`Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts.`);
3210
- else if (connectedAccount.items.length > 0) require_buffer.logger_default.warn(`[Warn:AllowMultiple] Multiple connected accounts found for user ${userId} in auth config ${authConfigId}`);
2739
+ if (connectedAccount.items.length > 0 && !options?.allowMultiple) throw new require_CustomTool.ComposioMultipleConnectedAccountsError(`Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts.`);
2740
+ else if (connectedAccount.items.length > 0) require_ComposioError.logger_default.warn(`[Warn:AllowMultiple] Multiple connected accounts found for user ${userId} in auth config ${authConfigId}`);
3211
2741
  const state = options?.config ?? void 0;
3212
2742
  const response = await this.client.connectedAccounts.create({
3213
2743
  auth_config: { id: authConfigId },
@@ -3257,7 +2787,7 @@ var ConnectedAccounts = class {
3257
2787
  */
3258
2788
  async link(userId, authConfigId, options) {
3259
2789
  const requestOptions = await CreateConnectedAccountLinkOptionsSchema.safeParse(options || {});
3260
- if (!requestOptions.success) throw new ValidationError("Failed to parse create connected account link options", { cause: requestOptions.error });
2790
+ if (!requestOptions.success) throw new require_CustomTool.ValidationError("Failed to parse create connected account link options", { cause: requestOptions.error });
3261
2791
  try {
3262
2792
  const response = await this.client.link.create({
3263
2793
  auth_config_id: authConfigId,
@@ -3266,7 +2796,7 @@ var ConnectedAccounts = class {
3266
2796
  });
3267
2797
  return createConnectionRequest(this.client, response.connected_account_id, ConnectedAccountStatuses.INITIATED, response.redirect_url);
3268
2798
  } catch (error) {
3269
- throw new ComposioFailedToCreateConnectedAccountLink("Failed to create connected account link", { cause: error });
2799
+ throw new require_CustomTool.ComposioFailedToCreateConnectedAccountLink("Failed to create connected account link", { cause: error });
3270
2800
  }
3271
2801
  }
3272
2802
  /**
@@ -3354,7 +2884,7 @@ var ConnectedAccounts = class {
3354
2884
  let params = void 0;
3355
2885
  if (options) {
3356
2886
  const parsedOptions = ConnectedAccountRefreshOptionsSchema.safeParse(options);
3357
- if (!parsedOptions.success) throw new ValidationError("Failed to parse connected account refresh options", { cause: parsedOptions.error });
2887
+ if (!parsedOptions.success) throw new require_CustomTool.ValidationError("Failed to parse connected account refresh options", { cause: parsedOptions.error });
3358
2888
  params = {
3359
2889
  query_redirect_url: parsedOptions.data.redirectUrl,
3360
2890
  validate_credentials: parsedOptions.data.validateCredentials
@@ -3521,7 +3051,7 @@ var Toolkits = class {
3521
3051
  async getToolkits(query) {
3522
3052
  try {
3523
3053
  const parsedQuery = ToolkitsListParamsSchema.safeParse(query);
3524
- if (!parsedQuery.success) throw new ValidationError("Failed to parse toolkit list query", { cause: parsedQuery.error });
3054
+ if (!parsedQuery.success) throw new require_CustomTool.ValidationError("Failed to parse toolkit list query", { cause: parsedQuery.error });
3525
3055
  return transformToolkitListResponse(await this.client.toolkits.list({
3526
3056
  category: parsedQuery.data.category,
3527
3057
  managed_by: parsedQuery.data.managedBy,
@@ -3530,7 +3060,7 @@ var Toolkits = class {
3530
3060
  limit: parsedQuery.data.limit
3531
3061
  }));
3532
3062
  } catch (error) {
3533
- throw new ComposioToolkitFetchError("Failed to fetch toolkits", { cause: error });
3063
+ throw new require_CustomTool.ComposioToolkitFetchError("Failed to fetch toolkits", { cause: error });
3534
3064
  }
3535
3065
  }
3536
3066
  /**
@@ -3550,11 +3080,11 @@ var Toolkits = class {
3550
3080
  try {
3551
3081
  return transformToolkitRetrieveResponse(await this.client.toolkits.retrieve(slug));
3552
3082
  } catch (error) {
3553
- if (error instanceof openai.APIError && (error.status === 404 || error.status === 400)) throw new ComposioToolkitNotFoundError(`Toolkit with slug ${slug} not found`, {
3083
+ if (error instanceof openai.APIError && (error.status === 404 || error.status === 400)) throw new require_CustomTool.ComposioToolkitNotFoundError(`Toolkit with slug ${slug} not found`, {
3554
3084
  meta: { slug },
3555
3085
  cause: error
3556
3086
  });
3557
- throw new ComposioToolkitFetchError(`Couldn't fetch Toolkit with slug: ${slug}`, {
3087
+ throw new require_CustomTool.ComposioToolkitFetchError(`Couldn't fetch Toolkit with slug: ${slug}`, {
3558
3088
  meta: { slug },
3559
3089
  cause: error
3560
3090
  });
@@ -3572,10 +3102,10 @@ var Toolkits = class {
3572
3102
  }
3573
3103
  async getAuthConfigFields(toolkitSlug, authScheme, authConfigType, requiredOnly) {
3574
3104
  const toolkit = await this.getToolkitBySlug(toolkitSlug);
3575
- if (!toolkit.authConfigDetails) throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", { meta: { toolkitSlug } });
3576
- if (toolkit.authConfigDetails.length > 1 && !authScheme) require_buffer.logger_default.warn(`Multiple auth configs found for ${toolkitSlug}, please specify the auth scheme to get details of specific auth scheme. Selecting the first scheme by default.`, { meta: { toolkitSlug } });
3105
+ if (!toolkit.authConfigDetails) throw new require_CustomTool.ComposioAuthConfigNotFoundError("No auth config found for toolkit", { meta: { toolkitSlug } });
3106
+ if (toolkit.authConfigDetails.length > 1 && !authScheme) require_ComposioError.logger_default.warn(`Multiple auth configs found for ${toolkitSlug}, please specify the auth scheme to get details of specific auth scheme. Selecting the first scheme by default.`, { meta: { toolkitSlug } });
3577
3107
  const authConfig = authScheme ? toolkit.authConfigDetails.find((authConfig$1) => authConfig$1.mode === authScheme) : toolkit.authConfigDetails[0];
3578
- if (!authConfig) throw new ComposioAuthConfigNotFoundError(`Auth schema ${authScheme} not found for toolkit ${toolkitSlug} with auth scheme ${authScheme}`, { meta: {
3108
+ if (!authConfig) throw new require_CustomTool.ComposioAuthConfigNotFoundError(`Auth schema ${authScheme} not found for toolkit ${toolkitSlug} with auth scheme ${authScheme}`, { meta: {
3579
3109
  toolkitSlug,
3580
3110
  authScheme
3581
3111
  } });
@@ -3652,14 +3182,14 @@ var Toolkits = class {
3652
3182
  name: `${toolkit.name} Auth Config`
3653
3183
  })).id;
3654
3184
  } catch (error) {
3655
- if (error instanceof _composio_client.default.APIError && error.status === 400) throw new ComposioAuthConfigNotFoundError(`No Default auth config found for toolkit ${toolkitSlug}`, {
3185
+ if (error instanceof _composio_client.default.APIError && error.status === 400) throw new require_CustomTool.ComposioAuthConfigNotFoundError(`No Default auth config found for toolkit ${toolkitSlug}`, {
3656
3186
  meta: { toolkitSlug },
3657
3187
  cause: error,
3658
3188
  possibleFixes: [`Please Create an auth config for the toolkit ${toolkitSlug} via the dashboard`]
3659
3189
  });
3660
3190
  throw error;
3661
3191
  }
3662
- else throw new ComposioAuthConfigNotFoundError(`No auth configs found for toolkit ${toolkitSlug}`, { meta: { toolkitSlug } });
3192
+ else throw new require_CustomTool.ComposioAuthConfigNotFoundError(`No auth configs found for toolkit ${toolkitSlug}`, { meta: { toolkitSlug } });
3663
3193
  return await new ConnectedAccounts(this.client).initiate(userId, authConfigIdToUse, { allowMultiple: true });
3664
3194
  }
3665
3195
  };
@@ -3879,8 +3409,8 @@ var InternalService = class {
3879
3409
  projectId: response.project_id,
3880
3410
  pusherCluster: response.pusher_cluster
3881
3411
  });
3882
- require_buffer.logger_default.debug(`[InternalService] SDK realtime credentials: ${JSON.stringify(parsedResponse, null, 2)}`);
3883
- if (!parsedResponse.success) throw new ValidationError(`Failed to parse SDK realtime credentials`, { cause: parsedResponse.error });
3412
+ require_ComposioError.logger_default.debug(`[InternalService] SDK realtime credentials: ${JSON.stringify(parsedResponse, null, 2)}`);
3413
+ if (!parsedResponse.success) throw new require_CustomTool.ValidationError(`Failed to parse SDK realtime credentials`, { cause: parsedResponse.error });
3884
3414
  return parsedResponse.data;
3885
3415
  }
3886
3416
  };
@@ -3915,13 +3445,13 @@ var PusherService = class {
3915
3445
  try {
3916
3446
  sdkRealtimeCredentials = await internalService.getSDKRealtimeCredentials();
3917
3447
  } catch (error) {
3918
- throw new ComposioFailedToGetSDKRealtimeCredentialsError("Failed to get SDK realtime credentials", { cause: error });
3448
+ throw new require_CustomTool.ComposioFailedToGetSDKRealtimeCredentialsError("Failed to get SDK realtime credentials", { cause: error });
3919
3449
  }
3920
3450
  this.clientId = sdkRealtimeCredentials.projectId;
3921
3451
  this.pusherKey = sdkRealtimeCredentials.pusherKey;
3922
3452
  this.pusherCluster = sdkRealtimeCredentials.pusherCluster;
3923
3453
  this.pusherChannel = `private-${this.clientId}_triggers`;
3924
- require_buffer.logger_default.debug(`[PusherService] Creating Pusher client for client ID: ${this.clientId} in cluster ${this.pusherCluster}`);
3454
+ require_ComposioError.logger_default.debug(`[PusherService] Creating Pusher client for client ID: ${this.clientId} in cluster ${this.pusherCluster}`);
3925
3455
  try {
3926
3456
  const { default: Pusher } = await import("pusher-js");
3927
3457
  this.pusherClient = new Pusher(this.pusherKey, {
@@ -3933,7 +3463,7 @@ var PusherService = class {
3933
3463
  }
3934
3464
  });
3935
3465
  } catch (error) {
3936
- throw new ComposioFailedToCreatePusherClientError("Failed to create Pusher client", { cause: error });
3466
+ throw new require_CustomTool.ComposioFailedToCreatePusherClientError("Failed to create Pusher client", { cause: error });
3937
3467
  }
3938
3468
  }
3939
3469
  return this.pusherClient;
@@ -3965,19 +3495,19 @@ var PusherService = class {
3965
3495
  callback(JSON.parse(ev.chunks.join("")));
3966
3496
  } catch (parseError) {
3967
3497
  const errorMessage = parseError instanceof Error ? parseError.message : String(parseError);
3968
- require_buffer.logger_default.error("Failed to parse chunked data:", errorMessage);
3498
+ require_ComposioError.logger_default.error("Failed to parse chunked data:", errorMessage);
3969
3499
  } finally {
3970
3500
  delete events[typedData.id];
3971
3501
  }
3972
3502
  } catch (error) {
3973
3503
  const errorMessage = error instanceof Error ? error.message : String(error);
3974
- require_buffer.logger_default.error("Error processing chunked trigger data:", errorMessage);
3504
+ require_ComposioError.logger_default.error("Error processing chunked trigger data:", errorMessage);
3975
3505
  if (data && typeof data === "object" && "id" in data) delete events[data.id];
3976
3506
  }
3977
3507
  });
3978
3508
  } catch (error) {
3979
3509
  const errorMessage = error instanceof Error ? error.message : String(error);
3980
- require_buffer.logger_default.error("Failed to bind chunked events:", error);
3510
+ require_ComposioError.logger_default.error("Failed to bind chunked events:", error);
3981
3511
  throw new Error(`Failed to bind chunked events: ${errorMessage}`);
3982
3512
  }
3983
3513
  }
@@ -3993,24 +3523,24 @@ var PusherService = class {
3993
3523
  */
3994
3524
  async subscribe(fn) {
3995
3525
  try {
3996
- require_buffer.logger_default.debug(`[PusherService] Subscribing to channel: ${this.pusherChannel}`);
3526
+ require_ComposioError.logger_default.debug(`[PusherService] Subscribing to channel: ${this.pusherChannel}`);
3997
3527
  const channel = await (await this.getPusherClient()).subscribe(this.pusherChannel);
3998
3528
  channel.bind("pusher:subscription_error", (data) => {
3999
3529
  const error = data.error ? String(data.error) : "Unknown subscription error";
4000
- throw new ComposioFailedToSubscribeToPusherChannelError(`Trigger subscription error: ${error}`, { cause: error });
3530
+ throw new require_CustomTool.ComposioFailedToSubscribeToPusherChannelError(`Trigger subscription error: ${error}`, { cause: error });
4001
3531
  });
4002
3532
  const safeCallback = (data) => {
4003
3533
  try {
4004
3534
  fn(data);
4005
3535
  } catch (error) {
4006
3536
  const errorMessage = error instanceof Error ? error.message : String(error);
4007
- require_buffer.logger_default.error("❌ Error in trigger callback:", errorMessage);
3537
+ require_ComposioError.logger_default.error("❌ Error in trigger callback:", errorMessage);
4008
3538
  }
4009
3539
  };
4010
3540
  this.bindWithChunking(channel, "trigger_to_client", safeCallback);
4011
- require_buffer.logger_default.info(`✅ Subscribed to triggers. You should start receiving events now.`);
3541
+ require_ComposioError.logger_default.info(`✅ Subscribed to triggers. You should start receiving events now.`);
4012
3542
  } catch (error) {
4013
- throw new ComposioFailedToSubscribeToPusherChannelError("Failed to subscribe to Pusher channel", { cause: error });
3543
+ throw new require_CustomTool.ComposioFailedToSubscribeToPusherChannelError("Failed to subscribe to Pusher channel", { cause: error });
4014
3544
  }
4015
3545
  }
4016
3546
  /**
@@ -4023,11 +3553,11 @@ var PusherService = class {
4023
3553
  */
4024
3554
  async unsubscribe() {
4025
3555
  try {
4026
- require_buffer.logger_default.debug(`[PusherService] Unsubscribing from channel: ${this.pusherChannel}`);
3556
+ require_ComposioError.logger_default.debug(`[PusherService] Unsubscribing from channel: ${this.pusherChannel}`);
4027
3557
  await (await this.getPusherClient()).unsubscribe(this.pusherChannel);
4028
- require_buffer.logger_default.info(`✅ Unsubscribed from triggers.`);
3558
+ require_ComposioError.logger_default.info(`✅ Unsubscribed from triggers.`);
4029
3559
  } catch (error) {
4030
- throw new ComposioFailedToSubscribeToPusherChannelError("Failed to unsubscribe from Pusher channel", { cause: error });
3560
+ throw new require_CustomTool.ComposioFailedToSubscribeToPusherChannelError("Failed to unsubscribe from Pusher channel", { cause: error });
4031
3561
  }
4032
3562
  }
4033
3563
  };
@@ -4182,7 +3712,7 @@ var Triggers = class {
4182
3712
  */
4183
3713
  async listActive(query) {
4184
3714
  const parsedParams = TriggerInstanceListActiveParamsSchema.safeParse(query ?? {});
4185
- if (!parsedParams.success) throw new ValidationError(`Invalid parameters passed to list triggers`, { cause: parsedParams.error });
3715
+ if (!parsedParams.success) throw new require_CustomTool.ValidationError(`Invalid parameters passed to list triggers`, { cause: parsedParams.error });
4186
3716
  return transformTriggerInstanceListActiveResponse(await this.client.triggerInstances.listActive(query ? {
4187
3717
  auth_config_ids: parsedParams.data.authConfigIds,
4188
3718
  connected_account_ids: parsedParams.data.connectedAccountIds,
@@ -4204,14 +3734,14 @@ var Triggers = class {
4204
3734
  */
4205
3735
  async create(userId, slug, body) {
4206
3736
  const parsedBody = TriggerInstanceUpsertParamsSchema.safeParse(body ?? {});
4207
- if (!parsedBody.success) throw new ValidationError(`Invalid parameters passed to create trigger`, { cause: parsedBody.error });
3737
+ if (!parsedBody.success) throw new require_CustomTool.ValidationError(`Invalid parameters passed to create trigger`, { cause: parsedBody.error });
4208
3738
  let triggerType;
4209
3739
  let toolkitSlug;
4210
3740
  try {
4211
3741
  triggerType = await this.getType(slug);
4212
3742
  toolkitSlug = triggerType.toolkit.slug;
4213
3743
  } catch (error) {
4214
- if (error instanceof _composio_client.APIError && (error.status === 400 || error.status === 404)) throw new ComposioTriggerTypeNotFoundError(`Trigger type ${slug} not found`, {
3744
+ if (error instanceof _composio_client.APIError && (error.status === 400 || error.status === 404)) throw new require_CustomTool.ComposioTriggerTypeNotFoundError(`Trigger type ${slug} not found`, {
4215
3745
  cause: error,
4216
3746
  possibleFixes: [
4217
3747
  `Please check the trigger slug`,
@@ -4227,21 +3757,21 @@ var Triggers = class {
4227
3757
  user_ids: [userId],
4228
3758
  toolkit_slugs: [toolkitSlug]
4229
3759
  });
4230
- if (connectedAccounts.length === 0) throw new ComposioConnectedAccountNotFoundError(`No connected account found for user ${userId} for toolkit ${toolkitSlug}`, {
3760
+ if (connectedAccounts.length === 0) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`No connected account found for user ${userId} for toolkit ${toolkitSlug}`, {
4231
3761
  cause: /* @__PURE__ */ new Error(`No connected account found for user ${userId}`),
4232
3762
  possibleFixes: [`Create a new connected account for user ${userId}`]
4233
3763
  });
4234
3764
  const accountExists = connectedAccounts.some((acc) => acc.id === connectedAccountId);
4235
- if (connectedAccountId && !accountExists) throw new ComposioConnectedAccountNotFoundError(`Connected account ID ${connectedAccountId} not found for user ${userId}`, {
3765
+ if (connectedAccountId && !accountExists) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`Connected account ID ${connectedAccountId} not found for user ${userId}`, {
4236
3766
  cause: /* @__PURE__ */ new Error(`Connected account ID ${connectedAccountId} not found for user ${userId}`),
4237
3767
  possibleFixes: [`Create a new connected account for user ${userId}`, `Verify the connected account ID`]
4238
3768
  });
4239
3769
  if (!connectedAccountId) {
4240
3770
  connectedAccountId = connectedAccounts[0].id;
4241
- require_buffer.logger_default.warn(`[Warn] Multiple connected accounts found for user ${userId}, using the first one. Pass connectedAccountId to select a specific account.`);
3771
+ require_ComposioError.logger_default.warn(`[Warn] Multiple connected accounts found for user ${userId}, using the first one. Pass connectedAccountId to select a specific account.`);
4242
3772
  }
4243
3773
  } catch (error) {
4244
- if (error instanceof _composio_client.APIError && [400, 404].includes(error.status)) throw new ComposioConnectedAccountNotFoundError(`No connected account found for user ${userId} for toolkit ${toolkitSlug}`, {
3774
+ if (error instanceof _composio_client.APIError && [400, 404].includes(error.status)) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`No connected account found for user ${userId} for toolkit ${toolkitSlug}`, {
4245
3775
  cause: error,
4246
3776
  possibleFixes: [`Create a new connected account for user ${userId}`]
4247
3777
  });
@@ -4335,30 +3865,30 @@ var Triggers = class {
4335
3865
  */
4336
3866
  shouldSendTriggerAfterFilters(filters, data) {
4337
3867
  if (filters.toolkits?.length && !filters.toolkits.map((toolkit) => toolkit.toLowerCase()).includes(data.toolkitSlug.toLowerCase())) {
4338
- require_buffer.logger_default.debug("Trigger does not match toolkits filter", JSON.stringify(filters.toolkits, null, 2));
3868
+ require_ComposioError.logger_default.debug("Trigger does not match toolkits filter", JSON.stringify(filters.toolkits, null, 2));
4339
3869
  return false;
4340
3870
  }
4341
3871
  if (filters.triggerId && filters.triggerId !== data.id) {
4342
- require_buffer.logger_default.debug("Trigger does not match triggerId filter", JSON.stringify(filters.triggerId, null, 2));
3872
+ require_ComposioError.logger_default.debug("Trigger does not match triggerId filter", JSON.stringify(filters.triggerId, null, 2));
4343
3873
  return false;
4344
3874
  }
4345
3875
  if (filters.connectedAccountId && filters.connectedAccountId !== data.metadata.connectedAccount.id) {
4346
- require_buffer.logger_default.debug("Trigger does not match connectedAccountId filter", JSON.stringify(filters.connectedAccountId, null, 2));
3876
+ require_ComposioError.logger_default.debug("Trigger does not match connectedAccountId filter", JSON.stringify(filters.connectedAccountId, null, 2));
4347
3877
  return false;
4348
3878
  }
4349
3879
  if (filters.triggerSlug?.length && !filters.triggerSlug.map((triggerSlug) => triggerSlug.toLowerCase()).includes(data.triggerSlug.toLowerCase())) {
4350
- require_buffer.logger_default.debug("Trigger does not match triggerSlug filter", JSON.stringify(filters.triggerSlug, null, 2));
3880
+ require_ComposioError.logger_default.debug("Trigger does not match triggerSlug filter", JSON.stringify(filters.triggerSlug, null, 2));
4351
3881
  return false;
4352
3882
  }
4353
3883
  if (filters.triggerData && filters.triggerData !== data.metadata.triggerData) {
4354
- require_buffer.logger_default.debug("Trigger does not match triggerData filter", JSON.stringify(filters.triggerData, null, 2));
3884
+ require_ComposioError.logger_default.debug("Trigger does not match triggerData filter", JSON.stringify(filters.triggerData, null, 2));
4355
3885
  return false;
4356
3886
  }
4357
3887
  if (filters.userId && filters.userId !== data.metadata.connectedAccount.userId) {
4358
- require_buffer.logger_default.debug("Trigger does not match userId filter", JSON.stringify(filters.userId, null, 2));
3888
+ require_ComposioError.logger_default.debug("Trigger does not match userId filter", JSON.stringify(filters.userId, null, 2));
4359
3889
  return false;
4360
3890
  }
4361
- require_buffer.logger_default.debug("Trigger matches all filters", JSON.stringify(filters, null, 2));
3891
+ require_ComposioError.logger_default.debug("Trigger matches all filters", JSON.stringify(filters, null, 2));
4362
3892
  return true;
4363
3893
  }
4364
3894
  /**
@@ -4378,17 +3908,17 @@ var Triggers = class {
4378
3908
  async subscribe(fn, filters = {}) {
4379
3909
  if (!fn) throw new Error("Function is required for trigger subscription");
4380
3910
  const parsedFilters = TriggerSubscribeParamSchema.safeParse(filters);
4381
- if (!parsedFilters.success) throw new ValidationError(`Invalid parameters passed to subscribe to triggers`, { cause: parsedFilters.error });
4382
- require_buffer.logger_default.debug("🔄 Subscribing to triggers with filters: ", JSON.stringify(filters, null, 2));
3911
+ if (!parsedFilters.success) throw new require_CustomTool.ValidationError(`Invalid parameters passed to subscribe to triggers`, { cause: parsedFilters.error });
3912
+ require_ComposioError.logger_default.debug("🔄 Subscribing to triggers with filters: ", JSON.stringify(filters, null, 2));
4383
3913
  await this.pusherService.subscribe((_data) => {
4384
- require_buffer.logger_default.debug("Received raw trigger data", JSON.stringify(_data, null, 2));
3914
+ require_ComposioError.logger_default.debug("Received raw trigger data", JSON.stringify(_data, null, 2));
4385
3915
  const parsedData = this.parsePusherPayload(_data);
4386
3916
  if (this.shouldSendTriggerAfterFilters(parsedFilters.data, parsedData)) try {
4387
3917
  fn(parsedData);
4388
3918
  } catch (error) {
4389
- require_buffer.logger_default.error("❌ Error in trigger callback:", error);
3919
+ require_ComposioError.logger_default.error("❌ Error in trigger callback:", error);
4390
3920
  }
4391
- else require_buffer.logger_default.debug("Trigger does not match filters", JSON.stringify(parsedFilters.data, null, 2));
3921
+ else require_ComposioError.logger_default.debug("Trigger does not match filters", JSON.stringify(parsedFilters.data, null, 2));
4392
3922
  });
4393
3923
  }
4394
3924
  /**
@@ -4433,15 +3963,15 @@ var Triggers = class {
4433
3963
  parsePusherPayload(data) {
4434
3964
  const versionedResult = this.tryParseVersionedPayload(data);
4435
3965
  if (versionedResult.ok) {
4436
- require_buffer.logger_default.debug(`Parsed Pusher payload as ${versionedResult.version} format`);
3966
+ require_ComposioError.logger_default.debug(`Parsed Pusher payload as ${versionedResult.version} format`);
4437
3967
  return versionedResult.normalizedPayload;
4438
3968
  }
4439
3969
  const legacyData = data;
4440
3970
  if (legacyData.metadata?.nanoId && legacyData.appName) {
4441
- require_buffer.logger_default.debug("Parsed Pusher payload as legacy TriggerData format");
3971
+ require_ComposioError.logger_default.debug("Parsed Pusher payload as legacy TriggerData format");
4442
3972
  return transformIncomingTriggerPayload(legacyData);
4443
3973
  }
4444
- require_buffer.logger_default.warn("Unknown Pusher payload format. Payload keys: " + Object.keys(data).join(", "));
3974
+ require_ComposioError.logger_default.warn("Unknown Pusher payload format. Payload keys: " + Object.keys(data).join(", "));
4445
3975
  const id = toStringOrDefault(data.id, toStringOrDefault(data.trigger_id, "unknown"));
4446
3976
  const uuid = toStringOrDefault(data.uuid, toStringOrDefault(data.id, "unknown"));
4447
3977
  const triggerSlug = toStringOrDefault(data.triggerSlug, toStringOrDefault(data.trigger_name, "UNKNOWN"));
@@ -4547,8 +4077,8 @@ var Triggers = class {
4547
4077
  }[paramName];
4548
4078
  return headerName ? `'${paramName}' (from '${headerName}' header)` : `'${paramName}'`;
4549
4079
  });
4550
- if (missingParams.length > 0) throw new ValidationError(`Missing required parameters: ${missingParams.join(", ")}. Extract these values from the HTTP request headers and body.`, { cause: parsedParams.error });
4551
- throw new ValidationError("Invalid parameters passed to verifyWebhook", { cause: parsedParams.error });
4080
+ if (missingParams.length > 0) throw new require_CustomTool.ValidationError(`Missing required parameters: ${missingParams.join(", ")}. Extract these values from the HTTP request headers and body.`, { cause: parsedParams.error });
4081
+ throw new require_CustomTool.ValidationError("Invalid parameters passed to verifyWebhook", { cause: parsedParams.error });
4552
4082
  }
4553
4083
  const { payload, signature, secret, id: webhookId, timestamp: webhookTimestamp, tolerance } = parsedParams.data;
4554
4084
  if (tolerance > 0) this.validateWebhookTimestamp(webhookTimestamp, tolerance);
@@ -4569,7 +4099,7 @@ var Triggers = class {
4569
4099
  try {
4570
4100
  jsonPayload = JSON.parse(payload);
4571
4101
  } catch (error) {
4572
- throw new ComposioWebhookPayloadError("Failed to parse webhook payload as JSON", { cause: error });
4102
+ throw new require_CustomTool.ComposioWebhookPayloadError("Failed to parse webhook payload as JSON", { cause: error });
4573
4103
  }
4574
4104
  const result = this.tryParseVersionedPayload(jsonPayload);
4575
4105
  if (result.ok) {
@@ -4577,7 +4107,7 @@ var Triggers = class {
4577
4107
  return rest;
4578
4108
  }
4579
4109
  const { v1Error, v2Error, v3Error } = result;
4580
- throw new ComposioWebhookPayloadError("Webhook payload does not match any known version (V1, V2, or V3). Please ensure you are using a supported webhook payload format.", { cause: {
4110
+ throw new require_CustomTool.ComposioWebhookPayloadError("Webhook payload does not match any known version (V1, V2, or V3). Please ensure you are using a supported webhook payload format.", { cause: {
4581
4111
  v1Error,
4582
4112
  v2Error,
4583
4113
  v3Error
@@ -4714,25 +4244,25 @@ var Triggers = class {
4714
4244
  * @private
4715
4245
  */
4716
4246
  async verifyWebhookSignature(webhookId, webhookTimestamp, payload, signature, secret) {
4717
- if (payload.length === 0) throw new ComposioWebhookSignatureVerificationError("No webhook payload was provided.");
4718
- if (signature.length === 0) throw new ComposioWebhookSignatureVerificationError("No signature header value was provided. Please pass the value of the 'webhook-signature' header.");
4719
- if (secret.length === 0) throw new ComposioWebhookSignatureVerificationError("No webhook secret was provided. You can find your webhook secret in your Composio dashboard.");
4720
- if (webhookId.length === 0) throw new ComposioWebhookSignatureVerificationError("No webhook ID was provided. Please pass the value of the 'webhook-id' header.");
4721
- if (webhookTimestamp.length === 0) throw new ComposioWebhookSignatureVerificationError("No webhook timestamp was provided. Please pass the value of the 'webhook-timestamp' header.");
4247
+ if (payload.length === 0) throw new require_CustomTool.ComposioWebhookSignatureVerificationError("No webhook payload was provided.");
4248
+ if (signature.length === 0) throw new require_CustomTool.ComposioWebhookSignatureVerificationError("No signature header value was provided. Please pass the value of the 'webhook-signature' header.");
4249
+ if (secret.length === 0) throw new require_CustomTool.ComposioWebhookSignatureVerificationError("No webhook secret was provided. You can find your webhook secret in your Composio dashboard.");
4250
+ if (webhookId.length === 0) throw new require_CustomTool.ComposioWebhookSignatureVerificationError("No webhook ID was provided. Please pass the value of the 'webhook-id' header.");
4251
+ if (webhookTimestamp.length === 0) throw new require_CustomTool.ComposioWebhookSignatureVerificationError("No webhook timestamp was provided. Please pass the value of the 'webhook-timestamp' header.");
4722
4252
  const signatures = signature.split(" ");
4723
4253
  const v1Signatures = [];
4724
4254
  for (const sig of signatures) {
4725
4255
  const [version$1, value] = sig.split(",");
4726
4256
  if (version$1 === "v1" && value) v1Signatures.push(value);
4727
4257
  }
4728
- if (v1Signatures.length === 0) throw new ComposioWebhookSignatureVerificationError("No valid v1 signature found in the webhook-signature header. Expected format: 'v1,base64EncodedSignature'");
4258
+ if (v1Signatures.length === 0) throw new require_CustomTool.ComposioWebhookSignatureVerificationError("No valid v1 signature found in the webhook-signature header. Expected format: 'v1,base64EncodedSignature'");
4729
4259
  const expectedSignature = await hmacSha256Base64(secret, `${webhookId}.${webhookTimestamp}.${payload}`);
4730
4260
  let isValid = false;
4731
4261
  for (const providedSignature of v1Signatures) if (timingSafeEqual(providedSignature, expectedSignature)) {
4732
4262
  isValid = true;
4733
4263
  break;
4734
4264
  }
4735
- if (!isValid) throw new ComposioWebhookSignatureVerificationError("The signature provided is invalid. Please ensure you are using the correct webhook secret.");
4265
+ if (!isValid) throw new require_CustomTool.ComposioWebhookSignatureVerificationError("The signature provided is invalid. Please ensure you are using the correct webhook secret.");
4736
4266
  }
4737
4267
  /**
4738
4268
  * Validates that the webhook timestamp is within the allowed tolerance
@@ -4740,11 +4270,11 @@ var Triggers = class {
4740
4270
  */
4741
4271
  validateWebhookTimestamp(webhookTimestamp, tolerance) {
4742
4272
  const timestampSeconds = parseInt(webhookTimestamp, 10);
4743
- if (Number.isNaN(timestampSeconds)) throw new ComposioWebhookPayloadError(`Invalid webhook timestamp: ${webhookTimestamp}. Expected Unix timestamp in seconds.`);
4273
+ if (Number.isNaN(timestampSeconds)) throw new require_CustomTool.ComposioWebhookPayloadError(`Invalid webhook timestamp: ${webhookTimestamp}. Expected Unix timestamp in seconds.`);
4744
4274
  const webhookTimeMs = timestampSeconds * 1e3;
4745
4275
  const currentTime = Date.now();
4746
4276
  const timeDifference = Math.abs(currentTime - webhookTimeMs);
4747
- if (timeDifference > tolerance * 1e3) throw new ComposioWebhookSignatureVerificationError(`The webhook timestamp is outside the allowed tolerance. The webhook was sent ${Math.round(timeDifference / 1e3)} seconds ago, but the maximum allowed age is ${tolerance} seconds.`);
4277
+ if (timeDifference > tolerance * 1e3) throw new require_CustomTool.ComposioWebhookSignatureVerificationError(`The webhook timestamp is outside the allowed tolerance. The webhook was sent ${Math.round(timeDifference / 1e3)} seconds ago, but the maximum allowed age is ${tolerance} seconds.`);
4748
4278
  }
4749
4279
  };
4750
4280
 
@@ -4878,7 +4408,7 @@ var MCP = class {
4878
4408
  */
4879
4409
  async create(name, mcpConfig) {
4880
4410
  const config = MCPConfigCreationParamsSchema.safeParse(mcpConfig);
4881
- if (config.error) throw new ValidationError("Invalid parameters passed to create mcp config", { cause: config.error });
4411
+ if (config.error) throw new require_CustomTool.ValidationError("Invalid parameters passed to create mcp config", { cause: config.error });
4882
4412
  const toolkits = [];
4883
4413
  const auth_config_ids = [];
4884
4414
  const custom_tools = config.data.allowedTools ?? [];
@@ -4942,7 +4472,7 @@ var MCP = class {
4942
4472
  */
4943
4473
  async list(options) {
4944
4474
  const { data: params, error } = MCPListParamsSchema.safeParse(options);
4945
- if (error) throw new ValidationError("Failed to validate list options", { cause: error });
4475
+ if (error) throw new require_CustomTool.ValidationError("Failed to validate list options", { cause: error });
4946
4476
  return transform(await this.client.mcp.list({
4947
4477
  page_no: params.page,
4948
4478
  limit: params.limit,
@@ -5099,7 +4629,7 @@ var MCP = class {
5099
4629
  */
5100
4630
  async update(serverId, config) {
5101
4631
  const { data: params, error } = MCPUpdateParamsSchema.safeParse(config);
5102
- if (error) throw new ValidationError("Failed to validate update params", { cause: error });
4632
+ if (error) throw new require_CustomTool.ValidationError("Failed to validate update params", { cause: error });
5103
4633
  const toolkits = [];
5104
4634
  const auth_config_ids = [];
5105
4635
  const custom_tools = params.allowedTools ?? void 0;
@@ -5138,7 +4668,7 @@ var MCP = class {
5138
4668
  async generate(userId, mcpConfigId, options) {
5139
4669
  const server = await this.client.mcp.retrieve(mcpConfigId);
5140
4670
  const params = MCPGetInstanceParamsSchema.safeParse(options ?? { manuallyManageConnections: false });
5141
- if (params.error) throw new ValidationError("Invalid params passed for Get Instance Params", { cause: params.error });
4671
+ if (params.error) throw new require_CustomTool.ValidationError("Invalid params passed for Get Instance Params", { cause: params.error });
5142
4672
  const userIdsURL = (await this.client.mcp.generate.url({
5143
4673
  mcp_server_id: mcpConfigId,
5144
4674
  user_ids: [userId],
@@ -5153,7 +4683,7 @@ var MCP = class {
5153
4683
  allowedTools: server.allowed_tools,
5154
4684
  authConfigs: server.auth_config_ids
5155
4685
  });
5156
- if (serverInstance.error) throw new ValidationError("Failed to parse MCP server instance", { cause: serverInstance.error });
4686
+ if (serverInstance.error) throw new require_CustomTool.ValidationError("Failed to parse MCP server instance", { cause: serverInstance.error });
5157
4687
  return serverInstance.data;
5158
4688
  }
5159
4689
  };
@@ -5164,9 +4694,9 @@ const userDataPath = () => {
5164
4694
  try {
5165
4695
  const homeDir = _platform.platform.homedir();
5166
4696
  if (!homeDir) return null;
5167
- return _platform.platform.joinPath(homeDir, require_buffer.COMPOSIO_DIR, require_buffer.USER_DATA_FILE_NAME);
4697
+ return _platform.platform.joinPath(homeDir, require_ComposioError.COMPOSIO_DIR, require_ComposioError.USER_DATA_FILE_NAME);
5168
4698
  } catch (_error) {
5169
- require_buffer.logger_default.debug("Environment", `Unable to get user data path`);
4699
+ require_ComposioError.logger_default.debug("Environment", `Unable to get user data path`);
5170
4700
  return null;
5171
4701
  }
5172
4702
  };
@@ -5182,17 +4712,17 @@ const getUserDataJson = () => {
5182
4712
  const data = _platform.platform.readFileSync(dataPath, "utf8");
5183
4713
  return JSON.parse(data);
5184
4714
  } catch (_error) {
5185
- require_buffer.logger_default.debug("Environment", "No user data file found");
4715
+ require_ComposioError.logger_default.debug("Environment", "No user data file found");
5186
4716
  return {};
5187
4717
  }
5188
4718
  };
5189
4719
  function getSDKConfig(baseUrl, apiKey) {
5190
4720
  const { api_key: apiKeyFromUserConfig, base_url: baseURLFromUserConfig } = getUserDataJson();
5191
- const baseURLParsed = baseUrl || require_buffer.getEnvVariable("COMPOSIO_BASE_URL") || baseURLFromUserConfig || require_buffer.DEFAULT_BASE_URL;
5192
- const apiKeyParsed = apiKey || require_buffer.getEnvVariable("COMPOSIO_API_KEY") || apiKeyFromUserConfig || "";
5193
- if (!apiKeyParsed) require_buffer.ComposioError.handleAndThrow(new ComposioNoAPIKeyError());
5194
- require_buffer.logger_default.debug("Environment", `API Key: ${apiKeyParsed}`);
5195
- require_buffer.logger_default.debug("Environment", `Base URL: ${baseURLParsed}`);
4721
+ const baseURLParsed = baseUrl || require_ComposioError.getEnvVariable("COMPOSIO_BASE_URL") || baseURLFromUserConfig || require_ComposioError.DEFAULT_BASE_URL;
4722
+ const apiKeyParsed = apiKey || require_ComposioError.getEnvVariable("COMPOSIO_API_KEY") || apiKeyFromUserConfig || "";
4723
+ if (!apiKeyParsed) require_ComposioError.ComposioError.handleAndThrow(new require_CustomTool.ComposioNoAPIKeyError());
4724
+ require_ComposioError.logger_default.debug("Environment", `API Key: ${apiKeyParsed}`);
4725
+ require_ComposioError.logger_default.debug("Environment", `Base URL: ${baseURLParsed}`);
5196
4726
  return {
5197
4727
  baseURL: baseURLParsed,
5198
4728
  apiKey: apiKeyParsed
@@ -5212,7 +4742,7 @@ function getSDKConfig(baseUrl, apiKey) {
5212
4742
  */
5213
4743
  function getToolkitVersionsFromEnv(defaultVersions) {
5214
4744
  if (defaultVersions && typeof defaultVersions === "string") return defaultVersions;
5215
- const envPrefixedVersions = require_buffer.getEnvsWithPrefix(`COMPOSIO_TOOLKIT_VERSION_`);
4745
+ const envPrefixedVersions = require_ComposioError.getEnvsWithPrefix(`COMPOSIO_TOOLKIT_VERSION_`);
5216
4746
  const toolkitVersionsFromEnv = Object.entries(envPrefixedVersions).reduce((acc, [key, value]) => {
5217
4747
  const toolkitName = key.replace("COMPOSIO_TOOLKIT_VERSION_", "");
5218
4748
  acc[toolkitName.toLowerCase()] = value;
@@ -5242,7 +4772,7 @@ async function checkForLatestVersionFromNPM(currentVersion) {
5242
4772
  const prerelease = semver.default.prerelease(currentVersionFromPackageJson);
5243
4773
  if (prerelease && (String(prerelease[0]).includes("alpha") || String(prerelease[0]).includes("beta"))) return;
5244
4774
  const latestVersion = (await (await fetch(`https://registry.npmjs.org/${packageName}/latest`)).json()).version;
5245
- if (semver.default.gt(latestVersion, currentVersionFromPackageJson) && !require_buffer.IS_DEVELOPMENT_OR_CI) require_buffer.logger_default.info(`🚀 Upgrade available! Your composio-core version (${currentVersionFromPackageJson}) is behind. Latest version: ${latestVersion}.`);
4775
+ if (semver.default.gt(latestVersion, currentVersionFromPackageJson) && !require_ComposioError.IS_DEVELOPMENT_OR_CI) require_ComposioError.logger_default.info(`🚀 Upgrade available! Your composio-core version (${currentVersionFromPackageJson}) is behind. Latest version: ${latestVersion}.`);
5246
4776
  } catch (_error) {}
5247
4777
  }
5248
4778
 
@@ -5279,7 +4809,7 @@ var BaseProvider = class {
5279
4809
  * @returns {Promise<string>} The result of the tool execution.
5280
4810
  */
5281
4811
  executeTool(toolSlug, body, modifers) {
5282
- if (!this._globalExecuteToolFn) throw new ComposioGlobalExecuteToolFnNotSetError("executeToolFn is not set");
4812
+ if (!this._globalExecuteToolFn) throw new require_CustomTool.ComposioGlobalExecuteToolFnNotSetError("executeToolFn is not set");
5283
4813
  return this._globalExecuteToolFn(toolSlug, body, modifers);
5284
4814
  }
5285
4815
  };
@@ -5568,9 +5098,9 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5568
5098
  async handleAssistantMessage(userId, run, options, modifiers) {
5569
5099
  const tool_calls = run.required_action?.submit_tool_outputs?.tool_calls || [];
5570
5100
  return await Promise.all(tool_calls.map(async (tool_call) => {
5571
- require_buffer.logger_default.debug(`Executing tool call: ${tool_call.id}`);
5101
+ require_ComposioError.logger_default.debug(`Executing tool call: ${tool_call.id}`);
5572
5102
  const tool_response = await this.executeToolCall(userId, tool_call, options, modifiers);
5573
- require_buffer.logger_default.debug(`Tool call ${tool_call.id} executed with response: ${tool_response}`);
5103
+ require_ComposioError.logger_default.debug(`Tool call ${tool_call.id} executed with response: ${tool_response}`);
5574
5104
  return {
5575
5105
  tool_call_id: tool_call.id,
5576
5106
  output: JSON.stringify(tool_response)
@@ -5729,7 +5259,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5729
5259
 
5730
5260
  //#endregion
5731
5261
  //#region package.json
5732
- var version = "0.6.5";
5262
+ var version = "0.6.6";
5733
5263
 
5734
5264
  //#endregion
5735
5265
  //#region src/utils/session.ts
@@ -5849,7 +5379,11 @@ const ToolRouterCreateSessionConfigSchema = zod_v3.default.object({
5849
5379
  enableProxyExecution: zod_v3.default.boolean().optional().describe("Whether to enable proxy execution in the tool router session"),
5850
5380
  autoOffloadThreshold: zod_v3.default.number().optional().describe("The auto offload threshold in characters for the tool execution to be moved into workbench")
5851
5381
  }).optional().describe("The execution config for the tool router session"),
5852
- experimental: zod_v3.default.object({ assistivePrompt: zod_v3.default.object({ userTimezone: zod_v3.default.string().optional().describe("IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\") for timezone-aware assistive prompts") }).optional().describe("Configuration for assistive prompt generation") }).optional().describe("Experimental features configuration - not stable, may be modified or removed")
5382
+ experimental: zod_v3.default.object({
5383
+ assistivePrompt: zod_v3.default.object({ userTimezone: zod_v3.default.string().optional().describe("IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\") for timezone-aware assistive prompts") }).optional().describe("Configuration for assistive prompt generation"),
5384
+ customTools: zod_v3.default.array(zod_v3.default.custom()).optional().describe("Custom tools to include in this session. Created via createCustomTool() from @composio/core/experimental."),
5385
+ customToolkits: zod_v3.default.array(zod_v3.default.custom()).optional().describe("Custom toolkits to include in this session. Created via createCustomToolkit() from @composio/core/experimental.")
5386
+ }).optional().describe("Experimental features configuration - not stable, may be modified or removed")
5853
5387
  }).partial().describe("The config for the tool router session");
5854
5388
  const ToolkitConnectionStateSchema = zod_v3.default.object({
5855
5389
  slug: zod_v3.default.string().describe("The slug of a toolkit"),
@@ -5952,6 +5486,23 @@ const ToolRouterSessionExecuteResponseSchema = zod_v3.default.object({
5952
5486
  error: zod_v3.default.string().nullable(),
5953
5487
  logId: zod_v3.default.string()
5954
5488
  });
5489
+ const SessionProxyExecuteParamsSchema = zod_v3.default.object({
5490
+ toolkit: zod_v3.default.string(),
5491
+ endpoint: zod_v3.default.string(),
5492
+ method: zod_v3.default.enum([
5493
+ "GET",
5494
+ "POST",
5495
+ "PUT",
5496
+ "DELETE",
5497
+ "PATCH"
5498
+ ]),
5499
+ body: zod_v3.default.unknown().optional(),
5500
+ parameters: zod_v3.default.array(zod_v3.default.object({
5501
+ in: zod_v3.default.enum(["query", "header"]),
5502
+ name: zod_v3.default.string(),
5503
+ value: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.number()])
5504
+ })).optional()
5505
+ });
5955
5506
 
5956
5507
  //#endregion
5957
5508
  //#region src/lib/toolRouterParams.ts
@@ -5970,7 +5521,7 @@ const transformToolRouterToolsParams = (params) => {
5970
5521
  const tags = transformToolRouterTagsParams(data.tags);
5971
5522
  if (tags) acc[key] = { tags };
5972
5523
  }
5973
- } else throw new ValidationError(parsedResult.error.message);
5524
+ } else throw new require_CustomTool.ValidationError(parsedResult.error.message);
5974
5525
  } else acc[key] = { enable: params[key] };
5975
5526
  return acc;
5976
5527
  }, {});
@@ -5987,7 +5538,7 @@ const transformToolRouterManageConnectionsParams = (params) => {
5987
5538
  if (params === void 0) return { enable: true };
5988
5539
  if (typeof params === "boolean") return { enable: params };
5989
5540
  const parsedResult = ToolRouterConfigManageConnectionsSchema.safeParse(params);
5990
- if (!parsedResult.success) throw new ValidationError("Failed to parse manage connections config", { cause: parsedResult.error });
5541
+ if (!parsedResult.success) throw new require_CustomTool.ValidationError("Failed to parse manage connections config", { cause: parsedResult.error });
5991
5542
  const config = parsedResult.data;
5992
5543
  return {
5993
5544
  enable: config.enable ?? true,
@@ -6092,7 +5643,7 @@ function transformExecuteResponse(raw) {
6092
5643
  //#region src/types/ToolRouterSessionFilesMount.types.ts
6093
5644
  const ToolRouterSessionFilesMountListOptionsSchema = zod_v3.default.object({
6094
5645
  path: zod_v3.default.string().optional(),
6095
- mountId: zod_v3.default.string().default(require_buffer.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID),
5646
+ mountId: zod_v3.default.string().default(require_ComposioError.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID),
6096
5647
  cursor: zod_v3.default.string().optional(),
6097
5648
  limit: zod_v3.default.number().min(1).max(500).optional()
6098
5649
  });
@@ -6116,11 +5667,11 @@ const FileListResponseSchema = zod_v3.default.object({
6116
5667
  }));
6117
5668
  const ToolRouterSessionFilesMountUploadOptionsSchema = zod_v3.default.object({
6118
5669
  remotePath: zod_v3.default.string().optional(),
6119
- mountId: zod_v3.default.string().default(require_buffer.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID),
5670
+ mountId: zod_v3.default.string().default(require_ComposioError.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID),
6120
5671
  mimetype: zod_v3.default.string().optional()
6121
5672
  });
6122
- const ToolRouterSessionFilesMountDownloadOptionsSchema = zod_v3.default.object({ mountId: zod_v3.default.string().default(require_buffer.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID) });
6123
- const ToolRouterSessionFilesMountDeleteOptionsSchema = zod_v3.default.object({ mountId: zod_v3.default.string().default(require_buffer.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID) });
5673
+ const ToolRouterSessionFilesMountDownloadOptionsSchema = zod_v3.default.object({ mountId: zod_v3.default.string().default(require_ComposioError.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID) });
5674
+ const ToolRouterSessionFilesMountDeleteOptionsSchema = zod_v3.default.object({ mountId: zod_v3.default.string().default(require_ComposioError.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID) });
6124
5675
  const RemoteFileDataSchema = zod_v3.default.object({
6125
5676
  expires_at: zod_v3.default.string(),
6126
5677
  mount_relative_path: zod_v3.default.string(),
@@ -6196,7 +5747,7 @@ var RemoteFile = class RemoteFile {
6196
5747
  */
6197
5748
  static parse(data) {
6198
5749
  const parsed = RemoteFileDataSchema.safeParse(data);
6199
- if (!parsed.success) throw new ValidationError("Failed to parse remote file response", { cause: parsed.error });
5750
+ if (!parsed.success) throw new require_CustomTool.ValidationError("Failed to parse remote file response", { cause: parsed.error });
6200
5751
  return new RemoteFile(parsed.data);
6201
5752
  }
6202
5753
  /** Filename extracted from the mount path (e.g. "report.pdf" from "output/report.pdf") */
@@ -6210,7 +5761,7 @@ var RemoteFile = class RemoteFile {
6210
5761
  */
6211
5762
  async buffer() {
6212
5763
  const response = await fetch(this.downloadUrl);
6213
- if (!response.ok) throw new RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
5764
+ if (!response.ok) throw new require_CustomTool.RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
6214
5765
  statusCode: response.status,
6215
5766
  statusText: response.statusText,
6216
5767
  downloadUrl: this.downloadUrl,
@@ -6237,7 +5788,7 @@ var RemoteFile = class RemoteFile {
6237
5788
  */
6238
5789
  async blob() {
6239
5790
  const response = await fetch(this.downloadUrl);
6240
- if (!response.ok) throw new RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
5791
+ if (!response.ok) throw new require_CustomTool.RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
6241
5792
  statusCode: response.status,
6242
5793
  statusText: response.statusText,
6243
5794
  downloadUrl: this.downloadUrl,
@@ -6260,8 +5811,8 @@ var RemoteFile = class RemoteFile {
6260
5811
  const content = await this.buffer();
6261
5812
  const homeDir = _platform.platform.homedir();
6262
5813
  if (!homeDir) throw new Error("Cannot determine save location: home directory is not available");
6263
- const savePath = path ?? _platform.platform.joinPath(homeDir, require_buffer.COMPOSIO_DIR, require_buffer.TEMP_FILES_DIRECTORY_NAME, this.filename);
6264
- const dir = path != null ? getParentDir(savePath) : _platform.platform.joinPath(homeDir, require_buffer.COMPOSIO_DIR, require_buffer.TEMP_FILES_DIRECTORY_NAME);
5814
+ const savePath = path ?? _platform.platform.joinPath(homeDir, require_ComposioError.COMPOSIO_DIR, require_ComposioError.TEMP_FILES_DIRECTORY_NAME, this.filename);
5815
+ const dir = path != null ? getParentDir(savePath) : _platform.platform.joinPath(homeDir, require_ComposioError.COMPOSIO_DIR, require_ComposioError.TEMP_FILES_DIRECTORY_NAME);
6265
5816
  if (dir && !_platform.platform.existsSync(dir)) _platform.platform.mkdirSync(dir);
6266
5817
  _platform.platform.writeFileSync(savePath, content);
6267
5818
  return savePath;
@@ -6380,7 +5931,7 @@ var ToolRouterSessionFilesMount = class {
6380
5931
  */
6381
5932
  async list(options) {
6382
5933
  const listOptions = ToolRouterSessionFilesMountListOptionsSchema.safeParse(options ?? {});
6383
- if (!listOptions.success) throw new ValidationError("Failed to parse tool router session files mount list options", { cause: listOptions.error });
5934
+ if (!listOptions.success) throw new require_CustomTool.ValidationError("Failed to parse tool router session files mount list options", { cause: listOptions.error });
6384
5935
  const rawPath = listOptions.data.path;
6385
5936
  const mountRelativePrefix = rawPath === void 0 || rawPath === "" || rawPath === "/" ? void 0 : rawPath.startsWith("/") ? rawPath.slice(1) : rawPath;
6386
5937
  const response = await this.client.toolRouter.session.files.list(listOptions.data.mountId, {
@@ -6391,7 +5942,7 @@ var ToolRouterSessionFilesMount = class {
6391
5942
  });
6392
5943
  const data = typeof response === "object" && "body" in response ? response.body : response;
6393
5944
  const parsed = FileListResponseSchema.safeParse(data);
6394
- if (!parsed.success) throw new ValidationError("Failed to parse file list response", { cause: parsed.error });
5945
+ if (!parsed.success) throw new require_CustomTool.ValidationError("Failed to parse file list response", { cause: parsed.error });
6395
5946
  return parsed.data;
6396
5947
  }
6397
5948
  async normalizeUploadInput(input, options) {
@@ -6470,7 +6021,7 @@ var ToolRouterSessionFilesMount = class {
6470
6021
  */
6471
6022
  async upload(input, options) {
6472
6023
  const uploadOptions = ToolRouterSessionFilesMountUploadOptionsSchema.safeParse(options ?? {});
6473
- if (!uploadOptions.success) throw new ValidationError("Failed to parse tool router session files mount upload options", { cause: uploadOptions.error });
6024
+ if (!uploadOptions.success) throw new require_CustomTool.ValidationError("Failed to parse tool router session files mount upload options", { cause: uploadOptions.error });
6474
6025
  const { fileToUpload, remotePath, mimetype } = await this.normalizeUploadInput(input, uploadOptions.data);
6475
6026
  const createUploadURLResponse = await this.client.toolRouter.session.files.createUploadURL(uploadOptions.data.mountId, {
6476
6027
  session_id: this.sessionId,
@@ -6490,7 +6041,7 @@ var ToolRouterSessionFilesMount = class {
6490
6041
  });
6491
6042
  const downloadData = typeof createDownloadURLResponse === "object" && "body" in createDownloadURLResponse ? createDownloadURLResponse.body : createDownloadURLResponse;
6492
6043
  const parsed = RemoteFileDataSchema.safeParse(downloadData);
6493
- if (!parsed.success) throw new ValidationError("Failed to parse remote file properties", { cause: parsed.error });
6044
+ if (!parsed.success) throw new require_CustomTool.ValidationError("Failed to parse remote file properties", { cause: parsed.error });
6494
6045
  return new RemoteFile(parsed.data);
6495
6046
  }
6496
6047
  /**
@@ -6520,14 +6071,14 @@ var ToolRouterSessionFilesMount = class {
6520
6071
  */
6521
6072
  async download(filePath, options) {
6522
6073
  const downloadOptions = ToolRouterSessionFilesMountDownloadOptionsSchema.safeParse(options ?? {});
6523
- if (!downloadOptions.success) throw new ValidationError("Failed to parse tool router session files mount download options", { cause: downloadOptions.error });
6074
+ if (!downloadOptions.success) throw new require_CustomTool.ValidationError("Failed to parse tool router session files mount download options", { cause: downloadOptions.error });
6524
6075
  const createDownloadURLResponse = await this.client.toolRouter.session.files.createDownloadURL(downloadOptions.data.mountId, {
6525
6076
  session_id: this.sessionId,
6526
6077
  mount_relative_path: filePath
6527
6078
  });
6528
6079
  const downloadURLData = typeof createDownloadURLResponse === "object" && "body" in createDownloadURLResponse ? createDownloadURLResponse.body : createDownloadURLResponse;
6529
6080
  const parsed = RemoteFileDataSchema.safeParse(downloadURLData);
6530
- if (!parsed.success) throw new ValidationError("Failed to parse remote file properties", { cause: parsed.error });
6081
+ if (!parsed.success) throw new require_CustomTool.ValidationError("Failed to parse remote file properties", { cause: parsed.error });
6531
6082
  return new RemoteFile(parsed.data);
6532
6083
  }
6533
6084
  /**
@@ -6559,44 +6110,231 @@ var ToolRouterSessionFilesMount = class {
6559
6110
  */
6560
6111
  async delete(remotePath, options) {
6561
6112
  const deleteOptions = ToolRouterSessionFilesMountDeleteOptionsSchema.safeParse(options ?? {});
6562
- if (!deleteOptions.success) throw new ValidationError("Failed to parse tool router session files mount delete options", { cause: deleteOptions.error });
6113
+ if (!deleteOptions.success) throw new require_CustomTool.ValidationError("Failed to parse tool router session files mount delete options", { cause: deleteOptions.error });
6563
6114
  const deleteResponse = await this.client.toolRouter.session.files.delete(deleteOptions.data.mountId, {
6564
6115
  session_id: this.sessionId,
6565
6116
  mount_relative_path: remotePath
6566
6117
  });
6567
6118
  const fileDeleteResponse = FileDeleteResponseSchema.safeParse(deleteResponse);
6568
- if (!fileDeleteResponse.success) throw new ValidationError("Failed to parse file delete response", { cause: fileDeleteResponse.error });
6119
+ if (!fileDeleteResponse.success) throw new require_CustomTool.ValidationError("Failed to parse file delete response", { cause: fileDeleteResponse.error });
6569
6120
  return fileDeleteResponse.data;
6570
6121
  }
6571
6122
  };
6572
6123
 
6124
+ //#endregion
6125
+ //#region src/models/proxyParamsTransform.ts
6126
+ /**
6127
+ * Transform SDK session proxy params to the official client request format.
6128
+ * Converts SDK-facing `toolkit` → `toolkit_slug` and `parameters[].in` → `parameters[].type`.
6129
+ */
6130
+ function transformProxyParams(params) {
6131
+ const parameters = params.parameters?.map((p) => ({
6132
+ name: p.name,
6133
+ type: p.in,
6134
+ value: p.value.toString()
6135
+ }));
6136
+ return {
6137
+ toolkit_slug: params.toolkit,
6138
+ endpoint: params.endpoint,
6139
+ method: params.method,
6140
+ ...params.body !== void 0 ? { body: params.body } : {},
6141
+ ...parameters?.length ? { parameters } : {}
6142
+ };
6143
+ }
6144
+
6145
+ //#endregion
6146
+ //#region src/models/customToolExecution.ts
6147
+ /**
6148
+ * Find a custom tool entry by slug.
6149
+ * Checks both the final slug map (LOCAL_X — agent/LLM path) and original slug map (X — programmatic path).
6150
+ */
6151
+ function findCustomTool(map, slug) {
6152
+ if (!map) return void 0;
6153
+ const upper = slug.toUpperCase();
6154
+ return map.byFinalSlug.get(upper) ?? map.byOriginalSlug.get(upper);
6155
+ }
6156
+ /**
6157
+ * Execute a custom tool in-process.
6158
+ * Validates input via the Zod schema, calls the user's execute function,
6159
+ * and wraps the result into the standard response format.
6160
+ *
6161
+ * Callers provide a pre-built SessionContext (which may include sibling routing).
6162
+ */
6163
+ async function executeCustomTool(entry, arguments_, sessionContext) {
6164
+ const { handle } = entry;
6165
+ const parsed = handle.inputParams.safeParse(arguments_);
6166
+ if (!parsed.success) return {
6167
+ data: {},
6168
+ error: `Input validation failed: ${parsed.error.message}`,
6169
+ successful: false
6170
+ };
6171
+ try {
6172
+ return {
6173
+ data: await handle.execute(parsed.data, sessionContext) ?? {},
6174
+ error: null,
6175
+ successful: true
6176
+ };
6177
+ } catch (err) {
6178
+ return {
6179
+ data: {},
6180
+ error: err instanceof Error ? err.message : String(err),
6181
+ successful: false
6182
+ };
6183
+ }
6184
+ }
6185
+
6186
+ //#endregion
6187
+ //#region src/models/SessionContext.ts
6188
+ /**
6189
+ * Concrete implementation of SessionContext.
6190
+ * One instance is created per session (or per multi-execute batch) and shared
6191
+ * across all custom tool invocations, including sibling routing.
6192
+ *
6193
+ * When `customToolsMap` is provided, `execute()` checks local tools first
6194
+ * before falling back to the backend API. This allows tool A to call tool B
6195
+ * via `session.execute('B', ...)` without hitting the network.
6196
+ */
6197
+ var SessionContextImpl = class {
6198
+ userId;
6199
+ constructor(client, userId, sessionId, customToolsMap) {
6200
+ this.client = client;
6201
+ this.sessionId = sessionId;
6202
+ this.customToolsMap = customToolsMap;
6203
+ this.userId = userId;
6204
+ }
6205
+ /**
6206
+ * Execute any tool from within a custom tool.
6207
+ * Routes to sibling local tools in-process when available,
6208
+ * otherwise delegates to the backend API.
6209
+ */
6210
+ async execute(toolSlug, arguments_) {
6211
+ const entry = findCustomTool(this.customToolsMap, toolSlug);
6212
+ if (entry) return executeCustomTool(entry, arguments_, this);
6213
+ const response = await this.client.toolRouter.session.execute(this.sessionId, {
6214
+ tool_slug: toolSlug,
6215
+ arguments: arguments_
6216
+ });
6217
+ return {
6218
+ data: response.data,
6219
+ error: response.error,
6220
+ successful: !response.error
6221
+ };
6222
+ }
6223
+ /**
6224
+ * Proxy API calls through Composio's auth layer.
6225
+ * The backend resolves the connected account from the toolkit within the session.
6226
+ */
6227
+ async proxyExecute(params) {
6228
+ const validated = SessionProxyExecuteParamsSchema.safeParse(params);
6229
+ if (!validated.success) throw new require_CustomTool.ValidationError("Invalid proxy execute parameters", { cause: validated.error });
6230
+ const clientParams = transformProxyParams(validated.data);
6231
+ const response = await this.client.toolRouter.session.proxyExecute(this.sessionId, clientParams);
6232
+ return {
6233
+ status: response.status,
6234
+ data: response.data,
6235
+ headers: response.headers,
6236
+ ...response.binary_data ? { binaryData: {
6237
+ contentType: response.binary_data.content_type,
6238
+ size: response.binary_data.size,
6239
+ url: response.binary_data.url,
6240
+ expiresAt: response.binary_data.expires_at
6241
+ } } : {}
6242
+ };
6243
+ }
6244
+ };
6245
+
6573
6246
  //#endregion
6574
6247
  //#region src/models/ToolRouterSession.ts
6248
+ const COMPOSIO_MULTI_EXECUTE_TOOL = "COMPOSIO_MULTI_EXECUTE_TOOL";
6575
6249
  var ToolRouterSession = class {
6576
6250
  sessionId;
6577
6251
  mcp;
6578
6252
  experimental;
6579
- constructor(client, config, sessionId, mcp, experimentalOverrides) {
6253
+ /** Singleton session context — shared across all custom tool executions */
6254
+ sessionContext;
6255
+ constructor(client, config, sessionId, mcp, experimentalOverrides, customToolsMap, userId) {
6580
6256
  this.client = client;
6581
6257
  this.config = config;
6258
+ this.customToolsMap = customToolsMap;
6259
+ this.userId = userId;
6260
+ if (customToolsMap && !userId) throw new Error("userId is required when custom tools are bound to a session.");
6582
6261
  this.sessionId = sessionId;
6583
6262
  this.mcp = mcp;
6584
6263
  this.experimental = {
6585
6264
  assistivePrompt: experimentalOverrides?.assistivePrompt,
6586
6265
  files: new ToolRouterSessionFilesMount(client, sessionId)
6587
6266
  };
6267
+ if (customToolsMap && userId) this.sessionContext = new SessionContextImpl(client, userId, sessionId, customToolsMap);
6588
6268
  require_Telemetry.telemetry.instrument(this, "ToolRouterSession");
6589
6269
  }
6590
6270
  /**
6591
6271
  * Get the tools available in the session, formatted for your AI framework.
6592
6272
  * Requires a provider to be configured in the Composio constructor.
6273
+ *
6274
+ * When custom tools are bound to the session, execution of COMPOSIO_MULTI_EXECUTE_TOOL
6275
+ * is intercepted: local tools are executed in-process, remote tools are sent to the backend.
6593
6276
  */
6594
6277
  async tools(modifiers) {
6595
6278
  const ToolsModel = new Tools(this.client, this.config);
6596
6279
  const tools = await ToolsModel.getRawToolRouterMetaTools(this.sessionId, modifiers?.modifySchema ? { modifySchema: modifiers.modifySchema } : void 0);
6280
+ if (this.hasCustomTools()) {
6281
+ const routingExecuteFn = async (toolSlug, input) => {
6282
+ if (toolSlug === COMPOSIO_MULTI_EXECUTE_TOOL) return this.routeMultiExecute(input, ToolsModel, modifiers);
6283
+ return ToolsModel.executeMetaTool(toolSlug, {
6284
+ sessionId: this.sessionId,
6285
+ arguments: input
6286
+ }, modifiers);
6287
+ };
6288
+ if (!this.config?.provider) throw new Error("A provider is required when using custom tools with session.tools(). Pass a provider in the Composio constructor.");
6289
+ return this.config.provider.wrapTools(tools, routingExecuteFn);
6290
+ }
6597
6291
  return ToolsModel.wrapToolsForToolRouter(this.sessionId, tools, modifiers);
6598
6292
  }
6599
6293
  /**
6294
+ * List all custom tools registered in this session.
6295
+ * Returns tools with their final slugs, schemas, and resolved toolkit.
6296
+ *
6297
+ * @param options.toolkit - Filter by toolkit slug (e.g. 'gmail', 'DEV_TOOLS')
6298
+ * @returns Array of registered custom tools
6299
+ */
6300
+ customTools(options) {
6301
+ if (!this.customToolsMap) return [];
6302
+ const entries = Array.from(this.customToolsMap.byFinalSlug.values());
6303
+ return (options?.toolkit ? entries.filter((e) => e.toolkit?.toLowerCase() === options.toolkit.toLowerCase()) : entries).map((entry) => ({
6304
+ slug: entry.finalSlug,
6305
+ name: entry.handle.name,
6306
+ description: entry.handle.description,
6307
+ toolkit: entry.toolkit,
6308
+ inputSchema: entry.handle.inputSchema,
6309
+ outputSchema: entry.handle.outputSchema
6310
+ }));
6311
+ }
6312
+ /**
6313
+ * List all custom toolkits registered in this session.
6314
+ * Returns toolkits with their tools showing final slugs.
6315
+ *
6316
+ * @returns Array of registered custom toolkits
6317
+ */
6318
+ customToolkits() {
6319
+ const toolkits = this.customToolsMap?.toolkits;
6320
+ if (!toolkits?.length) return [];
6321
+ return toolkits.map((tk) => ({
6322
+ slug: tk.slug,
6323
+ name: tk.name,
6324
+ description: tk.description,
6325
+ tools: tk.tools.map((tool) => {
6326
+ return {
6327
+ slug: this.customToolsMap.byOriginalSlug.get(tool.slug.toUpperCase())?.finalSlug ?? tool.slug,
6328
+ name: tool.name,
6329
+ description: tool.description,
6330
+ toolkit: tk.slug,
6331
+ inputSchema: tool.inputSchema,
6332
+ outputSchema: tool.outputSchema
6333
+ };
6334
+ })
6335
+ }));
6336
+ }
6337
+ /**
6600
6338
  * Initiate an authorization flow for a toolkit.
6601
6339
  * Returns a ConnectionRequest with a redirect URL for the user.
6602
6340
  */
@@ -6613,7 +6351,7 @@ var ToolRouterSession = class {
6613
6351
  */
6614
6352
  async toolkits(options) {
6615
6353
  const toolkitOptions = ToolRouterToolkitsOptionsSchema.safeParse(options ?? {});
6616
- if (!toolkitOptions.success) throw new ValidationError("Failed to parse toolkits options", { cause: toolkitOptions.error });
6354
+ if (!toolkitOptions.success) throw new require_CustomTool.ValidationError("Failed to parse toolkits options", { cause: toolkitOptions.error });
6617
6355
  const result = await this.client.toolRouter.session.toolkits(this.sessionId, {
6618
6356
  cursor: toolkitOptions.data.nextCursor,
6619
6357
  limit: toolkitOptions.data.limit,
@@ -6649,20 +6387,6 @@ var ToolRouterSession = class {
6649
6387
  /**
6650
6388
  * Search for tools by semantic use case.
6651
6389
  * Returns relevant tools for the given query with schemas and guidance.
6652
- *
6653
- * @param params - Search parameters
6654
- * @param params.query - Semantic use-case query (e.g. "send emails", "create GitHub issues")
6655
- * @param params.toolkits - Optional toolkit slugs to filter by
6656
- * @returns Search results with matching tools and schemas
6657
- *
6658
- * @example
6659
- * ```typescript
6660
- * const session = await composio.toolRouter.use('session_123');
6661
- * const results = await session.search({
6662
- * query: 'send emails and notify Slack',
6663
- * toolkits: ['gmail', 'slack'],
6664
- * });
6665
- * ```
6666
6390
  */
6667
6391
  async search(params) {
6668
6392
  const transformed = transformSearchResponse(await this.client.toolRouter.session.search(this.sessionId, {
@@ -6674,33 +6398,142 @@ var ToolRouterSession = class {
6674
6398
  /**
6675
6399
  * Execute a tool within the session.
6676
6400
  *
6677
- * @param toolSlug - The tool slug to execute (e.g. "GMAIL_SEND_EMAIL")
6678
- * @param arguments_ - Optional tool arguments. Defaults to empty object if omitted.
6679
- * @returns The tool execution result
6401
+ * For custom tools, accepts the original slug (e.g. "GREP") or the
6402
+ * full slug (e.g. "LOCAL_GREP"). Custom tools are executed in-process;
6403
+ * remote tools are sent to the Composio backend.
6680
6404
  *
6681
- * @example
6682
- * ```typescript
6683
- * const session = await composio.toolRouter.use('session_123');
6684
- * const result = await session.execute('GMAIL_SEND_EMAIL', {
6685
- * to: 'user@example.com',
6686
- * subject: 'Hello',
6687
- * body: 'Hi!',
6688
- * });
6689
- * ```
6690
- *
6691
- * @example
6692
- * ```typescript
6693
- * // Execute with no arguments
6694
- * const result = await session.execute('HACKERNEWS_GET_USER');
6695
- * ```
6405
+ * @param toolSlug - The tool slug to execute
6406
+ * @param arguments_ - Optional tool arguments
6407
+ * @returns The tool execution result
6696
6408
  */
6697
6409
  async execute(toolSlug, arguments_) {
6410
+ const entry = findCustomTool(this.customToolsMap, toolSlug);
6411
+ if (entry) {
6412
+ const result = await executeCustomTool(entry, arguments_ ?? {}, this.sessionContext);
6413
+ return {
6414
+ data: result.data,
6415
+ error: result.error,
6416
+ logId: ""
6417
+ };
6418
+ }
6698
6419
  const transformed = transformExecuteResponse(await this.client.toolRouter.session.execute(this.sessionId, {
6699
6420
  tool_slug: toolSlug,
6700
6421
  arguments: arguments_ ?? {}
6701
6422
  }));
6702
6423
  return ToolRouterSessionExecuteResponseSchema.parse(transformed);
6703
6424
  }
6425
+ /**
6426
+ * Proxy an API call through Composio's auth layer using the session's connected account.
6427
+ * The backend resolves the connected account from the toolkit within the session.
6428
+ *
6429
+ * @param params - Proxy request parameters (toolkit, endpoint, method, body, headers/query params)
6430
+ * @returns The proxied API response with status, data, headers
6431
+ */
6432
+ async proxyExecute(params) {
6433
+ const validated = SessionProxyExecuteParamsSchema.safeParse(params);
6434
+ if (!validated.success) throw new require_CustomTool.ValidationError("Invalid proxy execute parameters", { cause: validated.error });
6435
+ const clientParams = transformProxyParams(validated.data);
6436
+ const response = await this.client.toolRouter.session.proxyExecute(this.sessionId, clientParams);
6437
+ return {
6438
+ status: response.status,
6439
+ data: response.data,
6440
+ headers: response.headers,
6441
+ ...response.binary_data ? { binaryData: {
6442
+ contentType: response.binary_data.content_type,
6443
+ size: response.binary_data.size,
6444
+ url: response.binary_data.url,
6445
+ expiresAt: response.binary_data.expires_at
6446
+ } } : {}
6447
+ };
6448
+ }
6449
+ /** Check if this session has any custom tools bound. */
6450
+ hasCustomTools() {
6451
+ return (this.customToolsMap?.byFinalSlug.size ?? 0) > 0;
6452
+ }
6453
+ /** Parse an individual tool item from COMPOSIO_MULTI_EXECUTE_TOOL's tools array */
6454
+ parseToolItem(item) {
6455
+ if (typeof item !== "object" || item === null) return {
6456
+ tool_slug: "",
6457
+ arguments: {}
6458
+ };
6459
+ const obj = item;
6460
+ return {
6461
+ tool_slug: String(obj.tool_slug ?? ""),
6462
+ arguments: obj.arguments ?? {}
6463
+ };
6464
+ }
6465
+ /**
6466
+ * Route a COMPOSIO_MULTI_EXECUTE_TOOL call.
6467
+ * Splits the tools[] array into local and remote, executes each appropriately,
6468
+ * and merges results preserving original order.
6469
+ */
6470
+ async routeMultiExecute(input, ToolsModel, modifiers) {
6471
+ const toolItems = input.tools;
6472
+ if (!Array.isArray(toolItems) || toolItems.length === 0) return ToolsModel.executeMetaTool(COMPOSIO_MULTI_EXECUTE_TOOL, {
6473
+ sessionId: this.sessionId,
6474
+ arguments: input
6475
+ }, modifiers);
6476
+ const parsed = toolItems.map((item) => this.parseToolItem(item));
6477
+ const localItems = [];
6478
+ const remoteIndices = [];
6479
+ for (let i = 0; i < parsed.length; i++) {
6480
+ const entry = findCustomTool(this.customToolsMap, parsed[i].tool_slug);
6481
+ if (entry) localItems.push({
6482
+ index: i,
6483
+ entry
6484
+ });
6485
+ else remoteIndices.push(i);
6486
+ }
6487
+ if (localItems.length === 0) return ToolsModel.executeMetaTool(COMPOSIO_MULTI_EXECUTE_TOOL, {
6488
+ sessionId: this.sessionId,
6489
+ arguments: input
6490
+ }, modifiers);
6491
+ const ctx = this.sessionContext;
6492
+ const localPromises = localItems.map(async ({ index, entry }) => {
6493
+ return {
6494
+ index,
6495
+ result: await executeCustomTool(entry, parsed[index].arguments, ctx)
6496
+ };
6497
+ });
6498
+ let remotePromise;
6499
+ if (remoteIndices.length > 0) {
6500
+ const remoteToolItems = remoteIndices.map((i) => toolItems[i]);
6501
+ const remoteInput = {
6502
+ ...input,
6503
+ tools: remoteToolItems
6504
+ };
6505
+ remotePromise = ToolsModel.executeMetaTool(COMPOSIO_MULTI_EXECUTE_TOOL, {
6506
+ sessionId: this.sessionId,
6507
+ arguments: remoteInput
6508
+ }, modifiers);
6509
+ }
6510
+ const [localResults, remoteResult] = await Promise.all([Promise.all(localPromises), remotePromise]);
6511
+ if (remoteIndices.length === 0 && localResults.length === 1) return localResults[0].result;
6512
+ const remoteData = remoteResult?.data ?? {};
6513
+ const remoteResults = Array.isArray(remoteData.results) ? remoteData.results : [];
6514
+ const localEntries = localResults.map(({ index, result }) => ({
6515
+ response: {
6516
+ successful: result.successful,
6517
+ data: result.data,
6518
+ ...result.error ? { error: result.error } : {}
6519
+ },
6520
+ tool_slug: parsed[index].tool_slug,
6521
+ ...result.error ? { error: result.error } : {}
6522
+ }));
6523
+ const allResults = [...remoteResults, ...localEntries].map((entry, i) => ({
6524
+ ...entry,
6525
+ index: i
6526
+ }));
6527
+ const hasAnyError = localResults.some((r) => r.result.error) || !!remoteResult?.error;
6528
+ return {
6529
+ data: {
6530
+ ...remoteData,
6531
+ results: allResults
6532
+ },
6533
+ error: hasAnyError ? `${allResults.filter((r) => r.error).length} out of ${allResults.length} tools failed` : null,
6534
+ successful: !hasAnyError
6535
+ };
6536
+ }
6704
6537
  };
6705
6538
 
6706
6539
  //#endregion
@@ -6727,34 +6560,28 @@ var ToolRouter = class {
6727
6560
  *
6728
6561
  * @example
6729
6562
  * ```typescript
6730
- * import { Composio } from '@composio/core';
6563
+ * import { Composio, experimental_createTool } from '@composio/core';
6731
6564
  *
6732
6565
  * const composio = new Composio();
6733
- * const userId = 'user_123';
6734
6566
  *
6735
- * const session = await composio.experimental.create(userId, {
6567
+ * const session = await composio.create('user_123', {
6736
6568
  * toolkits: ['gmail'],
6737
6569
  * manageConnections: true,
6738
- * tools: {
6739
- * gmail: {
6740
- * disabled: ['gmail_send_email']
6741
- * }
6570
+ * experimental: {
6571
+ * customTools: [myCustomTool],
6572
+ * customToolkits: [myToolkit],
6742
6573
  * },
6743
- * tags: ['readOnlyHint']
6744
6574
  * });
6745
- *
6746
- * console.log(session.sessionId);
6747
- * console.log(session.mcp.url);
6748
- *
6749
- * // Get tools formatted for your framework (requires provider)
6750
- * const tools = await session.tools();
6751
- *
6752
- * // Check toolkit connection states
6753
- * const toolkits = await session.toolkits();
6754
6575
  * ```
6755
6576
  */
6756
6577
  async create(userId, config) {
6757
6578
  const routerConfig = ToolRouterCreateSessionConfigSchema.parse(config ?? {});
6579
+ const customTools = routerConfig.experimental?.customTools;
6580
+ const customToolkits = routerConfig.experimental?.customToolkits;
6581
+ const experimentalPayload = {};
6582
+ if (routerConfig.experimental?.assistivePrompt?.userTimezone) experimentalPayload.assistive_prompt_config = { user_timezone: routerConfig.experimental.assistivePrompt.userTimezone };
6583
+ if (customTools?.length) experimentalPayload.custom_tools = require_CustomTool.serializeCustomTools(customTools);
6584
+ if (customToolkits?.length) experimentalPayload.custom_toolkits = require_CustomTool.serializeCustomToolkits(customToolkits);
6758
6585
  const payload = {
6759
6586
  user_id: userId,
6760
6587
  auth_configs: routerConfig.authConfigs,
@@ -6764,11 +6591,13 @@ var ToolRouter = class {
6764
6591
  tags: transformToolRouterTagsParams(routerConfig.tags),
6765
6592
  manage_connections: transformToolRouterManageConnectionsParams(routerConfig.manageConnections),
6766
6593
  workbench: transformToolRouterWorkbenchParams(routerConfig.workbench),
6767
- experimental: routerConfig.experimental?.assistivePrompt?.userTimezone ? { assistive_prompt_config: { user_timezone: routerConfig.experimental.assistivePrompt.userTimezone } } : void 0
6594
+ experimental: Object.keys(experimentalPayload).length > 0 ? experimentalPayload : void 0
6768
6595
  };
6769
6596
  const session = await this.client.toolRouter.session.create(payload);
6597
+ let customToolsMap;
6598
+ if (customTools?.length || customToolkits?.length) customToolsMap = require_CustomTool.buildCustomToolsMapFromResponse(customTools ?? [], customToolkits, session.experimental);
6770
6599
  const assistivePrompt = session.experimental?.assistive_prompt;
6771
- return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), { assistivePrompt });
6600
+ return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), { assistivePrompt }, customToolsMap, userId);
6772
6601
  }
6773
6602
  /**
6774
6603
  * Use an existing session
@@ -6897,7 +6726,7 @@ var Composio = class Composio {
6897
6726
  */
6898
6727
  constructor(config) {
6899
6728
  const { baseURL: baseURLParsed, apiKey: apiKeyParsed } = getSDKConfig(config?.baseURL, config?.apiKey);
6900
- if (require_buffer.IS_DEVELOPMENT_OR_CI) require_buffer.logger_default.debug(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
6729
+ if (require_ComposioError.IS_DEVELOPMENT_OR_CI) require_ComposioError.logger_default.debug(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
6901
6730
  /**
6902
6731
  * Set the default provider, if not provided by the user.
6903
6732
  */
@@ -6923,7 +6752,7 @@ var Composio = class Composio {
6923
6752
  apiKey: apiKeyParsed,
6924
6753
  baseURL: baseURLParsed,
6925
6754
  defaultHeaders: getDefaultHeaders(this.config.defaultHeaders, this.provider),
6926
- logLevel: require_buffer.COMPOSIO_LOG_LEVEL
6755
+ logLevel: require_ComposioError.COMPOSIO_LOG_LEVEL
6927
6756
  });
6928
6757
  this.tools = new Tools(this.client, this.config);
6929
6758
  this.mcp = new MCP(this.client);
@@ -7119,7 +6948,7 @@ function jsonSchemaToZodSchema(jsonSchema, { strict } = { strict: false }) {
7119
6948
  if (strict && schema) schema = removeNonRequiredProperties(schema);
7120
6949
  return (0, _composio_json_schema_to_zod.jsonSchemaToZod)(schema);
7121
6950
  } catch (error) {
7122
- throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", { cause: error });
6951
+ throw new require_CustomTool.JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", { cause: error });
7123
6952
  }
7124
6953
  }
7125
6954
 
@@ -7601,7 +7430,7 @@ const ComposioMcpUpdateResponseSchema = zod_v3.z.object({
7601
7430
 
7602
7431
  //#endregion
7603
7432
  exports.AuthConfigCreationToolAccessConfigSchema = AuthConfigCreationToolAccessConfigSchema;
7604
- exports.AuthConfigErrorCodes = AuthConfigErrorCodes;
7433
+ exports.AuthConfigErrorCodes = require_CustomTool.AuthConfigErrorCodes;
7605
7434
  exports.AuthConfigListParamsSchema = AuthConfigListParamsSchema;
7606
7435
  exports.AuthConfigListResponseSchema = AuthConfigListResponseSchema;
7607
7436
  exports.AuthConfigRetrieveResponseSchema = AuthConfigRetrieveResponseSchema;
@@ -7617,39 +7446,39 @@ exports.BaseAgenticProvider = BaseAgenticProvider;
7617
7446
  exports.BaseNonAgenticProvider = BaseNonAgenticProvider;
7618
7447
  exports.BillcomAuthConnectionDataSchema = BillcomAuthConnectionDataSchema;
7619
7448
  exports.Composio = Composio;
7620
- exports.ComposioAuthConfigNotFoundError = ComposioAuthConfigNotFoundError;
7621
- exports.ComposioConnectedAccountNotFoundError = ComposioConnectedAccountNotFoundError;
7449
+ exports.ComposioAuthConfigNotFoundError = require_CustomTool.ComposioAuthConfigNotFoundError;
7450
+ exports.ComposioConnectedAccountNotFoundError = require_CustomTool.ComposioConnectedAccountNotFoundError;
7622
7451
  exports.ComposioCustomCreateResponseSchema = ComposioCustomCreateResponseSchema;
7623
- exports.ComposioCustomToolsNotInitializedError = ComposioCustomToolsNotInitializedError;
7624
- exports.ComposioError = require_buffer.ComposioError;
7625
- exports.ComposioFailedToCreateConnectedAccountLink = ComposioFailedToCreateConnectedAccountLink;
7626
- exports.ComposioFailedToCreatePusherClientError = ComposioFailedToCreatePusherClientError;
7627
- exports.ComposioFailedToGetSDKRealtimeCredentialsError = ComposioFailedToGetSDKRealtimeCredentialsError;
7628
- exports.ComposioFailedToSubscribeToPusherChannelError = ComposioFailedToSubscribeToPusherChannelError;
7629
- exports.ComposioFailedToUnsubscribeFromPusherChannelError = ComposioFailedToUnsubscribeFromPusherChannelError;
7452
+ exports.ComposioCustomToolsNotInitializedError = require_CustomTool.ComposioCustomToolsNotInitializedError;
7453
+ exports.ComposioError = require_ComposioError.ComposioError;
7454
+ exports.ComposioFailedToCreateConnectedAccountLink = require_CustomTool.ComposioFailedToCreateConnectedAccountLink;
7455
+ exports.ComposioFailedToCreatePusherClientError = require_CustomTool.ComposioFailedToCreatePusherClientError;
7456
+ exports.ComposioFailedToGetSDKRealtimeCredentialsError = require_CustomTool.ComposioFailedToGetSDKRealtimeCredentialsError;
7457
+ exports.ComposioFailedToSubscribeToPusherChannelError = require_CustomTool.ComposioFailedToSubscribeToPusherChannelError;
7458
+ exports.ComposioFailedToUnsubscribeFromPusherChannelError = require_CustomTool.ComposioFailedToUnsubscribeFromPusherChannelError;
7630
7459
  exports.ComposioGenerateURLParamsSchema = ComposioGenerateURLParamsSchema;
7631
7460
  exports.ComposioGenerateURLResponseSchema = ComposioGenerateURLResponseSchema;
7632
- exports.ComposioGlobalExecuteToolFnNotSetError = ComposioGlobalExecuteToolFnNotSetError;
7633
- exports.ComposioInvalidExecuteFunctionError = ComposioInvalidExecuteFunctionError;
7634
- exports.ComposioInvalidModifierError = ComposioInvalidModifierError;
7461
+ exports.ComposioGlobalExecuteToolFnNotSetError = require_CustomTool.ComposioGlobalExecuteToolFnNotSetError;
7462
+ exports.ComposioInvalidExecuteFunctionError = require_CustomTool.ComposioInvalidExecuteFunctionError;
7463
+ exports.ComposioInvalidModifierError = require_CustomTool.ComposioInvalidModifierError;
7635
7464
  exports.ComposioMcpDeleteResponseSchema = ComposioMcpDeleteResponseSchema;
7636
7465
  exports.ComposioMcpListResponseSchema = ComposioMcpListResponseSchema;
7637
7466
  exports.ComposioMcpRetrieveResponseSchema = ComposioMcpRetrieveResponseSchema;
7638
7467
  exports.ComposioMcpUpdateResponseSchema = ComposioMcpUpdateResponseSchema;
7639
- exports.ComposioMultipleConnectedAccountsError = ComposioMultipleConnectedAccountsError;
7640
- exports.ComposioNoAPIKeyError = ComposioNoAPIKeyError;
7468
+ exports.ComposioMultipleConnectedAccountsError = require_CustomTool.ComposioMultipleConnectedAccountsError;
7469
+ exports.ComposioNoAPIKeyError = require_CustomTool.ComposioNoAPIKeyError;
7641
7470
  exports.ComposioProvider = ComposioProvider;
7642
- exports.ComposioProviderNotDefinedError = ComposioProviderNotDefinedError;
7643
- exports.ComposioToolExecutionError = ComposioToolExecutionError;
7644
- exports.ComposioToolNotFoundError = ComposioToolNotFoundError;
7645
- exports.ComposioToolVersionRequiredError = ComposioToolVersionRequiredError;
7646
- exports.ComposioToolkitFetchError = ComposioToolkitFetchError;
7647
- exports.ComposioToolkitNotFoundError = ComposioToolkitNotFoundError;
7648
- exports.ComposioTriggerTypeNotFoundError = ComposioTriggerTypeNotFoundError;
7649
- exports.ComposioWebhookPayloadError = ComposioWebhookPayloadError;
7650
- exports.ComposioWebhookSignatureVerificationError = ComposioWebhookSignatureVerificationError;
7471
+ exports.ComposioProviderNotDefinedError = require_CustomTool.ComposioProviderNotDefinedError;
7472
+ exports.ComposioToolExecutionError = require_CustomTool.ComposioToolExecutionError;
7473
+ exports.ComposioToolNotFoundError = require_CustomTool.ComposioToolNotFoundError;
7474
+ exports.ComposioToolVersionRequiredError = require_CustomTool.ComposioToolVersionRequiredError;
7475
+ exports.ComposioToolkitFetchError = require_CustomTool.ComposioToolkitFetchError;
7476
+ exports.ComposioToolkitNotFoundError = require_CustomTool.ComposioToolkitNotFoundError;
7477
+ exports.ComposioTriggerTypeNotFoundError = require_CustomTool.ComposioTriggerTypeNotFoundError;
7478
+ exports.ComposioWebhookPayloadError = require_CustomTool.ComposioWebhookPayloadError;
7479
+ exports.ComposioWebhookSignatureVerificationError = require_CustomTool.ComposioWebhookSignatureVerificationError;
7651
7480
  exports.ConnectedAccountAuthConfigSchema = ConnectedAccountAuthConfigSchema;
7652
- exports.ConnectedAccountErrorCodes = ConnectedAccountErrorCodes;
7481
+ exports.ConnectedAccountErrorCodes = require_CustomTool.ConnectedAccountErrorCodes;
7653
7482
  exports.ConnectedAccountListParamsSchema = ConnectedAccountListParamsSchema;
7654
7483
  exports.ConnectedAccountListResponseSchema = ConnectedAccountListResponseSchema;
7655
7484
  exports.ConnectedAccountRefreshOptionsSchema = ConnectedAccountRefreshOptionsSchema;
@@ -7658,9 +7487,9 @@ exports.ConnectedAccountStatusSchema = ConnectedAccountStatusSchema;
7658
7487
  exports.ConnectedAccountStatuses = ConnectedAccountStatuses;
7659
7488
  exports.ConnectionDataSchema = ConnectionDataSchema;
7660
7489
  exports.ConnectionExpiredEventSchema = ConnectionExpiredEventSchema;
7661
- exports.ConnectionRequestErrorCodes = ConnectionRequestErrorCodes;
7662
- exports.ConnectionRequestFailedError = ConnectionRequestFailedError;
7663
- exports.ConnectionRequestTimeoutError = ConnectionRequestTimeoutError;
7490
+ exports.ConnectionRequestErrorCodes = require_CustomTool.ConnectionRequestErrorCodes;
7491
+ exports.ConnectionRequestFailedError = require_CustomTool.ConnectionRequestFailedError;
7492
+ exports.ConnectionRequestTimeoutError = require_CustomTool.ConnectionRequestTimeoutError;
7664
7493
  exports.ConnectionStatus = ConnectionStatus;
7665
7494
  exports.ConnectionStatuses = ConnectionStatuses;
7666
7495
  exports.CreateAuthConfigParamsSchema = CreateAuthConfigParamsSchema;
@@ -7672,11 +7501,14 @@ exports.CreateConnectedAccountOptionsSchema = CreateConnectedAccountOptionsSchem
7672
7501
  exports.CreateConnectedAccountParamsSchema = CreateConnectedAccountParamsSchema;
7673
7502
  exports.CreateConnectedAccountResponseSchema = CreateConnectedAccountResponseSchema;
7674
7503
  exports.CreateCustomAuthConfigParamsSchema = CreateCustomAuthConfigParamsSchema;
7504
+ exports.CreateCustomToolBaseSchema = require_CustomTool.CreateCustomToolBaseSchema;
7505
+ exports.CreateCustomToolkitBaseSchema = require_CustomTool.CreateCustomToolkitBaseSchema;
7675
7506
  exports.CustomAuthParamsSchema = CustomAuthParamsSchema;
7676
7507
  exports.CustomConnectionDataSchema = CustomConnectionDataSchema;
7677
7508
  exports.CustomCreateResponseSchema = CustomCreateResponseSchema;
7678
7509
  exports.CustomOauth1ConnectionDataSchema = CustomOauth1ConnectionDataSchema;
7679
7510
  exports.CustomOauth2ConnectionDataSchema = CustomOauth2ConnectionDataSchema;
7511
+ exports.CustomToolSlugSchema = require_CustomTool.CustomToolSlugSchema;
7680
7512
  exports.DefaultCreateConnectedAccountParamsSchema = DefaultCreateConnectedAccountParamsSchema;
7681
7513
  exports.FileDeleteResponseSchema = FileDeleteResponseSchema;
7682
7514
  exports.FileListResponseSchema = FileListResponseSchema;
@@ -7684,7 +7516,7 @@ exports.GenerateURLParamsSchema = GenerateURLParamsSchema;
7684
7516
  exports.GenerateURLResponseSchema = GenerateURLResponseSchema;
7685
7517
  exports.IncomingTriggerPayloadSchema = IncomingTriggerPayloadSchema;
7686
7518
  exports.JSONSchemaPropertySchema = JSONSchemaPropertySchema;
7687
- exports.JsonSchemaToZodError = JsonSchemaToZodError;
7519
+ exports.JsonSchemaToZodError = require_CustomTool.JsonSchemaToZodError;
7688
7520
  exports.MCP = MCP;
7689
7521
  exports.MCPAuthOptionsSchema = MCPAuthOptionsSchema;
7690
7522
  exports.MCPGenerateURLParamsSchema = MCPGenerateURLParamsSchema;
@@ -7720,11 +7552,12 @@ exports.OpenAIProvider = OpenAIProvider;
7720
7552
  exports.RedirectableAuthSchemeSchema = RedirectableAuthSchemeSchema;
7721
7553
  exports.RemoteFile = RemoteFile;
7722
7554
  exports.RemoteFileDataSchema = RemoteFileDataSchema;
7723
- exports.RemoteFileDownloadError = RemoteFileDownloadError;
7724
- exports.RemoteFileErrorCodes = RemoteFileErrorCodes;
7725
- exports.SDKErrorCodes = SDKErrorCodes;
7555
+ exports.RemoteFileDownloadError = require_CustomTool.RemoteFileDownloadError;
7556
+ exports.RemoteFileErrorCodes = require_CustomTool.RemoteFileErrorCodes;
7557
+ exports.SDKErrorCodes = require_CustomTool.SDKErrorCodes;
7558
+ exports.SessionProxyExecuteParamsSchema = SessionProxyExecuteParamsSchema;
7726
7559
  exports.SingleConnectedAccountDetailedResponseSchema = SingleConnectedAccountDetailedResponseSchema;
7727
- exports.ToolErrorCodes = ToolErrorCodes;
7560
+ exports.ToolErrorCodes = require_CustomTool.ToolErrorCodes;
7728
7561
  exports.ToolExecuteMetaParamsSchema = ToolExecuteMetaParamsSchema;
7729
7562
  exports.ToolExecuteParamsSchema = ToolExecuteParamsSchema;
7730
7563
  exports.ToolExecuteResponseSchema = ToolExecuteResponseSchema;
@@ -7761,7 +7594,7 @@ exports.ToolkitAuthFieldsResponseSchema = ToolkitAuthFieldsResponseSchema;
7761
7594
  exports.ToolkitCategorySchema = ToolkitCategorySchema;
7762
7595
  exports.ToolkitConnectionStateSchema = ToolkitConnectionStateSchema;
7763
7596
  exports.ToolkitConnectionsDetailsSchema = ToolkitConnectionsDetailsSchema;
7764
- exports.ToolkitErrorCodes = ToolkitErrorCodes;
7597
+ exports.ToolkitErrorCodes = require_CustomTool.ToolkitErrorCodes;
7765
7598
  exports.ToolkitLatestVersionSchema = ToolkitLatestVersionSchema;
7766
7599
  exports.ToolkitMangedByEnumSchema = ToolkitMangedByEnumSchema;
7767
7600
  exports.ToolkitRetrieveCategoriesResponseSchema = ToolkitRetrieveCategoriesResponseSchema;
@@ -7772,7 +7605,7 @@ exports.ToolkitVersionParamSchema = ToolkitVersionParamSchema;
7772
7605
  exports.ToolkitVersionSchema = ToolkitVersionSchema;
7773
7606
  exports.ToolkitVersionsSchema = ToolkitVersionsSchema;
7774
7607
  exports.ToolkitsListParamsSchema = ToolkitsListParamsSchema;
7775
- exports.TriggerErrorCodes = TriggerErrorCodes;
7608
+ exports.TriggerErrorCodes = require_CustomTool.TriggerErrorCodes;
7776
7609
  exports.TriggerInstanceListActiveParamsSchema = TriggerInstanceListActiveParamsSchema;
7777
7610
  exports.TriggerInstanceListActiveResponseItemSchema = TriggerInstanceListActiveResponseItemSchema;
7778
7611
  exports.TriggerInstanceListActiveResponseSchema = TriggerInstanceListActiveResponseSchema;
@@ -7787,8 +7620,8 @@ exports.TriggerSubscribeParamSchema = TriggerSubscribeParamSchema;
7787
7620
  exports.TriggerTypeSchema = TriggerTypeSchema;
7788
7621
  exports.TriggersTypeListParamsSchema = TriggersTypeListParamsSchema;
7789
7622
  exports.TriggersTypeListResponseSchema = TriggersTypeListResponseSchema;
7790
- exports.ValidationError = ValidationError;
7791
- exports.ValidationErrorCodes = ValidationErrorCodes;
7623
+ exports.ValidationError = require_CustomTool.ValidationError;
7624
+ exports.ValidationErrorCodes = require_CustomTool.ValidationErrorCodes;
7792
7625
  exports.VerifyWebhookParamsSchema = VerifyWebhookParamsSchema;
7793
7626
  exports.WebhookConnectedAccountAuthConfigSchema = WebhookConnectedAccountAuthConfigSchema;
7794
7627
  exports.WebhookConnectionMetadataSchema = WebhookConnectionMetadataSchema;
@@ -7804,12 +7637,14 @@ exports.WebhookVersions = WebhookVersions;
7804
7637
  Object.defineProperty(exports, 'constants', {
7805
7638
  enumerable: true,
7806
7639
  get: function () {
7807
- return require_buffer.constants_exports;
7640
+ return require_ComposioError.constants_exports;
7808
7641
  }
7809
7642
  });
7810
7643
  exports.createConnectionRequest = createConnectionRequest;
7644
+ exports.experimental_createTool = require_CustomTool.createCustomTool;
7645
+ exports.experimental_createToolkit = require_CustomTool.createCustomToolkit;
7811
7646
  exports.getExtensionFromMimeType = getExtensionFromMimeType;
7812
- exports.handleToolExecutionError = handleToolExecutionError;
7647
+ exports.handleToolExecutionError = require_CustomTool.handleToolExecutionError;
7813
7648
  exports.jsonSchemaToZodSchema = jsonSchemaToZodSchema;
7814
- exports.logger = require_buffer.logger_default;
7649
+ exports.logger = require_ComposioError.logger_default;
7815
7650
  exports.removeNonRequiredProperties = removeNonRequiredProperties;