@composio/core 0.12.0 → 0.13.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.
Files changed (147) hide show
  1. package/dist/{BaseProvider-BBnsv9kS.d.mts → BaseProvider-Brb3o86-.d.mts} +80 -80
  2. package/dist/{CustomTool-DEB4BQPl.mjs → CustomTool-D9qwyMrv.mjs} +1 -1
  3. package/dist/{CustomTool-DH18rVQu.d.mts → CustomTool-DLf7JeKt.d.mts} +1 -1
  4. package/dist/CustomTool-NpHpqdnU.d.mts +74 -0
  5. package/dist/{composio-CHnEggnv.d.mts → composio-BHSQwOUz.d.mts} +503 -319
  6. package/dist/composio-DfPD7BAi.d.mts +5666 -0
  7. package/dist/{customTool.types-DpIdOJjL.d.mts → customTool.types-9yFqPjdw.d.mts} +448 -76
  8. package/dist/customTool.types-D-6YqFdW.d.mts +2826 -0
  9. package/dist/docs/error-consistency.md +97 -0
  10. package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +306 -0
  11. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +205 -0
  12. package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +488 -0
  13. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +94 -0
  14. package/dist/docs/reference/sdk-reference/typescript/index.mdx +67 -0
  15. package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +304 -0
  16. package/dist/docs/reference/sdk-reference/typescript/meta.json +17 -0
  17. package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +107 -0
  18. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +163 -0
  19. package/dist/docs/reference/sdk-reference/typescript/session.mdx +252 -0
  20. package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +155 -0
  21. package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +169 -0
  22. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +453 -0
  23. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +434 -0
  24. package/dist/{errors-D5f4pfvI.mjs → errors-DSIlYfl5.mjs} +2 -2
  25. package/dist/experimental/index.d.mts +2 -2
  26. package/dist/experimental/index.mjs +1 -1
  27. package/dist/index.d.mts +36 -6
  28. package/dist/index.mjs +455 -123
  29. package/dist/{jsonSchema-daqF3S3d.mjs → jsonSchema-CFKdONpP.mjs} +1 -1
  30. package/dist/{types-CaI5Z4PA.d.mts → types-BJLCRj9q.d.mts} +2 -2
  31. package/dist/types-CCh8qvui.d.mts +12 -0
  32. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
  33. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
  34. package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
  35. package/dist/utils/modifiers/FileToolModifier.node.mjs +2 -2
  36. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  37. package/docs/error-consistency.md +97 -0
  38. package/package.json +4 -3
  39. package/src/composio.ts +509 -0
  40. package/src/errors/AuthConfigErrors.ts +23 -0
  41. package/src/errors/ComposioError.ts +408 -0
  42. package/src/errors/ConnectedAccountsErrors.ts +158 -0
  43. package/src/errors/ConnectionRequestErrors.ts +32 -0
  44. package/src/errors/FileModifierErrors.ts +100 -0
  45. package/src/errors/PusherErrors.ts +28 -0
  46. package/src/errors/RemoteFileErrors.ts +62 -0
  47. package/src/errors/SDKErrors.ts +92 -0
  48. package/src/errors/ToolErrors.ts +244 -0
  49. package/src/errors/ToolkitErrors.ts +39 -0
  50. package/src/errors/TriggerErrors.ts +120 -0
  51. package/src/errors/ValidationErrors.ts +99 -0
  52. package/src/errors/index.ts +41 -0
  53. package/src/experimental/index.ts +28 -0
  54. package/src/index.ts +64 -0
  55. package/src/lib/toolRouterConstants.ts +1 -0
  56. package/src/lib/toolRouterParams.ts +306 -0
  57. package/src/lib/toolRouterSessionDelete.ts +30 -0
  58. package/src/models/AuthConfigs.ts +398 -0
  59. package/src/models/AuthScheme.ts +206 -0
  60. package/src/models/ConnectedAccounts.ts +735 -0
  61. package/src/models/ConnectionRequest.ts +150 -0
  62. package/src/models/CustomTool.ts +676 -0
  63. package/src/models/Experimental.ts +202 -0
  64. package/src/models/Files.node.ts +93 -0
  65. package/src/models/Files.workerd.ts +49 -0
  66. package/src/models/MCP.ts +478 -0
  67. package/src/models/RemoteFile.ts +172 -0
  68. package/src/models/SessionContext.ts +147 -0
  69. package/src/models/Sessions.ts +21 -0
  70. package/src/models/ToolRouter.ts +406 -0
  71. package/src/models/ToolRouterSession.ts +839 -0
  72. package/src/models/ToolRouterSessionFileMount.ts +389 -0
  73. package/src/models/Toolkits.ts +412 -0
  74. package/src/models/Tools.ts +1260 -0
  75. package/src/models/Triggers.ts +1381 -0
  76. package/src/models/customToolExecution.ts +118 -0
  77. package/src/models/inlineCustomToolsPayload.ts +17 -0
  78. package/src/models/proxyParamsTransform.ts +26 -0
  79. package/src/provider/BaseProvider.ts +138 -0
  80. package/src/provider/ComposioProvider.ts +29 -0
  81. package/src/provider/OpenAIProvider.ts +547 -0
  82. package/src/services/internal/InternalService.ts +50 -0
  83. package/src/services/internal/InternalService.types.ts +14 -0
  84. package/src/services/pusher/Pusher.ts +230 -0
  85. package/src/services/telemetry/TelemetryService.ts +48 -0
  86. package/src/services/telemetry/TelemetryService.types.ts +67 -0
  87. package/src/telemetry/BatchProcessor.ts +77 -0
  88. package/src/telemetry/README.md +123 -0
  89. package/src/telemetry/Telemetry.ts +356 -0
  90. package/src/types/ToolRouterSessionFilesMount.types.ts +96 -0
  91. package/src/types/authConfigs.types.ts +174 -0
  92. package/src/types/composio.types.ts +1 -0
  93. package/src/types/connectedAccountAuthStates.types.ts +852 -0
  94. package/src/types/connectedAccounts.types.ts +395 -0
  95. package/src/types/connectionRequest.types.ts +16 -0
  96. package/src/types/customTool.types.ts +261 -0
  97. package/src/types/files.types.ts +15 -0
  98. package/src/types/mcp.experimental.types.ts +163 -0
  99. package/src/types/mcp.types.ts +362 -0
  100. package/src/types/modifiers.types.ts +663 -0
  101. package/src/types/org.types.ts +0 -0
  102. package/src/types/provider.types.ts +41 -0
  103. package/src/types/pusher.types.ts +18 -0
  104. package/src/types/requestOptions.types.ts +62 -0
  105. package/src/types/telemetry.types.ts +89 -0
  106. package/src/types/tool.types.ts +408 -0
  107. package/src/types/toolRouter.types.ts +774 -0
  108. package/src/types/toolkit.types.ts +130 -0
  109. package/src/types/triggers.types.ts +401 -0
  110. package/src/types/webhookEvents.types.ts +219 -0
  111. package/src/utils/buffer.ts +30 -0
  112. package/src/utils/cancellation.ts +22 -0
  113. package/src/utils/config-defaults/ConfigDefaults.node.ts +7 -0
  114. package/src/utils/config-defaults/ConfigDefaults.workerd.ts +10 -0
  115. package/src/utils/config-defaults/index.ts +1 -0
  116. package/src/utils/config-defaults/types.ts +14 -0
  117. package/src/utils/constants.ts +22 -0
  118. package/src/utils/crypto.ts +34 -0
  119. package/src/utils/env.ts +34 -0
  120. package/src/utils/fileDirs.ts +81 -0
  121. package/src/utils/fileUtils.node.ts +458 -0
  122. package/src/utils/json-schema.ts +1 -0
  123. package/src/utils/jsonSchema.ts +355 -0
  124. package/src/utils/logger.ts +99 -0
  125. package/src/utils/mime.ts +75 -0
  126. package/src/utils/modifiers/FileToolModifier.node.ts +477 -0
  127. package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +132 -0
  128. package/src/utils/modifiers/FileToolModifier.workerd.ts +51 -0
  129. package/src/utils/pagination.ts +73 -0
  130. package/src/utils/pusher.ts +286 -0
  131. package/src/utils/schemaPropertyKeys.ts +433 -0
  132. package/src/utils/sdk.ts +110 -0
  133. package/src/utils/sensitiveFileUploadPaths.node.ts +105 -0
  134. package/src/utils/session.ts +114 -0
  135. package/src/utils/toolArguments.ts +73 -0
  136. package/src/utils/toolkitVersion.ts +26 -0
  137. package/src/utils/transform.ts +42 -0
  138. package/src/utils/transformers/authConfigs.ts +107 -0
  139. package/src/utils/transformers/connectedAccounts.ts +119 -0
  140. package/src/utils/transformers/mcp.ts +164 -0
  141. package/src/utils/transformers/toolRouterResponseTransform.ts +160 -0
  142. package/src/utils/transformers/toolkits.ts +100 -0
  143. package/src/utils/transformers/triggers.ts +118 -0
  144. package/src/utils/uploadDirAllowlist.node.ts +178 -0
  145. package/src/utils/uuid.ts +7 -0
  146. package/src/utils/version.ts +58 -0
  147. package/src/utils/zodSchema.ts +90 -0
