@composio/core 0.11.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.
Files changed (69) hide show
  1. package/dist/{BaseProvider-CVbQxTNa.d.cts → BaseProvider-BBnsv9kS.d.mts} +139 -92
  2. package/dist/CustomTool-DEB4BQPl.mjs +468 -0
  3. package/dist/{CustomTool-C-IUByoU.d.cts → CustomTool-DH18rVQu.d.mts} +2 -4
  4. package/dist/{FileModifierErrors-C7z16Dfi.mjs → FileModifierErrors-3fSwIWoa.mjs} +35 -36
  5. package/dist/{Telemetry-DQax33Gh.mjs → Telemetry-DhGI_J4G.mjs} +15 -15
  6. package/dist/{composio-pcA13w87.d.cts → composio-CHnEggnv.d.mts} +394 -349
  7. package/dist/{customTool.types-QtkAZQma.d.cts → customTool.types-DpIdOJjL.d.mts} +171 -192
  8. package/dist/{CustomTool-D5s-aADw.mjs → errors-D5f4pfvI.mjs} +70 -457
  9. package/dist/experimental/index.d.mts +2 -3
  10. package/dist/experimental/index.mjs +1 -3
  11. package/dist/{fileUtils.node-Dq7ebZPC.mjs → fileUtils.node-BiO1JQsJ.mjs} +26 -25
  12. package/dist/index.d.mts +1685 -2400
  13. package/dist/index.mjs +2238 -1912
  14. package/dist/jsonSchema-daqF3S3d.mjs +251 -0
  15. package/dist/models/Files.node.d.mts +1 -2
  16. package/dist/models/Files.node.mjs +3 -4
  17. package/dist/models/Files.workerd.d.mts +0 -1
  18. package/dist/platform/node.d.mts +1 -2
  19. package/dist/platform/workerd.d.mts +1 -2
  20. package/dist/{chunk-CWQeghP5.mjs → rolldown-runtime-w6R9maHv.mjs} +3 -5
  21. package/dist/{types-J2KCXP8R.d.mts → types-CaI5Z4PA.d.mts} +2 -3
  22. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -4
  23. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -4
  24. package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +3 -0
  25. package/dist/utils/json-schema.d.mts +2 -0
  26. package/dist/utils/json-schema.mjs +3 -0
  27. package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -1
  28. package/dist/utils/modifiers/FileToolModifier.node.mjs +44 -24
  29. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -1
  30. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
  31. package/package.json +39 -88
  32. package/dist/BaseProvider-BvHvJLXc.d.mts +0 -29378
  33. package/dist/CustomTool-CChQSp44.d.mts +0 -76
  34. package/dist/CustomTool-D3-NreIm.cjs +0 -1341
  35. package/dist/FileModifierErrors-BYJBHiay.cjs +0 -554
  36. package/dist/FileToolModifier.utils.neutral-DSBQs9-i.cjs +0 -96
  37. package/dist/Telemetry-BQ_pl5AK.cjs +0 -360
  38. package/dist/buffer-BjWptbNH.cjs +0 -63
  39. package/dist/chunk-CQwRTUmo.cjs +0 -53
  40. package/dist/composio-BlASKqjQ.d.mts +0 -5437
  41. package/dist/customTool.types-DLIORcYN.d.mts +0 -2475
  42. package/dist/experimental/index.cjs +0 -5
  43. package/dist/experimental/index.d.cts +0 -3
  44. package/dist/fileUtils.node-DtnSRMWa.cjs +0 -462
  45. package/dist/files.types-lo4zZd87.d.cts +0 -17
  46. package/dist/index.cjs +0 -8523
  47. package/dist/index.d.cts +0 -6065
  48. package/dist/models/Files.node.cjs +0 -55
  49. package/dist/models/Files.node.d.cts +0 -56
  50. package/dist/models/Files.workerd.cjs +0 -29
  51. package/dist/models/Files.workerd.d.cts +0 -13
  52. package/dist/platform/node.cjs +0 -55
  53. package/dist/platform/node.d.cts +0 -11
  54. package/dist/platform/workerd.cjs +0 -42
  55. package/dist/platform/workerd.d.cts +0 -12
  56. package/dist/types-DRG5qLxI.d.cts +0 -13
  57. package/dist/types-pDNm1lYs.d.cts +0 -69
  58. package/dist/utils/config-defaults/ConfigDefaults.node.cjs +0 -10
  59. package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +0 -7
  60. package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +0 -10
  61. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +0 -7
  62. package/dist/utils/modifiers/FileToolModifier.node.cjs +0 -224
  63. package/dist/utils/modifiers/FileToolModifier.node.d.cts +0 -22
  64. package/dist/utils/modifiers/FileToolModifier.workerd.cjs +0 -27
  65. package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +0 -20
  66. /package/dist/{FileToolModifier.utils.neutral-BpSceNK8.mjs → FileToolModifier.utils.neutral-B5rT711M.mjs} +0 -0
  67. /package/dist/{buffer-yOtEsT4J.mjs → buffer-PcbMMsgm.mjs} +0 -0
  68. /package/dist/{files.types-BXDWA_zS.d.mts → files.types-DeMC_mAW.d.mts} +0 -0
  69. /package/dist/{types-HpJQ8K9l.d.mts → types-DdoCRzLj.d.mts} +0 -0
