@composio/core 0.1.44 → 0.1.46

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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  The core Composio SDK which allows users to interact with the Composio Platform. It provides a powerful and flexible way to manage and execute tools, handle authentication, and integrate with various platforms and frameworks.
4
4
 
5
+ [Learn more about the SDK from our docs](https://docs.composio.dev)
6
+
5
7
  ## Core Features
6
8
 
7
9
  - **Tools**: Manage and execute tools within the Composio ecosystem. Includes functionality to list, retrieve, and execute tools.
@@ -27,22 +29,86 @@ pnpm add @composio/core
27
29
 
28
30
  ```typescript
29
31
  import { Composio } from '@composio/core';
30
- import { OpenAIProvider } from '@composio/openai';
32
+ import { OpenAI } from 'openai';
33
+
34
+ // Initialize OpenAI client
35
+ const openai = new OpenAI({
36
+ apiKey: process.env.OPENAI_API_KEY,
37
+ });
31
38
 
39
+ // Initialize Composio with your API key
32
40
  const composio = new Composio({
33
41
  apiKey: process.env.COMPOSIO_API_KEY,
34
- // OpenAIProvider is the default, so this is optional
35
- provider: new OpenAIProvider(),
36
42
  });
37
43
 
38
- // Fetch a single tool by slig
39
- const tools = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS');
44
+ async function main() {
45
+ try {
46
+ // Fetch tools - single tool or multiple tools
47
+ const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
48
+ // Or fetch multiple tools: await composio.tools.get('default', { toolkits: ['hackernews'] });
49
+
50
+ const query = "Find information about the HackerNews user 'pg'";
51
+
52
+ // Create chat completion with tools
53
+ const response = await openai.chat.completions.create({
54
+ model: 'gpt-4o',
55
+ messages: [
56
+ {
57
+ role: 'system',
58
+ content: 'You are a helpful assistant that can use tools to answer questions.',
59
+ },
60
+ { role: 'user', content: query },
61
+ ],
62
+ tools: tools,
63
+ tool_choice: 'auto',
64
+ });
65
+
66
+ // Handle tool calls if the assistant decides to use them
67
+ if (response.choices[0].message.tool_calls) {
68
+ console.log(
69
+ '🔧 Assistant is using tool:',
70
+ response.choices[0].message.tool_calls[0].function.name
71
+ );
72
+
73
+ // Execute the tool call
74
+ const toolResult = await composio.provider.executeToolCall(
75
+ 'default',
76
+ response.choices[0].message.tool_calls[0],
77
+ {
78
+ connectedAccountId: '', // Optional: specify connected account
79
+ }
80
+ );
81
+
82
+ console.log('✅ Tool execution result:', JSON.parse(toolResult));
83
+
84
+ // Get final response from assistant with tool result
85
+ const finalResponse = await openai.chat.completions.create({
86
+ model: 'gpt-4o',
87
+ messages: [
88
+ {
89
+ role: 'system',
90
+ content: 'You are a helpful assistant that can use tools to answer questions.',
91
+ },
92
+ { role: 'user', content: query },
93
+ response.choices[0].message,
94
+ {
95
+ role: 'tool',
96
+ tool_call_id: response.choices[0].message.tool_calls[0].id,
97
+ content: toolResult,
98
+ },
99
+ ],
100
+ });
101
+
102
+ console.log('🤖 Final response:', finalResponse.choices[0].message.content);
103
+ } else {
104
+ console.log('🤖 Response:', response.choices[0].message.content);
105
+ }
106
+ } catch (error) {
107
+ console.error('❌ Error:', error);
108
+ }
109
+ }
40
110
 
41
- // Fetch multiple tools
42
- const tools = await composio.tools.get('user123', {
43
- category: 'search',
44
- limit: 10,
45
- });
111
+ main();
46
112
  ```
47
113
 
48
114
  ## Configuration
@@ -51,12 +117,14 @@ The Composio constructor accepts the following configuration options:
51
117
 
52
118
  ```typescript
53
119
  interface ComposioConfig {
54
- apiKey?: string; // Your Composio API key
55
- baseURL?: string; // Custom API base URL (optional)
120
+ apiKey?: string | null; // Your Composio API key
121
+ baseURL?: string | null; // Custom API base URL (optional)
56
122
  allowTracking?: boolean; // Enable/disable telemetry (default: true)
57
- allowTracing?: boolean; // Enable/disable tracing (default: true)
123
+ autoUploadDownloadFiles?: boolean; // Whether to automatically upload and download files during tool execution (default: true)
58
124
  provider?: TProvider; // Custom provider (default: OpenAIProvider)
59
- host?: string; // Name of the host service which is using the SDK, this is for telemetry.
125
+ host?: string; // Name of the host service which is using the SDK, this is for telemetry
126
+ defaultHeaders?: ComposioRequestHeaders; // Request headers to be passed to the Composio API client
127
+ disableVersionCheck?: boolean; // Whether to disable version check for the Composio SDK (default: false)
60
128
  }
61
129
  ```
62
130
 
@@ -70,7 +138,7 @@ Schema modifiers allow you to transform tool schemas before they are used:
70
138
 
71
139
  ```typescript
72
140
  const tools = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
73
- modifySchema: (toolSlug: string, toolkitSlug: string, tool: Tool) => ({
141
+ modifySchema: ({ toolSlug, toolkitSlug, schema }) => ({
74
142
  ...tool,
75
143
  description: 'Enhanced HackerNews search with additional features',
76
144
  inputParameters: {
@@ -92,7 +160,7 @@ For agentic providers (like Vercel AI and Langchain), you can also modify tool e
92
160
  ```typescript
93
161
  const tools = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
94
162
  // Transform input before execution
95
- beforeExecute: (toolSlug: string, toolkitSlug: string, params: ToolExecuteParams) => ({
163
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => ({
96
164
  ...params,
97
165
  arguments: {
98
166
  ...params.arguments,
@@ -101,7 +169,7 @@ const tools = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
101
169
  }),
102
170
 
103
171
  // Transform output after execution
104
- afterExecute: (toolSlug: string, toolkitSlug: string, response: ToolExecuteResponse) => ({
172
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => ({
105
173
  ...response,
106
174
  data: {
107
175
  ...response.data,
@@ -128,11 +196,11 @@ const composio = new Composio({
128
196
  });
129
197
 
130
198
  // Create a connected account
131
- const connectionRequest = await composio.createConnectedAccount(
199
+ const connectionRequest = await composio.connectedAccounts.initiate(
132
200
  'user123', // userId
133
- 'HACKERNEWS', // authConfigId
201
+ 'ac_12343544', // authConfigId: You can create it from the dashboard
134
202
  {
135
- redirectUrl: 'https://your-app.com/callback',
203
+ callbackUrl: 'https://your-app.com/callback',
136
204
  data: {
137
205
  // Additional data for the connection
138
206
  scope: ['read', 'write'],
@@ -143,6 +211,7 @@ const connectionRequest = await composio.createConnectedAccount(
143
211
  // Wait for the connection to be established
144
212
  // Default timeout is 60 seconds
145
213
  const connectedAccount = await connectionRequest.waitForConnection();
214
+ console.log({ connectedAccount });
146
215
  ```
147
216
 
148
217
  ### Waiting for Connection Establishment
package/dist/index.cjs CHANGED
@@ -958,6 +958,7 @@ __export(constants_exports, {
958
958
  COMPOSIO_DIR: () => COMPOSIO_DIR,
959
959
  COMPOSIO_LOG_LEVEL: () => COMPOSIO_LOG_LEVEL,
960
960
  DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
961
+ DEFAULT_WEB_URL: () => DEFAULT_WEB_URL,
961
962
  IS_DEVELOPMENT_OR_CI: () => IS_DEVELOPMENT_OR_CI,
962
963
  TELEMETRY_URL: () => TELEMETRY_URL,
963
964
  TEMP_FILES_DIRECTORY_NAME: () => TEMP_FILES_DIRECTORY_NAME,
@@ -978,6 +979,7 @@ var COMPOSIO_DIR = ".composio";
978
979
  var USER_DATA_FILE_NAME = "user_data.json";
979
980
  var TEMP_FILES_DIRECTORY_NAME = "files";
980
981
  var DEFAULT_BASE_URL = "https://backend.composio.dev";
982
+ var DEFAULT_WEB_URL = "https://platform.composio.dev";
981
983
  var TELEMETRY_URL = "https://app.composio.dev";
982
984
  var CLIENT_PUSHER_KEY = getEnvVariable("CLIENT_PUSHER_KEY") || "ff9f18c208855d77a152";
983
985
  var COMPOSIO_LOG_LEVEL = getEnvVariable("COMPOSIO_LOG_LEVEL");
@@ -1473,6 +1475,9 @@ var import_uuid = require("uuid");
1473
1475
  function getRandomUUID() {
1474
1476
  return (0, import_uuid.v4)();
1475
1477
  }
1478
+ function getRandomShortId() {
1479
+ return getRandomUUID().slice(0, 8).replace(/-/g, "");
1480
+ }
1476
1481
 
1477
1482
  // src/services/telemetry/TelemetryService.ts
1478
1483
  var TELEMETRY_URL2 = "https://telemetry.composio.dev/v1";
@@ -2269,11 +2274,77 @@ var ComposioFileUploadError = class extends ComposioError {
2269
2274
  // src/utils/fileUtils.ts
2270
2275
  var import_crypto = __toESM(require("crypto"), 1);
2271
2276
  var import_path = __toESM(require("path"), 1);
2277
+ var getExtensionFromMimeType = (mimeType) => {
2278
+ const mimeToExt = {
2279
+ "text/plain": "txt",
2280
+ "text/html": "html",
2281
+ "text/css": "css",
2282
+ "text/javascript": "js",
2283
+ "application/json": "json",
2284
+ "application/xml": "xml",
2285
+ "application/pdf": "pdf",
2286
+ "application/zip": "zip",
2287
+ "application/x-zip-compressed": "zip",
2288
+ "application/gzip": "gz",
2289
+ "application/x-tar": "tar",
2290
+ "application/msword": "doc",
2291
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
2292
+ "application/vnd.ms-excel": "xls",
2293
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
2294
+ "application/vnd.ms-powerpoint": "ppt",
2295
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
2296
+ "image/jpeg": "jpg",
2297
+ "image/jpg": "jpg",
2298
+ "image/png": "png",
2299
+ "image/gif": "gif",
2300
+ "image/svg+xml": "svg",
2301
+ "image/webp": "webp",
2302
+ "image/bmp": "bmp",
2303
+ "image/tiff": "tiff",
2304
+ "audio/mpeg": "mp3",
2305
+ "audio/wav": "wav",
2306
+ "audio/ogg": "ogg",
2307
+ "video/mp4": "mp4",
2308
+ "video/mpeg": "mpeg",
2309
+ "video/quicktime": "mov",
2310
+ "video/x-msvideo": "avi",
2311
+ "video/webm": "webm"
2312
+ };
2313
+ const cleanMimeType = mimeType.split(";")[0].toLowerCase().trim();
2314
+ if (mimeToExt[cleanMimeType]) {
2315
+ return mimeToExt[cleanMimeType];
2316
+ }
2317
+ const parts = cleanMimeType.split("/");
2318
+ if (parts.length === 2) {
2319
+ const subtype = parts[1].toLowerCase();
2320
+ const cleanSubtype = subtype;
2321
+ if (cleanSubtype.includes("+")) {
2322
+ const plusParts = cleanSubtype.split("+");
2323
+ const prefix = plusParts[0];
2324
+ const suffix = plusParts[plusParts.length - 1];
2325
+ const knownPrefixes = ["svg", "atom", "rss"];
2326
+ if (knownPrefixes.includes(prefix)) {
2327
+ return prefix;
2328
+ }
2329
+ const structuredSuffixes = ["json", "xml", "yaml", "zip", "gzip"];
2330
+ if (structuredSuffixes.includes(suffix)) {
2331
+ return suffix;
2332
+ }
2333
+ return suffix;
2334
+ }
2335
+ return cleanSubtype || "txt";
2336
+ }
2337
+ return "txt";
2338
+ };
2339
+ var generateTimestampedFilename = (extension, prefix) => {
2340
+ const basePrefix = prefix || "file_ts";
2341
+ return `${basePrefix}${Date.now()}${getRandomShortId()}.${extension}`;
2342
+ };
2272
2343
  var readFileContent = async (path) => {
2273
2344
  try {
2274
2345
  const content = require("fs").readFileSync(path);
2275
2346
  return {
2276
- fileName: import_path.default.basename(path) || `file_${Date.now()}.${path.split(".").pop()}`,
2347
+ fileName: generateTimestampedFilename(path.split(".").pop() || "txt"),
2277
2348
  content: content.toString("base64"),
2278
2349
  mimeType: "application/octet-stream"
2279
2350
  };
@@ -2289,10 +2360,23 @@ var readFileContentFromURL = async (path) => {
2289
2360
  const arrayBuffer = await response.arrayBuffer();
2290
2361
  const content = Buffer.from(arrayBuffer);
2291
2362
  const mimeType = response.headers.get("content-type") || "application/octet-stream";
2363
+ const url = new URL(path);
2364
+ const pathname = url.pathname;
2365
+ let fileName = import_path.default.basename(pathname);
2366
+ if (!fileName || fileName === "/") {
2367
+ const extension = getExtensionFromMimeType(mimeType);
2368
+ fileName = generateTimestampedFilename(extension);
2369
+ } else {
2370
+ const hasExtension = fileName.includes(".");
2371
+ if (!hasExtension) {
2372
+ const extension = getExtensionFromMimeType(mimeType);
2373
+ fileName = generateTimestampedFilename(extension);
2374
+ }
2375
+ }
2292
2376
  return {
2293
2377
  content: content.toString("base64"),
2294
2378
  mimeType,
2295
- fileName: import_path.default.basename(path) || `file_${Date.now()}.${path.split(".").pop()}`
2379
+ fileName
2296
2380
  };
2297
2381
  };
2298
2382
  var uploadFileToS3 = async (fileName, content, toolSlug, toolkitSlug, mimeType, client) => {
@@ -2376,8 +2460,8 @@ var downloadFileFromS3 = async ({
2376
2460
  throw new Error(`Failed to download file: ${response.statusText}`);
2377
2461
  }
2378
2462
  const data = await response.arrayBuffer();
2379
- const extension = mimeType.split("/")[1] || "txt";
2380
- const fileName = `${toolSlug}_${Date.now()}.${extension}`;
2463
+ const extension = getExtensionFromMimeType(mimeType);
2464
+ const fileName = generateTimestampedFilename(extension, `${toolSlug}_`);
2381
2465
  const filePath = saveFile(fileName, Buffer.from(data), true);
2382
2466
  return {
2383
2467
  name: fileName,
@@ -6590,7 +6674,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
6590
6674
  };
6591
6675
 
6592
6676
  // package.json
6593
- var version = "0.1.44";
6677
+ var version = "0.1.46";
6594
6678
 
6595
6679
  // src/models/Files.ts
6596
6680
  var Files = class {
@@ -6745,7 +6829,9 @@ var Composio = class _Composio {
6745
6829
  }
6746
6830
  telemetry.instrument(this);
6747
6831
  telemetry.instrument(this.provider);
6748
- checkForLatestVersionFromNPM(version);
6832
+ if (!this.config.disableVersionCheck) {
6833
+ checkForLatestVersionFromNPM(version);
6834
+ }
6749
6835
  }
6750
6836
  /**
6751
6837
  * Get the Composio SDK client.
@@ -6824,7 +6910,7 @@ var removeNonRequiredProperties = (schema) => {
6824
6910
  )
6825
6911
  );
6826
6912
  }
6827
- schema.additionalProperties = schema.additionalProperties ?? false;
6913
+ schema.additionalProperties = false;
6828
6914
  return schema;
6829
6915
  };
6830
6916
  function jsonSchemaToZodSchema(jsonSchema, { strict } = {
package/dist/index.d.cts CHANGED
@@ -72791,6 +72791,12 @@ type ComposioConfig<TProvider extends BaseComposioProvider<unknown, unknown, unk
72791
72791
  * ```
72792
72792
  */
72793
72793
  defaultHeaders?: ComposioRequestHeaders;
72794
+ /**
72795
+ * Whether to disable version check for the Composio SDK.
72796
+ * @example true, false
72797
+ * @default false
72798
+ */
72799
+ disableVersionCheck?: boolean;
72794
72800
  };
72795
72801
  /**
72796
72802
  * Extract the MCP response type from a provider
@@ -73102,6 +73108,7 @@ declare const COMPOSIO_DIR = ".composio";
73102
73108
  declare const USER_DATA_FILE_NAME = "user_data.json";
73103
73109
  declare const TEMP_FILES_DIRECTORY_NAME = "files";
73104
73110
  declare const DEFAULT_BASE_URL = "https://backend.composio.dev";
73111
+ declare const DEFAULT_WEB_URL = "https://platform.composio.dev";
73105
73112
  declare const TELEMETRY_URL = "https://app.composio.dev";
73106
73113
  declare const CLIENT_PUSHER_KEY: string;
73107
73114
  declare const COMPOSIO_LOG_LEVEL: "debug" | "info" | "warn" | "error" | undefined;
@@ -73111,12 +73118,13 @@ declare const constants_CLIENT_PUSHER_KEY: typeof CLIENT_PUSHER_KEY;
73111
73118
  declare const constants_COMPOSIO_DIR: typeof COMPOSIO_DIR;
73112
73119
  declare const constants_COMPOSIO_LOG_LEVEL: typeof COMPOSIO_LOG_LEVEL;
73113
73120
  declare const constants_DEFAULT_BASE_URL: typeof DEFAULT_BASE_URL;
73121
+ declare const constants_DEFAULT_WEB_URL: typeof DEFAULT_WEB_URL;
73114
73122
  declare const constants_IS_DEVELOPMENT_OR_CI: typeof IS_DEVELOPMENT_OR_CI;
73115
73123
  declare const constants_TELEMETRY_URL: typeof TELEMETRY_URL;
73116
73124
  declare const constants_TEMP_FILES_DIRECTORY_NAME: typeof TEMP_FILES_DIRECTORY_NAME;
73117
73125
  declare const constants_USER_DATA_FILE_NAME: typeof USER_DATA_FILE_NAME;
73118
73126
  declare namespace constants {
73119
- export { constants_CLIENT_PUSHER_KEY as CLIENT_PUSHER_KEY, constants_COMPOSIO_DIR as COMPOSIO_DIR, constants_COMPOSIO_LOG_LEVEL as COMPOSIO_LOG_LEVEL, constants_DEFAULT_BASE_URL as DEFAULT_BASE_URL, constants_IS_DEVELOPMENT_OR_CI as IS_DEVELOPMENT_OR_CI, constants_TELEMETRY_URL as TELEMETRY_URL, constants_TEMP_FILES_DIRECTORY_NAME as TEMP_FILES_DIRECTORY_NAME, constants_USER_DATA_FILE_NAME as USER_DATA_FILE_NAME };
73127
+ export { constants_CLIENT_PUSHER_KEY as CLIENT_PUSHER_KEY, constants_COMPOSIO_DIR as COMPOSIO_DIR, constants_COMPOSIO_LOG_LEVEL as COMPOSIO_LOG_LEVEL, constants_DEFAULT_BASE_URL as DEFAULT_BASE_URL, constants_DEFAULT_WEB_URL as DEFAULT_WEB_URL, constants_IS_DEVELOPMENT_OR_CI as IS_DEVELOPMENT_OR_CI, constants_TELEMETRY_URL as TELEMETRY_URL, constants_TEMP_FILES_DIRECTORY_NAME as TEMP_FILES_DIRECTORY_NAME, constants_USER_DATA_FILE_NAME as USER_DATA_FILE_NAME };
73120
73128
  }
73121
73129
 
73122
73130
  declare const LOG_LEVELS: {
package/dist/index.d.ts CHANGED
@@ -72791,6 +72791,12 @@ type ComposioConfig<TProvider extends BaseComposioProvider<unknown, unknown, unk
72791
72791
  * ```
72792
72792
  */
72793
72793
  defaultHeaders?: ComposioRequestHeaders;
72794
+ /**
72795
+ * Whether to disable version check for the Composio SDK.
72796
+ * @example true, false
72797
+ * @default false
72798
+ */
72799
+ disableVersionCheck?: boolean;
72794
72800
  };
72795
72801
  /**
72796
72802
  * Extract the MCP response type from a provider
@@ -73102,6 +73108,7 @@ declare const COMPOSIO_DIR = ".composio";
73102
73108
  declare const USER_DATA_FILE_NAME = "user_data.json";
73103
73109
  declare const TEMP_FILES_DIRECTORY_NAME = "files";
73104
73110
  declare const DEFAULT_BASE_URL = "https://backend.composio.dev";
73111
+ declare const DEFAULT_WEB_URL = "https://platform.composio.dev";
73105
73112
  declare const TELEMETRY_URL = "https://app.composio.dev";
73106
73113
  declare const CLIENT_PUSHER_KEY: string;
73107
73114
  declare const COMPOSIO_LOG_LEVEL: "debug" | "info" | "warn" | "error" | undefined;
@@ -73111,12 +73118,13 @@ declare const constants_CLIENT_PUSHER_KEY: typeof CLIENT_PUSHER_KEY;
73111
73118
  declare const constants_COMPOSIO_DIR: typeof COMPOSIO_DIR;
73112
73119
  declare const constants_COMPOSIO_LOG_LEVEL: typeof COMPOSIO_LOG_LEVEL;
73113
73120
  declare const constants_DEFAULT_BASE_URL: typeof DEFAULT_BASE_URL;
73121
+ declare const constants_DEFAULT_WEB_URL: typeof DEFAULT_WEB_URL;
73114
73122
  declare const constants_IS_DEVELOPMENT_OR_CI: typeof IS_DEVELOPMENT_OR_CI;
73115
73123
  declare const constants_TELEMETRY_URL: typeof TELEMETRY_URL;
73116
73124
  declare const constants_TEMP_FILES_DIRECTORY_NAME: typeof TEMP_FILES_DIRECTORY_NAME;
73117
73125
  declare const constants_USER_DATA_FILE_NAME: typeof USER_DATA_FILE_NAME;
73118
73126
  declare namespace constants {
73119
- export { constants_CLIENT_PUSHER_KEY as CLIENT_PUSHER_KEY, constants_COMPOSIO_DIR as COMPOSIO_DIR, constants_COMPOSIO_LOG_LEVEL as COMPOSIO_LOG_LEVEL, constants_DEFAULT_BASE_URL as DEFAULT_BASE_URL, constants_IS_DEVELOPMENT_OR_CI as IS_DEVELOPMENT_OR_CI, constants_TELEMETRY_URL as TELEMETRY_URL, constants_TEMP_FILES_DIRECTORY_NAME as TEMP_FILES_DIRECTORY_NAME, constants_USER_DATA_FILE_NAME as USER_DATA_FILE_NAME };
73127
+ export { constants_CLIENT_PUSHER_KEY as CLIENT_PUSHER_KEY, constants_COMPOSIO_DIR as COMPOSIO_DIR, constants_COMPOSIO_LOG_LEVEL as COMPOSIO_LOG_LEVEL, constants_DEFAULT_BASE_URL as DEFAULT_BASE_URL, constants_DEFAULT_WEB_URL as DEFAULT_WEB_URL, constants_IS_DEVELOPMENT_OR_CI as IS_DEVELOPMENT_OR_CI, constants_TELEMETRY_URL as TELEMETRY_URL, constants_TEMP_FILES_DIRECTORY_NAME as TEMP_FILES_DIRECTORY_NAME, constants_USER_DATA_FILE_NAME as USER_DATA_FILE_NAME };
73120
73128
  }
73121
73129
 
73122
73130
  declare const LOG_LEVELS: {
package/dist/index.js CHANGED
@@ -789,6 +789,7 @@ __export(constants_exports, {
789
789
  COMPOSIO_DIR: () => COMPOSIO_DIR,
790
790
  COMPOSIO_LOG_LEVEL: () => COMPOSIO_LOG_LEVEL,
791
791
  DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
792
+ DEFAULT_WEB_URL: () => DEFAULT_WEB_URL,
792
793
  IS_DEVELOPMENT_OR_CI: () => IS_DEVELOPMENT_OR_CI,
793
794
  TELEMETRY_URL: () => TELEMETRY_URL,
794
795
  TEMP_FILES_DIRECTORY_NAME: () => TEMP_FILES_DIRECTORY_NAME,
@@ -809,6 +810,7 @@ var COMPOSIO_DIR = ".composio";
809
810
  var USER_DATA_FILE_NAME = "user_data.json";
810
811
  var TEMP_FILES_DIRECTORY_NAME = "files";
811
812
  var DEFAULT_BASE_URL = "https://backend.composio.dev";
813
+ var DEFAULT_WEB_URL = "https://platform.composio.dev";
812
814
  var TELEMETRY_URL = "https://app.composio.dev";
813
815
  var CLIENT_PUSHER_KEY = getEnvVariable("CLIENT_PUSHER_KEY") || "ff9f18c208855d77a152";
814
816
  var COMPOSIO_LOG_LEVEL = getEnvVariable("COMPOSIO_LOG_LEVEL");
@@ -1304,6 +1306,9 @@ import { v4 as uuidv4 } from "uuid";
1304
1306
  function getRandomUUID() {
1305
1307
  return uuidv4();
1306
1308
  }
1309
+ function getRandomShortId() {
1310
+ return getRandomUUID().slice(0, 8).replace(/-/g, "");
1311
+ }
1307
1312
 
1308
1313
  // src/services/telemetry/TelemetryService.ts
1309
1314
  var TELEMETRY_URL2 = "https://telemetry.composio.dev/v1";
@@ -2100,11 +2105,77 @@ var ComposioFileUploadError = class extends ComposioError {
2100
2105
  // src/utils/fileUtils.ts
2101
2106
  import crypto from "crypto";
2102
2107
  import pathModule from "path";
2108
+ var getExtensionFromMimeType = (mimeType) => {
2109
+ const mimeToExt = {
2110
+ "text/plain": "txt",
2111
+ "text/html": "html",
2112
+ "text/css": "css",
2113
+ "text/javascript": "js",
2114
+ "application/json": "json",
2115
+ "application/xml": "xml",
2116
+ "application/pdf": "pdf",
2117
+ "application/zip": "zip",
2118
+ "application/x-zip-compressed": "zip",
2119
+ "application/gzip": "gz",
2120
+ "application/x-tar": "tar",
2121
+ "application/msword": "doc",
2122
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
2123
+ "application/vnd.ms-excel": "xls",
2124
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
2125
+ "application/vnd.ms-powerpoint": "ppt",
2126
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
2127
+ "image/jpeg": "jpg",
2128
+ "image/jpg": "jpg",
2129
+ "image/png": "png",
2130
+ "image/gif": "gif",
2131
+ "image/svg+xml": "svg",
2132
+ "image/webp": "webp",
2133
+ "image/bmp": "bmp",
2134
+ "image/tiff": "tiff",
2135
+ "audio/mpeg": "mp3",
2136
+ "audio/wav": "wav",
2137
+ "audio/ogg": "ogg",
2138
+ "video/mp4": "mp4",
2139
+ "video/mpeg": "mpeg",
2140
+ "video/quicktime": "mov",
2141
+ "video/x-msvideo": "avi",
2142
+ "video/webm": "webm"
2143
+ };
2144
+ const cleanMimeType = mimeType.split(";")[0].toLowerCase().trim();
2145
+ if (mimeToExt[cleanMimeType]) {
2146
+ return mimeToExt[cleanMimeType];
2147
+ }
2148
+ const parts = cleanMimeType.split("/");
2149
+ if (parts.length === 2) {
2150
+ const subtype = parts[1].toLowerCase();
2151
+ const cleanSubtype = subtype;
2152
+ if (cleanSubtype.includes("+")) {
2153
+ const plusParts = cleanSubtype.split("+");
2154
+ const prefix = plusParts[0];
2155
+ const suffix = plusParts[plusParts.length - 1];
2156
+ const knownPrefixes = ["svg", "atom", "rss"];
2157
+ if (knownPrefixes.includes(prefix)) {
2158
+ return prefix;
2159
+ }
2160
+ const structuredSuffixes = ["json", "xml", "yaml", "zip", "gzip"];
2161
+ if (structuredSuffixes.includes(suffix)) {
2162
+ return suffix;
2163
+ }
2164
+ return suffix;
2165
+ }
2166
+ return cleanSubtype || "txt";
2167
+ }
2168
+ return "txt";
2169
+ };
2170
+ var generateTimestampedFilename = (extension, prefix) => {
2171
+ const basePrefix = prefix || "file_ts";
2172
+ return `${basePrefix}${Date.now()}${getRandomShortId()}.${extension}`;
2173
+ };
2103
2174
  var readFileContent = async (path) => {
2104
2175
  try {
2105
2176
  const content = __require("fs").readFileSync(path);
2106
2177
  return {
2107
- fileName: pathModule.basename(path) || `file_${Date.now()}.${path.split(".").pop()}`,
2178
+ fileName: generateTimestampedFilename(path.split(".").pop() || "txt"),
2108
2179
  content: content.toString("base64"),
2109
2180
  mimeType: "application/octet-stream"
2110
2181
  };
@@ -2120,10 +2191,23 @@ var readFileContentFromURL = async (path) => {
2120
2191
  const arrayBuffer = await response.arrayBuffer();
2121
2192
  const content = Buffer.from(arrayBuffer);
2122
2193
  const mimeType = response.headers.get("content-type") || "application/octet-stream";
2194
+ const url = new URL(path);
2195
+ const pathname = url.pathname;
2196
+ let fileName = pathModule.basename(pathname);
2197
+ if (!fileName || fileName === "/") {
2198
+ const extension = getExtensionFromMimeType(mimeType);
2199
+ fileName = generateTimestampedFilename(extension);
2200
+ } else {
2201
+ const hasExtension = fileName.includes(".");
2202
+ if (!hasExtension) {
2203
+ const extension = getExtensionFromMimeType(mimeType);
2204
+ fileName = generateTimestampedFilename(extension);
2205
+ }
2206
+ }
2123
2207
  return {
2124
2208
  content: content.toString("base64"),
2125
2209
  mimeType,
2126
- fileName: pathModule.basename(path) || `file_${Date.now()}.${path.split(".").pop()}`
2210
+ fileName
2127
2211
  };
2128
2212
  };
2129
2213
  var uploadFileToS3 = async (fileName, content, toolSlug, toolkitSlug, mimeType, client) => {
@@ -2207,8 +2291,8 @@ var downloadFileFromS3 = async ({
2207
2291
  throw new Error(`Failed to download file: ${response.statusText}`);
2208
2292
  }
2209
2293
  const data = await response.arrayBuffer();
2210
- const extension = mimeType.split("/")[1] || "txt";
2211
- const fileName = `${toolSlug}_${Date.now()}.${extension}`;
2294
+ const extension = getExtensionFromMimeType(mimeType);
2295
+ const fileName = generateTimestampedFilename(extension, `${toolSlug}_`);
2212
2296
  const filePath = saveFile(fileName, Buffer.from(data), true);
2213
2297
  return {
2214
2298
  name: fileName,
@@ -6421,7 +6505,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
6421
6505
  };
6422
6506
 
6423
6507
  // package.json
6424
- var version = "0.1.44";
6508
+ var version = "0.1.46";
6425
6509
 
6426
6510
  // src/models/Files.ts
6427
6511
  var Files = class {
@@ -6576,7 +6660,9 @@ var Composio = class _Composio {
6576
6660
  }
6577
6661
  telemetry.instrument(this);
6578
6662
  telemetry.instrument(this.provider);
6579
- checkForLatestVersionFromNPM(version);
6663
+ if (!this.config.disableVersionCheck) {
6664
+ checkForLatestVersionFromNPM(version);
6665
+ }
6580
6666
  }
6581
6667
  /**
6582
6668
  * Get the Composio SDK client.
@@ -6655,7 +6741,7 @@ var removeNonRequiredProperties = (schema) => {
6655
6741
  )
6656
6742
  );
6657
6743
  }
6658
- schema.additionalProperties = schema.additionalProperties ?? false;
6744
+ schema.additionalProperties = false;
6659
6745
  return schema;
6660
6746
  };
6661
6747
  function jsonSchemaToZodSchema(jsonSchema, { strict } = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/core",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -32,11 +32,11 @@
32
32
  "tsx": "^4.19.3",
33
33
  "typescript": "^5.8.3",
34
34
  "vitest": "^3.1.4",
35
- "@composio/json-schema-to-zod": "0.1.12"
35
+ "@composio/json-schema-to-zod": "0.1.13"
36
36
  },
37
37
  "dependencies": {
38
38
  "@composio/client": "0.1.0-alpha.31",
39
- "@composio/json-schema-to-zod": "0.1.12",
39
+ "@composio/json-schema-to-zod": "0.1.13",
40
40
  "@types/json-schema": "^7.0.15",
41
41
  "chalk": "^4.1.2",
42
42
  "openai": "^4.94.0",