@composio/core 0.20.0 → 0.21.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-fYEFjSLM.mjs → CustomTool-B-_VjWpy.mjs} +1 -1
- package/dist/{CustomTool-B3m-188G.d.mts → CustomTool-BHOYxLZX.d.mts} +1 -1
- package/dist/{cancellation-Dwa9lGHA.mjs → cancellation-DV8CIi52.mjs} +1 -1
- package/dist/{composio-B36OXii1.d.mts → composio-BTZsFajb.d.mts} +464 -4
- package/dist/{customTool.types-C436M_D0.d.mts → customTool.types-D_w21L56.d.mts} +454 -59
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +2 -1
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +1 -0
- package/dist/docs/reference/sdk-reference/typescript/meta.json +1 -0
- package/dist/docs/reference/sdk-reference/typescript/session-configs.mdx +83 -0
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +29 -20
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +10 -4
- package/dist/{errors-D_A4b2c2.mjs → errors-Dyiu3ifQ.mjs} +10 -6
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/index.d.mts +39 -26
- package/dist/index.mjs +1482 -1049
- package/dist/{types-Br3GBya5.d.mts → types-CgRsUGqm.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +2 -2
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/package.json +3 -1
- package/src/composio.ts +8 -0
- package/src/errors/ToolRouterErrors.ts +10 -6
- package/src/index.ts +2 -0
- package/src/lib/sessionConfigConflict.ts +43 -0
- package/src/lib/toolRouterParams.ts +34 -9
- package/src/lib/toolRouterSourceSessionConfig.ts +12 -0
- package/src/models/RemoteFile.ts +25 -8
- package/src/models/SessionConfigs.ts +117 -0
- package/src/models/ToolRouter.ts +19 -3
- package/src/models/ToolRouterSession.ts +45 -21
- package/src/models/Tools.ts +7 -5
- package/src/types/sessionConfigs.types.ts +81 -0
- package/src/types/tool.types.ts +2 -0
- package/src/types/toolRouter.types.ts +149 -7
- package/src/utils/safePath.ts +172 -0
- package/src/utils/transformers/sessionConfigs.ts +54 -0
- package/src/utils/transformers/toolRouterResponseTransform.ts +6 -0
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { c as DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID, d as USER_DATA_FILE_NAME, f as constants_exports, i as logger, l as IS_DEVELOPMENT_OR_CI, m as getEnvsWithPrefix, n as SsrfErrorCodes, o as COMPOSIO_DIR, p as getEnvVariable, r as ComposioError, s as DEFAULT_BASE_URL, t as ComposioBlockedInternalUrlError, u as TEMP_FILES_DIRECTORY_NAME } from "./SsrfErrors-DiQldIdC.mjs";
|
|
2
|
-
import { A as ComposioInvalidToolArgumentsError, B as ConnectionRequestTimeoutError, C as ValidationErrorCodes, D as ComposioGlobalExecuteToolFnNotSetError, E as ToolkitErrorCodes, F as ComposioToolVersionRequiredError, G as ComposioFailedToCreateConnectedAccountLink, H as ComposioConnectedAccountNotFoundError, I as ToolErrorCodes, J as ComposioSharedAccessDeniedError, K as ComposioLegacyConnectedAccountsEndpointRetiredError, L as handleToolExecutionError, M as ComposioToolExecutionError, N as ComposioToolFetchError, O as ComposioInvalidExecuteFunctionError, P as ComposioToolNotFoundError, Q as ComposioAuthConfigNotFoundError, R as ConnectionRequestErrorCodes, S as ValidationError, T as ComposioToolkitNotFoundError, U as ComposioConnectedAccountNotRevokableError, V as ComposioAclOnlyForSharedError, W as ComposioConnectedAccountRevocationNotSupportedError, X as ConnectedAccountErrorCodes, Y as ComposioSharedConnectionNotAccessibleError, Z as AuthConfigErrorCodes, _ as ComposioScopeConfigError, a as RemoteFileErrorCodes, b as JsonSchemaRefResolutionError, c as ComposioFailedToSubscribeToPusherChannelError, d as ComposioWebhookPayloadError, f as ComposioWebhookSignatureVerificationError, g as ComposioRequestCancelledError, h as ComposioNoAPIKeyError, i as RemoteFileDownloadError, j as ComposioProviderNotDefinedError, k as ComposioInvalidModifierError, l as ComposioFailedToUnsubscribeFromPusherChannelError, m as ComposioAPIKeyKindError, n as ComposioSessionConfigConflictError, o as ComposioFailedToCreatePusherClientError, p as TriggerErrorCodes, q as ComposioMultipleConnectedAccountsError, r as ToolRouterErrorCodes, s as ComposioFailedToGetSDKRealtimeCredentialsError, t as ComposioMCPDestinationError, u as ComposioTriggerTypeNotFoundError, v as SDKErrorCodes, w as ComposioToolkitFetchError, x as JsonSchemaToZodError, y as isRequestAbortError, z as ConnectionRequestFailedError } from "./errors-
|
|
2
|
+
import { A as ComposioInvalidToolArgumentsError, B as ConnectionRequestTimeoutError, C as ValidationErrorCodes, D as ComposioGlobalExecuteToolFnNotSetError, E as ToolkitErrorCodes, F as ComposioToolVersionRequiredError, G as ComposioFailedToCreateConnectedAccountLink, H as ComposioConnectedAccountNotFoundError, I as ToolErrorCodes, J as ComposioSharedAccessDeniedError, K as ComposioLegacyConnectedAccountsEndpointRetiredError, L as handleToolExecutionError, M as ComposioToolExecutionError, N as ComposioToolFetchError, O as ComposioInvalidExecuteFunctionError, P as ComposioToolNotFoundError, Q as ComposioAuthConfigNotFoundError, R as ConnectionRequestErrorCodes, S as ValidationError, T as ComposioToolkitNotFoundError, U as ComposioConnectedAccountNotRevokableError, V as ComposioAclOnlyForSharedError, W as ComposioConnectedAccountRevocationNotSupportedError, X as ConnectedAccountErrorCodes, Y as ComposioSharedConnectionNotAccessibleError, Z as AuthConfigErrorCodes, _ as ComposioScopeConfigError, a as RemoteFileErrorCodes, b as JsonSchemaRefResolutionError, c as ComposioFailedToSubscribeToPusherChannelError, d as ComposioWebhookPayloadError, f as ComposioWebhookSignatureVerificationError, g as ComposioRequestCancelledError, h as ComposioNoAPIKeyError, i as RemoteFileDownloadError, j as ComposioProviderNotDefinedError, k as ComposioInvalidModifierError, l as ComposioFailedToUnsubscribeFromPusherChannelError, m as ComposioAPIKeyKindError, n as ComposioSessionConfigConflictError, o as ComposioFailedToCreatePusherClientError, p as TriggerErrorCodes, q as ComposioMultipleConnectedAccountsError, r as ToolRouterErrorCodes, s as ComposioFailedToGetSDKRealtimeCredentialsError, t as ComposioMCPDestinationError, u as ComposioTriggerTypeNotFoundError, v as SDKErrorCodes, w as ComposioToolkitFetchError, x as JsonSchemaToZodError, y as isRequestAbortError, z as ConnectionRequestFailedError } from "./errors-Dyiu3ifQ.mjs";
|
|
3
3
|
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, o as FileModifierErrorCodes, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "./FileModifierErrors-CdGSABoq.mjs";
|
|
4
4
|
import { n as dropEmptyFileUploads, o as isPlainObject, s as schemaHasFileUploadable } from "./FileToolModifier.utils.neutral-DWFpnsj2.mjs";
|
|
5
|
-
import { a as jsonSchemaToZodSchema, c as toStrictJsonSchema, i as ensureObjectTypeOnProperties, n as deduplicateJsonSchemaRequiredArrays, o as omitNullToolArguments, r as dereferenceJsonSchema, s as removeNonRequiredProperties, t as withCancellation } from "./cancellation-
|
|
5
|
+
import { a as jsonSchemaToZodSchema, c as toStrictJsonSchema, i as ensureObjectTypeOnProperties, n as deduplicateJsonSchemaRequiredArrays, o as omitNullToolArguments, r as dereferenceJsonSchema, s as removeNonRequiredProperties, t as withCancellation } from "./cancellation-DV8CIi52.mjs";
|
|
6
6
|
import { t as telemetry } from "./Telemetry-JRJJYS4I.mjs";
|
|
7
7
|
import { a as readResponseBodyWithLimit, i as MAX_URL_UPLOAD_SIZE_BYTES, l as getRandomShortId, n as assertSafeFileUploadPath, o as arrayBufferToBase64, r as isBlockedSensitiveFileUploadPath, t as BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS } from "./sensitiveFileUploadPaths-BlLp-Yo2.mjs";
|
|
8
|
-
import { a as createCustomToolkit, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, f as CreateCustomToolkitBaseSchema, i as createCustomTool, l as serializeCustomToolkits, n as buildCustomToolsMap, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, u as serializeCustomTools } from "./CustomTool-
|
|
8
|
+
import { a as createCustomToolkit, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, f as CreateCustomToolkitBaseSchema, i as createCustomTool, l as serializeCustomToolkits, n as buildCustomToolsMap, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, u as serializeCustomTools } from "./CustomTool-B-_VjWpy.mjs";
|
|
9
9
|
import ComposioClient, { APIError, BadRequestError, ConflictError } from "@composio/client";
|
|
10
10
|
import { FileToolModifier } from "#file_tool_modifier";
|
|
11
11
|
import z, { z as z$1 } from "zod/v3";
|
|
@@ -1048,7 +1048,9 @@ const ToolExecuteResponseSchema = z$1.object({
|
|
|
1048
1048
|
error: z$1.string().nullable(),
|
|
1049
1049
|
successful: z$1.boolean(),
|
|
1050
1050
|
logId: z$1.string().optional(),
|
|
1051
|
-
sessionInfo: z$1.unknown().optional()
|
|
1051
|
+
sessionInfo: z$1.unknown().optional(),
|
|
1052
|
+
/** Actual premium usage charge when the Session opts into returning it. */
|
|
1053
|
+
premiumCharge: z$1.unknown().optional()
|
|
1052
1054
|
});
|
|
1053
1055
|
const ToolProxyParamsSchema = z$1.object({
|
|
1054
1056
|
endpoint: z$1.string(),
|
|
@@ -1179,6 +1181,88 @@ function resolveEffectiveUploadAllowlist(userDirs) {
|
|
|
1179
1181
|
return Array.isArray(resolved) ? resolved : [];
|
|
1180
1182
|
}
|
|
1181
1183
|
|
|
1184
|
+
//#endregion
|
|
1185
|
+
//#region src/utils/transformers/toolRouterResponseTransform.ts
|
|
1186
|
+
function transformSearchResult(raw) {
|
|
1187
|
+
return {
|
|
1188
|
+
index: raw.index,
|
|
1189
|
+
useCase: raw.use_case,
|
|
1190
|
+
primaryToolSlugs: raw.primary_tool_slugs,
|
|
1191
|
+
relatedToolSlugs: raw.related_tool_slugs,
|
|
1192
|
+
toolkits: raw.toolkits,
|
|
1193
|
+
difficulty: raw.difficulty,
|
|
1194
|
+
error: raw.error,
|
|
1195
|
+
executionGuidance: raw.execution_guidance,
|
|
1196
|
+
knownPitfalls: raw.known_pitfalls,
|
|
1197
|
+
memory: raw.memory,
|
|
1198
|
+
planId: raw.plan_id,
|
|
1199
|
+
recommendedPlanSteps: raw.recommended_plan_steps,
|
|
1200
|
+
referenceWorkbenchSnippets: raw.reference_workbench_snippets
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
function transformToolSchema(raw) {
|
|
1204
|
+
return {
|
|
1205
|
+
toolSlug: raw.tool_slug,
|
|
1206
|
+
toolkit: raw.toolkit,
|
|
1207
|
+
description: raw.description,
|
|
1208
|
+
hasFullSchema: raw.hasFullSchema,
|
|
1209
|
+
inputSchema: raw.input_schema,
|
|
1210
|
+
outputSchema: raw.output_schema,
|
|
1211
|
+
schemaRef: raw.schemaRef ? {
|
|
1212
|
+
args: { toolSlugs: raw.schemaRef.args.tool_slugs },
|
|
1213
|
+
message: raw.schemaRef.message,
|
|
1214
|
+
tool: raw.schemaRef.tool
|
|
1215
|
+
} : void 0
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
function transformToolkitConnectionStatus(raw) {
|
|
1219
|
+
return {
|
|
1220
|
+
toolkit: raw.toolkit,
|
|
1221
|
+
description: raw.description,
|
|
1222
|
+
hasActiveConnection: raw.has_active_connection,
|
|
1223
|
+
statusMessage: raw.status_message,
|
|
1224
|
+
connectionDetails: raw.connection_details,
|
|
1225
|
+
currentUserInfo: raw.current_user_info,
|
|
1226
|
+
...raw.hosted_account !== void 0 && { hostedAccount: { allowedToolSlugs: raw.hosted_account.allowed_tool_slugs } }
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Transforms a raw session search API response to camelCase.
|
|
1231
|
+
*/
|
|
1232
|
+
function transformSearchResponse(raw) {
|
|
1233
|
+
const toolSchemas = {};
|
|
1234
|
+
for (const [slug, schema] of Object.entries(raw.tool_schemas)) toolSchemas[slug] = transformToolSchema(schema);
|
|
1235
|
+
return {
|
|
1236
|
+
success: raw.success,
|
|
1237
|
+
error: raw.error,
|
|
1238
|
+
results: raw.results.map(transformSearchResult),
|
|
1239
|
+
toolSchemas,
|
|
1240
|
+
toolkitConnectionStatuses: raw.toolkit_connection_statuses.map(transformToolkitConnectionStatus),
|
|
1241
|
+
nextStepsGuidance: raw.next_steps_guidance,
|
|
1242
|
+
session: {
|
|
1243
|
+
id: raw.session.id,
|
|
1244
|
+
generateId: raw.session.generate_id,
|
|
1245
|
+
instructions: raw.session.instructions
|
|
1246
|
+
},
|
|
1247
|
+
timeInfo: {
|
|
1248
|
+
currentTimeUtc: raw.time_info.current_time_utc,
|
|
1249
|
+
currentTimeUtcEpochSeconds: raw.time_info.current_time_utc_epoch_seconds,
|
|
1250
|
+
message: raw.time_info.message
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Transforms a raw session execute API response to camelCase.
|
|
1256
|
+
*/
|
|
1257
|
+
function transformExecuteResponse(raw) {
|
|
1258
|
+
return {
|
|
1259
|
+
data: raw.data,
|
|
1260
|
+
error: raw.error,
|
|
1261
|
+
logId: raw.log_id,
|
|
1262
|
+
...raw.premium_charge !== void 0 && { premiumCharge: raw.premium_charge }
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1182
1266
|
//#endregion
|
|
1183
1267
|
//#region src/models/Tools.ts
|
|
1184
1268
|
const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
|
|
@@ -1910,11 +1994,13 @@ var Tools = class {
|
|
|
1910
1994
|
};
|
|
1911
1995
|
if (options?.experimental) executePayload.experimental = options.experimental;
|
|
1912
1996
|
const response = await withCancellation(() => this.client.toolRouter.session.execute(body.sessionId, executePayload, requestOptions), requestOptions?.signal);
|
|
1997
|
+
const { data, error, logId, premiumCharge } = transformExecuteResponse(response);
|
|
1913
1998
|
let result = {
|
|
1914
|
-
data
|
|
1915
|
-
error
|
|
1916
|
-
successful: !
|
|
1917
|
-
logId
|
|
1999
|
+
data,
|
|
2000
|
+
error,
|
|
2001
|
+
successful: !error,
|
|
2002
|
+
logId,
|
|
2003
|
+
...premiumCharge !== void 0 && { premiumCharge }
|
|
1918
2004
|
};
|
|
1919
2005
|
if (modifiers?.afterExecute) result = await modifiers.afterExecute({
|
|
1920
2006
|
toolSlug,
|
|
@@ -7388,1011 +7474,1242 @@ var Logs = class {
|
|
|
7388
7474
|
};
|
|
7389
7475
|
|
|
7390
7476
|
//#endregion
|
|
7391
|
-
//#region src/
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
*
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
/** Key identifier. Put it in the JWE protected header. */
|
|
7408
|
-
kid: z$1.string()
|
|
7409
|
-
});
|
|
7477
|
+
//#region src/lib/sessionConfigConflict.ts
|
|
7478
|
+
const SESSION_CONFIG_CONFLICT_MARKER = "sessionConfigConflict";
|
|
7479
|
+
/**
|
|
7480
|
+
* Adds the issue raised when a saved Session config (`experimental.sessionConfigId`)
|
|
7481
|
+
* is combined with inline access fields. `fields` lists every conflicting
|
|
7482
|
+
* field that was provided; nothing is added when it is empty.
|
|
7483
|
+
*/
|
|
7484
|
+
const addSessionConfigConflictIssue = (ctx, fields) => {
|
|
7485
|
+
if (fields.length === 0) return;
|
|
7486
|
+
ctx.addIssue({
|
|
7487
|
+
code: z$1.ZodIssueCode.custom,
|
|
7488
|
+
message: `experimental.sessionConfigId cannot be combined with ${fields.join(", ")}. A saved Session config sets the session's toolkit, tool and tag access; remove ${fields.length === 1 ? "that field" : "those fields"} or sessionConfigId`,
|
|
7489
|
+
path: ["experimental", "sessionConfigId"],
|
|
7490
|
+
params: { [SESSION_CONFIG_CONFLICT_MARKER]: true }
|
|
7491
|
+
});
|
|
7492
|
+
};
|
|
7410
7493
|
/**
|
|
7411
|
-
*
|
|
7494
|
+
* Parses session create or update input. A saved Session config combined with
|
|
7495
|
+
* inline access fields throws `ValidationError`; any other failure rethrows the
|
|
7496
|
+
* original `ZodError`, as `schema.parse()` would.
|
|
7412
7497
|
*/
|
|
7413
|
-
const
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
});
|
|
7419
|
-
|
|
7420
|
-
//#endregion
|
|
7421
|
-
//#region src/utils/transformers/keyring.ts
|
|
7422
|
-
const transformKeyringTransferKeysResponse = (response) => {
|
|
7423
|
-
return transform(response).with(KeyringTransferKeysResponseSchema).using((response) => ({
|
|
7424
|
-
activeKid: response.active_kid,
|
|
7425
|
-
keys: response.keys.map((key) => ({
|
|
7426
|
-
kty: key.kty,
|
|
7427
|
-
n: key.n,
|
|
7428
|
-
e: key.e,
|
|
7429
|
-
alg: key.alg,
|
|
7430
|
-
use: key.use,
|
|
7431
|
-
kid: key.kid
|
|
7432
|
-
}))
|
|
7433
|
-
}));
|
|
7498
|
+
const parseSessionConfigInput = (schema, input) => {
|
|
7499
|
+
const result = schema.safeParse(input);
|
|
7500
|
+
if (result.success) return result.data;
|
|
7501
|
+
if (result.error.issues.some((issue) => issue.code === z$1.ZodIssueCode.custom && issue.params?.[SESSION_CONFIG_CONFLICT_MARKER])) throw new ValidationError("Invalid session config", { cause: result.error });
|
|
7502
|
+
throw result.error;
|
|
7434
7503
|
};
|
|
7435
7504
|
|
|
7436
7505
|
//#endregion
|
|
7437
|
-
//#region src/
|
|
7506
|
+
//#region src/types/toolRouter.types.ts
|
|
7507
|
+
const SessionPreset = { DIRECT_TOOLS: "direct_tools" };
|
|
7508
|
+
const MCPServerTypeSchema = z.enum(["http", "sse"]);
|
|
7438
7509
|
/**
|
|
7439
|
-
*
|
|
7510
|
+
* Sandbox compute tier for the session sandbox.
|
|
7440
7511
|
*
|
|
7441
|
-
*
|
|
7442
|
-
*
|
|
7443
|
-
*
|
|
7444
|
-
*
|
|
7445
|
-
*
|
|
7512
|
+
* | Tier | vCPU | RAM |
|
|
7513
|
+
* | -------- | ---- | ----- |
|
|
7514
|
+
* | standard | 1 | 1 GB |
|
|
7515
|
+
* | medium | 2 | 2 GB |
|
|
7516
|
+
* | large | 4 | 4 GB |
|
|
7517
|
+
* | xlarge | 8 | 8 GB |
|
|
7518
|
+
*
|
|
7519
|
+
* Defaults to `standard` server-side when omitted.
|
|
7446
7520
|
*/
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7521
|
+
const SandboxSizeSchema = z.enum([
|
|
7522
|
+
"standard",
|
|
7523
|
+
"medium",
|
|
7524
|
+
"large",
|
|
7525
|
+
"xlarge"
|
|
7526
|
+
]);
|
|
7527
|
+
const ToolRouterSandboxConfigSchema = z.object({
|
|
7528
|
+
enable: z.boolean().default(true).describe("Whether to enable the sandbox entirely. Defaults to true. When set to false, no code execution tools (COMPOSIO_REMOTE_WORKBENCH, COMPOSIO_REMOTE_BASH_TOOL) are available in the session."),
|
|
7529
|
+
enableProxyExecution: z.boolean().optional().describe("Whether to enable proxy execution in the session sandbox"),
|
|
7530
|
+
autoOffloadThreshold: z.number().optional().describe("The auto offload threshold in characters for tool execution to move into the sandbox"),
|
|
7531
|
+
sandboxSize: SandboxSizeSchema.optional().describe("Sandbox compute tier. 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 sandbox on next access; the in-memory FS is lost, but /mnt/files/ persists.")
|
|
7532
|
+
});
|
|
7533
|
+
const ToolRouterConfigManageConnectionsSchema = z.object({
|
|
7534
|
+
enable: z.boolean().default(true).optional().describe("Whether to use tools to manage connections in the tool router session. Defaults to true, if set to false, you need to manage connections manually"),
|
|
7535
|
+
callbackUrl: z.string().optional().describe("The callback uri to use in the tool router session"),
|
|
7536
|
+
waitForConnections: z.boolean().optional().describe("Whether to wait for users to finish authenticating connections before proceeding to the next step. Defaults to false, if set to true, a wait for connections tool call will happen and finish when the connections are ready")
|
|
7537
|
+
}).strict();
|
|
7538
|
+
const ToolRouterToolkitsParamSchema = z.array(z.string()).describe("List of toolkits to enable in the tool router session");
|
|
7539
|
+
const ToolRouterToolkitsDisabledConfigSchema = z.object({ disable: ToolRouterToolkitsParamSchema.describe("List of toolkits to disable in the tool router session") }).strict();
|
|
7540
|
+
const ToolRouterToolkitsEnabledConfigSchema = z.object({ enable: ToolRouterToolkitsParamSchema.describe("List of toolkits to enable in the tool router session") }).strict();
|
|
7541
|
+
/** Experimental premium usage policy for a Session. */
|
|
7542
|
+
const ToolRouterPremiumUsageSchema = z.union([z.literal(false), z.object({
|
|
7543
|
+
toolkits: z.union([ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsDisabledConfigSchema]).optional(),
|
|
7544
|
+
tools: z.record(z.string(), z.union([z.object({ enable: z.array(z.string()) }).strict(), z.object({ disable: z.array(z.string()) }).strict()])).optional(),
|
|
7453
7545
|
/**
|
|
7454
|
-
*
|
|
7455
|
-
*
|
|
7456
|
-
*
|
|
7457
|
-
* Always seal new secrets to the key whose `kid` is `activeKid`: a JWE with
|
|
7458
|
-
* `RSA-OAEP-256` key management, `A256GCM` content encryption, and the
|
|
7459
|
-
* `kid` in the protected header. Older keys stay listed so values sealed to
|
|
7460
|
-
* them remain openable.
|
|
7461
|
-
*
|
|
7462
|
-
* The organization behind the API key must have an ACTIVE customer keyring
|
|
7463
|
-
* instance; otherwise the API answers 404.
|
|
7464
|
-
*
|
|
7465
|
-
* @returns {Promise<KeyringTransferKeysResponse>} The active key ID and every accepted public JWK, newest first
|
|
7466
|
-
*
|
|
7467
|
-
* @example
|
|
7468
|
-
* ```typescript
|
|
7469
|
-
* import { CompactEncrypt, importJWK } from 'jose';
|
|
7470
|
-
*
|
|
7471
|
-
* const { activeKid, keys } = await composio.keyring.listTransferKeys();
|
|
7472
|
-
* const jwk = keys.find(key => key.kid === activeKid)!;
|
|
7473
|
-
* const sealed = await new CompactEncrypt(new TextEncoder().encode(secret))
|
|
7474
|
-
* .setProtectedHeader({ alg: 'RSA-OAEP-256', enc: 'A256GCM', kid: activeKid })
|
|
7475
|
-
* .encrypt(await importJWK(jwk, 'RSA-OAEP-256'));
|
|
7476
|
-
* ```
|
|
7546
|
+
* Return the actual premium charge in Session tool responses. Controls
|
|
7547
|
+
* visibility only; on update, any policy object still re-enables premium
|
|
7548
|
+
* usage on a Session set to `false`.
|
|
7477
7549
|
*/
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7550
|
+
returnPremiumCharge: z.boolean().optional()
|
|
7551
|
+
}).strict()]);
|
|
7552
|
+
const ToolRouterManageConnectionsConfigSchema = z.object({
|
|
7553
|
+
enable: z.boolean().optional().describe("Whether to use tools to manage connections in the tool router session. Defaults to true, if set to false, you need to manage connections manually").default(true),
|
|
7554
|
+
callbackUrl: z.string().optional().describe("The callback url to use in the tool router session")
|
|
7555
|
+
});
|
|
7556
|
+
const ToolRouterTagsParamSchema = z.array(z.enum([
|
|
7557
|
+
"readOnlyHint",
|
|
7558
|
+
"destructiveHint",
|
|
7559
|
+
"idempotentHint",
|
|
7560
|
+
"openWorldHint"
|
|
7561
|
+
])).describe("The tags to filter the tools by");
|
|
7562
|
+
const ToolRouterTagsEnableDisableSchema = z.object({
|
|
7563
|
+
enable: ToolRouterTagsParamSchema.optional().describe("The tags to enable in the tool router session"),
|
|
7564
|
+
disable: ToolRouterTagsParamSchema.optional().describe("The tags to disable in the tool router session")
|
|
7565
|
+
}).strict();
|
|
7566
|
+
const ToolRouterConfigTagsSchema = z.union([ToolRouterTagsParamSchema, ToolRouterTagsEnableDisableSchema]).describe("The tags to use in the tool router session");
|
|
7487
7567
|
/**
|
|
7488
|
-
*
|
|
7489
|
-
*
|
|
7568
|
+
* Tools config - Configure tools per toolkit using toolkit slug as key
|
|
7569
|
+
* @example
|
|
7570
|
+
* ```typescript
|
|
7571
|
+
* {
|
|
7572
|
+
* gmail: {
|
|
7573
|
+
* enable: ['gmail_search', 'gmail_send']
|
|
7574
|
+
* },
|
|
7575
|
+
* slack: {
|
|
7576
|
+
* disable: ['slack_delete_message']
|
|
7577
|
+
* }
|
|
7578
|
+
* }
|
|
7579
|
+
* ```
|
|
7490
7580
|
*
|
|
7491
|
-
*
|
|
7492
|
-
*
|
|
7581
|
+
* @example
|
|
7582
|
+
* ```typescript
|
|
7583
|
+
* {
|
|
7584
|
+
* gmail: ['gmail_search', 'gmail_send'],
|
|
7585
|
+
* slack: { tags: ['readOnlyHint'] }
|
|
7586
|
+
* }
|
|
7587
|
+
* ```
|
|
7493
7588
|
*/
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
const
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
}
|
|
7509
|
-
const latestVersion = data.version;
|
|
7510
|
-
if (semver.gt(latestVersion, currentVersionFromPackageJson) && !IS_DEVELOPMENT_OR_CI) logger.info(`🚀 Upgrade available! Your ${packageName} version (${currentVersionFromPackageJson}) is behind. Latest version: ${latestVersion}.`);
|
|
7511
|
-
} catch (_error) {}
|
|
7512
|
-
}
|
|
7513
|
-
|
|
7514
|
-
//#endregion
|
|
7515
|
-
//#region src/provider/BaseProvider.ts
|
|
7516
|
-
/**
|
|
7517
|
-
* @internal
|
|
7518
|
-
* Base class for all providers.
|
|
7519
|
-
* This class is not meant to be used directly, but rather to be extended by different provider implementations.
|
|
7520
|
-
*/
|
|
7521
|
-
var BaseProvider = class {
|
|
7522
|
-
/**
|
|
7523
|
-
* @internal
|
|
7524
|
-
* The function to execute a tool.
|
|
7525
|
-
* This is set automatically injected by the core SDK.
|
|
7526
|
-
*/
|
|
7527
|
-
_globalExecuteToolFn;
|
|
7528
|
-
/**
|
|
7529
|
-
* @internal
|
|
7530
|
-
* Set the function to execute a tool.
|
|
7531
|
-
* This is set automatically and injected by the core SDK.
|
|
7532
|
-
*/
|
|
7533
|
-
_setExecuteToolFn(executeToolFn) {
|
|
7534
|
-
this._globalExecuteToolFn = executeToolFn;
|
|
7535
|
-
}
|
|
7536
|
-
/**
|
|
7537
|
-
* @public
|
|
7538
|
-
* Global function to execute a tool.
|
|
7539
|
-
* This function is used by providers to implement helper functions to execute tools.
|
|
7540
|
-
* This is a 1:1 mapping of the `execute` method in the `Tools` class.
|
|
7541
|
-
* @param {string} toolSlug - The slug of the tool to execute.
|
|
7542
|
-
* @param {ToolExecuteParams} body - The body of the tool execution.
|
|
7543
|
-
* @param {ExecuteToolModifiers} modifers - The modifiers of the tool execution.
|
|
7544
|
-
* @returns {Promise<string>} The result of the tool execution.
|
|
7545
|
-
*/
|
|
7546
|
-
executeTool(toolSlug, body, modifers) {
|
|
7547
|
-
if (!this._globalExecuteToolFn) throw new ComposioGlobalExecuteToolFnNotSetError("executeToolFn is not set");
|
|
7548
|
-
return this._globalExecuteToolFn(toolSlug, body, modifers);
|
|
7549
|
-
}
|
|
7550
|
-
/** Reject direct-only configuration when execution is bound to a session. */
|
|
7551
|
-
assertToolCallExecutionOptions(target, options, modifiers) {
|
|
7552
|
-
if (typeof target !== "string" && (options !== void 0 || modifiers !== void 0)) throw new TypeError("Direct execution options and modifiers cannot be used with a Tool Router session");
|
|
7553
|
-
}
|
|
7554
|
-
/**
|
|
7555
|
-
* Execute normalized provider arguments against either the direct tools API or
|
|
7556
|
-
* the Tool Router session that produced the model-visible tools.
|
|
7557
|
-
*/
|
|
7558
|
-
async executeToolForTarget(target, toolSlug, arguments_, options, modifiers) {
|
|
7559
|
-
this.assertToolCallExecutionOptions(target, options, modifiers);
|
|
7560
|
-
if (typeof target === "string") return this.executeTool(toolSlug, {
|
|
7561
|
-
arguments: arguments_,
|
|
7562
|
-
connectedAccountId: options?.connectedAccountId,
|
|
7563
|
-
customAuthParams: options?.customAuthParams,
|
|
7564
|
-
customConnectionData: options?.customConnectionData,
|
|
7565
|
-
userId: target
|
|
7566
|
-
}, modifiers);
|
|
7567
|
-
const result = await target.execute(toolSlug, arguments_);
|
|
7568
|
-
return {
|
|
7569
|
-
...result,
|
|
7570
|
-
successful: result.error === null
|
|
7571
|
-
};
|
|
7589
|
+
const ToolRouterToolsParamSchema = z.array(z.string()).describe("The tools to use in the tool router session");
|
|
7590
|
+
const ToolRouterConfigToolsSchema = z.union([
|
|
7591
|
+
ToolRouterToolsParamSchema,
|
|
7592
|
+
z.object({ enable: ToolRouterToolsParamSchema.describe("The tools to enable in the tool router session") }).strict(),
|
|
7593
|
+
z.object({ disable: ToolRouterToolsParamSchema.describe("The tools to disable in the tool router session") }).strict(),
|
|
7594
|
+
z.object({ tags: ToolRouterConfigTagsSchema.describe("The tags to filter the tools by, this will override the global tags") }).strict()
|
|
7595
|
+
]).superRefine((val, ctx) => {
|
|
7596
|
+
if (typeof val === "object" && !Array.isArray(val)) {
|
|
7597
|
+
const keys = Object.keys(val);
|
|
7598
|
+
if (keys.length > 1) ctx.addIssue({
|
|
7599
|
+
code: z.ZodIssueCode.custom,
|
|
7600
|
+
message: `Only one of 'enable', 'disable', or 'tags' can be specified, but found: ${keys.join(", ")}`,
|
|
7601
|
+
path: keys
|
|
7602
|
+
});
|
|
7572
7603
|
}
|
|
7604
|
+
});
|
|
7605
|
+
const ToolRouterCreateSessionConfigBaseSchema = z.object({
|
|
7606
|
+
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."),
|
|
7607
|
+
mcp: z.boolean().optional().describe("When true, the returned session surfaces its hosted MCP endpoint (`session.mcp.url` / `session.mcp.headers`) in the type, and an MCP URL that is not on the API base URL origin throws `ComposioMCPDestinationError` instead of leaving `session.mcp.headers` empty with a warning. The endpoint exists on every session at runtime regardless of this flag, but is only typed when `mcp: true` is passed. Default native tools (`session.tools()`) are unaffected. See https://docs.composio.dev/docs/sessions-via-mcp"),
|
|
7608
|
+
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).optional().describe("The tools to use in the tool router session"),
|
|
7609
|
+
tags: ToolRouterConfigTagsSchema.optional().describe("Global tags to filter the tools by"),
|
|
7610
|
+
toolkits: z.union([
|
|
7611
|
+
ToolRouterToolkitsParamSchema,
|
|
7612
|
+
ToolRouterToolkitsDisabledConfigSchema,
|
|
7613
|
+
ToolRouterToolkitsEnabledConfigSchema
|
|
7614
|
+
]).optional().describe("The toolkits to use in the tool router session"),
|
|
7615
|
+
premiumUsage: ToolRouterPremiumUsageSchema.optional().describe("Experimental premium usage policy. Omission permits eligible tools when the project allows premium usage; false disables it for this Session."),
|
|
7616
|
+
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({}),
|
|
7617
|
+
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({}),
|
|
7618
|
+
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."),
|
|
7619
|
+
sandbox: ToolRouterSandboxConfigSchema.optional().describe("The sandbox config for this session. Prefer this over workbench."),
|
|
7620
|
+
workbench: ToolRouterSandboxConfigSchema.optional().describe("Deprecated alias for sandbox. Accepted for backwards compatibility."),
|
|
7621
|
+
multiAccount: z.object({
|
|
7622
|
+
enable: z.boolean().default(false).describe("When true, enables multi-account mode for this session. Defaults to false."),
|
|
7623
|
+
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."),
|
|
7624
|
+
requireExplicitSelection: z.boolean().optional().describe("When true, require explicit account selection when multiple accounts are connected. When false (default), use the first/default account.")
|
|
7625
|
+
}).optional().describe("Multi-account configuration for this session"),
|
|
7626
|
+
preload: z.object({ tools: z.union([z.array(z.string()), z.literal("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."),
|
|
7627
|
+
experimental: z.object({
|
|
7628
|
+
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"),
|
|
7629
|
+
customTools: z.array(z.custom()).optional().describe("Custom tools to include in this session. Created via createCustomTool() from @composio/core/experimental."),
|
|
7630
|
+
customToolkits: z.array(z.custom()).optional().describe("Custom toolkits to include in this session. Created via createCustomToolkit() from @composio/core/experimental."),
|
|
7631
|
+
sessionConfigId: z.string().min(1).optional().describe("ID of a saved Session config (`sc_…`) to apply when the session is created. Cannot be combined with toolkits, tools, tags, customTools or customToolkits.")
|
|
7632
|
+
}).optional().describe("Experimental features configuration - not stable, may be modified or removed")
|
|
7633
|
+
}).partial().superRefine((config, ctx) => {
|
|
7634
|
+
if (config.experimental?.sessionConfigId !== void 0) addSessionConfigConflictIssue(ctx, [
|
|
7635
|
+
config.toolkits !== void 0 && "toolkits",
|
|
7636
|
+
config.tools !== void 0 && "tools",
|
|
7637
|
+
config.tags !== void 0 && "tags",
|
|
7638
|
+
config.experimental.customTools !== void 0 && "experimental.customTools",
|
|
7639
|
+
config.experimental.customToolkits !== void 0 && "experimental.customToolkits"
|
|
7640
|
+
].filter((field) => field !== false));
|
|
7641
|
+
if (config.sandbox !== void 0 && config.workbench !== void 0) ctx.addIssue({
|
|
7642
|
+
code: z.ZodIssueCode.custom,
|
|
7643
|
+
message: "Pass either sandbox or workbench, not both. workbench is a backwards-compatible alias for sandbox.",
|
|
7644
|
+
path: ["sandbox"]
|
|
7645
|
+
});
|
|
7646
|
+
}).describe("The config for the tool router session");
|
|
7647
|
+
const applyDirectToolsPresetDefaults = (value) => {
|
|
7648
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
7649
|
+
const config = value;
|
|
7650
|
+
if (config.sessionPreset !== SessionPreset.DIRECT_TOOLS) return value;
|
|
7651
|
+
const hasSandboxConfig = config.sandbox !== void 0 || config.workbench !== void 0;
|
|
7652
|
+
return {
|
|
7653
|
+
...config,
|
|
7654
|
+
manageConnections: config.manageConnections === void 0 ? false : config.manageConnections,
|
|
7655
|
+
...hasSandboxConfig ? {} : { sandbox: { enable: false } },
|
|
7656
|
+
preload: config.preload === void 0 ? { tools: "all" } : config.preload
|
|
7657
|
+
};
|
|
7573
7658
|
};
|
|
7659
|
+
const ToolRouterCreateSessionConfigSchema = z.preprocess(applyDirectToolsPresetDefaults, ToolRouterCreateSessionConfigBaseSchema).describe("The config for the tool router session");
|
|
7660
|
+
const ToolkitConnectionStateSchema = z.object({
|
|
7661
|
+
slug: z.string().describe("The slug of a toolkit"),
|
|
7662
|
+
name: z.string().describe("The name of a toolkit"),
|
|
7663
|
+
logo: z.string().optional().describe("The logo of a toolkit"),
|
|
7664
|
+
isNoAuth: z.boolean().default(false).describe("Whether the toolkit is no auth or not"),
|
|
7665
|
+
connection: z.object({
|
|
7666
|
+
isActive: z.boolean().describe("Whether the connection is active or not"),
|
|
7667
|
+
authConfig: z.object({
|
|
7668
|
+
id: z.string().describe("The id of the auth config"),
|
|
7669
|
+
mode: z.string().describe("The auth scheme used by the auth config"),
|
|
7670
|
+
isComposioManaged: z.boolean().describe("Whether the auth config is managed by Composio")
|
|
7671
|
+
}).nullish().describe("The auth config of a toolkit"),
|
|
7672
|
+
connectedAccount: z.object({
|
|
7673
|
+
id: z.string().describe("The id of the connected account"),
|
|
7674
|
+
status: z.string().describe("The status of the connected account")
|
|
7675
|
+
}).optional().describe("The connected account of a toolkit")
|
|
7676
|
+
}).optional().describe("The connection of a toolkit")
|
|
7677
|
+
}).describe("The connection state of a toolkit");
|
|
7678
|
+
const ToolkitConnectionsDetailsSchema = z.object({
|
|
7679
|
+
items: z.array(ToolkitConnectionStateSchema),
|
|
7680
|
+
cursor: z.string().optional(),
|
|
7681
|
+
totalPages: z.number()
|
|
7682
|
+
});
|
|
7683
|
+
const ToolRouterMCPServerConfigSchema = z.object({
|
|
7684
|
+
type: MCPServerTypeSchema,
|
|
7685
|
+
url: z.string(),
|
|
7686
|
+
headers: z.record(z.string(), z.string()).optional()
|
|
7687
|
+
});
|
|
7688
|
+
const ToolRouterToolkitsOptionsSchema = z.object({
|
|
7689
|
+
toolkits: z.array(z.string()).optional(),
|
|
7690
|
+
cursor: z.string().optional(),
|
|
7691
|
+
limit: z.number().optional(),
|
|
7692
|
+
isConnected: z.boolean().optional(),
|
|
7693
|
+
search: z.string().optional()
|
|
7694
|
+
});
|
|
7695
|
+
const ToolRouterSessionSearchResultReferenceWorkbenchSnippetSchema = z.object({
|
|
7696
|
+
code: z.string(),
|
|
7697
|
+
description: z.string()
|
|
7698
|
+
});
|
|
7699
|
+
const ToolRouterSessionSearchResultSchema = z.object({
|
|
7700
|
+
index: z.number(),
|
|
7701
|
+
useCase: z.string(),
|
|
7702
|
+
primaryToolSlugs: z.array(z.string()),
|
|
7703
|
+
relatedToolSlugs: z.array(z.string()),
|
|
7704
|
+
toolkits: z.array(z.string()),
|
|
7705
|
+
difficulty: z.string().optional(),
|
|
7706
|
+
error: z.string().nullable().optional(),
|
|
7707
|
+
executionGuidance: z.string().optional(),
|
|
7708
|
+
knownPitfalls: z.array(z.string()).optional(),
|
|
7709
|
+
memory: z.record(z.string(), z.array(z.string())).optional(),
|
|
7710
|
+
planId: z.string().optional(),
|
|
7711
|
+
recommendedPlanSteps: z.array(z.string()).optional(),
|
|
7712
|
+
referenceWorkbenchSnippets: z.array(ToolRouterSessionSearchResultReferenceWorkbenchSnippetSchema).optional()
|
|
7713
|
+
});
|
|
7714
|
+
const ToolRouterSessionSearchSessionSchema = z.object({
|
|
7715
|
+
id: z.string(),
|
|
7716
|
+
generateId: z.boolean(),
|
|
7717
|
+
instructions: z.string()
|
|
7718
|
+
});
|
|
7719
|
+
const ToolRouterSessionSearchTimeInfoSchema = z.object({
|
|
7720
|
+
currentTimeUtc: z.string(),
|
|
7721
|
+
currentTimeUtcEpochSeconds: z.number(),
|
|
7722
|
+
message: z.string()
|
|
7723
|
+
});
|
|
7724
|
+
const ToolRouterSessionSearchToolSchemasSchemaRefSchema = z.object({
|
|
7725
|
+
args: z.object({ toolSlugs: z.array(z.string()) }),
|
|
7726
|
+
message: z.string().optional(),
|
|
7727
|
+
tool: z.literal("COMPOSIO_GET_TOOL_SCHEMAS")
|
|
7728
|
+
});
|
|
7729
|
+
const ToolRouterSessionSearchToolSchemaSchema = z.object({
|
|
7730
|
+
toolSlug: z.string(),
|
|
7731
|
+
toolkit: z.string(),
|
|
7732
|
+
description: z.string().optional(),
|
|
7733
|
+
hasFullSchema: z.boolean().optional(),
|
|
7734
|
+
inputSchema: z.record(z.string(), z.unknown()).optional(),
|
|
7735
|
+
outputSchema: z.record(z.string(), z.unknown()).optional(),
|
|
7736
|
+
schemaRef: ToolRouterSessionSearchToolSchemasSchemaRefSchema.optional()
|
|
7737
|
+
});
|
|
7738
|
+
const ToolRouterSessionSearchToolkitConnectionStatusSchema = z.object({
|
|
7739
|
+
toolkit: z.string(),
|
|
7740
|
+
description: z.string(),
|
|
7741
|
+
hasActiveConnection: z.boolean(),
|
|
7742
|
+
statusMessage: z.string(),
|
|
7743
|
+
connectionDetails: z.record(z.string(), z.unknown()).optional(),
|
|
7744
|
+
currentUserInfo: z.record(z.string(), z.unknown()).optional(),
|
|
7745
|
+
/** Present when the toolkit runs on a Composio hosted account; only these tools run on it. */
|
|
7746
|
+
hostedAccount: z.object({ allowedToolSlugs: z.array(z.string()) }).optional()
|
|
7747
|
+
});
|
|
7748
|
+
const ToolRouterSessionSearchResponseSchema = z.object({
|
|
7749
|
+
success: z.boolean(),
|
|
7750
|
+
error: z.string().nullable(),
|
|
7751
|
+
results: z.array(ToolRouterSessionSearchResultSchema),
|
|
7752
|
+
toolSchemas: z.record(z.string(), ToolRouterSessionSearchToolSchemaSchema),
|
|
7753
|
+
toolkitConnectionStatuses: z.array(ToolRouterSessionSearchToolkitConnectionStatusSchema),
|
|
7754
|
+
nextStepsGuidance: z.array(z.string()),
|
|
7755
|
+
session: ToolRouterSessionSearchSessionSchema,
|
|
7756
|
+
timeInfo: ToolRouterSessionSearchTimeInfoSchema
|
|
7757
|
+
});
|
|
7758
|
+
const ToolRouterSessionExecuteResponseSchema = z.object({
|
|
7759
|
+
data: z.record(z.string(), z.unknown()),
|
|
7760
|
+
error: z.string().nullable(),
|
|
7761
|
+
logId: z.string(),
|
|
7762
|
+
/** Actual premium usage charge when the Session opts into returning it. */
|
|
7763
|
+
premiumCharge: z.unknown().optional()
|
|
7764
|
+
});
|
|
7765
|
+
const SessionProxyExecuteParamsSchema = z.object({
|
|
7766
|
+
/** The toolkit whose connected account to use for auth (e.g. 'gmail', 'github') */
|
|
7767
|
+
toolkit: z.string(),
|
|
7768
|
+
/** The API endpoint URL to call */
|
|
7769
|
+
endpoint: z.string(),
|
|
7770
|
+
/** HTTP method */
|
|
7771
|
+
method: z.enum([
|
|
7772
|
+
"GET",
|
|
7773
|
+
"POST",
|
|
7774
|
+
"PUT",
|
|
7775
|
+
"DELETE",
|
|
7776
|
+
"PATCH"
|
|
7777
|
+
]),
|
|
7778
|
+
/** Request body (for POST/PUT/PATCH) */
|
|
7779
|
+
body: z.unknown().optional(),
|
|
7780
|
+
/** Query params or headers to include */
|
|
7781
|
+
parameters: z.array(z.object({
|
|
7782
|
+
in: z.enum(["query", "header"]),
|
|
7783
|
+
name: z.string(),
|
|
7784
|
+
value: z.union([z.string(), z.number()])
|
|
7785
|
+
})).optional()
|
|
7786
|
+
});
|
|
7574
7787
|
/**
|
|
7575
|
-
*
|
|
7576
|
-
*
|
|
7577
|
-
*
|
|
7578
|
-
*/
|
|
7579
|
-
var BaseNonAgenticProvider = class extends BaseProvider {
|
|
7580
|
-
_isAgentic = false;
|
|
7581
|
-
};
|
|
7582
|
-
/**
|
|
7583
|
-
* @public
|
|
7584
|
-
* Base class for all agentic providers.
|
|
7585
|
-
* This class is not meant to be used directly, but rather to be extended by concrete provider implementations.
|
|
7788
|
+
* `manageConnections` shape accepted by `session.update()`. Unlike the create
|
|
7789
|
+
* schema, `callbackUrl: null` removes the stored callback URL while leaving
|
|
7790
|
+
* the sibling connection settings untouched.
|
|
7586
7791
|
*/
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7792
|
+
const ToolRouterUpdateManageConnectionsSchema = z.object({
|
|
7793
|
+
enable: z.boolean().optional().describe("Whether to use tools to manage connections in the tool router session. Defaults to true, if set to false, you need to manage connections manually"),
|
|
7794
|
+
callbackUrl: z.string().nullable().optional().describe("The callback url to use in the tool router session. `null` removes the stored callback url; sibling settings are untouched"),
|
|
7795
|
+
waitForConnections: z.boolean().optional().describe("Whether to wait for users to finish authenticating connections before proceeding to the next step. Defaults to false, if set to true, a wait for connections tool call will happen and finish when the connections are ready"),
|
|
7796
|
+
enableConnectionRemoval: z.boolean().nullable().optional().describe("Whether the session exposes the connection removal tool. `null` removes the stored override")
|
|
7797
|
+
}).strict();
|
|
7798
|
+
const ToolRouterElicitationDefaultSchema = z.enum([
|
|
7799
|
+
"allow_all",
|
|
7800
|
+
"ask_every_call",
|
|
7801
|
+
"ask_once_per_session"
|
|
7802
|
+
]);
|
|
7803
|
+
const ToolRouterElicitationOverrideSchema = z.enum([
|
|
7804
|
+
"always_allow",
|
|
7805
|
+
"always_deny",
|
|
7806
|
+
"ask_once",
|
|
7807
|
+
"ask_always"
|
|
7808
|
+
]);
|
|
7809
|
+
/**
|
|
7810
|
+
* `experimental` block accepted by `session.update()`. Each leaf follows the
|
|
7811
|
+
* PATCH contract of the API: omit to keep the stored value, `null` to remove
|
|
7812
|
+
* it, a value to replace it.
|
|
7813
|
+
*/
|
|
7814
|
+
const ToolRouterUpdateExperimentalSchema = z.object({
|
|
7815
|
+
permissions: z.object({
|
|
7816
|
+
default: ToolRouterElicitationDefaultSchema,
|
|
7817
|
+
overrides: z.record(z.string(), ToolRouterElicitationOverrideSchema).optional()
|
|
7818
|
+
}).strict().nullable().optional().describe("Per-tool elicitation permission config. `null` removes the stored block"),
|
|
7819
|
+
linkUrlOverwrite: z.string().nullable().optional().describe("Base URL override for connection link redirects. `null` removes the stored override"),
|
|
7820
|
+
fastMode: z.boolean().nullable().optional().describe("Fast search mode. `null` removes the stored override"),
|
|
7821
|
+
submitFeedback: z.object({ enable: z.boolean() }).strict().nullable().optional().describe("Exposes the COMPOSIO_SUBMIT_FEEDBACK helper tool. `null` removes the stored block"),
|
|
7822
|
+
sessionConfigId: z.string().min(1).optional().describe("Apply the latest active saved Session config (`sc_…`) from this project to this session. Replaces the session's toolkit, tool and tag access and cannot be combined with toolkits, tools or tags")
|
|
7823
|
+
}).strict();
|
|
7824
|
+
/**
|
|
7825
|
+
* Options for `session.update()`. For every policy block, omitting the key
|
|
7826
|
+
* preserves the stored value and `null` removes the stored override (which can
|
|
7827
|
+
* increase access: `toolkits: null` restores the unrestricted default, unlike
|
|
7828
|
+
* `toolkits: []`, which denies every app toolkit).
|
|
7829
|
+
*/
|
|
7830
|
+
const ToolRouterUpdateSessionConfigSchema = z.object({
|
|
7831
|
+
premiumUsage: ToolRouterPremiumUsageSchema.optional().describe("Experimental premium usage policy. False disables it. Any supplied object, even one that only sets returnPremiumCharge, re-enables it. Omitted subfields keep their stored values."),
|
|
7832
|
+
toolkits: z.union([
|
|
7833
|
+
ToolRouterToolkitsParamSchema,
|
|
7834
|
+
ToolRouterToolkitsDisabledConfigSchema,
|
|
7835
|
+
ToolRouterToolkitsEnabledConfigSchema
|
|
7836
|
+
]).nullable().optional().describe("Toolkit policy. An empty allowlist (`[]` or `{ enable: [] }`) is sent as-is and denies every app toolkit; `null` removes the stored policy and restores the unrestricted default"),
|
|
7837
|
+
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).nullable().optional().describe("Replaces the entire stored tools map; `null` removes the override"),
|
|
7838
|
+
tags: ToolRouterConfigTagsSchema.nullable().optional().describe("Replaces the global tag policy; `null` removes the override"),
|
|
7839
|
+
authConfigs: z.record(z.string(), z.string()).nullable().optional().describe("Replaces the entire stored auth config map; `null` removes the override"),
|
|
7840
|
+
connectedAccounts: z.record(z.string(), z.union([z.string(), z.array(z.string())])).transform((rec) => {
|
|
7841
|
+
const out = {};
|
|
7842
|
+
for (const [k, v] of Object.entries(rec)) out[k] = typeof v === "string" ? [v] : v;
|
|
7843
|
+
return out;
|
|
7844
|
+
}).nullable().optional().describe("Replaces the entire stored connected accounts map; `null` removes the override"),
|
|
7845
|
+
manageConnections: z.union([z.boolean(), ToolRouterUpdateManageConnectionsSchema]).nullable().optional(),
|
|
7846
|
+
sandbox: ToolRouterSandboxConfigSchema.partial().nullable().optional(),
|
|
7847
|
+
workbench: ToolRouterSandboxConfigSchema.partial().nullable().optional(),
|
|
7848
|
+
multiAccount: z.object({
|
|
7849
|
+
enable: z.boolean().optional(),
|
|
7850
|
+
maxAccountsPerToolkit: z.number().int().min(2).max(10).nullable().optional().describe("`null` removes the stored maximum so the default applies again"),
|
|
7851
|
+
requireExplicitSelection: z.boolean().optional()
|
|
7852
|
+
}).nullable().optional().describe("`null` removes the session override; the mode then resolves to disabled"),
|
|
7853
|
+
preload: z.object({ tools: z.union([z.array(z.string()), z.literal("all")]).optional() }).strict().nullable().optional().describe("Replaces the stored preload; `null` removes it"),
|
|
7854
|
+
search: z.object({ enable: z.boolean().optional() }).strict().nullable().optional().describe("Replaces the search block; `null` removes it and restores the defaults"),
|
|
7855
|
+
execute: z.object({ enableMultiExecute: z.boolean().optional() }).strict().nullable().optional().describe("Replaces the execute block; `null` removes it and restores the defaults"),
|
|
7856
|
+
experimental: ToolRouterUpdateExperimentalSchema.nullable().optional().describe("Experimental settings; `null` removes the stored block"),
|
|
7857
|
+
expectedConfigVersion: z.union([z.number().int().positive(), z.literal(false)]).optional().describe("Precondition sent as `expected_config_version`. A positive integer (for example `session.configVersion`) makes the update conditional, so a concurrent change surfaces as ComposioSessionConfigConflictError instead of being overwritten; the API must support the field. Omitted or `false`: no precondition (last writer wins)")
|
|
7858
|
+
}).partial().superRefine((config, ctx) => {
|
|
7859
|
+
if (config.experimental?.sessionConfigId !== void 0) addSessionConfigConflictIssue(ctx, [
|
|
7860
|
+
config.toolkits !== void 0 && "toolkits",
|
|
7861
|
+
config.tools !== void 0 && "tools",
|
|
7862
|
+
config.tags !== void 0 && "tags"
|
|
7863
|
+
].filter((field) => field !== false));
|
|
7864
|
+
if (config.sandbox !== void 0 && config.workbench !== void 0) ctx.addIssue({
|
|
7865
|
+
code: z.ZodIssueCode.custom,
|
|
7866
|
+
message: "Pass either sandbox or workbench, not both. workbench is a backwards-compatible alias for sandbox.",
|
|
7867
|
+
path: ["sandbox"]
|
|
7868
|
+
});
|
|
7869
|
+
});
|
|
7870
|
+
const ToolRouterSessionDeleteResponseSchema = z.object({
|
|
7871
|
+
sessionId: z.string(),
|
|
7872
|
+
deleted: z.literal(true)
|
|
7873
|
+
});
|
|
7874
|
+
/**
|
|
7875
|
+
* Options for `session.listConfigHistory()`.
|
|
7876
|
+
*/
|
|
7877
|
+
const ToolRouterSessionListConfigHistoryOptionsSchema = z.object({
|
|
7878
|
+
/** Cursor from a previous response's `nextCursor`. */
|
|
7879
|
+
cursor: z.string().optional(),
|
|
7880
|
+
/** Number of items per page, max allowed is 100. */
|
|
7881
|
+
limit: z.number().optional()
|
|
7882
|
+
});
|
|
7883
|
+
const ToolRouterSessionEnsureConnectedOptionsSchema = z.object({
|
|
7884
|
+
callbackUrl: z.string().optional(),
|
|
7885
|
+
alias: z.string().optional(),
|
|
7886
|
+
experimental: ConnectedAccountExperimentalSchema.optional(),
|
|
7887
|
+
/** Max time to wait for a newly-initiated connection to become active, in milliseconds. Defaults to 60000. */
|
|
7888
|
+
timeout: z.number().int().positive().optional()
|
|
7889
|
+
});
|
|
7590
7890
|
|
|
7591
7891
|
//#endregion
|
|
7592
|
-
//#region src/
|
|
7892
|
+
//#region src/types/sessionConfigs.types.ts
|
|
7593
7893
|
/**
|
|
7594
|
-
*
|
|
7595
|
-
*
|
|
7596
|
-
* Models (and MCP transports) occasionally emit tool-call arguments as a JSON
|
|
7597
|
-
* *string* instead of an object. `COMPOSIO_MULTI_EXECUTE_TOOL` and Vercel AI
|
|
7598
|
-
* SDK streaming are common triggers. Forwarding that raw string to execution
|
|
7599
|
-
* surfaces opaque downstream errors such as
|
|
7600
|
-
* `tool_use.input: Input should be a valid dictionary`.
|
|
7601
|
-
*
|
|
7602
|
-
* `normalizeToolArguments` is the single coercion every provider routes through
|
|
7603
|
-
* so the behaviour is identical everywhere instead of being re-implemented
|
|
7604
|
-
* (inconsistently) per provider.
|
|
7605
|
-
*
|
|
7606
|
-
* @see https://github.com/ComposioHQ/composio/issues/2406
|
|
7894
|
+
* Params for `composio.sessionConfigs.list()`. The backend owns the defaults:
|
|
7895
|
+
* active configs only, 20 per page, at most 100.
|
|
7607
7896
|
*/
|
|
7897
|
+
const SessionConfigListParamsSchema = z$1.object({
|
|
7898
|
+
/** Case-insensitive substring match against the config name. */
|
|
7899
|
+
search: z$1.string().optional(),
|
|
7900
|
+
/** `true` returns only archived configs. Omitted returns active configs. */
|
|
7901
|
+
archived: z$1.boolean().optional(),
|
|
7902
|
+
/** Page size. The backend defaults to 20 and caps it at 100. */
|
|
7903
|
+
limit: z$1.number().optional(),
|
|
7904
|
+
/** `nextCursor` from a previous page. */
|
|
7905
|
+
cursor: z$1.string().optional()
|
|
7906
|
+
});
|
|
7608
7907
|
/**
|
|
7609
|
-
*
|
|
7908
|
+
* A saved Session config as listed by `composio.sessionConfigs.list()`.
|
|
7909
|
+
*/
|
|
7910
|
+
const SessionConfigSummarySchema = z$1.object({
|
|
7911
|
+
/** Stable `sc_…` identifier. */
|
|
7912
|
+
id: z$1.string(),
|
|
7913
|
+
/** Project-unique display name. */
|
|
7914
|
+
name: z$1.string(),
|
|
7915
|
+
archived: z$1.boolean(),
|
|
7916
|
+
/** ISO 8601 timestamp. */
|
|
7917
|
+
createdAt: z$1.string(),
|
|
7918
|
+
/** ISO 8601 timestamp. */
|
|
7919
|
+
updatedAt: z$1.string()
|
|
7920
|
+
});
|
|
7921
|
+
const SessionConfigListResponseSchema = z$1.object({
|
|
7922
|
+
items: z$1.array(SessionConfigSummarySchema),
|
|
7923
|
+
/** Cursor for the next page, or `null` on the last page. */
|
|
7924
|
+
nextCursor: z$1.string().nullable()
|
|
7925
|
+
});
|
|
7926
|
+
const SessionConfigTagPolicySchema = z$1.object({
|
|
7927
|
+
enable: z$1.array(ToolRouterTagsParamSchema.element).optional(),
|
|
7928
|
+
disable: z$1.array(ToolRouterTagsParamSchema.element).optional()
|
|
7929
|
+
});
|
|
7930
|
+
/**
|
|
7931
|
+
* The access policy stored in a saved Session config, in the backend's
|
|
7932
|
+
* `enable`/`disable` shape. Toolkit slug keys and tag names are kept exactly
|
|
7933
|
+
* as the backend sends them.
|
|
7934
|
+
*/
|
|
7935
|
+
const SessionConfigPolicySchema = z$1.object({
|
|
7936
|
+
toolkits: z$1.union([z$1.object({ enable: z$1.array(z$1.string()) }), z$1.object({ disable: z$1.array(z$1.string()) })]).optional(),
|
|
7937
|
+
/** Per-toolkit tool policy, keyed by toolkit slug. */
|
|
7938
|
+
tools: z$1.record(z$1.string(), z$1.union([
|
|
7939
|
+
z$1.object({ enable: z$1.array(z$1.string()) }),
|
|
7940
|
+
z$1.object({ disable: z$1.array(z$1.string()) }),
|
|
7941
|
+
z$1.object({ tags: SessionConfigTagPolicySchema })
|
|
7942
|
+
])).optional(),
|
|
7943
|
+
/** Global tag policy. */
|
|
7944
|
+
tags: SessionConfigTagPolicySchema.optional()
|
|
7945
|
+
});
|
|
7946
|
+
/**
|
|
7947
|
+
* A saved Session config with its description and access policy, as returned
|
|
7948
|
+
* by `composio.sessionConfigs.get()`.
|
|
7949
|
+
*/
|
|
7950
|
+
const SessionConfigSchema = SessionConfigSummarySchema.extend({
|
|
7951
|
+
description: z$1.string().nullable(),
|
|
7952
|
+
config: SessionConfigPolicySchema
|
|
7953
|
+
});
|
|
7954
|
+
|
|
7955
|
+
//#endregion
|
|
7956
|
+
//#region src/utils/transformers/sessionConfigs.ts
|
|
7957
|
+
const transformSessionConfigSummary = (response) => {
|
|
7958
|
+
return transform(response).with(SessionConfigSummarySchema).using((response) => ({
|
|
7959
|
+
id: response.id,
|
|
7960
|
+
name: response.name,
|
|
7961
|
+
archived: response.archived,
|
|
7962
|
+
createdAt: response.created_at,
|
|
7963
|
+
updatedAt: response.updated_at
|
|
7964
|
+
}));
|
|
7965
|
+
};
|
|
7966
|
+
const transformSessionConfigListResponse = (response) => {
|
|
7967
|
+
return transform(response).with(SessionConfigListResponseSchema).using((response) => ({
|
|
7968
|
+
items: response.items.map(transformSessionConfigSummary),
|
|
7969
|
+
nextCursor: response.next_cursor
|
|
7970
|
+
}));
|
|
7971
|
+
};
|
|
7972
|
+
const transformSessionConfig = (response) => {
|
|
7973
|
+
return transform(response).with(SessionConfigSchema).using((response) => ({
|
|
7974
|
+
id: response.id,
|
|
7975
|
+
name: response.name,
|
|
7976
|
+
description: response.description,
|
|
7977
|
+
archived: response.archived,
|
|
7978
|
+
config: response.config,
|
|
7979
|
+
createdAt: response.created_at,
|
|
7980
|
+
updatedAt: response.updated_at
|
|
7981
|
+
}));
|
|
7982
|
+
};
|
|
7983
|
+
|
|
7984
|
+
//#endregion
|
|
7985
|
+
//#region src/models/SessionConfigs.ts
|
|
7986
|
+
/**
|
|
7987
|
+
* `composio.sessionConfigs` — saved, reusable Session configs.
|
|
7610
7988
|
*
|
|
7611
|
-
*
|
|
7612
|
-
*
|
|
7613
|
-
*
|
|
7614
|
-
*
|
|
7615
|
-
* - Anything that does not resolve to a plain object (arrays, primitives,
|
|
7616
|
-
* unparseable strings, JSON that parses to a non-object) throws a typed
|
|
7617
|
-
* {@link ComposioInvalidToolArgumentsError} so callers get an actionable
|
|
7618
|
-
* message instead of a raw `SyntaxError` or a silent malformed payload.
|
|
7989
|
+
* A Session config is a named access policy (`sc_…`) built in the Composio
|
|
7990
|
+
* Dashboard under Sessions → Configs. Pass its id as
|
|
7991
|
+
* `experimental.sessionConfigId` to `composio.sessions.create()` or
|
|
7992
|
+
* `session.update()` to apply it.
|
|
7619
7993
|
*
|
|
7620
|
-
*
|
|
7621
|
-
*
|
|
7622
|
-
*
|
|
7994
|
+
* These endpoints require Session configs to be enabled for the project;
|
|
7995
|
+
* otherwise the backend returns 403.
|
|
7996
|
+
*
|
|
7997
|
+
* @example
|
|
7998
|
+
* ```typescript
|
|
7999
|
+
* const { items } = await composio.sessionConfigs.list({ search: 'support' });
|
|
8000
|
+
* const sessionConfig = await composio.sessionConfigs.get(items[0].id);
|
|
8001
|
+
* const session = await composio.sessions.create('user_123', {
|
|
8002
|
+
* experimental: { sessionConfigId: sessionConfig.id },
|
|
8003
|
+
* });
|
|
8004
|
+
* ```
|
|
7623
8005
|
*/
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
let parsed;
|
|
7630
|
-
try {
|
|
7631
|
-
parsed = JSON.parse(trimmed);
|
|
7632
|
-
} catch (cause) {
|
|
7633
|
-
throw new ComposioInvalidToolArgumentsError(`${describeTool(toolSlug)} received arguments as a string that is not valid JSON`, { cause: cause instanceof Error ? cause : void 0 });
|
|
7634
|
-
}
|
|
7635
|
-
return assertPlainObject(parsed, toolSlug);
|
|
8006
|
+
var SessionConfigs = class {
|
|
8007
|
+
client;
|
|
8008
|
+
constructor(client) {
|
|
8009
|
+
this.client = client;
|
|
8010
|
+
telemetry.instrument(this, "SessionConfigs");
|
|
7636
8011
|
}
|
|
7637
|
-
return assertPlainObject(input, toolSlug);
|
|
7638
|
-
}
|
|
7639
|
-
function assertPlainObject(value, toolSlug) {
|
|
7640
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) return value;
|
|
7641
|
-
const actual = Array.isArray(value) ? "array" : typeof value;
|
|
7642
|
-
throw new ComposioInvalidToolArgumentsError(`${describeTool(toolSlug)} expected arguments to be an object, received ${actual}`);
|
|
7643
|
-
}
|
|
7644
|
-
function describeTool(toolSlug) {
|
|
7645
|
-
return toolSlug ? `Tool '${toolSlug}'` : "Tool";
|
|
7646
|
-
}
|
|
7647
|
-
|
|
7648
|
-
//#endregion
|
|
7649
|
-
//#region src/provider/OpenAIProvider.ts
|
|
7650
|
-
var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
7651
|
-
name = "openai";
|
|
7652
8012
|
/**
|
|
7653
|
-
*
|
|
8013
|
+
* List the project's saved Session configs with cursor pagination.
|
|
7654
8014
|
*
|
|
7655
|
-
*
|
|
7656
|
-
*
|
|
8015
|
+
* Omitting `archived` returns active configs; `archived: true` returns only
|
|
8016
|
+
* archived ones. The backend defaults `limit` to 20 and caps it at 100.
|
|
8017
|
+
*
|
|
8018
|
+
* Requires Session configs to be enabled for the project.
|
|
8019
|
+
*
|
|
8020
|
+
* @param {SessionConfigListParams} [params] - `search`, `archived`, `limit` and `cursor`
|
|
8021
|
+
* @returns {Promise<SessionConfigListResponse>} Config summaries and the next cursor
|
|
8022
|
+
* @throws {ValidationError} If the params fail validation
|
|
7657
8023
|
*
|
|
7658
8024
|
* @example
|
|
7659
8025
|
* ```typescript
|
|
7660
|
-
*
|
|
7661
|
-
*
|
|
7662
|
-
*
|
|
7663
|
-
*
|
|
7664
|
-
*
|
|
7665
|
-
*
|
|
7666
|
-
* const composio = new Composio({
|
|
7667
|
-
* apiKey: 'your-api-key',
|
|
7668
|
-
* provider: new OpenAIProvider()
|
|
7669
|
-
* });
|
|
8026
|
+
* let cursor: string | undefined;
|
|
8027
|
+
* do {
|
|
8028
|
+
* const page = await composio.sessionConfigs.list({ cursor });
|
|
8029
|
+
* for (const item of page.items) console.log(item.id, item.name);
|
|
8030
|
+
* cursor = page.nextCursor ?? undefined;
|
|
8031
|
+
* } while (cursor);
|
|
7670
8032
|
* ```
|
|
7671
8033
|
*/
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
* OpenAI uses the standard format by default.
|
|
7678
|
-
*
|
|
7679
|
-
* @param data - The MCP URL response data
|
|
7680
|
-
* @returns Standard MCP server response format
|
|
7681
|
-
*/
|
|
7682
|
-
wrapMcpServerResponse(data) {
|
|
7683
|
-
return data.map((item) => ({
|
|
7684
|
-
url: new URL(item.url),
|
|
7685
|
-
name: item.name
|
|
7686
|
-
}));
|
|
8034
|
+
async list(params, requestOptions) {
|
|
8035
|
+
const parsedParams = SessionConfigListParamsSchema.safeParse(params ?? {});
|
|
8036
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse session config list params", { cause: parsedParams.error });
|
|
8037
|
+
const result = await withCancellation(() => this.client.sessionConfigs.list(parsedParams.data, requestOptions), requestOptions?.signal);
|
|
8038
|
+
return transformSessionConfigListResponse(result);
|
|
7687
8039
|
}
|
|
7688
8040
|
/**
|
|
7689
|
-
*
|
|
8041
|
+
* Retrieve one saved Session config with its description and access
|
|
8042
|
+
* policy. A missing or cross-project id surfaces as the backend's 404.
|
|
7690
8043
|
*
|
|
7691
|
-
*
|
|
7692
|
-
* expected by OpenAI's function calling API.
|
|
8044
|
+
* Requires Session configs to be enabled for the project.
|
|
7693
8045
|
*
|
|
7694
|
-
* @param
|
|
7695
|
-
* @returns The
|
|
8046
|
+
* @param {string} id - The `sc_…` id of the Session config
|
|
8047
|
+
* @returns {Promise<SessionConfig>} The config and its policy
|
|
8048
|
+
* @throws {ValidationError} If `id` is empty
|
|
7696
8049
|
*
|
|
7697
8050
|
* @example
|
|
7698
8051
|
* ```typescript
|
|
7699
|
-
*
|
|
7700
|
-
*
|
|
7701
|
-
* slug: 'SEARCH_TOOL',
|
|
7702
|
-
* description: 'Search for information',
|
|
7703
|
-
* inputParameters: {
|
|
7704
|
-
* type: 'object',
|
|
7705
|
-
* properties: {
|
|
7706
|
-
* query: { type: 'string' }
|
|
7707
|
-
* },
|
|
7708
|
-
* required: ['query']
|
|
7709
|
-
* }
|
|
7710
|
-
* };
|
|
7711
|
-
*
|
|
7712
|
-
* const openAITool = provider.wrapTool(composioTool);
|
|
8052
|
+
* const sessionConfig = await composio.sessionConfigs.get('sc_abc123');
|
|
8053
|
+
* console.log(sessionConfig.config.toolkits);
|
|
7713
8054
|
* ```
|
|
7714
8055
|
*/
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
name: tool.slug,
|
|
7720
|
-
description: tool.description,
|
|
7721
|
-
parameters: deduplicateJsonSchemaRequiredArrays(tool.inputParameters)
|
|
7722
|
-
}
|
|
7723
|
-
};
|
|
7724
|
-
};
|
|
7725
|
-
/**
|
|
7726
|
-
* Wraps multiple Composio tools in the OpenAI function calling format.
|
|
7727
|
-
*
|
|
7728
|
-
* This method transforms a list of Composio tools into the format
|
|
7729
|
-
* expected by OpenAI's function calling API.
|
|
7730
|
-
*
|
|
7731
|
-
* @param tools - Array of Composio tools to wrap
|
|
7732
|
-
* @returns Array of wrapped tools in OpenAI format
|
|
7733
|
-
*
|
|
7734
|
-
* @example
|
|
7735
|
-
* ```typescript
|
|
7736
|
-
* // Wrap multiple tools for use with OpenAI
|
|
7737
|
-
* const composioTools = [
|
|
7738
|
-
* {
|
|
7739
|
-
* slug: 'SEARCH_TOOL',
|
|
7740
|
-
* description: 'Search for information',
|
|
7741
|
-
* inputParameters: {
|
|
7742
|
-
* type: 'object',
|
|
7743
|
-
* properties: {
|
|
7744
|
-
* query: { type: 'string' }
|
|
7745
|
-
* }
|
|
7746
|
-
* }
|
|
7747
|
-
* },
|
|
7748
|
-
* {
|
|
7749
|
-
* slug: 'WEATHER_TOOL',
|
|
7750
|
-
* description: 'Get weather information',
|
|
7751
|
-
* inputParameters: {
|
|
7752
|
-
* type: 'object',
|
|
7753
|
-
* properties: {
|
|
7754
|
-
* location: { type: 'string' }
|
|
7755
|
-
* }
|
|
7756
|
-
* }
|
|
7757
|
-
* }
|
|
7758
|
-
* ];
|
|
7759
|
-
*
|
|
7760
|
-
* const openAITools = provider.wrapTools(composioTools);
|
|
7761
|
-
* ```
|
|
7762
|
-
*/
|
|
7763
|
-
wrapTools = (tools) => {
|
|
7764
|
-
return tools.map((tool) => this.wrapTool(tool));
|
|
7765
|
-
};
|
|
7766
|
-
async executeToolCall(executionTarget, tool, options, modifiers) {
|
|
7767
|
-
const arguments_ = normalizeToolArguments(tool.function.arguments, tool.function.name);
|
|
7768
|
-
const result = await this.executeToolForTarget(executionTarget, tool.function.name, arguments_, options, modifiers);
|
|
7769
|
-
return JSON.stringify(result);
|
|
8056
|
+
async get(id, requestOptions) {
|
|
8057
|
+
if (id.trim() === "") throw new ValidationError("Session config id must be a non-empty string");
|
|
8058
|
+
const result = await withCancellation(() => this.client.sessionConfigs.retrieve(id, requestOptions), requestOptions?.signal);
|
|
8059
|
+
return transformSessionConfig(result);
|
|
7770
8060
|
}
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
8061
|
+
};
|
|
8062
|
+
|
|
8063
|
+
//#endregion
|
|
8064
|
+
//#region src/types/keyring.types.ts
|
|
8065
|
+
/**
|
|
8066
|
+
* A public JWK a secret can be sealed to. Fields keep their JWK names so a
|
|
8067
|
+
* key can be handed straight to WebCrypto or a JOSE library.
|
|
8068
|
+
*/
|
|
8069
|
+
const KeyringTransferKeySchema = z$1.object({
|
|
8070
|
+
/** Key type. Always `RSA`. */
|
|
8071
|
+
kty: z$1.string(),
|
|
8072
|
+
/** RSA modulus, base64url-encoded. */
|
|
8073
|
+
n: z$1.string(),
|
|
8074
|
+
/** RSA public exponent, base64url-encoded. */
|
|
8075
|
+
e: z$1.string(),
|
|
8076
|
+
/** Key-management algorithm for the JWE (`RSA-OAEP-256`). Pair it with `A256GCM` content encryption. */
|
|
8077
|
+
alg: z$1.string(),
|
|
8078
|
+
/** Key use. Always `enc`. */
|
|
8079
|
+
use: z$1.string(),
|
|
8080
|
+
/** Key identifier. Put it in the JWE protected header. */
|
|
8081
|
+
kid: z$1.string()
|
|
8082
|
+
});
|
|
8083
|
+
/**
|
|
8084
|
+
* Response of `composio.keyring.listTransferKeys()`.
|
|
8085
|
+
*/
|
|
8086
|
+
const KeyringTransferKeysResponseSchema = z$1.object({
|
|
8087
|
+
/** The `kid` of the key to seal new secrets to. */
|
|
8088
|
+
activeKid: z$1.string(),
|
|
8089
|
+
/** Every currently accepted transfer key, newest first. */
|
|
8090
|
+
keys: z$1.array(KeyringTransferKeySchema)
|
|
8091
|
+
});
|
|
8092
|
+
|
|
8093
|
+
//#endregion
|
|
8094
|
+
//#region src/utils/transformers/keyring.ts
|
|
8095
|
+
const transformKeyringTransferKeysResponse = (response) => {
|
|
8096
|
+
return transform(response).with(KeyringTransferKeysResponseSchema).using((response) => ({
|
|
8097
|
+
activeKid: response.active_kid,
|
|
8098
|
+
keys: response.keys.map((key) => ({
|
|
8099
|
+
kty: key.kty,
|
|
8100
|
+
n: key.n,
|
|
8101
|
+
e: key.e,
|
|
8102
|
+
alg: key.alg,
|
|
8103
|
+
use: key.use,
|
|
8104
|
+
kid: key.kid
|
|
8105
|
+
}))
|
|
8106
|
+
}));
|
|
8107
|
+
};
|
|
8108
|
+
|
|
8109
|
+
//#endregion
|
|
8110
|
+
//#region src/models/Keyring.ts
|
|
8111
|
+
/**
|
|
8112
|
+
* `composio.keyring` — the organization's customer-managed keyring.
|
|
8113
|
+
*
|
|
8114
|
+
* @example
|
|
8115
|
+
* ```typescript
|
|
8116
|
+
* const { activeKid, keys } = await composio.keyring.listTransferKeys();
|
|
8117
|
+
* const sealingKey = keys.find(key => key.kid === activeKid);
|
|
8118
|
+
* ```
|
|
8119
|
+
*/
|
|
8120
|
+
var Keyring = class {
|
|
8121
|
+
client;
|
|
8122
|
+
constructor(client) {
|
|
8123
|
+
this.client = client;
|
|
8124
|
+
telemetry.instrument(this, "Keyring");
|
|
7785
8125
|
}
|
|
7786
8126
|
/**
|
|
7787
|
-
*
|
|
7788
|
-
*
|
|
7789
|
-
* This method processes tool calls from an OpenAI Assistant run,
|
|
7790
|
-
* executes each tool call, and returns the tool outputs for submission.
|
|
8127
|
+
* Lists the public transfer keys of the organization's active customer
|
|
8128
|
+
* keyring, the keys a secret is sealed to before it is sent to Composio.
|
|
7791
8129
|
*
|
|
7792
|
-
*
|
|
8130
|
+
* Always seal new secrets to the key whose `kid` is `activeKid`: a JWE with
|
|
8131
|
+
* `RSA-OAEP-256` key management, `A256GCM` content encryption, and the
|
|
8132
|
+
* `kid` in the protected header. Older keys stay listed so values sealed to
|
|
8133
|
+
* them remain openable.
|
|
7793
8134
|
*
|
|
7794
|
-
*
|
|
7795
|
-
*
|
|
7796
|
-
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
7797
|
-
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
7798
|
-
* @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} Array of tool outputs for submission
|
|
8135
|
+
* The organization behind the API key must have an ACTIVE customer keyring
|
|
8136
|
+
* instance; otherwise the API answers 404.
|
|
7799
8137
|
*
|
|
8138
|
+
* @returns {Promise<KeyringTransferKeysResponse>} The active key ID and every accepted public JWK, newest first
|
|
7800
8139
|
*
|
|
7801
8140
|
* @example
|
|
7802
8141
|
* ```typescript
|
|
7803
|
-
*
|
|
7804
|
-
* const run = {
|
|
7805
|
-
* id: 'run_abc123',
|
|
7806
|
-
* required_action: {
|
|
7807
|
-
* submit_tool_outputs: {
|
|
7808
|
-
* tool_calls: [
|
|
7809
|
-
* {
|
|
7810
|
-
* id: 'call_xyz789',
|
|
7811
|
-
* type: 'function',
|
|
7812
|
-
* function: {
|
|
7813
|
-
* name: 'SEARCH_TOOL',
|
|
7814
|
-
* arguments: '{"query":"composio documentation"}'
|
|
7815
|
-
* }
|
|
7816
|
-
* }
|
|
7817
|
-
* ]
|
|
7818
|
-
* }
|
|
7819
|
-
* }
|
|
7820
|
-
* };
|
|
7821
|
-
*
|
|
7822
|
-
* const toolOutputs = await provider.handleAssistantMessage(
|
|
7823
|
-
* 'user123',
|
|
7824
|
-
* run,
|
|
7825
|
-
* { connectedAccountId: 'conn_xyz456' }
|
|
7826
|
-
* );
|
|
8142
|
+
* import { CompactEncrypt, importJWK } from 'jose';
|
|
7827
8143
|
*
|
|
7828
|
-
*
|
|
7829
|
-
*
|
|
7830
|
-
*
|
|
7831
|
-
*
|
|
7832
|
-
*
|
|
7833
|
-
* );
|
|
8144
|
+
* const { activeKid, keys } = await composio.keyring.listTransferKeys();
|
|
8145
|
+
* const jwk = keys.find(key => key.kid === activeKid)!;
|
|
8146
|
+
* const sealed = await new CompactEncrypt(new TextEncoder().encode(secret))
|
|
8147
|
+
* .setProtectedHeader({ alg: 'RSA-OAEP-256', enc: 'A256GCM', kid: activeKid })
|
|
8148
|
+
* .encrypt(await importJWK(jwk, 'RSA-OAEP-256'));
|
|
7834
8149
|
* ```
|
|
7835
8150
|
*/
|
|
7836
|
-
async
|
|
7837
|
-
const
|
|
7838
|
-
return
|
|
7839
|
-
logger.debug(`Executing tool call: ${tool_call.id}`);
|
|
7840
|
-
const tool_response = await this.executeToolCall(userId, tool_call, options, modifiers);
|
|
7841
|
-
logger.debug(`Tool call ${tool_call.id} executed with response: ${tool_response}`);
|
|
7842
|
-
return {
|
|
7843
|
-
tool_call_id: tool_call.id,
|
|
7844
|
-
output: JSON.stringify(tool_response)
|
|
7845
|
-
};
|
|
7846
|
-
}));
|
|
8151
|
+
async listTransferKeys(requestOptions) {
|
|
8152
|
+
const result = await withCancellation(() => this.client.keyring.listTransferKeys(requestOptions), requestOptions?.signal);
|
|
8153
|
+
return transformKeyringTransferKeysResponse(result);
|
|
7847
8154
|
}
|
|
8155
|
+
};
|
|
8156
|
+
|
|
8157
|
+
//#endregion
|
|
8158
|
+
//#region src/utils/version.ts
|
|
8159
|
+
const VERSION_CHECK_TIMEOUT_MS = 2e3;
|
|
8160
|
+
/**
|
|
8161
|
+
* Checks for the latest version of the Composio SDK from NPM.
|
|
8162
|
+
* If a newer version is available, it logs a warning to the console.
|
|
8163
|
+
*
|
|
8164
|
+
* Best-effort: never throws. The npm registry request is aborted after
|
|
8165
|
+
* {@link VERSION_CHECK_TIMEOUT_MS} milliseconds.
|
|
8166
|
+
*/
|
|
8167
|
+
async function checkForLatestVersionFromNPM(currentVersion) {
|
|
8168
|
+
try {
|
|
8169
|
+
const packageName = "@composio/core";
|
|
8170
|
+
const currentVersionFromPackageJson = currentVersion;
|
|
8171
|
+
if (!semver.valid(currentVersionFromPackageJson)) return;
|
|
8172
|
+
const prerelease = semver.prerelease(currentVersionFromPackageJson);
|
|
8173
|
+
if (prerelease && (String(prerelease[0]).includes("alpha") || String(prerelease[0]).includes("beta"))) return;
|
|
8174
|
+
const controller = new AbortController();
|
|
8175
|
+
const timer = setTimeout(() => controller.abort(), VERSION_CHECK_TIMEOUT_MS);
|
|
8176
|
+
let data;
|
|
8177
|
+
try {
|
|
8178
|
+
data = await (await fetch(`https://registry.npmjs.org/${packageName}/latest`, { signal: controller.signal })).json();
|
|
8179
|
+
} finally {
|
|
8180
|
+
clearTimeout(timer);
|
|
8181
|
+
}
|
|
8182
|
+
const latestVersion = data.version;
|
|
8183
|
+
if (semver.gt(latestVersion, currentVersionFromPackageJson) && !IS_DEVELOPMENT_OR_CI) logger.info(`🚀 Upgrade available! Your ${packageName} version (${currentVersionFromPackageJson}) is behind. Latest version: ${latestVersion}.`);
|
|
8184
|
+
} catch (_error) {}
|
|
8185
|
+
}
|
|
8186
|
+
|
|
8187
|
+
//#endregion
|
|
8188
|
+
//#region src/provider/BaseProvider.ts
|
|
8189
|
+
/**
|
|
8190
|
+
* @internal
|
|
8191
|
+
* Base class for all providers.
|
|
8192
|
+
* This class is not meant to be used directly, but rather to be extended by different provider implementations.
|
|
8193
|
+
*/
|
|
8194
|
+
var BaseProvider = class {
|
|
7848
8195
|
/**
|
|
7849
|
-
*
|
|
7850
|
-
*
|
|
7851
|
-
* This
|
|
7852
|
-
* that require action, and yields each event from the stream. It's designed
|
|
7853
|
-
* for streaming Assistant responses while handling tool calls in real-time.
|
|
7854
|
-
*
|
|
7855
|
-
* @deprecated Assistant API is deprecated, please use responses or chat completions instead. It will be removed in the next major version.
|
|
7856
|
-
*
|
|
7857
|
-
* @param {string} userId - The user ID for authentication and tracking
|
|
7858
|
-
* @param {OpenAI} client - The OpenAI client instance
|
|
7859
|
-
* @param {Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>} runStream - The Assistant run stream
|
|
7860
|
-
* @param {OpenAI.Beta.Threads.Thread} thread - The thread object
|
|
7861
|
-
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
7862
|
-
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
7863
|
-
* @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} Generator yielding stream events
|
|
7864
|
-
*
|
|
7865
|
-
*
|
|
7866
|
-
*
|
|
7867
|
-
* @example
|
|
7868
|
-
* ```typescript
|
|
7869
|
-
* // Process an OpenAI Assistant stream with tool calls
|
|
7870
|
-
* const thread = await openai.beta.threads.create();
|
|
7871
|
-
* const runStream = openai.beta.threads.runs.stream(thread.id, {
|
|
7872
|
-
* assistant_id: 'asst_abc123',
|
|
7873
|
-
* tools: provider.wrapTools(composioTools)
|
|
7874
|
-
* });
|
|
7875
|
-
*
|
|
7876
|
-
* // Process the stream and handle tool calls
|
|
7877
|
-
* const streamProcessor = provider.waitAndHandleAssistantStreamToolCalls(
|
|
7878
|
-
* 'user123',
|
|
7879
|
-
* openai,
|
|
7880
|
-
* runStream,
|
|
7881
|
-
* thread,
|
|
7882
|
-
* { connectedAccountId: 'conn_xyz456' }
|
|
7883
|
-
* );
|
|
7884
|
-
*
|
|
7885
|
-
* // Consume the stream events
|
|
7886
|
-
* for await (const event of streamProcessor) {
|
|
7887
|
-
* if (event.event === 'thread.message.delta') {
|
|
7888
|
-
* console.log(event.data.delta.content);
|
|
7889
|
-
* }
|
|
7890
|
-
* }
|
|
7891
|
-
* ```
|
|
8196
|
+
* @internal
|
|
8197
|
+
* The function to execute a tool.
|
|
8198
|
+
* This is set automatically injected by the core SDK.
|
|
7892
8199
|
*/
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
if (!runId) continue;
|
|
7902
|
-
if (event.event === "thread.run.requires_action") {
|
|
7903
|
-
const toolOutputs = await this.handleAssistantMessage(userId, event.data, options, modifiers);
|
|
7904
|
-
await client.beta.threads.runs.submitToolOutputs(runId, {
|
|
7905
|
-
thread_id: thread.id,
|
|
7906
|
-
tool_outputs: toolOutputs
|
|
7907
|
-
});
|
|
7908
|
-
}
|
|
7909
|
-
if ([
|
|
7910
|
-
"thread.run.completed",
|
|
7911
|
-
"thread.run.failed",
|
|
7912
|
-
"thread.run.cancelled",
|
|
7913
|
-
"thread.run.expired"
|
|
7914
|
-
].includes(event.event)) break;
|
|
7915
|
-
}
|
|
7916
|
-
if (!runId) throw new Error("No run ID found");
|
|
7917
|
-
let finalRun = await client.beta.threads.runs.retrieve(runId, { thread_id: thread.id });
|
|
7918
|
-
while ([
|
|
7919
|
-
"queued",
|
|
7920
|
-
"in_progress",
|
|
7921
|
-
"requires_action"
|
|
7922
|
-
].includes(finalRun.status)) if (finalRun.status === "requires_action") {
|
|
7923
|
-
const toolOutputs = await this.handleAssistantMessage(userId, finalRun, options, modifiers);
|
|
7924
|
-
finalRun = await client.beta.threads.runs.submitToolOutputs(runId, {
|
|
7925
|
-
thread_id: thread.id,
|
|
7926
|
-
tool_outputs: toolOutputs
|
|
7927
|
-
});
|
|
7928
|
-
} else {
|
|
7929
|
-
finalRun = await client.beta.threads.runs.retrieve(runId, { thread_id: thread.id });
|
|
7930
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
7931
|
-
}
|
|
8200
|
+
_globalExecuteToolFn;
|
|
8201
|
+
/**
|
|
8202
|
+
* @internal
|
|
8203
|
+
* Set the function to execute a tool.
|
|
8204
|
+
* This is set automatically and injected by the core SDK.
|
|
8205
|
+
*/
|
|
8206
|
+
_setExecuteToolFn(executeToolFn) {
|
|
8207
|
+
this._globalExecuteToolFn = executeToolFn;
|
|
7932
8208
|
}
|
|
7933
8209
|
/**
|
|
7934
|
-
*
|
|
7935
|
-
*
|
|
7936
|
-
* This
|
|
7937
|
-
*
|
|
7938
|
-
*
|
|
7939
|
-
*
|
|
7940
|
-
* @
|
|
7941
|
-
*
|
|
7942
|
-
* @param {string} userId - The user ID for authentication and tracking
|
|
7943
|
-
* @param {OpenAI} client - The OpenAI client instance
|
|
7944
|
-
* @param {OpenAI.Beta.Threads.Run} run - The initial run object
|
|
7945
|
-
* @param {OpenAI.Beta.Threads.Thread} thread - The thread object
|
|
7946
|
-
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
7947
|
-
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
7948
|
-
* @returns {Promise<OpenAI.Beta.Threads.Run>} The final run object after completion
|
|
7949
|
-
*
|
|
7950
|
-
* @example
|
|
7951
|
-
* ```typescript
|
|
7952
|
-
* // Process an OpenAI Assistant run with tool calls
|
|
7953
|
-
* const thread = await openai.beta.threads.create();
|
|
7954
|
-
* await openai.beta.threads.messages.create(thread.id, {
|
|
7955
|
-
* role: 'user',
|
|
7956
|
-
* content: 'Find information about Composio'
|
|
7957
|
-
* });
|
|
7958
|
-
*
|
|
7959
|
-
* let run = await openai.beta.threads.runs.create(thread.id, {
|
|
7960
|
-
* assistant_id: 'asst_abc123',
|
|
7961
|
-
* tools: provider.wrapTools(composioTools)
|
|
7962
|
-
* });
|
|
7963
|
-
*
|
|
7964
|
-
* // Wait for the run to complete, handling any tool calls
|
|
7965
|
-
* run = await provider.waitAndHandleAssistantToolCalls(
|
|
7966
|
-
* 'user123',
|
|
7967
|
-
* openai,
|
|
7968
|
-
* run,
|
|
7969
|
-
* thread,
|
|
7970
|
-
* { connectedAccountId: 'conn_xyz456' }
|
|
7971
|
-
* );
|
|
7972
|
-
*
|
|
7973
|
-
* // Get the final messages after run completion
|
|
7974
|
-
* const messages = await openai.beta.threads.messages.list(thread.id);
|
|
7975
|
-
* console.log(messages.data[0].content);
|
|
7976
|
-
* ```
|
|
8210
|
+
* @public
|
|
8211
|
+
* Global function to execute a tool.
|
|
8212
|
+
* This function is used by providers to implement helper functions to execute tools.
|
|
8213
|
+
* This is a 1:1 mapping of the `execute` method in the `Tools` class.
|
|
8214
|
+
* @param {string} toolSlug - The slug of the tool to execute.
|
|
8215
|
+
* @param {ToolExecuteParams} body - The body of the tool execution.
|
|
8216
|
+
* @param {ExecuteToolModifiers} modifers - The modifiers of the tool execution.
|
|
8217
|
+
* @returns {Promise<string>} The result of the tool execution.
|
|
7977
8218
|
*/
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
8219
|
+
executeTool(toolSlug, body, modifers) {
|
|
8220
|
+
if (!this._globalExecuteToolFn) throw new ComposioGlobalExecuteToolFnNotSetError("executeToolFn is not set");
|
|
8221
|
+
return this._globalExecuteToolFn(toolSlug, body, modifers);
|
|
8222
|
+
}
|
|
8223
|
+
/** Reject direct-only configuration when execution is bound to a session. */
|
|
8224
|
+
assertToolCallExecutionOptions(target, options, modifiers) {
|
|
8225
|
+
if (typeof target !== "string" && (options !== void 0 || modifiers !== void 0)) throw new TypeError("Direct execution options and modifiers cannot be used with a Tool Router session");
|
|
8226
|
+
}
|
|
8227
|
+
/**
|
|
8228
|
+
* Execute normalized provider arguments against either the direct tools API or
|
|
8229
|
+
* the Tool Router session that produced the model-visible tools.
|
|
8230
|
+
*/
|
|
8231
|
+
async executeToolForTarget(target, toolSlug, arguments_, options, modifiers) {
|
|
8232
|
+
this.assertToolCallExecutionOptions(target, options, modifiers);
|
|
8233
|
+
if (typeof target === "string") return this.executeTool(toolSlug, {
|
|
8234
|
+
arguments: arguments_,
|
|
8235
|
+
connectedAccountId: options?.connectedAccountId,
|
|
8236
|
+
customAuthParams: options?.customAuthParams,
|
|
8237
|
+
customConnectionData: options?.customConnectionData,
|
|
8238
|
+
userId: target
|
|
8239
|
+
}, modifiers);
|
|
8240
|
+
const result = await target.execute(toolSlug, arguments_);
|
|
8241
|
+
return {
|
|
8242
|
+
...result,
|
|
8243
|
+
successful: result.error === null
|
|
8244
|
+
};
|
|
7995
8245
|
}
|
|
7996
8246
|
};
|
|
7997
|
-
|
|
7998
|
-
//#endregion
|
|
7999
|
-
//#region package.json
|
|
8000
|
-
var version = "0.20.0";
|
|
8001
|
-
|
|
8002
|
-
//#endregion
|
|
8003
|
-
//#region src/utils/session.ts
|
|
8004
8247
|
/**
|
|
8005
|
-
*
|
|
8006
|
-
*
|
|
8248
|
+
* @public
|
|
8249
|
+
* Base class for all non-agentic providers.
|
|
8250
|
+
* This class is not meant to be used directly, but rather to be extended by concrete provider implementations.
|
|
8007
8251
|
*/
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
}
|
|
8019
|
-
if ("WorkerGlobalScope" in global && typeof global.WorkerGlobalScope !== "undefined" && "importScripts" in global && typeof global.importScripts === "function") return "WEB_WORKER";
|
|
8020
|
-
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") return "REACT_NATIVE";
|
|
8021
|
-
if (typeof window !== "undefined" && typeof document !== "undefined") return "BROWSER";
|
|
8022
|
-
return "UNKNOWN";
|
|
8023
|
-
}
|
|
8024
|
-
const RUNTIME_ENV = detectRuntime();
|
|
8025
|
-
function getSessionHeaders(provider) {
|
|
8026
|
-
return {
|
|
8027
|
-
"x-framework": provider?.name || "unknown",
|
|
8028
|
-
"x-source": "TYPESCRIPT_SDK",
|
|
8029
|
-
"x-runtime": RUNTIME_ENV,
|
|
8030
|
-
"x-sdk-version": version
|
|
8031
|
-
};
|
|
8032
|
-
}
|
|
8033
|
-
const getDefaultHeaders = (headers, provider) => {
|
|
8034
|
-
const sessionHeaders = getSessionHeaders(provider);
|
|
8035
|
-
return {
|
|
8036
|
-
...headers || {},
|
|
8037
|
-
...sessionHeaders
|
|
8038
|
-
};
|
|
8252
|
+
var BaseNonAgenticProvider = class extends BaseProvider {
|
|
8253
|
+
_isAgentic = false;
|
|
8254
|
+
};
|
|
8255
|
+
/**
|
|
8256
|
+
* @public
|
|
8257
|
+
* Base class for all agentic providers.
|
|
8258
|
+
* This class is not meant to be used directly, but rather to be extended by concrete provider implementations.
|
|
8259
|
+
*/
|
|
8260
|
+
var BaseAgenticProvider = class extends BaseProvider {
|
|
8261
|
+
_isAgentic = true;
|
|
8039
8262
|
};
|
|
8040
8263
|
|
|
8041
8264
|
//#endregion
|
|
8042
|
-
//#region src/
|
|
8043
|
-
const SessionPreset = { DIRECT_TOOLS: "direct_tools" };
|
|
8044
|
-
const MCPServerTypeSchema = z.enum(["http", "sse"]);
|
|
8265
|
+
//#region src/utils/toolArguments.ts
|
|
8045
8266
|
/**
|
|
8046
|
-
*
|
|
8267
|
+
* Tool-argument normalization.
|
|
8047
8268
|
*
|
|
8048
|
-
*
|
|
8049
|
-
*
|
|
8050
|
-
*
|
|
8051
|
-
*
|
|
8052
|
-
*
|
|
8053
|
-
* | xlarge | 8 | 8 GB |
|
|
8269
|
+
* Models (and MCP transports) occasionally emit tool-call arguments as a JSON
|
|
8270
|
+
* *string* instead of an object. `COMPOSIO_MULTI_EXECUTE_TOOL` and Vercel AI
|
|
8271
|
+
* SDK streaming are common triggers. Forwarding that raw string to execution
|
|
8272
|
+
* surfaces opaque downstream errors such as
|
|
8273
|
+
* `tool_use.input: Input should be a valid dictionary`.
|
|
8054
8274
|
*
|
|
8055
|
-
*
|
|
8275
|
+
* `normalizeToolArguments` is the single coercion every provider routes through
|
|
8276
|
+
* so the behaviour is identical everywhere instead of being re-implemented
|
|
8277
|
+
* (inconsistently) per provider.
|
|
8278
|
+
*
|
|
8279
|
+
* @see https://github.com/ComposioHQ/composio/issues/2406
|
|
8056
8280
|
*/
|
|
8057
|
-
const SandboxSizeSchema = z.enum([
|
|
8058
|
-
"standard",
|
|
8059
|
-
"medium",
|
|
8060
|
-
"large",
|
|
8061
|
-
"xlarge"
|
|
8062
|
-
]);
|
|
8063
|
-
const ToolRouterSandboxConfigSchema = z.object({
|
|
8064
|
-
enable: z.boolean().default(true).describe("Whether to enable the sandbox entirely. Defaults to true. When set to false, no code execution tools (COMPOSIO_REMOTE_WORKBENCH, COMPOSIO_REMOTE_BASH_TOOL) are available in the session."),
|
|
8065
|
-
enableProxyExecution: z.boolean().optional().describe("Whether to enable proxy execution in the session sandbox"),
|
|
8066
|
-
autoOffloadThreshold: z.number().optional().describe("The auto offload threshold in characters for tool execution to move into the sandbox"),
|
|
8067
|
-
sandboxSize: SandboxSizeSchema.optional().describe("Sandbox compute tier. 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 sandbox on next access; the in-memory FS is lost, but /mnt/files/ persists.")
|
|
8068
|
-
});
|
|
8069
|
-
const ToolRouterConfigManageConnectionsSchema = z.object({
|
|
8070
|
-
enable: z.boolean().default(true).optional().describe("Whether to use tools to manage connections in the tool router session. Defaults to true, if set to false, you need to manage connections manually"),
|
|
8071
|
-
callbackUrl: z.string().optional().describe("The callback uri to use in the tool router session"),
|
|
8072
|
-
waitForConnections: z.boolean().optional().describe("Whether to wait for users to finish authenticating connections before proceeding to the next step. Defaults to false, if set to true, a wait for connections tool call will happen and finish when the connections are ready")
|
|
8073
|
-
}).strict();
|
|
8074
|
-
const ToolRouterToolkitsParamSchema = z.array(z.string()).describe("List of toolkits to enable in the tool router session");
|
|
8075
|
-
const ToolRouterToolkitsDisabledConfigSchema = z.object({ disable: ToolRouterToolkitsParamSchema.describe("List of toolkits to disable in the tool router session") }).strict();
|
|
8076
|
-
const ToolRouterToolkitsEnabledConfigSchema = z.object({ enable: ToolRouterToolkitsParamSchema.describe("List of toolkits to enable in the tool router session") }).strict();
|
|
8077
|
-
const ToolRouterManageConnectionsConfigSchema = z.object({
|
|
8078
|
-
enable: z.boolean().optional().describe("Whether to use tools to manage connections in the tool router session. Defaults to true, if set to false, you need to manage connections manually").default(true),
|
|
8079
|
-
callbackUrl: z.string().optional().describe("The callback url to use in the tool router session")
|
|
8080
|
-
});
|
|
8081
|
-
const ToolRouterTagsParamSchema = z.array(z.enum([
|
|
8082
|
-
"readOnlyHint",
|
|
8083
|
-
"destructiveHint",
|
|
8084
|
-
"idempotentHint",
|
|
8085
|
-
"openWorldHint"
|
|
8086
|
-
])).describe("The tags to filter the tools by");
|
|
8087
|
-
const ToolRouterTagsEnableDisableSchema = z.object({
|
|
8088
|
-
enable: ToolRouterTagsParamSchema.optional().describe("The tags to enable in the tool router session"),
|
|
8089
|
-
disable: ToolRouterTagsParamSchema.optional().describe("The tags to disable in the tool router session")
|
|
8090
|
-
}).strict();
|
|
8091
|
-
const ToolRouterConfigTagsSchema = z.union([ToolRouterTagsParamSchema, ToolRouterTagsEnableDisableSchema]).describe("The tags to use in the tool router session");
|
|
8092
8281
|
/**
|
|
8093
|
-
*
|
|
8094
|
-
* @example
|
|
8095
|
-
* ```typescript
|
|
8096
|
-
* {
|
|
8097
|
-
* gmail: {
|
|
8098
|
-
* enable: ['gmail_search', 'gmail_send']
|
|
8099
|
-
* },
|
|
8100
|
-
* slack: {
|
|
8101
|
-
* disable: ['slack_delete_message']
|
|
8102
|
-
* }
|
|
8103
|
-
* }
|
|
8104
|
-
* ```
|
|
8282
|
+
* Coerce model-supplied tool arguments into a plain object.
|
|
8105
8283
|
*
|
|
8106
|
-
*
|
|
8107
|
-
*
|
|
8108
|
-
*
|
|
8109
|
-
*
|
|
8110
|
-
*
|
|
8111
|
-
*
|
|
8112
|
-
*
|
|
8284
|
+
* Rules:
|
|
8285
|
+
* - `null` / `undefined` → `{}` (some models send no arguments for no-arg tools).
|
|
8286
|
+
* - A plain object is returned unchanged.
|
|
8287
|
+
* - A string is JSON-parsed; an empty / whitespace-only string becomes `{}`.
|
|
8288
|
+
* - Anything that does not resolve to a plain object (arrays, primitives,
|
|
8289
|
+
* unparseable strings, JSON that parses to a non-object) throws a typed
|
|
8290
|
+
* {@link ComposioInvalidToolArgumentsError} so callers get an actionable
|
|
8291
|
+
* message instead of a raw `SyntaxError` or a silent malformed payload.
|
|
8292
|
+
*
|
|
8293
|
+
* @param input - Raw arguments as received from the model / framework.
|
|
8294
|
+
* @param toolSlug - Optional tool slug, used to enrich the error message.
|
|
8295
|
+
* @returns The normalized arguments as a `Record<string, unknown>`.
|
|
8113
8296
|
*/
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
path: keys
|
|
8127
|
-
});
|
|
8297
|
+
function normalizeToolArguments(input, toolSlug) {
|
|
8298
|
+
if (input === null || input === void 0) return {};
|
|
8299
|
+
if (typeof input === "string") {
|
|
8300
|
+
const trimmed = input.trim();
|
|
8301
|
+
if (trimmed === "") return {};
|
|
8302
|
+
let parsed;
|
|
8303
|
+
try {
|
|
8304
|
+
parsed = JSON.parse(trimmed);
|
|
8305
|
+
} catch (cause) {
|
|
8306
|
+
throw new ComposioInvalidToolArgumentsError(`${describeTool(toolSlug)} received arguments as a string that is not valid JSON`, { cause: cause instanceof Error ? cause : void 0 });
|
|
8307
|
+
}
|
|
8308
|
+
return assertPlainObject(parsed, toolSlug);
|
|
8128
8309
|
}
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
})
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
});
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8310
|
+
return assertPlainObject(input, toolSlug);
|
|
8311
|
+
}
|
|
8312
|
+
function assertPlainObject(value, toolSlug) {
|
|
8313
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) return value;
|
|
8314
|
+
const actual = Array.isArray(value) ? "array" : typeof value;
|
|
8315
|
+
throw new ComposioInvalidToolArgumentsError(`${describeTool(toolSlug)} expected arguments to be an object, received ${actual}`);
|
|
8316
|
+
}
|
|
8317
|
+
function describeTool(toolSlug) {
|
|
8318
|
+
return toolSlug ? `Tool '${toolSlug}'` : "Tool";
|
|
8319
|
+
}
|
|
8320
|
+
|
|
8321
|
+
//#endregion
|
|
8322
|
+
//#region src/provider/OpenAIProvider.ts
|
|
8323
|
+
var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
8324
|
+
name = "openai";
|
|
8325
|
+
/**
|
|
8326
|
+
* Creates a new instance of the OpenAIProvider.
|
|
8327
|
+
*
|
|
8328
|
+
* This is the default provider for the Composio SDK and is automatically
|
|
8329
|
+
* available without additional installation.
|
|
8330
|
+
*
|
|
8331
|
+
* @example
|
|
8332
|
+
* ```typescript
|
|
8333
|
+
* // The OpenAIProvider is used by default when initializing Composio
|
|
8334
|
+
* const composio = new Composio({
|
|
8335
|
+
* apiKey: 'your-api-key'
|
|
8336
|
+
* });
|
|
8337
|
+
*
|
|
8338
|
+
* // You can also explicitly specify it
|
|
8339
|
+
* const composio = new Composio({
|
|
8340
|
+
* apiKey: 'your-api-key',
|
|
8341
|
+
* provider: new OpenAIProvider()
|
|
8342
|
+
* });
|
|
8343
|
+
* ```
|
|
8344
|
+
*/
|
|
8345
|
+
constructor() {
|
|
8346
|
+
super();
|
|
8347
|
+
}
|
|
8348
|
+
/**
|
|
8349
|
+
* Transform MCP URL response into OpenAI-specific format.
|
|
8350
|
+
* OpenAI uses the standard format by default.
|
|
8351
|
+
*
|
|
8352
|
+
* @param data - The MCP URL response data
|
|
8353
|
+
* @returns Standard MCP server response format
|
|
8354
|
+
*/
|
|
8355
|
+
wrapMcpServerResponse(data) {
|
|
8356
|
+
return data.map((item) => ({
|
|
8357
|
+
url: new URL(item.url),
|
|
8358
|
+
name: item.name
|
|
8359
|
+
}));
|
|
8360
|
+
}
|
|
8361
|
+
/**
|
|
8362
|
+
* Wraps a Composio tool in the OpenAI function calling format.
|
|
8363
|
+
*
|
|
8364
|
+
* This method transforms a Composio tool definition into the format
|
|
8365
|
+
* expected by OpenAI's function calling API.
|
|
8366
|
+
*
|
|
8367
|
+
* @param tool - The Composio tool to wrap
|
|
8368
|
+
* @returns The wrapped tool in OpenAI format
|
|
8369
|
+
*
|
|
8370
|
+
* @example
|
|
8371
|
+
* ```typescript
|
|
8372
|
+
* // Wrap a single tool for use with OpenAI
|
|
8373
|
+
* const composioTool = {
|
|
8374
|
+
* slug: 'SEARCH_TOOL',
|
|
8375
|
+
* description: 'Search for information',
|
|
8376
|
+
* inputParameters: {
|
|
8377
|
+
* type: 'object',
|
|
8378
|
+
* properties: {
|
|
8379
|
+
* query: { type: 'string' }
|
|
8380
|
+
* },
|
|
8381
|
+
* required: ['query']
|
|
8382
|
+
* }
|
|
8383
|
+
* };
|
|
8384
|
+
*
|
|
8385
|
+
* const openAITool = provider.wrapTool(composioTool);
|
|
8386
|
+
* ```
|
|
8387
|
+
*/
|
|
8388
|
+
wrapTool = (tool) => {
|
|
8389
|
+
return {
|
|
8390
|
+
type: "function",
|
|
8391
|
+
function: {
|
|
8392
|
+
name: tool.slug,
|
|
8393
|
+
description: tool.description,
|
|
8394
|
+
parameters: deduplicateJsonSchemaRequiredArrays(tool.inputParameters)
|
|
8395
|
+
}
|
|
8396
|
+
};
|
|
8173
8397
|
};
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
}
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
}
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
}
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
}
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
*
|
|
8301
|
-
*
|
|
8302
|
-
*
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
}
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
*
|
|
8323
|
-
*
|
|
8324
|
-
*
|
|
8325
|
-
|
|
8326
|
-
const
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
*
|
|
8338
|
-
*
|
|
8339
|
-
*
|
|
8340
|
-
*
|
|
8341
|
-
*/
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8398
|
+
/**
|
|
8399
|
+
* Wraps multiple Composio tools in the OpenAI function calling format.
|
|
8400
|
+
*
|
|
8401
|
+
* This method transforms a list of Composio tools into the format
|
|
8402
|
+
* expected by OpenAI's function calling API.
|
|
8403
|
+
*
|
|
8404
|
+
* @param tools - Array of Composio tools to wrap
|
|
8405
|
+
* @returns Array of wrapped tools in OpenAI format
|
|
8406
|
+
*
|
|
8407
|
+
* @example
|
|
8408
|
+
* ```typescript
|
|
8409
|
+
* // Wrap multiple tools for use with OpenAI
|
|
8410
|
+
* const composioTools = [
|
|
8411
|
+
* {
|
|
8412
|
+
* slug: 'SEARCH_TOOL',
|
|
8413
|
+
* description: 'Search for information',
|
|
8414
|
+
* inputParameters: {
|
|
8415
|
+
* type: 'object',
|
|
8416
|
+
* properties: {
|
|
8417
|
+
* query: { type: 'string' }
|
|
8418
|
+
* }
|
|
8419
|
+
* }
|
|
8420
|
+
* },
|
|
8421
|
+
* {
|
|
8422
|
+
* slug: 'WEATHER_TOOL',
|
|
8423
|
+
* description: 'Get weather information',
|
|
8424
|
+
* inputParameters: {
|
|
8425
|
+
* type: 'object',
|
|
8426
|
+
* properties: {
|
|
8427
|
+
* location: { type: 'string' }
|
|
8428
|
+
* }
|
|
8429
|
+
* }
|
|
8430
|
+
* }
|
|
8431
|
+
* ];
|
|
8432
|
+
*
|
|
8433
|
+
* const openAITools = provider.wrapTools(composioTools);
|
|
8434
|
+
* ```
|
|
8435
|
+
*/
|
|
8436
|
+
wrapTools = (tools) => {
|
|
8437
|
+
return tools.map((tool) => this.wrapTool(tool));
|
|
8438
|
+
};
|
|
8439
|
+
async executeToolCall(executionTarget, tool, options, modifiers) {
|
|
8440
|
+
const arguments_ = normalizeToolArguments(tool.function.arguments, tool.function.name);
|
|
8441
|
+
const result = await this.executeToolForTarget(executionTarget, tool.function.name, arguments_, options, modifiers);
|
|
8442
|
+
return JSON.stringify(result);
|
|
8443
|
+
}
|
|
8444
|
+
async handleToolCalls(executionTarget, chatCompletion, options, modifiers) {
|
|
8445
|
+
this.assertToolCallExecutionOptions(executionTarget, options, modifiers);
|
|
8446
|
+
const outputs = [];
|
|
8447
|
+
const [choice] = chatCompletion.choices;
|
|
8448
|
+
for (const toolCall of choice?.message.tool_calls ?? []) {
|
|
8449
|
+
if (toolCall.type !== "function") continue;
|
|
8450
|
+
const toolResult = typeof executionTarget === "string" ? await this.executeToolCall(executionTarget, toolCall, options, modifiers) : await this.executeToolCall(executionTarget, toolCall);
|
|
8451
|
+
outputs.push({
|
|
8452
|
+
role: "tool",
|
|
8453
|
+
tool_call_id: toolCall.id,
|
|
8454
|
+
content: toolResult
|
|
8455
|
+
});
|
|
8456
|
+
}
|
|
8457
|
+
return outputs;
|
|
8458
|
+
}
|
|
8459
|
+
/**
|
|
8460
|
+
* Handles all the tool calls from the OpenAI Assistant API.
|
|
8461
|
+
*
|
|
8462
|
+
* This method processes tool calls from an OpenAI Assistant run,
|
|
8463
|
+
* executes each tool call, and returns the tool outputs for submission.
|
|
8464
|
+
*
|
|
8465
|
+
* @deprecated Assistant API is deprecated, please use responses or chat completions instead. This method will be removed in the next major version.
|
|
8466
|
+
*
|
|
8467
|
+
* @param {string} userId - The user ID for authentication and tracking
|
|
8468
|
+
* @param {OpenAI.Beta.Threads.Run} run - The Assistant run object containing tool calls
|
|
8469
|
+
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
8470
|
+
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
8471
|
+
* @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} Array of tool outputs for submission
|
|
8472
|
+
*
|
|
8473
|
+
*
|
|
8474
|
+
* @example
|
|
8475
|
+
* ```typescript
|
|
8476
|
+
* // Handle tool calls from an OpenAI Assistant run
|
|
8477
|
+
* const run = {
|
|
8478
|
+
* id: 'run_abc123',
|
|
8479
|
+
* required_action: {
|
|
8480
|
+
* submit_tool_outputs: {
|
|
8481
|
+
* tool_calls: [
|
|
8482
|
+
* {
|
|
8483
|
+
* id: 'call_xyz789',
|
|
8484
|
+
* type: 'function',
|
|
8485
|
+
* function: {
|
|
8486
|
+
* name: 'SEARCH_TOOL',
|
|
8487
|
+
* arguments: '{"query":"composio documentation"}'
|
|
8488
|
+
* }
|
|
8489
|
+
* }
|
|
8490
|
+
* ]
|
|
8491
|
+
* }
|
|
8492
|
+
* }
|
|
8493
|
+
* };
|
|
8494
|
+
*
|
|
8495
|
+
* const toolOutputs = await provider.handleAssistantMessage(
|
|
8496
|
+
* 'user123',
|
|
8497
|
+
* run,
|
|
8498
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
8499
|
+
* );
|
|
8500
|
+
*
|
|
8501
|
+
* // Submit tool outputs back to OpenAI
|
|
8502
|
+
* await openai.beta.threads.runs.submitToolOutputs(
|
|
8503
|
+
* thread.id,
|
|
8504
|
+
* run.id,
|
|
8505
|
+
* { tool_outputs: toolOutputs }
|
|
8506
|
+
* );
|
|
8507
|
+
* ```
|
|
8508
|
+
*/
|
|
8509
|
+
async handleAssistantMessage(userId, run, options, modifiers) {
|
|
8510
|
+
const tool_calls = run.required_action?.submit_tool_outputs?.tool_calls || [];
|
|
8511
|
+
return await Promise.all(tool_calls.map(async (tool_call) => {
|
|
8512
|
+
logger.debug(`Executing tool call: ${tool_call.id}`);
|
|
8513
|
+
const tool_response = await this.executeToolCall(userId, tool_call, options, modifiers);
|
|
8514
|
+
logger.debug(`Tool call ${tool_call.id} executed with response: ${tool_response}`);
|
|
8515
|
+
return {
|
|
8516
|
+
tool_call_id: tool_call.id,
|
|
8517
|
+
output: JSON.stringify(tool_response)
|
|
8518
|
+
};
|
|
8519
|
+
}));
|
|
8520
|
+
}
|
|
8521
|
+
/**
|
|
8522
|
+
* Waits for the assistant stream and handles the tool calls.
|
|
8523
|
+
*
|
|
8524
|
+
* This method processes an OpenAI Assistant stream, handles any tool calls
|
|
8525
|
+
* that require action, and yields each event from the stream. It's designed
|
|
8526
|
+
* for streaming Assistant responses while handling tool calls in real-time.
|
|
8527
|
+
*
|
|
8528
|
+
* @deprecated Assistant API is deprecated, please use responses or chat completions instead. It will be removed in the next major version.
|
|
8529
|
+
*
|
|
8530
|
+
* @param {string} userId - The user ID for authentication and tracking
|
|
8531
|
+
* @param {OpenAI} client - The OpenAI client instance
|
|
8532
|
+
* @param {Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>} runStream - The Assistant run stream
|
|
8533
|
+
* @param {OpenAI.Beta.Threads.Thread} thread - The thread object
|
|
8534
|
+
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
8535
|
+
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
8536
|
+
* @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} Generator yielding stream events
|
|
8537
|
+
*
|
|
8538
|
+
*
|
|
8539
|
+
*
|
|
8540
|
+
* @example
|
|
8541
|
+
* ```typescript
|
|
8542
|
+
* // Process an OpenAI Assistant stream with tool calls
|
|
8543
|
+
* const thread = await openai.beta.threads.create();
|
|
8544
|
+
* const runStream = openai.beta.threads.runs.stream(thread.id, {
|
|
8545
|
+
* assistant_id: 'asst_abc123',
|
|
8546
|
+
* tools: provider.wrapTools(composioTools)
|
|
8547
|
+
* });
|
|
8548
|
+
*
|
|
8549
|
+
* // Process the stream and handle tool calls
|
|
8550
|
+
* const streamProcessor = provider.waitAndHandleAssistantStreamToolCalls(
|
|
8551
|
+
* 'user123',
|
|
8552
|
+
* openai,
|
|
8553
|
+
* runStream,
|
|
8554
|
+
* thread,
|
|
8555
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
8556
|
+
* );
|
|
8557
|
+
*
|
|
8558
|
+
* // Consume the stream events
|
|
8559
|
+
* for await (const event of streamProcessor) {
|
|
8560
|
+
* if (event.event === 'thread.message.delta') {
|
|
8561
|
+
* console.log(event.data.delta.content);
|
|
8562
|
+
* }
|
|
8563
|
+
* }
|
|
8564
|
+
* ```
|
|
8565
|
+
*/
|
|
8566
|
+
async *waitAndHandleAssistantStreamToolCalls(userId, client, runStream, thread, options, modifiers) {
|
|
8567
|
+
let runId = null;
|
|
8568
|
+
for await (const event of runStream) {
|
|
8569
|
+
yield event;
|
|
8570
|
+
if (event.event === "thread.run.created") {
|
|
8571
|
+
const { id } = event.data;
|
|
8572
|
+
runId = id;
|
|
8573
|
+
}
|
|
8574
|
+
if (!runId) continue;
|
|
8575
|
+
if (event.event === "thread.run.requires_action") {
|
|
8576
|
+
const toolOutputs = await this.handleAssistantMessage(userId, event.data, options, modifiers);
|
|
8577
|
+
await client.beta.threads.runs.submitToolOutputs(runId, {
|
|
8578
|
+
thread_id: thread.id,
|
|
8579
|
+
tool_outputs: toolOutputs
|
|
8580
|
+
});
|
|
8581
|
+
}
|
|
8582
|
+
if ([
|
|
8583
|
+
"thread.run.completed",
|
|
8584
|
+
"thread.run.failed",
|
|
8585
|
+
"thread.run.cancelled",
|
|
8586
|
+
"thread.run.expired"
|
|
8587
|
+
].includes(event.event)) break;
|
|
8588
|
+
}
|
|
8589
|
+
if (!runId) throw new Error("No run ID found");
|
|
8590
|
+
let finalRun = await client.beta.threads.runs.retrieve(runId, { thread_id: thread.id });
|
|
8591
|
+
while ([
|
|
8592
|
+
"queued",
|
|
8593
|
+
"in_progress",
|
|
8594
|
+
"requires_action"
|
|
8595
|
+
].includes(finalRun.status)) if (finalRun.status === "requires_action") {
|
|
8596
|
+
const toolOutputs = await this.handleAssistantMessage(userId, finalRun, options, modifiers);
|
|
8597
|
+
finalRun = await client.beta.threads.runs.submitToolOutputs(runId, {
|
|
8598
|
+
thread_id: thread.id,
|
|
8599
|
+
tool_outputs: toolOutputs
|
|
8600
|
+
});
|
|
8601
|
+
} else {
|
|
8602
|
+
finalRun = await client.beta.threads.runs.retrieve(runId, { thread_id: thread.id });
|
|
8603
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
8604
|
+
}
|
|
8605
|
+
}
|
|
8606
|
+
/**
|
|
8607
|
+
* Waits for the assistant tool calls and handles them.
|
|
8608
|
+
*
|
|
8609
|
+
* This method polls an OpenAI Assistant run until it completes or requires action,
|
|
8610
|
+
* handles any tool calls, and returns the final run object. It's designed for
|
|
8611
|
+
* non-streaming Assistant interactions.
|
|
8612
|
+
*
|
|
8613
|
+
* @deprecated Assistant API is deprecated, please use responses or chat completions instead. It will be removed in the next major version.
|
|
8614
|
+
*
|
|
8615
|
+
* @param {string} userId - The user ID for authentication and tracking
|
|
8616
|
+
* @param {OpenAI} client - The OpenAI client instance
|
|
8617
|
+
* @param {OpenAI.Beta.Threads.Run} run - The initial run object
|
|
8618
|
+
* @param {OpenAI.Beta.Threads.Thread} thread - The thread object
|
|
8619
|
+
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
8620
|
+
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
8621
|
+
* @returns {Promise<OpenAI.Beta.Threads.Run>} The final run object after completion
|
|
8622
|
+
*
|
|
8623
|
+
* @example
|
|
8624
|
+
* ```typescript
|
|
8625
|
+
* // Process an OpenAI Assistant run with tool calls
|
|
8626
|
+
* const thread = await openai.beta.threads.create();
|
|
8627
|
+
* await openai.beta.threads.messages.create(thread.id, {
|
|
8628
|
+
* role: 'user',
|
|
8629
|
+
* content: 'Find information about Composio'
|
|
8630
|
+
* });
|
|
8631
|
+
*
|
|
8632
|
+
* let run = await openai.beta.threads.runs.create(thread.id, {
|
|
8633
|
+
* assistant_id: 'asst_abc123',
|
|
8634
|
+
* tools: provider.wrapTools(composioTools)
|
|
8635
|
+
* });
|
|
8636
|
+
*
|
|
8637
|
+
* // Wait for the run to complete, handling any tool calls
|
|
8638
|
+
* run = await provider.waitAndHandleAssistantToolCalls(
|
|
8639
|
+
* 'user123',
|
|
8640
|
+
* openai,
|
|
8641
|
+
* run,
|
|
8642
|
+
* thread,
|
|
8643
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
8644
|
+
* );
|
|
8645
|
+
*
|
|
8646
|
+
* // Get the final messages after run completion
|
|
8647
|
+
* const messages = await openai.beta.threads.messages.list(thread.id);
|
|
8648
|
+
* console.log(messages.data[0].content);
|
|
8649
|
+
* ```
|
|
8650
|
+
*/
|
|
8651
|
+
async waitAndHandleAssistantToolCalls(userId, client, run, thread, options, modifiers) {
|
|
8652
|
+
while ([
|
|
8653
|
+
"queued",
|
|
8654
|
+
"in_progress",
|
|
8655
|
+
"requires_action"
|
|
8656
|
+
].includes(run.status)) {
|
|
8657
|
+
const tool_outputs = await this.handleAssistantMessage(userId, run, options, modifiers);
|
|
8658
|
+
if (run.status === "requires_action") run = await client.beta.threads.runs.submitToolOutputs(run.id, {
|
|
8659
|
+
thread_id: thread.id,
|
|
8660
|
+
tool_outputs
|
|
8661
|
+
});
|
|
8662
|
+
else {
|
|
8663
|
+
run = await client.beta.threads.runs.retrieve(run.id, { thread_id: thread.id });
|
|
8664
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
8665
|
+
}
|
|
8666
|
+
}
|
|
8667
|
+
return run;
|
|
8668
|
+
}
|
|
8669
|
+
};
|
|
8670
|
+
|
|
8671
|
+
//#endregion
|
|
8672
|
+
//#region package.json
|
|
8673
|
+
var version = "0.21.0";
|
|
8674
|
+
|
|
8675
|
+
//#endregion
|
|
8676
|
+
//#region src/utils/session.ts
|
|
8380
8677
|
/**
|
|
8381
|
-
*
|
|
8678
|
+
* Detect the JavaScript runtime environment without importing any external modules.
|
|
8679
|
+
* Uses only built-in globals to avoid breaking in different environments.
|
|
8382
8680
|
*/
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8681
|
+
function detectRuntime() {
|
|
8682
|
+
const global = globalThis;
|
|
8683
|
+
if ("Bun" in global && typeof global.Bun !== "undefined") return "BUN";
|
|
8684
|
+
if ("Deno" in global && typeof global.Deno !== "undefined") return "DENO";
|
|
8685
|
+
if (typeof process !== "undefined" && process.versions && process.versions.node) return "NODEJS";
|
|
8686
|
+
if ("caches" in global && typeof global.caches !== "undefined" && "WebSocketPair" in global && typeof global.WebSocketPair !== "undefined") return "CLOUDFLARE_WORKERS";
|
|
8687
|
+
if ("EdgeRuntime" in global && typeof global.EdgeRuntime !== "undefined") return "VERCEL_EDGE";
|
|
8688
|
+
if ("ServiceWorkerGlobalScope" in global && typeof global.ServiceWorkerGlobalScope !== "undefined") {
|
|
8689
|
+
const ServiceWorkerScope = global.ServiceWorkerGlobalScope;
|
|
8690
|
+
if (ServiceWorkerScope && global instanceof ServiceWorkerScope) return "SERVICE_WORKER";
|
|
8691
|
+
}
|
|
8692
|
+
if ("WorkerGlobalScope" in global && typeof global.WorkerGlobalScope !== "undefined" && "importScripts" in global && typeof global.importScripts === "function") return "WEB_WORKER";
|
|
8693
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") return "REACT_NATIVE";
|
|
8694
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") return "BROWSER";
|
|
8695
|
+
return "UNKNOWN";
|
|
8696
|
+
}
|
|
8697
|
+
const RUNTIME_ENV = detectRuntime();
|
|
8698
|
+
function getSessionHeaders(provider) {
|
|
8699
|
+
return {
|
|
8700
|
+
"x-framework": provider?.name || "unknown",
|
|
8701
|
+
"x-source": "TYPESCRIPT_SDK",
|
|
8702
|
+
"x-runtime": RUNTIME_ENV,
|
|
8703
|
+
"x-sdk-version": version
|
|
8704
|
+
};
|
|
8705
|
+
}
|
|
8706
|
+
const getDefaultHeaders = (headers, provider) => {
|
|
8707
|
+
const sessionHeaders = getSessionHeaders(provider);
|
|
8708
|
+
return {
|
|
8709
|
+
...headers || {},
|
|
8710
|
+
...sessionHeaders
|
|
8711
|
+
};
|
|
8712
|
+
};
|
|
8396
8713
|
|
|
8397
8714
|
//#endregion
|
|
8398
8715
|
//#region src/lib/toolRouterParams.ts
|
|
@@ -8449,6 +8766,14 @@ const transformToolRouterSandboxParams = (params) => {
|
|
|
8449
8766
|
sandbox_size: params.sandboxSize
|
|
8450
8767
|
};
|
|
8451
8768
|
};
|
|
8769
|
+
const transformToolRouterPremiumUsageParams = (config) => {
|
|
8770
|
+
if (config === false) return false;
|
|
8771
|
+
return {
|
|
8772
|
+
...config.toolkits !== void 0 && { toolkits: config.toolkits },
|
|
8773
|
+
...config.tools !== void 0 && { tools: config.tools },
|
|
8774
|
+
...config.returnPremiumCharge !== void 0 && { return_premium_charge: config.returnPremiumCharge }
|
|
8775
|
+
};
|
|
8776
|
+
};
|
|
8452
8777
|
const transformToolRouterUpdateManageConnectionsParams = (params) => {
|
|
8453
8778
|
if (typeof params === "boolean") return { enable: params };
|
|
8454
8779
|
const parsedResult = ToolRouterUpdateManageConnectionsSchema.safeParse(params);
|
|
@@ -8502,11 +8827,12 @@ const transformToolRouterToolkitsParams = (params) => {
|
|
|
8502
8827
|
* including `null` (remove the stored override) and empty collections (an
|
|
8503
8828
|
* empty toolkit allowlist denies every app toolkit). The
|
|
8504
8829
|
* `expectedConfigVersion` option is not a body field here: the session
|
|
8505
|
-
*
|
|
8830
|
+
* adds it only when the caller explicitly supplies a numeric version.
|
|
8506
8831
|
*/
|
|
8507
8832
|
const transformToolRouterUpdateParams = (config) => {
|
|
8508
8833
|
const params = {};
|
|
8509
8834
|
if (config.toolkits !== void 0) params.toolkits = config.toolkits === null ? null : transformToolRouterToolkitsParams(config.toolkits);
|
|
8835
|
+
if (config.premiumUsage !== void 0) params.premium_usage = transformToolRouterPremiumUsageParams(config.premiumUsage);
|
|
8510
8836
|
if (config.tools !== void 0) params.tools = config.tools === null ? null : transformToolRouterToolsParams(config.tools);
|
|
8511
8837
|
if (config.tags !== void 0) params.tags = config.tags === null ? null : transformToolRouterTagsParams(config.tags);
|
|
8512
8838
|
if (config.authConfigs !== void 0) params.auth_configs = config.authConfigs;
|
|
@@ -8610,84 +8936,15 @@ const buildMCPServerConfig = (input) => {
|
|
|
8610
8936
|
};
|
|
8611
8937
|
|
|
8612
8938
|
//#endregion
|
|
8613
|
-
//#region src/
|
|
8614
|
-
function transformSearchResult(raw) {
|
|
8615
|
-
return {
|
|
8616
|
-
index: raw.index,
|
|
8617
|
-
useCase: raw.use_case,
|
|
8618
|
-
primaryToolSlugs: raw.primary_tool_slugs,
|
|
8619
|
-
relatedToolSlugs: raw.related_tool_slugs,
|
|
8620
|
-
toolkits: raw.toolkits,
|
|
8621
|
-
difficulty: raw.difficulty,
|
|
8622
|
-
error: raw.error,
|
|
8623
|
-
executionGuidance: raw.execution_guidance,
|
|
8624
|
-
knownPitfalls: raw.known_pitfalls,
|
|
8625
|
-
memory: raw.memory,
|
|
8626
|
-
planId: raw.plan_id,
|
|
8627
|
-
recommendedPlanSteps: raw.recommended_plan_steps,
|
|
8628
|
-
referenceWorkbenchSnippets: raw.reference_workbench_snippets
|
|
8629
|
-
};
|
|
8630
|
-
}
|
|
8631
|
-
function transformToolSchema(raw) {
|
|
8632
|
-
return {
|
|
8633
|
-
toolSlug: raw.tool_slug,
|
|
8634
|
-
toolkit: raw.toolkit,
|
|
8635
|
-
description: raw.description,
|
|
8636
|
-
hasFullSchema: raw.hasFullSchema,
|
|
8637
|
-
inputSchema: raw.input_schema,
|
|
8638
|
-
outputSchema: raw.output_schema,
|
|
8639
|
-
schemaRef: raw.schemaRef ? {
|
|
8640
|
-
args: { toolSlugs: raw.schemaRef.args.tool_slugs },
|
|
8641
|
-
message: raw.schemaRef.message,
|
|
8642
|
-
tool: raw.schemaRef.tool
|
|
8643
|
-
} : void 0
|
|
8644
|
-
};
|
|
8645
|
-
}
|
|
8646
|
-
function transformToolkitConnectionStatus(raw) {
|
|
8647
|
-
return {
|
|
8648
|
-
toolkit: raw.toolkit,
|
|
8649
|
-
description: raw.description,
|
|
8650
|
-
hasActiveConnection: raw.has_active_connection,
|
|
8651
|
-
statusMessage: raw.status_message,
|
|
8652
|
-
connectionDetails: raw.connection_details,
|
|
8653
|
-
currentUserInfo: raw.current_user_info
|
|
8654
|
-
};
|
|
8655
|
-
}
|
|
8656
|
-
/**
|
|
8657
|
-
* Transforms a raw session search API response to camelCase.
|
|
8658
|
-
*/
|
|
8659
|
-
function transformSearchResponse(raw) {
|
|
8660
|
-
const toolSchemas = {};
|
|
8661
|
-
for (const [slug, schema] of Object.entries(raw.tool_schemas)) toolSchemas[slug] = transformToolSchema(schema);
|
|
8662
|
-
return {
|
|
8663
|
-
success: raw.success,
|
|
8664
|
-
error: raw.error,
|
|
8665
|
-
results: raw.results.map(transformSearchResult),
|
|
8666
|
-
toolSchemas,
|
|
8667
|
-
toolkitConnectionStatuses: raw.toolkit_connection_statuses.map(transformToolkitConnectionStatus),
|
|
8668
|
-
nextStepsGuidance: raw.next_steps_guidance,
|
|
8669
|
-
session: {
|
|
8670
|
-
id: raw.session.id,
|
|
8671
|
-
generateId: raw.session.generate_id,
|
|
8672
|
-
instructions: raw.session.instructions
|
|
8673
|
-
},
|
|
8674
|
-
timeInfo: {
|
|
8675
|
-
currentTimeUtc: raw.time_info.current_time_utc,
|
|
8676
|
-
currentTimeUtcEpochSeconds: raw.time_info.current_time_utc_epoch_seconds,
|
|
8677
|
-
message: raw.time_info.message
|
|
8678
|
-
}
|
|
8679
|
-
};
|
|
8680
|
-
}
|
|
8939
|
+
//#region src/lib/toolRouterSourceSessionConfig.ts
|
|
8681
8940
|
/**
|
|
8682
|
-
*
|
|
8941
|
+
* Reads the saved Session config most recently applied to a session from a
|
|
8942
|
+
* create, retrieve, attach or patch response. Copies only `id`.
|
|
8683
8943
|
*/
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
logId: raw.log_id
|
|
8689
|
-
};
|
|
8690
|
-
}
|
|
8944
|
+
const getSourceSessionConfig = (response) => {
|
|
8945
|
+
const source = response.experimental?.source_session_config;
|
|
8946
|
+
return source ? { id: source.id } : void 0;
|
|
8947
|
+
};
|
|
8691
8948
|
|
|
8692
8949
|
//#endregion
|
|
8693
8950
|
//#region src/types/ToolRouterSessionFilesMount.types.ts
|
|
@@ -8745,6 +9002,134 @@ const FileDeleteResponseSchema = z.object({
|
|
|
8745
9002
|
sandboxMountPrefix: data.sandbox_mount_prefix
|
|
8746
9003
|
}));
|
|
8747
9004
|
|
|
9005
|
+
//#endregion
|
|
9006
|
+
//#region src/utils/safePath.ts
|
|
9007
|
+
/**
|
|
9008
|
+
* Filename containment for untrusted input.
|
|
9009
|
+
*
|
|
9010
|
+
* Every field of an API response is untrusted, including filenames. When such a
|
|
9011
|
+
* value becomes part of a filesystem path it must pass through this module
|
|
9012
|
+
* first, and validation must happen before any `mkdir` or write so a rejected
|
|
9013
|
+
* value leaves nothing behind on disk.
|
|
9014
|
+
*
|
|
9015
|
+
* TypeScript counterpart of `safe_basename` in `python/composio/utils/safe_path.py`.
|
|
9016
|
+
* The two use the same validation order and whitespace rules. Path extraction
|
|
9017
|
+
* is intentionally limited here; see `untrustedBasename`.
|
|
9018
|
+
*
|
|
9019
|
+
* Pure string logic with no filesystem access: no static `node:*` imports, so
|
|
9020
|
+
* it is usable from edge/workerd builds.
|
|
9021
|
+
*/
|
|
9022
|
+
/**
|
|
9023
|
+
* Upper bound on a filename, well under the 255-byte limit common to
|
|
9024
|
+
* ext4/APFS/NTFS. Keeps a long server-supplied name from failing with a raw
|
|
9025
|
+
* `ENAMETOOLONG` mid-write. Matches `MAX_COMPONENT_LENGTH` in the Python SDK.
|
|
9026
|
+
*/
|
|
9027
|
+
const MAX_FILENAME_BYTES = 128;
|
|
9028
|
+
/**
|
|
9029
|
+
* Reserved DOS device names. Writing to one on Windows targets the device
|
|
9030
|
+
* rather than a file. Rejected on every platform so behavior does not diverge
|
|
9031
|
+
* between a POSIX developer machine and a Windows deployment.
|
|
9032
|
+
*/
|
|
9033
|
+
const WINDOWS_RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
9034
|
+
"CON",
|
|
9035
|
+
"PRN",
|
|
9036
|
+
"AUX",
|
|
9037
|
+
"NUL",
|
|
9038
|
+
...Array.from({ length: 9 }, (_, i) => `COM${i + 1}`),
|
|
9039
|
+
...Array.from({ length: 9 }, (_, i) => `LPT${i + 1}`),
|
|
9040
|
+
...[
|
|
9041
|
+
"¹",
|
|
9042
|
+
"²",
|
|
9043
|
+
"³"
|
|
9044
|
+
].flatMap((superscript) => [`COM${superscript}`, `LPT${superscript}`])
|
|
9045
|
+
]);
|
|
9046
|
+
/** Control characters and characters reserved by Windows. */
|
|
9047
|
+
const WINDOWS_INVALID_CHARS = /[\u0000-\u001f<>:"|?*]/;
|
|
9048
|
+
/**
|
|
9049
|
+
* Python str.strip() whitespace: Unicode White_Space plus U+001C–U+001F.
|
|
9050
|
+
* Unlike JavaScript trim(), this includes U+0085 and preserves U+FEFF.
|
|
9051
|
+
*/
|
|
9052
|
+
const PYTHON_WHITESPACE = "[\\u0009-\\u000d\\u001c-\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]";
|
|
9053
|
+
const SURROUNDING_WHITESPACE = new RegExp(`^${PYTHON_WHITESPACE}+|${PYTHON_WHITESPACE}+$`, "g");
|
|
9054
|
+
/**
|
|
9055
|
+
* Returns the last path segment of `value`, treating both `/` and `\` as
|
|
9056
|
+
* separators, or `''` when there is none.
|
|
9057
|
+
*
|
|
9058
|
+
* `path.basename()` on POSIX only splits on `/`, so a name crafted for a
|
|
9059
|
+
* Windows target (`..\..\evil`) comes back intact on macOS and Linux. Splitting
|
|
9060
|
+
* on both and removing an initial drive prefix also handles `C:report.txt`.
|
|
9061
|
+
* This is not a full `PureWindowsPath` parser: dot components stay literal,
|
|
9062
|
+
* and UNC anchors are not interpreted.
|
|
9063
|
+
*
|
|
9064
|
+
* Never throws: this is a display value as well as the input to
|
|
9065
|
+
* {@link safeBasename}, and it is read while constructing download errors.
|
|
9066
|
+
*/
|
|
9067
|
+
function untrustedBasename(value) {
|
|
9068
|
+
const segments = value.replace(/^[a-z]:/i, "").split(/[/\\]+/);
|
|
9069
|
+
while (segments.length > 0 && segments[segments.length - 1] === "") segments.pop();
|
|
9070
|
+
return segments[segments.length - 1] ?? "";
|
|
9071
|
+
}
|
|
9072
|
+
/**
|
|
9073
|
+
* True when `value` contains a surrogate code unit that is not part of a valid
|
|
9074
|
+
* pair. Such a string cannot be encoded as UTF-8; `TextEncoder` silently
|
|
9075
|
+
* substitutes U+FFFD, which would write a file under a name the response never
|
|
9076
|
+
* specified. `String.prototype.isWellFormed()` is ES2024 and this package
|
|
9077
|
+
* targets es2022, hence the manual scan.
|
|
9078
|
+
*/
|
|
9079
|
+
function hasLoneSurrogate(value) {
|
|
9080
|
+
for (let i = 0; i < value.length; i++) {
|
|
9081
|
+
const code = value.charCodeAt(i);
|
|
9082
|
+
if (code >= 55296 && code <= 56319) {
|
|
9083
|
+
const next = value.charCodeAt(i + 1);
|
|
9084
|
+
if (!(next >= 56320 && next <= 57343)) return true;
|
|
9085
|
+
i++;
|
|
9086
|
+
} else if (code >= 56320 && code <= 57343) return true;
|
|
9087
|
+
}
|
|
9088
|
+
return false;
|
|
9089
|
+
}
|
|
9090
|
+
/**
|
|
9091
|
+
* Collapses an untrusted filename to a bare, writable basename.
|
|
9092
|
+
*
|
|
9093
|
+
* Applies, in order: no usable basename (empty or a run of dots once
|
|
9094
|
+
* surrounding whitespace is stripped), NUL bytes, control and Windows-reserved
|
|
9095
|
+
* characters, trailing space or dot, invalid Unicode, a byte-length bound, and
|
|
9096
|
+
* reserved device names. This is the order `safe_basename` uses in the Python
|
|
9097
|
+
* SDK. This implementation rejects lone surrogates rather than relying on
|
|
9098
|
+
* Python filesystem encoding behavior.
|
|
9099
|
+
*
|
|
9100
|
+
* Names that leave no usable basename are refused rather than replaced with a
|
|
9101
|
+
* generated one: a response that cannot name its own file is malformed or
|
|
9102
|
+
* hostile, and inventing a name would hide that. `""`, `"."` and `".."` make
|
|
9103
|
+
* an output path equal to, or escape, its own directory, which surfaces as a
|
|
9104
|
+
* raw `EISDIR` at write time instead of a validation error.
|
|
9105
|
+
*
|
|
9106
|
+
* The usability check runs on the *trimmed* basename because that is what gets
|
|
9107
|
+
* written: Python-compatible stripping removes whitespace, so `"\u00a0.\u00a0"` would
|
|
9108
|
+
* otherwise pass a check on the raw segment and then be written as `"."`. The
|
|
9109
|
+
* hazard checks that follow run on the raw segment so a trailing ASCII space or
|
|
9110
|
+
* dot is refused, not trimmed away. Check the stripped value for trailing dots
|
|
9111
|
+
* too, since stripping whitespace can expose one.
|
|
9112
|
+
*
|
|
9113
|
+
* @param name - The untrusted filename or relative path to reduce.
|
|
9114
|
+
* @param label - How the value is described in error messages.
|
|
9115
|
+
* @returns The validated bare basename, with surrounding whitespace trimmed.
|
|
9116
|
+
* @throws ValidationError if `name` yields no usable basename or is unsafe to write.
|
|
9117
|
+
*/
|
|
9118
|
+
function safeBasename(name, label = "filename") {
|
|
9119
|
+
const rawBasename = untrustedBasename(name);
|
|
9120
|
+
const basename = rawBasename.replace(SURROUNDING_WHITESPACE, "");
|
|
9121
|
+
if (!basename || /^\.+$/.test(basename)) throw new ValidationError(`Path traversal detected: ${label} ${JSON.stringify(name)} leaves no usable basename to write to.`);
|
|
9122
|
+
if (rawBasename.includes("\0")) throw new ValidationError(`Refusing to write ${label} containing a NUL byte: ${JSON.stringify(name)}`);
|
|
9123
|
+
if (WINDOWS_INVALID_CHARS.test(rawBasename)) throw new ValidationError(`Refusing to write ${label} containing characters reserved by Windows: ${JSON.stringify(name)}`);
|
|
9124
|
+
if (rawBasename.endsWith(" ") || rawBasename.endsWith(".") || basename.endsWith(".")) throw new ValidationError(`Refusing to write ${label} ending in a space or dot: ${JSON.stringify(name)}`);
|
|
9125
|
+
if (hasLoneSurrogate(basename)) throw new ValidationError(`Refusing to write ${label} containing invalid Unicode: ${JSON.stringify(name)}`);
|
|
9126
|
+
const encodedLength = new TextEncoder().encode(basename).length;
|
|
9127
|
+
if (encodedLength > 128) throw new ValidationError(`Refusing to write ${label} longer than ${128} bytes: ${JSON.stringify(basename.slice(0, 32))}... (${encodedLength} bytes)`);
|
|
9128
|
+
const deviceName = basename.split(".", 1)[0].replace(/ +$/, "").toUpperCase();
|
|
9129
|
+
if (WINDOWS_RESERVED_NAMES.has(deviceName)) throw new ValidationError(`Refusing to write ${label} that is a reserved device name: ${JSON.stringify(name)}`);
|
|
9130
|
+
return basename;
|
|
9131
|
+
}
|
|
9132
|
+
|
|
8748
9133
|
//#endregion
|
|
8749
9134
|
//#region src/models/RemoteFile.ts
|
|
8750
9135
|
function getParentDir(filePath) {
|
|
@@ -8804,9 +9189,20 @@ var RemoteFile = class RemoteFile {
|
|
|
8804
9189
|
if (!parsed.success) throw new ValidationError("Failed to parse remote file response", { cause: parsed.error });
|
|
8805
9190
|
return new RemoteFile(parsed.data);
|
|
8806
9191
|
}
|
|
8807
|
-
/**
|
|
9192
|
+
/**
|
|
9193
|
+
* Filename extracted from the mount path (e.g. "report.pdf" from "output/report.pdf").
|
|
9194
|
+
*
|
|
9195
|
+
* Deliberately non-throwing: this is a display value, and `downloadBytes()`
|
|
9196
|
+
* reads it while constructing `RemoteFileDownloadError`. A validator here
|
|
9197
|
+
* would replace a genuine download error with a validation error thrown from
|
|
9198
|
+
* inside the error constructor. {@link save} validates instead, at the point
|
|
9199
|
+
* the value actually becomes a path.
|
|
9200
|
+
*
|
|
9201
|
+
* Both `/` and `\` count as separators, as in the Python SDK, so a mount path
|
|
9202
|
+
* crafted for a Windows target is reduced the same way on every platform.
|
|
9203
|
+
*/
|
|
8808
9204
|
get filename() {
|
|
8809
|
-
return
|
|
9205
|
+
return untrustedBasename(this.mountRelativePath);
|
|
8810
9206
|
}
|
|
8811
9207
|
downloadError(message, cause, response) {
|
|
8812
9208
|
return new RemoteFileDownloadError(message, {
|
|
@@ -8873,14 +9269,16 @@ var RemoteFile = class RemoteFile {
|
|
|
8873
9269
|
* @param path - Local path to save the file. If omitted, saves to the Composio temp directory using the filename from the mount path.
|
|
8874
9270
|
* @returns The absolute path where the file was saved
|
|
8875
9271
|
* @throws Error if file system is not supported or the save fails
|
|
9272
|
+
* @throws ValidationError if `path` is omitted and the mount path yields no usable filename
|
|
8876
9273
|
*/
|
|
8877
9274
|
async save(path) {
|
|
8878
9275
|
if (!platform.supportsFileSystem) throw new Error("File system operations are not supported in this runtime (e.g. Cloudflare Workers). Use buffer(), text(), or blob() to work with the file content in memory, or run in Node.js.");
|
|
8879
|
-
const content = await this.buffer();
|
|
8880
9276
|
const homeDir = platform.homedir();
|
|
8881
9277
|
if (!homeDir) throw new Error("Cannot determine save location: home directory is not available");
|
|
8882
|
-
const
|
|
8883
|
-
const
|
|
9278
|
+
const defaultDir = platform.joinPath(homeDir, COMPOSIO_DIR, TEMP_FILES_DIRECTORY_NAME);
|
|
9279
|
+
const savePath = path ?? platform.joinPath(defaultDir, safeBasename(this.mountRelativePath, "mount path"));
|
|
9280
|
+
const content = await this.buffer();
|
|
9281
|
+
const dir = path != null ? getParentDir(savePath) : defaultDir;
|
|
8884
9282
|
if (dir && !platform.existsSync(dir)) platform.mkdirSync(dir);
|
|
8885
9283
|
platform.writeFileSync(savePath, content);
|
|
8886
9284
|
return savePath;
|
|
@@ -9428,9 +9826,9 @@ var ToolRouterSession = class {
|
|
|
9428
9826
|
mcp;
|
|
9429
9827
|
experimental;
|
|
9430
9828
|
/**
|
|
9431
|
-
*
|
|
9432
|
-
*
|
|
9433
|
-
* `
|
|
9829
|
+
* The session's current configuration (policy snapshot and runtime
|
|
9830
|
+
* settings). Refreshed in place by `update()`. For saved, reusable Session
|
|
9831
|
+
* configs, see `composio.sessionConfigs`.
|
|
9434
9832
|
*/
|
|
9435
9833
|
config;
|
|
9436
9834
|
preload;
|
|
@@ -9438,8 +9836,8 @@ var ToolRouterSession = class {
|
|
|
9438
9836
|
sandbox;
|
|
9439
9837
|
/**
|
|
9440
9838
|
* Version of the server-side configuration this object last observed.
|
|
9441
|
-
* Refreshed in place by `update()
|
|
9442
|
-
*
|
|
9839
|
+
* Refreshed in place by `update()`. Pass it as `expectedConfigVersion` to
|
|
9840
|
+
* make an update conditional.
|
|
9443
9841
|
*/
|
|
9444
9842
|
configVersion;
|
|
9445
9843
|
warnings;
|
|
@@ -9464,7 +9862,8 @@ var ToolRouterSession = class {
|
|
|
9464
9862
|
this.mcp = mcp;
|
|
9465
9863
|
this.experimental = {
|
|
9466
9864
|
assistivePrompt: experimentalOverrides?.assistivePrompt,
|
|
9467
|
-
files: new ToolRouterSessionFilesMount(client, sessionId)
|
|
9865
|
+
files: new ToolRouterSessionFilesMount(client, sessionId),
|
|
9866
|
+
sourceSessionConfig: experimentalOverrides?.sourceSessionConfig
|
|
9468
9867
|
};
|
|
9469
9868
|
this.config = config;
|
|
9470
9869
|
this.preload = metadata?.preload ?? config.preload;
|
|
@@ -9837,24 +10236,33 @@ var ToolRouterSession = class {
|
|
|
9837
10236
|
* map entirely. `manageConnections.callbackUrl: null` removes only the
|
|
9838
10237
|
* stored callback URL.
|
|
9839
10238
|
*
|
|
9840
|
-
*
|
|
9841
|
-
* `
|
|
10239
|
+
* By default the request carries no precondition: the last writer wins.
|
|
10240
|
+
* Pass `expectedConfigVersion` (for example `session.configVersion`) to make
|
|
10241
|
+
* the update conditional: the API then applies it only when the stored
|
|
10242
|
+
* version still matches, and a concurrent change surfaces as
|
|
9842
10243
|
* {@link ComposioSessionConfigConflictError} (HTTP 409) instead of being
|
|
9843
|
-
* overwritten.
|
|
9844
|
-
*
|
|
9845
|
-
*
|
|
9846
|
-
* exactly once. On conflict this object is left
|
|
9847
|
-
* session with `sessions.use(sessionId)` and retry
|
|
9848
|
-
* `configVersion`.
|
|
9849
|
-
*
|
|
9850
|
-
* `
|
|
9851
|
-
*
|
|
9852
|
-
* `
|
|
10244
|
+
* overwritten. The API must support the `expected_config_version` field;
|
|
10245
|
+
* otherwise it rejects the request with a 400. `expectedConfigVersion: false`
|
|
10246
|
+
* is the same as omitting it. The PATCH is never retried by the transport,
|
|
10247
|
+
* so a 409 is reported exactly once. On conflict this object is left
|
|
10248
|
+
* unchanged: re-fetch the session with `sessions.use(sessionId)` and retry
|
|
10249
|
+
* against the fresh `configVersion`.
|
|
10250
|
+
*
|
|
10251
|
+
* `experimental.sessionConfigId` applies a saved Session config: it
|
|
10252
|
+
* replaces the session's toolkit, tool and tag access and cannot be combined
|
|
10253
|
+
* with `toolkits`, `tools` or `tags` (a `ValidationError` is thrown before
|
|
10254
|
+
* any request). A 409 while applying it means the session or the config
|
|
10255
|
+
* changed; re-fetch the session and retry. Backend 400, 403 and 404 errors,
|
|
10256
|
+
* for example for an archived or missing config, surface unchanged.
|
|
10257
|
+
*
|
|
10258
|
+
* `config`, `configVersion`, `preload`, `sandbox`, `warnings` and
|
|
10259
|
+
* `experimental.sourceSessionConfig` are refreshed in place only after a
|
|
10260
|
+
* successful response, and the updated `config` is returned.
|
|
9853
10261
|
*/
|
|
9854
10262
|
async update(config, requestOptions) {
|
|
9855
|
-
const parsed = ToolRouterUpdateSessionConfigSchema
|
|
10263
|
+
const parsed = parseSessionConfigInput(ToolRouterUpdateSessionConfigSchema, config);
|
|
9856
10264
|
const body = transformToolRouterUpdateParams(parsed);
|
|
9857
|
-
const expectedConfigVersion = parsed.expectedConfigVersion === false ? void 0 : parsed.expectedConfigVersion
|
|
10265
|
+
const expectedConfigVersion = parsed.expectedConfigVersion === false ? void 0 : parsed.expectedConfigVersion;
|
|
9858
10266
|
if (expectedConfigVersion !== void 0) body.expected_config_version = expectedConfigVersion;
|
|
9859
10267
|
let response;
|
|
9860
10268
|
try {
|
|
@@ -9863,13 +10271,24 @@ var ToolRouterSession = class {
|
|
|
9863
10271
|
maxRetries: 0
|
|
9864
10272
|
}), requestOptions?.signal);
|
|
9865
10273
|
} catch (error) {
|
|
9866
|
-
if (error instanceof ConflictError)
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
10274
|
+
if (error instanceof ConflictError) {
|
|
10275
|
+
const sessionConfigId = parsed.experimental?.sessionConfigId;
|
|
10276
|
+
if (sessionConfigId !== void 0) throw new ComposioSessionConfigConflictError(`Session ${this.sessionId} or Session config ${sessionConfigId} changed while the config was being applied; re-fetch the session and retry the update`, {
|
|
10277
|
+
cause: error,
|
|
10278
|
+
meta: {
|
|
10279
|
+
sessionId: this.sessionId,
|
|
10280
|
+
sessionConfigId,
|
|
10281
|
+
expectedConfigVersion
|
|
10282
|
+
}
|
|
10283
|
+
});
|
|
10284
|
+
throw new ComposioSessionConfigConflictError(expectedConfigVersion === void 0 ? `Session ${this.sessionId} configuration changed while this update was in flight; re-fetch the session and retry the update` : `Session ${this.sessionId} configuration is no longer at version ${expectedConfigVersion}; re-fetch the session and retry the update`, {
|
|
10285
|
+
cause: error,
|
|
10286
|
+
meta: {
|
|
10287
|
+
sessionId: this.sessionId,
|
|
10288
|
+
expectedConfigVersion
|
|
10289
|
+
}
|
|
10290
|
+
});
|
|
10291
|
+
}
|
|
9873
10292
|
throw error;
|
|
9874
10293
|
}
|
|
9875
10294
|
this.configVersion = response.config_version;
|
|
@@ -9877,6 +10296,7 @@ var ToolRouterSession = class {
|
|
|
9877
10296
|
this.preload = response.config.preload;
|
|
9878
10297
|
this.sandbox = response.config.workbench;
|
|
9879
10298
|
this.warnings = response.warnings ?? [];
|
|
10299
|
+
this.experimental.sourceSessionConfig = getSourceSessionConfig(response);
|
|
9880
10300
|
return this.config;
|
|
9881
10301
|
}
|
|
9882
10302
|
/**
|
|
@@ -10042,7 +10462,8 @@ var ToolRouterSession = class {
|
|
|
10042
10462
|
return {
|
|
10043
10463
|
data: mergedData,
|
|
10044
10464
|
error: hasAnyError ? remoteError && failedCount === 0 ? remoteError : `${failedCount} out of ${allResults.length} tools failed` : null,
|
|
10045
|
-
successful: !hasAnyError
|
|
10465
|
+
successful: !hasAnyError,
|
|
10466
|
+
...remoteResult?.premiumCharge !== void 0 && { premiumCharge: remoteResult.premiumCharge }
|
|
10046
10467
|
};
|
|
10047
10468
|
}
|
|
10048
10469
|
};
|
|
@@ -10103,7 +10524,7 @@ var ToolRouter = class {
|
|
|
10103
10524
|
});
|
|
10104
10525
|
}
|
|
10105
10526
|
async create(userId, config, requestOptions) {
|
|
10106
|
-
const routerConfig = ToolRouterCreateSessionConfigSchema
|
|
10527
|
+
const routerConfig = parseSessionConfigInput(ToolRouterCreateSessionConfigSchema, config ?? {});
|
|
10107
10528
|
const isDirectToolsPreset = routerConfig.sessionPreset === SessionPreset.DIRECT_TOOLS;
|
|
10108
10529
|
const customTools = routerConfig.experimental?.customTools;
|
|
10109
10530
|
const customToolkits = routerConfig.experimental?.customToolkits;
|
|
@@ -10115,6 +10536,7 @@ var ToolRouter = class {
|
|
|
10115
10536
|
preloadTools: routerConfig.preload?.tools
|
|
10116
10537
|
});
|
|
10117
10538
|
const experimentalPayload = {};
|
|
10539
|
+
if (routerConfig.experimental?.sessionConfigId !== void 0) experimentalPayload.session_config_id = routerConfig.experimental.sessionConfigId;
|
|
10118
10540
|
if (routerConfig.experimental?.assistivePrompt?.userTimezone) experimentalPayload.assistive_prompt_config = { user_timezone: routerConfig.experimental.assistivePrompt.userTimezone };
|
|
10119
10541
|
if (inlineCustomToolsPayload?.custom_tools) experimentalPayload.custom_tools = inlineCustomToolsPayload.custom_tools;
|
|
10120
10542
|
if (inlineCustomToolsPayload?.custom_toolkits) experimentalPayload.custom_toolkits = inlineCustomToolsPayload.custom_toolkits;
|
|
@@ -10126,6 +10548,7 @@ var ToolRouter = class {
|
|
|
10126
10548
|
auth_configs: routerConfig.authConfigs,
|
|
10127
10549
|
connected_accounts: connectedAccountsPayload,
|
|
10128
10550
|
toolkits: transformToolRouterToolkitsParams(routerConfig.toolkits),
|
|
10551
|
+
...routerConfig.premiumUsage !== void 0 && { premium_usage: transformToolRouterPremiumUsageParams(routerConfig.premiumUsage) },
|
|
10129
10552
|
tools: transformToolRouterToolsParams(routerConfig.tools),
|
|
10130
10553
|
tags: transformToolRouterTagsParams(routerConfig.tags),
|
|
10131
10554
|
manage_connections: transformToolRouterManageConnectionsParams(routerConfig.manageConnections),
|
|
@@ -10147,7 +10570,10 @@ var ToolRouter = class {
|
|
|
10147
10570
|
inlineCustomToolsPayload
|
|
10148
10571
|
};
|
|
10149
10572
|
const assistivePrompt = session.experimental?.assistive_prompt;
|
|
10150
|
-
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp, routerConfig.mcp === true), {
|
|
10573
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp, routerConfig.mcp === true), {
|
|
10574
|
+
assistivePrompt,
|
|
10575
|
+
sourceSessionConfig: getSourceSessionConfig(session)
|
|
10576
|
+
}, customToolsMap, userId, metadata);
|
|
10151
10577
|
}
|
|
10152
10578
|
async use(id, options, requestOptions) {
|
|
10153
10579
|
const customTools = options?.customTools;
|
|
@@ -10180,7 +10606,7 @@ var ToolRouter = class {
|
|
|
10180
10606
|
preloadedCustomToolSlugs: getPreloadedCustomToolSlugs(customToolsMap, defaultCustomPreload),
|
|
10181
10607
|
inlineCustomToolsPayload
|
|
10182
10608
|
};
|
|
10183
|
-
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp, options?.mcp === true),
|
|
10609
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp, options?.mcp === true), { sourceSessionConfig: getSourceSessionConfig(session) }, customToolsMap, userId, metadata);
|
|
10184
10610
|
}
|
|
10185
10611
|
/**
|
|
10186
10612
|
* Delete a tool router session by ID.
|
|
@@ -10301,6 +10727,12 @@ var Composio = class Composio {
|
|
|
10301
10727
|
*/
|
|
10302
10728
|
sessions;
|
|
10303
10729
|
/**
|
|
10730
|
+
* Read the project's saved Session configs. Apply one with
|
|
10731
|
+
* `experimental.sessionConfigId` on `sessions.create()` or `session.update()`.
|
|
10732
|
+
* Requires Session configs to be enabled for the project.
|
|
10733
|
+
*/
|
|
10734
|
+
sessionConfigs;
|
|
10735
|
+
/**
|
|
10304
10736
|
* Legacy alias for `composio.sessions`.
|
|
10305
10737
|
* @deprecated Use `composio.sessions` instead — `toolRouter` was renamed to `sessions` and is kept only for backwards compatibility. Prefer `composio.sessions`; do not generate new code against `composio.toolRouter`.
|
|
10306
10738
|
*/
|
|
@@ -10459,6 +10891,7 @@ var Composio = class Composio {
|
|
|
10459
10891
|
this.experimental = new Experimental(this.client);
|
|
10460
10892
|
this.sessions = new Sessions(this.client, this.config);
|
|
10461
10893
|
this.toolRouter = this.sessions;
|
|
10894
|
+
this.sessionConfigs = new SessionConfigs(this.client);
|
|
10462
10895
|
/**
|
|
10463
10896
|
* Initialize session aliases.
|
|
10464
10897
|
* Properly bind the methods to maintain the correct 'this' context.
|
|
@@ -11383,4 +11816,4 @@ const ComposioMcpUpdateResponseSchema = z$1.object({
|
|
|
11383
11816
|
});
|
|
11384
11817
|
|
|
11385
11818
|
//#endregion
|
|
11386
|
-
export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAPIKeyKindError, ComposioAclOnlyForSharedError, ComposioAuthConfigNotFoundError, ComposioBlockedInternalUrlError, ComposioConnectedAccountNotFoundError, ComposioConnectedAccountNotRevokableError, ComposioConnectedAccountRevocationNotSupportedError, ComposioCustomCreateResponseSchema, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioFileNotFoundError, ComposioFileUploadAbortedError, ComposioFileUploadError, ComposioFileUploadPathNotAllowedError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioInvalidToolArgumentsError, ComposioLegacyConnectedAccountsEndpointRetiredError, ComposioMCPDestinationError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioRequestCancelledError, ComposioScopeConfigError, ComposioSensitiveFilePathBlockedError, ComposioSessionConfigConflictError, ComposioSharedAccessDeniedError, ComposioSharedConnectionNotAccessibleError, ComposioToolExecutionError, ComposioToolFetchError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAclConfigResponseSchema, ConnectedAccountAclConfigSchema, ConnectedAccountAuthConfigSchema, ConnectedAccountCompleteAuthParamsSchema, ConnectedAccountCompleteAuthResponseSchema, ConnectedAccountErrorCodes, ConnectedAccountExperimentalResponseSchema, ConnectedAccountExperimentalSchema, ConnectedAccountListParamsSchema, ConnectedAccountListResponseSchema, ConnectedAccountRefreshOptionsSchema, ConnectedAccountRetrieveResponseSchema, ConnectedAccountRevokeResponseSchema, ConnectedAccountRevokedTokenSchema, 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, CustomToolkitAuthSchemeSchema, CustomToolkitDeleteResponseSchema, CustomToolkitSyncParamsSchema, CustomToolkitSyncResponseSchema, CustomToolkitUpsertParamsSchema, CustomToolkitUpsertResponseSchema, CustomToolkits, DefaultCreateConnectedAccountParamsSchema, DefaultWebhookSubscriptionEvents, Experimental, FileDeleteResponseSchema, FileListResponseSchema, FileModifierErrorCodes, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, JsonSchemaRefResolutionError, JsonSchemaToZodError, Keyring, KeyringTransferKeySchema, KeyringTransferKeysResponseSchema, LogSearchFilterFieldSchema, LogSearchFilterOperatorSchema, LogSearchFilterSchema, LogSearchParamsSchema, LogSearchResponseSchema, LogSearchTimeRangeSchema, Logs, MAX_URL_UPLOAD_SIZE_BYTES, 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, Sessions, SetWebhookSubscriptionParamsSchema, SingleConnectedAccountDetailedResponseSchema, SsrfErrorCodes, ToolErrorCodes, ToolExecuteMetaParamsSchema, ToolExecuteParamsSchema, ToolExecuteResponseSchema, ToolExecutionLogDetailSchema, ToolExecutionLogLevelSchema, ToolExecutionLogParentSchema, ToolExecutionLogSchema, ToolExecutionLogStatusSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterErrorCodes, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterSandboxConfigSchema, ToolRouterSession, ToolRouterSessionDeleteResponseSchema, ToolRouterSessionEnsureConnectedOptionsSchema, ToolRouterSessionExecuteResponseSchema, ToolRouterSessionFilesMountDeleteOptionsSchema, ToolRouterSessionFilesMountDownloadOptionsSchema, ToolRouterSessionFilesMountListOptionsSchema, ToolRouterSessionFilesMountUploadOptionsSchema, ToolRouterSessionListConfigHistoryOptionsSchema, ToolRouterSessionSearchResponseSchema, ToolRouterTagsEnableDisableSchema, ToolRouterTagsParamSchema, ToolRouterToolkitsDisabledConfigSchema, ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsOptionsSchema, ToolRouterToolkitsParamSchema, ToolRouterToolsParamSchema, ToolRouterUpdateExperimentalSchema, ToolRouterUpdateManageConnectionsSchema, ToolRouterUpdateSessionConfigSchema, ToolSchema, ToolkitAuthConfigDetailsSchema, ToolkitAuthFieldSchema, ToolkitAuthFieldsResponseSchema, ToolkitCategorySchema, ToolkitChangelogItemSchema, ToolkitChangelogResponseSchema, ToolkitConditionalScopeSchema, ToolkitConnectionStateSchema, ToolkitConnectionsDetailsSchema, ToolkitErrorCodes, ToolkitGetManySlugsSchema, ToolkitGrantContextDimensionSchema, ToolkitLatestVersionSchema, ToolkitListGrantContextsParamsSchema, ToolkitListGrantContextsResponseSchema, ToolkitMangedByEnumSchema, ToolkitRecommendScopesParamsSchema, ToolkitRecommendScopesResponseSchema, ToolkitRetrieveCategoriesResponseSchema, ToolkitRetrieveResponseSchema, ToolkitSchema, ToolkitSortByEnumSchema, ToolkitVersionChangelogSchema, ToolkitVersionParamSchema, ToolkitVersionSchema, ToolkitVersionsSchema, ToolkitsGetManyParamsSchema, ToolkitsListParamsSchema, TriggerErrorCodes, TriggerInstanceListActiveParamsSchema, TriggerInstanceListActiveResponseItemSchema, TriggerInstanceListActiveResponseSchema, TriggerInstanceManageDeleteResponseSchema, TriggerInstanceManageUpdateParamsSchema, TriggerInstanceManageUpdateResponseSchema, TriggerInstanceUpsertParamsSchema, TriggerInstanceUpsertResponseSchema, TriggerStatusEnum, TriggerStatuses, TriggerSubscribeParamSchema, TriggerTypeSchema, TriggersTypeListParamsSchema, TriggersTypeListResponseSchema, UpdateConnectedAccountAclParamsSchema, UpdateConnectedAccountParamsSchema, Usage, UsageBreakdownGroupSchema, UsageBreakdownParamsSchema, UsageBreakdownResponseSchema, UsageEntitySummarySchema, UsageFiltersSchema, UsageOrderBySchema, UsageOrderDirectionSchema, UsageSummaryParamsSchema, UsageSummaryResponseSchema, ValidationError, ValidationErrorCodes, VerifyWebhookParamsSchema, WebhookConnectedAccountAuthConfigSchema, WebhookConnectionMetadataSchema, WebhookConnectionStateSchema, WebhookEndpointCreateParamsSchema, WebhookEndpointListItemSchema, WebhookEndpointListParamsSchema, WebhookEndpointListResponseSchema, WebhookEndpointReplaceParamsSchema, WebhookEndpointSchema, WebhookEndpointUpdateParamsSchema, WebhookEndpoints, WebhookEventSchema, WebhookEventTypes, WebhookPayloadSchema, WebhookPayloadV1Schema, WebhookPayloadV2Schema, WebhookPayloadV3Schema, WebhookSubscriptionDeleteResponseSchema, WebhookSubscriptionEventTypeSchema, WebhookSubscriptionEventTypesResponseSchema, WebhookSubscriptionListParamsSchema, WebhookSubscriptionListResponseSchema, WebhookSubscriptionRotateSecretResponseSchema, WebhookSubscriptionSchema, WebhookSubscriptionSetParamsSchema, WebhookSubscriptionUpdateParamsSchema, WebhookSubscriptions, WebhookTriggerPayloadV3Schema, WebhookVersionSchema, WebhookVersions, Webhooks, assertSafeFileUploadPath, constants_exports as constants, createConnectionRequest, deduplicateJsonSchemaRequiredArrays, dereferenceJsonSchema, ensureObjectTypeOnProperties, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit, getExtensionFromMimeType, handleToolExecutionError, isBlockedSensitiveFileUploadPath, isRequestAbortError, jsonSchemaToZodSchema, logger, mappingHasRenames, normalizeToolArguments, omitNullToolArguments, readResponseBodyWithLimit, removeNonRequiredProperties, restoreOriginalKeys, sanitizeSchemaPropertyKeys, telemetry, toStrictJsonSchema };
|
|
11819
|
+
export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAPIKeyKindError, ComposioAclOnlyForSharedError, ComposioAuthConfigNotFoundError, ComposioBlockedInternalUrlError, ComposioConnectedAccountNotFoundError, ComposioConnectedAccountNotRevokableError, ComposioConnectedAccountRevocationNotSupportedError, ComposioCustomCreateResponseSchema, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioFileNotFoundError, ComposioFileUploadAbortedError, ComposioFileUploadError, ComposioFileUploadPathNotAllowedError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioInvalidToolArgumentsError, ComposioLegacyConnectedAccountsEndpointRetiredError, ComposioMCPDestinationError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioRequestCancelledError, ComposioScopeConfigError, ComposioSensitiveFilePathBlockedError, ComposioSessionConfigConflictError, ComposioSharedAccessDeniedError, ComposioSharedConnectionNotAccessibleError, ComposioToolExecutionError, ComposioToolFetchError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAclConfigResponseSchema, ConnectedAccountAclConfigSchema, ConnectedAccountAuthConfigSchema, ConnectedAccountCompleteAuthParamsSchema, ConnectedAccountCompleteAuthResponseSchema, ConnectedAccountErrorCodes, ConnectedAccountExperimentalResponseSchema, ConnectedAccountExperimentalSchema, ConnectedAccountListParamsSchema, ConnectedAccountListResponseSchema, ConnectedAccountRefreshOptionsSchema, ConnectedAccountRetrieveResponseSchema, ConnectedAccountRevokeResponseSchema, ConnectedAccountRevokedTokenSchema, 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, CustomToolkitAuthSchemeSchema, CustomToolkitDeleteResponseSchema, CustomToolkitSyncParamsSchema, CustomToolkitSyncResponseSchema, CustomToolkitUpsertParamsSchema, CustomToolkitUpsertResponseSchema, CustomToolkits, DefaultCreateConnectedAccountParamsSchema, DefaultWebhookSubscriptionEvents, Experimental, FileDeleteResponseSchema, FileListResponseSchema, FileModifierErrorCodes, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, JsonSchemaRefResolutionError, JsonSchemaToZodError, Keyring, KeyringTransferKeySchema, KeyringTransferKeysResponseSchema, LogSearchFilterFieldSchema, LogSearchFilterOperatorSchema, LogSearchFilterSchema, LogSearchParamsSchema, LogSearchResponseSchema, LogSearchTimeRangeSchema, Logs, MAX_URL_UPLOAD_SIZE_BYTES, 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, SessionConfigListParamsSchema, SessionConfigListResponseSchema, SessionConfigPolicySchema, SessionConfigSchema, SessionConfigSummarySchema, SessionConfigs, SessionPreset, SessionProxyExecuteParamsSchema, Sessions, SetWebhookSubscriptionParamsSchema, SingleConnectedAccountDetailedResponseSchema, SsrfErrorCodes, ToolErrorCodes, ToolExecuteMetaParamsSchema, ToolExecuteParamsSchema, ToolExecuteResponseSchema, ToolExecutionLogDetailSchema, ToolExecutionLogLevelSchema, ToolExecutionLogParentSchema, ToolExecutionLogSchema, ToolExecutionLogStatusSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterErrorCodes, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterPremiumUsageSchema, ToolRouterSandboxConfigSchema, ToolRouterSession, ToolRouterSessionDeleteResponseSchema, ToolRouterSessionEnsureConnectedOptionsSchema, ToolRouterSessionExecuteResponseSchema, ToolRouterSessionFilesMountDeleteOptionsSchema, ToolRouterSessionFilesMountDownloadOptionsSchema, ToolRouterSessionFilesMountListOptionsSchema, ToolRouterSessionFilesMountUploadOptionsSchema, ToolRouterSessionListConfigHistoryOptionsSchema, ToolRouterSessionSearchResponseSchema, ToolRouterTagsEnableDisableSchema, ToolRouterTagsParamSchema, ToolRouterToolkitsDisabledConfigSchema, ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsOptionsSchema, ToolRouterToolkitsParamSchema, ToolRouterToolsParamSchema, ToolRouterUpdateExperimentalSchema, ToolRouterUpdateManageConnectionsSchema, ToolRouterUpdateSessionConfigSchema, ToolSchema, ToolkitAuthConfigDetailsSchema, ToolkitAuthFieldSchema, ToolkitAuthFieldsResponseSchema, ToolkitCategorySchema, ToolkitChangelogItemSchema, ToolkitChangelogResponseSchema, ToolkitConditionalScopeSchema, ToolkitConnectionStateSchema, ToolkitConnectionsDetailsSchema, ToolkitErrorCodes, ToolkitGetManySlugsSchema, ToolkitGrantContextDimensionSchema, ToolkitLatestVersionSchema, ToolkitListGrantContextsParamsSchema, ToolkitListGrantContextsResponseSchema, ToolkitMangedByEnumSchema, ToolkitRecommendScopesParamsSchema, ToolkitRecommendScopesResponseSchema, ToolkitRetrieveCategoriesResponseSchema, ToolkitRetrieveResponseSchema, ToolkitSchema, ToolkitSortByEnumSchema, ToolkitVersionChangelogSchema, ToolkitVersionParamSchema, ToolkitVersionSchema, ToolkitVersionsSchema, ToolkitsGetManyParamsSchema, ToolkitsListParamsSchema, TriggerErrorCodes, TriggerInstanceListActiveParamsSchema, TriggerInstanceListActiveResponseItemSchema, TriggerInstanceListActiveResponseSchema, TriggerInstanceManageDeleteResponseSchema, TriggerInstanceManageUpdateParamsSchema, TriggerInstanceManageUpdateResponseSchema, TriggerInstanceUpsertParamsSchema, TriggerInstanceUpsertResponseSchema, TriggerStatusEnum, TriggerStatuses, TriggerSubscribeParamSchema, TriggerTypeSchema, TriggersTypeListParamsSchema, TriggersTypeListResponseSchema, UpdateConnectedAccountAclParamsSchema, UpdateConnectedAccountParamsSchema, Usage, UsageBreakdownGroupSchema, UsageBreakdownParamsSchema, UsageBreakdownResponseSchema, UsageEntitySummarySchema, UsageFiltersSchema, UsageOrderBySchema, UsageOrderDirectionSchema, UsageSummaryParamsSchema, UsageSummaryResponseSchema, ValidationError, ValidationErrorCodes, VerifyWebhookParamsSchema, WebhookConnectedAccountAuthConfigSchema, WebhookConnectionMetadataSchema, WebhookConnectionStateSchema, WebhookEndpointCreateParamsSchema, WebhookEndpointListItemSchema, WebhookEndpointListParamsSchema, WebhookEndpointListResponseSchema, WebhookEndpointReplaceParamsSchema, WebhookEndpointSchema, WebhookEndpointUpdateParamsSchema, WebhookEndpoints, WebhookEventSchema, WebhookEventTypes, WebhookPayloadSchema, WebhookPayloadV1Schema, WebhookPayloadV2Schema, WebhookPayloadV3Schema, WebhookSubscriptionDeleteResponseSchema, WebhookSubscriptionEventTypeSchema, WebhookSubscriptionEventTypesResponseSchema, WebhookSubscriptionListParamsSchema, WebhookSubscriptionListResponseSchema, WebhookSubscriptionRotateSecretResponseSchema, WebhookSubscriptionSchema, WebhookSubscriptionSetParamsSchema, WebhookSubscriptionUpdateParamsSchema, WebhookSubscriptions, WebhookTriggerPayloadV3Schema, WebhookVersionSchema, WebhookVersions, Webhooks, assertSafeFileUploadPath, constants_exports as constants, createConnectionRequest, deduplicateJsonSchemaRequiredArrays, dereferenceJsonSchema, ensureObjectTypeOnProperties, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit, getExtensionFromMimeType, handleToolExecutionError, isBlockedSensitiveFileUploadPath, isRequestAbortError, jsonSchemaToZodSchema, logger, mappingHasRenames, normalizeToolArguments, omitNullToolArguments, readResponseBodyWithLimit, removeNonRequiredProperties, restoreOriginalKeys, sanitizeSchemaPropertyKeys, telemetry, toStrictJsonSchema };
|