@@ -1,554 +0,0 @@
1
- const require_chunk = require('./chunk-CQwRTUmo.cjs');
2
- let _composio_client = require("@composio/client");
3
- let zod_v3 = require("zod/v3");
4
- let chalk = require("chalk");
5
- chalk = require_chunk.__toESM(chalk);
6
-
7
- //#region src/utils/env.ts
8
- const getEnvVariable = (name, defaultValue = void 0) => {
9
- try {
10
- return process.env[name] || defaultValue;
11
- } catch (_e) {
12
- return defaultValue;
13
- }
14
- };
15
- /**
16
- * Method to return all the envs based on a specific prefix
17
- * @param prefix
18
- * @example
19
- * COMPOSIO_TOOLKIT_VERSION_GITHUB=20250902_00
20
- * COMPOSIO_TOOLKIT_VERSION_SLACK=20250902_00
21
- * COMPOSIO_TOOLKIT_VERSION_GMAIL=latest
22
- * @returns {Record<string, unknown>}
23
- * @returns
24
- */
25
- const getEnvsWithPrefix = (prefix) => {
26
- try {
27
- if (process && process.env) return Object.fromEntries(Object.entries(process.env).filter(([key]) => key.startsWith(prefix)));
28
- else return {};
29
- } catch (error) {
30
- return {};
31
- }
32
- };
33
-
34
- //#endregion
35
- //#region src/utils/constants.ts
36
- var constants_exports = /* @__PURE__ */ require_chunk.__exportAll({
37
- CLIENT_PUSHER_KEY: () => CLIENT_PUSHER_KEY,
38
- COMPOSIO_DIR: () => COMPOSIO_DIR,
39
- COMPOSIO_LOG_LEVEL: () => COMPOSIO_LOG_LEVEL,
40
- DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
41
- DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID: () => DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID,
42
- DEFAULT_WEB_URL: () => DEFAULT_WEB_URL,
43
- IS_DEVELOPMENT_OR_CI: () => IS_DEVELOPMENT_OR_CI,
44
- TELEMETRY_URL: () => TELEMETRY_URL,
45
- TEMP_FILES_DIRECTORY_NAME: () => TEMP_FILES_DIRECTORY_NAME,
46
- USER_DATA_FILE_NAME: () => USER_DATA_FILE_NAME
47
- });
48
- const COMPOSIO_DIR = ".composio";
49
- const USER_DATA_FILE_NAME = "user_data.json";
50
- const TEMP_FILES_DIRECTORY_NAME = "files";
51
- const DEFAULT_BASE_URL = "https://backend.composio.dev";
52
- const DEFAULT_WEB_URL = "https://dashboard.composio.dev/";
53
- const TELEMETRY_URL = "https://app.composio.dev";
54
- const CLIENT_PUSHER_KEY = getEnvVariable("CLIENT_PUSHER_KEY") || "ff9f18c208855d77a152";
55
- const COMPOSIO_LOG_LEVEL = getEnvVariable("COMPOSIO_LOG_LEVEL");
56
- const IS_DEVELOPMENT_OR_CI = getEnvVariable("DEVELOPMENT") || getEnvVariable("CI") || false;
57
- const DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID = "files";
58
-
59
- //#endregion
60
- //#region src/utils/logger.ts
61
- const LOG_LEVELS = {
62
- silent: -1,
63
- error: 0,
64
- warn: 1,
65
- info: 2,
66
- debug: 3
67
- };
68
- /**
69
- * Get the current log level from environment variables.
70
- * Defaults to 'info' if not set or invalid.
71
- * @returns {LogLevel} The current log level
72
- */
73
- const getLogLevel = () => {
74
- const envLevel = (COMPOSIO_LOG_LEVEL ?? "info")?.toLowerCase();
75
- return envLevel && envLevel in LOG_LEVELS ? envLevel : "info";
76
- };
77
- var Logger = class {
78
- level;
79
- includeTimestamp;
80
- console;
81
- constructor(options = {}) {
82
- this.level = options.level ?? getLogLevel();
83
- this.includeTimestamp = options.includeTimestamp ?? true;
84
- this.console = console;
85
- }
86
- formatMessage(args) {
87
- const formattedArgs = args.map((arg, index) => {
88
- if (typeof arg === "object") return JSON.stringify(arg);
89
- else {
90
- if (index === 0) if (args.length > 1) return chalk.default.yellow(`${arg}`);
91
- else return String(arg);
92
- return String(arg);
93
- }
94
- }).join("\n");
95
- if (!this.includeTimestamp) return formattedArgs;
96
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
97
- return `${chalk.default.gray(timestamp)} - ${formattedArgs}`;
98
- }
99
- shouldLog(level) {
100
- return LOG_LEVELS[level] <= LOG_LEVELS[this.level];
101
- }
102
- error(...args) {
103
- if (this.shouldLog("error")) this.console.error(this.formatMessage(args));
104
- }
105
- warn(...args) {
106
- if (this.shouldLog("warn")) this.console.warn(this.formatMessage(args));
107
- }
108
- info(...args) {
109
- if (this.shouldLog("info")) this.console.info(this.formatMessage(args));
110
- }
111
- debug(...args) {
112
- if (this.shouldLog("debug")) this.console.debug(this.formatMessage(args));
113
- }
114
- };
115
- const logger = new Logger();
116
- var logger_default = logger;
117
-
118
- //#endregion
119
- //#region src/errors/ComposioError.ts
120
- /**
121
- * @fileoverview Error class for Composio.
122
- *
123
- * This error class is used to create custom errors for Composio.
124
- * It extends the built-in Error class and adds additional properties for code, status code, cause, meta, and possible fixes.
125
- *
126
- * @author Musthaq Ahamad <musthaq@composio.dev>
127
- * @module errors/ComposioError
128
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
129
- */
130
- /**
131
- * Base error class for all Composio errors
132
- */
133
- var ComposioError = class ComposioError extends Error {
134
- /** @readonly Error name */
135
- name = "ComposioError";
136
- code;
137
- possibleFixes;
138
- errorId;
139
- /**
140
- * Creates a new ComposioError
141
- * @param message Error message
142
- * @param options Additional error options
143
- */
144
- constructor(message, options = {}) {
145
- super(message);
146
- if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
147
- const statusCode = options.statusCode || (options.cause instanceof _composio_client.BadRequestError ? options.cause.status : void 0);
148
- this.code = `TS-SDK::${options.code}`;
149
- this.possibleFixes = options.possibleFixes;
150
- this.definePropertyIfExists("statusCode", statusCode);
151
- this.definePropertyIfExists("cause", options.cause);
152
- const combinedStack = options.cause instanceof Error ? ComposioError.combineStackTraces(options.cause.stack, this.stack) : options.stack ?? this.stack;
153
- this.definePropertyIfExists("stack", combinedStack);
154
- if (options.meta && Object.keys(options.meta).length > 0) this.definePropertyIfExists("meta", options.meta);
155
- }
156
- /**
157
- * Helper method to define a property only if it has a value
158
- * @param propertyName Name of the property to define
159
- * @param value Value to assign to the property
160
- * @private
161
- */
162
- definePropertyIfExists(propertyName, value) {
163
- if (value !== void 0) Object.defineProperty(this, propertyName, {
164
- value,
165
- enumerable: true,
166
- writable: false,
167
- configurable: true
168
- });
169
- }
170
- /**
171
- * Helper method to combine stack traces when wrapping errors
172
- * This ensures the full call chain is preserved
173
- * @param originalStack The stack of the error being wrapped
174
- * @param currentStack The stack of the wrapper error
175
- * @returns Combined stack trace
176
- * @private
177
- */
178
- static combineStackTraces(originalStack, currentStack) {
179
- if (!originalStack) return currentStack;
180
- if (!currentStack) return originalStack;
181
- const currentHeader = currentStack.split("\n")[0];
182
- const originalStackBody = originalStack.split("\n").slice(1).join("\n");
183
- return `${currentHeader}\n${currentStack.split("\n").slice(1).join("\n")}\n\nCaused by:\n${originalStackBody}`;
184
- }
185
- /**
186
- * Extract and normalize error data for formatting
187
- * @param includeStack Whether to include stack trace information
188
- * @returns Structured error data for formatting
189
- * @private
190
- */
191
- getErrorData(includeStack = false) {
192
- const data = {
193
- name: this.name,
194
- message: this.message
195
- };
196
- const { cause, code, stack, statusCode, meta, possibleFixes } = this;
197
- if (cause !== void 0) {
198
- const rawCause = cause;
199
- data.cause = rawCause instanceof Error ? rawCause.message : String(rawCause);
200
- }
201
- if (code) data.code = code;
202
- if (statusCode !== void 0) data.statusCode = statusCode;
203
- if (meta) data.meta = meta;
204
- if (possibleFixes) data.possibleFixes = possibleFixes;
205
- if (includeStack && stack) if (stack.includes("Caused by:")) {
206
- const [currentStack, causeStack] = stack.split("Caused by:");
207
- data.stack = [
208
- ...currentStack.split("\n").slice(1),
209
- "Caused by:",
210
- ...causeStack.split("\n")
211
- ];
212
- } else data.stack = stack.split("\n").slice(1);
213
- return data;
214
- }
215
- /**
216
- * Prints a user-friendly, colorful representation of the error to the logger
217
- * @param includeStack Whether to include the stack trace in the output (default: false)
218
- */
219
- prettyPrint(includeStack = false) {
220
- const data = this.getErrorData(includeStack);
221
- let output = "\n" + chalk.default.bgRed.white.bold(" ERROR ") + " " + chalk.default.white.bold(data.message) + "\n";
222
- if (data.code) output += chalk.default.yellow(`Error Code: ${data.code}`) + "\n";
223
- if (data.statusCode !== void 0) output += chalk.default.yellow(`Status: ${data.statusCode}`) + "\n";
224
- if (data.cause) {
225
- output += chalk.default.gray("Reason:") + "\n";
226
- output += " " + chalk.default.white(data.cause) + "\n";
227
- }
228
- if (data.meta) {
229
- output += chalk.default.gray("Additional Information:") + "\n";
230
- output += " " + chalk.default.white(JSON.stringify(data.meta, null, 2).replace(/\n/g, "\n ")) + "\n";
231
- }
232
- if (data.possibleFixes?.length) {
233
- output += "\n" + chalk.default.cyan.bold("Try the following:") + "\n";
234
- const fixes = data.possibleFixes?.map((fix, index) => ` ${index + 1}. ` + chalk.default.white(fix));
235
- output += fixes?.join("\n") + "\n";
236
- }
237
- if (data.stack?.length) {
238
- output += "\n" + chalk.default.gray("Stack Trace:") + "\n";
239
- output += chalk.default.gray(data.stack.join("\n")) + "\n";
240
- }
241
- output += "\n";
242
- logger_default.error(output);
243
- }
244
- /**
245
- * Static factory method to create and pretty print an error in one step
246
- * @param message Error message
247
- * @param options Error options
248
- * @param includeStack Whether to include the stack trace in the output
249
- * @returns The created error instance
250
- */
251
- static createAndPrint(message, options = {}, includeStack = false) {
252
- const error = new ComposioError(message, options);
253
- error.prettyPrint(includeStack);
254
- return error;
255
- }
256
- /**
257
- * Utility function to handle errors in a consistent way
258
- * This properly displays the error without throwing
259
- * @param error The error to handle
260
- * @param options Options for error handling
261
- */
262
- static handle(error, options = {}) {
263
- const { includeStack = false, exitProcess = false } = options;
264
- if (error instanceof ComposioError) error.prettyPrint(includeStack);
265
- else if (error instanceof zod_v3.ZodError) this.handleZodError(error, includeStack);
266
- else if (error instanceof Error) this.handleStandardError(error, includeStack);
267
- else this.handleUnknownError(error);
268
- if (exitProcess) this.throwError(error);
269
- }
270
- /**
271
- * Utility function to handle errors and then throw them
272
- * This properly displays the error and then throws it, allowing callers to catch it.
273
- * Use this for fatal errors that should stop execution.
274
- * @param error The error to handle and throw
275
- * @param includeStack Whether to include the stack trace in the output
276
- * @throws ComposioError - Always throws after displaying the error
277
- */
278
- static handleAndThrow(error, includeStack = false) {
279
- this.handle(error, { includeStack });
280
- this.throwError(error);
281
- }
282
- /**
283
- * Helper method to throw an error as a ComposioError
284
- * @param error The error to throw
285
- * @private
286
- */
287
- static throwError(error) {
288
- if (error instanceof ComposioError) throw error;
289
- else if (error instanceof Error) throw new ComposioError(error.message, { cause: error });
290
- else throw new ComposioError(String(error));
291
- }
292
- /**
293
- * Helper method to handle Zod validation errors
294
- * @param error The Zod error to handle
295
- * @param includeStack Whether to include the stack trace
296
- * @private
297
- */
298
- static handleZodError(error, includeStack) {
299
- logger_default.error("\n" + chalk.default.bgRed.white.bold(" ERROR ") + " " + chalk.default.white.bold(error.message));
300
- logger_default.error(chalk.default.gray("Invalid parameters:"));
301
- error.errors.forEach((err) => {
302
- logger_default.error(chalk.default.yellow(err.path.join(".")) + " " + chalk.default.white(err.message));
303
- });
304
- logger_default.error(chalk.default.gray("Expected parameters:"));
305
- error.errors.forEach((err) => {
306
- logger_default.error(chalk.default.yellow(err.path.join(".")) + " " + chalk.default.white(err.message));
307
- });
308
- if (includeStack) {
309
- logger_default.error("\n" + chalk.default.gray("Validation Errors:"));
310
- error.errors.forEach((err) => {
311
- const path = err.path.join(".");
312
- logger_default.error(chalk.default.gray(" • ") + chalk.default.yellow(path ? `${path}: ` : "") + chalk.default.white(err.message));
313
- });
314
- if (error.stack) {
315
- logger_default.error("\n" + chalk.default.gray("Stack Trace:"));
316
- const stackLines = error.stack.split("\n").slice(1);
317
- logger_default.error(chalk.default.gray(stackLines.join("\n")));
318
- }
319
- }
320
- logger_default.error("");
321
- }
322
- /**
323
- * Helper method to handle standard Error objects
324
- * @param error The standard error to handle
325
- * @param includeStack Whether to include the stack trace
326
- * @private
327
- */
328
- static handleStandardError(error, includeStack) {
329
- logger_default.error("\n" + chalk.default.bgRed.white.bold(" ERROR ") + " " + chalk.default.white.bold(error.message));
330
- if (includeStack && error.stack) {
331
- logger_default.error("\n" + chalk.default.gray("Stack Trace:"));
332
- const stackLines = error.stack.split("\n").slice(1);
333
- logger_default.error(chalk.default.gray(stackLines.join("\n")));
334
- }
335
- logger_default.error("");
336
- }
337
- /**
338
- * Helper method to handle unknown error types
339
- * @param error The unknown error value
340
- * @private
341
- */
342
- static handleUnknownError(error) {
343
- logger_default.error("\n" + chalk.default.bgRed.white.bold(" ERROR ") + " " + chalk.default.white.bold("Unknown error occurred"));
344
- if (error !== null && error !== void 0) {
345
- logger_default.error(chalk.default.gray("Error details:"));
346
- logger_default.error(" " + chalk.default.white(String(error)));
347
- }
348
- logger_default.error("");
349
- }
350
- };
351
-
352
- //#endregion
353
- //#region src/errors/FileModifierErrors.ts
354
- const FileModifierErrorCodes = {
355
- FILE_UPLOAD_FAILED: "FILE_UPLOAD_FAILED",
356
- SENSITIVE_FILE_PATH_BLOCKED: "SENSITIVE_FILE_PATH_BLOCKED",
357
- FILE_UPLOAD_ABORTED: "FILE_UPLOAD_ABORTED",
358
- FILE_UPLOAD_PATH_NOT_ALLOWED: "FILE_UPLOAD_PATH_NOT_ALLOWED",
359
- FILE_NOT_FOUND: "FILE_NOT_FOUND"
360
- };
361
- var ComposioFileUploadError = class extends ComposioError {
362
- constructor(message = "Failed to upload file", options = {}) {
363
- super(message, {
364
- ...options,
365
- code: options.code ?? FileModifierErrorCodes.FILE_UPLOAD_FAILED,
366
- possibleFixes: options.possibleFixes || ["Check if the file exists in the location provided"]
367
- });
368
- this.name = "ComposioFileUploadError";
369
- }
370
- };
371
- /**
372
- * Thrown when a local file path is refused before upload (sensitive directory or
373
- * credential-like file name). Subclass of {@link ComposioFileUploadError} so existing
374
- * `instanceof ComposioFileUploadError` handlers still apply.
375
- */
376
- var ComposioSensitiveFilePathBlockedError = class extends ComposioFileUploadError {
377
- constructor(message, options = {}) {
378
- super(message, {
379
- ...options,
380
- code: FileModifierErrorCodes.SENSITIVE_FILE_PATH_BLOCKED,
381
- possibleFixes: options.possibleFixes ?? [
382
- "Use a file outside ~/.ssh, ~/.aws, and other credential locations",
383
- "Set sensitiveFileUploadProtection: false only if you understand the risk",
384
- "Add path segments to block with fileUploadPathDenySegments"
385
- ]
386
- });
387
- this.name = "ComposioSensitiveFilePathBlockedError";
388
- }
389
- };
390
- /**
391
- * Thrown when a `beforeFileUpload` hook returns `false`.
392
- */
393
- var ComposioFileUploadAbortedError = class extends ComposioFileUploadError {
394
- constructor(message, options = {}) {
395
- super(message, {
396
- ...options,
397
- code: FileModifierErrorCodes.FILE_UPLOAD_ABORTED,
398
- possibleFixes: options.possibleFixes ?? ["Change beforeFileUpload to return a file path to upload, or allow the upload to proceed"]
399
- });
400
- this.name = "ComposioFileUploadAbortedError";
401
- }
402
- };
403
- /**
404
- * Thrown when automatic file upload during tool execution is attempted from a path
405
- * that is outside the configured {@link ComposioConfig.fileUploadDirs} allowlist.
406
- *
407
- * This only fires for auto-upload (enabled via
408
- * `dangerouslyAllowAutoUploadDownloadFiles: true`). Manual `composio.files.upload()`
409
- * calls are never subject to this check.
410
- */
411
- var ComposioFileUploadPathNotAllowedError = class extends ComposioFileUploadError {
412
- constructor(message, options = {}) {
413
- super(message, {
414
- ...options,
415
- code: FileModifierErrorCodes.FILE_UPLOAD_PATH_NOT_ALLOWED,
416
- possibleFixes: options.possibleFixes ?? [
417
- "Move the file under one of the directories in `fileUploadDirs`",
418
- "Stage the file under the default upload dir (`~/.composio/temp`)",
419
- "Add the containing directory to `fileUploadDirs` when constructing Composio",
420
- "Pass the file by URL or as a File/Blob object instead of a filesystem path"
421
- ]
422
- });
423
- this.name = "ComposioFileUploadPathNotAllowedError";
424
- }
425
- };
426
- /**
427
- * Thrown when a local file path passed for upload does not exist on disk.
428
- * Provides extra debugging context (resolved absolute path, cwd, allowlist state)
429
- * to help the caller distinguish between "typo" and "not-allowlisted" failures.
430
- */
431
- var ComposioFileNotFoundError = class extends ComposioFileUploadError {
432
- constructor(message, options = {}) {
433
- super(message, {
434
- ...options,
435
- code: FileModifierErrorCodes.FILE_NOT_FOUND,
436
- possibleFixes: options.possibleFixes ?? [
437
- "Double-check the path for typos",
438
- "Remember relative paths are resolved against process.cwd() at upload time",
439
- "Verify the file exists and the process has read permission"
440
- ]
441
- });
442
- this.name = "ComposioFileNotFoundError";
443
- }
444
- };
445
-
446
- //#endregion
447
- Object.defineProperty(exports, 'COMPOSIO_DIR', {
448
- enumerable: true,
449
- get: function () {
450
- return COMPOSIO_DIR;
451
- }
452
- });
453
- Object.defineProperty(exports, 'COMPOSIO_LOG_LEVEL', {
454
- enumerable: true,
455
- get: function () {
456
- return COMPOSIO_LOG_LEVEL;
457
- }
458
- });
459
- Object.defineProperty(exports, 'ComposioError', {
460
- enumerable: true,
461
- get: function () {
462
- return ComposioError;
463
- }
464
- });
465
- Object.defineProperty(exports, 'ComposioFileNotFoundError', {
466
- enumerable: true,
467
- get: function () {
468
- return ComposioFileNotFoundError;
469
- }
470
- });
471
- Object.defineProperty(exports, 'ComposioFileUploadAbortedError', {
472
- enumerable: true,
473
- get: function () {
474
- return ComposioFileUploadAbortedError;
475
- }
476
- });
477
- Object.defineProperty(exports, 'ComposioFileUploadError', {
478
- enumerable: true,
479
- get: function () {
480
- return ComposioFileUploadError;
481
- }
482
- });
483
- Object.defineProperty(exports, 'ComposioFileUploadPathNotAllowedError', {
484
- enumerable: true,
485
- get: function () {
486
- return ComposioFileUploadPathNotAllowedError;
487
- }
488
- });
489
- Object.defineProperty(exports, 'ComposioSensitiveFilePathBlockedError', {
490
- enumerable: true,
491
- get: function () {
492
- return ComposioSensitiveFilePathBlockedError;
493
- }
494
- });
495
- Object.defineProperty(exports, 'DEFAULT_BASE_URL', {
496
- enumerable: true,
497
- get: function () {
498
- return DEFAULT_BASE_URL;
499
- }
500
- });
501
- Object.defineProperty(exports, 'DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID', {
502
- enumerable: true,
503
- get: function () {
504
- return DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID;
505
- }
506
- });
507
- Object.defineProperty(exports, 'FileModifierErrorCodes', {
508
- enumerable: true,
509
- get: function () {
510
- return FileModifierErrorCodes;
511
- }
512
- });
513
- Object.defineProperty(exports, 'IS_DEVELOPMENT_OR_CI', {
514
- enumerable: true,
515
- get: function () {
516
- return IS_DEVELOPMENT_OR_CI;
517
- }
518
- });
519
- Object.defineProperty(exports, 'TEMP_FILES_DIRECTORY_NAME', {
520
- enumerable: true,
521
- get: function () {
522
- return TEMP_FILES_DIRECTORY_NAME;
523
- }
524
- });
525
- Object.defineProperty(exports, 'USER_DATA_FILE_NAME', {
526
- enumerable: true,
527
- get: function () {
528
- return USER_DATA_FILE_NAME;
529
- }
530
- });
531
- Object.defineProperty(exports, 'constants_exports', {
532
- enumerable: true,
533
- get: function () {
534
- return constants_exports;
535
- }
536
- });
537
- Object.defineProperty(exports, 'getEnvVariable', {
538
- enumerable: true,
539
- get: function () {
540
- return getEnvVariable;
541
- }
542
- });
543
- Object.defineProperty(exports, 'getEnvsWithPrefix', {
544
- enumerable: true,
545
- get: function () {
546
- return getEnvsWithPrefix;
547
- }
548
- });
549
- Object.defineProperty(exports, 'logger_default', {
550
- enumerable: true,
551
- get: function () {
552
- return logger_default;
553
- }
554
- });
@@ -1,96 +0,0 @@
1
-
2
- //#region src/utils/modifiers/FileToolModifier.utils.neutral.ts
3
- function isPlainObject(val) {
4
- return typeof val === "object" && val !== null && !Array.isArray(val);
5
- }
6
- /**
7
- * Transforms a single JSON schema property, recursively handling nested properties,
8
- * anyOf, oneOf, and allOf.
9
- */
10
- const transformSchema = (property) => {
11
- if (property.file_uploadable) return {
12
- title: property.title,
13
- description: property.description,
14
- format: "path",
15
- type: "string",
16
- file_uploadable: true
17
- };
18
- const newProperty = { ...property };
19
- if (property.type === "object" && property.properties) newProperty.properties = transformProperties(property.properties);
20
- if (property.anyOf) newProperty.anyOf = property.anyOf.map(transformSchema);
21
- if (property.oneOf) newProperty.oneOf = property.oneOf.map(transformSchema);
22
- if (property.allOf) newProperty.allOf = property.allOf.map(transformSchema);
23
- if (property.items) if (Array.isArray(property.items)) newProperty.items = property.items.map(transformSchema);
24
- else newProperty.items = transformSchema(property.items);
25
- return newProperty;
26
- };
27
- /**
28
- * Transforms the properties of the tool schema to include the file upload URL.
29
- *
30
- * Attaches the format: 'path' to the properties that are file uploadable for agents.
31
- *
32
- * @param properties - The properties of the tool schema.
33
- * @returns The transformed properties.
34
- */
35
- const transformProperties = (properties) => {
36
- const newProperties = {};
37
- for (const [key, property] of Object.entries(properties)) newProperties[key] = transformSchema(property);
38
- return newProperties;
39
- };
40
- /**
41
- * Recursively checks if a schema (or any of its variants) contains a specific file property.
42
- */
43
- const schemaHasFileProperty = (schema, property) => {
44
- if (!schema) return false;
45
- if (schema[property]) return true;
46
- if (schema.properties) {
47
- for (const prop of Object.values(schema.properties)) if (schemaHasFileProperty(prop, property)) return true;
48
- }
49
- if (schema.anyOf) {
50
- for (const variant of schema.anyOf) if (schemaHasFileProperty(variant, property)) return true;
51
- }
52
- if (schema.oneOf) {
53
- for (const variant of schema.oneOf) if (schemaHasFileProperty(variant, property)) return true;
54
- }
55
- if (schema.allOf) {
56
- for (const variant of schema.allOf) if (schemaHasFileProperty(variant, property)) return true;
57
- }
58
- if (schema.items) {
59
- if (Array.isArray(schema.items)) {
60
- for (const item of schema.items) if (schemaHasFileProperty(item, property)) return true;
61
- } else if (schemaHasFileProperty(schema.items, property)) return true;
62
- }
63
- return false;
64
- };
65
- /**
66
- * Recursively checks if a schema (or any of its variants) contains file_uploadable properties.
67
- */
68
- const schemaHasFileUploadable = (schema) => {
69
- return schemaHasFileProperty(schema, "file_uploadable");
70
- };
71
-
72
- //#endregion
73
- Object.defineProperty(exports, 'isPlainObject', {
74
- enumerable: true,
75
- get: function () {
76
- return isPlainObject;
77
- }
78
- });
79
- Object.defineProperty(exports, 'schemaHasFileProperty', {
80
- enumerable: true,
81
- get: function () {
82
- return schemaHasFileProperty;
83
- }
84
- });
85
- Object.defineProperty(exports, 'schemaHasFileUploadable', {
86
- enumerable: true,
87
- get: function () {
88
- return schemaHasFileUploadable;
89
- }
90
- });
91
- Object.defineProperty(exports, 'transformProperties', {
92
- enumerable: true,
93
- get: function () {
94
- return transformProperties;
95
- }
96
- });