@composio/core 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CustomTool-CzhY9iPX.d.cts → CustomTool-87USJ2u0.d.cts} +1 -1
- package/dist/{CustomTool-BaRzlwyV.d.mts → CustomTool-BNxqr6BI.d.mts} +1 -1
- package/dist/{CustomTool-CVwF_isu.mjs → CustomTool-DOE7hgw6.mjs} +232 -27
- package/dist/{CustomTool-DnCSEC6t.cjs → CustomTool-Dj4fNvsu.cjs} +279 -26
- package/dist/{composio-CwcLLO7C.d.mts → composio-BJW2NaoA.d.mts} +174 -144
- package/dist/{composio-B75SFMkx.d.cts → composio-DTntXzL-.d.cts} +174 -144
- package/dist/{customTool.types-BL_z-C_B.d.mts → customTool.types-B3HG185y.d.mts} +332 -30
- package/dist/{customTool.types-2DhEI1vs.d.cts → customTool.types-Bd8ylotX.d.cts} +332 -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 +492 -58
- package/dist/index.d.cts +80 -9
- package/dist/index.d.mts +80 -9
- package/dist/index.mjs +489 -61
- 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-DGrpnYFI.d.mts → types-BClz5lKM.d.mts} +2 -2
- package/dist/{types-CZkT1raQ.d.cts → types-jsOgjrWN.d.cts} +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 ConnectedAccountErrorCodes, 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 ComposioMultipleConnectedAccountsError, R as ComposioAuthConfigNotFoundError, S as ComposioWebhookPayloadError, T as ComposioNoAPIKeyError, U as ComposioProviderNotDefinedError, V as ComposioInvalidExecuteFunctionError, W as ComposioToolExecutionError, X as ComposioFailedToCreateConnectedAccountLink, Y as ComposioConnectedAccountNotFoundError, Z as ComposioLegacyConnectedAccountsEndpointRetiredError, _ as ComposioFailedToCreatePusherClientError, a as createCustomToolkit, b as ComposioFailedToUnsubscribeFromPusherChannelError, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, 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, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, q as ToolErrorCodes, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, u as serializeCustomTools, v as ComposioFailedToGetSDKRealtimeCredentialsError, w as TriggerErrorCodes, x as ComposioTriggerTypeNotFoundError, y as ComposioFailedToSubscribeToPusherChannelError, z as ComposioCustomToolsNotInitializedError } from "./CustomTool-DOE7hgw6.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,7 +1032,8 @@ 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
|
]);
|
|
1026
1038
|
const CreateConnectedAccountParamsSchema = z$1.object({
|
|
1027
1039
|
authConfig: z$1.object({ id: z$1.string() }),
|
|
@@ -1476,6 +1488,7 @@ function resolveEffectiveUploadAllowlist(userDirs) {
|
|
|
1476
1488
|
|
|
1477
1489
|
//#endregion
|
|
1478
1490
|
//#region src/models/Tools.ts
|
|
1491
|
+
const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
|
|
1479
1492
|
/**
|
|
1480
1493
|
* This class is used to manage tools in the Composio SDK.
|
|
1481
1494
|
* It provides methods to list, get, and execute tools.
|
|
@@ -1743,7 +1756,17 @@ var Tools = class {
|
|
|
1743
1756
|
* ```
|
|
1744
1757
|
*/
|
|
1745
1758
|
async getRawToolRouterSessionTools(sessionId, options) {
|
|
1746
|
-
|
|
1759
|
+
const tools = [];
|
|
1760
|
+
let cursor;
|
|
1761
|
+
do {
|
|
1762
|
+
const response = await this.client.toolRouter.session.tools(sessionId, {
|
|
1763
|
+
limit: TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT,
|
|
1764
|
+
...cursor ? { cursor } : {}
|
|
1765
|
+
});
|
|
1766
|
+
tools.push(...response.items.map((tool) => this.transformToolCases(tool)));
|
|
1767
|
+
cursor = response.next_cursor;
|
|
1768
|
+
} while (cursor);
|
|
1769
|
+
let modifiedTools = tools;
|
|
1747
1770
|
if (options?.modifySchema) {
|
|
1748
1771
|
const modifier = options.modifySchema;
|
|
1749
1772
|
if (typeof modifier === "function") {
|
|
@@ -2065,7 +2088,7 @@ var Tools = class {
|
|
|
2065
2088
|
* @param {Tool} tool - Optional tool schema used to resolve toolkit metadata for modifiers
|
|
2066
2089
|
* @returns {Promise<ToolExecuteResponse>} The response from the tool execution
|
|
2067
2090
|
*/
|
|
2068
|
-
async executeSessionTool(toolSlug, body, modifiers, tool) {
|
|
2091
|
+
async executeSessionTool(toolSlug, body, modifiers, tool, options) {
|
|
2069
2092
|
const executeParams = ToolExecuteMetaParamsSchema.safeParse(body);
|
|
2070
2093
|
if (!executeParams.success) throw new ValidationError("Invalid tool execute session parameters", { cause: executeParams.error });
|
|
2071
2094
|
let modifiedParams = body.arguments ?? {};
|
|
@@ -2081,6 +2104,7 @@ var Tools = class {
|
|
|
2081
2104
|
arguments: modifiedParams,
|
|
2082
2105
|
enable_auto_workbench_offload: true
|
|
2083
2106
|
};
|
|
2107
|
+
if (options?.experimental) executePayload.experimental = options.experimental;
|
|
2084
2108
|
const response = await this.client.toolRouter.session.execute(body.sessionId, executePayload);
|
|
2085
2109
|
let result = {
|
|
2086
2110
|
data: response.data,
|
|
@@ -2714,28 +2738,36 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
|
|
|
2714
2738
|
* ```
|
|
2715
2739
|
*/
|
|
2716
2740
|
async function waitForConnection(timeout = 6e4) {
|
|
2741
|
+
const terminalErrorStates = [
|
|
2742
|
+
ConnectedAccountStatuses.FAILED,
|
|
2743
|
+
ConnectedAccountStatuses.EXPIRED,
|
|
2744
|
+
ConnectedAccountStatuses.REVOKED
|
|
2745
|
+
];
|
|
2746
|
+
const failIfTerminal = (response) => {
|
|
2747
|
+
if (terminalErrorStates.includes(response.status)) throw new ConnectionRequestFailedError(`Connection request failed with status: ${response.status}${response.status_reason ? `, reason: ${response.status_reason}` : ""}`, { meta: {
|
|
2748
|
+
connectedAccountId: state.id,
|
|
2749
|
+
status: response.status,
|
|
2750
|
+
statusReason: response.status_reason
|
|
2751
|
+
} });
|
|
2752
|
+
};
|
|
2717
2753
|
try {
|
|
2718
2754
|
const response = await client.connectedAccounts.retrieve(state.id);
|
|
2719
2755
|
if (response.status === ConnectedAccountStatuses.ACTIVE) {
|
|
2720
2756
|
state.status = ConnectedAccountStatuses.ACTIVE;
|
|
2721
2757
|
return transformConnectedAccountResponse(response);
|
|
2722
2758
|
}
|
|
2759
|
+
failIfTerminal(response);
|
|
2723
2760
|
} catch (error) {
|
|
2724
2761
|
if (error instanceof ComposioClient.NotFoundError) throw new ComposioConnectedAccountNotFoundError(`Connected account with id ${state.id} not found`, { meta: { connectedAccountId: state.id } });
|
|
2725
2762
|
else throw error;
|
|
2726
2763
|
}
|
|
2727
|
-
const terminalErrorStates = [ConnectedAccountStatuses.FAILED, ConnectedAccountStatuses.EXPIRED];
|
|
2728
2764
|
const start = Date.now();
|
|
2729
2765
|
const pollInterval = 1e3;
|
|
2730
2766
|
while (Date.now() - start < timeout) try {
|
|
2731
2767
|
const response = await client.connectedAccounts.retrieve(state.id);
|
|
2732
2768
|
state.status = response.status;
|
|
2733
2769
|
if (response.status === ConnectedAccountStatuses.ACTIVE) return transformConnectedAccountResponse(response);
|
|
2734
|
-
|
|
2735
|
-
connectedAccountId: state.id,
|
|
2736
|
-
status: response.status,
|
|
2737
|
-
statusReason: response.status_reason
|
|
2738
|
-
} });
|
|
2770
|
+
failIfTerminal(response);
|
|
2739
2771
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
2740
2772
|
} catch (error) {
|
|
2741
2773
|
throw error;
|
|
@@ -2753,6 +2785,19 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
|
|
|
2753
2785
|
//#endregion
|
|
2754
2786
|
//#region src/models/ConnectedAccounts.ts
|
|
2755
2787
|
/**
|
|
2788
|
+
* @fileoverview Connected accounts class for Composio SDK, used to manage connected accounts of a user.
|
|
2789
|
+
*
|
|
2790
|
+
* @author Musthaq Ahamad <musthaq@composio.dev>
|
|
2791
|
+
* @date 2025-05-05
|
|
2792
|
+
* @module ConnectedAccounts
|
|
2793
|
+
*/
|
|
2794
|
+
const LEGACY_RETIRING_OAUTH_SCHEMES = new Set([
|
|
2795
|
+
"OAUTH1",
|
|
2796
|
+
"OAUTH2",
|
|
2797
|
+
"DCR_OAUTH"
|
|
2798
|
+
]);
|
|
2799
|
+
let _legacyInitiateWarningEmitted = false;
|
|
2800
|
+
/**
|
|
2756
2801
|
* ConnectedAccounts class
|
|
2757
2802
|
*
|
|
2758
2803
|
* This class is used to manage connected accounts in the Composio SDK.
|
|
@@ -2810,6 +2855,22 @@ var ConnectedAccounts = class {
|
|
|
2810
2855
|
* This function creates a new connected account and returns a connection request.
|
|
2811
2856
|
* Users can then wait for the connection to be established using the `waitForConnection` method.
|
|
2812
2857
|
*
|
|
2858
|
+
* **Deprecated for Composio-managed OAuth (OAuth1, OAuth2, DCR_OAUTH).**
|
|
2859
|
+
* The legacy `POST /api/v3/connected_accounts` endpoint that this method
|
|
2860
|
+
* wraps is being retired for Composio-managed auth configs on redirectable
|
|
2861
|
+
* schemes. The cutover is **2026-05-08** for new organizations and
|
|
2862
|
+
* **2026-07-03** for all remaining organizations. After your org's cutover,
|
|
2863
|
+
* this method will throw {@link ComposioLegacyConnectedAccountsEndpointRetiredError}
|
|
2864
|
+
* for that specific combination.
|
|
2865
|
+
*
|
|
2866
|
+
* Use {@link ConnectedAccounts.link} for Composio-managed OAuth — it works for
|
|
2867
|
+
* every redirectable scheme regardless of whether the auth config is
|
|
2868
|
+
* Composio-managed or custom, and the return shape is the same.
|
|
2869
|
+
*
|
|
2870
|
+
* Custom auth configs (your own OAuth app) and non-OAuth schemes (API key,
|
|
2871
|
+
* bearer token, basic auth) are unaffected and continue to work on
|
|
2872
|
+
* `initiate()`. See https://docs.composio.dev/docs/changelog/2026/04/24
|
|
2873
|
+
*
|
|
2813
2874
|
* @param {string} userId - User ID of the connected account
|
|
2814
2875
|
* @param {string} authConfigId - Auth config ID of the connected account
|
|
2815
2876
|
* @param {CreateConnectedAccountOptions} options - Options for creating a new connected account
|
|
@@ -2874,7 +2935,18 @@ var ConnectedAccounts = class {
|
|
|
2874
2935
|
...options?.alias != null && { alias: options.alias }
|
|
2875
2936
|
}
|
|
2876
2937
|
};
|
|
2877
|
-
|
|
2938
|
+
let response;
|
|
2939
|
+
try {
|
|
2940
|
+
response = await this.client.connectedAccounts.create(createParams);
|
|
2941
|
+
} catch (error) {
|
|
2942
|
+
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 });
|
|
2943
|
+
throw error;
|
|
2944
|
+
}
|
|
2945
|
+
const responseAuthScheme = response.connectionData?.authScheme;
|
|
2946
|
+
if (!_legacyInitiateWarningEmitted && typeof responseAuthScheme === "string" && LEGACY_RETIRING_OAUTH_SCHEMES.has(responseAuthScheme)) {
|
|
2947
|
+
_legacyInitiateWarningEmitted = true;
|
|
2948
|
+
logger_default.warn("[Deprecation] composio.connectedAccounts.initiate() will stop working for Composio-managed OAuth auth configs on 2026-05-08 (new orgs) and 2026-07-03 (all orgs). If this auth config is Composio-managed, switch to composio.connectedAccounts.link() before then. Custom auth configs are unaffected. See https://docs.composio.dev/docs/changelog/2026/04/24");
|
|
2949
|
+
}
|
|
2878
2950
|
const redirectUrl = typeof response.connectionData?.val?.redirectUrl === "string" ? response.connectionData.val.redirectUrl : null;
|
|
2879
2951
|
return createConnectionRequest(this.client, response.id, response.connectionData.val.status, redirectUrl);
|
|
2880
2952
|
}
|
|
@@ -5413,7 +5485,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5413
5485
|
|
|
5414
5486
|
//#endregion
|
|
5415
5487
|
//#region package.json
|
|
5416
|
-
var version = "0.
|
|
5488
|
+
var version = "0.9.0";
|
|
5417
5489
|
|
|
5418
5490
|
//#endregion
|
|
5419
5491
|
//#region src/utils/session.ts
|
|
@@ -5456,6 +5528,7 @@ const getDefaultHeaders = (headers, provider) => {
|
|
|
5456
5528
|
|
|
5457
5529
|
//#endregion
|
|
5458
5530
|
//#region src/types/toolRouter.types.ts
|
|
5531
|
+
const SessionPreset = { DIRECT_TOOLS: "direct_tools" };
|
|
5459
5532
|
const MCPServerTypeSchema = z.enum(["http", "sse"]);
|
|
5460
5533
|
/**
|
|
5461
5534
|
* Sandbox compute tier for the tool router workbench.
|
|
@@ -5536,7 +5609,8 @@ const ToolRouterConfigToolsSchema = z.union([
|
|
|
5536
5609
|
});
|
|
5537
5610
|
}
|
|
5538
5611
|
});
|
|
5539
|
-
const
|
|
5612
|
+
const ToolRouterCreateSessionConfigBaseSchema = z.object({
|
|
5613
|
+
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
5614
|
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).optional().describe("The tools to use in the tool router session"),
|
|
5541
5615
|
tags: ToolRouterConfigTagsSchema.optional().describe("Global tags to filter the tools by"),
|
|
5542
5616
|
toolkits: z.union([
|
|
@@ -5545,26 +5619,38 @@ const ToolRouterCreateSessionConfigSchema = z.object({
|
|
|
5545
5619
|
ToolRouterToolkitsEnabledConfigSchema
|
|
5546
5620
|
]).optional().describe("The toolkits to use in the tool router session"),
|
|
5547
5621
|
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
|
|
5622
|
+
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
5623
|
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
5624
|
workbench: z.object({
|
|
5551
5625
|
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
5626
|
enableProxyExecution: z.boolean().optional().describe("Whether to enable proxy execution in the tool router session"),
|
|
5553
5627
|
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
|
|
5628
|
+
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
5629
|
}).optional().describe("The workbench config for the tool router session"),
|
|
5556
5630
|
multiAccount: z.object({
|
|
5557
5631
|
enable: z.boolean().default(false).describe("When true, enables multi-account mode for this session. Defaults to false."),
|
|
5558
5632
|
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
5633
|
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
5634
|
}).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.
|
|
5635
|
+
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
5636
|
experimental: z.object({
|
|
5563
5637
|
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
5638
|
customTools: z.array(z.custom()).optional().describe("Custom tools to include in this session. Created via createCustomTool() from @composio/core/experimental."),
|
|
5565
5639
|
customToolkits: z.array(z.custom()).optional().describe("Custom toolkits to include in this session. Created via createCustomToolkit() from @composio/core/experimental.")
|
|
5566
5640
|
}).optional().describe("Experimental features configuration - not stable, may be modified or removed")
|
|
5567
5641
|
}).partial().describe("The config for the tool router session");
|
|
5642
|
+
const applyDirectToolsPresetDefaults = (value) => {
|
|
5643
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
5644
|
+
const config = value;
|
|
5645
|
+
if (config.sessionPreset !== SessionPreset.DIRECT_TOOLS) return value;
|
|
5646
|
+
return {
|
|
5647
|
+
...config,
|
|
5648
|
+
manageConnections: config.manageConnections === void 0 ? false : config.manageConnections,
|
|
5649
|
+
workbench: config.workbench === void 0 ? { enable: false } : config.workbench,
|
|
5650
|
+
preload: config.preload === void 0 ? { tools: PRELOAD_TOOLS_ALL } : config.preload
|
|
5651
|
+
};
|
|
5652
|
+
};
|
|
5653
|
+
const ToolRouterCreateSessionConfigSchema = z.preprocess(applyDirectToolsPresetDefaults, ToolRouterCreateSessionConfigBaseSchema).describe("The config for the tool router session");
|
|
5568
5654
|
const ToolkitConnectionStateSchema = z.object({
|
|
5569
5655
|
slug: z.string().describe("The slug of a toolkit"),
|
|
5570
5656
|
name: z.string().describe("The name of a toolkit"),
|
|
@@ -5683,6 +5769,34 @@ const SessionProxyExecuteParamsSchema = z.object({
|
|
|
5683
5769
|
value: z.union([z.string(), z.number()])
|
|
5684
5770
|
})).optional()
|
|
5685
5771
|
});
|
|
5772
|
+
const ToolRouterUpdateSessionConfigSchema = z.object({
|
|
5773
|
+
toolkits: z.union([
|
|
5774
|
+
ToolRouterToolkitsParamSchema,
|
|
5775
|
+
ToolRouterToolkitsDisabledConfigSchema,
|
|
5776
|
+
ToolRouterToolkitsEnabledConfigSchema
|
|
5777
|
+
]).optional(),
|
|
5778
|
+
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).optional(),
|
|
5779
|
+
tags: ToolRouterConfigTagsSchema.optional(),
|
|
5780
|
+
authConfigs: z.record(z.string(), z.string()).optional(),
|
|
5781
|
+
connectedAccounts: z.record(z.string(), z.union([z.string(), z.array(z.string())])).transform((rec) => {
|
|
5782
|
+
const out = {};
|
|
5783
|
+
for (const [k, v] of Object.entries(rec)) out[k] = typeof v === "string" ? [v] : v;
|
|
5784
|
+
return out;
|
|
5785
|
+
}).optional(),
|
|
5786
|
+
manageConnections: z.union([z.boolean(), ToolRouterConfigManageConnectionsSchema]).nullable().optional(),
|
|
5787
|
+
workbench: z.object({
|
|
5788
|
+
enable: z.boolean().optional(),
|
|
5789
|
+
enableProxyExecution: z.boolean().optional(),
|
|
5790
|
+
autoOffloadThreshold: z.number().optional(),
|
|
5791
|
+
sandboxSize: SandboxSizeSchema.optional()
|
|
5792
|
+
}).nullable().optional(),
|
|
5793
|
+
multiAccount: z.object({
|
|
5794
|
+
enable: z.boolean().optional(),
|
|
5795
|
+
maxAccountsPerToolkit: z.number().int().min(2).max(10).optional(),
|
|
5796
|
+
requireExplicitSelection: z.boolean().optional()
|
|
5797
|
+
}).nullable().optional(),
|
|
5798
|
+
preload: z.object({ tools: z.union([z.array(z.string()), z.literal("all")]).optional() }).strict().optional()
|
|
5799
|
+
}).partial();
|
|
5686
5800
|
|
|
5687
5801
|
//#endregion
|
|
5688
5802
|
//#region src/lib/toolRouterParams.ts
|
|
@@ -5735,12 +5849,39 @@ const transformToolRouterWorkbenchParams = (params) => {
|
|
|
5735
5849
|
sandbox_size: params.sandboxSize
|
|
5736
5850
|
};
|
|
5737
5851
|
};
|
|
5852
|
+
/**
|
|
5853
|
+
* PATCH-safe variant of transformToolRouterManageConnectionsParams.
|
|
5854
|
+
* Does NOT apply defaults — only includes fields explicitly present in the input.
|
|
5855
|
+
*/
|
|
5856
|
+
const transformToolRouterUpdateManageConnectionsParams = (params) => {
|
|
5857
|
+
if (typeof params === "boolean") return { enable: params };
|
|
5858
|
+
const parsedResult = ToolRouterConfigManageConnectionsSchema.safeParse(params);
|
|
5859
|
+
if (!parsedResult.success) throw new ValidationError("Failed to parse manage connections config", { cause: parsedResult.error });
|
|
5860
|
+
const config = parsedResult.data;
|
|
5861
|
+
const result = {};
|
|
5862
|
+
if (config.enable !== void 0) result.enable = config.enable;
|
|
5863
|
+
if (config.callbackUrl !== void 0) result.callback_url = config.callbackUrl;
|
|
5864
|
+
if (config.waitForConnections !== void 0) result.enable_wait_for_connections = config.waitForConnections;
|
|
5865
|
+
return result;
|
|
5866
|
+
};
|
|
5867
|
+
/**
|
|
5868
|
+
* PATCH-safe variant of transformToolRouterWorkbenchParams.
|
|
5869
|
+
* Does NOT apply `enable ?? true` default — only includes fields explicitly present.
|
|
5870
|
+
*/
|
|
5871
|
+
const transformToolRouterUpdateWorkbenchParams = (params) => {
|
|
5872
|
+
const result = {};
|
|
5873
|
+
if (params.enable !== void 0) result.enable = params.enable;
|
|
5874
|
+
if (params.enableProxyExecution !== void 0) result.enable_proxy_execution = params.enableProxyExecution;
|
|
5875
|
+
if (params.autoOffloadThreshold !== void 0) result.auto_offload_threshold = params.autoOffloadThreshold;
|
|
5876
|
+
if (params.sandboxSize !== void 0) result.sandbox_size = params.sandboxSize;
|
|
5877
|
+
return result;
|
|
5878
|
+
};
|
|
5738
5879
|
const transformToolRouterMultiAccountParams = (params) => {
|
|
5739
5880
|
if (!params) return;
|
|
5740
5881
|
const transformedParams = {
|
|
5741
5882
|
enable: params.enable,
|
|
5742
5883
|
max_accounts_per_toolkit: params.maxAccountsPerToolkit,
|
|
5743
|
-
require_explicit_selection: params.requireExplicitSelection
|
|
5884
|
+
require_explicit_selection: params.requireExplicitSelection ?? (params.enable ? true : void 0)
|
|
5744
5885
|
};
|
|
5745
5886
|
if (transformedParams.enable === void 0 && transformedParams.max_accounts_per_toolkit === void 0 && transformedParams.require_explicit_selection === void 0) return;
|
|
5746
5887
|
return transformedParams;
|
|
@@ -5750,6 +5891,32 @@ const transformToolRouterToolkitsParams = (params) => {
|
|
|
5750
5891
|
if (Array.isArray(params)) return { enable: params };
|
|
5751
5892
|
return params;
|
|
5752
5893
|
};
|
|
5894
|
+
const transformToolRouterUpdateParams = (config) => {
|
|
5895
|
+
const params = {};
|
|
5896
|
+
if (config.toolkits !== void 0) params.toolkits = transformToolRouterToolkitsParams(config.toolkits);
|
|
5897
|
+
if (config.tools !== void 0) params.tools = transformToolRouterToolsParams(config.tools);
|
|
5898
|
+
if (config.tags !== void 0) params.tags = transformToolRouterTagsParams(config.tags);
|
|
5899
|
+
if (config.authConfigs !== void 0) params.auth_configs = config.authConfigs;
|
|
5900
|
+
if (config.connectedAccounts !== void 0) {
|
|
5901
|
+
const coerced = {};
|
|
5902
|
+
for (const [k, v] of Object.entries(config.connectedAccounts)) coerced[k] = typeof v === "string" ? [v] : v;
|
|
5903
|
+
params.connected_accounts = coerced;
|
|
5904
|
+
}
|
|
5905
|
+
if (config.manageConnections !== void 0) if (config.manageConnections === null) params.manage_connections = null;
|
|
5906
|
+
else params.manage_connections = transformToolRouterUpdateManageConnectionsParams(config.manageConnections);
|
|
5907
|
+
if (config.workbench !== void 0) if (config.workbench === null) params.workbench = null;
|
|
5908
|
+
else params.workbench = transformToolRouterUpdateWorkbenchParams(config.workbench);
|
|
5909
|
+
if (config.multiAccount !== void 0) if (config.multiAccount === null) params.multi_account = null;
|
|
5910
|
+
else {
|
|
5911
|
+
const ma = {};
|
|
5912
|
+
if (config.multiAccount.enable !== void 0) ma.enable = config.multiAccount.enable;
|
|
5913
|
+
if (config.multiAccount.maxAccountsPerToolkit !== void 0) ma.max_accounts_per_toolkit = config.multiAccount.maxAccountsPerToolkit;
|
|
5914
|
+
if (config.multiAccount.requireExplicitSelection !== void 0) ma.require_explicit_selection = config.multiAccount.requireExplicitSelection;
|
|
5915
|
+
params.multi_account = ma;
|
|
5916
|
+
}
|
|
5917
|
+
if (config.preload !== void 0) params.preload = config.preload;
|
|
5918
|
+
return params;
|
|
5919
|
+
};
|
|
5753
5920
|
|
|
5754
5921
|
//#endregion
|
|
5755
5922
|
//#region src/utils/transformers/toolRouterResponseTransform.ts
|
|
@@ -6343,7 +6510,23 @@ function transformProxyParams(params) {
|
|
|
6343
6510
|
function findCustomTool(map, slug) {
|
|
6344
6511
|
if (!map) return void 0;
|
|
6345
6512
|
const upper = slug.toUpperCase();
|
|
6346
|
-
|
|
6513
|
+
const finalSlugMatch = map.byFinalSlug.get(upper);
|
|
6514
|
+
if (finalSlugMatch) return finalSlugMatch;
|
|
6515
|
+
if (map.ambiguousOriginalSlugs?.has(upper)) return void 0;
|
|
6516
|
+
return map.byOriginalSlug.get(upper);
|
|
6517
|
+
}
|
|
6518
|
+
/**
|
|
6519
|
+
* Reject ambiguous bare original slugs before falling through to backend execution.
|
|
6520
|
+
* Agents receive final slugs (LOCAL_<TOOLKIT>_<TOOL>) from schemas, while bare original
|
|
6521
|
+
* slugs are only a convenience for manual session.execute() calls when unique.
|
|
6522
|
+
*/
|
|
6523
|
+
function assertUnambiguousCustomToolSlug(map, slug) {
|
|
6524
|
+
if (!map) return;
|
|
6525
|
+
const upper = slug.toUpperCase();
|
|
6526
|
+
if (!map.ambiguousOriginalSlugs?.has(upper)) return;
|
|
6527
|
+
const finalSlugs = [...map.byFinalSlug.values()].filter((entry) => entry.handle.slug.toUpperCase() === upper).map((entry) => entry.finalSlug).sort();
|
|
6528
|
+
const hint = finalSlugs.length ? ` Use one of: ${finalSlugs.join(", ")}.` : "";
|
|
6529
|
+
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
6530
|
}
|
|
6348
6531
|
/**
|
|
6349
6532
|
* Execute a custom tool in-process.
|
|
@@ -6375,6 +6558,12 @@ async function executeCustomTool(entry, arguments_, sessionContext) {
|
|
|
6375
6558
|
}
|
|
6376
6559
|
}
|
|
6377
6560
|
|
|
6561
|
+
//#endregion
|
|
6562
|
+
//#region src/models/inlineCustomToolsPayload.ts
|
|
6563
|
+
function inlineCustomToolsExperimental(payload) {
|
|
6564
|
+
return payload;
|
|
6565
|
+
}
|
|
6566
|
+
|
|
6378
6567
|
//#endregion
|
|
6379
6568
|
//#region src/models/SessionContext.ts
|
|
6380
6569
|
/**
|
|
@@ -6388,10 +6577,11 @@ async function executeCustomTool(entry, arguments_, sessionContext) {
|
|
|
6388
6577
|
*/
|
|
6389
6578
|
var SessionContextImpl = class {
|
|
6390
6579
|
userId;
|
|
6391
|
-
constructor(client, userId, sessionId, customToolsMap) {
|
|
6580
|
+
constructor(client, userId, sessionId, customToolsMap, inlineCustomToolsPayload) {
|
|
6392
6581
|
this.client = client;
|
|
6393
6582
|
this.sessionId = sessionId;
|
|
6394
6583
|
this.customToolsMap = customToolsMap;
|
|
6584
|
+
this.inlineCustomToolsPayload = inlineCustomToolsPayload;
|
|
6395
6585
|
this.userId = userId;
|
|
6396
6586
|
}
|
|
6397
6587
|
/**
|
|
@@ -6411,10 +6601,14 @@ var SessionContextImpl = class {
|
|
|
6411
6601
|
logId: ""
|
|
6412
6602
|
});
|
|
6413
6603
|
}
|
|
6414
|
-
|
|
6604
|
+
assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
|
|
6605
|
+
const executeParams = {
|
|
6415
6606
|
tool_slug: toolSlug,
|
|
6416
6607
|
arguments: arguments_
|
|
6417
|
-
}
|
|
6608
|
+
};
|
|
6609
|
+
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
6610
|
+
if (experimental) executeParams.experimental = experimental;
|
|
6611
|
+
const response = await this.client.toolRouter.session.execute(this.sessionId, executeParams);
|
|
6418
6612
|
return ToolRouterSessionExecuteResponseSchema.parse(transformExecuteResponse(response));
|
|
6419
6613
|
}
|
|
6420
6614
|
/**
|
|
@@ -6443,6 +6637,7 @@ var SessionContextImpl = class {
|
|
|
6443
6637
|
//#endregion
|
|
6444
6638
|
//#region src/models/ToolRouterSession.ts
|
|
6445
6639
|
const COMPOSIO_MULTI_EXECUTE_TOOL = "COMPOSIO_MULTI_EXECUTE_TOOL";
|
|
6640
|
+
const DIRECT_CUSTOM_TOOL_DESCRIPTION_PREFIX = "[Direct tool - call directly, no search needed beforehand.]";
|
|
6446
6641
|
var ToolRouterSession = class {
|
|
6447
6642
|
sessionId;
|
|
6448
6643
|
mcp;
|
|
@@ -6450,6 +6645,8 @@ var ToolRouterSession = class {
|
|
|
6450
6645
|
preload;
|
|
6451
6646
|
configVersion;
|
|
6452
6647
|
warnings;
|
|
6648
|
+
preloadedCustomToolSlugs;
|
|
6649
|
+
inlineCustomToolsPayload;
|
|
6453
6650
|
/** Singleton session context — shared across all custom tool executions */
|
|
6454
6651
|
sessionContext;
|
|
6455
6652
|
constructor(client, config, sessionId, mcp, experimentalOverrides, customToolsMap, userId, metadata) {
|
|
@@ -6467,7 +6664,9 @@ var ToolRouterSession = class {
|
|
|
6467
6664
|
this.preload = metadata?.preload ?? { tools: [] };
|
|
6468
6665
|
this.configVersion = metadata?.configVersion;
|
|
6469
6666
|
this.warnings = metadata?.warnings ?? [];
|
|
6470
|
-
|
|
6667
|
+
this.preloadedCustomToolSlugs = metadata?.preloadedCustomToolSlugs ?? [];
|
|
6668
|
+
this.inlineCustomToolsPayload = metadata?.inlineCustomToolsPayload;
|
|
6669
|
+
if (customToolsMap && userId) this.sessionContext = new SessionContextImpl(client, userId, sessionId, customToolsMap, this.inlineCustomToolsPayload);
|
|
6471
6670
|
telemetry.instrument(this, "ToolRouterSession");
|
|
6472
6671
|
}
|
|
6473
6672
|
/**
|
|
@@ -6480,19 +6679,64 @@ var ToolRouterSession = class {
|
|
|
6480
6679
|
async tools(modifiers) {
|
|
6481
6680
|
const ToolsModel = new Tools(this.client, this.config);
|
|
6482
6681
|
const tools = await ToolsModel.getRawToolRouterSessionTools(this.sessionId, modifiers?.modifySchema ? { modifySchema: modifiers.modifySchema } : void 0);
|
|
6483
|
-
const
|
|
6682
|
+
const sessionTools = await this.addPreloadedCustomTools(tools, modifiers);
|
|
6683
|
+
const toolBySlug = new Map(sessionTools.map((tool) => [tool.slug.toUpperCase(), tool]));
|
|
6484
6684
|
if (this.hasCustomTools()) {
|
|
6485
6685
|
const routingExecuteFn = async (toolSlug, input) => {
|
|
6486
|
-
if (toolSlug === COMPOSIO_MULTI_EXECUTE_TOOL) return this.routeMultiExecute(input, ToolsModel,
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6686
|
+
if (toolSlug === COMPOSIO_MULTI_EXECUTE_TOOL) return this.routeMultiExecute(input, ToolsModel, sessionTools, modifiers);
|
|
6687
|
+
const customTool = findCustomTool(this.customToolsMap, toolSlug);
|
|
6688
|
+
if (customTool) return executeCustomTool(customTool, input, this.sessionContext);
|
|
6689
|
+
assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
|
|
6690
|
+
return this.executeBackendSessionTool(ToolsModel, toolSlug, input, modifiers, toolBySlug.get(toolSlug.toUpperCase()));
|
|
6491
6691
|
};
|
|
6492
6692
|
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(
|
|
6693
|
+
return this.config.provider.wrapTools(sessionTools, routingExecuteFn);
|
|
6694
|
+
}
|
|
6695
|
+
return ToolsModel.wrapToolsForToolRouter(this.sessionId, sessionTools, modifiers);
|
|
6696
|
+
}
|
|
6697
|
+
async addPreloadedCustomTools(tools, modifiers) {
|
|
6698
|
+
const customTools = await this.getPreloadedCustomToolSchemas(modifiers);
|
|
6699
|
+
if (!customTools.length) return tools;
|
|
6700
|
+
const existingSlugs = new Set(tools.map((tool) => tool.slug.toUpperCase()));
|
|
6701
|
+
const appendedTools = customTools.filter((tool) => !existingSlugs.has(tool.slug.toUpperCase()));
|
|
6702
|
+
if (!appendedTools.length) return tools;
|
|
6703
|
+
return [...tools, ...appendedTools];
|
|
6704
|
+
}
|
|
6705
|
+
async getPreloadedCustomToolSchemas(modifiers) {
|
|
6706
|
+
if (!this.customToolsMap || !this.preloadedCustomToolSlugs.length) return [];
|
|
6707
|
+
const tools = [];
|
|
6708
|
+
for (const slug of this.preloadedCustomToolSlugs) {
|
|
6709
|
+
const entry = findCustomToolMapEntryByFinalSlug(this.customToolsMap, slug);
|
|
6710
|
+
if (!entry) continue;
|
|
6711
|
+
let tool = this.customToolEntryToTool(entry);
|
|
6712
|
+
if (modifiers?.modifySchema) tool = await modifiers.modifySchema({
|
|
6713
|
+
toolSlug: tool.slug,
|
|
6714
|
+
toolkitSlug: tool.toolkit?.slug ?? "custom",
|
|
6715
|
+
schema: tool
|
|
6716
|
+
});
|
|
6717
|
+
tools.push(tool);
|
|
6494
6718
|
}
|
|
6495
|
-
return
|
|
6719
|
+
return tools;
|
|
6720
|
+
}
|
|
6721
|
+
customToolEntryToTool(entry) {
|
|
6722
|
+
const toolkitSlug = entry.toolkit ?? "custom";
|
|
6723
|
+
const toolkitName = (this.customToolsMap?.toolkits?.find((toolkit) => toolkit.slug.toLowerCase() === toolkitSlug.toLowerCase()))?.name ?? entry.toolkit ?? "Custom";
|
|
6724
|
+
return {
|
|
6725
|
+
slug: entry.finalSlug,
|
|
6726
|
+
name: entry.handle.name,
|
|
6727
|
+
description: `${DIRECT_CUSTOM_TOOL_DESCRIPTION_PREFIX}\n${entry.handle.description}`,
|
|
6728
|
+
inputParameters: entry.handle.inputSchema,
|
|
6729
|
+
outputParameters: entry.handle.outputSchema,
|
|
6730
|
+
tags: [],
|
|
6731
|
+
toolkit: {
|
|
6732
|
+
slug: toolkitSlug,
|
|
6733
|
+
name: toolkitName
|
|
6734
|
+
},
|
|
6735
|
+
isDeprecated: false,
|
|
6736
|
+
availableVersions: [],
|
|
6737
|
+
scopes: [],
|
|
6738
|
+
isNoAuth: !entry.handle.extendsToolkit
|
|
6739
|
+
};
|
|
6496
6740
|
}
|
|
6497
6741
|
/**
|
|
6498
6742
|
* List all custom tools registered in this session.
|
|
@@ -6528,7 +6772,7 @@ var ToolRouterSession = class {
|
|
|
6528
6772
|
description: tk.description,
|
|
6529
6773
|
tools: tk.tools.map((tool) => {
|
|
6530
6774
|
return {
|
|
6531
|
-
slug: this.customToolsMap.byOriginalSlug.get(tool.slug.toUpperCase())?.finalSlug ?? tool.slug,
|
|
6775
|
+
slug: (findCustomToolMapEntryByToolkitAndOriginalSlug(this.customToolsMap, tk.slug, tool.slug) ?? this.customToolsMap.byOriginalSlug.get(tool.slug.toUpperCase()))?.finalSlug ?? tool.slug,
|
|
6532
6776
|
name: tool.name,
|
|
6533
6777
|
description: tool.description,
|
|
6534
6778
|
toolkit: tk.slug,
|
|
@@ -6594,10 +6838,13 @@ var ToolRouterSession = class {
|
|
|
6594
6838
|
* Returns relevant tools for the given query with schemas and guidance.
|
|
6595
6839
|
*/
|
|
6596
6840
|
async search(params) {
|
|
6597
|
-
const
|
|
6841
|
+
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
6842
|
+
const searchParams = {
|
|
6598
6843
|
queries: [{ use_case: params.query }],
|
|
6599
|
-
...params.toolkits?.length ? { toolkits: params.toolkits } : {}
|
|
6600
|
-
|
|
6844
|
+
...params.toolkits?.length ? { toolkits: params.toolkits } : {},
|
|
6845
|
+
...experimental ? { experimental } : {}
|
|
6846
|
+
};
|
|
6847
|
+
const transformed = transformSearchResponse(await this.client.toolRouter.session.search(this.sessionId, searchParams));
|
|
6601
6848
|
return ToolRouterSessionSearchResponseSchema.parse(transformed);
|
|
6602
6849
|
}
|
|
6603
6850
|
/**
|
|
@@ -6623,11 +6870,14 @@ var ToolRouterSession = class {
|
|
|
6623
6870
|
logId: ""
|
|
6624
6871
|
};
|
|
6625
6872
|
}
|
|
6873
|
+
assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
|
|
6626
6874
|
const executeParams = {
|
|
6627
6875
|
tool_slug: toolSlug,
|
|
6628
6876
|
arguments: arguments_ ?? {}
|
|
6629
6877
|
};
|
|
6630
6878
|
if (options?.account) executeParams.account = options.account;
|
|
6879
|
+
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
6880
|
+
if (experimental) executeParams.experimental = experimental;
|
|
6631
6881
|
const transformed = transformExecuteResponse(await this.client.toolRouter.session.execute(this.sessionId, executeParams));
|
|
6632
6882
|
return ToolRouterSessionExecuteResponseSchema.parse(transformed);
|
|
6633
6883
|
}
|
|
@@ -6655,10 +6905,31 @@ var ToolRouterSession = class {
|
|
|
6655
6905
|
} } : {}
|
|
6656
6906
|
};
|
|
6657
6907
|
}
|
|
6908
|
+
/**
|
|
6909
|
+
* Partially update the session configuration.
|
|
6910
|
+
* Only the fields provided will be changed; omitted fields are preserved.
|
|
6911
|
+
* Mutates this session's `configVersion`, `preload`, and `warnings` in-place.
|
|
6912
|
+
*/
|
|
6913
|
+
async update(config) {
|
|
6914
|
+
const params = transformToolRouterUpdateParams(ToolRouterUpdateSessionConfigSchema.parse(config));
|
|
6915
|
+
const response = await this.client.toolRouter.session.patch(this.sessionId, params);
|
|
6916
|
+
this.configVersion = response.config_version;
|
|
6917
|
+
this.preload = response.config.preload;
|
|
6918
|
+
this.warnings = response.warnings ?? [];
|
|
6919
|
+
}
|
|
6658
6920
|
/** Check if this session has any custom tools bound. */
|
|
6659
6921
|
hasCustomTools() {
|
|
6660
6922
|
return (this.customToolsMap?.byFinalSlug.size ?? 0) > 0;
|
|
6661
6923
|
}
|
|
6924
|
+
executeBackendSessionTool(ToolsModel, toolSlug, input, modifiers, tool) {
|
|
6925
|
+
const body = {
|
|
6926
|
+
sessionId: this.sessionId,
|
|
6927
|
+
arguments: input
|
|
6928
|
+
};
|
|
6929
|
+
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
6930
|
+
if (experimental) return ToolsModel.executeSessionTool(toolSlug, body, modifiers, tool, { experimental });
|
|
6931
|
+
return ToolsModel.executeSessionTool(toolSlug, body, modifiers, tool);
|
|
6932
|
+
}
|
|
6662
6933
|
/** Parse an individual tool item from COMPOSIO_MULTI_EXECUTE_TOOL's tools array */
|
|
6663
6934
|
parseToolItem(item) {
|
|
6664
6935
|
if (typeof item !== "object" || item === null) return {
|
|
@@ -6679,10 +6950,7 @@ var ToolRouterSession = class {
|
|
|
6679
6950
|
async routeMultiExecute(input, ToolsModel, tools, modifiers) {
|
|
6680
6951
|
const multiExecuteTool = tools.find((tool) => tool.slug === COMPOSIO_MULTI_EXECUTE_TOOL);
|
|
6681
6952
|
const toolItems = input.tools;
|
|
6682
|
-
if (!Array.isArray(toolItems) || toolItems.length === 0) return
|
|
6683
|
-
sessionId: this.sessionId,
|
|
6684
|
-
arguments: input
|
|
6685
|
-
}, modifiers, multiExecuteTool);
|
|
6953
|
+
if (!Array.isArray(toolItems) || toolItems.length === 0) return this.executeBackendSessionTool(ToolsModel, COMPOSIO_MULTI_EXECUTE_TOOL, input, modifiers, multiExecuteTool);
|
|
6686
6954
|
const parsed = toolItems.map((item) => this.parseToolItem(item));
|
|
6687
6955
|
const localItems = [];
|
|
6688
6956
|
const remoteIndices = [];
|
|
@@ -6692,12 +6960,12 @@ var ToolRouterSession = class {
|
|
|
6692
6960
|
index: i,
|
|
6693
6961
|
entry
|
|
6694
6962
|
});
|
|
6695
|
-
else
|
|
6963
|
+
else {
|
|
6964
|
+
assertUnambiguousCustomToolSlug(this.customToolsMap, parsed[i].tool_slug);
|
|
6965
|
+
remoteIndices.push(i);
|
|
6966
|
+
}
|
|
6696
6967
|
}
|
|
6697
|
-
if (localItems.length === 0) return
|
|
6698
|
-
sessionId: this.sessionId,
|
|
6699
|
-
arguments: input
|
|
6700
|
-
}, modifiers, multiExecuteTool);
|
|
6968
|
+
if (localItems.length === 0) return this.executeBackendSessionTool(ToolsModel, COMPOSIO_MULTI_EXECUTE_TOOL, input, modifiers, multiExecuteTool);
|
|
6701
6969
|
const ctx = this.sessionContext;
|
|
6702
6970
|
const localPromises = localItems.map(async ({ index, entry }) => {
|
|
6703
6971
|
return {
|
|
@@ -6712,10 +6980,7 @@ var ToolRouterSession = class {
|
|
|
6712
6980
|
...input,
|
|
6713
6981
|
tools: remoteToolItems
|
|
6714
6982
|
};
|
|
6715
|
-
remotePromise =
|
|
6716
|
-
sessionId: this.sessionId,
|
|
6717
|
-
arguments: remoteInput
|
|
6718
|
-
}, modifiers, multiExecuteTool);
|
|
6983
|
+
remotePromise = this.executeBackendSessionTool(ToolsModel, COMPOSIO_MULTI_EXECUTE_TOOL, remoteInput, modifiers, multiExecuteTool);
|
|
6719
6984
|
}
|
|
6720
6985
|
const [localResults, remoteResult] = await Promise.all([Promise.all(localPromises), remotePromise]);
|
|
6721
6986
|
if (remoteIndices.length === 0 && localResults.length === 1) return localResults[0].result;
|
|
@@ -6767,6 +7032,19 @@ function getSessionMetadata(session) {
|
|
|
6767
7032
|
warnings: "warnings" in session ? session.warnings ?? [] : []
|
|
6768
7033
|
};
|
|
6769
7034
|
}
|
|
7035
|
+
function preloadsAllCustomTools(preload) {
|
|
7036
|
+
return preload?.tools === PRELOAD_TOOLS_ALL;
|
|
7037
|
+
}
|
|
7038
|
+
function prepareInlineCustomTools(options) {
|
|
7039
|
+
const { customTools, customToolkits, defaultPreload = false, preloadTools } = options;
|
|
7040
|
+
assertNoCustomToolSlugsInPreload(preloadTools, !!(customTools?.length || customToolkits?.length) ? buildCustomToolsMap(customTools ?? [], customToolkits) : void 0);
|
|
7041
|
+
const serializedTools = customTools?.length ? serializeCustomTools(customTools, { defaultPreload }) : void 0;
|
|
7042
|
+
const serializedToolkits = customToolkits?.length ? serializeCustomToolkits(customToolkits, { defaultPreload }) : void 0;
|
|
7043
|
+
return serializedTools || serializedToolkits ? {
|
|
7044
|
+
...serializedTools ? { custom_tools: serializedTools } : {},
|
|
7045
|
+
...serializedToolkits ? { custom_toolkits: serializedToolkits } : {}
|
|
7046
|
+
} : void 0;
|
|
7047
|
+
}
|
|
6770
7048
|
var ToolRouter = class {
|
|
6771
7049
|
constructor(client, config) {
|
|
6772
7050
|
this.client = client;
|
|
@@ -6782,6 +7060,8 @@ var ToolRouter = class {
|
|
|
6782
7060
|
}
|
|
6783
7061
|
/**
|
|
6784
7062
|
* Creates a new tool router session for a user.
|
|
7063
|
+
* Use `sessionPreset: SessionPreset.DIRECT_TOOLS` when all needed tools
|
|
7064
|
+
* should be exposed directly; see `ToolRouterCreateSessionConfig`.
|
|
6785
7065
|
*
|
|
6786
7066
|
* @param userId {string} The user id to create the session for
|
|
6787
7067
|
* @param config {ToolRouterCreateSessionConfig} The config for the tool router session
|
|
@@ -6789,7 +7069,7 @@ var ToolRouter = class {
|
|
|
6789
7069
|
*
|
|
6790
7070
|
* @example
|
|
6791
7071
|
* ```typescript
|
|
6792
|
-
* import { Composio
|
|
7072
|
+
* import { Composio } from '@composio/core';
|
|
6793
7073
|
*
|
|
6794
7074
|
* const composio = new Composio();
|
|
6795
7075
|
*
|
|
@@ -6805,17 +7085,26 @@ var ToolRouter = class {
|
|
|
6805
7085
|
*/
|
|
6806
7086
|
async create(userId, config) {
|
|
6807
7087
|
const routerConfig = ToolRouterCreateSessionConfigSchema.parse(config ?? {});
|
|
7088
|
+
const isDirectToolsPreset = routerConfig.sessionPreset === SessionPreset.DIRECT_TOOLS;
|
|
6808
7089
|
const customTools = routerConfig.experimental?.customTools;
|
|
6809
7090
|
const customToolkits = routerConfig.experimental?.customToolkits;
|
|
7091
|
+
const defaultCustomPreload = preloadsAllCustomTools(routerConfig.preload);
|
|
7092
|
+
const inlineCustomToolsPayload = prepareInlineCustomTools({
|
|
7093
|
+
customTools,
|
|
7094
|
+
customToolkits,
|
|
7095
|
+
defaultPreload: defaultCustomPreload,
|
|
7096
|
+
preloadTools: routerConfig.preload?.tools
|
|
7097
|
+
});
|
|
6810
7098
|
const experimentalPayload = {};
|
|
6811
7099
|
if (routerConfig.experimental?.assistivePrompt?.userTimezone) experimentalPayload.assistive_prompt_config = { user_timezone: routerConfig.experimental.assistivePrompt.userTimezone };
|
|
6812
|
-
if (
|
|
6813
|
-
if (
|
|
7100
|
+
if (inlineCustomToolsPayload?.custom_tools) experimentalPayload.custom_tools = inlineCustomToolsPayload.custom_tools;
|
|
7101
|
+
if (inlineCustomToolsPayload?.custom_toolkits) experimentalPayload.custom_toolkits = inlineCustomToolsPayload.custom_toolkits;
|
|
6814
7102
|
const multiAccountPayload = transformToolRouterMultiAccountParams(routerConfig.multiAccount);
|
|
7103
|
+
const connectedAccountsPayload = routerConfig.connectedAccounts === void 0 ? void 0 : Object.fromEntries(Object.entries(routerConfig.connectedAccounts).map(([toolkit, ids]) => [toolkit, typeof ids === "string" ? [ids] : ids]));
|
|
6815
7104
|
const payload = {
|
|
6816
7105
|
user_id: userId,
|
|
6817
7106
|
auth_configs: routerConfig.authConfigs,
|
|
6818
|
-
connected_accounts:
|
|
7107
|
+
connected_accounts: connectedAccountsPayload,
|
|
6819
7108
|
toolkits: transformToolRouterToolkitsParams(routerConfig.toolkits),
|
|
6820
7109
|
tools: transformToolRouterToolsParams(routerConfig.tools),
|
|
6821
7110
|
tags: transformToolRouterTagsParams(routerConfig.tags),
|
|
@@ -6823,13 +7112,22 @@ var ToolRouter = class {
|
|
|
6823
7112
|
workbench: transformToolRouterWorkbenchParams(routerConfig.workbench),
|
|
6824
7113
|
multi_account: multiAccountPayload,
|
|
6825
7114
|
preload: routerConfig.preload,
|
|
7115
|
+
...isDirectToolsPreset && {
|
|
7116
|
+
search: { enable: false },
|
|
7117
|
+
execute: { enable_multi_execute: false }
|
|
7118
|
+
},
|
|
6826
7119
|
experimental: Object.keys(experimentalPayload).length > 0 ? experimentalPayload : void 0
|
|
6827
7120
|
};
|
|
6828
7121
|
const session = await this.client.toolRouter.session.create(payload);
|
|
6829
7122
|
let customToolsMap;
|
|
6830
7123
|
if (customTools?.length || customToolkits?.length) customToolsMap = buildCustomToolsMapFromResponse(customTools ?? [], customToolkits, session.experimental);
|
|
7124
|
+
const metadata = {
|
|
7125
|
+
...getSessionMetadata(session),
|
|
7126
|
+
preloadedCustomToolSlugs: getPreloadedCustomToolSlugs(customToolsMap, defaultCustomPreload),
|
|
7127
|
+
inlineCustomToolsPayload
|
|
7128
|
+
};
|
|
6831
7129
|
const assistivePrompt = session.experimental?.assistive_prompt;
|
|
6832
|
-
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), { assistivePrompt }, customToolsMap, userId,
|
|
7130
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), { assistivePrompt }, customToolsMap, userId, metadata);
|
|
6833
7131
|
}
|
|
6834
7132
|
/**
|
|
6835
7133
|
* Use an existing session
|
|
@@ -6848,9 +7146,36 @@ var ToolRouter = class {
|
|
|
6848
7146
|
* console.log(session.mcp.headers);
|
|
6849
7147
|
* ```
|
|
6850
7148
|
*/
|
|
6851
|
-
async use(id) {
|
|
6852
|
-
const
|
|
6853
|
-
|
|
7149
|
+
async use(id, options) {
|
|
7150
|
+
const customTools = options?.customTools;
|
|
7151
|
+
const customToolkits = options?.customToolkits;
|
|
7152
|
+
const hasCustoms = !!(customTools?.length || customToolkits?.length);
|
|
7153
|
+
let session;
|
|
7154
|
+
const attachInlineCustomToolsPayload = prepareInlineCustomTools({
|
|
7155
|
+
customTools,
|
|
7156
|
+
customToolkits
|
|
7157
|
+
});
|
|
7158
|
+
let inlineCustomToolsPayload = attachInlineCustomToolsPayload;
|
|
7159
|
+
if (hasCustoms) session = await this.client.toolRouter.session.attach(id, { experimental: attachInlineCustomToolsPayload });
|
|
7160
|
+
else session = await this.client.toolRouter.session.retrieve(id);
|
|
7161
|
+
const defaultCustomPreload = preloadsAllCustomTools(session.config.preload);
|
|
7162
|
+
if (hasCustoms && defaultCustomPreload) inlineCustomToolsPayload = prepareInlineCustomTools({
|
|
7163
|
+
customTools,
|
|
7164
|
+
customToolkits,
|
|
7165
|
+
defaultPreload: true
|
|
7166
|
+
});
|
|
7167
|
+
let customToolsMap;
|
|
7168
|
+
let userId;
|
|
7169
|
+
if (hasCustoms) {
|
|
7170
|
+
customToolsMap = buildCustomToolsMapFromResponse(customTools ?? [], customToolkits, session.experimental);
|
|
7171
|
+
userId = session.config.user_id;
|
|
7172
|
+
}
|
|
7173
|
+
const metadata = {
|
|
7174
|
+
...getSessionMetadata(session),
|
|
7175
|
+
preloadedCustomToolSlugs: getPreloadedCustomToolSlugs(customToolsMap, defaultCustomPreload),
|
|
7176
|
+
inlineCustomToolsPayload
|
|
7177
|
+
};
|
|
7178
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), void 0, customToolsMap, userId, metadata);
|
|
6854
7179
|
}
|
|
6855
7180
|
};
|
|
6856
7181
|
|
|
@@ -6897,6 +7222,8 @@ var Composio = class Composio {
|
|
|
6897
7222
|
toolRouter;
|
|
6898
7223
|
/**
|
|
6899
7224
|
* Creates a new tool router session for a user.
|
|
7225
|
+
* Use `sessionPreset: SessionPreset.DIRECT_TOOLS` when all needed tools
|
|
7226
|
+
* should be exposed directly; see `ToolRouterCreateSessionConfig`.
|
|
6900
7227
|
*
|
|
6901
7228
|
* @param userId {string} The user id to create the session for
|
|
6902
7229
|
* @param config {ToolRouterConfig} The config for the tool router session
|
|
@@ -7140,6 +7467,107 @@ var ComposioProvider = class extends BaseNonAgenticProvider {
|
|
|
7140
7467
|
|
|
7141
7468
|
//#endregion
|
|
7142
7469
|
//#region src/utils/jsonSchema.ts
|
|
7470
|
+
const MAX_REF_CHAIN_DEPTH = 100;
|
|
7471
|
+
const MAX_NODE_DEPTH = 512;
|
|
7472
|
+
const CYCLE_BREAK_SENTINEL = {
|
|
7473
|
+
type: "object",
|
|
7474
|
+
additionalProperties: true
|
|
7475
|
+
};
|
|
7476
|
+
const POLLUTING_KEYS = new Set([
|
|
7477
|
+
"__proto__",
|
|
7478
|
+
"constructor",
|
|
7479
|
+
"prototype"
|
|
7480
|
+
]);
|
|
7481
|
+
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"];
|
|
7482
|
+
const decodePointerSegment = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
7483
|
+
const failResolution = (pointer, segment) => {
|
|
7484
|
+
throw new JsonSchemaRefResolutionError(`Cannot resolve $ref ${pointer}`, {
|
|
7485
|
+
meta: {
|
|
7486
|
+
ref: pointer,
|
|
7487
|
+
failedAt: segment
|
|
7488
|
+
},
|
|
7489
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
7490
|
+
});
|
|
7491
|
+
};
|
|
7492
|
+
const stepInto = (cursor, segment, pointer) => {
|
|
7493
|
+
if (cursor === null || typeof cursor !== "object") failResolution(pointer, segment);
|
|
7494
|
+
if (Array.isArray(cursor)) {
|
|
7495
|
+
const i = Number(segment);
|
|
7496
|
+
if (!Number.isInteger(i) || i < 0 || i >= cursor.length) failResolution(pointer, segment);
|
|
7497
|
+
return cursor[i];
|
|
7498
|
+
}
|
|
7499
|
+
const obj = cursor;
|
|
7500
|
+
if (!Object.prototype.hasOwnProperty.call(obj, segment)) failResolution(pointer, segment);
|
|
7501
|
+
return obj[segment];
|
|
7502
|
+
};
|
|
7503
|
+
const resolvePointer = (root, pointer) => {
|
|
7504
|
+
if (pointer === "#" || pointer === "") return root;
|
|
7505
|
+
if (!pointer.startsWith("#/")) throw new JsonSchemaRefResolutionError(`Unsupported $ref pointer: ${pointer}`, {
|
|
7506
|
+
meta: { ref: pointer },
|
|
7507
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
7508
|
+
});
|
|
7509
|
+
return pointer.slice(2).split("/").map(decodePointerSegment).reduce((cursor, seg) => stepInto(cursor, seg, pointer), root);
|
|
7510
|
+
};
|
|
7511
|
+
/**
|
|
7512
|
+
* Inlines internal JSON Schema `$ref` pointers (`#/$defs/...` and legacy
|
|
7513
|
+
* `#/definitions/...`) so the returned schema can be safely handed to
|
|
7514
|
+
* consumers that don't tolerate unresolved references (e.g. AJV in
|
|
7515
|
+
* `@mastra/schema-compat`). External (`http://`, `https://`, …) refs are
|
|
7516
|
+
* left untouched. Cycles are broken with `{ type: 'object',
|
|
7517
|
+
* additionalProperties: true }`. The input is never mutated.
|
|
7518
|
+
*
|
|
7519
|
+
* @throws {JsonSchemaRefResolutionError} on malformed pointers, missing
|
|
7520
|
+
* targets, or chains past the depth cap.
|
|
7521
|
+
*/
|
|
7522
|
+
function dereferenceJsonSchema(schema) {
|
|
7523
|
+
if (!isPlainObject(schema)) return schema;
|
|
7524
|
+
const root = schema;
|
|
7525
|
+
const visiting = /* @__PURE__ */ new WeakSet();
|
|
7526
|
+
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)]));
|
|
7527
|
+
function walk(node, visitedRefs, chainDepth, nodeDepth) {
|
|
7528
|
+
if (nodeDepth >= MAX_NODE_DEPTH) throw new JsonSchemaRefResolutionError(`JSON Schema node depth exceeded cap (${MAX_NODE_DEPTH})`, { possibleFixes: REF_RESOLUTION_FIXES });
|
|
7529
|
+
if (Array.isArray(node)) {
|
|
7530
|
+
if (visiting.has(node)) return { ...CYCLE_BREAK_SENTINEL };
|
|
7531
|
+
visiting.add(node);
|
|
7532
|
+
try {
|
|
7533
|
+
return node.map((item) => walk(item, visitedRefs, chainDepth, nodeDepth + 1));
|
|
7534
|
+
} finally {
|
|
7535
|
+
visiting.delete(node);
|
|
7536
|
+
}
|
|
7537
|
+
}
|
|
7538
|
+
if (!isPlainObject(node)) return node;
|
|
7539
|
+
if (visiting.has(node)) return { ...CYCLE_BREAK_SENTINEL };
|
|
7540
|
+
visiting.add(node);
|
|
7541
|
+
try {
|
|
7542
|
+
const ref = typeof node.$ref === "string" ? node.$ref : null;
|
|
7543
|
+
if (ref === null || !ref.startsWith("#")) {
|
|
7544
|
+
if (ref !== null) logger_default.warn(`Leaving external $ref untouched: ${ref}`);
|
|
7545
|
+
return cloneChildren(node, visitedRefs, chainDepth, nodeDepth);
|
|
7546
|
+
}
|
|
7547
|
+
if (chainDepth >= MAX_REF_CHAIN_DEPTH) throw new JsonSchemaRefResolutionError(`JSON Schema $ref chain exceeded depth cap (${MAX_REF_CHAIN_DEPTH}): ${ref}`, {
|
|
7548
|
+
meta: { ref },
|
|
7549
|
+
possibleFixes: REF_RESOLUTION_FIXES
|
|
7550
|
+
});
|
|
7551
|
+
if (visitedRefs.has(ref)) return { ...CYCLE_BREAK_SENTINEL };
|
|
7552
|
+
const resolved = walk(resolvePointer(root, ref), new Set(visitedRefs).add(ref), chainDepth + 1, nodeDepth + 1);
|
|
7553
|
+
const siblings = { ...node };
|
|
7554
|
+
delete siblings.$ref;
|
|
7555
|
+
if (Object.keys(siblings).length === 0 || !isPlainObject(resolved)) return resolved;
|
|
7556
|
+
return {
|
|
7557
|
+
...resolved,
|
|
7558
|
+
...cloneChildren(siblings, visitedRefs, chainDepth, nodeDepth)
|
|
7559
|
+
};
|
|
7560
|
+
} finally {
|
|
7561
|
+
visiting.delete(node);
|
|
7562
|
+
}
|
|
7563
|
+
}
|
|
7564
|
+
const out = walk(root, /* @__PURE__ */ new Set(), 0, 0);
|
|
7565
|
+
if (isPlainObject(out)) {
|
|
7566
|
+
delete out.$defs;
|
|
7567
|
+
delete out.definitions;
|
|
7568
|
+
}
|
|
7569
|
+
return out;
|
|
7570
|
+
}
|
|
7143
7571
|
/**
|
|
7144
7572
|
* Removes all non-required properties from the schema
|
|
7145
7573
|
*
|
|
@@ -7678,4 +8106,4 @@ const ComposioMcpUpdateResponseSchema = z$1.object({
|
|
|
7678
8106
|
});
|
|
7679
8107
|
|
|
7680
8108
|
//#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 };
|
|
8109
|
+
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, ComposioLegacyConnectedAccountsEndpointRetiredError, 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, 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, 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 };
|