@composio/core 0.10.0 → 0.11.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/{tool.types-CB_4JKhV.d.mts → BaseProvider-BvHvJLXc.d.mts} +24346 -24345
- package/dist/{tool.types-CwbAy9l_.d.cts → BaseProvider-CVbQxTNa.d.cts} +24346 -24345
- package/dist/{CustomTool-aber890o.d.cts → CustomTool-C-IUByoU.d.cts} +1 -1
- package/dist/{CustomTool-DJUGNOer.d.mts → CustomTool-CChQSp44.d.mts} +1 -1
- package/dist/{CustomTool-CQ_YjABZ.cjs → CustomTool-D3-NreIm.cjs} +79 -79
- package/dist/{CustomTool-D7-1S2at.mjs → CustomTool-D5s-aADw.mjs} +74 -74
- package/dist/{FileToolModifier.utils.neutral-B7P7wn-b.mjs → FileToolModifier.utils.neutral-BpSceNK8.mjs} +1 -7
- package/dist/{FileToolModifier.utils.neutral-Dfwqgimk.cjs → FileToolModifier.utils.neutral-DSBQs9-i.cjs} +2 -8
- package/dist/{Telemetry-Dm-0sewu.cjs → Telemetry-BQ_pl5AK.cjs} +34 -9
- package/dist/{Telemetry-kgWlkavX.mjs → Telemetry-DQax33Gh.mjs} +34 -9
- package/dist/{composio-DRl6WCI9.d.mts → composio-BlASKqjQ.d.mts} +161 -208
- package/dist/{composio-CSMCZZgj.d.cts → composio-pcA13w87.d.cts} +161 -208
- package/dist/{customTool.types-CMOMgxoM.d.mts → customTool.types-DLIORcYN.d.mts} +43 -81
- package/dist/{customTool.types-BzEWHa0w.d.cts → customTool.types-QtkAZQma.d.cts} +43 -81
- package/dist/experimental/index.cjs +1 -1
- package/dist/experimental/index.d.cts +2 -2
- package/dist/experimental/index.d.mts +3 -3
- package/dist/experimental/index.mjs +1 -1
- package/dist/index.cjs +476 -590
- package/dist/index.d.cts +406 -13
- package/dist/index.d.mts +406 -13
- package/dist/index.mjs +473 -588
- package/dist/models/Files.node.cjs +1 -1
- package/dist/models/Files.node.mjs +1 -1
- package/dist/{types-BTOPdg4d.d.mts → types-DRG5qLxI.d.cts} +2 -2
- package/dist/{types-DE7O6Z6S.d.cts → types-J2KCXP8R.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +4 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +4 -4
- package/dist/utils/modifiers/FileToolModifier.node.cjs +38 -21
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +38 -21
- package/dist/utils/modifiers/FileToolModifier.workerd.cjs +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/package.json +11 -2
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CQwRTUmo.cjs');
|
|
2
2
|
const require_FileModifierErrors = require('./FileModifierErrors-BYJBHiay.cjs');
|
|
3
|
-
const require_CustomTool = require('./CustomTool-
|
|
4
|
-
const require_Telemetry = require('./Telemetry-
|
|
3
|
+
const require_CustomTool = require('./CustomTool-D3-NreIm.cjs');
|
|
4
|
+
const require_Telemetry = require('./Telemetry-BQ_pl5AK.cjs');
|
|
5
5
|
const require_buffer = require('./buffer-BjWptbNH.cjs');
|
|
6
|
-
const require_FileToolModifier_utils_neutral = require('./FileToolModifier.utils.neutral-
|
|
6
|
+
const require_FileToolModifier_utils_neutral = require('./FileToolModifier.utils.neutral-DSBQs9-i.cjs');
|
|
7
7
|
let _composio_client = require("@composio/client");
|
|
8
8
|
_composio_client = require_chunk.__toESM(_composio_client);
|
|
9
9
|
let _file_tool_modifier = require("#file_tool_modifier");
|
|
10
10
|
let zod_v3 = require("zod/v3");
|
|
11
11
|
zod_v3 = require_chunk.__toESM(zod_v3);
|
|
12
|
-
let zod_to_json_schema = require("zod-to-json-schema");
|
|
13
|
-
zod_to_json_schema = require_chunk.__toESM(zod_to_json_schema);
|
|
14
12
|
let _config_defaults = require("#config_defaults");
|
|
15
13
|
let _platform = require("#platform");
|
|
16
14
|
let openai = require("openai");
|
|
@@ -1016,490 +1014,6 @@ const ToolProxyParamsSchema = zod_v3.z.object({
|
|
|
1016
1014
|
customConnectionData: CustomConnectionDataSchema.describe("DEPRECATED: This field is deprecated and will be removed in the future.").optional()
|
|
1017
1015
|
});
|
|
1018
1016
|
|
|
1019
|
-
//#endregion
|
|
1020
|
-
//#region src/types/connectedAccounts.types.ts
|
|
1021
|
-
/**
|
|
1022
|
-
* Connected Account create parameters
|
|
1023
|
-
*/
|
|
1024
|
-
const ConnectedAccountStatuses = {
|
|
1025
|
-
INITIALIZING: "INITIALIZING",
|
|
1026
|
-
INITIATED: "INITIATED",
|
|
1027
|
-
ACTIVE: "ACTIVE",
|
|
1028
|
-
FAILED: "FAILED",
|
|
1029
|
-
EXPIRED: "EXPIRED",
|
|
1030
|
-
INACTIVE: "INACTIVE",
|
|
1031
|
-
REVOKED: "REVOKED"
|
|
1032
|
-
};
|
|
1033
|
-
const ConnectedAccountStatusSchema = zod_v3.z.enum([
|
|
1034
|
-
ConnectedAccountStatuses.INITIALIZING,
|
|
1035
|
-
ConnectedAccountStatuses.INITIATED,
|
|
1036
|
-
ConnectedAccountStatuses.ACTIVE,
|
|
1037
|
-
ConnectedAccountStatuses.FAILED,
|
|
1038
|
-
ConnectedAccountStatuses.EXPIRED,
|
|
1039
|
-
ConnectedAccountStatuses.INACTIVE,
|
|
1040
|
-
ConnectedAccountStatuses.REVOKED
|
|
1041
|
-
]);
|
|
1042
|
-
/**
|
|
1043
|
-
* Sharing model for a connected account.
|
|
1044
|
-
*
|
|
1045
|
-
* - `PRIVATE` (default): only the owning `userId` can use the connection.
|
|
1046
|
-
* - `SHARED`: can be used by other `userId`s, but only when the connection
|
|
1047
|
-
* is explicitly pinned in a tool-router session's config and only when
|
|
1048
|
-
* the requesting `userId` passes the connection's ACL (see
|
|
1049
|
-
* `allowAllUsers` / `allowedUserIds` / `notAllowedUserIds`).
|
|
1050
|
-
*/
|
|
1051
|
-
const ConnectedAccountTypes = {
|
|
1052
|
-
PRIVATE: "PRIVATE",
|
|
1053
|
-
SHARED: "SHARED"
|
|
1054
|
-
};
|
|
1055
|
-
const ConnectedAccountTypeSchema = zod_v3.z.enum([ConnectedAccountTypes.PRIVATE, ConnectedAccountTypes.SHARED]);
|
|
1056
|
-
/**
|
|
1057
|
-
* Per-user access control for a SHARED connected account. Ignored for
|
|
1058
|
-
* PRIVATE.
|
|
1059
|
-
*
|
|
1060
|
-
* Pass `aclConfigForShared` on create / PATCH to grant access; omit it
|
|
1061
|
-
* to leave the ACL unchanged (on PATCH) or to keep the default
|
|
1062
|
-
* deny-by-default state (on create). On responses, the field is
|
|
1063
|
-
* `undefined` when the caller isn't authorised to see the ACL —
|
|
1064
|
-
* distinguish that from an empty/default state explicitly.
|
|
1065
|
-
*
|
|
1066
|
-
* Resolution rule (deny wins):
|
|
1067
|
-
* 1. requesting `userId` in `notAllowedUserIds` → DENY
|
|
1068
|
-
* 2. `allowAllUsers === true` → ALLOW
|
|
1069
|
-
* 3. requesting `userId` in `allowedUserIds` → ALLOW
|
|
1070
|
-
* 4. otherwise → DENY (deny-by-default)
|
|
1071
|
-
*
|
|
1072
|
-
* Default state (block omitted or `{}`) means only the connection's
|
|
1073
|
-
* creator can use it. The creator must grant access explicitly.
|
|
1074
|
-
*
|
|
1075
|
-
* Limits: each list accepts up to 1000 entries; each `userId` is
|
|
1076
|
-
* 1..256 characters.
|
|
1077
|
-
*/
|
|
1078
|
-
const ACL_LIST_MAX_LENGTH = 1e3;
|
|
1079
|
-
const aclUserIdString = zod_v3.z.string().min(1).max(256);
|
|
1080
|
-
const ConnectedAccountAclConfigSchema = zod_v3.z.object({
|
|
1081
|
-
allowAllUsers: zod_v3.z.boolean().optional().describe("When true, any `userId` may use this SHARED connection (subject to the deny list). Default false."),
|
|
1082
|
-
allowedUserIds: zod_v3.z.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings allowed to use this SHARED connection. Default []."),
|
|
1083
|
-
notAllowedUserIds: zod_v3.z.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings denied access. Wins over allow on conflict. Default [].")
|
|
1084
|
-
});
|
|
1085
|
-
/**
|
|
1086
|
-
* Resolved ACL as it appears on responses. All three fields are populated
|
|
1087
|
-
* when the field is visible; the field itself is `undefined` for callers
|
|
1088
|
-
* not authorised to see it.
|
|
1089
|
-
*/
|
|
1090
|
-
const ConnectedAccountAclConfigResponseSchema = zod_v3.z.object({
|
|
1091
|
-
allowAllUsers: zod_v3.z.boolean(),
|
|
1092
|
-
allowedUserIds: zod_v3.z.array(zod_v3.z.string()),
|
|
1093
|
-
notAllowedUserIds: zod_v3.z.array(zod_v3.z.string())
|
|
1094
|
-
});
|
|
1095
|
-
/**
|
|
1096
|
-
* Experimental options for SHARED connections, passed at create / link time.
|
|
1097
|
-
*
|
|
1098
|
-
* **Experimental — shape may change in future releases.** Wrapped under a
|
|
1099
|
-
* dedicated `experimental` block on every input and response so the
|
|
1100
|
-
* experimental status is visible at every call site.
|
|
1101
|
-
*/
|
|
1102
|
-
const ConnectedAccountExperimentalSchema = zod_v3.z.object({
|
|
1103
|
-
accountType: ConnectedAccountTypeSchema.optional(),
|
|
1104
|
-
aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
|
|
1105
|
-
});
|
|
1106
|
-
/**
|
|
1107
|
-
* Resolved experimental block on retrieve / list responses. `accountType`
|
|
1108
|
-
* is always present when the block is; `aclConfigForShared` is only
|
|
1109
|
-
* present when the caller is authorised to see the ACL.
|
|
1110
|
-
*/
|
|
1111
|
-
const ConnectedAccountExperimentalResponseSchema = zod_v3.z.object({
|
|
1112
|
-
accountType: ConnectedAccountTypeSchema.optional(),
|
|
1113
|
-
aclConfigForShared: ConnectedAccountAclConfigResponseSchema.optional()
|
|
1114
|
-
});
|
|
1115
|
-
const CreateConnectedAccountParamsSchema = zod_v3.z.object({
|
|
1116
|
-
authConfig: zod_v3.z.object({ id: zod_v3.z.string() }),
|
|
1117
|
-
connection: zod_v3.z.object({
|
|
1118
|
-
data: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
|
|
1119
|
-
callbackUrl: zod_v3.z.string().optional(),
|
|
1120
|
-
userId: zod_v3.z.string().optional()
|
|
1121
|
-
})
|
|
1122
|
-
});
|
|
1123
|
-
const DefaultCreateConnectedAccountParamsSchema = zod_v3.z.object({
|
|
1124
|
-
auth_config: zod_v3.z.object({ id: zod_v3.z.string() }),
|
|
1125
|
-
connection: zod_v3.z.object({
|
|
1126
|
-
state: ConnectionDataSchema.optional(),
|
|
1127
|
-
data: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
|
|
1128
|
-
callback_url: zod_v3.z.string().optional(),
|
|
1129
|
-
user_id: zod_v3.z.string().optional(),
|
|
1130
|
-
alias: zod_v3.z.string().optional()
|
|
1131
|
-
})
|
|
1132
|
-
});
|
|
1133
|
-
const CreateConnectedAccountOptionsSchema = zod_v3.z.object({
|
|
1134
|
-
allowMultiple: zod_v3.z.boolean().optional(),
|
|
1135
|
-
callbackUrl: zod_v3.z.string().optional(),
|
|
1136
|
-
config: ConnectionDataSchema.optional(),
|
|
1137
|
-
alias: zod_v3.z.string().optional()
|
|
1138
|
-
});
|
|
1139
|
-
/**
|
|
1140
|
-
* Connected Account create response
|
|
1141
|
-
*/
|
|
1142
|
-
const CreateConnectedAccountResponseSchema = zod_v3.z.object({
|
|
1143
|
-
id: zod_v3.z.string(),
|
|
1144
|
-
status: ConnectedAccountStatusSchema,
|
|
1145
|
-
redirectUrl: zod_v3.z.string().nullable()
|
|
1146
|
-
});
|
|
1147
|
-
const ConnectedAccountAuthConfigSchema = zod_v3.z.object({
|
|
1148
|
-
id: zod_v3.z.string(),
|
|
1149
|
-
authScheme: AuthSchemeEnum.optional(),
|
|
1150
|
-
isComposioManaged: zod_v3.z.boolean(),
|
|
1151
|
-
isDisabled: zod_v3.z.boolean()
|
|
1152
|
-
});
|
|
1153
|
-
const ConnectedAccountRetrieveResponseSchema = zod_v3.z.object({
|
|
1154
|
-
id: zod_v3.z.string(),
|
|
1155
|
-
authConfig: ConnectedAccountAuthConfigSchema,
|
|
1156
|
-
wordId: zod_v3.z.string().nullable().optional(),
|
|
1157
|
-
alias: zod_v3.z.string().nullable().optional(),
|
|
1158
|
-
data: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
|
|
1159
|
-
params: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
|
|
1160
|
-
status: ConnectedAccountStatusSchema,
|
|
1161
|
-
statusReason: zod_v3.z.string().nullable(),
|
|
1162
|
-
toolkit: zod_v3.z.object({ slug: zod_v3.z.string() }),
|
|
1163
|
-
state: ConnectionDataSchema.optional(),
|
|
1164
|
-
testRequestEndpoint: zod_v3.z.string().optional(),
|
|
1165
|
-
isDisabled: zod_v3.z.boolean(),
|
|
1166
|
-
createdAt: zod_v3.z.string(),
|
|
1167
|
-
updatedAt: zod_v3.z.string(),
|
|
1168
|
-
experimental: ConnectedAccountExperimentalResponseSchema.optional()
|
|
1169
|
-
});
|
|
1170
|
-
const ConnectedAccountListParamsSchema = zod_v3.z.object({
|
|
1171
|
-
authConfigIds: zod_v3.z.array(zod_v3.z.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
|
|
1172
|
-
cursor: zod_v3.z.string().nullish().describe("The cursor to paginate through the connected accounts"),
|
|
1173
|
-
limit: zod_v3.z.number().nullable().optional().describe("The limit of the connected accounts to return"),
|
|
1174
|
-
orderBy: zod_v3.z.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
|
|
1175
|
-
statuses: zod_v3.z.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
|
|
1176
|
-
toolkitSlugs: zod_v3.z.array(zod_v3.z.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
|
|
1177
|
-
userIds: zod_v3.z.array(zod_v3.z.string()).nullable().optional().describe("The user ids of the connected accounts"),
|
|
1178
|
-
accountType: zod_v3.z.enum([
|
|
1179
|
-
"PRIVATE",
|
|
1180
|
-
"SHARED",
|
|
1181
|
-
"ALL"
|
|
1182
|
-
]).optional()
|
|
1183
|
-
});
|
|
1184
|
-
const ConnectedAccountListResponseSchema = zod_v3.z.object({
|
|
1185
|
-
items: zod_v3.z.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
|
|
1186
|
-
nextCursor: zod_v3.z.string().nullish().describe("The next cursor to paginate through the connected accounts"),
|
|
1187
|
-
totalPages: zod_v3.z.number().describe("The total number of pages of connected accounts")
|
|
1188
|
-
});
|
|
1189
|
-
const CreateConnectedAccountLinkOptionsSchema = zod_v3.z.object({
|
|
1190
|
-
callbackUrl: zod_v3.z.string().optional(),
|
|
1191
|
-
alias: zod_v3.z.string().optional(),
|
|
1192
|
-
allowMultiple: zod_v3.z.boolean().optional(),
|
|
1193
|
-
experimental: ConnectedAccountExperimentalSchema.optional()
|
|
1194
|
-
});
|
|
1195
|
-
const CreateConnectedAccountLinkResponseSchema = zod_v3.z.object({ redirectUrl: zod_v3.z.string() });
|
|
1196
|
-
const ConnectedAccountRefreshOptionsSchema = zod_v3.z.object({
|
|
1197
|
-
redirectUrl: zod_v3.z.string().optional(),
|
|
1198
|
-
validateCredentials: zod_v3.z.boolean().optional()
|
|
1199
|
-
});
|
|
1200
|
-
const UpdateConnectedAccountParamsSchema = zod_v3.z.object({ enabled: zod_v3.z.boolean() });
|
|
1201
|
-
/**
|
|
1202
|
-
* Params for `composio.connectedAccounts.updateAcl()`. Mirrors the inner
|
|
1203
|
-
* shape of the wire's `acl_config_for_shared` block — the SDK adds the
|
|
1204
|
-
* outer nesting at the boundary, so callers pass the three fields flat.
|
|
1205
|
-
*
|
|
1206
|
-
* PATCH-style semantics — omit a field to leave it unchanged; pass an
|
|
1207
|
-
* empty array to clear an allow/deny list. Raises
|
|
1208
|
-
* `ComposioAclOnlyForSharedError` on a PRIVATE connection.
|
|
1209
|
-
*
|
|
1210
|
-
* Each field is optional, but at least one must be provided — passing an
|
|
1211
|
-
* empty object is rejected as a no-op.
|
|
1212
|
-
*/
|
|
1213
|
-
const UpdateConnectedAccountAclParamsSchema = ConnectedAccountAclConfigSchema.refine((acl) => acl.allowAllUsers !== void 0 || acl.allowedUserIds !== void 0 || acl.notAllowedUserIds !== void 0, { message: "At least one of allowAllUsers, allowedUserIds, or notAllowedUserIds must be provided" });
|
|
1214
|
-
|
|
1215
|
-
//#endregion
|
|
1216
|
-
//#region src/utils/transform.ts
|
|
1217
|
-
function transform(raw) {
|
|
1218
|
-
return { with(schema) {
|
|
1219
|
-
return { using(transformer, options) {
|
|
1220
|
-
const transformed = transformer(raw);
|
|
1221
|
-
const result = schema.safeParse(transformed);
|
|
1222
|
-
if (!result.success) {
|
|
1223
|
-
const label = options?.label ? ` for ${options.label}` : "";
|
|
1224
|
-
const issues = result.error.issues.map((issue) => ` - ${issue.path.join(".") || "parameter"}: ${issue.message}`).join("\n");
|
|
1225
|
-
require_FileModifierErrors.logger_default.warn(`Transform validation failed${label}:\n${issues}`);
|
|
1226
|
-
return transformed;
|
|
1227
|
-
}
|
|
1228
|
-
return result.data;
|
|
1229
|
-
} };
|
|
1230
|
-
} };
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
//#endregion
|
|
1234
|
-
//#region src/utils/transformers/connectedAccounts.ts
|
|
1235
|
-
/**
|
|
1236
|
-
* Transforms the raw connected account response from the Composio API to the SDK format.
|
|
1237
|
-
*
|
|
1238
|
-
* This method converts property names from snake_case to camelCase and reorganizes
|
|
1239
|
-
* the data structure to match the SDK's standardized format.
|
|
1240
|
-
*
|
|
1241
|
-
* @param {RawConnectedAccountListResponse['items'][0]|RawConnectedAccountRetrieveResponse} response - The raw API response to transform
|
|
1242
|
-
* @returns {Promise<ConnectedAccountRetrieveResponse>} The transformed response
|
|
1243
|
-
* @throws {ZodError} If the response fails validation against the expected schema
|
|
1244
|
-
*
|
|
1245
|
-
* @private
|
|
1246
|
-
*/
|
|
1247
|
-
function transformConnectedAccountResponse(response) {
|
|
1248
|
-
const responseWithLabels = response;
|
|
1249
|
-
const parseState = (state) => {
|
|
1250
|
-
try {
|
|
1251
|
-
return state ? ConnectionDataSchema.parse(state) : void 0;
|
|
1252
|
-
} catch (error) {
|
|
1253
|
-
require_FileModifierErrors.logger_default.warn("Unsupported auth scheme in connected account state, ignoring state field", { error });
|
|
1254
|
-
return;
|
|
1255
|
-
}
|
|
1256
|
-
};
|
|
1257
|
-
return transform(response).with(ConnectedAccountRetrieveResponseSchema).using((response$1) => ({
|
|
1258
|
-
...response$1,
|
|
1259
|
-
authConfig: {
|
|
1260
|
-
...response$1.auth_config,
|
|
1261
|
-
id: response$1.auth_config.id,
|
|
1262
|
-
authScheme: response$1.auth_config.auth_scheme,
|
|
1263
|
-
isComposioManaged: response$1.auth_config.is_composio_managed,
|
|
1264
|
-
isDisabled: response$1.auth_config.is_disabled
|
|
1265
|
-
},
|
|
1266
|
-
wordId: responseWithLabels.word_id ?? null,
|
|
1267
|
-
alias: responseWithLabels.alias ?? null,
|
|
1268
|
-
data: response$1.data ?? void 0,
|
|
1269
|
-
state: parseState(response$1.state),
|
|
1270
|
-
status: response$1.status,
|
|
1271
|
-
statusReason: response$1.status_reason,
|
|
1272
|
-
isDisabled: response$1.is_disabled,
|
|
1273
|
-
createdAt: response$1.created_at,
|
|
1274
|
-
updatedAt: response$1.updated_at,
|
|
1275
|
-
testRequestEndpoint: response$1.test_request_endpoint,
|
|
1276
|
-
experimental: responseWithLabels.experimental ? {
|
|
1277
|
-
accountType: responseWithLabels.experimental.account_type,
|
|
1278
|
-
aclConfigForShared: responseWithLabels.experimental.acl_config_for_shared ? {
|
|
1279
|
-
allowAllUsers: responseWithLabels.experimental.acl_config_for_shared.allow_all_users,
|
|
1280
|
-
allowedUserIds: responseWithLabels.experimental.acl_config_for_shared.allowed_user_ids,
|
|
1281
|
-
notAllowedUserIds: responseWithLabels.experimental.acl_config_for_shared.not_allowed_user_ids
|
|
1282
|
-
} : void 0
|
|
1283
|
-
} : void 0
|
|
1284
|
-
}));
|
|
1285
|
-
}
|
|
1286
|
-
/**
|
|
1287
|
-
* Transforms the raw connected account list response from the Composio API to the SDK format.
|
|
1288
|
-
*
|
|
1289
|
-
* This method converts property names from snake_case to camelCase and reorganizes
|
|
1290
|
-
* the data structure to match the SDK's standardized format.
|
|
1291
|
-
*
|
|
1292
|
-
* @param {RawConnectedAccountListResponse} response - The raw API response to transform
|
|
1293
|
-
* @returns {ConnectedAccountListResponse} The transformed response
|
|
1294
|
-
* @throws {ZodError} If the response fails validation against the expected schema
|
|
1295
|
-
*
|
|
1296
|
-
* @private
|
|
1297
|
-
*/
|
|
1298
|
-
function transformConnectedAccountListResponse(response) {
|
|
1299
|
-
return transform(response).with(ConnectedAccountListResponseSchema).using((response$1) => ({
|
|
1300
|
-
items: response$1.items.map(transformConnectedAccountResponse),
|
|
1301
|
-
nextCursor: response$1.next_cursor ?? null,
|
|
1302
|
-
totalPages: response$1.total_pages
|
|
1303
|
-
}));
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
//#endregion
|
|
1307
|
-
//#region src/models/CustomTools.ts
|
|
1308
|
-
var CustomTools = class {
|
|
1309
|
-
client;
|
|
1310
|
-
customToolsRegistry;
|
|
1311
|
-
constructor(client) {
|
|
1312
|
-
if (!client) throw new require_FileModifierErrors.ComposioError("ComposioClient is required");
|
|
1313
|
-
this.client = client;
|
|
1314
|
-
this.customToolsRegistry = /* @__PURE__ */ new Map();
|
|
1315
|
-
require_Telemetry.telemetry.instrument(this, "CustomTools");
|
|
1316
|
-
}
|
|
1317
|
-
/**
|
|
1318
|
-
* Create a custom tool and registers it in the registry.
|
|
1319
|
-
* This is just an in memory registry and is not persisted.
|
|
1320
|
-
* @param {CustomToolOptions} toolOptions CustomToolOptions
|
|
1321
|
-
* @returns {Tool} The tool created
|
|
1322
|
-
*
|
|
1323
|
-
* @example
|
|
1324
|
-
* ```typescript
|
|
1325
|
-
* // Create a custom tool with input parameters
|
|
1326
|
-
* const customTool = await composio.customTools.createTool({
|
|
1327
|
-
* name: 'My Custom Tool',
|
|
1328
|
-
* description: 'A tool that performs a custom operation',
|
|
1329
|
-
* slug: 'MY_CUSTOM_TOOL',
|
|
1330
|
-
* inputParams: z.object({
|
|
1331
|
-
* query: z.string().describe('The search query'),
|
|
1332
|
-
* limit: z.number().optional().describe('Maximum number of results')
|
|
1333
|
-
* }),
|
|
1334
|
-
* execute: async (input, connectionConfig, executeToolRequest) => {
|
|
1335
|
-
* // Custom implementation logic
|
|
1336
|
-
* return {
|
|
1337
|
-
* data: { results: ['result1', 'result2'] }
|
|
1338
|
-
* };
|
|
1339
|
-
* }
|
|
1340
|
-
* });
|
|
1341
|
-
* ```
|
|
1342
|
-
*/
|
|
1343
|
-
async createTool(toolOptions) {
|
|
1344
|
-
const { slug, execute, inputParams, name, description } = toolOptions;
|
|
1345
|
-
if (!slug || !execute || !inputParams || !name) throw new Error("Invalid tool options");
|
|
1346
|
-
const paramsSchemaJson = zod_to_json_schema.default(inputParams, { name: "input" }).definitions.input;
|
|
1347
|
-
const toolSchema = {
|
|
1348
|
-
name,
|
|
1349
|
-
slug,
|
|
1350
|
-
description,
|
|
1351
|
-
inputParameters: {
|
|
1352
|
-
title: name,
|
|
1353
|
-
type: "object",
|
|
1354
|
-
description,
|
|
1355
|
-
properties: paramsSchemaJson.properties,
|
|
1356
|
-
required: paramsSchemaJson.required
|
|
1357
|
-
},
|
|
1358
|
-
outputParameters: {
|
|
1359
|
-
type: "object",
|
|
1360
|
-
title: `Response for ${name}`,
|
|
1361
|
-
properties: {}
|
|
1362
|
-
},
|
|
1363
|
-
tags: [],
|
|
1364
|
-
toolkit: {
|
|
1365
|
-
name: "custom",
|
|
1366
|
-
slug: "custom"
|
|
1367
|
-
}
|
|
1368
|
-
};
|
|
1369
|
-
this.customToolsRegistry.set(slug.toLowerCase(), {
|
|
1370
|
-
options: toolOptions,
|
|
1371
|
-
schema: toolSchema
|
|
1372
|
-
});
|
|
1373
|
-
return toolSchema;
|
|
1374
|
-
}
|
|
1375
|
-
/**
|
|
1376
|
-
* Get all the custom tools from the registry.
|
|
1377
|
-
* @param {string[]} param0.toolSlugs The slugs of the tools to get
|
|
1378
|
-
* @returns {ToolList} The list of tools
|
|
1379
|
-
*
|
|
1380
|
-
* @example
|
|
1381
|
-
* ```typescript
|
|
1382
|
-
* // Get all custom tools
|
|
1383
|
-
* const allTools = await composio.customTools.getCustomTools({});
|
|
1384
|
-
*
|
|
1385
|
-
* // Get specific custom tools by slug
|
|
1386
|
-
* const specificTools = await composio.customTools.getCustomTools({
|
|
1387
|
-
* toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL']
|
|
1388
|
-
* });
|
|
1389
|
-
* ```
|
|
1390
|
-
*/
|
|
1391
|
-
async getCustomTools({ toolSlugs }) {
|
|
1392
|
-
const tools = [];
|
|
1393
|
-
if (toolSlugs) for (const slug of toolSlugs) {
|
|
1394
|
-
const tool = this.customToolsRegistry.get(slug.toLowerCase());
|
|
1395
|
-
if (tool) tools.push(tool.schema);
|
|
1396
|
-
}
|
|
1397
|
-
else return Array.from(this.customToolsRegistry.values()).map((tool) => tool.schema);
|
|
1398
|
-
return tools;
|
|
1399
|
-
}
|
|
1400
|
-
/**
|
|
1401
|
-
* Get a custom tool by slug from the registry.
|
|
1402
|
-
* @param {string} slug The slug of the tool to get
|
|
1403
|
-
* @returns {Tool} The tool
|
|
1404
|
-
*
|
|
1405
|
-
* @example
|
|
1406
|
-
* ```typescript
|
|
1407
|
-
* // Get a specific custom tool by its slug
|
|
1408
|
-
* const myTool = await composio.customTools.getCustomToolBySlug('MY_CUSTOM_TOOL');
|
|
1409
|
-
* if (myTool) {
|
|
1410
|
-
* console.log(`Found tool: ${myTool.name}`);
|
|
1411
|
-
* } else {
|
|
1412
|
-
* console.log('Tool not found');
|
|
1413
|
-
* }
|
|
1414
|
-
* ```
|
|
1415
|
-
*/
|
|
1416
|
-
async getCustomToolBySlug(slug) {
|
|
1417
|
-
try {
|
|
1418
|
-
return this.customToolsRegistry.get(slug.toLowerCase())?.schema;
|
|
1419
|
-
} catch (error) {
|
|
1420
|
-
require_FileModifierErrors.logger_default.error(`Error getting custom tool: ${error}`);
|
|
1421
|
-
return;
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
/**
|
|
1425
|
-
* Get the connected account for the user and toolkit.
|
|
1426
|
-
* @param {string} toolkitSlug The slug of the toolkit
|
|
1427
|
-
* @param {ExecuteMetadata} metadata The metadata of the execution
|
|
1428
|
-
* @returns {ConnectedAccount} The connected account
|
|
1429
|
-
*/
|
|
1430
|
-
async getConnectedAccountForToolkit(toolkitSlug, userId, connectedAccountId) {
|
|
1431
|
-
try {
|
|
1432
|
-
await this.client.toolkits.retrieve(toolkitSlug);
|
|
1433
|
-
if ((await this.client.toolkits.retrieve(toolkitSlug)).auth_config_details?.some((details) => details.mode === AuthSchemeTypes.NO_AUTH)) return null;
|
|
1434
|
-
} catch (error) {
|
|
1435
|
-
throw new require_CustomTool.ComposioToolNotFoundError(`Toolkit with slug ${toolkitSlug} not found`, { cause: error });
|
|
1436
|
-
}
|
|
1437
|
-
const connectedAccounts = await this.client.connectedAccounts.list({
|
|
1438
|
-
toolkit_slugs: [toolkitSlug],
|
|
1439
|
-
user_ids: [userId]
|
|
1440
|
-
});
|
|
1441
|
-
if (!connectedAccounts.items.length) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`No connected accounts found for toolkit ${toolkitSlug}`);
|
|
1442
|
-
const connectedAccount = connectedAccountId ? connectedAccounts.items.find((item) => item.id === connectedAccountId) : connectedAccounts.items[0];
|
|
1443
|
-
if (!connectedAccount) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${userId}`);
|
|
1444
|
-
return transformConnectedAccountResponse(connectedAccount);
|
|
1445
|
-
}
|
|
1446
|
-
/**
|
|
1447
|
-
* Execute a custom tool
|
|
1448
|
-
*
|
|
1449
|
-
* @description If a toolkit is used, the connected account id is used to execute the tool.
|
|
1450
|
-
* If a connected account id is provided, it is used to execute the tool.
|
|
1451
|
-
* If a connected account id is not provided, the first connected account for the toolkit is used.
|
|
1452
|
-
*
|
|
1453
|
-
* @param {slug} slug The slug of the tool to execute
|
|
1454
|
-
* @param {Record<string, unknown>} inputParams The input parameters for the tool
|
|
1455
|
-
* @param {ExecuteMetadata} metadata The metadata of the execution
|
|
1456
|
-
* @returns {Promise<ToolExecuteResponse>} The response from the tool
|
|
1457
|
-
*/
|
|
1458
|
-
async executeCustomTool(slug, body) {
|
|
1459
|
-
const tool = this.customToolsRegistry.get(slug.toLowerCase());
|
|
1460
|
-
if (!tool) throw new require_CustomTool.ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
|
|
1461
|
-
let connectionConfig = null;
|
|
1462
|
-
const { toolkitSlug, execute, inputParams } = tool.options;
|
|
1463
|
-
let connectedAccountId = body.connectedAccountId;
|
|
1464
|
-
if (toolkitSlug && toolkitSlug !== "custom" && body.userId) {
|
|
1465
|
-
const connectedAccount = await this.getConnectedAccountForToolkit(toolkitSlug, body.userId, body.connectedAccountId);
|
|
1466
|
-
require_FileModifierErrors.logger_default.debug(`[CustomTool] Connected account for ${toolkitSlug} found for user ${body.userId}`, JSON.stringify(connectedAccount, null, 2));
|
|
1467
|
-
if (!connectedAccount) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${body.userId}`, { meta: {
|
|
1468
|
-
toolkitSlug,
|
|
1469
|
-
userId: body.userId
|
|
1470
|
-
} });
|
|
1471
|
-
connectionConfig = connectedAccount.state ?? null;
|
|
1472
|
-
connectedAccountId = connectedAccount.id;
|
|
1473
|
-
}
|
|
1474
|
-
if (typeof execute !== "function") throw new require_CustomTool.ComposioInvalidExecuteFunctionError("Invalid execute function", { meta: { toolSlug: slug } });
|
|
1475
|
-
const executeToolRequest = async (data) => {
|
|
1476
|
-
if (toolkitSlug && toolkitSlug === "custom") throw new require_CustomTool.ComposioInvalidExecuteFunctionError("Custom tools without a toolkit cannot be executed using the executeToolRequest function", { possibleFixes: ["Please manually execute the tool using your logic.", "Pass a toolkit slug to execute the tool on behalf of a toolkit credentials"] });
|
|
1477
|
-
const parameters = data.parameters?.map((param) => ({
|
|
1478
|
-
name: param.name,
|
|
1479
|
-
type: param.in,
|
|
1480
|
-
value: param.value.toString()
|
|
1481
|
-
}));
|
|
1482
|
-
return {
|
|
1483
|
-
data: (await this.client.tools.proxy({
|
|
1484
|
-
endpoint: data.endpoint,
|
|
1485
|
-
method: data.method,
|
|
1486
|
-
parameters,
|
|
1487
|
-
body: data.body,
|
|
1488
|
-
connected_account_id: connectedAccountId,
|
|
1489
|
-
custom_connection_data: data.customConnectionData
|
|
1490
|
-
})).data,
|
|
1491
|
-
error: null,
|
|
1492
|
-
successful: true,
|
|
1493
|
-
logId: void 0,
|
|
1494
|
-
sessionInfo: void 0
|
|
1495
|
-
};
|
|
1496
|
-
};
|
|
1497
|
-
const parsedInput = inputParams.safeParse(body.arguments);
|
|
1498
|
-
if (!parsedInput.success) throw new require_CustomTool.ValidationError("Invalid input parameters", { cause: parsedInput.error });
|
|
1499
|
-
return execute(parsedInput.data, connectionConfig, executeToolRequest);
|
|
1500
|
-
}
|
|
1501
|
-
};
|
|
1502
|
-
|
|
1503
1017
|
//#endregion
|
|
1504
1018
|
//#region src/utils/toolkitVersion.ts
|
|
1505
1019
|
/**
|
|
@@ -1595,12 +1109,27 @@ function resolveEffectiveUploadAllowlist(userDirs) {
|
|
|
1595
1109
|
//#region src/models/Tools.ts
|
|
1596
1110
|
const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
|
|
1597
1111
|
/**
|
|
1112
|
+
* Normalize a raw `input_parameters` / `output_parameters` payload returned by
|
|
1113
|
+
* the Composio API. Maps `null`, `undefined`, and empty `{}` — all of which
|
|
1114
|
+
* mean "no declared schema" — to `undefined` so the strict `ParametersSchema`
|
|
1115
|
+
* validator never sees them. Non-empty objects pass through unchanged and
|
|
1116
|
+
* remain subject to strict Zod validation.
|
|
1117
|
+
*
|
|
1118
|
+
* MCP-backed toolkits (granola_mcp, apify_mcp, tavily_mcp, …) have no
|
|
1119
|
+
* declared output schema and the API serializes that as `{}`, which would
|
|
1120
|
+
* otherwise trip `ParametersSchema`. See
|
|
1121
|
+
* https://github.com/ComposioHQ/composio/issues/3354.
|
|
1122
|
+
*/
|
|
1123
|
+
function normalizeRawToolParameters(params) {
|
|
1124
|
+
if (params == null || Object.keys(params).length === 0) return void 0;
|
|
1125
|
+
return params;
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1598
1128
|
* This class is used to manage tools in the Composio SDK.
|
|
1599
1129
|
* It provides methods to list, get, and execute tools.
|
|
1600
1130
|
*/
|
|
1601
1131
|
var Tools = class {
|
|
1602
1132
|
client;
|
|
1603
|
-
customTools;
|
|
1604
1133
|
provider;
|
|
1605
1134
|
autoUploadDownloadFiles;
|
|
1606
1135
|
toolkitVersions;
|
|
@@ -1615,7 +1144,6 @@ var Tools = class {
|
|
|
1615
1144
|
if (!client) throw new Error("ComposioClient is required");
|
|
1616
1145
|
if (!config?.provider) throw new require_CustomTool.ComposioProviderNotDefinedError("Provider not passed into Tools instance");
|
|
1617
1146
|
this.client = client;
|
|
1618
|
-
this.customTools = new CustomTools(client);
|
|
1619
1147
|
this.provider = config.provider;
|
|
1620
1148
|
this.autoUploadDownloadFiles = config?.dangerouslyAllowAutoUploadDownloadFiles === true;
|
|
1621
1149
|
this.toolkitVersions = config?.toolkitVersions ?? _config_defaults.CONFIG_DEFAULTS.toolkitVersions;
|
|
@@ -1645,8 +1173,8 @@ var Tools = class {
|
|
|
1645
1173
|
transformToolCases(tool) {
|
|
1646
1174
|
return ToolSchema.parse({
|
|
1647
1175
|
...tool,
|
|
1648
|
-
inputParameters: tool.input_parameters,
|
|
1649
|
-
outputParameters: tool.output_parameters,
|
|
1176
|
+
inputParameters: normalizeRawToolParameters(tool.input_parameters),
|
|
1177
|
+
outputParameters: normalizeRawToolParameters(tool.output_parameters),
|
|
1650
1178
|
availableVersions: tool.available_versions,
|
|
1651
1179
|
isDeprecated: tool.deprecated?.is_deprecated ?? false,
|
|
1652
1180
|
isNoAuth: tool.no_auth
|
|
@@ -1749,10 +1277,12 @@ var Tools = class {
|
|
|
1749
1277
|
return modifiedResult;
|
|
1750
1278
|
}
|
|
1751
1279
|
/**
|
|
1752
|
-
* Lists
|
|
1280
|
+
* Lists Composio API tools available to the SDK.
|
|
1753
1281
|
*
|
|
1754
|
-
* This method fetches tools from the
|
|
1755
|
-
*
|
|
1282
|
+
* This method fetches remote Composio tools from the API in raw format. The response can be
|
|
1283
|
+
* filtered and modified as needed. Local experimental custom tools are session-scoped; attach
|
|
1284
|
+
* them when creating or reusing a Tool Router session, then use `session.tools()`,
|
|
1285
|
+
* `session.customTools()`, or `session.execute()`.
|
|
1756
1286
|
* It provides access to the underlying tool data without provider-specific wrapping.
|
|
1757
1287
|
*
|
|
1758
1288
|
* @param {ToolListParams} query - Query parameters to filter the tools (required)
|
|
@@ -1829,8 +1359,7 @@ var Tools = class {
|
|
|
1829
1359
|
const tools = await this.client.tools.list(filters);
|
|
1830
1360
|
if (!tools) return [];
|
|
1831
1361
|
const caseTransformedTools = tools.items.map((tool) => this.transformToolCases(tool));
|
|
1832
|
-
|
|
1833
|
-
let modifiedTools = await this.applyDefaultSchemaModifiers([...caseTransformedTools, ...customTools]);
|
|
1362
|
+
let modifiedTools = await this.applyDefaultSchemaModifiers(caseTransformedTools);
|
|
1834
1363
|
if (options?.modifySchema) {
|
|
1835
1364
|
const modifier = options.modifySchema;
|
|
1836
1365
|
if (typeof modifier === "function") {
|
|
@@ -1891,6 +1420,9 @@ var Tools = class {
|
|
|
1891
1420
|
* This method fetches a single tool in raw format without provider-specific wrapping,
|
|
1892
1421
|
* providing direct access to the tool's schema and metadata. Tool versions are controlled
|
|
1893
1422
|
* at the Composio SDK initialization level through the `toolkitVersions` configuration.
|
|
1423
|
+
* Local experimental custom tools are session-scoped; attach them when creating or reusing a
|
|
1424
|
+
* Tool Router session, then use `session.tools()`, `session.customTools()`, or
|
|
1425
|
+
* `session.execute()`.
|
|
1894
1426
|
*
|
|
1895
1427
|
* @param {string} slug - The unique identifier of the tool (e.g., 'GITHUB_GET_REPOS')
|
|
1896
1428
|
* @param {GetRawComposioToolBySlugOptions} [options] - Optional configuration for tool retrieval
|
|
@@ -1920,9 +1452,6 @@ var Tools = class {
|
|
|
1920
1452
|
* }
|
|
1921
1453
|
* );
|
|
1922
1454
|
*
|
|
1923
|
-
* // Get a custom tool (will check custom tools first)
|
|
1924
|
-
* const customTool = await composio.tools.getRawComposioToolBySlug('MY_CUSTOM_TOOL');
|
|
1925
|
-
*
|
|
1926
1455
|
* // Access tool properties
|
|
1927
1456
|
* const githubTool = await composio.tools.getRawComposioToolBySlug('GITHUB_CREATE_ISSUE');
|
|
1928
1457
|
* console.log({
|
|
@@ -1936,11 +1465,6 @@ var Tools = class {
|
|
|
1936
1465
|
* ```
|
|
1937
1466
|
*/
|
|
1938
1467
|
async getRawComposioToolBySlug(slug, options) {
|
|
1939
|
-
const customTool = await this.customTools.getCustomToolBySlug(slug);
|
|
1940
|
-
if (customTool) {
|
|
1941
|
-
require_FileModifierErrors.logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
|
|
1942
|
-
return customTool;
|
|
1943
|
-
} else require_FileModifierErrors.logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
|
|
1944
1468
|
let tool;
|
|
1945
1469
|
try {
|
|
1946
1470
|
const retrieveParams = options?.version ? { version: options.version } : { toolkit_versions: this.toolkitVersions };
|
|
@@ -2092,8 +1616,7 @@ var Tools = class {
|
|
|
2092
1616
|
/**
|
|
2093
1617
|
* Executes a given tool with the provided parameters.
|
|
2094
1618
|
*
|
|
2095
|
-
* This method calls the Composio API
|
|
2096
|
-
* It automatically determines whether to use a custom tool or a Composio API tool based on the slug.
|
|
1619
|
+
* This method calls the Composio API to execute the tool and returns the response.
|
|
2097
1620
|
*
|
|
2098
1621
|
* **Version Control:**
|
|
2099
1622
|
* By default, manual tool execution requires a specific toolkit version. If the version resolves to "latest",
|
|
@@ -2110,7 +1633,6 @@ var Tools = class {
|
|
|
2110
1633
|
* @param {ExecuteToolModifiers} [modifiers] - Optional modifiers to transform the request or response
|
|
2111
1634
|
* @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
|
|
2112
1635
|
*
|
|
2113
|
-
* @throws {ComposioCustomToolsNotInitializedError} If the CustomTools instance is not initialized
|
|
2114
1636
|
* @throws {ComposioConnectedAccountNotFoundError} If the connected account is not found
|
|
2115
1637
|
* @throws {ComposioToolNotFoundError} If the tool with the given slug is not found
|
|
2116
1638
|
* @throws {ComposioToolVersionRequiredError} If version resolves to "latest" and dangerouslySkipVersionCheck is not true
|
|
@@ -2163,18 +1685,16 @@ var Tools = class {
|
|
|
2163
1685
|
* ```
|
|
2164
1686
|
*/
|
|
2165
1687
|
async execute(slug, body, modifiers) {
|
|
2166
|
-
if (!this.customTools) throw new require_CustomTool.ComposioCustomToolsNotInitializedError("CustomTools not initialized. Make sure Tools class is properly constructed.");
|
|
2167
1688
|
const executeParams = ToolExecuteParamsSchema.safeParse(body);
|
|
2168
1689
|
if (!executeParams.success) throw new require_CustomTool.ValidationError("Invalid tool execute parameters", { cause: executeParams.error });
|
|
2169
|
-
const
|
|
2170
|
-
const tool = customTool ?? await this.getRawComposioToolBySlug(slug, { version: body.version });
|
|
1690
|
+
const tool = await this.getRawComposioToolBySlug(slug, { version: body.version });
|
|
2171
1691
|
const toolkitSlug = tool.toolkit?.slug ?? "unknown";
|
|
2172
1692
|
const params = await this.applyBeforeExecuteModifiers(tool, {
|
|
2173
1693
|
toolSlug: slug,
|
|
2174
1694
|
toolkitSlug,
|
|
2175
1695
|
params: executeParams.data
|
|
2176
1696
|
}, modifiers);
|
|
2177
|
-
let result =
|
|
1697
|
+
let result = await this.executeComposioTool(tool, params);
|
|
2178
1698
|
result = await this.applyAfterExecuteModifiers(tool, {
|
|
2179
1699
|
toolSlug: slug,
|
|
2180
1700
|
toolkitSlug,
|
|
@@ -2308,54 +1828,6 @@ var Tools = class {
|
|
|
2308
1828
|
custom_connection_data: toolProxyParams.data.customConnectionData
|
|
2309
1829
|
});
|
|
2310
1830
|
}
|
|
2311
|
-
/**
|
|
2312
|
-
* Creates a custom tool that can be used within the Composio SDK.
|
|
2313
|
-
*
|
|
2314
|
-
* Custom tools allow you to extend the functionality of Composio with your own implementations
|
|
2315
|
-
* while keeping a consistent interface for both built-in and custom tools.
|
|
2316
|
-
*
|
|
2317
|
-
* @param {CustomToolOptions} body - The configuration for the custom tool
|
|
2318
|
-
* @returns {Promise<Tool>} The created custom tool
|
|
2319
|
-
*
|
|
2320
|
-
* @example
|
|
2321
|
-
* ```typescript
|
|
2322
|
-
* // creating a custom tool with a toolkit
|
|
2323
|
-
* await composio.tools.createCustomTool({
|
|
2324
|
-
* name: 'My Custom Tool',
|
|
2325
|
-
* description: 'A custom tool that does something specific',
|
|
2326
|
-
* slug: 'MY_CUSTOM_TOOL',
|
|
2327
|
-
* userId: 'default',
|
|
2328
|
-
* connectedAccountId: '123',
|
|
2329
|
-
* toolkitSlug: 'github',
|
|
2330
|
-
* inputParameters: z.object({
|
|
2331
|
-
* param1: z.string().describe('First parameter'),
|
|
2332
|
-
* }),
|
|
2333
|
-
* execute: async (input, connectionConfig, executeToolRequest) => {
|
|
2334
|
-
* // Custom logic here
|
|
2335
|
-
* return { data: { result: 'Success!' } };
|
|
2336
|
-
* }
|
|
2337
|
-
* });
|
|
2338
|
-
* ```
|
|
2339
|
-
*
|
|
2340
|
-
* @example
|
|
2341
|
-
* ```typescript
|
|
2342
|
-
* // creating a custom tool without a toolkit
|
|
2343
|
-
* await composio.tools.createCustomTool({
|
|
2344
|
-
* name: 'My Custom Tool',
|
|
2345
|
-
* description: 'A custom tool that does something specific',
|
|
2346
|
-
* slug: 'MY_CUSTOM_TOOL',
|
|
2347
|
-
* inputParameters: z.object({
|
|
2348
|
-
* param1: z.string().describe('First parameter'),
|
|
2349
|
-
* }),
|
|
2350
|
-
* execute: async (input) => {
|
|
2351
|
-
* // Custom logic here
|
|
2352
|
-
* return { data: { result: 'Success!' } };
|
|
2353
|
-
* }
|
|
2354
|
-
* });
|
|
2355
|
-
*/
|
|
2356
|
-
async createCustomTool(body) {
|
|
2357
|
-
return this.customTools.createTool(body);
|
|
2358
|
-
}
|
|
2359
1831
|
};
|
|
2360
1832
|
|
|
2361
1833
|
//#endregion
|
|
@@ -2454,6 +1926,24 @@ const ToolkitRetrieveCategoriesResponseSchema = zod_v3.z.object({
|
|
|
2454
1926
|
});
|
|
2455
1927
|
const ToolkitAuthFieldsResponseSchema = zod_v3.z.array(ToolkitAuthFieldSchema.extend({ required: zod_v3.z.boolean().optional() }));
|
|
2456
1928
|
|
|
1929
|
+
//#endregion
|
|
1930
|
+
//#region src/utils/transform.ts
|
|
1931
|
+
function transform(raw) {
|
|
1932
|
+
return { with(schema) {
|
|
1933
|
+
return { using(transformer, options) {
|
|
1934
|
+
const transformed = transformer(raw);
|
|
1935
|
+
const result = schema.safeParse(transformed);
|
|
1936
|
+
if (!result.success) {
|
|
1937
|
+
const label = options?.label ? ` for ${options.label}` : "";
|
|
1938
|
+
const issues = result.error.issues.map((issue) => ` - ${issue.path.join(".") || "parameter"}: ${issue.message}`).join("\n");
|
|
1939
|
+
require_FileModifierErrors.logger_default.warn(`Transform validation failed${label}:\n${issues}`);
|
|
1940
|
+
return transformed;
|
|
1941
|
+
}
|
|
1942
|
+
return result.data;
|
|
1943
|
+
} };
|
|
1944
|
+
} };
|
|
1945
|
+
}
|
|
1946
|
+
|
|
2457
1947
|
//#endregion
|
|
2458
1948
|
//#region src/utils/transformers/authConfigs.ts
|
|
2459
1949
|
/**
|
|
@@ -2790,6 +2280,275 @@ var AuthConfigs = class {
|
|
|
2790
2280
|
}
|
|
2791
2281
|
};
|
|
2792
2282
|
|
|
2283
|
+
//#endregion
|
|
2284
|
+
//#region src/types/connectedAccounts.types.ts
|
|
2285
|
+
/**
|
|
2286
|
+
* Connected Account create parameters
|
|
2287
|
+
*/
|
|
2288
|
+
const ConnectedAccountStatuses = {
|
|
2289
|
+
INITIALIZING: "INITIALIZING",
|
|
2290
|
+
INITIATED: "INITIATED",
|
|
2291
|
+
ACTIVE: "ACTIVE",
|
|
2292
|
+
FAILED: "FAILED",
|
|
2293
|
+
EXPIRED: "EXPIRED",
|
|
2294
|
+
INACTIVE: "INACTIVE",
|
|
2295
|
+
REVOKED: "REVOKED"
|
|
2296
|
+
};
|
|
2297
|
+
const ConnectedAccountStatusSchema = zod_v3.z.enum([
|
|
2298
|
+
ConnectedAccountStatuses.INITIALIZING,
|
|
2299
|
+
ConnectedAccountStatuses.INITIATED,
|
|
2300
|
+
ConnectedAccountStatuses.ACTIVE,
|
|
2301
|
+
ConnectedAccountStatuses.FAILED,
|
|
2302
|
+
ConnectedAccountStatuses.EXPIRED,
|
|
2303
|
+
ConnectedAccountStatuses.INACTIVE,
|
|
2304
|
+
ConnectedAccountStatuses.REVOKED
|
|
2305
|
+
]);
|
|
2306
|
+
/**
|
|
2307
|
+
* Sharing model for a connected account.
|
|
2308
|
+
*
|
|
2309
|
+
* - `PRIVATE` (default): only the owning `userId` can use the connection.
|
|
2310
|
+
* - `SHARED`: can be used by other `userId`s, but only when the connection
|
|
2311
|
+
* is explicitly pinned in a tool-router session's config and only when
|
|
2312
|
+
* the requesting `userId` passes the connection's ACL (see
|
|
2313
|
+
* `allowAllUsers` / `allowedUserIds` / `notAllowedUserIds`).
|
|
2314
|
+
*/
|
|
2315
|
+
const ConnectedAccountTypes = {
|
|
2316
|
+
PRIVATE: "PRIVATE",
|
|
2317
|
+
SHARED: "SHARED"
|
|
2318
|
+
};
|
|
2319
|
+
const ConnectedAccountTypeSchema = zod_v3.z.enum([ConnectedAccountTypes.PRIVATE, ConnectedAccountTypes.SHARED]);
|
|
2320
|
+
/**
|
|
2321
|
+
* Per-user access control for a SHARED connected account. Ignored for
|
|
2322
|
+
* PRIVATE.
|
|
2323
|
+
*
|
|
2324
|
+
* Pass `aclConfigForShared` on create / PATCH to grant access; omit it
|
|
2325
|
+
* to leave the ACL unchanged (on PATCH) or to keep the default
|
|
2326
|
+
* deny-by-default state (on create). On responses, the field is
|
|
2327
|
+
* `undefined` when the caller isn't authorised to see the ACL —
|
|
2328
|
+
* distinguish that from an empty/default state explicitly.
|
|
2329
|
+
*
|
|
2330
|
+
* Resolution rule (deny wins):
|
|
2331
|
+
* 1. requesting `userId` in `notAllowedUserIds` → DENY
|
|
2332
|
+
* 2. `allowAllUsers === true` → ALLOW
|
|
2333
|
+
* 3. requesting `userId` in `allowedUserIds` → ALLOW
|
|
2334
|
+
* 4. otherwise → DENY (deny-by-default)
|
|
2335
|
+
*
|
|
2336
|
+
* Default state (block omitted or `{}`) means only the connection's
|
|
2337
|
+
* creator can use it. The creator must grant access explicitly.
|
|
2338
|
+
*
|
|
2339
|
+
* Limits: each list accepts up to 1000 entries; each `userId` is
|
|
2340
|
+
* 1..256 characters.
|
|
2341
|
+
*/
|
|
2342
|
+
const ACL_LIST_MAX_LENGTH = 1e3;
|
|
2343
|
+
const aclUserIdString = zod_v3.z.string().min(1).max(256);
|
|
2344
|
+
const ConnectedAccountAclConfigSchema = zod_v3.z.object({
|
|
2345
|
+
allowAllUsers: zod_v3.z.boolean().optional().describe("When true, any `userId` may use this SHARED connection (subject to the deny list). Default false."),
|
|
2346
|
+
allowedUserIds: zod_v3.z.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings allowed to use this SHARED connection. Default []."),
|
|
2347
|
+
notAllowedUserIds: zod_v3.z.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings denied access. Wins over allow on conflict. Default [].")
|
|
2348
|
+
});
|
|
2349
|
+
/**
|
|
2350
|
+
* Resolved ACL as it appears on responses. All three fields are populated
|
|
2351
|
+
* when the field is visible; the field itself is `undefined` for callers
|
|
2352
|
+
* not authorised to see it.
|
|
2353
|
+
*/
|
|
2354
|
+
const ConnectedAccountAclConfigResponseSchema = zod_v3.z.object({
|
|
2355
|
+
allowAllUsers: zod_v3.z.boolean(),
|
|
2356
|
+
allowedUserIds: zod_v3.z.array(zod_v3.z.string()),
|
|
2357
|
+
notAllowedUserIds: zod_v3.z.array(zod_v3.z.string())
|
|
2358
|
+
});
|
|
2359
|
+
/**
|
|
2360
|
+
* Experimental options for SHARED connections, passed at create / link time.
|
|
2361
|
+
*
|
|
2362
|
+
* **Experimental — shape may change in future releases.** Wrapped under a
|
|
2363
|
+
* dedicated `experimental` block on every input and response so the
|
|
2364
|
+
* experimental status is visible at every call site.
|
|
2365
|
+
*/
|
|
2366
|
+
const ConnectedAccountExperimentalSchema = zod_v3.z.object({
|
|
2367
|
+
accountType: ConnectedAccountTypeSchema.optional(),
|
|
2368
|
+
aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
|
|
2369
|
+
});
|
|
2370
|
+
/**
|
|
2371
|
+
* Resolved experimental block on retrieve / list responses. `accountType`
|
|
2372
|
+
* is always present when the block is; `aclConfigForShared` is only
|
|
2373
|
+
* present when the caller is authorised to see the ACL.
|
|
2374
|
+
*/
|
|
2375
|
+
const ConnectedAccountExperimentalResponseSchema = zod_v3.z.object({
|
|
2376
|
+
accountType: ConnectedAccountTypeSchema.optional(),
|
|
2377
|
+
aclConfigForShared: ConnectedAccountAclConfigResponseSchema.optional()
|
|
2378
|
+
});
|
|
2379
|
+
const CreateConnectedAccountParamsSchema = zod_v3.z.object({
|
|
2380
|
+
authConfig: zod_v3.z.object({ id: zod_v3.z.string() }),
|
|
2381
|
+
connection: zod_v3.z.object({
|
|
2382
|
+
data: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
|
|
2383
|
+
callbackUrl: zod_v3.z.string().optional(),
|
|
2384
|
+
userId: zod_v3.z.string().optional()
|
|
2385
|
+
})
|
|
2386
|
+
});
|
|
2387
|
+
const DefaultCreateConnectedAccountParamsSchema = zod_v3.z.object({
|
|
2388
|
+
auth_config: zod_v3.z.object({ id: zod_v3.z.string() }),
|
|
2389
|
+
connection: zod_v3.z.object({
|
|
2390
|
+
state: ConnectionDataSchema.optional(),
|
|
2391
|
+
data: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
|
|
2392
|
+
callback_url: zod_v3.z.string().optional(),
|
|
2393
|
+
user_id: zod_v3.z.string().optional(),
|
|
2394
|
+
alias: zod_v3.z.string().optional()
|
|
2395
|
+
})
|
|
2396
|
+
});
|
|
2397
|
+
const CreateConnectedAccountOptionsSchema = zod_v3.z.object({
|
|
2398
|
+
allowMultiple: zod_v3.z.boolean().optional(),
|
|
2399
|
+
callbackUrl: zod_v3.z.string().optional(),
|
|
2400
|
+
config: ConnectionDataSchema.optional(),
|
|
2401
|
+
alias: zod_v3.z.string().optional()
|
|
2402
|
+
});
|
|
2403
|
+
/**
|
|
2404
|
+
* Connected Account create response
|
|
2405
|
+
*/
|
|
2406
|
+
const CreateConnectedAccountResponseSchema = zod_v3.z.object({
|
|
2407
|
+
id: zod_v3.z.string(),
|
|
2408
|
+
status: ConnectedAccountStatusSchema,
|
|
2409
|
+
redirectUrl: zod_v3.z.string().nullable()
|
|
2410
|
+
});
|
|
2411
|
+
const ConnectedAccountAuthConfigSchema = zod_v3.z.object({
|
|
2412
|
+
id: zod_v3.z.string(),
|
|
2413
|
+
authScheme: AuthSchemeEnum.optional(),
|
|
2414
|
+
isComposioManaged: zod_v3.z.boolean(),
|
|
2415
|
+
isDisabled: zod_v3.z.boolean()
|
|
2416
|
+
});
|
|
2417
|
+
const ConnectedAccountRetrieveResponseSchema = zod_v3.z.object({
|
|
2418
|
+
id: zod_v3.z.string(),
|
|
2419
|
+
authConfig: ConnectedAccountAuthConfigSchema,
|
|
2420
|
+
wordId: zod_v3.z.string().nullable().optional(),
|
|
2421
|
+
alias: zod_v3.z.string().nullable().optional(),
|
|
2422
|
+
data: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
|
|
2423
|
+
params: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
|
|
2424
|
+
status: ConnectedAccountStatusSchema,
|
|
2425
|
+
statusReason: zod_v3.z.string().nullable(),
|
|
2426
|
+
toolkit: zod_v3.z.object({ slug: zod_v3.z.string() }),
|
|
2427
|
+
state: ConnectionDataSchema.optional(),
|
|
2428
|
+
testRequestEndpoint: zod_v3.z.string().optional(),
|
|
2429
|
+
isDisabled: zod_v3.z.boolean(),
|
|
2430
|
+
createdAt: zod_v3.z.string(),
|
|
2431
|
+
updatedAt: zod_v3.z.string(),
|
|
2432
|
+
experimental: ConnectedAccountExperimentalResponseSchema.optional()
|
|
2433
|
+
});
|
|
2434
|
+
const ConnectedAccountListParamsSchema = zod_v3.z.object({
|
|
2435
|
+
authConfigIds: zod_v3.z.array(zod_v3.z.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
|
|
2436
|
+
cursor: zod_v3.z.string().nullish().describe("The cursor to paginate through the connected accounts"),
|
|
2437
|
+
limit: zod_v3.z.number().nullable().optional().describe("The limit of the connected accounts to return"),
|
|
2438
|
+
orderBy: zod_v3.z.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
|
|
2439
|
+
statuses: zod_v3.z.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
|
|
2440
|
+
toolkitSlugs: zod_v3.z.array(zod_v3.z.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
|
|
2441
|
+
userIds: zod_v3.z.array(zod_v3.z.string()).nullable().optional().describe("The user ids of the connected accounts"),
|
|
2442
|
+
accountType: zod_v3.z.enum([
|
|
2443
|
+
"PRIVATE",
|
|
2444
|
+
"SHARED",
|
|
2445
|
+
"ALL"
|
|
2446
|
+
]).optional()
|
|
2447
|
+
});
|
|
2448
|
+
const ConnectedAccountListResponseSchema = zod_v3.z.object({
|
|
2449
|
+
items: zod_v3.z.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
|
|
2450
|
+
nextCursor: zod_v3.z.string().nullish().describe("The next cursor to paginate through the connected accounts"),
|
|
2451
|
+
totalPages: zod_v3.z.number().describe("The total number of pages of connected accounts")
|
|
2452
|
+
});
|
|
2453
|
+
const CreateConnectedAccountLinkOptionsSchema = zod_v3.z.object({
|
|
2454
|
+
callbackUrl: zod_v3.z.string().optional(),
|
|
2455
|
+
alias: zod_v3.z.string().optional(),
|
|
2456
|
+
allowMultiple: zod_v3.z.boolean().optional(),
|
|
2457
|
+
experimental: ConnectedAccountExperimentalSchema.optional()
|
|
2458
|
+
});
|
|
2459
|
+
const CreateConnectedAccountLinkResponseSchema = zod_v3.z.object({ redirectUrl: zod_v3.z.string() });
|
|
2460
|
+
const ConnectedAccountRefreshOptionsSchema = zod_v3.z.object({
|
|
2461
|
+
redirectUrl: zod_v3.z.string().optional(),
|
|
2462
|
+
validateCredentials: zod_v3.z.boolean().optional()
|
|
2463
|
+
});
|
|
2464
|
+
const UpdateConnectedAccountParamsSchema = zod_v3.z.object({ enabled: zod_v3.z.boolean() });
|
|
2465
|
+
/**
|
|
2466
|
+
* Params for `composio.connectedAccounts.updateAcl()`. Mirrors the inner
|
|
2467
|
+
* shape of the wire's `acl_config_for_shared` block — the SDK adds the
|
|
2468
|
+
* outer nesting at the boundary, so callers pass the three fields flat.
|
|
2469
|
+
*
|
|
2470
|
+
* PATCH-style semantics — omit a field to leave it unchanged; pass an
|
|
2471
|
+
* empty array to clear an allow/deny list. Raises
|
|
2472
|
+
* `ComposioAclOnlyForSharedError` on a PRIVATE connection.
|
|
2473
|
+
*
|
|
2474
|
+
* Each field is optional, but at least one must be provided — passing an
|
|
2475
|
+
* empty object is rejected as a no-op.
|
|
2476
|
+
*/
|
|
2477
|
+
const UpdateConnectedAccountAclParamsSchema = ConnectedAccountAclConfigSchema.refine((acl) => acl.allowAllUsers !== void 0 || acl.allowedUserIds !== void 0 || acl.notAllowedUserIds !== void 0, { message: "At least one of allowAllUsers, allowedUserIds, or notAllowedUserIds must be provided" });
|
|
2478
|
+
|
|
2479
|
+
//#endregion
|
|
2480
|
+
//#region src/utils/transformers/connectedAccounts.ts
|
|
2481
|
+
/**
|
|
2482
|
+
* Transforms the raw connected account response from the Composio API to the SDK format.
|
|
2483
|
+
*
|
|
2484
|
+
* This method converts property names from snake_case to camelCase and reorganizes
|
|
2485
|
+
* the data structure to match the SDK's standardized format.
|
|
2486
|
+
*
|
|
2487
|
+
* @param {RawConnectedAccountListResponse['items'][0]|RawConnectedAccountRetrieveResponse} response - The raw API response to transform
|
|
2488
|
+
* @returns {Promise<ConnectedAccountRetrieveResponse>} The transformed response
|
|
2489
|
+
* @throws {ZodError} If the response fails validation against the expected schema
|
|
2490
|
+
*
|
|
2491
|
+
* @private
|
|
2492
|
+
*/
|
|
2493
|
+
function transformConnectedAccountResponse(response) {
|
|
2494
|
+
const responseWithLabels = response;
|
|
2495
|
+
const parseState = (state) => {
|
|
2496
|
+
try {
|
|
2497
|
+
return state ? ConnectionDataSchema.parse(state) : void 0;
|
|
2498
|
+
} catch (error) {
|
|
2499
|
+
require_FileModifierErrors.logger_default.warn("Unsupported auth scheme in connected account state, ignoring state field", { error });
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
};
|
|
2503
|
+
return transform(response).with(ConnectedAccountRetrieveResponseSchema).using((response$1) => ({
|
|
2504
|
+
...response$1,
|
|
2505
|
+
authConfig: {
|
|
2506
|
+
...response$1.auth_config,
|
|
2507
|
+
id: response$1.auth_config.id,
|
|
2508
|
+
authScheme: response$1.auth_config.auth_scheme,
|
|
2509
|
+
isComposioManaged: response$1.auth_config.is_composio_managed,
|
|
2510
|
+
isDisabled: response$1.auth_config.is_disabled
|
|
2511
|
+
},
|
|
2512
|
+
wordId: responseWithLabels.word_id ?? null,
|
|
2513
|
+
alias: responseWithLabels.alias ?? null,
|
|
2514
|
+
data: response$1.data ?? void 0,
|
|
2515
|
+
state: parseState(response$1.state),
|
|
2516
|
+
status: response$1.status,
|
|
2517
|
+
statusReason: response$1.status_reason,
|
|
2518
|
+
isDisabled: response$1.is_disabled,
|
|
2519
|
+
createdAt: response$1.created_at,
|
|
2520
|
+
updatedAt: response$1.updated_at,
|
|
2521
|
+
testRequestEndpoint: response$1.test_request_endpoint,
|
|
2522
|
+
experimental: responseWithLabels.experimental ? {
|
|
2523
|
+
accountType: responseWithLabels.experimental.account_type,
|
|
2524
|
+
aclConfigForShared: responseWithLabels.experimental.acl_config_for_shared ? {
|
|
2525
|
+
allowAllUsers: responseWithLabels.experimental.acl_config_for_shared.allow_all_users,
|
|
2526
|
+
allowedUserIds: responseWithLabels.experimental.acl_config_for_shared.allowed_user_ids,
|
|
2527
|
+
notAllowedUserIds: responseWithLabels.experimental.acl_config_for_shared.not_allowed_user_ids
|
|
2528
|
+
} : void 0
|
|
2529
|
+
} : void 0
|
|
2530
|
+
}));
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Transforms the raw connected account list response from the Composio API to the SDK format.
|
|
2534
|
+
*
|
|
2535
|
+
* This method converts property names from snake_case to camelCase and reorganizes
|
|
2536
|
+
* the data structure to match the SDK's standardized format.
|
|
2537
|
+
*
|
|
2538
|
+
* @param {RawConnectedAccountListResponse} response - The raw API response to transform
|
|
2539
|
+
* @returns {ConnectedAccountListResponse} The transformed response
|
|
2540
|
+
* @throws {ZodError} If the response fails validation against the expected schema
|
|
2541
|
+
*
|
|
2542
|
+
* @private
|
|
2543
|
+
*/
|
|
2544
|
+
function transformConnectedAccountListResponse(response) {
|
|
2545
|
+
return transform(response).with(ConnectedAccountListResponseSchema).using((response$1) => ({
|
|
2546
|
+
items: response$1.items.map(transformConnectedAccountResponse),
|
|
2547
|
+
nextCursor: response$1.next_cursor ?? null,
|
|
2548
|
+
totalPages: response$1.total_pages
|
|
2549
|
+
}));
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2793
2552
|
//#endregion
|
|
2794
2553
|
//#region src/models/ConnectionRequest.ts
|
|
2795
2554
|
/**
|
|
@@ -4243,11 +4002,13 @@ var Triggers = class {
|
|
|
4243
4002
|
});
|
|
4244
4003
|
throw error;
|
|
4245
4004
|
}
|
|
4246
|
-
|
|
4005
|
+
const upsertParams = {
|
|
4247
4006
|
connected_account_id: connectedAccountId,
|
|
4248
4007
|
trigger_config: parsedBody.data.triggerConfig,
|
|
4249
|
-
toolkit_versions: this.toolkitVersions
|
|
4250
|
-
|
|
4008
|
+
toolkit_versions: this.toolkitVersions,
|
|
4009
|
+
user_id: userId
|
|
4010
|
+
};
|
|
4011
|
+
return { triggerId: (await this.client.triggerInstances.upsert(slug, upsertParams)).trigger_id };
|
|
4251
4012
|
}
|
|
4252
4013
|
/**
|
|
4253
4014
|
* Update an existing trigger instance
|
|
@@ -5296,6 +5057,63 @@ var BaseAgenticProvider = class extends BaseProvider {
|
|
|
5296
5057
|
_isAgentic = true;
|
|
5297
5058
|
};
|
|
5298
5059
|
|
|
5060
|
+
//#endregion
|
|
5061
|
+
//#region src/utils/toolArguments.ts
|
|
5062
|
+
/**
|
|
5063
|
+
* Tool-argument normalization.
|
|
5064
|
+
*
|
|
5065
|
+
* Models (and MCP transports) occasionally emit tool-call arguments as a JSON
|
|
5066
|
+
* *string* instead of an object. `COMPOSIO_MULTI_EXECUTE_TOOL` and Vercel AI
|
|
5067
|
+
* SDK streaming are common triggers. Forwarding that raw string to execution
|
|
5068
|
+
* surfaces opaque downstream errors such as
|
|
5069
|
+
* `tool_use.input: Input should be a valid dictionary`.
|
|
5070
|
+
*
|
|
5071
|
+
* `normalizeToolArguments` is the single coercion every provider routes through
|
|
5072
|
+
* so the behaviour is identical everywhere instead of being re-implemented
|
|
5073
|
+
* (inconsistently) per provider.
|
|
5074
|
+
*
|
|
5075
|
+
* @see https://github.com/ComposioHQ/composio/issues/2406
|
|
5076
|
+
*/
|
|
5077
|
+
/**
|
|
5078
|
+
* Coerce model-supplied tool arguments into a plain object.
|
|
5079
|
+
*
|
|
5080
|
+
* Rules:
|
|
5081
|
+
* - `null` / `undefined` → `{}` (some models send no arguments for no-arg tools).
|
|
5082
|
+
* - A plain object is returned unchanged.
|
|
5083
|
+
* - A string is JSON-parsed; an empty / whitespace-only string becomes `{}`.
|
|
5084
|
+
* - Anything that does not resolve to a plain object (arrays, primitives,
|
|
5085
|
+
* unparseable strings, JSON that parses to a non-object) throws a typed
|
|
5086
|
+
* {@link ComposioInvalidToolArgumentsError} so callers get an actionable
|
|
5087
|
+
* message instead of a raw `SyntaxError` or a silent malformed payload.
|
|
5088
|
+
*
|
|
5089
|
+
* @param input - Raw arguments as received from the model / framework.
|
|
5090
|
+
* @param toolSlug - Optional tool slug, used to enrich the error message.
|
|
5091
|
+
* @returns The normalized arguments as a `Record<string, unknown>`.
|
|
5092
|
+
*/
|
|
5093
|
+
function normalizeToolArguments(input, toolSlug) {
|
|
5094
|
+
if (input === null || input === void 0) return {};
|
|
5095
|
+
if (typeof input === "string") {
|
|
5096
|
+
const trimmed = input.trim();
|
|
5097
|
+
if (trimmed === "") return {};
|
|
5098
|
+
let parsed;
|
|
5099
|
+
try {
|
|
5100
|
+
parsed = JSON.parse(trimmed);
|
|
5101
|
+
} catch (cause) {
|
|
5102
|
+
throw new require_CustomTool.ComposioInvalidToolArgumentsError(`${describeTool(toolSlug)} received arguments as a string that is not valid JSON`, { cause: cause instanceof Error ? cause : void 0 });
|
|
5103
|
+
}
|
|
5104
|
+
return assertPlainObject(parsed, toolSlug);
|
|
5105
|
+
}
|
|
5106
|
+
return assertPlainObject(input, toolSlug);
|
|
5107
|
+
}
|
|
5108
|
+
function assertPlainObject(value, toolSlug) {
|
|
5109
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) return value;
|
|
5110
|
+
const actual = Array.isArray(value) ? "array" : typeof value;
|
|
5111
|
+
throw new require_CustomTool.ComposioInvalidToolArgumentsError(`${describeTool(toolSlug)} expected arguments to be an object, received ${actual}`);
|
|
5112
|
+
}
|
|
5113
|
+
function describeTool(toolSlug) {
|
|
5114
|
+
return toolSlug ? `Tool '${toolSlug}'` : "Tool";
|
|
5115
|
+
}
|
|
5116
|
+
|
|
5299
5117
|
//#endregion
|
|
5300
5118
|
//#region src/provider/OpenAIProvider.ts
|
|
5301
5119
|
var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
@@ -5448,7 +5266,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5448
5266
|
*/
|
|
5449
5267
|
async executeToolCall(userId, tool, options, modifiers) {
|
|
5450
5268
|
const payload = {
|
|
5451
|
-
arguments:
|
|
5269
|
+
arguments: normalizeToolArguments(tool.function.arguments, tool.function.name),
|
|
5452
5270
|
connectedAccountId: options?.connectedAccountId,
|
|
5453
5271
|
customAuthParams: options?.customAuthParams,
|
|
5454
5272
|
customConnectionData: options?.customConnectionData,
|
|
@@ -5725,7 +5543,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5725
5543
|
|
|
5726
5544
|
//#endregion
|
|
5727
5545
|
//#region package.json
|
|
5728
|
-
var version = "0.
|
|
5546
|
+
var version = "0.11.0";
|
|
5729
5547
|
|
|
5730
5548
|
//#endregion
|
|
5731
5549
|
//#region src/utils/session.ts
|
|
@@ -7758,6 +7576,17 @@ const CYCLE_BREAK_SENTINEL = {
|
|
|
7758
7576
|
type: "object",
|
|
7759
7577
|
additionalProperties: true
|
|
7760
7578
|
};
|
|
7579
|
+
/**
|
|
7580
|
+
* In-band hint attached to the cycle-break sentinel when lenient mode
|
|
7581
|
+
* substitutes it for a dangling `$ref`. Makes the degradation visible to
|
|
7582
|
+
* LLMs that read the wrapped tool's schema — without it the LLM sees a
|
|
7583
|
+
* useless permissive object and no prose context. Wording is intentionally
|
|
7584
|
+
* context-neutral ("Schema shape", not "Output shape") because the helper
|
|
7585
|
+
* is used for both `inputParameters` and `outputParameters`. Overridden
|
|
7586
|
+
* when the caller's `$ref` node carries its own `description` sibling
|
|
7587
|
+
* (Draft 2020-12 sibling-keyword semantics).
|
|
7588
|
+
*/
|
|
7589
|
+
const UNRESOLVED_REF_DESCRIPTION = "Schema shape unresolved at the source — validate loosely. See https://github.com/ComposioHQ/composio/issues/3307.";
|
|
7761
7590
|
const POLLUTING_KEYS = new Set([
|
|
7762
7591
|
"__proto__",
|
|
7763
7592
|
"constructor",
|
|
@@ -7765,33 +7594,68 @@ const POLLUTING_KEYS = new Set([
|
|
|
7765
7594
|
]);
|
|
7766
7595
|
const REF_RESOLUTION_FIXES = ["Ensure the $ref pointer matches a path in $defs or definitions", "External $ref pointers (http://, https://, file://, …) are not resolved by the SDK"];
|
|
7767
7596
|
const decodePointerSegment = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
7768
|
-
const
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
possibleFixes: REF_RESOLUTION_FIXES
|
|
7775
|
-
});
|
|
7776
|
-
};
|
|
7777
|
-
const stepInto = (cursor, segment, pointer) => {
|
|
7778
|
-
if (cursor === null || typeof cursor !== "object") failResolution(pointer, segment);
|
|
7597
|
+
const tryStep = (cursor, segment) => {
|
|
7598
|
+
if (cursor === null || typeof cursor !== "object") return {
|
|
7599
|
+
kind: "unresolved",
|
|
7600
|
+
reason: "missing-target",
|
|
7601
|
+
failedAt: segment
|
|
7602
|
+
};
|
|
7779
7603
|
if (Array.isArray(cursor)) {
|
|
7780
7604
|
const i = Number(segment);
|
|
7781
|
-
if (!Number.isInteger(i) || i < 0 || i >= cursor.length)
|
|
7782
|
-
|
|
7605
|
+
if (!Number.isInteger(i) || i < 0 || i >= cursor.length) return {
|
|
7606
|
+
kind: "unresolved",
|
|
7607
|
+
reason: "missing-target",
|
|
7608
|
+
failedAt: segment
|
|
7609
|
+
};
|
|
7610
|
+
return {
|
|
7611
|
+
kind: "ok",
|
|
7612
|
+
value: cursor[i]
|
|
7613
|
+
};
|
|
7783
7614
|
}
|
|
7784
7615
|
const obj = cursor;
|
|
7785
|
-
if (!Object.prototype.hasOwnProperty.call(obj, segment))
|
|
7786
|
-
|
|
7616
|
+
if (!Object.prototype.hasOwnProperty.call(obj, segment)) return {
|
|
7617
|
+
kind: "unresolved",
|
|
7618
|
+
reason: "missing-target",
|
|
7619
|
+
failedAt: segment
|
|
7620
|
+
};
|
|
7621
|
+
return {
|
|
7622
|
+
kind: "ok",
|
|
7623
|
+
value: obj[segment]
|
|
7624
|
+
};
|
|
7625
|
+
};
|
|
7626
|
+
const tryResolvePointer = (root, pointer) => {
|
|
7627
|
+
if (pointer === "#" || pointer === "") return {
|
|
7628
|
+
kind: "ok",
|
|
7629
|
+
value: root
|
|
7630
|
+
};
|
|
7631
|
+
if (!pointer.startsWith("#/")) return {
|
|
7632
|
+
kind: "unresolved",
|
|
7633
|
+
reason: "malformed-pointer"
|
|
7634
|
+
};
|
|
7635
|
+
const segments = pointer.slice(2).split("/").map(decodePointerSegment);
|
|
7636
|
+
let cursor = root;
|
|
7637
|
+
for (const seg of segments) {
|
|
7638
|
+
const step = tryStep(cursor, seg);
|
|
7639
|
+
if (step.kind === "unresolved") return step;
|
|
7640
|
+
cursor = step.value;
|
|
7641
|
+
}
|
|
7642
|
+
return {
|
|
7643
|
+
kind: "ok",
|
|
7644
|
+
value: cursor
|
|
7645
|
+
};
|
|
7787
7646
|
};
|
|
7788
|
-
const
|
|
7789
|
-
if (
|
|
7790
|
-
if (!pointer.startsWith("#/")) throw new require_CustomTool.JsonSchemaRefResolutionError(`Unsupported $ref pointer: ${pointer}`, {
|
|
7647
|
+
const throwResolutionError = (pointer, result) => {
|
|
7648
|
+
if (result.reason === "malformed-pointer") throw new require_CustomTool.JsonSchemaRefResolutionError(`Unsupported $ref pointer: ${pointer}`, {
|
|
7791
7649
|
meta: { ref: pointer },
|
|
7792
7650
|
possibleFixes: REF_RESOLUTION_FIXES
|
|
7793
7651
|
});
|
|
7794
|
-
|
|
7652
|
+
throw new require_CustomTool.JsonSchemaRefResolutionError(`Cannot resolve $ref ${pointer}`, {
|
|
7653
|
+
meta: {
|
|
7654
|
+
ref: pointer,
|
|
7655
|
+
...result.failedAt !== void 0 ? { failedAt: result.failedAt } : {}
|
|
7656
|
+
},
|
|
7657
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
7658
|
+
});
|
|
7795
7659
|
};
|
|
7796
7660
|
/**
|
|
7797
7661
|
* Inlines internal JSON Schema `$ref` pointers (`#/$defs/...` and legacy
|
|
@@ -7801,11 +7665,20 @@ const resolvePointer = (root, pointer) => {
|
|
|
7801
7665
|
* left untouched. Cycles are broken with `{ type: 'object',
|
|
7802
7666
|
* additionalProperties: true }`. The input is never mutated.
|
|
7803
7667
|
*
|
|
7668
|
+
* By default, unresolved internal refs throw `JsonSchemaRefResolutionError`.
|
|
7669
|
+
* Pass `{ onUnresolved: 'sentinel' }` to replace the offending node with the
|
|
7670
|
+
* cycle-break sentinel instead — appropriate for schemas sourced from an
|
|
7671
|
+
* upstream service the caller cannot edit (the Composio API ships some
|
|
7672
|
+
* `outputParameters` with a `$ref` into `#/$defs/...` but never declares
|
|
7673
|
+
* `$defs`; see https://github.com/ComposioHQ/composio/issues/3307).
|
|
7674
|
+
*
|
|
7804
7675
|
* @throws {JsonSchemaRefResolutionError} on malformed pointers, missing
|
|
7805
|
-
* targets, or chains past the depth cap.
|
|
7676
|
+
* targets (strict mode only), or chains past the depth cap (both modes).
|
|
7806
7677
|
*/
|
|
7807
|
-
function dereferenceJsonSchema(schema) {
|
|
7678
|
+
function dereferenceJsonSchema(schema, options) {
|
|
7808
7679
|
if (!require_FileToolModifier_utils_neutral.isPlainObject(schema)) return schema;
|
|
7680
|
+
const strategy = options?.onUnresolved ?? "throw";
|
|
7681
|
+
const onReplace = options?.onReplace;
|
|
7809
7682
|
const root = schema;
|
|
7810
7683
|
const visiting = /* @__PURE__ */ new WeakSet();
|
|
7811
7684
|
const cloneChildren = (obj, visitedRefs, chainDepth, nodeDepth) => Object.fromEntries(Object.entries(obj).filter(([k]) => !POLLUTING_KEYS.has(k)).map(([k, v]) => [k, walk(v, visitedRefs, chainDepth, nodeDepth + 1)]));
|
|
@@ -7834,7 +7707,18 @@ function dereferenceJsonSchema(schema) {
|
|
|
7834
7707
|
possibleFixes: REF_RESOLUTION_FIXES
|
|
7835
7708
|
});
|
|
7836
7709
|
if (visitedRefs.has(ref)) return { ...CYCLE_BREAK_SENTINEL };
|
|
7837
|
-
const
|
|
7710
|
+
const result = tryResolvePointer(root, ref);
|
|
7711
|
+
let target;
|
|
7712
|
+
if (result.kind === "ok") target = result.value;
|
|
7713
|
+
else if (strategy === "sentinel") {
|
|
7714
|
+
onReplace?.(ref, result.reason);
|
|
7715
|
+
target = {
|
|
7716
|
+
...CYCLE_BREAK_SENTINEL,
|
|
7717
|
+
description: UNRESOLVED_REF_DESCRIPTION
|
|
7718
|
+
};
|
|
7719
|
+
} else throwResolutionError(ref, result);
|
|
7720
|
+
const nextRefs = new Set(visitedRefs).add(ref);
|
|
7721
|
+
const resolved = walk(target, nextRefs, chainDepth + 1, nodeDepth + 1);
|
|
7838
7722
|
const siblings = { ...node };
|
|
7839
7723
|
delete siblings.$ref;
|
|
7840
7724
|
if (Object.keys(siblings).length === 0 || !require_FileToolModifier_utils_neutral.isPlainObject(resolved)) return resolved;
|
|
@@ -8412,7 +8296,6 @@ exports.ComposioAclOnlyForSharedError = require_CustomTool.ComposioAclOnlyForSha
|
|
|
8412
8296
|
exports.ComposioAuthConfigNotFoundError = require_CustomTool.ComposioAuthConfigNotFoundError;
|
|
8413
8297
|
exports.ComposioConnectedAccountNotFoundError = require_CustomTool.ComposioConnectedAccountNotFoundError;
|
|
8414
8298
|
exports.ComposioCustomCreateResponseSchema = ComposioCustomCreateResponseSchema;
|
|
8415
|
-
exports.ComposioCustomToolsNotInitializedError = require_CustomTool.ComposioCustomToolsNotInitializedError;
|
|
8416
8299
|
exports.ComposioError = require_FileModifierErrors.ComposioError;
|
|
8417
8300
|
exports.ComposioFailedToCreateConnectedAccountLink = require_CustomTool.ComposioFailedToCreateConnectedAccountLink;
|
|
8418
8301
|
exports.ComposioFailedToCreatePusherClientError = require_CustomTool.ComposioFailedToCreatePusherClientError;
|
|
@@ -8428,6 +8311,7 @@ exports.ComposioGenerateURLResponseSchema = ComposioGenerateURLResponseSchema;
|
|
|
8428
8311
|
exports.ComposioGlobalExecuteToolFnNotSetError = require_CustomTool.ComposioGlobalExecuteToolFnNotSetError;
|
|
8429
8312
|
exports.ComposioInvalidExecuteFunctionError = require_CustomTool.ComposioInvalidExecuteFunctionError;
|
|
8430
8313
|
exports.ComposioInvalidModifierError = require_CustomTool.ComposioInvalidModifierError;
|
|
8314
|
+
exports.ComposioInvalidToolArgumentsError = require_CustomTool.ComposioInvalidToolArgumentsError;
|
|
8431
8315
|
exports.ComposioLegacyConnectedAccountsEndpointRetiredError = require_CustomTool.ComposioLegacyConnectedAccountsEndpointRetiredError;
|
|
8432
8316
|
exports.ComposioMcpDeleteResponseSchema = ComposioMcpDeleteResponseSchema;
|
|
8433
8317
|
exports.ComposioMcpListResponseSchema = ComposioMcpListResponseSchema;
|
|
@@ -8634,4 +8518,6 @@ exports.getExtensionFromMimeType = getExtensionFromMimeType;
|
|
|
8634
8518
|
exports.handleToolExecutionError = require_CustomTool.handleToolExecutionError;
|
|
8635
8519
|
exports.jsonSchemaToZodSchema = jsonSchemaToZodSchema;
|
|
8636
8520
|
exports.logger = require_FileModifierErrors.logger_default;
|
|
8637
|
-
exports.
|
|
8521
|
+
exports.normalizeToolArguments = normalizeToolArguments;
|
|
8522
|
+
exports.removeNonRequiredProperties = removeNonRequiredProperties;
|
|
8523
|
+
exports.telemetry = require_Telemetry.telemetry;
|