@composio/core 0.10.0 → 0.12.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.
- package/dist/{tool.types-CwbAy9l_.d.cts → BaseProvider-BBnsv9kS.d.mts} +23683 -23635
- package/dist/CustomTool-DEB4BQPl.mjs +468 -0
- package/dist/{CustomTool-aber890o.d.cts → CustomTool-DH18rVQu.d.mts} +2 -4
- package/dist/{FileModifierErrors-C7z16Dfi.mjs → FileModifierErrors-3fSwIWoa.mjs} +35 -36
- package/dist/{FileToolModifier.utils.neutral-B7P7wn-b.mjs → FileToolModifier.utils.neutral-B5rT711M.mjs} +1 -7
- package/dist/{Telemetry-kgWlkavX.mjs → Telemetry-DhGI_J4G.mjs} +48 -23
- package/dist/{composio-CSMCZZgj.d.cts → composio-CHnEggnv.d.mts} +433 -435
- package/dist/{customTool.types-BzEWHa0w.d.cts → customTool.types-DpIdOJjL.d.mts} +177 -236
- package/dist/{CustomTool-D7-1S2at.mjs → errors-D5f4pfvI.mjs} +132 -519
- package/dist/experimental/index.d.mts +2 -3
- package/dist/experimental/index.mjs +1 -3
- package/dist/{fileUtils.node-Dq7ebZPC.mjs → fileUtils.node-BiO1JQsJ.mjs} +26 -25
- package/dist/index.d.mts +2034 -2356
- package/dist/index.mjs +2546 -2335
- package/dist/jsonSchema-daqF3S3d.mjs +251 -0
- package/dist/models/Files.node.d.mts +1 -2
- package/dist/models/Files.node.mjs +3 -4
- package/dist/models/Files.workerd.d.mts +0 -1
- package/dist/platform/node.d.mts +1 -2
- package/dist/platform/workerd.d.mts +1 -2
- package/dist/{chunk-CWQeghP5.mjs → rolldown-runtime-w6R9maHv.mjs} +3 -5
- package/dist/{types-DE7O6Z6S.d.cts → types-CaI5Z4PA.d.mts} +2 -3
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +3 -0
- package/dist/utils/json-schema.d.mts +2 -0
- package/dist/utils/json-schema.mjs +3 -0
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +81 -44
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/package.json +48 -88
- package/dist/CustomTool-CQ_YjABZ.cjs +0 -1341
- package/dist/CustomTool-DJUGNOer.d.mts +0 -76
- package/dist/FileModifierErrors-BYJBHiay.cjs +0 -554
- package/dist/FileToolModifier.utils.neutral-Dfwqgimk.cjs +0 -102
- package/dist/Telemetry-Dm-0sewu.cjs +0 -335
- package/dist/buffer-BjWptbNH.cjs +0 -63
- package/dist/chunk-CQwRTUmo.cjs +0 -53
- package/dist/composio-DRl6WCI9.d.mts +0 -5484
- package/dist/customTool.types-CMOMgxoM.d.mts +0 -2513
- package/dist/experimental/index.cjs +0 -5
- package/dist/experimental/index.d.cts +0 -3
- package/dist/fileUtils.node-DtnSRMWa.cjs +0 -462
- package/dist/files.types-lo4zZd87.d.cts +0 -17
- package/dist/index.cjs +0 -8637
- package/dist/index.d.cts +0 -5672
- package/dist/models/Files.node.cjs +0 -55
- package/dist/models/Files.node.d.cts +0 -56
- package/dist/models/Files.workerd.cjs +0 -29
- package/dist/models/Files.workerd.d.cts +0 -13
- package/dist/platform/node.cjs +0 -55
- package/dist/platform/node.d.cts +0 -11
- package/dist/platform/workerd.cjs +0 -42
- package/dist/platform/workerd.d.cts +0 -12
- package/dist/tool.types-CB_4JKhV.d.mts +0 -29377
- package/dist/types-BTOPdg4d.d.mts +0 -13
- package/dist/types-pDNm1lYs.d.cts +0 -69
- package/dist/utils/config-defaults/ConfigDefaults.node.cjs +0 -10
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +0 -7
- package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +0 -10
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +0 -7
- package/dist/utils/modifiers/FileToolModifier.node.cjs +0 -207
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +0 -22
- package/dist/utils/modifiers/FileToolModifier.workerd.cjs +0 -27
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +0 -20
- /package/dist/{buffer-yOtEsT4J.mjs → buffer-PcbMMsgm.mjs} +0 -0
- /package/dist/{files.types-BXDWA_zS.d.mts → files.types-DeMC_mAW.d.mts} +0 -0
- /package/dist/{types-HpJQ8K9l.d.mts → types-DdoCRzLj.d.mts} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
3
|
-
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-DJUGNOer.mjs";
|
|
1
|
+
import { S as SessionContext, a as CreateCustomToolkitParams, c as CustomToolExecuteFn, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams } from "../customTool.types-DpIdOJjL.mjs";
|
|
2
|
+
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-DH18rVQu.mjs";
|
|
4
3
|
export { type CreateCustomToolParams, type CreateCustomToolkitParams, type CustomTool, type CustomToolExecuteFn, type CustomToolkit, type SessionContext, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../FileModifierErrors-C7z16Dfi.mjs";
|
|
3
|
-
import { a as createCustomToolkit, i as createCustomTool } from "../CustomTool-D7-1S2at.mjs";
|
|
1
|
+
import { a as createCustomToolkit, i as createCustomTool } from "../CustomTool-DEB4BQPl.mjs";
|
|
4
2
|
|
|
5
3
|
export { createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ComposioSensitiveFilePathBlockedError, c as
|
|
2
|
-
import { i as getRandomShortId, n as base64ToUint8Array, r as uint8ArrayToBase64 } from "./buffer-
|
|
1
|
+
import { a as ComposioSensitiveFilePathBlockedError, c as logger, i as ComposioFileUploadPathNotAllowedError, l as COMPOSIO_DIR, m as TEMP_FILES_DIRECTORY_NAME, t as ComposioFileNotFoundError } from "./FileModifierErrors-3fSwIWoa.mjs";
|
|
2
|
+
import { i as getRandomShortId, n as base64ToUint8Array, r as uint8ArrayToBase64 } from "./buffer-PcbMMsgm.mjs";
|
|
3
3
|
import { platform } from "#platform";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import * as path from "node:path";
|
|
@@ -289,13 +289,13 @@ const readFileContent = async (filePath) => {
|
|
|
289
289
|
throw new Error(`Error reading file at ${filePath}: ${error}`);
|
|
290
290
|
}
|
|
291
291
|
};
|
|
292
|
-
const readFileContentFromURL = async (path
|
|
293
|
-
const response = await fetch(path
|
|
292
|
+
const readFileContentFromURL = async (path, signal) => {
|
|
293
|
+
const response = await fetch(path, { signal });
|
|
294
294
|
if (!response.ok) throw new Error(`Failed to fetch file: ${response.statusText}`);
|
|
295
295
|
const arrayBuffer = await response.arrayBuffer();
|
|
296
296
|
const content = new Uint8Array(arrayBuffer);
|
|
297
297
|
const mimeType = response.headers.get("content-type") || "application/octet-stream";
|
|
298
|
-
const pathname = new URL(path
|
|
298
|
+
const pathname = new URL(path).pathname;
|
|
299
299
|
let fileName = platform.basename(pathname);
|
|
300
300
|
if (!fileName || fileName === "/") fileName = generateTimestampedFilename(getExtensionFromMimeType(mimeType));
|
|
301
301
|
else if (!fileName.includes(".")) fileName = generateTimestampedFilename(getExtensionFromMimeType(mimeType));
|
|
@@ -305,7 +305,7 @@ const readFileContentFromURL = async (path$1) => {
|
|
|
305
305
|
fileName
|
|
306
306
|
};
|
|
307
307
|
};
|
|
308
|
-
const uploadFileToS3 = async (fileName, content, toolSlug, toolkitSlug, mimeType, client) => {
|
|
308
|
+
const uploadFileToS3 = async (fileName, content, toolSlug, toolkitSlug, mimeType, client, signal) => {
|
|
309
309
|
const contentBytes = base64ToUint8Array(content);
|
|
310
310
|
const { key, new_presigned_url: signedURL } = await client.files.createPresignedURL({
|
|
311
311
|
filename: fileName,
|
|
@@ -313,22 +313,20 @@ const uploadFileToS3 = async (fileName, content, toolSlug, toolkitSlug, mimeType
|
|
|
313
313
|
md5: crypto.createHash("md5").update(contentBytes).digest("hex"),
|
|
314
314
|
tool_slug: toolSlug,
|
|
315
315
|
toolkit_slug: toolkitSlug
|
|
316
|
-
});
|
|
317
|
-
|
|
316
|
+
}, { signal });
|
|
317
|
+
logger.debug(`Uploading ${key} file to S3: ${key}`);
|
|
318
318
|
const uploadBuffer = new Uint8Array(contentBytes.byteLength);
|
|
319
319
|
uploadBuffer.set(contentBytes);
|
|
320
320
|
const uploadResponse = await fetch(signedURL, {
|
|
321
321
|
method: "PUT",
|
|
322
322
|
body: uploadBuffer,
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
"Content-Length": contentBytes.length.toString()
|
|
326
|
-
}
|
|
323
|
+
signal,
|
|
324
|
+
headers: { "Content-Type": mimeType }
|
|
327
325
|
});
|
|
328
326
|
if (!uploadResponse.ok) throw new Error(`Failed to upload file to S3: ${uploadResponse.statusText}`);
|
|
329
327
|
return key;
|
|
330
328
|
};
|
|
331
|
-
const readFile = async (file) => {
|
|
329
|
+
const readFile = async (file, signal) => {
|
|
332
330
|
if (file instanceof File) {
|
|
333
331
|
const content = await file.arrayBuffer();
|
|
334
332
|
return {
|
|
@@ -336,27 +334,27 @@ const readFile = async (file) => {
|
|
|
336
334
|
content: uint8ArrayToBase64(new Uint8Array(content)),
|
|
337
335
|
mimeType: file.type
|
|
338
336
|
};
|
|
339
|
-
} else if (typeof file === "string") if (file.startsWith("http")) return await readFileContentFromURL(file);
|
|
337
|
+
} else if (typeof file === "string") if (file.startsWith("http")) return await readFileContentFromURL(file, signal);
|
|
340
338
|
else return await readFileContent(file);
|
|
341
339
|
throw new Error("Invalid file type");
|
|
342
340
|
};
|
|
343
|
-
const getFileDataAfterUploadingToS3 = async (file, { toolSlug, toolkitSlug, client, sensitiveFileUploadProtection, fileUploadPathDenySegments, fileUploadAllowlist }) => {
|
|
341
|
+
const getFileDataAfterUploadingToS3 = async (file, { toolSlug, toolkitSlug, client, sensitiveFileUploadProtection, fileUploadPathDenySegments, fileUploadAllowlist, signal }) => {
|
|
344
342
|
if (!file) throw new Error("Either path or blob must be provided");
|
|
345
343
|
const isLocalPath = typeof file === "string" && !file.startsWith("http");
|
|
346
344
|
if (isLocalPath && fileUploadAllowlist !== void 0) assertPathInsideUploadDirs(file, fileUploadAllowlist);
|
|
347
345
|
if (sensitiveFileUploadProtection !== false && isLocalPath) assertSafeFileUploadPath(file, { additionalDenySegments: fileUploadPathDenySegments });
|
|
348
|
-
const fileData = await readFile(file);
|
|
349
|
-
|
|
350
|
-
const s3key = await uploadFileToS3(platform.basename(fileData.fileName), fileData.content, toolSlug, toolkitSlug, fileData.mimeType, client);
|
|
351
|
-
|
|
346
|
+
const fileData = await readFile(file, signal);
|
|
347
|
+
logger.debug(`Uploading file to S3...`);
|
|
348
|
+
const s3key = await uploadFileToS3(platform.basename(fileData.fileName), fileData.content, toolSlug, toolkitSlug, fileData.mimeType, client, signal);
|
|
349
|
+
logger.debug(`Done! File uploaded to S3: ${s3key}`, JSON.stringify(fileData, null, 2));
|
|
352
350
|
return {
|
|
353
351
|
name: fileData.fileName,
|
|
354
352
|
mimetype: fileData.mimeType,
|
|
355
353
|
s3key
|
|
356
354
|
};
|
|
357
355
|
};
|
|
358
|
-
const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType, fileDownloadDir }) => {
|
|
359
|
-
const response = await fetch(s3Url);
|
|
356
|
+
const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType, fileDownloadDir, signal }) => {
|
|
357
|
+
const response = await fetch(s3Url, { signal });
|
|
360
358
|
if (!response.ok) throw new Error(`Failed to download file: ${response.statusText}`);
|
|
361
359
|
const data = await response.arrayBuffer();
|
|
362
360
|
const fileName = generateTimestampedFilename(getExtensionFromMimeType(mimeType), `${toolSlug}_`);
|
|
@@ -364,6 +362,9 @@ const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType, fileDownloadDir }
|
|
|
364
362
|
name: fileName,
|
|
365
363
|
mimeType,
|
|
366
364
|
s3Url,
|
|
365
|
+
/**
|
|
366
|
+
* @todo: fix in follow-up PR.
|
|
367
|
+
*/
|
|
367
368
|
filePath: saveFile(fileName, new Uint8Array(data), {
|
|
368
369
|
isTempFile: fileDownloadDir === void 0,
|
|
369
370
|
outputDir: fileDownloadDir
|
|
@@ -417,7 +418,7 @@ const saveFile = (file, content, options = {}) => {
|
|
|
417
418
|
const opts = typeof options === "boolean" ? { isTempFile: options } : options;
|
|
418
419
|
try {
|
|
419
420
|
if (!platform.supportsFileSystem) {
|
|
420
|
-
|
|
421
|
+
logger.debug("File system operations are not supported in this runtime environment");
|
|
421
422
|
return null;
|
|
422
423
|
}
|
|
423
424
|
let composioFilesDir;
|
|
@@ -427,18 +428,18 @@ const saveFile = (file, content, options = {}) => {
|
|
|
427
428
|
if (!platform.existsSync(absDir)) platform.mkdirSync(absDir);
|
|
428
429
|
composioFilesDir = absDir;
|
|
429
430
|
} catch (err) {
|
|
430
|
-
|
|
431
|
+
logger.warn(`fileDownloadDir "${absDir}" is not writable, falling back to the default (~/.composio/files). Error: ${err}`);
|
|
431
432
|
composioFilesDir = getComposioTempFilesDir(true);
|
|
432
433
|
}
|
|
433
434
|
} else composioFilesDir = opts.isTempFile ? getComposioTempFilesDir(true) : getComposioDir(true);
|
|
434
435
|
if (!composioFilesDir) return null;
|
|
435
436
|
const filePath = platform.joinPath(composioFilesDir, platform.basename(file));
|
|
436
|
-
|
|
437
|
+
logger.info(`Saving file to: ${filePath}`);
|
|
437
438
|
if (content instanceof Uint8Array) platform.writeFileSync(filePath, content);
|
|
438
439
|
else platform.writeFileSync(filePath, content, "utf8");
|
|
439
440
|
return filePath;
|
|
440
441
|
} catch (_error) {
|
|
441
|
-
|
|
442
|
+
logger.debug(`Error saving file: ${_error}`);
|
|
442
443
|
return null;
|
|
443
444
|
}
|
|
444
445
|
};
|