@composio/core 0.13.1 → 0.14.1
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 +62 -247
- package/dist/BaseProvider-Dc5yKZhk.d.mts +29394 -0
- package/dist/{CustomTool-DLf7JeKt.d.mts → CustomTool-4nVuwLzO.d.mts} +1 -2
- package/dist/{CustomTool-D9qwyMrv.mjs → CustomTool-l-j5HtEf.mjs} +17 -15
- package/dist/FileModifierErrors-B8V8_3VE.mjs +97 -0
- package/dist/{FileModifierErrors-3fSwIWoa.mjs → SsrfErrors-DNJt57GL.mjs} +24 -85
- package/dist/{Telemetry-DhGI_J4G.mjs → Telemetry-CF0rNHu2.mjs} +40 -8
- package/dist/{jsonSchema-CFKdONpP.mjs → cancellation-BbJ-UQ__.mjs} +64 -19
- package/dist/{composio-BHSQwOUz.d.mts → composio-ChU3eD9F.d.mts} +1083 -1061
- package/dist/{customTool.types-9yFqPjdw.d.mts → customTool.types-CX2-LbfI.d.mts} +634 -601
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +1 -22
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +2 -0
- package/dist/{errors-DSIlYfl5.mjs → errors-BcEUHZbq.mjs} +75 -74
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-BiO1JQsJ.mjs → fileUtils.node-DOkW4PBg.mjs} +36 -70
- package/dist/index.d.mts +2446 -1563
- package/dist/index.mjs +1415 -1381
- 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 +3 -0
- package/dist/platform/workerd.d.mts +1 -2
- package/dist/platform/workerd.mjs +30 -3
- package/dist/sensitiveFileUploadPaths-C43dHP7S.mjs +164 -0
- package/dist/{types-BJLCRj9q.d.mts → types-D5N60gUD.d.mts} +2 -3
- package/dist/{types-DdoCRzLj.d.mts → types-DY1r-kN9.d.mts} +9 -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 +6 -5
- 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 +152 -0
- package/dist/utils/ssrfGuard.workerd.d.mts +9 -0
- package/dist/utils/ssrfGuard.workerd.mjs +17 -0
- package/package.json +20 -15
- package/src/errors/SsrfErrors.ts +48 -0
- package/src/errors/index.ts +3 -0
- package/src/index.ts +10 -0
- package/src/models/CustomTool.ts +1 -3
- package/src/models/ToolRouterSession.ts +38 -16
- package/src/models/ToolRouterSessionFileMount.ts +7 -3
- package/src/models/Tools.ts +32 -2
- package/src/models/Triggers.ts +16 -76
- package/src/platform/node.ts +4 -0
- package/src/platform/types.ts +10 -0
- package/src/platform/workerd.ts +36 -3
- package/src/provider/OpenAIProvider.ts +19 -14
- package/src/telemetry/Telemetry.ts +9 -6
- package/src/telemetry/redact.ts +40 -0
- package/src/types/tool.types.ts +36 -32
- package/src/utils/fileUtils.node.ts +29 -6
- package/src/utils/jsonSchema.ts +58 -0
- package/src/utils/modifiers/FileToolModifier.node.ts +2 -1
- package/src/utils/readResponseBody.ts +63 -0
- package/src/utils/sdk.ts +5 -4
- package/src/utils/{sensitiveFileUploadPaths.node.ts → sensitiveFileUploadPaths.ts} +29 -13
- package/src/utils/ssrfGuard.node.ts +202 -0
- package/src/utils/ssrfGuard.workerd.ts +19 -0
- package/src/utils/toolkitVersion.ts +21 -2
- package/dist/BaseProvider-Brb3o86-.d.mts +0 -29425
- package/dist/CustomTool-NpHpqdnU.d.mts +0 -74
- package/dist/buffer-PcbMMsgm.mjs +0 -33
- package/dist/composio-DfPD7BAi.d.mts +0 -5666
- package/dist/customTool.types-D-6YqFdW.d.mts +0 -2826
- package/dist/types-CCh8qvui.d.mts +0 -12
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as CreateCustomToolkitParams, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams, t as AnyZodSchema } from "./customTool.types-
|
|
1
|
+
import { a as CreateCustomToolkitParams, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams, t as AnyZodSchema } from "./customTool.types-CX2-LbfI.mjs";
|
|
2
2
|
import { SessionCreateResponse } from "@composio/client/resources/tool-router/session/session.mjs";
|
|
3
|
-
|
|
4
3
|
//#region src/models/CustomTool.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Create a custom tool for use in tool router sessions.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { z } from "zod/v3";
|
|
1
|
+
import { _ as ValidationError } from "./errors-BcEUHZbq.mjs";
|
|
2
|
+
import { z as z$1 } from "zod/v3";
|
|
3
3
|
import * as z4 from "zod/v4";
|
|
4
4
|
import * as zodToJsonSchema from "zod-to-json-schema";
|
|
5
5
|
|
|
@@ -9,32 +9,32 @@ import * as zodToJsonSchema from "zod-to-json-schema";
|
|
|
9
9
|
* Alphanumeric, underscores, and hyphens only. No `LOCAL_` or `COMPOSIO_` prefix.
|
|
10
10
|
* Length is validated contextually (standalone vs extension vs toolkit) at creation time.
|
|
11
11
|
*/
|
|
12
|
-
const CustomToolSlugSchema = z.string().min(1, "slug is required").regex(/^[A-Za-z0-9_-]+$/, "slug must only contain alphanumeric characters, underscores, and hyphens").refine((s) => !s.toUpperCase().startsWith("LOCAL_"), { message: "slug must not start with \"LOCAL_\" — this prefix is reserved for internal routing." }).refine((s) => !s.toUpperCase().startsWith("COMPOSIO_"), { message: "slug must not start with \"COMPOSIO_\" — this prefix is reserved for Composio meta tools." });
|
|
12
|
+
const CustomToolSlugSchema = z$1.string().min(1, "slug is required").regex(/^[A-Za-z0-9_-]+$/, "slug must only contain alphanumeric characters, underscores, and hyphens").refine((s) => !s.toUpperCase().startsWith("LOCAL_"), { message: "slug must not start with \"LOCAL_\" — this prefix is reserved for internal routing." }).refine((s) => !s.toUpperCase().startsWith("COMPOSIO_"), { message: "slug must not start with \"COMPOSIO_\" — this prefix is reserved for Composio meta tools." });
|
|
13
13
|
/**
|
|
14
14
|
* Zod schema for validating the string/scalar fields of createCustomTool() options.
|
|
15
15
|
* Slug is validated separately as the first argument.
|
|
16
16
|
* Used internally for validation — inputParams, outputParams, and execute are checked manually.
|
|
17
17
|
*/
|
|
18
|
-
const CreateCustomToolBaseSchema = z.object({
|
|
19
|
-
name: z.string().min(1, "createCustomTool: name is required"),
|
|
20
|
-
description: z.string().min(1, "createCustomTool: description is required"),
|
|
18
|
+
const CreateCustomToolBaseSchema = z$1.object({
|
|
19
|
+
name: z$1.string().min(1, "createCustomTool: name is required"),
|
|
20
|
+
description: z$1.string().min(1, "createCustomTool: description is required"),
|
|
21
21
|
/**
|
|
22
22
|
* Composio toolkit slug that this tool extends (inherits auth from).
|
|
23
23
|
* Must be a valid Composio toolkit slug (e.g. `'gmail'`, `'github'`, `'meta_ads'`).
|
|
24
24
|
* The backend validates this against the toolkit catalog.
|
|
25
25
|
* Leave empty for tools that don't need any Composio-managed authentication.
|
|
26
26
|
*/
|
|
27
|
-
extendsToolkit: z.string().optional(),
|
|
28
|
-
preload: z.boolean().optional().describe("When true, include this custom tool in session.tools() so it can be called without searching first.")
|
|
27
|
+
extendsToolkit: z$1.string().optional(),
|
|
28
|
+
preload: z$1.boolean().optional().describe("When true, include this custom tool in session.tools() so it can be called without searching first.")
|
|
29
29
|
});
|
|
30
30
|
/**
|
|
31
31
|
* Zod schema for validating the string/scalar fields of createCustomToolkit() options.
|
|
32
32
|
* Slug is validated separately as the first argument.
|
|
33
33
|
*/
|
|
34
|
-
const CreateCustomToolkitBaseSchema = z.object({
|
|
35
|
-
name: z.string().min(1, "createCustomToolkit: name is required"),
|
|
36
|
-
description: z.string().min(1, "createCustomToolkit: description is required"),
|
|
37
|
-
preload: z.boolean().optional().describe("When true, include tools from this custom toolkit in session.tools(). Tool-level preload values override this default.")
|
|
34
|
+
const CreateCustomToolkitBaseSchema = z$1.object({
|
|
35
|
+
name: z$1.string().min(1, "createCustomToolkit: name is required"),
|
|
36
|
+
description: z$1.string().min(1, "createCustomToolkit: description is required"),
|
|
37
|
+
preload: z$1.boolean().optional().describe("When true, include tools from this custom toolkit in session.tools(). Tool-level preload values override this default.")
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
//#endregion
|
|
@@ -56,11 +56,12 @@ const isZodObjectSchema = (value) => {
|
|
|
56
56
|
};
|
|
57
57
|
const zodSchemaToJsonSchema = (schema, name = "schema", mode = "output") => {
|
|
58
58
|
if (isZodV4Schema(schema)) return stripSchemaKeyword(z4.toJSONSchema(schema, { io: mode }));
|
|
59
|
-
|
|
59
|
+
const converted = zodToJsonSchema.default(schema, {
|
|
60
60
|
name,
|
|
61
61
|
pipeStrategy: mode,
|
|
62
62
|
effectStrategy: mode === "input" ? "input" : "any"
|
|
63
|
-
})
|
|
63
|
+
});
|
|
64
|
+
return stripSchemaKeyword(getNamedDefinition(converted, name));
|
|
64
65
|
};
|
|
65
66
|
const zodObjectSchemaToJsonSchema = (schema, name = "schema", mode = "input") => {
|
|
66
67
|
if (!isZodObjectSchema(schema)) throw new Error("Expected a z.object() schema.");
|
|
@@ -114,7 +115,8 @@ function validateSlugLength(toolSlug, toolkitSlug, context) {
|
|
|
114
115
|
const finalLength = computeFinalSlugLength(toolSlug, toolkitSlug);
|
|
115
116
|
if (finalLength > MAX_SLUG_LENGTH) {
|
|
116
117
|
const prefix = LOCAL_TOOL_PREFIX + (toolkitSlug ? `${toolkitSlug.toUpperCase()}_` : "");
|
|
117
|
-
|
|
118
|
+
const available = MAX_SLUG_LENGTH - prefix.length;
|
|
119
|
+
throw new ValidationError(`${context}: slug "${toolSlug}" is too long. With prefix "${prefix}", the final slug would be ${finalLength} characters (max ${MAX_SLUG_LENGTH}). Shorten the slug to at most ${available} characters.`);
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
/**
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { r as ComposioError } from "./SsrfErrors-DNJt57GL.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/errors/FileModifierErrors.ts
|
|
4
|
+
const FileModifierErrorCodes = {
|
|
5
|
+
FILE_UPLOAD_FAILED: "FILE_UPLOAD_FAILED",
|
|
6
|
+
SENSITIVE_FILE_PATH_BLOCKED: "SENSITIVE_FILE_PATH_BLOCKED",
|
|
7
|
+
FILE_UPLOAD_ABORTED: "FILE_UPLOAD_ABORTED",
|
|
8
|
+
FILE_UPLOAD_PATH_NOT_ALLOWED: "FILE_UPLOAD_PATH_NOT_ALLOWED",
|
|
9
|
+
FILE_NOT_FOUND: "FILE_NOT_FOUND"
|
|
10
|
+
};
|
|
11
|
+
var ComposioFileUploadError = class extends ComposioError {
|
|
12
|
+
constructor(message = "Failed to upload file", options = {}) {
|
|
13
|
+
super(message, {
|
|
14
|
+
...options,
|
|
15
|
+
code: options.code ?? FileModifierErrorCodes.FILE_UPLOAD_FAILED,
|
|
16
|
+
possibleFixes: options.possibleFixes || ["Check if the file exists in the location provided"]
|
|
17
|
+
});
|
|
18
|
+
this.name = "ComposioFileUploadError";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Thrown when a local file path is refused before upload (sensitive directory or
|
|
23
|
+
* credential-like file name). Subclass of {@link ComposioFileUploadError} so existing
|
|
24
|
+
* `instanceof ComposioFileUploadError` handlers still apply.
|
|
25
|
+
*/
|
|
26
|
+
var ComposioSensitiveFilePathBlockedError = class extends ComposioFileUploadError {
|
|
27
|
+
constructor(message, options = {}) {
|
|
28
|
+
super(message, {
|
|
29
|
+
...options,
|
|
30
|
+
code: FileModifierErrorCodes.SENSITIVE_FILE_PATH_BLOCKED,
|
|
31
|
+
possibleFixes: options.possibleFixes ?? [
|
|
32
|
+
"Use a file outside ~/.ssh, ~/.aws, and other credential locations",
|
|
33
|
+
"Set sensitiveFileUploadProtection: false only if you understand the risk",
|
|
34
|
+
"Add path segments to block with fileUploadPathDenySegments"
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
this.name = "ComposioSensitiveFilePathBlockedError";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Thrown when a `beforeFileUpload` hook returns `false`.
|
|
42
|
+
*/
|
|
43
|
+
var ComposioFileUploadAbortedError = class extends ComposioFileUploadError {
|
|
44
|
+
constructor(message, options = {}) {
|
|
45
|
+
super(message, {
|
|
46
|
+
...options,
|
|
47
|
+
code: FileModifierErrorCodes.FILE_UPLOAD_ABORTED,
|
|
48
|
+
possibleFixes: options.possibleFixes ?? ["Change beforeFileUpload to return a file path to upload, or allow the upload to proceed"]
|
|
49
|
+
});
|
|
50
|
+
this.name = "ComposioFileUploadAbortedError";
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Thrown when automatic file upload during tool execution is attempted from a path
|
|
55
|
+
* that is outside the configured {@link ComposioConfig.fileUploadDirs} allowlist.
|
|
56
|
+
*
|
|
57
|
+
* This only fires for auto-upload (enabled via
|
|
58
|
+
* `dangerouslyAllowAutoUploadDownloadFiles: true`). Manual `composio.files.upload()`
|
|
59
|
+
* calls are never subject to this check.
|
|
60
|
+
*/
|
|
61
|
+
var ComposioFileUploadPathNotAllowedError = class extends ComposioFileUploadError {
|
|
62
|
+
constructor(message, options = {}) {
|
|
63
|
+
super(message, {
|
|
64
|
+
...options,
|
|
65
|
+
code: FileModifierErrorCodes.FILE_UPLOAD_PATH_NOT_ALLOWED,
|
|
66
|
+
possibleFixes: options.possibleFixes ?? [
|
|
67
|
+
"Move the file under one of the directories in `fileUploadDirs`",
|
|
68
|
+
"Stage the file under the default upload dir (`~/.composio/temp`)",
|
|
69
|
+
"Add the containing directory to `fileUploadDirs` when constructing Composio",
|
|
70
|
+
"Pass the file by URL or as a File/Blob object instead of a filesystem path"
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
this.name = "ComposioFileUploadPathNotAllowedError";
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Thrown when a local file path passed for upload does not exist on disk.
|
|
78
|
+
* Provides extra debugging context (resolved absolute path, cwd, allowlist state)
|
|
79
|
+
* to help the caller distinguish between "typo" and "not-allowlisted" failures.
|
|
80
|
+
*/
|
|
81
|
+
var ComposioFileNotFoundError = class extends ComposioFileUploadError {
|
|
82
|
+
constructor(message, options = {}) {
|
|
83
|
+
super(message, {
|
|
84
|
+
...options,
|
|
85
|
+
code: FileModifierErrorCodes.FILE_NOT_FOUND,
|
|
86
|
+
possibleFixes: options.possibleFixes ?? [
|
|
87
|
+
"Double-check the path for typos",
|
|
88
|
+
"Remember relative paths are resolved against process.cwd() at upload time",
|
|
89
|
+
"Verify the file exists and the process has read permission"
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
this.name = "ComposioFileNotFoundError";
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
export { ComposioSensitiveFilePathBlockedError as a, ComposioFileUploadPathNotAllowedError as i, ComposioFileUploadAbortedError as n, FileModifierErrorCodes as o, ComposioFileUploadError as r, ComposioFileNotFoundError as t };
|
|
@@ -348,98 +348,37 @@ var ComposioError$1 = class ComposioError$1 extends Error {
|
|
|
348
348
|
};
|
|
349
349
|
|
|
350
350
|
//#endregion
|
|
351
|
-
//#region src/errors/
|
|
352
|
-
const
|
|
353
|
-
FILE_UPLOAD_FAILED: "FILE_UPLOAD_FAILED",
|
|
354
|
-
SENSITIVE_FILE_PATH_BLOCKED: "SENSITIVE_FILE_PATH_BLOCKED",
|
|
355
|
-
FILE_UPLOAD_ABORTED: "FILE_UPLOAD_ABORTED",
|
|
356
|
-
FILE_UPLOAD_PATH_NOT_ALLOWED: "FILE_UPLOAD_PATH_NOT_ALLOWED",
|
|
357
|
-
FILE_NOT_FOUND: "FILE_NOT_FOUND"
|
|
358
|
-
};
|
|
359
|
-
var ComposioFileUploadError = class extends ComposioError$1 {
|
|
360
|
-
constructor(message = "Failed to upload file", options = {}) {
|
|
361
|
-
super(message, {
|
|
362
|
-
...options,
|
|
363
|
-
code: options.code ?? FileModifierErrorCodes.FILE_UPLOAD_FAILED,
|
|
364
|
-
possibleFixes: options.possibleFixes || ["Check if the file exists in the location provided"]
|
|
365
|
-
});
|
|
366
|
-
this.name = "ComposioFileUploadError";
|
|
367
|
-
}
|
|
368
|
-
};
|
|
351
|
+
//#region src/errors/SsrfErrors.ts
|
|
352
|
+
const SsrfErrorCodes = { BLOCKED_INTERNAL_URL: "BLOCKED_INTERNAL_URL" };
|
|
369
353
|
/**
|
|
370
|
-
* Thrown when a
|
|
371
|
-
*
|
|
372
|
-
*
|
|
354
|
+
* Thrown when a URL file input resolves to a private, loopback, link-local, or
|
|
355
|
+
* otherwise internal address, or points at a non-http(s) scheme. Guards against
|
|
356
|
+
* turning URL-based file uploads (including Tool Router session files and
|
|
357
|
+
* automatic upload during tool execution) into a server-side request forgery
|
|
358
|
+
* (SSRF) probe of internal infrastructure such as cloud metadata endpoints
|
|
359
|
+
* (`169.254.169.254`).
|
|
373
360
|
*/
|
|
374
|
-
var
|
|
375
|
-
constructor(message, options = {}) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
"Add path segments to block with fileUploadPathDenySegments"
|
|
383
|
-
]
|
|
384
|
-
});
|
|
385
|
-
this.name = "ComposioSensitiveFilePathBlockedError";
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
/**
|
|
389
|
-
* Thrown when a `beforeFileUpload` hook returns `false`.
|
|
390
|
-
*/
|
|
391
|
-
var ComposioFileUploadAbortedError = class extends ComposioFileUploadError {
|
|
392
|
-
constructor(message, options = {}) {
|
|
393
|
-
super(message, {
|
|
394
|
-
...options,
|
|
395
|
-
code: FileModifierErrorCodes.FILE_UPLOAD_ABORTED,
|
|
396
|
-
possibleFixes: options.possibleFixes ?? ["Change beforeFileUpload to return a file path to upload, or allow the upload to proceed"]
|
|
397
|
-
});
|
|
398
|
-
this.name = "ComposioFileUploadAbortedError";
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
/**
|
|
402
|
-
* Thrown when automatic file upload during tool execution is attempted from a path
|
|
403
|
-
* that is outside the configured {@link ComposioConfig.fileUploadDirs} allowlist.
|
|
404
|
-
*
|
|
405
|
-
* This only fires for auto-upload (enabled via
|
|
406
|
-
* `dangerouslyAllowAutoUploadDownloadFiles: true`). Manual `composio.files.upload()`
|
|
407
|
-
* calls are never subject to this check.
|
|
408
|
-
*/
|
|
409
|
-
var ComposioFileUploadPathNotAllowedError = class extends ComposioFileUploadError {
|
|
410
|
-
constructor(message, options = {}) {
|
|
411
|
-
super(message, {
|
|
412
|
-
...options,
|
|
413
|
-
code: FileModifierErrorCodes.FILE_UPLOAD_PATH_NOT_ALLOWED,
|
|
414
|
-
possibleFixes: options.possibleFixes ?? [
|
|
415
|
-
"Move the file under one of the directories in `fileUploadDirs`",
|
|
416
|
-
"Stage the file under the default upload dir (`~/.composio/temp`)",
|
|
417
|
-
"Add the containing directory to `fileUploadDirs` when constructing Composio",
|
|
418
|
-
"Pass the file by URL or as a File/Blob object instead of a filesystem path"
|
|
419
|
-
]
|
|
420
|
-
});
|
|
421
|
-
this.name = "ComposioFileUploadPathNotAllowedError";
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
/**
|
|
425
|
-
* Thrown when a local file path passed for upload does not exist on disk.
|
|
426
|
-
* Provides extra debugging context (resolved absolute path, cwd, allowlist state)
|
|
427
|
-
* to help the caller distinguish between "typo" and "not-allowlisted" failures.
|
|
428
|
-
*/
|
|
429
|
-
var ComposioFileNotFoundError = class extends ComposioFileUploadError {
|
|
430
|
-
constructor(message, options = {}) {
|
|
361
|
+
var ComposioBlockedInternalUrlError = class extends ComposioError$1 {
|
|
362
|
+
constructor(message = "Refusing to fetch an internal or non-public URL", options = {}) {
|
|
363
|
+
const { url, resolvedIp, meta: optionsMeta, ...rest } = options;
|
|
364
|
+
const meta = {
|
|
365
|
+
...optionsMeta,
|
|
366
|
+
...url && { url },
|
|
367
|
+
...resolvedIp && { resolvedIp }
|
|
368
|
+
};
|
|
431
369
|
super(message, {
|
|
432
|
-
...
|
|
433
|
-
code:
|
|
370
|
+
...rest,
|
|
371
|
+
code: SsrfErrorCodes.BLOCKED_INTERNAL_URL,
|
|
372
|
+
meta: Object.keys(meta).length > 0 ? meta : void 0,
|
|
434
373
|
possibleFixes: options.possibleFixes ?? [
|
|
435
|
-
"
|
|
436
|
-
"
|
|
437
|
-
"
|
|
374
|
+
"Use a publicly reachable http(s) URL",
|
|
375
|
+
"Do not point file inputs at localhost, link-local, or private-network hosts",
|
|
376
|
+
"If the source is internal, download it yourself and pass a File/Blob instead of a URL"
|
|
438
377
|
]
|
|
439
378
|
});
|
|
440
|
-
this.name = "
|
|
379
|
+
this.name = "ComposioBlockedInternalUrlError";
|
|
441
380
|
}
|
|
442
381
|
};
|
|
443
382
|
|
|
444
383
|
//#endregion
|
|
445
|
-
export {
|
|
384
|
+
export { COMPOSIO_DIR as a, DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID as c, USER_DATA_FILE_NAME as d, constants_exports as f, logger as i, IS_DEVELOPMENT_OR_CI as l, getEnvsWithPrefix as m, SsrfErrorCodes as n, COMPOSIO_LOG_LEVEL as o, getEnvVariable as p, ComposioError$1 as r, DEFAULT_BASE_URL as s, ComposioBlockedInternalUrlError as t, TEMP_FILES_DIRECTORY_NAME as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as logger, p as getEnvVariable, r as ComposioError$1 } from "./SsrfErrors-DNJt57GL.mjs";
|
|
2
|
+
import { l as getRandomUUID } from "./sensitiveFileUploadPaths-C43dHP7S.mjs";
|
|
3
3
|
import { ComposioError } from "@composio/client";
|
|
4
4
|
|
|
5
5
|
//#region src/types/telemetry.types.ts
|
|
@@ -99,6 +99,38 @@ var TelemetryService = class {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/telemetry/redact.ts
|
|
104
|
+
/**
|
|
105
|
+
* Best-effort redaction of secrets from free-form error text before it is sent
|
|
106
|
+
* to the telemetry endpoint.
|
|
107
|
+
*
|
|
108
|
+
* Error `message` and `stack` fields routinely interpolate URLs (with
|
|
109
|
+
* query-string tokens / presigned signatures), `Authorization` headers, API
|
|
110
|
+
* keys, and connected-account identifiers. None of that should leave the
|
|
111
|
+
* process. Structured telemetry fields never carry raw secrets, so only the two
|
|
112
|
+
* free-form strings are passed through here.
|
|
113
|
+
*
|
|
114
|
+
* This is defence-in-depth, not a proof: it targets the shapes we have seen
|
|
115
|
+
* leak. When in doubt it over-redacts rather than under-redacts.
|
|
116
|
+
*/
|
|
117
|
+
const REDACTED = "[REDACTED]";
|
|
118
|
+
const REDACTION_RULES = [
|
|
119
|
+
[/(\bhttps?:\/\/[^\s?#'"]+)\?[^\s'"]*/gi, `$1?${REDACTED}`],
|
|
120
|
+
[/\b(bearer|basic)\s+[A-Za-z0-9._~+/=-]+/gi, `$1 ${REDACTED}`],
|
|
121
|
+
[/\b(authorization|api[-_]?key|apikey|x-api-key|access[-_]?token|refresh[-_]?token|client[-_]?secret|secret|password|passwd|pwd)\b(\s*[:=]+\s*)(["']?)([^\s"',}&]+)\3/gi, `$1$2$3${REDACTED}$3`]
|
|
122
|
+
];
|
|
123
|
+
/**
|
|
124
|
+
* Redact common secret shapes from a free-form string. Returns the input
|
|
125
|
+
* unchanged when it is empty or `undefined`.
|
|
126
|
+
*/
|
|
127
|
+
const redactSensitiveText = (input) => {
|
|
128
|
+
if (!input) return input;
|
|
129
|
+
let output = input;
|
|
130
|
+
for (const [pattern, replacement] of REDACTION_RULES) output = output.replace(pattern, replacement);
|
|
131
|
+
return output;
|
|
132
|
+
};
|
|
133
|
+
|
|
102
134
|
//#endregion
|
|
103
135
|
//#region src/telemetry/Telemetry.ts
|
|
104
136
|
/**
|
|
@@ -244,21 +276,21 @@ var TelemetryTransport = class {
|
|
|
244
276
|
if (error instanceof ComposioError) telemetryPayload.error = {
|
|
245
277
|
errorId: error.errorId,
|
|
246
278
|
name: error.name,
|
|
247
|
-
message: error.message,
|
|
248
|
-
stack: error.stack
|
|
279
|
+
message: redactSensitiveText(error.message),
|
|
280
|
+
stack: redactSensitiveText(error.stack)
|
|
249
281
|
};
|
|
250
282
|
else if (error instanceof ComposioError$1) telemetryPayload.error = {
|
|
251
283
|
errorId: error.errorId,
|
|
252
284
|
name: error.name,
|
|
253
285
|
code: error.code,
|
|
254
|
-
message: error.message,
|
|
255
|
-
stack: error.stack
|
|
286
|
+
message: redactSensitiveText(error.message),
|
|
287
|
+
stack: redactSensitiveText(error.stack)
|
|
256
288
|
};
|
|
257
289
|
else if (error instanceof Error) telemetryPayload.error = {
|
|
258
290
|
errorId: error.errorId,
|
|
259
291
|
name: error.name ?? "Unknown error",
|
|
260
|
-
message: error.message,
|
|
261
|
-
stack: error.stack
|
|
292
|
+
message: redactSensitiveText(error.message),
|
|
293
|
+
stack: redactSensitiveText(error.stack)
|
|
262
294
|
};
|
|
263
295
|
this.deferTelemetry(() => this.sendErrorTelemetry(telemetryPayload));
|
|
264
296
|
}
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as logger } from "./SsrfErrors-DNJt57GL.mjs";
|
|
2
|
+
import { f as ComposioRequestCancelledError, g as JsonSchemaToZodError, h as JsonSchemaRefResolutionError, m as isRequestAbortError } from "./errors-BcEUHZbq.mjs";
|
|
3
3
|
import { t as isPlainObject } from "./FileToolModifier.utils.neutral-B5rT711M.mjs";
|
|
4
4
|
import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
|
|
5
5
|
|
|
6
|
-
//#region src/utils/cancellation.ts
|
|
7
|
-
/** @internal */
|
|
8
|
-
async function withCancellation(call, signal) {
|
|
9
|
-
try {
|
|
10
|
-
return await call();
|
|
11
|
-
} catch (error) {
|
|
12
|
-
if (signal?.aborted && isRequestAbortError(error)) {
|
|
13
|
-
const underlyingMessage = error instanceof Error ? error.message : "";
|
|
14
|
-
throw new ComposioRequestCancelledError(underlyingMessage ? `Request was cancelled by the caller: ${underlyingMessage}` : "Request was cancelled by the caller", { cause: error instanceof Error ? error : void 0 });
|
|
15
|
-
}
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
6
|
//#region src/utils/jsonSchema.ts
|
|
22
7
|
const MAX_REF_CHAIN_DEPTH = 100;
|
|
23
8
|
const MAX_NODE_DEPTH = 512;
|
|
@@ -36,7 +21,7 @@ const CYCLE_BREAK_SENTINEL = {
|
|
|
36
21
|
* (Draft 2020-12 sibling-keyword semantics).
|
|
37
22
|
*/
|
|
38
23
|
const UNRESOLVED_REF_DESCRIPTION = "Schema shape unresolved at the source — validate loosely. See https://github.com/ComposioHQ/composio/issues/3307.";
|
|
39
|
-
const POLLUTING_KEYS = new Set([
|
|
24
|
+
const POLLUTING_KEYS = /* @__PURE__ */ new Set([
|
|
40
25
|
"__proto__",
|
|
41
26
|
"constructor",
|
|
42
27
|
"prototype"
|
|
@@ -187,6 +172,51 @@ function dereferenceJsonSchema(schema, options) {
|
|
|
187
172
|
return out;
|
|
188
173
|
}
|
|
189
174
|
/**
|
|
175
|
+
* Returns a deep-cloned JSON Schema whose `required` arrays contain each entry
|
|
176
|
+
* at most once. Duplicate entries are invalid in JSON Schema 2020-12 but do
|
|
177
|
+
* not change the schema's meaning, so preserving the first occurrence is safe.
|
|
178
|
+
*
|
|
179
|
+
* Tool schemas originate both from the Composio API and direct provider calls.
|
|
180
|
+
* Keeping this normalization provider-agnostic lets every SDK provider receive
|
|
181
|
+
* canonical API schemas, while providers that further transform a schema can
|
|
182
|
+
* reapply it at their own emission boundary.
|
|
183
|
+
*/
|
|
184
|
+
function deduplicateJsonSchemaRequiredArrays(schema) {
|
|
185
|
+
const seenSchemaValues = /* @__PURE__ */ new WeakMap();
|
|
186
|
+
const seenInstanceValues = /* @__PURE__ */ new WeakMap();
|
|
187
|
+
const instanceValueKeywords = /* @__PURE__ */ new Set([
|
|
188
|
+
"const",
|
|
189
|
+
"default",
|
|
190
|
+
"enum",
|
|
191
|
+
"examples"
|
|
192
|
+
]);
|
|
193
|
+
function walk(value, isSchema, depth = 0) {
|
|
194
|
+
if (depth > MAX_NODE_DEPTH) throw new RangeError(`JSON Schema exceeds maximum nesting depth of ${MAX_NODE_DEPTH}`);
|
|
195
|
+
const seen = isSchema ? seenSchemaValues : seenInstanceValues;
|
|
196
|
+
if (Array.isArray(value)) {
|
|
197
|
+
const existing = seen.get(value);
|
|
198
|
+
if (existing) return existing;
|
|
199
|
+
const clone = [];
|
|
200
|
+
seen.set(value, clone);
|
|
201
|
+
for (const item of value) clone.push(walk(item, isSchema, depth + 1));
|
|
202
|
+
return clone;
|
|
203
|
+
}
|
|
204
|
+
if (!isPlainObject(value)) return value;
|
|
205
|
+
const existing = seen.get(value);
|
|
206
|
+
if (existing) return existing;
|
|
207
|
+
const clone = {};
|
|
208
|
+
seen.set(value, clone);
|
|
209
|
+
for (const [key, child] of Object.entries(value)) Object.defineProperty(clone, key, {
|
|
210
|
+
configurable: true,
|
|
211
|
+
enumerable: true,
|
|
212
|
+
value: isSchema && key === "required" && Array.isArray(child) ? [...new Set(walk(child, false, depth + 1))] : walk(child, isSchema && !instanceValueKeywords.has(key), depth + 1),
|
|
213
|
+
writable: true
|
|
214
|
+
});
|
|
215
|
+
return clone;
|
|
216
|
+
}
|
|
217
|
+
return walk(schema, true);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
190
220
|
* Removes all non-required properties from the schema
|
|
191
221
|
*
|
|
192
222
|
* if no items are required, the schema is returned as is
|
|
@@ -248,4 +278,19 @@ function jsonSchemaToZodSchema(jsonSchema, { strict } = { strict: false }) {
|
|
|
248
278
|
}
|
|
249
279
|
|
|
250
280
|
//#endregion
|
|
251
|
-
|
|
281
|
+
//#region src/utils/cancellation.ts
|
|
282
|
+
/** @internal */
|
|
283
|
+
async function withCancellation(call, signal) {
|
|
284
|
+
try {
|
|
285
|
+
return await call();
|
|
286
|
+
} catch (error) {
|
|
287
|
+
if (signal?.aborted && isRequestAbortError(error)) {
|
|
288
|
+
const underlyingMessage = error instanceof Error ? error.message : "";
|
|
289
|
+
throw new ComposioRequestCancelledError(underlyingMessage ? `Request was cancelled by the caller: ${underlyingMessage}` : "Request was cancelled by the caller", { cause: error instanceof Error ? error : void 0 });
|
|
290
|
+
}
|
|
291
|
+
throw error;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
//#endregion
|
|
296
|
+
export { removeNonRequiredProperties as a, jsonSchemaToZodSchema as i, deduplicateJsonSchemaRequiredArrays as n, dereferenceJsonSchema as r, withCancellation as t };
|