@composio/core 0.6.9 → 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.
- package/dist/{CustomTool-B0ssIcQn.d.cts → CustomTool-B1b2MXbO.d.cts} +1 -1
- package/dist/{CustomTool-Cyo1aJ2l.cjs → CustomTool-Cywkgg64.cjs} +28 -28
- package/dist/{CustomTool-AYNimqhf.mjs → CustomTool-D8cxWvi9.mjs} +1 -1
- package/dist/{CustomTool-CaO_eE3G.d.mts → CustomTool-VQMc17af.d.mts} +1 -1
- package/dist/{ComposioError-CYaI68Mo.cjs → FileModifierErrors-DuKpNYju.cjs} +74 -0
- package/dist/{ComposioError-ChkSdxqU.mjs → FileModifierErrors-LQwvd6pa.mjs} +51 -1
- package/dist/{Telemetry-CjVa99gU.mjs → Telemetry-BJ2KYlDT.mjs} +1 -1
- package/dist/{Telemetry-A89k5RTv.cjs → Telemetry-JZNofztq.cjs} +17 -17
- package/dist/{composio-BREEwwMk.d.mts → composio-D8u53qsy.d.mts} +161 -157
- package/dist/{composio-COTWSJh4.d.cts → composio-ruMDVx1b.d.cts} +161 -157
- package/dist/{customTool.types-DIvgAKNO.d.cts → customTool.types-9jJUADW-.d.cts} +18 -51
- package/dist/{customTool.types-jiqAXiST.d.mts → customTool.types-C6-M75bi.d.mts} +18 -51
- package/dist/experimental/index.cjs +2 -2
- package/dist/experimental/index.d.cts +2 -2
- package/dist/experimental/index.d.mts +3 -3
- package/dist/experimental/index.mjs +2 -2
- package/dist/{fileUtils.node-DF-AY0Td.cjs → fileUtils.node-DsDsZfEl.cjs} +74 -10
- package/dist/{fileUtils.node-BOZnseMe.mjs → fileUtils.node-mlBa5nwX.mjs} +67 -5
- package/dist/index.cjs +95 -101
- package/dist/index.d.cts +31 -7
- package/dist/index.d.mts +31 -7
- package/dist/index.mjs +34 -44
- package/dist/models/Files.node.cjs +9 -5
- package/dist/models/Files.node.d.cts +5 -1
- package/dist/models/Files.node.d.mts +5 -1
- package/dist/models/Files.node.mjs +9 -5
- package/dist/platform/node.mjs +7 -7
- package/dist/{tool.types-bencsexi.d.mts → tool.types-BGrE7Vqc.d.mts} +34 -21
- package/dist/{tool.types-BWc7GUrD.d.cts → tool.types-C5DMrBdm.d.cts} +34 -21
- package/dist/{types-mVw5PfwE.d.cts → types-DZaf5VcY.d.cts} +2 -2
- package/dist/{types-C7Ld_qbu.d.mts → types-WkBTUiQh.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +4 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +4 -4
- package/dist/utils/modifiers/FileToolModifier.node.cjs +55 -24
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +3 -2
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -2
- package/dist/utils/modifiers/FileToolModifier.node.mjs +51 -20
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/package.json +1 -1
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_fileUtils_node = require('../../fileUtils.node-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
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
|
-
|
|
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-
|
|
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
|
-
|
|
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
|
|
3
|
-
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../../fileUtils.node-
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
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-
|
|
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
|