@composio/core 0.9.1 → 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.
Files changed (39) hide show
  1. package/dist/{tool.types-CB_4JKhV.d.mts → BaseProvider-BvHvJLXc.d.mts} +24346 -24345
  2. package/dist/{tool.types-CwbAy9l_.d.cts → BaseProvider-CVbQxTNa.d.cts} +24346 -24345
  3. package/dist/{CustomTool-PSRHsd85.d.cts → CustomTool-C-IUByoU.d.cts} +1 -1
  4. package/dist/{CustomTool-BFkwL1aY.d.mts → CustomTool-CChQSp44.d.mts} +1 -1
  5. package/dist/{CustomTool-Bkk0QYzw.cjs → CustomTool-D3-NreIm.cjs} +81 -81
  6. package/dist/{CustomTool-IIUhFtP8.mjs → CustomTool-D5s-aADw.mjs} +76 -76
  7. package/dist/{FileToolModifier.utils.neutral-B7P7wn-b.mjs → FileToolModifier.utils.neutral-BpSceNK8.mjs} +1 -7
  8. package/dist/{FileToolModifier.utils.neutral-Dfwqgimk.cjs → FileToolModifier.utils.neutral-DSBQs9-i.cjs} +2 -8
  9. package/dist/{Telemetry-Dm-0sewu.cjs → Telemetry-BQ_pl5AK.cjs} +34 -9
  10. package/dist/{Telemetry-kgWlkavX.mjs → Telemetry-DQax33Gh.mjs} +34 -9
  11. package/dist/{composio-Dzlk0Wj4.d.mts → composio-BlASKqjQ.d.mts} +216 -237
  12. package/dist/{composio-BnLWW0B6.d.cts → composio-pcA13w87.d.cts} +216 -237
  13. package/dist/{customTool.types-oV5boR1w.d.mts → customTool.types-DLIORcYN.d.mts} +195 -138
  14. package/dist/{customTool.types-BVgnEbR2.d.cts → customTool.types-QtkAZQma.d.cts} +195 -138
  15. package/dist/experimental/index.cjs +1 -1
  16. package/dist/experimental/index.d.cts +2 -2
  17. package/dist/experimental/index.d.mts +3 -3
  18. package/dist/experimental/index.mjs +1 -1
  19. package/dist/index.cjs +623 -654
  20. package/dist/index.d.cts +415 -18
  21. package/dist/index.d.mts +415 -18
  22. package/dist/index.mjs +617 -652
  23. package/dist/models/Files.node.cjs +1 -1
  24. package/dist/models/Files.node.mjs +1 -1
  25. package/dist/{types-4vkdo_RG.d.cts → types-DRG5qLxI.d.cts} +2 -2
  26. package/dist/{types-AcoPzTnm.d.mts → types-J2KCXP8R.d.mts} +2 -2
  27. package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +2 -2
  28. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +4 -4
  29. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +2 -2
  30. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +4 -4
  31. package/dist/utils/modifiers/FileToolModifier.node.cjs +38 -21
  32. package/dist/utils/modifiers/FileToolModifier.node.d.cts +1 -1
  33. package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
  34. package/dist/utils/modifiers/FileToolModifier.node.mjs +38 -21
  35. package/dist/utils/modifiers/FileToolModifier.workerd.cjs +1 -1
  36. package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +1 -1
  37. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  38. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
  39. package/package.json +12 -3
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-Bkk0QYzw.cjs');
4
- const require_Telemetry = require('./Telemetry-Dm-0sewu.cjs');
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-Dfwqgimk.cjs');
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,465 +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
- const CreateConnectedAccountParamsSchema = zod_v3.z.object({
1096
- authConfig: zod_v3.z.object({ id: zod_v3.z.string() }),
1097
- connection: zod_v3.z.object({
1098
- data: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
1099
- callbackUrl: zod_v3.z.string().optional(),
1100
- userId: zod_v3.z.string().optional()
1101
- })
1102
- });
1103
- const DefaultCreateConnectedAccountParamsSchema = zod_v3.z.object({
1104
- auth_config: zod_v3.z.object({ id: zod_v3.z.string() }),
1105
- connection: zod_v3.z.object({
1106
- state: ConnectionDataSchema.optional(),
1107
- data: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
1108
- callback_url: zod_v3.z.string().optional(),
1109
- user_id: zod_v3.z.string().optional(),
1110
- alias: zod_v3.z.string().optional()
1111
- })
1112
- });
1113
- const CreateConnectedAccountOptionsSchema = zod_v3.z.object({
1114
- allowMultiple: zod_v3.z.boolean().optional(),
1115
- callbackUrl: zod_v3.z.string().optional(),
1116
- config: ConnectionDataSchema.optional(),
1117
- alias: zod_v3.z.string().optional()
1118
- });
1119
- /**
1120
- * Connected Account create response
1121
- */
1122
- const CreateConnectedAccountResponseSchema = zod_v3.z.object({
1123
- id: zod_v3.z.string(),
1124
- status: ConnectedAccountStatusSchema,
1125
- redirectUrl: zod_v3.z.string().nullable()
1126
- });
1127
- const ConnectedAccountAuthConfigSchema = zod_v3.z.object({
1128
- id: zod_v3.z.string(),
1129
- authScheme: AuthSchemeEnum.optional(),
1130
- isComposioManaged: zod_v3.z.boolean(),
1131
- isDisabled: zod_v3.z.boolean()
1132
- });
1133
- const ConnectedAccountRetrieveResponseSchema = zod_v3.z.object({
1134
- id: zod_v3.z.string(),
1135
- authConfig: ConnectedAccountAuthConfigSchema,
1136
- wordId: zod_v3.z.string().nullable().optional(),
1137
- alias: zod_v3.z.string().nullable().optional(),
1138
- data: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
1139
- params: zod_v3.z.record(zod_v3.z.string(), zod_v3.z.unknown()).optional(),
1140
- status: ConnectedAccountStatusSchema,
1141
- statusReason: zod_v3.z.string().nullable(),
1142
- toolkit: zod_v3.z.object({ slug: zod_v3.z.string() }),
1143
- state: ConnectionDataSchema.optional(),
1144
- testRequestEndpoint: zod_v3.z.string().optional(),
1145
- isDisabled: zod_v3.z.boolean(),
1146
- createdAt: zod_v3.z.string(),
1147
- updatedAt: zod_v3.z.string(),
1148
- accountType: ConnectedAccountTypeSchema.optional(),
1149
- aclConfigForShared: ConnectedAccountAclConfigResponseSchema.optional()
1150
- });
1151
- const ConnectedAccountListParamsSchema = zod_v3.z.object({
1152
- authConfigIds: zod_v3.z.array(zod_v3.z.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
1153
- cursor: zod_v3.z.string().nullish().describe("The cursor to paginate through the connected accounts"),
1154
- limit: zod_v3.z.number().nullable().optional().describe("The limit of the connected accounts to return"),
1155
- orderBy: zod_v3.z.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
1156
- statuses: zod_v3.z.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
1157
- toolkitSlugs: zod_v3.z.array(zod_v3.z.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
1158
- userIds: zod_v3.z.array(zod_v3.z.string()).nullable().optional().describe("The user ids of the connected accounts")
1159
- });
1160
- const ConnectedAccountListResponseSchema = zod_v3.z.object({
1161
- items: zod_v3.z.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
1162
- nextCursor: zod_v3.z.string().nullish().describe("The next cursor to paginate through the connected accounts"),
1163
- totalPages: zod_v3.z.number().describe("The total number of pages of connected accounts")
1164
- });
1165
- const CreateConnectedAccountLinkOptionsSchema = zod_v3.z.object({
1166
- callbackUrl: zod_v3.z.string().optional(),
1167
- alias: zod_v3.z.string().optional(),
1168
- allowMultiple: zod_v3.z.boolean().optional(),
1169
- accountType: ConnectedAccountTypeSchema.optional(),
1170
- aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
1171
- });
1172
- const CreateConnectedAccountLinkResponseSchema = zod_v3.z.object({ redirectUrl: zod_v3.z.string() });
1173
- const ConnectedAccountRefreshOptionsSchema = zod_v3.z.object({
1174
- redirectUrl: zod_v3.z.string().optional(),
1175
- validateCredentials: zod_v3.z.boolean().optional()
1176
- });
1177
- const UpdateConnectedAccountParamsSchema = zod_v3.z.object({ enabled: zod_v3.z.boolean() });
1178
- /**
1179
- * Params for `composio.connectedAccounts.updateAcl()`. Mirrors the inner
1180
- * shape of the wire's `acl_config_for_shared` block — the SDK adds the
1181
- * outer nesting at the boundary, so callers pass the three fields flat.
1182
- *
1183
- * PATCH-style semantics — omit a field to leave it unchanged; pass an
1184
- * empty array to clear an allow/deny list. Raises
1185
- * `ComposioAclOnlyForSharedError` on a PRIVATE connection.
1186
- *
1187
- * Each field is optional, but at least one must be provided — passing an
1188
- * empty object is rejected as a no-op.
1189
- */
1190
- 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" });
1191
-
1192
- //#endregion
1193
- //#region src/utils/transform.ts
1194
- function transform(raw) {
1195
- return { with(schema) {
1196
- return { using(transformer, options) {
1197
- const transformed = transformer(raw);
1198
- const result = schema.safeParse(transformed);
1199
- if (!result.success) {
1200
- const label = options?.label ? ` for ${options.label}` : "";
1201
- const issues = result.error.issues.map((issue) => ` - ${issue.path.join(".") || "parameter"}: ${issue.message}`).join("\n");
1202
- require_FileModifierErrors.logger_default.warn(`Transform validation failed${label}:\n${issues}`);
1203
- return transformed;
1204
- }
1205
- return result.data;
1206
- } };
1207
- } };
1208
- }
1209
-
1210
- //#endregion
1211
- //#region src/utils/transformers/connectedAccounts.ts
1212
- /**
1213
- * Transforms the raw connected account response from the Composio API to the SDK format.
1214
- *
1215
- * This method converts property names from snake_case to camelCase and reorganizes
1216
- * the data structure to match the SDK's standardized format.
1217
- *
1218
- * @param {RawConnectedAccountListResponse['items'][0]|RawConnectedAccountRetrieveResponse} response - The raw API response to transform
1219
- * @returns {Promise<ConnectedAccountRetrieveResponse>} The transformed response
1220
- * @throws {ZodError} If the response fails validation against the expected schema
1221
- *
1222
- * @private
1223
- */
1224
- function transformConnectedAccountResponse(response) {
1225
- const responseWithLabels = response;
1226
- const parseState = (state) => {
1227
- try {
1228
- return state ? ConnectionDataSchema.parse(state) : void 0;
1229
- } catch (error) {
1230
- require_FileModifierErrors.logger_default.warn("Unsupported auth scheme in connected account state, ignoring state field", { error });
1231
- return;
1232
- }
1233
- };
1234
- return transform(response).with(ConnectedAccountRetrieveResponseSchema).using((response$1) => ({
1235
- ...response$1,
1236
- authConfig: {
1237
- ...response$1.auth_config,
1238
- id: response$1.auth_config.id,
1239
- authScheme: response$1.auth_config.auth_scheme,
1240
- isComposioManaged: response$1.auth_config.is_composio_managed,
1241
- isDisabled: response$1.auth_config.is_disabled
1242
- },
1243
- wordId: responseWithLabels.word_id ?? null,
1244
- alias: responseWithLabels.alias ?? null,
1245
- data: response$1.data ?? void 0,
1246
- state: parseState(response$1.state),
1247
- status: response$1.status,
1248
- statusReason: response$1.status_reason,
1249
- isDisabled: response$1.is_disabled,
1250
- createdAt: response$1.created_at,
1251
- updatedAt: response$1.updated_at,
1252
- testRequestEndpoint: response$1.test_request_endpoint,
1253
- accountType: responseWithLabels.account_type,
1254
- aclConfigForShared: responseWithLabels.acl_config_for_shared ? {
1255
- allowAllUsers: responseWithLabels.acl_config_for_shared.allow_all_users,
1256
- allowedUserIds: responseWithLabels.acl_config_for_shared.allowed_user_ids,
1257
- notAllowedUserIds: responseWithLabels.acl_config_for_shared.not_allowed_user_ids
1258
- } : void 0
1259
- }));
1260
- }
1261
- /**
1262
- * Transforms the raw connected account list response from the Composio API to the SDK format.
1263
- *
1264
- * This method converts property names from snake_case to camelCase and reorganizes
1265
- * the data structure to match the SDK's standardized format.
1266
- *
1267
- * @param {RawConnectedAccountListResponse} response - The raw API response to transform
1268
- * @returns {ConnectedAccountListResponse} The transformed response
1269
- * @throws {ZodError} If the response fails validation against the expected schema
1270
- *
1271
- * @private
1272
- */
1273
- function transformConnectedAccountListResponse(response) {
1274
- return transform(response).with(ConnectedAccountListResponseSchema).using((response$1) => ({
1275
- items: response$1.items.map(transformConnectedAccountResponse),
1276
- nextCursor: response$1.next_cursor ?? null,
1277
- totalPages: response$1.total_pages
1278
- }));
1279
- }
1280
-
1281
- //#endregion
1282
- //#region src/models/CustomTools.ts
1283
- var CustomTools = class {
1284
- client;
1285
- customToolsRegistry;
1286
- constructor(client) {
1287
- if (!client) throw new require_FileModifierErrors.ComposioError("ComposioClient is required");
1288
- this.client = client;
1289
- this.customToolsRegistry = /* @__PURE__ */ new Map();
1290
- require_Telemetry.telemetry.instrument(this, "CustomTools");
1291
- }
1292
- /**
1293
- * Create a custom tool and registers it in the registry.
1294
- * This is just an in memory registry and is not persisted.
1295
- * @param {CustomToolOptions} toolOptions CustomToolOptions
1296
- * @returns {Tool} The tool created
1297
- *
1298
- * @example
1299
- * ```typescript
1300
- * // Create a custom tool with input parameters
1301
- * const customTool = await composio.customTools.createTool({
1302
- * name: 'My Custom Tool',
1303
- * description: 'A tool that performs a custom operation',
1304
- * slug: 'MY_CUSTOM_TOOL',
1305
- * inputParams: z.object({
1306
- * query: z.string().describe('The search query'),
1307
- * limit: z.number().optional().describe('Maximum number of results')
1308
- * }),
1309
- * execute: async (input, connectionConfig, executeToolRequest) => {
1310
- * // Custom implementation logic
1311
- * return {
1312
- * data: { results: ['result1', 'result2'] }
1313
- * };
1314
- * }
1315
- * });
1316
- * ```
1317
- */
1318
- async createTool(toolOptions) {
1319
- const { slug, execute, inputParams, name, description } = toolOptions;
1320
- if (!slug || !execute || !inputParams || !name) throw new Error("Invalid tool options");
1321
- const paramsSchemaJson = zod_to_json_schema.default(inputParams, { name: "input" }).definitions.input;
1322
- const toolSchema = {
1323
- name,
1324
- slug,
1325
- description,
1326
- inputParameters: {
1327
- title: name,
1328
- type: "object",
1329
- description,
1330
- properties: paramsSchemaJson.properties,
1331
- required: paramsSchemaJson.required
1332
- },
1333
- outputParameters: {
1334
- type: "object",
1335
- title: `Response for ${name}`,
1336
- properties: {}
1337
- },
1338
- tags: [],
1339
- toolkit: {
1340
- name: "custom",
1341
- slug: "custom"
1342
- }
1343
- };
1344
- this.customToolsRegistry.set(slug.toLowerCase(), {
1345
- options: toolOptions,
1346
- schema: toolSchema
1347
- });
1348
- return toolSchema;
1349
- }
1350
- /**
1351
- * Get all the custom tools from the registry.
1352
- * @param {string[]} param0.toolSlugs The slugs of the tools to get
1353
- * @returns {ToolList} The list of tools
1354
- *
1355
- * @example
1356
- * ```typescript
1357
- * // Get all custom tools
1358
- * const allTools = await composio.customTools.getCustomTools({});
1359
- *
1360
- * // Get specific custom tools by slug
1361
- * const specificTools = await composio.customTools.getCustomTools({
1362
- * toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL']
1363
- * });
1364
- * ```
1365
- */
1366
- async getCustomTools({ toolSlugs }) {
1367
- const tools = [];
1368
- if (toolSlugs) for (const slug of toolSlugs) {
1369
- const tool = this.customToolsRegistry.get(slug.toLowerCase());
1370
- if (tool) tools.push(tool.schema);
1371
- }
1372
- else return Array.from(this.customToolsRegistry.values()).map((tool) => tool.schema);
1373
- return tools;
1374
- }
1375
- /**
1376
- * Get a custom tool by slug from the registry.
1377
- * @param {string} slug The slug of the tool to get
1378
- * @returns {Tool} The tool
1379
- *
1380
- * @example
1381
- * ```typescript
1382
- * // Get a specific custom tool by its slug
1383
- * const myTool = await composio.customTools.getCustomToolBySlug('MY_CUSTOM_TOOL');
1384
- * if (myTool) {
1385
- * console.log(`Found tool: ${myTool.name}`);
1386
- * } else {
1387
- * console.log('Tool not found');
1388
- * }
1389
- * ```
1390
- */
1391
- async getCustomToolBySlug(slug) {
1392
- try {
1393
- return this.customToolsRegistry.get(slug.toLowerCase())?.schema;
1394
- } catch (error) {
1395
- require_FileModifierErrors.logger_default.error(`Error getting custom tool: ${error}`);
1396
- return;
1397
- }
1398
- }
1399
- /**
1400
- * Get the connected account for the user and toolkit.
1401
- * @param {string} toolkitSlug The slug of the toolkit
1402
- * @param {ExecuteMetadata} metadata The metadata of the execution
1403
- * @returns {ConnectedAccount} The connected account
1404
- */
1405
- async getConnectedAccountForToolkit(toolkitSlug, userId, connectedAccountId) {
1406
- try {
1407
- await this.client.toolkits.retrieve(toolkitSlug);
1408
- if ((await this.client.toolkits.retrieve(toolkitSlug)).auth_config_details?.some((details) => details.mode === AuthSchemeTypes.NO_AUTH)) return null;
1409
- } catch (error) {
1410
- throw new require_CustomTool.ComposioToolNotFoundError(`Toolkit with slug ${toolkitSlug} not found`, { cause: error });
1411
- }
1412
- const connectedAccounts = await this.client.connectedAccounts.list({
1413
- toolkit_slugs: [toolkitSlug],
1414
- user_ids: [userId]
1415
- });
1416
- if (!connectedAccounts.items.length) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`No connected accounts found for toolkit ${toolkitSlug}`);
1417
- const connectedAccount = connectedAccountId ? connectedAccounts.items.find((item) => item.id === connectedAccountId) : connectedAccounts.items[0];
1418
- if (!connectedAccount) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${userId}`);
1419
- return transformConnectedAccountResponse(connectedAccount);
1420
- }
1421
- /**
1422
- * Execute a custom tool
1423
- *
1424
- * @description If a toolkit is used, the connected account id is used to execute the tool.
1425
- * If a connected account id is provided, it is used to execute the tool.
1426
- * If a connected account id is not provided, the first connected account for the toolkit is used.
1427
- *
1428
- * @param {slug} slug The slug of the tool to execute
1429
- * @param {Record<string, unknown>} inputParams The input parameters for the tool
1430
- * @param {ExecuteMetadata} metadata The metadata of the execution
1431
- * @returns {Promise<ToolExecuteResponse>} The response from the tool
1432
- */
1433
- async executeCustomTool(slug, body) {
1434
- const tool = this.customToolsRegistry.get(slug.toLowerCase());
1435
- if (!tool) throw new require_CustomTool.ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
1436
- let connectionConfig = null;
1437
- const { toolkitSlug, execute, inputParams } = tool.options;
1438
- let connectedAccountId = body.connectedAccountId;
1439
- if (toolkitSlug && toolkitSlug !== "custom" && body.userId) {
1440
- const connectedAccount = await this.getConnectedAccountForToolkit(toolkitSlug, body.userId, body.connectedAccountId);
1441
- require_FileModifierErrors.logger_default.debug(`[CustomTool] Connected account for ${toolkitSlug} found for user ${body.userId}`, JSON.stringify(connectedAccount, null, 2));
1442
- if (!connectedAccount) throw new require_CustomTool.ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${body.userId}`, { meta: {
1443
- toolkitSlug,
1444
- userId: body.userId
1445
- } });
1446
- connectionConfig = connectedAccount.state ?? null;
1447
- connectedAccountId = connectedAccount.id;
1448
- }
1449
- if (typeof execute !== "function") throw new require_CustomTool.ComposioInvalidExecuteFunctionError("Invalid execute function", { meta: { toolSlug: slug } });
1450
- const executeToolRequest = async (data) => {
1451
- 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"] });
1452
- const parameters = data.parameters?.map((param) => ({
1453
- name: param.name,
1454
- type: param.in,
1455
- value: param.value.toString()
1456
- }));
1457
- return {
1458
- data: (await this.client.tools.proxy({
1459
- endpoint: data.endpoint,
1460
- method: data.method,
1461
- parameters,
1462
- body: data.body,
1463
- connected_account_id: connectedAccountId,
1464
- custom_connection_data: data.customConnectionData
1465
- })).data,
1466
- error: null,
1467
- successful: true,
1468
- logId: void 0,
1469
- sessionInfo: void 0
1470
- };
1471
- };
1472
- const parsedInput = inputParams.safeParse(body.arguments);
1473
- if (!parsedInput.success) throw new require_CustomTool.ValidationError("Invalid input parameters", { cause: parsedInput.error });
1474
- return execute(parsedInput.data, connectionConfig, executeToolRequest);
1475
- }
1476
- };
1477
-
1478
1017
  //#endregion
