@composio/core 0.6.10 → 0.6.11

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 (42) hide show
  1. package/dist/{CustomTool-BpjZfEYa.d.cts → CustomTool-B1b2MXbO.d.cts} +1 -1
  2. package/dist/{CustomTool-Cyo1aJ2l.cjs → CustomTool-Cywkgg64.cjs} +28 -28
  3. package/dist/{CustomTool-AYNimqhf.mjs → CustomTool-D8cxWvi9.mjs} +1 -1
  4. package/dist/{CustomTool-w_JFqb4t.d.mts → CustomTool-VQMc17af.d.mts} +1 -1
  5. package/dist/{ComposioError-CYaI68Mo.cjs → FileModifierErrors-DuKpNYju.cjs} +74 -0
  6. package/dist/{ComposioError-ChkSdxqU.mjs → FileModifierErrors-LQwvd6pa.mjs} +51 -1
  7. package/dist/{Telemetry-CjVa99gU.mjs → Telemetry-BJ2KYlDT.mjs} +1 -1
  8. package/dist/{Telemetry-A89k5RTv.cjs → Telemetry-JZNofztq.cjs} +17 -17
  9. package/dist/{composio-HztGH0kt.d.mts → composio-D8u53qsy.d.mts} +161 -157
  10. package/dist/{composio-CQuG4JPT.d.cts → composio-ruMDVx1b.d.cts} +161 -157
  11. package/dist/{customTool.types-BxvwmFDN.d.cts → customTool.types-9jJUADW-.d.cts} +17 -51
  12. package/dist/{customTool.types-CBLEoQnI.d.mts → customTool.types-C6-M75bi.d.mts} +17 -51
  13. package/dist/experimental/index.cjs +2 -2
  14. package/dist/experimental/index.d.cts +2 -2
  15. package/dist/experimental/index.d.mts +3 -3
  16. package/dist/experimental/index.mjs +2 -2
  17. package/dist/{fileUtils.node-DF-AY0Td.cjs → fileUtils.node-DsDsZfEl.cjs} +74 -10
  18. package/dist/{fileUtils.node-BOZnseMe.mjs → fileUtils.node-mlBa5nwX.mjs} +67 -5
  19. package/dist/index.cjs +95 -101
  20. package/dist/index.d.cts +31 -7
  21. package/dist/index.d.mts +31 -7
  22. package/dist/index.mjs +34 -44
  23. package/dist/models/Files.node.cjs +9 -5
  24. package/dist/models/Files.node.d.cts +5 -1
  25. package/dist/models/Files.node.d.mts +5 -1
  26. package/dist/models/Files.node.mjs +9 -5
  27. package/dist/platform/node.mjs +7 -7
  28. package/dist/{tool.types-bencsexi.d.mts → tool.types-BGrE7Vqc.d.mts} +34 -21
  29. package/dist/{tool.types-BWc7GUrD.d.cts → tool.types-C5DMrBdm.d.cts} +34 -21
  30. package/dist/{types-CJQ9IGrf.d.cts → types-DZaf5VcY.d.cts} +2 -2
  31. package/dist/{types-BZc_R1DA.d.mts → types-WkBTUiQh.d.mts} +2 -2
  32. package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +2 -2
  33. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +4 -4
  34. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +2 -2
  35. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +4 -4
  36. package/dist/utils/modifiers/FileToolModifier.node.cjs +55 -24
  37. package/dist/utils/modifiers/FileToolModifier.node.d.cts +3 -2
  38. package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -2
  39. package/dist/utils/modifiers/FileToolModifier.node.mjs +51 -20
  40. package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +1 -1
  41. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  42. package/package.json +1 -1
@@ -1,21 +1,7 @@
1
- const require_ComposioError = require('../../ComposioError-CYaI68Mo.cjs');
2
- const require_fileUtils_node = require('../../fileUtils.node-DF-AY0Td.cjs');
1
+ const require_FileModifierErrors = require('../../FileModifierErrors-DuKpNYju.cjs');
2
+ const require_fileUtils_node = require('../../fileUtils.node-DsDsZfEl.cjs');
3
3
  const require_FileToolModifier_utils_neutral = require('../../FileToolModifier.utils.neutral-BdMpiyie.cjs');
