@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.
- package/dist/{tool.types-CB_4JKhV.d.mts → BaseProvider-BvHvJLXc.d.mts} +24346 -24345
- package/dist/{tool.types-CwbAy9l_.d.cts → BaseProvider-CVbQxTNa.d.cts} +24346 -24345
- package/dist/{CustomTool-PSRHsd85.d.cts → CustomTool-C-IUByoU.d.cts} +1 -1
- package/dist/{CustomTool-BFkwL1aY.d.mts → CustomTool-CChQSp44.d.mts} +1 -1
- package/dist/{CustomTool-Bkk0QYzw.cjs → CustomTool-D3-NreIm.cjs} +81 -81
- package/dist/{CustomTool-IIUhFtP8.mjs → CustomTool-D5s-aADw.mjs} +76 -76
- package/dist/{FileToolModifier.utils.neutral-B7P7wn-b.mjs → FileToolModifier.utils.neutral-BpSceNK8.mjs} +1 -7
- package/dist/{FileToolModifier.utils.neutral-Dfwqgimk.cjs → FileToolModifier.utils.neutral-DSBQs9-i.cjs} +2 -8
- package/dist/{Telemetry-Dm-0sewu.cjs → Telemetry-BQ_pl5AK.cjs} +34 -9
- package/dist/{Telemetry-kgWlkavX.mjs → Telemetry-DQax33Gh.mjs} +34 -9
- package/dist/{composio-Dzlk0Wj4.d.mts → composio-BlASKqjQ.d.mts} +216 -237
- package/dist/{composio-BnLWW0B6.d.cts → composio-pcA13w87.d.cts} +216 -237
- package/dist/{customTool.types-oV5boR1w.d.mts → customTool.types-DLIORcYN.d.mts} +195 -138
- package/dist/{customTool.types-BVgnEbR2.d.cts → customTool.types-QtkAZQma.d.cts} +195 -138
- package/dist/experimental/index.cjs +1 -1
- package/dist/experimental/index.d.cts +2 -2
- package/dist/experimental/index.d.mts +3 -3
- package/dist/experimental/index.mjs +1 -1
- package/dist/index.cjs +623 -654
- package/dist/index.d.cts +415 -18
- package/dist/index.d.mts +415 -18
- package/dist/index.mjs +617 -652
- package/dist/models/Files.node.cjs +1 -1
- package/dist/models/Files.node.mjs +1 -1
- package/dist/{types-4vkdo_RG.d.cts → types-DRG5qLxI.d.cts} +2 -2
- package/dist/{types-AcoPzTnm.d.mts → types-J2KCXP8R.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +4 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +4 -4
- package/dist/utils/modifiers/FileToolModifier.node.cjs +38 -21
- package/dist/utils/modifiers/FileToolModifier.node.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +38 -21
- package/dist/utils/modifiers/FileToolModifier.workerd.cjs +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/package.json +12 -3
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
|
|
4
|
-
import { t as telemetry } from "./Telemetry-
|
|
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-
|
|
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,465 +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
|
-
const CreateConnectedAccountParamsSchema = z$1.object({
|
|
1092
|
-
authConfig: z$1.object({ id: z$1.string() }),
|
|
1093
|
-
connection: z$1.object({
|
|
1094
|
-
data: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1095
|
-
callbackUrl: z$1.string().optional(),
|
|
1096
|
-
userId: z$1.string().optional()
|
|
1097
|
-
})
|
|
1098
|
-
});
|
|
1099
|
-
const DefaultCreateConnectedAccountParamsSchema = z$1.object({
|
|
1100
|
-
auth_config: z$1.object({ id: z$1.string() }),
|
|
1101
|
-
connection: z$1.object({
|
|
1102
|
-
state: ConnectionDataSchema.optional(),
|
|
1103
|
-
data: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1104
|
-
callback_url: z$1.string().optional(),
|
|
1105
|
-
user_id: z$1.string().optional(),
|
|
1106
|
-
alias: z$1.string().optional()
|
|
1107
|
-
})
|
|
1108
|
-
});
|
|
1109
|
-
const CreateConnectedAccountOptionsSchema = z$1.object({
|
|
1110
|
-
allowMultiple: z$1.boolean().optional(),
|
|
1111
|
-
callbackUrl: z$1.string().optional(),
|
|
1112
|
-
config: ConnectionDataSchema.optional(),
|
|
1113
|
-
alias: z$1.string().optional()
|
|
1114
|
-
});
|
|
1115
|
-
/**
|
|
1116
|
-
* Connected Account create response
|
|
1117
|
-
*/
|
|
1118
|
-
const CreateConnectedAccountResponseSchema = z$1.object({
|
|
1119
|
-
id: z$1.string(),
|
|
1120
|
-
status: ConnectedAccountStatusSchema,
|
|
1121
|
-
redirectUrl: z$1.string().nullable()
|
|
1122
|
-
});
|
|
1123
|
-
const ConnectedAccountAuthConfigSchema = z$1.object({
|
|
1124
|
-
id: z$1.string(),
|
|
1125
|
-
authScheme: AuthSchemeEnum.optional(),
|
|
1126
|
-
isComposioManaged: z$1.boolean(),
|
|
1127
|
-
isDisabled: z$1.boolean()
|
|
1128
|
-
});
|
|
1129
|
-
const ConnectedAccountRetrieveResponseSchema = z$1.object({
|
|
1130
|
-
id: z$1.string(),
|
|
1131
|
-
authConfig: ConnectedAccountAuthConfigSchema,
|
|
1132
|
-
wordId: z$1.string().nullable().optional(),
|
|
1133
|
-
alias: z$1.string().nullable().optional(),
|
|
1134
|
-
data: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1135
|
-
params: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1136
|
-
status: ConnectedAccountStatusSchema,
|
|
1137
|
-
statusReason: z$1.string().nullable(),
|
|
1138
|
-
toolkit: z$1.object({ slug: z$1.string() }),
|
|
1139
|
-
state: ConnectionDataSchema.optional(),
|
|
1140
|
-
testRequestEndpoint: z$1.string().optional(),
|
|
1141
|
-
isDisabled: z$1.boolean(),
|
|
1142
|
-
createdAt: z$1.string(),
|
|
1143
|
-
updatedAt: z$1.string(),
|
|
1144
|
-
accountType: ConnectedAccountTypeSchema.optional(),
|
|
1145
|
-
aclConfigForShared: ConnectedAccountAclConfigResponseSchema.optional()
|
|
1146
|
-
});
|
|
1147
|
-
const ConnectedAccountListParamsSchema = z$1.object({
|
|
1148
|
-
authConfigIds: z$1.array(z$1.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
|
|
1149
|
-
cursor: z$1.string().nullish().describe("The cursor to paginate through the connected accounts"),
|
|
1150
|
-
limit: z$1.number().nullable().optional().describe("The limit of the connected accounts to return"),
|
|
1151
|
-
orderBy: z$1.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
|
|
1152
|
-
statuses: z$1.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
|
|
1153
|
-
toolkitSlugs: z$1.array(z$1.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
|
|
1154
|
-
userIds: z$1.array(z$1.string()).nullable().optional().describe("The user ids of the connected accounts")
|
|
1155
|
-
});
|
|
1156
|
-
const ConnectedAccountListResponseSchema = z$1.object({
|
|
1157
|
-
items: z$1.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
|
|
1158
|
-
nextCursor: z$1.string().nullish().describe("The next cursor to paginate through the connected accounts"),
|
|
1159
|
-
totalPages: z$1.number().describe("The total number of pages of connected accounts")
|
|
1160
|
-
});
|
|
1161
|
-
const CreateConnectedAccountLinkOptionsSchema = z$1.object({
|
|
1162
|
-
callbackUrl: z$1.string().optional(),
|
|
1163
|
-
alias: z$1.string().optional(),
|
|
1164
|
-
allowMultiple: z$1.boolean().optional(),
|
|
1165
|
-
accountType: ConnectedAccountTypeSchema.optional(),
|
|
1166
|
-
aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
|
|
1167
|
-
});
|
|
1168
|
-
const CreateConnectedAccountLinkResponseSchema = z$1.object({ redirectUrl: z$1.string() });
|
|
1169
|
-
const ConnectedAccountRefreshOptionsSchema = z$1.object({
|
|
1170
|
-
redirectUrl: z$1.string().optional(),
|
|
1171
|
-
validateCredentials: z$1.boolean().optional()
|
|
1172
|
-
});
|
|
1173
|
-
const UpdateConnectedAccountParamsSchema = z$1.object({ enabled: z$1.boolean() });
|
|
1174
|
-
/**
|
|
1175
|
-
* Params for `composio.connectedAccounts.updateAcl()`. Mirrors the inner
|
|
1176
|
-
* shape of the wire's `acl_config_for_shared` block — the SDK adds the
|
|
1177
|
-
* outer nesting at the boundary, so callers pass the three fields flat.
|
|
1178
|
-
*
|
|
1179
|
-
* PATCH-style semantics — omit a field to leave it unchanged; pass an
|
|
1180
|
-
* empty array to clear an allow/deny list. Raises
|
|
1181
|
-
* `ComposioAclOnlyForSharedError` on a PRIVATE connection.
|
|
1182
|
-
*
|
|
1183
|
-
* Each field is optional, but at least one must be provided — passing an
|
|
1184
|
-
* empty object is rejected as a no-op.
|
|
1185
|
-
*/
|
|
1186
|
-
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" });
|
|
1187
|
-
|
|
1188
|
-
//#endregion
|
|
1189
|
-
//#region src/utils/transform.ts
|
|
1190
|
-
function transform(raw) {
|
|
1191
|
-
return { with(schema) {
|
|
1192
|
-
return { using(transformer, options) {
|
|
1193
|
-
const transformed = transformer(raw);
|
|
1194
|
-
const result = schema.safeParse(transformed);
|
|
1195
|
-
if (!result.success) {
|
|
1196
|
-
const label = options?.label ? ` for ${options.label}` : "";
|
|
1197
|
-
const issues = result.error.issues.map((issue) => ` - ${issue.path.join(".") || "parameter"}: ${issue.message}`).join("\n");
|
|
1198
|
-
logger_default.warn(`Transform validation failed${label}:\n${issues}`);
|
|
1199
|
-
return transformed;
|
|
1200
|
-
}
|
|
1201
|
-
return result.data;
|
|
1202
|
-
} };
|
|
1203
|
-
} };
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
//#endregion
|
|
1207
|
-
//#region src/utils/transformers/connectedAccounts.ts
|
|
1208
|
-
/**
|
|
1209
|
-
* Transforms the raw connected account response from the Composio API to the SDK format.
|
|
1210
|
-
*
|
|
1211
|
-
* This method converts property names from snake_case to camelCase and reorganizes
|
|
1212
|
-
* the data structure to match the SDK's standardized format.
|
|
1213
|
-
*
|
|
1214
|
-
* @param {RawConnectedAccountListResponse['items'][0]|RawConnectedAccountRetrieveResponse} response - The raw API response to transform
|
|
1215
|
-
* @returns {Promise<ConnectedAccountRetrieveResponse>} The transformed response
|
|
1216
|
-
* @throws {ZodError} If the response fails validation against the expected schema
|
|
1217
|
-
*
|
|
1218
|
-
* @private
|
|
1219
|
-
*/
|
|
1220
|
-
function transformConnectedAccountResponse(response) {
|
|
1221
|
-
const responseWithLabels = response;
|
|
1222
|
-
const parseState = (state) => {
|
|
1223
|
-
try {
|
|
1224
|
-
return state ? ConnectionDataSchema.parse(state) : void 0;
|
|
1225
|
-
} catch (error) {
|
|
1226
|
-
logger_default.warn("Unsupported auth scheme in connected account state, ignoring state field", { error });
|
|
1227
|
-
return;
|
|
1228
|
-
}
|
|
1229
|
-
};
|
|
1230
|
-
return transform(response).with(ConnectedAccountRetrieveResponseSchema).using((response$1) => ({
|
|
1231
|
-
...response$1,
|
|
1232
|
-
authConfig: {
|
|
1233
|
-
...response$1.auth_config,
|
|
1234
|
-
id: response$1.auth_config.id,
|
|
1235
|
-
authScheme: response$1.auth_config.auth_scheme,
|
|
1236
|
-
isComposioManaged: response$1.auth_config.is_composio_managed,
|
|
1237
|
-
isDisabled: response$1.auth_config.is_disabled
|
|
1238
|
-
},
|
|
1239
|
-
wordId: responseWithLabels.word_id ?? null,
|
|
1240
|
-
alias: responseWithLabels.alias ?? null,
|
|
1241
|
-
data: response$1.data ?? void 0,
|
|
1242
|
-
state: parseState(response$1.state),
|
|
1243
|
-
status: response$1.status,
|
|
1244
|
-
statusReason: response$1.status_reason,
|
|
1245
|
-
isDisabled: response$1.is_disabled,
|
|
1246
|
-
createdAt: response$1.created_at,
|
|
1247
|
-
updatedAt: response$1.updated_at,
|
|
1248
|
-
testRequestEndpoint: response$1.test_request_endpoint,
|
|
1249
|
-
accountType: responseWithLabels.account_type,
|
|
1250
|
-
aclConfigForShared: responseWithLabels.acl_config_for_shared ? {
|
|
1251
|
-
allowAllUsers: responseWithLabels.acl_config_for_shared.allow_all_users,
|
|
1252
|
-
allowedUserIds: responseWithLabels.acl_config_for_shared.allowed_user_ids,
|
|
1253
|
-
notAllowedUserIds: responseWithLabels.acl_config_for_shared.not_allowed_user_ids
|
|
1254
|
-
} : void 0
|
|
1255
|
-
}));
|
|
1256
|
-
}
|
|
1257
|
-
/**
|
|
1258
|
-
* Transforms the raw connected account list response from the Composio API to the SDK format.
|
|
1259
|
-
*
|
|
1260
|
-
* This method converts property names from snake_case to camelCase and reorganizes
|
|
1261
|
-
* the data structure to match the SDK's standardized format.
|
|
1262
|
-
*
|
|
1263
|
-
* @param {RawConnectedAccountListResponse} response - The raw API response to transform
|
|
1264
|
-
* @returns {ConnectedAccountListResponse} The transformed response
|
|
1265
|
-
* @throws {ZodError} If the response fails validation against the expected schema
|
|
1266
|
-
*
|
|
1267
|
-
* @private
|
|
1268
|
-
*/
|
|
1269
|
-
function transformConnectedAccountListResponse(response) {
|
|
1270
|
-
return transform(response).with(ConnectedAccountListResponseSchema).using((response$1) => ({
|
|
1271
|
-
items: response$1.items.map(transformConnectedAccountResponse),
|
|
1272
|
-
nextCursor: response$1.next_cursor ?? null,
|
|
1273
|
-
totalPages: response$1.total_pages
|
|
1274
|
-
}));
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
//#endregion
|
|
1278
|
-
//#region src/models/CustomTools.ts
|
|
1279
|
-
var CustomTools = class {
|
|
1280
|
-
client;
|
|
1281
|
-
customToolsRegistry;
|
|
1282
|
-
constructor(client) {
|
|
1283
|
-
if (!client) throw new ComposioError("ComposioClient is required");
|
|
1284
|
-
this.client = client;
|
|
1285
|
-
this.customToolsRegistry = /* @__PURE__ */ new Map();
|
|
1286
|
-
telemetry.instrument(this, "CustomTools");
|
|
1287
|
-
}
|
|
1288
|
-
/**
|
|
1289
|
-
* Create a custom tool and registers it in the registry.
|
|
1290
|
-
* This is just an in memory registry and is not persisted.
|
|
1291
|
-
* @param {CustomToolOptions} toolOptions CustomToolOptions
|
|
1292
|
-
* @returns {Tool} The tool created
|
|
1293
|
-
*
|
|
1294
|
-
* @example
|
|
1295
|
-
* ```typescript
|
|
1296
|
-
* // Create a custom tool with input parameters
|
|
1297
|
-
* const customTool = await composio.customTools.createTool({
|
|
1298
|
-
* name: 'My Custom Tool',
|
|
1299
|
-
* description: 'A tool that performs a custom operation',
|
|
1300
|
-
* slug: 'MY_CUSTOM_TOOL',
|
|
1301
|
-
* inputParams: z.object({
|
|
1302
|
-
* query: z.string().describe('The search query'),
|
|
1303
|
-
* limit: z.number().optional().describe('Maximum number of results')
|
|
1304
|
-
* }),
|
|
1305
|
-
* execute: async (input, connectionConfig, executeToolRequest) => {
|
|
1306
|
-
* // Custom implementation logic
|
|
1307
|
-
* return {
|
|
1308
|
-
* data: { results: ['result1', 'result2'] }
|
|
1309
|
-
* };
|
|
1310
|
-
* }
|
|
1311
|
-
* });
|
|
1312
|
-
* ```
|
|
1313
|
-
*/
|
|
1314
|
-
async createTool(toolOptions) {
|
|
1315
|
-
const { slug, execute, inputParams, name, description } = toolOptions;
|
|
1316
|
-
if (!slug || !execute || !inputParams || !name) throw new Error("Invalid tool options");
|
|
1317
|
-
const paramsSchemaJson = zodToJsonSchema.default(inputParams, { name: "input" }).definitions.input;
|
|
1318
|
-
const toolSchema = {
|
|
1319
|
-
name,
|
|
1320
|
-
slug,
|
|
1321
|
-
description,
|
|
1322
|
-
inputParameters: {
|
|
1323
|
-
title: name,
|
|
1324
|
-
type: "object",
|
|
1325
|
-
description,
|
|
1326
|
-
properties: paramsSchemaJson.properties,
|
|
1327
|
-
required: paramsSchemaJson.required
|
|
1328
|
-
},
|
|
1329
|
-
outputParameters: {
|
|
1330
|
-
type: "object",
|
|
1331
|
-
title: `Response for ${name}`,
|
|
1332
|
-
properties: {}
|
|
1333
|
-
},
|
|
1334
|
-
tags: [],
|
|
1335
|
-
toolkit: {
|
|
1336
|
-
name: "custom",
|
|
1337
|
-
slug: "custom"
|
|
1338
|
-
}
|
|
1339
|
-
};
|
|
1340
|
-
this.customToolsRegistry.set(slug.toLowerCase(), {
|
|
1341
|
-
options: toolOptions,
|
|
1342
|
-
schema: toolSchema
|
|
1343
|
-
});
|
|
1344
|
-
return toolSchema;
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* Get all the custom tools from the registry.
|
|
1348
|
-
* @param {string[]} param0.toolSlugs The slugs of the tools to get
|
|
1349
|
-
* @returns {ToolList} The list of tools
|
|
1350
|
-
*
|
|
1351
|
-
* @example
|
|
1352
|
-
* ```typescript
|
|
1353
|
-
* // Get all custom tools
|
|
1354
|
-
* const allTools = await composio.customTools.getCustomTools({});
|
|
1355
|
-
*
|
|
1356
|
-
* // Get specific custom tools by slug
|
|
1357
|
-
* const specificTools = await composio.customTools.getCustomTools({
|
|
1358
|
-
* toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL']
|
|
1359
|
-
* });
|
|
1360
|
-
* ```
|
|
1361
|
-
*/
|
|
1362
|
-
async getCustomTools({ toolSlugs }) {
|
|
1363
|
-
const tools = [];
|
|
1364
|
-
if (toolSlugs) for (const slug of toolSlugs) {
|
|
1365
|
-
const tool = this.customToolsRegistry.get(slug.toLowerCase());
|
|
1366
|
-
if (tool) tools.push(tool.schema);
|
|
1367
|
-
}
|
|
1368
|
-
else return Array.from(this.customToolsRegistry.values()).map((tool) => tool.schema);
|
|
1369
|
-
return tools;
|
|
1370
|
-
}
|
|
1371
|
-
/**
|
|
1372
|
-
* Get a custom tool by slug from the registry.
|
|
1373
|
-
* @param {string} slug The slug of the tool to get
|
|
1374
|
-
* @returns {Tool} The tool
|
|
1375
|
-
*
|
|
1376
|
-
* @example
|
|
1377
|
-
* ```typescript
|
|
1378
|
-
* // Get a specific custom tool by its slug
|
|
1379
|
-
* const myTool = await composio.customTools.getCustomToolBySlug('MY_CUSTOM_TOOL');
|
|
1380
|
-
* if (myTool) {
|
|
1381
|
-
* console.log(`Found tool: ${myTool.name}`);
|
|
1382
|
-
* } else {
|
|
1383
|
-
* console.log('Tool not found');
|
|
1384
|
-
* }
|
|
1385
|
-
* ```
|
|
1386
|
-
*/
|
|
1387
|
-
async getCustomToolBySlug(slug) {
|
|
1388
|
-
try {
|
|
1389
|
-
return this.customToolsRegistry.get(slug.toLowerCase())?.schema;
|
|
1390
|
-
} catch (error) {
|
|
1391
|
-
logger_default.error(`Error getting custom tool: ${error}`);
|
|
1392
|
-
return;
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
/**
|
|
1396
|
-
* Get the connected account for the user and toolkit.
|
|
1397
|
-
* @param {string} toolkitSlug The slug of the toolkit
|
|
1398
|
-
* @param {ExecuteMetadata} metadata The metadata of the execution
|
|
1399
|
-
* @returns {ConnectedAccount} The connected account
|
|
1400
|
-
*/
|
|
1401
|
-
async getConnectedAccountForToolkit(toolkitSlug, userId, connectedAccountId) {
|
|
1402
|
-
try {
|
|
1403
|
-
await this.client.toolkits.retrieve(toolkitSlug);
|
|
1404
|
-
if ((await this.client.toolkits.retrieve(toolkitSlug)).auth_config_details?.some((details) => details.mode === AuthSchemeTypes.NO_AUTH)) return null;
|
|
1405
|
-
} catch (error) {
|
|
1406
|
-
throw new ComposioToolNotFoundError(`Toolkit with slug ${toolkitSlug} not found`, { cause: error });
|
|
1407
|
-
}
|
|
1408
|
-
const connectedAccounts = await this.client.connectedAccounts.list({
|
|
1409
|
-
toolkit_slugs: [toolkitSlug],
|
|
1410
|
-
user_ids: [userId]
|
|
1411
|
-
});
|
|
1412
|
-
if (!connectedAccounts.items.length) throw new ComposioConnectedAccountNotFoundError(`No connected accounts found for toolkit ${toolkitSlug}`);
|
|
1413
|
-
const connectedAccount = connectedAccountId ? connectedAccounts.items.find((item) => item.id === connectedAccountId) : connectedAccounts.items[0];
|
|
1414
|
-
if (!connectedAccount) throw new ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${userId}`);
|
|
1415
|
-
return transformConnectedAccountResponse(connectedAccount);
|
|
1416
|
-
}
|
|
1417
|
-
/**
|
|
1418
|
-
* Execute a custom tool
|
|
1419
|
-
*
|
|
1420
|
-
* @description If a toolkit is used, the connected account id is used to execute the tool.
|
|
1421
|
-
* If a connected account id is provided, it is used to execute the tool.
|
|
1422
|
-
* If a connected account id is not provided, the first connected account for the toolkit is used.
|
|
1423
|
-
*
|
|
1424
|
-
* @param {slug} slug The slug of the tool to execute
|
|
1425
|
-
* @param {Record<string, unknown>} inputParams The input parameters for the tool
|
|
1426
|
-
* @param {ExecuteMetadata} metadata The metadata of the execution
|
|
1427
|
-
* @returns {Promise<ToolExecuteResponse>} The response from the tool
|
|
1428
|
-
*/
|
|
1429
|
-
async executeCustomTool(slug, body) {
|
|
1430
|
-
const tool = this.customToolsRegistry.get(slug.toLowerCase());
|
|
1431
|
-
if (!tool) throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
|
|
1432
|
-
let connectionConfig = null;
|
|
1433
|
-
const { toolkitSlug, execute, inputParams } = tool.options;
|
|
1434
|
-
let connectedAccountId = body.connectedAccountId;
|
|
1435
|
-
if (toolkitSlug && toolkitSlug !== "custom" && body.userId) {
|
|
1436
|
-
const connectedAccount = await this.getConnectedAccountForToolkit(toolkitSlug, body.userId, body.connectedAccountId);
|
|
1437
|
-
logger_default.debug(`[CustomTool] Connected account for ${toolkitSlug} found for user ${body.userId}`, JSON.stringify(connectedAccount, null, 2));
|
|
1438
|
-
if (!connectedAccount) throw new ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${body.userId}`, { meta: {
|
|
1439
|
-
toolkitSlug,
|
|
1440
|
-
userId: body.userId
|
|
1441
|
-
} });
|
|
1442
|
-
connectionConfig = connectedAccount.state ?? null;
|
|
1443
|
-
connectedAccountId = connectedAccount.id;
|
|
1444
|
-
}
|
|
1445
|
-
if (typeof execute !== "function") throw new ComposioInvalidExecuteFunctionError("Invalid execute function", { meta: { toolSlug: slug } });
|
|
1446
|
-
const executeToolRequest = async (data) => {
|
|
1447
|
-
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"] });
|
|
1448
|
-
const parameters = data.parameters?.map((param) => ({
|
|
1449
|
-
name: param.name,
|
|
1450
|
-
type: param.in,
|
|
1451
|
-
value: param.value.toString()
|
|
1452
|
-
}));
|
|
1453
|
-
return {
|
|
1454
|
-
data: (await this.client.tools.proxy({
|
|
1455
|
-
endpoint: data.endpoint,
|
|
1456
|
-
method: data.method,
|
|
1457
|
-
parameters,
|
|
1458
|
-
body: data.body,
|
|
1459
|
-
connected_account_id: connectedAccountId,
|
|
1460
|
-
custom_connection_data: data.customConnectionData
|
|
1461
|
-
})).data,
|
|
1462
|
-
error: null,
|
|
1463
|
-
successful: true,
|
|
1464
|
-
logId: void 0,
|
|
1465
|
-
sessionInfo: void 0
|
|
1466
|
-
};
|
|
1467
|
-
};
|
|
1468
|
-
const parsedInput = inputParams.safeParse(body.arguments);
|
|
1469
|
-
if (!parsedInput.success) throw new ValidationError("Invalid input parameters", { cause: parsedInput.error });
|
|
1470
|
-
return execute(parsedInput.data, connectionConfig, executeToolRequest);
|
|
1471
|
-
}
|
|
1472
|
-
};
|
|
1473
|
-
|
|
1474
1014
|
//#endregion
|
|
1475
1015
|
//#region src/utils/toolkitVersion.ts
|
|
1476
1016
|
/**
|
|
@@ -1566,12 +1106,27 @@ function resolveEffectiveUploadAllowlist(userDirs) {
|
|
|
1566
1106
|
//#region src/models/Tools.ts
|
|
1567
1107
|
const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
|
|
1568
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
|
+
/**
|
|
1569
1125
|
* This class is used to manage tools in the Composio SDK.
|
|
1570
1126
|
* It provides methods to list, get, and execute tools.
|
|
1571
1127
|
*/
|
|
1572
1128
|
var Tools = class {
|
|
1573
1129
|
client;
|
|
1574
|
-
customTools;
|
|
1575
1130
|
provider;
|
|
1576
1131
|
autoUploadDownloadFiles;
|
|
1577
1132
|
toolkitVersions;
|
|
@@ -1586,7 +1141,6 @@ var Tools = class {
|
|
|
1586
1141
|
if (!client) throw new Error("ComposioClient is required");
|
|
1587
1142
|
if (!config?.provider) throw new ComposioProviderNotDefinedError("Provider not passed into Tools instance");
|
|
1588
1143
|
this.client = client;
|
|
1589
|
-
this.customTools = new CustomTools(client);
|
|
1590
1144
|
this.provider = config.provider;
|
|
1591
1145
|
this.autoUploadDownloadFiles = config?.dangerouslyAllowAutoUploadDownloadFiles === true;
|
|
1592
1146
|
this.toolkitVersions = config?.toolkitVersions ?? CONFIG_DEFAULTS.toolkitVersions;
|
|
@@ -1616,8 +1170,8 @@ var Tools = class {
|
|
|
1616
1170
|
transformToolCases(tool) {
|
|
1617
1171
|
return ToolSchema.parse({
|
|
1618
1172
|
...tool,
|
|
1619
|
-
inputParameters: tool.input_parameters,
|
|
1620
|
-
outputParameters: tool.output_parameters,
|
|
1173
|
+
inputParameters: normalizeRawToolParameters(tool.input_parameters),
|
|
1174
|
+
outputParameters: normalizeRawToolParameters(tool.output_parameters),
|
|
1621
1175
|
availableVersions: tool.available_versions,
|
|
1622
1176
|
isDeprecated: tool.deprecated?.is_deprecated ?? false,
|
|
1623
1177
|
isNoAuth: tool.no_auth
|
|
@@ -1720,10 +1274,12 @@ var Tools = class {
|
|
|
1720
1274
|
return modifiedResult;
|
|
1721
1275
|
}
|
|
1722
1276
|
/**
|
|
1723
|
-
* Lists
|
|
1277
|
+
* Lists Composio API tools available to the SDK.
|
|
1724
1278
|
*
|
|
1725
|
-
* This method fetches tools from the
|
|
1726
|
-
*
|
|
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()`.
|
|
1727
1283
|
* It provides access to the underlying tool data without provider-specific wrapping.
|
|
1728
1284
|
*
|
|
1729
1285
|
* @param {ToolListParams} query - Query parameters to filter the tools (required)
|
|
@@ -1800,8 +1356,7 @@ var Tools = class {
|
|
|
1800
1356
|
const tools = await this.client.tools.list(filters);
|
|
1801
1357
|
if (!tools) return [];
|
|
1802
1358
|
const caseTransformedTools = tools.items.map((tool) => this.transformToolCases(tool));
|
|
1803
|
-
|
|
1804
|
-
let modifiedTools = await this.applyDefaultSchemaModifiers([...caseTransformedTools, ...customTools]);
|
|
1359
|
+
let modifiedTools = await this.applyDefaultSchemaModifiers(caseTransformedTools);
|
|
1805
1360
|
if (options?.modifySchema) {
|
|
1806
1361
|
const modifier = options.modifySchema;
|
|
1807
1362
|
if (typeof modifier === "function") {
|
|
@@ -1862,6 +1417,9 @@ var Tools = class {
|
|
|
1862
1417
|
* This method fetches a single tool in raw format without provider-specific wrapping,
|
|
1863
1418
|
* providing direct access to the tool's schema and metadata. Tool versions are controlled
|
|
1864
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()`.
|
|
1865
1423
|
*
|
|
1866
1424
|
* @param {string} slug - The unique identifier of the tool (e.g., 'GITHUB_GET_REPOS')
|
|
1867
1425
|
* @param {GetRawComposioToolBySlugOptions} [options] - Optional configuration for tool retrieval
|
|
@@ -1891,9 +1449,6 @@ var Tools = class {
|
|
|
1891
1449
|
* }
|
|
1892
1450
|
* );
|
|
1893
1451
|
*
|
|
1894
|
-
* // Get a custom tool (will check custom tools first)
|
|
1895
|
-
* const customTool = await composio.tools.getRawComposioToolBySlug('MY_CUSTOM_TOOL');
|
|
1896
|
-
*
|
|
1897
1452
|
* // Access tool properties
|
|
1898
1453
|
* const githubTool = await composio.tools.getRawComposioToolBySlug('GITHUB_CREATE_ISSUE');
|
|
1899
1454
|
* console.log({
|
|
@@ -1907,11 +1462,6 @@ var Tools = class {
|
|
|
1907
1462
|
* ```
|
|
1908
1463
|
*/
|
|
1909
1464
|
async getRawComposioToolBySlug(slug, options) {
|
|
1910
|
-
const customTool = await this.customTools.getCustomToolBySlug(slug);
|
|
1911
|
-
if (customTool) {
|
|
1912
|
-
logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
|
|
1913
|
-
return customTool;
|
|
1914
|
-
} else logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
|
|
1915
1465
|
let tool;
|
|
1916
1466
|
try {
|
|
1917
1467
|
const retrieveParams = options?.version ? { version: options.version } : { toolkit_versions: this.toolkitVersions };
|
|
@@ -2063,8 +1613,7 @@ var Tools = class {
|
|
|
2063
1613
|
/**
|
|
2064
1614
|
* Executes a given tool with the provided parameters.
|
|
2065
1615
|
*
|
|
2066
|
-
* This method calls the Composio API
|
|
2067
|
-
* 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.
|
|
2068
1617
|
*
|
|
2069
1618
|
* **Version Control:**
|
|
2070
1619
|
* By default, manual tool execution requires a specific toolkit version. If the version resolves to "latest",
|
|
@@ -2081,7 +1630,6 @@ var Tools = class {
|
|
|
2081
1630
|
* @param {ExecuteToolModifiers} [modifiers] - Optional modifiers to transform the request or response
|
|
2082
1631
|
* @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
|
|
2083
1632
|
*
|
|
2084
|
-
* @throws {ComposioCustomToolsNotInitializedError} If the CustomTools instance is not initialized
|
|
2085
1633
|
* @throws {ComposioConnectedAccountNotFoundError} If the connected account is not found
|
|
2086
1634
|
* @throws {ComposioToolNotFoundError} If the tool with the given slug is not found
|
|
2087
1635
|
* @throws {ComposioToolVersionRequiredError} If version resolves to "latest" and dangerouslySkipVersionCheck is not true
|
|
@@ -2134,18 +1682,16 @@ var Tools = class {
|
|
|
2134
1682
|
* ```
|
|
2135
1683
|
*/
|
|
2136
1684
|
async execute(slug, body, modifiers) {
|
|
2137
|
-
if (!this.customTools) throw new ComposioCustomToolsNotInitializedError("CustomTools not initialized. Make sure Tools class is properly constructed.");
|
|
2138
1685
|
const executeParams = ToolExecuteParamsSchema.safeParse(body);
|
|
2139
1686
|
if (!executeParams.success) throw new ValidationError("Invalid tool execute parameters", { cause: executeParams.error });
|
|
2140
|
-
const
|
|
2141
|
-
const tool = customTool ?? await this.getRawComposioToolBySlug(slug, { version: body.version });
|
|
1687
|
+
const tool = await this.getRawComposioToolBySlug(slug, { version: body.version });
|
|
2142
1688
|
const toolkitSlug = tool.toolkit?.slug ?? "unknown";
|
|
2143
1689
|
const params = await this.applyBeforeExecuteModifiers(tool, {
|
|
2144
1690
|
toolSlug: slug,
|
|
2145
1691
|
toolkitSlug,
|
|
2146
1692
|
params: executeParams.data
|
|
2147
1693
|
}, modifiers);
|
|
2148
|
-
let result =
|
|
1694
|
+
let result = await this.executeComposioTool(tool, params);
|
|
2149
1695
|
result = await this.applyAfterExecuteModifiers(tool, {
|
|
2150
1696
|
toolSlug: slug,
|
|
2151
1697
|
toolkitSlug,
|
|
@@ -2279,54 +1825,6 @@ var Tools = class {
|
|
|
2279
1825
|
custom_connection_data: toolProxyParams.data.customConnectionData
|
|
2280
1826
|
});
|
|
2281
1827
|
}
|
|
2282
|
-
/**
|
|
2283
|
-
* Creates a custom tool that can be used within the Composio SDK.
|
|
2284
|
-
*
|
|
2285
|
-
* Custom tools allow you to extend the functionality of Composio with your own implementations
|
|
2286
|
-
* while keeping a consistent interface for both built-in and custom tools.
|
|
2287
|
-
*
|
|
2288
|
-
* @param {CustomToolOptions} body - The configuration for the custom tool
|
|
2289
|
-
* @returns {Promise<Tool>} The created custom tool
|
|
2290
|
-
*
|
|
2291
|
-
* @example
|
|
2292
|
-
* ```typescript
|
|
2293
|
-
* // creating a custom tool with a toolkit
|
|
2294
|
-
* await composio.tools.createCustomTool({
|
|
2295
|
-
* name: 'My Custom Tool',
|
|
2296
|
-
* description: 'A custom tool that does something specific',
|
|
2297
|
-
* slug: 'MY_CUSTOM_TOOL',
|
|
2298
|
-
* userId: 'default',
|
|
2299
|
-
* connectedAccountId: '123',
|
|
2300
|
-
* toolkitSlug: 'github',
|
|
2301
|
-
* inputParameters: z.object({
|
|
2302
|
-
* param1: z.string().describe('First parameter'),
|
|
2303
|
-
* }),
|
|
2304
|
-
* execute: async (input, connectionConfig, executeToolRequest) => {
|
|
2305
|
-
* // Custom logic here
|
|
2306
|
-
* return { data: { result: 'Success!' } };
|
|
2307
|
-
* }
|
|
2308
|
-
* });
|
|
2309
|
-
* ```
|
|
2310
|
-
*
|
|
2311
|
-
* @example
|
|
2312
|
-
* ```typescript
|
|
2313
|
-
* // creating a custom tool without a toolkit
|
|
2314
|
-
* await composio.tools.createCustomTool({
|
|
2315
|
-
* name: 'My Custom Tool',
|
|
2316
|
-
* description: 'A custom tool that does something specific',
|
|
2317
|
-
* slug: 'MY_CUSTOM_TOOL',
|
|
2318
|
-
* inputParameters: z.object({
|
|
2319
|
-
* param1: z.string().describe('First parameter'),
|
|
2320
|
-
* }),
|
|
2321
|
-
* execute: async (input) => {
|
|
2322
|
-
* // Custom logic here
|
|
2323
|
-
* return { data: { result: 'Success!' } };
|
|
2324
|
-
* }
|
|
2325
|
-
* });
|
|
2326
|
-
*/
|
|
2327
|
-
async createCustomTool(body) {
|
|
2328
|
-
return this.customTools.createTool(body);
|
|
2329
|
-
}
|
|
2330
1828
|
};
|
|
2331
1829
|
|
|
2332
1830
|
//#endregion
|
|
@@ -2425,6 +1923,24 @@ const ToolkitRetrieveCategoriesResponseSchema = z$1.object({
|
|
|
2425
1923
|
});
|
|
2426
1924
|
const ToolkitAuthFieldsResponseSchema = z$1.array(ToolkitAuthFieldSchema.extend({ required: z$1.boolean().optional() }));
|
|
2427
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
|
+
|
|
2428
1944
|
//#endregion
|
|
2429
1945
|
//#region src/utils/transformers/authConfigs.ts
|
|
2430
1946
|
/**
|
|
@@ -2761,6 +2277,275 @@ var AuthConfigs = class {
|
|
|
2761
2277
|
}
|
|
2762
2278
|
};
|
|
2763
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
|
+
|
|
2764
2549
|
//#endregion
|
|
2765
2550
|
//#region src/models/ConnectionRequest.ts
|
|
2766
2551
|
/**
|
|
@@ -2859,22 +2644,28 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
|
|
|
2859
2644
|
}
|
|
2860
2645
|
|
|
2861
2646
|
//#endregion
|
|
2862
|
-
//#region src/models/
|
|
2647
|
+
//#region src/models/Experimental.ts
|
|
2863
2648
|
/**
|
|
2864
|
-
* @fileoverview
|
|
2649
|
+
* @fileoverview The `composio.experimental` namespace. Houses experimental
|
|
2650
|
+
* SDK methods whose shape may change in future releases.
|
|
2865
2651
|
*
|
|
2866
|
-
*
|
|
2867
|
-
*
|
|
2868
|
-
*
|
|
2652
|
+
* For experimental stateless factories (e.g. `experimental_createTool`),
|
|
2653
|
+
* see the top-level `experimental_*` exports from `@composio/core`.
|
|
2654
|
+
* Anything that takes a Composio client and performs I/O belongs here.
|
|
2869
2655
|
*/
|
|
2870
|
-
|
|
2656
|
+
/**
|
|
2657
|
+
* Server-side 400 message the API uses to reject ACL writes against a
|
|
2658
|
+
* PRIVATE connection. Substring-matched in `updateAcl` here, and in the
|
|
2659
|
+
* sibling `connectedAccounts.link()` / `session.authorize()` call sites
|
|
2660
|
+
* — kept as a single constant so a server-side message tweak only
|
|
2661
|
+
* requires one edit.
|
|
2662
|
+
*/
|
|
2663
|
+
const ACL_ONLY_FOR_SHARED_ERROR_FRAGMENT = "acl_config_for_shared is only valid on SHARED";
|
|
2871
2664
|
/**
|
|
2872
2665
|
* Serialise the SDK's `aclConfigForShared` (camelCase) to the wire's
|
|
2873
2666
|
* `acl_config_for_shared` block. Returns `undefined` when the caller
|
|
2874
2667
|
* didn't pass anything (PATCH-style "don't touch ACL"); returns `{}`
|
|
2875
|
-
* when the caller passed an explicit empty object
|
|
2876
|
-
* deny-by-default, but the explicit form preserves the caller's intent
|
|
2877
|
-
* in network traces.
|
|
2668
|
+
* when the caller passed an explicit empty object.
|
|
2878
2669
|
*/
|
|
2879
2670
|
function serializeAclConfigForWire(acl) {
|
|
2880
2671
|
if (acl === void 0) return void 0;
|
|
@@ -2885,6 +2676,110 @@ function serializeAclConfigForWire(acl) {
|
|
|
2885
2676
|
};
|
|
2886
2677
|
}
|
|
2887
2678
|
/**
|
|
2679
|
+
* Serialise the SDK's `experimental` options block (camelCase) to the
|
|
2680
|
+
* wire's `experimental` block (snake_case). Used by both
|
|
2681
|
+
* `connectedAccounts.link()` and `session.authorize()`. Returns
|
|
2682
|
+
* `undefined` when the caller didn't pass the block at all.
|
|
2683
|
+
*/
|
|
2684
|
+
function serializeExperimentalForWire(experimental) {
|
|
2685
|
+
if (experimental === void 0) return void 0;
|
|
2686
|
+
const aclWire = serializeAclConfigForWire(experimental.aclConfigForShared);
|
|
2687
|
+
const wire = {};
|
|
2688
|
+
if (experimental.accountType !== void 0) wire.account_type = experimental.accountType;
|
|
2689
|
+
if (aclWire !== void 0) wire.acl_config_for_shared = aclWire;
|
|
2690
|
+
return wire;
|
|
2691
|
+
}
|
|
2692
|
+
/**
|
|
2693
|
+
* `composio.experimental` namespace. Mirrors the Python SDK's
|
|
2694
|
+
* `composio.experimental` mount, with one method per experimental
|
|
2695
|
+
* surface. **Shape may change in future releases.**
|
|
2696
|
+
*/
|
|
2697
|
+
var Experimental = class {
|
|
2698
|
+
client;
|
|
2699
|
+
constructor(client) {
|
|
2700
|
+
this.client = client;
|
|
2701
|
+
telemetry.instrument(this, "Experimental");
|
|
2702
|
+
}
|
|
2703
|
+
/**
|
|
2704
|
+
* Update the per-user ACL on a SHARED connected account.
|
|
2705
|
+
* **Experimental — shape may change in future releases.**
|
|
2706
|
+
*
|
|
2707
|
+
* Only meaningful for SHARED connections — calling this on a PRIVATE
|
|
2708
|
+
* connection raises `ComposioAclOnlyForSharedError` (400). ACL writes
|
|
2709
|
+
* require the connection's creator or an API key.
|
|
2710
|
+
*
|
|
2711
|
+
* PATCH semantics: omit a field to leave it unchanged; pass an empty
|
|
2712
|
+
* array to clear an allow/deny list. At least one field must be
|
|
2713
|
+
* provided.
|
|
2714
|
+
*
|
|
2715
|
+
* Resolution rule (deny wins):
|
|
2716
|
+
* 1. requesting `userId` in `notAllowedUserIds` → DENY
|
|
2717
|
+
* 2. `allowAllUsers === true` → ALLOW
|
|
2718
|
+
* 3. requesting `userId` in `allowedUserIds` → ALLOW
|
|
2719
|
+
* 4. otherwise → DENY
|
|
2720
|
+
*
|
|
2721
|
+
* @example
|
|
2722
|
+
* ```typescript
|
|
2723
|
+
* import { Composio } from '@composio/core';
|
|
2724
|
+
*
|
|
2725
|
+
* const composio = new Composio({ apiKey: '...' });
|
|
2726
|
+
*
|
|
2727
|
+
* // Allow every userId to use this connection
|
|
2728
|
+
* await composio.experimental.updateAcl('ca_abc', { allowAllUsers: true });
|
|
2729
|
+
*
|
|
2730
|
+
* // Everyone except a specific user
|
|
2731
|
+
* await composio.experimental.updateAcl('ca_abc', {
|
|
2732
|
+
* allowAllUsers: true,
|
|
2733
|
+
* notAllowedUserIds: ['user_bob'],
|
|
2734
|
+
* });
|
|
2735
|
+
*
|
|
2736
|
+
* // Targeted allow
|
|
2737
|
+
* await composio.experimental.updateAcl('ca_abc', {
|
|
2738
|
+
* allowedUserIds: ['user_alice', 'user_bob'],
|
|
2739
|
+
* });
|
|
2740
|
+
*
|
|
2741
|
+
* // Revoke a previously-granted allow list (back to deny-by-default)
|
|
2742
|
+
* await composio.experimental.updateAcl('ca_abc', { allowedUserIds: [] });
|
|
2743
|
+
* ```
|
|
2744
|
+
*
|
|
2745
|
+
* **Empty-array semantics — read carefully.** Passing `[]` for either
|
|
2746
|
+
* list **replaces** the list, it does not extend it:
|
|
2747
|
+
*
|
|
2748
|
+
* - `allowedUserIds: []` → revoke all previously-granted user IDs (state
|
|
2749
|
+
* reverts to deny-by-default unless `allowAllUsers` is true).
|
|
2750
|
+
* - `notAllowedUserIds: []` → **clears the deny list**, which silently
|
|
2751
|
+
* re-grants access to users you previously blocked. Always pair an
|
|
2752
|
+
* empty deny list with a deliberate audit of the allow side.
|
|
2753
|
+
*
|
|
2754
|
+
* @returns The PATCH response (`{ id, status, success }`). To read
|
|
2755
|
+
* the updated ACL block, call
|
|
2756
|
+
* `composio.connectedAccounts.get(nanoid)` after the promise
|
|
2757
|
+
* resolves and inspect `account.experimental?.aclConfigForShared`.
|
|
2758
|
+
*/
|
|
2759
|
+
async updateAcl(nanoid, params) {
|
|
2760
|
+
const parsedParams = UpdateConnectedAccountAclParamsSchema.safeParse(params);
|
|
2761
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse connected account ACL update params", { cause: parsedParams.error });
|
|
2762
|
+
const body = { experimental: { acl_config_for_shared: serializeAclConfigForWire(parsedParams.data) } };
|
|
2763
|
+
try {
|
|
2764
|
+
return await this.client.connectedAccounts.patch(nanoid, body);
|
|
2765
|
+
} catch (error) {
|
|
2766
|
+
if (error instanceof BadRequestError && typeof error.message === "string" && error.message.includes(ACL_ONLY_FOR_SHARED_ERROR_FRAGMENT)) throw new ComposioAclOnlyForSharedError(error.message, { cause: error });
|
|
2767
|
+
throw error;
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
};
|
|
2771
|
+
|
|
2772
|
+
//#endregion
|
|
2773
|
+
//#region src/models/ConnectedAccounts.ts
|
|
2774
|
+
/**
|
|
2775
|
+
* @fileoverview Connected accounts class for Composio SDK, used to manage connected accounts of a user.
|
|
2776
|
+
*
|
|
2777
|
+
* @author Musthaq Ahamad <musthaq@composio.dev>
|
|
2778
|
+
* @date 2025-05-05
|
|
2779
|
+
* @module ConnectedAccounts
|
|
2780
|
+
*/
|
|
2781
|
+
let _legacyInitiateWarningEmitted = false;
|
|
2782
|
+
/**
|
|
2888
2783
|
* ConnectedAccounts class
|
|
2889
2784
|
*
|
|
2890
2785
|
* This class is used to manage connected accounts in the Composio SDK.
|
|
@@ -2932,7 +2827,8 @@ var ConnectedAccounts = class {
|
|
|
2932
2827
|
order_by: parsedQuery.data.orderBy,
|
|
2933
2828
|
statuses: parsedQuery.data.statuses,
|
|
2934
2829
|
toolkit_slugs: parsedQuery.data.toolkitSlugs,
|
|
2935
|
-
user_ids: parsedQuery.data.userIds
|
|
2830
|
+
user_ids: parsedQuery.data.userIds,
|
|
2831
|
+
...parsedQuery.data.accountType !== void 0 && { account_type: parsedQuery.data.accountType }
|
|
2936
2832
|
};
|
|
2937
2833
|
}
|
|
2938
2834
|
return transformConnectedAccountListResponse(await this.client.connectedAccounts.list(rawQuery));
|
|
@@ -3088,20 +2984,19 @@ var ConnectedAccounts = class {
|
|
|
3088
2984
|
if (existing.items.length > 0 && !requestOptions.data.allowMultiple) throw new ComposioMultipleConnectedAccountsError(`Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts.`);
|
|
3089
2985
|
else if (existing.items.length > 0) logger_default.warn(`[Warn:AllowMultiple] Multiple connected accounts found for user ${userId} in auth config ${authConfigId}`);
|
|
3090
2986
|
const opts = requestOptions.data;
|
|
3091
|
-
const
|
|
2987
|
+
const experimentalWire = serializeExperimentalForWire(opts.experimental);
|
|
3092
2988
|
const body = {
|
|
3093
2989
|
auth_config_id: authConfigId,
|
|
3094
2990
|
user_id: userId,
|
|
3095
2991
|
...opts.callbackUrl !== void 0 && { callback_url: opts.callbackUrl },
|
|
3096
2992
|
...opts.alias !== void 0 && { alias: opts.alias },
|
|
3097
|
-
...
|
|
3098
|
-
...aclWire !== void 0 && { acl_config_for_shared: aclWire }
|
|
2993
|
+
...experimentalWire !== void 0 && { experimental: experimentalWire }
|
|
3099
2994
|
};
|
|
3100
2995
|
try {
|
|
3101
2996
|
const response = await this.client.link.create(body);
|
|
3102
2997
|
return createConnectionRequest(this.client, response.connected_account_id, ConnectedAccountStatuses.INITIATED, response.redirect_url);
|
|
3103
2998
|
} catch (error) {
|
|
3104
|
-
if (error instanceof BadRequestError && typeof error.message === "string" && error.message.includes(
|
|
2999
|
+
if (error instanceof BadRequestError && typeof error.message === "string" && error.message.includes(ACL_ONLY_FOR_SHARED_ERROR_FRAGMENT)) throw new ComposioAclOnlyForSharedError(error.message, { cause: error });
|
|
3105
3000
|
throw new ComposioFailedToCreateConnectedAccountLink("Failed to create connected account link", { cause: error });
|
|
3106
3001
|
}
|
|
3107
3002
|
}
|
|
@@ -3260,7 +3155,8 @@ var ConnectedAccounts = class {
|
|
|
3260
3155
|
/**
|
|
3261
3156
|
* Enable or disable a connected account. Accepts `{ enabled: boolean }`.
|
|
3262
3157
|
*
|
|
3263
|
-
* For ACL writes on SHARED connections, see
|
|
3158
|
+
* For ACL writes on SHARED connections, see
|
|
3159
|
+
* `composio.experimental.updateAcl()`.
|
|
3264
3160
|
*
|
|
3265
3161
|
* @param {string} nanoid - The unique identifier of the connected account
|
|
3266
3162
|
* @param {UpdateConnectedAccountParams} params - The update parameters
|
|
@@ -3277,67 +3173,6 @@ var ConnectedAccounts = class {
|
|
|
3277
3173
|
if (!parsedParams.success) throw new ValidationError("Failed to parse connected account update params", { cause: parsedParams.error });
|
|
3278
3174
|
return this.client.connectedAccounts.updateStatus(nanoid, parsedParams.data);
|
|
3279
3175
|
}
|
|
3280
|
-
/**
|
|
3281
|
-
* Update the per-user ACL on a SHARED connected account.
|
|
3282
|
-
*
|
|
3283
|
-
* Only meaningful for SHARED connections — calling this on a PRIVATE
|
|
3284
|
-
* connection raises `ComposioAclOnlyForSharedError` (400). ACL writes
|
|
3285
|
-
* require the connection's creator or an API key; alias edits via
|
|
3286
|
-
* {@link update} are governed separately.
|
|
3287
|
-
*
|
|
3288
|
-
* PATCH semantics: omit a field to leave it unchanged; pass an empty array
|
|
3289
|
-
* to clear an allow/deny list. At least one field must be provided.
|
|
3290
|
-
*
|
|
3291
|
-
* Resolution rule (deny wins):
|
|
3292
|
-
* 1. requesting `userId` in `notAllowedUserIds` → DENY
|
|
3293
|
-
* 2. `allowAllUsers === true` → ALLOW
|
|
3294
|
-
* 3. requesting `userId` in `allowedUserIds` → ALLOW
|
|
3295
|
-
* 4. otherwise → DENY
|
|
3296
|
-
*
|
|
3297
|
-
* @example
|
|
3298
|
-
* ```typescript
|
|
3299
|
-
* // Allow every userId to use this connection
|
|
3300
|
-
* await composio.connectedAccounts.updateAcl('ca_abc', { allowAllUsers: true });
|
|
3301
|
-
*
|
|
3302
|
-
* // Everyone except a specific user
|
|
3303
|
-
* await composio.connectedAccounts.updateAcl('ca_abc', {
|
|
3304
|
-
* allowAllUsers: true,
|
|
3305
|
-
* notAllowedUserIds: ['user_bob'],
|
|
3306
|
-
* });
|
|
3307
|
-
*
|
|
3308
|
-
* // Targeted allow
|
|
3309
|
-
* await composio.connectedAccounts.updateAcl('ca_abc', {
|
|
3310
|
-
* allowedUserIds: ['user_alice', 'user_bob'],
|
|
3311
|
-
* });
|
|
3312
|
-
*
|
|
3313
|
-
* // Revoke a previously-granted allow list (back to deny-by-default)
|
|
3314
|
-
* await composio.connectedAccounts.updateAcl('ca_abc', { allowedUserIds: [] });
|
|
3315
|
-
* ```
|
|
3316
|
-
*
|
|
3317
|
-
* **Empty-array semantics — read carefully.** Passing `[]` for either
|
|
3318
|
-
* list **replaces** the list, it does not extend it:
|
|
3319
|
-
*
|
|
3320
|
-
* - `allowedUserIds: []` → revoke all previously-granted user IDs (state
|
|
3321
|
-
* reverts to deny-by-default unless `allowAllUsers` is true).
|
|
3322
|
-
* - `notAllowedUserIds: []` → **clears the deny list**, which silently
|
|
3323
|
-
* re-grants access to users you previously blocked. Always pair an
|
|
3324
|
-
* empty deny list with a deliberate audit of the allow side.
|
|
3325
|
-
*
|
|
3326
|
-
* @returns The PATCH response (`{ id, status, success }`). To read the
|
|
3327
|
-
* updated `aclConfigForShared` block, call `get(nanoid)` after the
|
|
3328
|
-
* promise resolves.
|
|
3329
|
-
*/
|
|
3330
|
-
async updateAcl(nanoid, params) {
|
|
3331
|
-
const parsedParams = UpdateConnectedAccountAclParamsSchema.safeParse(params);
|
|
3332
|
-
if (!parsedParams.success) throw new ValidationError("Failed to parse connected account ACL update params", { cause: parsedParams.error });
|
|
3333
|
-
const body = { acl_config_for_shared: serializeAclConfigForWire(parsedParams.data) };
|
|
3334
|
-
try {
|
|
3335
|
-
return await this.client.connectedAccounts.patch(nanoid, body);
|
|
3336
|
-
} catch (error) {
|
|
3337
|
-
if (error instanceof BadRequestError && typeof error.message === "string" && error.message.includes("acl_config_for_shared is only valid on SHARED")) throw new ComposioAclOnlyForSharedError(error.message, { cause: error });
|
|
3338
|
-
throw error;
|
|
3339
|
-
}
|
|
3340
|
-
}
|
|
3341
3176
|
};
|
|
3342
3177
|
|
|
3343
3178
|
//#endregion
|
|
@@ -4164,11 +3999,13 @@ var Triggers = class {
|
|
|
4164
3999
|
});
|
|
4165
4000
|
throw error;
|
|
4166
4001
|
}
|
|
4167
|
-
|
|
4002
|
+
const upsertParams = {
|
|
4168
4003
|
connected_account_id: connectedAccountId,
|
|
4169
4004
|
trigger_config: parsedBody.data.triggerConfig,
|
|
4170
|
-
toolkit_versions: this.toolkitVersions
|
|
4171
|
-
|
|
4005
|
+
toolkit_versions: this.toolkitVersions,
|
|
4006
|
+
user_id: userId
|
|
4007
|
+
};
|
|
4008
|
+
return { triggerId: (await this.client.triggerInstances.upsert(slug, upsertParams)).trigger_id };
|
|
4172
4009
|
}
|
|
4173
4010
|
/**
|
|
4174
4011
|
* Update an existing trigger instance
|
|
@@ -5217,6 +5054,63 @@ var BaseAgenticProvider = class extends BaseProvider {
|
|
|
5217
5054
|
_isAgentic = true;
|
|
5218
5055
|
};
|
|
5219
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
|
+
|
|
5220
5114
|
//#endregion
|
|
5221
5115
|
//#region src/provider/OpenAIProvider.ts
|
|
5222
5116
|
var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
@@ -5369,7 +5263,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5369
5263
|
*/
|
|
5370
5264
|
async executeToolCall(userId, tool, options, modifiers) {
|
|
5371
5265
|
const payload = {
|
|
5372
|
-
arguments:
|
|
5266
|
+
arguments: normalizeToolArguments(tool.function.arguments, tool.function.name),
|
|
5373
5267
|
connectedAccountId: options?.connectedAccountId,
|
|
5374
5268
|
customAuthParams: options?.customAuthParams,
|
|
5375
5269
|
customConnectionData: options?.customConnectionData,
|
|
@@ -5646,7 +5540,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5646
5540
|
|
|
5647
5541
|
//#endregion
|
|
5648
5542
|
//#region package.json
|
|
5649
|
-
var version = "0.
|
|
5543
|
+
var version = "0.11.0";
|
|
5650
5544
|
|
|
5651
5545
|
//#endregion
|
|
5652
5546
|
//#region src/utils/session.ts
|
|
@@ -6810,8 +6704,7 @@ const DIRECT_CUSTOM_TOOL_DESCRIPTION_PREFIX = "[Direct tool - call directly, no
|
|
|
6810
6704
|
const AuthorizeOptionsSchema = z$1.object({
|
|
6811
6705
|
callbackUrl: z$1.string().optional(),
|
|
6812
6706
|
alias: z$1.string().optional(),
|
|
6813
|
-
|
|
6814
|
-
aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
|
|
6707
|
+
experimental: ConnectedAccountExperimentalSchema.optional()
|
|
6815
6708
|
});
|
|
6816
6709
|
var ToolRouterSession = class {
|
|
6817
6710
|
sessionId;
|
|
@@ -6961,9 +6854,11 @@ var ToolRouterSession = class {
|
|
|
6961
6854
|
* Initiate an authorization flow for a toolkit.
|
|
6962
6855
|
* Returns a ConnectionRequest with a redirect URL for the user.
|
|
6963
6856
|
*
|
|
6964
|
-
*
|
|
6965
|
-
* with a per-user ACL in one flow. Default
|
|
6966
|
-
* a PRIVATE connection.
|
|
6857
|
+
* Pass `experimental: { accountType: 'SHARED', aclConfigForShared }` to
|
|
6858
|
+
* create a SHARED connection with a per-user ACL in one flow. Default
|
|
6859
|
+
* behaviour (omit the block) creates a PRIVATE connection.
|
|
6860
|
+
*
|
|
6861
|
+
* Experimental — shape may change in future releases.
|
|
6967
6862
|
*
|
|
6968
6863
|
* `aclConfigForShared` is validated against the same caps as
|
|
6969
6864
|
* `composio.connectedAccounts.link()` (≤1000 entries per list, each
|
|
@@ -6974,23 +6869,18 @@ var ToolRouterSession = class {
|
|
|
6974
6869
|
const requestOptions = AuthorizeOptionsSchema.safeParse(options ?? {});
|
|
6975
6870
|
if (!requestOptions.success) throw new ValidationError("Failed to parse tool router authorize options", { cause: requestOptions.error });
|
|
6976
6871
|
const opts = requestOptions.data;
|
|
6977
|
-
const
|
|
6978
|
-
...opts.aclConfigForShared.allowAllUsers !== void 0 && { allow_all_users: opts.aclConfigForShared.allowAllUsers },
|
|
6979
|
-
...opts.aclConfigForShared.allowedUserIds !== void 0 && { allowed_user_ids: opts.aclConfigForShared.allowedUserIds },
|
|
6980
|
-
...opts.aclConfigForShared.notAllowedUserIds !== void 0 && { not_allowed_user_ids: opts.aclConfigForShared.notAllowedUserIds }
|
|
6981
|
-
};
|
|
6872
|
+
const experimentalWire = serializeExperimentalForWire(opts.experimental);
|
|
6982
6873
|
const body = {
|
|
6983
6874
|
toolkit,
|
|
6984
6875
|
...opts.callbackUrl !== void 0 && { callback_url: opts.callbackUrl },
|
|
6985
6876
|
...opts.alias !== void 0 && { alias: opts.alias },
|
|
6986
|
-
...
|
|
6987
|
-
...aclWire !== void 0 && { acl_config_for_shared: aclWire }
|
|
6877
|
+
...experimentalWire !== void 0 && { experimental: experimentalWire }
|
|
6988
6878
|
};
|
|
6989
6879
|
let response;
|
|
6990
6880
|
try {
|
|
6991
6881
|
response = await this.client.toolRouter.session.link(this.sessionId, body);
|
|
6992
6882
|
} catch (error) {
|
|
6993
|
-
if (error instanceof BadRequestError && typeof error.message === "string" && error.message.includes(
|
|
6883
|
+
if (error instanceof BadRequestError && typeof error.message === "string" && error.message.includes(ACL_ONLY_FOR_SHARED_ERROR_FRAGMENT)) throw new ComposioAclOnlyForSharedError(error.message, { cause: error });
|
|
6994
6884
|
throw error;
|
|
6995
6885
|
}
|
|
6996
6886
|
return createConnectionRequest(this.client, response.connected_account_id, ConnectedAccountStatuses.INITIATED, response.redirect_url);
|
|
@@ -7414,6 +7304,14 @@ var Composio = class Composio {
|
|
|
7414
7304
|
authConfigs;
|
|
7415
7305
|
/** Manage authenticated connections */
|
|
7416
7306
|
connectedAccounts;
|
|
7307
|
+
/**
|
|
7308
|
+
* Experimental SDK methods whose shape may change in future releases.
|
|
7309
|
+
* Houses stateful operations like {@link Experimental.updateAcl} that
|
|
7310
|
+
* take a client and perform I/O. Stateless experimental factories
|
|
7311
|
+
* (e.g. `experimental_createTool`) stay at the top level.
|
|
7312
|
+
* @experimental
|
|
7313
|
+
*/
|
|
7314
|
+
experimental;
|
|
7417
7315
|
/** Model Context Protocol server management */
|
|
7418
7316
|
mcp;
|
|
7419
7317
|
/**
|
|
@@ -7529,6 +7427,7 @@ var Composio = class Composio {
|
|
|
7529
7427
|
fileDownloadDir: this.config.fileDownloadDir
|
|
7530
7428
|
});
|
|
7531
7429
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
7430
|
+
this.experimental = new Experimental(this.client);
|
|
7532
7431
|
this.toolRouter = new ToolRouter(this.client, this.config);
|
|
7533
7432
|
/**
|
|
7534
7433
|
* Initialize tool router methods
|
|
@@ -7674,6 +7573,17 @@ const CYCLE_BREAK_SENTINEL = {
|
|
|
7674
7573
|
type: "object",
|
|
7675
7574
|
additionalProperties: true
|
|
7676
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.";
|
|
7677
7587
|
const POLLUTING_KEYS = new Set([
|
|
7678
7588
|
"__proto__",
|
|
7679
7589
|
"constructor",
|
|
@@ -7681,33 +7591,68 @@ const POLLUTING_KEYS = new Set([
|
|
|
7681
7591
|
]);
|
|
7682
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"];
|
|
7683
7593
|
const decodePointerSegment = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
7684
|
-
const
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
possibleFixes: REF_RESOLUTION_FIXES
|
|
7691
|
-
});
|
|
7692
|
-
};
|
|
7693
|
-
const stepInto = (cursor, segment, pointer) => {
|
|
7694
|
-
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
|
+
};
|
|
7695
7600
|
if (Array.isArray(cursor)) {
|
|
7696
7601
|
const i = Number(segment);
|
|
7697
|
-
if (!Number.isInteger(i) || i < 0 || i >= cursor.length)
|
|
7698
|
-
|
|
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
|
+
};
|
|
7699
7611
|
}
|
|
7700
7612
|
const obj = cursor;
|
|
7701
|
-
if (!Object.prototype.hasOwnProperty.call(obj, segment))
|
|
7702
|
-
|
|
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
|
+
};
|
|
7703
7643
|
};
|
|
7704
|
-
const
|
|
7705
|
-
if (
|
|
7706
|
-
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}`, {
|
|
7707
7646
|
meta: { ref: pointer },
|
|
7708
7647
|
possibleFixes: REF_RESOLUTION_FIXES
|
|
7709
7648
|
});
|
|
7710
|
-
|
|
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
|
+
});
|
|
7711
7656
|
};
|
|
7712
7657
|
/**
|
|
7713
7658
|
* Inlines internal JSON Schema `$ref` pointers (`#/$defs/...` and legacy
|
|
@@ -7717,11 +7662,20 @@ const resolvePointer = (root, pointer) => {
|
|
|
7717
7662
|
* left untouched. Cycles are broken with `{ type: 'object',
|
|
7718
7663
|
* additionalProperties: true }`. The input is never mutated.
|
|
7719
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
|
+
*
|
|
7720
7672
|
* @throws {JsonSchemaRefResolutionError} on malformed pointers, missing
|
|
7721
|
-
* targets, or chains past the depth cap.
|
|
7673
|
+
* targets (strict mode only), or chains past the depth cap (both modes).
|
|
7722
7674
|
*/
|
|
7723
|
-
function dereferenceJsonSchema(schema) {
|
|
7675
|
+
function dereferenceJsonSchema(schema, options) {
|
|
7724
7676
|
if (!isPlainObject(schema)) return schema;
|
|
7677
|
+
const strategy = options?.onUnresolved ?? "throw";
|
|
7678
|
+
const onReplace = options?.onReplace;
|
|
7725
7679
|
const root = schema;
|
|
7726
7680
|
const visiting = /* @__PURE__ */ new WeakSet();
|
|
7727
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)]));
|
|
@@ -7750,7 +7704,18 @@ function dereferenceJsonSchema(schema) {
|
|
|
7750
7704
|
possibleFixes: REF_RESOLUTION_FIXES
|
|
7751
7705
|
});
|
|
7752
7706
|
if (visitedRefs.has(ref)) return { ...CYCLE_BREAK_SENTINEL };
|
|
7753
|
-
const
|
|
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);
|
|
7754
7719
|
const siblings = { ...node };
|
|
7755
7720
|
delete siblings.$ref;
|
|
7756
7721
|
if (Object.keys(siblings).length === 0 || !isPlainObject(resolved)) return resolved;
|
|
@@ -8307,4 +8272,4 @@ const ComposioMcpUpdateResponseSchema = z$1.object({
|
|
|
8307
8272
|
});
|
|
8308
8273
|
|
|
8309
8274
|
//#endregion
|
|
8310
|
-
export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAclOnlyForSharedError, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomCreateResponseSchema,
|
|
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 };
|