@composio/core 0.6.4 → 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-B_7Qy99Q.d.mts → BaseProvider-B2v5L9PY.d.mts} +218 -218
- package/dist/{BaseProvider-DF03HAz3.d.cts → BaseProvider-B_UIuruL.d.cts} +218 -218
- package/dist/{Telemetry-B3HlLpMT.mjs → Telemetry-CHfDfthM.mjs} +1 -1
- package/dist/{Telemetry-DBe2oppA.cjs → Telemetry-DRFfIuVS.cjs} +1 -1
- 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-COyITeJf.d.cts → composio-B-tZKVA0.d.cts} +897 -305
- package/dist/{composio-ClplAPbl.d.mts → composio-OAY2JH-U.d.mts} +897 -305
- 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 +802 -100
- package/dist/index.d.cts +132 -5
- package/dist/index.d.mts +132 -5
- package/dist/index.mjs +789 -101
- package/dist/models/Files.node.cjs +3 -3
- package/dist/models/Files.node.mjs +3 -3
- package/dist/{types-BO1Bf2Xz.d.mts → types-Bo0skt5g.d.mts} +2 -2
- package/dist/{types-Bib0jIbg.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.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CQwRTUmo.cjs');
|
|
2
|
-
const require_buffer = require('./buffer-
|
|
3
|
-
const require_Telemetry = require('./Telemetry-
|
|
2
|
+
const require_buffer = require('./buffer-Dy7Xi_sk.cjs');
|
|
3
|
+
const require_Telemetry = require('./Telemetry-DRFfIuVS.cjs');
|
|
4
4
|
let _composio_client = require("@composio/client");
|
|
5
5
|
_composio_client = require_chunk.__toESM(_composio_client);
|
|
6
6
|
let _file_tool_modifier = require("#file_tool_modifier");
|
|
@@ -1444,6 +1444,39 @@ var ComposioWebhookPayloadError = class extends require_buffer.ComposioError {
|
|
|
1444
1444
|
}
|
|
1445
1445
|
};
|
|
1446
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
|
+
|
|
1447
1480
|
//#endregion
|
|
1448
1481
|
//#region src/types/connectedAccounts.types.ts
|
|
1449
1482
|
/**
|
|
@@ -5696,7 +5729,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5696
5729
|
|
|
5697
5730
|
//#endregion
|
|
5698
5731
|
//#region package.json
|
|
5699
|
-
var version = "0.6.
|
|
5732
|
+
var version = "0.6.5-alpha.0";
|
|
5700
5733
|
|
|
5701
5734
|
//#endregion
|
|
5702
5735
|
//#region src/utils/session.ts
|
|
@@ -5853,6 +5886,72 @@ const ToolRouterToolkitsOptionsSchema = zod_v3.default.object({
|
|
|
5853
5886
|
isConnected: zod_v3.default.boolean().optional(),
|
|
5854
5887
|
search: zod_v3.default.string().optional()
|
|
5855
5888
|
});
|
|
5889
|
+
const ToolRouterSessionSearchResultReferenceWorkbenchSnippetSchema = zod_v3.default.object({
|
|
5890
|
+
code: zod_v3.default.string(),
|
|
5891
|
+
description: zod_v3.default.string()
|
|
5892
|
+
});
|
|
5893
|
+
const ToolRouterSessionSearchResultSchema = zod_v3.default.object({
|
|
5894
|
+
index: zod_v3.default.number(),
|
|
5895
|
+
useCase: zod_v3.default.string(),
|
|
5896
|
+
primaryToolSlugs: zod_v3.default.array(zod_v3.default.string()),
|
|
5897
|
+
relatedToolSlugs: zod_v3.default.array(zod_v3.default.string()),
|
|
5898
|
+
toolkits: zod_v3.default.array(zod_v3.default.string()),
|
|
5899
|
+
difficulty: zod_v3.default.string().optional(),
|
|
5900
|
+
error: zod_v3.default.string().nullable().optional(),
|
|
5901
|
+
executionGuidance: zod_v3.default.string().optional(),
|
|
5902
|
+
knownPitfalls: zod_v3.default.array(zod_v3.default.string()).optional(),
|
|
5903
|
+
memory: zod_v3.default.record(zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())).optional(),
|
|
5904
|
+
planId: zod_v3.default.string().optional(),
|
|
5905
|
+
recommendedPlanSteps: zod_v3.default.array(zod_v3.default.string()).optional(),
|
|
5906
|
+
referenceWorkbenchSnippets: zod_v3.default.array(ToolRouterSessionSearchResultReferenceWorkbenchSnippetSchema).optional()
|
|
5907
|
+
});
|
|
5908
|
+
const ToolRouterSessionSearchSessionSchema = zod_v3.default.object({
|
|
5909
|
+
id: zod_v3.default.string(),
|
|
5910
|
+
generateId: zod_v3.default.boolean(),
|
|
5911
|
+
instructions: zod_v3.default.string()
|
|
5912
|
+
});
|
|
5913
|
+
const ToolRouterSessionSearchTimeInfoSchema = zod_v3.default.object({
|
|
5914
|
+
currentTimeUtc: zod_v3.default.string(),
|
|
5915
|
+
currentTimeUtcEpochSeconds: zod_v3.default.number(),
|
|
5916
|
+
message: zod_v3.default.string()
|
|
5917
|
+
});
|
|
5918
|
+
const ToolRouterSessionSearchToolSchemasSchemaRefSchema = zod_v3.default.object({
|
|
5919
|
+
args: zod_v3.default.object({ toolSlugs: zod_v3.default.array(zod_v3.default.string()) }),
|
|
5920
|
+
message: zod_v3.default.string(),
|
|
5921
|
+
tool: zod_v3.default.literal("COMPOSIO_GET_TOOL_SCHEMAS")
|
|
5922
|
+
});
|
|
5923
|
+
const ToolRouterSessionSearchToolSchemaSchema = zod_v3.default.object({
|
|
5924
|
+
toolSlug: zod_v3.default.string(),
|
|
5925
|
+
toolkit: zod_v3.default.string(),
|
|
5926
|
+
description: zod_v3.default.string().optional(),
|
|
5927
|
+
hasFullSchema: zod_v3.default.boolean().optional(),
|
|
5928
|
+
inputSchema: zod_v3.default.record(zod_v3.default.string(), zod_v3.default.unknown()).optional(),
|
|
5929
|
+
outputSchema: zod_v3.default.record(zod_v3.default.string(), zod_v3.default.unknown()).optional(),
|
|
5930
|
+
schemaRef: ToolRouterSessionSearchToolSchemasSchemaRefSchema.optional()
|
|
5931
|
+
});
|
|
5932
|
+
const ToolRouterSessionSearchToolkitConnectionStatusSchema = zod_v3.default.object({
|
|
5933
|
+
toolkit: zod_v3.default.string(),
|
|
5934
|
+
description: zod_v3.default.string(),
|
|
5935
|
+
hasActiveConnection: zod_v3.default.boolean(),
|
|
5936
|
+
statusMessage: zod_v3.default.string(),
|
|
5937
|
+
connectionDetails: zod_v3.default.record(zod_v3.default.string(), zod_v3.default.unknown()).optional(),
|
|
5938
|
+
currentUserInfo: zod_v3.default.record(zod_v3.default.string(), zod_v3.default.unknown()).optional()
|
|
5939
|
+
});
|
|
5940
|
+
const ToolRouterSessionSearchResponseSchema = zod_v3.default.object({
|
|
5941
|
+
success: zod_v3.default.boolean(),
|
|
5942
|
+
error: zod_v3.default.string().nullable(),
|
|
5943
|
+
results: zod_v3.default.array(ToolRouterSessionSearchResultSchema),
|
|
5944
|
+
toolSchemas: zod_v3.default.record(zod_v3.default.string(), ToolRouterSessionSearchToolSchemaSchema),
|
|
5945
|
+
toolkitConnectionStatuses: zod_v3.default.array(ToolRouterSessionSearchToolkitConnectionStatusSchema),
|
|
5946
|
+
nextStepsGuidance: zod_v3.default.array(zod_v3.default.string()),
|
|
5947
|
+
session: ToolRouterSessionSearchSessionSchema,
|
|
5948
|
+
timeInfo: ToolRouterSessionSearchTimeInfoSchema
|
|
5949
|
+
});
|
|
5950
|
+
const ToolRouterSessionExecuteResponseSchema = zod_v3.default.object({
|
|
5951
|
+
data: zod_v3.default.record(zod_v3.default.string(), zod_v3.default.unknown()),
|
|
5952
|
+
error: zod_v3.default.string().nullable(),
|
|
5953
|
+
logId: zod_v3.default.string()
|
|
5954
|
+
});
|
|
5856
5955
|
|
|
5857
5956
|
//#endregion
|
|
5858
5957
|
//#region src/lib/toolRouterParams.ts
|
|
@@ -5910,117 +6009,719 @@ const transformToolRouterToolkitsParams = (params) => {
|
|
|
5910
6009
|
};
|
|
5911
6010
|
|
|
5912
6011
|
//#endregion
|
|
5913
|
-
//#region src/
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
6012
|
+
//#region src/utils/transformers/toolRouterResponseTransform.ts
|
|
6013
|
+
function transformSearchResult(raw) {
|
|
6014
|
+
return {
|
|
6015
|
+
index: raw.index,
|
|
6016
|
+
useCase: raw.use_case,
|
|
6017
|
+
primaryToolSlugs: raw.primary_tool_slugs,
|
|
6018
|
+
relatedToolSlugs: raw.related_tool_slugs,
|
|
6019
|
+
toolkits: raw.toolkits,
|
|
6020
|
+
difficulty: raw.difficulty,
|
|
6021
|
+
error: raw.error,
|
|
6022
|
+
executionGuidance: raw.execution_guidance,
|
|
6023
|
+
knownPitfalls: raw.known_pitfalls,
|
|
6024
|
+
memory: raw.memory,
|
|
6025
|
+
planId: raw.plan_id,
|
|
6026
|
+
recommendedPlanSteps: raw.recommended_plan_steps,
|
|
6027
|
+
referenceWorkbenchSnippets: raw.reference_workbench_snippets
|
|
6028
|
+
};
|
|
6029
|
+
}
|
|
6030
|
+
function transformToolSchema(raw) {
|
|
6031
|
+
return {
|
|
6032
|
+
toolSlug: raw.tool_slug,
|
|
6033
|
+
toolkit: raw.toolkit,
|
|
6034
|
+
description: raw.description,
|
|
6035
|
+
hasFullSchema: raw.hasFullSchema,
|
|
6036
|
+
inputSchema: raw.input_schema,
|
|
6037
|
+
outputSchema: raw.output_schema,
|
|
6038
|
+
schemaRef: raw.schemaRef ? {
|
|
6039
|
+
args: { toolSlugs: raw.schemaRef.args.tool_slugs },
|
|
6040
|
+
message: raw.schemaRef.message,
|
|
6041
|
+
tool: raw.schemaRef.tool
|
|
6042
|
+
} : void 0
|
|
6043
|
+
};
|
|
6044
|
+
}
|
|
6045
|
+
function transformToolkitConnectionStatus(raw) {
|
|
6046
|
+
return {
|
|
6047
|
+
toolkit: raw.toolkit,
|
|
6048
|
+
description: raw.description,
|
|
6049
|
+
hasActiveConnection: raw.has_active_connection,
|
|
6050
|
+
statusMessage: raw.status_message,
|
|
6051
|
+
connectionDetails: raw.connection_details,
|
|
6052
|
+
currentUserInfo: raw.current_user_info
|
|
6053
|
+
};
|
|
6054
|
+
}
|
|
6055
|
+
/**
|
|
6056
|
+
* Transforms a raw session search API response to camelCase.
|
|
6057
|
+
*/
|
|
6058
|
+
function transformSearchResponse(raw) {
|
|
6059
|
+
const toolSchemas = {};
|
|
6060
|
+
for (const [slug, schema] of Object.entries(raw.tool_schemas)) toolSchemas[slug] = transformToolSchema(schema);
|
|
6061
|
+
return {
|
|
6062
|
+
success: raw.success,
|
|
6063
|
+
error: raw.error,
|
|
6064
|
+
results: raw.results.map(transformSearchResult),
|
|
6065
|
+
toolSchemas,
|
|
6066
|
+
toolkitConnectionStatuses: raw.toolkit_connection_statuses.map(transformToolkitConnectionStatus),
|
|
6067
|
+
nextStepsGuidance: raw.next_steps_guidance,
|
|
6068
|
+
session: {
|
|
6069
|
+
id: raw.session.id,
|
|
6070
|
+
generateId: raw.session.generate_id,
|
|
6071
|
+
instructions: raw.session.instructions
|
|
6072
|
+
},
|
|
6073
|
+
timeInfo: {
|
|
6074
|
+
currentTimeUtc: raw.time_info.current_time_utc,
|
|
6075
|
+
currentTimeUtcEpochSeconds: raw.time_info.current_time_utc_epoch_seconds,
|
|
6076
|
+
message: raw.time_info.message
|
|
6077
|
+
}
|
|
6078
|
+
};
|
|
6079
|
+
}
|
|
6080
|
+
/**
|
|
6081
|
+
* Transforms a raw session execute API response to camelCase.
|
|
6082
|
+
*/
|
|
6083
|
+
function transformExecuteResponse(raw) {
|
|
6084
|
+
return {
|
|
6085
|
+
data: raw.data,
|
|
6086
|
+
error: raw.error,
|
|
6087
|
+
logId: raw.log_id
|
|
6088
|
+
};
|
|
6089
|
+
}
|
|
6090
|
+
|
|
6091
|
+
//#endregion
|
|
6092
|
+
//#region src/types/ToolRouterSessionFilesMount.types.ts
|
|
6093
|
+
const ToolRouterSessionFilesMountListOptionsSchema = zod_v3.default.object({
|
|
6094
|
+
path: zod_v3.default.string().optional(),
|
|
6095
|
+
mountId: zod_v3.default.string().default(require_buffer.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID),
|
|
6096
|
+
cursor: zod_v3.default.string().optional(),
|
|
6097
|
+
limit: zod_v3.default.number().min(1).max(500).optional()
|
|
6098
|
+
});
|
|
6099
|
+
const FileListItemSchema = zod_v3.default.object({
|
|
6100
|
+
last_modified: zod_v3.default.string(),
|
|
6101
|
+
mount_relative_path: zod_v3.default.string(),
|
|
6102
|
+
sandbox_mount_prefix: zod_v3.default.string(),
|
|
6103
|
+
size: zod_v3.default.number()
|
|
6104
|
+
});
|
|
6105
|
+
const FileListResponseSchema = zod_v3.default.object({
|
|
6106
|
+
items: zod_v3.default.array(FileListItemSchema),
|
|
6107
|
+
next_cursor: zod_v3.default.string().optional()
|
|
6108
|
+
}).transform((data) => ({
|
|
6109
|
+
items: data.items.map((item) => ({
|
|
6110
|
+
lastModified: item.last_modified,
|
|
6111
|
+
mountRelativePath: item.mount_relative_path,
|
|
6112
|
+
sandboxMountPrefix: item.sandbox_mount_prefix,
|
|
6113
|
+
size: item.size
|
|
6114
|
+
})),
|
|
6115
|
+
nextCursor: data.next_cursor
|
|
6116
|
+
}));
|
|
6117
|
+
const ToolRouterSessionFilesMountUploadOptionsSchema = zod_v3.default.object({
|
|
6118
|
+
remotePath: zod_v3.default.string().optional(),
|
|
6119
|
+
mountId: zod_v3.default.string().default(require_buffer.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID),
|
|
6120
|
+
mimetype: zod_v3.default.string().optional()
|
|
6121
|
+
});
|
|
6122
|
+
const ToolRouterSessionFilesMountDownloadOptionsSchema = zod_v3.default.object({ mountId: zod_v3.default.string().default(require_buffer.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID) });
|
|
6123
|
+
const ToolRouterSessionFilesMountDeleteOptionsSchema = zod_v3.default.object({ mountId: zod_v3.default.string().default(require_buffer.DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID) });
|
|
6124
|
+
const RemoteFileDataSchema = zod_v3.default.object({
|
|
6125
|
+
expires_at: zod_v3.default.string(),
|
|
6126
|
+
mount_relative_path: zod_v3.default.string(),
|
|
6127
|
+
sandbox_mount_prefix: zod_v3.default.string(),
|
|
6128
|
+
download_url: zod_v3.default.string()
|
|
6129
|
+
}).transform((data) => ({
|
|
6130
|
+
expiresAt: data.expires_at,
|
|
6131
|
+
mountRelativePath: data.mount_relative_path,
|
|
6132
|
+
sandboxMountPrefix: data.sandbox_mount_prefix,
|
|
6133
|
+
downloadUrl: data.download_url
|
|
6134
|
+
}));
|
|
6135
|
+
const FileDeleteResponseSchema = zod_v3.default.object({
|
|
6136
|
+
mount_relative_path: zod_v3.default.string(),
|
|
6137
|
+
sandbox_mount_prefix: zod_v3.default.string()
|
|
6138
|
+
}).transform((data) => ({
|
|
6139
|
+
mountRelativePath: data.mount_relative_path,
|
|
6140
|
+
sandboxMountPrefix: data.sandbox_mount_prefix
|
|
6141
|
+
}));
|
|
6142
|
+
|
|
6143
|
+
//#endregion
|
|
6144
|
+
//#region src/models/RemoteFile.ts
|
|
6145
|
+
function getParentDir(filePath) {
|
|
6146
|
+
const lastSep = Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"));
|
|
6147
|
+
if (lastSep <= 0) return "";
|
|
6148
|
+
return filePath.slice(0, lastSep);
|
|
6149
|
+
}
|
|
6150
|
+
/**
|
|
6151
|
+
* Represents a file stored in a tool router session's file mount.
|
|
6152
|
+
* Provides methods to fetch, save, and work with the file content.
|
|
6153
|
+
*
|
|
6154
|
+
* @example
|
|
6155
|
+
* ```typescript
|
|
6156
|
+
* const remoteFile = await session.files.download('/output/report.pdf');
|
|
6157
|
+
* const buffer = await remoteFile.buffer();
|
|
6158
|
+
* await remoteFile.save('/tmp/report.pdf');
|
|
6159
|
+
* const text = await remoteFile.text();
|
|
6160
|
+
* ```
|
|
6161
|
+
*
|
|
6162
|
+
* @example
|
|
6163
|
+
* ```typescript
|
|
6164
|
+
* // Create from API response (snake_case)
|
|
6165
|
+
* const remoteFile = RemoteFile.parse(apiResponse);
|
|
6166
|
+
*
|
|
6167
|
+
* // Or create from parsed data (camelCase)
|
|
6168
|
+
* const remoteFile = new RemoteFile({
|
|
6169
|
+
* expiresAt: '...',
|
|
6170
|
+
* mountRelativePath: 'report.pdf',
|
|
6171
|
+
* sandboxMountPrefix: '/mnt/files',
|
|
6172
|
+
* downloadUrl: 'https://...',
|
|
6173
|
+
* });
|
|
6174
|
+
* ```
|
|
6175
|
+
*/
|
|
6176
|
+
var RemoteFile = class RemoteFile {
|
|
6177
|
+
/** ISO 8601 timestamp when the download URL expires */
|
|
6178
|
+
expiresAt;
|
|
6179
|
+
/** Relative path within the mount (e.g. "report.pdf") */
|
|
6180
|
+
mountRelativePath;
|
|
6181
|
+
/** Absolute mount path inside the sandbox (e.g. /mnt/files) */
|
|
6182
|
+
sandboxMountPrefix;
|
|
6183
|
+
/** Presigned URL for downloading the file */
|
|
6184
|
+
downloadUrl;
|
|
6185
|
+
constructor(data) {
|
|
6186
|
+
this.expiresAt = data.expiresAt;
|
|
6187
|
+
this.mountRelativePath = data.mountRelativePath;
|
|
6188
|
+
this.sandboxMountPrefix = data.sandboxMountPrefix;
|
|
6189
|
+
this.downloadUrl = data.downloadUrl;
|
|
6190
|
+
}
|
|
6191
|
+
/**
|
|
6192
|
+
* Parses an API response (snake_case) and returns a RemoteFile instance.
|
|
6193
|
+
* @param data - Raw API response with snake_case keys
|
|
6194
|
+
* @returns A RemoteFile instance
|
|
6195
|
+
* @throws ValidationError if the response shape is invalid
|
|
6196
|
+
*/
|
|
6197
|
+
static parse(data) {
|
|
6198
|
+
const parsed = RemoteFileDataSchema.safeParse(data);
|
|
6199
|
+
if (!parsed.success) throw new ValidationError("Failed to parse remote file response", { cause: parsed.error });
|
|
6200
|
+
return new RemoteFile(parsed.data);
|
|
6201
|
+
}
|
|
6202
|
+
/** Filename extracted from the mount path (e.g. "report.pdf" from "output/report.pdf") */
|
|
6203
|
+
get filename() {
|
|
6204
|
+
return _platform.platform.basename(this.mountRelativePath);
|
|
6205
|
+
}
|
|
6206
|
+
/**
|
|
6207
|
+
* Fetches the file content as a buffer.
|
|
6208
|
+
* @returns The file content as a Uint8Array
|
|
6209
|
+
* @throws RemoteFileDownloadError if the fetch fails
|
|
6210
|
+
*/
|
|
6211
|
+
async buffer() {
|
|
6212
|
+
const response = await fetch(this.downloadUrl);
|
|
6213
|
+
if (!response.ok) throw new RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
|
|
6214
|
+
statusCode: response.status,
|
|
6215
|
+
statusText: response.statusText,
|
|
6216
|
+
downloadUrl: this.downloadUrl,
|
|
6217
|
+
mountRelativePath: this.mountRelativePath,
|
|
6218
|
+
filename: this.filename,
|
|
6219
|
+
cause: /* @__PURE__ */ new Error(`HTTP ${response.status}: ${response.statusText}`)
|
|
6220
|
+
});
|
|
6221
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
6222
|
+
return new Uint8Array(arrayBuffer);
|
|
6223
|
+
}
|
|
6224
|
+
/**
|
|
6225
|
+
* Fetches the file content as UTF-8 text.
|
|
6226
|
+
* @returns The file content as a string
|
|
6227
|
+
* @throws Error if the fetch fails
|
|
6228
|
+
*/
|
|
6229
|
+
async text() {
|
|
6230
|
+
const buf = await this.buffer();
|
|
6231
|
+
return new TextDecoder().decode(buf);
|
|
5919
6232
|
}
|
|
5920
6233
|
/**
|
|
5921
|
-
*
|
|
5922
|
-
* @
|
|
5923
|
-
* @
|
|
6234
|
+
* Fetches the file content as a Blob.
|
|
6235
|
+
* @returns The file content as a Blob
|
|
6236
|
+
* @throws RemoteFileDownloadError if the fetch fails
|
|
6237
|
+
*/
|
|
6238
|
+
async blob() {
|
|
6239
|
+
const response = await fetch(this.downloadUrl);
|
|
6240
|
+
if (!response.ok) throw new RemoteFileDownloadError(`Failed to download file: ${response.status} ${response.statusText}`, {
|
|
6241
|
+
statusCode: response.status,
|
|
6242
|
+
statusText: response.statusText,
|
|
6243
|
+
downloadUrl: this.downloadUrl,
|
|
6244
|
+
mountRelativePath: this.mountRelativePath,
|
|
6245
|
+
filename: this.filename,
|
|
6246
|
+
cause: /* @__PURE__ */ new Error(`HTTP ${response.status}: ${response.statusText}`)
|
|
6247
|
+
});
|
|
6248
|
+
return response.blob();
|
|
6249
|
+
}
|
|
6250
|
+
/**
|
|
6251
|
+
* Downloads and saves the file to the local filesystem.
|
|
6252
|
+
* Requires a Node.js runtime with file system support (not available in Cloudflare Workers/Edge).
|
|
5924
6253
|
*
|
|
6254
|
+
* @param path - Local path to save the file. If omitted, saves to the Composio temp directory using the filename from the mount path.
|
|
6255
|
+
* @returns The absolute path where the file was saved
|
|
6256
|
+
* @throws Error if file system is not supported or the save fails
|
|
5925
6257
|
*/
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
6258
|
+
async save(path) {
|
|
6259
|
+
if (!_platform.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.");
|
|
6260
|
+
const content = await this.buffer();
|
|
6261
|
+
const homeDir = _platform.platform.homedir();
|
|
6262
|
+
if (!homeDir) throw new Error("Cannot determine save location: home directory is not available");
|
|
6263
|
+
const savePath = path ?? _platform.platform.joinPath(homeDir, require_buffer.COMPOSIO_DIR, require_buffer.TEMP_FILES_DIRECTORY_NAME, this.filename);
|
|
6264
|
+
const dir = path != null ? getParentDir(savePath) : _platform.platform.joinPath(homeDir, require_buffer.COMPOSIO_DIR, require_buffer.TEMP_FILES_DIRECTORY_NAME);
|
|
6265
|
+
if (dir && !_platform.platform.existsSync(dir)) _platform.platform.mkdirSync(dir);
|
|
6266
|
+
_platform.platform.writeFileSync(savePath, content);
|
|
6267
|
+
return savePath;
|
|
6268
|
+
}
|
|
6269
|
+
};
|
|
6270
|
+
|
|
6271
|
+
//#endregion
|
|
6272
|
+
//#region src/utils/mime.ts
|
|
6273
|
+
/**
|
|
6274
|
+
* Maps MIME types to file extensions.
|
|
6275
|
+
* Used when deriving filenames from content-type headers (e.g. for URLs without path segments).
|
|
6276
|
+
*/
|
|
6277
|
+
function getExtensionFromMimeType(mimeType) {
|
|
6278
|
+
const mimeToExt = {
|
|
6279
|
+
"text/plain": "txt",
|
|
6280
|
+
"text/html": "html",
|
|
6281
|
+
"text/css": "css",
|
|
6282
|
+
"text/javascript": "js",
|
|
6283
|
+
"application/json": "json",
|
|
6284
|
+
"application/xml": "xml",
|
|
6285
|
+
"application/pdf": "pdf",
|
|
6286
|
+
"application/zip": "zip",
|
|
6287
|
+
"application/x-zip-compressed": "zip",
|
|
6288
|
+
"application/gzip": "gz",
|
|
6289
|
+
"application/octet-stream": "bin",
|
|
6290
|
+
"application/x-tar": "tar",
|
|
6291
|
+
"application/msword": "doc",
|
|
6292
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
6293
|
+
"application/vnd.ms-excel": "xls",
|
|
6294
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
6295
|
+
"application/vnd.ms-powerpoint": "ppt",
|
|
6296
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
|
|
6297
|
+
"image/jpeg": "jpg",
|
|
6298
|
+
"image/jpg": "jpg",
|
|
6299
|
+
"image/png": "png",
|
|
6300
|
+
"image/gif": "gif",
|
|
6301
|
+
"image/svg+xml": "svg",
|
|
6302
|
+
"image/webp": "webp",
|
|
6303
|
+
"image/bmp": "bmp",
|
|
6304
|
+
"image/tiff": "tiff",
|
|
6305
|
+
"audio/mpeg": "mp3",
|
|
6306
|
+
"audio/wav": "wav",
|
|
6307
|
+
"audio/ogg": "ogg",
|
|
6308
|
+
"video/mp4": "mp4",
|
|
6309
|
+
"video/mpeg": "mpeg",
|
|
6310
|
+
"video/quicktime": "mov",
|
|
6311
|
+
"video/x-msvideo": "avi",
|
|
6312
|
+
"video/webm": "webm"
|
|
5935
6313
|
};
|
|
6314
|
+
const cleanMimeType = mimeType.split(";")[0].toLowerCase().trim();
|
|
6315
|
+
if (mimeToExt[cleanMimeType]) return mimeToExt[cleanMimeType];
|
|
6316
|
+
const parts = cleanMimeType.split("/");
|
|
6317
|
+
if (parts.length === 2) {
|
|
6318
|
+
const subtype = parts[1].toLowerCase();
|
|
6319
|
+
if (subtype.includes("+")) {
|
|
6320
|
+
const plusParts = subtype.split("+");
|
|
6321
|
+
const prefix = plusParts[0];
|
|
6322
|
+
const suffix = plusParts[plusParts.length - 1];
|
|
6323
|
+
if ([
|
|
6324
|
+
"svg",
|
|
6325
|
+
"atom",
|
|
6326
|
+
"rss"
|
|
6327
|
+
].includes(prefix)) return prefix;
|
|
6328
|
+
if ([
|
|
6329
|
+
"json",
|
|
6330
|
+
"xml",
|
|
6331
|
+
"yaml",
|
|
6332
|
+
"zip",
|
|
6333
|
+
"gzip"
|
|
6334
|
+
].includes(suffix)) return suffix;
|
|
6335
|
+
return suffix;
|
|
6336
|
+
}
|
|
6337
|
+
return subtype || "txt";
|
|
6338
|
+
}
|
|
6339
|
+
return "bin";
|
|
6340
|
+
}
|
|
6341
|
+
|
|
6342
|
+
//#endregion
|
|
6343
|
+
//#region src/models/ToolRouterSessionFileMount.ts
|
|
6344
|
+
var ToolRouterSessionFilesMount = class {
|
|
6345
|
+
sessionId;
|
|
6346
|
+
client;
|
|
6347
|
+
constructor(client, sessionId) {
|
|
6348
|
+
this.client = client;
|
|
6349
|
+
this.sessionId = sessionId;
|
|
6350
|
+
require_Telemetry.telemetry.instrument(this, "ToolRouterSessionFiles");
|
|
6351
|
+
}
|
|
5936
6352
|
/**
|
|
6353
|
+
* Lists files and directories at the specified path on the session's file mount.
|
|
5937
6354
|
*
|
|
5938
|
-
*
|
|
5939
|
-
*
|
|
6355
|
+
* Use this to browse the virtual filesystem attached to the tool router session.
|
|
6356
|
+
* The path is relative to the mount root (e.g., `"/"` for root, `"/documents"` for a subdirectory).
|
|
6357
|
+
* Supports cursor-based pagination via `cursor` and `limit` options.
|
|
6358
|
+
*
|
|
6359
|
+
* @param options - Optional configuration for the list operation.
|
|
6360
|
+
* @param options.path - The directory path to list. Use `"/"` for the mount root.
|
|
6361
|
+
* @param options.mountId - The ID of the file mount to operate on. Defaults to `"files"` when omitted.
|
|
6362
|
+
* @param options.cursor - Pagination cursor from the previous response's nextCursor field.
|
|
6363
|
+
* @param options.limit - Maximum number of files to return per page (1-500).
|
|
6364
|
+
* @returns List of files with nextCursor for pagination.
|
|
5940
6365
|
*
|
|
5941
6366
|
* @example
|
|
5942
6367
|
* ```typescript
|
|
5943
|
-
* import { Composio } from '@composio/core';
|
|
5944
|
-
*
|
|
5945
|
-
* const composio = new Composio();
|
|
5946
6368
|
* const session = await composio.toolRouter.use('session_123');
|
|
6369
|
+
* const { items, nextCursor } = await session.files.list({ path: '/' });
|
|
6370
|
+
* ```
|
|
5947
6371
|
*
|
|
5948
|
-
*
|
|
5949
|
-
*
|
|
6372
|
+
* @example
|
|
6373
|
+
* ```typescript
|
|
6374
|
+
* // Paginated listing
|
|
6375
|
+
* let result = await session.files.list({ path: '/', limit: 10 });
|
|
6376
|
+
* while (result.nextCursor) {
|
|
6377
|
+
* result = await session.files.list({ path: '/', cursor: result.nextCursor, limit: 10 });
|
|
6378
|
+
* }
|
|
5950
6379
|
* ```
|
|
5951
6380
|
*/
|
|
5952
|
-
|
|
5953
|
-
const
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
6381
|
+
async list(options) {
|
|
6382
|
+
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 });
|
|
6384
|
+
const rawPath = listOptions.data.path;
|
|
6385
|
+
const mountRelativePrefix = rawPath === void 0 || rawPath === "" || rawPath === "/" ? void 0 : rawPath.startsWith("/") ? rawPath.slice(1) : rawPath;
|
|
6386
|
+
const response = await this.client.toolRouter.session.files.list(listOptions.data.mountId, {
|
|
6387
|
+
session_id: this.sessionId,
|
|
6388
|
+
mount_relative_prefix: mountRelativePrefix,
|
|
6389
|
+
cursor: listOptions.data.cursor,
|
|
6390
|
+
limit: listOptions.data.limit
|
|
6391
|
+
});
|
|
6392
|
+
const data = typeof response === "object" && "body" in response ? response.body : response;
|
|
6393
|
+
const parsed = FileListResponseSchema.safeParse(data);
|
|
6394
|
+
if (!parsed.success) throw new ValidationError("Failed to parse file list response", { cause: parsed.error });
|
|
6395
|
+
return parsed.data;
|
|
6396
|
+
}
|
|
6397
|
+
async normalizeUploadInput(input, options) {
|
|
6398
|
+
if (typeof input === "string") {
|
|
6399
|
+
if (input.startsWith("http://") || input.startsWith("https://")) {
|
|
6400
|
+
const response = await fetch(input);
|
|
6401
|
+
if (!response.ok) throw new Error(`Failed to fetch file from URL: ${response.statusText}`);
|
|
6402
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
6403
|
+
const mimeType = (response.headers.get("content-type") || "application/octet-stream").split(";")[0].trim();
|
|
6404
|
+
const segments = new URL(input).pathname.split("/").filter(Boolean);
|
|
6405
|
+
let filename$1 = segments.length > 0 ? segments[segments.length - 1] : "";
|
|
6406
|
+
if (!filename$1 || !filename$1.includes(".")) {
|
|
6407
|
+
const extension = getExtensionFromMimeType(mimeType);
|
|
6408
|
+
filename$1 = `${require_buffer.getRandomShortId()}.${extension}`;
|
|
6409
|
+
}
|
|
6410
|
+
return {
|
|
6411
|
+
fileToUpload: new File([arrayBuffer], filename$1, { type: mimeType }),
|
|
6412
|
+
remotePath: options.remotePath ?? filename$1,
|
|
6413
|
+
mimetype: mimeType
|
|
6414
|
+
};
|
|
6415
|
+
}
|
|
6416
|
+
const content = _platform.platform.readFileSync(input);
|
|
6417
|
+
const buffer$1 = content instanceof Uint8Array ? new Uint8Array(content) : new TextEncoder().encode(content);
|
|
6418
|
+
const filename = _platform.platform.basename(input);
|
|
6419
|
+
const mimetype$1 = options.mimetype ?? "application/octet-stream";
|
|
5963
6420
|
return {
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
name: item$1.name,
|
|
5968
|
-
logo: item$1.meta?.logo,
|
|
5969
|
-
isNoAuth: item$1.is_no_auth,
|
|
5970
|
-
connection: item$1.is_no_auth ? void 0 : {
|
|
5971
|
-
isActive: item$1.connected_account?.status === "ACTIVE",
|
|
5972
|
-
authConfig: item$1.connected_account && {
|
|
5973
|
-
id: item$1.connected_account?.auth_config.id,
|
|
5974
|
-
mode: item$1.connected_account?.auth_config.auth_scheme,
|
|
5975
|
-
isComposioManaged: item$1.connected_account?.auth_config.is_composio_managed
|
|
5976
|
-
},
|
|
5977
|
-
connectedAccount: item$1.connected_account ? {
|
|
5978
|
-
id: item$1.connected_account.id,
|
|
5979
|
-
status: item$1.connected_account.status
|
|
5980
|
-
} : void 0
|
|
5981
|
-
}
|
|
5982
|
-
}));
|
|
5983
|
-
}),
|
|
5984
|
-
nextCursor: result.next_cursor,
|
|
5985
|
-
totalPages: result.total_pages
|
|
6421
|
+
fileToUpload: new File([buffer$1], filename, { type: mimetype$1 }),
|
|
6422
|
+
remotePath: options.remotePath ?? filename,
|
|
6423
|
+
mimetype: mimetype$1
|
|
5986
6424
|
};
|
|
6425
|
+
}
|
|
6426
|
+
if (input instanceof File) return {
|
|
6427
|
+
fileToUpload: input,
|
|
6428
|
+
remotePath: options.remotePath ?? (input.name || `upload-${require_buffer.getRandomShortId()}.bin`),
|
|
6429
|
+
mimetype: input.type || "application/octet-stream"
|
|
5987
6430
|
};
|
|
5988
|
-
|
|
5989
|
-
|
|
6431
|
+
const buffer = input instanceof ArrayBuffer ? new Uint8Array(input) : input;
|
|
6432
|
+
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\" })");
|
|
6433
|
+
const mimetype = options.mimetype ?? "application/octet-stream";
|
|
6434
|
+
const ext = getExtensionFromMimeType(mimetype);
|
|
6435
|
+
const remotePath = options.remotePath ?? `upload-${require_buffer.getRandomShortId()}.${ext}`;
|
|
6436
|
+
return {
|
|
6437
|
+
fileToUpload: new File([buffer], remotePath, { type: mimetype }),
|
|
6438
|
+
remotePath,
|
|
6439
|
+
mimetype
|
|
6440
|
+
};
|
|
6441
|
+
}
|
|
5990
6442
|
/**
|
|
5991
|
-
*
|
|
5992
|
-
*
|
|
5993
|
-
*
|
|
6443
|
+
* Uploads a file to the session's file mount.
|
|
6444
|
+
*
|
|
6445
|
+
* Accepts a file path (local or URL), a native File object, or a raw buffer.
|
|
6446
|
+
* The file is stored in the virtual filesystem associated with the tool router session.
|
|
6447
|
+
*
|
|
6448
|
+
* @param input - File path (string), native File, or raw buffer (ArrayBuffer | Uint8Array).
|
|
6449
|
+
* @param options - Optional configuration. When passing a buffer, remotePath is required.
|
|
6450
|
+
* @returns Metadata about the uploaded file.
|
|
6451
|
+
*
|
|
6452
|
+
* @example
|
|
6453
|
+
* ```typescript
|
|
6454
|
+
* // From file path (local or URL)
|
|
6455
|
+
* await session.files.upload('/path/to/report.pdf');
|
|
6456
|
+
* await session.files.upload('https://example.com/file.pdf');
|
|
6457
|
+
* ```
|
|
6458
|
+
*
|
|
6459
|
+
* @example
|
|
6460
|
+
* ```typescript
|
|
6461
|
+
* // From native File (e.g. from input[type=file])
|
|
6462
|
+
* await session.files.upload(fileInput.files[0]);
|
|
6463
|
+
* ```
|
|
6464
|
+
*
|
|
6465
|
+
* @example
|
|
6466
|
+
* ```typescript
|
|
6467
|
+
* // From raw buffer
|
|
6468
|
+
* await session.files.upload(buffer, { remotePath: 'data.json', mimetype: 'application/json' });
|
|
6469
|
+
* ```
|
|
6470
|
+
*/
|
|
6471
|
+
async upload(input, options) {
|
|
6472
|
+
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 });
|
|
6474
|
+
const { fileToUpload, remotePath, mimetype } = await this.normalizeUploadInput(input, uploadOptions.data);
|
|
6475
|
+
const createUploadURLResponse = await this.client.toolRouter.session.files.createUploadURL(uploadOptions.data.mountId, {
|
|
6476
|
+
session_id: this.sessionId,
|
|
6477
|
+
mount_relative_path: remotePath,
|
|
6478
|
+
mimetype
|
|
6479
|
+
});
|
|
6480
|
+
const uploadURLData = typeof createUploadURLResponse === "object" && "body" in createUploadURLResponse ? createUploadURLResponse.body : createUploadURLResponse;
|
|
6481
|
+
const uploadResponse = await fetch(uploadURLData.upload_url, {
|
|
6482
|
+
method: "PUT",
|
|
6483
|
+
body: await fileToUpload.arrayBuffer(),
|
|
6484
|
+
headers: { "Content-Type": mimetype }
|
|
6485
|
+
});
|
|
6486
|
+
if (!uploadResponse.ok) throw new Error(`Failed to upload file: ${uploadResponse.statusText}`);
|
|
6487
|
+
const createDownloadURLResponse = await this.client.toolRouter.session.files.createDownloadURL(uploadOptions.data.mountId, {
|
|
6488
|
+
session_id: this.sessionId,
|
|
6489
|
+
mount_relative_path: uploadURLData.mount_relative_path
|
|
6490
|
+
});
|
|
6491
|
+
const downloadData = typeof createDownloadURLResponse === "object" && "body" in createDownloadURLResponse ? createDownloadURLResponse.body : createDownloadURLResponse;
|
|
6492
|
+
const parsed = RemoteFileDataSchema.safeParse(downloadData);
|
|
6493
|
+
if (!parsed.success) throw new ValidationError("Failed to parse remote file properties", { cause: parsed.error });
|
|
6494
|
+
return new RemoteFile(parsed.data);
|
|
6495
|
+
}
|
|
6496
|
+
/**
|
|
6497
|
+
* Downloads a file from the session's file mount to the local filesystem.
|
|
6498
|
+
*
|
|
6499
|
+
* Retrieves a file stored in the session's virtual filesystem (e.g., one produced
|
|
6500
|
+
* by a tool or previously uploaded) and saves it to the specified local path.
|
|
6501
|
+
*
|
|
6502
|
+
* @param filePath - The path of the file on the mount to download, or the local path where the file should be saved (implementation-specific).
|
|
6503
|
+
* @param options - Optional configuration for the download.
|
|
6504
|
+
* @param options.mountId - The ID of the file mount to download from. Defaults to `"files"` when omitted.
|
|
6505
|
+
* @returns The downloaded file data or path (implementation-specific).
|
|
6506
|
+
*
|
|
6507
|
+
* @example
|
|
6508
|
+
* ```typescript
|
|
6509
|
+
* const session = await composio.toolRouter.use('session_123');
|
|
6510
|
+
* const result = await session.files.download('/output/report.pdf');
|
|
6511
|
+
* ```
|
|
6512
|
+
*
|
|
6513
|
+
* @example
|
|
6514
|
+
* ```typescript
|
|
6515
|
+
* // Download from a custom mount
|
|
6516
|
+
* await session.files.download('/exports/data.json', {
|
|
6517
|
+
* mountId: 'custom-mount',
|
|
6518
|
+
* });
|
|
6519
|
+
* ```
|
|
6520
|
+
*/
|
|
6521
|
+
async download(filePath, options) {
|
|
6522
|
+
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 });
|
|
6524
|
+
const createDownloadURLResponse = await this.client.toolRouter.session.files.createDownloadURL(downloadOptions.data.mountId, {
|
|
6525
|
+
session_id: this.sessionId,
|
|
6526
|
+
mount_relative_path: filePath
|
|
6527
|
+
});
|
|
6528
|
+
const downloadURLData = typeof createDownloadURLResponse === "object" && "body" in createDownloadURLResponse ? createDownloadURLResponse.body : createDownloadURLResponse;
|
|
6529
|
+
const parsed = RemoteFileDataSchema.safeParse(downloadURLData);
|
|
6530
|
+
if (!parsed.success) throw new ValidationError("Failed to parse remote file properties", { cause: parsed.error });
|
|
6531
|
+
return new RemoteFile(parsed.data);
|
|
6532
|
+
}
|
|
6533
|
+
/**
|
|
6534
|
+
* Deletes a file or directory at the specified path on the session's file mount.
|
|
6535
|
+
*
|
|
6536
|
+
* Removes the file or directory from the virtual filesystem. Use with caution:
|
|
6537
|
+
* deletion is typically irreversible. Ensure the path exists and is intended for removal.
|
|
6538
|
+
*
|
|
6539
|
+
* @param remotePath - The path of the file or directory to delete on the mount.
|
|
6540
|
+
* @param options - Optional configuration for the delete operation.
|
|
6541
|
+
* @param options.mountId - The ID of the file mount to operate on. Defaults to `"files"` when omitted.
|
|
6542
|
+
* @returns Confirmation of deletion (implementation-specific).
|
|
6543
|
+
*
|
|
6544
|
+
* @example
|
|
6545
|
+
* ```typescript
|
|
6546
|
+
* const session = await composio.toolRouter.use('session_123');
|
|
6547
|
+
* await session.files.delete('/temp/cache.json');
|
|
6548
|
+
* ```
|
|
5994
6549
|
*
|
|
5995
|
-
* @
|
|
5996
|
-
*
|
|
6550
|
+
* @example
|
|
6551
|
+
* ```typescript
|
|
6552
|
+
* // Delete from a custom mount
|
|
6553
|
+
* await session.files.delete('/old-backup', {
|
|
6554
|
+
* mountId: 'custom-mount',
|
|
6555
|
+
* });
|
|
6556
|
+
* ```
|
|
6557
|
+
*
|
|
6558
|
+
* @warning This operation is destructive. Deleted files cannot be recovered.
|
|
5997
6559
|
*/
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6560
|
+
async delete(remotePath, options) {
|
|
6561
|
+
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 });
|
|
6563
|
+
const deleteResponse = await this.client.toolRouter.session.files.delete(deleteOptions.data.mountId, {
|
|
6564
|
+
session_id: this.sessionId,
|
|
6565
|
+
mount_relative_path: remotePath
|
|
6566
|
+
});
|
|
6567
|
+
const fileDeleteResponse = FileDeleteResponseSchema.safeParse(deleteResponse);
|
|
6568
|
+
if (!fileDeleteResponse.success) throw new ValidationError("Failed to parse file delete response", { cause: fileDeleteResponse.error });
|
|
6569
|
+
return fileDeleteResponse.data;
|
|
6570
|
+
}
|
|
6571
|
+
};
|
|
6572
|
+
|
|
6573
|
+
//#endregion
|
|
6574
|
+
//#region src/models/ToolRouterSession.ts
|
|
6575
|
+
var ToolRouterSession = class {
|
|
6576
|
+
sessionId;
|
|
6577
|
+
mcp;
|
|
6578
|
+
files;
|
|
6579
|
+
constructor(client, config, sessionId, mcp, experimental) {
|
|
6580
|
+
this.client = client;
|
|
6581
|
+
this.config = config;
|
|
6582
|
+
this.experimental = experimental;
|
|
6583
|
+
this.sessionId = sessionId;
|
|
6584
|
+
this.mcp = mcp;
|
|
6585
|
+
this.files = new ToolRouterSessionFilesMount(client, sessionId);
|
|
6586
|
+
require_Telemetry.telemetry.instrument(this, "ToolRouterSession");
|
|
6587
|
+
}
|
|
6588
|
+
/**
|
|
6589
|
+
* Get the tools available in the session, formatted for your AI framework.
|
|
6590
|
+
* Requires a provider to be configured in the Composio constructor.
|
|
6591
|
+
*/
|
|
6592
|
+
async tools(modifiers) {
|
|
6593
|
+
const ToolsModel = new Tools(this.client, this.config);
|
|
6594
|
+
const tools = await ToolsModel.getRawToolRouterMetaTools(this.sessionId, modifiers?.modifySchema ? { modifySchema: modifiers.modifySchema } : void 0);
|
|
6595
|
+
return ToolsModel.wrapToolsForToolRouter(this.sessionId, tools, modifiers);
|
|
6596
|
+
}
|
|
6597
|
+
/**
|
|
6598
|
+
* Initiate an authorization flow for a toolkit.
|
|
6599
|
+
* Returns a ConnectionRequest with a redirect URL for the user.
|
|
6600
|
+
*/
|
|
6601
|
+
async authorize(toolkit, options) {
|
|
6602
|
+
const response = await this.client.toolRouter.session.link(this.sessionId, {
|
|
6603
|
+
...options?.callbackUrl ? { callback_url: options.callbackUrl } : {},
|
|
6604
|
+
toolkit
|
|
6605
|
+
});
|
|
6606
|
+
return createConnectionRequest(this.client, response.connected_account_id, ConnectedAccountStatuses.INITIATED, response.redirect_url);
|
|
6607
|
+
}
|
|
6608
|
+
/**
|
|
6609
|
+
* Query the connection state of toolkits in the session.
|
|
6610
|
+
* Supports pagination and filtering by toolkit slugs.
|
|
6611
|
+
*/
|
|
6612
|
+
async toolkits(options) {
|
|
6613
|
+
const toolkitOptions = ToolRouterToolkitsOptionsSchema.safeParse(options ?? {});
|
|
6614
|
+
if (!toolkitOptions.success) throw new ValidationError("Failed to parse toolkits options", { cause: toolkitOptions.error });
|
|
6615
|
+
const result = await this.client.toolRouter.session.toolkits(this.sessionId, {
|
|
6616
|
+
cursor: toolkitOptions.data.nextCursor,
|
|
6617
|
+
limit: toolkitOptions.data.limit,
|
|
6618
|
+
toolkits: toolkitOptions.data.toolkits,
|
|
6619
|
+
is_connected: toolkitOptions.data.isConnected,
|
|
6620
|
+
search: toolkitOptions.data.search
|
|
6621
|
+
});
|
|
6622
|
+
return {
|
|
6623
|
+
items: result.items.map((item) => {
|
|
6624
|
+
return transform(item).with(ToolkitConnectionStateSchema).using((item$1) => ({
|
|
6625
|
+
slug: item$1.slug,
|
|
6626
|
+
name: item$1.name,
|
|
6627
|
+
logo: item$1.meta?.logo,
|
|
6628
|
+
isNoAuth: item$1.is_no_auth,
|
|
6629
|
+
connection: item$1.is_no_auth ? void 0 : {
|
|
6630
|
+
isActive: item$1.connected_account?.status === "ACTIVE",
|
|
6631
|
+
authConfig: item$1.connected_account && {
|
|
6632
|
+
id: item$1.connected_account?.auth_config.id,
|
|
6633
|
+
mode: item$1.connected_account?.auth_config.auth_scheme,
|
|
6634
|
+
isComposioManaged: item$1.connected_account?.auth_config.is_composio_managed
|
|
6635
|
+
},
|
|
6636
|
+
connectedAccount: item$1.connected_account ? {
|
|
6637
|
+
id: item$1.connected_account.id,
|
|
6638
|
+
status: item$1.connected_account.status
|
|
6639
|
+
} : void 0
|
|
6640
|
+
}
|
|
6641
|
+
}));
|
|
6642
|
+
}),
|
|
6643
|
+
nextCursor: result.next_cursor ?? void 0,
|
|
6644
|
+
totalPages: result.total_pages
|
|
6003
6645
|
};
|
|
6004
|
-
}
|
|
6646
|
+
}
|
|
6005
6647
|
/**
|
|
6006
|
-
*
|
|
6007
|
-
*
|
|
6008
|
-
*
|
|
6009
|
-
* @
|
|
6648
|
+
* Search for tools by semantic use case.
|
|
6649
|
+
* Returns relevant tools for the given query with schemas and guidance.
|
|
6650
|
+
*
|
|
6651
|
+
* @param params - Search parameters
|
|
6652
|
+
* @param params.query - Semantic use-case query (e.g. "send emails", "create GitHub issues")
|
|
6653
|
+
* @param params.toolkits - Optional toolkit slugs to filter by
|
|
6654
|
+
* @returns Search results with matching tools and schemas
|
|
6655
|
+
*
|
|
6656
|
+
* @example
|
|
6657
|
+
* ```typescript
|
|
6658
|
+
* const session = await composio.toolRouter.use('session_123');
|
|
6659
|
+
* const results = await session.search({
|
|
6660
|
+
* query: 'send emails and notify Slack',
|
|
6661
|
+
* toolkits: ['gmail', 'slack'],
|
|
6662
|
+
* });
|
|
6663
|
+
* ```
|
|
6010
6664
|
*/
|
|
6011
|
-
|
|
6665
|
+
async search(params) {
|
|
6666
|
+
const transformed = transformSearchResponse(await this.client.toolRouter.session.search(this.sessionId, {
|
|
6667
|
+
queries: [{ use_case: params.query }],
|
|
6668
|
+
...params.toolkits?.length ? { toolkits: params.toolkits } : {}
|
|
6669
|
+
}));
|
|
6670
|
+
return ToolRouterSessionSearchResponseSchema.parse(transformed);
|
|
6671
|
+
}
|
|
6672
|
+
/**
|
|
6673
|
+
* Execute a tool within the session.
|
|
6674
|
+
*
|
|
6675
|
+
* @param toolSlug - The tool slug to execute (e.g. "GMAIL_SEND_EMAIL")
|
|
6676
|
+
* @param arguments_ - Optional tool arguments. Defaults to empty object if omitted.
|
|
6677
|
+
* @returns The tool execution result
|
|
6678
|
+
*
|
|
6679
|
+
* @example
|
|
6680
|
+
* ```typescript
|
|
6681
|
+
* const session = await composio.toolRouter.use('session_123');
|
|
6682
|
+
* const result = await session.execute('GMAIL_SEND_EMAIL', {
|
|
6683
|
+
* to: 'user@example.com',
|
|
6684
|
+
* subject: 'Hello',
|
|
6685
|
+
* body: 'Hi!',
|
|
6686
|
+
* });
|
|
6687
|
+
* ```
|
|
6688
|
+
*
|
|
6689
|
+
* @example
|
|
6690
|
+
* ```typescript
|
|
6691
|
+
* // Execute with no arguments
|
|
6692
|
+
* const result = await session.execute('HACKERNEWS_GET_USER');
|
|
6693
|
+
* ```
|
|
6694
|
+
*/
|
|
6695
|
+
async execute(toolSlug, arguments_) {
|
|
6696
|
+
const transformed = transformExecuteResponse(await this.client.toolRouter.session.execute(this.sessionId, {
|
|
6697
|
+
tool_slug: toolSlug,
|
|
6698
|
+
arguments: arguments_ ?? {}
|
|
6699
|
+
}));
|
|
6700
|
+
return ToolRouterSessionExecuteResponseSchema.parse(transformed);
|
|
6701
|
+
}
|
|
6702
|
+
};
|
|
6703
|
+
|
|
6704
|
+
//#endregion
|
|
6705
|
+
//#region src/models/ToolRouter.ts
|
|
6706
|
+
var ToolRouter = class {
|
|
6707
|
+
constructor(client, config) {
|
|
6708
|
+
this.client = client;
|
|
6709
|
+
this.config = config;
|
|
6710
|
+
require_Telemetry.telemetry.instrument(this, "ToolRouter");
|
|
6711
|
+
}
|
|
6712
|
+
createMCPServerConfig({ type, url }) {
|
|
6012
6713
|
return {
|
|
6013
6714
|
type,
|
|
6014
6715
|
url,
|
|
6015
|
-
headers: { ...this.config?.apiKey ? { "x-api-key": this.config
|
|
6716
|
+
headers: { ...this.config?.apiKey ? { "x-api-key": this.config.apiKey } : {} }
|
|
6016
6717
|
};
|
|
6017
|
-
}
|
|
6718
|
+
}
|
|
6018
6719
|
/**
|
|
6019
6720
|
* Creates a new tool router session for a user.
|
|
6020
6721
|
*
|
|
6021
6722
|
* @param userId {string} The user id to create the session for
|
|
6022
6723
|
* @param config {ToolRouterCreateSessionConfig} The config for the tool router session
|
|
6023
|
-
* @returns {Promise<
|
|
6724
|
+
* @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session
|
|
6024
6725
|
*
|
|
6025
6726
|
* @example
|
|
6026
6727
|
* ```typescript
|
|
@@ -6065,19 +6766,12 @@ var ToolRouter = class {
|
|
|
6065
6766
|
};
|
|
6066
6767
|
const session = await this.client.toolRouter.session.create(payload);
|
|
6067
6768
|
const experimental = session.experimental ? { assistivePrompt: session.experimental.assistive_prompt } : void 0;
|
|
6068
|
-
return
|
|
6069
|
-
sessionId: session.session_id,
|
|
6070
|
-
mcp: this.createMCPServerConfig(session.mcp),
|
|
6071
|
-
tools: this.createToolsFn(session.session_id),
|
|
6072
|
-
authorize: this.createAuthorizeFn(session.session_id),
|
|
6073
|
-
toolkits: this.createToolkitsFn(session.session_id),
|
|
6074
|
-
experimental
|
|
6075
|
-
};
|
|
6769
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), experimental);
|
|
6076
6770
|
}
|
|
6077
6771
|
/**
|
|
6078
6772
|
* Use an existing session
|
|
6079
6773
|
* @param id {string} The id of the session to use
|
|
6080
|
-
* @returns {Promise<
|
|
6774
|
+
* @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session
|
|
6081
6775
|
*
|
|
6082
6776
|
* @example
|
|
6083
6777
|
* ```typescript
|
|
@@ -6093,13 +6787,7 @@ var ToolRouter = class {
|
|
|
6093
6787
|
*/
|
|
6094
6788
|
async use(id) {
|
|
6095
6789
|
const session = await this.client.toolRouter.session.retrieve(id);
|
|
6096
|
-
return
|
|
6097
|
-
sessionId: session.session_id,
|
|
6098
|
-
mcp: this.createMCPServerConfig(session.mcp),
|
|
6099
|
-
tools: this.createToolsFn(session.session_id),
|
|
6100
|
-
authorize: this.createAuthorizeFn(session.session_id),
|
|
6101
|
-
toolkits: this.createToolkitsFn(session.session_id)
|
|
6102
|
-
};
|
|
6790
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp));
|
|
6103
6791
|
}
|
|
6104
6792
|
};
|
|
6105
6793
|
|
|
@@ -6149,7 +6837,7 @@ var Composio = class Composio {
|
|
|
6149
6837
|
*
|
|
6150
6838
|
* @param userId {string} The user id to create the session for
|
|
6151
6839
|
* @param config {ToolRouterConfig} The config for the tool router session
|
|
6152
|
-
* @returns {Promise<
|
|
6840
|
+
* @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session
|
|
6153
6841
|
*
|
|
6154
6842
|
* @example
|
|
6155
6843
|
* ```typescript
|
|
@@ -6172,7 +6860,7 @@ var Composio = class Composio {
|
|
|
6172
6860
|
* Use an existing tool router session
|
|
6173
6861
|
*
|
|
6174
6862
|
* @param id {string} The id of the session to use
|
|
6175
|
-
* @returns {Promise<
|
|
6863
|
+
* @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session
|
|
6176
6864
|
*/
|
|
6177
6865
|
use;
|
|
6178
6866
|
/**
|
|
@@ -6980,6 +7668,8 @@ exports.CustomCreateResponseSchema = CustomCreateResponseSchema;
|
|
|
6980
7668
|
exports.CustomOauth1ConnectionDataSchema = CustomOauth1ConnectionDataSchema;
|
|
6981
7669
|
exports.CustomOauth2ConnectionDataSchema = CustomOauth2ConnectionDataSchema;
|
|
6982
7670
|
exports.DefaultCreateConnectedAccountParamsSchema = DefaultCreateConnectedAccountParamsSchema;
|
|
7671
|
+
exports.FileDeleteResponseSchema = FileDeleteResponseSchema;
|
|
7672
|
+
exports.FileListResponseSchema = FileListResponseSchema;
|
|
6983
7673
|
exports.GenerateURLParamsSchema = GenerateURLParamsSchema;
|
|
6984
7674
|
exports.GenerateURLResponseSchema = GenerateURLResponseSchema;
|
|
6985
7675
|
exports.IncomingTriggerPayloadSchema = IncomingTriggerPayloadSchema;
|
|
@@ -7018,6 +7708,10 @@ exports.Oauth2InitiatedConnectionDataSchema = Oauth2InitiatedConnectionDataSchem
|
|
|
7018
7708
|
exports.Oauth2InitiatingConnectionDataSchema = Oauth2InitiatingConnectionDataSchema;
|
|
7019
7709
|
exports.OpenAIProvider = OpenAIProvider;
|
|
7020
7710
|
exports.RedirectableAuthSchemeSchema = RedirectableAuthSchemeSchema;
|
|
7711
|
+
exports.RemoteFile = RemoteFile;
|
|
7712
|
+
exports.RemoteFileDataSchema = RemoteFileDataSchema;
|
|
7713
|
+
exports.RemoteFileDownloadError = RemoteFileDownloadError;
|
|
7714
|
+
exports.RemoteFileErrorCodes = RemoteFileErrorCodes;
|
|
7021
7715
|
exports.SDKErrorCodes = SDKErrorCodes;
|
|
7022
7716
|
exports.SingleConnectedAccountDetailedResponseSchema = SingleConnectedAccountDetailedResponseSchema;
|
|
7023
7717
|
exports.ToolErrorCodes = ToolErrorCodes;
|
|
@@ -7036,6 +7730,13 @@ exports.ToolRouterConfigToolsSchema = ToolRouterConfigToolsSchema;
|
|
|
7036
7730
|
exports.ToolRouterCreateSessionConfigSchema = ToolRouterCreateSessionConfigSchema;
|
|
7037
7731
|
exports.ToolRouterMCPServerConfigSchema = ToolRouterMCPServerConfigSchema;
|
|
7038
7732
|
exports.ToolRouterManageConnectionsConfigSchema = ToolRouterManageConnectionsConfigSchema;
|
|
7733
|
+
exports.ToolRouterSession = ToolRouterSession;
|
|
7734
|
+
exports.ToolRouterSessionExecuteResponseSchema = ToolRouterSessionExecuteResponseSchema;
|
|
7735
|
+
exports.ToolRouterSessionFilesMountDeleteOptionsSchema = ToolRouterSessionFilesMountDeleteOptionsSchema;
|
|
7736
|
+
exports.ToolRouterSessionFilesMountDownloadOptionsSchema = ToolRouterSessionFilesMountDownloadOptionsSchema;
|
|
7737
|
+
exports.ToolRouterSessionFilesMountListOptionsSchema = ToolRouterSessionFilesMountListOptionsSchema;
|
|
7738
|
+
exports.ToolRouterSessionFilesMountUploadOptionsSchema = ToolRouterSessionFilesMountUploadOptionsSchema;
|
|
7739
|
+
exports.ToolRouterSessionSearchResponseSchema = ToolRouterSessionSearchResponseSchema;
|
|
7039
7740
|
exports.ToolRouterTagsEnableDisableSchema = ToolRouterTagsEnableDisableSchema;
|
|
7040
7741
|
exports.ToolRouterTagsParamSchema = ToolRouterTagsParamSchema;
|
|
7041
7742
|
exports.ToolRouterToolkitsDisabledConfigSchema = ToolRouterToolkitsDisabledConfigSchema;
|
|
@@ -7097,6 +7798,7 @@ Object.defineProperty(exports, 'constants', {
|
|
|
7097
7798
|
}
|
|
7098
7799
|
});
|
|
7099
7800
|
exports.createConnectionRequest = createConnectionRequest;
|
|
7801
|
+
exports.getExtensionFromMimeType = getExtensionFromMimeType;
|
|
7100
7802
|
exports.handleToolExecutionError = handleToolExecutionError;
|
|
7101
7803
|
exports.jsonSchemaToZodSchema = jsonSchemaToZodSchema;
|
|
7102
7804
|
exports.logger = require_buffer.logger_default;
|