1479
1018
  //#region src/utils/toolkitVersion.ts
1480
1019
  /**
@@ -1570,12 +1109,27 @@ function resolveEffectiveUploadAllowlist(userDirs) {
1570
1109
  //#region src/models/Tools.ts
1571
1110
  const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
1572
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
+ /**
1573
1128
  * This class is used to manage tools in the Composio SDK.
1574
1129
  * It provides methods to list, get, and execute tools.
1575
1130
  */
1576
1131
  var Tools = class {
1577
1132
  client;
1578
- customTools;
1579
1133
  provider;
1580
1134
  autoUploadDownloadFiles;
1581
1135
  toolkitVersions;
@@ -1590,7 +1144,6 @@ var Tools = class {
1590
1144
  if (!client) throw new Error("ComposioClient is required");
1591
1145
  if (!config?.provider) throw new require_CustomTool.ComposioProviderNotDefinedError("Provider not passed into Tools instance");
1592
1146
  this.client = client;
1593
- this.customTools = new CustomTools(client);
1594
1147
  this.provider = config.provider;
1595
1148
  this.autoUploadDownloadFiles = config?.dangerouslyAllowAutoUploadDownloadFiles === true;
1596
1149
  this.toolkitVersions = config?.toolkitVersions ?? _config_defaults.CONFIG_DEFAULTS.toolkitVersions;
@@ -1620,8 +1173,8 @@ var Tools = class {
1620
1173
  transformToolCases(tool) {
1621
1174
  return ToolSchema.parse({
1622
1175
  ...tool,
1623
- inputParameters: tool.input_parameters,
1624
- outputParameters: tool.output_parameters,
1176
+ inputParameters: normalizeRawToolParameters(tool.input_parameters),
1177
+ outputParameters: normalizeRawToolParameters(tool.output_parameters),
1625
1178
  availableVersions: tool.available_versions,
1626
1179
  isDeprecated: tool.deprecated?.is_deprecated ?? false,
1627
1180
  isNoAuth: tool.no_auth
@@ -1724,10 +1277,12 @@ var Tools = class {
1724
1277
  return modifiedResult;
1725
1278
  }
1726
1279
  /**
1727
- * Lists all tools available in the Composio SDK including custom tools.
1280
+ * Lists Composio API tools available to the SDK.
1728
1281
  *
1729
- * This method fetches tools from the Composio API in raw format and combines them with
1730
- * any registered custom tools. The response can be filtered and modified as needed.
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()`.
1731
1286
  * It provides access to the underlying tool data without provider-specific wrapping.
1732
1287
  *
1733
1288
  * @param {ToolListParams} query - Query parameters to filter the tools (required)
@@ -1804,8 +1359,7 @@ var Tools = class {
1804
1359
  const tools = await this.client.tools.list(filters);
1805
1360
  if (!tools) return [];
1806
1361
  const caseTransformedTools = tools.items.map((tool) => this.transformToolCases(tool));
1807
- const customTools = await this.customTools.getCustomTools({ toolSlugs: "tools" in queryParams.data ? queryParams.data.tools : void 0 });
1808
- let modifiedTools = await this.applyDefaultSchemaModifiers([...caseTransformedTools, ...customTools]);
1362
+ let modifiedTools = await this.applyDefaultSchemaModifiers(caseTransformedTools);
1809
1363
  if (options?.modifySchema) {
1810
1364
  const modifier = options.modifySchema;
1811
1365
  if (typeof modifier === "function") {
@@ -1866,6 +1420,9 @@ var Tools = class {
1866
1420
  * This method fetches a single tool in raw format without provider-specific wrapping,
1867
1421
  * providing direct access to the tool's schema and metadata. Tool versions are controlled
1868
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()`.
1869
1426
  *
1870
1427
  * @param {string} slug - The unique identifier of the tool (e.g., 'GITHUB_GET_REPOS')
1871
1428
  * @param {GetRawComposioToolBySlugOptions} [options] - Optional configuration for tool retrieval
@@ -1895,9 +1452,6 @@ var Tools = class {
1895
1452
  * }
1896
1453
  * );
1897
1454
  *
1898
- * // Get a custom tool (will check custom tools first)
1899
- * const customTool = await composio.tools.getRawComposioToolBySlug('MY_CUSTOM_TOOL');
1900
- *
1901
1455
  * // Access tool properties
1902
1456
  * const githubTool = await composio.tools.getRawComposioToolBySlug('GITHUB_CREATE_ISSUE');
1903
1457
  * console.log({
@@ -1911,11 +1465,6 @@ var Tools = class {
1911
1465
  * ```
1912
1466
  */
1913
1467
  async getRawComposioToolBySlug(slug, options) {
1914
- const customTool = await this.customTools.getCustomToolBySlug(slug);
1915
- if (customTool) {
1916
- require_FileModifierErrors.logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
1917
- return customTool;
1918
- } else require_FileModifierErrors.logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
1919
1468
  let tool;
1920
1469
  try {
1921
1470
  const retrieveParams = options?.version ? { version: options.version } : { toolkit_versions: this.toolkitVersions };
@@ -2067,8 +1616,7 @@ var Tools = class {
2067
1616
  /**
2068
1617
  * Executes a given tool with the provided parameters.
2069
1618
  *
2070
- * This method calls the Composio API or a custom tool handler to execute the tool and returns the response.
2071
- * 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.
2072
1620
  *
2073
1621
  * **Version Control:**
2074
1622
  * By default, manual tool execution requires a specific toolkit version. If the version resolves to "latest",
@@ -2085,7 +1633,6 @@ var Tools = class {
2085
1633
  * @param {ExecuteToolModifiers} [modifiers] - Optional modifiers to transform the request or response
2086
1634
  * @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
2087
1635
  *
2088
- * @throws {ComposioCustomToolsNotInitializedError} If the CustomTools instance is not initialized
2089
1636
  * @throws {ComposioConnectedAccountNotFoundError} If the connected account is not found
2090
1637
  * @throws {ComposioToolNotFoundError} If the tool with the given slug is not found
2091
1638
  * @throws {ComposioToolVersionRequiredError} If version resolves to "latest" and dangerouslySkipVersionCheck is not true
@@ -2138,18 +1685,16 @@ var Tools = class {
2138
1685
  * ```
2139
1686
  */
2140
1687
  async execute(slug, body, modifiers) {
2141
- if (!this.customTools) throw new require_CustomTool.ComposioCustomToolsNotInitializedError("CustomTools not initialized. Make sure Tools class is properly constructed.");
2142
1688
  const executeParams = ToolExecuteParamsSchema.safeParse(body);
2143
1689
  if (!executeParams.success) throw new require_CustomTool.ValidationError("Invalid tool execute parameters", { cause: executeParams.error });
2144
- const customTool = await this.customTools.getCustomToolBySlug(slug);
2145
- const tool = customTool ?? await this.getRawComposioToolBySlug(slug, { version: body.version });
1690
+ const tool = await this.getRawComposioToolBySlug(slug, { version: body.version });
2146
1691
  const toolkitSlug = tool.toolkit?.slug ?? "unknown";
2147
1692
  const params = await this.applyBeforeExecuteModifiers(tool, {
2148
1693
  toolSlug: slug,
2149
1694
  toolkitSlug,
2150
1695
  params: executeParams.data
2151
1696
  }, modifiers);
2152
- let result = customTool ? await this.customTools.executeCustomTool(customTool.slug, params) : await this.executeComposioTool(tool, params);
1697
+ let result = await this.executeComposioTool(tool, params);
2153
1698
  result = await this.applyAfterExecuteModifiers(tool, {
2154
1699
  toolSlug: slug,
2155
1700
  toolkitSlug,
@@ -2283,54 +1828,6 @@ var Tools = class {
2283
1828
  custom_connection_data: toolProxyParams.data.customConnectionData
2284
1829
  });
2285
1830
  }
2286
- /**
2287
- * Creates a custom tool that can be used within the Composio SDK.
2288
- *
2289
- * Custom tools allow you to extend the functionality of Composio with your own implementations
2290
- * while keeping a consistent interface for both built-in and custom tools.
2291
- *
2292
- * @param {CustomToolOptions} body - The configuration for the custom tool
2293
- * @returns {Promise<Tool>} The created custom tool
2294
- *
2295
- * @example
2296
- * ```typescript
2297
- * // creating a custom tool with a toolkit
2298
- * await composio.tools.createCustomTool({
2299
- * name: 'My Custom Tool',
2300
- * description: 'A custom tool that does something specific',
2301
- * slug: 'MY_CUSTOM_TOOL',
2302
- * userId: 'default',
2303
- * connectedAccountId: '123',
2304
- * toolkitSlug: 'github',
2305
- * inputParameters: z.object({
2306
- * param1: z.string().describe('First parameter'),
2307
- * }),
2308
- * execute: async (input, connectionConfig, executeToolRequest) => {
2309
- * // Custom logic here
2310
- * return { data: { result: 'Success!' } };
2311
- * }
2312
- * });
2313
- * ```
2314
- *
2315
- * @example
2316
- * ```typescript
2317
- * // creating a custom tool without a toolkit
2318
- * await composio.tools.createCustomTool({
2319
- * name: 'My Custom Tool',
2320
- * description: 'A custom tool that does something specific',
2321
- * slug: 'MY_CUSTOM_TOOL',
2322
- * inputParameters: z.object({
2323
- * param1: z.string().describe('First parameter'),
2324
- * }),
2325
- * execute: async (input) => {
2326
- * // Custom logic here
2327
- * return { data: { result: 'Success!' } };
2328
- * }
2329
- * });
2330
- */
2331
- async createCustomTool(body) {
2332
- return this.customTools.createTool(body);
2333
- }
2334
1831
  };
2335
1832
 
2336
1833
  //#endregion
@@ -2429,6 +1926,24 @@ const ToolkitRetrieveCategoriesResponseSchema = zod_v3.z.object({
2429
1926
  });
2430
1927
  const ToolkitAuthFieldsResponseSchema = zod_v3.z.array(ToolkitAuthFieldSchema.extend({ required: zod_v3.z.boolean().optional() }));
2431
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
+
2432
1947
  //#endregion
2433
1948
  //#region src/utils/transformers/authConfigs.ts
2434
1949
  /**
@@ -2765,6 +2280,275 @@ var AuthConfigs = class {
2765
2280
  }
2766
2281
  };
2767
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
+
2768
2552
  //#endregion
2769
2553
  //#region src/models/ConnectionRequest.ts
2770
2554
  /**
@@ -2863,22 +2647,28 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
2863
2647
  }
2864
2648
 
2865
2649
  //#endregion
2866
- //#region src/models/ConnectedAccounts.ts
2650
+ //#region src/models/Experimental.ts
2867
2651
  /**
2868
- * @fileoverview Connected accounts class for Composio SDK, used to manage connected accounts of a user.
2652
+ * @fileoverview The `composio.experimental` namespace. Houses experimental
2653
+ * SDK methods whose shape may change in future releases.
2869
2654
  *
2870
- * @author Musthaq Ahamad <musthaq@composio.dev>
2871
- * @date 2025-05-05
2872
- * @module ConnectedAccounts
2655
+ * For experimental stateless factories (e.g. `experimental_createTool`),
2656
+ * see the top-level `experimental_*` exports from `@composio/core`.
2657
+ * Anything that takes a Composio client and performs I/O belongs here.
2873
2658
  */
2874
- let _legacyInitiateWarningEmitted = false;
2659
+ /**
2660
+ * Server-side 400 message the API uses to reject ACL writes against a
2661
+ * PRIVATE connection. Substring-matched in `updateAcl` here, and in the
2662
+ * sibling `connectedAccounts.link()` / `session.authorize()` call sites
2663
+ * — kept as a single constant so a server-side message tweak only
2664
+ * requires one edit.
2665
+ */
2666
+ const ACL_ONLY_FOR_SHARED_ERROR_FRAGMENT = "acl_config_for_shared is only valid on SHARED";
2875
2667
  /**
2876
2668
  * Serialise the SDK's `aclConfigForShared` (camelCase) to the wire's
2877
2669
  * `acl_config_for_shared` block. Returns `undefined` when the caller
2878
2670
  * didn't pass anything (PATCH-style "don't touch ACL"); returns `{}`
2879
- * when the caller passed an explicit empty object — both mean
2880
- * deny-by-default, but the explicit form preserves the caller's intent
2881
- * in network traces.
2671
+ * when the caller passed an explicit empty object.
2882
2672
  */
2883
2673
  function serializeAclConfigForWire(acl) {
2884
2674
  if (acl === void 0) return void 0;
@@ -2889,6 +2679,110 @@ function serializeAclConfigForWire(acl) {
2889
2679
  };
2890
2680
  }
2891
2681
  /**
2682
+ * Serialise the SDK's `experimental` options block (camelCase) to the
2683
+ * wire's `experimental` block (snake_case). Used by both
2684
+ * `connectedAccounts.link()` and `session.authorize()`. Returns
2685
+ * `undefined` when the caller didn't pass the block at all.
2686
+ */
2687
+ function serializeExperimentalForWire(experimental) {
2688
+ if (experimental === void 0) return void 0;
2689
+ const aclWire = serializeAclConfigForWire(experimental.aclConfigForShared);
2690
+ const wire = {};
2691
+ if (experimental.accountType !== void 0) wire.account_type = experimental.accountType;
2692
+ if (aclWire !== void 0) wire.acl_config_for_shared = aclWire;
2693
+ return wire;
2694
+ }
2695
+ /**
2696
+ * `composio.experimental` namespace. Mirrors the Python SDK's
2697
+ * `composio.experimental` mount, with one method per experimental
2698
+ * surface. **Shape may change in future releases.**
2699
+ */
2700
+ var Experimental = class {
2701
+ client;
2702
+ constructor(client) {
2703
+ this.client = client;
2704
+ require_Telemetry.telemetry.instrument(this, "Experimental");
2705
+ }
2706
+ /**
2707
+ * Update the per-user ACL on a SHARED connected account.
2708
+ * **Experimental — shape may change in future releases.**
2709
+ *
2710
+ * Only meaningful for SHARED connections — calling this on a PRIVATE
2711
+ * connection raises `ComposioAclOnlyForSharedError` (400). ACL writes
2712
+ * require the connection's creator or an API key.
2713
+ *
2714
+ * PATCH semantics: omit a field to leave it unchanged; pass an empty
2715
+ * array to clear an allow/deny list. At least one field must be
2716
+ * provided.
2717
+ *
2718
+ * Resolution rule (deny wins):
2719
+ * 1. requesting `userId` in `notAllowedUserIds` → DENY
2720
+ * 2. `allowAllUsers === true` → ALLOW
2721
+ * 3. requesting `userId` in `allowedUserIds` → ALLOW
2722
+ * 4. otherwise → DENY
2723
+ *
2724
+ * @example
2725
+ * ```typescript
2726
+ * import { Composio } from '@composio/core';
2727
+ *
2728
+ * const composio = new Composio({ apiKey: '...' });
2729
+ *
2730
+ * // Allow every userId to use this connection
2731
+ * await composio.experimental.updateAcl('ca_abc', { allowAllUsers: true });
2732
+ *
2733
+ * // Everyone except a specific user
2734
+ * await composio.experimental.updateAcl('ca_abc', {
2735
+ * allowAllUsers: true,
2736
+ * notAllowedUserIds: ['user_bob'],
2737
+ * });
2738
+ *
2739
+ * // Targeted allow
2740
+ * await composio.experimental.updateAcl('ca_abc', {
2741
+ * allowedUserIds: ['user_alice', 'user_bob'],
2742
+ * });
2743
+ *
2744
+ * // Revoke a previously-granted allow list (back to deny-by-default)
2745
+ * await composio.experimental.updateAcl('ca_abc', { allowedUserIds: [] });
2746
+ * ```
2747
+ *
2748
+ * **Empty-array semantics — read carefully.** Passing `[]` for either
2749
+ * list **replaces** the list, it does not extend it:
2750
+ *
2751
+ * - `allowedUserIds: []` → revoke all previously-granted user IDs (state
2752
+ * reverts to deny-by-default unless `allowAllUsers` is true).
2753
+ * - `notAllowedUserIds: []` → **clears the deny list**, which silently
2754
+ * re-grants access to users you previously blocked. Always pair an
2755
+ * empty deny list with a deliberate audit of the allow side.
2756
+ *
2757
+ * @returns The PATCH response (`{ id, status, success }`). To read
2758
+ * the updated ACL block, call
2759
+ * `composio.connectedAccounts.get(nanoid)` after the promise
2760
+ * resolves and inspect `account.experimental?.aclConfigForShared`.
2761
+ */
2762
+ async updateAcl(nanoid, params) {
2763
+ const parsedParams = UpdateConnectedAccountAclParamsSchema.safeParse(params);
2764
+ if (!parsedParams.success) throw new require_CustomTool.ValidationError("Failed to parse connected account ACL update params", { cause: parsedParams.error });
2765
+ const body = { experimental: { acl_config_for_shared: serializeAclConfigForWire(parsedParams.data) } };
2766
+ try {
2767
+ return await this.client.connectedAccounts.patch(nanoid, body);
2768
+ } catch (error) {
2769
+ if (error instanceof _composio_client.BadRequestError && typeof error.message === "string" && error.message.includes(ACL_ONLY_FOR_SHARED_ERROR_FRAGMENT)) throw new require_CustomTool.ComposioAclOnlyForSharedError(error.message, { cause: error });
2770
+ throw error;
2771
+ }
2772
+ }
2773
+ };
2774
+
2775
+ //#endregion
2776
+ //#region src/models/ConnectedAccounts.ts
2777
+ /**
2778
+ * @fileoverview Connected accounts class for Composio SDK, used to manage connected accounts of a user.
2779
+ *
2780
+ * @author Musthaq Ahamad <musthaq@composio.dev>
2781
+ * @date 2025-05-05
2782
+ * @module ConnectedAccounts
2783
+ */
2784
+ let _legacyInitiateWarningEmitted = false;
2785
+ /**
2892
2786
  * ConnectedAccounts class
2893
2787
  *
2894
2788
  * This class is used to manage connected accounts in the Composio SDK.
@@ -2936,7 +2830,8 @@ var ConnectedAccounts = class {
2936
2830
  order_by: parsedQuery.data.orderBy,
2937
2831
  statuses: parsedQuery.data.statuses,
2938
2832
  toolkit_slugs: parsedQuery.data.toolkitSlugs,
2939
- user_ids: parsedQuery.data.userIds
2833
+ user_ids: parsedQuery.data.userIds,
2834
+ ...parsedQuery.data.accountType !== void 0 && { account_type: parsedQuery.data.accountType }
2940
2835
  };
2941
2836
  }
2942
2837
  return transformConnectedAccountListResponse(await this.client.connectedAccounts.list(rawQuery));
@@ -3092,20 +2987,19 @@ var ConnectedAccounts = class {
3092
2987
  if (existing.items.length > 0 && !requestOptions.data.allowMultiple) throw new require_CustomTool.ComposioMultipleConnectedAccountsError(`Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts.`);
3093
2988
  else if (existing.items.length > 0) require_FileModifierErrors.logger_default.warn(`[Warn:AllowMultiple] Multiple connected accounts found for user ${userId} in auth config ${authConfigId}`);
3094
2989
  const opts = requestOptions.data;
3095
- const aclWire = serializeAclConfigForWire(opts.aclConfigForShared);
2990
+ const experimentalWire = serializeExperimentalForWire(opts.experimental);
3096
2991
  const body = {
3097
2992
  auth_config_id: authConfigId,
3098
2993
  user_id: userId,
3099
2994
  ...opts.callbackUrl !== void 0 && { callback_url: opts.callbackUrl },
3100
2995
  ...opts.alias !== void 0 && { alias: opts.alias },
3101
- ...opts.accountType !== void 0 && { account_type: opts.accountType },
3102
- ...aclWire !== void 0 && { acl_config_for_shared: aclWire }
2996
+ ...experimentalWire !== void 0 && { experimental: experimentalWire }
3103
2997
  };
3104
2998
  try {
3105
2999
  const response = await this.client.link.create(body);
3106
3000
  return createConnectionRequest(this.client, response.connected_account_id, ConnectedAccountStatuses.INITIATED, response.redirect_url);
3107
3001
  } catch (error) {
3108
- if (error instanceof _composio_client.BadRequestError && typeof error.message === "string" && error.message.includes("acl_config_for_shared is only valid on SHARED")) throw new require_CustomTool.ComposioAclOnlyForSharedError(error.message, { cause: error });
3002
+ if (error instanceof _composio_client.BadRequestError && typeof error.message === "string" && error.message.includes(ACL_ONLY_FOR_SHARED_ERROR_FRAGMENT)) throw new require_CustomTool.ComposioAclOnlyForSharedError(error.message, { cause: error });
3109
3003
  throw new require_CustomTool.ComposioFailedToCreateConnectedAccountLink("Failed to create connected account link", { cause: error });
3110
3004
  }
3111
3005
  }
@@ -3264,7 +3158,8 @@ var ConnectedAccounts = class {
3264
3158
  /**
3265
3159
  * Enable or disable a connected account. Accepts `{ enabled: boolean }`.
3266
3160
  *
3267
- * For ACL writes on SHARED connections, see {@link updateAcl}.
3161
+ * For ACL writes on SHARED connections, see
3162
+ * `composio.experimental.updateAcl()`.
3268
3163
  *
3269
3164
  * @param {string} nanoid - The unique identifier of the connected account
3270
3165
  * @param {UpdateConnectedAccountParams} params - The update parameters
@@ -3281,67 +3176,6 @@ var ConnectedAccounts = class {
3281
3176
  if (!parsedParams.success) throw new require_CustomTool.ValidationError("Failed to parse connected account update params", { cause: parsedParams.error });
3282
3177
  return this.client.connectedAccounts.updateStatus(nanoid, parsedParams.data);
3283
3178
  }
3284
- /**
3285
- * Update the per-user ACL on a SHARED connected account.
3286
- *
3287
- * Only meaningful for SHARED connections — calling this on a PRIVATE
3288
- * connection raises `ComposioAclOnlyForSharedError` (400). ACL writes
3289
- * require the connection's creator or an API key; alias edits via
3290
- * {@link update} are governed separately.
3291
- *
3292
- * PATCH semantics: omit a field to leave it unchanged; pass an empty array
3293
- * to clear an allow/deny list. At least one field must be provided.
3294
- *
3295
- * Resolution rule (deny wins):
3296
- * 1. requesting `userId` in `notAllowedUserIds` → DENY
3297
- * 2. `allowAllUsers === true` → ALLOW
3298
- * 3. requesting `userId` in `allowedUserIds` → ALLOW
3299
- * 4. otherwise → DENY
3300
- *
3301
- * @example
3302
- * ```typescript
3303
- * // Allow every userId to use this connection
3304
- * await composio.connectedAccounts.updateAcl('ca_abc', { allowAllUsers: true });
3305
- *
3306
- * // Everyone except a specific user
3307
- * await composio.connectedAccounts.updateAcl('ca_abc', {
3308
- * allowAllUsers: true,
3309
- * notAllowedUserIds: ['user_bob'],
3310
- * });
3311
- *
3312
- * // Targeted allow
3313
- * await composio.connectedAccounts.updateAcl('ca_abc', {
3314
- * allowedUserIds: ['user_alice', 'user_bob'],
3315
- * });
3316
- *
3317
- * // Revoke a previously-granted allow list (back to deny-by-default)
3318
- * await composio.connectedAccounts.updateAcl('ca_abc', { allowedUserIds: [] });
3319
- * ```
3320
- *
3321
- * **Empty-array semantics — read carefully.** Passing `[]` for either
3322
- * list **replaces** the list, it does not extend it:
3323
- *
3324
- * - `allowedUserIds: []` → revoke all previously-granted user IDs (state
3325
- * reverts to deny-by-default unless `allowAllUsers` is true).
3326
- * - `notAllowedUserIds: []` → **clears the deny list**, which silently
3327
- * re-grants access to users you previously blocked. Always pair an
3328
- * empty deny list with a deliberate audit of the allow side.
3329
- *
3330
- * @returns The PATCH response (`{ id, status, success }`). To read the
3331
- * updated `aclConfigForShared` block, call `get(nanoid)` after the
3332
- * promise resolves.
3333
- */
3334
- async updateAcl(nanoid, params) {
3335
- const parsedParams = UpdateConnectedAccountAclParamsSchema.safeParse(params);
3336
- if (!parsedParams.success) throw new require_CustomTool.ValidationError("Failed to parse connected account ACL update params", { cause: parsedParams.error });
3337
- const body = { acl_config_for_shared: serializeAclConfigForWire(parsedParams.data) };
3338
- try {
3339
- return await this.client.connectedAccounts.patch(nanoid, body);
3340
- } catch (error) {
3341
- if (error instanceof _composio_client.BadRequestError && typeof error.message === "string" && error.message.includes("acl_config_for_shared is only valid on SHARED")) throw new require_CustomTool.ComposioAclOnlyForSharedError(error.message, { cause: error });
3342
- throw error;
3343
- }
3344
- }
3345
3179
  };
3346
3180
 
3347
3181
  //#endregion
@@ -4168,11 +4002,13 @@ var Triggers = class {
4168
4002
  });
4169
4003
  throw error;
4170
4004
  }
4171
- return { triggerId: (await this.client.triggerInstances.upsert(slug, {
4005
+ const upsertParams = {
4172
4006
  connected_account_id: connectedAccountId,
4173
4007
  trigger_config: parsedBody.data.triggerConfig,
4174
- toolkit_versions: this.toolkitVersions
4175
- })).trigger_id };
4008
+ toolkit_versions: this.toolkitVersions,
4009
+ user_id: userId
4010
+ };
4011
+ return { triggerId: (await this.client.triggerInstances.upsert(slug, upsertParams)).trigger_id };
4176
4012
  }
4177
4013
  /**
4178
4014
  * Update an existing trigger instance
@@ -5221,6 +5057,63 @@ var BaseAgenticProvider = class extends BaseProvider {
5221
5057
  _isAgentic = true;
5222
5058
  };
5223
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
+
5224
5117
  //#endregion
5225
5118
  //#region src/provider/OpenAIProvider.ts
5226
5119
  var OpenAIProvider = class extends BaseNonAgenticProvider {
@@ -5373,7 +5266,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5373
5266
  */
5374
5267
  async executeToolCall(userId, tool, options, modifiers) {
5375
5268
  const payload = {
5376
- arguments: JSON.parse(tool.function.arguments),
5269
+ arguments: normalizeToolArguments(tool.function.arguments, tool.function.name),
5377
5270
  connectedAccountId: options?.connectedAccountId,
5378
5271
  customAuthParams: options?.customAuthParams,
5379
5272
  customConnectionData: options?.customConnectionData,
@@ -5650,7 +5543,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5650
5543
 
5651
5544
  //#endregion
5652
5545
  //#region package.json
5653
- var version = "0.9.1";
5546
+ var version = "0.11.0";
5654
5547
 
5655
5548
  //#endregion
5656
5549
  //#region src/utils/session.ts
@@ -6814,8 +6707,7 @@ const DIRECT_CUSTOM_TOOL_DESCRIPTION_PREFIX = "[Direct tool - call directly, no
6814
6707
  const AuthorizeOptionsSchema = zod_v3.z.object({
6815
6708
  callbackUrl: zod_v3.z.string().optional(),
6816
6709
  alias: zod_v3.z.string().optional(),
6817
- accountType: ConnectedAccountTypeSchema.optional(),
6818
- aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
6710
+ experimental: ConnectedAccountExperimentalSchema.optional()
6819
6711
  });
6820
6712
  var ToolRouterSession = class {
6821
6713
  sessionId;
@@ -6965,9 +6857,11 @@ var ToolRouterSession = class {
6965
6857
  * Initiate an authorization flow for a toolkit.
6966
6858
  * Returns a ConnectionRequest with a redirect URL for the user.
6967
6859
  *
6968
- * Use `accountType` and `aclConfigForShared` to create a SHARED connection
6969
- * with a per-user ACL in one flow. Default behaviour (omit both) creates
6970
- * a PRIVATE connection.
6860
+ * Pass `experimental: { accountType: 'SHARED', aclConfigForShared }` to
6861
+ * create a SHARED connection with a per-user ACL in one flow. Default
6862
+ * behaviour (omit the block) creates a PRIVATE connection.
6863
+ *
6864
+ * Experimental — shape may change in future releases.
6971
6865
  *
6972
6866
  * `aclConfigForShared` is validated against the same caps as
6973
6867
  * `composio.connectedAccounts.link()` (≤1000 entries per list, each
@@ -6978,23 +6872,18 @@ var ToolRouterSession = class {
6978
6872
  const requestOptions = AuthorizeOptionsSchema.safeParse(options ?? {});
6979
6873
  if (!requestOptions.success) throw new require_CustomTool.ValidationError("Failed to parse tool router authorize options", { cause: requestOptions.error });
6980
6874
  const opts = requestOptions.data;
6981
- const aclWire = opts.aclConfigForShared === void 0 ? void 0 : {
6982
- ...opts.aclConfigForShared.allowAllUsers !== void 0 && { allow_all_users: opts.aclConfigForShared.allowAllUsers },
6983
- ...opts.aclConfigForShared.allowedUserIds !== void 0 && { allowed_user_ids: opts.aclConfigForShared.allowedUserIds },
6984
- ...opts.aclConfigForShared.notAllowedUserIds !== void 0 && { not_allowed_user_ids: opts.aclConfigForShared.notAllowedUserIds }
6985
- };
6875
+ const experimentalWire = serializeExperimentalForWire(opts.experimental);
6986
6876
  const body = {
6987
6877
  toolkit,
6988
6878
  ...opts.callbackUrl !== void 0 && { callback_url: opts.callbackUrl },
6989
6879
  ...opts.alias !== void 0 && { alias: opts.alias },
6990
- ...opts.accountType !== void 0 && { account_type: opts.accountType },
6991
- ...aclWire !== void 0 && { acl_config_for_shared: aclWire }
6880
+ ...experimentalWire !== void 0 && { experimental: experimentalWire }
6992
6881
  };
6993
6882
  let response;
6994
6883
  try {
6995
6884
  response = await this.client.toolRouter.session.link(this.sessionId, body);
6996
6885
  } catch (error) {
6997
- if (error instanceof _composio_client.BadRequestError && typeof error.message === "string" && error.message.includes("acl_config_for_shared is only valid on SHARED")) throw new require_CustomTool.ComposioAclOnlyForSharedError(error.message, { cause: error });
6886
+ if (error instanceof _composio_client.BadRequestError && typeof error.message === "string" && error.message.includes(ACL_ONLY_FOR_SHARED_ERROR_FRAGMENT)) throw new require_CustomTool.ComposioAclOnlyForSharedError(error.message, { cause: error });
6998
6887
  throw error;
6999
6888
  }
7000
6889
  return createConnectionRequest(this.client, response.connected_account_id, ConnectedAccountStatuses.INITIATED, response.redirect_url);
@@ -7418,6 +7307,14 @@ var Composio = class Composio {
7418
7307
  authConfigs;
7419
7308
  /** Manage authenticated connections */
7420
7309
  connectedAccounts;
7310
+ /**
7311
+ * Experimental SDK methods whose shape may change in future releases.
7312
+ * Houses stateful operations like {@link Experimental.updateAcl} that
7313
+ * take a client and perform I/O. Stateless experimental factories
7314
+ * (e.g. `experimental_createTool`) stay at the top level.
7315
+ * @experimental
7316
+ */
7317
+ experimental;
7421
7318
  /** Model Context Protocol server management */
7422
7319
  mcp;
7423
7320
  /**
@@ -7533,6 +7430,7 @@ var Composio = class Composio {
7533
7430
  fileDownloadDir: this.config.fileDownloadDir
7534
7431
  });
7535
7432
  this.connectedAccounts = new ConnectedAccounts(this.client);
7433
+ this.experimental = new Experimental(this.client);
7536
7434
  this.toolRouter = new ToolRouter(this.client, this.config);
7537
7435
  /**
7538
7436
  * Initialize tool router methods
@@ -7678,6 +7576,17 @@ const CYCLE_BREAK_SENTINEL = {
7678
7576
  type: "object",
7679
7577
  additionalProperties: true
7680
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.";
7681
7590
  const POLLUTING_KEYS = new Set([
7682
7591
  "__proto__",
7683
7592
  "constructor",
@@ -7685,33 +7594,68 @@ const POLLUTING_KEYS = new Set([
7685
7594
  ]);
7686
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"];
7687
7596
  const decodePointerSegment = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
7688
- const failResolution = (pointer, segment) => {
7689
- throw new require_CustomTool.JsonSchemaRefResolutionError(`Cannot resolve $ref ${pointer}`, {
7690
- meta: {
7691
- ref: pointer,
7692
- failedAt: segment
7693
- },
7694
- possibleFixes: REF_RESOLUTION_FIXES
7695
- });
7696
- };
7697
- const stepInto = (cursor, segment, pointer) => {
7698
- 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
+ };
7699
7603
  if (Array.isArray(cursor)) {
7700
7604
  const i = Number(segment);
7701
- if (!Number.isInteger(i) || i < 0 || i >= cursor.length) failResolution(pointer, segment);
7702
- return cursor[i];
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
+ };
7703
7614
  }
7704
7615
  const obj = cursor;
7705
- if (!Object.prototype.hasOwnProperty.call(obj, segment)) failResolution(pointer, segment);
7706
- return obj[segment];
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
+ };
7707
7646
  };
7708
- const resolvePointer = (root, pointer) => {
7709
- if (pointer === "#" || pointer === "") return root;
7710
- 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}`, {
7711
7649
  meta: { ref: pointer },
7712
7650
  possibleFixes: REF_RESOLUTION_FIXES
7713
7651
  });
7714
- return pointer.slice(2).split("/").map(decodePointerSegment).reduce((cursor, seg) => stepInto(cursor, seg, pointer), root);
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
+ });
7715
7659
  };
7716
7660
  /**
7717
7661
  * Inlines internal JSON Schema `$ref` pointers (`#/$defs/...` and legacy
@@ -7721,11 +7665,20 @@ const resolvePointer = (root, pointer) => {
7721
7665
  * left untouched. Cycles are broken with `{ type: 'object',
7722
7666
  * additionalProperties: true }`. The input is never mutated.
7723
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
+ *
7724
7675
  * @throws {JsonSchemaRefResolutionError} on malformed pointers, missing
7725
- * targets, or chains past the depth cap.
7676
+ * targets (strict mode only), or chains past the depth cap (both modes).
7726
7677
  */
7727
- function dereferenceJsonSchema(schema) {
7678
+ function dereferenceJsonSchema(schema, options) {
7728
7679
  if (!require_FileToolModifier_utils_neutral.isPlainObject(schema)) return schema;
7680
+ const strategy = options?.onUnresolved ?? "throw";
7681
+ const onReplace = options?.onReplace;
7729
7682
  const root = schema;
7730
7683
  const visiting = /* @__PURE__ */ new WeakSet();
7731
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)]));
@@ -7754,7 +7707,18 @@ function dereferenceJsonSchema(schema) {
7754
7707
  possibleFixes: REF_RESOLUTION_FIXES
7755
7708
  });
7756
7709
  if (visitedRefs.has(ref)) return { ...CYCLE_BREAK_SENTINEL };
7757
- const resolved = walk(resolvePointer(root, ref), new Set(visitedRefs).add(ref), chainDepth + 1, nodeDepth + 1);
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);
7758
7722
  const siblings = { ...node };
7759
7723
  delete siblings.$ref;
7760
7724
  if (Object.keys(siblings).length === 0 || !require_FileToolModifier_utils_neutral.isPlainObject(resolved)) return resolved;
@@ -8332,7 +8296,6 @@ exports.ComposioAclOnlyForSharedError = require_CustomTool.ComposioAclOnlyForSha
8332
8296
  exports.ComposioAuthConfigNotFoundError = require_CustomTool.ComposioAuthConfigNotFoundError;
8333
8297
  exports.ComposioConnectedAccountNotFoundError = require_CustomTool.ComposioConnectedAccountNotFoundError;
8334
8298
  exports.ComposioCustomCreateResponseSchema = ComposioCustomCreateResponseSchema;
8335
- exports.ComposioCustomToolsNotInitializedError = require_CustomTool.ComposioCustomToolsNotInitializedError;
8336
8299
  exports.ComposioError = require_FileModifierErrors.ComposioError;
8337
8300
  exports.ComposioFailedToCreateConnectedAccountLink = require_CustomTool.ComposioFailedToCreateConnectedAccountLink;
8338
8301
  exports.ComposioFailedToCreatePusherClientError = require_CustomTool.ComposioFailedToCreatePusherClientError;
@@ -8348,6 +8311,7 @@ exports.ComposioGenerateURLResponseSchema = ComposioGenerateURLResponseSchema;
8348
8311
  exports.ComposioGlobalExecuteToolFnNotSetError = require_CustomTool.ComposioGlobalExecuteToolFnNotSetError;
8349
8312
  exports.ComposioInvalidExecuteFunctionError = require_CustomTool.ComposioInvalidExecuteFunctionError;
8350
8313
  exports.ComposioInvalidModifierError = require_CustomTool.ComposioInvalidModifierError;
8314
+ exports.ComposioInvalidToolArgumentsError = require_CustomTool.ComposioInvalidToolArgumentsError;
8351
8315
  exports.ComposioLegacyConnectedAccountsEndpointRetiredError = require_CustomTool.ComposioLegacyConnectedAccountsEndpointRetiredError;
8352
8316
  exports.ComposioMcpDeleteResponseSchema = ComposioMcpDeleteResponseSchema;
8353
8317
  exports.ComposioMcpListResponseSchema = ComposioMcpListResponseSchema;
@@ -8372,6 +8336,8 @@ exports.ConnectedAccountAclConfigResponseSchema = ConnectedAccountAclConfigRespo
8372
8336
  exports.ConnectedAccountAclConfigSchema = ConnectedAccountAclConfigSchema;
8373
8337
  exports.ConnectedAccountAuthConfigSchema = ConnectedAccountAuthConfigSchema;
8374
8338
  exports.ConnectedAccountErrorCodes = require_CustomTool.ConnectedAccountErrorCodes;
8339
+ exports.ConnectedAccountExperimentalResponseSchema = ConnectedAccountExperimentalResponseSchema;
8340
+ exports.ConnectedAccountExperimentalSchema = ConnectedAccountExperimentalSchema;
8375
8341
  exports.ConnectedAccountListParamsSchema = ConnectedAccountListParamsSchema;
8376
8342
  exports.ConnectedAccountListResponseSchema = ConnectedAccountListResponseSchema;
8377
8343
  exports.ConnectedAccountRefreshOptionsSchema = ConnectedAccountRefreshOptionsSchema;
@@ -8405,6 +8371,7 @@ exports.CustomOauth1ConnectionDataSchema = CustomOauth1ConnectionDataSchema;
8405
8371
  exports.CustomOauth2ConnectionDataSchema = CustomOauth2ConnectionDataSchema;
8406
8372
  exports.CustomToolSlugSchema = require_CustomTool.CustomToolSlugSchema;
8407
8373
  exports.DefaultCreateConnectedAccountParamsSchema = DefaultCreateConnectedAccountParamsSchema;
8374
+ exports.Experimental = Experimental;
8408
8375
  exports.FileDeleteResponseSchema = FileDeleteResponseSchema;
8409
8376
  exports.FileListResponseSchema = FileListResponseSchema;
8410
8377
  exports.FileModifierErrorCodes = require_FileModifierErrors.FileModifierErrorCodes;
@@ -8551,4 +8518,6 @@ exports.getExtensionFromMimeType = getExtensionFromMimeType;
8551
8518
  exports.handleToolExecutionError = require_CustomTool.handleToolExecutionError;
8552
8519
  exports.jsonSchemaToZodSchema = jsonSchemaToZodSchema;
8553
8520
  exports.logger = require_FileModifierErrors.logger_default;
8554
- exports.removeNonRequiredProperties = removeNonRequiredProperties;
8521
+ exports.normalizeToolArguments = normalizeToolArguments;
8522
+ exports.removeNonRequiredProperties = removeNonRequiredProperties;
8523
+ exports.telemetry = require_Telemetry.telemetry;