4
4
 
5
- //#region src/errors/FileModifierErrors.ts
6
- const FileModifierErrorCodes = { FILE_UPLOAD_FAILED: "FILE_UPLOAD_FAILED" };
7
- var ComposioFileUploadError = class extends require_ComposioError.ComposioError {
8
- constructor(message = "Failed to upload file", options = {}) {
9
- super(message, {
10
- ...options,
11
- code: FileModifierErrorCodes.FILE_UPLOAD_FAILED,
12
- possibleFixes: options.possibleFixes || ["Check if the file exists in the location provided"]
13
- });
14
- this.name = "ComposioFileUploadError";
15
- }
16
- };
17
-
18
- //#endregion
19
5
  //#region src/utils/modifiers/FileToolModifier.node.ts
20
6
  /**
21
7
  * Recursively walks a runtime value and its matching JSON-Schema node,
@@ -26,11 +12,52 @@ var ComposioFileUploadError = class extends require_ComposioError.ComposioError
26
12
  const hydrateFiles = async (value, schema, ctx) => {
27
13
  if (schema?.file_uploadable) {
28
14
  if (typeof value !== "string" && !(value instanceof File)) return value;
29
- require_ComposioError.logger_default.debug(`Uploading file "${value}"`);
15
+ const runBeforeFileUpload = async (path) => {
16
+ if (!ctx.beforeFileUpload) return path;
17
+ const out = await ctx.beforeFileUpload({
18
+ path,
19
+ toolSlug: ctx.toolSlug,
20
+ toolkitSlug: ctx.toolkitSlug
21
+ });
22
+ if (out === false) throw new require_FileModifierErrors.ComposioFileUploadAbortedError("File upload was aborted because beforeFileUpload returned false.");
23
+ return out;
24
+ };
25
+ if (typeof value === "string") {
26
+ const pathOrUrl = await runBeforeFileUpload(value);
27
+ require_FileModifierErrors.logger_default.debug(`Uploading file "${pathOrUrl}"`);
28
+ return require_fileUtils_node.getFileDataAfterUploadingToS3(pathOrUrl, {
29
+ toolSlug: ctx.toolSlug,
30
+ toolkitSlug: ctx.toolkitSlug,
31
+ client: ctx.client,
32
+ sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
33
+ fileUploadPathDenySegments: ctx.fileUploadPathDenySegments
34
+ });
35
+ }
36
+ if (ctx.beforeFileUpload) {
37
+ const out = await ctx.beforeFileUpload({
38
+ path: value.name,
39
+ toolSlug: ctx.toolSlug,
40
+ toolkitSlug: ctx.toolkitSlug
41
+ });
42
+ if (out === false) throw new require_FileModifierErrors.ComposioFileUploadAbortedError("File upload was aborted because beforeFileUpload returned false.");
43
+ if (typeof out === "string" && out !== value.name) {
44
+ require_FileModifierErrors.logger_default.debug(`Uploading file from path "${out}" (replaced File: ${value.name})`);
45
+ return require_fileUtils_node.getFileDataAfterUploadingToS3(out, {
46
+ toolSlug: ctx.toolSlug,
47
+ toolkitSlug: ctx.toolkitSlug,
48
+ client: ctx.client,
49
+ sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
50
+ fileUploadPathDenySegments: ctx.fileUploadPathDenySegments
51
+ });
52
+ }
53
+ }
54
+ require_FileModifierErrors.logger_default.debug(`Uploading file "${value.name}"`);
30
55
  return require_fileUtils_node.getFileDataAfterUploadingToS3(value, {
31
56
  toolSlug: ctx.toolSlug,
32
57
  toolkitSlug: ctx.toolkitSlug,
33
- client: ctx.client
58
+ client: ctx.client,
59
+ sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
60
+ fileUploadPathDenySegments: ctx.fileUploadPathDenySegments
34
61
  });
35
62
  }
36
63
  const schemaVariants = [
@@ -63,13 +90,13 @@ const hydrateFiles = async (value, schema, ctx) => {
63
90
  const downloadS3File = async (value, ctx) => {
64
91
  const { s3url, mimetype } = value;
65
92
  try {
66
- require_ComposioError.logger_default.debug(`Downloading from S3: ${s3url}`);
93
+ require_FileModifierErrors.logger_default.debug(`Downloading from S3: ${s3url}`);
67
94
  const dl = await require_fileUtils_node.downloadFileFromS3({
68
95
  toolSlug: ctx.toolSlug,
69
96
  s3Url: s3url,
70
97
  mimeType: mimetype ?? "application/octet-stream"
71
98
  });
72
- require_ComposioError.logger_default.debug(`Downloaded → ${dl.filePath}`);
99
+ require_FileModifierErrors.logger_default.debug(`Downloaded → ${dl.filePath}`);
73
100
  return {
74
101
  uri: dl.filePath,
75
102
  file_downloaded: dl.filePath ? true : false,
@@ -77,7 +104,7 @@ const downloadS3File = async (value, ctx) => {
77
104
  mimeType: dl.mimeType
78
105
  };
79
106
  } catch (err) {
80
- require_ComposioError.logger_default.error(`Download failed: ${s3url}`, { cause: err });
107
+ require_FileModifierErrors.logger_default.error(`Download failed: ${s3url}`, { cause: err });
81
108
  return {
82
109
  uri: "",
83
110
  file_downloaded: false,
@@ -126,8 +153,10 @@ const hydrateDownloads = async (value, schema, ctx) => {
126
153
  };
127
154
  var FileToolModifier = class {
128
155
  client;
129
- constructor(client) {
156
+ fileUploadPathOptions;
157
+ constructor(client, fileUploadPathOptions = {}) {
130
158
  this.client = client;
159
+ this.fileUploadPathOptions = fileUploadPathOptions;
131
160
  }
132
161
  async modifyToolSchema(toolSlug, toolkitSlug, schema) {
133
162
  if (!schema.inputParameters?.properties) return schema;
@@ -148,14 +177,16 @@ var FileToolModifier = class {
148
177
  const newArgs = await hydrateFiles(args, tool.inputParameters, {
149
178
  toolSlug,
150
179
  toolkitSlug,
151
- client: this.client
180
+ client: this.client,
181
+ ...this.fileUploadPathOptions
152
182
  });
153
183
  return {
154
184
  ...params,
155
185
  arguments: newArgs
156
186
  };
157
187
  } catch (error) {
158
- throw new ComposioFileUploadError("Failed to upload file", { cause: error });
188
+ if (error instanceof require_FileModifierErrors.ComposioSensitiveFilePathBlockedError || error instanceof require_FileModifierErrors.ComposioFileUploadAbortedError) throw error;
189
+ throw new require_FileModifierErrors.ComposioFileUploadError("Failed to upload file", { cause: error });
159
190
  }
160
191
  }
161
192
  async fileDownloadModifier(tool, options) {
@@ -1,10 +1,11 @@
1
- import { d as ToolExecuteResponse, l as ToolExecuteParams, o as Tool } from "../../tool.types-BWc7GUrD.cjs";
1
+ import { d as ToolExecuteResponse, l as ToolExecuteParams, o as Tool } from "../../tool.types-C5DMrBdm.cjs";
2
2
  import ComposioClient from "@composio/client";
3
3
 
4
4
  //#region src/utils/modifiers/FileToolModifier.node.d.ts
5
5
  declare class FileToolModifier {
6
6
  private client;
7
- constructor(client: ComposioClient);
7
+ private fileUploadPathOptions;
8
+ constructor(client: ComposioClient, fileUploadPathOptions?: FileToolModifier['fileUploadPathOptions']);
8
9
  modifyToolSchema(toolSlug: string, toolkitSlug: string, schema: Tool): Promise<Tool>;
9
10
  fileUploadModifier(tool: Tool, options: {
10
11
  toolSlug: string;
@@ -1,10 +1,11 @@
1
- import { d as ToolExecuteResponse, l as ToolExecuteParams, o as Tool } from "../../tool.types-bencsexi.mjs";
1
+ import { d as ToolExecuteResponse, l as ToolExecuteParams, o as Tool } from "../../tool.types-BGrE7Vqc.mjs";
2
2
  import ComposioClient from "@composio/client";
3
3
 
4
4
  //#region src/utils/modifiers/FileToolModifier.node.d.ts
5
5
  declare class FileToolModifier {
6
6
  private client;
7
- constructor(client: ComposioClient);
7
+ private fileUploadPathOptions;
8
+ constructor(client: ComposioClient, fileUploadPathOptions?: FileToolModifier['fileUploadPathOptions']);
8
9
  modifyToolSchema(toolSlug: string, toolkitSlug: string, schema: Tool): Promise<Tool>;
9
10
  fileUploadModifier(tool: Tool, options: {
10
11
  toolSlug: string;
@@ -1,22 +1,8 @@
1
1
  import "../../chunk-CWQeghP5.mjs";
2
- import { n as logger_default, t as ComposioError } from "../../ComposioError-ChkSdxqU.mjs";
3
- import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../../fileUtils.node-BOZnseMe.mjs";
2
+ import { n as ComposioFileUploadError, o as logger_default, r as ComposioSensitiveFilePathBlockedError, t as ComposioFileUploadAbortedError } from "../../FileModifierErrors-LQwvd6pa.mjs";
3
+ import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../../fileUtils.node-mlBa5nwX.mjs";
4
4
  import { i as transformProperties, n as schemaHasFileDownloadable, r as schemaHasFileUploadable, t as isPlainObject } from "../../FileToolModifier.utils.neutral-BcIR-cVE.mjs";
5
5
 
6
- //#region src/errors/FileModifierErrors.ts
7
- const FileModifierErrorCodes = { FILE_UPLOAD_FAILED: "FILE_UPLOAD_FAILED" };
8
- var ComposioFileUploadError = class extends ComposioError {
9
- constructor(message = "Failed to upload file", options = {}) {
10
- super(message, {
11
- ...options,
12
- code: FileModifierErrorCodes.FILE_UPLOAD_FAILED,
13
- possibleFixes: options.possibleFixes || ["Check if the file exists in the location provided"]
14
- });
15
- this.name = "ComposioFileUploadError";
16
- }
17
- };
18
-
19
- //#endregion
20
6
  //#region src/utils/modifiers/FileToolModifier.node.ts
21
7
  /**
22
8
  * Recursively walks a runtime value and its matching JSON-Schema node,
@@ -27,11 +13,52 @@ var ComposioFileUploadError = class extends ComposioError {
27
13
  const hydrateFiles = async (value, schema, ctx) => {
28
14
  if (schema?.file_uploadable) {
29
15
  if (typeof value !== "string" && !(value instanceof File)) return value;
30
- logger_default.debug(`Uploading file "${value}"`);
16
+ const runBeforeFileUpload = async (path) => {
17
+ if (!ctx.beforeFileUpload) return path;
18
+ const out = await ctx.beforeFileUpload({
19
+ path,
20
+ toolSlug: ctx.toolSlug,
21
+ toolkitSlug: ctx.toolkitSlug
22
+ });
23
+ if (out === false) throw new ComposioFileUploadAbortedError("File upload was aborted because beforeFileUpload returned false.");
24
+ return out;
25
+ };
26
+ if (typeof value === "string") {
27
+ const pathOrUrl = await runBeforeFileUpload(value);
28
+ logger_default.debug(`Uploading file "${pathOrUrl}"`);
29
+ return getFileDataAfterUploadingToS3(pathOrUrl, {
30
+ toolSlug: ctx.toolSlug,
31
+ toolkitSlug: ctx.toolkitSlug,
32
+ client: ctx.client,
33
+ sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
34
+ fileUploadPathDenySegments: ctx.fileUploadPathDenySegments
35
+ });
36
+ }
37
+ if (ctx.beforeFileUpload) {
38
+ const out = await ctx.beforeFileUpload({
39
+ path: value.name,
40
+ toolSlug: ctx.toolSlug,
41
+ toolkitSlug: ctx.toolkitSlug
42
+ });
43
+ if (out === false) throw new ComposioFileUploadAbortedError("File upload was aborted because beforeFileUpload returned false.");
44
+ if (typeof out === "string" && out !== value.name) {
45
+ logger_default.debug(`Uploading file from path "${out}" (replaced File: ${value.name})`);
46
+ return getFileDataAfterUploadingToS3(out, {
47
+ toolSlug: ctx.toolSlug,
48
+ toolkitSlug: ctx.toolkitSlug,
49
+ client: ctx.client,
50
+ sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
51
+ fileUploadPathDenySegments: ctx.fileUploadPathDenySegments
52
+ });
53
+ }
54
+ }
55
+ logger_default.debug(`Uploading file "${value.name}"`);
31
56
  return getFileDataAfterUploadingToS3(value, {
32
57
  toolSlug: ctx.toolSlug,
33
58
  toolkitSlug: ctx.toolkitSlug,
34
- client: ctx.client
59
+ client: ctx.client,
60
+ sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
61
+ fileUploadPathDenySegments: ctx.fileUploadPathDenySegments
35
62
  });
36
63
  }
37
64
  const schemaVariants = [
@@ -127,8 +154,10 @@ const hydrateDownloads = async (value, schema, ctx) => {
127
154
  };
128
155
  var FileToolModifier = class {
129
156
  client;
130
- constructor(client) {
157
+ fileUploadPathOptions;
158
+ constructor(client, fileUploadPathOptions = {}) {
131
159
  this.client = client;
160
+ this.fileUploadPathOptions = fileUploadPathOptions;
132
161
  }
133
162
  async modifyToolSchema(toolSlug, toolkitSlug, schema) {
134
163
  if (!schema.inputParameters?.properties) return schema;
@@ -149,13 +178,15 @@ var FileToolModifier = class {
149
178
  const newArgs = await hydrateFiles(args, tool.inputParameters, {
150
179
  toolSlug,
151
180
  toolkitSlug,
152
- client: this.client
181
+ client: this.client,
182
+ ...this.fileUploadPathOptions
153
183
  });
154
184
  return {
155
185
  ...params,
156
186
  arguments: newArgs
157
187
  };
158
188
  } catch (error) {
189
+ if (error instanceof ComposioSensitiveFilePathBlockedError || error instanceof ComposioFileUploadAbortedError) throw error;
159
190
  throw new ComposioFileUploadError("Failed to upload file", { cause: error });
160
191
  }
161
192
  }
@@ -1,4 +1,4 @@
1
- import { d as ToolExecuteResponse, l as ToolExecuteParams, o as Tool } from "../../tool.types-BWc7GUrD.cjs";
1
+ import { d as ToolExecuteResponse, l as ToolExecuteParams, o as Tool } from "../../tool.types-C5DMrBdm.cjs";
2
2
  import ComposioClient from "@composio/client";
3
3
 
4
4
  //#region src/utils/modifiers/FileToolModifier.workerd.d.ts
@@ -1,4 +1,4 @@
1
- import { d as ToolExecuteResponse, l as ToolExecuteParams, o as Tool } from "../../tool.types-bencsexi.mjs";
1
+ import { d as ToolExecuteResponse, l as ToolExecuteParams, o as Tool } from "../../tool.types-BGrE7Vqc.mjs";
2
2
  import ComposioClient from "@composio/client";
3
3
 
4
4
  //#region src/utils/modifiers/FileToolModifier.workerd.d.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@composio/core",
3
3
  "type": "module",
4
- "version": "0.6.10",
4
+ "version": "0.6.11",
5
5
  "description": "",
6
6
  "main": "dist/index.mjs",
7
7
  "publishConfig": {