@composio/core 0.29.0 → 0.31.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.
Files changed (80) hide show
  1. package/README.md +23 -0
  2. package/dist/{CustomTool-Bd1KdWvo.mjs → CustomTool-9Vlb4XaS.mjs} +4 -7
  3. package/dist/{CustomTool-CMW-d2ZN.d.mts → CustomTool-Ds5aLDth.d.mts} +2 -4
  4. package/dist/FileModifierErrors-WrqokuIF.mjs +199 -0
  5. package/dist/{FileToolModifier.utils.neutral-DWFpnsj2.mjs → FileToolModifier.utils.neutral-BQP85ZJj.mjs} +1 -2
  6. package/dist/{SsrfErrors-DiQldIdC.mjs → SsrfErrors-BSVMW915.mjs} +49 -26
  7. package/dist/{Telemetry-D2PJwXKx.mjs → Telemetry-a7SOQXcg.mjs} +6 -10
  8. package/dist/{composio-D5UV5HXN.d.mts → composio-Ba89XGHL.d.mts} +310 -222
  9. package/dist/{customTool.types-B9fs34dv.d.mts → customTool.types-DHxXBU6E.d.mts} +205 -268
  10. package/dist/docs/error-consistency.md +3 -3
  11. package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +9 -0
  12. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +1 -0
  13. package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +6 -11
  14. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +1 -1
  15. package/dist/docs/reference/sdk-reference/typescript/index.mdx +1 -1
  16. package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +2 -2
  17. package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +1 -1
  18. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +2 -2
  19. package/dist/{errors-BK6Xc7Ia.mjs → errors-xC13uvaA.mjs} +56 -139
  20. package/dist/experimental/index.d.mts +16 -2
  21. package/dist/experimental/index.mjs +1 -1
  22. package/dist/{fileUtils.node-ILI1IjnZ.mjs → fileUtils.node-CAwIbWYH.mjs} +6 -8
  23. package/dist/{files.types-DeMC_mAW.d.mts → files.types-Dg6HcEzs.d.mts} +0 -2
  24. package/dist/index.d.mts +37 -72
  25. package/dist/index.mjs +339 -254
  26. package/dist/{cancellation-BoJjs34Y.mjs → jsonSchema-Cc4EtHRw.mjs} +5 -22
  27. package/dist/models/Files.node.d.mts +32 -13
  28. package/dist/models/Files.node.mjs +36 -19
  29. package/dist/models/Files.workerd.d.mts +8 -3
  30. package/dist/models/Files.workerd.mjs +1 -2
  31. package/dist/platform/node.d.mts +2 -4
  32. package/dist/platform/node.mjs +15 -16
  33. package/dist/platform/workerd.d.mts +2 -4
  34. package/dist/platform/workerd.mjs +1 -2
  35. package/dist/requestOptions.types-DWrTcbss.d.mts +38 -0
  36. package/dist/rolldown-runtime-ad2WFvuA.mjs +17 -0
  37. package/dist/{sensitiveFileUploadPaths-BaEORC7-.mjs → sensitiveFileUploadPaths-CSyJ3Ku8.mjs} +22 -12
  38. package/dist/{ssrfGuard.node-BZ270bcu.mjs → ssrfGuard.node-CdIkwqVu.mjs} +3 -5
  39. package/dist/{types-CaP2SytR.d.mts → types-DcdZy5Nc.d.mts} +2 -4
  40. package/dist/{types-DuVZKrXO.d.mts → types-Ds6XbK1m.d.mts} +0 -2
  41. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +2 -4
  42. package/dist/utils/config-defaults/ConfigDefaults.node.mjs +1 -2
  43. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +2 -4
  44. package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +1 -2
  45. package/dist/utils/modifiers/FileToolModifier.node.d.mts +2 -4
  46. package/dist/utils/modifiers/FileToolModifier.node.mjs +7 -8
  47. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +2 -4
  48. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +2 -3
  49. package/dist/utils/ssrfGuard.node.d.mts +1 -3
  50. package/dist/utils/ssrfGuard.node.mjs +1 -1
  51. package/dist/utils/ssrfGuard.workerd.d.mts +1 -3
  52. package/dist/utils/ssrfGuard.workerd.mjs +2 -3
  53. package/docs/error-consistency.md +3 -3
  54. package/package.json +12 -13
  55. package/src/composio.ts +12 -0
  56. package/src/errors/ComposioError.ts +40 -16
  57. package/src/errors/ConnectedAccountsErrors.ts +2 -2
  58. package/src/errors/ToolErrors.ts +107 -30
  59. package/src/errors/apiErrorDetails.ts +40 -0
  60. package/src/models/AuthConfigs.ts +9 -0
  61. package/src/models/ConnectionRequest.ts +12 -4
  62. package/src/models/CustomToolkits.ts +11 -17
  63. package/src/models/Experimental.ts +2 -7
  64. package/src/models/Files.node.ts +68 -37
  65. package/src/models/MCP.ts +2 -2
  66. package/src/models/RemoteFile.ts +22 -16
  67. package/src/models/SessionContext.ts +6 -7
  68. package/src/models/ToolRouterSession.ts +16 -23
  69. package/src/models/Tools.ts +220 -22
  70. package/src/models/Triggers.ts +8 -2
  71. package/src/types/authConfigs.types.ts +14 -0
  72. package/src/types/customToolkits.types.ts +4 -9
  73. package/src/types/tool.types.ts +1 -1
  74. package/src/types/toolkit.types.ts +21 -0
  75. package/src/utils/cancellation.ts +5 -1
  76. package/src/utils/transformers/authConfigs.ts +6 -2
  77. package/src/utils/transformers/toolkits.ts +7 -0
  78. package/dist/FileModifierErrors-CdGSABoq.mjs +0 -97
  79. package/dist/rolldown-runtime-w6R9maHv.mjs +0 -18
  80. package/src/models/inlineCustomToolsPayload.ts +0 -17
