@composio/core 0.11.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.
Files changed (193) hide show
  1. package/dist/BaseProvider-BBnsv9kS.d.mts +29425 -0
  2. package/dist/{BaseProvider-CVbQxTNa.d.cts → BaseProvider-Brb3o86-.d.mts} +91 -44
  3. package/dist/CustomTool-D9qwyMrv.mjs +468 -0
  4. package/dist/{CustomTool-C-IUByoU.d.cts → CustomTool-Dmi6ti3I.d.mts} +2 -4
  5. package/dist/{CustomTool-CChQSp44.d.mts → CustomTool-DrJpOhY2.d.mts} +2 -4
  6. package/dist/{FileModifierErrors-C7z16Dfi.mjs → FileModifierErrors-3fSwIWoa.mjs} +35 -36
  7. package/dist/{Telemetry-DQax33Gh.mjs → Telemetry-DhGI_J4G.mjs} +15 -15
  8. package/dist/{composio-pcA13w87.d.cts → composio-DHIKRdeG.d.mts} +641 -380
  9. package/dist/{composio-BlASKqjQ.d.mts → composio-vMwhASRc.d.mts} +1390 -1129
  10. package/dist/{customTool.types-QtkAZQma.d.cts → customTool.types-CKH2R2ia.d.mts} +487 -189
  11. package/dist/{customTool.types-DLIORcYN.d.mts → customTool.types-DXin7Cfc.d.mts} +924 -626
  12. package/dist/docs/error-consistency.md +97 -0
  13. package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +306 -0
  14. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +205 -0
  15. package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +488 -0
  16. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +94 -0
  17. package/dist/docs/reference/sdk-reference/typescript/index.mdx +67 -0
  18. package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +304 -0
  19. package/dist/docs/reference/sdk-reference/typescript/meta.json +17 -0
  20. package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +107 -0
  21. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +163 -0
  22. package/dist/docs/reference/sdk-reference/typescript/session.mdx +229 -0
  23. package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +131 -0
  24. package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +169 -0
  25. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +453 -0
  26. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +434 -0
  27. package/dist/{CustomTool-D5s-aADw.mjs → errors-DSIlYfl5.mjs} +72 -459
  28. package/dist/experimental/index.d.mts +2 -3
  29. package/dist/experimental/index.mjs +1 -3
  30. package/dist/{fileUtils.node-Dq7ebZPC.mjs → fileUtils.node-BiO1JQsJ.mjs} +26 -25
  31. package/dist/index.d.mts +1708 -2400
  32. package/dist/index.mjs +2632 -2006
  33. package/dist/jsonSchema-CFKdONpP.mjs +251 -0
  34. package/dist/models/Files.node.d.mts +1 -2
  35. package/dist/models/Files.node.mjs +3 -4
  36. package/dist/models/Files.workerd.d.mts +0 -1
  37. package/dist/platform/node.d.mts +1 -2
  38. package/dist/platform/workerd.d.mts +1 -2
  39. package/dist/{chunk-CWQeghP5.mjs → rolldown-runtime-w6R9maHv.mjs} +3 -5
  40. package/dist/{types-J2KCXP8R.d.mts → types-D4Id3wXA.d.mts} +2 -3
  41. package/dist/{types-DRG5qLxI.d.cts → types-qTbYYBJw.d.mts} +2 -3
  42. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -4
  43. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -4
  44. package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +3 -0
  45. package/dist/utils/json-schema.d.mts +2 -0
  46. package/dist/utils/json-schema.mjs +3 -0
  47. package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -1
  48. package/dist/utils/modifiers/FileToolModifier.node.mjs +44 -24
  49. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -1
  50. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
  51. package/docs/error-consistency.md +97 -0
  52. package/package.json +40 -88
  53. package/src/composio.ts +509 -0
  54. package/src/errors/AuthConfigErrors.ts +23 -0
  55. package/src/errors/ComposioError.ts +408 -0
  56. package/src/errors/ConnectedAccountsErrors.ts +158 -0
  57. package/src/errors/ConnectionRequestErrors.ts +32 -0
  58. package/src/errors/FileModifierErrors.ts +100 -0
  59. package/src/errors/PusherErrors.ts +28 -0
  60. package/src/errors/RemoteFileErrors.ts +62 -0
  61. package/src/errors/SDKErrors.ts +92 -0
  62. package/src/errors/ToolErrors.ts +244 -0
  63. package/src/errors/ToolkitErrors.ts +39 -0
  64. package/src/errors/TriggerErrors.ts +120 -0
  65. package/src/errors/ValidationErrors.ts +99 -0
  66. package/src/errors/index.ts +41 -0
  67. package/src/experimental/index.ts +28 -0
  68. package/src/index.ts +64 -0
  69. package/src/lib/toolRouterConstants.ts +1 -0
  70. package/src/lib/toolRouterParams.ts +306 -0
  71. package/src/models/AuthConfigs.ts +398 -0
  72. package/src/models/AuthScheme.ts +206 -0
  73. package/src/models/ConnectedAccounts.ts +735 -0
  74. package/src/models/ConnectionRequest.ts +150 -0
  75. package/src/models/CustomTool.ts +676 -0
  76. package/src/models/Experimental.ts +202 -0
  77. package/src/models/Files.node.ts +93 -0
  78. package/src/models/Files.workerd.ts +49 -0
  79. package/src/models/MCP.ts +478 -0
  80. package/src/models/RemoteFile.ts +172 -0
  81. package/src/models/SessionContext.ts +147 -0
  82. package/src/models/Sessions.ts +21 -0
  83. package/src/models/ToolRouter.ts +391 -0
  84. package/src/models/ToolRouterSession.ts +827 -0
  85. package/src/models/ToolRouterSessionFileMount.ts +389 -0
  86. package/src/models/Toolkits.ts +412 -0
  87. package/src/models/Tools.ts +1260 -0
  88. package/src/models/Triggers.ts +1381 -0
  89. package/src/models/customToolExecution.ts +118 -0
  90. package/src/models/inlineCustomToolsPayload.ts +17 -0
  91. package/src/models/proxyParamsTransform.ts +26 -0
  92. package/src/provider/BaseProvider.ts +138 -0
  93. package/src/provider/ComposioProvider.ts +29 -0
  94. package/src/provider/OpenAIProvider.ts +547 -0
  95. package/src/services/internal/InternalService.ts +50 -0
  96. package/src/services/internal/InternalService.types.ts +14 -0
  97. package/src/services/pusher/Pusher.ts +230 -0
  98. package/src/services/telemetry/TelemetryService.ts +48 -0
  99. package/src/services/telemetry/TelemetryService.types.ts +67 -0
  100. package/src/telemetry/BatchProcessor.ts +77 -0
  101. package/src/telemetry/README.md +123 -0
  102. package/src/telemetry/Telemetry.ts +356 -0
  103. package/src/types/ToolRouterSessionFilesMount.types.ts +96 -0
  104. package/src/types/authConfigs.types.ts +174 -0
  105. package/src/types/composio.types.ts +1 -0
  106. package/src/types/connectedAccountAuthStates.types.ts +852 -0
  107. package/src/types/connectedAccounts.types.ts +395 -0
  108. package/src/types/connectionRequest.types.ts +16 -0
  109. package/src/types/customTool.types.ts +261 -0
  110. package/{dist/files.types-lo4zZd87.d.cts → src/types/files.types.ts} +3 -5
  111. package/src/types/mcp.experimental.types.ts +163 -0
  112. package/src/types/mcp.types.ts +362 -0
  113. package/src/types/modifiers.types.ts +663 -0
  114. package/src/types/org.types.ts +0 -0
  115. package/src/types/provider.types.ts +41 -0
  116. package/src/types/pusher.types.ts +18 -0
  117. package/src/types/requestOptions.types.ts +62 -0
  118. package/src/types/telemetry.types.ts +89 -0
  119. package/src/types/tool.types.ts +408 -0
  120. package/src/types/toolRouter.types.ts +761 -0
  121. package/src/types/toolkit.types.ts +130 -0
  122. package/src/types/triggers.types.ts +401 -0
  123. package/src/types/webhookEvents.types.ts +219 -0
  124. package/src/utils/buffer.ts +30 -0
  125. package/src/utils/cancellation.ts +22 -0
  126. package/src/utils/config-defaults/ConfigDefaults.node.ts +7 -0
  127. package/src/utils/config-defaults/ConfigDefaults.workerd.ts +10 -0
  128. package/src/utils/config-defaults/index.ts +1 -0
  129. package/src/utils/config-defaults/types.ts +14 -0
  130. package/src/utils/constants.ts +22 -0
  131. package/src/utils/crypto.ts +34 -0
  132. package/src/utils/env.ts +34 -0
  133. package/src/utils/fileDirs.ts +81 -0
  134. package/src/utils/fileUtils.node.ts +458 -0
  135. package/src/utils/json-schema.ts +1 -0
  136. package/src/utils/jsonSchema.ts +355 -0
  137. package/src/utils/logger.ts +99 -0
  138. package/src/utils/mime.ts +75 -0
  139. package/src/utils/modifiers/FileToolModifier.node.ts +477 -0
  140. package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +132 -0
  141. package/src/utils/modifiers/FileToolModifier.workerd.ts +51 -0
  142. package/src/utils/pagination.ts +73 -0
  143. package/src/utils/pusher.ts +286 -0
  144. package/src/utils/schemaPropertyKeys.ts +433 -0
  145. package/src/utils/sdk.ts +110 -0
  146. package/src/utils/sensitiveFileUploadPaths.node.ts +105 -0
  147. package/src/utils/session.ts +114 -0
  148. package/src/utils/toolArguments.ts +73 -0
  149. package/src/utils/toolkitVersion.ts +26 -0
  150. package/src/utils/transform.ts +42 -0
  151. package/src/utils/transformers/authConfigs.ts +107 -0
  152. package/src/utils/transformers/connectedAccounts.ts +119 -0
  153. package/src/utils/transformers/mcp.ts +164 -0
  154. package/src/utils/transformers/toolRouterResponseTransform.ts +160 -0
  155. package/src/utils/transformers/toolkits.ts +100 -0
  156. package/src/utils/transformers/triggers.ts +118 -0
  157. package/src/utils/uploadDirAllowlist.node.ts +178 -0
  158. package/src/utils/uuid.ts +7 -0
  159. package/src/utils/version.ts +58 -0
  160. package/src/utils/zodSchema.ts +90 -0
  161. package/dist/BaseProvider-BvHvJLXc.d.mts +0 -29378
  162. package/dist/CustomTool-D3-NreIm.cjs +0 -1341
  163. package/dist/FileModifierErrors-BYJBHiay.cjs +0 -554
  164. package/dist/FileToolModifier.utils.neutral-DSBQs9-i.cjs +0 -96
  165. package/dist/Telemetry-BQ_pl5AK.cjs +0 -360
  166. package/dist/buffer-BjWptbNH.cjs +0 -63
  167. package/dist/chunk-CQwRTUmo.cjs +0 -53
  168. package/dist/experimental/index.cjs +0 -5
  169. package/dist/experimental/index.d.cts +0 -3
  170. package/dist/fileUtils.node-DtnSRMWa.cjs +0 -462
  171. package/dist/index.cjs +0 -8523
  172. package/dist/index.d.cts +0 -6065
  173. package/dist/models/Files.node.cjs +0 -55
  174. package/dist/models/Files.node.d.cts +0 -56
  175. package/dist/models/Files.workerd.cjs +0 -29
  176. package/dist/models/Files.workerd.d.cts +0 -13
  177. package/dist/platform/node.cjs +0 -55
  178. package/dist/platform/node.d.cts +0 -11
  179. package/dist/platform/workerd.cjs +0 -42
  180. package/dist/platform/workerd.d.cts +0 -12
  181. package/dist/types-pDNm1lYs.d.cts +0 -69
  182. package/dist/utils/config-defaults/ConfigDefaults.node.cjs +0 -10
  183. package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +0 -7
  184. package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +0 -10
  185. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +0 -7
  186. package/dist/utils/modifiers/FileToolModifier.node.cjs +0 -224
  187. package/dist/utils/modifiers/FileToolModifier.node.d.cts +0 -22
  188. package/dist/utils/modifiers/FileToolModifier.workerd.cjs +0 -27
  189. package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +0 -20
  190. /package/dist/{FileToolModifier.utils.neutral-BpSceNK8.mjs → FileToolModifier.utils.neutral-B5rT711M.mjs} +0 -0
  191. /package/dist/{buffer-yOtEsT4J.mjs → buffer-PcbMMsgm.mjs} +0 -0
  192. /package/dist/{files.types-BXDWA_zS.d.mts → files.types-DeMC_mAW.d.mts} +0 -0
  193. /package/dist/{types-HpJQ8K9l.d.mts → types-DdoCRzLj.d.mts} +0 -0
