@composio/core 0.1.12-alpha.12 → 0.1.12-alpha.14

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
@@ -119,14 +119,27 @@ var ToolListResponseSchema = import_zod.z.object({
119
119
  nextCursor: import_zod.z.string().nullable().optional(),
120
120
  totalPages: import_zod.z.number()
121
121
  });
122
- var ToolListParamsSchema = import_zod.z.object({
123
- tools: import_zod.z.array(import_zod.z.string()).optional(),
124
- cursor: import_zod.z.string().optional(),
122
+ var ToolListFilterByToolsSchema = import_zod.z.object({
123
+ tools: import_zod.z.array(import_zod.z.string())
124
+ });
125
+ var ToolListFilterByToolkitsSchema = import_zod.z.object({
126
+ toolkits: import_zod.z.array(import_zod.z.string()),
125
127
  important: import_zod.z.boolean().optional(),
128
+ cursor: import_zod.z.string().optional(),
126
129
  limit: import_zod.z.number().optional(),
127
- search: import_zod.z.string().optional(),
128
- toolkits: import_zod.z.array(import_zod.z.string()).optional()
130
+ search: import_zod.z.string().optional()
129
131
  });
132
+ var ToolListFilterBySearchSchema = import_zod.z.object({
133
+ search: import_zod.z.string(),
134
+ toolkits: import_zod.z.array(import_zod.z.string()).optional(),
135
+ cursor: import_zod.z.string().optional(),
136
+ limit: import_zod.z.number().optional()
137
+ });
138
+ var ToolListParamsSchema = import_zod.z.union([
139
+ ToolListFilterByToolsSchema,
140
+ ToolListFilterByToolkitsSchema,
141
+ ToolListFilterBySearchSchema
142
+ ]);
130
143
  var CustomAuthParamsSchema = import_zod.z.object({
131
144
  baseURL: import_zod.z.string().optional(),
132
145
  body: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
@@ -951,7 +964,7 @@ var CustomTools = class {
951
964
  outputParameters: {
952
965
  type: "object",
953
966
  title: `Response for ${name}`,
954
- properties: []
967
+ properties: {}
955
968
  },
956
969
  tags: [],
957
970
  toolkit: { name: "custom", slug: "custom" }
@@ -1283,34 +1296,45 @@ var Tools = class {
1283
1296
  * );
1284
1297
  * ```
1285
1298
  */
1286
- async getRawComposioTools(userId, query = {}, modifier) {
1299
+ async getRawComposioTools(userId, query, modifier) {
1300
+ if ("tools" in query && "toolkits" in query) {
1301
+ throw new ValidationError(
1302
+ "Invalid tool list parameters. You should not use tools and toolkits filter together."
1303
+ );
1304
+ }
1287
1305
  const queryParams = ToolListParamsSchema.safeParse(query);
1288
1306
  if (queryParams.error) {
1289
1307
  throw new ValidationError("Invalid tool list parameters", {
1290
1308
  cause: queryParams.error
1291
1309
  });
1292
1310
  }
1311
+ if (!("tools" in queryParams.data || "toolkits" in queryParams.data || "search" in queryParams.data)) {
1312
+ throw new ValidationError(
1313
+ "Invalid tool list parameters, atleast one of the following parameters is required: tools, toolkits, search"
1314
+ );
1315
+ }
1293
1316
  const tools = await this.client.tools.list({
1294
- tool_slugs: queryParams.data.tools?.join(","),
1295
- toolkit_slug: queryParams.data.toolkits?.join(","),
1296
- cursor: queryParams.data.cursor,
1297
- important: typeof queryParams.data.important === "undefined" ? void 0 : queryParams.data.important ? "true" : "false",
1298
- limit: queryParams.data.limit?.toString(),
1299
- search: queryParams.data.search
1317
+ tool_slugs: "tools" in queryParams.data ? queryParams.data.tools?.join(",") : void 0,
1318
+ toolkit_slug: "toolkits" in queryParams.data ? queryParams.data.toolkits?.join(",") : void 0,
1319
+ cursor: "cursor" in queryParams.data ? queryParams.data.cursor : void 0,
1320
+ important: "important" in queryParams.data ? queryParams.data.important ? "true" : "false" : void 0,
1321
+ limit: "limit" in queryParams.data ? queryParams.data.limit?.toString() : void 0,
1322
+ search: "search" in queryParams.data ? queryParams.data.search : void 0
1300
1323
  });
1301
1324
  if (!tools) {
1302
1325
  return [];
1303
1326
  }
1304
1327
  const caseTransformedTools = tools.items.map((tool) => this.transformToolCases(tool));
1305
1328
  const customTools = await this.customTools.getCustomTools({
1306
- toolSlugs: queryParams.data.tools
1329
+ toolSlugs: "tools" in queryParams.data ? queryParams.data.tools : void 0
1307
1330
  });
1308
1331
  let modifiedTools = [...caseTransformedTools, ...customTools];
1309
1332
  if (modifier) {
1310
1333
  if (typeof modifier === "function") {
1311
- modifiedTools = modifiedTools.map((tool) => {
1312
- return modifier(tool.slug, tool.toolkit?.slug ?? "unknown", tool);
1313
- });
1334
+ const modifiedPromises = modifiedTools.map(
1335
+ (tool) => modifier(tool.slug, tool.toolkit?.slug ?? "unknown", tool)
1336
+ );
1337
+ modifiedTools = await Promise.all(modifiedPromises);
1314
1338
  } else {
1315
1339
  throw new ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
1316
1340
  }
@@ -1344,7 +1368,7 @@ var Tools = class {
1344
1368
  let modifiedTool = this.transformToolCases(tool);
1345
1369
  if (modifier) {
1346
1370
  if (typeof modifier === "function") {
1347
- modifiedTool = modifier(slug, modifiedTool.toolkit?.slug ?? "unknown", modifiedTool);
1371
+ modifiedTool = await modifier(slug, modifiedTool.toolkit?.slug ?? "unknown", modifiedTool);
1348
1372
  } else {
1349
1373
  throw new ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
1350
1374
  }
@@ -1372,8 +1396,10 @@ var Tools = class {
1372
1396
  }
1373
1397
  /**
1374
1398
  * @internal
1399
+ * @description
1375
1400
  * Creates a function that executes a tool.
1376
- * This function is used by agentic the toolsets to execute the tool
1401
+ * This function is used by agentic toolsets to execute the tool
1402
+ *
1377
1403
  * @param {string} userId - The user id
1378
1404
  * @param {ExecuteToolModifiers} modifiers - The modifiers to be applied to the tool
1379
1405
  * @returns {ExecuteToolFn} The execute tool function
@@ -1402,7 +1428,7 @@ var Tools = class {
1402
1428
  async handleCustomToolExecution(tool, body, modifiers) {
1403
1429
  if (modifiers?.beforeExecute) {
1404
1430
  if (typeof modifiers.beforeExecute === "function") {
1405
- body = modifiers.beforeExecute(tool.slug, "unknown", body);
1431
+ body = await modifiers.beforeExecute(tool.slug, "unknown", body);
1406
1432
  } else {
1407
1433
  throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
1408
1434
  }
@@ -1413,7 +1439,7 @@ var Tools = class {
1413
1439
  });
1414
1440
  if (modifiers?.afterExecute) {
1415
1441
  if (typeof modifiers.afterExecute === "function") {
1416
- result = modifiers.afterExecute(tool.slug, "unknown", result);
1442
+ result = await modifiers.afterExecute(tool.slug, "unknown", result);
1417
1443
  } else {
1418
1444
  throw new ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
1419
1445
  }
@@ -1431,7 +1457,7 @@ var Tools = class {
1431
1457
  async handleComposioToolExecution(tool, body, modifiers) {
1432
1458
  if (modifiers?.beforeExecute) {
1433
1459
  if (typeof modifiers.beforeExecute === "function") {
1434
- body = modifiers.beforeExecute(tool.slug, tool.toolkit?.slug ?? "unknown", body);
1460
+ body = await modifiers.beforeExecute(tool.slug, tool.toolkit?.slug ?? "unknown", body);
1435
1461
  } else {
1436
1462
  throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
1437
1463
  }
@@ -1452,7 +1478,7 @@ var Tools = class {
1452
1478
  result = this.transformToolExecuteResponse(result);
1453
1479
  if (modifiers?.afterExecute) {
1454
1480
  if (typeof modifiers.afterExecute === "function") {
1455
- result = modifiers.afterExecute(tool.slug, tool.toolkit?.slug ?? "unknown", result);
1481
+ result = await modifiers.afterExecute(tool.slug, tool.toolkit?.slug ?? "unknown", result);
1456
1482
  } else {
1457
1483
  throw new ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
1458
1484
  }
@@ -3825,7 +3851,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
3825
3851
  };
3826
3852
 
3827
3853
  // package.json
3828
- var version = "0.1.12-alpha.12";
3854
+ var version = "0.1.12-alpha.14";
3829
3855
 
3830
3856
  // src/composio.ts
3831
3857
  var Composio = class {
package/dist/index.d.cts CHANGED
@@ -136,32 +136,75 @@ type Tool = z.infer<typeof ToolSchema>;
136
136
  * Plain SDK level Tool List
137
137
  */
138
138
  type ToolList = Array<Tool>;
139
+ type ToolsOnlyParams = {
140
+ tools: string[];
141
+ toolkits?: never;
142
+ important?: never;
143
+ cursor?: never;
144
+ limit?: never;
145
+ search?: never;
146
+ };
147
+ type ToolkitsOnlyParams = {
148
+ tools?: never;
149
+ toolkits?: string[];
150
+ important?: boolean;
151
+ cursor?: string;
152
+ limit?: number;
153
+ search?: never;
154
+ };
155
+ type ToolkitSearchOnlyParams = {
156
+ tools?: never;
157
+ toolkits?: string[];
158
+ important?: never;
159
+ cursor?: string;
160
+ limit?: number;
161
+ search?: string;
162
+ };
139
163
  /**
140
164
  * ToolListParams is the parameters for the list of tools.
165
+ * You must provide either tools or toolkits, but not both.
141
166
  */
142
- declare const ToolListParamsSchema: z.ZodObject<{
143
- tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
144
- cursor: z.ZodOptional<z.ZodString>;
167
+ type ToolListParams = ToolsOnlyParams | ToolkitsOnlyParams | ToolkitSearchOnlyParams;
168
+ declare const ToolListParamsSchema: z.ZodUnion<[z.ZodObject<{
169
+ tools: z.ZodArray<z.ZodString, "many">;
170
+ }, "strip", z.ZodTypeAny, {
171
+ tools: string[];
172
+ }, {
173
+ tools: string[];
174
+ }>, z.ZodObject<{
175
+ toolkits: z.ZodArray<z.ZodString, "many">;
145
176
  important: z.ZodOptional<z.ZodBoolean>;
177
+ cursor: z.ZodOptional<z.ZodString>;
146
178
  limit: z.ZodOptional<z.ZodNumber>;
147
179
  search: z.ZodOptional<z.ZodString>;
148
- toolkits: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
149
180
  }, "strip", z.ZodTypeAny, {
150
- tools?: string[] | undefined;
151
- cursor?: string | undefined;
181
+ toolkits: string[];
152
182
  important?: boolean | undefined;
183
+ cursor?: string | undefined;
153
184
  limit?: number | undefined;
154
185
  search?: string | undefined;
155
- toolkits?: string[] | undefined;
156
186
  }, {
157
- tools?: string[] | undefined;
158
- cursor?: string | undefined;
187
+ toolkits: string[];
159
188
  important?: boolean | undefined;
189
+ cursor?: string | undefined;
160
190
  limit?: number | undefined;
161
191
  search?: string | undefined;
192
+ }>, z.ZodObject<{
193
+ search: z.ZodString;
194
+ toolkits: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
195
+ cursor: z.ZodOptional<z.ZodString>;
196
+ limit: z.ZodOptional<z.ZodNumber>;
197
+ }, "strip", z.ZodTypeAny, {
198
+ search: string;
162
199
  toolkits?: string[] | undefined;
163
- }>;
164
- type ToolListParams = z.infer<typeof ToolListParamsSchema>;
200
+ cursor?: string | undefined;
201
+ limit?: number | undefined;
202
+ }, {
203
+ search: string;
204
+ toolkits?: string[] | undefined;
205
+ cursor?: string | undefined;
206
+ limit?: number | undefined;
207
+ }>]>;
165
208
  /**
166
209
  * CustomAuthParams is the parameters for the custom authentication.
167
210
  */
@@ -474,7 +517,7 @@ type BaseComposioProvider<TToolCollection, TTool> = BaseNonAgenticProvider<TTool
474
517
  * };
475
518
  * ```
476
519
  */
477
- type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => ToolExecuteParams;
520
+ type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => Promise<ToolExecuteParams>;
478
521
  /**
479
522
  * Modifier for altering the tool execution response after execution completes.
480
523
  *
@@ -525,7 +568,7 @@ type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecute
525
568
  * };
526
569
  * ```
527
570
  */
528
- type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => ToolExecuteResponse;
571
+ type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => Promise<ToolExecuteResponse>;
529
572
  /**
530
573
  * Modifier for altering the tool schema before it's exposed to consumers.
531
574
  *
@@ -585,7 +628,7 @@ type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteR
585
628
  * };
586
629
  * ```
587
630
  */
588
- type TransformToolSchemaModifier = (toolSlug: string, toolkitSlug: string, toolSchema: Tool) => Tool;
631
+ type TransformToolSchemaModifier = (toolSlug: string, toolkitSlug: string, toolSchema: Tool) => Tool | Promise<Tool>;
589
632
  /**
590
633
  * Options for non-agentic tool configuration.
591
634
  *
@@ -796,7 +839,7 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
796
839
  * );
797
840
  * ```
798
841
  */
799
- getRawComposioTools(userId: string, query?: ToolListParams, modifier?: TransformToolSchemaModifier): Promise<ToolList>;
842
+ getRawComposioTools(userId: string, query: ToolListParams, modifier?: TransformToolSchemaModifier): Promise<ToolList>;
800
843
  /**
801
844
  * Retrieves a tool by its Slug.
802
845
  * This method is used to get the raw tools from the composio API.
@@ -860,8 +903,10 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
860
903
  get<T extends TProvider>(userId: string, slug: string, options?: ProviderOptions<TProvider>): Promise<ReturnType<T['wrapTools']>>;
861
904
  /**
862
905
  * @internal
906
+ * @description
863
907
  * Creates a function that executes a tool.
864
- * This function is used by agentic the toolsets to execute the tool
908
+ * This function is used by agentic toolsets to execute the tool
909
+ *
865
910
  * @param {string} userId - The user id
866
911
  * @param {ExecuteToolModifiers} modifiers - The modifiers to be applied to the tool
867
912
  * @returns {ExecuteToolFn} The execute tool function
package/dist/index.d.ts CHANGED
@@ -136,32 +136,75 @@ type Tool = z.infer<typeof ToolSchema>;
136
136
  * Plain SDK level Tool List
137
137
  */
138
138
  type ToolList = Array<Tool>;
139
+ type ToolsOnlyParams = {
140
+ tools: string[];
141
+ toolkits?: never;
142
+ important?: never;
143
+ cursor?: never;
144
+ limit?: never;
145
+ search?: never;
146
+ };
147
+ type ToolkitsOnlyParams = {
148
+ tools?: never;
149
+ toolkits?: string[];
150
+ important?: boolean;
151
+ cursor?: string;
152
+ limit?: number;
153
+ search?: never;
154
+ };
155
+ type ToolkitSearchOnlyParams = {
156
+ tools?: never;
157
+ toolkits?: string[];
158
+ important?: never;
159
+ cursor?: string;
160
+ limit?: number;
161
+ search?: string;
162
+ };
139
163
  /**
140
164
  * ToolListParams is the parameters for the list of tools.
165
+ * You must provide either tools or toolkits, but not both.
141
166
  */
142
- declare const ToolListParamsSchema: z.ZodObject<{
143
- tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
144
- cursor: z.ZodOptional<z.ZodString>;
167
+ type ToolListParams = ToolsOnlyParams | ToolkitsOnlyParams | ToolkitSearchOnlyParams;
168
+ declare const ToolListParamsSchema: z.ZodUnion<[z.ZodObject<{
169
+ tools: z.ZodArray<z.ZodString, "many">;
170
+ }, "strip", z.ZodTypeAny, {
171
+ tools: string[];
172
+ }, {
173
+ tools: string[];
174
+ }>, z.ZodObject<{
175
+ toolkits: z.ZodArray<z.ZodString, "many">;
145
176
  important: z.ZodOptional<z.ZodBoolean>;
177
+ cursor: z.ZodOptional<z.ZodString>;
146
178
  limit: z.ZodOptional<z.ZodNumber>;
147
179
  search: z.ZodOptional<z.ZodString>;
148
- toolkits: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
149
180
  }, "strip", z.ZodTypeAny, {
150
- tools?: string[] | undefined;
151
- cursor?: string | undefined;
181
+ toolkits: string[];
152
182
  important?: boolean | undefined;
183
+ cursor?: string | undefined;
153
184
  limit?: number | undefined;
154
185
  search?: string | undefined;
155
- toolkits?: string[] | undefined;
156
186
  }, {
157
- tools?: string[] | undefined;
158
- cursor?: string | undefined;
187
+ toolkits: string[];
159
188
  important?: boolean | undefined;
189
+ cursor?: string | undefined;
160
190
  limit?: number | undefined;
161
191
  search?: string | undefined;
192
+ }>, z.ZodObject<{
193
+ search: z.ZodString;
194
+ toolkits: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
195
+ cursor: z.ZodOptional<z.ZodString>;
196
+ limit: z.ZodOptional<z.ZodNumber>;
197
+ }, "strip", z.ZodTypeAny, {
198
+ search: string;
162
199
  toolkits?: string[] | undefined;
163
- }>;
164
- type ToolListParams = z.infer<typeof ToolListParamsSchema>;
200
+ cursor?: string | undefined;
201
+ limit?: number | undefined;
202
+ }, {
203
+ search: string;
204
+ toolkits?: string[] | undefined;
205
+ cursor?: string | undefined;
206
+ limit?: number | undefined;
207
+ }>]>;
165
208
  /**
166
209
  * CustomAuthParams is the parameters for the custom authentication.
167
210
  */
@@ -474,7 +517,7 @@ type BaseComposioProvider<TToolCollection, TTool> = BaseNonAgenticProvider<TTool
474
517
  * };
475
518
  * ```
476
519
  */
477
- type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => ToolExecuteParams;
520
+ type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => Promise<ToolExecuteParams>;
478
521
  /**
479
522
  * Modifier for altering the tool execution response after execution completes.
480
523
  *
@@ -525,7 +568,7 @@ type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecute
525
568
  * };
526
569
  * ```
527
570
  */
528
- type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => ToolExecuteResponse;
571
+ type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => Promise<ToolExecuteResponse>;
529
572
  /**
530
573
  * Modifier for altering the tool schema before it's exposed to consumers.
531
574
  *
@@ -585,7 +628,7 @@ type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteR
585
628
  * };
586
629
  * ```
587
630
  */
588
- type TransformToolSchemaModifier = (toolSlug: string, toolkitSlug: string, toolSchema: Tool) => Tool;
631
+ type TransformToolSchemaModifier = (toolSlug: string, toolkitSlug: string, toolSchema: Tool) => Tool | Promise<Tool>;
589
632
  /**
590
633
  * Options for non-agentic tool configuration.
591
634
  *
@@ -796,7 +839,7 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
796
839
  * );
797
840
  * ```
798
841
  */
799
- getRawComposioTools(userId: string, query?: ToolListParams, modifier?: TransformToolSchemaModifier): Promise<ToolList>;
842
+ getRawComposioTools(userId: string, query: ToolListParams, modifier?: TransformToolSchemaModifier): Promise<ToolList>;
800
843
  /**
801
844
  * Retrieves a tool by its Slug.
802
845
  * This method is used to get the raw tools from the composio API.
@@ -860,8 +903,10 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
860
903
  get<T extends TProvider>(userId: string, slug: string, options?: ProviderOptions<TProvider>): Promise<ReturnType<T['wrapTools']>>;
861
904
  /**
862
905
  * @internal
906
+ * @description
863
907
  * Creates a function that executes a tool.
864
- * This function is used by agentic the toolsets to execute the tool
908
+ * This function is used by agentic toolsets to execute the tool
909
+ *
865
910
  * @param {string} userId - The user id
866
911
  * @param {ExecuteToolModifiers} modifiers - The modifiers to be applied to the tool
867
912
  * @returns {ExecuteToolFn} The execute tool function
package/dist/index.js CHANGED
@@ -56,14 +56,27 @@ var ToolListResponseSchema = z.object({
56
56
  nextCursor: z.string().nullable().optional(),
57
57
  totalPages: z.number()
58
58
  });
59
- var ToolListParamsSchema = z.object({
60
- tools: z.array(z.string()).optional(),
61
- cursor: z.string().optional(),
59
+ var ToolListFilterByToolsSchema = z.object({
60
+ tools: z.array(z.string())
61
+ });
62
+ var ToolListFilterByToolkitsSchema = z.object({
63
+ toolkits: z.array(z.string()),
62
64
  important: z.boolean().optional(),
65
+ cursor: z.string().optional(),
63
66
  limit: z.number().optional(),
64
- search: z.string().optional(),
65
- toolkits: z.array(z.string()).optional()
67
+ search: z.string().optional()
66
68
  });
69
+ var ToolListFilterBySearchSchema = z.object({
70
+ search: z.string(),
71
+ toolkits: z.array(z.string()).optional(),
72
+ cursor: z.string().optional(),
73
+ limit: z.number().optional()
74
+ });
75
+ var ToolListParamsSchema = z.union([
76
+ ToolListFilterByToolsSchema,
77
+ ToolListFilterByToolkitsSchema,
78
+ ToolListFilterBySearchSchema
79
+ ]);
67
80
  var CustomAuthParamsSchema = z.object({
68
81
  baseURL: z.string().optional(),
69
82
  body: z.record(z.string(), z.unknown()).optional(),
@@ -888,7 +901,7 @@ var CustomTools = class {
888
901
  outputParameters: {
889
902
  type: "object",
890
903
  title: `Response for ${name}`,
891
- properties: []
904
+ properties: {}
892
905
  },
893
906
  tags: [],
894
907
  toolkit: { name: "custom", slug: "custom" }
@@ -1220,34 +1233,45 @@ var Tools = class {
1220
1233
  * );
1221
1234
  * ```
1222
1235
  */
1223
- async getRawComposioTools(userId, query = {}, modifier) {
1236
+ async getRawComposioTools(userId, query, modifier) {
1237
+ if ("tools" in query && "toolkits" in query) {
1238
+ throw new ValidationError(
1239
+ "Invalid tool list parameters. You should not use tools and toolkits filter together."
1240
+ );
1241
+ }
1224
1242
  const queryParams = ToolListParamsSchema.safeParse(query);
1225
1243
  if (queryParams.error) {
1226
1244
  throw new ValidationError("Invalid tool list parameters", {
1227
1245
  cause: queryParams.error
1228
1246
  });
1229
1247
  }
1248
+ if (!("tools" in queryParams.data || "toolkits" in queryParams.data || "search" in queryParams.data)) {
1249
+ throw new ValidationError(
1250
+ "Invalid tool list parameters, atleast one of the following parameters is required: tools, toolkits, search"
1251
+ );
1252
+ }
1230
1253
  const tools = await this.client.tools.list({
1231
- tool_slugs: queryParams.data.tools?.join(","),
1232
- toolkit_slug: queryParams.data.toolkits?.join(","),
1233
- cursor: queryParams.data.cursor,
1234
- important: typeof queryParams.data.important === "undefined" ? void 0 : queryParams.data.important ? "true" : "false",
1235
- limit: queryParams.data.limit?.toString(),
1236
- search: queryParams.data.search
1254
+ tool_slugs: "tools" in queryParams.data ? queryParams.data.tools?.join(",") : void 0,
1255
+ toolkit_slug: "toolkits" in queryParams.data ? queryParams.data.toolkits?.join(",") : void 0,
1256
+ cursor: "cursor" in queryParams.data ? queryParams.data.cursor : void 0,
1257
+ important: "important" in queryParams.data ? queryParams.data.important ? "true" : "false" : void 0,
1258
+ limit: "limit" in queryParams.data ? queryParams.data.limit?.toString() : void 0,
1259
+ search: "search" in queryParams.data ? queryParams.data.search : void 0
1237
1260
  });
1238
1261
  if (!tools) {
1239
1262
  return [];
1240
1263
  }
1241
1264
  const caseTransformedTools = tools.items.map((tool) => this.transformToolCases(tool));
1242
1265
  const customTools = await this.customTools.getCustomTools({
1243
- toolSlugs: queryParams.data.tools
1266
+ toolSlugs: "tools" in queryParams.data ? queryParams.data.tools : void 0
1244
1267
  });
1245
1268
  let modifiedTools = [...caseTransformedTools, ...customTools];
1246
1269
  if (modifier) {
1247
1270
  if (typeof modifier === "function") {
1248
- modifiedTools = modifiedTools.map((tool) => {
1249
- return modifier(tool.slug, tool.toolkit?.slug ?? "unknown", tool);
1250
- });
1271
+ const modifiedPromises = modifiedTools.map(
1272
+ (tool) => modifier(tool.slug, tool.toolkit?.slug ?? "unknown", tool)
1273
+ );
1274
+ modifiedTools = await Promise.all(modifiedPromises);
1251
1275
  } else {
1252
1276
  throw new ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
1253
1277
  }
@@ -1281,7 +1305,7 @@ var Tools = class {
1281
1305
  let modifiedTool = this.transformToolCases(tool);
1282
1306
  if (modifier) {
1283
1307
  if (typeof modifier === "function") {
1284
- modifiedTool = modifier(slug, modifiedTool.toolkit?.slug ?? "unknown", modifiedTool);
1308
+ modifiedTool = await modifier(slug, modifiedTool.toolkit?.slug ?? "unknown", modifiedTool);
1285
1309
  } else {
1286
1310
  throw new ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
1287
1311
  }
@@ -1309,8 +1333,10 @@ var Tools = class {
1309
1333
  }
1310
1334
  /**
1311
1335
  * @internal
1336
+ * @description
1312
1337
  * Creates a function that executes a tool.
1313
- * This function is used by agentic the toolsets to execute the tool
1338
+ * This function is used by agentic toolsets to execute the tool
1339
+ *
1314
1340
  * @param {string} userId - The user id
1315
1341
  * @param {ExecuteToolModifiers} modifiers - The modifiers to be applied to the tool
1316
1342
  * @returns {ExecuteToolFn} The execute tool function
@@ -1339,7 +1365,7 @@ var Tools = class {
1339
1365
  async handleCustomToolExecution(tool, body, modifiers) {
1340
1366
  if (modifiers?.beforeExecute) {
1341
1367
  if (typeof modifiers.beforeExecute === "function") {
1342
- body = modifiers.beforeExecute(tool.slug, "unknown", body);
1368
+ body = await modifiers.beforeExecute(tool.slug, "unknown", body);
1343
1369
  } else {
1344
1370
  throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
1345
1371
  }
@@ -1350,7 +1376,7 @@ var Tools = class {
1350
1376
  });
1351
1377
  if (modifiers?.afterExecute) {
1352
1378
  if (typeof modifiers.afterExecute === "function") {
1353
- result = modifiers.afterExecute(tool.slug, "unknown", result);
1379
+ result = await modifiers.afterExecute(tool.slug, "unknown", result);
1354
1380
  } else {
1355
1381
  throw new ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
1356
1382
  }
@@ -1368,7 +1394,7 @@ var Tools = class {
1368
1394
  async handleComposioToolExecution(tool, body, modifiers) {
1369
1395
  if (modifiers?.beforeExecute) {
1370
1396
  if (typeof modifiers.beforeExecute === "function") {
1371
- body = modifiers.beforeExecute(tool.slug, tool.toolkit?.slug ?? "unknown", body);
1397
+ body = await modifiers.beforeExecute(tool.slug, tool.toolkit?.slug ?? "unknown", body);
1372
1398
  } else {
1373
1399
  throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
1374
1400
  }
@@ -1389,7 +1415,7 @@ var Tools = class {
1389
1415
  result = this.transformToolExecuteResponse(result);
1390
1416
  if (modifiers?.afterExecute) {
1391
1417
  if (typeof modifiers.afterExecute === "function") {
1392
- result = modifiers.afterExecute(tool.slug, tool.toolkit?.slug ?? "unknown", result);
1418
+ result = await modifiers.afterExecute(tool.slug, tool.toolkit?.slug ?? "unknown", result);
1393
1419
  } else {
1394
1420
  throw new ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
1395
1421
  }
@@ -3762,7 +3788,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
3762
3788
  };
3763
3789
 
3764
3790
  // package.json
3765
- var version = "0.1.12-alpha.12";
3791
+ var version = "0.1.12-alpha.14";
3766
3792
 
3767
3793
  // src/composio.ts
3768
3794
  var Composio = class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/core",
3
- "version": "0.1.12-alpha.12",
3
+ "version": "0.1.12-alpha.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",