@composio/core 0.8.1 → 0.9.1
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/{CustomTool-BaRzlwyV.d.mts → CustomTool-BFkwL1aY.d.mts} +1 -1
- package/dist/{CustomTool-DnCSEC6t.cjs → CustomTool-Bkk0QYzw.cjs} +352 -26
- package/dist/{CustomTool-CVwF_isu.mjs → CustomTool-IIUhFtP8.mjs} +287 -27
- package/dist/{CustomTool-CzhY9iPX.d.cts → CustomTool-PSRHsd85.d.cts} +1 -1
- package/dist/{composio-B75SFMkx.d.cts → composio-BnLWW0B6.d.cts} +249 -166
- package/dist/{composio-CwcLLO7C.d.mts → composio-Dzlk0Wj4.d.mts} +249 -166
- package/dist/{customTool.types-2DhEI1vs.d.cts → customTool.types-BVgnEbR2.d.cts} +467 -30
- package/dist/{customTool.types-BL_z-C_B.d.mts → customTool.types-oV5boR1w.d.mts} +467 -30
- 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 +715 -72
- package/dist/index.d.cts +122 -9
- package/dist/index.d.mts +122 -9
- package/dist/index.mjs +704 -75
- package/dist/{tool.types-CNYy-lBq.d.mts → tool.types-CB_4JKhV.d.mts} +600 -37
- package/dist/{tool.types-BlXcjUs1.d.cts → tool.types-CwbAy9l_.d.cts} +600 -37
- package/dist/{types-CZkT1raQ.d.cts → types-4vkdo_RG.d.cts} +2 -2
- package/dist/{types-DGrpnYFI.d.mts → types-AcoPzTnm.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.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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 { A as
|
|
3
|
+
import { $ as ComposioMultipleConnectedAccountsError, A as ValidationErrorCodes, B as ComposioGlobalExecuteToolFnNotSetError, C as ComposioWebhookSignatureVerificationError, D as JsonSchemaRefResolutionError, E as SDKErrorCodes, F as ConnectionRequestFailedError, G as ComposioToolNotFoundError, H as ComposioInvalidModifierError, I as ConnectionRequestTimeoutError, J as handleToolExecutionError, K as ComposioToolVersionRequiredError, L as AuthConfigErrorCodes, M as ComposioToolkitNotFoundError, N as ToolkitErrorCodes, O as JsonSchemaToZodError, P as ConnectionRequestErrorCodes, Q as ComposioLegacyConnectedAccountsEndpointRetiredError, R as ComposioAuthConfigNotFoundError, S as ComposioWebhookPayloadError, T as ComposioNoAPIKeyError, U as ComposioProviderNotDefinedError, V as ComposioInvalidExecuteFunctionError, W as ComposioToolExecutionError, X as ComposioConnectedAccountNotFoundError, Y as ComposioAclOnlyForSharedError, Z as ComposioFailedToCreateConnectedAccountLink, _ as ComposioFailedToCreatePusherClientError, a as createCustomToolkit, b as ComposioFailedToUnsubscribeFromPusherChannelError, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, et as ComposioSharedAccessDeniedError, f as CreateCustomToolkitBaseSchema, g as RemoteFileErrorCodes, h as RemoteFileDownloadError, i as createCustomTool, j as ComposioToolkitFetchError, k as ValidationError, l as serializeCustomToolkits, m as PRELOAD_TOOLS_ALL, n as buildCustomToolsMap, nt as ConnectedAccountErrorCodes, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, q as ToolErrorCodes, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, tt as ComposioSharedConnectionNotAccessibleError, u as serializeCustomTools, v as ComposioFailedToGetSDKRealtimeCredentialsError, w as TriggerErrorCodes, x as ComposioTriggerTypeNotFoundError, y as ComposioFailedToSubscribeToPusherChannelError, z as ComposioCustomToolsNotInitializedError } from "./CustomTool-IIUhFtP8.mjs";
|
|
4
4
|
import { t as telemetry } from "./Telemetry-kgWlkavX.mjs";
|
|
5
5
|
import { i as getRandomShortId, t as arrayBufferToBase64 } from "./buffer-yOtEsT4J.mjs";
|
|
6
|
-
import { r as schemaHasFileUploadable } from "./FileToolModifier.utils.neutral-B7P7wn-b.mjs";
|
|
7
|
-
import ComposioClient, { APIError } from "@composio/client";
|
|
6
|
+
import { r as schemaHasFileUploadable, t as isPlainObject } from "./FileToolModifier.utils.neutral-B7P7wn-b.mjs";
|
|
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
10
|
import * as zodToJsonSchema from "zod-to-json-schema";
|
|
@@ -152,7 +152,8 @@ const ConnectionStatuses = {
|
|
|
152
152
|
ACTIVE: "ACTIVE",
|
|
153
153
|
FAILED: "FAILED",
|
|
154
154
|
EXPIRED: "EXPIRED",
|
|
155
|
-
INACTIVE: "INACTIVE"
|
|
155
|
+
INACTIVE: "INACTIVE",
|
|
156
|
+
REVOKED: "REVOKED"
|
|
156
157
|
};
|
|
157
158
|
const RedirectableAuthSchemeSchema = z$1.enum([AuthSchemeTypes.OAUTH1, AuthSchemeTypes.OAUTH2]);
|
|
158
159
|
const BaseSchemeRaw = z$1.object({
|
|
@@ -250,13 +251,18 @@ const Oauth2InactiveConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.
|
|
|
250
251
|
scope: z$1.string().optional()
|
|
251
252
|
}).optional().describe("for slack user scopes")
|
|
252
253
|
}).catchall(z$1.unknown());
|
|
254
|
+
const Oauth2RevokedConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
|
|
255
|
+
status: z$1.literal(ConnectionStatuses.REVOKED),
|
|
256
|
+
revoked_at: z$1.string().optional()
|
|
257
|
+
}).catchall(z$1.unknown());
|
|
253
258
|
const Oauth2ConnectionDataSchema = z$1.discriminatedUnion("status", [
|
|
254
259
|
Oauth2InitiatingConnectionDataSchema,
|
|
255
260
|
Oauth2InitiatedConnectionDataSchema,
|
|
256
261
|
Oauth2ActiveConnectionDataSchema,
|
|
257
262
|
Oauth2FailedConnectionDataSchema,
|
|
258
263
|
Oauth2ExpiredConnectionDataSchema,
|
|
259
|
-
Oauth2InactiveConnectionDataSchema
|
|
264
|
+
Oauth2InactiveConnectionDataSchema,
|
|
265
|
+
Oauth2RevokedConnectionDataSchema
|
|
260
266
|
]);
|
|
261
267
|
const CustomOauth2ConnectionDataSchema = Oauth2ActiveConnectionDataSchema.omit({ status: true });
|
|
262
268
|
const S2SOauth2BaseSchema = BaseSchemeRaw.extend({ status: z$1.literal(ConnectionStatuses.INITIALIZING) }).catchall(z$1.unknown());
|
|
@@ -305,6 +311,10 @@ const S2SOauth2ConnectionDataSchema = z$1.discriminatedUnion("status", [
|
|
|
305
311
|
S2SOauth2BaseSchema.extend({
|
|
306
312
|
status: z$1.literal(ConnectionStatuses.EXPIRED),
|
|
307
313
|
expired_at: z$1.string().optional()
|
|
314
|
+
}).catchall(z$1.unknown()),
|
|
315
|
+
S2SOauth2BaseSchema.extend({
|
|
316
|
+
status: z$1.literal(ConnectionStatuses.REVOKED),
|
|
317
|
+
revoked_at: z$1.string().optional()
|
|
308
318
|
}).catchall(z$1.unknown())
|
|
309
319
|
]);
|
|
310
320
|
const CustomS2SOauth2ConnectionDataSchema = BaseSchemeRaw.extend({
|
|
@@ -1013,7 +1023,8 @@ const ConnectedAccountStatuses = {
|
|
|
1013
1023
|
ACTIVE: "ACTIVE",
|
|
1014
1024
|
FAILED: "FAILED",
|
|
1015
1025
|
EXPIRED: "EXPIRED",
|
|
1016
|
-
INACTIVE: "INACTIVE"
|
|
1026
|
+
INACTIVE: "INACTIVE",
|
|
1027
|
+
REVOKED: "REVOKED"
|
|
1017
1028
|
};
|
|
1018
1029
|
const ConnectedAccountStatusSchema = z$1.enum([
|
|
1019
1030
|
ConnectedAccountStatuses.INITIALIZING,
|
|
@@ -1021,8 +1032,62 @@ const ConnectedAccountStatusSchema = z$1.enum([
|
|
|
1021
1032
|
ConnectedAccountStatuses.ACTIVE,
|
|
1022
1033
|
ConnectedAccountStatuses.FAILED,
|
|
1023
1034
|
ConnectedAccountStatuses.EXPIRED,
|
|
1024
|
-
ConnectedAccountStatuses.INACTIVE
|
|
1035
|
+
ConnectedAccountStatuses.INACTIVE,
|
|
1036
|
+
ConnectedAccountStatuses.REVOKED
|
|
1025
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
|
+
});
|
|
1026
1091
|
const CreateConnectedAccountParamsSchema = z$1.object({
|
|
1027
1092
|
authConfig: z$1.object({ id: z$1.string() }),
|
|
1028
1093
|
connection: z$1.object({
|
|
@@ -1075,7 +1140,9 @@ const ConnectedAccountRetrieveResponseSchema = z$1.object({
|
|
|
1075
1140
|
testRequestEndpoint: z$1.string().optional(),
|
|
1076
1141
|
isDisabled: z$1.boolean(),
|
|
1077
1142
|
createdAt: z$1.string(),
|
|
1078
|
-
updatedAt: z$1.string()
|
|
1143
|
+
updatedAt: z$1.string(),
|
|
1144
|
+
accountType: ConnectedAccountTypeSchema.optional(),
|
|
1145
|
+
aclConfigForShared: ConnectedAccountAclConfigResponseSchema.optional()
|
|
1079
1146
|
});
|
|
1080
1147
|
const ConnectedAccountListParamsSchema = z$1.object({
|
|
1081
1148
|
authConfigIds: z$1.array(z$1.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
|
|
@@ -1094,7 +1161,9 @@ const ConnectedAccountListResponseSchema = z$1.object({
|
|
|
1094
1161
|
const CreateConnectedAccountLinkOptionsSchema = z$1.object({
|
|
1095
1162
|
callbackUrl: z$1.string().optional(),
|
|
1096
1163
|
alias: z$1.string().optional(),
|
|
1097
|
-
allowMultiple: z$1.boolean().optional()
|
|
1164
|
+
allowMultiple: z$1.boolean().optional(),
|
|
1165
|
+
accountType: ConnectedAccountTypeSchema.optional(),
|
|
1166
|
+
aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
|
|
1098
1167
|
});
|
|
1099
1168
|
const CreateConnectedAccountLinkResponseSchema = z$1.object({ redirectUrl: z$1.string() });
|
|
1100
1169
|
const ConnectedAccountRefreshOptionsSchema = z$1.object({
|
|
@@ -1102,6 +1171,19 @@ const ConnectedAccountRefreshOptionsSchema = z$1.object({
|
|
|
1102
1171
|
validateCredentials: z$1.boolean().optional()
|
|
1103
1172
|
});
|
|
1104
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" });
|
|
1105
1187
|
|
|
1106
1188
|
//#endregion
|
|
1107
1189
|
//#region src/utils/transform.ts
|
|
@@ -1163,7 +1245,13 @@ function transformConnectedAccountResponse(response) {
|
|
|
1163
1245
|
isDisabled: response$1.is_disabled,
|
|
1164
1246
|
createdAt: response$1.created_at,
|
|
1165
1247
|
updatedAt: response$1.updated_at,
|
|
1166
|
-
testRequestEndpoint: response$1.test_request_endpoint
|
|
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
|
|
1167
1255
|
}));
|
|
1168
1256
|
}
|
|
1169
1257
|
/**
|
|
@@ -1476,6 +1564,7 @@ function resolveEffectiveUploadAllowlist(userDirs) {
|
|
|
1476
1564
|
|
|
1477
1565
|
//#endregion
|
|
1478
1566
|
//#region src/models/Tools.ts
|
|
1567
|
+
const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
|
|
1479
1568
|
/**
|
|
1480
1569
|
* This class is used to manage tools in the Composio SDK.
|
|
1481
1570
|
* It provides methods to list, get, and execute tools.
|
|
@@ -1743,7 +1832,17 @@ var Tools = class {
|
|
|
1743
1832
|
* ```
|
|
1744
1833
|
*/
|
|
1745
1834
|
async getRawToolRouterSessionTools(sessionId, options) {
|
|
1746
|
-
|
|
1835
|
+
const tools = [];
|
|
1836
|
+
let cursor;
|
|
1837
|
+
do {
|
|
1838
|
+
const response = await this.client.toolRouter.session.tools(sessionId, {
|
|
1839
|
+
limit: TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT,
|
|
1840
|
+
...cursor ? { cursor } : {}
|
|
1841
|
+
});
|
|
1842
|
+
tools.push(...response.items.map((tool) => this.transformToolCases(tool)));
|
|
1843
|
+
cursor = response.next_cursor;
|
|
1844
|
+
} while (cursor);
|
|
1845
|
+
let modifiedTools = tools;
|
|
1747
1846
|
if (options?.modifySchema) {
|
|
1748
1847
|
const modifier = options.modifySchema;
|
|
1749
1848
|
if (typeof modifier === "function") {
|
|
@@ -2065,7 +2164,7 @@ var Tools = class {
|
|
|
2065
2164
|
* @param {Tool} tool - Optional tool schema used to resolve toolkit metadata for modifiers
|
|
2066
2165
|
* @returns {Promise<ToolExecuteResponse>} The response from the tool execution
|
|
2067
2166
|
*/
|
|
2068
|
-
async executeSessionTool(toolSlug, body, modifiers, tool) {
|
|
2167
|
+
async executeSessionTool(toolSlug, body, modifiers, tool, options) {
|
|
2069
2168
|
const executeParams = ToolExecuteMetaParamsSchema.safeParse(body);
|
|
2070
2169
|
if (!executeParams.success) throw new ValidationError("Invalid tool execute session parameters", { cause: executeParams.error });
|
|
2071
2170
|
let modifiedParams = body.arguments ?? {};
|
|
@@ -2081,6 +2180,7 @@ var Tools = class {
|
|
|
2081
2180
|
arguments: modifiedParams,
|
|
2082
2181
|
enable_auto_workbench_offload: true
|
|
2083
2182
|
};
|
|
2183
|
+
if (options?.experimental) executePayload.experimental = options.experimental;
|
|
2084
2184
|
const response = await this.client.toolRouter.session.execute(body.sessionId, executePayload);
|
|
2085
2185
|
let result = {
|
|
2086
2186
|
data: response.data,
|
|
@@ -2714,28 +2814,36 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
|
|
|
2714
2814
|
* ```
|
|
2715
2815
|
*/
|
|
2716
2816
|
async function waitForConnection(timeout = 6e4) {
|
|
2817
|
+
const terminalErrorStates = [
|
|
2818
|
+
ConnectedAccountStatuses.FAILED,
|
|
2819
|
+
ConnectedAccountStatuses.EXPIRED,
|
|
2820
|
+
ConnectedAccountStatuses.REVOKED
|
|
2821
|
+
];
|
|
2822
|
+
const failIfTerminal = (response) => {
|
|
2823
|
+
if (terminalErrorStates.includes(response.status)) throw new ConnectionRequestFailedError(`Connection request failed with status: ${response.status}${response.status_reason ? `, reason: ${response.status_reason}` : ""}`, { meta: {
|
|
2824
|
+
connectedAccountId: state.id,
|
|
2825
|
+
status: response.status,
|
|
2826
|
+
statusReason: response.status_reason
|
|
2827
|
+
} });
|
|
2828
|
+
};
|
|
2717
2829
|
try {
|
|
2718
2830
|
const response = await client.connectedAccounts.retrieve(state.id);
|
|
2719
2831
|
if (response.status === ConnectedAccountStatuses.ACTIVE) {
|
|
2720
2832
|
state.status = ConnectedAccountStatuses.ACTIVE;
|
|
2721
2833
|
return transformConnectedAccountResponse(response);
|
|
2722
2834
|
}
|
|
2835
|
+
failIfTerminal(response);
|
|
2723
2836
|
} catch (error) {
|
|
2724
2837
|
if (error instanceof ComposioClient.NotFoundError) throw new ComposioConnectedAccountNotFoundError(`Connected account with id ${state.id} not found`, { meta: { connectedAccountId: state.id } });
|
|
2725
2838
|
else throw error;
|
|
2726
2839
|
}
|
|
2727
|
-
const terminalErrorStates = [ConnectedAccountStatuses.FAILED, ConnectedAccountStatuses.EXPIRED];
|
|
2728
2840
|
const start = Date.now();
|
|
2729
2841
|
const pollInterval = 1e3;
|
|
2730
2842
|
while (Date.now() - start < timeout) try {
|
|
2731
2843
|
const response = await client.connectedAccounts.retrieve(state.id);
|
|
2732
2844
|
state.status = response.status;
|
|
2733
2845
|
if (response.status === ConnectedAccountStatuses.ACTIVE) return transformConnectedAccountResponse(response);
|
|
2734
|
-
|
|
2735
|
-
connectedAccountId: state.id,
|
|
2736
|
-
status: response.status,
|
|
2737
|
-
statusReason: response.status_reason
|
|
2738
|
-
} });
|
|
2846
|
+
failIfTerminal(response);
|
|
2739
2847
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
2740
2848
|
} catch (error) {
|
|
2741
2849
|
throw error;
|
|
@@ -2753,6 +2861,30 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
|
|
|
2753
2861
|
//#endregion
|
|
2754
2862
|
//#region src/models/ConnectedAccounts.ts
|
|
2755
2863
|
/**
|
|
2864
|
+
* @fileoverview Connected accounts class for Composio SDK, used to manage connected accounts of a user.
|
|
2865
|
+
*
|
|
2866
|
+
* @author Musthaq Ahamad <musthaq@composio.dev>
|
|
2867
|
+
* @date 2025-05-05
|
|
2868
|
+
* @module ConnectedAccounts
|
|
2869
|
+
*/
|
|
2870
|
+
let _legacyInitiateWarningEmitted = false;
|
|
2871
|
+
/**
|
|
2872
|
+
* Serialise the SDK's `aclConfigForShared` (camelCase) to the wire's
|
|
2873
|
+
* `acl_config_for_shared` block. Returns `undefined` when the caller
|
|
2874
|
+
* didn't pass anything (PATCH-style "don't touch ACL"); returns `{}`
|
|
2875
|
+
* when the caller passed an explicit empty object — both mean
|
|
2876
|
+
* deny-by-default, but the explicit form preserves the caller's intent
|
|
2877
|
+
* in network traces.
|
|
2878
|
+
*/
|
|
2879
|
+
function serializeAclConfigForWire(acl) {
|
|
2880
|
+
if (acl === void 0) return void 0;
|
|
2881
|
+
return {
|
|
2882
|
+
...acl.allowAllUsers !== void 0 && { allow_all_users: acl.allowAllUsers },
|
|
2883
|
+
...acl.allowedUserIds !== void 0 && { allowed_user_ids: acl.allowedUserIds },
|
|
2884
|
+
...acl.notAllowedUserIds !== void 0 && { not_allowed_user_ids: acl.notAllowedUserIds }
|
|
2885
|
+
};
|
|
2886
|
+
}
|
|
2887
|
+
/**
|
|
2756
2888
|
* ConnectedAccounts class
|
|
2757
2889
|
*
|
|
2758
2890
|
* This class is used to manage connected accounts in the Composio SDK.
|
|
@@ -2810,6 +2942,22 @@ var ConnectedAccounts = class {
|
|
|
2810
2942
|
* This function creates a new connected account and returns a connection request.
|
|
2811
2943
|
* Users can then wait for the connection to be established using the `waitForConnection` method.
|
|
2812
2944
|
*
|
|
2945
|
+
* **Deprecated for Composio-managed OAuth (OAuth1, OAuth2, DCR_OAUTH).**
|
|
2946
|
+
* The legacy `POST /api/v3/connected_accounts` endpoint that this method
|
|
2947
|
+
* wraps is being retired for Composio-managed auth configs on redirectable
|
|
2948
|
+
* schemes. The cutover is **2026-05-08** for new organizations and
|
|
2949
|
+
* **2026-07-03** for all remaining organizations. After your org's cutover,
|
|
2950
|
+
* this method will throw {@link ComposioLegacyConnectedAccountsEndpointRetiredError}
|
|
2951
|
+
* for that specific combination.
|
|
2952
|
+
*
|
|
2953
|
+
* Use {@link ConnectedAccounts.link} for Composio-managed OAuth — it works for
|
|
2954
|
+
* every redirectable scheme regardless of whether the auth config is
|
|
2955
|
+
* Composio-managed or custom, and the return shape is the same.
|
|
2956
|
+
*
|
|
2957
|
+
* Custom auth configs (your own OAuth app) and non-OAuth schemes (API key,
|
|
2958
|
+
* bearer token, basic auth) are unaffected and continue to work on
|
|
2959
|
+
* `initiate()`. See https://docs.composio.dev/docs/changelog/2026/04/24
|
|
2960
|
+
*
|
|
2813
2961
|
* @param {string} userId - User ID of the connected account
|
|
2814
2962
|
* @param {string} authConfigId - Auth config ID of the connected account
|
|
2815
2963
|
* @param {CreateConnectedAccountOptions} options - Options for creating a new connected account
|
|
@@ -2874,7 +3022,23 @@ var ConnectedAccounts = class {
|
|
|
2874
3022
|
...options?.alias != null && { alias: options.alias }
|
|
2875
3023
|
}
|
|
2876
3024
|
};
|
|
2877
|
-
|
|
3025
|
+
let response;
|
|
3026
|
+
let httpResponse;
|
|
3027
|
+
try {
|
|
3028
|
+
const apiCall = this.client.connectedAccounts.create(createParams);
|
|
3029
|
+
if (typeof apiCall.withResponse === "function") {
|
|
3030
|
+
const resolved = await apiCall.withResponse();
|
|
3031
|
+
response = resolved.data;
|
|
3032
|
+
httpResponse = resolved.response;
|
|
3033
|
+
} else response = await apiCall;
|
|
3034
|
+
} catch (error) {
|
|
3035
|
+
if (error instanceof BadRequestError && typeof error.message === "string" && error.message.includes("no longer supported") && error.message.includes("/api/v3/connected_accounts/link")) throw new ComposioLegacyConnectedAccountsEndpointRetiredError(error.message, { cause: error });
|
|
3036
|
+
throw error;
|
|
3037
|
+
}
|
|
3038
|
+
if (!_legacyInitiateWarningEmitted && httpResponse?.headers.get("Deprecation")) {
|
|
3039
|
+
_legacyInitiateWarningEmitted = true;
|
|
3040
|
+
logger_default.warn("[Deprecation] composio.connectedAccounts.initiate() will stop working for this auth config on or before 2026-07-03 (see Sunset header on the response). Switch to composio.connectedAccounts.link() — same return shape, same allowMultiple semantics. https://docs.composio.dev/docs/changelog/2026/04/24");
|
|
3041
|
+
}
|
|
2878
3042
|
const redirectUrl = typeof response.connectionData?.val?.redirectUrl === "string" ? response.connectionData.val.redirectUrl : null;
|
|
2879
3043
|
return createConnectionRequest(this.client, response.id, response.connectionData.val.status, redirectUrl);
|
|
2880
3044
|
}
|
|
@@ -2923,15 +3087,21 @@ var ConnectedAccounts = class {
|
|
|
2923
3087
|
});
|
|
2924
3088
|
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.`);
|
|
2925
3089
|
else if (existing.items.length > 0) logger_default.warn(`[Warn:AllowMultiple] Multiple connected accounts found for user ${userId} in auth config ${authConfigId}`);
|
|
3090
|
+
const opts = requestOptions.data;
|
|
3091
|
+
const aclWire = serializeAclConfigForWire(opts.aclConfigForShared);
|
|
3092
|
+
const body = {
|
|
3093
|
+
auth_config_id: authConfigId,
|
|
3094
|
+
user_id: userId,
|
|
3095
|
+
...opts.callbackUrl !== void 0 && { callback_url: opts.callbackUrl },
|
|
3096
|
+
...opts.alias !== void 0 && { alias: opts.alias },
|
|
3097
|
+
...opts.accountType !== void 0 && { account_type: opts.accountType },
|
|
3098
|
+
...aclWire !== void 0 && { acl_config_for_shared: aclWire }
|
|
3099
|
+
};
|
|
2926
3100
|
try {
|
|
2927
|
-
const response = await this.client.link.create(
|
|
2928
|
-
auth_config_id: authConfigId,
|
|
2929
|
-
user_id: userId,
|
|
2930
|
-
...requestOptions?.data.callbackUrl && { callback_url: requestOptions.data.callbackUrl },
|
|
2931
|
-
...requestOptions?.data.alias != null && { alias: requestOptions.data.alias }
|
|
2932
|
-
});
|
|
3101
|
+
const response = await this.client.link.create(body);
|
|
2933
3102
|
return createConnectionRequest(this.client, response.connected_account_id, ConnectedAccountStatuses.INITIATED, response.redirect_url);
|
|
2934
3103
|
} catch (error) {
|
|
3104
|
+
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 });
|
|
2935
3105
|
throw new ComposioFailedToCreateConnectedAccountLink("Failed to create connected account link", { cause: error });
|
|
2936
3106
|
}
|
|
2937
3107
|
}
|
|
@@ -3088,7 +3258,9 @@ var ConnectedAccounts = class {
|
|
|
3088
3258
|
return this.client.connectedAccounts.updateStatus(nanoid, { enabled: false });
|
|
3089
3259
|
}
|
|
3090
3260
|
/**
|
|
3091
|
-
*
|
|
3261
|
+
* Enable or disable a connected account. Accepts `{ enabled: boolean }`.
|
|
3262
|
+
*
|
|
3263
|
+
* For ACL writes on SHARED connections, see {@link updateAcl}.
|
|
3092
3264
|
*
|
|
3093
3265
|
* @param {string} nanoid - The unique identifier of the connected account
|
|
3094
3266
|
* @param {UpdateConnectedAccountParams} params - The update parameters
|
|
@@ -3105,6 +3277,67 @@ var ConnectedAccounts = class {
|
|
|
3105
3277
|
if (!parsedParams.success) throw new ValidationError("Failed to parse connected account update params", { cause: parsedParams.error });
|
|
3106
3278
|
return this.client.connectedAccounts.updateStatus(nanoid, parsedParams.data);
|
|
3107
3279
|
}
|
|
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
|
+
}
|
|
3108
3341
|
};
|
|
3109
3342
|
|
|
3110
3343
|
//#endregion
|
|
@@ -5413,7 +5646,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5413
5646
|
|
|
5414
5647
|
//#endregion
|
|
5415
5648
|
//#region package.json
|
|
5416
|
-
var version = "0.
|
|
5649
|
+
var version = "0.9.1";
|
|
5417
5650
|
|
|
5418
5651
|
//#endregion
|
|
5419
5652
|
//#region src/utils/session.ts
|
|
@@ -5456,6 +5689,7 @@ const getDefaultHeaders = (headers, provider) => {
|
|
|
5456
5689
|
|
|
5457
5690
|
//#endregion
|
|
5458
5691
|
//#region src/types/toolRouter.types.ts
|
|
5692
|
+
const SessionPreset = { DIRECT_TOOLS: "direct_tools" };
|
|
5459
5693
|
const MCPServerTypeSchema = z.enum(["http", "sse"]);
|
|
5460
5694
|
/**
|
|
5461
5695
|
* Sandbox compute tier for the tool router workbench.
|
|
@@ -5536,7 +5770,8 @@ const ToolRouterConfigToolsSchema = z.union([
|
|
|
5536
5770
|
});
|
|
5537
5771
|
}
|
|
5538
5772
|
});
|
|
5539
|
-
const
|
|
5773
|
+
const ToolRouterCreateSessionConfigBaseSchema = z.object({
|
|
5774
|
+
sessionPreset: z.literal(SessionPreset.DIRECT_TOOLS).optional().describe("Shortcut to expose every tool allowed by the session filters directly in session.tools() and the MCP tool list. This disables meta tools by default (search, multi-execute, manage-connections, and workbench). Use when all tools are known upfront and helper/meta tools are not needed. Without this preset, ToolRouter uses its default configuration with meta tools enabled."),
|
|
5540
5775
|
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).optional().describe("The tools to use in the tool router session"),
|
|
5541
5776
|
tags: ToolRouterConfigTagsSchema.optional().describe("Global tags to filter the tools by"),
|
|
5542
5777
|
toolkits: z.union([
|
|
@@ -5545,26 +5780,38 @@ const ToolRouterCreateSessionConfigSchema = z.object({
|
|
|
5545
5780
|
ToolRouterToolkitsEnabledConfigSchema
|
|
5546
5781
|
]).optional().describe("The toolkits to use in the tool router session"),
|
|
5547
5782
|
authConfigs: z.record(z.string(), z.string()).describe("The auth configs to use in the tool router session. The key is the toolkit slug, the value is the auth config id.").default({}),
|
|
5548
|
-
connectedAccounts: z.record(z.string(), z.string()).describe("The connected accounts to use in the tool router session. The key is the toolkit slug, the value is
|
|
5783
|
+
connectedAccounts: z.record(z.string(), z.union([z.string(), z.array(z.string())])).describe("The connected accounts to use in the tool router session. The key is the toolkit slug, the value is a connected account id or an array of ids. Only one account per toolkit is allowed when multi-account mode is disabled.").default({}),
|
|
5549
5784
|
manageConnections: z.union([z.boolean(), ToolRouterConfigManageConnectionsSchema]).optional().default(true).describe("The config for the manage connections in the tool router session. Defaults to true, if set to false, you need to manage connections manually. If set to an object, you can configure the manage connections settings."),
|
|
5550
5785
|
workbench: z.object({
|
|
5551
5786
|
enable: z.boolean().default(true).describe("Whether to enable the workbench entirely. Defaults to true. When set to false, no code execution tools (COMPOSIO_REMOTE_WORKBENCH, COMPOSIO_REMOTE_BASH_TOOL) are available in the session."),
|
|
5552
5787
|
enableProxyExecution: z.boolean().optional().describe("Whether to enable proxy execution in the tool router session"),
|
|
5553
5788
|
autoOffloadThreshold: z.number().optional().describe("The auto offload threshold in characters for the tool execution to be moved into workbench"),
|
|
5554
|
-
sandboxSize: SandboxSizeSchema.optional().describe("Sandbox compute tier for the workbench. One of \"standard\" (1 vCPU / 1 GB), \"medium\" (2 vCPU / 2 GB), \"large\" (4 vCPU / 4 GB), or \"xlarge\" (8 vCPU / 8 GB). Defaults to \"standard\" server-side. Changing this on an existing session recreates the sandbox on next access; the
|
|
5789
|
+
sandboxSize: SandboxSizeSchema.optional().describe("Sandbox compute tier for the workbench. One of \"standard\" (1 vCPU / 1 GB), \"medium\" (2 vCPU / 2 GB), \"large\" (4 vCPU / 4 GB), or \"xlarge\" (8 vCPU / 8 GB). Defaults to \"standard\" server-side. Changing this on an existing session recreates the session's workbench sandbox on next access; the in-memory FS is lost, but /mnt/files/ persists.")
|
|
5555
5790
|
}).optional().describe("The workbench config for the tool router session"),
|
|
5556
5791
|
multiAccount: z.object({
|
|
5557
5792
|
enable: z.boolean().default(false).describe("When true, enables multi-account mode for this session. Defaults to false."),
|
|
5558
5793
|
maxAccountsPerToolkit: z.number().int().min(2).max(10).optional().describe("Maximum number of connected accounts allowed per toolkit. Defaults to 5 when multi-account is enabled."),
|
|
5559
5794
|
requireExplicitSelection: z.boolean().optional().describe("When true, require explicit account selection when multiple accounts are connected. When false (default), use the first/default account.")
|
|
5560
5795
|
}).optional().describe("Multi-account configuration for this session"),
|
|
5561
|
-
preload: z.object({ tools: z.array(z.string()).optional().describe("Tool slugs to preload into session.tools() and the MCP tool list.
|
|
5796
|
+
preload: z.object({ tools: z.union([z.array(z.string()), z.literal(PRELOAD_TOOLS_ALL)]).optional().describe("Tool slugs to preload into session.tools() and the MCP tool list, or \"all\" to preload every app tool allowed by the session filters. \"all\" requires a positive filter such as toolkits, tools, or tags; the backend validates and caps the final tool set.") }).strict().optional().describe("Preload configuration for tools that should be exposed without search."),
|
|
5562
5797
|
experimental: z.object({
|
|
5563
5798
|
assistivePrompt: z.object({ userTimezone: z.string().optional().describe("IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\") for timezone-aware assistive prompts") }).optional().describe("Configuration for assistive prompt generation"),
|
|
5564
5799
|
customTools: z.array(z.custom()).optional().describe("Custom tools to include in this session. Created via createCustomTool() from @composio/core/experimental."),
|
|
5565
5800
|
customToolkits: z.array(z.custom()).optional().describe("Custom toolkits to include in this session. Created via createCustomToolkit() from @composio/core/experimental.")
|
|
5566
5801
|
}).optional().describe("Experimental features configuration - not stable, may be modified or removed")
|
|
5567
5802
|
}).partial().describe("The config for the tool router session");
|
|
5803
|
+
const applyDirectToolsPresetDefaults = (value) => {
|
|
5804
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
5805
|
+
const config = value;
|
|
5806
|
+
if (config.sessionPreset !== SessionPreset.DIRECT_TOOLS) return value;
|
|
5807
|
+
return {
|
|
5808
|
+
...config,
|
|
5809
|
+
manageConnections: config.manageConnections === void 0 ? false : config.manageConnections,
|
|
5810
|
+
workbench: config.workbench === void 0 ? { enable: false } : config.workbench,
|
|
5811
|
+
preload: config.preload === void 0 ? { tools: PRELOAD_TOOLS_ALL } : config.preload
|
|
5812
|
+
};
|
|
5813
|
+
};
|
|
5814
|
+
const ToolRouterCreateSessionConfigSchema = z.preprocess(applyDirectToolsPresetDefaults, ToolRouterCreateSessionConfigBaseSchema).describe("The config for the tool router session");
|
|
5568
5815
|
const ToolkitConnectionStateSchema = z.object({
|
|
5569
5816
|
slug: z.string().describe("The slug of a toolkit"),
|
|
5570
5817
|
name: z.string().describe("The name of a toolkit"),
|
|
@@ -5683,6 +5930,34 @@ const SessionProxyExecuteParamsSchema = z.object({
|
|
|
5683
5930
|
value: z.union([z.string(), z.number()])
|
|
5684
5931
|
})).optional()
|
|
5685
5932
|
});
|
|
5933
|
+
const ToolRouterUpdateSessionConfigSchema = z.object({
|
|
5934
|
+
toolkits: z.union([
|
|
5935
|
+
ToolRouterToolkitsParamSchema,
|
|
5936
|
+
ToolRouterToolkitsDisabledConfigSchema,
|
|
5937
|
+
ToolRouterToolkitsEnabledConfigSchema
|
|
5938
|
+
]).optional(),
|
|
5939
|
+
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).optional(),
|
|
5940
|
+
tags: ToolRouterConfigTagsSchema.optional(),
|
|
5941
|
+
authConfigs: z.record(z.string(), z.string()).optional(),
|
|
5942
|
+
connectedAccounts: z.record(z.string(), z.union([z.string(), z.array(z.string())])).transform((rec) => {
|
|
5943
|
+
const out = {};
|
|
5944
|
+
for (const [k, v] of Object.entries(rec)) out[k] = typeof v === "string" ? [v] : v;
|
|
5945
|
+
return out;
|
|
5946
|
+
}).optional(),
|
|
5947
|
+
manageConnections: z.union([z.boolean(), ToolRouterConfigManageConnectionsSchema]).nullable().optional(),
|
|
5948
|
+
workbench: z.object({
|
|
5949
|
+
enable: z.boolean().optional(),
|
|
5950
|
+
enableProxyExecution: z.boolean().optional(),
|
|
5951
|
+
autoOffloadThreshold: z.number().optional(),
|
|
5952
|
+
sandboxSize: SandboxSizeSchema.optional()
|
|
5953
|
+
}).nullable().optional(),
|
|
5954
|
+
multiAccount: z.object({
|
|
5955
|
+
enable: z.boolean().optional(),
|
|
5956
|
+
maxAccountsPerToolkit: z.number().int().min(2).max(10).optional(),
|
|
5957
|
+
requireExplicitSelection: z.boolean().optional()
|
|
5958
|
+
}).nullable().optional(),
|
|
5959
|
+
preload: z.object({ tools: z.union([z.array(z.string()), z.literal("all")]).optional() }).strict().optional()
|
|
5960
|
+
}).partial();
|
|
5686
5961
|
|
|
5687
5962
|
//#endregion
|
|
5688
5963
|
//#region src/lib/toolRouterParams.ts
|
|
@@ -5735,12 +6010,39 @@ const transformToolRouterWorkbenchParams = (params) => {
|
|
|
5735
6010
|
sandbox_size: params.sandboxSize
|
|
5736
6011
|
};
|
|
5737
6012
|
};
|
|
6013
|
+
/**
|
|
6014
|
+
* PATCH-safe variant of transformToolRouterManageConnectionsParams.
|
|
6015
|
+
* Does NOT apply defaults — only includes fields explicitly present in the input.
|
|
6016
|
+
*/
|
|
6017
|
+
const transformToolRouterUpdateManageConnectionsParams = (params) => {
|
|
6018
|
+
if (typeof params === "boolean") return { enable: params };
|
|
6019
|
+
const parsedResult = ToolRouterConfigManageConnectionsSchema.safeParse(params);
|
|
6020
|
+
if (!parsedResult.success) throw new ValidationError("Failed to parse manage connections config", { cause: parsedResult.error });
|
|
6021
|
+
const config = parsedResult.data;
|
|
6022
|
+
const result = {};
|
|
6023
|
+
if (config.enable !== void 0) result.enable = config.enable;
|
|
6024
|
+
if (config.callbackUrl !== void 0) result.callback_url = config.callbackUrl;
|
|
6025
|
+
if (config.waitForConnections !== void 0) result.enable_wait_for_connections = config.waitForConnections;
|
|
6026
|
+
return result;
|
|
6027
|
+
};
|
|
6028
|
+
/**
|
|
6029
|
+
* PATCH-safe variant of transformToolRouterWorkbenchParams.
|
|
6030
|
+
* Does NOT apply `enable ?? true` default — only includes fields explicitly present.
|
|
6031
|
+
*/
|
|
6032
|
+
const transformToolRouterUpdateWorkbenchParams = (params) => {
|
|
6033
|
+
const result = {};
|
|
6034
|
+
if (params.enable !== void 0) result.enable = params.enable;
|
|
6035
|
+
if (params.enableProxyExecution !== void 0) result.enable_proxy_execution = params.enableProxyExecution;
|
|
6036
|
+
if (params.autoOffloadThreshold !== void 0) result.auto_offload_threshold = params.autoOffloadThreshold;
|
|
6037
|
+
if (params.sandboxSize !== void 0) result.sandbox_size = params.sandboxSize;
|
|
6038
|
+
return result;
|
|
6039
|
+
};
|
|
5738
6040
|
const transformToolRouterMultiAccountParams = (params) => {
|
|
5739
6041
|
if (!params) return;
|
|
5740
6042
|
const transformedParams = {
|
|
5741
6043
|
enable: params.enable,
|
|
5742
6044
|
max_accounts_per_toolkit: params.maxAccountsPerToolkit,
|
|
5743
|
-
require_explicit_selection: params.requireExplicitSelection
|
|
6045
|
+
require_explicit_selection: params.requireExplicitSelection ?? (params.enable ? true : void 0)
|
|
5744
6046
|
};
|
|
5745
6047
|
if (transformedParams.enable === void 0 && transformedParams.max_accounts_per_toolkit === void 0 && transformedParams.require_explicit_selection === void 0) return;
|
|
5746
6048
|
return transformedParams;
|
|
@@ -5750,6 +6052,32 @@ const transformToolRouterToolkitsParams = (params) => {
|
|
|
5750
6052
|
if (Array.isArray(params)) return { enable: params };
|
|
5751
6053
|
return params;
|
|
5752
6054
|
};
|
|
6055
|
+
const transformToolRouterUpdateParams = (config) => {
|
|
6056
|
+
const params = {};
|
|
6057
|
+
if (config.toolkits !== void 0) params.toolkits = transformToolRouterToolkitsParams(config.toolkits);
|
|
6058
|
+
if (config.tools !== void 0) params.tools = transformToolRouterToolsParams(config.tools);
|
|
6059
|
+
if (config.tags !== void 0) params.tags = transformToolRouterTagsParams(config.tags);
|
|
6060
|
+
if (config.authConfigs !== void 0) params.auth_configs = config.authConfigs;
|
|
6061
|
+
if (config.connectedAccounts !== void 0) {
|
|
6062
|
+
const coerced = {};
|
|
6063
|
+
for (const [k, v] of Object.entries(config.connectedAccounts)) coerced[k] = typeof v === "string" ? [v] : v;
|
|
6064
|
+
params.connected_accounts = coerced;
|
|
6065
|
+
}
|
|
6066
|
+
if (config.manageConnections !== void 0) if (config.manageConnections === null) params.manage_connections = null;
|
|
6067
|
+
else params.manage_connections = transformToolRouterUpdateManageConnectionsParams(config.manageConnections);
|
|
6068
|
+
if (config.workbench !== void 0) if (config.workbench === null) params.workbench = null;
|
|
6069
|
+
else params.workbench = transformToolRouterUpdateWorkbenchParams(config.workbench);
|
|
6070
|
+
if (config.multiAccount !== void 0) if (config.multiAccount === null) params.multi_account = null;
|
|
6071
|
+
else {
|
|
6072
|
+
const ma = {};
|
|
6073
|
+
if (config.multiAccount.enable !== void 0) ma.enable = config.multiAccount.enable;
|
|
6074
|
+
if (config.multiAccount.maxAccountsPerToolkit !== void 0) ma.max_accounts_per_toolkit = config.multiAccount.maxAccountsPerToolkit;
|
|
6075
|
+
if (config.multiAccount.requireExplicitSelection !== void 0) ma.require_explicit_selection = config.multiAccount.requireExplicitSelection;
|
|
6076
|
+
params.multi_account = ma;
|
|
6077
|
+
}
|
|
6078
|
+
if (config.preload !== void 0) params.preload = config.preload;
|
|
6079
|
+
return params;
|
|
6080
|
+
};
|
|
5753
6081
|
|
|
5754
6082
|
//#endregion
|
|
5755
6083
|
//#region src/utils/transformers/toolRouterResponseTransform.ts
|
|
@@ -6343,7 +6671,23 @@ function transformProxyParams(params) {
|
|
|
6343
6671
|
function findCustomTool(map, slug) {
|
|
6344
6672
|
if (!map) return void 0;
|
|
6345
6673
|
const upper = slug.toUpperCase();
|
|
6346
|
-
|
|
6674
|
+
const finalSlugMatch = map.byFinalSlug.get(upper);
|
|
6675
|
+
if (finalSlugMatch) return finalSlugMatch;
|
|
6676
|
+
if (map.ambiguousOriginalSlugs?.has(upper)) return void 0;
|
|
6677
|
+
return map.byOriginalSlug.get(upper);
|
|
6678
|
+
}
|
|
6679
|
+
/**
|
|
6680
|
+
* Reject ambiguous bare original slugs before falling through to backend execution.
|
|
6681
|
+
* Agents receive final slugs (LOCAL_<TOOLKIT>_<TOOL>) from schemas, while bare original
|
|
6682
|
+
* slugs are only a convenience for manual session.execute() calls when unique.
|
|
6683
|
+
*/
|
|
6684
|
+
function assertUnambiguousCustomToolSlug(map, slug) {
|
|
6685
|
+
if (!map) return;
|
|
6686
|
+
const upper = slug.toUpperCase();
|
|
6687
|
+
if (!map.ambiguousOriginalSlugs?.has(upper)) return;
|
|
6688
|
+
const finalSlugs = [...map.byFinalSlug.values()].filter((entry) => entry.handle.slug.toUpperCase() === upper).map((entry) => entry.finalSlug).sort();
|
|
6689
|
+
const hint = finalSlugs.length ? ` Use one of: ${finalSlugs.join(", ")}.` : "";
|
|
6690
|
+
throw new ValidationError(`Ambiguous custom tool slug "${slug}". Multiple custom toolkit tools share this original slug; manual session.execute() by original slug is only supported when the original slug is unique.` + hint);
|
|
6347
6691
|
}
|
|
6348
6692
|
/**
|
|
6349
6693
|
* Execute a custom tool in-process.
|
|
@@ -6375,6 +6719,12 @@ async function executeCustomTool(entry, arguments_, sessionContext) {
|
|
|
6375
6719
|
}
|
|
6376
6720
|
}
|
|
6377
6721
|
|
|
6722
|
+
//#endregion
|
|
6723
|
+
//#region src/models/inlineCustomToolsPayload.ts
|
|
6724
|
+
function inlineCustomToolsExperimental(payload) {
|
|
6725
|
+
return payload;
|
|
6726
|
+
}
|
|
6727
|
+
|
|
6378
6728
|
//#endregion
|
|
6379
6729
|
//#region src/models/SessionContext.ts
|
|
6380
6730
|
/**
|
|
@@ -6388,10 +6738,11 @@ async function executeCustomTool(entry, arguments_, sessionContext) {
|
|
|
6388
6738
|
*/
|
|
6389
6739
|
var SessionContextImpl = class {
|
|
6390
6740
|
userId;
|
|
6391
|
-
constructor(client, userId, sessionId, customToolsMap) {
|
|
6741
|
+
constructor(client, userId, sessionId, customToolsMap, inlineCustomToolsPayload) {
|
|
6392
6742
|
this.client = client;
|
|
6393
6743
|
this.sessionId = sessionId;
|
|
6394
6744
|
this.customToolsMap = customToolsMap;
|
|
6745
|
+
this.inlineCustomToolsPayload = inlineCustomToolsPayload;
|
|
6395
6746
|
this.userId = userId;
|
|
6396
6747
|
}
|
|
6397
6748
|
/**
|
|
@@ -6411,10 +6762,14 @@ var SessionContextImpl = class {
|
|
|
6411
6762
|
logId: ""
|
|
6412
6763
|
});
|
|
6413
6764
|
}
|
|
6414
|
-
|
|
6765
|
+
assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
|
|
6766
|
+
const executeParams = {
|
|
6415
6767
|
tool_slug: toolSlug,
|
|
6416
6768
|
arguments: arguments_
|
|
6417
|
-
}
|
|
6769
|
+
};
|
|
6770
|
+
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
6771
|
+
if (experimental) executeParams.experimental = experimental;
|
|
6772
|
+
const response = await this.client.toolRouter.session.execute(this.sessionId, executeParams);
|
|
6418
6773
|
return ToolRouterSessionExecuteResponseSchema.parse(transformExecuteResponse(response));
|
|
6419
6774
|
}
|
|
6420
6775
|
/**
|
|
@@ -6443,6 +6798,21 @@ var SessionContextImpl = class {
|
|
|
6443
6798
|
//#endregion
|
|
6444
6799
|
//#region src/models/ToolRouterSession.ts
|
|
6445
6800
|
const COMPOSIO_MULTI_EXECUTE_TOOL = "COMPOSIO_MULTI_EXECUTE_TOOL";
|
|
6801
|
+
const DIRECT_CUSTOM_TOOL_DESCRIPTION_PREFIX = "[Direct tool - call directly, no search needed beforehand.]";
|
|
6802
|
+
/**
|
|
6803
|
+
* Options accepted by {@link ToolRouterSession.authorize}.
|
|
6804
|
+
*
|
|
6805
|
+
* Validated at the SDK boundary so callers get clear `ValidationError`s for
|
|
6806
|
+
* oversized ACL lists or invalid `userId`s — same caps as the equivalent
|
|
6807
|
+
* `composio.connectedAccounts.link()` path (≤1000 entries per list, each
|
|
6808
|
+
* `userId` 1..256 characters).
|
|
6809
|
+
*/
|
|
6810
|
+
const AuthorizeOptionsSchema = z$1.object({
|
|
6811
|
+
callbackUrl: z$1.string().optional(),
|
|
6812
|
+
alias: z$1.string().optional(),
|
|
6813
|
+
accountType: ConnectedAccountTypeSchema.optional(),
|
|
6814
|
+
aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
|
|
6815
|
+
});
|
|
6446
6816
|
var ToolRouterSession = class {
|
|
6447
6817
|
sessionId;
|
|
6448
6818
|
mcp;
|
|
@@ -6450,6 +6820,8 @@ var ToolRouterSession = class {
|
|
|
6450
6820
|
preload;
|
|
6451
6821
|
configVersion;
|
|
6452
6822
|
warnings;
|
|
6823
|
+
preloadedCustomToolSlugs;
|
|
6824
|
+
inlineCustomToolsPayload;
|
|
6453
6825
|
/** Singleton session context — shared across all custom tool executions */
|
|
6454
6826
|
sessionContext;
|
|
6455
6827
|
constructor(client, config, sessionId, mcp, experimentalOverrides, customToolsMap, userId, metadata) {
|
|
@@ -6467,7 +6839,9 @@ var ToolRouterSession = class {
|
|
|
6467
6839
|
this.preload = metadata?.preload ?? { tools: [] };
|
|
6468
6840
|
this.configVersion = metadata?.configVersion;
|
|
6469
6841
|
this.warnings = metadata?.warnings ?? [];
|
|
6470
|
-
|
|
6842
|
+
this.preloadedCustomToolSlugs = metadata?.preloadedCustomToolSlugs ?? [];
|
|
6843
|
+
this.inlineCustomToolsPayload = metadata?.inlineCustomToolsPayload;
|
|
6844
|
+
if (customToolsMap && userId) this.sessionContext = new SessionContextImpl(client, userId, sessionId, customToolsMap, this.inlineCustomToolsPayload);
|
|
6471
6845
|
telemetry.instrument(this, "ToolRouterSession");
|
|
6472
6846
|
}
|
|
6473
6847
|
/**
|
|
@@ -6480,19 +6854,64 @@ var ToolRouterSession = class {
|
|
|
6480
6854
|
async tools(modifiers) {
|
|
6481
6855
|
const ToolsModel = new Tools(this.client, this.config);
|
|
6482
6856
|
const tools = await ToolsModel.getRawToolRouterSessionTools(this.sessionId, modifiers?.modifySchema ? { modifySchema: modifiers.modifySchema } : void 0);
|
|
6483
|
-
const
|
|
6857
|
+
const sessionTools = await this.addPreloadedCustomTools(tools, modifiers);
|
|
6858
|
+
const toolBySlug = new Map(sessionTools.map((tool) => [tool.slug.toUpperCase(), tool]));
|
|
6484
6859
|
if (this.hasCustomTools()) {
|
|
6485
6860
|
const routingExecuteFn = async (toolSlug, input) => {
|
|
6486
|
-
if (toolSlug === COMPOSIO_MULTI_EXECUTE_TOOL) return this.routeMultiExecute(input, ToolsModel,
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6861
|
+
if (toolSlug === COMPOSIO_MULTI_EXECUTE_TOOL) return this.routeMultiExecute(input, ToolsModel, sessionTools, modifiers);
|
|
6862
|
+
const customTool = findCustomTool(this.customToolsMap, toolSlug);
|
|
6863
|
+
if (customTool) return executeCustomTool(customTool, input, this.sessionContext);
|
|
6864
|
+
assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
|
|
6865
|
+
return this.executeBackendSessionTool(ToolsModel, toolSlug, input, modifiers, toolBySlug.get(toolSlug.toUpperCase()));
|
|
6491
6866
|
};
|
|
6492
6867
|
if (!this.config?.provider) throw new Error("A provider is required when using custom tools with session.tools(). Pass a provider in the Composio constructor.");
|
|
6493
|
-
return this.config.provider.wrapTools(
|
|
6868
|
+
return this.config.provider.wrapTools(sessionTools, routingExecuteFn);
|
|
6869
|
+
}
|
|
6870
|
+
return ToolsModel.wrapToolsForToolRouter(this.sessionId, sessionTools, modifiers);
|
|
6871
|
+
}
|
|
6872
|
+
async addPreloadedCustomTools(tools, modifiers) {
|
|
6873
|
+
const customTools = await this.getPreloadedCustomToolSchemas(modifiers);
|
|
6874
|
+
if (!customTools.length) return tools;
|
|
6875
|
+
const existingSlugs = new Set(tools.map((tool) => tool.slug.toUpperCase()));
|
|
6876
|
+
const appendedTools = customTools.filter((tool) => !existingSlugs.has(tool.slug.toUpperCase()));
|
|
6877
|
+
if (!appendedTools.length) return tools;
|
|
6878
|
+
return [...tools, ...appendedTools];
|
|
6879
|
+
}
|
|
6880
|
+
async getPreloadedCustomToolSchemas(modifiers) {
|
|
6881
|
+
if (!this.customToolsMap || !this.preloadedCustomToolSlugs.length) return [];
|
|
6882
|
+
const tools = [];
|
|
6883
|
+
for (const slug of this.preloadedCustomToolSlugs) {
|
|
6884
|
+
const entry = findCustomToolMapEntryByFinalSlug(this.customToolsMap, slug);
|
|
6885
|
+
if (!entry) continue;
|
|
6886
|
+
let tool = this.customToolEntryToTool(entry);
|
|
6887
|
+
if (modifiers?.modifySchema) tool = await modifiers.modifySchema({
|
|
6888
|
+
toolSlug: tool.slug,
|
|
6889
|
+
toolkitSlug: tool.toolkit?.slug ?? "custom",
|
|
6890
|
+
schema: tool
|
|
6891
|
+
});
|
|
6892
|
+
tools.push(tool);
|
|
6494
6893
|
}
|
|
6495
|
-
return
|
|
6894
|
+
return tools;
|
|
6895
|
+
}
|
|
6896
|
+
customToolEntryToTool(entry) {
|
|
6897
|
+
const toolkitSlug = entry.toolkit ?? "custom";
|
|
6898
|
+
const toolkitName = (this.customToolsMap?.toolkits?.find((toolkit) => toolkit.slug.toLowerCase() === toolkitSlug.toLowerCase()))?.name ?? entry.toolkit ?? "Custom";
|
|
6899
|
+
return {
|
|
6900
|
+
slug: entry.finalSlug,
|
|
6901
|
+
name: entry.handle.name,
|
|
6902
|
+
description: `${DIRECT_CUSTOM_TOOL_DESCRIPTION_PREFIX}\n${entry.handle.description}`,
|
|
6903
|
+
inputParameters: entry.handle.inputSchema,
|
|
6904
|
+
outputParameters: entry.handle.outputSchema,
|
|
6905
|
+
tags: [],
|
|
6906
|
+
toolkit: {
|
|
6907
|
+
slug: toolkitSlug,
|
|
6908
|
+
name: toolkitName
|
|
6909
|
+
},
|
|
6910
|
+
isDeprecated: false,
|
|
6911
|
+
availableVersions: [],
|
|
6912
|
+
scopes: [],
|
|
6913
|
+
isNoAuth: !entry.handle.extendsToolkit
|
|
6914
|
+
};
|
|
6496
6915
|
}
|
|
6497
6916
|
/**
|
|
6498
6917
|
* List all custom tools registered in this session.
|
|
@@ -6528,7 +6947,7 @@ var ToolRouterSession = class {
|
|
|
6528
6947
|
description: tk.description,
|
|
6529
6948
|
tools: tk.tools.map((tool) => {
|
|
6530
6949
|
return {
|
|
6531
|
-
slug: this.customToolsMap.byOriginalSlug.get(tool.slug.toUpperCase())?.finalSlug ?? tool.slug,
|
|
6950
|
+
slug: (findCustomToolMapEntryByToolkitAndOriginalSlug(this.customToolsMap, tk.slug, tool.slug) ?? this.customToolsMap.byOriginalSlug.get(tool.slug.toUpperCase()))?.finalSlug ?? tool.slug,
|
|
6532
6951
|
name: tool.name,
|
|
6533
6952
|
description: tool.description,
|
|
6534
6953
|
toolkit: tk.slug,
|
|
@@ -6541,13 +6960,39 @@ var ToolRouterSession = class {
|
|
|
6541
6960
|
/**
|
|
6542
6961
|
* Initiate an authorization flow for a toolkit.
|
|
6543
6962
|
* Returns a ConnectionRequest with a redirect URL for the user.
|
|
6963
|
+
*
|
|
6964
|
+
* Use `accountType` and `aclConfigForShared` to create a SHARED connection
|
|
6965
|
+
* with a per-user ACL in one flow. Default behaviour (omit both) creates
|
|
6966
|
+
* a PRIVATE connection.
|
|
6967
|
+
*
|
|
6968
|
+
* `aclConfigForShared` is validated against the same caps as
|
|
6969
|
+
* `composio.connectedAccounts.link()` (≤1000 entries per list, each
|
|
6970
|
+
* `userId` 1..256 characters). Invalid input throws `ValidationError`
|
|
6971
|
+
* at the SDK boundary.
|
|
6544
6972
|
*/
|
|
6545
6973
|
async authorize(toolkit, options) {
|
|
6546
|
-
const
|
|
6974
|
+
const requestOptions = AuthorizeOptionsSchema.safeParse(options ?? {});
|
|
6975
|
+
if (!requestOptions.success) throw new ValidationError("Failed to parse tool router authorize options", { cause: requestOptions.error });
|
|
6976
|
+
const opts = requestOptions.data;
|
|
6977
|
+
const aclWire = opts.aclConfigForShared === void 0 ? void 0 : {
|
|
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
|
+
};
|
|
6982
|
+
const body = {
|
|
6547
6983
|
toolkit,
|
|
6548
|
-
...
|
|
6549
|
-
...
|
|
6550
|
-
|
|
6984
|
+
...opts.callbackUrl !== void 0 && { callback_url: opts.callbackUrl },
|
|
6985
|
+
...opts.alias !== void 0 && { alias: opts.alias },
|
|
6986
|
+
...opts.accountType !== void 0 && { account_type: opts.accountType },
|
|
6987
|
+
...aclWire !== void 0 && { acl_config_for_shared: aclWire }
|
|
6988
|
+
};
|
|
6989
|
+
let response;
|
|
6990
|
+
try {
|
|
6991
|
+
response = await this.client.toolRouter.session.link(this.sessionId, body);
|
|
6992
|
+
} catch (error) {
|
|
6993
|
+
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 });
|
|
6994
|
+
throw error;
|
|
6995
|
+
}
|
|
6551
6996
|
return createConnectionRequest(this.client, response.connected_account_id, ConnectedAccountStatuses.INITIATED, response.redirect_url);
|
|
6552
6997
|
}
|
|
6553
6998
|
/**
|
|
@@ -6594,10 +7039,13 @@ var ToolRouterSession = class {
|
|
|
6594
7039
|
* Returns relevant tools for the given query with schemas and guidance.
|
|
6595
7040
|
*/
|
|
6596
7041
|
async search(params) {
|
|
6597
|
-
const
|
|
7042
|
+
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
7043
|
+
const searchParams = {
|
|
6598
7044
|
queries: [{ use_case: params.query }],
|
|
6599
|
-
...params.toolkits?.length ? { toolkits: params.toolkits } : {}
|
|
6600
|
-
|
|
7045
|
+
...params.toolkits?.length ? { toolkits: params.toolkits } : {},
|
|
7046
|
+
...experimental ? { experimental } : {}
|
|
7047
|
+
};
|
|
7048
|
+
const transformed = transformSearchResponse(await this.client.toolRouter.session.search(this.sessionId, searchParams));
|
|
6601
7049
|
return ToolRouterSessionSearchResponseSchema.parse(transformed);
|
|
6602
7050
|
}
|
|
6603
7051
|
/**
|
|
@@ -6623,11 +7071,14 @@ var ToolRouterSession = class {
|
|
|
6623
7071
|
logId: ""
|
|
6624
7072
|
};
|
|
6625
7073
|
}
|
|
7074
|
+
assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
|
|
6626
7075
|
const executeParams = {
|
|
6627
7076
|
tool_slug: toolSlug,
|
|
6628
7077
|
arguments: arguments_ ?? {}
|
|
6629
7078
|
};
|
|
6630
7079
|
if (options?.account) executeParams.account = options.account;
|
|
7080
|
+
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
7081
|
+
if (experimental) executeParams.experimental = experimental;
|
|
6631
7082
|
const transformed = transformExecuteResponse(await this.client.toolRouter.session.execute(this.sessionId, executeParams));
|
|
6632
7083
|
return ToolRouterSessionExecuteResponseSchema.parse(transformed);
|
|
6633
7084
|
}
|
|
@@ -6655,10 +7106,31 @@ var ToolRouterSession = class {
|
|
|
6655
7106
|
} } : {}
|
|
6656
7107
|
};
|
|
6657
7108
|
}
|
|
7109
|
+
/**
|
|
7110
|
+
* Partially update the session configuration.
|
|
7111
|
+
* Only the fields provided will be changed; omitted fields are preserved.
|
|
7112
|
+
* Mutates this session's `configVersion`, `preload`, and `warnings` in-place.
|
|
7113
|
+
*/
|
|
7114
|
+
async update(config) {
|
|
7115
|
+
const params = transformToolRouterUpdateParams(ToolRouterUpdateSessionConfigSchema.parse(config));
|
|
7116
|
+
const response = await this.client.toolRouter.session.patch(this.sessionId, params);
|
|
7117
|
+
this.configVersion = response.config_version;
|
|
7118
|
+
this.preload = response.config.preload;
|
|
7119
|
+
this.warnings = response.warnings ?? [];
|
|
7120
|
+
}
|
|
6658
7121
|
/** Check if this session has any custom tools bound. */
|
|
6659
7122
|
hasCustomTools() {
|
|
6660
7123
|
return (this.customToolsMap?.byFinalSlug.size ?? 0) > 0;
|
|
6661
7124
|
}
|
|
7125
|
+
executeBackendSessionTool(ToolsModel, toolSlug, input, modifiers, tool) {
|
|
7126
|
+
const body = {
|
|
7127
|
+
sessionId: this.sessionId,
|
|
7128
|
+
arguments: input
|
|
7129
|
+
};
|
|
7130
|
+
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
7131
|
+
if (experimental) return ToolsModel.executeSessionTool(toolSlug, body, modifiers, tool, { experimental });
|
|
7132
|
+
return ToolsModel.executeSessionTool(toolSlug, body, modifiers, tool);
|
|
7133
|
+
}
|
|
6662
7134
|
/** Parse an individual tool item from COMPOSIO_MULTI_EXECUTE_TOOL's tools array */
|
|
6663
7135
|
parseToolItem(item) {
|
|
6664
7136
|
if (typeof item !== "object" || item === null) return {
|
|
@@ -6679,10 +7151,7 @@ var ToolRouterSession = class {
|
|
|
6679
7151
|
async routeMultiExecute(input, ToolsModel, tools, modifiers) {
|
|
6680
7152
|
const multiExecuteTool = tools.find((tool) => tool.slug === COMPOSIO_MULTI_EXECUTE_TOOL);
|
|
6681
7153
|
const toolItems = input.tools;
|
|
6682
|
-
if (!Array.isArray(toolItems) || toolItems.length === 0) return
|
|
6683
|
-
sessionId: this.sessionId,
|
|
6684
|
-
arguments: input
|
|
6685
|
-
}, modifiers, multiExecuteTool);
|
|
7154
|
+
if (!Array.isArray(toolItems) || toolItems.length === 0) return this.executeBackendSessionTool(ToolsModel, COMPOSIO_MULTI_EXECUTE_TOOL, input, modifiers, multiExecuteTool);
|
|
6686
7155
|
const parsed = toolItems.map((item) => this.parseToolItem(item));
|
|
6687
7156
|
const localItems = [];
|
|
6688
7157
|
const remoteIndices = [];
|
|
@@ -6692,12 +7161,12 @@ var ToolRouterSession = class {
|
|
|
6692
7161
|
index: i,
|
|
6693
7162
|
entry
|
|
6694
7163
|
});
|
|
6695
|
-
else
|
|
7164
|
+
else {
|
|
7165
|
+
assertUnambiguousCustomToolSlug(this.customToolsMap, parsed[i].tool_slug);
|
|
7166
|
+
remoteIndices.push(i);
|
|
7167
|
+
}
|
|
6696
7168
|
}
|
|
6697
|
-
if (localItems.length === 0) return
|
|
6698
|
-
sessionId: this.sessionId,
|
|
6699
|
-
arguments: input
|
|
6700
|
-
}, modifiers, multiExecuteTool);
|
|
7169
|
+
if (localItems.length === 0) return this.executeBackendSessionTool(ToolsModel, COMPOSIO_MULTI_EXECUTE_TOOL, input, modifiers, multiExecuteTool);
|
|
6701
7170
|
const ctx = this.sessionContext;
|
|
6702
7171
|
const localPromises = localItems.map(async ({ index, entry }) => {
|
|
6703
7172
|
return {
|
|
@@ -6712,10 +7181,7 @@ var ToolRouterSession = class {
|
|
|
6712
7181
|
...input,
|
|
6713
7182
|
tools: remoteToolItems
|
|
6714
7183
|
};
|
|
6715
|
-
remotePromise =
|
|
6716
|
-
sessionId: this.sessionId,
|
|
6717
|
-
arguments: remoteInput
|
|
6718
|
-
}, modifiers, multiExecuteTool);
|
|
7184
|
+
remotePromise = this.executeBackendSessionTool(ToolsModel, COMPOSIO_MULTI_EXECUTE_TOOL, remoteInput, modifiers, multiExecuteTool);
|
|
6719
7185
|
}
|
|
6720
7186
|
const [localResults, remoteResult] = await Promise.all([Promise.all(localPromises), remotePromise]);
|
|
6721
7187
|
if (remoteIndices.length === 0 && localResults.length === 1) return localResults[0].result;
|
|
@@ -6767,6 +7233,19 @@ function getSessionMetadata(session) {
|
|
|
6767
7233
|
warnings: "warnings" in session ? session.warnings ?? [] : []
|
|
6768
7234
|
};
|
|
6769
7235
|
}
|
|
7236
|
+
function preloadsAllCustomTools(preload) {
|
|
7237
|
+
return preload?.tools === PRELOAD_TOOLS_ALL;
|
|
7238
|
+
}
|
|
7239
|
+
function prepareInlineCustomTools(options) {
|
|
7240
|
+
const { customTools, customToolkits, defaultPreload = false, preloadTools } = options;
|
|
7241
|
+
assertNoCustomToolSlugsInPreload(preloadTools, !!(customTools?.length || customToolkits?.length) ? buildCustomToolsMap(customTools ?? [], customToolkits) : void 0);
|
|
7242
|
+
const serializedTools = customTools?.length ? serializeCustomTools(customTools, { defaultPreload }) : void 0;
|
|
7243
|
+
const serializedToolkits = customToolkits?.length ? serializeCustomToolkits(customToolkits, { defaultPreload }) : void 0;
|
|
7244
|
+
return serializedTools || serializedToolkits ? {
|
|
7245
|
+
...serializedTools ? { custom_tools: serializedTools } : {},
|
|
7246
|
+
...serializedToolkits ? { custom_toolkits: serializedToolkits } : {}
|
|
7247
|
+
} : void 0;
|
|
7248
|
+
}
|
|
6770
7249
|
var ToolRouter = class {
|
|
6771
7250
|
constructor(client, config) {
|
|
6772
7251
|
this.client = client;
|
|
@@ -6782,6 +7261,8 @@ var ToolRouter = class {
|
|
|
6782
7261
|
}
|
|
6783
7262
|
/**
|
|
6784
7263
|
* Creates a new tool router session for a user.
|
|
7264
|
+
* Use `sessionPreset: SessionPreset.DIRECT_TOOLS` when all needed tools
|
|
7265
|
+
* should be exposed directly; see `ToolRouterCreateSessionConfig`.
|
|
6785
7266
|
*
|
|
6786
7267
|
* @param userId {string} The user id to create the session for
|
|
6787
7268
|
* @param config {ToolRouterCreateSessionConfig} The config for the tool router session
|
|
@@ -6789,7 +7270,7 @@ var ToolRouter = class {
|
|
|
6789
7270
|
*
|
|
6790
7271
|
* @example
|
|
6791
7272
|
* ```typescript
|
|
6792
|
-
* import { Composio
|
|
7273
|
+
* import { Composio } from '@composio/core';
|
|
6793
7274
|
*
|
|
6794
7275
|
* const composio = new Composio();
|
|
6795
7276
|
*
|
|
@@ -6805,17 +7286,26 @@ var ToolRouter = class {
|
|
|
6805
7286
|
*/
|
|
6806
7287
|
async create(userId, config) {
|
|
6807
7288
|
const routerConfig = ToolRouterCreateSessionConfigSchema.parse(config ?? {});
|
|
7289
|
+
const isDirectToolsPreset = routerConfig.sessionPreset === SessionPreset.DIRECT_TOOLS;
|
|
6808
7290
|
const customTools = routerConfig.experimental?.customTools;
|
|
6809
7291
|
const customToolkits = routerConfig.experimental?.customToolkits;
|
|
7292
|
+
const defaultCustomPreload = preloadsAllCustomTools(routerConfig.preload);
|
|
7293
|
+
const inlineCustomToolsPayload = prepareInlineCustomTools({
|
|
7294
|
+
customTools,
|
|
7295
|
+
customToolkits,
|
|
7296
|
+
defaultPreload: defaultCustomPreload,
|
|
7297
|
+
preloadTools: routerConfig.preload?.tools
|
|
7298
|
+
});
|
|
6810
7299
|
const experimentalPayload = {};
|
|
6811
7300
|
if (routerConfig.experimental?.assistivePrompt?.userTimezone) experimentalPayload.assistive_prompt_config = { user_timezone: routerConfig.experimental.assistivePrompt.userTimezone };
|
|
6812
|
-
if (
|
|
6813
|
-
if (
|
|
7301
|
+
if (inlineCustomToolsPayload?.custom_tools) experimentalPayload.custom_tools = inlineCustomToolsPayload.custom_tools;
|
|
7302
|
+
if (inlineCustomToolsPayload?.custom_toolkits) experimentalPayload.custom_toolkits = inlineCustomToolsPayload.custom_toolkits;
|
|
6814
7303
|
const multiAccountPayload = transformToolRouterMultiAccountParams(routerConfig.multiAccount);
|
|
7304
|
+
const connectedAccountsPayload = routerConfig.connectedAccounts === void 0 ? void 0 : Object.fromEntries(Object.entries(routerConfig.connectedAccounts).map(([toolkit, ids]) => [toolkit, typeof ids === "string" ? [ids] : ids]));
|
|
6815
7305
|
const payload = {
|
|
6816
7306
|
user_id: userId,
|
|
6817
7307
|
auth_configs: routerConfig.authConfigs,
|
|
6818
|
-
connected_accounts:
|
|
7308
|
+
connected_accounts: connectedAccountsPayload,
|
|
6819
7309
|
toolkits: transformToolRouterToolkitsParams(routerConfig.toolkits),
|
|
6820
7310
|
tools: transformToolRouterToolsParams(routerConfig.tools),
|
|
6821
7311
|
tags: transformToolRouterTagsParams(routerConfig.tags),
|
|
@@ -6823,13 +7313,22 @@ var ToolRouter = class {
|
|
|
6823
7313
|
workbench: transformToolRouterWorkbenchParams(routerConfig.workbench),
|
|
6824
7314
|
multi_account: multiAccountPayload,
|
|
6825
7315
|
preload: routerConfig.preload,
|
|
7316
|
+
...isDirectToolsPreset && {
|
|
7317
|
+
search: { enable: false },
|
|
7318
|
+
execute: { enable_multi_execute: false }
|
|
7319
|
+
},
|
|
6826
7320
|
experimental: Object.keys(experimentalPayload).length > 0 ? experimentalPayload : void 0
|
|
6827
7321
|
};
|
|
6828
7322
|
const session = await this.client.toolRouter.session.create(payload);
|
|
6829
7323
|
let customToolsMap;
|
|
6830
7324
|
if (customTools?.length || customToolkits?.length) customToolsMap = buildCustomToolsMapFromResponse(customTools ?? [], customToolkits, session.experimental);
|
|
7325
|
+
const metadata = {
|
|
7326
|
+
...getSessionMetadata(session),
|
|
7327
|
+
preloadedCustomToolSlugs: getPreloadedCustomToolSlugs(customToolsMap, defaultCustomPreload),
|
|
7328
|
+
inlineCustomToolsPayload
|
|
7329
|
+
};
|
|
6831
7330
|
const assistivePrompt = session.experimental?.assistive_prompt;
|
|
6832
|
-
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), { assistivePrompt }, customToolsMap, userId,
|
|
7331
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), { assistivePrompt }, customToolsMap, userId, metadata);
|
|
6833
7332
|
}
|
|
6834
7333
|
/**
|
|
6835
7334
|
* Use an existing session
|
|
@@ -6848,9 +7347,36 @@ var ToolRouter = class {
|
|
|
6848
7347
|
* console.log(session.mcp.headers);
|
|
6849
7348
|
* ```
|
|
6850
7349
|
*/
|
|
6851
|
-
async use(id) {
|
|
6852
|
-
const
|
|
6853
|
-
|
|
7350
|
+
async use(id, options) {
|
|
7351
|
+
const customTools = options?.customTools;
|
|
7352
|
+
const customToolkits = options?.customToolkits;
|
|
7353
|
+
const hasCustoms = !!(customTools?.length || customToolkits?.length);
|
|
7354
|
+
let session;
|
|
7355
|
+
const attachInlineCustomToolsPayload = prepareInlineCustomTools({
|
|
7356
|
+
customTools,
|
|
7357
|
+
customToolkits
|
|
7358
|
+
});
|
|
7359
|
+
let inlineCustomToolsPayload = attachInlineCustomToolsPayload;
|
|
7360
|
+
if (hasCustoms) session = await this.client.toolRouter.session.attach(id, { experimental: attachInlineCustomToolsPayload });
|
|
7361
|
+
else session = await this.client.toolRouter.session.retrieve(id);
|
|
7362
|
+
const defaultCustomPreload = preloadsAllCustomTools(session.config.preload);
|
|
7363
|
+
if (hasCustoms && defaultCustomPreload) inlineCustomToolsPayload = prepareInlineCustomTools({
|
|
7364
|
+
customTools,
|
|
7365
|
+
customToolkits,
|
|
7366
|
+
defaultPreload: true
|
|
7367
|
+
});
|
|
7368
|
+
let customToolsMap;
|
|
7369
|
+
let userId;
|
|
7370
|
+
if (hasCustoms) {
|
|
7371
|
+
customToolsMap = buildCustomToolsMapFromResponse(customTools ?? [], customToolkits, session.experimental);
|
|
7372
|
+
userId = session.config.user_id;
|
|
7373
|
+
}
|
|
7374
|
+
const metadata = {
|
|
7375
|
+
...getSessionMetadata(session),
|
|
7376
|
+
preloadedCustomToolSlugs: getPreloadedCustomToolSlugs(customToolsMap, defaultCustomPreload),
|
|
7377
|
+
inlineCustomToolsPayload
|
|
7378
|
+
};
|
|
7379
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), void 0, customToolsMap, userId, metadata);
|
|
6854
7380
|
}
|
|
6855
7381
|
};
|
|
6856
7382
|
|
|
@@ -6897,6 +7423,8 @@ var Composio = class Composio {
|
|
|
6897
7423
|
toolRouter;
|
|
6898
7424
|
/**
|
|
6899
7425
|
* Creates a new tool router session for a user.
|
|
7426
|
+
* Use `sessionPreset: SessionPreset.DIRECT_TOOLS` when all needed tools
|
|
7427
|
+
* should be exposed directly; see `ToolRouterCreateSessionConfig`.
|
|
6900
7428
|
*
|
|
6901
7429
|
* @param userId {string} The user id to create the session for
|
|
6902
7430
|
* @param config {ToolRouterConfig} The config for the tool router session
|
|
@@ -7140,6 +7668,107 @@ var ComposioProvider = class extends BaseNonAgenticProvider {
|
|
|
7140
7668
|
|
|
7141
7669
|
//#endregion
|
|
7142
7670
|
//#region src/utils/jsonSchema.ts
|
|
7671
|
+
const MAX_REF_CHAIN_DEPTH = 100;
|
|
7672
|
+
const MAX_NODE_DEPTH = 512;
|
|
7673
|
+
const CYCLE_BREAK_SENTINEL = {
|
|
7674
|
+
type: "object",
|
|
7675
|
+
additionalProperties: true
|
|
7676
|
+
};
|
|
7677
|
+
const POLLUTING_KEYS = new Set([
|
|
7678
|
+
"__proto__",
|
|
7679
|
+
"constructor",
|
|
7680
|
+
"prototype"
|
|
7681
|
+
]);
|
|
7682
|
+
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
|
+
const decodePointerSegment = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
7684
|
+
const failResolution = (pointer, segment) => {
|
|
7685
|
+
throw new JsonSchemaRefResolutionError(`Cannot resolve $ref ${pointer}`, {
|
|
7686
|
+
meta: {
|
|
7687
|
+
ref: pointer,
|
|
7688
|
+
failedAt: segment
|
|
7689
|
+
},
|
|
7690
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
7691
|
+
});
|
|
7692
|
+
};
|
|
7693
|
+
const stepInto = (cursor, segment, pointer) => {
|
|
7694
|
+
if (cursor === null || typeof cursor !== "object") failResolution(pointer, segment);
|
|
7695
|
+
if (Array.isArray(cursor)) {
|
|
7696
|
+
const i = Number(segment);
|
|
7697
|
+
if (!Number.isInteger(i) || i < 0 || i >= cursor.length) failResolution(pointer, segment);
|
|
7698
|
+
return cursor[i];
|
|
7699
|
+
}
|
|
7700
|
+
const obj = cursor;
|
|
7701
|
+
if (!Object.prototype.hasOwnProperty.call(obj, segment)) failResolution(pointer, segment);
|
|
7702
|
+
return obj[segment];
|
|
7703
|
+
};
|
|
7704
|
+
const resolvePointer = (root, pointer) => {
|
|
7705
|
+
if (pointer === "#" || pointer === "") return root;
|
|
7706
|
+
if (!pointer.startsWith("#/")) throw new JsonSchemaRefResolutionError(`Unsupported $ref pointer: ${pointer}`, {
|
|
7707
|
+
meta: { ref: pointer },
|
|
7708
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
7709
|
+
});
|
|
7710
|
+
return pointer.slice(2).split("/").map(decodePointerSegment).reduce((cursor, seg) => stepInto(cursor, seg, pointer), root);
|
|
7711
|
+
};
|
|
7712
|
+
/**
|
|
7713
|
+
* Inlines internal JSON Schema `$ref` pointers (`#/$defs/...` and legacy
|
|
7714
|
+
* `#/definitions/...`) so the returned schema can be safely handed to
|
|
7715
|
+
* consumers that don't tolerate unresolved references (e.g. AJV in
|
|
7716
|
+
* `@mastra/schema-compat`). External (`http://`, `https://`, …) refs are
|
|
7717
|
+
* left untouched. Cycles are broken with `{ type: 'object',
|
|
7718
|
+
* additionalProperties: true }`. The input is never mutated.
|
|
7719
|
+
*
|
|
7720
|
+
* @throws {JsonSchemaRefResolutionError} on malformed pointers, missing
|
|
7721
|
+
* targets, or chains past the depth cap.
|
|
7722
|
+
*/
|
|
7723
|
+
function dereferenceJsonSchema(schema) {
|
|
7724
|
+
if (!isPlainObject(schema)) return schema;
|
|
7725
|
+
const root = schema;
|
|
7726
|
+
const visiting = /* @__PURE__ */ new WeakSet();
|
|
7727
|
+
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)]));
|
|
7728
|
+
function walk(node, visitedRefs, chainDepth, nodeDepth) {
|
|
7729
|
+
if (nodeDepth >= MAX_NODE_DEPTH) throw new JsonSchemaRefResolutionError(`JSON Schema node depth exceeded cap (${MAX_NODE_DEPTH})`, { possibleFixes: REF_RESOLUTION_FIXES });
|
|
7730
|
+
if (Array.isArray(node)) {
|
|
7731
|
+
if (visiting.has(node)) return { ...CYCLE_BREAK_SENTINEL };
|
|
7732
|
+
visiting.add(node);
|
|
7733
|
+
try {
|
|
7734
|
+
return node.map((item) => walk(item, visitedRefs, chainDepth, nodeDepth + 1));
|
|
7735
|
+
} finally {
|
|
7736
|
+
visiting.delete(node);
|
|
7737
|
+
}
|
|
7738
|
+
}
|
|
7739
|
+
if (!isPlainObject(node)) return node;
|
|
7740
|
+
if (visiting.has(node)) return { ...CYCLE_BREAK_SENTINEL };
|
|
7741
|
+
visiting.add(node);
|
|
7742
|
+
try {
|
|
7743
|
+
const ref = typeof node.$ref === "string" ? node.$ref : null;
|
|
7744
|
+
if (ref === null || !ref.startsWith("#")) {
|
|
7745
|
+
if (ref !== null) logger_default.warn(`Leaving external $ref untouched: ${ref}`);
|
|
7746
|
+
return cloneChildren(node, visitedRefs, chainDepth, nodeDepth);
|
|
7747
|
+
}
|
|
7748
|
+
if (chainDepth >= MAX_REF_CHAIN_DEPTH) throw new JsonSchemaRefResolutionError(`JSON Schema $ref chain exceeded depth cap (${MAX_REF_CHAIN_DEPTH}): ${ref}`, {
|
|
7749
|
+
meta: { ref },
|
|
7750
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
7751
|
+
});
|
|
7752
|
+
if (visitedRefs.has(ref)) return { ...CYCLE_BREAK_SENTINEL };
|
|
7753
|
+
const resolved = walk(resolvePointer(root, ref), new Set(visitedRefs).add(ref), chainDepth + 1, nodeDepth + 1);
|
|
7754
|
+
const siblings = { ...node };
|
|
7755
|
+
delete siblings.$ref;
|
|
7756
|
+
if (Object.keys(siblings).length === 0 || !isPlainObject(resolved)) return resolved;
|
|
7757
|
+
return {
|
|
7758
|
+
...resolved,
|
|
7759
|
+
...cloneChildren(siblings, visitedRefs, chainDepth, nodeDepth)
|
|
7760
|
+
};
|
|
7761
|
+
} finally {
|
|
7762
|
+
visiting.delete(node);
|
|
7763
|
+
}
|
|
7764
|
+
}
|
|
7765
|
+
const out = walk(root, /* @__PURE__ */ new Set(), 0, 0);
|
|
7766
|
+
if (isPlainObject(out)) {
|
|
7767
|
+
delete out.$defs;
|
|
7768
|
+
delete out.definitions;
|
|
7769
|
+
}
|
|
7770
|
+
return out;
|
|
7771
|
+
}
|
|
7143
7772
|
/**
|
|
7144
7773
|
* Removes all non-required properties from the schema
|
|
7145
7774
|
*
|
|
@@ -7678,4 +8307,4 @@ const ComposioMcpUpdateResponseSchema = z$1.object({
|
|
|
7678
8307
|
});
|
|
7679
8308
|
|
|
7680
8309
|
//#endregion
|
|
7681
|
-
export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomCreateResponseSchema, ComposioCustomToolsNotInitializedError, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioFileNotFoundError, ComposioFileUploadAbortedError, ComposioFileUploadError, ComposioFileUploadPathNotAllowedError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioSensitiveFilePathBlockedError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAuthConfigSchema, ConnectedAccountErrorCodes, ConnectedAccountListParamsSchema, ConnectedAccountListResponseSchema, ConnectedAccountRefreshOptionsSchema, ConnectedAccountRetrieveResponseSchema, ConnectedAccountStatusSchema, ConnectedAccountStatuses, 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, FileDeleteResponseSchema, FileListResponseSchema, FileModifierErrorCodes, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, 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, OpenAIProvider, RedirectableAuthSchemeSchema, RemoteFile, RemoteFileDataSchema, RemoteFileDownloadError, RemoteFileErrorCodes, SDKErrorCodes, SandboxSizeSchema, 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, 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, UpdateConnectedAccountParamsSchema, ValidationError, ValidationErrorCodes, VerifyWebhookParamsSchema, WebhookConnectedAccountAuthConfigSchema, WebhookConnectionMetadataSchema, WebhookConnectionStateSchema, WebhookEventSchema, WebhookEventTypes, WebhookPayloadSchema, WebhookPayloadV1Schema, WebhookPayloadV2Schema, WebhookPayloadV3Schema, WebhookTriggerPayloadV3Schema, WebhookVersions, constants_exports as constants, createConnectionRequest, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit, getExtensionFromMimeType, handleToolExecutionError, jsonSchemaToZodSchema, logger_default as logger, removeNonRequiredProperties };
|
|
8310
|
+
export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAclOnlyForSharedError, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomCreateResponseSchema, ComposioCustomToolsNotInitializedError, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioFileNotFoundError, ComposioFileUploadAbortedError, ComposioFileUploadError, ComposioFileUploadPathNotAllowedError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioLegacyConnectedAccountsEndpointRetiredError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioSensitiveFilePathBlockedError, ComposioSharedAccessDeniedError, ComposioSharedConnectionNotAccessibleError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAclConfigResponseSchema, ConnectedAccountAclConfigSchema, ConnectedAccountAuthConfigSchema, ConnectedAccountErrorCodes, 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, FileDeleteResponseSchema, FileListResponseSchema, FileModifierErrorCodes, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, JsonSchemaRefResolutionError, JsonSchemaToZodError, MCP, MCPAuthOptionsSchema, MCPGenerateURLParamsSchema, MCPGetServerParamsSchema, MCPMultiAppServerSchema, MCPServerCreateResponseSchema, MCPServerListResponseSchema, MCPServerSchema, MCPServerTypeSchema, MCPServerUpdateParamsSchema, MCPSingleAppServerSchema, MCPToolkitConfigSchema, MCPToolkitConfigsArraySchema, McpDeleteResponseSchema, McpListResponseSchema, McpRetrieveResponseSchema, McpUpdateResponseSchema, Oauth1ActiveConnectionDataSchema, Oauth1ConnectionDataSchema, Oauth1ExpiredConnectionDataSchema, Oauth1FailedConnectionDataSchema, Oauth1InactiveConnectionDataSchema, Oauth1InitiatedConnectionDataSchema, Oauth1InitiatingConnectionDataSchema, Oauth2ActiveConnectionDataSchema, Oauth2ConnectionDataSchema, Oauth2ExpiredConnectionDataSchema, Oauth2FailedConnectionDataSchema, Oauth2InactiveConnectionDataSchema, Oauth2InitiatedConnectionDataSchema, Oauth2InitiatingConnectionDataSchema, Oauth2RevokedConnectionDataSchema, OpenAIProvider, RedirectableAuthSchemeSchema, RemoteFile, RemoteFileDataSchema, RemoteFileDownloadError, RemoteFileErrorCodes, SDKErrorCodes, SandboxSizeSchema, SessionPreset, SessionProxyExecuteParamsSchema, SingleConnectedAccountDetailedResponseSchema, ToolErrorCodes, ToolExecuteMetaParamsSchema, ToolExecuteParamsSchema, ToolExecuteResponseSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterSession, ToolRouterSessionExecuteResponseSchema, ToolRouterSessionFilesMountDeleteOptionsSchema, ToolRouterSessionFilesMountDownloadOptionsSchema, ToolRouterSessionFilesMountListOptionsSchema, ToolRouterSessionFilesMountUploadOptionsSchema, ToolRouterSessionSearchResponseSchema, ToolRouterTagsEnableDisableSchema, ToolRouterTagsParamSchema, ToolRouterToolkitsDisabledConfigSchema, ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsOptionsSchema, ToolRouterToolkitsParamSchema, ToolRouterToolsParamSchema, ToolRouterUpdateSessionConfigSchema, ToolSchema, ToolkitAuthConfigDetailsSchema, ToolkitAuthFieldSchema, ToolkitAuthFieldsResponseSchema, ToolkitCategorySchema, ToolkitConnectionStateSchema, ToolkitConnectionsDetailsSchema, ToolkitErrorCodes, ToolkitLatestVersionSchema, ToolkitMangedByEnumSchema, ToolkitRetrieveCategoriesResponseSchema, ToolkitRetrieveResponseSchema, ToolkitSchema, ToolkitSortByEnumSchema, ToolkitVersionParamSchema, ToolkitVersionSchema, ToolkitVersionsSchema, ToolkitsListParamsSchema, TriggerErrorCodes, TriggerInstanceListActiveParamsSchema, TriggerInstanceListActiveResponseItemSchema, TriggerInstanceListActiveResponseSchema, TriggerInstanceManageDeleteResponseSchema, TriggerInstanceManageUpdateParamsSchema, TriggerInstanceManageUpdateResponseSchema, TriggerInstanceUpsertParamsSchema, TriggerInstanceUpsertResponseSchema, TriggerStatusEnum, TriggerStatuses, TriggerSubscribeParamSchema, TriggerTypeSchema, TriggersTypeListParamsSchema, TriggersTypeListResponseSchema, UpdateConnectedAccountAclParamsSchema, UpdateConnectedAccountParamsSchema, ValidationError, ValidationErrorCodes, VerifyWebhookParamsSchema, WebhookConnectedAccountAuthConfigSchema, WebhookConnectionMetadataSchema, WebhookConnectionStateSchema, WebhookEventSchema, WebhookEventTypes, WebhookPayloadSchema, WebhookPayloadV1Schema, WebhookPayloadV2Schema, WebhookPayloadV3Schema, WebhookTriggerPayloadV3Schema, WebhookVersions, constants_exports as constants, createConnectionRequest, dereferenceJsonSchema, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit, getExtensionFromMimeType, handleToolExecutionError, jsonSchemaToZodSchema, logger_default as logger, removeNonRequiredProperties };
|