@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.
Files changed (69) hide show
  1. package/dist/{tool.types-CwbAy9l_.d.cts → BaseProvider-BBnsv9kS.d.mts} +23683 -23635
  2. package/dist/CustomTool-DEB4BQPl.mjs +468 -0
  3. package/dist/{CustomTool-aber890o.d.cts → CustomTool-DH18rVQu.d.mts} +2 -4
  4. package/dist/{FileModifierErrors-C7z16Dfi.mjs → FileModifierErrors-3fSwIWoa.mjs} +35 -36
  5. package/dist/{FileToolModifier.utils.neutral-B7P7wn-b.mjs → FileToolModifier.utils.neutral-B5rT711M.mjs} +1 -7
  6. package/dist/{Telemetry-kgWlkavX.mjs → Telemetry-DhGI_J4G.mjs} +48 -23
  7. package/dist/{composio-CSMCZZgj.d.cts → composio-CHnEggnv.d.mts} +433 -435
  8. package/dist/{customTool.types-BzEWHa0w.d.cts → customTool.types-DpIdOJjL.d.mts} +177 -236
  9. package/dist/{CustomTool-D7-1S2at.mjs → errors-D5f4pfvI.mjs} +132 -519
  10. package/dist/experimental/index.d.mts +2 -3
  11. package/dist/experimental/index.mjs +1 -3
  12. package/dist/{fileUtils.node-Dq7ebZPC.mjs → fileUtils.node-BiO1JQsJ.mjs} +26 -25
  13. package/dist/index.d.mts +2034 -2356
  14. package/dist/index.mjs +2546 -2335
  15. package/dist/jsonSchema-daqF3S3d.mjs +251 -0
  16. package/dist/models/Files.node.d.mts +1 -2
  17. package/dist/models/Files.node.mjs +3 -4
  18. package/dist/models/Files.workerd.d.mts +0 -1
  19. package/dist/platform/node.d.mts +1 -2
  20. package/dist/platform/workerd.d.mts +1 -2
  21. package/dist/{chunk-CWQeghP5.mjs → rolldown-runtime-w6R9maHv.mjs} +3 -5
  22. package/dist/{types-DE7O6Z6S.d.cts → types-CaI5Z4PA.d.mts} +2 -3
  23. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -4
  24. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -4
  25. package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +3 -0
  26. package/dist/utils/json-schema.d.mts +2 -0
  27. package/dist/utils/json-schema.mjs +3 -0
  28. package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -1
  29. package/dist/utils/modifiers/FileToolModifier.node.mjs +81 -44
  30. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -1
  31. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
  32. package/package.json +48 -88
  33. package/dist/CustomTool-CQ_YjABZ.cjs +0 -1341
  34. package/dist/CustomTool-DJUGNOer.d.mts +0 -76
  35. package/dist/FileModifierErrors-BYJBHiay.cjs +0 -554
  36. package/dist/FileToolModifier.utils.neutral-Dfwqgimk.cjs +0 -102
  37. package/dist/Telemetry-Dm-0sewu.cjs +0 -335
  38. package/dist/buffer-BjWptbNH.cjs +0 -63
  39. package/dist/chunk-CQwRTUmo.cjs +0 -53
  40. package/dist/composio-DRl6WCI9.d.mts +0 -5484
  41. package/dist/customTool.types-CMOMgxoM.d.mts +0 -2513
  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 -8637
  47. package/dist/index.d.cts +0 -5672
  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/tool.types-CB_4JKhV.d.mts +0 -29377
  57. package/dist/types-BTOPdg4d.d.mts +0 -13
  58. package/dist/types-pDNm1lYs.d.cts +0 -69
  59. package/dist/utils/config-defaults/ConfigDefaults.node.cjs +0 -10
  60. package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +0 -7
  61. package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +0 -10
  62. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +0 -7
  63. package/dist/utils/modifiers/FileToolModifier.node.cjs +0 -207
  64. package/dist/utils/modifiers/FileToolModifier.node.d.cts +0 -22
  65. package/dist/utils/modifiers/FileToolModifier.workerd.cjs +0 -27
  66. package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +0 -20
  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,76 +0,0 @@
