@composio/core 0.12.0 → 0.13.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-Brb3o86-.d.mts +29425 -0
- package/dist/{CustomTool-DEB4BQPl.mjs → CustomTool-D9qwyMrv.mjs} +1 -1
- package/dist/{CustomTool-DH18rVQu.d.mts → CustomTool-Dmi6ti3I.d.mts} +1 -1
- package/dist/CustomTool-DrJpOhY2.d.mts +74 -0
- package/dist/{composio-CHnEggnv.d.mts → composio-DHIKRdeG.d.mts} +253 -37
- package/dist/composio-vMwhASRc.d.mts +5698 -0
- package/dist/{customTool.types-DpIdOJjL.d.mts → customTool.types-CKH2R2ia.d.mts} +344 -25
- package/dist/customTool.types-DXin7Cfc.d.mts +2773 -0
- package/dist/docs/error-consistency.md +97 -0
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +306 -0
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +205 -0
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +488 -0
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +94 -0
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +67 -0
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +304 -0
- package/dist/docs/reference/sdk-reference/typescript/meta.json +17 -0
- package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +107 -0
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +163 -0
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +229 -0
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +131 -0
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +169 -0
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +453 -0
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +434 -0
- package/dist/{errors-D5f4pfvI.mjs → errors-DSIlYfl5.mjs} +2 -2
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/index.d.mts +27 -4
- package/dist/index.mjs +423 -123
- package/dist/{jsonSchema-daqF3S3d.mjs → jsonSchema-CFKdONpP.mjs} +1 -1
- package/dist/{types-CaI5Z4PA.d.mts → types-D4Id3wXA.d.mts} +1 -1
- package/dist/types-qTbYYBJw.d.mts +12 -0
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +2 -2
- package/docs/error-consistency.md +97 -0
- package/package.json +4 -3
- package/src/composio.ts +509 -0
- package/src/errors/AuthConfigErrors.ts +23 -0
- package/src/errors/ComposioError.ts +408 -0
- package/src/errors/ConnectedAccountsErrors.ts +158 -0
- package/src/errors/ConnectionRequestErrors.ts +32 -0
- package/src/errors/FileModifierErrors.ts +100 -0
- package/src/errors/PusherErrors.ts +28 -0
- package/src/errors/RemoteFileErrors.ts +62 -0
- package/src/errors/SDKErrors.ts +92 -0
- package/src/errors/ToolErrors.ts +244 -0
- package/src/errors/ToolkitErrors.ts +39 -0
- package/src/errors/TriggerErrors.ts +120 -0
- package/src/errors/ValidationErrors.ts +99 -0
- package/src/errors/index.ts +41 -0
- package/src/experimental/index.ts +28 -0
- package/src/index.ts +64 -0
- package/src/lib/toolRouterConstants.ts +1 -0
- package/src/lib/toolRouterParams.ts +306 -0
- package/src/models/AuthConfigs.ts +398 -0
- package/src/models/AuthScheme.ts +206 -0
- package/src/models/ConnectedAccounts.ts +735 -0
- package/src/models/ConnectionRequest.ts +150 -0
- package/src/models/CustomTool.ts +676 -0
- package/src/models/Experimental.ts +202 -0
- package/src/models/Files.node.ts +93 -0
- package/src/models/Files.workerd.ts +49 -0
- package/src/models/MCP.ts +478 -0
- package/src/models/RemoteFile.ts +172 -0
- package/src/models/SessionContext.ts +147 -0
- package/src/models/Sessions.ts +21 -0
- package/src/models/ToolRouter.ts +391 -0
- package/src/models/ToolRouterSession.ts +827 -0
- package/src/models/ToolRouterSessionFileMount.ts +389 -0
- package/src/models/Toolkits.ts +412 -0
- package/src/models/Tools.ts +1260 -0
- package/src/models/Triggers.ts +1381 -0
- package/src/models/customToolExecution.ts +118 -0
- package/src/models/inlineCustomToolsPayload.ts +17 -0
- package/src/models/proxyParamsTransform.ts +26 -0
- package/src/provider/BaseProvider.ts +138 -0
- package/src/provider/ComposioProvider.ts +29 -0
- package/src/provider/OpenAIProvider.ts +547 -0
- package/src/services/internal/InternalService.ts +50 -0
- package/src/services/internal/InternalService.types.ts +14 -0
- package/src/services/pusher/Pusher.ts +230 -0
- package/src/services/telemetry/TelemetryService.ts +48 -0
- package/src/services/telemetry/TelemetryService.types.ts +67 -0
- package/src/telemetry/BatchProcessor.ts +77 -0
- package/src/telemetry/README.md +123 -0
- package/src/telemetry/Telemetry.ts +356 -0
- package/src/types/ToolRouterSessionFilesMount.types.ts +96 -0
- package/src/types/authConfigs.types.ts +174 -0
- package/src/types/composio.types.ts +1 -0
- package/src/types/connectedAccountAuthStates.types.ts +852 -0
- package/src/types/connectedAccounts.types.ts +395 -0
- package/src/types/connectionRequest.types.ts +16 -0
- package/src/types/customTool.types.ts +261 -0
- package/src/types/files.types.ts +15 -0
- package/src/types/mcp.experimental.types.ts +163 -0
- package/src/types/mcp.types.ts +362 -0
- package/src/types/modifiers.types.ts +663 -0
- package/src/types/org.types.ts +0 -0
- package/src/types/provider.types.ts +41 -0
- package/src/types/pusher.types.ts +18 -0
- package/src/types/requestOptions.types.ts +62 -0
- package/src/types/telemetry.types.ts +89 -0
- package/src/types/tool.types.ts +408 -0
- package/src/types/toolRouter.types.ts +761 -0
- package/src/types/toolkit.types.ts +130 -0
- package/src/types/triggers.types.ts +401 -0
- package/src/types/webhookEvents.types.ts +219 -0
- package/src/utils/buffer.ts +30 -0
- package/src/utils/cancellation.ts +22 -0
- package/src/utils/config-defaults/ConfigDefaults.node.ts +7 -0
- package/src/utils/config-defaults/ConfigDefaults.workerd.ts +10 -0
- package/src/utils/config-defaults/index.ts +1 -0
- package/src/utils/config-defaults/types.ts +14 -0
- package/src/utils/constants.ts +22 -0
- package/src/utils/crypto.ts +34 -0
- package/src/utils/env.ts +34 -0
- package/src/utils/fileDirs.ts +81 -0
- package/src/utils/fileUtils.node.ts +458 -0
- package/src/utils/json-schema.ts +1 -0
- package/src/utils/jsonSchema.ts +355 -0
- package/src/utils/logger.ts +99 -0
- package/src/utils/mime.ts +75 -0
- package/src/utils/modifiers/FileToolModifier.node.ts +477 -0
- package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +132 -0
- package/src/utils/modifiers/FileToolModifier.workerd.ts +51 -0
- package/src/utils/pagination.ts +73 -0
- package/src/utils/pusher.ts +286 -0
- package/src/utils/schemaPropertyKeys.ts +433 -0
- package/src/utils/sdk.ts +110 -0
- package/src/utils/sensitiveFileUploadPaths.node.ts +105 -0
- package/src/utils/session.ts +114 -0
- package/src/utils/toolArguments.ts +73 -0
- package/src/utils/toolkitVersion.ts +26 -0
- package/src/utils/transform.ts +42 -0
- package/src/utils/transformers/authConfigs.ts +107 -0
- package/src/utils/transformers/connectedAccounts.ts +119 -0
- package/src/utils/transformers/mcp.ts +164 -0
- package/src/utils/transformers/toolRouterResponseTransform.ts +160 -0
- package/src/utils/transformers/toolkits.ts +100 -0
- package/src/utils/transformers/triggers.ts +118 -0
- package/src/utils/uploadDirAllowlist.node.ts +178 -0
- package/src/utils/uuid.ts +7 -0
- package/src/utils/version.ts +58 -0
- package/src/utils/zodSchema.ts +90 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ComposioError, ComposioErrorOptions } from './ComposioError';
|
|
2
|
+
|
|
3
|
+
export const FileModifierErrorCodes = {
|
|
4
|
+
FILE_UPLOAD_FAILED: 'FILE_UPLOAD_FAILED',
|
|
5
|
+
SENSITIVE_FILE_PATH_BLOCKED: 'SENSITIVE_FILE_PATH_BLOCKED',
|
|
6
|
+
FILE_UPLOAD_ABORTED: 'FILE_UPLOAD_ABORTED',
|
|
7
|
+
FILE_UPLOAD_PATH_NOT_ALLOWED: 'FILE_UPLOAD_PATH_NOT_ALLOWED',
|
|
8
|
+
FILE_NOT_FOUND: 'FILE_NOT_FOUND',
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
export class ComposioFileUploadError extends ComposioError {
|
|
12
|
+
constructor(message: string = 'Failed to upload file', options: ComposioErrorOptions = {}) {
|
|
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
|
+
/**
|
|
23
|
+
* Thrown when a local file path is refused before upload (sensitive directory or
|
|
24
|
+
* credential-like file name). Subclass of {@link ComposioFileUploadError} so existing
|
|
25
|
+
* `instanceof ComposioFileUploadError` handlers still apply.
|
|
26
|
+
*/
|
|
27
|
+
export class ComposioSensitiveFilePathBlockedError extends ComposioFileUploadError {
|
|
28
|
+
constructor(message: string, options: ComposioErrorOptions = {}) {
|
|
29
|
+
super(message, {
|
|
30
|
+
...options,
|
|
31
|
+
code: FileModifierErrorCodes.SENSITIVE_FILE_PATH_BLOCKED,
|
|
32
|
+
possibleFixes: options.possibleFixes ?? [
|
|
33
|
+
'Use a file outside ~/.ssh, ~/.aws, and other credential locations',
|
|
34
|
+
'Set sensitiveFileUploadProtection: false only if you understand the risk',
|
|
35
|
+
'Add path segments to block with fileUploadPathDenySegments',
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
this.name = 'ComposioSensitiveFilePathBlockedError';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Thrown when a `beforeFileUpload` hook returns `false`.
|
|
44
|
+
*/
|
|
45
|
+
export class ComposioFileUploadAbortedError extends ComposioFileUploadError {
|
|
46
|
+
constructor(message: string, options: ComposioErrorOptions = {}) {
|
|
47
|
+
super(message, {
|
|
48
|
+
...options,
|
|
49
|
+
code: FileModifierErrorCodes.FILE_UPLOAD_ABORTED,
|
|
50
|
+
possibleFixes: options.possibleFixes ?? [
|
|
51
|
+
'Change beforeFileUpload to return a file path to upload, or allow the upload to proceed',
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
this.name = 'ComposioFileUploadAbortedError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Thrown when automatic file upload during tool execution is attempted from a path
|
|
60
|
+
* that is outside the configured {@link ComposioConfig.fileUploadDirs} allowlist.
|
|
61
|
+
*
|
|
62
|
+
* This only fires for auto-upload (enabled via
|
|
63
|
+
* `dangerouslyAllowAutoUploadDownloadFiles: true`). Manual `composio.files.upload()`
|
|
64
|
+
* calls are never subject to this check.
|
|
65
|
+
*/
|
|
66
|
+
export class ComposioFileUploadPathNotAllowedError extends ComposioFileUploadError {
|
|
67
|
+
constructor(message: string, options: ComposioErrorOptions = {}) {
|
|
68
|
+
super(message, {
|
|
69
|
+
...options,
|
|
70
|
+
code: FileModifierErrorCodes.FILE_UPLOAD_PATH_NOT_ALLOWED,
|
|
71
|
+
possibleFixes: options.possibleFixes ?? [
|
|
72
|
+
'Move the file under one of the directories in `fileUploadDirs`',
|
|
73
|
+
'Stage the file under the default upload dir (`~/.composio/temp`)',
|
|
74
|
+
'Add the containing directory to `fileUploadDirs` when constructing Composio',
|
|
75
|
+
'Pass the file by URL or as a File/Blob object instead of a filesystem path',
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
this.name = 'ComposioFileUploadPathNotAllowedError';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Thrown when a local file path passed for upload does not exist on disk.
|
|
84
|
+
* Provides extra debugging context (resolved absolute path, cwd, allowlist state)
|
|
85
|
+
* to help the caller distinguish between "typo" and "not-allowlisted" failures.
|
|
86
|
+
*/
|
|
87
|
+
export class ComposioFileNotFoundError extends ComposioFileUploadError {
|
|
88
|
+
constructor(message: string, options: ComposioErrorOptions = {}) {
|
|
89
|
+
super(message, {
|
|
90
|
+
...options,
|
|
91
|
+
code: FileModifierErrorCodes.FILE_NOT_FOUND,
|
|
92
|
+
possibleFixes: options.possibleFixes ?? [
|
|
93
|
+
'Double-check the path for typos',
|
|
94
|
+
'Remember relative paths are resolved against process.cwd() at upload time',
|
|
95
|
+
'Verify the file exists and the process has read permission',
|
|
96
|
+
],
|
|
97
|
+
});
|
|
98
|
+
this.name = 'ComposioFileNotFoundError';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ComposioError } from './ComposioError';
|
|
2
|
+
|
|
3
|
+
export const PusherErrorCodes = {
|
|
4
|
+
PUSHER_CLIENT_NOT_FOUND: 'PUSHER_CLIENT_NOT_FOUND',
|
|
5
|
+
PUSHER_SUBSCRIPTION_ERROR: 'PUSHER_SUBSCRIPTION_ERROR',
|
|
6
|
+
} as const;
|
|
7
|
+
|
|
8
|
+
export class PusherClientNotFoundError extends ComposioError {
|
|
9
|
+
public name = 'PusherClientNotFoundError';
|
|
10
|
+
public code = PusherErrorCodes.PUSHER_CLIENT_NOT_FOUND;
|
|
11
|
+
public statusCode = 404;
|
|
12
|
+
public possibleFixes = ['Please contact support.'];
|
|
13
|
+
|
|
14
|
+
constructor(message: string, options?: ErrorOptions) {
|
|
15
|
+
super(message, options);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class PusherSubscriptionError extends ComposioError {
|
|
20
|
+
public name = 'PusherSubscriptionError';
|
|
21
|
+
public code = PusherErrorCodes.PUSHER_SUBSCRIPTION_ERROR;
|
|
22
|
+
public statusCode = 400;
|
|
23
|
+
public possibleFixes = ['Please contact support.'];
|
|
24
|
+
|
|
25
|
+
constructor(message: string, options?: ErrorOptions) {
|
|
26
|
+
super(message, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ComposioError, ComposioErrorOptions } from './ComposioError';
|
|
2
|
+
|
|
3
|
+
export const RemoteFileErrorCodes = {
|
|
4
|
+
DOWNLOAD_FAILED: 'REMOTE_FILE_DOWNLOAD_FAILED',
|
|
5
|
+
} as const;
|
|
6
|
+
|
|
7
|
+
export interface RemoteFileDownloadErrorOptions extends Omit<ComposioErrorOptions, 'code'> {
|
|
8
|
+
/** HTTP status code from the failed response */
|
|
9
|
+
statusCode?: number;
|
|
10
|
+
/** HTTP status text (e.g. "Not Found", "Forbidden") */
|
|
11
|
+
statusText?: string;
|
|
12
|
+
/** The presigned download URL that failed */
|
|
13
|
+
downloadUrl?: string;
|
|
14
|
+
/** Mount-relative path of the file (e.g. "output/report.pdf") */
|
|
15
|
+
mountRelativePath?: string;
|
|
16
|
+
/** Filename extracted from the mount path */
|
|
17
|
+
filename?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Error thrown when fetching a remote file from a tool router session mount fails.
|
|
22
|
+
* Includes HTTP status, URL, and file path context for debugging.
|
|
23
|
+
*/
|
|
24
|
+
export class RemoteFileDownloadError extends ComposioError {
|
|
25
|
+
constructor(
|
|
26
|
+
message: string = 'Failed to download remote file',
|
|
27
|
+
options: RemoteFileDownloadErrorOptions = {}
|
|
28
|
+
) {
|
|
29
|
+
const {
|
|
30
|
+
statusCode,
|
|
31
|
+
statusText,
|
|
32
|
+
downloadUrl,
|
|
33
|
+
mountRelativePath,
|
|
34
|
+
filename,
|
|
35
|
+
meta: optionsMeta,
|
|
36
|
+
...rest
|
|
37
|
+
} = options;
|
|
38
|
+
|
|
39
|
+
const meta: Record<string, unknown> = {
|
|
40
|
+
...optionsMeta,
|
|
41
|
+
...(statusCode !== undefined && { statusCode }),
|
|
42
|
+
...(statusText && { statusText }),
|
|
43
|
+
...(downloadUrl && { downloadUrl }),
|
|
44
|
+
...(mountRelativePath && { mountRelativePath }),
|
|
45
|
+
...(filename && { filename }),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
super(message, {
|
|
49
|
+
...rest,
|
|
50
|
+
code: RemoteFileErrorCodes.DOWNLOAD_FAILED,
|
|
51
|
+
statusCode,
|
|
52
|
+
meta: Object.keys(meta).length > 0 ? meta : undefined,
|
|
53
|
+
possibleFixes: options.possibleFixes ?? [
|
|
54
|
+
'Verify the download URL has not expired (check expiresAt)',
|
|
55
|
+
'Ensure the file exists at the specified mount path',
|
|
56
|
+
'Retry the operation; presigned URLs may have transient failures',
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
this.name = 'RemoteFileDownloadError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { APIUserAbortError } from '@composio/client';
|
|
2
|
+
import { ComposioError, ComposioErrorOptions } from './ComposioError';
|
|
3
|
+
|
|
4
|
+
export const SDKErrorCodes = {
|
|
5
|
+
NO_API_KEY_PROVIDED: 'NO_API_KEY_PROVIDED',
|
|
6
|
+
REQUEST_CANCELLED: 'REQUEST_CANCELLED',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export class ComposioNoAPIKeyError extends ComposioError {
|
|
10
|
+
constructor(
|
|
11
|
+
message: string = 'No Composio API key provided',
|
|
12
|
+
options: Omit<ComposioErrorOptions, 'code' | 'statusCode'> = {}
|
|
13
|
+
) {
|
|
14
|
+
const defaultCause =
|
|
15
|
+
"Couldn't find an API key in the params, environment variables or in the user config file";
|
|
16
|
+
|
|
17
|
+
super(message, {
|
|
18
|
+
...options,
|
|
19
|
+
code: SDKErrorCodes.NO_API_KEY_PROVIDED,
|
|
20
|
+
cause: options.cause || defaultCause,
|
|
21
|
+
possibleFixes: options.possibleFixes || [
|
|
22
|
+
'Ensure you have an API key passed in the params, or in environment variable (COMPOSIO_API_KEY) or in the user config file',
|
|
23
|
+
'To get an API key, please sign up at https://composio.dev/signup',
|
|
24
|
+
'You can also use the Composio CLI to create a project and get an API key',
|
|
25
|
+
],
|
|
26
|
+
statusCode: 401,
|
|
27
|
+
});
|
|
28
|
+
this.name = 'ComposioNoAPIKeyError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Thrown when an SDK call is cancelled via the caller-supplied `AbortSignal`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* try {
|
|
38
|
+
* await composio.tools.execute(slug, body, { signal: AbortSignal.timeout(5_000) });
|
|
39
|
+
* } catch (err) {
|
|
40
|
+
* if (err instanceof ComposioRequestCancelledError) return;
|
|
41
|
+
* throw err;
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export class ComposioRequestCancelledError extends ComposioError {
|
|
46
|
+
constructor(
|
|
47
|
+
message: string = 'Request was cancelled by the caller',
|
|
48
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
49
|
+
) {
|
|
50
|
+
super(message, {
|
|
51
|
+
...options,
|
|
52
|
+
code: SDKErrorCodes.REQUEST_CANCELLED,
|
|
53
|
+
possibleFixes: options.possibleFixes ?? [
|
|
54
|
+
'This error is expected when you abort the request via AbortController. Handle it in your catch block to distinguish caller-initiated cancellation from other failures.',
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
this.name = 'ComposioRequestCancelledError';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* `APIUserAbortError` has `.name === "Error"` at runtime (doesn't override it),
|
|
63
|
+
* so we fall back to `constructor.name` for dual-package-hazard cases.
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export function isRequestAbortError(error: unknown): boolean {
|
|
67
|
+
return _isRequestAbortErrorAt(error, /* depth= */ 0);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function _isRequestAbortErrorAt(error: unknown, depth: number): boolean {
|
|
71
|
+
if (depth > 5) return false;
|
|
72
|
+
if (error instanceof APIUserAbortError) return true;
|
|
73
|
+
if (
|
|
74
|
+
typeof DOMException !== 'undefined' &&
|
|
75
|
+
error instanceof DOMException &&
|
|
76
|
+
error.name === 'AbortError'
|
|
77
|
+
) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (!(error instanceof Error)) return false;
|
|
81
|
+
if (
|
|
82
|
+
error.constructor.name === 'APIUserAbortError' ||
|
|
83
|
+
error.name === 'AbortError' ||
|
|
84
|
+
error.name === 'APIUserAbortError'
|
|
85
|
+
) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
if ('cause' in error && error.cause !== undefined && error.cause !== null) {
|
|
89
|
+
return _isRequestAbortErrorAt(error.cause, depth + 1);
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { APIError } from '@composio/client';
|
|
2
|
+
import { ComposioError, ComposioErrorOptions } from './ComposioError';
|
|
3
|
+
import { ComposioConnectedAccountNotFoundError } from './ConnectedAccountsErrors';
|
|
4
|
+
|
|
5
|
+
export const ToolErrorCodes = {
|
|
6
|
+
TOOLSET_NOT_DEFINED: 'TOOLSET_NOT_DEFINED',
|
|
7
|
+
TOOL_NOT_FOUND: 'TOOL_NOT_FOUND',
|
|
8
|
+
INVALID_MODIFIER: 'INVALID_MODIFIER',
|
|
9
|
+
TOOL_EXECUTION_ERROR: 'TOOL_EXECUTION_ERROR',
|
|
10
|
+
INVALID_TOOL_ARGUMENTS: 'INVALID_TOOL_ARGUMENTS',
|
|
11
|
+
INVALID_EXECUTE_FUNCTION: 'INVALID_EXECUTE_FUNCTION',
|
|
12
|
+
GLOBAL_EXECUTE_TOOL_FN_NOT_SET: 'GLOBAL_EXECUTE_TOOL_FN_NOT_SET',
|
|
13
|
+
TOOL_VERSION_REQUIRED: 'TOOL_VERSION_REQUIRED',
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
export class ComposioProviderNotDefinedError extends ComposioError {
|
|
17
|
+
constructor(
|
|
18
|
+
message: string = 'Provider not defined',
|
|
19
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
20
|
+
) {
|
|
21
|
+
super(message, {
|
|
22
|
+
...options,
|
|
23
|
+
code: ToolErrorCodes.TOOLSET_NOT_DEFINED,
|
|
24
|
+
possibleFixes: options.possibleFixes || [
|
|
25
|
+
'Ensure that the provider is defined in the Composio project and passed into the tool instance',
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
this.name = 'ComposioProviderNotDefinedError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class ComposioToolNotFoundError extends ComposioError {
|
|
33
|
+
constructor(
|
|
34
|
+
message: string = 'Tool not found',
|
|
35
|
+
options: Omit<ComposioErrorOptions, 'code' | 'statusCode'> = {}
|
|
36
|
+
) {
|
|
37
|
+
super(message, {
|
|
38
|
+
...options,
|
|
39
|
+
code: ToolErrorCodes.TOOL_NOT_FOUND,
|
|
40
|
+
possibleFixes: options.possibleFixes || [
|
|
41
|
+
'Ensure the tool slug is correct and exists in the Composio project',
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
this.name = 'ComposioToolNotFoundError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class ComposioInvalidModifierError extends ComposioError {
|
|
49
|
+
constructor(
|
|
50
|
+
message: string = 'Invalid modifier',
|
|
51
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
52
|
+
) {
|
|
53
|
+
super(message, {
|
|
54
|
+
...options,
|
|
55
|
+
code: ToolErrorCodes.INVALID_MODIFIER,
|
|
56
|
+
possibleFixes: options.possibleFixes || [
|
|
57
|
+
'Ensure the modifier is a function and returns a valid result',
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
this.name = 'ComposioInvalidModifierError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class ComposioToolExecutionError extends ComposioError {
|
|
65
|
+
constructor(message: string = 'Tool execution error', options: ComposioErrorOptions = {}) {
|
|
66
|
+
super(message, {
|
|
67
|
+
...options,
|
|
68
|
+
code: options.code || ToolErrorCodes.TOOL_EXECUTION_ERROR,
|
|
69
|
+
cause: options.cause,
|
|
70
|
+
possibleFixes: options.possibleFixes || [
|
|
71
|
+
'Ensure the tool is correctly configured and the input is valid',
|
|
72
|
+
'Ensure the userId is correct and has an active connected account for the user in case of non NoAuth toolkits',
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
this.name = 'ComposioToolExecutionError';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class ComposioInvalidToolArgumentsError extends ComposioError {
|
|
81
|
+
constructor(
|
|
82
|
+
message: string = 'Invalid tool arguments',
|
|
83
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
84
|
+
) {
|
|
85
|
+
super(message, {
|
|
86
|
+
...options,
|
|
87
|
+
code: ToolErrorCodes.INVALID_TOOL_ARGUMENTS,
|
|
88
|
+
possibleFixes: options.possibleFixes || [
|
|
89
|
+
'Tool arguments must be a JSON object (or a string that parses to one)',
|
|
90
|
+
'If a model emitted the arguments as a string, ensure it is valid JSON',
|
|
91
|
+
],
|
|
92
|
+
});
|
|
93
|
+
this.name = 'ComposioInvalidToolArgumentsError';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export class ComposioInvalidExecuteFunctionError extends ComposioError {
|
|
98
|
+
constructor(
|
|
99
|
+
message: string = 'Invalid execute function',
|
|
100
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
101
|
+
) {
|
|
102
|
+
super(message, {
|
|
103
|
+
...options,
|
|
104
|
+
code: ToolErrorCodes.INVALID_EXECUTE_FUNCTION,
|
|
105
|
+
possibleFixes: options.possibleFixes || [
|
|
106
|
+
'Ensure the execute function is a valid function and returns a valid result',
|
|
107
|
+
],
|
|
108
|
+
});
|
|
109
|
+
this.name = 'ComposioInvalidExecuteFunctionError';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export class ComposioGlobalExecuteToolFnNotSetError extends ComposioError {
|
|
114
|
+
constructor(
|
|
115
|
+
message: string = 'Global execute tool function not set',
|
|
116
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
117
|
+
) {
|
|
118
|
+
super(message, {
|
|
119
|
+
...options,
|
|
120
|
+
code: ToolErrorCodes.GLOBAL_EXECUTE_TOOL_FN_NOT_SET,
|
|
121
|
+
possibleFixes: options.possibleFixes || [
|
|
122
|
+
'Ensure the global execute tool function is set in the provider',
|
|
123
|
+
],
|
|
124
|
+
});
|
|
125
|
+
this.name = 'ComposioGlobalExecuteToolFnNotSetError';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Error thrown when toolkit version is not specified for manual tool execution.
|
|
131
|
+
*
|
|
132
|
+
* This error is thrown when attempting to execute a tool manually (via `tools.execute()`)
|
|
133
|
+
* and the resolved version is "latest" without `dangerouslySkipVersionCheck` set to true.
|
|
134
|
+
*
|
|
135
|
+
* **Why this error exists:**
|
|
136
|
+
* Using "latest" version in manual execution can lead to unexpected behavior when new
|
|
137
|
+
* toolkit versions are released, potentially breaking your application. For production
|
|
138
|
+
* use, it's recommended to pin specific toolkit versions.
|
|
139
|
+
*
|
|
140
|
+
* **How to fix:**
|
|
141
|
+
* 1. Specify a concrete version in the execute call
|
|
142
|
+
* 2. Configure toolkit versions at SDK initialization
|
|
143
|
+
* 3. Set toolkit version via environment variable
|
|
144
|
+
* 4. Use dangerouslySkipVersionCheck (not recommended for production)
|
|
145
|
+
*
|
|
146
|
+
* @example ❌ This will throw ComposioToolVersionRequiredError if toolkitVersions is 'latest'
|
|
147
|
+
* ```typescript
|
|
148
|
+
* await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
149
|
+
* userId: 'default',
|
|
150
|
+
* arguments: { owner: 'composio' }
|
|
151
|
+
* });
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @example ✅ Fix 1: Pass specific version in execute call
|
|
155
|
+
* ```typescript
|
|
156
|
+
* await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
157
|
+
* userId: 'default',
|
|
158
|
+
* version: '20250909_00',
|
|
159
|
+
* arguments: { owner: 'composio' }
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @example ✅ Fix 2: Configure toolkit versions at SDK level
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const composio = new Composio({
|
|
166
|
+
* toolkitVersions: { github: '20250909_00' }
|
|
167
|
+
* });
|
|
168
|
+
* await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
169
|
+
* userId: 'default',
|
|
170
|
+
* arguments: { owner: 'composio' }
|
|
171
|
+
* });
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @example ✅ Fix 3: Use environment variable
|
|
175
|
+
* ```typescript
|
|
176
|
+
* // Set: COMPOSIO_TOOLKIT_VERSION_GITHUB=20250909_00
|
|
177
|
+
* await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
178
|
+
* userId: 'default',
|
|
179
|
+
* arguments: { owner: 'composio' }
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @example ⚠️ Fix 4: Skip version check (not recommended for production)
|
|
184
|
+
* ```typescript
|
|
185
|
+
* await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
186
|
+
* userId: 'default',
|
|
187
|
+
* dangerouslySkipVersionCheck: true,
|
|
188
|
+
* arguments: { owner: 'composio' }
|
|
189
|
+
* });
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
export class ComposioToolVersionRequiredError extends ComposioError {
|
|
193
|
+
constructor(
|
|
194
|
+
message: string = 'Toolkit version not specified. For manual execution of the tool please pass a specific toolkit version',
|
|
195
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
196
|
+
) {
|
|
197
|
+
super(message, {
|
|
198
|
+
...options,
|
|
199
|
+
code: ToolErrorCodes.TOOL_VERSION_REQUIRED,
|
|
200
|
+
possibleFixes: options.possibleFixes || [
|
|
201
|
+
'Pass the toolkit version as a parameter to the execute function ("latest" is not supported in manual execution)',
|
|
202
|
+
'Set the toolkit versions in the Composio config (toolkitVersions: { <toolkit-slug>: "<toolkit-version>" })',
|
|
203
|
+
'Set the toolkit version in the environment variable (COMPOSIO_TOOLKIT_VERSION_<TOOLKIT_SLUG>)',
|
|
204
|
+
'Set dangerouslySkipVersionCheck to true (this might cause unexpected behavior when new versions of the tools are released)',
|
|
205
|
+
],
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export interface ComposioAPIServerErrorBody {
|
|
210
|
+
error: {
|
|
211
|
+
message: string;
|
|
212
|
+
code: number;
|
|
213
|
+
status: number;
|
|
214
|
+
request_id: string;
|
|
215
|
+
suggested_fix: string;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Map of error codes to their corresponding error constructors
|
|
220
|
+
const ERROR_CODE_HANDLERS = new Map<number, (message: string) => ComposioError>([
|
|
221
|
+
[1803, msg => new ComposioConnectedAccountNotFoundError(msg)],
|
|
222
|
+
// Add more error code handlers here as needed
|
|
223
|
+
]);
|
|
224
|
+
|
|
225
|
+
export const handleToolExecutionError = (tool: string, actualError: Error): ComposioError => {
|
|
226
|
+
// Handle specific API error codes
|
|
227
|
+
if (actualError instanceof APIError && actualError.error) {
|
|
228
|
+
const errorBody = actualError.error as ComposioAPIServerErrorBody;
|
|
229
|
+
const errorCode = errorBody?.error?.code;
|
|
230
|
+
const errorMessage = errorBody?.error?.message;
|
|
231
|
+
|
|
232
|
+
if (errorCode && ERROR_CODE_HANDLERS.has(errorCode)) {
|
|
233
|
+
return ERROR_CODE_HANDLERS.get(errorCode)!(errorMessage || 'An error occurred');
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Default error for all other cases
|
|
238
|
+
return new ComposioToolExecutionError(`Error executing the tool ${tool}`, {
|
|
239
|
+
cause: actualError,
|
|
240
|
+
possibleFixes: [
|
|
241
|
+
'Ensure the tool slug is correct and the input arguments for the tool is valid',
|
|
242
|
+
],
|
|
243
|
+
});
|
|
244
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ComposioError, ComposioErrorOptions } from './ComposioError';
|
|
2
|
+
|
|
3
|
+
export const ToolkitErrorCodes = {
|
|
4
|
+
TOOLKIT_NOT_FOUND: 'TOOLKIT_NOT_FOUND',
|
|
5
|
+
} as const;
|
|
6
|
+
|
|
7
|
+
export class ComposioToolkitNotFoundError extends ComposioError {
|
|
8
|
+
constructor(
|
|
9
|
+
message: string = 'Toolkit not found',
|
|
10
|
+
options: Omit<ComposioErrorOptions, 'code' | 'statusCode'> = {}
|
|
11
|
+
) {
|
|
12
|
+
super(message, {
|
|
13
|
+
...options,
|
|
14
|
+
code: 'TOOLKIT_NOT_FOUND',
|
|
15
|
+
possibleFixes: options.possibleFixes || [
|
|
16
|
+
'Ensure the toolkit is correctly configured and the slug is valid',
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
this.name = 'ComposioToolkitNotFoundError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class ComposioToolkitFetchError extends ComposioError {
|
|
24
|
+
constructor(
|
|
25
|
+
message: string = 'Failed to fetch toolkit',
|
|
26
|
+
options: Omit<ComposioErrorOptions, 'code' | 'statusCode'> = {}
|
|
27
|
+
) {
|
|
28
|
+
super(message, {
|
|
29
|
+
...options,
|
|
30
|
+
code: 'TOOLKIT_FETCH_ERROR',
|
|
31
|
+
possibleFixes: options.possibleFixes || [
|
|
32
|
+
'Ensure the toolkit slug is valid',
|
|
33
|
+
'Ensure you are using the correct API key',
|
|
34
|
+
'Ensure you are using the correct API endpoint / Base URL and it is working',
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
this.name = 'ComposioToolkitFetchError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ComposioError, ComposioErrorOptions } from './ComposioError';
|
|
2
|
+
|
|
3
|
+
export const TriggerErrorCodes = {
|
|
4
|
+
TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS: 'TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS',
|
|
5
|
+
TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT: 'TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT',
|
|
6
|
+
TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL: 'TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL',
|
|
7
|
+
TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL:
|
|
8
|
+
'TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL',
|
|
9
|
+
TRIGGER_TYPE_NOT_FOUND: 'TRIGGER_TYPE_NOT_FOUND',
|
|
10
|
+
WEBHOOK_SIGNATURE_VERIFICATION_FAILED: 'WEBHOOK_SIGNATURE_VERIFICATION_FAILED',
|
|
11
|
+
WEBHOOK_PAYLOAD_INVALID: 'WEBHOOK_PAYLOAD_INVALID',
|
|
12
|
+
} as const;
|
|
13
|
+
|
|
14
|
+
export class ComposioFailedToGetSDKRealtimeCredentialsError extends ComposioError {
|
|
15
|
+
constructor(
|
|
16
|
+
message: string = 'Failed to get SDK realtime credentials',
|
|
17
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
18
|
+
) {
|
|
19
|
+
super(message, {
|
|
20
|
+
...options,
|
|
21
|
+
code: TriggerErrorCodes.TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS,
|
|
22
|
+
possibleFixes: options.possibleFixes || ['Please contact support.'],
|
|
23
|
+
});
|
|
24
|
+
this.name = 'ComposioFailedToGetSDKRealtimeCredentialsError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class ComposioFailedToCreatePusherClientError extends ComposioError {
|
|
29
|
+
constructor(
|
|
30
|
+
message: string = 'Failed to create Pusher client',
|
|
31
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
32
|
+
) {
|
|
33
|
+
super(message, {
|
|
34
|
+
...options,
|
|
35
|
+
code: TriggerErrorCodes.TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT,
|
|
36
|
+
possibleFixes: options.possibleFixes || ['Please contact support.'],
|
|
37
|
+
});
|
|
38
|
+
this.name = 'ComposioFailedToCreatePusherClientError';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class ComposioFailedToSubscribeToPusherChannelError extends ComposioError {
|
|
43
|
+
constructor(
|
|
44
|
+
message: string = 'Failed to subscribe to Pusher channel',
|
|
45
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
46
|
+
) {
|
|
47
|
+
super(message, {
|
|
48
|
+
...options,
|
|
49
|
+
code: TriggerErrorCodes.TRIGGER_FAILED_TO_SUBSCRIBE_TO_PUSHER_CHANNEL,
|
|
50
|
+
possibleFixes: options.possibleFixes || ['Please contact support.'],
|
|
51
|
+
});
|
|
52
|
+
this.name = 'ComposioFailedToSubscribeToPusherChannelError';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class ComposioFailedToUnsubscribeFromPusherChannelError extends ComposioError {
|
|
57
|
+
constructor(
|
|
58
|
+
message: string = 'Failed to unsubscribe from Pusher channel',
|
|
59
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
60
|
+
) {
|
|
61
|
+
super(message, {
|
|
62
|
+
...options,
|
|
63
|
+
code: TriggerErrorCodes.TRIGGER_FAILED_TO_UNSUBSCRIBE_FROM_PUSHER_CHANNEL,
|
|
64
|
+
possibleFixes: options.possibleFixes || ['Please contact support.'],
|
|
65
|
+
});
|
|
66
|
+
this.name = 'ComposioFailedToUnsubscribeFromPusherChannelError';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export class ComposioTriggerTypeNotFoundError extends ComposioError {
|
|
71
|
+
constructor(
|
|
72
|
+
message: string = 'Trigger type not found',
|
|
73
|
+
options: Omit<ComposioErrorOptions, 'code' | 'statusCode'> = {}
|
|
74
|
+
) {
|
|
75
|
+
super(message, {
|
|
76
|
+
...options,
|
|
77
|
+
code: TriggerErrorCodes.TRIGGER_TYPE_NOT_FOUND,
|
|
78
|
+
statusCode: 404,
|
|
79
|
+
possibleFixes: options.possibleFixes || ['Please contact support.'],
|
|
80
|
+
});
|
|
81
|
+
this.name = 'ComposioTriggerTypeNotFoundError';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export class ComposioWebhookSignatureVerificationError extends ComposioError {
|
|
86
|
+
constructor(
|
|
87
|
+
message: string = 'Webhook signature verification failed',
|
|
88
|
+
options: Omit<ComposioErrorOptions, 'code' | 'statusCode'> = {}
|
|
89
|
+
) {
|
|
90
|
+
super(message, {
|
|
91
|
+
...options,
|
|
92
|
+
code: TriggerErrorCodes.WEBHOOK_SIGNATURE_VERIFICATION_FAILED,
|
|
93
|
+
statusCode: 401,
|
|
94
|
+
possibleFixes: options.possibleFixes || [
|
|
95
|
+
'Verify that the webhook secret is correct.',
|
|
96
|
+
'Ensure the raw request body is passed without modifications.',
|
|
97
|
+
'Check that the signature header value is being passed correctly.',
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
this.name = 'ComposioWebhookSignatureVerificationError';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export class ComposioWebhookPayloadError extends ComposioError {
|
|
105
|
+
constructor(
|
|
106
|
+
message: string = 'Invalid webhook payload',
|
|
107
|
+
options: Omit<ComposioErrorOptions, 'code' | 'statusCode'> = {}
|
|
108
|
+
) {
|
|
109
|
+
super(message, {
|
|
110
|
+
...options,
|
|
111
|
+
code: TriggerErrorCodes.WEBHOOK_PAYLOAD_INVALID,
|
|
112
|
+
statusCode: 400,
|
|
113
|
+
possibleFixes: options.possibleFixes || [
|
|
114
|
+
'Ensure the webhook payload is valid JSON.',
|
|
115
|
+
'Verify the payload structure matches the expected format.',
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
this.name = 'ComposioWebhookPayloadError';
|
|
119
|
+
}
|
|
120
|
+
}
|