@composio/core 0.6.3 → 0.6.5-alpha.0
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/{BaseProvider-C7yGAyLz.d.mts → BaseProvider-B2v5L9PY.d.mts} +2273 -363
- package/dist/{BaseProvider-X7JCCvcK.d.cts → BaseProvider-B_UIuruL.d.cts} +2273 -363
- package/dist/{Telemetry-Bn5VseVi.mjs → Telemetry-CHfDfthM.mjs} +5 -8
- package/dist/{Telemetry-DErMJqj0.cjs → Telemetry-DRFfIuVS.cjs} +5 -8
- package/dist/{buffer-BFpVRahf.mjs → buffer-C1MwV-7j.mjs} +3 -1
- package/dist/{buffer-CYf1Z6Sd.cjs → buffer-Dy7Xi_sk.cjs} +8 -0
- package/dist/{composio-uGEfnO6v.d.cts → composio-B-tZKVA0.d.cts} +994 -407
- package/dist/{composio-Ds1Z80p8.d.mts → composio-OAY2JH-U.d.mts} +994 -407
- package/dist/{fileUtils.node-DLp53qm1.cjs → fileUtils.node-BUe2eO0j.cjs} +1 -1
- package/dist/{fileUtils.node-MOEGtpnI.mjs → fileUtils.node-D1JLL4nZ.mjs} +1 -1
- package/dist/index.cjs +1075 -123
- package/dist/index.d.cts +4906 -5
- package/dist/index.d.mts +4906 -5
- package/dist/index.mjs +1054 -124
- package/dist/models/Files.node.cjs +3 -3
- package/dist/models/Files.node.mjs +3 -3
- package/dist/{types-CMQAtpc_.d.mts → types-Bo0skt5g.d.mts} +2 -2
- package/dist/{types-CTXCkF_v.d.cts → types-lcoAiXDa.d.cts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +3 -3
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +3 -3
- package/dist/utils/modifiers/FileToolModifier.node.cjs +2 -2
- 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 +2 -2
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/generated/ably.ts +20 -0
- package/generated/accelo.ts +8 -0
- package/generated/acculynx.ts +17 -0
- package/generated/active_campaign.ts +30 -0
- package/generated/adobe.ts +8 -0
- package/generated/adyntel.ts +12 -0
- package/generated/aero_workflow.ts +8 -0
- package/generated/affinity.ts +29 -0
- package/generated/agencyzoom.ts +108 -0
- package/generated/ahrefs.ts +49 -0
- package/generated/airtable.ts +26 -0
- package/generated/alchemy.ts +16 -0
- package/generated/algolia.ts +39 -0
- package/generated/altoviz.ts +18 -0
- package/generated/amazon.ts +8 -0
- package/generated/amcards.ts +11 -0
- package/generated/amplitude.ts +25 -0
- package/generated/anthropic_administrator.ts +13 -0
- package/generated/apaleo.ts +38 -0
- package/generated/apollo.ts +40 -0
- package/generated/appdrag.ts +8 -0
- package/generated/appsflyer.ts +8 -0
- package/generated/asana.ts +95 -0
- package/generated/ashby.ts +8 -0
- package/generated/atlassian.ts +8 -0
- package/generated/attio.ts +20 -0
- package/generated/auth0.ts +8 -0
- package/generated/axonaut.ts +8 -0
- package/generated/bamboohr.ts +168 -0
- package/generated/bannerbear.ts +17 -0
- package/generated/baserow.ts +11 -0
- package/generated/battlenet.ts +8 -0
- package/generated/beeminder.ts +14 -0
- package/generated/bigmailer.ts +12 -0
- package/generated/bigml.ts +15 -0
- package/generated/bill.ts +218 -0
- package/generated/bitbucket.ts +25 -0
- package/generated/bitwarden.ts +8 -0
- package/generated/blackbaud.ts +8 -0
- package/generated/blackboard.ts +323 -0
- package/generated/boldsign.ts +8 -0
- package/generated/bolna.ts +24 -0
- package/generated/borneo.ts +162 -0
- package/generated/botbaba.ts +8 -0
- package/generated/box.ts +282 -0
- package/generated/braintree.ts +8 -0
- package/generated/brandfetch.ts +15 -0
- package/generated/breezy_hr.ts +8 -0
- package/generated/brevo.ts +28 -0
- package/generated/brex.ts +8 -0
- package/generated/brex_staging.ts +8 -0
- package/generated/brightpearl.ts +8 -0
- package/generated/brilliant_directories.ts +15 -0
- package/generated/browseai.ts +18 -0
- package/generated/browserbase_tool.ts +10 -0
- package/generated/browserhub.ts +8 -0
- package/generated/browserless.ts +16 -0
- package/generated/bubble.ts +8 -0
- package/generated/bugbug.ts +13 -0
- package/generated/builtwith.ts +21 -0
- package/generated/cal.ts +150 -0
- package/generated/calendly.ts +51 -0
- package/generated/canva.ts +41 -0
- package/generated/canvas.ts +100 -0
- package/generated/chatwork.ts +17 -0
- package/generated/chmeetings.ts +8 -0
- package/generated/clickup.ts +153 -0
- package/generated/clockify.ts +23 -0
- package/generated/close.ts +15 -0
- package/generated/cloudflare.ts +10 -0
- package/generated/coda.ts +115 -0
- package/generated/codeinterpreter.ts +14 -0
- package/generated/coinbase.ts +15 -0
- package/generated/coinmarketcal.ts +8 -0
- package/generated/composio.ts +34 -0
- package/generated/composio_search.ts +22 -0
- package/generated/confluence.ts +199 -0
- package/generated/contentful.ts +12 -0
- package/generated/crustdata.ts +23 -0
- package/generated/customer_io.ts +8 -0
- package/generated/cutt_ly.ts +10 -0
- package/generated/d2lbrightspace.ts +54 -0
- package/generated/dailybot.ts +15 -0
- package/generated/datadog.ts +47 -0
- package/generated/datagma.ts +8 -0
- package/generated/datarobot.ts +8 -0
- package/generated/deel.ts +8 -0
- package/generated/demio.ts +8 -0
- package/generated/dialpad.ts +201 -0
- package/generated/digicert.ts +15 -0
- package/generated/discord.ts +17 -0
- package/generated/discordbot.ts +173 -0
- package/generated/docmosis.ts +8 -0
- package/generated/docusign.ts +351 -0
- package/generated/dropbox.ts +20 -0
- package/generated/dropbox_sign.ts +8 -0
- package/generated/dynamics365.ts +25 -0
- package/generated/echtpost.ts +10 -0
- package/generated/elevenlabs.ts +70 -0
- package/generated/emailoctopus.ts +16 -0
- package/generated/enigma.ts +11 -0
- package/generated/entelligence.ts +11 -0
- package/generated/epic_games.ts +8 -0
- package/generated/eventbrite.ts +12 -0
- package/generated/exa.ts +13 -0
- package/generated/excel.ts +34 -0
- package/generated/exist.ts +8 -0
- package/generated/facebook.ts +8 -0
- package/generated/factorial.ts +8 -0
- package/generated/figma.ts +59 -0
- package/generated/finage.ts +19 -0
- package/generated/firecrawl.ts +16 -0
- package/generated/fireflies.ts +21 -0
- package/generated/fitbit.ts +8 -0
- package/generated/flutterwave.ts +33 -0
- package/generated/fomo.ts +10 -0
- package/generated/formcarry.ts +10 -0
- package/generated/formsite.ts +14 -0
- package/generated/foursquare.ts +14 -0
- package/generated/freshbooks.ts +11 -0
- package/generated/freshdesk.ts +16 -0
- package/generated/front.ts +8 -0
- package/generated/github.ts +967 -0
- package/generated/gitlab.ts +82 -0
- package/generated/gmail.d.ts +86 -0
- package/generated/gmail.js +13 -0
- package/generated/gmail.ts +95 -0
- package/generated/go_to_webinar.ts +8 -0
- package/generated/gong.ts +63 -0
- package/generated/google_analytics.ts +13 -0
- package/generated/google_maps.ts +16 -0
- package/generated/googleads.ts +14 -0
- package/generated/googlebigquery.ts +10 -0
- package/generated/googlecalendar.ts +39 -0
- package/generated/googledocs.ts +41 -0
- package/generated/googledrive.ts +62 -0
- package/generated/googlemeet.ts +18 -0
- package/generated/googlephotos.ts +22 -0
- package/generated/googlesheets.ts +40 -0
- package/generated/googleslides.ts +8 -0
- package/generated/googlesuper.ts +230 -0
- package/generated/googletasks.ts +23 -0
- package/generated/gorgias.ts +41 -0
- package/generated/gumroad.ts +14 -0
- package/generated/guru.ts +8 -0
- package/generated/hackernews.ts +15 -0
- package/generated/hackerrank_work.ts +8 -0
- package/generated/harvest.ts +56 -0
- package/generated/helcim.ts +8 -0
- package/generated/heygen.ts +44 -0
- package/generated/highlevel.ts +8 -0
- package/generated/hubspot.ts +252 -0
- package/generated/humanloop.ts +13 -0
- package/generated/icims_talent_cloud.ts +8 -0
- package/generated/idea_scale.ts +8 -0
- package/generated/index.ts +151 -0
- package/generated/insighto_ai.ts +19 -0
- package/generated/intercom.ts +52 -0
- package/generated/interzoid.ts +8 -0
- package/generated/jira.ts +59 -0
- package/generated/jotform.ts +15 -0
- package/generated/junglescout.ts +15 -0
- package/generated/keap.ts +8 -0
- package/generated/kibana.ts +58 -0
- package/generated/kit.ts +38 -0
- package/generated/klaviyo.ts +240 -0
- package/generated/klipfolio.ts +20 -0
- package/generated/kommo.ts +24 -0
- package/generated/lastpass.ts +8 -0
- package/generated/launch_darkly.ts +16 -0
- package/generated/leadfeeder.ts +13 -0
- package/generated/leadoku.ts +10 -0
- package/generated/lever.ts +8 -0
- package/generated/lever_sandbox.ts +8 -0
- package/generated/lexoffice.ts +8 -0
- package/generated/linear.ts +31 -0
- package/generated/linkedin.ts +13 -0
- package/generated/linkhut.ts +14 -0
- package/generated/linkup.ts +11 -0
- package/generated/listennotes.ts +35 -0
- package/generated/lmnt.ts +16 -0
- package/generated/lodgify.ts +10 -0
- package/generated/mailchimp.ts +285 -0
- package/generated/mailerlite.ts +8 -0
- package/generated/maintainx.ts +20 -0
- package/generated/make.ts +12 -0
- package/generated/mboum.ts +8 -0
- package/generated/mem0.ts +52 -0
- package/generated/metaads.ts +25 -0
- package/generated/metatextai.ts +8 -0
- package/generated/microsoft_clarity.ts +10 -0
- package/generated/microsoft_teams.ts +22 -0
- package/generated/microsoft_tenant.ts +8 -0
- package/generated/miro.ts +23 -0
- package/generated/mixpanel.ts +30 -0
- package/generated/mocean.ts +8 -0
- package/generated/monday.ts +30 -0
- package/generated/mopinion.ts +8 -0
- package/generated/more_trees.ts +10 -0
- package/generated/moxie.ts +8 -0
- package/generated/moz.ts +8 -0
- package/generated/mural.ts +14 -0
- package/generated/nasdaq.ts +15 -0
- package/generated/ncscale.ts +8 -0
- package/generated/neon.ts +78 -0
- package/generated/netsuite.ts +8 -0
- package/generated/nextdns.ts +11 -0
- package/generated/ngrok.ts +18 -0
- package/generated/notion.ts +40 -0
- package/generated/oncehub.ts +8 -0
- package/generated/one_drive.ts +49 -0
- package/generated/onepage.ts +11 -0
- package/generated/open_sea.ts +33 -0
- package/generated/outlook.ts +37 -0
- package/generated/pagerduty.ts +362 -0
- package/generated/pandadoc.ts +23 -0
- package/generated/peopledatalabs.ts +24 -0
- package/generated/perplexityai.ts +10 -0
- package/generated/piggy.ts +8 -0
- package/generated/pipedrive.ts +288 -0
- package/generated/placekey.ts +12 -0
- package/generated/posthog.ts +367 -0
- package/generated/precoro.ts +8 -0
- package/generated/printnode.ts +8 -0
- package/generated/process_street.ts +14 -0
- package/generated/productboard.ts +8 -0
- package/generated/qualaroo.ts +8 -0
- package/generated/quickbooks.ts +22 -0
- package/generated/rafflys.ts +8 -0
- package/generated/ragic.ts +10 -0
- package/generated/ramp.ts +17 -0
- package/generated/ravenseotools.ts +8 -0
- package/generated/recallai.ts +17 -0
- package/generated/reddit.ts +19 -0
- package/generated/resend.ts +27 -0
- package/generated/retellai.ts +19 -0
- package/generated/retently.ts +24 -0
- package/generated/ring_central.ts +8 -0
- package/generated/rippling.ts +8 -0
- package/generated/rocket_reach.ts +8 -0
- package/generated/rocketlane.ts +42 -0
- package/generated/rootly.ts +12 -0
- package/generated/rosette_text_analytics.ts +12 -0
- package/generated/sage.ts +8 -0
- package/generated/salesforce.ts +46 -0
- package/generated/scrape_do.ts +28 -0
- package/generated/scrapingant.ts +14 -0
- package/generated/screenshotone.ts +10 -0
- package/generated/seismic.ts +8 -0
- package/generated/semanticscholar.ts +23 -0
- package/generated/semrush.ts +45 -0
- package/generated/sendgrid.ts +384 -0
- package/generated/sentry.ts +185 -0
- package/generated/serpapi.ts +32 -0
- package/generated/servicem8.ts +37 -0
- package/generated/servicenow.ts +14 -0
- package/generated/share_point.ts +15 -0
- package/generated/shopify.ts +37 -0
- package/generated/shortcut.ts +131 -0
- package/generated/simplesat.ts +11 -0
- package/generated/slack.d.ts +16 -0
- package/generated/slack.js +11 -0
- package/generated/slack.ts +24 -0
- package/generated/slackbot.ts +205 -0
- package/generated/smartrecruiters.ts +8 -0
- package/generated/smugmug.ts +14 -0
- package/generated/snowflake.ts +15 -0
- package/generated/sourcegraph.ts +16 -0
- package/generated/square.ts +8 -0
- package/generated/stack_exchange.ts +17 -0
- package/generated/starton.ts +11 -0
- package/generated/storeganise.ts +12 -0
- package/generated/stripe.ts +50 -0
- package/generated/supabase.ts +86 -0
- package/generated/survey_monkey.ts +8 -0
- package/generated/tally.ts +25 -0
- package/generated/tapfiliate.ts +11 -0
- package/generated/tapform.ts +8 -0
- package/generated/tavily.ts +10 -0
- package/generated/terminus.ts +8 -0
- package/generated/text_to_pdf.ts +10 -0
- package/generated/textrazor.ts +22 -0
- package/generated/timecamp.ts +10 -0
- package/generated/timekit.ts +8 -0
- package/generated/timely.ts +11 -0
- package/generated/tinypng.ts +15 -0
- package/generated/tinyurl.ts +10 -0
- package/generated/tisane.ts +15 -0
- package/generated/todoist.ts +19 -0
- package/generated/toneden.ts +8 -0
- package/generated/tpscheck.ts +10 -0
- package/generated/trello.ts +360 -0
- package/generated/twitch.ts +8 -0
- package/generated/twitter.ts +82 -0
- package/generated/twitter_media.ts +10 -0
- package/generated/typefully.ts +14 -0
- package/generated/venly.ts +8 -0
- package/generated/vero.ts +8 -0
- package/generated/visme.ts +8 -0
- package/generated/waboxapp.ts +8 -0
- package/generated/wakatime.ts +8 -0
- package/generated/wave_accounting.ts +8 -0
- package/generated/weathermap.ts +10 -0
- package/generated/webex.ts +37 -0
- package/generated/webflow.ts +30 -0
- package/generated/whatsapp.ts +14 -0
- package/generated/wiz.ts +8 -0
- package/generated/workiom.ts +12 -0
- package/generated/wrike.ts +47 -0
- package/generated/xero.ts +13 -0
- package/generated/yandex.ts +13 -0
- package/generated/ynab.ts +8 -0
- package/generated/yousearch.ts +10 -0
- package/generated/youtube.ts +26 -0
- package/generated/zendesk.ts +23 -0
- package/generated/zenrows.ts +25 -0
- package/generated/zenserp.ts +20 -0
- package/generated/zoho.ts +33 -0
- package/generated/zoho_bigin.ts +21 -0
- package/generated/zoho_books.ts +8 -0
- package/generated/zoho_desk.ts +8 -0
- package/generated/zoho_inventory.ts +8 -0
- package/generated/zoho_invoice.ts +15 -0
- package/generated/zoho_mail.ts +8 -0
- package/generated/zoom.ts +181 -0
- package/generated/zoominfo.ts +26 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk-Dx2NuYGI.mjs";
|
|
2
|
-
import { c as COMPOSIO_DIR, d as IS_DEVELOPMENT_OR_CI, g as
|
|
3
|
-
import { t as telemetry } from "./Telemetry-
|
|
2
|
+
import { _ as getEnvsWithPrefix, c as COMPOSIO_DIR, d as DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID, f as IS_DEVELOPMENT_OR_CI, g as getEnvVariable, h as constants_exports, i as getRandomShortId, l as COMPOSIO_LOG_LEVEL, m as USER_DATA_FILE_NAME, o as ComposioError, p as TEMP_FILES_DIRECTORY_NAME, s as logger_default, t as arrayBufferToBase64, u as DEFAULT_BASE_URL } from "./buffer-C1MwV-7j.mjs";
|
|
3
|
+
import { t as telemetry } from "./Telemetry-CHfDfthM.mjs";
|
|
4
4
|
import ComposioClient, { APIError } from "@composio/client";
|
|
5
5
|
import { FileToolModifier } from "#file_tool_modifier";
|
|
6
6
|
import z, { ZodError, z as z$1 } from "zod/v3";
|
|
@@ -30,7 +30,8 @@ const AuthSchemeTypes = {
|
|
|
30
30
|
CALCOM_AUTH: "CALCOM_AUTH",
|
|
31
31
|
SERVICE_ACCOUNT: "SERVICE_ACCOUNT",
|
|
32
32
|
SAML: "SAML",
|
|
33
|
-
DCR_OAUTH: "DCR_OAUTH"
|
|
33
|
+
DCR_OAUTH: "DCR_OAUTH",
|
|
34
|
+
S2S_OAUTH2: "S2S_OAUTH2"
|
|
34
35
|
};
|
|
35
36
|
const AuthConfigCreationToolAccessConfigSchema = z$1.object({ toolsForConnectedAccountCreation: z$1.array(z$1.string()).optional() });
|
|
36
37
|
const AuthConfigToolAccessConfigSchema = z$1.object({
|
|
@@ -50,7 +51,8 @@ const AuthSchemeEnum = z$1.enum([
|
|
|
50
51
|
"CALCOM_AUTH",
|
|
51
52
|
"SERVICE_ACCOUNT",
|
|
52
53
|
"SAML",
|
|
53
|
-
"DCR_OAUTH"
|
|
54
|
+
"DCR_OAUTH",
|
|
55
|
+
"S2S_OAUTH2"
|
|
54
56
|
]);
|
|
55
57
|
const CreateCustomAuthConfigParamsSchema = z$1.object({
|
|
56
58
|
type: z$1.literal("use_custom_auth"),
|
|
@@ -254,6 +256,70 @@ const Oauth2ConnectionDataSchema = z$1.discriminatedUnion("status", [
|
|
|
254
256
|
Oauth2InactiveConnectionDataSchema
|
|
255
257
|
]);
|
|
256
258
|
const CustomOauth2ConnectionDataSchema = Oauth2ActiveConnectionDataSchema.omit({ status: true });
|
|
259
|
+
const S2SOauth2BaseSchema = BaseSchemeRaw.extend({ status: z$1.literal(ConnectionStatuses.INITIALIZING) }).catchall(z$1.unknown());
|
|
260
|
+
const S2SOauth2ConnectionDataSchema = z$1.discriminatedUnion("status", [
|
|
261
|
+
S2SOauth2BaseSchema,
|
|
262
|
+
S2SOauth2BaseSchema.extend({ status: z$1.literal(ConnectionStatuses.INITIATED) }).catchall(z$1.unknown()),
|
|
263
|
+
S2SOauth2BaseSchema.extend({
|
|
264
|
+
status: z$1.literal(ConnectionStatuses.ACTIVE),
|
|
265
|
+
access_token: z$1.string().optional(),
|
|
266
|
+
id_token: z$1.string().optional(),
|
|
267
|
+
token_type: z$1.string().optional(),
|
|
268
|
+
refresh_token: z$1.string().nullish(),
|
|
269
|
+
expires_in: z$1.union([
|
|
270
|
+
z$1.string(),
|
|
271
|
+
z$1.number(),
|
|
272
|
+
z$1.null()
|
|
273
|
+
]).optional(),
|
|
274
|
+
scope: z$1.union([
|
|
275
|
+
z$1.string(),
|
|
276
|
+
z$1.array(z$1.string()),
|
|
277
|
+
z$1.null()
|
|
278
|
+
]).optional()
|
|
279
|
+
}).catchall(z$1.unknown()),
|
|
280
|
+
S2SOauth2BaseSchema.extend({
|
|
281
|
+
status: z$1.literal(ConnectionStatuses.INACTIVE),
|
|
282
|
+
access_token: z$1.string().optional(),
|
|
283
|
+
id_token: z$1.string().optional(),
|
|
284
|
+
token_type: z$1.string().optional(),
|
|
285
|
+
refresh_token: z$1.string().nullish(),
|
|
286
|
+
expires_in: z$1.union([
|
|
287
|
+
z$1.string(),
|
|
288
|
+
z$1.number(),
|
|
289
|
+
z$1.null()
|
|
290
|
+
]).optional(),
|
|
291
|
+
scope: z$1.union([
|
|
292
|
+
z$1.string(),
|
|
293
|
+
z$1.array(z$1.string()),
|
|
294
|
+
z$1.null()
|
|
295
|
+
]).optional()
|
|
296
|
+
}).catchall(z$1.unknown()),
|
|
297
|
+
S2SOauth2BaseSchema.extend({
|
|
298
|
+
status: z$1.literal(ConnectionStatuses.FAILED),
|
|
299
|
+
error: z$1.string().optional(),
|
|
300
|
+
error_description: z$1.string().optional()
|
|
301
|
+
}).catchall(z$1.unknown()),
|
|
302
|
+
S2SOauth2BaseSchema.extend({
|
|
303
|
+
status: z$1.literal(ConnectionStatuses.EXPIRED),
|
|
304
|
+
expired_at: z$1.string().optional()
|
|
305
|
+
}).catchall(z$1.unknown())
|
|
306
|
+
]);
|
|
307
|
+
const CustomS2SOauth2ConnectionDataSchema = BaseSchemeRaw.extend({
|
|
308
|
+
access_token: z$1.string().optional(),
|
|
309
|
+
id_token: z$1.string().optional(),
|
|
310
|
+
token_type: z$1.string().optional(),
|
|
311
|
+
refresh_token: z$1.string().nullish().optional(),
|
|
312
|
+
expires_in: z$1.union([
|
|
313
|
+
z$1.string(),
|
|
314
|
+
z$1.number(),
|
|
315
|
+
z$1.null()
|
|
316
|
+
]).optional(),
|
|
317
|
+
scope: z$1.union([
|
|
318
|
+
z$1.string(),
|
|
319
|
+
z$1.array(z$1.string()),
|
|
320
|
+
z$1.null()
|
|
321
|
+
]).optional()
|
|
322
|
+
}).catchall(z$1.unknown());
|
|
257
323
|
const Oauth1InitiatingConnectionDataSchema = BaseSchemeRaw.extend({ status: z$1.literal(ConnectionStatuses.INITIALIZING) }).catchall(z$1.unknown());
|
|
258
324
|
const Oauth1InitiatedConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
|
|
259
325
|
status: z$1.literal(ConnectionStatuses.INITIATED),
|
|
@@ -614,6 +680,10 @@ const ConnectionDataSchema = z$1.discriminatedUnion("authScheme", [
|
|
|
614
680
|
authScheme: z$1.literal(AuthSchemeTypes.OAUTH2),
|
|
615
681
|
val: Oauth2ConnectionDataSchema
|
|
616
682
|
}),
|
|
683
|
+
z$1.object({
|
|
684
|
+
authScheme: z$1.literal(AuthSchemeTypes.S2S_OAUTH2),
|
|
685
|
+
val: S2SOauth2ConnectionDataSchema
|
|
686
|
+
}),
|
|
617
687
|
z$1.object({
|
|
618
688
|
authScheme: z$1.literal(AuthSchemeTypes.API_KEY),
|
|
619
689
|
val: ApiKeyConnectionDataSchema
|
|
@@ -665,6 +735,11 @@ const CustomConnectionDataSchema = z$1.discriminatedUnion("authScheme", [
|
|
|
665
735
|
toolkitSlug: z$1.string(),
|
|
666
736
|
val: CustomOauth2ConnectionDataSchema
|
|
667
737
|
}),
|
|
738
|
+
z$1.object({
|
|
739
|
+
authScheme: z$1.literal(AuthSchemeTypes.S2S_OAUTH2),
|
|
740
|
+
toolkitSlug: z$1.string(),
|
|
741
|
+
val: CustomS2SOauth2ConnectionDataSchema
|
|
742
|
+
}),
|
|
668
743
|
z$1.object({
|
|
669
744
|
authScheme: z$1.literal(AuthSchemeTypes.DCR_OAUTH),
|
|
670
745
|
toolkitSlug: z$1.string(),
|
|
@@ -1365,6 +1440,39 @@ var ComposioWebhookPayloadError = class extends ComposioError {
|
|
|
1365
1440
|
}
|
|
1366
1441
|
};
|
|
1367
1442
|
|
|
1443
|
+
//#endregion
|
|
1444
|
+
//#region src/errors/RemoteFileErrors.ts
|
|
1445
|
+
const RemoteFileErrorCodes = { DOWNLOAD_FAILED: "REMOTE_FILE_DOWNLOAD_FAILED" };
|
|
1446
|
+
/**
|
|
1447
|
+
* Error thrown when fetching a remote file from a tool router session mount fails.
|
|
1448
|
+
* Includes HTTP status, URL, and file path context for debugging.
|
|
1449
|
+
*/
|
|
1450
|
+
var RemoteFileDownloadError = class extends ComposioError {
|
|
1451
|
+
constructor(message = "Failed to download remote file", options = {}) {
|
|
1452
|
+
const { statusCode, statusText, downloadUrl, mountRelativePath, filename, meta: optionsMeta, ...rest } = options;
|
|
1453
|
+
const meta = {
|
|
1454
|
+
...optionsMeta,
|
|
1455
|
+
...statusCode !== void 0 && { statusCode },
|
|
1456
|
+
...statusText && { statusText },
|
|
1457
|
+
...downloadUrl && { downloadUrl },
|
|
1458
|
+
...mountRelativePath && { mountRelativePath },
|
|
1459
|
+
...filename && { filename }
|
|
1460
|
+
};
|
|
1461
|
+
super(message, {
|
|
1462
|
+
...rest,
|
|
1463
|
+
code: RemoteFileErrorCodes.DOWNLOAD_FAILED,
|
|
1464
|
+
statusCode,
|
|
1465
|
+
meta: Object.keys(meta).length > 0 ? meta : void 0,
|
|
1466
|
+
possibleFixes: options.possibleFixes ?? [
|
|
1467
|
+
"Verify the download URL has not expired (check expiresAt)",
|
|
1468
|
+
"Ensure the file exists at the specified mount path",
|
|
1469
|
+
"Retry the operation; presigned URLs may have transient failures"
|
|
1470
|
+
]
|
|
1471
|
+
});
|
|
1472
|
+
this.name = "RemoteFileDownloadError";
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1368
1476
|
//#endregion
|
|
1369
1477
|
//#region src/types/connectedAccounts.types.ts
|
|
1370
1478
|
/**
|
|
@@ -1418,6 +1526,7 @@ const CreateConnectedAccountResponseSchema = z$1.object({
|
|
|
1418
1526
|
});
|
|
1419
1527
|
const ConnectedAccountAuthConfigSchema = z$1.object({
|
|
1420
1528
|
id: z$1.string(),
|
|
1529
|
+
authScheme: AuthSchemeEnum.optional(),
|
|
1421
1530
|
isComposioManaged: z$1.boolean(),
|
|
1422
1531
|
isDisabled: z$1.boolean()
|
|
1423
1532
|
});
|
|
@@ -1500,6 +1609,7 @@ function transformConnectedAccountResponse(response) {
|
|
|
1500
1609
|
authConfig: {
|
|
1501
1610
|
...response$1.auth_config,
|
|
1502
1611
|
id: response$1.auth_config.id,
|
|
1612
|
+
authScheme: response$1.auth_config.auth_scheme,
|
|
1503
1613
|
isComposioManaged: response$1.auth_config.is_composio_managed,
|
|
1504
1614
|
isDisabled: response$1.auth_config.is_disabled
|
|
1505
1615
|
},
|
|
@@ -3242,7 +3352,7 @@ var ConnectedAccounts = class {
|
|
|
3242
3352
|
const parsedOptions = ConnectedAccountRefreshOptionsSchema.safeParse(options);
|
|
3243
3353
|
if (!parsedOptions.success) throw new ValidationError("Failed to parse connected account refresh options", { cause: parsedOptions.error });
|
|
3244
3354
|
params = {
|
|
3245
|
-
|
|
3355
|
+
query_redirect_url: parsedOptions.data.redirectUrl,
|
|
3246
3356
|
validate_credentials: parsedOptions.data.validateCredentials
|
|
3247
3357
|
};
|
|
3248
3358
|
}
|
|
@@ -3673,11 +3783,19 @@ const WebhookPayloadV2Schema = z$1.object({
|
|
|
3673
3783
|
user_id: z$1.string()
|
|
3674
3784
|
}).passthrough()
|
|
3675
3785
|
});
|
|
3676
|
-
/** V3 webhook payload -
|
|
3786
|
+
/** V3 webhook payload - generic envelope for all composio.* events */
|
|
3677
3787
|
const WebhookPayloadV3Schema = z$1.object({
|
|
3678
3788
|
id: z$1.string(),
|
|
3679
3789
|
timestamp: z$1.string(),
|
|
3680
|
-
type: z$1.
|
|
3790
|
+
type: z$1.string().refine((val) => val.startsWith("composio."), { message: "V3 event type must start with 'composio.'" }),
|
|
3791
|
+
metadata: z$1.record(z$1.unknown()),
|
|
3792
|
+
data: z$1.record(z$1.unknown())
|
|
3793
|
+
});
|
|
3794
|
+
/** V3 trigger-specific payload - has trigger metadata fields */
|
|
3795
|
+
const WebhookTriggerPayloadV3Schema = z$1.object({
|
|
3796
|
+
id: z$1.string(),
|
|
3797
|
+
timestamp: z$1.string(),
|
|
3798
|
+
type: z$1.string(),
|
|
3681
3799
|
metadata: z$1.object({
|
|
3682
3800
|
log_id: z$1.string(),
|
|
3683
3801
|
trigger_slug: z$1.string(),
|
|
@@ -3685,7 +3803,7 @@ const WebhookPayloadV3Schema = z$1.object({
|
|
|
3685
3803
|
connected_account_id: z$1.string(),
|
|
3686
3804
|
auth_config_id: z$1.string(),
|
|
3687
3805
|
user_id: z$1.string()
|
|
3688
|
-
}),
|
|
3806
|
+
}).passthrough(),
|
|
3689
3807
|
data: z$1.record(z$1.unknown())
|
|
3690
3808
|
});
|
|
3691
3809
|
/** Union of all webhook payload versions */
|
|
@@ -4531,28 +4649,55 @@ var Triggers = class {
|
|
|
4531
4649
|
* @private
|
|
4532
4650
|
*/
|
|
4533
4651
|
normalizeV3Payload(payload) {
|
|
4534
|
-
const
|
|
4535
|
-
|
|
4652
|
+
const triggerResult = WebhookTriggerPayloadV3Schema.safeParse(payload);
|
|
4653
|
+
if (triggerResult.success) {
|
|
4654
|
+
const triggerSlug = triggerResult.data.metadata.trigger_slug;
|
|
4655
|
+
const toolkitSlug = triggerSlug.split("_")[0]?.toUpperCase() || "UNKNOWN";
|
|
4656
|
+
return {
|
|
4657
|
+
id: triggerResult.data.metadata.trigger_id,
|
|
4658
|
+
uuid: triggerResult.data.metadata.trigger_id,
|
|
4659
|
+
triggerSlug,
|
|
4660
|
+
toolkitSlug,
|
|
4661
|
+
userId: triggerResult.data.metadata.user_id,
|
|
4662
|
+
payload: payload.data,
|
|
4663
|
+
originalPayload: payload.data,
|
|
4664
|
+
metadata: {
|
|
4665
|
+
id: triggerResult.data.metadata.trigger_id,
|
|
4666
|
+
uuid: triggerResult.data.metadata.trigger_id,
|
|
4667
|
+
toolkitSlug,
|
|
4668
|
+
triggerSlug,
|
|
4669
|
+
triggerConfig: {},
|
|
4670
|
+
connectedAccount: {
|
|
4671
|
+
id: triggerResult.data.metadata.connected_account_id,
|
|
4672
|
+
uuid: triggerResult.data.metadata.connected_account_id,
|
|
4673
|
+
authConfigId: triggerResult.data.metadata.auth_config_id,
|
|
4674
|
+
authConfigUUID: triggerResult.data.metadata.auth_config_id,
|
|
4675
|
+
userId: triggerResult.data.metadata.user_id,
|
|
4676
|
+
status: "ACTIVE"
|
|
4677
|
+
}
|
|
4678
|
+
}
|
|
4679
|
+
};
|
|
4680
|
+
}
|
|
4536
4681
|
return {
|
|
4537
|
-
id: payload.
|
|
4538
|
-
uuid: payload.
|
|
4539
|
-
triggerSlug,
|
|
4540
|
-
toolkitSlug,
|
|
4541
|
-
userId:
|
|
4682
|
+
id: payload.id,
|
|
4683
|
+
uuid: payload.id,
|
|
4684
|
+
triggerSlug: payload.type,
|
|
4685
|
+
toolkitSlug: "COMPOSIO",
|
|
4686
|
+
userId: "",
|
|
4542
4687
|
payload: payload.data,
|
|
4543
|
-
originalPayload: payload
|
|
4688
|
+
originalPayload: payload,
|
|
4544
4689
|
metadata: {
|
|
4545
|
-
id: payload.
|
|
4546
|
-
uuid: payload.
|
|
4547
|
-
toolkitSlug,
|
|
4548
|
-
triggerSlug,
|
|
4690
|
+
id: payload.id,
|
|
4691
|
+
uuid: payload.id,
|
|
4692
|
+
toolkitSlug: "COMPOSIO",
|
|
4693
|
+
triggerSlug: payload.type,
|
|
4549
4694
|
triggerConfig: {},
|
|
4550
4695
|
connectedAccount: {
|
|
4551
|
-
id:
|
|
4552
|
-
uuid:
|
|
4553
|
-
authConfigId:
|
|
4554
|
-
authConfigUUID:
|
|
4555
|
-
userId:
|
|
4696
|
+
id: "",
|
|
4697
|
+
uuid: "",
|
|
4698
|
+
authConfigId: "",
|
|
4699
|
+
authConfigUUID: "",
|
|
4700
|
+
userId: "",
|
|
4556
4701
|
status: "ACTIVE"
|
|
4557
4702
|
}
|
|
4558
4703
|
}
|
|
@@ -5580,7 +5725,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5580
5725
|
|
|
5581
5726
|
//#endregion
|
|
5582
5727
|
//#region package.json
|
|
5583
|
-
var version = "0.6.
|
|
5728
|
+
var version = "0.6.5-alpha.0";
|
|
5584
5729
|
|
|
5585
5730
|
//#endregion
|
|
5586
5731
|
//#region src/utils/session.ts
|
|
@@ -5737,6 +5882,72 @@ const ToolRouterToolkitsOptionsSchema = z.object({
|
|
|
5737
5882
|
isConnected: z.boolean().optional(),
|
|
5738
5883
|
search: z.string().optional()
|
|
5739
5884
|
});
|
|
5885
|
+
const ToolRouterSessionSearchResultReferenceWorkbenchSnippetSchema = z.object({
|
|
5886
|
+
code: z.string(),
|
|
5887
|
+
description: z.string()
|
|
5888
|
+
});
|
|
5889
|
+
const ToolRouterSessionSearchResultSchema = z.object({
|
|
5890
|
+
index: z.number(),
|
|
5891
|
+
useCase: z.string(),
|
|
5892
|
+
primaryToolSlugs: z.array(z.string()),
|
|
5893
|
+
relatedToolSlugs: z.array(z.string()),
|
|
5894
|
+
toolkits: z.array(z.string()),
|
|
5895
|
+
difficulty: z.string().optional(),
|
|
5896
|
+
error: z.string().nullable().optional(),
|
|
5897
|
+
executionGuidance: z.string().optional(),
|
|
5898
|
+
knownPitfalls: z.array(z.string()).optional(),
|
|
5899
|
+
memory: z.record(z.string(), z.array(z.string())).optional(),
|
|
5900
|
+
planId: z.string().optional(),
|
|
5901
|
+
recommendedPlanSteps: z.array(z.string()).optional(),
|
|
5902
|
+
referenceWorkbenchSnippets: z.array(ToolRouterSessionSearchResultReferenceWorkbenchSnippetSchema).optional()
|
|
5903
|
+
});
|
|
5904
|
+
const ToolRouterSessionSearchSessionSchema = z.object({
|
|
5905
|
+
id: z.string(),
|
|
5906
|
+
generateId: z.boolean(),
|
|
5907
|
+
instructions: z.string()
|
|
5908
|
+
});
|
|
5909
|
+
const ToolRouterSessionSearchTimeInfoSchema = z.object({
|
|
5910
|
+
currentTimeUtc: z.string(),
|
|
5911
|
+
currentTimeUtcEpochSeconds: z.number(),
|
|
5912
|
+
message: z.string()
|
|
5913
|
+
});
|
|
5914
|
+
const ToolRouterSessionSearchToolSchemasSchemaRefSchema = z.object({
|
|
5915
|
+
args: z.object({ toolSlugs: z.array(z.string()) }),
|
|
5916
|
+
message: z.string(),
|
|
5917
|
+
tool: z.literal("COMPOSIO_GET_TOOL_SCHEMAS")
|
|
5918
|
+
});
|
|
5919
|
+
const ToolRouterSessionSearchToolSchemaSchema = z.object({
|
|
5920
|
+
toolSlug: z.string(),
|
|
5921
|
+
toolkit: z.string(),
|
|
5922
|
+
description: z.string().optional(),
|
|
5923
|
+
hasFullSchema: z.boolean().optional(),
|
|
5924
|
+
inputSchema: z.record(z.string(), z.unknown()).optional(),
|
|
5925
|
+
outputSchema: z.record(z.string(), z.unknown()).optional(),
|
|
5926
|
+
schemaRef: ToolRouterSessionSearchToolSchemasSchemaRefSchema.optional()
|
|
5927
|
+
});
|
|
5928
|
+
const ToolRouterSessionSearchToolkitConnectionStatusSchema = z.object({
|
|
5929
|
+
toolkit: z.string(),
|
|
5930
|
+
description: z.string(),
|
|
5931
|
+
hasActiveConnection: z.boolean(),
|
|
5932
|
+
statusMessage: z.string(),
|
|
5933
|
+
connectionDetails: z.record(z.string(), z.unknown()).optional(),
|
|
5934
|
+
currentUserInfo: z.record(z.string(), z.unknown()).optional()
|
|
5935
|
+
});
|
|
5936
|
+
const ToolRouterSessionSearchResponseSchema = z.object({
|
|
5937
|
+
success: z.boolean(),
|
|
5938
|
+
error: z.string().nullable(),
|
|
5939
|
+
results: z.array(ToolRouterSessionSearchResultSchema),
|
|
5940
|
+
toolSchemas: z.record(z.string(), ToolRouterSessionSearchToolSchemaSchema),
|
|
5941
|
+
toolkitConnectionStatuses: z.array(ToolRouterSessionSearchToolkitConnectionStatusSchema),
|
|
5942
|
+
nextStepsGuidance: z.array(z.string()),
|
|
5943
|
+
session: ToolRouterSessionSearchSessionSchema,
|
|
5944
|
+
timeInfo: ToolRouterSessionSearchTimeInfoSchema
|
|
5945
|
+
});
|
|
5946
|
+
const ToolRouterSessionExecuteResponseSchema = z.object({
|
|
5947
|
+
data: z.record(z.string(), z.unknown()),
|
|
5948
|
+
error: z.string().nullable(),
|
|
5949
|
+
logId: z.string()
|
|
5950
|
+
});
|
|
5740
5951
|
|
|
5741
5952
|
//#endregion
|
|
5742
5953
|
//#region src/lib/toolRouterParams.ts
|
|
@@ -5794,117 +6005,719 @@ const transformToolRouterToolkitsParams = (params) => {
|
|
|
5794
6005
|
};
|
|
5795
6006
|
|
|
5796
6007
|
//#endregion
|
|
5797
|
-
//#region src/
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
6008
|
+
//#region src/utils/transformers/toolRouterResponseTransform.ts
|
|
6009
|
+
function transformSearchResult(raw) {
|
|
6010
|
+
return {
|
|
6011
|
+
index: raw.index,
|
|
6012
|
+
useCase: raw.use_case,
|
|
6013
|
+
primaryToolSlugs: raw.primary_tool_slugs,
|
|
6014
|
+
relatedToolSlugs: raw.related_tool_slugs,
|
|
6015
|
+
toolkits: raw.toolkits,
|
|
6016
|
+
difficulty: raw.difficulty,
|
|
6017
|
+
error: raw.error,
|
|
6018
|
+
executionGuidance: raw.execution_guidance,
|
|
6019
|
+
knownPitfalls: raw.known_pitfalls,
|
|
6020
|
+
memory: raw.memory,
|
|
6021
|
+
planId: raw.plan_id,
|
|
6022
|
+
recommendedPlanSteps: raw.recommended_plan_steps,
|
|
6023
|
+
referenceWorkbenchSnippets: raw.reference_workbench_snippets
|
|
6024
|
+
};
|
|
6025
|
+
}
|
|
6026
|
+
function transformToolSchema(raw) {
|
|
6027
|
+
return {
|
|
6028
|
+
toolSlug: raw.tool_slug,
|
|
6029
|
+
toolkit: raw.toolkit,
|
|
6030
|
+
description: raw.description,
|
|
6031
|
+
hasFullSchema: raw.hasFullSchema,
|
|
6032
|
+
inputSchema: raw.input_schema,
|
|
6033
|
+
outputSchema: raw.output_schema,
|
|
6034
|
+
schemaRef: raw.schemaRef ? {
|
|
6035
|
+
args: { toolSlugs: raw.schemaRef.args.tool_slugs },
|
|
6036
|
+
message: raw.schemaRef.message,
|
|
6037
|
+
tool: raw.schemaRef.tool
|
|
6038
|
+
} : void 0
|
|
6039
|
+
};
|
|
6040
|
+
}
|
|
6041
|
+
function transformToolkitConnectionStatus(raw) {
|
|
6042
|
+
return {
|
|
6043
|
+
toolkit: raw.toolkit,
|
|
6044
|
+
description: raw.description,
|
|
6045
|
+
hasActiveConnection: raw.has_active_connection,
|
|
6046
|
+
statusMessage: raw.status_message,
|
|
6047
|
+
connectionDetails: raw.connection_details,
|
|
6048
|
+
currentUserInfo: raw.current_user_info
|
|
6049
|
+
};
|
|
6050
|
+
}
|
|
6051
|
+
/**
|
|
6052
|
+
* Transforms a raw session search API response to camelCase.
|
|
6053
|
+
*/
|
|
6054
|
+
function transformSearchResponse(raw) {
|
|
6055
|
+
const toolSchemas = {};
|
|
6056
|
+
for (const [slug, schema] of Object.entries(raw.tool_schemas)) toolSchemas[slug] = transformToolSchema(schema);
|
|
6057
|
+
return {
|
|
6058
|
+
success: raw.success,
|
|
6059
|
+
error: raw.error,
|
|
6060
|
+
results: raw.results.map(transformSearchResult),
|
|
6061
|
+
toolSchemas,
|
|
6062
|
+
toolkitConnectionStatuses: raw.toolkit_connection_statuses.map(transformToolkitConnectionStatus),
|
|
6063
|
+
nextStepsGuidance: raw.next_steps_guidance,
|
|
6064
|
+
session: {
|
|
6065
|
+
id: raw.session.id,
|
|
6066
|
+
generateId: raw.session.generate_id,
|
|
6067
|
+
instructions: raw.session.instructions
|
|
6068
|
+
},
|
|
6069
|
+
timeInfo: {
|
|
6070
|
+
currentTimeUtc: raw.time_info.current_time_utc,
|
|
6071
|
+
currentTimeUtcEpochSeconds: raw.time_info.current_time_utc_epoch_seconds,
|
|
6072
|
+
message: raw.time_info.message
|
|
6073
|
+
}
|
|
6074
|
+
};
|
|
6075
|
+
}
|
|
6076
|
+
/**
|
|
6077
|
+
* Transforms a raw session execute API response to camelCase.
|
|
6078
|
+
*/
|
|
6079
|
+
function transformExecuteResponse(raw) {
|
|
6080
|
+
return {
|
|
6081
|
+
data: raw.data,
|
|
6082
|
+
error: raw.error,
|
|
6083
|
+
logId: raw.log_id
|
|
6084
|
+
};
|
|
6085
|
+
}
|
|
6086
|
+
|
|
6087
|
+
//#endregion
|
|
6088
|
+
//#region src/types/ToolRouterSessionFilesMount.types.ts
|
|
6089
|
+
const ToolRouterSessionFilesMountListOptionsSchema = z.object({
|
|
6090
|
+
path: z.string().optional(),
|
|
6091
|
+
mountId: z.string().default(DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID),
|
|
6092
|
+
cursor: z.string().optional(),
|
|
6093
|
+
limit: z.number().min(1).max(500).optional()
|
|
6094
|
+
});
|
|
6095
|
+
const FileListItemSchema = z.object({
|
|
6096
|
+
last_modified: z.string(),
|
|
6097
|
+
mount_relative_path: z.string(),
|
|
6098
|
+
sandbox_mount_prefix: z.string(),
|
|
6099
|
+
size: z.number()
|
|
6100
|
+
});
|
|
6101
|
+
const FileListResponseSchema = z.object({
|
|
6102
|
+
items: z.array(FileListItemSchema),
|
|
6103
|
+
next_cursor: z.string().optional()
|
|
6104
|
+
}).transform((data) => ({
|
|
6105
|
+
items: data.items.map((item) => ({
|
|
6106
|
+
lastModified: item.last_modified,
|
|
6107
|
+
mountRelativePath: item.mount_relative_path,
|
|
6108
|
+
sandboxMountPrefix: item.sandbox_mount_prefix,
|
|
6109
|
+
size: item.size
|
|
6110
|
+
})),
|
|
6111
|
+
nextCursor: data.next_cursor
|
|
6112
|
+
}));
|
|
6113
|
+
const ToolRouterSessionFilesMountUploadOptionsSchema = z.object({
|
|
6114
|
+
remotePath: z.string().optional(),
|
|
6115
|
+
mountId: z.string().default(DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID),
|
|
6116
|
+
mimetype: z.string().optional()
|
|
6117
|
+
});
|
|
6118
|
+
const ToolRouterSessionFilesMountDownloadOptionsSchema = z.object({ mountId: z.string().default(DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID) });
|
|
6119
|
+
const ToolRouterSessionFilesMountDeleteOptionsSchema = z.object({ mountId: z.string().default(DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID) });
|
|
6120
|
+
const RemoteFileDataSchema = z.object({
|
|
6121
|
+
expires_at: z.string(),
|
|
6122
|
+
mount_relative_path: z.string(),
|
|
6123
|
+
sandbox_mount_prefix: z.string(),
|
|
6124
|
+
download_url: z.string()
|
|
6125
|
+
}).transform((data) => ({
|
|
6126
|
+
expiresAt: data.expires_at,
|
|
6127
|
+
mountRelativePath: data.mount_relative_path,
|
|
6128
|
+
sandboxMountPrefix: data.sandbox_mount_prefix,
|
|
6129
|
+
downloadUrl: data.download_url
|
|
6130
|
+
}));
|
|
6131
|
+
const FileDeleteResponseSchema = z.object({
|
|
6132
|
+
mount_relative_path: z.string(),
|
|
6133
|
+
sandbox_mount_prefix: z.string()
|
|
6134
|
+
}).transform((data) => ({
|
|
6135
|
+
mountRelativePath: data.mount_relative_path,
|
|
6136
|
+
sandboxMountPrefix: data.sandbox_mount_prefix
|
|
6137
|
+
}));
|
|
6138
|
+
|
|
6139
|
+
//#endregion
|
|
6140
|
+
//#region src/models/RemoteFile.ts
|
|
6141
|
+
function getParentDir(filePath) {
|
|
6142
|
+
const lastSep = Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"));
|
|
6143
|
+
if (lastSep <= 0) return "";
|
|
6144
|
+
return filePath.slice(0, lastSep);
|
|
6145
|
+
}
|
|
6146
|
+
/**
|
|
6147
|
+
* Represents a file stored in a tool router session's file mount.
|
|
6148
|
+
* Provides methods to fetch, save, and work with the file content.
|
|
6149
|
+
*
|
|
6150
|
+
* @example
|
|
6151
|
+
* ```typescript
|
|
6152
|
+
* const remoteFile = await session.files.download('/output/report.pdf');
|
|
6153
|
+
* const buffer = await remoteFile.buffer();
|
|
6154
|
+
* await remoteFile.save('/tmp/report.pdf');
|
|
6155
|
+
* const text = await remoteFile.text();
|
|
6156
|
+
* ```
|
|
6157
|
+
*
|
|
6158
|
+
* @example
|
|
6159
|
+
* ```typescript
|
|
6160
|
+
* // Create from API response (snake_case)
|
|
6161
|
+
* const remoteFile = RemoteFile.parse(apiResponse);
|
|
6162
|
+
*
|
|
6163
|
+
* // Or create from parsed data (camelCase)
|
|
6164
|
+
* const remoteFile = new RemoteFile({
|
|
6165
|
+
* expiresAt: '...',
|
|
6166
|
+
* mountRelativePath: 'report.pdf',
|
|
6167
|
+
* sandboxMountPrefix: '/mnt/files',
|
|
6168
|
+
* downloadUrl: 'https://...',
|
|
6169
|
+
* });
|
|
6170
|
+
* ```
|
|
6171
|
+
*/
|
|
6172
|
+
var RemoteFile = class RemoteFile {
|
|
6173
|
+
/** ISO 8601 timestamp when the download URL expires */
|
|
6174
|
+
expiresAt;
|
|
6175
|
+
/** Relative path within the mount (e.g. "report.pdf") */
|
|
6176
|
+
mountRelativePath;
|
|
6177
|
+
/** Absolute mount path inside the sandbox (e.g. /mnt/files) */
|
|
6178
|
+
sandboxMountPrefix;
|
|
6179
|
+
/** Presigned URL for downloading the file */
|
|
6180
|
+
downloadUrl;
|
|
6181
|
+
constructor(data) {
|
|
6182
|
+
this.expiresAt = data.expiresAt;
|
|
6183
|
+
this.mountRelativePath = data.mountRelativePath;
|
|
6184
|
+
this.sandboxMountPrefix = data.sandboxMountPrefix;
|
|
6185
|
+
this.downloadUrl = data.downloadUrl;
|
|
6186
|
+
}
|
|
6187
|
+
/**
|
|
6188
|
+
* Parses an API response (snake_case) and returns a RemoteFile instance.
|
|
6189
|
+
* @param data - Raw API response with snake_case keys
|
|
6190
|
+
* @returns A RemoteFile instance
|
|
6191
|
+
* @throws ValidationError if the response shape is invalid
|
|
6192
|
+
*/
|
|
6193
|
+
static parse(data) {
|
|
6194
|
+
const parsed = RemoteFileDataSchema.safeParse(data);
|
|
6195
|
+
if (!parsed.success) throw new ValidationError("Failed to parse remote file response", { cause: parsed.error });
|
|
6196
|
+
return new RemoteFile(parsed.data);
|
|
6197
|
+
}
|
|
6198
|
+
/** Filename extracted from the mount path (e.g. "report.pdf" from "output/report.pdf") */
|
|
6199
|
+
get filename() {
|
|
6200
|
+
return platform.basename(this.mountRelativePath);
|
|
6201
|
+
}
|
|
6202
|
+
/**
|
|
6203
|
+
* Fetches the file content as a buffer.
|
|
6204
|
+
* @returns The file content as a Uint8Array
|
|
6205
|
+
* @throws RemoteFileDownloadError if the fetch fails
|
|
6206
|
+
*/
|
|
6207
|
+
async buffer() {
|
|
6208
|
+
const response = await fetch(this.downloadUrl);
|
|
6209
|
+
if (!response.ok) throw new RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
|
|
6210
|
+
statusCode: response.status,
|
|
6211
|
+
statusText: response.statusText,
|
|
6212
|
+
downloadUrl: this.downloadUrl,
|
|
6213
|
+
mountRelativePath: this.mountRelativePath,
|
|
6214
|
+
filename: this.filename,
|
|
6215
|
+
cause: /* @__PURE__ */ new Error(`HTTP ${response.status}: ${response.statusText}`)
|
|
6216
|
+
});
|
|
6217
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
6218
|
+
return new Uint8Array(arrayBuffer);
|
|
6219
|
+
}
|
|
6220
|
+
/**
|
|
6221
|
+
* Fetches the file content as UTF-8 text.
|
|
6222
|
+
* @returns The file content as a string
|
|
6223
|
+
* @throws Error if the fetch fails
|
|
6224
|
+
*/
|
|
6225
|
+
async text() {
|
|
6226
|
+
const buf = await this.buffer();
|
|
6227
|
+
return new TextDecoder().decode(buf);
|
|
5803
6228
|
}
|
|
5804
6229
|
/**
|
|
5805
|
-
*
|
|
5806
|
-
* @
|
|
5807
|
-
* @
|
|
6230
|
+
* Fetches the file content as a Blob.
|
|
6231
|
+
* @returns The file content as a Blob
|
|
6232
|
+
* @throws RemoteFileDownloadError if the fetch fails
|
|
6233
|
+
*/
|
|
6234
|
+
async blob() {
|
|
6235
|
+
const response = await fetch(this.downloadUrl);
|
|
6236
|
+
if (!response.ok) throw new RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
|
|
6237
|
+
statusCode: response.status,
|
|
6238
|
+
statusText: response.statusText,
|
|
6239
|
+
downloadUrl: this.downloadUrl,
|
|
6240
|
+
mountRelativePath: this.mountRelativePath,
|
|
6241
|
+
filename: this.filename,
|
|
6242
|
+
cause: /* @__PURE__ */ new Error(`HTTP ${response.status}: ${response.statusText}`)
|
|
6243
|
+
});
|
|
6244
|
+
return response.blob();
|
|
6245
|
+
}
|
|
6246
|
+
/**
|
|
6247
|
+
* Downloads and saves the file to the local filesystem.
|
|
6248
|
+
* Requires a Node.js runtime with file system support (not available in Cloudflare Workers/Edge).
|
|
5808
6249
|
*
|
|
6250
|
+
* @param path - Local path to save the file. If omitted, saves to the Composio temp directory using the filename from the mount path.
|
|
6251
|
+
* @returns The absolute path where the file was saved
|
|
6252
|
+
* @throws Error if file system is not supported or the save fails
|
|
5809
6253
|
*/
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
6254
|
+
async save(path) {
|
|
6255
|
+
if (!platform.supportsFileSystem) throw new Error("File system operations are not supported in this runtime (e.g. Cloudflare Workers). Use buffer(), text(), or blob() to work with the file content in memory, or run in Node.js.");
|
|
6256
|
+
const content = await this.buffer();
|
|
6257
|
+
const homeDir = platform.homedir();
|
|
6258
|
+
if (!homeDir) throw new Error("Cannot determine save location: home directory is not available");
|
|
6259
|
+
const savePath = path ?? platform.joinPath(homeDir, COMPOSIO_DIR, TEMP_FILES_DIRECTORY_NAME, this.filename);
|
|
6260
|
+
const dir = path != null ? getParentDir(savePath) : platform.joinPath(homeDir, COMPOSIO_DIR, TEMP_FILES_DIRECTORY_NAME);
|
|
6261
|
+
if (dir && !platform.existsSync(dir)) platform.mkdirSync(dir);
|
|
6262
|
+
platform.writeFileSync(savePath, content);
|
|
6263
|
+
return savePath;
|
|
6264
|
+
}
|
|
6265
|
+
};
|
|
6266
|
+
|
|
6267
|
+
//#endregion
|
|
6268
|
+
//#region src/utils/mime.ts
|
|
6269
|
+
/**
|
|
6270
|
+
* Maps MIME types to file extensions.
|
|
6271
|
+
* Used when deriving filenames from content-type headers (e.g. for URLs without path segments).
|
|
6272
|
+
*/
|
|
6273
|
+
function getExtensionFromMimeType(mimeType) {
|
|
6274
|
+
const mimeToExt = {
|
|
6275
|
+
"text/plain": "txt",
|
|
6276
|
+
"text/html": "html",
|
|
6277
|
+
"text/css": "css",
|
|
6278
|
+
"text/javascript": "js",
|
|
6279
|
+
"application/json": "json",
|
|
6280
|
+
"application/xml": "xml",
|
|
6281
|
+
"application/pdf": "pdf",
|
|
6282
|
+
"application/zip": "zip",
|
|
6283
|
+
"application/x-zip-compressed": "zip",
|
|
6284
|
+
"application/gzip": "gz",
|
|
6285
|
+
"application/octet-stream": "bin",
|
|
6286
|
+
"application/x-tar": "tar",
|
|
6287
|
+
"application/msword": "doc",
|
|
6288
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
6289
|
+
"application/vnd.ms-excel": "xls",
|
|
6290
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
6291
|
+
"application/vnd.ms-powerpoint": "ppt",
|
|
6292
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
|
|
6293
|
+
"image/jpeg": "jpg",
|
|
6294
|
+
"image/jpg": "jpg",
|
|
6295
|
+
"image/png": "png",
|
|
6296
|
+
"image/gif": "gif",
|
|
6297
|
+
"image/svg+xml": "svg",
|
|
6298
|
+
"image/webp": "webp",
|
|
6299
|
+
"image/bmp": "bmp",
|
|
6300
|
+
"image/tiff": "tiff",
|
|
6301
|
+
"audio/mpeg": "mp3",
|
|
6302
|
+
"audio/wav": "wav",
|
|
6303
|
+
"audio/ogg": "ogg",
|
|
6304
|
+
"video/mp4": "mp4",
|
|
6305
|
+
"video/mpeg": "mpeg",
|
|
6306
|
+
"video/quicktime": "mov",
|
|
6307
|
+
"video/x-msvideo": "avi",
|
|
6308
|
+
"video/webm": "webm"
|
|
5819
6309
|
};
|
|
6310
|
+
const cleanMimeType = mimeType.split(";")[0].toLowerCase().trim();
|
|
6311
|
+
if (mimeToExt[cleanMimeType]) return mimeToExt[cleanMimeType];
|
|
6312
|
+
const parts = cleanMimeType.split("/");
|
|
6313
|
+
if (parts.length === 2) {
|
|
6314
|
+
const subtype = parts[1].toLowerCase();
|
|
6315
|
+
if (subtype.includes("+")) {
|
|
6316
|
+
const plusParts = subtype.split("+");
|
|
6317
|
+
const prefix = plusParts[0];
|
|
6318
|
+
const suffix = plusParts[plusParts.length - 1];
|
|
6319
|
+
if ([
|
|
6320
|
+
"svg",
|
|
6321
|
+
"atom",
|
|
6322
|
+
"rss"
|
|
6323
|
+
].includes(prefix)) return prefix;
|
|
6324
|
+
if ([
|
|
6325
|
+
"json",
|
|
6326
|
+
"xml",
|
|
6327
|
+
"yaml",
|
|
6328
|
+
"zip",
|
|
6329
|
+
"gzip"
|
|
6330
|
+
].includes(suffix)) return suffix;
|
|
6331
|
+
return suffix;
|
|
6332
|
+
}
|
|
6333
|
+
return subtype || "txt";
|
|
6334
|
+
}
|
|
6335
|
+
return "bin";
|
|
6336
|
+
}
|
|
6337
|
+
|
|
6338
|
+
//#endregion
|
|
6339
|
+
//#region src/models/ToolRouterSessionFileMount.ts
|
|
6340
|
+
var ToolRouterSessionFilesMount = class {
|
|
6341
|
+
sessionId;
|
|
6342
|
+
client;
|
|
6343
|
+
constructor(client, sessionId) {
|
|
6344
|
+
this.client = client;
|
|
6345
|
+
this.sessionId = sessionId;
|
|
6346
|
+
telemetry.instrument(this, "ToolRouterSessionFiles");
|
|
6347
|
+
}
|
|
5820
6348
|
/**
|
|
6349
|
+
* Lists files and directories at the specified path on the session's file mount.
|
|
6350
|
+
*
|
|
6351
|
+
* Use this to browse the virtual filesystem attached to the tool router session.
|
|
6352
|
+
* The path is relative to the mount root (e.g., `"/"` for root, `"/documents"` for a subdirectory).
|
|
6353
|
+
* Supports cursor-based pagination via `cursor` and `limit` options.
|
|
5821
6354
|
*
|
|
5822
|
-
* @param
|
|
5823
|
-
* @
|
|
6355
|
+
* @param options - Optional configuration for the list operation.
|
|
6356
|
+
* @param options.path - The directory path to list. Use `"/"` for the mount root.
|
|
6357
|
+
* @param options.mountId - The ID of the file mount to operate on. Defaults to `"files"` when omitted.
|
|
6358
|
+
* @param options.cursor - Pagination cursor from the previous response's nextCursor field.
|
|
6359
|
+
* @param options.limit - Maximum number of files to return per page (1-500).
|
|
6360
|
+
* @returns List of files with nextCursor for pagination.
|
|
5824
6361
|
*
|
|
5825
6362
|
* @example
|
|
5826
6363
|
* ```typescript
|
|
5827
|
-
* import { Composio } from '@composio/core';
|
|
5828
|
-
*
|
|
5829
|
-
* const composio = new Composio();
|
|
5830
6364
|
* const session = await composio.toolRouter.use('session_123');
|
|
6365
|
+
* const { items, nextCursor } = await session.files.list({ path: '/' });
|
|
6366
|
+
* ```
|
|
5831
6367
|
*
|
|
5832
|
-
*
|
|
5833
|
-
*
|
|
6368
|
+
* @example
|
|
6369
|
+
* ```typescript
|
|
6370
|
+
* // Paginated listing
|
|
6371
|
+
* let result = await session.files.list({ path: '/', limit: 10 });
|
|
6372
|
+
* while (result.nextCursor) {
|
|
6373
|
+
* result = await session.files.list({ path: '/', cursor: result.nextCursor, limit: 10 });
|
|
6374
|
+
* }
|
|
5834
6375
|
* ```
|
|
5835
6376
|
*/
|
|
5836
|
-
|
|
5837
|
-
const
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
6377
|
+
async list(options) {
|
|
6378
|
+
const listOptions = ToolRouterSessionFilesMountListOptionsSchema.safeParse(options ?? {});
|
|
6379
|
+
if (!listOptions.success) throw new ValidationError("Failed to parse tool router session files mount list options", { cause: listOptions.error });
|
|
6380
|
+
const rawPath = listOptions.data.path;
|
|
6381
|
+
const mountRelativePrefix = rawPath === void 0 || rawPath === "" || rawPath === "/" ? void 0 : rawPath.startsWith("/") ? rawPath.slice(1) : rawPath;
|
|
6382
|
+
const response = await this.client.toolRouter.session.files.list(listOptions.data.mountId, {
|
|
6383
|
+
session_id: this.sessionId,
|
|
6384
|
+
mount_relative_prefix: mountRelativePrefix,
|
|
6385
|
+
cursor: listOptions.data.cursor,
|
|
6386
|
+
limit: listOptions.data.limit
|
|
6387
|
+
});
|
|
6388
|
+
const data = typeof response === "object" && "body" in response ? response.body : response;
|
|
6389
|
+
const parsed = FileListResponseSchema.safeParse(data);
|
|
6390
|
+
if (!parsed.success) throw new ValidationError("Failed to parse file list response", { cause: parsed.error });
|
|
6391
|
+
return parsed.data;
|
|
6392
|
+
}
|
|
6393
|
+
async normalizeUploadInput(input, options) {
|
|
6394
|
+
if (typeof input === "string") {
|
|
6395
|
+
if (input.startsWith("http://") || input.startsWith("https://")) {
|
|
6396
|
+
const response = await fetch(input);
|
|
6397
|
+
if (!response.ok) throw new Error(`Failed to fetch file from URL: ${response.statusText}`);
|
|
6398
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
6399
|
+
const mimeType = (response.headers.get("content-type") || "application/octet-stream").split(";")[0].trim();
|
|
6400
|
+
const segments = new URL(input).pathname.split("/").filter(Boolean);
|
|
6401
|
+
let filename$1 = segments.length > 0 ? segments[segments.length - 1] : "";
|
|
6402
|
+
if (!filename$1 || !filename$1.includes(".")) {
|
|
6403
|
+
const extension = getExtensionFromMimeType(mimeType);
|
|
6404
|
+
filename$1 = `${getRandomShortId()}.${extension}`;
|
|
6405
|
+
}
|
|
6406
|
+
return {
|
|
6407
|
+
fileToUpload: new File([arrayBuffer], filename$1, { type: mimeType }),
|
|
6408
|
+
remotePath: options.remotePath ?? filename$1,
|
|
6409
|
+
mimetype: mimeType
|
|
6410
|
+
};
|
|
6411
|
+
}
|
|
6412
|
+
const content = platform.readFileSync(input);
|
|
6413
|
+
const buffer$1 = content instanceof Uint8Array ? new Uint8Array(content) : new TextEncoder().encode(content);
|
|
6414
|
+
const filename = platform.basename(input);
|
|
6415
|
+
const mimetype$1 = options.mimetype ?? "application/octet-stream";
|
|
5847
6416
|
return {
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
name: item$1.name,
|
|
5852
|
-
logo: item$1.meta?.logo,
|
|
5853
|
-
isNoAuth: item$1.is_no_auth,
|
|
5854
|
-
connection: item$1.is_no_auth ? void 0 : {
|
|
5855
|
-
isActive: item$1.connected_account?.status === "ACTIVE",
|
|
5856
|
-
authConfig: item$1.connected_account && {
|
|
5857
|
-
id: item$1.connected_account?.auth_config.id,
|
|
5858
|
-
mode: item$1.connected_account?.auth_config.auth_scheme,
|
|
5859
|
-
isComposioManaged: item$1.connected_account?.auth_config.is_composio_managed
|
|
5860
|
-
},
|
|
5861
|
-
connectedAccount: item$1.connected_account ? {
|
|
5862
|
-
id: item$1.connected_account.id,
|
|
5863
|
-
status: item$1.connected_account.status
|
|
5864
|
-
} : void 0
|
|
5865
|
-
}
|
|
5866
|
-
}));
|
|
5867
|
-
}),
|
|
5868
|
-
nextCursor: result.next_cursor,
|
|
5869
|
-
totalPages: result.total_pages
|
|
6417
|
+
fileToUpload: new File([buffer$1], filename, { type: mimetype$1 }),
|
|
6418
|
+
remotePath: options.remotePath ?? filename,
|
|
6419
|
+
mimetype: mimetype$1
|
|
5870
6420
|
};
|
|
6421
|
+
}
|
|
6422
|
+
if (input instanceof File) return {
|
|
6423
|
+
fileToUpload: input,
|
|
6424
|
+
remotePath: options.remotePath ?? (input.name || `upload-${getRandomShortId()}.bin`),
|
|
6425
|
+
mimetype: input.type || "application/octet-stream"
|
|
5871
6426
|
};
|
|
5872
|
-
|
|
5873
|
-
|
|
6427
|
+
const buffer = input instanceof ArrayBuffer ? new Uint8Array(input) : input;
|
|
6428
|
+
if (!options.mimetype && !options.remotePath) throw new Error("When passing a buffer, either mimetype or remotePath (filename) is required. Example: files.upload(buffer, { remotePath: \"data.json\", mimetype: \"application/json\" })");
|
|
6429
|
+
const mimetype = options.mimetype ?? "application/octet-stream";
|
|
6430
|
+
const ext = getExtensionFromMimeType(mimetype);
|
|
6431
|
+
const remotePath = options.remotePath ?? `upload-${getRandomShortId()}.${ext}`;
|
|
6432
|
+
return {
|
|
6433
|
+
fileToUpload: new File([buffer], remotePath, { type: mimetype }),
|
|
6434
|
+
remotePath,
|
|
6435
|
+
mimetype
|
|
6436
|
+
};
|
|
6437
|
+
}
|
|
5874
6438
|
/**
|
|
5875
|
-
*
|
|
5876
|
-
*
|
|
5877
|
-
*
|
|
6439
|
+
* Uploads a file to the session's file mount.
|
|
6440
|
+
*
|
|
6441
|
+
* Accepts a file path (local or URL), a native File object, or a raw buffer.
|
|
6442
|
+
* The file is stored in the virtual filesystem associated with the tool router session.
|
|
6443
|
+
*
|
|
6444
|
+
* @param input - File path (string), native File, or raw buffer (ArrayBuffer | Uint8Array).
|
|
6445
|
+
* @param options - Optional configuration. When passing a buffer, remotePath is required.
|
|
6446
|
+
* @returns Metadata about the uploaded file.
|
|
6447
|
+
*
|
|
6448
|
+
* @example
|
|
6449
|
+
* ```typescript
|
|
6450
|
+
* // From file path (local or URL)
|
|
6451
|
+
* await session.files.upload('/path/to/report.pdf');
|
|
6452
|
+
* await session.files.upload('https://example.com/file.pdf');
|
|
6453
|
+
* ```
|
|
6454
|
+
*
|
|
6455
|
+
* @example
|
|
6456
|
+
* ```typescript
|
|
6457
|
+
* // From native File (e.g. from input[type=file])
|
|
6458
|
+
* await session.files.upload(fileInput.files[0]);
|
|
6459
|
+
* ```
|
|
5878
6460
|
*
|
|
5879
|
-
* @
|
|
5880
|
-
*
|
|
6461
|
+
* @example
|
|
6462
|
+
* ```typescript
|
|
6463
|
+
* // From raw buffer
|
|
6464
|
+
* await session.files.upload(buffer, { remotePath: 'data.json', mimetype: 'application/json' });
|
|
6465
|
+
* ```
|
|
5881
6466
|
*/
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
6467
|
+
async upload(input, options) {
|
|
6468
|
+
const uploadOptions = ToolRouterSessionFilesMountUploadOptionsSchema.safeParse(options ?? {});
|
|
6469
|
+
if (!uploadOptions.success) throw new ValidationError("Failed to parse tool router session files mount upload options", { cause: uploadOptions.error });
|
|
6470
|
+
const { fileToUpload, remotePath, mimetype } = await this.normalizeUploadInput(input, uploadOptions.data);
|
|
6471
|
+
const createUploadURLResponse = await this.client.toolRouter.session.files.createUploadURL(uploadOptions.data.mountId, {
|
|
6472
|
+
session_id: this.sessionId,
|
|
6473
|
+
mount_relative_path: remotePath,
|
|
6474
|
+
mimetype
|
|
6475
|
+
});
|
|
6476
|
+
const uploadURLData = typeof createUploadURLResponse === "object" && "body" in createUploadURLResponse ? createUploadURLResponse.body : createUploadURLResponse;
|
|
6477
|
+
const uploadResponse = await fetch(uploadURLData.upload_url, {
|
|
6478
|
+
method: "PUT",
|
|
6479
|
+
body: await fileToUpload.arrayBuffer(),
|
|
6480
|
+
headers: { "Content-Type": mimetype }
|
|
6481
|
+
});
|
|
6482
|
+
if (!uploadResponse.ok) throw new Error(`Failed to upload file: ${uploadResponse.statusText}`);
|
|
6483
|
+
const createDownloadURLResponse = await this.client.toolRouter.session.files.createDownloadURL(uploadOptions.data.mountId, {
|
|
6484
|
+
session_id: this.sessionId,
|
|
6485
|
+
mount_relative_path: uploadURLData.mount_relative_path
|
|
6486
|
+
});
|
|
6487
|
+
const downloadData = typeof createDownloadURLResponse === "object" && "body" in createDownloadURLResponse ? createDownloadURLResponse.body : createDownloadURLResponse;
|
|
6488
|
+
const parsed = RemoteFileDataSchema.safeParse(downloadData);
|
|
6489
|
+
if (!parsed.success) throw new ValidationError("Failed to parse remote file properties", { cause: parsed.error });
|
|
6490
|
+
return new RemoteFile(parsed.data);
|
|
6491
|
+
}
|
|
6492
|
+
/**
|
|
6493
|
+
* Downloads a file from the session's file mount to the local filesystem.
|
|
6494
|
+
*
|
|
6495
|
+
* Retrieves a file stored in the session's virtual filesystem (e.g., one produced
|
|
6496
|
+
* by a tool or previously uploaded) and saves it to the specified local path.
|
|
6497
|
+
*
|
|
6498
|
+
* @param filePath - The path of the file on the mount to download, or the local path where the file should be saved (implementation-specific).
|
|
6499
|
+
* @param options - Optional configuration for the download.
|
|
6500
|
+
* @param options.mountId - The ID of the file mount to download from. Defaults to `"files"` when omitted.
|
|
6501
|
+
* @returns The downloaded file data or path (implementation-specific).
|
|
6502
|
+
*
|
|
6503
|
+
* @example
|
|
6504
|
+
* ```typescript
|
|
6505
|
+
* const session = await composio.toolRouter.use('session_123');
|
|
6506
|
+
* const result = await session.files.download('/output/report.pdf');
|
|
6507
|
+
* ```
|
|
6508
|
+
*
|
|
6509
|
+
* @example
|
|
6510
|
+
* ```typescript
|
|
6511
|
+
* // Download from a custom mount
|
|
6512
|
+
* await session.files.download('/exports/data.json', {
|
|
6513
|
+
* mountId: 'custom-mount',
|
|
6514
|
+
* });
|
|
6515
|
+
* ```
|
|
6516
|
+
*/
|
|
6517
|
+
async download(filePath, options) {
|
|
6518
|
+
const downloadOptions = ToolRouterSessionFilesMountDownloadOptionsSchema.safeParse(options ?? {});
|
|
6519
|
+
if (!downloadOptions.success) throw new ValidationError("Failed to parse tool router session files mount download options", { cause: downloadOptions.error });
|
|
6520
|
+
const createDownloadURLResponse = await this.client.toolRouter.session.files.createDownloadURL(downloadOptions.data.mountId, {
|
|
6521
|
+
session_id: this.sessionId,
|
|
6522
|
+
mount_relative_path: filePath
|
|
6523
|
+
});
|
|
6524
|
+
const downloadURLData = typeof createDownloadURLResponse === "object" && "body" in createDownloadURLResponse ? createDownloadURLResponse.body : createDownloadURLResponse;
|
|
6525
|
+
const parsed = RemoteFileDataSchema.safeParse(downloadURLData);
|
|
6526
|
+
if (!parsed.success) throw new ValidationError("Failed to parse remote file properties", { cause: parsed.error });
|
|
6527
|
+
return new RemoteFile(parsed.data);
|
|
6528
|
+
}
|
|
6529
|
+
/**
|
|
6530
|
+
* Deletes a file or directory at the specified path on the session's file mount.
|
|
6531
|
+
*
|
|
6532
|
+
* Removes the file or directory from the virtual filesystem. Use with caution:
|
|
6533
|
+
* deletion is typically irreversible. Ensure the path exists and is intended for removal.
|
|
6534
|
+
*
|
|
6535
|
+
* @param remotePath - The path of the file or directory to delete on the mount.
|
|
6536
|
+
* @param options - Optional configuration for the delete operation.
|
|
6537
|
+
* @param options.mountId - The ID of the file mount to operate on. Defaults to `"files"` when omitted.
|
|
6538
|
+
* @returns Confirmation of deletion (implementation-specific).
|
|
6539
|
+
*
|
|
6540
|
+
* @example
|
|
6541
|
+
* ```typescript
|
|
6542
|
+
* const session = await composio.toolRouter.use('session_123');
|
|
6543
|
+
* await session.files.delete('/temp/cache.json');
|
|
6544
|
+
* ```
|
|
6545
|
+
*
|
|
6546
|
+
* @example
|
|
6547
|
+
* ```typescript
|
|
6548
|
+
* // Delete from a custom mount
|
|
6549
|
+
* await session.files.delete('/old-backup', {
|
|
6550
|
+
* mountId: 'custom-mount',
|
|
6551
|
+
* });
|
|
6552
|
+
* ```
|
|
6553
|
+
*
|
|
6554
|
+
* @warning This operation is destructive. Deleted files cannot be recovered.
|
|
6555
|
+
*/
|
|
6556
|
+
async delete(remotePath, options) {
|
|
6557
|
+
const deleteOptions = ToolRouterSessionFilesMountDeleteOptionsSchema.safeParse(options ?? {});
|
|
6558
|
+
if (!deleteOptions.success) throw new ValidationError("Failed to parse tool router session files mount delete options", { cause: deleteOptions.error });
|
|
6559
|
+
const deleteResponse = await this.client.toolRouter.session.files.delete(deleteOptions.data.mountId, {
|
|
6560
|
+
session_id: this.sessionId,
|
|
6561
|
+
mount_relative_path: remotePath
|
|
6562
|
+
});
|
|
6563
|
+
const fileDeleteResponse = FileDeleteResponseSchema.safeParse(deleteResponse);
|
|
6564
|
+
if (!fileDeleteResponse.success) throw new ValidationError("Failed to parse file delete response", { cause: fileDeleteResponse.error });
|
|
6565
|
+
return fileDeleteResponse.data;
|
|
6566
|
+
}
|
|
6567
|
+
};
|
|
6568
|
+
|
|
6569
|
+
//#endregion
|
|
6570
|
+
//#region src/models/ToolRouterSession.ts
|
|
6571
|
+
var ToolRouterSession = class {
|
|
6572
|
+
sessionId;
|
|
6573
|
+
mcp;
|
|
6574
|
+
files;
|
|
6575
|
+
constructor(client, config, sessionId, mcp, experimental) {
|
|
6576
|
+
this.client = client;
|
|
6577
|
+
this.config = config;
|
|
6578
|
+
this.experimental = experimental;
|
|
6579
|
+
this.sessionId = sessionId;
|
|
6580
|
+
this.mcp = mcp;
|
|
6581
|
+
this.files = new ToolRouterSessionFilesMount(client, sessionId);
|
|
6582
|
+
telemetry.instrument(this, "ToolRouterSession");
|
|
6583
|
+
}
|
|
6584
|
+
/**
|
|
6585
|
+
* Get the tools available in the session, formatted for your AI framework.
|
|
6586
|
+
* Requires a provider to be configured in the Composio constructor.
|
|
6587
|
+
*/
|
|
6588
|
+
async tools(modifiers) {
|
|
6589
|
+
const ToolsModel = new Tools(this.client, this.config);
|
|
6590
|
+
const tools = await ToolsModel.getRawToolRouterMetaTools(this.sessionId, modifiers?.modifySchema ? { modifySchema: modifiers.modifySchema } : void 0);
|
|
6591
|
+
return ToolsModel.wrapToolsForToolRouter(this.sessionId, tools, modifiers);
|
|
6592
|
+
}
|
|
6593
|
+
/**
|
|
6594
|
+
* Initiate an authorization flow for a toolkit.
|
|
6595
|
+
* Returns a ConnectionRequest with a redirect URL for the user.
|
|
6596
|
+
*/
|
|
6597
|
+
async authorize(toolkit, options) {
|
|
6598
|
+
const response = await this.client.toolRouter.session.link(this.sessionId, {
|
|
6599
|
+
...options?.callbackUrl ? { callback_url: options.callbackUrl } : {},
|
|
6600
|
+
toolkit
|
|
6601
|
+
});
|
|
6602
|
+
return createConnectionRequest(this.client, response.connected_account_id, ConnectedAccountStatuses.INITIATED, response.redirect_url);
|
|
6603
|
+
}
|
|
6604
|
+
/**
|
|
6605
|
+
* Query the connection state of toolkits in the session.
|
|
6606
|
+
* Supports pagination and filtering by toolkit slugs.
|
|
6607
|
+
*/
|
|
6608
|
+
async toolkits(options) {
|
|
6609
|
+
const toolkitOptions = ToolRouterToolkitsOptionsSchema.safeParse(options ?? {});
|
|
6610
|
+
if (!toolkitOptions.success) throw new ValidationError("Failed to parse toolkits options", { cause: toolkitOptions.error });
|
|
6611
|
+
const result = await this.client.toolRouter.session.toolkits(this.sessionId, {
|
|
6612
|
+
cursor: toolkitOptions.data.nextCursor,
|
|
6613
|
+
limit: toolkitOptions.data.limit,
|
|
6614
|
+
toolkits: toolkitOptions.data.toolkits,
|
|
6615
|
+
is_connected: toolkitOptions.data.isConnected,
|
|
6616
|
+
search: toolkitOptions.data.search
|
|
6617
|
+
});
|
|
6618
|
+
return {
|
|
6619
|
+
items: result.items.map((item) => {
|
|
6620
|
+
return transform(item).with(ToolkitConnectionStateSchema).using((item$1) => ({
|
|
6621
|
+
slug: item$1.slug,
|
|
6622
|
+
name: item$1.name,
|
|
6623
|
+
logo: item$1.meta?.logo,
|
|
6624
|
+
isNoAuth: item$1.is_no_auth,
|
|
6625
|
+
connection: item$1.is_no_auth ? void 0 : {
|
|
6626
|
+
isActive: item$1.connected_account?.status === "ACTIVE",
|
|
6627
|
+
authConfig: item$1.connected_account && {
|
|
6628
|
+
id: item$1.connected_account?.auth_config.id,
|
|
6629
|
+
mode: item$1.connected_account?.auth_config.auth_scheme,
|
|
6630
|
+
isComposioManaged: item$1.connected_account?.auth_config.is_composio_managed
|
|
6631
|
+
},
|
|
6632
|
+
connectedAccount: item$1.connected_account ? {
|
|
6633
|
+
id: item$1.connected_account.id,
|
|
6634
|
+
status: item$1.connected_account.status
|
|
6635
|
+
} : void 0
|
|
6636
|
+
}
|
|
6637
|
+
}));
|
|
6638
|
+
}),
|
|
6639
|
+
nextCursor: result.next_cursor ?? void 0,
|
|
6640
|
+
totalPages: result.total_pages
|
|
5887
6641
|
};
|
|
5888
|
-
}
|
|
6642
|
+
}
|
|
6643
|
+
/**
|
|
6644
|
+
* Search for tools by semantic use case.
|
|
6645
|
+
* Returns relevant tools for the given query with schemas and guidance.
|
|
6646
|
+
*
|
|
6647
|
+
* @param params - Search parameters
|
|
6648
|
+
* @param params.query - Semantic use-case query (e.g. "send emails", "create GitHub issues")
|
|
6649
|
+
* @param params.toolkits - Optional toolkit slugs to filter by
|
|
6650
|
+
* @returns Search results with matching tools and schemas
|
|
6651
|
+
*
|
|
6652
|
+
* @example
|
|
6653
|
+
* ```typescript
|
|
6654
|
+
* const session = await composio.toolRouter.use('session_123');
|
|
6655
|
+
* const results = await session.search({
|
|
6656
|
+
* query: 'send emails and notify Slack',
|
|
6657
|
+
* toolkits: ['gmail', 'slack'],
|
|
6658
|
+
* });
|
|
6659
|
+
* ```
|
|
6660
|
+
*/
|
|
6661
|
+
async search(params) {
|
|
6662
|
+
const transformed = transformSearchResponse(await this.client.toolRouter.session.search(this.sessionId, {
|
|
6663
|
+
queries: [{ use_case: params.query }],
|
|
6664
|
+
...params.toolkits?.length ? { toolkits: params.toolkits } : {}
|
|
6665
|
+
}));
|
|
6666
|
+
return ToolRouterSessionSearchResponseSchema.parse(transformed);
|
|
6667
|
+
}
|
|
5889
6668
|
/**
|
|
5890
|
-
*
|
|
5891
|
-
*
|
|
5892
|
-
* @param
|
|
5893
|
-
* @
|
|
6669
|
+
* Execute a tool within the session.
|
|
6670
|
+
*
|
|
6671
|
+
* @param toolSlug - The tool slug to execute (e.g. "GMAIL_SEND_EMAIL")
|
|
6672
|
+
* @param arguments_ - Optional tool arguments. Defaults to empty object if omitted.
|
|
6673
|
+
* @returns The tool execution result
|
|
6674
|
+
*
|
|
6675
|
+
* @example
|
|
6676
|
+
* ```typescript
|
|
6677
|
+
* const session = await composio.toolRouter.use('session_123');
|
|
6678
|
+
* const result = await session.execute('GMAIL_SEND_EMAIL', {
|
|
6679
|
+
* to: 'user@example.com',
|
|
6680
|
+
* subject: 'Hello',
|
|
6681
|
+
* body: 'Hi!',
|
|
6682
|
+
* });
|
|
6683
|
+
* ```
|
|
6684
|
+
*
|
|
6685
|
+
* @example
|
|
6686
|
+
* ```typescript
|
|
6687
|
+
* // Execute with no arguments
|
|
6688
|
+
* const result = await session.execute('HACKERNEWS_GET_USER');
|
|
6689
|
+
* ```
|
|
5894
6690
|
*/
|
|
5895
|
-
|
|
6691
|
+
async execute(toolSlug, arguments_) {
|
|
6692
|
+
const transformed = transformExecuteResponse(await this.client.toolRouter.session.execute(this.sessionId, {
|
|
6693
|
+
tool_slug: toolSlug,
|
|
6694
|
+
arguments: arguments_ ?? {}
|
|
6695
|
+
}));
|
|
6696
|
+
return ToolRouterSessionExecuteResponseSchema.parse(transformed);
|
|
6697
|
+
}
|
|
6698
|
+
};
|
|
6699
|
+
|
|
6700
|
+
//#endregion
|
|
6701
|
+
//#region src/models/ToolRouter.ts
|
|
6702
|
+
var ToolRouter = class {
|
|
6703
|
+
constructor(client, config) {
|
|
6704
|
+
this.client = client;
|
|
6705
|
+
this.config = config;
|
|
6706
|
+
telemetry.instrument(this, "ToolRouter");
|
|
6707
|
+
}
|
|
6708
|
+
createMCPServerConfig({ type, url }) {
|
|
5896
6709
|
return {
|
|
5897
6710
|
type,
|
|
5898
6711
|
url,
|
|
5899
|
-
headers: { ...this.config?.apiKey ? { "x-api-key": this.config
|
|
6712
|
+
headers: { ...this.config?.apiKey ? { "x-api-key": this.config.apiKey } : {} }
|
|
5900
6713
|
};
|
|
5901
|
-
}
|
|
6714
|
+
}
|
|
5902
6715
|
/**
|
|
5903
6716
|
* Creates a new tool router session for a user.
|
|
5904
6717
|
*
|
|
5905
6718
|
* @param userId {string} The user id to create the session for
|
|
5906
6719
|
* @param config {ToolRouterCreateSessionConfig} The config for the tool router session
|
|
5907
|
-
* @returns {Promise<
|
|
6720
|
+
* @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session
|
|
5908
6721
|
*
|
|
5909
6722
|
* @example
|
|
5910
6723
|
* ```typescript
|
|
@@ -5949,19 +6762,12 @@ var ToolRouter = class {
|
|
|
5949
6762
|
};
|
|
5950
6763
|
const session = await this.client.toolRouter.session.create(payload);
|
|
5951
6764
|
const experimental = session.experimental ? { assistivePrompt: session.experimental.assistive_prompt } : void 0;
|
|
5952
|
-
return
|
|
5953
|
-
sessionId: session.session_id,
|
|
5954
|
-
mcp: this.createMCPServerConfig(session.mcp),
|
|
5955
|
-
tools: this.createToolsFn(session.session_id),
|
|
5956
|
-
authorize: this.createAuthorizeFn(session.session_id),
|
|
5957
|
-
toolkits: this.createToolkitsFn(session.session_id),
|
|
5958
|
-
experimental
|
|
5959
|
-
};
|
|
6765
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), experimental);
|
|
5960
6766
|
}
|
|
5961
6767
|
/**
|
|
5962
6768
|
* Use an existing session
|
|
5963
6769
|
* @param id {string} The id of the session to use
|
|
5964
|
-
* @returns {Promise<
|
|
6770
|
+
* @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session
|
|
5965
6771
|
*
|
|
5966
6772
|
* @example
|
|
5967
6773
|
* ```typescript
|
|
@@ -5977,13 +6783,7 @@ var ToolRouter = class {
|
|
|
5977
6783
|
*/
|
|
5978
6784
|
async use(id) {
|
|
5979
6785
|
const session = await this.client.toolRouter.session.retrieve(id);
|
|
5980
|
-
return
|
|
5981
|
-
sessionId: session.session_id,
|
|
5982
|
-
mcp: this.createMCPServerConfig(session.mcp),
|
|
5983
|
-
tools: this.createToolsFn(session.session_id),
|
|
5984
|
-
authorize: this.createAuthorizeFn(session.session_id),
|
|
5985
|
-
toolkits: this.createToolkitsFn(session.session_id)
|
|
5986
|
-
};
|
|
6786
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp));
|
|
5987
6787
|
}
|
|
5988
6788
|
};
|
|
5989
6789
|
|
|
@@ -6033,7 +6833,7 @@ var Composio = class Composio {
|
|
|
6033
6833
|
*
|
|
6034
6834
|
* @param userId {string} The user id to create the session for
|
|
6035
6835
|
* @param config {ToolRouterConfig} The config for the tool router session
|
|
6036
|
-
* @returns {Promise<
|
|
6836
|
+
* @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session
|
|
6037
6837
|
*
|
|
6038
6838
|
* @example
|
|
6039
6839
|
* ```typescript
|
|
@@ -6056,7 +6856,7 @@ var Composio = class Composio {
|
|
|
6056
6856
|
* Use an existing tool router session
|
|
6057
6857
|
*
|
|
6058
6858
|
* @param id {string} The id of the session to use
|
|
6059
|
-
* @returns {Promise<
|
|
6859
|
+
* @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session
|
|
6060
6860
|
*/
|
|
6061
6861
|
use;
|
|
6062
6862
|
/**
|
|
@@ -6460,6 +7260,136 @@ var AuthScheme = class {
|
|
|
6460
7260
|
}
|
|
6461
7261
|
};
|
|
6462
7262
|
|
|
7263
|
+
//#endregion
|
|
7264
|
+
//#region src/types/webhookEvents.types.ts
|
|
7265
|
+
const WebhookEventTypes = {
|
|
7266
|
+
CONNECTION_EXPIRED: "composio.connected_account.expired",
|
|
7267
|
+
TRIGGER_MESSAGE: "composio.trigger.message"
|
|
7268
|
+
};
|
|
7269
|
+
/**
|
|
7270
|
+
* Auth config schema for webhook payloads (raw API format, snake_case).
|
|
7271
|
+
*
|
|
7272
|
+
* This intentionally does NOT reuse ConnectedAccountAuthConfigSchema from
|
|
7273
|
+
* connectedAccounts.types.ts because:
|
|
7274
|
+
* - Webhook payloads arrive in raw snake_case (is_composio_managed, is_disabled)
|
|
7275
|
+
* while the SDK schema uses camelCase (isComposioManaged, isDisabled)
|
|
7276
|
+
* - Webhook payloads include additional fields (auth_scheme, deprecated)
|
|
7277
|
+
* not present in the SDK schema
|
|
7278
|
+
*
|
|
7279
|
+
* Uses .passthrough() to accept unknown fields the API may add in the future.
|
|
7280
|
+
*
|
|
7281
|
+
* @see ConnectedAccountAuthConfigSchema in connectedAccounts.types.ts for the camelCase SDK version
|
|
7282
|
+
*/
|
|
7283
|
+
const WebhookConnectedAccountAuthConfigSchema = z$1.object({
|
|
7284
|
+
id: z$1.string(),
|
|
7285
|
+
auth_scheme: z$1.nativeEnum(AuthSchemeTypes),
|
|
7286
|
+
is_composio_managed: z$1.boolean(),
|
|
7287
|
+
is_disabled: z$1.boolean(),
|
|
7288
|
+
deprecated: z$1.object({ uuid: z$1.string() }).optional()
|
|
7289
|
+
}).passthrough();
|
|
7290
|
+
/**
|
|
7291
|
+
* Simplified connection state schema for webhook payloads (raw API format).
|
|
7292
|
+
*
|
|
7293
|
+
* This intentionally does NOT reuse ConnectionDataSchema from
|
|
7294
|
+
* connectedAccountAuthStates.types.ts because:
|
|
7295
|
+
* - ConnectionDataSchema is a discriminated union requiring typed `val`
|
|
7296
|
+
* per auth scheme (e.g., Oauth2ConnectionDataSchema)
|
|
7297
|
+
* - Webhook payloads need loose validation (z.record(z.unknown()))
|
|
7298
|
+
* since the connection state varies and isn't the focus of event handling
|
|
7299
|
+
*
|
|
7300
|
+
* Uses .passthrough() to accept unknown fields the API may add in the future.
|
|
7301
|
+
*
|
|
7302
|
+
* @see ConnectionDataSchema in connectedAccountAuthStates.types.ts for the full typed version
|
|
7303
|
+
*/
|
|
7304
|
+
const WebhookConnectionStateSchema = z$1.object({
|
|
7305
|
+
authScheme: z$1.nativeEnum(AuthSchemeTypes),
|
|
7306
|
+
val: z$1.record(z$1.unknown())
|
|
7307
|
+
}).passthrough();
|
|
7308
|
+
/**
|
|
7309
|
+
* Connected account data schema for webhook payloads (raw API format, snake_case).
|
|
7310
|
+
*
|
|
7311
|
+
* This is the snake_case equivalent of ConnectedAccountRetrieveResponseSchema
|
|
7312
|
+
* from connectedAccounts.types.ts. It intentionally does NOT reuse that schema because:
|
|
7313
|
+
* - Webhook payloads arrive in raw snake_case (auth_config, user_id, created_at, etc.)
|
|
7314
|
+
* while the SDK schema uses camelCase (authConfig, createdAt, etc.)
|
|
7315
|
+
* - The SDK applies a transformation layer (utils/transformers/connectedAccounts.ts)
|
|
7316
|
+
* before validation; webhooks are validated directly by the user
|
|
7317
|
+
* - Webhook payloads include user_id, which the SDK schema omits
|
|
7318
|
+
*
|
|
7319
|
+
* Uses .passthrough() to accept unknown fields the API may add in the future.
|
|
7320
|
+
*
|
|
7321
|
+
* @see ConnectedAccountRetrieveResponseSchema in connectedAccounts.types.ts for the camelCase SDK version
|
|
7322
|
+
* @see utils/transformers/connectedAccounts.ts for the snake-to-camel transformation
|
|
7323
|
+
*/
|
|
7324
|
+
const SingleConnectedAccountDetailedResponseSchema = z$1.object({
|
|
7325
|
+
toolkit: z$1.object({ slug: z$1.string().describe("The slug of the toolkit") }).passthrough(),
|
|
7326
|
+
auth_config: WebhookConnectedAccountAuthConfigSchema,
|
|
7327
|
+
id: z$1.string(),
|
|
7328
|
+
user_id: z$1.string(),
|
|
7329
|
+
status: z$1.nativeEnum(ConnectionStatuses),
|
|
7330
|
+
created_at: z$1.string(),
|
|
7331
|
+
updated_at: z$1.string(),
|
|
7332
|
+
state: WebhookConnectionStateSchema,
|
|
7333
|
+
data: z$1.record(z$1.unknown()),
|
|
7334
|
+
params: z$1.record(z$1.unknown()),
|
|
7335
|
+
status_reason: z$1.string().nullable(),
|
|
7336
|
+
is_disabled: z$1.boolean(),
|
|
7337
|
+
test_request_endpoint: z$1.string().optional(),
|
|
7338
|
+
deprecated: z$1.object({
|
|
7339
|
+
labels: z$1.array(z$1.string()),
|
|
7340
|
+
uuid: z$1.string()
|
|
7341
|
+
}).optional()
|
|
7342
|
+
}).passthrough();
|
|
7343
|
+
/**
|
|
7344
|
+
* Webhook metadata for connection events.
|
|
7345
|
+
* Note: This differs from the trigger webhook metadata in WebhookTriggerPayloadV3Schema.
|
|
7346
|
+
*
|
|
7347
|
+
* Uses .passthrough() to accept unknown fields the API may add in the future.
|
|
7348
|
+
*/
|
|
7349
|
+
const WebhookConnectionMetadataSchema = z$1.object({
|
|
7350
|
+
project_id: z$1.string(),
|
|
7351
|
+
org_id: z$1.string()
|
|
7352
|
+
}).passthrough();
|
|
7353
|
+
/**
|
|
7354
|
+
* Connection expired webhook event payload.
|
|
7355
|
+
* Emitted when a connected account expires due to authentication refresh failure.
|
|
7356
|
+
*
|
|
7357
|
+
* Uses .passthrough() to accept unknown fields the API may add in the future.
|
|
7358
|
+
*
|
|
7359
|
+
* @example
|
|
7360
|
+
* ```typescript
|
|
7361
|
+
* import { ConnectionExpiredEventSchema } from '@composio/core';
|
|
7362
|
+
*
|
|
7363
|
+
* // In your webhook handler
|
|
7364
|
+
* const result = ConnectionExpiredEventSchema.safeParse(webhookPayload);
|
|
7365
|
+
* if (result.success) {
|
|
7366
|
+
* const { data, metadata } = result.data;
|
|
7367
|
+
* console.log(`Connection ${data.id} expired for user ${data.user_id}`);
|
|
7368
|
+
* console.log(`Toolkit: ${data.toolkit.slug}`);
|
|
7369
|
+
* console.log(`Project: ${metadata.project_id}`);
|
|
7370
|
+
* }
|
|
7371
|
+
* ```
|
|
7372
|
+
*/
|
|
7373
|
+
const ConnectionExpiredEventSchema = z$1.object({
|
|
7374
|
+
id: z$1.string(),
|
|
7375
|
+
timestamp: z$1.string(),
|
|
7376
|
+
type: z$1.literal(WebhookEventTypes.CONNECTION_EXPIRED),
|
|
7377
|
+
data: SingleConnectedAccountDetailedResponseSchema,
|
|
7378
|
+
metadata: WebhookConnectionMetadataSchema
|
|
7379
|
+
}).passthrough();
|
|
7380
|
+
/**
|
|
7381
|
+
* Union of all typed webhook event schemas.
|
|
7382
|
+
* Extend this as new event types are added.
|
|
7383
|
+
*
|
|
7384
|
+
* Note: This covers specific known event types with strict validation.
|
|
7385
|
+
* For unknown or new event types, use WebhookPayloadV3Schema from
|
|
7386
|
+
* triggers.types.ts which accepts any composio.* event with loose validation.
|
|
7387
|
+
*
|
|
7388
|
+
* Trigger events (composio.trigger.message) are handled through the
|
|
7389
|
+
* WebhookTriggerPayloadV3Schema in triggers.types.ts and the TriggerEvent type.
|
|
7390
|
+
*/
|
|
7391
|
+
const WebhookEventSchema = z$1.discriminatedUnion("type", [ConnectionExpiredEventSchema]);
|
|
7392
|
+
|
|
6463
7393
|
//#endregion
|
|
6464
7394
|
//#region src/types/mcp.types.ts
|
|
6465
7395
|
/**
|
|
@@ -6656,4 +7586,4 @@ const ComposioMcpUpdateResponseSchema = z$1.object({
|
|
|
6656
7586
|
});
|
|
6657
7587
|
|
|
6658
7588
|
//#endregion
|
|
6659
|
-
export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomCreateResponseSchema, ComposioCustomToolsNotInitializedError, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAuthConfigSchema, ConnectedAccountErrorCodes, ConnectedAccountListParamsSchema, ConnectedAccountListResponseSchema, ConnectedAccountRefreshOptionsSchema, ConnectedAccountRetrieveResponseSchema, ConnectedAccountStatusSchema, ConnectedAccountStatuses, ConnectionDataSchema, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConnectionStatus, ConnectionStatuses, CreateAuthConfigParamsSchema, CreateAuthConfigResponseSchema, CreateComposioManagedAuthConfigParamsSchema, CreateConnectedAccountLinkOptionsSchema, CreateConnectedAccountLinkResponseSchema, CreateConnectedAccountOptionsSchema, CreateConnectedAccountParamsSchema, CreateConnectedAccountResponseSchema, CreateCustomAuthConfigParamsSchema, CustomAuthParamsSchema, CustomConnectionDataSchema, CustomCreateResponseSchema, CustomOauth1ConnectionDataSchema, CustomOauth2ConnectionDataSchema, DefaultCreateConnectedAccountParamsSchema, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, JsonSchemaToZodError, MCP, MCPAuthOptionsSchema, MCPGenerateURLParamsSchema, MCPGetServerParamsSchema, MCPMultiAppServerSchema, MCPServerCreateResponseSchema, MCPServerListResponseSchema, MCPServerSchema, MCPServerTypeSchema, MCPServerUpdateParamsSchema, MCPSingleAppServerSchema, MCPToolkitConfigSchema, MCPToolkitConfigsArraySchema, McpDeleteResponseSchema, McpListResponseSchema, McpRetrieveResponseSchema, McpUpdateResponseSchema, Oauth1ActiveConnectionDataSchema, Oauth1ConnectionDataSchema, Oauth1ExpiredConnectionDataSchema, Oauth1FailedConnectionDataSchema, Oauth1InactiveConnectionDataSchema, Oauth1InitiatedConnectionDataSchema, Oauth1InitiatingConnectionDataSchema, Oauth2ActiveConnectionDataSchema, Oauth2ConnectionDataSchema, Oauth2ExpiredConnectionDataSchema, Oauth2FailedConnectionDataSchema, Oauth2InactiveConnectionDataSchema, Oauth2InitiatedConnectionDataSchema, Oauth2InitiatingConnectionDataSchema, OpenAIProvider, RedirectableAuthSchemeSchema, SDKErrorCodes, ToolErrorCodes, ToolExecuteMetaParamsSchema, ToolExecuteParamsSchema, ToolExecuteResponseSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterTagsEnableDisableSchema, ToolRouterTagsParamSchema, ToolRouterToolkitsDisabledConfigSchema, ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsOptionsSchema, ToolRouterToolkitsParamSchema, ToolRouterToolsParamSchema, ToolSchema, ToolkitAuthConfigDetailsSchema, ToolkitAuthFieldSchema, ToolkitAuthFieldsResponseSchema, ToolkitCategorySchema, ToolkitConnectionStateSchema, ToolkitConnectionsDetailsSchema, ToolkitErrorCodes, ToolkitLatestVersionSchema, ToolkitMangedByEnumSchema, ToolkitRetrieveCategoriesResponseSchema, ToolkitRetrieveResponseSchema, ToolkitSchema, ToolkitSortByEnumSchema, ToolkitVersionParamSchema, ToolkitVersionSchema, ToolkitVersionsSchema, ToolkitsListParamsSchema, TriggerErrorCodes, TriggerInstanceListActiveParamsSchema, TriggerInstanceListActiveResponseItemSchema, TriggerInstanceListActiveResponseSchema, TriggerInstanceManageDeleteResponseSchema, TriggerInstanceManageUpdateParamsSchema, TriggerInstanceManageUpdateResponseSchema, TriggerInstanceUpsertParamsSchema, TriggerInstanceUpsertResponseSchema, TriggerStatusEnum, TriggerStatuses, TriggerSubscribeParamSchema, TriggerTypeSchema, TriggersTypeListParamsSchema, TriggersTypeListResponseSchema, ValidationError, ValidationErrorCodes, VerifyWebhookParamsSchema, WebhookPayloadSchema, WebhookPayloadV1Schema, WebhookPayloadV2Schema, WebhookPayloadV3Schema, WebhookVersions, constants_exports as constants, createConnectionRequest, handleToolExecutionError, jsonSchemaToZodSchema, logger_default as logger, removeNonRequiredProperties };
|
|
7589
|
+
export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomCreateResponseSchema, ComposioCustomToolsNotInitializedError, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAuthConfigSchema, ConnectedAccountErrorCodes, ConnectedAccountListParamsSchema, ConnectedAccountListResponseSchema, ConnectedAccountRefreshOptionsSchema, ConnectedAccountRetrieveResponseSchema, ConnectedAccountStatusSchema, ConnectedAccountStatuses, ConnectionDataSchema, ConnectionExpiredEventSchema, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConnectionStatus, ConnectionStatuses, CreateAuthConfigParamsSchema, CreateAuthConfigResponseSchema, CreateComposioManagedAuthConfigParamsSchema, CreateConnectedAccountLinkOptionsSchema, CreateConnectedAccountLinkResponseSchema, CreateConnectedAccountOptionsSchema, CreateConnectedAccountParamsSchema, CreateConnectedAccountResponseSchema, CreateCustomAuthConfigParamsSchema, CustomAuthParamsSchema, CustomConnectionDataSchema, CustomCreateResponseSchema, CustomOauth1ConnectionDataSchema, CustomOauth2ConnectionDataSchema, DefaultCreateConnectedAccountParamsSchema, FileDeleteResponseSchema, FileListResponseSchema, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, JsonSchemaToZodError, MCP, MCPAuthOptionsSchema, MCPGenerateURLParamsSchema, MCPGetServerParamsSchema, MCPMultiAppServerSchema, MCPServerCreateResponseSchema, MCPServerListResponseSchema, MCPServerSchema, MCPServerTypeSchema, MCPServerUpdateParamsSchema, MCPSingleAppServerSchema, MCPToolkitConfigSchema, MCPToolkitConfigsArraySchema, McpDeleteResponseSchema, McpListResponseSchema, McpRetrieveResponseSchema, McpUpdateResponseSchema, Oauth1ActiveConnectionDataSchema, Oauth1ConnectionDataSchema, Oauth1ExpiredConnectionDataSchema, Oauth1FailedConnectionDataSchema, Oauth1InactiveConnectionDataSchema, Oauth1InitiatedConnectionDataSchema, Oauth1InitiatingConnectionDataSchema, Oauth2ActiveConnectionDataSchema, Oauth2ConnectionDataSchema, Oauth2ExpiredConnectionDataSchema, Oauth2FailedConnectionDataSchema, Oauth2InactiveConnectionDataSchema, Oauth2InitiatedConnectionDataSchema, Oauth2InitiatingConnectionDataSchema, OpenAIProvider, RedirectableAuthSchemeSchema, RemoteFile, RemoteFileDataSchema, RemoteFileDownloadError, RemoteFileErrorCodes, SDKErrorCodes, SingleConnectedAccountDetailedResponseSchema, ToolErrorCodes, ToolExecuteMetaParamsSchema, ToolExecuteParamsSchema, ToolExecuteResponseSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterSession, ToolRouterSessionExecuteResponseSchema, ToolRouterSessionFilesMountDeleteOptionsSchema, ToolRouterSessionFilesMountDownloadOptionsSchema, ToolRouterSessionFilesMountListOptionsSchema, ToolRouterSessionFilesMountUploadOptionsSchema, ToolRouterSessionSearchResponseSchema, ToolRouterTagsEnableDisableSchema, ToolRouterTagsParamSchema, ToolRouterToolkitsDisabledConfigSchema, ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsOptionsSchema, ToolRouterToolkitsParamSchema, ToolRouterToolsParamSchema, ToolSchema, ToolkitAuthConfigDetailsSchema, ToolkitAuthFieldSchema, ToolkitAuthFieldsResponseSchema, ToolkitCategorySchema, ToolkitConnectionStateSchema, ToolkitConnectionsDetailsSchema, ToolkitErrorCodes, ToolkitLatestVersionSchema, ToolkitMangedByEnumSchema, ToolkitRetrieveCategoriesResponseSchema, ToolkitRetrieveResponseSchema, ToolkitSchema, ToolkitSortByEnumSchema, ToolkitVersionParamSchema, ToolkitVersionSchema, ToolkitVersionsSchema, ToolkitsListParamsSchema, TriggerErrorCodes, TriggerInstanceListActiveParamsSchema, TriggerInstanceListActiveResponseItemSchema, TriggerInstanceListActiveResponseSchema, TriggerInstanceManageDeleteResponseSchema, TriggerInstanceManageUpdateParamsSchema, TriggerInstanceManageUpdateResponseSchema, TriggerInstanceUpsertParamsSchema, TriggerInstanceUpsertResponseSchema, TriggerStatusEnum, TriggerStatuses, TriggerSubscribeParamSchema, TriggerTypeSchema, TriggersTypeListParamsSchema, TriggersTypeListResponseSchema, ValidationError, ValidationErrorCodes, VerifyWebhookParamsSchema, WebhookConnectedAccountAuthConfigSchema, WebhookConnectionMetadataSchema, WebhookConnectionStateSchema, WebhookEventSchema, WebhookEventTypes, WebhookPayloadSchema, WebhookPayloadV1Schema, WebhookPayloadV2Schema, WebhookPayloadV3Schema, WebhookTriggerPayloadV3Schema, WebhookVersions, constants_exports as constants, createConnectionRequest, getExtensionFromMimeType, handleToolExecutionError, jsonSchemaToZodSchema, logger_default as logger, removeNonRequiredProperties };
|