@@ -0,0 +1,389 @@
1
+ import { telemetry } from '../telemetry/Telemetry';
2
+ import { Composio as ComposioClient } from '@composio/client';
3
+ import {
4
+ FileDeleteResponse,
5
+ FileDeleteResponseSchema,
6
+ FileListResponse,
7
+ FileListResponseSchema,
8
+ RemoteFileDataSchema,
9
+ ToolRouterSessionFilesMountDeleteOptions,
10
+ ToolRouterSessionFilesMountDeleteOptionsSchema,
11
+ ToolRouterSessionFilesMountDownloadOptions,
12
+ ToolRouterSessionFilesMountDownloadOptionsSchema,
13
+ ToolRouterSessionFilesMountListOptions,
14
+ ToolRouterSessionFilesMountListOptionsSchema,
15
+ ToolRouterSessionFilesMountUploadOptions,
16
+ ToolRouterSessionFilesMountUploadOptionsSchema,
17
+ } from '../types/ToolRouterSessionFilesMount.types';
18
+ import { RemoteFile } from './RemoteFile';
19
+ import { ValidationError } from '../errors';
20
+ import { platform } from '#platform';
21
+ import { getExtensionFromMimeType } from '../utils/mime';
22
+ import { getRandomShortId } from '../utils/uuid';
23
+
24
+ /**
25
+ * File mount for a Composio session, reached via `session.experimental.files`
26
+ * on a session created with `composio.sessions.create(...)`. Upload, list,
27
+ * download, and delete files scoped to a single session.
28
+ */
29
+ export class ToolRouterSessionFilesMount {
30
+ private readonly sessionId: string;
31
+ private readonly client: ComposioClient;
32
+
33
+ constructor(client: ComposioClient, sessionId: string) {
34
+ this.client = client;
35
+ this.sessionId = sessionId;
36
+ telemetry.instrument(this, 'ToolRouterSessionFiles');
37
+ }
38
+
39
+ /**
40
+ * Lists files and directories at the specified path on the session's file mount.
41
+ *
42
+ * Use this to browse the virtual filesystem attached to the tool router session.
43
+ * The path is relative to the mount root (e.g., `"/"` for root, `"/documents"` for a subdirectory).
44
+ * Supports cursor-based pagination via `cursor` and `limit` options.
45
+ *
46
+ * @param options - Optional configuration for the list operation.
47
+ * @param options.path - The directory path to list. Use `"/"` for the mount root.
48
+ * @param options.mountId - The ID of the file mount to operate on. Defaults to `"files"` when omitted.
49
+ * @param options.cursor - Pagination cursor from the previous response's nextCursor field.
50
+ * @param options.limit - Maximum number of files to return per page (1-500).
51
+ * @returns List of files with nextCursor for pagination.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const session = await composio.toolRouter.use('session_123');
56
+ * const { items, nextCursor } = await session.experimental.files.list({ path: '/' });
57
+ * ```
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * // Paginated listing
62
+ * let result = await session.experimental.files.list({ path: '/', limit: 10 });
63
+ * while (result.nextCursor) {
64
+ * result = await session.experimental.files.list({ path: '/', cursor: result.nextCursor, limit: 10 });
65
+ * }
66
+ * ```
67
+ */
68
+ async list(options?: ToolRouterSessionFilesMountListOptions): Promise<FileListResponse> {
69
+ const listOptions = ToolRouterSessionFilesMountListOptionsSchema.safeParse(options ?? {});
70
+
71
+ if (!listOptions.success) {
72
+ throw new ValidationError('Failed to parse tool router session files mount list options', {
73
+ cause: listOptions.error,
74
+ });
75
+ }
76
+
77
+ // API requires: no leading slash, min 1 char when provided. Omit for root.
78
+ const rawPath = listOptions.data.path;
79
+ const mountRelativePrefix =
80
+ rawPath === undefined || rawPath === '' || rawPath === '/'
81
+ ? undefined
82
+ : rawPath.startsWith('/')
83
+ ? rawPath.slice(1)
84
+ : rawPath;
85
+
86
+ const response = await this.client.toolRouter.session.files.list(listOptions.data.mountId, {
87
+ session_id: this.sessionId,
88
+ mount_relative_prefix: mountRelativePrefix,
89
+ cursor: listOptions.data.cursor,
90
+ limit: listOptions.data.limit,
91
+ });
92
+
93
+ const data =
94
+ typeof response === 'object' && 'body' in response
95
+ ? (response as { body: unknown }).body
96
+ : response;
97
+
98
+ const parsed = FileListResponseSchema.safeParse(data);
99
+ if (!parsed.success) {
100
+ throw new ValidationError('Failed to parse file list response', {
101
+ cause: parsed.error,
102
+ });
103
+ }
104
+ return parsed.data;
105
+ }
106
+
107
+ private async normalizeUploadInput(
108
+ input: string | File | ArrayBuffer | Uint8Array,
109
+ options: { remotePath?: string; mimetype?: string }
110
+ ): Promise<{ fileToUpload: File; remotePath: string; mimetype: string }> {
111
+ if (typeof input === 'string') {
112
+ if (input.startsWith('http://') || input.startsWith('https://')) {
113
+ const response = await fetch(input);
114
+ if (!response.ok) {
115
+ throw new Error(`Failed to fetch file from URL: ${response.statusText}`);
116
+ }
117
+ const arrayBuffer = await response.arrayBuffer();
118
+ const rawContentType = response.headers.get('content-type') || 'application/octet-stream';
119
+ const mimeType = rawContentType.split(';')[0].trim();
120
+ const url = new URL(input);
121
+ const pathname = url.pathname;
122
+ const segments = pathname.split('/').filter(Boolean);
123
+ let filename = segments.length > 0 ? segments[segments.length - 1] : '';
124
+ if (!filename || !filename.includes('.')) {
125
+ const extension = getExtensionFromMimeType(mimeType);
126
+ filename = `${getRandomShortId()}.${extension}`;
127
+ }
128
+ const file = new File([arrayBuffer], filename, { type: mimeType });
129
+ return {
130
+ fileToUpload: file,
131
+ remotePath: options.remotePath ?? filename,
132
+ mimetype: mimeType,
133
+ };
134
+ }
135
+ const content = platform.readFileSync(input);
136
+ const buffer =
137
+ content instanceof Uint8Array
138
+ ? new Uint8Array(content)
139
+ : new TextEncoder().encode(content as string);
140
+ const filename = platform.basename(input);
141
+ const mimetype = options.mimetype ?? 'application/octet-stream';
142
+ const file = new File([buffer], filename, { type: mimetype });
143
+ return {
144
+ fileToUpload: file,
145
+ remotePath: options.remotePath ?? filename,
146
+ mimetype,
147
+ };
148
+ }
149
+
150
+ if (input instanceof File) {
151
+ return {
152
+ fileToUpload: input,
153
+ remotePath: options.remotePath ?? (input.name || `upload-${getRandomShortId()}.bin`),
154
+ mimetype: input.type || 'application/octet-stream',
155
+ };
156
+ }
157
+
158
+ const buffer = input instanceof ArrayBuffer ? new Uint8Array(input) : input;
159
+ if (!options.mimetype && !options.remotePath) {
160
+ throw new Error(
161
+ 'When passing a buffer, either mimetype or remotePath (filename) is required. ' +
162
+ 'Example: files.upload(buffer, { remotePath: "data.json", mimetype: "application/json" })'
163
+ );
164
+ }
165
+ const mimetype = options.mimetype ?? 'application/octet-stream';
166
+ const ext = getExtensionFromMimeType(mimetype);
167
+ const remotePath = options.remotePath ?? `upload-${getRandomShortId()}.${ext}`;
168
+ const file = new File([buffer as BlobPart], remotePath, { type: mimetype });
169
+ return {
170
+ fileToUpload: file,
171
+ remotePath,
172
+ mimetype,
173
+ };
174
+ }
175
+
176
+ /**
177
+ * Uploads a file to the session's file mount.
178
+ *
179
+ * Accepts a file path (local or URL), a native File object, or a raw buffer.
180
+ * The file is stored in the virtual filesystem associated with the tool router session.
181
+ *
182
+ * @param input - File path (string), native File, or raw buffer (ArrayBuffer | Uint8Array).
183
+ * @param options - Optional configuration. When passing a buffer, remotePath is required.
184
+ * @returns Metadata about the uploaded file.
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * // From file path (local or URL)
189
+ * await session.experimental.files.upload('/path/to/report.pdf');
190
+ * await session.experimental.files.upload('https://example.com/file.pdf');
191
+ * ```
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * // From native File (e.g. from input[type=file])
196
+ * await session.experimental.files.upload(fileInput.files[0]);
197
+ * ```
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * // From raw buffer
202
+ * await session.experimental.files.upload(buffer, { remotePath: 'data.json', mimetype: 'application/json' });
203
+ * ```
204
+ */
205
+ async upload(
206
+ input: string | File | ArrayBuffer | Uint8Array,
207
+ options?: ToolRouterSessionFilesMountUploadOptions
208
+ ): Promise<RemoteFile> {
209
+ const uploadOptions = ToolRouterSessionFilesMountUploadOptionsSchema.safeParse(options ?? {});
210
+
211
+ if (!uploadOptions.success) {
212
+ throw new ValidationError('Failed to parse tool router session files mount upload options', {
213
+ cause: uploadOptions.error,
214
+ });
215
+ }
216
+
217
+ const { fileToUpload, remotePath, mimetype } = await this.normalizeUploadInput(
218
+ input,
219
+ uploadOptions.data
220
+ );
221
+
222
+ const createUploadURLResponse = await this.client.toolRouter.session.files.createUploadURL(
223
+ uploadOptions.data.mountId,
224
+ {
225
+ session_id: this.sessionId,
226
+ mount_relative_path: remotePath,
227
+ mimetype,
228
+ }
229
+ );
230
+
231
+ const uploadURLData =
232
+ typeof createUploadURLResponse === 'object' && 'body' in createUploadURLResponse
233
+ ? (createUploadURLResponse as { body: unknown }).body
234
+ : createUploadURLResponse;
235
+
236
+ const uploadResponse = await fetch((uploadURLData as { upload_url: string }).upload_url, {
237
+ method: 'PUT',
238
+ body: await fileToUpload.arrayBuffer(),
239
+ headers: {
240
+ 'Content-Type': mimetype,
241
+ },
242
+ });
243
+
244
+ if (!uploadResponse.ok) {
245
+ throw new Error(`Failed to upload file: ${uploadResponse.statusText}`);
246
+ }
247
+
248
+ const createDownloadURLResponse = await this.client.toolRouter.session.files.createDownloadURL(
249
+ uploadOptions.data.mountId,
250
+ {
251
+ session_id: this.sessionId,
252
+ mount_relative_path: (uploadURLData as { mount_relative_path: string }).mount_relative_path,
253
+ }
254
+ );
255
+
256
+ const downloadData =
257
+ typeof createDownloadURLResponse === 'object' && 'body' in createDownloadURLResponse
258
+ ? (createDownloadURLResponse as { body: unknown }).body
259
+ : createDownloadURLResponse;
260
+
261
+ const parsed = RemoteFileDataSchema.safeParse(downloadData);
262
+ if (!parsed.success) {
263
+ throw new ValidationError('Failed to parse remote file properties', {
264
+ cause: parsed.error,
265
+ });
266
+ }
267
+
268
+ return new RemoteFile(parsed.data);
269
+ }
270
+
271
+ /**
272
+ * Downloads a file from the session's file mount to the local filesystem.
273
+ *
274
+ * Retrieves a file stored in the session's virtual filesystem (e.g., one produced
275
+ * by a tool or previously uploaded) and saves it to the specified local path.
276
+ *
277
+ * @param filePath - The path of the file on the mount to download, or the local path where the file should be saved (implementation-specific).
278
+ * @param options - Optional configuration for the download.
279
+ * @param options.mountId - The ID of the file mount to download from. Defaults to `"files"` when omitted.
280
+ * @returns The downloaded file data or path (implementation-specific).
281
+ *
282
+ * @example
283
+ * ```typescript
284
+ * const session = await composio.toolRouter.use('session_123');
285
+ * const result = await session.experimental.files.download('/output/report.pdf');
286
+ * ```
287
+ *
288
+ * @example
289
+ * ```typescript
290
+ * // Download from a custom mount
291
+ * await session.experimental.files.download('/exports/data.json', {
292
+ * mountId: 'custom-mount',
293
+ * });
294
+ * ```
295
+ */
296
+ async download(
297
+ filePath: string,
298
+ options?: ToolRouterSessionFilesMountDownloadOptions
299
+ ): Promise<RemoteFile> {
300
+ const downloadOptions = ToolRouterSessionFilesMountDownloadOptionsSchema.safeParse(
301
+ options ?? {}
302
+ );
303
+
304
+ if (!downloadOptions.success) {
305
+ throw new ValidationError(
306
+ 'Failed to parse tool router session files mount download options',
307
+ {
308
+ cause: downloadOptions.error,
309
+ }
310
+ );
311
+ }
312
+
313
+ const createDownloadURLResponse = await this.client.toolRouter.session.files.createDownloadURL(
314
+ downloadOptions.data.mountId,
315
+ {
316
+ session_id: this.sessionId,
317
+ mount_relative_path: filePath,
318
+ }
319
+ );
320
+
321
+ const downloadURLData =
322
+ typeof createDownloadURLResponse === 'object' && 'body' in createDownloadURLResponse
323
+ ? (createDownloadURLResponse as { body: unknown }).body
324
+ : createDownloadURLResponse;
325
+
326
+ const parsed = RemoteFileDataSchema.safeParse(downloadURLData);
327
+ if (!parsed.success) {
328
+ throw new ValidationError('Failed to parse remote file properties', {
329
+ cause: parsed.error,
330
+ });
331
+ }
332
+ return new RemoteFile(parsed.data);
333
+ }
334
+
335
+ /**
336
+ * Deletes a file or directory at the specified path on the session's file mount.
337
+ *
338
+ * Removes the file or directory from the virtual filesystem. Use with caution:
339
+ * deletion is typically irreversible. Ensure the path exists and is intended for removal.
340
+ *
341
+ * @param remotePath - The path of the file or directory to delete on the mount.
342
+ * @param options - Optional configuration for the delete operation.
343
+ * @param options.mountId - The ID of the file mount to operate on. Defaults to `"files"` when omitted.
344
+ * @returns Confirmation of deletion (implementation-specific).
345
+ *
346
+ * @example
347
+ * ```typescript
348
+ * const session = await composio.toolRouter.use('session_123');
349
+ * await session.experimental.files.delete('/temp/cache.json');
350
+ * ```
351
+ *
352
+ * @example
353
+ * ```typescript
354
+ * // Delete from a custom mount
355
+ * await session.experimental.files.delete('/old-backup', {
356
+ * mountId: 'custom-mount',
357
+ * });
358
+ * ```
359
+ *
360
+ * @warning This operation is destructive. Deleted files cannot be recovered.
361
+ */
362
+ async delete(
363
+ remotePath: string,
364
+ options?: ToolRouterSessionFilesMountDeleteOptions
365
+ ): Promise<FileDeleteResponse> {
366
+ const deleteOptions = ToolRouterSessionFilesMountDeleteOptionsSchema.safeParse(options ?? {});
367
+
368
+ if (!deleteOptions.success) {
369
+ throw new ValidationError('Failed to parse tool router session files mount delete options', {
370
+ cause: deleteOptions.error,
371
+ });
372
+ }
373
+
374
+ const deleteResponse = await this.client.toolRouter.session.files.delete(
375
+ deleteOptions.data.mountId,
376
+ {
377
+ session_id: this.sessionId,
378
+ mount_relative_path: remotePath,
379
+ }
380
+ );
381
+ const fileDeleteResponse = FileDeleteResponseSchema.safeParse(deleteResponse);
382
+ if (!fileDeleteResponse.success) {
383
+ throw new ValidationError('Failed to parse file delete response', {
384
+ cause: fileDeleteResponse.error,
385
+ });
386
+ }
387
+ return fileDeleteResponse.data;
388
+ }
389
+ }