@composio/core 0.1.25 → 0.1.27

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/index.cjs CHANGED
@@ -122,9 +122,6 @@ __export(index_exports, {
122
122
  ToolKitItemSchema: () => ToolKitItemSchema,
123
123
  ToolKitListResponseSchema: () => ToolKitListResponseSchema,
124
124
  ToolKitMetaSchema: () => ToolKitMetaSchema,
125
- ToolListFilterBySearchSchema: () => ToolListFilterBySearchSchema,
126
- ToolListFilterByToolkitsSchema: () => ToolListFilterByToolkitsSchema,
127
- ToolListFilterByToolsSchema: () => ToolListFilterByToolsSchema,
128
125
  ToolListParamsSchema: () => ToolListParamsSchema,
129
126
  ToolListResponseSchema: () => ToolListResponseSchema,
130
127
  ToolProxyParamsSchema: () => ToolProxyParamsSchema,
@@ -248,34 +245,22 @@ var ToolSchema = import_zod.z.object({
248
245
  outputParameters: ParametersSchema.optional().describe("The output parameters of the tool"),
249
246
  tags: import_zod.z.optional(import_zod.z.array(import_zod.z.string())).describe("The tags of the tool. eg: Important").default([]),
250
247
  toolkit: import_zod.z.optional(ToolkitSchema).describe("The toolkit of the tool"),
251
- version: import_zod.z.optional(import_zod.z.string()).describe('The version of the tool, e.g. "1.0.0"')
248
+ version: import_zod.z.optional(import_zod.z.string()).describe('The version of the tool, e.g. "1.0.0"'),
249
+ scopes: import_zod.z.optional(import_zod.z.array(import_zod.z.string())).describe('The scopes of the tool. eg: ["task:add"]')
252
250
  });
253
251
  var ToolListResponseSchema = import_zod.z.object({
254
252
  items: import_zod.z.array(ToolSchema),
255
253
  nextCursor: import_zod.z.string().nullable().optional(),
256
254
  totalPages: import_zod.z.number()
257
255
  });
258
- var ToolListFilterByToolsSchema = import_zod.z.object({
259
- tools: import_zod.z.array(import_zod.z.string())
260
- });
261
- var ToolListFilterByToolkitsSchema = import_zod.z.object({
262
- toolkits: import_zod.z.array(import_zod.z.string()),
263
- important: import_zod.z.boolean().optional(),
264
- cursor: import_zod.z.string().optional(),
256
+ var ToolListParamsSchema = import_zod.z.object({
257
+ tools: import_zod.z.array(import_zod.z.string()).optional(),
258
+ toolkits: import_zod.z.array(import_zod.z.string()).optional(),
259
+ scopes: import_zod.z.array(import_zod.z.string()).optional(),
260
+ tags: import_zod.z.array(import_zod.z.string()).optional(),
265
261
  limit: import_zod.z.number().optional(),
266
262
  search: import_zod.z.string().optional()
267
263
  });
268
- var ToolListFilterBySearchSchema = import_zod.z.object({
269
- search: import_zod.z.string(),
270
- toolkits: import_zod.z.array(import_zod.z.string()).optional(),
271
- cursor: import_zod.z.string().optional(),
272
- limit: import_zod.z.number().optional()
273
- });
274
- var ToolListParamsSchema = import_zod.z.union([
275
- ToolListFilterByToolsSchema,
276
- ToolListFilterByToolkitsSchema,
277
- ToolListFilterBySearchSchema
278
- ]);
279
264
  var CustomAuthParamsSchema = import_zod.z.object({
280
265
  baseURL: import_zod.z.string().optional(),
281
266
  body: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
@@ -323,6 +308,19 @@ var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"), 1);
323
308
  // src/utils/logger.ts
324
309
  var import_chalk = __toESM(require("chalk"), 1);
325
310
 
311
+ // src/utils/constants.ts
312
+ var constants_exports = {};
313
+ __export(constants_exports, {
314
+ CLIENT_PUSHER_KEY: () => CLIENT_PUSHER_KEY,
315
+ COMPOSIO_DIR: () => COMPOSIO_DIR,
316
+ COMPOSIO_LOG_LEVEL: () => COMPOSIO_LOG_LEVEL,
317
+ DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
318
+ IS_DEVELOPMENT_OR_CI: () => IS_DEVELOPMENT_OR_CI,
319
+ TELEMETRY_URL: () => TELEMETRY_URL,
320
+ TEMP_FILES_DIRECTORY_NAME: () => TEMP_FILES_DIRECTORY_NAME,
321
+ USER_DATA_FILE_NAME: () => USER_DATA_FILE_NAME
322
+ });
323
+
326
324
  // src/utils/env.ts
327
325
  var getEnvVariable = (name, defaultValue = void 0) => {
328
326
  try {
@@ -332,6 +330,16 @@ var getEnvVariable = (name, defaultValue = void 0) => {
332
330
  }
333
331
  };
334
332
 
333
+ // src/utils/constants.ts
334
+ var COMPOSIO_DIR = ".composio";
335
+ var USER_DATA_FILE_NAME = "user_data.json";
336
+ var TEMP_FILES_DIRECTORY_NAME = "files";
337
+ var DEFAULT_BASE_URL = "https://backend.composio.dev";
338
+ var TELEMETRY_URL = "https://app.composio.dev";
339
+ var CLIENT_PUSHER_KEY = getEnvVariable("CLIENT_PUSHER_KEY") || "ff9f18c208855d77a152";
340
+ var COMPOSIO_LOG_LEVEL = getEnvVariable("COMPOSIO_LOG_LEVEL");
341
+ var IS_DEVELOPMENT_OR_CI = getEnvVariable("DEVELOPMENT") || getEnvVariable("CI") || false;
342
+
335
343
  // src/utils/logger.ts
336
344
  var LOG_LEVELS = {
337
345
  silent: -1,
@@ -346,7 +354,7 @@ var LOG_LEVELS = {
346
354
  // Debug information
347
355
  };
348
356
  var getLogLevel = () => {
349
- const envLevel = getEnvVariable("COMPOSIO_LOG_LEVEL", "info")?.toLowerCase();
357
+ const envLevel = (COMPOSIO_LOG_LEVEL ?? "info")?.toLowerCase();
350
358
  return envLevel && envLevel in LOG_LEVELS ? envLevel : "info";
351
359
  };
352
360
  var Logger = class {
@@ -824,7 +832,7 @@ function getRandomUUID() {
824
832
  }
825
833
 
826
834
  // src/services/telemetry/TelemetryService.ts
827
- var TELEMETRY_URL = "https://telemetry.composio.dev/v1";
835
+ var TELEMETRY_URL2 = "https://telemetry.composio.dev/v1";
828
836
  var TelemetryService = class {
829
837
  /**
830
838
  * Sends a metric to the Telemetry API.
@@ -832,7 +840,7 @@ var TelemetryService = class {
832
840
  * @returns The response from the Telemetry API.
833
841
  */
834
842
  static async sendMetric(payload) {
835
- return fetch(`${TELEMETRY_URL}/metrics/invocations`, {
843
+ return fetch(`${TELEMETRY_URL2}/metrics/invocations`, {
836
844
  method: "POST",
837
845
  headers: {
838
846
  "Content-Type": "application/json"
@@ -846,7 +854,7 @@ var TelemetryService = class {
846
854
  * @returns The response from the Telemetry API.
847
855
  */
848
856
  static async sendErrorLog(payload) {
849
- return fetch(`${TELEMETRY_URL}/errors`, {
857
+ return fetch(`${TELEMETRY_URL2}/errors`, {
850
858
  method: "POST",
851
859
  headers: {
852
860
  "Content-Type": "application/json"
@@ -1212,8 +1220,7 @@ var AuthSchemeTypes = {
1212
1220
  NO_AUTH: "NO_AUTH",
1213
1221
  BASIC_WITH_JWT: "BASIC_WITH_JWT",
1214
1222
  COMPOSIO_LINK: "COMPOSIO_LINK",
1215
- CALCOM_AUTH: "CALCOM_AUTH",
1216
- SNOWFLAKE: "SNOWFLAKE"
1223
+ CALCOM_AUTH: "CALCOM_AUTH"
1217
1224
  };
1218
1225
  var AuthSchemeEnum = import_zod4.z.enum([
1219
1226
  "OAUTH2",
@@ -1226,8 +1233,7 @@ var AuthSchemeEnum = import_zod4.z.enum([
1226
1233
  "NO_AUTH",
1227
1234
  "BASIC_WITH_JWT",
1228
1235
  "COMPOSIO_LINK",
1229
- "CALCOM_AUTH",
1230
- "SNOWFLAKE"
1236
+ "CALCOM_AUTH"
1231
1237
  ]);
1232
1238
  var CreateCustomAuthConfigParamsSchema = import_zod4.z.object({
1233
1239
  type: import_zod4.z.literal("use_custom_auth"),
@@ -1589,21 +1595,6 @@ var CalcomAuthConnectionDataSchema = import_zod5.z.discriminatedUnion("status",
1589
1595
  expired_at: import_zod5.z.string().optional()
1590
1596
  }).catchall(import_zod5.z.unknown())
1591
1597
  ]);
1592
- var SnowflakeInitiatingSchema = BaseSchemeRaw.extend({
1593
- status: import_zod5.z.literal(ConnectionStatuses.ACTIVE)
1594
- }).catchall(import_zod5.z.unknown());
1595
- var SnowflakeConnectionDataSchema = import_zod5.z.discriminatedUnion("status", [
1596
- SnowflakeInitiatingSchema,
1597
- SnowflakeInitiatingSchema.extend({
1598
- status: import_zod5.z.literal(ConnectionStatuses.FAILED),
1599
- error: import_zod5.z.string().optional(),
1600
- error_description: import_zod5.z.string().optional()
1601
- }).catchall(import_zod5.z.unknown()),
1602
- SnowflakeInitiatingSchema.extend({
1603
- status: import_zod5.z.literal(ConnectionStatuses.EXPIRED),
1604
- expired_at: import_zod5.z.string().optional()
1605
- }).catchall(import_zod5.z.unknown())
1606
- ]);
1607
1598
  var ConnectionDataSchema = import_zod5.z.discriminatedUnion("authScheme", [
1608
1599
  import_zod5.z.object({
1609
1600
  authScheme: import_zod5.z.literal(AuthSchemeTypes.OAUTH1),
@@ -1668,13 +1659,13 @@ var ConnectionDataSchema = import_zod5.z.discriminatedUnion("authScheme", [
1668
1659
  */
1669
1660
  val: CalcomAuthConnectionDataSchema
1670
1661
  }),
1671
- import_zod5.z.object({
1672
- authScheme: import_zod5.z.literal(AuthSchemeTypes.SNOWFLAKE),
1673
- /**
1674
- * the main connection data discriminated by auth scheme
1675
- */
1676
- val: SnowflakeConnectionDataSchema
1677
- }),
1662
+ // z.object({
1663
+ // authScheme: z.literal(AuthSchemeTypes.SNOWFLAKE),
1664
+ // /**
1665
+ // * the main connection data discriminated by auth scheme
1666
+ // */
1667
+ // val: SnowflakeConnectionDataSchema,
1668
+ // }),
1678
1669
  import_zod5.z.object({
1679
1670
  authScheme: import_zod5.z.literal(AuthSchemeTypes.BILLCOM_AUTH),
1680
1671
  /**
@@ -1738,34 +1729,6 @@ var CreateConnectedAccountResponseSchema = import_zod6.z.object({
1738
1729
  status: ConnectedAccountStatusSchema,
1739
1730
  redirectUrl: import_zod6.z.string().nullable()
1740
1731
  });
1741
- var ConnectedAccountAuthSchemes = {
1742
- OAUTH1: "OAUTH1",
1743
- OAUTH2: "OAUTH2",
1744
- COMPOSIO_LINK: "COMPOSIO_LINK",
1745
- API_KEY: "API_KEY",
1746
- BASIC: "BASIC",
1747
- BEARER_TOKEN: "BEARER_TOKEN",
1748
- GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
1749
- NO_AUTH: "NO_AUTH",
1750
- CALCOM_AUTH: "CALCOM_AUTH",
1751
- SNOWFLAKE: "SNOWFLAKE",
1752
- BILLCOM_AUTH: "BILLCOM_AUTH",
1753
- BASIC_WITH_JWT: "BASIC_WITH_JWT"
1754
- };
1755
- var ConnectedAccountAuthSchemesSchema = import_zod6.z.enum([
1756
- ConnectedAccountAuthSchemes.OAUTH2,
1757
- ConnectedAccountAuthSchemes.OAUTH1,
1758
- ConnectedAccountAuthSchemes.API_KEY,
1759
- ConnectedAccountAuthSchemes.BASIC,
1760
- ConnectedAccountAuthSchemes.BILLCOM_AUTH,
1761
- ConnectedAccountAuthSchemes.BEARER_TOKEN,
1762
- ConnectedAccountAuthSchemes.GOOGLE_SERVICE_ACCOUNT,
1763
- ConnectedAccountAuthSchemes.NO_AUTH,
1764
- ConnectedAccountAuthSchemes.BASIC_WITH_JWT,
1765
- ConnectedAccountAuthSchemes.COMPOSIO_LINK,
1766
- ConnectedAccountAuthSchemes.CALCOM_AUTH,
1767
- ConnectedAccountAuthSchemes.SNOWFLAKE
1768
- ]);
1769
1732
  var ConnectedAccountAuthConfigSchema = import_zod6.z.object({
1770
1733
  id: import_zod6.z.string(),
1771
1734
  isComposioManaged: import_zod6.z.boolean(),
@@ -2236,7 +2199,7 @@ var Tools = class {
2236
2199
  * // Get tools with filters
2237
2200
  * const githubTools = await composio.tools.getRawComposioTools({
2238
2201
  * toolkits: ['github'],
2239
- * important: true
2202
+ * limit: 10
2240
2203
  * });
2241
2204
  *
2242
2205
  * // Get tools with schema transformation
@@ -2269,14 +2232,16 @@ var Tools = class {
2269
2232
  if ("tools" in queryParams.data) {
2270
2233
  limit = "9999";
2271
2234
  }
2272
- const tools = await this.client.tools.list({
2273
- tool_slugs: "tools" in queryParams.data ? queryParams.data.tools?.join(",") : void 0,
2274
- toolkit_slug: "toolkits" in queryParams.data ? queryParams.data.toolkits?.join(",") : void 0,
2275
- cursor: "cursor" in queryParams.data ? queryParams.data.cursor : void 0,
2276
- important: "important" in queryParams.data ? queryParams.data.important ? "true" : "false" : void 0,
2277
- limit,
2278
- search: "search" in queryParams.data ? queryParams.data.search : void 0
2279
- });
2235
+ const filters = {
2236
+ ..."tools" in queryParams.data ? { tool_slugs: queryParams.data.tools?.join(",") } : {},
2237
+ ..."toolkits" in queryParams.data ? { toolkit_slug: queryParams.data.toolkits?.join(",") } : {},
2238
+ ...limit ? { limit } : {},
2239
+ ..."tags" in queryParams.data ? { tags: queryParams.data.tags } : {},
2240
+ ..."scopes" in queryParams.data ? { scopes: queryParams.data.scopes } : {},
2241
+ ..."search" in queryParams.data ? { search: queryParams.data.search } : {}
2242
+ };
2243
+ logger_default.info(`Fetching tools with filters: ${JSON.stringify(filters, null, 2)}`);
2244
+ const tools = await this.client.tools.list(filters);
2280
2245
  if (!tools) {
2281
2246
  return [];
2282
2247
  }
@@ -2357,7 +2322,7 @@ var Tools = class {
2357
2322
  * @internal
2358
2323
  * @description
2359
2324
  * Creates a function that executes a tool.
2360
- * This function is used by agentic toolsets to execute the tool
2325
+ * This function is used by agentic providers to execute the tool
2361
2326
  *
2362
2327
  * @param {string} userId - The user id
2363
2328
  * @param {ExecuteToolModifiers} modifiers - The modifiers to be applied to the tool
@@ -2723,14 +2688,11 @@ var ToolkitRetrieveCategoriesResponseSchema = import_zod7.z.object({
2723
2688
  nextCursor: import_zod7.z.string().nullable(),
2724
2689
  totalPages: import_zod7.z.number()
2725
2690
  });
2726
- var ToolkitAuthFieldsResponseSchema = import_zod7.z.object({
2727
- authScheme: AuthSchemeEnum,
2728
- fields: import_zod7.z.array(
2729
- ToolkitAuthFieldSchema.extend({
2730
- required: import_zod7.z.boolean().optional()
2731
- })
2732
- )
2733
- });
2691
+ var ToolkitAuthFieldsResponseSchema = import_zod7.z.array(
2692
+ ToolkitAuthFieldSchema.extend({
2693
+ required: import_zod7.z.boolean().optional()
2694
+ })
2695
+ );
2734
2696
 
2735
2697
  // src/models/AuthConfigs.ts
2736
2698
  var AuthConfigs = class {
@@ -3292,7 +3254,6 @@ var ConnectedAccounts = class {
3292
3254
  id: authConfigId
3293
3255
  },
3294
3256
  connection: {
3295
- state: options?.config,
3296
3257
  callback_url: options?.callbackUrl,
3297
3258
  user_id: userId
3298
3259
  }
@@ -3622,43 +3583,37 @@ var Toolkits = class {
3622
3583
  }
3623
3584
  const authConfig = authScheme ? toolkit.authConfigDetails.find((authConfig2) => authConfig2.mode === authScheme) : toolkit.authConfigDetails[0];
3624
3585
  if (!authConfig) {
3625
- throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", {
3626
- meta: {
3627
- toolkitSlug,
3628
- authScheme
3586
+ throw new ComposioAuthConfigNotFoundError(
3587
+ `Auth schema ${authScheme} not found for toolkit ${toolkitSlug} with auth scheme ${authScheme}`,
3588
+ {
3589
+ meta: {
3590
+ toolkitSlug,
3591
+ authScheme
3592
+ }
3629
3593
  }
3630
- });
3594
+ );
3631
3595
  }
3632
3596
  const requiredFields = authConfig.fields[authConfigType].required.map((field) => ({
3633
3597
  ...field,
3634
3598
  required: true
3635
3599
  }));
3636
3600
  if (requiredOnly) {
3637
- return {
3638
- authScheme: AuthSchemeEnum.parse(authConfig.mode),
3639
- fields: requiredFields
3640
- };
3601
+ return requiredFields;
3641
3602
  }
3642
3603
  const optionalFields = authConfig.fields[authConfigType].optional.map((field) => ({
3643
3604
  ...field,
3644
3605
  required: false
3645
3606
  }));
3646
- return {
3647
- authScheme: AuthSchemeEnum.parse(authConfig.mode),
3648
- fields: [...requiredFields, ...optionalFields]
3649
- };
3607
+ return [...requiredFields, ...optionalFields];
3650
3608
  }
3651
3609
  /**
3652
3610
  * Retrieves the fields required for creating an auth config for a toolkit.
3653
3611
  * @param toolkitSlug - The slug of the toolkit to retrieve the fields for
3654
3612
  * @param authScheme - The auth scheme to retrieve the fields for
3655
- * @param requiredOnly - Whether to only return the required fields
3613
+ * @param options.requiredOnly - Whether to only return the required fields
3656
3614
  * @returns {Promise<ToolkitAuthFieldsResponse>} The fields required for creating an auth config
3657
3615
  */
3658
- async getAuthConfigCreationFields(toolkitSlug, {
3659
- authScheme,
3660
- requiredOnly = false
3661
- } = {}) {
3616
+ async getAuthConfigCreationFields(toolkitSlug, authScheme, { requiredOnly = false } = {}) {
3662
3617
  return this.getAuthConfigFields(
3663
3618
  toolkitSlug,
3664
3619
  authScheme ?? null,
@@ -3670,13 +3625,10 @@ var Toolkits = class {
3670
3625
  * Retrieves the fields required for initiating a connected account for a toolkit.
3671
3626
  * @param toolkitSlug - The slug of the toolkit to retrieve the fields for
3672
3627
  * @param authScheme - The auth scheme to retrieve the fields for
3673
- * @param requiredOnly - Whether to only return the required fields
3628
+ * @param options.requiredOnly - Whether to only return the required fields
3674
3629
  * @returns {Promise<ToolkitAuthFieldsResponse>} The fields required for initiating a connected account
3675
3630
  */
3676
- async getConnectedAccountInitiationFields(toolkitSlug, {
3677
- authScheme,
3678
- requiredOnly = false
3679
- } = {}) {
3631
+ async getConnectedAccountInitiationFields(toolkitSlug, authScheme, { requiredOnly = false } = {}) {
3680
3632
  return this.getAuthConfigFields(
3681
3633
  toolkitSlug,
3682
3634
  authScheme ?? null,
@@ -5177,23 +5129,6 @@ var MCP = class {
5177
5129
  }
5178
5130
  };
5179
5131
 
5180
- // src/utils/constants.ts
5181
- var constants_exports = {};
5182
- __export(constants_exports, {
5183
- COMPOSIO_DIR: () => COMPOSIO_DIR,
5184
- DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
5185
- IS_DEVELOPMENT_OR_CI: () => IS_DEVELOPMENT_OR_CI,
5186
- TELEMETRY_URL: () => TELEMETRY_URL2,
5187
- TEMP_FILES_DIRECTORY_NAME: () => TEMP_FILES_DIRECTORY_NAME,
5188
- USER_DATA_FILE_NAME: () => USER_DATA_FILE_NAME
5189
- });
5190
- var COMPOSIO_DIR = ".composio";
5191
- var USER_DATA_FILE_NAME = "user_data.json";
5192
- var TEMP_FILES_DIRECTORY_NAME = "files";
5193
- var DEFAULT_BASE_URL = "https://backend.composio.dev";
5194
- var TELEMETRY_URL2 = "https://app.composio.dev";
5195
- var IS_DEVELOPMENT_OR_CI = process.env.DEVELOPMENT || process.env.CI || false;
5196
-
5197
5132
  // src/utils/sdk.ts
5198
5133
  var userDataPath = () => {
5199
5134
  try {
@@ -5740,7 +5675,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5740
5675
  };
5741
5676
 
5742
5677
  // package.json
5743
- var version = "0.1.25";
5678
+ var version = "0.1.27";
5744
5679
 
5745
5680
  // src/composio.ts
5746
5681
  var Composio = class _Composio {
@@ -5809,7 +5744,7 @@ var Composio = class _Composio {
5809
5744
  apiKey: apiKeyParsed,
5810
5745
  baseURL: baseURLParsed,
5811
5746
  defaultHeaders: config?.defaultHeaders,
5812
- logLevel: process.env.COMPOSIO_LOG_LEVEL ?? void 0
5747
+ logLevel: COMPOSIO_LOG_LEVEL
5813
5748
  });
5814
5749
  this.config = {
5815
5750
  ...config,
@@ -6079,19 +6014,6 @@ var AuthScheme = class {
6079
6014
  }
6080
6015
  };
6081
6016
  }
6082
- /**
6083
- * Creates a ConnectionData object for Snowflake authentication
6084
- * @returns ConnectionData object
6085
- */
6086
- static Snowflake(params) {
6087
- return {
6088
- authScheme: AuthSchemeTypes.SNOWFLAKE,
6089
- val: {
6090
- status: ConnectionStatuses.ACTIVE,
6091
- ...params
6092
- }
6093
- };
6094
- }
6095
6017
  /**
6096
6018
  * Creates a ConnectionData object for Bill.com authentication
6097
6019
  * @param params The Bill.com auth parameters
@@ -6201,9 +6123,6 @@ var AuthScheme = class {
6201
6123
  ToolKitItemSchema,
6202
6124
  ToolKitListResponseSchema,
6203
6125
  ToolKitMetaSchema,
6204
- ToolListFilterBySearchSchema,
6205
- ToolListFilterByToolkitsSchema,
6206
- ToolListFilterByToolsSchema,
6207
6126
  ToolListParamsSchema,
6208
6127
  ToolListResponseSchema,
6209
6128
  ToolProxyParamsSchema,