@@ -1,7 +1,6 @@
1
1
  /**
2
- * @fileoverview `composio.experimental.customToolkits`: register and manage
2
+ * @fileoverview `composio.customToolkits`: register and manage
3
3
  * project-owned custom toolkits.
4
- * **Experimental — custom toolkits are in pilot; shape may change.**
5
4
  *
6
5
  * @module CustomToolkits
7
6
  */
@@ -39,14 +38,14 @@ import {
39
38
  } from '../utils/transformers/customToolkits';
40
39
 
41
40
  const UPSERT_DEPRECATION =
42
- '[Deprecation] composio.experimental.customToolkits.upsert() is deprecated. ' +
41
+ '[Deprecation] composio.customToolkits.upsert() is deprecated. ' +
43
42
  'Use create() for a new toolkit and update(slug, ...) to change its name, logo or API key field.';
44
43
  let _upsertDeprecationWarned = false;
45
44
 
46
45
  /**
47
- * `composio.experimental.customToolkits` — toolkits your project registers
46
+ * `composio.customToolkits` — toolkits your project registers
48
47
  * from its own app or MCP server, with their own auth configs and connected
49
- * accounts. **Experimental — custom toolkits are in pilot; shape may change.**
48
+ * accounts.
50
49
  *
51
50
  * These live on the Composio platform. They are unrelated to the in-process
52
51
  * toolkits built with `experimental_createToolkit()`, which run inside your
@@ -54,13 +53,13 @@ let _upsertDeprecationWarned = false;
54
53
  *
55
54
  * @example
56
55
  * ```typescript
57
- * const { slug } = await composio.experimental.customToolkits.create({
56
+ * const { slug } = await composio.customToolkits.create({
58
57
  * name: 'My Toolkit',
59
58
  * mcpUrl: 'https://mcp.example.com/mcp',
60
59
  * authSchemes: [{ mode: 'DCR_OAUTH', discoveryUrl: 'https://mcp.example.com/.well-known/oauth-authorization-server' }],
61
60
  * userId: 'all',
62
61
  * });
63
- * await composio.experimental.customToolkits.update(slug, { name: 'My Renamed Toolkit' });
62
+ * await composio.customToolkits.update(slug, { name: 'My Renamed Toolkit' });
64
63
  * ```
65
64
  */
