@composio/core 0.14.0 → 0.15.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-lCxnjFKQ.d.mts → BaseProvider-BN2-Nktx.d.mts} +224 -180
- package/dist/{CustomTool-C_5NvBsX.mjs → CustomTool-l-j5HtEf.mjs} +1 -1
- package/dist/{CustomTool-CmokRT9q.d.mts → CustomTool-zjeDpZ91.d.mts} +1 -2
- package/dist/FileModifierErrors-B8V8_3VE.mjs +97 -0
- package/dist/{SsrfErrors-BQRozkeU.mjs → SsrfErrors-DNJt57GL.mjs} +5 -98
- package/dist/{Telemetry-llfvticE.mjs → Telemetry-DuGJSwUt.mjs} +3 -3
- package/dist/{cancellation-W65QRyj2.mjs → cancellation-BbJ-UQ__.mjs} +2 -2
- package/dist/{composio-6C8kHtqc.d.mts → composio-Bf8hnBBq.d.mts} +24 -21
- package/dist/{customTool.types-kFhNYuzh.d.mts → customTool.types-Bhom9a2R.d.mts} +73 -40
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +2 -0
- package/dist/{errors-B165yJUQ.mjs → errors-BcEUHZbq.mjs} +2 -1
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-iPFi2o4i.mjs → fileUtils.node-BQ0fWge3.mjs} +9 -154
- package/dist/index.d.mts +1585 -752
- package/dist/index.mjs +39 -20
- package/dist/models/Files.node.d.mts +2 -11
- package/dist/models/Files.node.mjs +2 -2
- package/dist/models/Files.workerd.d.mts +0 -1
- package/dist/platform/node.d.mts +1 -2
- package/dist/platform/node.mjs +24 -0
- package/dist/platform/workerd.d.mts +1 -2
- package/dist/platform/workerd.mjs +30 -3
- package/dist/{sensitiveFileUploadPaths-B1OLsd8F.mjs → sensitiveFileUploadPaths-BVEt0peg.mjs} +64 -9
- package/dist/{types-yCrveqAj.d.mts → types-CePuCfD-.d.mts} +2 -3
- package/dist/{types-DY1r-kN9.d.mts → types-D5A2wzBl.d.mts} +8 -0
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -2
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -2
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -2
- package/dist/utils/modifiers/FileToolModifier.node.mjs +5 -4
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -2
- package/dist/utils/ssrfGuard.node.d.mts +22 -0
- package/dist/utils/ssrfGuard.node.mjs +153 -0
- package/dist/utils/ssrfGuard.workerd.d.mts +9 -0
- package/dist/utils/ssrfGuard.workerd.mjs +17 -0
- package/package.json +17 -11
- package/src/errors/SsrfErrors.ts +4 -3
- package/src/models/ToolRouterSessionFileMount.ts +10 -3
- package/src/platform/node.ts +40 -0
- package/src/platform/types.ts +9 -0
- package/src/platform/workerd.ts +35 -3
- package/src/telemetry/redact.ts +6 -1
- package/src/types/tool.types.ts +52 -8
- package/src/utils/fileUtils.node.ts +5 -2
- package/src/utils/modifiers/FileToolModifier.node.ts +3 -3
- package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +6 -4
- package/src/utils/readResponseBody.ts +63 -0
- package/src/utils/sdk.ts +2 -2
- package/src/utils/sensitiveFileUploadPaths.ts +12 -9
- package/src/utils/ssrfGuard.node.ts +12 -8
- package/src/utils/ssrfGuard.workerd.ts +19 -0
- package/src/utils/version.ts +21 -20
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as ToolErrorCodes, B as ComposioSharedAccessDeniedError, C as ComposioInvalidExecuteFunctionError, D as ComposioToolExecutionError, E as ComposioProviderNotDefinedError, F as ComposioAclOnlyForSharedError, H as ConnectedAccountErrorCodes, I as ComposioConnectedAccountNotFoundError, L as ComposioFailedToCreateConnectedAccountLink, M as ConnectionRequestErrorCodes, N as ConnectionRequestFailedError, O as ComposioToolNotFoundError, P as ConnectionRequestTimeoutError, R as ComposioLegacyConnectedAccountsEndpointRetiredError, S as ComposioGlobalExecuteToolFnNotSetError, T as ComposioInvalidToolArgumentsError, U as AuthConfigErrorCodes, V as ComposioSharedConnectionNotAccessibleError, W as ComposioAuthConfigNotFoundError, _ as ValidationError, a as ComposioFailedToSubscribeToPusherChannelError, b as ComposioToolkitNotFoundError, c as ComposioWebhookPayloadError, d as ComposioNoAPIKeyError, f as ComposioRequestCancelledError, g as JsonSchemaToZodError, h as JsonSchemaRefResolutionError, i as ComposioFailedToGetSDKRealtimeCredentialsError, j as handleToolExecutionError, k as ComposioToolVersionRequiredError, l as ComposioWebhookSignatureVerificationError, m as isRequestAbortError, n as RemoteFileErrorCodes, o as ComposioFailedToUnsubscribeFromPusherChannelError, p as SDKErrorCodes, r as ComposioFailedToCreatePusherClientError, s as ComposioTriggerTypeNotFoundError, t as RemoteFileDownloadError, u as TriggerErrorCodes, v as ValidationErrorCodes, w as ComposioInvalidModifierError, x as ToolkitErrorCodes, y as ComposioToolkitFetchError, z as ComposioMultipleConnectedAccountsError } from "./errors-
|
|
1
|
+
import { a as COMPOSIO_DIR, c as DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID, d as USER_DATA_FILE_NAME, f as constants_exports, i as logger, l as IS_DEVELOPMENT_OR_CI, m as getEnvsWithPrefix, n as SsrfErrorCodes, o as COMPOSIO_LOG_LEVEL, p as getEnvVariable, r as ComposioError, s as DEFAULT_BASE_URL, t as ComposioBlockedInternalUrlError, u as TEMP_FILES_DIRECTORY_NAME } from "./SsrfErrors-DNJt57GL.mjs";
|
|
2
|
+
import { A as ToolErrorCodes, B as ComposioSharedAccessDeniedError, C as ComposioInvalidExecuteFunctionError, D as ComposioToolExecutionError, E as ComposioProviderNotDefinedError, F as ComposioAclOnlyForSharedError, H as ConnectedAccountErrorCodes, I as ComposioConnectedAccountNotFoundError, L as ComposioFailedToCreateConnectedAccountLink, M as ConnectionRequestErrorCodes, N as ConnectionRequestFailedError, O as ComposioToolNotFoundError, P as ConnectionRequestTimeoutError, R as ComposioLegacyConnectedAccountsEndpointRetiredError, S as ComposioGlobalExecuteToolFnNotSetError, T as ComposioInvalidToolArgumentsError, U as AuthConfigErrorCodes, V as ComposioSharedConnectionNotAccessibleError, W as ComposioAuthConfigNotFoundError, _ as ValidationError, a as ComposioFailedToSubscribeToPusherChannelError, b as ComposioToolkitNotFoundError, c as ComposioWebhookPayloadError, d as ComposioNoAPIKeyError, f as ComposioRequestCancelledError, g as JsonSchemaToZodError, h as JsonSchemaRefResolutionError, i as ComposioFailedToGetSDKRealtimeCredentialsError, j as handleToolExecutionError, k as ComposioToolVersionRequiredError, l as ComposioWebhookSignatureVerificationError, m as isRequestAbortError, n as RemoteFileErrorCodes, o as ComposioFailedToUnsubscribeFromPusherChannelError, p as SDKErrorCodes, r as ComposioFailedToCreatePusherClientError, s as ComposioTriggerTypeNotFoundError, t as RemoteFileDownloadError, u as TriggerErrorCodes, v as ValidationErrorCodes, w as ComposioInvalidModifierError, x as ToolkitErrorCodes, y as ComposioToolkitFetchError, z as ComposioMultipleConnectedAccountsError } from "./errors-BcEUHZbq.mjs";
|
|
3
|
+
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, o as FileModifierErrorCodes, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "./FileModifierErrors-B8V8_3VE.mjs";
|
|
3
4
|
import { r as schemaHasFileUploadable, t as isPlainObject } from "./FileToolModifier.utils.neutral-B5rT711M.mjs";
|
|
4
|
-
import { a as removeNonRequiredProperties, i as jsonSchemaToZodSchema, n as deduplicateJsonSchemaRequiredArrays, r as dereferenceJsonSchema, t as withCancellation } from "./cancellation-
|
|
5
|
-
import { t as telemetry } from "./Telemetry-
|
|
6
|
-
import {
|
|
7
|
-
import { a as createCustomToolkit, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, f as CreateCustomToolkitBaseSchema, i as createCustomTool, l as serializeCustomToolkits, n as buildCustomToolsMap, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, u as serializeCustomTools } from "./CustomTool-
|
|
5
|
+
import { a as removeNonRequiredProperties, i as jsonSchemaToZodSchema, n as deduplicateJsonSchemaRequiredArrays, r as dereferenceJsonSchema, t as withCancellation } from "./cancellation-BbJ-UQ__.mjs";
|
|
6
|
+
import { t as telemetry } from "./Telemetry-DuGJSwUt.mjs";
|
|
7
|
+
import { a as arrayBufferToBase64, c as getRandomShortId, i as readResponseBodyWithLimit, n as assertSafeFileUploadPath, r as isBlockedSensitiveFileUploadPath, t as BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS } from "./sensitiveFileUploadPaths-BVEt0peg.mjs";
|
|
8
|
+
import { a as createCustomToolkit, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, f as CreateCustomToolkitBaseSchema, i as createCustomTool, l as serializeCustomToolkits, n as buildCustomToolsMap, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, u as serializeCustomTools } from "./CustomTool-l-j5HtEf.mjs";
|
|
8
9
|
import ComposioClient, { APIError, BadRequestError } from "@composio/client";
|
|
9
10
|
import { FileToolModifier } from "#file_tool_modifier";
|
|
10
11
|
import z, { z as z$1 } from "zod/v3";
|
|
@@ -13,6 +14,7 @@ import { platform } from "#platform";
|
|
|
13
14
|
import { APIError as APIError$1 } from "openai";
|
|
14
15
|
import semver from "semver";
|
|
15
16
|
import { Files } from "#files";
|
|
17
|
+
import { ssrfSafeFetch } from "#ssrf_guard";
|
|
16
18
|
|
|
17
19
|
//#region src/types/authConfigs.types.ts
|
|
18
20
|
const AuthConfigTypes = {
|
|
@@ -876,15 +878,15 @@ const JSONSchemaPropertySchema = z$1.object({
|
|
|
876
878
|
allOf: z$1.lazy(() => z$1.array(JSONSchemaPropertySchema)).optional(),
|
|
877
879
|
not: z$1.lazy(() => JSONSchemaPropertySchema).optional(),
|
|
878
880
|
title: z$1.string().optional(),
|
|
879
|
-
default: z$1.
|
|
881
|
+
default: z$1.unknown().optional(),
|
|
880
882
|
nullable: z$1.boolean().optional(),
|
|
881
883
|
properties: z$1.lazy(() => z$1.record(z$1.string(), JSONSchemaPropertySchema)).optional(),
|
|
882
884
|
required: z$1.array(z$1.string()).optional(),
|
|
883
885
|
file_uploadable: z$1.boolean().optional(),
|
|
884
886
|
file_downloadable: z$1.boolean().optional(),
|
|
885
887
|
items: z$1.lazy(() => z$1.union([JSONSchemaPropertySchema, z$1.array(JSONSchemaPropertySchema)])).optional(),
|
|
886
|
-
enum: z$1.array(z$1.
|
|
887
|
-
const: z$1.
|
|
888
|
+
enum: z$1.array(z$1.unknown()).optional(),
|
|
889
|
+
const: z$1.unknown().optional(),
|
|
888
890
|
minimum: z$1.number().optional(),
|
|
889
891
|
maximum: z$1.number().optional(),
|
|
890
892
|
exclusiveMinimum: z$1.number().optional(),
|
|
@@ -901,7 +903,7 @@ const JSONSchemaPropertySchema = z$1.object({
|
|
|
901
903
|
maxProperties: z$1.number().optional(),
|
|
902
904
|
patternProperties: z$1.lazy(() => z$1.record(z$1.string(), JSONSchemaPropertySchema)).optional(),
|
|
903
905
|
additionalProperties: z$1.union([z$1.boolean(), z$1.lazy(() => JSONSchemaPropertySchema)]).optional(),
|
|
904
|
-
examples: z$1.array(z$1.
|
|
906
|
+
examples: z$1.array(z$1.unknown()).optional(),
|
|
905
907
|
readOnly: z$1.boolean().optional(),
|
|
906
908
|
writeOnly: z$1.boolean().optional(),
|
|
907
909
|
if: z$1.lazy(() => JSONSchemaPropertySchema).optional(),
|
|
@@ -920,7 +922,7 @@ const ParametersSchema = z$1.preprocess(deduplicateJsonSchemaRequiredArrays, z$1
|
|
|
920
922
|
properties: z$1.record(z$1.string(), JSONSchemaPropertySchema),
|
|
921
923
|
required: z$1.array(z$1.string()).optional(),
|
|
922
924
|
title: z$1.string().optional(),
|
|
923
|
-
default: z$1.
|
|
925
|
+
default: z$1.unknown().optional(),
|
|
924
926
|
nullable: z$1.boolean().optional(),
|
|
925
927
|
description: z$1.string().optional(),
|
|
926
928
|
additionalProperties: z$1.boolean().default(false).optional(),
|
|
@@ -5419,8 +5421,8 @@ function getSDKConfig(baseUrl, apiKey) {
|
|
|
5419
5421
|
*
|
|
5420
5422
|
* Priority order:
|
|
5421
5423
|
* 1. If defaultVersions is a string, use it as global version for all toolkits
|
|
5422
|
-
* 2.
|
|
5423
|
-
* 3.
|
|
5424
|
+
* 2. User-provided toolkit version mappings (defaultVersions object)
|
|
5425
|
+
* 3. Environment variables (COMPOSIO_TOOLKIT_VERSION_<TOOLKIT_NAME>)
|
|
5424
5426
|
* 4. Fallback to 'latest' if no versions are configured
|
|
5425
5427
|
*
|
|
5426
5428
|
* @param defaultVersions - Optional default versions configuration (string for global version or object mapping toolkit names to versions)
|
|
@@ -5446,9 +5448,13 @@ function getToolkitVersionsFromEnv(defaultVersions) {
|
|
|
5446
5448
|
|
|
5447
5449
|
//#endregion
|
|
5448
5450
|
//#region src/utils/version.ts
|
|
5451
|
+
const VERSION_CHECK_TIMEOUT_MS = 2e3;
|
|
5449
5452
|
/**
|
|
5450
5453
|
* Checks for the latest version of the Composio SDK from NPM.
|
|
5451
5454
|
* If a newer version is available, it logs a warning to the console.
|
|
5455
|
+
*
|
|
5456
|
+
* Best-effort: never throws. The npm registry request is aborted after
|
|
5457
|
+
* {@link VERSION_CHECK_TIMEOUT_MS} milliseconds.
|
|
5452
5458
|
*/
|
|
5453
5459
|
async function checkForLatestVersionFromNPM(currentVersion) {
|
|
5454
5460
|
try {
|
|
@@ -5457,8 +5463,16 @@ async function checkForLatestVersionFromNPM(currentVersion) {
|
|
|
5457
5463
|
if (!semver.valid(currentVersionFromPackageJson)) return;
|
|
5458
5464
|
const prerelease = semver.prerelease(currentVersionFromPackageJson);
|
|
5459
5465
|
if (prerelease && (String(prerelease[0]).includes("alpha") || String(prerelease[0]).includes("beta"))) return;
|
|
5460
|
-
const
|
|
5461
|
-
|
|
5466
|
+
const controller = new AbortController();
|
|
5467
|
+
const timer = setTimeout(() => controller.abort(), VERSION_CHECK_TIMEOUT_MS);
|
|
5468
|
+
let data;
|
|
5469
|
+
try {
|
|
5470
|
+
data = await (await fetch(`https://registry.npmjs.org/${packageName}/latest`, { signal: controller.signal })).json();
|
|
5471
|
+
} finally {
|
|
5472
|
+
clearTimeout(timer);
|
|
5473
|
+
}
|
|
5474
|
+
const latestVersion = data.version;
|
|
5475
|
+
if (semver.gt(latestVersion, currentVersionFromPackageJson) && !IS_DEVELOPMENT_OR_CI) logger.info(`🚀 Upgrade available! Your ${packageName} version (${currentVersionFromPackageJson}) is behind. Latest version: ${latestVersion}.`);
|
|
5462
5476
|
} catch (_error) {}
|
|
5463
5477
|
}
|
|
5464
5478
|
|
|
@@ -6004,7 +6018,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
6004
6018
|
|
|
6005
6019
|
//#endregion
|
|
6006
6020
|
//#region package.json
|
|
6007
|
-
var version = "0.
|
|
6021
|
+
var version = "0.15.0";
|
|
6008
6022
|
|
|
6009
6023
|
//#endregion
|
|
6010
6024
|
//#region src/utils/session.ts
|
|
@@ -6861,9 +6875,12 @@ var ToolRouterSessionFilesMount = class {
|
|
|
6861
6875
|
async normalizeUploadInput(input, options) {
|
|
6862
6876
|
if (typeof input === "string") {
|
|
6863
6877
|
if (input.startsWith("http://") || input.startsWith("https://")) {
|
|
6864
|
-
const response = await
|
|
6865
|
-
if (!response.ok)
|
|
6866
|
-
|
|
6878
|
+
const response = await ssrfSafeFetch(input);
|
|
6879
|
+
if (!response.ok) {
|
|
6880
|
+
await response.body?.cancel().catch(() => void 0);
|
|
6881
|
+
throw new Error(`Failed to fetch file from URL: ${response.statusText}`);
|
|
6882
|
+
}
|
|
6883
|
+
const content = await readResponseBodyWithLimit(response);
|
|
6867
6884
|
const mimeType = (response.headers.get("content-type") || "application/octet-stream").split(";")[0].trim();
|
|
6868
6885
|
const segments = new URL(input).pathname.split("/").filter(Boolean);
|
|
6869
6886
|
let filename = segments.length > 0 ? segments[segments.length - 1] : "";
|
|
@@ -6872,7 +6889,7 @@ var ToolRouterSessionFilesMount = class {
|
|
|
6872
6889
|
filename = `${getRandomShortId()}.${extension}`;
|
|
6873
6890
|
}
|
|
6874
6891
|
return {
|
|
6875
|
-
fileToUpload: new File([
|
|
6892
|
+
fileToUpload: new File([content], filename, { type: mimeType }),
|
|
6876
6893
|
remotePath: options.remotePath ?? filename,
|
|
6877
6894
|
mimetype: mimeType
|
|
6878
6895
|
};
|
|
@@ -6908,6 +6925,8 @@ var ToolRouterSessionFilesMount = class {
|
|
|
6908
6925
|
*
|
|
6909
6926
|
* Accepts a file path (local or URL), a native File object, or a raw buffer.
|
|
6910
6927
|
* The file is stored in the virtual filesystem associated with the tool router session.
|
|
6928
|
+
* URL inputs require a Node.js or Bun runtime so the destination can be DNS-validated;
|
|
6929
|
+
* edge runtimes must fetch the file themselves and pass a File or ArrayBuffer.
|
|
6911
6930
|
*
|
|
6912
6931
|
* @param input - File path (string), native File, or raw buffer (ArrayBuffer | Uint8Array).
|
|
6913
6932
|
* @param options - Optional configuration. When passing a buffer, remotePath is required.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { n as FileUploadData, t as FileDownloadData } from "../files.types-DeMC_mAW.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
|
-
|
|
4
3
|
//#region src/models/Files.node.d.ts
|
|
5
4
|
declare class Files {
|
|
6
5
|
private readonly client;
|
|
@@ -27,11 +26,7 @@ declare class Files {
|
|
|
27
26
|
* toolkitSlug: 'google_drive'
|
|
28
27
|
* });
|
|
29
28
|
* */
|
|
30
|
-
upload({
|
|
31
|
-
file,
|
|
32
|
-
toolSlug,
|
|
33
|
-
toolkitSlug
|
|
34
|
-
}: {
|
|
29
|
+
upload({ file, toolSlug, toolkitSlug }: {
|
|
35
30
|
file: File | string;
|
|
36
31
|
toolSlug: string;
|
|
37
32
|
toolkitSlug: string;
|
|
@@ -41,11 +36,7 @@ declare class Files {
|
|
|
41
36
|
* @param s3key - The S3 key of the file to download.
|
|
42
37
|
* @returns The file data.
|
|
43
38
|
*/
|
|
44
|
-
download({
|
|
45
|
-
toolSlug,
|
|
46
|
-
s3Url,
|
|
47
|
-
mimeType
|
|
48
|
-
}: {
|
|
39
|
+
download({ toolSlug, s3Url, mimeType }: {
|
|
49
40
|
s3Url: string;
|
|
50
41
|
toolSlug: string;
|
|
51
42
|
mimeType: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as telemetry } from "../Telemetry-
|
|
2
|
-
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-
|
|
1
|
+
import { t as telemetry } from "../Telemetry-DuGJSwUt.mjs";
|
|
2
|
+
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-BQ0fWge3.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/models/Files.node.ts
|
|
5
5
|
var Files = class {
|
package/dist/platform/node.d.mts
CHANGED
package/dist/platform/node.mjs
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import * as fs$1 from "node:fs";
|
|
2
2
|
import * as os from "node:os";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
+
import { isFsCaseSensitive } from "is-fs-case-sensitive";
|
|
4
5
|
|
|
5
6
|
//#region src/platform/node.ts
|
|
7
|
+
const findNearestExistingDirectory = (filePath) => {
|
|
8
|
+
let candidate = path.resolve(filePath);
|
|
9
|
+
try {
|
|
10
|
+
if (!fs$1.statSync(candidate).isDirectory()) candidate = path.dirname(candidate);
|
|
11
|
+
} catch {
|
|
12
|
+
candidate = path.dirname(candidate);
|
|
13
|
+
}
|
|
14
|
+
while (true) {
|
|
15
|
+
try {
|
|
16
|
+
if (fs$1.statSync(candidate).isDirectory()) return candidate;
|
|
17
|
+
} catch {}
|
|
18
|
+
const parent = path.dirname(candidate);
|
|
19
|
+
if (parent === candidate) return candidate;
|
|
20
|
+
candidate = parent;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
6
23
|
/**
|
|
7
24
|
* Node.js platform implementation.
|
|
8
25
|
* Provides full file system and OS operations using Node.js built-in modules.
|
|
@@ -34,6 +51,13 @@ const platform = {
|
|
|
34
51
|
realpathSync(filePath) {
|
|
35
52
|
return fs$1.realpathSync(filePath);
|
|
36
53
|
},
|
|
54
|
+
isFileSystemCaseSensitive(filePath) {
|
|
55
|
+
try {
|
|
56
|
+
return isFsCaseSensitive(findNearestExistingDirectory(filePath));
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
37
61
|
mkdirSync(dirPath) {
|
|
38
62
|
fs$1.mkdirSync(dirPath, { recursive: true });
|
|
39
63
|
},
|
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
//#region src/platform/workerd.ts
|
|
2
|
+
const SLASH_CHAR_CODE = 47;
|
|
3
|
+
/**
|
|
4
|
+
* Trailing-slash trim without a regex. The equivalent pattern backtracks
|
|
5
|
+
* quadratically on long runs of slashes (CodeQL js/polynomial-redos), so this
|
|
6
|
+
* walks the string from the end instead. Returns the input unchanged when
|
|
7
|
+
* there is nothing to trim, so the common case allocates nothing.
|
|
8
|
+
*/
|
|
9
|
+
const trimTrailingSlashes = (value) => {
|
|
10
|
+
let end = value.length;
|
|
11
|
+
while (end > 0 && value.charCodeAt(end - 1) === SLASH_CHAR_CODE) end--;
|
|
12
|
+
return end === value.length ? value : value.slice(0, end);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Leading-and-trailing slash trim without a regex, matching the semantics of
|
|
16
|
+
* the previous leading/trailing slash-trim replace for every input, including
|
|
17
|
+
* a string that is entirely slashes.
|
|
18
|
+
*/
|
|
19
|
+
const trimSurroundingSlashes = (value) => {
|
|
20
|
+
let start = 0;
|
|
21
|
+
let end = value.length;
|
|
22
|
+
while (start < end && value.charCodeAt(start) === SLASH_CHAR_CODE) start++;
|
|
23
|
+
while (end > start && value.charCodeAt(end - 1) === SLASH_CHAR_CODE) end--;
|
|
24
|
+
return start === 0 && end === value.length ? value : value.slice(start, end);
|
|
25
|
+
};
|
|
2
26
|
/**
|
|
3
27
|
* Cloudflare Workers / Edge runtime platform implementation.
|
|
4
28
|
* Provides stub implementations for file system operations that are unavailable in edge runtimes.
|
|
@@ -11,8 +35,8 @@ const platform = {
|
|
|
11
35
|
},
|
|
12
36
|
joinPath(...paths) {
|
|
13
37
|
return paths.map((segment, index) => {
|
|
14
|
-
if (index === 0) return segment
|
|
15
|
-
return segment
|
|
38
|
+
if (index === 0) return trimTrailingSlashes(segment);
|
|
39
|
+
return trimSurroundingSlashes(segment);
|
|
16
40
|
}).filter(Boolean).join("/");
|
|
17
41
|
},
|
|
18
42
|
resolvePath(...paths) {
|
|
@@ -22,7 +46,7 @@ const platform = {
|
|
|
22
46
|
return filePath.startsWith("/");
|
|
23
47
|
},
|
|
24
48
|
basename(filePath) {
|
|
25
|
-
const segments = filePath
|
|
49
|
+
const segments = trimTrailingSlashes(filePath).split("/");
|
|
26
50
|
return segments[segments.length - 1] || "";
|
|
27
51
|
},
|
|
28
52
|
existsSync(_filePath) {
|
|
@@ -31,6 +55,9 @@ const platform = {
|
|
|
31
55
|
realpathSync(filePath) {
|
|
32
56
|
return filePath;
|
|
33
57
|
},
|
|
58
|
+
isFileSystemCaseSensitive(_filePath) {
|
|
59
|
+
return true;
|
|
60
|
+
},
|
|
34
61
|
mkdirSync(_dirPath) {},
|
|
35
62
|
readFileSync(_filePath, _encoding) {
|
|
36
63
|
throw new Error("File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). Use environment variables or external storage services instead.");
|
package/dist/{sensitiveFileUploadPaths-B1OLsd8F.mjs → sensitiveFileUploadPaths-BVEt0peg.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as ComposioSensitiveFilePathBlockedError } from "./FileModifierErrors-B8V8_3VE.mjs";
|
|
2
2
|
import { platform } from "#platform";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/uuid.ts
|
|
@@ -32,6 +32,56 @@ const uint8ArrayToBase64 = (bytes) => {
|
|
|
32
32
|
return btoa(binary);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/utils/readResponseBody.ts
|
|
37
|
+
/** Maximum size accepted for files fetched from user-supplied URLs (100 MiB). */
|
|
38
|
+
const MAX_URL_UPLOAD_SIZE_BYTES = 100 * 1024 * 1024;
|
|
39
|
+
const sizeLimitError = (actualSize, maxBytes) => /* @__PURE__ */ new Error(`File size (${actualSize} bytes) exceeds maximum allowed size (${maxBytes} bytes)`);
|
|
40
|
+
/**
|
|
41
|
+
* Read a fetch response without allowing an untrusted server to exhaust memory.
|
|
42
|
+
*
|
|
43
|
+
* `Content-Length` is checked as an early rejection, but the streamed byte
|
|
44
|
+
* count is authoritative because the header can be absent or dishonest.
|
|
45
|
+
*/
|
|
46
|
+
const readResponseBodyWithLimit = async (response, maxBytes = MAX_URL_UPLOAD_SIZE_BYTES) => {
|
|
47
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0) throw new RangeError("maxBytes must be a non-negative safe integer");
|
|
48
|
+
const contentLength = response.headers.get("content-length")?.trim();
|
|
49
|
+
if (contentLength && /^\d+$/.test(contentLength)) {
|
|
50
|
+
const declaredSize = Number(contentLength);
|
|
51
|
+
if (!Number.isSafeInteger(declaredSize) || declaredSize > maxBytes) {
|
|
52
|
+
const error = sizeLimitError(declaredSize, maxBytes);
|
|
53
|
+
await response.body?.cancel(error).catch(() => void 0);
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!response.body) return /* @__PURE__ */ new Uint8Array();
|
|
58
|
+
const reader = response.body.getReader();
|
|
59
|
+
const chunks = [];
|
|
60
|
+
let totalBytes = 0;
|
|
61
|
+
try {
|
|
62
|
+
while (true) {
|
|
63
|
+
const { done, value } = await reader.read();
|
|
64
|
+
if (done) break;
|
|
65
|
+
if (!value || value.byteLength === 0) continue;
|
|
66
|
+
totalBytes += value.byteLength;
|
|
67
|
+
if (totalBytes > maxBytes) {
|
|
68
|
+
await reader.cancel(sizeLimitError(totalBytes, maxBytes));
|
|
69
|
+
throw sizeLimitError(totalBytes, maxBytes);
|
|
70
|
+
}
|
|
71
|
+
chunks.push(value);
|
|
72
|
+
}
|
|
73
|
+
} finally {
|
|
74
|
+
reader.releaseLock();
|
|
75
|
+
}
|
|
76
|
+
const body = new Uint8Array(totalBytes);
|
|
77
|
+
let offset = 0;
|
|
78
|
+
for (const chunk of chunks) {
|
|
79
|
+
body.set(chunk, offset);
|
|
80
|
+
offset += chunk.byteLength;
|
|
81
|
+
}
|
|
82
|
+
return body;
|
|
83
|
+
};
|
|
84
|
+
|
|
35
85
|
//#endregion
|
|
36
86
|
//#region src/utils/sensitiveFileUploadPaths.ts
|
|
37
87
|
/**
|
|
@@ -45,7 +95,8 @@ const uint8ArrayToBase64 = (bytes) => {
|
|
|
45
95
|
*/
|
|
46
96
|
/**
|
|
47
97
|
* Path segments (a single path component) that indicate a sensitive directory when
|
|
48
|
-
* they appear anywhere in a resolved local path.
|
|
98
|
+
* they appear anywhere in a resolved local path. Matching follows the case sensitivity
|
|
99
|
+
* of the filesystem containing that path.
|
|
49
100
|
*/
|
|
50
101
|
const BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS = [
|
|
51
102
|
".ssh",
|
|
@@ -61,17 +112,19 @@ const BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS = [
|
|
|
61
112
|
const SECRET_LIKE_BASENAME = /^(\.env(\.|$)|\.netrc$|\.pgpass$)/i;
|
|
62
113
|
/** Default SSH private key basenames (public keys like id_rsa.pub are allowed). */
|
|
63
114
|
const DEFAULT_PRIVATE_KEY_BASENAME = /^id_(rsa|ed25519|ecdsa|dsa|ecdsa_sk)(\.old)?$/i;
|
|
64
|
-
const isWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
65
115
|
/**
|
|
66
116
|
* Returns normalized path segments, resolving symlinks when the path exists.
|
|
67
117
|
*/
|
|
68
|
-
function
|
|
118
|
+
function normalizePath(filePath) {
|
|
69
119
|
const absolute = platform.resolvePath(filePath);
|
|
70
120
|
let resolved = absolute;
|
|
71
121
|
try {
|
|
72
122
|
if (platform.existsSync(absolute)) resolved = platform.realpathSync(absolute);
|
|
73
123
|
} catch {}
|
|
74
|
-
return
|
|
124
|
+
return {
|
|
125
|
+
resolvedPath: resolved,
|
|
126
|
+
segments: resolved.split(/[/\\]+/).filter(Boolean)
|
|
127
|
+
};
|
|
75
128
|
}
|
|
76
129
|
/**
|
|
77
130
|
* True if the path is under a built-in or extra deny segment, or the basename
|
|
@@ -81,9 +134,11 @@ function isBlockedSensitiveFileUploadPath(filePath, additionalDenySegments) {
|
|
|
81
134
|
return getSensitiveFileUploadPathBlockReason(filePath, additionalDenySegments) != null;
|
|
82
135
|
}
|
|
83
136
|
function getSensitiveFileUploadPathBlockReason(filePath, additionalDenySegments) {
|
|
84
|
-
const segments =
|
|
85
|
-
const
|
|
86
|
-
const
|
|
137
|
+
const { resolvedPath, segments } = normalizePath(filePath);
|
|
138
|
+
const isCaseSensitive = platform.isFileSystemCaseSensitive?.(resolvedPath) ?? true;
|
|
139
|
+
const normalizeSegment = (segment) => isCaseSensitive ? segment : segment.toLowerCase();
|
|
140
|
+
const deny = new Set([...BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS, ...(additionalDenySegments ?? []).map((s) => s.trim()).filter(Boolean)].map(normalizeSegment));
|
|
141
|
+
const segmentsForMatch = isCaseSensitive ? segments : segments.map(normalizeSegment);
|
|
87
142
|
for (let i = 0; i < segments.length; i++) if (deny.has(segmentsForMatch[i])) return `path segment "${segments[i]}" is in the sensitive file upload denylist`;
|
|
88
143
|
const basename = segments.length > 0 ? segments[segments.length - 1] : "";
|
|
89
144
|
if (basename) {
|
|
@@ -111,4 +166,4 @@ function assertSafeFileUploadPath(filePath, options) {
|
|
|
111
166
|
}
|
|
112
167
|
|
|
113
168
|
//#endregion
|
|
114
|
-
export {
|
|
169
|
+
export { arrayBufferToBase64 as a, getRandomShortId as c, readResponseBodyWithLimit as i, getRandomUUID as l, assertSafeFileUploadPath as n, base64ToUint8Array as o, isBlockedSensitiveFileUploadPath as r, uint8ArrayToBase64 as s, BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS as t };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as BaseComposioProvider } from "./BaseProvider-
|
|
2
|
-
import { n as ComposioConfig } from "./composio-
|
|
3
|
-
|
|
1
|
+
import { n as BaseComposioProvider } from "./BaseProvider-BN2-Nktx.mjs";
|
|
2
|
+
import { n as ComposioConfig } from "./composio-Bf8hnBBq.mjs";
|
|
4
3
|
//#region src/utils/config-defaults/types.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Configuration defaults for Composio.
|
|
@@ -46,6 +46,14 @@ interface Platform {
|
|
|
46
46
|
* @returns The resolved path, or the input path if it cannot be resolved.
|
|
47
47
|
*/
|
|
48
48
|
realpathSync(filePath: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Returns whether paths on the filesystem containing `filePath` are
|
|
51
|
+
* case-sensitive. Node checks the nearest existing directory so the result
|
|
52
|
+
* follows the target mount rather than the operating-system default.
|
|
53
|
+
* Runtimes without a filesystem return true to preserve exact path matching.
|
|
54
|
+
* @param filePath - A file or directory on the filesystem to inspect.
|
|
55
|
+
*/
|
|
56
|
+
isFileSystemCaseSensitive?(filePath: string): boolean;
|
|
49
57
|
/**
|
|
50
58
|
* Creates a directory at the given path, including parent directories if needed.
|
|
51
59
|
* @param dirPath - The directory path to create.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { gn as Tool, xn as ToolExecuteResponse, yn as ToolExecuteParams } from "../../BaseProvider-
|
|
1
|
+
import { gn as Tool, xn as ToolExecuteResponse, yn as ToolExecuteParams } from "../../BaseProvider-BN2-Nktx.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/modifiers/FileToolModifier.node.d.ts
|
|
5
4
|
declare class FileToolModifier {
|
|
6
5
|
private client;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as ComposioRequestCancelledError } from "../../errors-
|
|
1
|
+
import { i as logger } from "../../SsrfErrors-DNJt57GL.mjs";
|
|
2
|
+
import { f as ComposioRequestCancelledError } from "../../errors-BcEUHZbq.mjs";
|
|
3
|
+
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "../../FileModifierErrors-B8V8_3VE.mjs";
|
|
3
4
|
import { i as transformProperties, n as schemaHasFileProperty, t as isPlainObject } from "../../FileToolModifier.utils.neutral-B5rT711M.mjs";
|
|
4
|
-
import { r as dereferenceJsonSchema, t as withCancellation } from "../../cancellation-
|
|
5
|
-
import { n as getFileDataAfterUploadingToS3, r as isHttpUrl, t as downloadFileFromS3 } from "../../fileUtils.node-
|
|
5
|
+
import { r as dereferenceJsonSchema, t as withCancellation } from "../../cancellation-BbJ-UQ__.mjs";
|
|
6
|
+
import { n as getFileDataAfterUploadingToS3, r as isHttpUrl, t as downloadFileFromS3 } from "../../fileUtils.node-BQ0fWge3.mjs";
|
|
6
7
|
|
|
7
8
|
//#region src/utils/modifiers/FileToolModifier.node.ts
|
|
8
9
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { gn as Tool, xn as ToolExecuteResponse, yn as ToolExecuteParams } from "../../BaseProvider-
|
|
1
|
+
import { gn as Tool, xn as ToolExecuteResponse, yn as ToolExecuteParams } from "../../BaseProvider-BN2-Nktx.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/modifiers/FileToolModifier.workerd.d.ts
|
|
5
4
|
declare class FileToolModifier {
|
|
6
5
|
constructor(_client: ComposioClient);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/utils/ssrfGuard.node.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* True when `ip` is a private, loopback, link-local, or otherwise
|
|
4
|
+
* non-publicly-routable address. Fails closed (returns `true`) for anything that
|
|
5
|
+
* is not a valid IPv4/IPv6 literal.
|
|
6
|
+
*/
|
|
7
|
+
declare const isBlockedIp: (ip: string) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Validate a single URL: it must be http(s), its host must resolve, and every
|
|
10
|
+
* resolved address must be publicly routable. Throws
|
|
11
|
+
* {@link ComposioBlockedInternalUrlError} otherwise.
|
|
12
|
+
*/
|
|
13
|
+
declare const assertSafeFetchTarget: (rawUrl: string) => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Drop-in replacement for `fetch` that blocks SSRF. Validates the target before
|
|
16
|
+
* connecting and re-validates every redirect hop (redirects are followed
|
|
17
|
+
* manually up to {@link MAX_REDIRECTS}). Intermediate redirect bodies are
|
|
18
|
+
* cancelled; non-redirect responses are returned unchanged.
|
|
19
|
+
*/
|
|
20
|
+
declare const ssrfSafeFetch: (rawUrl: string, init?: RequestInit, maxRedirects?: number) => Promise<Response>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { assertSafeFetchTarget, isBlockedIp, ssrfSafeFetch };
|