@composio/core 0.6.5 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{buffer-Dy7Xi_sk.cjs → ComposioError-CYaI68Mo.cjs} +1 -63
- package/dist/{buffer-C1MwV-7j.mjs → ComposioError-ChkSdxqU.mjs} +3 -35
- package/dist/CustomTool-BlpMy_R5.d.cts +75 -0
- package/dist/CustomTool-C1q7Y3Nq.mjs +743 -0
- package/dist/CustomTool-CZZbiZgh.d.mts +75 -0
- package/dist/CustomTool-G2lKa7eb.cjs +1014 -0
- package/dist/{Telemetry-DRFfIuVS.cjs → Telemetry-A89k5RTv.cjs} +18 -17
- package/dist/{Telemetry-CHfDfthM.mjs → Telemetry-CjVa99gU.mjs} +2 -1
- package/dist/buffer-BjWptbNH.cjs +63 -0
- package/dist/buffer-yOtEsT4J.mjs +33 -0
- package/dist/{composio-BC28OAhR.d.mts → composio-CbZbGwhD.d.mts} +67 -1692
- package/dist/{composio-BBswEUus.d.cts → composio-Yl_Y7F6u.d.cts} +67 -1692
- package/dist/customTool.types-CEo_oLEU.d.mts +1860 -0
- package/dist/customTool.types-CzBEXJw5.d.cts +1860 -0
- package/dist/experimental/index.cjs +5 -0
- package/dist/experimental/index.d.cts +3 -0
- package/dist/experimental/index.d.mts +4 -0
- package/dist/experimental/index.mjs +5 -0
- package/dist/{fileUtils.node-D1JLL4nZ.mjs → fileUtils.node-BOZnseMe.mjs} +2 -1
- package/dist/{fileUtils.node-BUe2eO0j.cjs → fileUtils.node-DF-AY0Td.cjs} +10 -9
- package/dist/index.cjs +552 -715
- package/dist/index.d.cts +61 -43
- package/dist/index.d.mts +61 -43
- package/dist/index.mjs +366 -535
- package/dist/models/Files.node.cjs +3 -3
- package/dist/models/Files.node.d.cts +1 -1
- package/dist/models/Files.node.d.mts +1 -1
- package/dist/models/Files.node.mjs +4 -4
- package/dist/platform/node.d.cts +1 -1
- package/dist/platform/node.d.mts +1 -1
- package/dist/platform/workerd.d.cts +1 -1
- package/dist/platform/workerd.d.mts +1 -1
- package/dist/{BaseProvider-SxQ_komh.d.cts → tool.types-BWc7GUrD.d.cts} +10904 -10905
- package/dist/{BaseProvider-CaOKzzuo.d.mts → tool.types-bencsexi.d.mts} +10904 -10905
- package/dist/{types-DY0bIIqG.d.mts → types-C_HOnR64.d.cts} +2 -2
- package/dist/{types-CHz185FL.d.cts → types-e_z7dQdL.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +4 -3
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +4 -3
- package/dist/utils/modifiers/FileToolModifier.node.cjs +8 -8
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +4 -4
- package/dist/utils/modifiers/FileToolModifier.workerd.cjs +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/package.json +17 -3
- package/generated/ably.ts +0 -20
- package/generated/accelo.ts +0 -8
- package/generated/acculynx.ts +0 -17
- package/generated/active_campaign.ts +0 -30
- package/generated/adobe.ts +0 -8
- package/generated/adyntel.ts +0 -12
- package/generated/aero_workflow.ts +0 -8
- package/generated/affinity.ts +0 -29
- package/generated/agencyzoom.ts +0 -108
- package/generated/ahrefs.ts +0 -49
- package/generated/airtable.ts +0 -26
- package/generated/alchemy.ts +0 -16
- package/generated/algolia.ts +0 -39
- package/generated/altoviz.ts +0 -18
- package/generated/amazon.ts +0 -8
- package/generated/amcards.ts +0 -11
- package/generated/amplitude.ts +0 -25
- package/generated/anthropic_administrator.ts +0 -13
- package/generated/apaleo.ts +0 -38
- package/generated/apollo.ts +0 -40
- package/generated/appdrag.ts +0 -8
- package/generated/appsflyer.ts +0 -8
- package/generated/asana.ts +0 -95
- package/generated/ashby.ts +0 -8
- package/generated/atlassian.ts +0 -8
- package/generated/attio.ts +0 -20
- package/generated/auth0.ts +0 -8
- package/generated/axonaut.ts +0 -8
- package/generated/bamboohr.ts +0 -168
- package/generated/bannerbear.ts +0 -17
- package/generated/baserow.ts +0 -11
- package/generated/battlenet.ts +0 -8
- package/generated/beeminder.ts +0 -14
- package/generated/bigmailer.ts +0 -12
- package/generated/bigml.ts +0 -15
- package/generated/bill.ts +0 -218
- package/generated/bitbucket.ts +0 -25
- package/generated/bitwarden.ts +0 -8
- package/generated/blackbaud.ts +0 -8
- package/generated/blackboard.ts +0 -323
- package/generated/boldsign.ts +0 -8
- package/generated/bolna.ts +0 -24
- package/generated/borneo.ts +0 -162
- package/generated/botbaba.ts +0 -8
- package/generated/box.ts +0 -282
- package/generated/braintree.ts +0 -8
- package/generated/brandfetch.ts +0 -15
- package/generated/breezy_hr.ts +0 -8
- package/generated/brevo.ts +0 -28
- package/generated/brex.ts +0 -8
- package/generated/brex_staging.ts +0 -8
- package/generated/brightpearl.ts +0 -8
- package/generated/brilliant_directories.ts +0 -15
- package/generated/browseai.ts +0 -18
- package/generated/browserbase_tool.ts +0 -10
- package/generated/browserhub.ts +0 -8
- package/generated/browserless.ts +0 -16
- package/generated/bubble.ts +0 -8
- package/generated/bugbug.ts +0 -13
- package/generated/builtwith.ts +0 -21
- package/generated/cal.ts +0 -150
- package/generated/calendly.ts +0 -51
- package/generated/canva.ts +0 -41
- package/generated/canvas.ts +0 -100
- package/generated/chatwork.ts +0 -17
- package/generated/chmeetings.ts +0 -8
- package/generated/clickup.ts +0 -153
- package/generated/clockify.ts +0 -23
- package/generated/close.ts +0 -15
- package/generated/cloudflare.ts +0 -10
- package/generated/coda.ts +0 -115
- package/generated/codeinterpreter.ts +0 -14
- package/generated/coinbase.ts +0 -15
- package/generated/coinmarketcal.ts +0 -8
- package/generated/composio.ts +0 -34
- package/generated/composio_search.ts +0 -22
- package/generated/confluence.ts +0 -199
- package/generated/contentful.ts +0 -12
- package/generated/crustdata.ts +0 -23
- package/generated/customer_io.ts +0 -8
- package/generated/cutt_ly.ts +0 -10
- package/generated/d2lbrightspace.ts +0 -54
- package/generated/dailybot.ts +0 -15
- package/generated/datadog.ts +0 -47
- package/generated/datagma.ts +0 -8
- package/generated/datarobot.ts +0 -8
- package/generated/deel.ts +0 -8
- package/generated/demio.ts +0 -8
- package/generated/dialpad.ts +0 -201
- package/generated/digicert.ts +0 -15
- package/generated/discord.ts +0 -17
- package/generated/discordbot.ts +0 -173
- package/generated/docmosis.ts +0 -8
- package/generated/docusign.ts +0 -351
- package/generated/dropbox.ts +0 -20
- package/generated/dropbox_sign.ts +0 -8
- package/generated/dynamics365.ts +0 -25
- package/generated/echtpost.ts +0 -10
- package/generated/elevenlabs.ts +0 -70
- package/generated/emailoctopus.ts +0 -16
- package/generated/enigma.ts +0 -11
- package/generated/entelligence.ts +0 -11
- package/generated/epic_games.ts +0 -8
- package/generated/eventbrite.ts +0 -12
- package/generated/exa.ts +0 -13
- package/generated/excel.ts +0 -34
- package/generated/exist.ts +0 -8
- package/generated/facebook.ts +0 -8
- package/generated/factorial.ts +0 -8
- package/generated/figma.ts +0 -59
- package/generated/finage.ts +0 -19
- package/generated/firecrawl.ts +0 -16
- package/generated/fireflies.ts +0 -21
- package/generated/fitbit.ts +0 -8
- package/generated/flutterwave.ts +0 -33
- package/generated/fomo.ts +0 -10
- package/generated/formcarry.ts +0 -10
- package/generated/formsite.ts +0 -14
- package/generated/foursquare.ts +0 -14
- package/generated/freshbooks.ts +0 -11
- package/generated/freshdesk.ts +0 -16
- package/generated/front.ts +0 -8
- package/generated/github.ts +0 -967
- package/generated/gitlab.ts +0 -82
- package/generated/gmail.d.ts +0 -86
- package/generated/gmail.js +0 -13
- package/generated/gmail.ts +0 -95
- package/generated/go_to_webinar.ts +0 -8
- package/generated/gong.ts +0 -63
- package/generated/google_analytics.ts +0 -13
- package/generated/google_maps.ts +0 -16
- package/generated/googleads.ts +0 -14
- package/generated/googlebigquery.ts +0 -10
- package/generated/googlecalendar.ts +0 -39
- package/generated/googledocs.ts +0 -41
- package/generated/googledrive.ts +0 -62
- package/generated/googlemeet.ts +0 -18
- package/generated/googlephotos.ts +0 -22
- package/generated/googlesheets.ts +0 -40
- package/generated/googleslides.ts +0 -8
- package/generated/googlesuper.ts +0 -230
- package/generated/googletasks.ts +0 -23
- package/generated/gorgias.ts +0 -41
- package/generated/gumroad.ts +0 -14
- package/generated/guru.ts +0 -8
- package/generated/hackernews.ts +0 -15
- package/generated/hackerrank_work.ts +0 -8
- package/generated/harvest.ts +0 -56
- package/generated/helcim.ts +0 -8
- package/generated/heygen.ts +0 -44
- package/generated/highlevel.ts +0 -8
- package/generated/hubspot.ts +0 -252
- package/generated/humanloop.ts +0 -13
- package/generated/icims_talent_cloud.ts +0 -8
- package/generated/idea_scale.ts +0 -8
- package/generated/index.ts +0 -151
- package/generated/insighto_ai.ts +0 -19
- package/generated/intercom.ts +0 -52
- package/generated/interzoid.ts +0 -8
- package/generated/jira.ts +0 -59
- package/generated/jotform.ts +0 -15
- package/generated/junglescout.ts +0 -15
- package/generated/keap.ts +0 -8
- package/generated/kibana.ts +0 -58
- package/generated/kit.ts +0 -38
- package/generated/klaviyo.ts +0 -240
- package/generated/klipfolio.ts +0 -20
- package/generated/kommo.ts +0 -24
- package/generated/lastpass.ts +0 -8
- package/generated/launch_darkly.ts +0 -16
- package/generated/leadfeeder.ts +0 -13
- package/generated/leadoku.ts +0 -10
- package/generated/lever.ts +0 -8
- package/generated/lever_sandbox.ts +0 -8
- package/generated/lexoffice.ts +0 -8
- package/generated/linear.ts +0 -31
- package/generated/linkedin.ts +0 -13
- package/generated/linkhut.ts +0 -14
- package/generated/linkup.ts +0 -11
- package/generated/listennotes.ts +0 -35
- package/generated/lmnt.ts +0 -16
- package/generated/lodgify.ts +0 -10
- package/generated/mailchimp.ts +0 -285
- package/generated/mailerlite.ts +0 -8
- package/generated/maintainx.ts +0 -20
- package/generated/make.ts +0 -12
- package/generated/mboum.ts +0 -8
- package/generated/mem0.ts +0 -52
- package/generated/metaads.ts +0 -25
- package/generated/metatextai.ts +0 -8
- package/generated/microsoft_clarity.ts +0 -10
- package/generated/microsoft_teams.ts +0 -22
- package/generated/microsoft_tenant.ts +0 -8
- package/generated/miro.ts +0 -23
- package/generated/mixpanel.ts +0 -30
- package/generated/mocean.ts +0 -8
- package/generated/monday.ts +0 -30
- package/generated/mopinion.ts +0 -8
- package/generated/more_trees.ts +0 -10
- package/generated/moxie.ts +0 -8
- package/generated/moz.ts +0 -8
- package/generated/mural.ts +0 -14
- package/generated/nasdaq.ts +0 -15
- package/generated/ncscale.ts +0 -8
- package/generated/neon.ts +0 -78
- package/generated/netsuite.ts +0 -8
- package/generated/nextdns.ts +0 -11
- package/generated/ngrok.ts +0 -18
- package/generated/notion.ts +0 -40
- package/generated/oncehub.ts +0 -8
- package/generated/one_drive.ts +0 -49
- package/generated/onepage.ts +0 -11
- package/generated/open_sea.ts +0 -33
- package/generated/outlook.ts +0 -37
- package/generated/pagerduty.ts +0 -362
- package/generated/pandadoc.ts +0 -23
- package/generated/peopledatalabs.ts +0 -24
- package/generated/perplexityai.ts +0 -10
- package/generated/piggy.ts +0 -8
- package/generated/pipedrive.ts +0 -288
- package/generated/placekey.ts +0 -12
- package/generated/posthog.ts +0 -367
- package/generated/precoro.ts +0 -8
- package/generated/printnode.ts +0 -8
- package/generated/process_street.ts +0 -14
- package/generated/productboard.ts +0 -8
- package/generated/qualaroo.ts +0 -8
- package/generated/quickbooks.ts +0 -22
- package/generated/rafflys.ts +0 -8
- package/generated/ragic.ts +0 -10
- package/generated/ramp.ts +0 -17
- package/generated/ravenseotools.ts +0 -8
- package/generated/recallai.ts +0 -17
- package/generated/reddit.ts +0 -19
- package/generated/resend.ts +0 -27
- package/generated/retellai.ts +0 -19
- package/generated/retently.ts +0 -24
- package/generated/ring_central.ts +0 -8
- package/generated/rippling.ts +0 -8
- package/generated/rocket_reach.ts +0 -8
- package/generated/rocketlane.ts +0 -42
- package/generated/rootly.ts +0 -12
- package/generated/rosette_text_analytics.ts +0 -12
- package/generated/sage.ts +0 -8
- package/generated/salesforce.ts +0 -46
- package/generated/scrape_do.ts +0 -28
- package/generated/scrapingant.ts +0 -14
- package/generated/screenshotone.ts +0 -10
- package/generated/seismic.ts +0 -8
- package/generated/semanticscholar.ts +0 -23
- package/generated/semrush.ts +0 -45
- package/generated/sendgrid.ts +0 -384
- package/generated/sentry.ts +0 -185
- package/generated/serpapi.ts +0 -32
- package/generated/servicem8.ts +0 -37
- package/generated/servicenow.ts +0 -14
- package/generated/share_point.ts +0 -15
- package/generated/shopify.ts +0 -37
- package/generated/shortcut.ts +0 -131
- package/generated/simplesat.ts +0 -11
- package/generated/slack.d.ts +0 -16
- package/generated/slack.js +0 -11
- package/generated/slack.ts +0 -24
- package/generated/slackbot.ts +0 -205
- package/generated/smartrecruiters.ts +0 -8
- package/generated/smugmug.ts +0 -14
- package/generated/snowflake.ts +0 -15
- package/generated/sourcegraph.ts +0 -16
- package/generated/square.ts +0 -8
- package/generated/stack_exchange.ts +0 -17
- package/generated/starton.ts +0 -11
- package/generated/storeganise.ts +0 -12
- package/generated/stripe.ts +0 -50
- package/generated/supabase.ts +0 -86
- package/generated/survey_monkey.ts +0 -8
- package/generated/tally.ts +0 -25
- package/generated/tapfiliate.ts +0 -11
- package/generated/tapform.ts +0 -8
- package/generated/tavily.ts +0 -10
- package/generated/terminus.ts +0 -8
- package/generated/text_to_pdf.ts +0 -10
- package/generated/textrazor.ts +0 -22
- package/generated/timecamp.ts +0 -10
- package/generated/timekit.ts +0 -8
- package/generated/timely.ts +0 -11
- package/generated/tinypng.ts +0 -15
- package/generated/tinyurl.ts +0 -10
- package/generated/tisane.ts +0 -15
- package/generated/todoist.ts +0 -19
- package/generated/toneden.ts +0 -8
- package/generated/tpscheck.ts +0 -10
- package/generated/trello.ts +0 -360
- package/generated/twitch.ts +0 -8
- package/generated/twitter.ts +0 -82
- package/generated/twitter_media.ts +0 -10
- package/generated/typefully.ts +0 -14
- package/generated/venly.ts +0 -8
- package/generated/vero.ts +0 -8
- package/generated/visme.ts +0 -8
- package/generated/waboxapp.ts +0 -8
- package/generated/wakatime.ts +0 -8
- package/generated/wave_accounting.ts +0 -8
- package/generated/weathermap.ts +0 -10
- package/generated/webex.ts +0 -37
- package/generated/webflow.ts +0 -30
- package/generated/whatsapp.ts +0 -14
- package/generated/wiz.ts +0 -8
- package/generated/workiom.ts +0 -12
- package/generated/wrike.ts +0 -47
- package/generated/xero.ts +0 -13
- package/generated/yandex.ts +0 -13
- package/generated/ynab.ts +0 -8
- package/generated/yousearch.ts +0 -10
- package/generated/youtube.ts +0 -26
- package/generated/zendesk.ts +0 -23
- package/generated/zenrows.ts +0 -25
- package/generated/zenserp.ts +0 -20
- package/generated/zoho.ts +0 -33
- package/generated/zoho_bigin.ts +0 -21
- package/generated/zoho_books.ts +0 -8
- package/generated/zoho_desk.ts +0 -8
- package/generated/zoho_inventory.ts +0 -8
- package/generated/zoho_invoice.ts +0 -15
- package/generated/zoho_mail.ts +0 -8
- package/generated/zoom.ts +0 -181
- package/generated/zoominfo.ts +0 -26
- /package/dist/{FileToolModifier.utils.neutral-BN_L8usp.mjs → FileToolModifier.utils.neutral-BcIR-cVE.mjs} +0 -0
- /package/dist/{FileToolModifier.utils.neutral-Bcl7LVf4.cjs → FileToolModifier.utils.neutral-BdMpiyie.cjs} +0 -0
- /package/dist/{chunk-Dx2NuYGI.mjs → chunk-CWQeghP5.mjs} +0 -0
- /package/dist/{files.types-BDqIUdfP.d.mts → files.types-BXDWA_zS.d.mts} +0 -0
- /package/dist/{files.types-nK6eTNnc.d.cts → files.types-lo4zZd87.d.cts} +0 -0
- /package/dist/{types-BF2OQZRP.d.cts → types-CXR6l5Sj.d.mts} +0 -0
- /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
|
|
3
|
-
const
|
|
2
|
+
const require_ComposioError = require('./ComposioError-CYaI68Mo.cjs');
|
|
3
|
+
const require_CustomTool = require('./CustomTool-G2lKa7eb.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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1696
|
+
require_ComposioError.logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
|
|
2167
1697
|
return customTool;
|
|
2168
|
-
} else
|
|
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)
|
|
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)
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3556
|
+
require_ComposioError.logger_default.debug(`[PusherService] Unsubscribing from channel: ${this.pusherChannel}`);
|
|
4027
3557
|
await (await this.getPusherClient()).unsubscribe(this.pusherChannel);
|
|
4028
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3919
|
+
require_ComposioError.logger_default.error("❌ Error in trigger callback:", error);
|
|
4390
3920
|
}
|
|
4391
|
-
else
|
|
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
|
-
|
|
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
|
-
|
|
3971
|
+
require_ComposioError.logger_default.debug("Parsed Pusher payload as legacy TriggerData format");
|
|
4442
3972
|
return transformIncomingTriggerPayload(legacyData);
|
|
4443
3973
|
}
|
|
4444
|
-
|
|
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,
|
|
4697
|
+
return _platform.platform.joinPath(homeDir, require_ComposioError.COMPOSIO_DIR, require_ComposioError.USER_DATA_FILE_NAME);
|
|
5168
4698
|
} catch (_error) {
|
|
5169
|
-
|
|
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
|
-
|
|
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 ||
|
|
5192
|
-
const apiKeyParsed = apiKey ||
|
|
5193
|
-
if (!apiKeyParsed)
|
|
5194
|
-
|
|
5195
|
-
|
|
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 =
|
|
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) && !
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
5262
|
+
var version = "0.6.7";
|
|
5733
5263
|
|
|
5734
5264
|
//#endregion
|
|
5735
5265
|
//#region src/utils/session.ts
|
|
@@ -5846,10 +5376,15 @@ const ToolRouterCreateSessionConfigSchema = zod_v3.default.object({
|
|
|
5846
5376
|
connectedAccounts: zod_v3.default.record(zod_v3.default.string(), zod_v3.default.string()).describe("The connected accounts to use in the tool router session. The key is the toolkit slug, the value is the connected account id.").default({}),
|
|
5847
5377
|
manageConnections: zod_v3.default.union([zod_v3.default.boolean(), ToolRouterConfigManageConnectionsSchema]).optional().default(true).describe("The config for the manage connections in the tool router session. Defaults to true, if set to false, you need to manage connections manually. If set to an object, you can configure the manage connections settings."),
|
|
5848
5378
|
workbench: zod_v3.default.object({
|
|
5379
|
+
enable: zod_v3.default.boolean().default(true).describe("Whether to enable the workbench entirely. Defaults to true. When set to false, no code execution tools (COMPOSIO_REMOTE_WORKBENCH, COMPOSIO_REMOTE_BASH_TOOL) are available in the session."),
|
|
5849
5380
|
enableProxyExecution: zod_v3.default.boolean().optional().describe("Whether to enable proxy execution in the tool router session"),
|
|
5850
5381
|
autoOffloadThreshold: zod_v3.default.number().optional().describe("The auto offload threshold in characters for the tool execution to be moved into workbench")
|
|
5851
|
-
}).optional().describe("The
|
|
5852
|
-
experimental: zod_v3.default.object({
|
|
5382
|
+
}).optional().describe("The workbench config for the tool router session"),
|
|
5383
|
+
experimental: zod_v3.default.object({
|
|
5384
|
+
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"),
|
|
5385
|
+
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."),
|
|
5386
|
+
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.")
|
|
5387
|
+
}).optional().describe("Experimental features configuration - not stable, may be modified or removed")
|
|
5853
5388
|
}).partial().describe("The config for the tool router session");
|
|
5854
5389
|
const ToolkitConnectionStateSchema = zod_v3.default.object({
|
|
5855
5390
|
slug: zod_v3.default.string().describe("The slug of a toolkit"),
|
|
@@ -5952,6 +5487,23 @@ const ToolRouterSessionExecuteResponseSchema = zod_v3.default.object({
|
|
|
5952
5487
|
error: zod_v3.default.string().nullable(),
|
|
5953
5488
|
logId: zod_v3.default.string()
|
|
5954
5489
|
});
|
|
5490
|
+
const SessionProxyExecuteParamsSchema = zod_v3.default.object({
|
|
5491
|
+
toolkit: zod_v3.default.string(),
|
|
5492
|
+
endpoint: zod_v3.default.string(),
|
|
5493
|
+
method: zod_v3.default.enum([
|
|
5494
|
+
"GET",
|
|
5495
|
+
"POST",
|
|
5496
|
+
"PUT",
|
|
5497
|
+
"DELETE",
|
|
5498
|
+
"PATCH"
|
|
5499
|
+
]),
|
|
5500
|
+
body: zod_v3.default.unknown().optional(),
|
|
5501
|
+
parameters: zod_v3.default.array(zod_v3.default.object({
|
|
5502
|
+
in: zod_v3.default.enum(["query", "header"]),
|
|
5503
|
+
name: zod_v3.default.string(),
|
|
5504
|
+
value: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.number()])
|
|
5505
|
+
})).optional()
|
|
5506
|
+
});
|
|
5955
5507
|
|
|
5956
5508
|
//#endregion
|
|
5957
5509
|
//#region src/lib/toolRouterParams.ts
|
|
@@ -5970,7 +5522,7 @@ const transformToolRouterToolsParams = (params) => {
|
|
|
5970
5522
|
const tags = transformToolRouterTagsParams(data.tags);
|
|
5971
5523
|
if (tags) acc[key] = { tags };
|
|
5972
5524
|
}
|
|
5973
|
-
} else throw new ValidationError(parsedResult.error.message);
|
|
5525
|
+
} else throw new require_CustomTool.ValidationError(parsedResult.error.message);
|
|
5974
5526
|
} else acc[key] = { enable: params[key] };
|
|
5975
5527
|
return acc;
|
|
5976
5528
|
}, {});
|
|
@@ -5987,7 +5539,7 @@ const transformToolRouterManageConnectionsParams = (params) => {
|
|
|
5987
5539
|
if (params === void 0) return { enable: true };
|
|
5988
5540
|
if (typeof params === "boolean") return { enable: params };
|
|
5989
5541
|
const parsedResult = ToolRouterConfigManageConnectionsSchema.safeParse(params);
|
|
5990
|
-
if (!parsedResult.success) throw new ValidationError("Failed to parse manage connections config", { cause: parsedResult.error });
|
|
5542
|
+
if (!parsedResult.success) throw new require_CustomTool.ValidationError("Failed to parse manage connections config", { cause: parsedResult.error });
|
|
5991
5543
|
const config = parsedResult.data;
|
|
5992
5544
|
return {
|
|
5993
5545
|
enable: config.enable ?? true,
|
|
@@ -5998,6 +5550,7 @@ const transformToolRouterManageConnectionsParams = (params) => {
|
|
|
5998
5550
|
const transformToolRouterWorkbenchParams = (params) => {
|
|
5999
5551
|
if (!params) return;
|
|
6000
5552
|
return {
|
|
5553
|
+
enable: params.enable ?? true,
|
|
6001
5554
|
enable_proxy_execution: params.enableProxyExecution,
|
|
6002
5555
|
auto_offload_threshold: params.autoOffloadThreshold
|
|
6003
5556
|
};
|
|
@@ -6092,7 +5645,7 @@ function transformExecuteResponse(raw) {
|
|
|
6092
5645
|
//#region src/types/ToolRouterSessionFilesMount.types.ts
|
|
6093
5646
|
const ToolRouterSessionFilesMountListOptionsSchema = zod_v3.default.object({
|
|
6094
5647
|
path: zod_v3.default.string().optional(),
|
|
6095
|
-
mountId: zod_v3.default.string().default(
|
|
5648
|
+
mountId: zod_v3.default.string().default(require_ComposioError.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID),
|
|
6096
5649
|
cursor: zod_v3.default.string().optional(),
|
|
6097
5650
|
limit: zod_v3.default.number().min(1).max(500).optional()
|
|
6098
5651
|
});
|
|
@@ -6116,11 +5669,11 @@ const FileListResponseSchema = zod_v3.default.object({
|
|
|
6116
5669
|
}));
|
|
6117
5670
|
const ToolRouterSessionFilesMountUploadOptionsSchema = zod_v3.default.object({
|
|
6118
5671
|
remotePath: zod_v3.default.string().optional(),
|
|
6119
|
-
mountId: zod_v3.default.string().default(
|
|
5672
|
+
mountId: zod_v3.default.string().default(require_ComposioError.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID),
|
|
6120
5673
|
mimetype: zod_v3.default.string().optional()
|
|
6121
5674
|
});
|
|
6122
|
-
const ToolRouterSessionFilesMountDownloadOptionsSchema = zod_v3.default.object({ mountId: zod_v3.default.string().default(
|
|
6123
|
-
const ToolRouterSessionFilesMountDeleteOptionsSchema = zod_v3.default.object({ mountId: zod_v3.default.string().default(
|
|
5675
|
+
const ToolRouterSessionFilesMountDownloadOptionsSchema = zod_v3.default.object({ mountId: zod_v3.default.string().default(require_ComposioError.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID) });
|
|
5676
|
+
const ToolRouterSessionFilesMountDeleteOptionsSchema = zod_v3.default.object({ mountId: zod_v3.default.string().default(require_ComposioError.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID) });
|
|
6124
5677
|
const RemoteFileDataSchema = zod_v3.default.object({
|
|
6125
5678
|
expires_at: zod_v3.default.string(),
|
|
6126
5679
|
mount_relative_path: zod_v3.default.string(),
|
|
@@ -6196,7 +5749,7 @@ var RemoteFile = class RemoteFile {
|
|
|
6196
5749
|
*/
|
|
6197
5750
|
static parse(data) {
|
|
6198
5751
|
const parsed = RemoteFileDataSchema.safeParse(data);
|
|
6199
|
-
if (!parsed.success) throw new ValidationError("Failed to parse remote file response", { cause: parsed.error });
|
|
5752
|
+
if (!parsed.success) throw new require_CustomTool.ValidationError("Failed to parse remote file response", { cause: parsed.error });
|
|
6200
5753
|
return new RemoteFile(parsed.data);
|
|
6201
5754
|
}
|
|
6202
5755
|
/** Filename extracted from the mount path (e.g. "report.pdf" from "output/report.pdf") */
|
|
@@ -6210,7 +5763,7 @@ var RemoteFile = class RemoteFile {
|
|
|
6210
5763
|
*/
|
|
6211
5764
|
async buffer() {
|
|
6212
5765
|
const response = await fetch(this.downloadUrl);
|
|
6213
|
-
if (!response.ok) throw new RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
|
|
5766
|
+
if (!response.ok) throw new require_CustomTool.RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
|
|
6214
5767
|
statusCode: response.status,
|
|
6215
5768
|
statusText: response.statusText,
|
|
6216
5769
|
downloadUrl: this.downloadUrl,
|
|
@@ -6237,7 +5790,7 @@ var RemoteFile = class RemoteFile {
|
|
|
6237
5790
|
*/
|
|
6238
5791
|
async blob() {
|
|
6239
5792
|
const response = await fetch(this.downloadUrl);
|
|
6240
|
-
if (!response.ok) throw new RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
|
|
5793
|
+
if (!response.ok) throw new require_CustomTool.RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
|
|
6241
5794
|
statusCode: response.status,
|
|
6242
5795
|
statusText: response.statusText,
|
|
6243
5796
|
downloadUrl: this.downloadUrl,
|
|
@@ -6260,8 +5813,8 @@ var RemoteFile = class RemoteFile {
|
|
|
6260
5813
|
const content = await this.buffer();
|
|
6261
5814
|
const homeDir = _platform.platform.homedir();
|
|
6262
5815
|
if (!homeDir) throw new Error("Cannot determine save location: home directory is not available");
|
|
6263
|
-
const savePath = path ?? _platform.platform.joinPath(homeDir,
|
|
6264
|
-
const dir = path != null ? getParentDir(savePath) : _platform.platform.joinPath(homeDir,
|
|
5816
|
+
const savePath = path ?? _platform.platform.joinPath(homeDir, require_ComposioError.COMPOSIO_DIR, require_ComposioError.TEMP_FILES_DIRECTORY_NAME, this.filename);
|
|
5817
|
+
const dir = path != null ? getParentDir(savePath) : _platform.platform.joinPath(homeDir, require_ComposioError.COMPOSIO_DIR, require_ComposioError.TEMP_FILES_DIRECTORY_NAME);
|
|
6265
5818
|
if (dir && !_platform.platform.existsSync(dir)) _platform.platform.mkdirSync(dir);
|
|
6266
5819
|
_platform.platform.writeFileSync(savePath, content);
|
|
6267
5820
|
return savePath;
|
|
@@ -6380,7 +5933,7 @@ var ToolRouterSessionFilesMount = class {
|
|
|
6380
5933
|
*/
|
|
6381
5934
|
async list(options) {
|
|
6382
5935
|
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 });
|
|
5936
|
+
if (!listOptions.success) throw new require_CustomTool.ValidationError("Failed to parse tool router session files mount list options", { cause: listOptions.error });
|
|
6384
5937
|
const rawPath = listOptions.data.path;
|
|
6385
5938
|
const mountRelativePrefix = rawPath === void 0 || rawPath === "" || rawPath === "/" ? void 0 : rawPath.startsWith("/") ? rawPath.slice(1) : rawPath;
|
|
6386
5939
|
const response = await this.client.toolRouter.session.files.list(listOptions.data.mountId, {
|
|
@@ -6391,7 +5944,7 @@ var ToolRouterSessionFilesMount = class {
|
|
|
6391
5944
|
});
|
|
6392
5945
|
const data = typeof response === "object" && "body" in response ? response.body : response;
|
|
6393
5946
|
const parsed = FileListResponseSchema.safeParse(data);
|
|
6394
|
-
if (!parsed.success) throw new ValidationError("Failed to parse file list response", { cause: parsed.error });
|
|
5947
|
+
if (!parsed.success) throw new require_CustomTool.ValidationError("Failed to parse file list response", { cause: parsed.error });
|
|
6395
5948
|
return parsed.data;
|
|
6396
5949
|
}
|
|
6397
5950
|
async normalizeUploadInput(input, options) {
|
|
@@ -6470,7 +6023,7 @@ var ToolRouterSessionFilesMount = class {
|
|
|
6470
6023
|
*/
|
|
6471
6024
|
async upload(input, options) {
|
|
6472
6025
|
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 });
|
|
6026
|
+
if (!uploadOptions.success) throw new require_CustomTool.ValidationError("Failed to parse tool router session files mount upload options", { cause: uploadOptions.error });
|
|
6474
6027
|
const { fileToUpload, remotePath, mimetype } = await this.normalizeUploadInput(input, uploadOptions.data);
|
|
6475
6028
|
const createUploadURLResponse = await this.client.toolRouter.session.files.createUploadURL(uploadOptions.data.mountId, {
|
|
6476
6029
|
session_id: this.sessionId,
|
|
@@ -6490,7 +6043,7 @@ var ToolRouterSessionFilesMount = class {
|
|
|
6490
6043
|
});
|
|
6491
6044
|
const downloadData = typeof createDownloadURLResponse === "object" && "body" in createDownloadURLResponse ? createDownloadURLResponse.body : createDownloadURLResponse;
|
|
6492
6045
|
const parsed = RemoteFileDataSchema.safeParse(downloadData);
|
|
6493
|
-
if (!parsed.success) throw new ValidationError("Failed to parse remote file properties", { cause: parsed.error });
|
|
6046
|
+
if (!parsed.success) throw new require_CustomTool.ValidationError("Failed to parse remote file properties", { cause: parsed.error });
|
|
6494
6047
|
return new RemoteFile(parsed.data);
|
|
6495
6048
|
}
|
|
6496
6049
|
/**
|
|
@@ -6520,14 +6073,14 @@ var ToolRouterSessionFilesMount = class {
|
|
|
6520
6073
|
*/
|
|
6521
6074
|
async download(filePath, options) {
|
|
6522
6075
|
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 });
|
|
6076
|
+
if (!downloadOptions.success) throw new require_CustomTool.ValidationError("Failed to parse tool router session files mount download options", { cause: downloadOptions.error });
|
|
6524
6077
|
const createDownloadURLResponse = await this.client.toolRouter.session.files.createDownloadURL(downloadOptions.data.mountId, {
|
|
6525
6078
|
session_id: this.sessionId,
|
|
6526
6079
|
mount_relative_path: filePath
|
|
6527
6080
|
});
|
|
6528
6081
|
const downloadURLData = typeof createDownloadURLResponse === "object" && "body" in createDownloadURLResponse ? createDownloadURLResponse.body : createDownloadURLResponse;
|
|
6529
6082
|
const parsed = RemoteFileDataSchema.safeParse(downloadURLData);
|
|
6530
|
-
if (!parsed.success) throw new ValidationError("Failed to parse remote file properties", { cause: parsed.error });
|
|
6083
|
+
if (!parsed.success) throw new require_CustomTool.ValidationError("Failed to parse remote file properties", { cause: parsed.error });
|
|
6531
6084
|
return new RemoteFile(parsed.data);
|
|
6532
6085
|
}
|
|
6533
6086
|
/**
|
|
@@ -6559,44 +6112,231 @@ var ToolRouterSessionFilesMount = class {
|
|
|
6559
6112
|
*/
|
|
6560
6113
|
async delete(remotePath, options) {
|
|
6561
6114
|
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 });
|
|
6115
|
+
if (!deleteOptions.success) throw new require_CustomTool.ValidationError("Failed to parse tool router session files mount delete options", { cause: deleteOptions.error });
|
|
6563
6116
|
const deleteResponse = await this.client.toolRouter.session.files.delete(deleteOptions.data.mountId, {
|
|
6564
6117
|
session_id: this.sessionId,
|
|
6565
6118
|
mount_relative_path: remotePath
|
|
6566
6119
|
});
|
|
6567
6120
|
const fileDeleteResponse = FileDeleteResponseSchema.safeParse(deleteResponse);
|
|
6568
|
-
if (!fileDeleteResponse.success) throw new ValidationError("Failed to parse file delete response", { cause: fileDeleteResponse.error });
|
|
6121
|
+
if (!fileDeleteResponse.success) throw new require_CustomTool.ValidationError("Failed to parse file delete response", { cause: fileDeleteResponse.error });
|
|
6569
6122
|
return fileDeleteResponse.data;
|
|
6570
6123
|
}
|
|
6571
6124
|
};
|
|
6572
6125
|
|
|
6126
|
+
//#endregion
|
|
6127
|
+
//#region src/models/proxyParamsTransform.ts
|
|
6128
|
+
/**
|
|
6129
|
+
* Transform SDK session proxy params to the official client request format.
|
|
6130
|
+
* Converts SDK-facing `toolkit` → `toolkit_slug` and `parameters[].in` → `parameters[].type`.
|
|
6131
|
+
*/
|
|
6132
|
+
function transformProxyParams(params) {
|
|
6133
|
+
const parameters = params.parameters?.map((p) => ({
|
|
6134
|
+
name: p.name,
|
|
6135
|
+
type: p.in,
|
|
6136
|
+
value: p.value.toString()
|
|
6137
|
+
}));
|
|
6138
|
+
return {
|
|
6139
|
+
toolkit_slug: params.toolkit,
|
|
6140
|
+
endpoint: params.endpoint,
|
|
6141
|
+
method: params.method,
|
|
6142
|
+
...params.body !== void 0 ? { body: params.body } : {},
|
|
6143
|
+
...parameters?.length ? { parameters } : {}
|
|
6144
|
+
};
|
|
6145
|
+
}
|
|
6146
|
+
|
|
6147
|
+
//#endregion
|
|
6148
|
+
//#region src/models/customToolExecution.ts
|
|
6149
|
+
/**
|
|
6150
|
+
* Find a custom tool entry by slug.
|
|
6151
|
+
* Checks both the final slug map (LOCAL_X — agent/LLM path) and original slug map (X — programmatic path).
|
|
6152
|
+
*/
|
|
6153
|
+
function findCustomTool(map, slug) {
|
|
6154
|
+
if (!map) return void 0;
|
|
6155
|
+
const upper = slug.toUpperCase();
|
|
6156
|
+
return map.byFinalSlug.get(upper) ?? map.byOriginalSlug.get(upper);
|
|
6157
|
+
}
|
|
6158
|
+
/**
|
|
6159
|
+
* Execute a custom tool in-process.
|
|
6160
|
+
* Validates input via the Zod schema, calls the user's execute function,
|
|
6161
|
+
* and wraps the result into the standard response format.
|
|
6162
|
+
*
|
|
6163
|
+
* Callers provide a pre-built SessionContext (which may include sibling routing).
|
|
6164
|
+
*/
|
|
6165
|
+
async function executeCustomTool(entry, arguments_, sessionContext) {
|
|
6166
|
+
const { handle } = entry;
|
|
6167
|
+
const parsed = handle.inputParams.safeParse(arguments_);
|
|
6168
|
+
if (!parsed.success) return {
|
|
6169
|
+
data: {},
|
|
6170
|
+
error: `Input validation failed: ${parsed.error.message}`,
|
|
6171
|
+
successful: false
|
|
6172
|
+
};
|
|
6173
|
+
try {
|
|
6174
|
+
return {
|
|
6175
|
+
data: await handle.execute(parsed.data, sessionContext) ?? {},
|
|
6176
|
+
error: null,
|
|
6177
|
+
successful: true
|
|
6178
|
+
};
|
|
6179
|
+
} catch (err) {
|
|
6180
|
+
return {
|
|
6181
|
+
data: {},
|
|
6182
|
+
error: err instanceof Error ? err.message : String(err),
|
|
6183
|
+
successful: false
|
|
6184
|
+
};
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
6187
|
+
|
|
6188
|
+
//#endregion
|
|
6189
|
+
//#region src/models/SessionContext.ts
|
|
6190
|
+
/**
|
|
6191
|
+
* Concrete implementation of SessionContext.
|
|
6192
|
+
* One instance is created per session (or per multi-execute batch) and shared
|
|
6193
|
+
* across all custom tool invocations, including sibling routing.
|
|
6194
|
+
*
|
|
6195
|
+
* When `customToolsMap` is provided, `execute()` checks local tools first
|
|
6196
|
+
* before falling back to the backend API. This allows tool A to call tool B
|
|
6197
|
+
* via `session.execute('B', ...)` without hitting the network.
|
|
6198
|
+
*/
|
|
6199
|
+
var SessionContextImpl = class {
|
|
6200
|
+
userId;
|
|
6201
|
+
constructor(client, userId, sessionId, customToolsMap) {
|
|
6202
|
+
this.client = client;
|
|
6203
|
+
this.sessionId = sessionId;
|
|
6204
|
+
this.customToolsMap = customToolsMap;
|
|
6205
|
+
this.userId = userId;
|
|
6206
|
+
}
|
|
6207
|
+
/**
|
|
6208
|
+
* Execute any tool from within a custom tool.
|
|
6209
|
+
* Routes to sibling local tools in-process when available,
|
|
6210
|
+
* otherwise delegates to the backend API.
|
|
6211
|
+
*/
|
|
6212
|
+
async execute(toolSlug, arguments_) {
|
|
6213
|
+
const entry = findCustomTool(this.customToolsMap, toolSlug);
|
|
6214
|
+
if (entry) return executeCustomTool(entry, arguments_, this);
|
|
6215
|
+
const response = await this.client.toolRouter.session.execute(this.sessionId, {
|
|
6216
|
+
tool_slug: toolSlug,
|
|
6217
|
+
arguments: arguments_
|
|
6218
|
+
});
|
|
6219
|
+
return {
|
|
6220
|
+
data: response.data,
|
|
6221
|
+
error: response.error,
|
|
6222
|
+
successful: !response.error
|
|
6223
|
+
};
|
|
6224
|
+
}
|
|
6225
|
+
/**
|
|
6226
|
+
* Proxy API calls through Composio's auth layer.
|
|
6227
|
+
* The backend resolves the connected account from the toolkit within the session.
|
|
6228
|
+
*/
|
|
6229
|
+
async proxyExecute(params) {
|
|
6230
|
+
const validated = SessionProxyExecuteParamsSchema.safeParse(params);
|
|
6231
|
+
if (!validated.success) throw new require_CustomTool.ValidationError("Invalid proxy execute parameters", { cause: validated.error });
|
|
6232
|
+
const clientParams = transformProxyParams(validated.data);
|
|
6233
|
+
const response = await this.client.toolRouter.session.proxyExecute(this.sessionId, clientParams);
|
|
6234
|
+
return {
|
|
6235
|
+
status: response.status,
|
|
6236
|
+
data: response.data,
|
|
6237
|
+
headers: response.headers,
|
|
6238
|
+
...response.binary_data ? { binaryData: {
|
|
6239
|
+
contentType: response.binary_data.content_type,
|
|
6240
|
+
size: response.binary_data.size,
|
|
6241
|
+
url: response.binary_data.url,
|
|
6242
|
+
expiresAt: response.binary_data.expires_at
|
|
6243
|
+
} } : {}
|
|
6244
|
+
};
|
|
6245
|
+
}
|
|
6246
|
+
};
|
|
6247
|
+
|
|
6573
6248
|
//#endregion
|
|
6574
6249
|
//#region src/models/ToolRouterSession.ts
|
|
6250
|
+
const COMPOSIO_MULTI_EXECUTE_TOOL = "COMPOSIO_MULTI_EXECUTE_TOOL";
|
|
6575
6251
|
var ToolRouterSession = class {
|
|
6576
6252
|
sessionId;
|
|
6577
6253
|
mcp;
|
|
6578
6254
|
experimental;
|
|
6579
|
-
|
|
6255
|
+
/** Singleton session context — shared across all custom tool executions */
|
|
6256
|
+
sessionContext;
|
|
6257
|
+
constructor(client, config, sessionId, mcp, experimentalOverrides, customToolsMap, userId) {
|
|
6580
6258
|
this.client = client;
|
|
6581
6259
|
this.config = config;
|
|
6260
|
+
this.customToolsMap = customToolsMap;
|
|
6261
|
+
this.userId = userId;
|
|
6262
|
+
if (customToolsMap && !userId) throw new Error("userId is required when custom tools are bound to a session.");
|
|
6582
6263
|
this.sessionId = sessionId;
|
|
6583
6264
|
this.mcp = mcp;
|
|
6584
6265
|
this.experimental = {
|
|
6585
6266
|
assistivePrompt: experimentalOverrides?.assistivePrompt,
|
|
6586
6267
|
files: new ToolRouterSessionFilesMount(client, sessionId)
|
|
6587
6268
|
};
|
|
6269
|
+
if (customToolsMap && userId) this.sessionContext = new SessionContextImpl(client, userId, sessionId, customToolsMap);
|
|
6588
6270
|
require_Telemetry.telemetry.instrument(this, "ToolRouterSession");
|
|
6589
6271
|
}
|
|
6590
6272
|
/**
|
|
6591
6273
|
* Get the tools available in the session, formatted for your AI framework.
|
|
6592
6274
|
* Requires a provider to be configured in the Composio constructor.
|
|
6275
|
+
*
|
|
6276
|
+
* When custom tools are bound to the session, execution of COMPOSIO_MULTI_EXECUTE_TOOL
|
|
6277
|
+
* is intercepted: local tools are executed in-process, remote tools are sent to the backend.
|
|
6593
6278
|
*/
|
|
6594
6279
|
async tools(modifiers) {
|
|
6595
6280
|
const ToolsModel = new Tools(this.client, this.config);
|
|
6596
6281
|
const tools = await ToolsModel.getRawToolRouterMetaTools(this.sessionId, modifiers?.modifySchema ? { modifySchema: modifiers.modifySchema } : void 0);
|
|
6282
|
+
if (this.hasCustomTools()) {
|
|
6283
|
+
const routingExecuteFn = async (toolSlug, input) => {
|
|
6284
|
+
if (toolSlug === COMPOSIO_MULTI_EXECUTE_TOOL) return this.routeMultiExecute(input, ToolsModel, modifiers);
|
|
6285
|
+
return ToolsModel.executeMetaTool(toolSlug, {
|
|
6286
|
+
sessionId: this.sessionId,
|
|
6287
|
+
arguments: input
|
|
6288
|
+
}, modifiers);
|
|
6289
|
+
};
|
|
6290
|
+
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.");
|
|
6291
|
+
return this.config.provider.wrapTools(tools, routingExecuteFn);
|
|
6292
|
+
}
|
|
6597
6293
|
return ToolsModel.wrapToolsForToolRouter(this.sessionId, tools, modifiers);
|
|
6598
6294
|
}
|
|
6599
6295
|
/**
|
|
6296
|
+
* List all custom tools registered in this session.
|
|
6297
|
+
* Returns tools with their final slugs, schemas, and resolved toolkit.
|
|
6298
|
+
*
|
|
6299
|
+
* @param options.toolkit - Filter by toolkit slug (e.g. 'gmail', 'DEV_TOOLS')
|
|
6300
|
+
* @returns Array of registered custom tools
|
|
6301
|
+
*/
|
|
6302
|
+
customTools(options) {
|
|
6303
|
+
if (!this.customToolsMap) return [];
|
|
6304
|
+
const entries = Array.from(this.customToolsMap.byFinalSlug.values());
|
|
6305
|
+
return (options?.toolkit ? entries.filter((e) => e.toolkit?.toLowerCase() === options.toolkit.toLowerCase()) : entries).map((entry) => ({
|
|
6306
|
+
slug: entry.finalSlug,
|
|
6307
|
+
name: entry.handle.name,
|
|
6308
|
+
description: entry.handle.description,
|
|
6309
|
+
toolkit: entry.toolkit,
|
|
6310
|
+
inputSchema: entry.handle.inputSchema,
|
|
6311
|
+
outputSchema: entry.handle.outputSchema
|
|
6312
|
+
}));
|
|
6313
|
+
}
|
|
6314
|
+
/**
|
|
6315
|
+
* List all custom toolkits registered in this session.
|
|
6316
|
+
* Returns toolkits with their tools showing final slugs.
|
|
6317
|
+
*
|
|
6318
|
+
* @returns Array of registered custom toolkits
|
|
6319
|
+
*/
|
|
6320
|
+
customToolkits() {
|
|
6321
|
+
const toolkits = this.customToolsMap?.toolkits;
|
|
6322
|
+
if (!toolkits?.length) return [];
|
|
6323
|
+
return toolkits.map((tk) => ({
|
|
6324
|
+
slug: tk.slug,
|
|
6325
|
+
name: tk.name,
|
|
6326
|
+
description: tk.description,
|
|
6327
|
+
tools: tk.tools.map((tool) => {
|
|
6328
|
+
return {
|
|
6329
|
+
slug: this.customToolsMap.byOriginalSlug.get(tool.slug.toUpperCase())?.finalSlug ?? tool.slug,
|
|
6330
|
+
name: tool.name,
|
|
6331
|
+
description: tool.description,
|
|
6332
|
+
toolkit: tk.slug,
|
|
6333
|
+
inputSchema: tool.inputSchema,
|
|
6334
|
+
outputSchema: tool.outputSchema
|
|
6335
|
+
};
|
|
6336
|
+
})
|
|
6337
|
+
}));
|
|
6338
|
+
}
|
|
6339
|
+
/**
|
|
6600
6340
|
* Initiate an authorization flow for a toolkit.
|
|
6601
6341
|
* Returns a ConnectionRequest with a redirect URL for the user.
|
|
6602
6342
|
*/
|
|
@@ -6613,7 +6353,7 @@ var ToolRouterSession = class {
|
|
|
6613
6353
|
*/
|
|
6614
6354
|
async toolkits(options) {
|
|
6615
6355
|
const toolkitOptions = ToolRouterToolkitsOptionsSchema.safeParse(options ?? {});
|
|
6616
|
-
if (!toolkitOptions.success) throw new ValidationError("Failed to parse toolkits options", { cause: toolkitOptions.error });
|
|
6356
|
+
if (!toolkitOptions.success) throw new require_CustomTool.ValidationError("Failed to parse toolkits options", { cause: toolkitOptions.error });
|
|
6617
6357
|
const result = await this.client.toolRouter.session.toolkits(this.sessionId, {
|
|
6618
6358
|
cursor: toolkitOptions.data.nextCursor,
|
|
6619
6359
|
limit: toolkitOptions.data.limit,
|
|
@@ -6649,20 +6389,6 @@ var ToolRouterSession = class {
|
|
|
6649
6389
|
/**
|
|
6650
6390
|
* Search for tools by semantic use case.
|
|
6651
6391
|
* 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
6392
|
*/
|
|
6667
6393
|
async search(params) {
|
|
6668
6394
|
const transformed = transformSearchResponse(await this.client.toolRouter.session.search(this.sessionId, {
|
|
@@ -6674,33 +6400,142 @@ var ToolRouterSession = class {
|
|
|
6674
6400
|
/**
|
|
6675
6401
|
* Execute a tool within the session.
|
|
6676
6402
|
*
|
|
6677
|
-
*
|
|
6678
|
-
*
|
|
6679
|
-
*
|
|
6403
|
+
* For custom tools, accepts the original slug (e.g. "GREP") or the
|
|
6404
|
+
* full slug (e.g. "LOCAL_GREP"). Custom tools are executed in-process;
|
|
6405
|
+
* remote tools are sent to the Composio backend.
|
|
6680
6406
|
*
|
|
6681
|
-
* @
|
|
6682
|
-
*
|
|
6683
|
-
*
|
|
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
|
-
* ```
|
|
6407
|
+
* @param toolSlug - The tool slug to execute
|
|
6408
|
+
* @param arguments_ - Optional tool arguments
|
|
6409
|
+
* @returns The tool execution result
|
|
6696
6410
|
*/
|
|
6697
6411
|
async execute(toolSlug, arguments_) {
|
|
6412
|
+
const entry = findCustomTool(this.customToolsMap, toolSlug);
|
|
6413
|
+
if (entry) {
|
|
6414
|
+
const result = await executeCustomTool(entry, arguments_ ?? {}, this.sessionContext);
|
|
6415
|
+
return {
|
|
6416
|
+
data: result.data,
|
|
6417
|
+
error: result.error,
|
|
6418
|
+
logId: ""
|
|
6419
|
+
};
|
|
6420
|
+
}
|
|
6698
6421
|
const transformed = transformExecuteResponse(await this.client.toolRouter.session.execute(this.sessionId, {
|
|
6699
6422
|
tool_slug: toolSlug,
|
|
6700
6423
|
arguments: arguments_ ?? {}
|
|
6701
6424
|
}));
|
|
6702
6425
|
return ToolRouterSessionExecuteResponseSchema.parse(transformed);
|
|
6703
6426
|
}
|
|
6427
|
+
/**
|
|
6428
|
+
* Proxy an API call through Composio's auth layer using the session's connected account.
|
|
6429
|
+
* The backend resolves the connected account from the toolkit within the session.
|
|
6430
|
+
*
|
|
6431
|
+
* @param params - Proxy request parameters (toolkit, endpoint, method, body, headers/query params)
|
|
6432
|
+
* @returns The proxied API response with status, data, headers
|
|
6433
|
+
*/
|
|
6434
|
+
async proxyExecute(params) {
|
|
6435
|
+
const validated = SessionProxyExecuteParamsSchema.safeParse(params);
|
|
6436
|
+
if (!validated.success) throw new require_CustomTool.ValidationError("Invalid proxy execute parameters", { cause: validated.error });
|
|
6437
|
+
const clientParams = transformProxyParams(validated.data);
|
|
6438
|
+
const response = await this.client.toolRouter.session.proxyExecute(this.sessionId, clientParams);
|
|
6439
|
+
return {
|
|
6440
|
+
status: response.status,
|
|
6441
|
+
data: response.data,
|
|
6442
|
+
headers: response.headers,
|
|
6443
|
+
...response.binary_data ? { binaryData: {
|
|
6444
|
+
contentType: response.binary_data.content_type,
|
|
6445
|
+
size: response.binary_data.size,
|
|
6446
|
+
url: response.binary_data.url,
|
|
6447
|
+
expiresAt: response.binary_data.expires_at
|
|
6448
|
+
} } : {}
|
|
6449
|
+
};
|
|
6450
|
+
}
|
|
6451
|
+
/** Check if this session has any custom tools bound. */
|
|
6452
|
+
hasCustomTools() {
|
|
6453
|
+
return (this.customToolsMap?.byFinalSlug.size ?? 0) > 0;
|
|
6454
|
+
}
|
|
6455
|
+
/** Parse an individual tool item from COMPOSIO_MULTI_EXECUTE_TOOL's tools array */
|
|
6456
|
+
parseToolItem(item) {
|
|
6457
|
+
if (typeof item !== "object" || item === null) return {
|
|
6458
|
+
tool_slug: "",
|
|
6459
|
+
arguments: {}
|
|
6460
|
+
};
|
|
6461
|
+
const obj = item;
|
|
6462
|
+
return {
|
|
6463
|
+
tool_slug: String(obj.tool_slug ?? ""),
|
|
6464
|
+
arguments: obj.arguments ?? {}
|
|
6465
|
+
};
|
|
6466
|
+
}
|
|
6467
|
+
/**
|
|
6468
|
+
* Route a COMPOSIO_MULTI_EXECUTE_TOOL call.
|
|
6469
|
+
* Splits the tools[] array into local and remote, executes each appropriately,
|
|
6470
|
+
* and merges results preserving original order.
|
|
6471
|
+
*/
|
|
6472
|
+
async routeMultiExecute(input, ToolsModel, modifiers) {
|
|
6473
|
+
const toolItems = input.tools;
|
|
6474
|
+
if (!Array.isArray(toolItems) || toolItems.length === 0) return ToolsModel.executeMetaTool(COMPOSIO_MULTI_EXECUTE_TOOL, {
|
|
6475
|
+
sessionId: this.sessionId,
|
|
6476
|
+
arguments: input
|
|
6477
|
+
}, modifiers);
|
|
6478
|
+
const parsed = toolItems.map((item) => this.parseToolItem(item));
|
|
6479
|
+
const localItems = [];
|
|
6480
|
+
const remoteIndices = [];
|
|
6481
|
+
for (let i = 0; i < parsed.length; i++) {
|
|
6482
|
+
const entry = findCustomTool(this.customToolsMap, parsed[i].tool_slug);
|
|
6483
|
+
if (entry) localItems.push({
|
|
6484
|
+
index: i,
|
|
6485
|
+
entry
|
|
6486
|
+
});
|
|
6487
|
+
else remoteIndices.push(i);
|
|
6488
|
+
}
|
|
6489
|
+
if (localItems.length === 0) return ToolsModel.executeMetaTool(COMPOSIO_MULTI_EXECUTE_TOOL, {
|
|
6490
|
+
sessionId: this.sessionId,
|
|
6491
|
+
arguments: input
|
|
6492
|
+
}, modifiers);
|
|
6493
|
+
const ctx = this.sessionContext;
|
|
6494
|
+
const localPromises = localItems.map(async ({ index, entry }) => {
|
|
6495
|
+
return {
|
|
6496
|
+
index,
|
|
6497
|
+
result: await executeCustomTool(entry, parsed[index].arguments, ctx)
|
|
6498
|
+
};
|
|
6499
|
+
});
|
|
6500
|
+
let remotePromise;
|
|
6501
|
+
if (remoteIndices.length > 0) {
|
|
6502
|
+
const remoteToolItems = remoteIndices.map((i) => toolItems[i]);
|
|
6503
|
+
const remoteInput = {
|
|
6504
|
+
...input,
|
|
6505
|
+
tools: remoteToolItems
|
|
6506
|
+
};
|
|
6507
|
+
remotePromise = ToolsModel.executeMetaTool(COMPOSIO_MULTI_EXECUTE_TOOL, {
|
|
6508
|
+
sessionId: this.sessionId,
|
|
6509
|
+
arguments: remoteInput
|
|
6510
|
+
}, modifiers);
|
|
6511
|
+
}
|
|
6512
|
+
const [localResults, remoteResult] = await Promise.all([Promise.all(localPromises), remotePromise]);
|
|
6513
|
+
if (remoteIndices.length === 0 && localResults.length === 1) return localResults[0].result;
|
|
6514
|
+
const remoteData = remoteResult?.data ?? {};
|
|
6515
|
+
const remoteResults = Array.isArray(remoteData.results) ? remoteData.results : [];
|
|
6516
|
+
const localEntries = localResults.map(({ index, result }) => ({
|
|
6517
|
+
response: {
|
|
6518
|
+
successful: result.successful,
|
|
6519
|
+
data: result.data,
|
|
6520
|
+
...result.error ? { error: result.error } : {}
|
|
6521
|
+
},
|
|
6522
|
+
tool_slug: parsed[index].tool_slug,
|
|
6523
|
+
...result.error ? { error: result.error } : {}
|
|
6524
|
+
}));
|
|
6525
|
+
const allResults = [...remoteResults, ...localEntries].map((entry, i) => ({
|
|
6526
|
+
...entry,
|
|
6527
|
+
index: i
|
|
6528
|
+
}));
|
|
6529
|
+
const hasAnyError = localResults.some((r) => r.result.error) || !!remoteResult?.error;
|
|
6530
|
+
return {
|
|
6531
|
+
data: {
|
|
6532
|
+
...remoteData,
|
|
6533
|
+
results: allResults
|
|
6534
|
+
},
|
|
6535
|
+
error: hasAnyError ? `${allResults.filter((r) => r.error).length} out of ${allResults.length} tools failed` : null,
|
|
6536
|
+
successful: !hasAnyError
|
|
6537
|
+
};
|
|
6538
|
+
}
|
|
6704
6539
|
};
|
|
6705
6540
|
|
|
6706
6541
|
//#endregion
|
|
@@ -6727,34 +6562,28 @@ var ToolRouter = class {
|
|
|
6727
6562
|
*
|
|
6728
6563
|
* @example
|
|
6729
6564
|
* ```typescript
|
|
6730
|
-
* import { Composio } from '@composio/core';
|
|
6565
|
+
* import { Composio, experimental_createTool } from '@composio/core';
|
|
6731
6566
|
*
|
|
6732
6567
|
* const composio = new Composio();
|
|
6733
|
-
* const userId = 'user_123';
|
|
6734
6568
|
*
|
|
6735
|
-
* const session = await composio.
|
|
6569
|
+
* const session = await composio.create('user_123', {
|
|
6736
6570
|
* toolkits: ['gmail'],
|
|
6737
6571
|
* manageConnections: true,
|
|
6738
|
-
*
|
|
6739
|
-
*
|
|
6740
|
-
*
|
|
6741
|
-
* }
|
|
6572
|
+
* experimental: {
|
|
6573
|
+
* customTools: [myCustomTool],
|
|
6574
|
+
* customToolkits: [myToolkit],
|
|
6742
6575
|
* },
|
|
6743
|
-
* tags: ['readOnlyHint']
|
|
6744
6576
|
* });
|
|
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
6577
|
* ```
|
|
6755
6578
|
*/
|
|
6756
6579
|
async create(userId, config) {
|
|
6757
6580
|
const routerConfig = ToolRouterCreateSessionConfigSchema.parse(config ?? {});
|
|
6581
|
+
const customTools = routerConfig.experimental?.customTools;
|
|
6582
|
+
const customToolkits = routerConfig.experimental?.customToolkits;
|
|
6583
|
+
const experimentalPayload = {};
|
|
6584
|
+
if (routerConfig.experimental?.assistivePrompt?.userTimezone) experimentalPayload.assistive_prompt_config = { user_timezone: routerConfig.experimental.assistivePrompt.userTimezone };
|
|
6585
|
+
if (customTools?.length) experimentalPayload.custom_tools = require_CustomTool.serializeCustomTools(customTools);
|
|
6586
|
+
if (customToolkits?.length) experimentalPayload.custom_toolkits = require_CustomTool.serializeCustomToolkits(customToolkits);
|
|
6758
6587
|
const payload = {
|
|
6759
6588
|
user_id: userId,
|
|
6760
6589
|
auth_configs: routerConfig.authConfigs,
|
|
@@ -6764,11 +6593,13 @@ var ToolRouter = class {
|
|
|
6764
6593
|
tags: transformToolRouterTagsParams(routerConfig.tags),
|
|
6765
6594
|
manage_connections: transformToolRouterManageConnectionsParams(routerConfig.manageConnections),
|
|
6766
6595
|
workbench: transformToolRouterWorkbenchParams(routerConfig.workbench),
|
|
6767
|
-
experimental:
|
|
6596
|
+
experimental: Object.keys(experimentalPayload).length > 0 ? experimentalPayload : void 0
|
|
6768
6597
|
};
|
|
6769
6598
|
const session = await this.client.toolRouter.session.create(payload);
|
|
6599
|
+
let customToolsMap;
|
|
6600
|
+
if (customTools?.length || customToolkits?.length) customToolsMap = require_CustomTool.buildCustomToolsMapFromResponse(customTools ?? [], customToolkits, session.experimental);
|
|
6770
6601
|
const assistivePrompt = session.experimental?.assistive_prompt;
|
|
6771
|
-
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), { assistivePrompt });
|
|
6602
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), { assistivePrompt }, customToolsMap, userId);
|
|
6772
6603
|
}
|
|
6773
6604
|
/**
|
|
6774
6605
|
* Use an existing session
|
|
@@ -6897,7 +6728,7 @@ var Composio = class Composio {
|
|
|
6897
6728
|
*/
|
|
6898
6729
|
constructor(config) {
|
|
6899
6730
|
const { baseURL: baseURLParsed, apiKey: apiKeyParsed } = getSDKConfig(config?.baseURL, config?.apiKey);
|
|
6900
|
-
if (
|
|
6731
|
+
if (require_ComposioError.IS_DEVELOPMENT_OR_CI) require_ComposioError.logger_default.debug(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
|
|
6901
6732
|
/**
|
|
6902
6733
|
* Set the default provider, if not provided by the user.
|
|
6903
6734
|
*/
|
|
@@ -6923,7 +6754,7 @@ var Composio = class Composio {
|
|
|
6923
6754
|
apiKey: apiKeyParsed,
|
|
6924
6755
|
baseURL: baseURLParsed,
|
|
6925
6756
|
defaultHeaders: getDefaultHeaders(this.config.defaultHeaders, this.provider),
|
|
6926
|
-
logLevel:
|
|
6757
|
+
logLevel: require_ComposioError.COMPOSIO_LOG_LEVEL
|
|
6927
6758
|
});
|
|
6928
6759
|
this.tools = new Tools(this.client, this.config);
|
|
6929
6760
|
this.mcp = new MCP(this.client);
|
|
@@ -7119,7 +6950,7 @@ function jsonSchemaToZodSchema(jsonSchema, { strict } = { strict: false }) {
|
|
|
7119
6950
|
if (strict && schema) schema = removeNonRequiredProperties(schema);
|
|
7120
6951
|
return (0, _composio_json_schema_to_zod.jsonSchemaToZod)(schema);
|
|
7121
6952
|
} catch (error) {
|
|
7122
|
-
throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", { cause: error });
|
|
6953
|
+
throw new require_CustomTool.JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", { cause: error });
|
|
7123
6954
|
}
|
|
7124
6955
|
}
|
|
7125
6956
|
|
|
@@ -7601,7 +7432,7 @@ const ComposioMcpUpdateResponseSchema = zod_v3.z.object({
|
|
|
7601
7432
|
|
|
7602
7433
|
//#endregion
|
|
7603
7434
|
exports.AuthConfigCreationToolAccessConfigSchema = AuthConfigCreationToolAccessConfigSchema;
|
|
7604
|
-
exports.AuthConfigErrorCodes = AuthConfigErrorCodes;
|
|
7435
|
+
exports.AuthConfigErrorCodes = require_CustomTool.AuthConfigErrorCodes;
|
|
7605
7436
|
exports.AuthConfigListParamsSchema = AuthConfigListParamsSchema;
|
|
7606
7437
|
exports.AuthConfigListResponseSchema = AuthConfigListResponseSchema;
|
|
7607
7438
|
exports.AuthConfigRetrieveResponseSchema = AuthConfigRetrieveResponseSchema;
|
|
@@ -7617,39 +7448,39 @@ exports.BaseAgenticProvider = BaseAgenticProvider;
|
|
|
7617
7448
|
exports.BaseNonAgenticProvider = BaseNonAgenticProvider;
|
|
7618
7449
|
exports.BillcomAuthConnectionDataSchema = BillcomAuthConnectionDataSchema;
|
|
7619
7450
|
exports.Composio = Composio;
|
|
7620
|
-
exports.ComposioAuthConfigNotFoundError = ComposioAuthConfigNotFoundError;
|
|
7621
|
-
exports.ComposioConnectedAccountNotFoundError = ComposioConnectedAccountNotFoundError;
|
|
7451
|
+
exports.ComposioAuthConfigNotFoundError = require_CustomTool.ComposioAuthConfigNotFoundError;
|
|
7452
|
+
exports.ComposioConnectedAccountNotFoundError = require_CustomTool.ComposioConnectedAccountNotFoundError;
|
|
7622
7453
|
exports.ComposioCustomCreateResponseSchema = ComposioCustomCreateResponseSchema;
|
|
7623
|
-
exports.ComposioCustomToolsNotInitializedError = ComposioCustomToolsNotInitializedError;
|
|
7624
|
-
exports.ComposioError =
|
|
7625
|
-
exports.ComposioFailedToCreateConnectedAccountLink = ComposioFailedToCreateConnectedAccountLink;
|
|
7626
|
-
exports.ComposioFailedToCreatePusherClientError = ComposioFailedToCreatePusherClientError;
|
|
7627
|
-
exports.ComposioFailedToGetSDKRealtimeCredentialsError = ComposioFailedToGetSDKRealtimeCredentialsError;
|
|
7628
|
-
exports.ComposioFailedToSubscribeToPusherChannelError = ComposioFailedToSubscribeToPusherChannelError;
|
|
7629
|
-
exports.ComposioFailedToUnsubscribeFromPusherChannelError = ComposioFailedToUnsubscribeFromPusherChannelError;
|
|
7454
|
+
exports.ComposioCustomToolsNotInitializedError = require_CustomTool.ComposioCustomToolsNotInitializedError;
|
|
7455
|
+
exports.ComposioError = require_ComposioError.ComposioError;
|
|
7456
|
+
exports.ComposioFailedToCreateConnectedAccountLink = require_CustomTool.ComposioFailedToCreateConnectedAccountLink;
|
|
7457
|
+
exports.ComposioFailedToCreatePusherClientError = require_CustomTool.ComposioFailedToCreatePusherClientError;
|
|
7458
|
+
exports.ComposioFailedToGetSDKRealtimeCredentialsError = require_CustomTool.ComposioFailedToGetSDKRealtimeCredentialsError;
|
|
7459
|
+
exports.ComposioFailedToSubscribeToPusherChannelError = require_CustomTool.ComposioFailedToSubscribeToPusherChannelError;
|
|
7460
|
+
exports.ComposioFailedToUnsubscribeFromPusherChannelError = require_CustomTool.ComposioFailedToUnsubscribeFromPusherChannelError;
|
|
7630
7461
|
exports.ComposioGenerateURLParamsSchema = ComposioGenerateURLParamsSchema;
|
|
7631
7462
|
exports.ComposioGenerateURLResponseSchema = ComposioGenerateURLResponseSchema;
|
|
7632
|
-
exports.ComposioGlobalExecuteToolFnNotSetError = ComposioGlobalExecuteToolFnNotSetError;
|
|
7633
|
-
exports.ComposioInvalidExecuteFunctionError = ComposioInvalidExecuteFunctionError;
|
|
7634
|
-
exports.ComposioInvalidModifierError = ComposioInvalidModifierError;
|
|
7463
|
+
exports.ComposioGlobalExecuteToolFnNotSetError = require_CustomTool.ComposioGlobalExecuteToolFnNotSetError;
|
|
7464
|
+
exports.ComposioInvalidExecuteFunctionError = require_CustomTool.ComposioInvalidExecuteFunctionError;
|
|
7465
|
+
exports.ComposioInvalidModifierError = require_CustomTool.ComposioInvalidModifierError;
|
|
7635
7466
|
exports.ComposioMcpDeleteResponseSchema = ComposioMcpDeleteResponseSchema;
|
|
7636
7467
|
exports.ComposioMcpListResponseSchema = ComposioMcpListResponseSchema;
|
|
7637
7468
|
exports.ComposioMcpRetrieveResponseSchema = ComposioMcpRetrieveResponseSchema;
|
|
7638
7469
|
exports.ComposioMcpUpdateResponseSchema = ComposioMcpUpdateResponseSchema;
|
|
7639
|
-
exports.ComposioMultipleConnectedAccountsError = ComposioMultipleConnectedAccountsError;
|
|
7640
|
-
exports.ComposioNoAPIKeyError = ComposioNoAPIKeyError;
|
|
7470
|
+
exports.ComposioMultipleConnectedAccountsError = require_CustomTool.ComposioMultipleConnectedAccountsError;
|
|
7471
|
+
exports.ComposioNoAPIKeyError = require_CustomTool.ComposioNoAPIKeyError;
|
|
7641
7472
|
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;
|
|
7473
|
+
exports.ComposioProviderNotDefinedError = require_CustomTool.ComposioProviderNotDefinedError;
|
|
7474
|
+
exports.ComposioToolExecutionError = require_CustomTool.ComposioToolExecutionError;
|
|
7475
|
+
exports.ComposioToolNotFoundError = require_CustomTool.ComposioToolNotFoundError;
|
|
7476
|
+
exports.ComposioToolVersionRequiredError = require_CustomTool.ComposioToolVersionRequiredError;
|
|
7477
|
+
exports.ComposioToolkitFetchError = require_CustomTool.ComposioToolkitFetchError;
|
|
7478
|
+
exports.ComposioToolkitNotFoundError = require_CustomTool.ComposioToolkitNotFoundError;
|
|
7479
|
+
exports.ComposioTriggerTypeNotFoundError = require_CustomTool.ComposioTriggerTypeNotFoundError;
|
|
7480
|
+
exports.ComposioWebhookPayloadError = require_CustomTool.ComposioWebhookPayloadError;
|
|
7481
|
+
exports.ComposioWebhookSignatureVerificationError = require_CustomTool.ComposioWebhookSignatureVerificationError;
|
|
7651
7482
|
exports.ConnectedAccountAuthConfigSchema = ConnectedAccountAuthConfigSchema;
|
|
7652
|
-
exports.ConnectedAccountErrorCodes = ConnectedAccountErrorCodes;
|
|
7483
|
+
exports.ConnectedAccountErrorCodes = require_CustomTool.ConnectedAccountErrorCodes;
|
|
7653
7484
|
exports.ConnectedAccountListParamsSchema = ConnectedAccountListParamsSchema;
|
|
7654
7485
|
exports.ConnectedAccountListResponseSchema = ConnectedAccountListResponseSchema;
|
|
7655
7486
|
exports.ConnectedAccountRefreshOptionsSchema = ConnectedAccountRefreshOptionsSchema;
|
|
@@ -7658,9 +7489,9 @@ exports.ConnectedAccountStatusSchema = ConnectedAccountStatusSchema;
|
|
|
7658
7489
|
exports.ConnectedAccountStatuses = ConnectedAccountStatuses;
|
|
7659
7490
|
exports.ConnectionDataSchema = ConnectionDataSchema;
|
|
7660
7491
|
exports.ConnectionExpiredEventSchema = ConnectionExpiredEventSchema;
|
|
7661
|
-
exports.ConnectionRequestErrorCodes = ConnectionRequestErrorCodes;
|
|
7662
|
-
exports.ConnectionRequestFailedError = ConnectionRequestFailedError;
|
|
7663
|
-
exports.ConnectionRequestTimeoutError = ConnectionRequestTimeoutError;
|
|
7492
|
+
exports.ConnectionRequestErrorCodes = require_CustomTool.ConnectionRequestErrorCodes;
|
|
7493
|
+
exports.ConnectionRequestFailedError = require_CustomTool.ConnectionRequestFailedError;
|
|
7494
|
+
exports.ConnectionRequestTimeoutError = require_CustomTool.ConnectionRequestTimeoutError;
|
|
7664
7495
|
exports.ConnectionStatus = ConnectionStatus;
|
|
7665
7496
|
exports.ConnectionStatuses = ConnectionStatuses;
|
|
7666
7497
|
exports.CreateAuthConfigParamsSchema = CreateAuthConfigParamsSchema;
|
|
@@ -7672,11 +7503,14 @@ exports.CreateConnectedAccountOptionsSchema = CreateConnectedAccountOptionsSchem
|
|
|
7672
7503
|
exports.CreateConnectedAccountParamsSchema = CreateConnectedAccountParamsSchema;
|
|
7673
7504
|
exports.CreateConnectedAccountResponseSchema = CreateConnectedAccountResponseSchema;
|
|
7674
7505
|
exports.CreateCustomAuthConfigParamsSchema = CreateCustomAuthConfigParamsSchema;
|
|
7506
|
+
exports.CreateCustomToolBaseSchema = require_CustomTool.CreateCustomToolBaseSchema;
|
|
7507
|
+
exports.CreateCustomToolkitBaseSchema = require_CustomTool.CreateCustomToolkitBaseSchema;
|
|
7675
7508
|
exports.CustomAuthParamsSchema = CustomAuthParamsSchema;
|
|
7676
7509
|
exports.CustomConnectionDataSchema = CustomConnectionDataSchema;
|
|
7677
7510
|
exports.CustomCreateResponseSchema = CustomCreateResponseSchema;
|
|
7678
7511
|
exports.CustomOauth1ConnectionDataSchema = CustomOauth1ConnectionDataSchema;
|
|
7679
7512
|
exports.CustomOauth2ConnectionDataSchema = CustomOauth2ConnectionDataSchema;
|
|
7513
|
+
exports.CustomToolSlugSchema = require_CustomTool.CustomToolSlugSchema;
|
|
7680
7514
|
exports.DefaultCreateConnectedAccountParamsSchema = DefaultCreateConnectedAccountParamsSchema;
|
|
7681
7515
|
exports.FileDeleteResponseSchema = FileDeleteResponseSchema;
|
|
7682
7516
|
exports.FileListResponseSchema = FileListResponseSchema;
|
|
@@ -7684,7 +7518,7 @@ exports.GenerateURLParamsSchema = GenerateURLParamsSchema;
|
|
|
7684
7518
|
exports.GenerateURLResponseSchema = GenerateURLResponseSchema;
|
|
7685
7519
|
exports.IncomingTriggerPayloadSchema = IncomingTriggerPayloadSchema;
|
|
7686
7520
|
exports.JSONSchemaPropertySchema = JSONSchemaPropertySchema;
|
|
7687
|
-
exports.JsonSchemaToZodError = JsonSchemaToZodError;
|
|
7521
|
+
exports.JsonSchemaToZodError = require_CustomTool.JsonSchemaToZodError;
|
|
7688
7522
|
exports.MCP = MCP;
|
|
7689
7523
|
exports.MCPAuthOptionsSchema = MCPAuthOptionsSchema;
|
|
7690
7524
|
exports.MCPGenerateURLParamsSchema = MCPGenerateURLParamsSchema;
|
|
@@ -7720,11 +7554,12 @@ exports.OpenAIProvider = OpenAIProvider;
|
|
|
7720
7554
|
exports.RedirectableAuthSchemeSchema = RedirectableAuthSchemeSchema;
|
|
7721
7555
|
exports.RemoteFile = RemoteFile;
|
|
7722
7556
|
exports.RemoteFileDataSchema = RemoteFileDataSchema;
|
|
7723
|
-
exports.RemoteFileDownloadError = RemoteFileDownloadError;
|
|
7724
|
-
exports.RemoteFileErrorCodes = RemoteFileErrorCodes;
|
|
7725
|
-
exports.SDKErrorCodes = SDKErrorCodes;
|
|
7557
|
+
exports.RemoteFileDownloadError = require_CustomTool.RemoteFileDownloadError;
|
|
7558
|
+
exports.RemoteFileErrorCodes = require_CustomTool.RemoteFileErrorCodes;
|
|
7559
|
+
exports.SDKErrorCodes = require_CustomTool.SDKErrorCodes;
|
|
7560
|
+
exports.SessionProxyExecuteParamsSchema = SessionProxyExecuteParamsSchema;
|
|
7726
7561
|
exports.SingleConnectedAccountDetailedResponseSchema = SingleConnectedAccountDetailedResponseSchema;
|
|
7727
|
-
exports.ToolErrorCodes = ToolErrorCodes;
|
|
7562
|
+
exports.ToolErrorCodes = require_CustomTool.ToolErrorCodes;
|
|
7728
7563
|
exports.ToolExecuteMetaParamsSchema = ToolExecuteMetaParamsSchema;
|
|
7729
7564
|
exports.ToolExecuteParamsSchema = ToolExecuteParamsSchema;
|
|
7730
7565
|
exports.ToolExecuteResponseSchema = ToolExecuteResponseSchema;
|
|
@@ -7761,7 +7596,7 @@ exports.ToolkitAuthFieldsResponseSchema = ToolkitAuthFieldsResponseSchema;
|
|
|
7761
7596
|
exports.ToolkitCategorySchema = ToolkitCategorySchema;
|
|
7762
7597
|
exports.ToolkitConnectionStateSchema = ToolkitConnectionStateSchema;
|
|
7763
7598
|
exports.ToolkitConnectionsDetailsSchema = ToolkitConnectionsDetailsSchema;
|
|
7764
|
-
exports.ToolkitErrorCodes = ToolkitErrorCodes;
|
|
7599
|
+
exports.ToolkitErrorCodes = require_CustomTool.ToolkitErrorCodes;
|
|
7765
7600
|
exports.ToolkitLatestVersionSchema = ToolkitLatestVersionSchema;
|
|
7766
7601
|
exports.ToolkitMangedByEnumSchema = ToolkitMangedByEnumSchema;
|
|
7767
7602
|
exports.ToolkitRetrieveCategoriesResponseSchema = ToolkitRetrieveCategoriesResponseSchema;
|
|
@@ -7772,7 +7607,7 @@ exports.ToolkitVersionParamSchema = ToolkitVersionParamSchema;
|
|
|
7772
7607
|
exports.ToolkitVersionSchema = ToolkitVersionSchema;
|
|
7773
7608
|
exports.ToolkitVersionsSchema = ToolkitVersionsSchema;
|
|
7774
7609
|
exports.ToolkitsListParamsSchema = ToolkitsListParamsSchema;
|
|
7775
|
-
exports.TriggerErrorCodes = TriggerErrorCodes;
|
|
7610
|
+
exports.TriggerErrorCodes = require_CustomTool.TriggerErrorCodes;
|
|
7776
7611
|
exports.TriggerInstanceListActiveParamsSchema = TriggerInstanceListActiveParamsSchema;
|
|
7777
7612
|
exports.TriggerInstanceListActiveResponseItemSchema = TriggerInstanceListActiveResponseItemSchema;
|
|
7778
7613
|
exports.TriggerInstanceListActiveResponseSchema = TriggerInstanceListActiveResponseSchema;
|
|
@@ -7787,8 +7622,8 @@ exports.TriggerSubscribeParamSchema = TriggerSubscribeParamSchema;
|
|
|
7787
7622
|
exports.TriggerTypeSchema = TriggerTypeSchema;
|
|
7788
7623
|
exports.TriggersTypeListParamsSchema = TriggersTypeListParamsSchema;
|
|
7789
7624
|
exports.TriggersTypeListResponseSchema = TriggersTypeListResponseSchema;
|
|
7790
|
-
exports.ValidationError = ValidationError;
|
|
7791
|
-
exports.ValidationErrorCodes = ValidationErrorCodes;
|
|
7625
|
+
exports.ValidationError = require_CustomTool.ValidationError;
|
|
7626
|
+
exports.ValidationErrorCodes = require_CustomTool.ValidationErrorCodes;
|
|
7792
7627
|
exports.VerifyWebhookParamsSchema = VerifyWebhookParamsSchema;
|
|
7793
7628
|
exports.WebhookConnectedAccountAuthConfigSchema = WebhookConnectedAccountAuthConfigSchema;
|
|
7794
7629
|
exports.WebhookConnectionMetadataSchema = WebhookConnectionMetadataSchema;
|
|
@@ -7804,12 +7639,14 @@ exports.WebhookVersions = WebhookVersions;
|
|
|
7804
7639
|
Object.defineProperty(exports, 'constants', {
|
|
7805
7640
|
enumerable: true,
|
|
7806
7641
|
get: function () {
|
|
7807
|
-
return
|
|
7642
|
+
return require_ComposioError.constants_exports;
|
|
7808
7643
|
}
|
|
7809
7644
|
});
|
|
7810
7645
|
exports.createConnectionRequest = createConnectionRequest;
|
|
7646
|
+
exports.experimental_createTool = require_CustomTool.createCustomTool;
|
|
7647
|
+
exports.experimental_createToolkit = require_CustomTool.createCustomToolkit;
|
|
7811
7648
|
exports.getExtensionFromMimeType = getExtensionFromMimeType;
|
|
7812
|
-
exports.handleToolExecutionError = handleToolExecutionError;
|
|
7649
|
+
exports.handleToolExecutionError = require_CustomTool.handleToolExecutionError;
|
|
7813
7650
|
exports.jsonSchemaToZodSchema = jsonSchemaToZodSchema;
|
|
7814
|
-
exports.logger =
|
|
7651
|
+
exports.logger = require_ComposioError.logger_default;
|
|
7815
7652
|
exports.removeNonRequiredProperties = removeNonRequiredProperties;
|