@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.
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-aber890o.d.cts → CustomTool-C-IUByoU.d.cts} +1 -1
  4. package/dist/{CustomTool-DJUGNOer.d.mts → CustomTool-CChQSp44.d.mts} +1 -1
  5. package/dist/{CustomTool-CQ_YjABZ.cjs → CustomTool-D3-NreIm.cjs} +79 -79
  6. package/dist/{CustomTool-D7-1S2at.mjs → CustomTool-D5s-aADw.mjs} +74 -74
  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-DRl6WCI9.d.mts → composio-BlASKqjQ.d.mts} +161 -208
  12. package/dist/{composio-CSMCZZgj.d.cts → composio-pcA13w87.d.cts} +161 -208
  13. package/dist/{customTool.types-CMOMgxoM.d.mts → customTool.types-DLIORcYN.d.mts} +43 -81
  14. package/dist/{customTool.types-BzEWHa0w.d.cts → customTool.types-QtkAZQma.d.cts} +43 -81
  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 +476 -590
  20. package/dist/index.d.cts +406 -13
  21. package/dist/index.d.mts +406 -13
  22. package/dist/index.mjs +473 -588
  23. package/dist/models/Files.node.cjs +1 -1
  24. package/dist/models/Files.node.mjs +1 -1
  25. package/dist/{types-BTOPdg4d.d.mts → types-DRG5qLxI.d.cts} +2 -2
  26. package/dist/{types-DE7O6Z6S.d.cts → 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 +11 -2
package/dist/index.mjs CHANGED
@@ -1,13 +1,12 @@
1
1
  import "./chunk-CWQeghP5.mjs";
2
2
  import { _ as getEnvVariable, a as ComposioSensitiveFilePathBlockedError, c as logger_default, d as DEFAULT_BASE_URL, f as DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID, g as constants_exports, h as USER_DATA_FILE_NAME, i as ComposioFileUploadPathNotAllowedError, l as COMPOSIO_DIR, m as TEMP_FILES_DIRECTORY_NAME, n as ComposioFileUploadAbortedError, o as FileModifierErrorCodes, p as IS_DEVELOPMENT_OR_CI, r as ComposioFileUploadError, s as ComposioError, t as ComposioFileNotFoundError, u as COMPOSIO_LOG_LEVEL, v as getEnvsWithPrefix } from "./FileModifierErrors-C7z16Dfi.mjs";
3
- import { $ as ComposioMultipleConnectedAccountsError, A as ValidationErrorCodes, B as ComposioGlobalExecuteToolFnNotSetError, C as ComposioWebhookSignatureVerificationError, D as JsonSchemaRefResolutionError, E as SDKErrorCodes, F as ConnectionRequestFailedError, G as ComposioToolNotFoundError, H as ComposioInvalidModifierError, I as ConnectionRequestTimeoutError, J as handleToolExecutionError, K as ComposioToolVersionRequiredError, L as AuthConfigErrorCodes, M as ComposioToolkitNotFoundError, N as ToolkitErrorCodes, O as JsonSchemaToZodError, P as ConnectionRequestErrorCodes, Q as ComposioLegacyConnectedAccountsEndpointRetiredError, R as ComposioAuthConfigNotFoundError, S as ComposioWebhookPayloadError, T as ComposioNoAPIKeyError, U as ComposioProviderNotDefinedError, V as ComposioInvalidExecuteFunctionError, W as ComposioToolExecutionError, X as ComposioConnectedAccountNotFoundError, Y as ComposioAclOnlyForSharedError, Z as ComposioFailedToCreateConnectedAccountLink, _ as ComposioFailedToCreatePusherClientError, a as createCustomToolkit, b as ComposioFailedToUnsubscribeFromPusherChannelError, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, et as ComposioSharedAccessDeniedError, f as CreateCustomToolkitBaseSchema, g as RemoteFileErrorCodes, h as RemoteFileDownloadError, i as createCustomTool, j as ComposioToolkitFetchError, k as ValidationError, l as serializeCustomToolkits, m as PRELOAD_TOOLS_ALL, n as buildCustomToolsMap, nt as ConnectedAccountErrorCodes, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, q as ToolErrorCodes, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, tt as ComposioSharedConnectionNotAccessibleError, u as serializeCustomTools, v as ComposioFailedToGetSDKRealtimeCredentialsError, w as TriggerErrorCodes, x as ComposioTriggerTypeNotFoundError, y as ComposioFailedToSubscribeToPusherChannelError, z as ComposioCustomToolsNotInitializedError } from "./CustomTool-D7-1S2at.mjs";
4
- import { t as telemetry } from "./Telemetry-kgWlkavX.mjs";
3
+ import { $ as ComposioMultipleConnectedAccountsError, A as ConnectionRequestErrorCodes, B as ComposioInvalidExecuteFunctionError, C as ComposioWebhookSignatureVerificationError, D as ComposioToolkitFetchError, E as SDKErrorCodes, F as JsonSchemaRefResolutionError, G as ComposioToolNotFoundError, H as ComposioInvalidToolArgumentsError, I as JsonSchemaToZodError, J as handleToolExecutionError, K as ComposioToolVersionRequiredError, L as ValidationError, M as ConnectionRequestTimeoutError, N as AuthConfigErrorCodes, O as ComposioToolkitNotFoundError, P as ComposioAuthConfigNotFoundError, Q as ComposioLegacyConnectedAccountsEndpointRetiredError, R as ValidationErrorCodes, S as ComposioWebhookPayloadError, T as ComposioNoAPIKeyError, U as ComposioProviderNotDefinedError, V as ComposioInvalidModifierError, W as ComposioToolExecutionError, X as ComposioConnectedAccountNotFoundError, Y as ComposioAclOnlyForSharedError, Z as ComposioFailedToCreateConnectedAccountLink, _ as ComposioFailedToCreatePusherClientError, a as createCustomToolkit, b as ComposioFailedToUnsubscribeFromPusherChannelError, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, et as ComposioSharedAccessDeniedError, f as CreateCustomToolkitBaseSchema, g as RemoteFileErrorCodes, h as RemoteFileDownloadError, i as createCustomTool, j as ConnectionRequestFailedError, k as ToolkitErrorCodes, l as serializeCustomToolkits, m as PRELOAD_TOOLS_ALL, n as buildCustomToolsMap, nt as ConnectedAccountErrorCodes, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, q as ToolErrorCodes, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, tt as ComposioSharedConnectionNotAccessibleError, u as serializeCustomTools, v as ComposioFailedToGetSDKRealtimeCredentialsError, w as TriggerErrorCodes, x as ComposioTriggerTypeNotFoundError, y as ComposioFailedToSubscribeToPusherChannelError, z as ComposioGlobalExecuteToolFnNotSetError } from "./CustomTool-D5s-aADw.mjs";
4
+ import { t as telemetry } from "./Telemetry-DQax33Gh.mjs";
5
5
  import { i as getRandomShortId, t as arrayBufferToBase64 } from "./buffer-yOtEsT4J.mjs";
6
- import { r as schemaHasFileUploadable, t as isPlainObject } from "./FileToolModifier.utils.neutral-B7P7wn-b.mjs";
6
+ import { r as schemaHasFileUploadable, t as isPlainObject } from "./FileToolModifier.utils.neutral-BpSceNK8.mjs";
7
7
  import ComposioClient, { APIError, BadRequestError } from "@composio/client";
8
8
  import { FileToolModifier } from "#file_tool_modifier";
9
9
  import z, { z as z$1 } from "zod/v3";
10
- import * as zodToJsonSchema from "zod-to-json-schema";
11
10
  import { CONFIG_DEFAULTS } from "#config_defaults";
12
11
  import { platform } from "#platform";
13
12
  import { APIError as APIError$1 } from "openai";
@@ -1012,490 +1011,6 @@ const ToolProxyParamsSchema = z$1.object({
1012
1011
  customConnectionData: CustomConnectionDataSchema.describe("DEPRECATED: This field is deprecated and will be removed in the future.").optional()
1013
1012
  });
1014
1013
 
1015
- //#endregion
1016
- //#region src/types/connectedAccounts.types.ts
1017
- /**
1018
- * Connected Account create parameters
1019
- */
1020
- const ConnectedAccountStatuses = {
1021
- INITIALIZING: "INITIALIZING",
1022
- INITIATED: "INITIATED",
1023
- ACTIVE: "ACTIVE",
1024
- FAILED: "FAILED",
1025
- EXPIRED: "EXPIRED",
1026
- INACTIVE: "INACTIVE",
1027
- REVOKED: "REVOKED"
1028
- };
1029
- const ConnectedAccountStatusSchema = z$1.enum([
1030
- ConnectedAccountStatuses.INITIALIZING,
1031
- ConnectedAccountStatuses.INITIATED,
1032
- ConnectedAccountStatuses.ACTIVE,
1033
- ConnectedAccountStatuses.FAILED,
1034
- ConnectedAccountStatuses.EXPIRED,
1035
- ConnectedAccountStatuses.INACTIVE,
1036
- ConnectedAccountStatuses.REVOKED
1037
- ]);
1038
- /**
1039
- * Sharing model for a connected account.
1040
- *
1041
- * - `PRIVATE` (default): only the owning `userId` can use the connection.
1042
- * - `SHARED`: can be used by other `userId`s, but only when the connection
1043
- * is explicitly pinned in a tool-router session's config and only when
1044
- * the requesting `userId` passes the connection's ACL (see
1045
- * `allowAllUsers` / `allowedUserIds` / `notAllowedUserIds`).
1046
- */
1047
- const ConnectedAccountTypes = {
1048
- PRIVATE: "PRIVATE",
1049
- SHARED: "SHARED"
1050
- };
1051
- const ConnectedAccountTypeSchema = z$1.enum([ConnectedAccountTypes.PRIVATE, ConnectedAccountTypes.SHARED]);
1052
- /**
1053
- * Per-user access control for a SHARED connected account. Ignored for
1054
- * PRIVATE.
1055
- *
1056
- * Pass `aclConfigForShared` on create / PATCH to grant access; omit it
1057
- * to leave the ACL unchanged (on PATCH) or to keep the default
1058
- * deny-by-default state (on create). On responses, the field is
1059
- * `undefined` when the caller isn't authorised to see the ACL —
1060
- * distinguish that from an empty/default state explicitly.
1061
- *
1062
- * Resolution rule (deny wins):
1063
- * 1. requesting `userId` in `notAllowedUserIds` → DENY
1064
- * 2. `allowAllUsers === true` → ALLOW
1065
- * 3. requesting `userId` in `allowedUserIds` → ALLOW
1066
- * 4. otherwise → DENY (deny-by-default)
1067
- *
1068
- * Default state (block omitted or `{}`) means only the connection's
1069
- * creator can use it. The creator must grant access explicitly.
1070
- *
1071
- * Limits: each list accepts up to 1000 entries; each `userId` is
1072
- * 1..256 characters.
1073
- */
1074
- const ACL_LIST_MAX_LENGTH = 1e3;
1075
- const aclUserIdString = z$1.string().min(1).max(256);
1076
- const ConnectedAccountAclConfigSchema = z$1.object({
1077
- allowAllUsers: z$1.boolean().optional().describe("When true, any `userId` may use this SHARED connection (subject to the deny list). Default false."),
1078
- allowedUserIds: z$1.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings allowed to use this SHARED connection. Default []."),
1079
- notAllowedUserIds: z$1.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings denied access. Wins over allow on conflict. Default [].")
1080
- });
1081
- /**
1082
- * Resolved ACL as it appears on responses. All three fields are populated
1083
- * when the field is visible; the field itself is `undefined` for callers
1084
- * not authorised to see it.
1085
- */
1086
- const ConnectedAccountAclConfigResponseSchema = z$1.object({
1087
- allowAllUsers: z$1.boolean(),
1088
- allowedUserIds: z$1.array(z$1.string()),
1089
- notAllowedUserIds: z$1.array(z$1.string())
1090
- });
1091
- /**
1092
- * Experimental options for SHARED connections, passed at create / link time.
1093
- *
1094
- * **Experimental — shape may change in future releases.** Wrapped under a
1095
- * dedicated `experimental` block on every input and response so the
1096
- * experimental status is visible at every call site.
1097
- */
1098
- const ConnectedAccountExperimentalSchema = z$1.object({
1099
- accountType: ConnectedAccountTypeSchema.optional(),
1100
- aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
1101
- });
1102
- /**
1103
- * Resolved experimental block on retrieve / list responses. `accountType`
1104
- * is always present when the block is; `aclConfigForShared` is only
1105
- * present when the caller is authorised to see the ACL.
1106
- */
1107
- const ConnectedAccountExperimentalResponseSchema = z$1.object({
1108
- accountType: ConnectedAccountTypeSchema.optional(),
1109
- aclConfigForShared: ConnectedAccountAclConfigResponseSchema.optional()
1110
- });
1111
- const CreateConnectedAccountParamsSchema = z$1.object({
1112
- authConfig: z$1.object({ id: z$1.string() }),
1113
- connection: z$1.object({
1114
- data: z$1.record(z$1.string(), z$1.unknown()).optional(),
1115
- callbackUrl: z$1.string().optional(),
1116
- userId: z$1.string().optional()
1117
- })
1118
- });
1119
- const DefaultCreateConnectedAccountParamsSchema = z$1.object({
1120
- auth_config: z$1.object({ id: z$1.string() }),
1121
- connection: z$1.object({
1122
- state: ConnectionDataSchema.optional(),
1123
- data: z$1.record(z$1.string(), z$1.unknown()).optional(),
1124
- callback_url: z$1.string().optional(),
1125
- user_id: z$1.string().optional(),
1126
- alias: z$1.string().optional()
1127
- })
1128
- });
1129
- const CreateConnectedAccountOptionsSchema = z$1.object({
1130
- allowMultiple: z$1.boolean().optional(),
1131
- callbackUrl: z$1.string().optional(),
1132
- config: ConnectionDataSchema.optional(),
1133
- alias: z$1.string().optional()
1134
- });
1135
- /**
1136
- * Connected Account create response
1137
- */
1138
- const CreateConnectedAccountResponseSchema = z$1.object({
1139
- id: z$1.string(),
1140
- status: ConnectedAccountStatusSchema,
1141
- redirectUrl: z$1.string().nullable()
1142
- });
1143
- const ConnectedAccountAuthConfigSchema = z$1.object({
1144
- id: z$1.string(),
1145
- authScheme: AuthSchemeEnum.optional(),
1146
- isComposioManaged: z$1.boolean(),
1147
- isDisabled: z$1.boolean()
1148
- });
1149
- const ConnectedAccountRetrieveResponseSchema = z$1.object({
1150
- id: z$1.string(),
1151
- authConfig: ConnectedAccountAuthConfigSchema,
1152
- wordId: z$1.string().nullable().optional(),
1153
- alias: z$1.string().nullable().optional(),
1154
- data: z$1.record(z$1.string(), z$1.unknown()).optional(),
1155
- params: z$1.record(z$1.string(), z$1.unknown()).optional(),
1156
- status: ConnectedAccountStatusSchema,
1157
- statusReason: z$1.string().nullable(),
1158
- toolkit: z$1.object({ slug: z$1.string() }),
1159
- state: ConnectionDataSchema.optional(),
1160
- testRequestEndpoint: z$1.string().optional(),
1161
- isDisabled: z$1.boolean(),
1162
- createdAt: z$1.string(),
1163
- updatedAt: z$1.string(),
1164
- experimental: ConnectedAccountExperimentalResponseSchema.optional()
1165
- });
1166
- const ConnectedAccountListParamsSchema = z$1.object({
1167
- authConfigIds: z$1.array(z$1.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
1168
- cursor: z$1.string().nullish().describe("The cursor to paginate through the connected accounts"),
1169
- limit: z$1.number().nullable().optional().describe("The limit of the connected accounts to return"),
1170
- orderBy: z$1.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
1171
- statuses: z$1.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
1172
- toolkitSlugs: z$1.array(z$1.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
1173
- userIds: z$1.array(z$1.string()).nullable().optional().describe("The user ids of the connected accounts"),
1174
- accountType: z$1.enum([
1175
- "PRIVATE",
1176
- "SHARED",
1177
- "ALL"
1178
- ]).optional()
1179
- });
1180
- const ConnectedAccountListResponseSchema = z$1.object({
1181
- items: z$1.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
1182
- nextCursor: z$1.string().nullish().describe("The next cursor to paginate through the connected accounts"),
1183
- totalPages: z$1.number().describe("The total number of pages of connected accounts")
1184
- });
1185
- const CreateConnectedAccountLinkOptionsSchema = z$1.object({
1186
- callbackUrl: z$1.string().optional(),
1187
- alias: z$1.string().optional(),
1188
- allowMultiple: z$1.boolean().optional(),
1189
- experimental: ConnectedAccountExperimentalSchema.optional()
1190
- });
1191
- const CreateConnectedAccountLinkResponseSchema = z$1.object({ redirectUrl: z$1.string() });
1192
- const ConnectedAccountRefreshOptionsSchema = z$1.object({
1193
- redirectUrl: z$1.string().optional(),
1194
- validateCredentials: z$1.boolean().optional()
1195
- });
1196
- const UpdateConnectedAccountParamsSchema = z$1.object({ enabled: z$1.boolean() });
1197
- /**
1198
- * Params for `composio.connectedAccounts.updateAcl()`. Mirrors the inner
1199
- * shape of the wire's `acl_config_for_shared` block — the SDK adds the
1200
- * outer nesting at the boundary, so callers pass the three fields flat.
1201
- *
1202
- * PATCH-style semantics — omit a field to leave it unchanged; pass an
1203
- * empty array to clear an allow/deny list. Raises
1204
- * `ComposioAclOnlyForSharedError` on a PRIVATE connection.
1205
- *
1206
- * Each field is optional, but at least one must be provided — passing an
1207
- * empty object is rejected as a no-op.
1208
- */
1209
- 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" });
1210
-
1211
- //#endregion
1212
- //#region src/utils/transform.ts
1213
- function transform(raw) {
1214
- return { with(schema) {
1215
- return { using(transformer, options) {
1216
- const transformed = transformer(raw);
1217
- const result = schema.safeParse(transformed);
1218
- if (!result.success) {
1219
- const label = options?.label ? ` for ${options.label}` : "";
1220
- const issues = result.error.issues.map((issue) => ` - ${issue.path.join(".") || "parameter"}: ${issue.message}`).join("\n");
1221
- logger_default.warn(`Transform validation failed${label}:\n${issues}`);
1222
- return transformed;
1223
- }
1224
- return result.data;
1225
- } };
1226
- } };
1227
- }
1228
-
1229
- //#endregion
1230
- //#region src/utils/transformers/connectedAccounts.ts
1231
- /**
1232
- * Transforms the raw connected account response from the Composio API to the SDK format.
1233
- *
1234
- * This method converts property names from snake_case to camelCase and reorganizes
1235
- * the data structure to match the SDK's standardized format.
1236
- *
1237
- * @param {RawConnectedAccountListResponse['items'][0]|RawConnectedAccountRetrieveResponse} response - The raw API response to transform
1238
- * @returns {Promise<ConnectedAccountRetrieveResponse>} The transformed response
1239
- * @throws {ZodError} If the response fails validation against the expected schema
1240
- *
1241
- * @private
1242
- */
1243
- function transformConnectedAccountResponse(response) {
1244
- const responseWithLabels = response;
1245
- const parseState = (state) => {
1246
- try {
1247
- return state ? ConnectionDataSchema.parse(state) : void 0;
1248
- } catch (error) {
1249
- logger_default.warn("Unsupported auth scheme in connected account state, ignoring state field", { error });
1250
- return;
1251
- }
1252
- };
1253
- return transform(response).with(ConnectedAccountRetrieveResponseSchema).using((response$1) => ({
1254
- ...response$1,
1255
- authConfig: {
1256
- ...response$1.auth_config,
1257
- id: response$1.auth_config.id,
1258
- authScheme: response$1.auth_config.auth_scheme,
1259
- isComposioManaged: response$1.auth_config.is_composio_managed,
1260
- isDisabled: response$1.auth_config.is_disabled
1261
- },
1262
- wordId: responseWithLabels.word_id ?? null,
1263
- alias: responseWithLabels.alias ?? null,
1264
- data: response$1.data ?? void 0,
1265
- state: parseState(response$1.state),
1266
- status: response$1.status,
1267
- statusReason: response$1.status_reason,
1268
- isDisabled: response$1.is_disabled,
1269
- createdAt: response$1.created_at,
1270
- updatedAt: response$1.updated_at,
1271
- testRequestEndpoint: response$1.test_request_endpoint,
1272
- experimental: responseWithLabels.experimental ? {
1273
- accountType: responseWithLabels.experimental.account_type,
1274
- aclConfigForShared: responseWithLabels.experimental.acl_config_for_shared ? {
1275
- allowAllUsers: responseWithLabels.experimental.acl_config_for_shared.allow_all_users,
1276
- allowedUserIds: responseWithLabels.experimental.acl_config_for_shared.allowed_user_ids,
1277
- notAllowedUserIds: responseWithLabels.experimental.acl_config_for_shared.not_allowed_user_ids
1278
- } : void 0
1279
- } : void 0
1280
- }));
1281
- }
1282
- /**
1283
- * Transforms the raw connected account list response from the Composio API to the SDK format.
1284
- *
1285
- * This method converts property names from snake_case to camelCase and reorganizes
1286
- * the data structure to match the SDK's standardized format.
1287
- *
1288
- * @param {RawConnectedAccountListResponse} response - The raw API response to transform
1289
- * @returns {ConnectedAccountListResponse} The transformed response
1290
- * @throws {ZodError} If the response fails validation against the expected schema
1291
- *
1292
- * @private
1293
- */
1294
- function transformConnectedAccountListResponse(response) {
1295
- return transform(response).with(ConnectedAccountListResponseSchema).using((response$1) => ({
1296
- items: response$1.items.map(transformConnectedAccountResponse),
1297
- nextCursor: response$1.next_cursor ?? null,
1298
- totalPages: response$1.total_pages
1299
- }));
1300
- }
1301
-
1302
- //#endregion
1303
- //#region src/models/CustomTools.ts
1304
- var CustomTools = class {
1305
- client;
1306
- customToolsRegistry;
1307
- constructor(client) {
1308
- if (!client) throw new ComposioError("ComposioClient is required");
1309
- this.client = client;
1310
- this.customToolsRegistry = /* @__PURE__ */ new Map();
1311
- telemetry.instrument(this, "CustomTools");
1312
- }
1313
- /**
1314
- * Create a custom tool and registers it in the registry.
1315
- * This is just an in memory registry and is not persisted.
1316
- * @param {CustomToolOptions} toolOptions CustomToolOptions
1317
- * @returns {Tool} The tool created
1318
- *
1319
- * @example
1320
- * ```typescript
1321
- * // Create a custom tool with input parameters
1322
- * const customTool = await composio.customTools.createTool({
1323
- * name: 'My Custom Tool',
1324
- * description: 'A tool that performs a custom operation',
1325
- * slug: 'MY_CUSTOM_TOOL',
1326
- * inputParams: z.object({
1327
- * query: z.string().describe('The search query'),
1328
- * limit: z.number().optional().describe('Maximum number of results')
1329
- * }),
1330
- * execute: async (input, connectionConfig, executeToolRequest) => {
1331
- * // Custom implementation logic
1332
- * return {
1333
- * data: { results: ['result1', 'result2'] }
1334
- * };
1335
- * }
1336
- * });
1337
- * ```
1338
- */
1339
- async createTool(toolOptions) {
1340
- const { slug, execute, inputParams, name, description } = toolOptions;
1341
- if (!slug || !execute || !inputParams || !name) throw new Error("Invalid tool options");
1342
- const paramsSchemaJson = zodToJsonSchema.default(inputParams, { name: "input" }).definitions.input;
1343
- const toolSchema = {
1344
- name,
1345
- slug,
1346
- description,
1347
- inputParameters: {
1348
- title: name,
1349
- type: "object",
1350
- description,
1351
- properties: paramsSchemaJson.properties,
1352
- required: paramsSchemaJson.required
1353
- },
1354
- outputParameters: {
1355
- type: "object",
1356
- title: `Response for ${name}`,
1357
- properties: {}
1358
- },
1359
- tags: [],
1360
- toolkit: {
1361
- name: "custom",
1362
- slug: "custom"
1363
- }
1364
- };
1365
- this.customToolsRegistry.set(slug.toLowerCase(), {
1366
- options: toolOptions,
1367
- schema: toolSchema
1368
- });
1369
- return toolSchema;
1370
- }
1371
- /**
1372
- * Get all the custom tools from the registry.
1373
- * @param {string[]} param0.toolSlugs The slugs of the tools to get
1374
- * @returns {ToolList} The list of tools
1375
- *
1376
- * @example
1377
- * ```typescript
1378
- * // Get all custom tools
1379
- * const allTools = await composio.customTools.getCustomTools({});
1380
- *
1381
- * // Get specific custom tools by slug
1382
- * const specificTools = await composio.customTools.getCustomTools({
1383
- * toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL']
1384
- * });
1385
- * ```
1386
- */
1387
- async getCustomTools({ toolSlugs }) {
1388
- const tools = [];
1389
- if (toolSlugs) for (const slug of toolSlugs) {
1390
- const tool = this.customToolsRegistry.get(slug.toLowerCase());
1391
- if (tool) tools.push(tool.schema);
1392
- }
1393
- else return Array.from(this.customToolsRegistry.values()).map((tool) => tool.schema);
1394
- return tools;
1395
- }
1396
- /**
1397
- * Get a custom tool by slug from the registry.
1398
- * @param {string} slug The slug of the tool to get
1399
- * @returns {Tool} The tool
1400
- *
1401
- * @example
1402
- * ```typescript
1403
- * // Get a specific custom tool by its slug
1404
- * const myTool = await composio.customTools.getCustomToolBySlug('MY_CUSTOM_TOOL');
1405
- * if (myTool) {
1406
- * console.log(`Found tool: ${myTool.name}`);
1407
- * } else {
1408
- * console.log('Tool not found');
1409
- * }
1410
- * ```
1411
- */
1412
- async getCustomToolBySlug(slug) {
1413
- try {
1414
- return this.customToolsRegistry.get(slug.toLowerCase())?.schema;
1415
- } catch (error) {
1416
- logger_default.error(`Error getting custom tool: ${error}`);
1417
- return;
1418
- }
1419
- }
1420
- /**
1421
- * Get the connected account for the user and toolkit.
1422
- * @param {string} toolkitSlug The slug of the toolkit
1423
- * @param {ExecuteMetadata} metadata The metadata of the execution
1424
- * @returns {ConnectedAccount} The connected account
1425
- */
1426
- async getConnectedAccountForToolkit(toolkitSlug, userId, connectedAccountId) {
1427
- try {
1428
- await this.client.toolkits.retrieve(toolkitSlug);
1429
- if ((await this.client.toolkits.retrieve(toolkitSlug)).auth_config_details?.some((details) => details.mode === AuthSchemeTypes.NO_AUTH)) return null;
1430
- } catch (error) {
1431
- throw new ComposioToolNotFoundError(`Toolkit with slug ${toolkitSlug} not found`, { cause: error });
1432
- }
1433
- const connectedAccounts = await this.client.connectedAccounts.list({
1434
- toolkit_slugs: [toolkitSlug],
1435
- user_ids: [userId]
1436
- });
1437
- if (!connectedAccounts.items.length) throw new ComposioConnectedAccountNotFoundError(`No connected accounts found for toolkit ${toolkitSlug}`);
1438
- const connectedAccount = connectedAccountId ? connectedAccounts.items.find((item) => item.id === connectedAccountId) : connectedAccounts.items[0];
1439
- if (!connectedAccount) throw new ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${userId}`);
1440
- return transformConnectedAccountResponse(connectedAccount);
1441
- }
1442
- /**
1443
- * Execute a custom tool
1444
- *
1445
- * @description If a toolkit is used, the connected account id is used to execute the tool.
1446
- * If a connected account id is provided, it is used to execute the tool.
1447
- * If a connected account id is not provided, the first connected account for the toolkit is used.
1448
- *
1449
- * @param {slug} slug The slug of the tool to execute
1450
- * @param {Record<string, unknown>} inputParams The input parameters for the tool
1451
- * @param {ExecuteMetadata} metadata The metadata of the execution
1452
- * @returns {Promise<ToolExecuteResponse>} The response from the tool
1453
- */
1454
- async executeCustomTool(slug, body) {
1455
- const tool = this.customToolsRegistry.get(slug.toLowerCase());
1456
- if (!tool) throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
1457
- let connectionConfig = null;
1458
- const { toolkitSlug, execute, inputParams } = tool.options;
1459
- let connectedAccountId = body.connectedAccountId;
1460
- if (toolkitSlug && toolkitSlug !== "custom" && body.userId) {
1461
- const connectedAccount = await this.getConnectedAccountForToolkit(toolkitSlug, body.userId, body.connectedAccountId);
1462
- logger_default.debug(`[CustomTool] Connected account for ${toolkitSlug} found for user ${body.userId}`, JSON.stringify(connectedAccount, null, 2));
1463
- if (!connectedAccount) throw new ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${body.userId}`, { meta: {
1464
- toolkitSlug,
1465
- userId: body.userId
1466
- } });
1467
- connectionConfig = connectedAccount.state ?? null;
1468
- connectedAccountId = connectedAccount.id;
1469
- }
1470
- if (typeof execute !== "function") throw new ComposioInvalidExecuteFunctionError("Invalid execute function", { meta: { toolSlug: slug } });
1471
- const executeToolRequest = async (data) => {
1472
- if (toolkitSlug && toolkitSlug === "custom") throw new 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"] });
1473
- const parameters = data.parameters?.map((param) => ({
1474
- name: param.name,
1475
- type: param.in,
1476
- value: param.value.toString()
1477
- }));
1478
- return {
1479
- data: (await this.client.tools.proxy({
1480
- endpoint: data.endpoint,
1481
- method: data.method,
1482
- parameters,
1483
- body: data.body,
1484
- connected_account_id: connectedAccountId,
1485
- custom_connection_data: data.customConnectionData
1486
- })).data,
1487
- error: null,
1488
- successful: true,
1489
- logId: void 0,
1490
- sessionInfo: void 0
1491
- };
1492
- };
1493
- const parsedInput = inputParams.safeParse(body.arguments);
1494
- if (!parsedInput.success) throw new ValidationError("Invalid input parameters", { cause: parsedInput.error });
1495
- return execute(parsedInput.data, connectionConfig, executeToolRequest);
1496
- }
1497
- };
1498
-
1499
1014
  //#endregion
1500
1015
  //#region src/utils/toolkitVersion.ts
1501
1016
  /**
@@ -1591,12 +1106,27 @@ function resolveEffectiveUploadAllowlist(userDirs) {
1591
1106
  //#region src/models/Tools.ts
1592
1107
  const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
1593
1108
  /**
1109
+ * Normalize a raw `input_parameters` / `output_parameters` payload returned by
1110
+ * the Composio API. Maps `null`, `undefined`, and empty `{}` — all of which
1111
+ * mean "no declared schema" — to `undefined` so the strict `ParametersSchema`
1112
+ * validator never sees them. Non-empty objects pass through unchanged and
1113
+ * remain subject to strict Zod validation.
1114
+ *
1115
+ * MCP-backed toolkits (granola_mcp, apify_mcp, tavily_mcp, …) have no
1116
+ * declared output schema and the API serializes that as `{}`, which would
1117
+ * otherwise trip `ParametersSchema`. See
1118
+ * https://github.com/ComposioHQ/composio/issues/3354.
1119
+ */
1120
+ function normalizeRawToolParameters(params) {
1121
+ if (params == null || Object.keys(params).length === 0) return void 0;
1122
+ return params;
1123
+ }
1124
+ /**
1594
1125
  * This class is used to manage tools in the Composio SDK.
1595
1126
  * It provides methods to list, get, and execute tools.
1596
1127
  */
1597
1128
  var Tools = class {
1598
1129
  client;
1599
- customTools;
1600
1130
  provider;
1601
1131
  autoUploadDownloadFiles;
1602
1132
  toolkitVersions;
@@ -1611,7 +1141,6 @@ var Tools = class {
1611
1141
  if (!client) throw new Error("ComposioClient is required");
1612
1142
  if (!config?.provider) throw new ComposioProviderNotDefinedError("Provider not passed into Tools instance");
1613
1143
  this.client = client;
1614
- this.customTools = new CustomTools(client);
1615
1144
  this.provider = config.provider;
1616
1145
  this.autoUploadDownloadFiles = config?.dangerouslyAllowAutoUploadDownloadFiles === true;
1617
1146
  this.toolkitVersions = config?.toolkitVersions ?? CONFIG_DEFAULTS.toolkitVersions;
@@ -1641,8 +1170,8 @@ var Tools = class {
1641
1170
  transformToolCases(tool) {
1642
1171
  return ToolSchema.parse({
1643
1172
  ...tool,
1644
- inputParameters: tool.input_parameters,
1645
- outputParameters: tool.output_parameters,
1173
+ inputParameters: normalizeRawToolParameters(tool.input_parameters),
1174
+ outputParameters: normalizeRawToolParameters(tool.output_parameters),
1646
1175
  availableVersions: tool.available_versions,
1647
1176
  isDeprecated: tool.deprecated?.is_deprecated ?? false,
1648
1177
  isNoAuth: tool.no_auth
@@ -1745,10 +1274,12 @@ var Tools = class {
1745
1274
  return modifiedResult;
1746
1275
  }
1747
1276
  /**
1748
- * Lists all tools available in the Composio SDK including custom tools.
1277
+ * Lists Composio API tools available to the SDK.
1749
1278
  *
1750
- * This method fetches tools from the Composio API in raw format and combines them with
1751
- * any registered custom tools. The response can be filtered and modified as needed.
1279
+ * This method fetches remote Composio tools from the API in raw format. The response can be
1280
+ * filtered and modified as needed. Local experimental custom tools are session-scoped; attach
1281
+ * them when creating or reusing a Tool Router session, then use `session.tools()`,
1282
+ * `session.customTools()`, or `session.execute()`.
1752
1283
  * It provides access to the underlying tool data without provider-specific wrapping.
1753
1284
  *
1754
1285
  * @param {ToolListParams} query - Query parameters to filter the tools (required)
@@ -1825,8 +1356,7 @@ var Tools = class {
1825
1356
  const tools = await this.client.tools.list(filters);
1826
1357
  if (!tools) return [];
1827
1358
  const caseTransformedTools = tools.items.map((tool) => this.transformToolCases(tool));
1828
- const customTools = await this.customTools.getCustomTools({ toolSlugs: "tools" in queryParams.data ? queryParams.data.tools : void 0 });
1829
- let modifiedTools = await this.applyDefaultSchemaModifiers([...caseTransformedTools, ...customTools]);
1359
+ let modifiedTools = await this.applyDefaultSchemaModifiers(caseTransformedTools);
1830
1360
  if (options?.modifySchema) {
1831
1361
  const modifier = options.modifySchema;
1832
1362
  if (typeof modifier === "function") {
@@ -1887,6 +1417,9 @@ var Tools = class {
1887
1417
  * This method fetches a single tool in raw format without provider-specific wrapping,
1888
1418
  * providing direct access to the tool's schema and metadata. Tool versions are controlled
1889
1419
  * at the Composio SDK initialization level through the `toolkitVersions` configuration.
1420
+ * Local experimental custom tools are session-scoped; attach them when creating or reusing a
1421
+ * Tool Router session, then use `session.tools()`, `session.customTools()`, or
1422
+ * `session.execute()`.
1890
1423
  *
1891
1424
  * @param {string} slug - The unique identifier of the tool (e.g., 'GITHUB_GET_REPOS')
1892
1425
  * @param {GetRawComposioToolBySlugOptions} [options] - Optional configuration for tool retrieval
@@ -1916,9 +1449,6 @@ var Tools = class {
1916
1449
  * }
1917
1450
  * );
1918
1451
  *
1919
- * // Get a custom tool (will check custom tools first)
1920
- * const customTool = await composio.tools.getRawComposioToolBySlug('MY_CUSTOM_TOOL');
1921
- *
1922
1452
  * // Access tool properties
1923
1453
  * const githubTool = await composio.tools.getRawComposioToolBySlug('GITHUB_CREATE_ISSUE');
1924
1454
  * console.log({
@@ -1932,11 +1462,6 @@ var Tools = class {
1932
1462
  * ```
1933
1463
  */
1934
1464
  async getRawComposioToolBySlug(slug, options) {
1935
- const customTool = await this.customTools.getCustomToolBySlug(slug);
1936
- if (customTool) {
1937
- logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
1938
- return customTool;
1939
- } else logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
1940
1465
  let tool;
1941
1466
  try {
1942
1467
  const retrieveParams = options?.version ? { version: options.version } : { toolkit_versions: this.toolkitVersions };
@@ -2088,8 +1613,7 @@ var Tools = class {
2088
1613
  /**
2089
1614
  * Executes a given tool with the provided parameters.
2090
1615
  *
2091
- * This method calls the Composio API or a custom tool handler to execute the tool and returns the response.
2092
- * It automatically determines whether to use a custom tool or a Composio API tool based on the slug.
1616
+ * This method calls the Composio API to execute the tool and returns the response.
2093
1617
  *
2094
1618
  * **Version Control:**
2095
1619
  * By default, manual tool execution requires a specific toolkit version. If the version resolves to "latest",
@@ -2106,7 +1630,6 @@ var Tools = class {
2106
1630
  * @param {ExecuteToolModifiers} [modifiers] - Optional modifiers to transform the request or response
2107
1631
  * @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
2108
1632
  *
2109
- * @throws {ComposioCustomToolsNotInitializedError} If the CustomTools instance is not initialized
2110
1633
  * @throws {ComposioConnectedAccountNotFoundError} If the connected account is not found
2111
1634
  * @throws {ComposioToolNotFoundError} If the tool with the given slug is not found
2112
1635
  * @throws {ComposioToolVersionRequiredError} If version resolves to "latest" and dangerouslySkipVersionCheck is not true
@@ -2159,18 +1682,16 @@ var Tools = class {
2159
1682
  * ```
2160
1683
  */
2161
1684
  async execute(slug, body, modifiers) {
2162
- if (!this.customTools) throw new ComposioCustomToolsNotInitializedError("CustomTools not initialized. Make sure Tools class is properly constructed.");
2163
1685
  const executeParams = ToolExecuteParamsSchema.safeParse(body);
2164
1686
  if (!executeParams.success) throw new ValidationError("Invalid tool execute parameters", { cause: executeParams.error });
2165
- const customTool = await this.customTools.getCustomToolBySlug(slug);
2166
- const tool = customTool ?? await this.getRawComposioToolBySlug(slug, { version: body.version });
1687
+ const tool = await this.getRawComposioToolBySlug(slug, { version: body.version });
2167
1688
  const toolkitSlug = tool.toolkit?.slug ?? "unknown";
2168
1689
  const params = await this.applyBeforeExecuteModifiers(tool, {
2169
1690
  toolSlug: slug,
2170
1691
  toolkitSlug,
2171
1692
  params: executeParams.data
2172
1693
  }, modifiers);
2173
- let result = customTool ? await this.customTools.executeCustomTool(customTool.slug, params) : await this.executeComposioTool(tool, params);
1694
+ let result = await this.executeComposioTool(tool, params);
2174
1695
  result = await this.applyAfterExecuteModifiers(tool, {
2175
1696
  toolSlug: slug,
2176
1697
  toolkitSlug,
@@ -2304,54 +1825,6 @@ var Tools = class {
2304
1825
  custom_connection_data: toolProxyParams.data.customConnectionData
2305
1826
  });
2306
1827
  }
2307
- /**
2308
- * Creates a custom tool that can be used within the Composio SDK.
2309
- *
2310
- * Custom tools allow you to extend the functionality of Composio with your own implementations
2311
- * while keeping a consistent interface for both built-in and custom tools.
2312
- *
2313
- * @param {CustomToolOptions} body - The configuration for the custom tool
2314
- * @returns {Promise<Tool>} The created custom tool
2315
- *
2316
- * @example
2317
- * ```typescript
2318
- * // creating a custom tool with a toolkit
2319
- * await composio.tools.createCustomTool({
2320
- * name: 'My Custom Tool',
2321
- * description: 'A custom tool that does something specific',
2322
- * slug: 'MY_CUSTOM_TOOL',
2323
- * userId: 'default',
2324
- * connectedAccountId: '123',
2325
- * toolkitSlug: 'github',
2326
- * inputParameters: z.object({
2327
- * param1: z.string().describe('First parameter'),
2328
- * }),
2329
- * execute: async (input, connectionConfig, executeToolRequest) => {
2330
- * // Custom logic here
2331
- * return { data: { result: 'Success!' } };
2332
- * }
2333
- * });
2334
- * ```
2335
- *
2336
- * @example
2337
- * ```typescript
2338
- * // creating a custom tool without a toolkit
2339
- * await composio.tools.createCustomTool({
2340
- * name: 'My Custom Tool',
2341
- * description: 'A custom tool that does something specific',
2342
- * slug: 'MY_CUSTOM_TOOL',
2343
- * inputParameters: z.object({
2344
- * param1: z.string().describe('First parameter'),
2345
- * }),
2346
- * execute: async (input) => {
2347
- * // Custom logic here
2348
- * return { data: { result: 'Success!' } };
2349
- * }
2350
- * });
2351
- */
2352
- async createCustomTool(body) {
2353
- return this.customTools.createTool(body);
2354
- }
2355
1828
  };
2356
1829
 
2357
1830
  //#endregion
@@ -2450,6 +1923,24 @@ const ToolkitRetrieveCategoriesResponseSchema = z$1.object({
2450
1923
  });
2451
1924
  const ToolkitAuthFieldsResponseSchema = z$1.array(ToolkitAuthFieldSchema.extend({ required: z$1.boolean().optional() }));
2452
1925
 
1926
+ //#endregion
1927
+ //#region src/utils/transform.ts
1928
+ function transform(raw) {
1929
+ return { with(schema) {
1930
+ return { using(transformer, options) {
1931
+ const transformed = transformer(raw);
1932
+ const result = schema.safeParse(transformed);
1933
+ if (!result.success) {
1934
+ const label = options?.label ? ` for ${options.label}` : "";
1935
+ const issues = result.error.issues.map((issue) => ` - ${issue.path.join(".") || "parameter"}: ${issue.message}`).join("\n");
1936
+ logger_default.warn(`Transform validation failed${label}:\n${issues}`);
1937
+ return transformed;
1938
+ }
1939
+ return result.data;
1940
+ } };
1941
+ } };
1942
+ }
1943
+
2453
1944
  //#endregion
2454
1945
  //#region src/utils/transformers/authConfigs.ts
2455
1946
  /**
@@ -2786,6 +2277,275 @@ var AuthConfigs = class {
2786
2277
  }
2787
2278
  };
2788
2279
 
2280
+ //#endregion
2281
+ //#region src/types/connectedAccounts.types.ts
2282
+ /**
2283
+ * Connected Account create parameters
2284
+ */
2285
+ const ConnectedAccountStatuses = {
2286
+ INITIALIZING: "INITIALIZING",
2287
+ INITIATED: "INITIATED",
2288
+ ACTIVE: "ACTIVE",
2289
+ FAILED: "FAILED",
2290
+ EXPIRED: "EXPIRED",
2291
+ INACTIVE: "INACTIVE",
2292
+ REVOKED: "REVOKED"
2293
+ };
2294
+ const ConnectedAccountStatusSchema = z$1.enum([
2295
+ ConnectedAccountStatuses.INITIALIZING,
2296
+ ConnectedAccountStatuses.INITIATED,
2297
+ ConnectedAccountStatuses.ACTIVE,
2298
+ ConnectedAccountStatuses.FAILED,
2299
+ ConnectedAccountStatuses.EXPIRED,
2300
+ ConnectedAccountStatuses.INACTIVE,
2301
+ ConnectedAccountStatuses.REVOKED
2302
+ ]);
2303
+ /**
2304
+ * Sharing model for a connected account.
2305
+ *
2306
+ * - `PRIVATE` (default): only the owning `userId` can use the connection.
2307
+ * - `SHARED`: can be used by other `userId`s, but only when the connection
2308
+ * is explicitly pinned in a tool-router session's config and only when
2309
+ * the requesting `userId` passes the connection's ACL (see
2310
+ * `allowAllUsers` / `allowedUserIds` / `notAllowedUserIds`).
2311
+ */
2312
+ const ConnectedAccountTypes = {
2313
+ PRIVATE: "PRIVATE",
2314
+ SHARED: "SHARED"
2315
+ };
2316
+ const ConnectedAccountTypeSchema = z$1.enum([ConnectedAccountTypes.PRIVATE, ConnectedAccountTypes.SHARED]);
2317
+ /**
2318
+ * Per-user access control for a SHARED connected account. Ignored for
2319
+ * PRIVATE.
2320
+ *
2321
+ * Pass `aclConfigForShared` on create / PATCH to grant access; omit it
2322
+ * to leave the ACL unchanged (on PATCH) or to keep the default
2323
+ * deny-by-default state (on create). On responses, the field is
2324
+ * `undefined` when the caller isn't authorised to see the ACL —
2325
+ * distinguish that from an empty/default state explicitly.
2326
+ *
2327
+ * Resolution rule (deny wins):
2328
+ * 1. requesting `userId` in `notAllowedUserIds` → DENY
2329
+ * 2. `allowAllUsers === true` → ALLOW
2330
+ * 3. requesting `userId` in `allowedUserIds` → ALLOW
2331
+ * 4. otherwise → DENY (deny-by-default)
2332
+ *
2333
+ * Default state (block omitted or `{}`) means only the connection's
2334
+ * creator can use it. The creator must grant access explicitly.
2335
+ *
2336
+ * Limits: each list accepts up to 1000 entries; each `userId` is
2337
+ * 1..256 characters.
2338
+ */
2339
+ const ACL_LIST_MAX_LENGTH = 1e3;
2340
+ const aclUserIdString = z$1.string().min(1).max(256);
2341
+ const ConnectedAccountAclConfigSchema = z$1.object({
2342
+ allowAllUsers: z$1.boolean().optional().describe("When true, any `userId` may use this SHARED connection (subject to the deny list). Default false."),
2343
+ allowedUserIds: z$1.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings allowed to use this SHARED connection. Default []."),
2344
+ notAllowedUserIds: z$1.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings denied access. Wins over allow on conflict. Default [].")
2345
+ });
2346
+ /**
2347
+ * Resolved ACL as it appears on responses. All three fields are populated
2348
+ * when the field is visible; the field itself is `undefined` for callers
2349
+ * not authorised to see it.
2350
+ */
2351
+ const ConnectedAccountAclConfigResponseSchema = z$1.object({
2352
+ allowAllUsers: z$1.boolean(),
2353
+ allowedUserIds: z$1.array(z$1.string()),
2354
+ notAllowedUserIds: z$1.array(z$1.string())
2355
+ });
2356
+ /**
2357
+ * Experimental options for SHARED connections, passed at create / link time.
2358
+ *
2359
+ * **Experimental — shape may change in future releases.** Wrapped under a
2360
+ * dedicated `experimental` block on every input and response so the
2361
+ * experimental status is visible at every call site.
2362
+ */
2363
+ const ConnectedAccountExperimentalSchema = z$1.object({
2364
+ accountType: ConnectedAccountTypeSchema.optional(),
2365
+ aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
2366
+ });
2367
+ /**
2368
+ * Resolved experimental block on retrieve / list responses. `accountType`
2369
+ * is always present when the block is; `aclConfigForShared` is only
2370
+ * present when the caller is authorised to see the ACL.
2371
+ */
2372
+ const ConnectedAccountExperimentalResponseSchema = z$1.object({
2373
+ accountType: ConnectedAccountTypeSchema.optional(),
2374
+ aclConfigForShared: ConnectedAccountAclConfigResponseSchema.optional()
2375
+ });
2376
+ const CreateConnectedAccountParamsSchema = z$1.object({
2377
+ authConfig: z$1.object({ id: z$1.string() }),
2378
+ connection: z$1.object({
2379
+ data: z$1.record(z$1.string(), z$1.unknown()).optional(),
2380
+ callbackUrl: z$1.string().optional(),
2381
+ userId: z$1.string().optional()
2382
+ })
2383
+ });
2384
+ const DefaultCreateConnectedAccountParamsSchema = z$1.object({
2385
+ auth_config: z$1.object({ id: z$1.string() }),
2386
+ connection: z$1.object({
2387
+ state: ConnectionDataSchema.optional(),
2388
+ data: z$1.record(z$1.string(), z$1.unknown()).optional(),
2389
+ callback_url: z$1.string().optional(),
2390
+ user_id: z$1.string().optional(),
2391
+ alias: z$1.string().optional()
2392
+ })
2393
+ });
2394
+ const CreateConnectedAccountOptionsSchema = z$1.object({
2395
+ allowMultiple: z$1.boolean().optional(),
2396
+ callbackUrl: z$1.string().optional(),
2397
+ config: ConnectionDataSchema.optional(),
2398
+ alias: z$1.string().optional()
2399
+ });
2400
+ /**
2401
+ * Connected Account create response
2402
+ */
2403
+ const CreateConnectedAccountResponseSchema = z$1.object({
2404
+ id: z$1.string(),
2405
+ status: ConnectedAccountStatusSchema,
2406
+ redirectUrl: z$1.string().nullable()
2407
+ });
2408
+ const ConnectedAccountAuthConfigSchema = z$1.object({
2409
+ id: z$1.string(),
2410
+ authScheme: AuthSchemeEnum.optional(),
2411
+ isComposioManaged: z$1.boolean(),
2412
+ isDisabled: z$1.boolean()
2413
+ });
2414
+ const ConnectedAccountRetrieveResponseSchema = z$1.object({
2415
+ id: z$1.string(),
2416
+ authConfig: ConnectedAccountAuthConfigSchema,
2417
+ wordId: z$1.string().nullable().optional(),
2418
+ alias: z$1.string().nullable().optional(),
2419
+ data: z$1.record(z$1.string(), z$1.unknown()).optional(),
2420
+ params: z$1.record(z$1.string(), z$1.unknown()).optional(),
2421
+ status: ConnectedAccountStatusSchema,
2422
+ statusReason: z$1.string().nullable(),
2423
+ toolkit: z$1.object({ slug: z$1.string() }),
2424
+ state: ConnectionDataSchema.optional(),
2425
+ testRequestEndpoint: z$1.string().optional(),
2426
+ isDisabled: z$1.boolean(),
2427
+ createdAt: z$1.string(),
2428
+ updatedAt: z$1.string(),
2429
+ experimental: ConnectedAccountExperimentalResponseSchema.optional()
2430
+ });
2431
+ const ConnectedAccountListParamsSchema = z$1.object({
2432
+ authConfigIds: z$1.array(z$1.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
2433
+ cursor: z$1.string().nullish().describe("The cursor to paginate through the connected accounts"),
2434
+ limit: z$1.number().nullable().optional().describe("The limit of the connected accounts to return"),
2435
+ orderBy: z$1.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
2436
+ statuses: z$1.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
2437
+ toolkitSlugs: z$1.array(z$1.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
2438
+ userIds: z$1.array(z$1.string()).nullable().optional().describe("The user ids of the connected accounts"),
2439
+ accountType: z$1.enum([
2440
+ "PRIVATE",
2441
+ "SHARED",
2442
+ "ALL"
2443
+ ]).optional()
2444
+ });
2445
+ const ConnectedAccountListResponseSchema = z$1.object({
2446
+ items: z$1.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
2447
+ nextCursor: z$1.string().nullish().describe("The next cursor to paginate through the connected accounts"),
2448
+ totalPages: z$1.number().describe("The total number of pages of connected accounts")
2449
+ });
2450
+ const CreateConnectedAccountLinkOptionsSchema = z$1.object({
2451
+ callbackUrl: z$1.string().optional(),
2452
+ alias: z$1.string().optional(),
2453
+ allowMultiple: z$1.boolean().optional(),
2454
+ experimental: ConnectedAccountExperimentalSchema.optional()
2455
+ });
2456
+ const CreateConnectedAccountLinkResponseSchema = z$1.object({ redirectUrl: z$1.string() });
2457
+ const ConnectedAccountRefreshOptionsSchema = z$1.object({
2458
+ redirectUrl: z$1.string().optional(),
2459
+ validateCredentials: z$1.boolean().optional()
2460
+ });
2461
+ const UpdateConnectedAccountParamsSchema = z$1.object({ enabled: z$1.boolean() });
2462
+ /**
2463
+ * Params for `composio.connectedAccounts.updateAcl()`. Mirrors the inner
2464
+ * shape of the wire's `acl_config_for_shared` block — the SDK adds the
2465
+ * outer nesting at the boundary, so callers pass the three fields flat.
2466
+ *
2467
+ * PATCH-style semantics — omit a field to leave it unchanged; pass an
2468
+ * empty array to clear an allow/deny list. Raises
2469
+ * `ComposioAclOnlyForSharedError` on a PRIVATE connection.
2470
+ *
2471
+ * Each field is optional, but at least one must be provided — passing an
2472
+ * empty object is rejected as a no-op.
2473
+ */
2474
+ 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" });
2475
+
2476
+ //#endregion
2477
+ //#region src/utils/transformers/connectedAccounts.ts
2478
+ /**
2479
+ * Transforms the raw connected account response from the Composio API to the SDK format.
2480
+ *
2481
+ * This method converts property names from snake_case to camelCase and reorganizes
2482
+ * the data structure to match the SDK's standardized format.
2483
+ *
2484
+ * @param {RawConnectedAccountListResponse['items'][0]|RawConnectedAccountRetrieveResponse} response - The raw API response to transform
2485
+ * @returns {Promise<ConnectedAccountRetrieveResponse>} The transformed response
2486
+ * @throws {ZodError} If the response fails validation against the expected schema
2487
+ *
2488
+ * @private
2489
+ */
2490
+ function transformConnectedAccountResponse(response) {
2491
+ const responseWithLabels = response;
2492
+ const parseState = (state) => {
2493
+ try {
2494
+ return state ? ConnectionDataSchema.parse(state) : void 0;
2495
+ } catch (error) {
2496
+ logger_default.warn("Unsupported auth scheme in connected account state, ignoring state field", { error });
2497
+ return;
2498
+ }
2499
+ };
2500
+ return transform(response).with(ConnectedAccountRetrieveResponseSchema).using((response$1) => ({
2501
+ ...response$1,
2502
+ authConfig: {
2503
+ ...response$1.auth_config,
2504
+ id: response$1.auth_config.id,
2505
+ authScheme: response$1.auth_config.auth_scheme,
2506
+ isComposioManaged: response$1.auth_config.is_composio_managed,
2507
+ isDisabled: response$1.auth_config.is_disabled
2508
+ },
2509
+ wordId: responseWithLabels.word_id ?? null,
2510
+ alias: responseWithLabels.alias ?? null,
2511
+ data: response$1.data ?? void 0,
2512
+ state: parseState(response$1.state),
2513
+ status: response$1.status,
2514
+ statusReason: response$1.status_reason,
2515
+ isDisabled: response$1.is_disabled,
2516
+ createdAt: response$1.created_at,
2517
+ updatedAt: response$1.updated_at,
2518
+ testRequestEndpoint: response$1.test_request_endpoint,
2519
+ experimental: responseWithLabels.experimental ? {
2520
+ accountType: responseWithLabels.experimental.account_type,
2521
+ aclConfigForShared: responseWithLabels.experimental.acl_config_for_shared ? {
2522
+ allowAllUsers: responseWithLabels.experimental.acl_config_for_shared.allow_all_users,
2523
+ allowedUserIds: responseWithLabels.experimental.acl_config_for_shared.allowed_user_ids,
2524
+ notAllowedUserIds: responseWithLabels.experimental.acl_config_for_shared.not_allowed_user_ids
2525
+ } : void 0
2526
+ } : void 0
2527
+ }));
2528
+ }
2529
+ /**
2530
+ * Transforms the raw connected account list response from the Composio API to the SDK format.
2531
+ *
2532
+ * This method converts property names from snake_case to camelCase and reorganizes
2533
+ * the data structure to match the SDK's standardized format.
2534
+ *
2535
+ * @param {RawConnectedAccountListResponse} response - The raw API response to transform
2536
+ * @returns {ConnectedAccountListResponse} The transformed response
2537
+ * @throws {ZodError} If the response fails validation against the expected schema
2538
+ *
2539
+ * @private
2540
+ */
2541
+ function transformConnectedAccountListResponse(response) {
2542
+ return transform(response).with(ConnectedAccountListResponseSchema).using((response$1) => ({
2543
+ items: response$1.items.map(transformConnectedAccountResponse),
2544
+ nextCursor: response$1.next_cursor ?? null,
2545
+ totalPages: response$1.total_pages
2546
+ }));
2547
+ }
2548
+
2789
2549
  //#endregion
2790
2550
  //#region src/models/ConnectionRequest.ts
2791
2551
  /**
@@ -4239,11 +3999,13 @@ var Triggers = class {
4239
3999
  });
4240
4000
  throw error;
4241
4001
  }
4242
- return { triggerId: (await this.client.triggerInstances.upsert(slug, {
4002
+ const upsertParams = {
4243
4003
  connected_account_id: connectedAccountId,
4244
4004
  trigger_config: parsedBody.data.triggerConfig,
4245
- toolkit_versions: this.toolkitVersions
4246
- })).trigger_id };
4005
+ toolkit_versions: this.toolkitVersions,
4006
+ user_id: userId
4007
+ };
4008
+ return { triggerId: (await this.client.triggerInstances.upsert(slug, upsertParams)).trigger_id };
4247
4009
  }
4248
4010
  /**
4249
4011
  * Update an existing trigger instance
@@ -5292,6 +5054,63 @@ var BaseAgenticProvider = class extends BaseProvider {
5292
5054
  _isAgentic = true;
5293
5055
  };
5294
5056
 
5057
+ //#endregion
5058
+ //#region src/utils/toolArguments.ts
5059
+ /**
5060
+ * Tool-argument normalization.
5061
+ *
5062
+ * Models (and MCP transports) occasionally emit tool-call arguments as a JSON
5063
+ * *string* instead of an object. `COMPOSIO_MULTI_EXECUTE_TOOL` and Vercel AI
5064
+ * SDK streaming are common triggers. Forwarding that raw string to execution
5065
+ * surfaces opaque downstream errors such as
5066
+ * `tool_use.input: Input should be a valid dictionary`.
5067
+ *
5068
+ * `normalizeToolArguments` is the single coercion every provider routes through
5069
+ * so the behaviour is identical everywhere instead of being re-implemented
5070
+ * (inconsistently) per provider.
5071
+ *
5072
+ * @see https://github.com/ComposioHQ/composio/issues/2406
5073
+ */
5074
+ /**
5075
+ * Coerce model-supplied tool arguments into a plain object.
5076
+ *
5077
+ * Rules:
5078
+ * - `null` / `undefined` → `{}` (some models send no arguments for no-arg tools).
5079
+ * - A plain object is returned unchanged.
5080
+ * - A string is JSON-parsed; an empty / whitespace-only string becomes `{}`.
5081
+ * - Anything that does not resolve to a plain object (arrays, primitives,
5082
+ * unparseable strings, JSON that parses to a non-object) throws a typed
5083
+ * {@link ComposioInvalidToolArgumentsError} so callers get an actionable
5084
+ * message instead of a raw `SyntaxError` or a silent malformed payload.
5085
+ *
5086
+ * @param input - Raw arguments as received from the model / framework.
5087
+ * @param toolSlug - Optional tool slug, used to enrich the error message.
5088
+ * @returns The normalized arguments as a `Record<string, unknown>`.
5089
+ */
5090
+ function normalizeToolArguments(input, toolSlug) {
5091
+ if (input === null || input === void 0) return {};
5092
+ if (typeof input === "string") {
5093
+ const trimmed = input.trim();
5094
+ if (trimmed === "") return {};
5095
+ let parsed;
5096
+ try {
5097
+ parsed = JSON.parse(trimmed);
5098
+ } catch (cause) {
5099
+ throw new ComposioInvalidToolArgumentsError(`${describeTool(toolSlug)} received arguments as a string that is not valid JSON`, { cause: cause instanceof Error ? cause : void 0 });
5100
+ }
5101
+ return assertPlainObject(parsed, toolSlug);
5102
+ }
5103
+ return assertPlainObject(input, toolSlug);
5104
+ }
5105
+ function assertPlainObject(value, toolSlug) {
5106
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) return value;
5107
+ const actual = Array.isArray(value) ? "array" : typeof value;
5108
+ throw new ComposioInvalidToolArgumentsError(`${describeTool(toolSlug)} expected arguments to be an object, received ${actual}`);
5109
+ }
5110
+ function describeTool(toolSlug) {
5111
+ return toolSlug ? `Tool '${toolSlug}'` : "Tool";
5112
+ }
5113
+
5295
5114
  //#endregion
5296
5115
  //#region src/provider/OpenAIProvider.ts
5297
5116
  var OpenAIProvider = class extends BaseNonAgenticProvider {
@@ -5444,7 +5263,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5444
5263
  */
5445
5264
  async executeToolCall(userId, tool, options, modifiers) {
5446
5265
  const payload = {
5447
- arguments: JSON.parse(tool.function.arguments),
5266
+ arguments: normalizeToolArguments(tool.function.arguments, tool.function.name),
5448
5267
  connectedAccountId: options?.connectedAccountId,
5449
5268
  customAuthParams: options?.customAuthParams,
5450
5269
  customConnectionData: options?.customConnectionData,
@@ -5721,7 +5540,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5721
5540
 
5722
5541
  //#endregion
5723
5542
  //#region package.json
5724
- var version = "0.10.0";
5543
+ var version = "0.11.0";
5725
5544
 
5726
5545
  //#endregion
5727
5546
  //#region src/utils/session.ts
@@ -7754,6 +7573,17 @@ const CYCLE_BREAK_SENTINEL = {
7754
7573
  type: "object",
7755
7574
  additionalProperties: true
7756
7575
  };
7576
+ /**
7577
+ * In-band hint attached to the cycle-break sentinel when lenient mode
7578
+ * substitutes it for a dangling `$ref`. Makes the degradation visible to
7579
+ * LLMs that read the wrapped tool's schema — without it the LLM sees a
7580
+ * useless permissive object and no prose context. Wording is intentionally
7581
+ * context-neutral ("Schema shape", not "Output shape") because the helper
7582
+ * is used for both `inputParameters` and `outputParameters`. Overridden
7583
+ * when the caller's `$ref` node carries its own `description` sibling
7584
+ * (Draft 2020-12 sibling-keyword semantics).
7585
+ */
7586
+ const UNRESOLVED_REF_DESCRIPTION = "Schema shape unresolved at the source — validate loosely. See https://github.com/ComposioHQ/composio/issues/3307.";
7757
7587
  const POLLUTING_KEYS = new Set([
7758
7588
  "__proto__",
7759
7589
  "constructor",
@@ -7761,33 +7591,68 @@ const POLLUTING_KEYS = new Set([
7761
7591
  ]);
7762
7592
  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"];
7763
7593
  const decodePointerSegment = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
7764
- const failResolution = (pointer, segment) => {
7765
- throw new JsonSchemaRefResolutionError(`Cannot resolve $ref ${pointer}`, {
7766
- meta: {
7767
- ref: pointer,
7768
- failedAt: segment
7769
- },
7770
- possibleFixes: REF_RESOLUTION_FIXES
7771
- });
7772
- };
7773
- const stepInto = (cursor, segment, pointer) => {
7774
- if (cursor === null || typeof cursor !== "object") failResolution(pointer, segment);
7594
+ const tryStep = (cursor, segment) => {
7595
+ if (cursor === null || typeof cursor !== "object") return {
7596
+ kind: "unresolved",
7597
+ reason: "missing-target",
7598
+ failedAt: segment
7599
+ };
7775
7600
  if (Array.isArray(cursor)) {
7776
7601
  const i = Number(segment);
7777
- if (!Number.isInteger(i) || i < 0 || i >= cursor.length) failResolution(pointer, segment);
7778
- return cursor[i];
7602
+ if (!Number.isInteger(i) || i < 0 || i >= cursor.length) return {
7603
+ kind: "unresolved",
7604
+ reason: "missing-target",
7605
+ failedAt: segment
7606
+ };
7607
+ return {
7608
+ kind: "ok",
7609
+ value: cursor[i]
7610
+ };
7779
7611
  }
7780
7612
  const obj = cursor;
7781
- if (!Object.prototype.hasOwnProperty.call(obj, segment)) failResolution(pointer, segment);
7782
- return obj[segment];
7613
+ if (!Object.prototype.hasOwnProperty.call(obj, segment)) return {
7614
+ kind: "unresolved",
7615
+ reason: "missing-target",
7616
+ failedAt: segment
7617
+ };
7618
+ return {
7619
+ kind: "ok",
7620
+ value: obj[segment]
7621
+ };
7622
+ };
7623
+ const tryResolvePointer = (root, pointer) => {
7624
+ if (pointer === "#" || pointer === "") return {
7625
+ kind: "ok",
7626
+ value: root
7627
+ };
7628
+ if (!pointer.startsWith("#/")) return {
7629
+ kind: "unresolved",
7630
+ reason: "malformed-pointer"
7631
+ };
7632
+ const segments = pointer.slice(2).split("/").map(decodePointerSegment);
7633
+ let cursor = root;
7634
+ for (const seg of segments) {
7635
+ const step = tryStep(cursor, seg);
7636
+ if (step.kind === "unresolved") return step;
7637
+ cursor = step.value;
7638
+ }
7639
+ return {
7640
+ kind: "ok",
7641
+ value: cursor
7642
+ };
7783
7643
  };
7784
- const resolvePointer = (root, pointer) => {
7785
- if (pointer === "#" || pointer === "") return root;
7786
- if (!pointer.startsWith("#/")) throw new JsonSchemaRefResolutionError(`Unsupported $ref pointer: ${pointer}`, {
7644
+ const throwResolutionError = (pointer, result) => {
7645
+ if (result.reason === "malformed-pointer") throw new JsonSchemaRefResolutionError(`Unsupported $ref pointer: ${pointer}`, {
7787
7646
  meta: { ref: pointer },
7788
7647
  possibleFixes: REF_RESOLUTION_FIXES
7789
7648
  });
7790
- return pointer.slice(2).split("/").map(decodePointerSegment).reduce((cursor, seg) => stepInto(cursor, seg, pointer), root);
7649
+ throw new JsonSchemaRefResolutionError(`Cannot resolve $ref ${pointer}`, {
7650
+ meta: {
7651
+ ref: pointer,
7652
+ ...result.failedAt !== void 0 ? { failedAt: result.failedAt } : {}
7653
+ },
7654
+ possibleFixes: REF_RESOLUTION_FIXES
7655
+ });
7791
7656
  };
7792
7657
  /**
7793
7658
  * Inlines internal JSON Schema `$ref` pointers (`#/$defs/...` and legacy
@@ -7797,11 +7662,20 @@ const resolvePointer = (root, pointer) => {
7797
7662
  * left untouched. Cycles are broken with `{ type: 'object',
7798
7663
  * additionalProperties: true }`. The input is never mutated.
7799
7664
  *
7665
+ * By default, unresolved internal refs throw `JsonSchemaRefResolutionError`.
7666
+ * Pass `{ onUnresolved: 'sentinel' }` to replace the offending node with the
7667
+ * cycle-break sentinel instead — appropriate for schemas sourced from an
7668
+ * upstream service the caller cannot edit (the Composio API ships some
7669
+ * `outputParameters` with a `$ref` into `#/$defs/...` but never declares
7670
+ * `$defs`; see https://github.com/ComposioHQ/composio/issues/3307).
7671
+ *
7800
7672
  * @throws {JsonSchemaRefResolutionError} on malformed pointers, missing
7801
- * targets, or chains past the depth cap.
7673
+ * targets (strict mode only), or chains past the depth cap (both modes).
7802
7674
  */
7803
- function dereferenceJsonSchema(schema) {
7675
+ function dereferenceJsonSchema(schema, options) {
7804
7676
  if (!isPlainObject(schema)) return schema;
7677
+ const strategy = options?.onUnresolved ?? "throw";
7678
+ const onReplace = options?.onReplace;
7805
7679
  const root = schema;
7806
7680
  const visiting = /* @__PURE__ */ new WeakSet();
7807
7681
  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)]));
@@ -7830,7 +7704,18 @@ function dereferenceJsonSchema(schema) {
7830
7704
  possibleFixes: REF_RESOLUTION_FIXES
7831
7705
  });
7832
7706
  if (visitedRefs.has(ref)) return { ...CYCLE_BREAK_SENTINEL };
7833
- const resolved = walk(resolvePointer(root, ref), new Set(visitedRefs).add(ref), chainDepth + 1, nodeDepth + 1);
7707
+ const result = tryResolvePointer(root, ref);
7708
+ let target;
7709
+ if (result.kind === "ok") target = result.value;
7710
+ else if (strategy === "sentinel") {
7711
+ onReplace?.(ref, result.reason);
7712
+ target = {
7713
+ ...CYCLE_BREAK_SENTINEL,
7714
+ description: UNRESOLVED_REF_DESCRIPTION
7715
+ };
7716
+ } else throwResolutionError(ref, result);
7717
+ const nextRefs = new Set(visitedRefs).add(ref);
7718
+ const resolved = walk(target, nextRefs, chainDepth + 1, nodeDepth + 1);
7834
7719
  const siblings = { ...node };
7835
7720
  delete siblings.$ref;
7836
7721
  if (Object.keys(siblings).length === 0 || !isPlainObject(resolved)) return resolved;
@@ -8387,4 +8272,4 @@ const ComposioMcpUpdateResponseSchema = z$1.object({
8387
8272
  });
8388
8273
 
8389
8274
  //#endregion
8390
- export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAclOnlyForSharedError, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomCreateResponseSchema, ComposioCustomToolsNotInitializedError, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioFileNotFoundError, ComposioFileUploadAbortedError, ComposioFileUploadError, ComposioFileUploadPathNotAllowedError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioLegacyConnectedAccountsEndpointRetiredError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioSensitiveFilePathBlockedError, ComposioSharedAccessDeniedError, ComposioSharedConnectionNotAccessibleError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAclConfigResponseSchema, ConnectedAccountAclConfigSchema, ConnectedAccountAuthConfigSchema, ConnectedAccountErrorCodes, ConnectedAccountExperimentalResponseSchema, ConnectedAccountExperimentalSchema, ConnectedAccountListParamsSchema, ConnectedAccountListResponseSchema, ConnectedAccountRefreshOptionsSchema, ConnectedAccountRetrieveResponseSchema, ConnectedAccountStatusSchema, ConnectedAccountStatuses, ConnectedAccountTypeSchema, ConnectedAccountTypes, ConnectionDataSchema, ConnectionExpiredEventSchema, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConnectionStatus, ConnectionStatuses, CreateAuthConfigParamsSchema, CreateAuthConfigResponseSchema, CreateComposioManagedAuthConfigParamsSchema, CreateConnectedAccountLinkOptionsSchema, CreateConnectedAccountLinkResponseSchema, CreateConnectedAccountOptionsSchema, CreateConnectedAccountParamsSchema, CreateConnectedAccountResponseSchema, CreateCustomAuthConfigParamsSchema, CreateCustomToolBaseSchema, CreateCustomToolkitBaseSchema, CustomAuthParamsSchema, CustomConnectionDataSchema, CustomCreateResponseSchema, CustomOauth1ConnectionDataSchema, CustomOauth2ConnectionDataSchema, CustomToolSlugSchema, DefaultCreateConnectedAccountParamsSchema, Experimental, FileDeleteResponseSchema, FileListResponseSchema, FileModifierErrorCodes, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, JsonSchemaRefResolutionError, JsonSchemaToZodError, MCP, MCPAuthOptionsSchema, MCPGenerateURLParamsSchema, MCPGetServerParamsSchema, MCPMultiAppServerSchema, MCPServerCreateResponseSchema, MCPServerListResponseSchema, MCPServerSchema, MCPServerTypeSchema, MCPServerUpdateParamsSchema, MCPSingleAppServerSchema, MCPToolkitConfigSchema, MCPToolkitConfigsArraySchema, McpDeleteResponseSchema, McpListResponseSchema, McpRetrieveResponseSchema, McpUpdateResponseSchema, Oauth1ActiveConnectionDataSchema, Oauth1ConnectionDataSchema, Oauth1ExpiredConnectionDataSchema, Oauth1FailedConnectionDataSchema, Oauth1InactiveConnectionDataSchema, Oauth1InitiatedConnectionDataSchema, Oauth1InitiatingConnectionDataSchema, Oauth2ActiveConnectionDataSchema, Oauth2ConnectionDataSchema, Oauth2ExpiredConnectionDataSchema, Oauth2FailedConnectionDataSchema, Oauth2InactiveConnectionDataSchema, Oauth2InitiatedConnectionDataSchema, Oauth2InitiatingConnectionDataSchema, Oauth2RevokedConnectionDataSchema, OpenAIProvider, RedirectableAuthSchemeSchema, RemoteFile, RemoteFileDataSchema, RemoteFileDownloadError, RemoteFileErrorCodes, SDKErrorCodes, SandboxSizeSchema, SessionPreset, SessionProxyExecuteParamsSchema, SingleConnectedAccountDetailedResponseSchema, ToolErrorCodes, ToolExecuteMetaParamsSchema, ToolExecuteParamsSchema, ToolExecuteResponseSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterSession, ToolRouterSessionExecuteResponseSchema, ToolRouterSessionFilesMountDeleteOptionsSchema, ToolRouterSessionFilesMountDownloadOptionsSchema, ToolRouterSessionFilesMountListOptionsSchema, ToolRouterSessionFilesMountUploadOptionsSchema, ToolRouterSessionSearchResponseSchema, ToolRouterTagsEnableDisableSchema, ToolRouterTagsParamSchema, ToolRouterToolkitsDisabledConfigSchema, ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsOptionsSchema, ToolRouterToolkitsParamSchema, ToolRouterToolsParamSchema, ToolRouterUpdateSessionConfigSchema, ToolSchema, ToolkitAuthConfigDetailsSchema, ToolkitAuthFieldSchema, ToolkitAuthFieldsResponseSchema, ToolkitCategorySchema, ToolkitConnectionStateSchema, ToolkitConnectionsDetailsSchema, ToolkitErrorCodes, ToolkitLatestVersionSchema, ToolkitMangedByEnumSchema, ToolkitRetrieveCategoriesResponseSchema, ToolkitRetrieveResponseSchema, ToolkitSchema, ToolkitSortByEnumSchema, ToolkitVersionParamSchema, ToolkitVersionSchema, ToolkitVersionsSchema, ToolkitsListParamsSchema, TriggerErrorCodes, TriggerInstanceListActiveParamsSchema, TriggerInstanceListActiveResponseItemSchema, TriggerInstanceListActiveResponseSchema, TriggerInstanceManageDeleteResponseSchema, TriggerInstanceManageUpdateParamsSchema, TriggerInstanceManageUpdateResponseSchema, TriggerInstanceUpsertParamsSchema, TriggerInstanceUpsertResponseSchema, TriggerStatusEnum, TriggerStatuses, TriggerSubscribeParamSchema, TriggerTypeSchema, TriggersTypeListParamsSchema, TriggersTypeListResponseSchema, UpdateConnectedAccountAclParamsSchema, UpdateConnectedAccountParamsSchema, ValidationError, ValidationErrorCodes, VerifyWebhookParamsSchema, WebhookConnectedAccountAuthConfigSchema, WebhookConnectionMetadataSchema, WebhookConnectionStateSchema, WebhookEventSchema, WebhookEventTypes, WebhookPayloadSchema, WebhookPayloadV1Schema, WebhookPayloadV2Schema, WebhookPayloadV3Schema, WebhookTriggerPayloadV3Schema, WebhookVersions, constants_exports as constants, createConnectionRequest, dereferenceJsonSchema, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit, getExtensionFromMimeType, handleToolExecutionError, jsonSchemaToZodSchema, logger_default as logger, removeNonRequiredProperties };
8275
+ export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAclOnlyForSharedError, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomCreateResponseSchema, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioFileNotFoundError, ComposioFileUploadAbortedError, ComposioFileUploadError, ComposioFileUploadPathNotAllowedError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioInvalidToolArgumentsError, ComposioLegacyConnectedAccountsEndpointRetiredError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioSensitiveFilePathBlockedError, ComposioSharedAccessDeniedError, ComposioSharedConnectionNotAccessibleError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAclConfigResponseSchema, ConnectedAccountAclConfigSchema, ConnectedAccountAuthConfigSchema, ConnectedAccountErrorCodes, ConnectedAccountExperimentalResponseSchema, ConnectedAccountExperimentalSchema, ConnectedAccountListParamsSchema, ConnectedAccountListResponseSchema, ConnectedAccountRefreshOptionsSchema, ConnectedAccountRetrieveResponseSchema, ConnectedAccountStatusSchema, ConnectedAccountStatuses, ConnectedAccountTypeSchema, ConnectedAccountTypes, ConnectionDataSchema, ConnectionExpiredEventSchema, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConnectionStatus, ConnectionStatuses, CreateAuthConfigParamsSchema, CreateAuthConfigResponseSchema, CreateComposioManagedAuthConfigParamsSchema, CreateConnectedAccountLinkOptionsSchema, CreateConnectedAccountLinkResponseSchema, CreateConnectedAccountOptionsSchema, CreateConnectedAccountParamsSchema, CreateConnectedAccountResponseSchema, CreateCustomAuthConfigParamsSchema, CreateCustomToolBaseSchema, CreateCustomToolkitBaseSchema, CustomAuthParamsSchema, CustomConnectionDataSchema, CustomCreateResponseSchema, CustomOauth1ConnectionDataSchema, CustomOauth2ConnectionDataSchema, CustomToolSlugSchema, DefaultCreateConnectedAccountParamsSchema, Experimental, FileDeleteResponseSchema, FileListResponseSchema, FileModifierErrorCodes, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, JsonSchemaRefResolutionError, JsonSchemaToZodError, MCP, MCPAuthOptionsSchema, MCPGenerateURLParamsSchema, MCPGetServerParamsSchema, MCPMultiAppServerSchema, MCPServerCreateResponseSchema, MCPServerListResponseSchema, MCPServerSchema, MCPServerTypeSchema, MCPServerUpdateParamsSchema, MCPSingleAppServerSchema, MCPToolkitConfigSchema, MCPToolkitConfigsArraySchema, McpDeleteResponseSchema, McpListResponseSchema, McpRetrieveResponseSchema, McpUpdateResponseSchema, Oauth1ActiveConnectionDataSchema, Oauth1ConnectionDataSchema, Oauth1ExpiredConnectionDataSchema, Oauth1FailedConnectionDataSchema, Oauth1InactiveConnectionDataSchema, Oauth1InitiatedConnectionDataSchema, Oauth1InitiatingConnectionDataSchema, Oauth2ActiveConnectionDataSchema, Oauth2ConnectionDataSchema, Oauth2ExpiredConnectionDataSchema, Oauth2FailedConnectionDataSchema, Oauth2InactiveConnectionDataSchema, Oauth2InitiatedConnectionDataSchema, Oauth2InitiatingConnectionDataSchema, Oauth2RevokedConnectionDataSchema, OpenAIProvider, RedirectableAuthSchemeSchema, RemoteFile, RemoteFileDataSchema, RemoteFileDownloadError, RemoteFileErrorCodes, SDKErrorCodes, SandboxSizeSchema, SessionPreset, SessionProxyExecuteParamsSchema, SingleConnectedAccountDetailedResponseSchema, ToolErrorCodes, ToolExecuteMetaParamsSchema, ToolExecuteParamsSchema, ToolExecuteResponseSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterSession, ToolRouterSessionExecuteResponseSchema, ToolRouterSessionFilesMountDeleteOptionsSchema, ToolRouterSessionFilesMountDownloadOptionsSchema, ToolRouterSessionFilesMountListOptionsSchema, ToolRouterSessionFilesMountUploadOptionsSchema, ToolRouterSessionSearchResponseSchema, ToolRouterTagsEnableDisableSchema, ToolRouterTagsParamSchema, ToolRouterToolkitsDisabledConfigSchema, ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsOptionsSchema, ToolRouterToolkitsParamSchema, ToolRouterToolsParamSchema, ToolRouterUpdateSessionConfigSchema, ToolSchema, ToolkitAuthConfigDetailsSchema, ToolkitAuthFieldSchema, ToolkitAuthFieldsResponseSchema, ToolkitCategorySchema, ToolkitConnectionStateSchema, ToolkitConnectionsDetailsSchema, ToolkitErrorCodes, ToolkitLatestVersionSchema, ToolkitMangedByEnumSchema, ToolkitRetrieveCategoriesResponseSchema, ToolkitRetrieveResponseSchema, ToolkitSchema, ToolkitSortByEnumSchema, ToolkitVersionParamSchema, ToolkitVersionSchema, ToolkitVersionsSchema, ToolkitsListParamsSchema, TriggerErrorCodes, TriggerInstanceListActiveParamsSchema, TriggerInstanceListActiveResponseItemSchema, TriggerInstanceListActiveResponseSchema, TriggerInstanceManageDeleteResponseSchema, TriggerInstanceManageUpdateParamsSchema, TriggerInstanceManageUpdateResponseSchema, TriggerInstanceUpsertParamsSchema, TriggerInstanceUpsertResponseSchema, TriggerStatusEnum, TriggerStatuses, TriggerSubscribeParamSchema, TriggerTypeSchema, TriggersTypeListParamsSchema, TriggersTypeListResponseSchema, UpdateConnectedAccountAclParamsSchema, UpdateConnectedAccountParamsSchema, ValidationError, ValidationErrorCodes, VerifyWebhookParamsSchema, WebhookConnectedAccountAuthConfigSchema, WebhookConnectionMetadataSchema, WebhookConnectionStateSchema, WebhookEventSchema, WebhookEventTypes, WebhookPayloadSchema, WebhookPayloadV1Schema, WebhookPayloadV2Schema, WebhookPayloadV3Schema, WebhookTriggerPayloadV3Schema, WebhookVersions, constants_exports as constants, createConnectionRequest, dereferenceJsonSchema, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit, getExtensionFromMimeType, handleToolExecutionError, jsonSchemaToZodSchema, logger_default as logger, normalizeToolArguments, removeNonRequiredProperties, telemetry };