1
- import { a as CustomTool, h as CustomToolkit, i as CreateCustomToolkitParams, n as CreateCustomToolParams } from "./customTool.types-CMOMgxoM.mjs";
2
- import { z as z$1 } from "zod/v3";
3
- import { SessionCreateResponse } from "@composio/client/resources/tool-router/session/session.mjs";
4
-
5
- //#region src/models/CustomTool.d.ts
6
-
7
- /**
8
- * Create a custom tool for use in tool router sessions.
9
- *
10
- * The returned object is a lightweight reference containing the tool's metadata
11
- * and execute function. Pass it to `composio.create(userId, { experimental: { customTools: [...] } })`
12
- * to bind it to a session.
13
- *
14
- * Just return the result data from `execute`, or throw an error.
15
- * The SDK wraps it into the standard response format internally.
16
- *
17
- * **Slug naming:** The slug you provide is automatically prefixed with `LOCAL_` when
18
- * exposed to the agent (e.g. `'GREP'` becomes `LOCAL_GREP`). If the tool is inside a
19
- * custom toolkit, the toolkit slug is also included (e.g. `LOCAL_DEV_TOOLS_GREP`).
20
- * The `LOCAL_` prefix is reserved and cannot be used in your slug.
21
- *
22
- * @param slug - Unique tool identifier (alphanumeric, underscores, hyphens; no LOCAL_ or COMPOSIO_ prefix)
23
- * @param options - Tool definition including name, schema, and execute function
24
- * @returns A CustomTool to pass to session creation
25
- *
26
- * @example Standalone tool (no auth)
27
- * ```typescript
28
- * const grep = createCustomTool('GREP', {
29
- * name: 'Grep Search',
30
- * description: 'Search for patterns in files',
31
- * inputParams: z.object({ pattern: z.string(), path: z.string() }),
32
- * execute: async (input) => ({ matches: [] }),
33
- * });
34
- * ```
35
- *
36
- * @example Tool extending a Composio toolkit (inherits auth)
37
- * ```typescript
38
- * const getImportant = createCustomTool('GET_IMPORTANT_EMAILS', {
39
- * name: 'Get Important Emails',
40
- * description: 'Fetch high-priority emails',
41
- * extendsToolkit: 'gmail',
42
- * inputParams: z.object({ limit: z.number().default(10) }),
43
- * execute: async (input, ctx) => {
44
- * // Same response shape as session.execute(): { data, error, logId }
45
- * const result = await ctx.execute('GMAIL_SEARCH', { query: 'is:important' });
46
- * return { emails: result.data };
47
- * },
48
- * });
49
- * ```
50
- */
51
- declare function createCustomTool<T extends z$1.ZodType>(slug: string, options: CreateCustomToolParams<T>): CustomTool;
52
- /**
53
- * Create a custom toolkit that groups related tools.
54
- *
55
- * Tools passed here must NOT have `extendsToolkit` set — they inherit the toolkit identity instead.
56
- *
57
- * **Slug naming:** The toolkit slug becomes part of the final tool slug exposed to the agent.
58
- * For example, a toolkit `'DEV_TOOLS'` with a tool `'GREP'` produces `LOCAL_DEV_TOOLS_GREP`.
59
- * The `LOCAL_` prefix is reserved and cannot be used in your slug.
60
- *
61
- * @param slug - Unique toolkit identifier (alphanumeric, underscores, hyphens; no LOCAL_ or COMPOSIO_ prefix)
62
- * @param options - Toolkit definition including name, description, and tools
63
- * @returns A CustomToolkit to pass to session creation
64
- *
65
- * @example
66
- * ```typescript
67
- * const devTools = createCustomToolkit('DEV_TOOLS', {
68
- * name: 'Dev Tools',
69
- * description: 'Local dev utilities',
70
- * tools: [grepTool, sedTool],
71
- * });
72
- * ```
73
- */
74
- declare function createCustomToolkit(slug: string, options: CreateCustomToolkitParams): CustomToolkit;
75
- //#endregion
76
- export { createCustomToolkit as n, createCustomTool as t };
@@ -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
- });