66
65
  export class CustomToolkits {
@@ -73,7 +72,6 @@ export class CustomToolkits {
73
72
 
74
73
  /**
75
74
  * Creates a custom MCP toolkit and returns its generated slug.
76
- * **Experimental — custom toolkits are in pilot; shape may change.**
77
75
  *
78
76
  * Set `userId` to `'all'` to share the toolkit with every user in the
79
77
  * project, or to a user ID to make it private to that user. `mcpUrl`,
@@ -87,7 +85,7 @@ export class CustomToolkits {
87
85
  *
88
86
  * @example
89
87
  * ```typescript
90
- * const { slug, connectLink } = await composio.experimental.customToolkits.create({
88
+ * const { slug, connectLink } = await composio.customToolkits.create({
91
89
  * name: 'Internal API',
92
90
  * mcpUrl: 'https://mcp.internal.example.com/mcp',
93
91
  * authSchemes: [
@@ -118,7 +116,6 @@ export class CustomToolkits {
118
116
  /**
119
117
  * Updates a custom toolkit's name, logo or API key field copy. Omitted
120
118
  * fields keep their current value.
121
- * **Experimental — custom toolkits are in pilot; shape may change.**
122
119
  *
123
120
  * On a project with 2FA enabled, updating a private toolkit requires the
124
121
  * `userId` it is private to.
@@ -130,7 +127,7 @@ export class CustomToolkits {
130
127
  *
131
128
  * @example
132
129
  * ```typescript
133
- * await composio.experimental.customToolkits.update('CUSTOM_INTERNAL_API_K7F2Q', {
130
+ * await composio.customToolkits.update('CUSTOM_INTERNAL_API_K7F2Q', {
134
131
  * name: 'Internal API (prod)',
135
132
  * userId: 'user_123',
136
133
  * });
@@ -158,7 +155,6 @@ export class CustomToolkits {
158
155
  /**
159
156
  * Creates a custom toolkit, or updates its display metadata (name, API key
160
157
  * field copy) when the project already owns a toolkit with this slug.
161
- * **Experimental — custom toolkits are in pilot; shape may change.**
162
158
  *
163
159
  * `mcpUrl` and `authSchemes` cannot change on an existing toolkit:
164
160
  * re-sending them unchanged is a no-op, and changing them fails with a 409.
@@ -170,7 +166,7 @@ export class CustomToolkits {
170
166
  *
171
167
  * @example
172
168
  * ```typescript
173
- * await composio.experimental.customToolkits.upsert({
169
+ * await composio.customToolkits.upsert({
174
170
  * slug: 'INTERNAL_API',
175
171
  * toolkitConfig: {
176
172
  * name: 'Internal API',
@@ -211,7 +207,6 @@ export class CustomToolkits {
211
207
  /**
212
208
  * Re-fetches the tool definitions of a custom toolkit from its remote MCP
213
209
  * server. Call it when automatic sync fails or the remote tools change.
214
- * **Experimental — custom toolkits are in pilot; shape may change.**
215
210
  *
216
211
  * @param {string} slug - The custom toolkit slug (`CUSTOM_...`)
217
212
  * @param {CustomToolkitSyncParams} [params] - Optional connected account to fetch the definitions with
@@ -220,7 +215,7 @@ export class CustomToolkits {
220
215
  *
221
216
  * @example
222
217
  * ```typescript
223
- * const { version, syncedCount } = await composio.experimental.customToolkits.sync(
218
+ * const { version, syncedCount } = await composio.customToolkits.sync(
224
219
  * 'CUSTOM_MY_TOOLKIT',
225
220
  * { connectedAccountId: 'ca_abc123' }
226
221
  * );
@@ -249,7 +244,6 @@ export class CustomToolkits {
249
244
  * Deletes a custom toolkit owned by the project, with its tools, auth
250
245
  * configs and connected accounts. The credentials behind those connected
251
246
  * accounts are revoked in background jobs (`revokeJobIds`).
252
- * **Experimental — custom toolkits are in pilot; shape may change.**
253
247
  *
254
248
  * Composio-managed toolkits cannot be deleted; the API answers 403.
255
249
  *
@@ -258,7 +252,7 @@ export class CustomToolkits {
258
252
  *
259
253
  * @example
260
254
  * ```typescript
261
- * const result = await composio.experimental.customToolkits.delete('CUSTOM_MY_TOOLKIT');
255
+ * const result = await composio.customToolkits.delete('CUSTOM_MY_TOOLKIT');
262
256
  * console.log(result.connectedAccountsDeleted);
263
257
  * ```
264
258
  */
@@ -144,13 +144,8 @@ export class Experimental {
144
144
  usage: Usage;
145
145
 
146
146
  /**
147
- * Register and manage project-owned custom toolkits (`create()` / `update()` / `sync()` / `delete()`).
148
- * **Experimental — custom toolkits are in pilot; shape may change.**
149
- *
150
- * @example
151
- * ```typescript
152
- * await composio.experimental.customToolkits.sync('CUSTOM_MY_TOOLKIT');
153
- * ```
147
+ * Same object as `composio.customToolkits`.
148
+ * @deprecated Use `composio.customToolkits` instead. Custom toolkits are no longer experimental; this alias is kept for backwards compatibility.
154
149
  */
155
150
  customToolkits: CustomToolkits;
156
151
 
@@ -7,7 +7,9 @@
7
7
  */
8
8
  import ComposioClient from '@composio/client';
9
9
  import { FileDownloadData, FileUploadData } from '../types/files.types';
10
+ import { ComposioRequestOptions } from '../types/requestOptions.types';
10
11
  import { downloadFileFromS3, getFileDataAfterUploadingToS3 } from '../utils/fileUtils.node';
12
+ import { withCancellation } from '../utils/cancellation';
11
13
  import { telemetry } from '../telemetry/Telemetry';
12
14
 
13
15
  export class Files {
@@ -36,58 +38,87 @@ export class Files {
36
38
  * @param {File | string} params.file - The path to the file to upload, a URL of the file, or a File object.
37
39
  * @param {string} params.toolSlug - The slug of the tool that is uploading the file.
38
40
  * @param {string} params.toolkitSlug - The slug of the toolkit that is uploading the file.
41
+ * @param {ComposioRequestOptions} [requestOptions] - Optional request options. `signal` cancels
42
+ * the file read from a URL, the presigned-URL request, and the S3 transfer; the call then
43
+ * rejects with {@link ComposioRequestCancelledError}.
39
44
  * @returns {Promise<FileUploadData>} The uploaded file data.
40
45
  *
41
46
  * @example
42
47
  *
43
- * const fileData = await composio.files.upload({
44
- * file: 'path/to/file.pdf',
45
- * toolSlug: 'google_drive_upload',
46
- * toolkitSlug: 'google_drive'
47
- * });
48
+ * const fileData = await composio.files.upload(
49
+ * {
50
+ * file: 'path/to/file.pdf',
51
+ * toolSlug: 'google_drive_upload',
52
+ * toolkitSlug: 'google_drive',
53
+ * },
54
+ * { signal: AbortSignal.timeout(30_000) }
55
+ * );
48
56
  * */
49
- async upload({
50
- file,
51
- toolSlug,
52
- toolkitSlug,
53
- }: {
54
- file: File | string;
55
- toolSlug: string;
56
- toolkitSlug: string;
57
- }): Promise<FileUploadData> {
57
+ async upload(
58
+ {
59
+ file,
60
+ toolSlug,
61
+ toolkitSlug,
62
+ }: {
63
+ file: File | string;
64
+ toolSlug: string;
65
+ toolkitSlug: string;
66
+ },
67
+ requestOptions?: ComposioRequestOptions
68
+ ): Promise<FileUploadData> {
69
+ const signal = requestOptions?.signal;
58
70
  // Note: manual `composio.files.upload()` intentionally skips the
59
71
  // `fileUploadDirs` allowlist. The allowlist only gates *automatic* upload
60
72
  // during tool execution (see FileToolModifier).
61
- const fileData = await getFileDataAfterUploadingToS3(file, {
62
- toolSlug,
63
- toolkitSlug,
64
- client: this.client,
65
- sensitiveFileUploadProtection: this.fileOptions.sensitiveFileUploadProtection,
66
- fileUploadPathDenySegments: this.fileOptions.fileUploadPathDenySegments,
67
- });
68
- return fileData;
73
+ return withCancellation(
74
+ () =>
75
+ getFileDataAfterUploadingToS3(file, {
76
+ toolSlug,
77
+ toolkitSlug,
78
+ client: this.client,
79
+ sensitiveFileUploadProtection: this.fileOptions.sensitiveFileUploadProtection,
80
+ fileUploadPathDenySegments: this.fileOptions.fileUploadPathDenySegments,
81
+ signal,
82
+ }),
83
+ signal
84
+ );
69
85
  }
70
86
 
71
87
  /**
72
88
  * Download a file from S3 and return the file data.
73
- * @param s3key - The S3 key of the file to download.
74
- * @returns The file data.
89
+ *
90
+ * @param params - The download parameters.
91
+ * @param {string} params.s3Url - The S3 URL of the file to download.
92
+ * @param {string} params.toolSlug - The slug of the tool the file belongs to, used as the file name prefix.
93
+ * @param {string} params.mimeType - The MIME type of the file, used to pick the file extension.
94
+ * @param {ComposioRequestOptions} [requestOptions] - Optional request options. `signal` cancels
95
+ * the download before the file is written; the call then rejects with
96
+ * {@link ComposioRequestCancelledError}.
97
+ * @returns {Promise<FileDownloadData>} The downloaded file data.
75
98
  */
76
- async download({
77
- toolSlug,
78
- s3Url,
79
- mimeType,
80
- }: {
81
- s3Url: string;
82
- toolSlug: string;
83
- mimeType: string;
84
- }): Promise<FileDownloadData> {
85
- const fileDownloadData = await downloadFileFromS3({
99
+ async download(
100
+ {
86
101
  toolSlug,
87
102
  s3Url,
88
103
  mimeType,
89
- fileDownloadDir: this.fileOptions.fileDownloadDir,
90
- });
91
- return fileDownloadData;
104
+ }: {
105
+ s3Url: string;
106
+ toolSlug: string;
107
+ mimeType: string;
108
+ },
109
+ requestOptions?: ComposioRequestOptions
110
+ ): Promise<FileDownloadData> {
111
+ const signal = requestOptions?.signal;
112
+ return withCancellation(
113
+ () =>
114
+ downloadFileFromS3({
115
+ toolSlug,
116
+ s3Url,
117
+ mimeType,
118
+ fileDownloadDir: this.fileOptions.fileDownloadDir,
119
+ signal,
120
+ }),
121
+ signal
122
+ );
92
123
  }
93
124
  }
package/src/models/MCP.ts CHANGED
@@ -249,7 +249,7 @@ export class MCP {
249
249
  * const server = await composio.experimental.mcp.get("mcp_12345");
250
250
  *
251
251
  * console.log(server.name); // "My Personal MCP Server"
252
- * console.log(server.allowedTools); // ["GITHUB_CREATE_ISSUE", "SLACK_SEND_MESSAGE"]
252
+ * console.log(server.allowedTools); // ["GITHUB_CREATE_AN_ISSUE", "SLACK_SEND_MESSAGE"]
253
253
  * console.log(server.toolkits); // ["github", "slack"]
254
254
  * console.log(server.serverInstanceCount); // 3
255
255
  *
@@ -343,7 +343,7 @@ export class MCP {
343
343
  * {
344
344
  * toolkit: "github",
345
345
  * authConfigId: "auth_abc123",
346
- * allowedTools: ["GITHUB_CREATE_ISSUE", "GITHUB_LIST_REPOS"]
346
+ * allowedTools: ["GITHUB_CREATE_AN_ISSUE", "GITHUB_LIST_REPOS"]
347
347
  * },
348
348
  * {
349
349
  * toolkit: "slack",
@@ -175,7 +175,8 @@ export class RemoteFile {
175
175
  * Downloads and saves the file to the local filesystem.
176
176
  * Requires a Node.js runtime with file system support (not available in Cloudflare Workers/Edge).
177
177
  *
178
- * @param path - Local path to save the file. If omitted, saves to the Composio temp directory using the filename from the mount path.
178
+ * @param path - Local path to save the file. An explicit path does not require a home directory.
179
+ * If omitted, saves to the Composio temp directory using the filename from the mount path.
179
180
  * An existing default destination gets a copy number before its extension.
180
181
  * @returns The absolute path where the file was saved
181
182
  * @throws Error if file system is not supported or the save fails
@@ -189,30 +190,35 @@ export class RemoteFile {
189
190
  );
190
191
  }
191
192
 
193
+ // An explicit `path` is the caller's own, so it needs no home directory.
194
+ if (path != null) {
195
+ const content = await this.buffer();
196
+ const dir = getParentDir(path);
197
+ if (dir && !platform.existsSync(dir)) {
198
+ platform.mkdirSync(dir);
199
+ }
200
+ platform.writeFileSync(path, content);
201
+ return path;
202
+ }
203
+
192
204
  const homeDir = platform.homedir();
193
205
  if (!homeDir) {
194
206
  throw new Error('Cannot determine save location: home directory is not available');
195
207
  }
196
208
 
197
- // An explicit `path` is the caller's own. The default branch builds a path
198
- // out of `mountRelativePath`, a server-controlled response field, so it is
199
- // validated first (SEC-316, mirroring the Python SDK): a value such as `""`,
200
- // `"."` or `"foo/.."` would otherwise make `savePath` its own directory or
201
- // the parent, and fail with a raw `EISDIR` only after `mkdirSync` had run.
209
+ // The default path is built from `mountRelativePath`, a server-controlled
210
+ // response field, so it is validated first (SEC-316, mirroring the Python
211
+ // SDK): a value such as `""`, `"."` or `"foo/.."` would otherwise make
212
+ // `savePath` its own directory or the parent, and fail with a raw `EISDIR`
213
+ // only after `mkdirSync` had run.
202
214
  const defaultDir = platform.joinPath(homeDir, COMPOSIO_DIR, TEMP_FILES_DIRECTORY_NAME);
203
- const defaultName = path == null ? safeBasename(this.mountRelativePath, 'mount path') : '';
204
- const savePath = path ?? platform.joinPath(defaultDir, defaultName);
215
+ const defaultName = safeBasename(this.mountRelativePath, 'mount path');
216
+ const savePath = platform.joinPath(defaultDir, defaultName);
205
217
 
206
218
  const content = await this.buffer();
207
219
 
208
- const dir = path != null ? getParentDir(savePath) : defaultDir;
209
- if (dir && !platform.existsSync(dir)) {
210
- platform.mkdirSync(dir);
211
- }
212
-
213
- if (path != null) {
214
- platform.writeFileSync(savePath, content);
215
- return savePath;
220
+ if (!platform.existsSync(defaultDir)) {
221
+ platform.mkdirSync(defaultDir);
216
222
  }
217
223
 
218
224
  // Server names can equal a digest-tagged name literally. Reserve a new
@@ -17,6 +17,7 @@ import {
17
17
  ToolRouterSessionExecuteResponseSchema,
18
18
  } from '../types/toolRouter.types';
19
19
  import { ValidationError } from '../errors';
20
+ import { handleToolExecutionError } from '../errors/ToolErrors';
20
21
  import { transformProxyParams } from './proxyParamsTransform';
21
22
  import {
22
23
  assertUnambiguousCustomToolSlug,
@@ -28,7 +29,6 @@ import {
28
29
  transformProxyExecuteResponse,
29
30
  } from '../utils/transformers/toolRouterResponseTransform';
30
31
  import type { SessionExecuteParams } from '@composio/client/resources/tool-router/session';
31
- import { inlineCustomToolsExperimental } from './inlineCustomToolsPayload';
32
32
  import { withCancellation } from '../utils/cancellation';
33
33
  import { withoutRetries } from '../utils/retries';
34
34
 
@@ -97,11 +97,8 @@ export class SessionContextImpl implements SessionContext {
97
97
  tool_slug: toolSlug,
98
98
  arguments: arguments_,
99
99
  };
100
- const experimental = inlineCustomToolsExperimental<
101
- NonNullable<SessionExecuteParams['experimental']>
102
- >(this.inlineCustomToolsPayload);
103
- if (experimental) {
104
- executeParams.experimental = experimental;
100
+ if (this.inlineCustomToolsPayload) {
101
+ executeParams.experimental = this.inlineCustomToolsPayload;
105
102
  }
106
103
 
107
104
  const response = await withCancellation(
@@ -112,7 +109,9 @@ export class SessionContextImpl implements SessionContext {
112
109
  withoutRetries(requestOptions)
113
110
  ),
114
111
  requestOptions?.signal
115
- );
112
+ ).catch((error: unknown) => {
113
+ throw handleToolExecutionError(toolSlug, error as Error);
114
+ });
116
115
  return ToolRouterSessionExecuteResponseSchema.parse(
117
116
  transformExecuteResponse(response, toolSlug)
118
117
  );
@@ -6,6 +6,7 @@ import type { ComposioRequestOptions } from '../types/requestOptions.types';
6
6
  import { withCancellation } from '../utils/cancellation';
7
7
  import { withoutRetries } from '../utils/retries';
8
8
  import { ComposioRequestCancelledError } from '../errors/SDKErrors';
9
+ import { handleToolExecutionError } from '../errors/ToolErrors';
9
10
  import {
10
11
  ComposioSessionConfigConflictError,
11
12
  ComposioToolInputRequiredError,
@@ -78,7 +79,6 @@ import type {
78
79
  SessionLinkParams,
79
80
  SessionPatchParams,
80
81
  SessionPatchResponse,
81
- SessionSearchParams,
82
82
  } from '@composio/client/resources/tool-router/session';
83
83
  import { SessionProxyExecuteParamsSchema } from '../types/toolRouter.types';
84
84
  import { SessionContextImpl } from './SessionContext';
@@ -92,7 +92,6 @@ import {
92
92
  findCustomToolMapEntryByToolkitAndOriginalSlug,
93
93
  } from './CustomTool';
94
94
  import { transformProxyParams } from './proxyParamsTransform';
95
- import { inlineCustomToolsExperimental } from './inlineCustomToolsPayload';
96
95
  import { transformToolRouterUpdateParams } from '../lib/toolRouterParams';
97
96
  import { parseSessionConfigInput } from '../lib/sessionConfigConflict';
98
97
  import { getSourceSessionConfig } from '../lib/toolRouterSourceSessionConfig';
@@ -681,13 +680,10 @@ export class ToolRouterSession<
681
680
  },
682
681
  requestOptions?: ComposioRequestOptions
683
682
  ): Promise<ToolRouterSessionSearchResponse> {
684
- const experimental = inlineCustomToolsExperimental<
685
- NonNullable<SessionSearchParams['experimental']>
686
- >(this.inlineCustomToolsPayload);
687
683
  const searchParams = {
688
684
  queries: [{ use_case: params.query }],
689
685
  ...(params.toolkits?.length ? { toolkits: params.toolkits } : {}),
690
- ...(experimental ? { experimental } : {}),
686
+ ...(this.inlineCustomToolsPayload && { experimental: this.inlineCustomToolsPayload }),
691
687
  };
692
688
  const response = await withCancellation(
693
689
  () => this.client.toolRouter.session.search(this.sessionId, searchParams, requestOptions),
@@ -752,11 +748,8 @@ export class ToolRouterSession<
752
748
  if (options?.account) {
753
749
  executeParams.account = options.account;
754
750
  }
755
- const experimental = inlineCustomToolsExperimental<
756
- NonNullable<SessionExecuteParams['experimental']>
757
- >(this.inlineCustomToolsPayload);
758
- if (experimental) {
759
- executeParams.experimental = experimental;
751
+ if (this.inlineCustomToolsPayload) {
752
+ executeParams.experimental = this.inlineCustomToolsPayload;
760
753
  }
761
754
 
762
755
  const response = await withCancellation(
@@ -767,7 +760,9 @@ export class ToolRouterSession<
767
760
  withoutRetries(requestOptions)
768
761
  ),
769
762
  requestOptions?.signal
770
- );
763
+ ).catch((error: unknown) => {
764
+ throw handleToolExecutionError(toolSlug, error as Error);
765
+ });
771
766
  const transformed = transformExecuteResponse(response, toolSlug);
772
767
  return ToolRouterSessionExecuteResponseSchema.parse(transformed);
773
768
  }
@@ -804,11 +799,8 @@ export class ToolRouterSession<
804
799
  arguments: arguments_ ?? {},
805
800
  ...inputResponseParams(options),
806
801
  };
807
- const experimental = inlineCustomToolsExperimental<
808
- NonNullable<SessionExecuteMetaParams['experimental']>
809
- >(this.inlineCustomToolsPayload);
810
- if (experimental) {
811
- executeMetaParams.experimental = experimental;
802
+ if (this.inlineCustomToolsPayload) {
803
+ executeMetaParams.experimental = this.inlineCustomToolsPayload;
812
804
  }
813
805
 
814
806
  const response = await withCancellation(
@@ -819,7 +811,9 @@ export class ToolRouterSession<
819
811
  withoutRetries(requestOptions)
820
812
  ),
821
813
  requestOptions?.signal
822
- );
814
+ ).catch((error: unknown) => {
815
+ throw handleToolExecutionError(slug, error as Error);
816
+ });
823
817
  const transformed = transformExecuteResponse(response, slug);
824
818
  return ToolRouterSessionExecuteResponseSchema.parse(transformed);
825
819
  }
@@ -1025,11 +1019,10 @@ export class ToolRouterSession<
1025
1019
  tool?: Tool
1026
1020
  ): Promise<ToolExecuteResponse> {
1027
1021
  const body = { sessionId: this.sessionId, arguments: input };
1028
- const experimental = inlineCustomToolsExperimental<
1029
- NonNullable<SessionExecuteParams['experimental']>
1030
- >(this.inlineCustomToolsPayload);
1031
- if (experimental) {
1032
- return ToolsModel.executeSessionTool(toolSlug, body, modifiers, tool, { experimental });
1022
+ if (this.inlineCustomToolsPayload) {
1023
+ return ToolsModel.executeSessionTool(toolSlug, body, modifiers, tool, {
1024
+ experimental: this.inlineCustomToolsPayload,
1025
+ });
1033
1026
  }
1034
1027
  return ToolsModel.executeSessionTool(toolSlug, body, modifiers, tool);
1035
1028
  }