@composio/core 0.1.0-rc.7 → 0.1.4-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -35,8 +35,8 @@ var ToolListParamsSchema = z.object({
35
35
  important: z.string().optional(),
36
36
  limit: z.string().optional(),
37
37
  search: z.string().optional(),
38
- toolkitSlug: z.string().optional(),
39
- toolSlugs: z.array(z.string()).optional()
38
+ toolkits: z.string().optional(),
39
+ tools: z.array(z.string()).optional()
40
40
  });
41
41
  var CustomAuthParamsSchema = z.object({
42
42
  baseURL: z.string().optional(),
@@ -400,15 +400,15 @@ var Tools = class {
400
400
  important: queryParams.data.important,
401
401
  limit: queryParams.data.limit,
402
402
  search: queryParams.data.search,
403
- toolkit_slug: queryParams.data.toolkitSlug,
404
- tool_slugs: queryParams.data.toolSlugs?.join(",")
403
+ toolkit_slug: queryParams.data.toolkits,
404
+ tool_slugs: queryParams.data.tools?.join(",")
405
405
  });
406
406
  if (!tools) {
407
407
  return [];
408
408
  }
409
409
  const caseTransformedTools = tools.items.map((tool) => this.transformToolCases(tool));
410
410
  const customTools = await this.customTools.getCustomTools({
411
- toolSlugs: queryParams.data.toolSlugs
411
+ toolSlugs: queryParams.data.tools
412
412
  });
413
413
  let modifiedTools = [...caseTransformedTools, ...customTools];
414
414
  if (modifier) {
@@ -446,13 +446,36 @@ var Tools = class {
446
446
  }
447
447
  return modifiedToool;
448
448
  }
449
- async get(userId, arg1, options) {
450
- if (typeof arg1 === "string") {
451
- return this.toolset.getToolBySlug(userId, arg1, options);
449
+ async get(userId, arg2, options) {
450
+ const executeToolFn = this.createExecuteToolFn(userId, options);
451
+ if (typeof arg2 === "string") {
452
+ const tool = await this.getComposioToolBySlug(userId, arg2, options?.modifyToolSchema);
453
+ return this.toolset.wrapTool(tool, executeToolFn);
452
454
  } else {
453
- return this.toolset.getTools(userId, arg1, options);
455
+ const tools = await this.getComposioTools(userId, arg2, options?.modifyToolSchema);
456
+ return this.toolset.wrapTools(tools, executeToolFn);
454
457
  }
455
458
  }
459
+ /**
460
+ * Creates a function that executes a tool.
461
+ * This function is used by agentic the toolsets to execute the tool
462
+ * @param {string} userId - The user id
463
+ * @param {ExecuteToolModifiers} modifiers - The modifiers to be applied to the tool
464
+ * @returns {ExecuteToolFn} The execute tool function
465
+ */
466
+ createExecuteToolFn(userId, modifiers) {
467
+ const executeToolFn = async (toolSlug, input) => {
468
+ return await this.execute(
469
+ toolSlug,
470
+ {
471
+ userId,
472
+ arguments: input
473
+ },
474
+ modifiers
475
+ );
476
+ };
477
+ return executeToolFn;
478
+ }
456
479
  /**
457
480
  * Exectes a given tool with the provided parameters.
458
481
  *
@@ -542,6 +565,87 @@ var Tools = class {
542
565
  }
543
566
  };
544
567
 
568
+ // src/types/toolkit.types.ts
569
+ import { z as z2 } from "zod";
570
+ var ToolkitMangedByEnumSchema = z2.enum(["all", "composio_managed", "project_managed"]);
571
+ var ToolkitSortByEnumSchema = z2.enum(["usage", "alphabetically"]);
572
+ var ToolkitsListParamsSchema = z2.object({
573
+ category: z2.string().optional(),
574
+ isLocal: z2.boolean().optional(),
575
+ managedBy: ToolkitMangedByEnumSchema.optional(),
576
+ sortBy: ToolkitSortByEnumSchema.optional()
577
+ });
578
+ var ToolKitMetaSchema = z2.object({
579
+ categories: z2.array(
580
+ z2.object({
581
+ id: z2.string(),
582
+ name: z2.string()
583
+ })
584
+ ),
585
+ createdAt: z2.string(),
586
+ description: z2.string(),
587
+ logo: z2.string(),
588
+ toolsCount: z2.number(),
589
+ triggersCount: z2.number(),
590
+ updatedAt: z2.string()
591
+ });
592
+ var ToolKitItemSchema = z2.object({
593
+ name: z2.string(),
594
+ slug: z2.string(),
595
+ meta: ToolKitMetaSchema,
596
+ isLocalToolkit: z2.boolean(),
597
+ authSchemes: z2.array(z2.string()).optional(),
598
+ composioManagedAuthSchemes: z2.array(z2.string()).optional(),
599
+ noAuth: z2.boolean().optional()
600
+ });
601
+ var ToolKitListResponseSchema = z2.object({
602
+ items: z2.array(ToolKitItemSchema),
603
+ nextCursor: z2.string().nullable(),
604
+ totalPages: z2.number()
605
+ });
606
+ var ToolkitAuthFieldSchema = z2.object({
607
+ name: z2.string(),
608
+ displayName: z2.string(),
609
+ type: z2.string(),
610
+ default: z2.string().nullable().optional()
611
+ });
612
+ var ToolkitAuthConfigDetailsSchema = z2.object({
613
+ name: z2.string(),
614
+ mode: z2.string(),
615
+ fields: z2.array(
616
+ z2.object({
617
+ authConfigCreation: z2.object({
618
+ optional: z2.array(ToolkitAuthFieldSchema),
619
+ required: z2.array(ToolkitAuthFieldSchema)
620
+ }),
621
+ connectedAccountInitiation: z2.object({
622
+ optional: z2.array(ToolkitAuthFieldSchema),
623
+ required: z2.array(ToolkitAuthFieldSchema)
624
+ })
625
+ })
626
+ ),
627
+ proxy: z2.object({
628
+ baseUrul: z2.string()
629
+ })
630
+ });
631
+ var ToolkitRetrieveResponseSchema = z2.object({
632
+ name: z2.string(),
633
+ slug: z2.string(),
634
+ meta: ToolKitMetaSchema,
635
+ isLocalToolkit: z2.boolean(),
636
+ composioManagedAuthSchemes: z2.array(z2.string()).optional(),
637
+ authConfigDetails: z2.array(ToolkitAuthConfigDetailsSchema).optional()
638
+ });
639
+ var ToolkitCategorySchema = z2.object({
640
+ id: z2.string(),
641
+ name: z2.string()
642
+ });
643
+ var ToolkitRetrieveCategoriesResponseSchema = z2.object({
644
+ items: z2.array(ToolkitCategorySchema),
645
+ nextCursor: z2.string().nullable(),
646
+ totalPages: z2.number()
647
+ });
648
+
545
649
  // src/models/Toolkits.ts
546
650
  var Toolkits = class {
547
651
  client;
@@ -553,8 +657,31 @@ var Toolkits = class {
553
657
  * This method fetches the toolkits from the Composio API.
554
658
  * @returns {Promise<Toolkit[]>} List of toolkits
555
659
  */
556
- async getToolkits(query, options) {
557
- return this.client.toolkits.list(query, options);
660
+ async getToolkits(query) {
661
+ const parsedQuery = ToolkitsListParamsSchema.parse(query);
662
+ const result = await this.client.toolkits.list({
663
+ category: parsedQuery.category,
664
+ is_local: parsedQuery.isLocal,
665
+ managed_by: parsedQuery.managedBy,
666
+ sort_by: parsedQuery.sortBy
667
+ });
668
+ const parsedResult = ToolKitListResponseSchema.parse({
669
+ items: result.items.map((item) => {
670
+ const parsedItem = ToolKitItemSchema.parse({
671
+ name: item.name,
672
+ slug: item.slug,
673
+ meta: item.meta,
674
+ isLocalToolkit: item.is_local_toolkit,
675
+ authSchemes: item.auth_schemes,
676
+ composioManagedAuthSchemes: item.composio_managed_auth_schemes,
677
+ noAuth: item.no_auth
678
+ });
679
+ return parsedItem;
680
+ }),
681
+ nextCursor: result.next_cursor,
682
+ totalPages: result.total_pages
683
+ });
684
+ return parsedResult;
558
685
  }
559
686
  /**
560
687
  * Fetches a toolkit by its Slug.
@@ -563,16 +690,49 @@ var Toolkits = class {
563
690
  * @param options - Request options
564
691
  * @returns {Promise<ToolkitRetrieveResponse>} The toolkit object
565
692
  */
566
- async getToolkitBySlug(slug, options) {
567
- return this.client.toolkits.retrieve(slug, options);
693
+ async getToolkitBySlug(slug) {
694
+ const result = await this.client.toolkits.retrieve(slug);
695
+ const parsedResult = ToolkitRetrieveResponseSchema.parse({
696
+ name: result.name,
697
+ slug: result.slug,
698
+ meta: result.meta,
699
+ isLocalToolkit: result.is_local_toolkit,
700
+ composioManagedAuthSchemes: result.composio_managed_auth_schemes,
701
+ authConfigDetails: result.auth_config_details
702
+ });
703
+ return parsedResult;
704
+ }
705
+ /**
706
+ * Fetches a toolkit by its Slug or a list of toolkits.
707
+ * This method retrieves the toolkit from the Composio API.
708
+ * @param arg - The ID of the toolkit to be retrieved or a list of parameters
709
+ * @returns {Promise<ToolkitRetrieveResponse | ToolKitListResponse>} The toolkit object or a list of toolkits
710
+ */
711
+ async get(arg) {
712
+ if (typeof arg === "string") {
713
+ return this.getToolkitBySlug(arg);
714
+ }
715
+ return this.getToolkits(arg);
568
716
  }
569
717
  /**
570
718
  * Fetches all categories available in the Composio SDK
571
719
  *
572
720
  * @returns {Promise<ToolkitRetrieveCategoriesResponse>} List of categories
573
721
  */
574
- async listCategories(options) {
575
- return this.client.toolkits.retrieveCategories(options);
722
+ async listCategories() {
723
+ const result = await this.client.toolkits.retrieveCategories();
724
+ const parsedResult = ToolkitRetrieveCategoriesResponseSchema.parse({
725
+ items: result.items.map((item) => {
726
+ const parsedItem = ToolkitCategorySchema.parse({
727
+ id: item.id,
728
+ name: item.name
729
+ });
730
+ return parsedItem;
731
+ }),
732
+ nextCursor: result.next_cursor,
733
+ totalPages: result.total_pages
734
+ });
735
+ return parsedResult;
576
736
  }
577
737
  };
578
738
 
@@ -901,7 +1061,7 @@ var AuthConfigs = class {
901
1061
  };
902
1062
 
903
1063
  // src/types/connectedAccounts.types.ts
904
- import { z as z2 } from "zod";
1064
+ import { z as z3 } from "zod";
905
1065
  var ConnectedAccountStatuses = {
906
1066
  ACTIVE: "ACTIVE",
907
1067
  INACTIVE: "INACTIVE",
@@ -910,7 +1070,7 @@ var ConnectedAccountStatuses = {
910
1070
  EXPIRED: "EXPIRED",
911
1071
  FAILED: "FAILED"
912
1072
  };
913
- var ConnectedAccountStatusSchema = z2.enum([
1073
+ var ConnectedAccountStatusSchema = z3.enum([
914
1074
  ConnectedAccountStatuses.ACTIVE,
915
1075
  ConnectedAccountStatuses.INACTIVE,
916
1076
  ConnectedAccountStatuses.PENDING,
@@ -918,20 +1078,34 @@ var ConnectedAccountStatusSchema = z2.enum([
918
1078
  ConnectedAccountStatuses.EXPIRED,
919
1079
  ConnectedAccountStatuses.FAILED
920
1080
  ]);
921
- var CreateConnectedAccountParamsSchema = z2.object({
922
- authConfig: z2.object({
923
- id: z2.string()
1081
+ var CreateConnectedAccountParamsSchema = z3.object({
1082
+ authConfig: z3.object({
1083
+ id: z3.string()
924
1084
  }),
925
- connection: z2.object({
926
- data: z2.record(z2.string(), z2.unknown()).optional(),
927
- rediretUrl: z2.string().optional(),
928
- userId: z2.string().optional()
1085
+ connection: z3.object({
1086
+ data: z3.record(z3.string(), z3.unknown()).optional(),
1087
+ redirectUrl: z3.string().optional(),
1088
+ userId: z3.string().optional()
929
1089
  })
930
1090
  });
931
- var CreateConnectedAccountResponseSchema = z2.object({
932
- id: z2.string(),
1091
+ var DefaultCreateConnectedAccountParamsSchema = z3.object({
1092
+ auth_config: z3.object({
1093
+ id: z3.string()
1094
+ }),
1095
+ connection: z3.object({
1096
+ data: z3.record(z3.string(), z3.unknown()).optional(),
1097
+ redirect_uri: z3.string().optional(),
1098
+ user_id: z3.string().optional()
1099
+ })
1100
+ });
1101
+ var CreateConnectedAccountOptionsSchema = z3.object({
1102
+ redirectUrl: z3.string().optional(),
1103
+ data: z3.record(z3.string(), z3.unknown()).optional()
1104
+ });
1105
+ var CreateConnectedAccountResponseSchema = z3.object({
1106
+ id: z3.string(),
933
1107
  status: ConnectedAccountStatusSchema,
934
- redirectUrl: z2.string().nullable()
1108
+ redirectUrl: z3.string().nullable()
935
1109
  });
936
1110
  var ConnectedAccountAuthSchemes = {
937
1111
  OAUTH2: "OAUTH2",
@@ -948,7 +1122,7 @@ var ConnectedAccountAuthSchemes = {
948
1122
  CALCOM_AUTH: "CALCOM_AUTH",
949
1123
  SNOWFLAKE: "SNOWFLAKE"
950
1124
  };
951
- var ConnectedAccountAuthSchemesSchema = z2.enum([
1125
+ var ConnectedAccountAuthSchemesSchema = z3.enum([
952
1126
  ConnectedAccountAuthSchemes.OAUTH2,
953
1127
  ConnectedAccountAuthSchemes.OAUTH1,
954
1128
  ConnectedAccountAuthSchemes.OAUTH1A,
@@ -963,28 +1137,28 @@ var ConnectedAccountAuthSchemesSchema = z2.enum([
963
1137
  ConnectedAccountAuthSchemes.CALCOM_AUTH,
964
1138
  ConnectedAccountAuthSchemes.SNOWFLAKE
965
1139
  ]);
966
- var ConnectedAccountAuthConfigSchema = z2.object({
967
- id: z2.string(),
1140
+ var ConnectedAccountAuthConfigSchema = z3.object({
1141
+ id: z3.string(),
968
1142
  authScheme: ConnectedAccountAuthSchemesSchema,
969
- isComposioManaged: z2.boolean(),
970
- isDisabled: z2.boolean()
1143
+ isComposioManaged: z3.boolean(),
1144
+ isDisabled: z3.boolean()
971
1145
  });
972
- var ConnectedAccountRetrieveResponseSchema = z2.object({
973
- id: z2.string(),
974
- uuid: z2.string(),
1146
+ var ConnectedAccountRetrieveResponseSchema = z3.object({
1147
+ id: z3.string(),
1148
+ uuid: z3.string(),
975
1149
  authConfig: ConnectedAccountAuthConfigSchema,
976
- userId: z2.string(),
977
- data: z2.record(z2.string(), z2.unknown()),
978
- params: z2.record(z2.string(), z2.unknown()),
1150
+ userId: z3.string(),
1151
+ data: z3.record(z3.string(), z3.unknown()),
1152
+ params: z3.record(z3.string(), z3.unknown()),
979
1153
  status: ConnectedAccountStatusSchema,
980
- statusReason: z2.string().nullable(),
981
- toolkit: z2.object({
982
- slug: z2.string()
1154
+ statusReason: z3.string().nullable(),
1155
+ toolkit: z3.object({
1156
+ slug: z3.string()
983
1157
  }),
984
- testRequestEndpoint: z2.string().optional(),
985
- isDisabled: z2.boolean(),
986
- createdAt: z2.string(),
987
- updatedAt: z2.string()
1158
+ testRequestEndpoint: z3.string().optional(),
1159
+ isDisabled: z3.boolean(),
1160
+ createdAt: z3.string(),
1161
+ updatedAt: z3.string()
988
1162
  });
989
1163
 
990
1164
  // src/models/ConnectionRequest.ts
@@ -1004,7 +1178,7 @@ var ConnectionRequest = class {
1004
1178
  * @returns
1005
1179
  */
1006
1180
  async transformResponse(response) {
1007
- return {
1181
+ const parsedResponse = ConnectedAccountRetrieveResponseSchema.parse({
1008
1182
  ...response,
1009
1183
  userId: response.user_id,
1010
1184
  // Add the missing userId property
@@ -1019,7 +1193,8 @@ var ConnectionRequest = class {
1019
1193
  createdAt: response.created_at,
1020
1194
  updatedAt: response.updated_at,
1021
1195
  testRequestEndpoint: response.test_request_endpoint
1022
- };
1196
+ });
1197
+ return parsedResponse;
1023
1198
  }
1024
1199
  /**
1025
1200
  * Wait for the connection to be established.
@@ -1065,8 +1240,8 @@ var ConnectedAccounts = class {
1065
1240
  * @param {RequestOptions} options - Request options
1066
1241
  * @returns {Promise<ConnectedAccountListResponse>} List of connected accounts
1067
1242
  */
1068
- async list(query, options) {
1069
- return this.client.connectedAccounts.list(query, options);
1243
+ async list(query) {
1244
+ return this.client.connectedAccounts.list(query);
1070
1245
  }
1071
1246
  /**
1072
1247
  * Create a new connected account
@@ -1074,8 +1249,8 @@ var ConnectedAccounts = class {
1074
1249
  * @param {RequestOptions} options - Request options
1075
1250
  * @returns {Promise<ConnectedAccountCreateResponse>} Created connected account
1076
1251
  */
1077
- async create(data, options) {
1078
- return this.client.connectedAccounts.create(data, options);
1252
+ async create(data) {
1253
+ return this.client.connectedAccounts.create(data);
1079
1254
  }
1080
1255
  /**
1081
1256
  * Get a connected account by nanoid
@@ -1083,8 +1258,8 @@ var ConnectedAccounts = class {
1083
1258
  * @param {RequestOptions} options - Request options
1084
1259
  * @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
1085
1260
  */
1086
- async get(nanoid, options) {
1087
- return this.client.connectedAccounts.retrieve(nanoid, options);
1261
+ async get(nanoid) {
1262
+ return this.client.connectedAccounts.retrieve(nanoid);
1088
1263
  }
1089
1264
  /**
1090
1265
  * Delete a connected account
@@ -1092,8 +1267,8 @@ var ConnectedAccounts = class {
1092
1267
  * @param {RequestOptions} options - Request options
1093
1268
  * @returns {Promise<ConnectedAccountDeleteResponse>} Response from deletion
1094
1269
  */
1095
- async delete(nanoid, options) {
1096
- return this.client.connectedAccounts.delete(nanoid, options);
1270
+ async delete(nanoid) {
1271
+ return this.client.connectedAccounts.delete(nanoid);
1097
1272
  }
1098
1273
  /**
1099
1274
  * Refresh a connected account's credentials
@@ -1101,8 +1276,8 @@ var ConnectedAccounts = class {
1101
1276
  * @param {RequestOptions} options - Request options
1102
1277
  * @returns {Promise<ConnectedAccountRefreshResponse>} Refreshed connected account details
1103
1278
  */
1104
- async refresh(nanoid, options) {
1105
- return this.client.connectedAccounts.refresh(nanoid, options);
1279
+ async refresh(nanoid) {
1280
+ return this.client.connectedAccounts.refresh(nanoid);
1106
1281
  }
1107
1282
  /**
1108
1283
  * Update the status of a connected account
@@ -1111,8 +1286,8 @@ var ConnectedAccounts = class {
1111
1286
  * @param {RequestOptions} options - Request options
1112
1287
  * @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
1113
1288
  */
1114
- async updateStatus(nanoid, params, options) {
1115
- return this.client.connectedAccounts.updateStatus(nanoid, params, options);
1289
+ async updateStatus(nanoid, params) {
1290
+ return this.client.connectedAccounts.updateStatus(nanoid, params);
1116
1291
  }
1117
1292
  /**
1118
1293
  * Enable a connected account
@@ -1120,8 +1295,8 @@ var ConnectedAccounts = class {
1120
1295
  * @param {RequestOptions} options - Request options
1121
1296
  * @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
1122
1297
  */
1123
- async enable(nanoid, options) {
1124
- return this.client.connectedAccounts.updateStatus(nanoid, { enabled: true }, options);
1298
+ async enable(nanoid) {
1299
+ return this.client.connectedAccounts.updateStatus(nanoid, { enabled: true });
1125
1300
  }
1126
1301
  /**
1127
1302
  * Disable a connected account
@@ -1129,8 +1304,8 @@ var ConnectedAccounts = class {
1129
1304
  * @param {RequestOptions} options - Request options
1130
1305
  * @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
1131
1306
  */
1132
- async disable(nanoid, options) {
1133
- return this.client.connectedAccounts.updateStatus(nanoid, { enabled: false }, options);
1307
+ async disable(nanoid) {
1308
+ return this.client.connectedAccounts.updateStatus(nanoid, { enabled: false });
1134
1309
  }
1135
1310
  /**
1136
1311
  * Compound function to create a new connected account.
@@ -1139,16 +1314,16 @@ var ConnectedAccounts = class {
1139
1314
  * @param {CreateConnectedAccountParams} data - Data for creating a new connected account
1140
1315
  * @returns {Promise<ConnectionRequest>} Connection request object
1141
1316
  */
1142
- async createConnectedAccount(data) {
1143
- const { authConfig, connection } = data;
1317
+ async createConnectedAccount(userId, authConfigId, options) {
1318
+ const { redirectUrl, data } = options;
1144
1319
  const response = await this.create({
1145
1320
  auth_config: {
1146
- id: authConfig.id
1321
+ id: authConfigId
1147
1322
  },
1148
1323
  connection: {
1149
- data: connection.data,
1150
- redirect_uri: connection.rediretUrl,
1151
- user_id: connection.userId
1324
+ data,
1325
+ redirect_uri: redirectUrl,
1326
+ user_id: userId
1152
1327
  }
1153
1328
  });
1154
1329
  return new ConnectionRequest(this.client, response.id, response.status);
@@ -1438,37 +1613,44 @@ async function checkForLatestVersionFromNPM(currentVersion) {
1438
1613
  }
1439
1614
 
1440
1615
  // src/toolset/BaseToolset.ts
1441
- var BaseNonAgenticToolset = class {
1442
- composio;
1443
- setComposio(composio) {
1444
- this.composio = composio;
1445
- }
1446
- getComposio() {
1447
- if (!this.composio) {
1448
- throw new Error(
1449
- "Client not initialized. Make sure the toolset is properly initialized with Composio."
1450
- );
1451
- }
1452
- return this.composio;
1616
+ var BaseToolset = class {
1617
+ /**
1618
+ * @internal
1619
+ * The function to execute a tool.
1620
+ * This is set automatically injected by the core SDK.
1621
+ */
1622
+ _globalExecuteToolFn;
1623
+ /**
1624
+ * @internal
1625
+ * Set the function to execute a tool.
1626
+ * This is set automatically injected by the core SDK.
1627
+ */
1628
+ _setExecuteToolFn(executeToolFn) {
1629
+ this._globalExecuteToolFn = executeToolFn;
1453
1630
  }
1454
- };
1455
- var BaseAgenticToolset = class {
1456
- composio;
1457
- setComposio(composio) {
1458
- this.composio = composio;
1459
- }
1460
- getComposio() {
1461
- if (!this.composio) {
1462
- throw new Error(
1463
- "Client not initialized. Make sure the toolset is properly initialized with Composio."
1464
- );
1465
- }
1466
- return this.composio;
1631
+ /**
1632
+ * @public
1633
+ * Gloabl function to execute a tool.
1634
+ * This function is used by toolset providers to implement helper functions to execute tools.
1635
+ * This is a 1:1 mapping of the `execute` method in the `Tools` class.
1636
+ * @param {string} toolSlug - The slug of the tool to execute.
1637
+ * @param {Record<string, unknown>} input - The input to the tool.
1638
+ * @returns {Promise<string>} The result of the tool execution.
1639
+ */
1640
+ executeTool(toolSlug, body, modifers) {
1641
+ return this._globalExecuteToolFn(toolSlug, body, modifers);
1467
1642
  }
1468
1643
  };
1644
+ var BaseNonAgenticToolset = class extends BaseToolset {
1645
+ _isAgentic = false;
1646
+ };
1647
+ var BaseAgenticToolset = class extends BaseToolset {
1648
+ _isAgentic = true;
1649
+ };
1469
1650
 
1470
1651
  // src/toolset/OpenAIToolset.ts
1471
1652
  var OpenAIToolset = class extends BaseNonAgenticToolset {
1653
+ name = "openai";
1472
1654
  /**
1473
1655
  * Absract method to wrap a tool in the toolset.
1474
1656
  * This method is implemented by the toolset.
@@ -1486,49 +1668,24 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1486
1668
  function: formattedSchema
1487
1669
  };
1488
1670
  };
1489
- /**
1490
- * Get all the tools from the Composio in OpenAI format.
1491
- * @param params - The parameters for the tool list.
1492
- * @param modifiers - Optional modifiers to transform tool schemas
1493
- * @returns The tools.
1494
- */
1495
- async getTools(userId, params, modifiers) {
1496
- const tools = await this.getComposio()?.tools.getComposioTools(
1497
- userId,
1498
- params,
1499
- modifiers?.modifyToolSchema
1500
- );
1501
- return tools?.map((tool) => this.wrapTool(tool)) ?? [];
1502
- }
1503
- async getToolBySlug(userId, slug, modifiers) {
1504
- const tool = await this.getComposio().tools.getComposioToolBySlug(
1505
- userId,
1506
- slug,
1507
- modifiers?.modifyToolSchema
1508
- );
1509
- return this.wrapTool(tool);
1510
- }
1671
+ wrapTools = (tools) => {
1672
+ return tools.map((tool) => this.wrapTool(tool));
1673
+ };
1511
1674
  /**
1512
1675
  * Execute a tool call.
1513
1676
  * @param {OpenAI.ChatCompletionMessageToolCall} tool - The tool to execute.
1514
1677
  * @param {string} userId - The user id.
1515
1678
  * @returns {Promise<string>} The result of the tool call.
1516
1679
  */
1517
- async executeToolCall(userId, tool, modifiers) {
1518
- const toolSchema = await this.getComposio().tools.getComposioToolBySlug(
1519
- userId,
1520
- tool.function.name
1521
- );
1522
- const appSlug = toolSchema?.toolkit?.slug.toLowerCase();
1523
- if (!appSlug) {
1524
- throw new Error("App slug not found");
1525
- }
1680
+ async executeToolCall(userId, tool, options, modifiers) {
1526
1681
  const payload = {
1527
- userId,
1528
- arguments: JSON.parse(tool.function.arguments)
1682
+ arguments: JSON.parse(tool.function.arguments),
1683
+ connectedAccountId: options.connectedAccountId,
1684
+ customAuthParams: options.customAuthParams,
1685
+ userId
1529
1686
  };
1530
- const results = await this.getComposio().tools.execute(toolSchema.slug, payload, modifiers);
1531
- return JSON.stringify(results);
1687
+ const result = await this.executeTool(tool.function.name, payload, modifiers);
1688
+ return JSON.stringify(result);
1532
1689
  }
1533
1690
  /**
1534
1691
  * Handle the tool call from the assistant.
@@ -1537,11 +1694,13 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1537
1694
  * @param {string} userId - The user id.
1538
1695
  * @returns {Promise<string[]>} The results of the tool call.
1539
1696
  */
1540
- async handleToolCall(userId, chatCompletion, modifiers) {
1697
+ async handleToolCall(userId, chatCompletion, options, modifiers) {
1541
1698
  const outputs = [];
1542
1699
  for (const message of chatCompletion.choices) {
1543
1700
  if (message.message.tool_calls) {
1544
- outputs.push(await this.executeToolCall(userId, message.message.tool_calls[0], modifiers));
1701
+ outputs.push(
1702
+ await this.executeToolCall(userId, message.message.tool_calls[0], options, modifiers)
1703
+ );
1545
1704
  }
1546
1705
  }
1547
1706
  return outputs;
@@ -1553,7 +1712,7 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1553
1712
  * @param {string} userId - The user id.
1554
1713
  * @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} The tool outputs.
1555
1714
  */
1556
- async handleAssistantMessage(userId, run, modifiers) {
1715
+ async handleAssistantMessage(userId, run, options, modifiers) {
1557
1716
  const tool_calls = run.required_action?.submit_tool_outputs?.tool_calls || [];
1558
1717
  const tool_outputs = await Promise.all(
1559
1718
  tool_calls.map(async (tool_call) => {
@@ -1561,6 +1720,7 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1561
1720
  const tool_response = await this.executeToolCall(
1562
1721
  userId,
1563
1722
  tool_call,
1723
+ options,
1564
1724
  modifiers
1565
1725
  );
1566
1726
  logger_default.debug(`Tool call ${tool_call.id} executed with response: ${tool_response}`);
@@ -1581,7 +1741,7 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1581
1741
  * @param {string} userId - The user id.
1582
1742
  * @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} The run stream.
1583
1743
  */
1584
- async *waitAndHandleAssistantStreamToolCalls(userId, client, runStream, thread, modifiers) {
1744
+ async *waitAndHandleAssistantStreamToolCalls(userId, client, runStream, thread, options, modifiers) {
1585
1745
  let runId = null;
1586
1746
  for await (const event of runStream) {
1587
1747
  yield event;
@@ -1593,7 +1753,12 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1593
1753
  continue;
1594
1754
  }
1595
1755
  if (event.event === "thread.run.requires_action") {
1596
- const toolOutputs = await this.handleAssistantMessage(userId, event.data, modifiers);
1756
+ const toolOutputs = await this.handleAssistantMessage(
1757
+ userId,
1758
+ event.data,
1759
+ options,
1760
+ modifiers
1761
+ );
1597
1762
  await client.beta.threads.runs.submitToolOutputs(thread.id, runId, {
1598
1763
  tool_outputs: toolOutputs
1599
1764
  });
@@ -1613,7 +1778,7 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1613
1778
  let finalRun = await client.beta.threads.runs.retrieve(thread.id, runId);
1614
1779
  while (["queued", "in_progress", "requires_action"].includes(finalRun.status)) {
1615
1780
  if (finalRun.status === "requires_action") {
1616
- const toolOutputs = await this.handleAssistantMessage(userId, finalRun, modifiers);
1781
+ const toolOutputs = await this.handleAssistantMessage(userId, finalRun, options, modifiers);
1617
1782
  finalRun = await client.beta.threads.runs.submitToolOutputs(thread.id, runId, {
1618
1783
  tool_outputs: toolOutputs
1619
1784
  });
@@ -1632,9 +1797,9 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1632
1797
  * @param {string} userId - The user id.
1633
1798
  * @returns {Promise<OpenAI.Beta.Threads.Run>} The run object.
1634
1799
  */
1635
- async waitAndHandleAssistantToolCalls(userId, client, run, thread, modifiers) {
1800
+ async waitAndHandleAssistantToolCalls(userId, client, run, thread, options, modifiers) {
1636
1801
  while (["queued", "in_progress", "requires_action"].includes(run.status)) {
1637
- const tool_outputs = await this.handleAssistantMessage(userId, run, modifiers);
1802
+ const tool_outputs = await this.handleAssistantMessage(userId, run, options, modifiers);
1638
1803
  if (run.status === "requires_action") {
1639
1804
  run = await client.beta.threads.runs.submitToolOutputs(thread.id, run.id, {
1640
1805
  tool_outputs
@@ -1649,7 +1814,7 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1649
1814
  };
1650
1815
 
1651
1816
  // package.json
1652
- var version = "0.1.0-rc.7";
1817
+ var version = "0.1.3-alpha.0";
1653
1818
 
1654
1819
  // src/utils/uuid.ts
1655
1820
  import { v4 as uuidv4 } from "uuid";
@@ -1659,7 +1824,6 @@ function getRandomUUID() {
1659
1824
 
1660
1825
  // src/composio.ts
1661
1826
  var Composio = class {
1662
- DEFAULT_USER_ID = "default";
1663
1827
  /**
1664
1828
  * The Composio API client.
1665
1829
  * @type {ComposioClient}
@@ -1708,8 +1872,8 @@ var Composio = class {
1708
1872
  allowTracking: config.allowTracking ?? true
1709
1873
  };
1710
1874
  this.toolset = config.toolset ?? new OpenAIToolset();
1711
- this.toolset.setComposio(this);
1712
1875
  this.tools = new Tools(this.client, this.toolset);
1876
+ this.toolset._setExecuteToolFn(this.tools.execute);
1713
1877
  this.toolkits = new Toolkits(this.client);
1714
1878
  this.triggers = new Triggers(this.client);
1715
1879
  this.authConfigs = new AuthConfigs(this.client);
@@ -1780,30 +1944,12 @@ var Composio = class {
1780
1944
 
1781
1945
  // src/toolset/ComposioToolset.ts
1782
1946
  var ComposioToolset = class extends BaseNonAgenticToolset {
1783
- FILE_NAME = "core/toolset/ComposioToolset.ts";
1784
- constructor() {
1785
- super();
1786
- }
1947
+ name = "ComposioToolset";
1787
1948
  wrapTool = (tool) => {
1788
1949
  return tool;
1789
1950
  };
1790
- async getTools(userId, params, options) {
1791
- const tools = await this.getComposio().tools.getComposioTools(
1792
- userId,
1793
- params,
1794
- options?.modifyToolSchema
1795
- );
1796
- return tools?.map((tool) => this.wrapTool(tool)) ?? [];
1797
- }
1798
- async getToolBySlug(userId, slug, modifiers) {
1799
- const tool = await this.getComposio().tools.getComposioToolBySlug(
1800
- userId,
1801
- slug,
1802
- modifiers?.modifyToolSchema
1803
- );
1804
- return this.wrapTool(tool);
1805
- }
1806
- async test() {
1951
+ wrapTools(tools) {
1952
+ return tools.map((tool) => this.wrapTool(tool));
1807
1953
  }
1808
1954
  };
1809
1955
 
@@ -1812,39 +1958,39 @@ var BaseTelemetryTransport = class {
1812
1958
  };
1813
1959
 
1814
1960
  // src/utils/jsonSchema.ts
1815
- import { z as z3 } from "zod";
1961
+ import { z as z4 } from "zod";
1816
1962
  function jsonSchemaPropertiesToTSTypes(value) {
1817
1963
  if (!value.type) {
1818
- return z3.object({});
1964
+ return z4.object({});
1819
1965
  }
1820
1966
  let zodType;
1821
1967
  switch (value.type) {
1822
1968
  case "string":
1823
- zodType = z3.string().describe(
1969
+ zodType = z4.string().describe(
1824
1970
  (value.description || "") + (value.examples ? `
1825
1971
  Examples: ${value.examples.join(", ")}` : "")
1826
1972
  );
1827
1973
  break;
1828
1974
  case "number":
1829
- zodType = z3.number().describe(
1975
+ zodType = z4.number().describe(
1830
1976
  (value.description || "") + (value.examples ? `
1831
1977
  Examples: ${value.examples.join(", ")}` : "")
1832
1978
  );
1833
1979
  break;
1834
1980
  case "integer":
1835
- zodType = z3.number().int().describe(
1981
+ zodType = z4.number().int().describe(
1836
1982
  (value.description || "") + (value.examples ? `
1837
1983
  Examples: ${value.examples.join(", ")}` : "")
1838
1984
  );
1839
1985
  break;
1840
1986
  case "boolean":
1841
- zodType = z3.boolean().describe(
1987
+ zodType = z4.boolean().describe(
1842
1988
  (value.description || "") + (value.examples ? `
1843
1989
  Examples: ${value.examples.join(", ")}` : "")
1844
1990
  );
1845
1991
  break;
1846
1992
  case "array":
1847
- zodType = z3.array(
1993
+ zodType = z4.array(
1848
1994
  jsonSchemaPropertiesToTSTypes(
1849
1995
  value.items
1850
1996
  )
@@ -1860,7 +2006,7 @@ Examples: ${value.examples.join(", ")}` : "")
1860
2006
  );
1861
2007
  break;
1862
2008
  case "null":
1863
- zodType = z3.null().describe(value.description || "");
2009
+ zodType = z4.null().describe(value.description || "");
1864
2010
  break;
1865
2011
  default:
1866
2012
  throw new Error(`Unsupported JSON schema type: ${value.type}`);
@@ -1871,7 +2017,7 @@ function jsonSchemaToModel(jsonSchema) {
1871
2017
  const properties = jsonSchema.properties;
1872
2018
  const requiredFields = jsonSchema.required || [];
1873
2019
  if (!properties) {
1874
- return z3.object({});
2020
+ return z4.object({});
1875
2021
  }
1876
2022
  const zodSchema = {};
1877
2023
  for (const [key, _] of Object.entries(properties)) {
@@ -1883,7 +2029,7 @@ function jsonSchemaToModel(jsonSchema) {
1883
2029
  schema
1884
2030
  )
1885
2031
  );
1886
- zodType = z3.union(anyOfTypes).describe(
2032
+ zodType = z4.union(anyOfTypes).describe(
1887
2033
  (value.description || "") + (value.examples ? `
1888
2034
  Examples: ${value.examples.join(", ")}` : "")
1889
2035
  );
@@ -1893,7 +2039,7 @@ Examples: ${value.examples.join(", ")}` : "")
1893
2039
  schema
1894
2040
  )
1895
2041
  );
1896
- zodType = z3.intersection(
2042
+ zodType = z4.intersection(
1897
2043
  allOfTypes[0],
1898
2044
  allOfTypes.slice(1).reduce((acc, schema) => acc.and(schema), allOfTypes[0])
1899
2045
  ).describe(
@@ -1917,7 +2063,7 @@ Examples: ${value.examples.join(", ")}` : "")
1917
2063
  zodSchema[key] = zodType.optional();
1918
2064
  }
1919
2065
  }
1920
- return z3.object(zodSchema);
2066
+ return z4.object(zodSchema);
1921
2067
  }
1922
2068
  export {
1923
2069
  BaseAgenticToolset,