@composio/core 0.1.55 → 0.2.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.cjs +186 -196
- package/dist/index.d.cts +194 -39
- package/dist/index.d.ts +194 -39
- package/dist/index.js +173 -185
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -718,8 +718,8 @@ var ToolExecuteParamsSchema = z3.object({
|
|
|
718
718
|
customConnectionData: CustomConnectionDataSchema.optional(),
|
|
719
719
|
arguments: z3.record(z3.string(), z3.unknown()).optional(),
|
|
720
720
|
userId: z3.string().optional(),
|
|
721
|
-
// we have no auth apps which can be execute
|
|
722
721
|
version: z3.union([z3.literal("latest"), z3.string()]).optional(),
|
|
722
|
+
dangerouslySkipVersionCheck: z3.boolean().optional(),
|
|
723
723
|
text: z3.string().optional()
|
|
724
724
|
});
|
|
725
725
|
var ToolExecuteResponseSchema = z3.object({
|
|
@@ -871,6 +871,9 @@ var Logger = class {
|
|
|
871
871
|
var logger = new Logger();
|
|
872
872
|
var logger_default = logger;
|
|
873
873
|
|
|
874
|
+
// src/errors/ToolErrors.ts
|
|
875
|
+
import { APIError } from "@composio/client";
|
|
876
|
+
|
|
874
877
|
// src/errors/ComposioError.ts
|
|
875
878
|
import chalk2 from "chalk";
|
|
876
879
|
import { ZodError } from "zod/v3";
|
|
@@ -1109,6 +1112,46 @@ ${originalStackBody}`;
|
|
|
1109
1112
|
}
|
|
1110
1113
|
};
|
|
1111
1114
|
|
|
1115
|
+
// src/errors/ConnectedAccountsErrors.ts
|
|
1116
|
+
var ConnectedAccountErrorCodes = {
|
|
1117
|
+
CONNECTED_ACCOUNT_NOT_FOUND: "CONNECTED_ACCOUNT_NOT_FOUND",
|
|
1118
|
+
MULTIPLE_CONNECTED_ACCOUNTS: "MULTIPLE_CONNECTED_ACCOUNTS",
|
|
1119
|
+
FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK: "FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK"
|
|
1120
|
+
};
|
|
1121
|
+
var ComposioConnectedAccountNotFoundError = class extends ComposioError {
|
|
1122
|
+
constructor(message = "Connected account not found", options = {}) {
|
|
1123
|
+
super(message, {
|
|
1124
|
+
...options,
|
|
1125
|
+
code: ConnectedAccountErrorCodes.CONNECTED_ACCOUNT_NOT_FOUND,
|
|
1126
|
+
statusCode: 404,
|
|
1127
|
+
possibleFixes: options.possibleFixes || [
|
|
1128
|
+
"Ensure the connected account exists and is active in your Composio dashboard"
|
|
1129
|
+
]
|
|
1130
|
+
});
|
|
1131
|
+
this.name = "ComposioConnectedAccountNotFoundError";
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
var ComposioMultipleConnectedAccountsError = class extends ComposioError {
|
|
1135
|
+
constructor(message = "Multiple connected accounts found") {
|
|
1136
|
+
super(message, {
|
|
1137
|
+
code: ConnectedAccountErrorCodes.MULTIPLE_CONNECTED_ACCOUNTS,
|
|
1138
|
+
possibleFixes: [
|
|
1139
|
+
"Use the allowMultiple flag to allow multiple connected accounts per user for an auth config"
|
|
1140
|
+
]
|
|
1141
|
+
});
|
|
1142
|
+
this.name = "ComposioMultipleConnectedAccountsError";
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
var ComposioFailedToCreateConnectedAccountLink = class extends ComposioError {
|
|
1146
|
+
constructor(message = "Failed to create connected account link", options = {}) {
|
|
1147
|
+
super(message, {
|
|
1148
|
+
...options,
|
|
1149
|
+
code: ConnectedAccountErrorCodes.FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK
|
|
1150
|
+
});
|
|
1151
|
+
this.name = "ComposioFailedToCreateConnectedAccountLink";
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1112
1155
|
// src/errors/ToolErrors.ts
|
|
1113
1156
|
var ToolErrorCodes = {
|
|
1114
1157
|
TOOLSET_NOT_DEFINED: "TOOLSET_NOT_DEFINED",
|
|
@@ -1117,7 +1160,8 @@ var ToolErrorCodes = {
|
|
|
1117
1160
|
CUSTOM_TOOLS_NOT_INITIALIZED: "CUSTOM_TOOLS_NOT_INITIALIZED",
|
|
1118
1161
|
TOOL_EXECUTION_ERROR: "TOOL_EXECUTION_ERROR",
|
|
1119
1162
|
INVALID_EXECUTE_FUNCTION: "INVALID_EXECUTE_FUNCTION",
|
|
1120
|
-
GLOBAL_EXECUTE_TOOL_FN_NOT_SET: "GLOBAL_EXECUTE_TOOL_FN_NOT_SET"
|
|
1163
|
+
GLOBAL_EXECUTE_TOOL_FN_NOT_SET: "GLOBAL_EXECUTE_TOOL_FN_NOT_SET",
|
|
1164
|
+
TOOL_VERSION_REQUIRED: "TOOL_VERSION_REQUIRED"
|
|
1121
1165
|
};
|
|
1122
1166
|
var ComposioProviderNotDefinedError = class extends ComposioError {
|
|
1123
1167
|
constructor(message = "Provider not defined", options = {}) {
|
|
@@ -1168,18 +1212,16 @@ var ComposioCustomToolsNotInitializedError = class extends ComposioError {
|
|
|
1168
1212
|
}
|
|
1169
1213
|
};
|
|
1170
1214
|
var ComposioToolExecutionError = class extends ComposioError {
|
|
1171
|
-
error;
|
|
1172
1215
|
constructor(message = "Tool execution error", options = {}) {
|
|
1173
|
-
const { originalError, ...restOptions } = options;
|
|
1174
1216
|
super(message, {
|
|
1175
|
-
...
|
|
1217
|
+
...options,
|
|
1176
1218
|
code: options.code || ToolErrorCodes.TOOL_EXECUTION_ERROR,
|
|
1177
|
-
cause: options.cause
|
|
1219
|
+
cause: options.cause,
|
|
1178
1220
|
possibleFixes: options.possibleFixes || [
|
|
1179
|
-
"Ensure the tool is correctly configured and the input is valid"
|
|
1221
|
+
"Ensure the tool is correctly configured and the input is valid",
|
|
1222
|
+
"Ensure the userId is correct and has an active connected account for the user in case of non NoAuth toolkits"
|
|
1180
1223
|
]
|
|
1181
1224
|
});
|
|
1182
|
-
this.error = originalError || (options.cause instanceof Error ? options.cause : options.cause ? new Error(String(options.cause)) : new Error("Unknown error"));
|
|
1183
1225
|
this.name = "ComposioToolExecutionError";
|
|
1184
1226
|
}
|
|
1185
1227
|
};
|
|
@@ -1207,45 +1249,39 @@ var ComposioGlobalExecuteToolFnNotSetError = class extends ComposioError {
|
|
|
1207
1249
|
this.name = "ComposioGlobalExecuteToolFnNotSetError";
|
|
1208
1250
|
}
|
|
1209
1251
|
};
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
var ConnectedAccountErrorCodes = {
|
|
1213
|
-
CONNECTED_ACCOUNT_NOT_FOUND: "CONNECTED_ACCOUNT_NOT_FOUND",
|
|
1214
|
-
MULTIPLE_CONNECTED_ACCOUNTS: "MULTIPLE_CONNECTED_ACCOUNTS",
|
|
1215
|
-
FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK: "FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK"
|
|
1216
|
-
};
|
|
1217
|
-
var ComposioConnectedAccountNotFoundError = class extends ComposioError {
|
|
1218
|
-
constructor(message = "Connected account not found", options = {}) {
|
|
1252
|
+
var ComposioToolVersionRequiredError = class extends ComposioError {
|
|
1253
|
+
constructor(message = "Toolkit version not specified. For manual execution of the tool please pass a specific toolkit version", options = {}) {
|
|
1219
1254
|
super(message, {
|
|
1220
1255
|
...options,
|
|
1221
|
-
code:
|
|
1222
|
-
statusCode: 404,
|
|
1256
|
+
code: ToolErrorCodes.TOOL_VERSION_REQUIRED,
|
|
1223
1257
|
possibleFixes: options.possibleFixes || [
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
}
|
|
1229
|
-
};
|
|
1230
|
-
var ComposioMultipleConnectedAccountsError = class extends ComposioError {
|
|
1231
|
-
constructor(message = "Multiple connected accounts found") {
|
|
1232
|
-
super(message, {
|
|
1233
|
-
code: ConnectedAccountErrorCodes.MULTIPLE_CONNECTED_ACCOUNTS,
|
|
1234
|
-
possibleFixes: [
|
|
1235
|
-
"Use the allowMultiple flag to allow multiple connected accounts per user for an auth config"
|
|
1258
|
+
'Pass the toolkit version as a parameter to the execute function ("latest" is not supported in manual execution)',
|
|
1259
|
+
'Set the toolkit versions in the Composio config (toolkitVersions: { <toolkit-slug>: "<toolkit-version>" })',
|
|
1260
|
+
"Set the toolkit version in the environment variable (COMPOSIO_TOOLKIT_VERSION_<TOOLKIT_SLUG>)",
|
|
1261
|
+
"Set dangerouslySkipVersionCheck to true (this might cause unexpected behavior when new versions of the tools are released)"
|
|
1236
1262
|
]
|
|
1237
1263
|
});
|
|
1238
|
-
this.name = "ComposioMultipleConnectedAccountsError";
|
|
1239
1264
|
}
|
|
1240
1265
|
};
|
|
1241
|
-
var
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1266
|
+
var ERROR_CODE_HANDLERS = /* @__PURE__ */ new Map([
|
|
1267
|
+
[1803, (msg) => new ComposioConnectedAccountNotFoundError(msg)]
|
|
1268
|
+
// Add more error code handlers here as needed
|
|
1269
|
+
]);
|
|
1270
|
+
var handleToolExecutionError = (tool, actualError) => {
|
|
1271
|
+
if (actualError instanceof APIError && actualError.error) {
|
|
1272
|
+
const errorBody = actualError.error;
|
|
1273
|
+
const errorCode = errorBody?.error?.code;
|
|
1274
|
+
const errorMessage = errorBody?.error?.message;
|
|
1275
|
+
if (errorCode && ERROR_CODE_HANDLERS.has(errorCode)) {
|
|
1276
|
+
return ERROR_CODE_HANDLERS.get(errorCode)(errorMessage || "An error occurred");
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
return new ComposioToolExecutionError(`Error executing the tool ${tool}`, {
|
|
1280
|
+
cause: actualError,
|
|
1281
|
+
possibleFixes: [
|
|
1282
|
+
"Ensure the tool slug is correct and the input arguments for the tool is valid"
|
|
1283
|
+
]
|
|
1284
|
+
});
|
|
1249
1285
|
};
|
|
1250
1286
|
|
|
1251
1287
|
// src/telemetry/Telemetry.ts
|
|
@@ -1960,9 +1996,6 @@ var CustomTools = class {
|
|
|
1960
1996
|
* ```
|
|
1961
1997
|
*/
|
|
1962
1998
|
async getCustomToolBySlug(slug) {
|
|
1963
|
-
if (!slug) {
|
|
1964
|
-
throw new Error("Tool slug is required");
|
|
1965
|
-
}
|
|
1966
1999
|
try {
|
|
1967
2000
|
const tool = this.customToolsRegistry.get(slug.toLowerCase());
|
|
1968
2001
|
return tool?.schema;
|
|
@@ -2600,39 +2633,6 @@ var Tools = class {
|
|
|
2600
2633
|
sessionInfo: response.session_info
|
|
2601
2634
|
});
|
|
2602
2635
|
}
|
|
2603
|
-
/**
|
|
2604
|
-
* Get the connected account id for a given tool
|
|
2605
|
-
* @param {string} userId - The user id
|
|
2606
|
-
* @param {string} toolSlug - The tool slug
|
|
2607
|
-
* @returns {Promise<string | null>} The connected account id or null if the toolkit is a no auth app
|
|
2608
|
-
*/
|
|
2609
|
-
async getConnectedAccountIdForTool(userId, toolSlug) {
|
|
2610
|
-
const tool = await this.getRawComposioToolBySlug(toolSlug);
|
|
2611
|
-
if (!tool.toolkit) {
|
|
2612
|
-
throw new Error(`Unable to find toolkit for tool ${toolSlug}`);
|
|
2613
|
-
}
|
|
2614
|
-
const toolkit = await this.client.toolkits.retrieve(tool.toolkit.slug);
|
|
2615
|
-
if (!toolkit) {
|
|
2616
|
-
throw new Error(`Unable to find toolkit for tool ${toolSlug}`);
|
|
2617
|
-
}
|
|
2618
|
-
const isNoAuthApp = toolkit.auth_config_details?.some(
|
|
2619
|
-
(authConfigDetails) => authConfigDetails.mode === AuthSchemeTypes.NO_AUTH
|
|
2620
|
-
);
|
|
2621
|
-
if (!isNoAuthApp) {
|
|
2622
|
-
const connectedAccounts = await this.client.connectedAccounts.list({
|
|
2623
|
-
user_ids: [userId],
|
|
2624
|
-
toolkit_slugs: [tool.toolkit.slug]
|
|
2625
|
-
});
|
|
2626
|
-
if (connectedAccounts.items.length === 0) {
|
|
2627
|
-
throw new Error("No connected accounts found");
|
|
2628
|
-
}
|
|
2629
|
-
logger_default.warn(
|
|
2630
|
-
`Using the first connected account for tool ${toolSlug}. To change this behaviour please explicitly pass a connectedAccountId for the tool`
|
|
2631
|
-
);
|
|
2632
|
-
return connectedAccounts.items[0].id;
|
|
2633
|
-
}
|
|
2634
|
-
return null;
|
|
2635
|
-
}
|
|
2636
2636
|
/**
|
|
2637
2637
|
* Applies the default schema modifiers to the tools
|
|
2638
2638
|
* @param tools - The tools to apply the default schema modifiers to
|
|
@@ -2962,7 +2962,10 @@ var Tools = class {
|
|
|
2962
2962
|
toolSlug,
|
|
2963
2963
|
{
|
|
2964
2964
|
userId,
|
|
2965
|
-
arguments: input
|
|
2965
|
+
arguments: input,
|
|
2966
|
+
// dangerously skip version check for agentic and non agentic tool execution via providers
|
|
2967
|
+
// this can be safe because most agentic flows users fetch latest version and then execute the tool
|
|
2968
|
+
dangerouslySkipVersionCheck: true
|
|
2966
2969
|
},
|
|
2967
2970
|
modifiers
|
|
2968
2971
|
);
|
|
@@ -2971,81 +2974,32 @@ var Tools = class {
|
|
|
2971
2974
|
}
|
|
2972
2975
|
/**
|
|
2973
2976
|
* @internal
|
|
2974
|
-
*
|
|
2977
|
+
* Executes a composio tool via API without modifiers
|
|
2975
2978
|
* @param tool - The tool to execute
|
|
2976
2979
|
* @param body - The body of the tool execution
|
|
2977
|
-
* @param modifiers - The modifiers to be applied to the tool execution
|
|
2978
2980
|
* @returns The response from the tool execution
|
|
2979
2981
|
*/
|
|
2980
|
-
async
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
toolSlug: tool.slug,
|
|
2985
|
-
toolkitSlug: tool.toolkit?.slug ?? "unknown",
|
|
2986
|
-
params: body
|
|
2987
|
-
});
|
|
2988
|
-
} else {
|
|
2989
|
-
throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
|
|
2990
|
-
}
|
|
2982
|
+
async executeComposioTool(tool, body) {
|
|
2983
|
+
const toolkitVersion = body.version ?? getToolkitVersion(tool.toolkit?.slug ?? "unknown", this.toolkitVersions);
|
|
2984
|
+
if (toolkitVersion === "latest" && !body.dangerouslySkipVersionCheck) {
|
|
2985
|
+
throw new ComposioToolVersionRequiredError();
|
|
2991
2986
|
}
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
}
|
|
2987
|
+
try {
|
|
2988
|
+
const result = await this.client.tools.execute(tool.slug, {
|
|
2989
|
+
allow_tracing: body.allowTracing,
|
|
2990
|
+
connected_account_id: body.connectedAccountId,
|
|
2991
|
+
custom_auth_params: body.customAuthParams,
|
|
2992
|
+
custom_connection_data: body.customConnectionData,
|
|
2993
|
+
arguments: body.arguments,
|
|
2994
|
+
user_id: body.userId,
|
|
2995
|
+
version: toolkitVersion,
|
|
2996
|
+
text: body.text
|
|
2997
|
+
});
|
|
2998
|
+
return this.transformToolExecuteResponse(result);
|
|
2999
|
+
} catch (error) {
|
|
3000
|
+
const toolError = handleToolExecutionError(tool.slug, error);
|
|
3001
|
+
throw toolError;
|
|
3003
3002
|
}
|
|
3004
|
-
return result;
|
|
3005
|
-
}
|
|
3006
|
-
/**
|
|
3007
|
-
* @internal
|
|
3008
|
-
* Handles the execution of a composio tool
|
|
3009
|
-
* @param tool - The tool to execute
|
|
3010
|
-
* @param body - The body of the tool execution
|
|
3011
|
-
* @param modifiers - The modifiers to be applied to the tool execution
|
|
3012
|
-
* @returns The response from the tool execution
|
|
3013
|
-
*/
|
|
3014
|
-
async handleComposioToolExecution(tool, body, modifiers) {
|
|
3015
|
-
body = await this.applyBeforeExecuteModifiers(
|
|
3016
|
-
tool,
|
|
3017
|
-
{
|
|
3018
|
-
toolSlug: tool.slug,
|
|
3019
|
-
toolkitSlug: tool.toolkit?.slug ?? "unknown",
|
|
3020
|
-
params: body
|
|
3021
|
-
},
|
|
3022
|
-
modifiers?.beforeExecute
|
|
3023
|
-
);
|
|
3024
|
-
let connectedAccountId = body.connectedAccountId;
|
|
3025
|
-
if (!connectedAccountId && body.userId) {
|
|
3026
|
-
connectedAccountId = await this.getConnectedAccountIdForTool(body.userId, tool.slug) || void 0;
|
|
3027
|
-
}
|
|
3028
|
-
let result = await this.client.tools.execute(tool.slug, {
|
|
3029
|
-
allow_tracing: body.allowTracing,
|
|
3030
|
-
connected_account_id: body.connectedAccountId,
|
|
3031
|
-
custom_auth_params: body.customAuthParams,
|
|
3032
|
-
custom_connection_data: body.customConnectionData,
|
|
3033
|
-
arguments: body.arguments,
|
|
3034
|
-
user_id: body.userId,
|
|
3035
|
-
version: body.version ?? getToolkitVersion(tool.toolkit?.slug ?? "unknown", this.toolkitVersions),
|
|
3036
|
-
text: body.text
|
|
3037
|
-
});
|
|
3038
|
-
result = this.transformToolExecuteResponse(result);
|
|
3039
|
-
result = await this.applyAfterExecuteModifiers(
|
|
3040
|
-
tool,
|
|
3041
|
-
{
|
|
3042
|
-
toolSlug: tool.slug,
|
|
3043
|
-
toolkitSlug: tool.toolkit?.slug ?? "unknown",
|
|
3044
|
-
result
|
|
3045
|
-
},
|
|
3046
|
-
modifiers?.afterExecute
|
|
3047
|
-
);
|
|
3048
|
-
return result;
|
|
3049
3003
|
}
|
|
3050
3004
|
/**
|
|
3051
3005
|
* Executes a given tool with the provided parameters.
|
|
@@ -3053,34 +3007,68 @@ var Tools = class {
|
|
|
3053
3007
|
* This method calls the Composio API or a custom tool handler to execute the tool and returns the response.
|
|
3054
3008
|
* It automatically determines whether to use a custom tool or a Composio API tool based on the slug.
|
|
3055
3009
|
*
|
|
3010
|
+
* **Version Control:**
|
|
3011
|
+
* By default, manual tool execution requires a specific toolkit version. If the version resolves to "latest",
|
|
3012
|
+
* the execution will throw a `ComposioToolVersionRequiredError` unless `dangerouslySkipVersionCheck` is set to `true`.
|
|
3013
|
+
* This helps prevent unexpected behavior when new toolkit versions are released.
|
|
3014
|
+
*
|
|
3056
3015
|
* @param {string} slug - The slug/ID of the tool to be executed
|
|
3057
3016
|
* @param {ToolExecuteParams} body - The parameters to be passed to the tool
|
|
3017
|
+
* @param {string} [body.version] - The specific version of the tool to execute (e.g., "20250909_00")
|
|
3018
|
+
* @param {boolean} [body.dangerouslySkipVersionCheck] - Skip version validation for "latest" version (use with caution)
|
|
3019
|
+
* @param {string} [body.userId] - The user ID to execute the tool for
|
|
3020
|
+
* @param {string} [body.connectedAccountId] - The connected account ID to use for authenticated tools
|
|
3021
|
+
* @param {Record<string, unknown>} [body.arguments] - The arguments to pass to the tool
|
|
3058
3022
|
* @param {ExecuteToolModifiers} [modifiers] - Optional modifiers to transform the request or response
|
|
3059
3023
|
* @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
|
|
3060
3024
|
*
|
|
3061
3025
|
* @throws {ComposioCustomToolsNotInitializedError} If the CustomTools instance is not initialized
|
|
3026
|
+
* @throws {ComposioConnectedAccountNotFoundError} If the connected account is not found
|
|
3062
3027
|
* @throws {ComposioToolNotFoundError} If the tool with the given slug is not found
|
|
3028
|
+
* @throws {ComposioToolVersionRequiredError} If version resolves to "latest" and dangerouslySkipVersionCheck is not true
|
|
3063
3029
|
* @throws {ComposioToolExecutionError} If there is an error during tool execution
|
|
3064
3030
|
*
|
|
3065
|
-
* @example
|
|
3031
|
+
* @example Execute with a specific version (recommended for production)
|
|
3032
|
+
* ```typescript
|
|
3033
|
+
* const result = await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
3034
|
+
* userId: 'default',
|
|
3035
|
+
* version: '20250909_00',
|
|
3036
|
+
* arguments: { owner: 'composio' }
|
|
3037
|
+
* });
|
|
3038
|
+
* ```
|
|
3039
|
+
*
|
|
3040
|
+
* @example Execute with dangerouslySkipVersionCheck (not recommended for production)
|
|
3066
3041
|
* ```typescript
|
|
3067
|
-
* // Execute a Composio API tool
|
|
3068
3042
|
* const result = await composio.tools.execute('HACKERNEWS_GET_USER', {
|
|
3069
3043
|
* userId: 'default',
|
|
3070
|
-
* arguments: { userId: 'pg' }
|
|
3044
|
+
* arguments: { userId: 'pg' },
|
|
3045
|
+
* dangerouslySkipVersionCheck: true // Allows execution with "latest" version
|
|
3071
3046
|
* });
|
|
3047
|
+
* ```
|
|
3072
3048
|
*
|
|
3073
|
-
*
|
|
3049
|
+
* @example Execute with SDK-level toolkit versions configuration
|
|
3050
|
+
* ```typescript
|
|
3051
|
+
* // If toolkitVersions are set during Composio initialization, no need to pass version
|
|
3052
|
+
* const composio = new Composio({ toolkitVersions: { github: '20250909_00' } });
|
|
3053
|
+
* const result = await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
3054
|
+
* userId: 'default',
|
|
3055
|
+
* arguments: { owner: 'composio' }
|
|
3056
|
+
* });
|
|
3057
|
+
* ```
|
|
3058
|
+
*
|
|
3059
|
+
* @example Execute with modifiers
|
|
3060
|
+
* ```typescript
|
|
3074
3061
|
* const result = await composio.tools.execute('GITHUB_GET_ISSUES', {
|
|
3075
3062
|
* userId: 'default',
|
|
3063
|
+
* version: '20250909_00',
|
|
3076
3064
|
* arguments: { owner: 'composio', repo: 'sdk' }
|
|
3077
3065
|
* }, {
|
|
3078
|
-
* beforeExecute: (toolSlug, toolkitSlug, params) => {
|
|
3079
|
-
*
|
|
3066
|
+
* beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
|
|
3067
|
+
* console.log(`Executing ${toolSlug} from ${toolkitSlug}`);
|
|
3080
3068
|
* return params;
|
|
3081
3069
|
* },
|
|
3082
|
-
* afterExecute: (toolSlug, toolkitSlug, result) => {
|
|
3083
|
-
*
|
|
3070
|
+
* afterExecute: ({ toolSlug, toolkitSlug, result }) => {
|
|
3071
|
+
* console.log(`Completed ${toolSlug}`);
|
|
3084
3072
|
* return result;
|
|
3085
3073
|
* }
|
|
3086
3074
|
* });
|
|
@@ -3096,31 +3084,29 @@ var Tools = class {
|
|
|
3096
3084
|
if (!executeParams.success) {
|
|
3097
3085
|
throw new ValidationError("Invalid tool execute parameters", { cause: executeParams.error });
|
|
3098
3086
|
}
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
);
|
|
3123
|
-
}
|
|
3087
|
+
const customTool = await this.customTools.getCustomToolBySlug(slug);
|
|
3088
|
+
const tool = customTool ?? await this.getRawComposioToolBySlug(slug);
|
|
3089
|
+
const toolkitSlug = tool.toolkit?.slug ?? "unknown";
|
|
3090
|
+
const params = await this.applyBeforeExecuteModifiers(
|
|
3091
|
+
tool,
|
|
3092
|
+
{
|
|
3093
|
+
toolSlug: slug,
|
|
3094
|
+
toolkitSlug,
|
|
3095
|
+
params: executeParams.data
|
|
3096
|
+
},
|
|
3097
|
+
modifiers?.beforeExecute
|
|
3098
|
+
);
|
|
3099
|
+
let result = customTool ? await this.customTools.executeCustomTool(customTool.slug, params) : await this.executeComposioTool(tool, params);
|
|
3100
|
+
result = await this.applyAfterExecuteModifiers(
|
|
3101
|
+
tool,
|
|
3102
|
+
{
|
|
3103
|
+
toolSlug: slug,
|
|
3104
|
+
toolkitSlug,
|
|
3105
|
+
result
|
|
3106
|
+
},
|
|
3107
|
+
modifiers?.afterExecute
|
|
3108
|
+
);
|
|
3109
|
+
return result;
|
|
3124
3110
|
}
|
|
3125
3111
|
/**
|
|
3126
3112
|
* Fetches the list of all available tools in the Composio SDK.
|
|
@@ -4080,7 +4066,7 @@ var ConnectedAccounts = class {
|
|
|
4080
4066
|
};
|
|
4081
4067
|
|
|
4082
4068
|
// src/models/Toolkits.ts
|
|
4083
|
-
import { APIError } from "openai";
|
|
4069
|
+
import { APIError as APIError2 } from "openai";
|
|
4084
4070
|
|
|
4085
4071
|
// src/utils/transformers/toolkits.ts
|
|
4086
4072
|
var transformToolkitListResponse = (response) => {
|
|
@@ -4211,7 +4197,7 @@ var Toolkits = class {
|
|
|
4211
4197
|
const result = await this.client.toolkits.retrieve(slug);
|
|
4212
4198
|
return transformToolkitRetrieveResponse(result);
|
|
4213
4199
|
} catch (error) {
|
|
4214
|
-
if (error instanceof
|
|
4200
|
+
if (error instanceof APIError2 && (error.status === 404 || error.status === 400)) {
|
|
4215
4201
|
throw new ComposioToolkitNotFoundError(`Toolkit with slug ${slug} not found`, {
|
|
4216
4202
|
meta: {
|
|
4217
4203
|
slug
|
|
@@ -4400,7 +4386,7 @@ var Toolkits = class {
|
|
|
4400
4386
|
};
|
|
4401
4387
|
|
|
4402
4388
|
// src/models/Triggers.ts
|
|
4403
|
-
import { APIError as
|
|
4389
|
+
import { APIError as APIError3 } from "@composio/client";
|
|
4404
4390
|
|
|
4405
4391
|
// src/types/triggers.types.ts
|
|
4406
4392
|
import { z as z6 } from "zod/v3";
|
|
@@ -4916,7 +4902,7 @@ var Triggers = class {
|
|
|
4916
4902
|
triggerType = await this.getType(slug);
|
|
4917
4903
|
toolkitSlug = triggerType.toolkit.slug;
|
|
4918
4904
|
} catch (error) {
|
|
4919
|
-
if (error instanceof
|
|
4905
|
+
if (error instanceof APIError3 && (error.status === 400 || error.status === 404)) {
|
|
4920
4906
|
throw new ComposioTriggerTypeNotFoundError(`Trigger type ${slug} not found`, {
|
|
4921
4907
|
cause: error,
|
|
4922
4908
|
possibleFixes: [
|
|
@@ -4965,7 +4951,7 @@ var Triggers = class {
|
|
|
4965
4951
|
);
|
|
4966
4952
|
}
|
|
4967
4953
|
} catch (error) {
|
|
4968
|
-
if (error instanceof
|
|
4954
|
+
if (error instanceof APIError3 && [400, 404].includes(error.status)) {
|
|
4969
4955
|
throw new ComposioConnectedAccountNotFoundError(
|
|
4970
4956
|
`No connected account found for user ${userId} for toolkit ${toolkitSlug}`,
|
|
4971
4957
|
{
|
|
@@ -7177,7 +7163,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
7177
7163
|
};
|
|
7178
7164
|
|
|
7179
7165
|
// package.json
|
|
7180
|
-
var version = "0.
|
|
7166
|
+
var version = "0.2.0";
|
|
7181
7167
|
|
|
7182
7168
|
// src/models/Files.ts
|
|
7183
7169
|
var Files = class {
|
|
@@ -7721,6 +7707,7 @@ export {
|
|
|
7721
7707
|
ComposioProviderNotDefinedError,
|
|
7722
7708
|
ComposioToolExecutionError,
|
|
7723
7709
|
ComposioToolNotFoundError,
|
|
7710
|
+
ComposioToolVersionRequiredError,
|
|
7724
7711
|
ComposioToolkitFetchError,
|
|
7725
7712
|
ComposioToolkitNotFoundError,
|
|
7726
7713
|
ConnectedAccountAuthConfigSchema,
|
|
@@ -7832,6 +7819,7 @@ export {
|
|
|
7832
7819
|
ValidationErrorCodes,
|
|
7833
7820
|
constants_exports as constants,
|
|
7834
7821
|
createConnectionRequest,
|
|
7822
|
+
handleToolExecutionError,
|
|
7835
7823
|
jsonSchemaToZodSchema,
|
|
7836
7824
|
logger_default as logger,
|
|
7837
7825
|
removeNonRequiredProperties
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"semver": "^7.7.2",
|
|
48
48
|
"uuid": "^13.0.0",
|
|
49
49
|
"zod-to-json-schema": "^3.24.5",
|
|
50
|
-
"@composio/json-schema-to-zod": "0.1.
|
|
50
|
+
"@composio/json-schema-to-zod": "0.1.17"
|
|
51
51
|
},
|
|
52
52
|
"gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064",
|
|
53
53
|
"scripts": {
|