@composio/core 0.6.11 → 0.7.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/README.md +1 -1
- package/dist/{CustomTool-VQMc17af.d.mts → CustomTool-Ba10IhPz.d.mts} +1 -1
- package/dist/{CustomTool-D8cxWvi9.mjs → CustomTool-CVwF_isu.mjs} +1 -1
- package/dist/{CustomTool-Cywkgg64.cjs → CustomTool-DnCSEC6t.cjs} +1 -1
- package/dist/{CustomTool-B1b2MXbO.d.cts → CustomTool-nBE0dlz6.d.cts} +1 -1
- package/dist/{FileModifierErrors-DuKpNYju.cjs → FileModifierErrors-BYJBHiay.cjs} +57 -1
- package/dist/{FileModifierErrors-LQwvd6pa.mjs → FileModifierErrors-C7z16Dfi.mjs} +46 -2
- package/dist/{Telemetry-JZNofztq.cjs → Telemetry-Dm-0sewu.cjs} +1 -1
- package/dist/{Telemetry-BJ2KYlDT.mjs → Telemetry-kgWlkavX.mjs} +1 -1
- package/dist/{composio-ruMDVx1b.d.cts → composio-BzzHNwFB.d.cts} +99 -44
- package/dist/{composio-D8u53qsy.d.mts → composio-CHcG9NOJ.d.mts} +99 -44
- package/dist/{customTool.types-9jJUADW-.d.cts → customTool.types-BJQtw3IG.d.cts} +1 -1
- package/dist/{customTool.types-C6-M75bi.d.mts → customTool.types-qSSvYChT.d.mts} +1 -1
- package/dist/experimental/index.cjs +2 -2
- package/dist/experimental/index.d.cts +2 -2
- package/dist/experimental/index.d.mts +3 -3
- package/dist/experimental/index.mjs +2 -2
- package/dist/{fileUtils.node-mlBa5nwX.mjs → fileUtils.node-Dq7ebZPC.mjs} +177 -12
- package/dist/{fileUtils.node-DsDsZfEl.cjs → fileUtils.node-DtnSRMWa.cjs} +177 -12
- package/dist/index.cjs +132 -17
- package/dist/index.d.cts +26 -5
- package/dist/index.d.mts +26 -5
- package/dist/index.mjs +131 -18
- package/dist/models/Files.node.cjs +10 -9
- package/dist/models/Files.node.d.cts +3 -2
- package/dist/models/Files.node.d.mts +3 -2
- package/dist/models/Files.node.mjs +10 -9
- package/dist/platform/node.cjs +6 -0
- package/dist/platform/node.d.cts +1 -1
- package/dist/platform/node.d.mts +1 -1
- package/dist/platform/node.mjs +6 -0
- package/dist/platform/workerd.cjs +6 -0
- package/dist/platform/workerd.d.cts +1 -1
- package/dist/platform/workerd.d.mts +1 -1
- package/dist/platform/workerd.mjs +6 -0
- package/dist/{tool.types-C5DMrBdm.d.cts → tool.types-4f4Ktd2s.d.cts} +23 -6
- package/dist/{tool.types-BGrE7Vqc.d.mts → tool.types-DJxP_6-g.d.mts} +23 -6
- package/dist/{types-WkBTUiQh.d.mts → types-BvGecO9n.d.mts} +3 -3
- package/dist/{types-DiL6FAZi.d.cts → types-HpJQ8K9l.d.mts} +10 -0
- package/dist/{types-DZaf5VcY.d.cts → types-W8Zn17SC.d.cts} +3 -3
- package/dist/{types-CXR6l5Sj.d.mts → types-pDNm1lYs.d.cts} +10 -0
- package/dist/utils/config-defaults/ConfigDefaults.node.cjs +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +4 -4
- package/dist/utils/config-defaults/ConfigDefaults.node.mjs +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +4 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.cjs +21 -17
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +2 -2
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +2 -2
- package/dist/utils/modifiers/FileToolModifier.node.mjs +21 -17
- package/dist/utils/modifiers/FileToolModifier.workerd.cjs +3 -3
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +2 -2
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +2 -2
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +3 -3
- 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 +1 -1
- package/src/platform/node.ts +8 -0
- package/src/platform/types.ts +12 -0
- package/src/platform/workerd.ts +12 -0
- /package/dist/{FileToolModifier.utils.neutral-BcIR-cVE.mjs → FileToolModifier.utils.neutral-B7P7wn-b.mjs} +0 -0
- /package/dist/{FileToolModifier.utils.neutral-BdMpiyie.cjs → FileToolModifier.utils.neutral-Dfwqgimk.cjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as ComposioSensitiveFilePathBlockedError, c as logger_default, i as ComposioFileUploadPathNotAllowedError, l as COMPOSIO_DIR, m as TEMP_FILES_DIRECTORY_NAME, t as ComposioFileNotFoundError } from "./FileModifierErrors-C7z16Dfi.mjs";
|
|
2
2
|
import { i as getRandomShortId, n as base64ToUint8Array, r as uint8ArrayToBase64 } from "./buffer-yOtEsT4J.mjs";
|
|
3
3
|
import { platform } from "#platform";
|
|
4
4
|
import fs from "node:fs";
|
|
@@ -63,6 +63,151 @@ function assertSafeFileUploadPath(filePath, options) {
|
|
|
63
63
|
} });
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/utils/uploadDirAllowlist.node.ts
|
|
68
|
+
/**
|
|
69
|
+
* Allowlist for automatic file upload during tool execution.
|
|
70
|
+
*
|
|
71
|
+
* This is only consulted when `dangerouslyAllowAutoUploadDownloadFiles` is enabled.
|
|
72
|
+
* Manual `composio.files.upload()` calls are not subject to the allowlist.
|
|
73
|
+
*
|
|
74
|
+
* - A local path is accepted iff its real (symlink-resolved, absolute) path is
|
|
75
|
+
* inside one of the allowed directories on a path-component boundary.
|
|
76
|
+
* `/tmp/foo` allows `/tmp/foo/bar` but NOT `/tmp/foo-bar`.
|
|
77
|
+
* - URLs (`http(s)://…`) and `File`/`Blob` values never hit this check.
|
|
78
|
+
* - User-provided `fileUploadDirs` fully replaces the default `[~/.composio/temp]`.
|
|
79
|
+
* - On Windows, path comparisons are case-insensitive.
|
|
80
|
+
*/
|
|
81
|
+
function normalizeForCompare(p) {
|
|
82
|
+
return process.platform === "win32" ? p.toLowerCase() : p;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* True if `child` is equal to `parent` or nested inside it on a component
|
|
86
|
+
* boundary. Assumes both paths are absolute and normalized.
|
|
87
|
+
*/
|
|
88
|
+
function isInsideDir(child, parent) {
|
|
89
|
+
const a = normalizeForCompare(child);
|
|
90
|
+
const b = normalizeForCompare(parent);
|
|
91
|
+
if (a === b) return true;
|
|
92
|
+
const sep = path.sep;
|
|
93
|
+
const bWithSep = b.endsWith(sep) ? b : b + sep;
|
|
94
|
+
return a.startsWith(bWithSep);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Returns the real (symlink-resolved) absolute path when the target exists,
|
|
98
|
+
* else `null`. Mirrors the semantics of the sensitive-path util.
|
|
99
|
+
*/
|
|
100
|
+
function tryRealpath(absPath) {
|
|
101
|
+
try {
|
|
102
|
+
if (fs.existsSync(absPath)) return fs.realpathSync(absPath);
|
|
103
|
+
} catch {}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
function formatAllowlist(dirs) {
|
|
107
|
+
if (dirs.length === 0) return " (none configured — all local paths are blocked)";
|
|
108
|
+
return dirs.map((d) => ` - ${d}`).join("\n");
|
|
109
|
+
}
|
|
110
|
+
function buildHelpFooter(allowlist) {
|
|
111
|
+
return [
|
|
112
|
+
"",
|
|
113
|
+
"Allowed upload directories (fileUploadDirs):",
|
|
114
|
+
formatAllowlist(allowlist),
|
|
115
|
+
"",
|
|
116
|
+
"Fix one of the following:",
|
|
117
|
+
"",
|
|
118
|
+
" 1. Recommended — move the file under an allowed directory, or add your",
|
|
119
|
+
" directory to the allowlist:",
|
|
120
|
+
" new Composio({",
|
|
121
|
+
" fileUploadDirs: ['/abs/path/to/uploads', '~/.composio/temp'],",
|
|
122
|
+
" })",
|
|
123
|
+
" Note: user-provided `fileUploadDirs` REPLACES the default",
|
|
124
|
+
" `~/.composio/temp`. Include it explicitly if you want staged uploads",
|
|
125
|
+
" to keep working.",
|
|
126
|
+
"",
|
|
127
|
+
" 2. Pass the file by URL or as a File/Blob object instead of a filesystem",
|
|
128
|
+
" path. URLs and File objects are never path-checked.",
|
|
129
|
+
"",
|
|
130
|
+
" 3. (Dangerous) Bypass the allowlist entirely by opting into automatic",
|
|
131
|
+
" file upload/download from any readable path:",
|
|
132
|
+
" new Composio({ dangerouslyAllowAutoUploadDownloadFiles: true })",
|
|
133
|
+
" WARNING: This lets a prompt-injected or misbehaving tool read ANY",
|
|
134
|
+
" file the process can access. Only enable it in trusted, sandboxed",
|
|
135
|
+
" environments. The built-in sensitive-path denylist (.ssh, .aws,",
|
|
136
|
+
" .env, private SSH keys, etc.) still applies unless you also set",
|
|
137
|
+
" `sensitiveFileUploadProtection: false`."
|
|
138
|
+
].join("\n");
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* @throws {ComposioFileNotFoundError} when `filePath` does not exist on disk.
|
|
142
|
+
* @throws {ComposioFileUploadPathNotAllowedError} when the resolved path is
|
|
143
|
+
* outside every entry of `allowlist`.
|
|
144
|
+
*/
|
|
145
|
+
function assertPathInsideUploadDirs(filePath, allowlist) {
|
|
146
|
+
const attempted = filePath;
|
|
147
|
+
const abs = path.resolve(filePath);
|
|
148
|
+
const real = tryRealpath(abs);
|
|
149
|
+
if (!real) {
|
|
150
|
+
const cwd = process.cwd();
|
|
151
|
+
const parent = path.dirname(abs);
|
|
152
|
+
const parentExists = (() => {
|
|
153
|
+
try {
|
|
154
|
+
return fs.existsSync(parent);
|
|
155
|
+
} catch {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
})();
|
|
159
|
+
throw new ComposioFileNotFoundError([
|
|
160
|
+
`Refusing to auto-upload "${attempted}": the file does not exist on disk.`,
|
|
161
|
+
"",
|
|
162
|
+
`Path attempted: ${attempted}`,
|
|
163
|
+
`Resolved to: ${abs}`,
|
|
164
|
+
`Process cwd: ${cwd}`,
|
|
165
|
+
`Parent exists: ${parentExists ? "yes (" + parent + ")" : "no (" + parent + ")"}`,
|
|
166
|
+
"",
|
|
167
|
+
"Common causes:",
|
|
168
|
+
" - Typo in the filename passed to the tool.",
|
|
169
|
+
" - Relative path resolved against the wrong working directory",
|
|
170
|
+
" (relative paths use process.cwd() at the moment of upload).",
|
|
171
|
+
" - File was deleted between the tool being called and the upload starting.",
|
|
172
|
+
"",
|
|
173
|
+
buildHelpFooter(allowlist)
|
|
174
|
+
].join("\n"), { meta: {
|
|
175
|
+
attempted,
|
|
176
|
+
resolved: abs,
|
|
177
|
+
cwd,
|
|
178
|
+
allowlist
|
|
179
|
+
} });
|
|
180
|
+
}
|
|
181
|
+
if (allowlist.length === 0) throw new ComposioFileUploadPathNotAllowedError([
|
|
182
|
+
`Refusing to auto-upload "${attempted}": no upload directories are configured.`,
|
|
183
|
+
"",
|
|
184
|
+
`Path attempted: ${attempted}`,
|
|
185
|
+
`Resolved to: ${real}`,
|
|
186
|
+
"",
|
|
187
|
+
"Automatic file upload during tool execution is locked down by default",
|
|
188
|
+
"to prevent a prompt-injected tool from exfiltrating server files",
|
|
189
|
+
"(source code, .env, SSH keys, etc.).",
|
|
190
|
+
buildHelpFooter(allowlist)
|
|
191
|
+
].join("\n"), { meta: {
|
|
192
|
+
attempted,
|
|
193
|
+
resolved: real,
|
|
194
|
+
allowlist
|
|
195
|
+
} });
|
|
196
|
+
for (const dir of allowlist) if (isInsideDir(real, tryRealpath(dir) ?? path.resolve(dir))) return;
|
|
197
|
+
throw new ComposioFileUploadPathNotAllowedError([
|
|
198
|
+
`Refusing to auto-upload "${attempted}": resolved path is not inside any`,
|
|
199
|
+
"directory in the configured `fileUploadDirs` allowlist.",
|
|
200
|
+
"",
|
|
201
|
+
`Path attempted: ${attempted}`,
|
|
202
|
+
`Resolved to: ${real}`,
|
|
203
|
+
buildHelpFooter(allowlist)
|
|
204
|
+
].join("\n"), { meta: {
|
|
205
|
+
attempted,
|
|
206
|
+
resolved: real,
|
|
207
|
+
allowlist
|
|
208
|
+
} });
|
|
209
|
+
}
|
|
210
|
+
|
|
66
211
|
//#endregion
|
|
67
212
|
//#region src/utils/fileUtils.node.ts
|
|
68
213
|
const getExtensionFromMimeType = (mimeType) => {
|
|
@@ -195,9 +340,11 @@ const readFile = async (file) => {
|
|
|
195
340
|
else return await readFileContent(file);
|
|
196
341
|
throw new Error("Invalid file type");
|
|
197
342
|
};
|
|
198
|
-
const getFileDataAfterUploadingToS3 = async (file, { toolSlug, toolkitSlug, client, sensitiveFileUploadProtection, fileUploadPathDenySegments }) => {
|
|
343
|
+
const getFileDataAfterUploadingToS3 = async (file, { toolSlug, toolkitSlug, client, sensitiveFileUploadProtection, fileUploadPathDenySegments, fileUploadAllowlist }) => {
|
|
199
344
|
if (!file) throw new Error("Either path or blob must be provided");
|
|
200
|
-
|
|
345
|
+
const isLocalPath = typeof file === "string" && !file.startsWith("http");
|
|
346
|
+
if (isLocalPath && fileUploadAllowlist !== void 0) assertPathInsideUploadDirs(file, fileUploadAllowlist);
|
|
347
|
+
if (sensitiveFileUploadProtection !== false && isLocalPath) assertSafeFileUploadPath(file, { additionalDenySegments: fileUploadPathDenySegments });
|
|
201
348
|
const fileData = await readFile(file);
|
|
202
349
|
logger_default.debug(`Uploading file to S3...`);
|
|
203
350
|
const s3key = await uploadFileToS3(platform.basename(fileData.fileName), fileData.content, toolSlug, toolkitSlug, fileData.mimeType, client);
|
|
@@ -208,7 +355,7 @@ const getFileDataAfterUploadingToS3 = async (file, { toolSlug, toolkitSlug, clie
|
|
|
208
355
|
s3key
|
|
209
356
|
};
|
|
210
357
|
};
|
|
211
|
-
const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType }) => {
|
|
358
|
+
const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType, fileDownloadDir }) => {
|
|
212
359
|
const response = await fetch(s3Url);
|
|
213
360
|
if (!response.ok) throw new Error(`Failed to download file: ${response.statusText}`);
|
|
214
361
|
const data = await response.arrayBuffer();
|
|
@@ -217,7 +364,10 @@ const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType }) => {
|
|
|
217
364
|
name: fileName,
|
|
218
365
|
mimeType,
|
|
219
366
|
s3Url,
|
|
220
|
-
filePath: saveFile(fileName, new Uint8Array(data),
|
|
367
|
+
filePath: saveFile(fileName, new Uint8Array(data), {
|
|
368
|
+
isTempFile: fileDownloadDir === void 0,
|
|
369
|
+
outputDir: fileDownloadDir
|
|
370
|
+
})
|
|
221
371
|
};
|
|
222
372
|
};
|
|
223
373
|
/**
|
|
@@ -253,19 +403,34 @@ const getComposioTempFilesDir = (createDirIfNotExists = false) => {
|
|
|
253
403
|
}
|
|
254
404
|
};
|
|
255
405
|
/**
|
|
256
|
-
* Saves a file to
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
406
|
+
* Saves a file to a local directory.
|
|
407
|
+
*
|
|
408
|
+
* Directory precedence (highest first):
|
|
409
|
+
* 1. `options.outputDir` (explicit, absolute or relative; created if missing)
|
|
410
|
+
* 2. `options.isTempFile === true` → `<home>/.composio/files`
|
|
411
|
+
* 3. fallback → `<home>/.composio`
|
|
412
|
+
*
|
|
413
|
+
* @returns The absolute path to the saved file, or `null` if the runtime has
|
|
414
|
+
* no filesystem (e.g. Cloudflare Workers) or the save failed.
|
|
261
415
|
*/
|
|
262
|
-
const saveFile = (file, content,
|
|
416
|
+
const saveFile = (file, content, options = {}) => {
|
|
417
|
+
const opts = typeof options === "boolean" ? { isTempFile: options } : options;
|
|
263
418
|
try {
|
|
264
419
|
if (!platform.supportsFileSystem) {
|
|
265
420
|
logger_default.debug("File system operations are not supported in this runtime environment");
|
|
266
421
|
return null;
|
|
267
422
|
}
|
|
268
|
-
|
|
423
|
+
let composioFilesDir;
|
|
424
|
+
if (opts.outputDir) {
|
|
425
|
+
const absDir = platform.joinPath(opts.outputDir);
|
|
426
|
+
try {
|
|
427
|
+
if (!platform.existsSync(absDir)) platform.mkdirSync(absDir);
|
|
428
|
+
composioFilesDir = absDir;
|
|
429
|
+
} catch (err) {
|
|
430
|
+
logger_default.warn(`fileDownloadDir "${absDir}" is not writable, falling back to the default (~/.composio/files). Error: ${err}`);
|
|
431
|
+
composioFilesDir = getComposioTempFilesDir(true);
|
|
432
|
+
}
|
|
433
|
+
} else composioFilesDir = opts.isTempFile ? getComposioTempFilesDir(true) : getComposioDir(true);
|
|
269
434
|
if (!composioFilesDir) return null;
|
|
270
435
|
const filePath = platform.joinPath(composioFilesDir, platform.basename(file));
|
|
271
436
|
logger_default.info(`Saving file to: ${filePath}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CQwRTUmo.cjs');
|
|
2
|
-
const require_FileModifierErrors = require('./FileModifierErrors-
|
|
2
|
+
const require_FileModifierErrors = require('./FileModifierErrors-BYJBHiay.cjs');
|
|
3
3
|
const require_buffer = require('./buffer-BjWptbNH.cjs');
|
|
4
4
|
let _platform = require("#platform");
|
|
5
5
|
let node_fs = require("node:fs");
|
|
@@ -67,6 +67,151 @@ function assertSafeFileUploadPath(filePath, options) {
|
|
|
67
67
|
} });
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/utils/uploadDirAllowlist.node.ts
|
|
72
|
+
/**
|
|
73
|
+
* Allowlist for automatic file upload during tool execution.
|
|
74
|
+
*
|
|
75
|
+
* This is only consulted when `dangerouslyAllowAutoUploadDownloadFiles` is enabled.
|
|
76
|
+
* Manual `composio.files.upload()` calls are not subject to the allowlist.
|
|
77
|
+
*
|
|
78
|
+
* - A local path is accepted iff its real (symlink-resolved, absolute) path is
|
|
79
|
+
* inside one of the allowed directories on a path-component boundary.
|
|
80
|
+
* `/tmp/foo` allows `/tmp/foo/bar` but NOT `/tmp/foo-bar`.
|
|
81
|
+
* - URLs (`http(s)://…`) and `File`/`Blob` values never hit this check.
|
|
82
|
+
* - User-provided `fileUploadDirs` fully replaces the default `[~/.composio/temp]`.
|
|
83
|
+
* - On Windows, path comparisons are case-insensitive.
|
|
84
|
+
*/
|
|
85
|
+
function normalizeForCompare(p) {
|
|
86
|
+
return process.platform === "win32" ? p.toLowerCase() : p;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* True if `child` is equal to `parent` or nested inside it on a component
|
|
90
|
+
* boundary. Assumes both paths are absolute and normalized.
|
|
91
|
+
*/
|
|
92
|
+
function isInsideDir(child, parent) {
|
|
93
|
+
const a = normalizeForCompare(child);
|
|
94
|
+
const b = normalizeForCompare(parent);
|
|
95
|
+
if (a === b) return true;
|
|
96
|
+
const sep = node_path.sep;
|
|
97
|
+
const bWithSep = b.endsWith(sep) ? b : b + sep;
|
|
98
|
+
return a.startsWith(bWithSep);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns the real (symlink-resolved) absolute path when the target exists,
|
|
102
|
+
* else `null`. Mirrors the semantics of the sensitive-path util.
|
|
103
|
+
*/
|
|
104
|
+
function tryRealpath(absPath) {
|
|
105
|
+
try {
|
|
106
|
+
if (node_fs.default.existsSync(absPath)) return node_fs.default.realpathSync(absPath);
|
|
107
|
+
} catch {}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function formatAllowlist(dirs) {
|
|
111
|
+
if (dirs.length === 0) return " (none configured — all local paths are blocked)";
|
|
112
|
+
return dirs.map((d) => ` - ${d}`).join("\n");
|
|
113
|
+
}
|
|
114
|
+
function buildHelpFooter(allowlist) {
|
|
115
|
+
return [
|
|
116
|
+
"",
|
|
117
|
+
"Allowed upload directories (fileUploadDirs):",
|
|
118
|
+
formatAllowlist(allowlist),
|
|
119
|
+
"",
|
|
120
|
+
"Fix one of the following:",
|
|
121
|
+
"",
|
|
122
|
+
" 1. Recommended — move the file under an allowed directory, or add your",
|
|
123
|
+
" directory to the allowlist:",
|
|
124
|
+
" new Composio({",
|
|
125
|
+
" fileUploadDirs: ['/abs/path/to/uploads', '~/.composio/temp'],",
|
|
126
|
+
" })",
|
|
127
|
+
" Note: user-provided `fileUploadDirs` REPLACES the default",
|
|
128
|
+
" `~/.composio/temp`. Include it explicitly if you want staged uploads",
|
|
129
|
+
" to keep working.",
|
|
130
|
+
"",
|
|
131
|
+
" 2. Pass the file by URL or as a File/Blob object instead of a filesystem",
|
|
132
|
+
" path. URLs and File objects are never path-checked.",
|
|
133
|
+
"",
|
|
134
|
+
" 3. (Dangerous) Bypass the allowlist entirely by opting into automatic",
|
|
135
|
+
" file upload/download from any readable path:",
|
|
136
|
+
" new Composio({ dangerouslyAllowAutoUploadDownloadFiles: true })",
|
|
137
|
+
" WARNING: This lets a prompt-injected or misbehaving tool read ANY",
|
|
138
|
+
" file the process can access. Only enable it in trusted, sandboxed",
|
|
139
|
+
" environments. The built-in sensitive-path denylist (.ssh, .aws,",
|
|
140
|
+
" .env, private SSH keys, etc.) still applies unless you also set",
|
|
141
|
+
" `sensitiveFileUploadProtection: false`."
|
|
142
|
+
].join("\n");
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @throws {ComposioFileNotFoundError} when `filePath` does not exist on disk.
|
|
146
|
+
* @throws {ComposioFileUploadPathNotAllowedError} when the resolved path is
|
|
147
|
+
* outside every entry of `allowlist`.
|
|
148
|
+
*/
|
|
149
|
+
function assertPathInsideUploadDirs(filePath, allowlist) {
|
|
150
|
+
const attempted = filePath;
|
|
151
|
+
const abs = node_path.resolve(filePath);
|
|
152
|
+
const real = tryRealpath(abs);
|
|
153
|
+
if (!real) {
|
|
154
|
+
const cwd = process.cwd();
|
|
155
|
+
const parent = node_path.dirname(abs);
|
|
156
|
+
const parentExists = (() => {
|
|
157
|
+
try {
|
|
158
|
+
return node_fs.default.existsSync(parent);
|
|
159
|
+
} catch {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
})();
|
|
163
|
+
throw new require_FileModifierErrors.ComposioFileNotFoundError([
|
|
164
|
+
`Refusing to auto-upload "${attempted}": the file does not exist on disk.`,
|
|
165
|
+
"",
|
|
166
|
+
`Path attempted: ${attempted}`,
|
|
167
|
+
`Resolved to: ${abs}`,
|
|
168
|
+
`Process cwd: ${cwd}`,
|
|
169
|
+
`Parent exists: ${parentExists ? "yes (" + parent + ")" : "no (" + parent + ")"}`,
|
|
170
|
+
"",
|
|
171
|
+
"Common causes:",
|
|
172
|
+
" - Typo in the filename passed to the tool.",
|
|
173
|
+
" - Relative path resolved against the wrong working directory",
|
|
174
|
+
" (relative paths use process.cwd() at the moment of upload).",
|
|
175
|
+
" - File was deleted between the tool being called and the upload starting.",
|
|
176
|
+
"",
|
|
177
|
+
buildHelpFooter(allowlist)
|
|
178
|
+
].join("\n"), { meta: {
|
|
179
|
+
attempted,
|
|
180
|
+
resolved: abs,
|
|
181
|
+
cwd,
|
|
182
|
+
allowlist
|
|
183
|
+
} });
|
|
184
|
+
}
|
|
185
|
+
if (allowlist.length === 0) throw new require_FileModifierErrors.ComposioFileUploadPathNotAllowedError([
|
|
186
|
+
`Refusing to auto-upload "${attempted}": no upload directories are configured.`,
|
|
187
|
+
"",
|
|
188
|
+
`Path attempted: ${attempted}`,
|
|
189
|
+
`Resolved to: ${real}`,
|
|
190
|
+
"",
|
|
191
|
+
"Automatic file upload during tool execution is locked down by default",
|
|
192
|
+
"to prevent a prompt-injected tool from exfiltrating server files",
|
|
193
|
+
"(source code, .env, SSH keys, etc.).",
|
|
194
|
+
buildHelpFooter(allowlist)
|
|
195
|
+
].join("\n"), { meta: {
|
|
196
|
+
attempted,
|
|
197
|
+
resolved: real,
|
|
198
|
+
allowlist
|
|
199
|
+
} });
|
|
200
|
+
for (const dir of allowlist) if (isInsideDir(real, tryRealpath(dir) ?? node_path.resolve(dir))) return;
|
|
201
|
+
throw new require_FileModifierErrors.ComposioFileUploadPathNotAllowedError([
|
|
202
|
+
`Refusing to auto-upload "${attempted}": resolved path is not inside any`,
|
|
203
|
+
"directory in the configured `fileUploadDirs` allowlist.",
|
|
204
|
+
"",
|
|
205
|
+
`Path attempted: ${attempted}`,
|
|
206
|
+
`Resolved to: ${real}`,
|
|
207
|
+
buildHelpFooter(allowlist)
|
|
208
|
+
].join("\n"), { meta: {
|
|
209
|
+
attempted,
|
|
210
|
+
resolved: real,
|
|
211
|
+
allowlist
|
|
212
|
+
} });
|
|
213
|
+
}
|
|
214
|
+
|
|
70
215
|
//#endregion
|
|
71
216
|
//#region src/utils/fileUtils.node.ts
|
|
72
217
|
const getExtensionFromMimeType = (mimeType) => {
|
|
@@ -199,9 +344,11 @@ const readFile = async (file) => {
|
|
|
199
344
|
else return await readFileContent(file);
|
|
200
345
|
throw new Error("Invalid file type");
|
|
201
346
|
};
|
|
202
|
-
const getFileDataAfterUploadingToS3 = async (file, { toolSlug, toolkitSlug, client, sensitiveFileUploadProtection, fileUploadPathDenySegments }) => {
|
|
347
|
+
const getFileDataAfterUploadingToS3 = async (file, { toolSlug, toolkitSlug, client, sensitiveFileUploadProtection, fileUploadPathDenySegments, fileUploadAllowlist }) => {
|
|
203
348
|
if (!file) throw new Error("Either path or blob must be provided");
|
|
204
|
-
|
|
349
|
+
const isLocalPath = typeof file === "string" && !file.startsWith("http");
|
|
350
|
+
if (isLocalPath && fileUploadAllowlist !== void 0) assertPathInsideUploadDirs(file, fileUploadAllowlist);
|
|
351
|
+
if (sensitiveFileUploadProtection !== false && isLocalPath) assertSafeFileUploadPath(file, { additionalDenySegments: fileUploadPathDenySegments });
|
|
205
352
|
const fileData = await readFile(file);
|
|
206
353
|
require_FileModifierErrors.logger_default.debug(`Uploading file to S3...`);
|
|
207
354
|
const s3key = await uploadFileToS3(_platform.platform.basename(fileData.fileName), fileData.content, toolSlug, toolkitSlug, fileData.mimeType, client);
|
|
@@ -212,7 +359,7 @@ const getFileDataAfterUploadingToS3 = async (file, { toolSlug, toolkitSlug, clie
|
|
|
212
359
|
s3key
|
|
213
360
|
};
|
|
214
361
|
};
|
|
215
|
-
const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType }) => {
|
|
362
|
+
const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType, fileDownloadDir }) => {
|
|
216
363
|
const response = await fetch(s3Url);
|
|
217
364
|
if (!response.ok) throw new Error(`Failed to download file: ${response.statusText}`);
|
|
218
365
|
const data = await response.arrayBuffer();
|
|
@@ -221,7 +368,10 @@ const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType }) => {
|
|
|
221
368
|
name: fileName,
|
|
222
369
|
mimeType,
|
|
223
370
|
s3Url,
|
|
224
|
-
filePath: saveFile(fileName, new Uint8Array(data),
|
|
371
|
+
filePath: saveFile(fileName, new Uint8Array(data), {
|
|
372
|
+
isTempFile: fileDownloadDir === void 0,
|
|
373
|
+
outputDir: fileDownloadDir
|
|
374
|
+
})
|
|
225
375
|
};
|
|
226
376
|
};
|
|
227
377
|
/**
|
|
@@ -257,19 +407,34 @@ const getComposioTempFilesDir = (createDirIfNotExists = false) => {
|
|
|
257
407
|
}
|
|
258
408
|
};
|
|
259
409
|
/**
|
|
260
|
-
* Saves a file to
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
410
|
+
* Saves a file to a local directory.
|
|
411
|
+
*
|
|
412
|
+
* Directory precedence (highest first):
|
|
413
|
+
* 1. `options.outputDir` (explicit, absolute or relative; created if missing)
|
|
414
|
+
* 2. `options.isTempFile === true` → `<home>/.composio/files`
|
|
415
|
+
* 3. fallback → `<home>/.composio`
|
|
416
|
+
*
|
|
417
|
+
* @returns The absolute path to the saved file, or `null` if the runtime has
|
|
418
|
+
* no filesystem (e.g. Cloudflare Workers) or the save failed.
|
|
265
419
|
*/
|
|
266
|
-
const saveFile = (file, content,
|
|
420
|
+
const saveFile = (file, content, options = {}) => {
|
|
421
|
+
const opts = typeof options === "boolean" ? { isTempFile: options } : options;
|
|
267
422
|
try {
|
|
268
423
|
if (!_platform.platform.supportsFileSystem) {
|
|
269
424
|
require_FileModifierErrors.logger_default.debug("File system operations are not supported in this runtime environment");
|
|
270
425
|
return null;
|
|
271
426
|
}
|
|
272
|
-
|
|
427
|
+
let composioFilesDir;
|
|
428
|
+
if (opts.outputDir) {
|
|
429
|
+
const absDir = _platform.platform.joinPath(opts.outputDir);
|
|
430
|
+
try {
|
|
431
|
+
if (!_platform.platform.existsSync(absDir)) _platform.platform.mkdirSync(absDir);
|
|
432
|
+
composioFilesDir = absDir;
|
|
433
|
+
} catch (err) {
|
|
434
|
+
require_FileModifierErrors.logger_default.warn(`fileDownloadDir "${absDir}" is not writable, falling back to the default (~/.composio/files). Error: ${err}`);
|
|
435
|
+
composioFilesDir = getComposioTempFilesDir(true);
|
|
436
|
+
}
|
|
437
|
+
} else composioFilesDir = opts.isTempFile ? getComposioTempFilesDir(true) : getComposioDir(true);
|
|
273
438
|
if (!composioFilesDir) return null;
|
|
274
439
|
const filePath = _platform.platform.joinPath(composioFilesDir, _platform.platform.basename(file));
|
|
275
440
|
require_FileModifierErrors.logger_default.info(`Saving file to: ${filePath}`);
|