@@ -1,55 +0,0 @@
1
- require('../FileModifierErrors-BYJBHiay.cjs');
2
- const require_Telemetry = require('../Telemetry-BQ_pl5AK.cjs');
3
- const require_fileUtils_node = require('../fileUtils.node-DtnSRMWa.cjs');
4
-
5
- //#region src/models/Files.node.ts
6
- var Files = class {
7
- fileOptions;
8
- constructor(client, fileOptions = {}) {
9
- this.client = client;
10
- this.fileOptions = fileOptions;
11
- require_Telemetry.telemetry.instrument(this, "Files");
12
- }
13
- /**
14
- * Upload a file and return the file data.
15
- *
16
- * @param params - The upload parameters.
17
- * @param {File | string} params.file - The path to the file to upload, a URL of the file, or a File object.
18
- * @param {string} params.toolSlug - The slug of the tool that is uploading the file.
19
- * @param {string} params.toolkitSlug - The slug of the toolkit that is uploading the file.
20
- * @returns {Promise<FileUploadData>} The uploaded file data.
21
- *
22
- * @example
23
- *
24
- * const fileData = await composio.files.upload({
25
- * file: 'path/to/file.pdf',
26
- * toolSlug: 'google_drive_upload',
27
- * toolkitSlug: 'google_drive'
28
- * });
29
- * */
30
- async upload({ file, toolSlug, toolkitSlug }) {
31
- return await require_fileUtils_node.getFileDataAfterUploadingToS3(file, {
32
- toolSlug,
33
- toolkitSlug,
34
- client: this.client,
35
- sensitiveFileUploadProtection: this.fileOptions.sensitiveFileUploadProtection,
36
- fileUploadPathDenySegments: this.fileOptions.fileUploadPathDenySegments
37
- });
38
- }
39
- /**
40
- * Download a file from S3 and return the file data.
41
- * @param s3key - The S3 key of the file to download.
42
- * @returns The file data.
43
- */
44
- async download({ toolSlug, s3Url, mimeType }) {
45
- return await require_fileUtils_node.downloadFileFromS3({
46
- toolSlug,
47
- s3Url,
48
- mimeType,
49
- fileDownloadDir: this.fileOptions.fileDownloadDir
50
- });
51
- }
52
- };
53
-
54
- //#endregion
55
- exports.Files = Files;
@@ -1,56 +0,0 @@
1
- import { n as FileUploadData, t as FileDownloadData } from "../files.types-lo4zZd87.cjs";
2
- import ComposioClient from "@composio/client";
3
-
4
- //#region src/models/Files.node.d.ts
5
-
6
- declare class Files {
7
- private readonly client;
8
- private readonly fileOptions;
9
- constructor(client: ComposioClient, fileOptions?: {
10
- sensitiveFileUploadProtection?: boolean;
11
- fileUploadPathDenySegments?: string[];
12
- fileDownloadDir?: string;
13
- });
14
- /**
15
- * Upload a file and return the file data.
16
- *
17
- * @param params - The upload parameters.
18
- * @param {File | string} params.file - The path to the file to upload, a URL of the file, or a File object.
19
- * @param {string} params.toolSlug - The slug of the tool that is uploading the file.
20
- * @param {string} params.toolkitSlug - The slug of the toolkit that is uploading the file.
21
- * @returns {Promise<FileUploadData>} The uploaded file data.
22
- *
23
- * @example
24
- *
25
- * const fileData = await composio.files.upload({
26
- * file: 'path/to/file.pdf',
27
- * toolSlug: 'google_drive_upload',
28
- * toolkitSlug: 'google_drive'
29
- * });
30
- * */
31
- upload({
32
- file,
33
- toolSlug,
34
- toolkitSlug
35
- }: {
36
- file: File | string;
37
- toolSlug: string;
38
- toolkitSlug: string;
39
- }): Promise<FileUploadData>;
40
- /**
41
- * Download a file from S3 and return the file data.
42
- * @param s3key - The S3 key of the file to download.
43
- * @returns The file data.
44
- */
45
- download({
46
- toolSlug,
47
- s3Url,
48
- mimeType
49
- }: {
50
- s3Url: string;
51
- toolSlug: string;
52
- mimeType: string;
53
- }): Promise<FileDownloadData>;
54
- }
55
- //#endregion
56
- export { Files };
@@ -1,29 +0,0 @@
1
-
2
- //#region src/models/Files.workerd.ts
3
- const UNSUPPORTED_MESSAGE = "File operations (upload/download) are not supported in Cloudflare Workers or Edge runtimes. These operations require Node.js-specific APIs (e.g., `node:crypto`, `node:fs`) that are not available in this environment. Please use a Node.js runtime for file operations.";
4
- /**
5
- * Creates a Proxy that throws a user-friendly error when any method is accessed.
6
- * This ensures that users get a clear error message when attempting to use
7
- * file operations in unsupported environments.
8
- */
9
- const createUnsupportedFilesProxy = () => {
10
- return new Proxy({}, { get(_target, prop) {
11
- if (prop === Symbol.toStringTag) return "Files";
12
- if (prop === "constructor") return Files;
13
- return () => {
14
- throw new Error(UNSUPPORTED_MESSAGE);
15
- };
16
- } });
17
- };
18
- /**
19
- * Files class for Cloudflare Workers / Edge runtimes.
20
- * All methods throw an error indicating that file operations are not supported.
21
- */
22
- var Files = class {
23
- constructor(_client) {
24
- return createUnsupportedFilesProxy();
25
- }
26
- };
27
-
28
- //#endregion
29
- exports.Files = Files;
@@ -1,13 +0,0 @@
1
- import ComposioClient from "@composio/client";
2
-
3
- //#region src/models/Files.workerd.d.ts
4
-
5
- /**
6
- * Files class for Cloudflare Workers / Edge runtimes.
7
- * All methods throw an error indicating that file operations are not supported.
8
- */
9
- declare class Files {
10
- constructor(_client: ComposioClient);
11
- }
12
- //#endregion
13
- export { Files };
@@ -1,55 +0,0 @@
1
- const require_chunk = require('../chunk-CQwRTUmo.cjs');
2
- let node_fs = require("node:fs");
3
- node_fs = require_chunk.__toESM(node_fs);
4
- let node_os = require("node:os");
5
- node_os = require_chunk.__toESM(node_os);
6
- let node_path = require("node:path");
7
- node_path = require_chunk.__toESM(node_path);
8
-
9
- //#region src/platform/node.ts
10
- /**
11
- * Node.js platform implementation.
12
- * Provides full file system and OS operations using Node.js built-in modules.
13
- */
14
- const platform = {
15
- supportsFileSystem: true,
16
- homedir() {
17
- try {
18
- return node_os.homedir();
19
- } catch {
20
- return null;
21
- }
22
- },
23
- joinPath(...paths) {
24
- return node_path.join(...paths);
25
- },
26
- resolvePath(...paths) {
27
- return node_path.resolve(...paths);
28
- },
29
- isAbsolutePath(filePath) {
30
- return node_path.isAbsolute(filePath);
31
- },
32
- basename(filePath) {
33
- return node_path.basename(filePath);
34
- },
35
- existsSync(filePath) {
36
- return node_fs.existsSync(filePath);
37
- },
38
- mkdirSync(dirPath) {
39
- node_fs.mkdirSync(dirPath, { recursive: true });
40
- },
41
- readFileSync(filePath, encoding) {
42
- if (encoding === void 0) {
43
- const buf = node_fs.readFileSync(filePath, { encoding: null });
44
- return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
45
- }
46
- return node_fs.readFileSync(filePath, { encoding });
47
- },
48
- writeFileSync(filePath, content, encoding) {
49
- if (encoding && typeof content === "string") node_fs.writeFileSync(filePath, content, { encoding });
50
- else node_fs.writeFileSync(filePath, content);
51
- }
52
- };
53
-
54
- //#endregion
55
- exports.platform = platform;
@@ -1,11 +0,0 @@
1
- import { t as Platform } from "../types-pDNm1lYs.cjs";
2
-
3
- //#region src/platform/node.d.ts
4
-
5
- /**
6
- * Node.js platform implementation.
7
- * Provides full file system and OS operations using Node.js built-in modules.
8
- */
9
- declare const platform: Platform;
10
- //#endregion
11
- export { platform };
@@ -1,42 +0,0 @@
1
-
2
- //#region src/platform/workerd.ts
3
- /**
4
- * Cloudflare Workers / Edge runtime platform implementation.
5
- * Provides stub implementations for file system operations that are unavailable in edge runtimes.
6
- * All file system operations gracefully return null/empty values or throw descriptive errors.
7
- */
8
- const platform = {
9
- supportsFileSystem: false,
10
- homedir() {
11
- return null;
12
- },
13
- joinPath(...paths) {
14
- return paths.map((segment, index) => {
15
- if (index === 0) return segment.replace(/\/+$/, "");
16
- return segment.replace(/^\/+|\/+$/g, "");
17
- }).filter(Boolean).join("/");
18
- },
19
- resolvePath(...paths) {
20
- return this.joinPath(...paths);
21
- },
22
- isAbsolutePath(filePath) {
23
- return filePath.startsWith("/");
24
- },
25
- basename(filePath) {
26
- const segments = filePath.replace(/\/+$/, "").split("/");
27
- return segments[segments.length - 1] || "";
28
- },
29
- existsSync(_filePath) {
30
- return false;
31
- },
32
- mkdirSync(_dirPath) {},
33
- readFileSync(_filePath, _encoding) {
34
- throw new Error("File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). Use environment variables or external storage services instead.");
35
- },
36
- writeFileSync(_filePath, _content, _encoding) {
37
- throw new Error("File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). Use environment variables or external storage services instead.");
38
- }
39
- };
40
-
41
- //#endregion
42
- exports.platform = platform;
@@ -1,12 +0,0 @@
1
- import { t as Platform } from "../types-pDNm1lYs.cjs";
2
-
3
- //#region src/platform/workerd.d.ts
4
-
5
- /**
6
- * Cloudflare Workers / Edge runtime platform implementation.
7
- * Provides stub implementations for file system operations that are unavailable in edge runtimes.
8
- * All file system operations gracefully return null/empty values or throw descriptive errors.
9
- */
10
- declare const platform: Platform;
11
- //#endregion
12
- export { platform };
@@ -1,69 +0,0 @@
1
- //#region src/platform/types.d.ts
2
- /**
3
- * Platform abstraction for file system and OS operations.
4
- * This interface allows different implementations for Node.js and edge runtimes (e.g., Cloudflare Workers).
5
- */
6
- interface Platform {
7
- /**
8
- * Returns the user's home directory path.
9
- * @returns The home directory path, or null if unavailable (e.g., in edge runtimes).
10
- */
11
- homedir(): string | null;
12
- /**
13
- * Joins path segments into a single path.
14
- * @param paths - Path segments to join.
15
- * @returns The joined path.
16
- */
17
- joinPath(...paths: string[]): string;
18
- /**
19
- * Resolves a sequence of paths into an absolute path. On Node this is
20
- * `path.resolve`; on edge runtimes without a working directory it
21
- * normalizes/joins the segments and returns the result verbatim.
22
- */
23
- resolvePath(...paths: string[]): string;
24
- /**
25
- * Returns true if the given path is absolute.
26
- */
27
- isAbsolutePath(filePath: string): boolean;
28
- /**
29
- * Returns the last portion of a path (the filename).
30
- * @param filePath - The path to extract the basename from.
31
- * @returns The basename of the path.
32
- */
33
- basename(filePath: string): string;
34
- /**
35
- * Checks if a file or directory exists at the given path.
36
- * @param filePath - The path to check.
37
- * @returns True if the path exists, false otherwise.
38
- */
39
- existsSync(filePath: string): boolean;
40
- /**
41
- * Creates a directory at the given path, including parent directories if needed.
42
- * @param dirPath - The directory path to create.
43
- */
44
- mkdirSync(dirPath: string): void;
45
- /**
46
- * Reads a file synchronously and returns its contents.
47
- * @param filePath - The path to the file.
48
- * @param encoding - Optional encoding (e.g., 'utf8'). If not provided, returns an Uint8Array.
49
- * @returns The file contents as a string (if encoding provided) or Uint8Array.
50
- */
51
- readFileSync(filePath: string, encoding?: never): Uint8Array;
52
- readFileSync(filePath: string, encoding: Uint8ArrayEncoding): string;
53
- /**
54
- * Writes content to a file synchronously.
55
- * @param filePath - The path to the file.
56
- * @param content - The content to write (string or Uint8Array).
57
- * @param encoding - Optional encoding for string content.
58
- */
59
- writeFileSync(filePath: string, content: Uint8Array, encoding?: never): void;
60
- writeFileSync(filePath: string, content: string, encoding: Uint8ArrayEncoding): void;
61
- /**
62
- * Indicates whether this platform supports file system operations.
63
- * Edge runtimes like Cloudflare Workers return false.
64
- */
65
- readonly supportsFileSystem: boolean;
66
- }
67
- type Uint8ArrayEncoding = 'utf8';
68
- //#endregion
69
- export { Platform as t };
@@ -1,10 +0,0 @@
1
-
2
- //#region src/utils/config-defaults/ConfigDefaults.node.ts
3
- const CONFIG_DEFAULTS = {
4
- dangerouslyAllowAutoUploadDownloadFiles: false,
5
- allowTracking: true,
6
- toolkitVersions: "latest"
7
- };
8
-
9
- //#endregion
10
- exports.CONFIG_DEFAULTS = CONFIG_DEFAULTS;
@@ -1,7 +0,0 @@
1
- import "../../composio-pcA13w87.cjs";
2
- import { t as ConfigDefaults } from "../../types-DRG5qLxI.cjs";
3
-
4
- //#region src/utils/config-defaults/ConfigDefaults.node.d.ts
5
- declare const CONFIG_DEFAULTS: ConfigDefaults;
6
- //#endregion
7
- export { CONFIG_DEFAULTS };
@@ -1,10 +0,0 @@
1
-
2
- //#region src/utils/config-defaults/ConfigDefaults.workerd.ts
3
- const CONFIG_DEFAULTS = {
4
- dangerouslyAllowAutoUploadDownloadFiles: false,
5
- allowTracking: true,
6
- toolkitVersions: "latest"
7
- };
8
-
9
- //#endregion
10
- exports.CONFIG_DEFAULTS = CONFIG_DEFAULTS;
@@ -1,7 +0,0 @@
1
- import "../../composio-pcA13w87.cjs";
2
- import { t as ConfigDefaults } from "../../types-DRG5qLxI.cjs";
3
-
4
- //#region src/utils/config-defaults/ConfigDefaults.workerd.d.ts
5
- declare const CONFIG_DEFAULTS: ConfigDefaults;
6
- //#endregion
7
- export { CONFIG_DEFAULTS };
@@ -1,224 +0,0 @@
1
- const require_FileModifierErrors = require('../../FileModifierErrors-BYJBHiay.cjs');
2
- const require_FileToolModifier_utils_neutral = require('../../FileToolModifier.utils.neutral-DSBQs9-i.cjs');
3
- const require_fileUtils_node = require('../../fileUtils.node-DtnSRMWa.cjs');
4
-
5
- //#region src/utils/modifiers/FileToolModifier.node.ts
6
- const getSchemaVariants = (schema) => [
7
- ...schema?.anyOf ?? [],
8
- ...schema?.oneOf ?? [],
9
- ...schema?.allOf ?? []
10
- ];
11
- const jsonSchemaTypeMatchesValue = (schema, value) => {
12
- const schemaType = schema.type;
13
- if (Array.isArray(schemaType)) return schemaType.some((type) => jsonSchemaTypeMatchesValue({
14
- ...schema,
15
- type
16
- }, value));
17
- if (schemaType === void 0) {
18
- if (schema.properties) return require_FileToolModifier_utils_neutral.isPlainObject(value);
19
- if (schema.items) return Array.isArray(value);
20
- return false;
21
- }
22
- switch (schemaType) {
23
- case "array": return Array.isArray(value);
24
- case "object": return require_FileToolModifier_utils_neutral.isPlainObject(value);
25
- case "string": return typeof value === "string";
26
- case "integer": return Number.isInteger(value);
27
- case "number": return typeof value === "number";
28
- case "boolean": return typeof value === "boolean";
29
- case "null": return value === null;
30
- default: return false;
31
- }
32
- };
33
- const findSchemaVariantWithFileProperty = (schema, property, value) => {
34
- const candidates = getSchemaVariants(schema).filter((variant) => require_FileToolModifier_utils_neutral.schemaHasFileProperty(variant, property));
35
- return candidates.find((candidate) => jsonSchemaTypeMatchesValue(candidate, value)) ?? candidates[0];
36
- };
37
- /**
38
- * Recursively walks a runtime value and its matching JSON-Schema node,
39
- * uploading any string path whose schema node has `file_uploadable: true`.
40
- * The function returns a **new** value with all substitutions applied;
41
- * nothing is mutated in-place.
42
- */
43
- const hydrateFiles = async (value, schema, ctx) => {
44
- if (schema?.file_uploadable) {
45
- if (typeof value !== "string" && !(value instanceof File)) return value;
46
- const runBeforeFileUpload = async (path, source) => {
47
- if (!ctx.beforeFileUpload) return path;
48
- const out = await ctx.beforeFileUpload({
49
- path,
50
- source,
51
- toolSlug: ctx.toolSlug,
52
- toolkitSlug: ctx.toolkitSlug
53
- });
54
- if (out === false) throw new require_FileModifierErrors.ComposioFileUploadAbortedError("File upload was aborted because beforeFileUpload returned false.");
55
- return out;
56
- };
57
- if (typeof value === "string") {
58
- const pathOrUrl = await runBeforeFileUpload(value, value.startsWith("http") ? "url" : "path");
59
- require_FileModifierErrors.logger_default.debug(`Uploading file "${pathOrUrl}"`);
60
- return require_fileUtils_node.getFileDataAfterUploadingToS3(pathOrUrl, {
61
- toolSlug: ctx.toolSlug,
62
- toolkitSlug: ctx.toolkitSlug,
63
- client: ctx.client,
64
- sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
65
- fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,
66
- fileUploadAllowlist: ctx.fileUploadAllowlist
67
- });
68
- }
69
- if (ctx.beforeFileUpload) {
70
- const out = await ctx.beforeFileUpload({
71
- path: value.name,
72
- source: "file",
73
- toolSlug: ctx.toolSlug,
74
- toolkitSlug: ctx.toolkitSlug
75
- });
76
- if (out === false) throw new require_FileModifierErrors.ComposioFileUploadAbortedError("File upload was aborted because beforeFileUpload returned false.");
77
- if (typeof out === "string" && out !== value.name) {
78
- require_FileModifierErrors.logger_default.debug(`Uploading file from path "${out}" (replaced File: ${value.name})`);
79
- return require_fileUtils_node.getFileDataAfterUploadingToS3(out, {
80
- toolSlug: ctx.toolSlug,
81
- toolkitSlug: ctx.toolkitSlug,
82
- client: ctx.client,
83
- sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
84
- fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,
85
- fileUploadAllowlist: ctx.fileUploadAllowlist
86
- });
87
- }
88
- }
89
- require_FileModifierErrors.logger_default.debug(`Uploading file "${value.name}"`);
90
- return require_fileUtils_node.getFileDataAfterUploadingToS3(value, {
91
- toolSlug: ctx.toolSlug,
92
- toolkitSlug: ctx.toolkitSlug,
93
- client: ctx.client,
94
- sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
95
- fileUploadPathDenySegments: ctx.fileUploadPathDenySegments
96
- });
97
- }
98
- const uploadableVariant = findSchemaVariantWithFileProperty(schema, "file_uploadable", value);
99
- if (uploadableVariant) return hydrateFiles(value, uploadableVariant, ctx);
100
- if (schema?.type === "object" && schema.properties && require_FileToolModifier_utils_neutral.isPlainObject(value)) {
101
- const transformed = {};
102
- for (const [k, v] of Object.entries(value)) transformed[k] = await hydrateFiles(v, schema.properties[k], ctx);
103
- return transformed;
104
- }
105
- if (schema?.type === "array" && schema.items && Array.isArray(value)) {
106
- const itemSchema = Array.isArray(schema.items) ? schema.items[0] : schema.items;
107
- return Promise.all(value.map((item) => hydrateFiles(item, itemSchema, ctx)));
108
- }
109
- return value;
110
- };
111
- /**
112
- * Downloads a file from S3 and returns a replacement object.
113
- */
114
- const downloadS3File = async (value, ctx) => {
115
- const { s3url, mimetype } = value;
116
- try {
117
- require_FileModifierErrors.logger_default.debug(`Downloading from S3: ${s3url}`);
118
- const dl = await require_fileUtils_node.downloadFileFromS3({
119
- toolSlug: ctx.toolSlug,
120
- s3Url: s3url,
121
- mimeType: mimetype ?? "application/octet-stream",
122
- fileDownloadDir: ctx.fileDownloadDir
123
- });
124
- require_FileModifierErrors.logger_default.debug(`Downloaded → ${dl.filePath}`);
125
- return {
126
- uri: dl.filePath,
127
- file_downloaded: dl.filePath ? true : false,
128
- s3url,
129
- mimeType: dl.mimeType
130
- };
131
- } catch (err) {
132
- require_FileModifierErrors.logger_default.error(`Download failed: ${s3url}`, { cause: err });
133
- return {
134
- uri: "",
135
- file_downloaded: false,
136
- s3url,
137
- mimeType: mimetype ?? "application/octet-stream"
138
- };
139
- }
140
- };
141
- /**
142
- * Recursively walks an arbitrary value and its matching JSON-Schema node.
143
- * Whenever it encounters an object that represents a file reference
144
- * (i.e. has an `s3url`), it downloads the file and returns a replacement:
145
- * {
146
- * uri: "<local-path>",
147
- * file_downloaded: true | false,
148
- * s3url: "<original S3 URL>",
149
- * mimeType: "<detected-or-fallback-mime-type>"
150
- * }
151
- *
152
- * The function is side-effect-free: it never mutates the input value.
153
- */
154
- const hydrateDownloads = async (value, schema, ctx) => {
155
- if (require_FileToolModifier_utils_neutral.isPlainObject(value) && typeof value.s3url === "string") return downloadS3File(value, ctx);
156
- if (schema?.file_downloadable && require_FileToolModifier_utils_neutral.isPlainObject(value) && typeof value.s3url === "string") return downloadS3File(value, ctx);
157
- if (getSchemaVariants(schema).length > 0) {
158
- const downloadableVariant = findSchemaVariantWithFileProperty(schema, "file_downloadable", value);
159
- if (downloadableVariant) return hydrateDownloads(value, downloadableVariant, ctx);
160
- return hydrateDownloads(value, void 0, ctx);
161
- }
162
- if (require_FileToolModifier_utils_neutral.isPlainObject(value)) {
163
- const pairs = await Promise.all(Object.entries(value).map(async ([k, v]) => [k, await hydrateDownloads(v, schema?.properties?.[k], ctx)]));
164
- return Object.fromEntries(pairs);
165
- }
166
- if (Array.isArray(value)) {
167
- const itemSchema = schema?.items ? Array.isArray(schema.items) ? schema.items[0] : schema.items : void 0;
168
- return Promise.all(value.map((item) => hydrateDownloads(item, itemSchema, ctx)));
169
- }
170
- return value;
171
- };
172
- var FileToolModifier = class {
173
- client;
174
- fileUploadPathOptions;
175
- constructor(client, fileUploadPathOptions = {}) {
176
- this.client = client;
177
- this.fileUploadPathOptions = fileUploadPathOptions;
178
- }
179
- async modifyToolSchema(schema) {
180
- if (!schema.inputParameters?.properties) return schema;
181
- const properties = require_FileToolModifier_utils_neutral.transformProperties(schema.inputParameters.properties);
182
- return {
183
- ...schema,
184
- inputParameters: {
185
- ...schema.inputParameters,
186
- properties
187
- }
188
- };
189
- }
190
- async fileUploadModifier(tool, options) {
191
- const { params, toolSlug, toolkitSlug = "unknown" } = options;
192
- const { arguments: args } = params;
193
- if (!args || typeof args !== "object") return params;
194
- try {
195
- const newArgs = await hydrateFiles(args, tool.inputParameters, {
196
- toolSlug,
197
- toolkitSlug,
198
- client: this.client,
199
- ...this.fileUploadPathOptions
200
- });
201
- return {
202
- ...params,
203
- arguments: newArgs
204
- };
205
- } catch (error) {
206
- if (error instanceof require_FileModifierErrors.ComposioSensitiveFilePathBlockedError || error instanceof require_FileModifierErrors.ComposioFileUploadAbortedError || error instanceof require_FileModifierErrors.ComposioFileUploadPathNotAllowedError || error instanceof require_FileModifierErrors.ComposioFileNotFoundError) throw error;
207
- throw new require_FileModifierErrors.ComposioFileUploadError("Failed to upload file", { cause: error });
208
- }
209
- }
210
- async fileDownloadModifier(tool, options) {
211
- const { result, toolSlug } = options;
212
- const dataWithDownloads = await hydrateDownloads(result.data, tool.outputParameters, {
213
- toolSlug,
214
- fileDownloadDir: this.fileUploadPathOptions.fileDownloadDir
215
- });
216
- return {
217
- ...result,
218
- data: dataWithDownloads
219
- };
220
- }
221
- };
222
-
223
- //#endregion
224
- exports.FileToolModifier = FileToolModifier;
@@ -1,22 +0,0 @@
1
- import { gn as Tool, xn as ToolExecuteResponse, yn as ToolExecuteParams } from "../../BaseProvider-CVbQxTNa.cjs";
2
- import ComposioClient from "@composio/client";
3
-
4
- //#region src/utils/modifiers/FileToolModifier.node.d.ts
5
- declare class FileToolModifier {
6
- private client;
7
- private fileUploadPathOptions;
8
- constructor(client: ComposioClient, fileUploadPathOptions?: FileToolModifier['fileUploadPathOptions']);
9
- modifyToolSchema(schema: Tool): Promise<Tool>;
10
- fileUploadModifier(tool: Tool, options: {
11
- toolSlug: string;
12
- toolkitSlug?: string;
13
- params: ToolExecuteParams;
14
- }): Promise<ToolExecuteParams>;
15
- fileDownloadModifier(tool: Tool, options: {
16
- toolSlug: string;
17
- toolkitSlug: string;
18
- result: ToolExecuteResponse;
19
- }): Promise<ToolExecuteResponse>;
20
- }
21
- //#endregion
22
- export { FileToolModifier };
@@ -1,27 +0,0 @@
1
- const require_FileToolModifier_utils_neutral = require('../../FileToolModifier.utils.neutral-DSBQs9-i.cjs');
2
-
3
- //#region src/utils/modifiers/FileToolModifier.workerd.ts
4
- const UNSUPPORTED_MESSAGE = "File upload/download modifiers are not available on edge runtimes yet. Please set `dangerouslyAllowAutoUploadDownloadFiles: false` (or unset it; it defaults to false) or run Composio in another JS runtime (Node.js / Bun).";
5
- var FileToolModifier = class {
6
- constructor(_client) {}
7
- async modifyToolSchema(schema) {
8
- if (!schema.inputParameters?.properties) return schema;
9
- const properties = require_FileToolModifier_utils_neutral.transformProperties(schema.inputParameters.properties);
10
- return {
11
- ...schema,
12
- inputParameters: {
13
- ...schema.inputParameters,
14
- properties
15
- }
16
- };
17
- }
18
- async fileUploadModifier(_tool, _options) {
19
- throw new Error(UNSUPPORTED_MESSAGE);
20
- }
21
- async fileDownloadModifier(_tool, _options) {
22
- throw new Error(UNSUPPORTED_MESSAGE);
23
- }
24
- };
25
-
26
- //#endregion
27
- exports.FileToolModifier = FileToolModifier;