@composio/core 0.22.0 → 0.23.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-CKBCElpT.d.mts → CustomTool-CnHdegDK.d.mts} +1 -1
- package/dist/{CustomTool-B-_VjWpy.mjs → CustomTool-CnJxXr07.mjs} +1 -1
- package/dist/{cancellation-DV8CIi52.mjs → cancellation-BQibgpRG.mjs} +166 -34
- package/dist/{composio-C-418N1P.d.mts → composio-Dq708dZS.d.mts} +2 -20
- package/dist/{customTool.types-CK408sI-.d.mts → customTool.types-B8lVpHOP.d.mts} +21 -64
- package/dist/docs/reference/sdk-reference/typescript/logs.mdx +4 -4
- package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +1 -1
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +2 -2
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +2 -2
- package/dist/docs/reference/sdk-reference/typescript/usage.mdx +2 -2
- package/dist/{errors-Dyiu3ifQ.mjs → errors-BN15NcCW.mjs} +34 -2
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/index.d.mts +45 -4
- package/dist/index.mjs +1589 -1448
- package/dist/platform/node.d.mts +1 -1
- package/dist/platform/node.mjs +13 -0
- package/dist/platform/workerd.d.mts +1 -1
- package/dist/platform/workerd.mjs +3 -0
- package/dist/{types-D5A2wzBl.d.mts → types-DuVZKrXO.d.mts} +2 -0
- package/dist/{types-RpMRVn4D.d.mts → types-eTw8Yw7Y.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 +7 -4
- package/src/errors/ToolRouterErrors.ts +65 -0
- package/src/lib/toolRouterParams.ts +4 -14
- package/src/models/CustomToolkits.ts +1 -1
- package/src/models/RemoteFile.ts +24 -5
- package/src/models/SessionContext.ts +24 -4
- package/src/models/ToolRouter.ts +2 -4
- package/src/models/ToolRouterSession.ts +44 -13
- package/src/models/Tools.ts +20 -36
- package/src/models/customToolExecution.ts +10 -0
- package/src/platform/node.ts +16 -0
- package/src/platform/types.ts +3 -0
- package/src/platform/workerd.ts +4 -0
- package/src/provider/BaseProvider.ts +2 -1
- package/src/types/tool.types.ts +5 -0
- package/src/types/toolRouter.types.ts +10 -24
- package/src/utils/jsonSchema.ts +191 -36
- package/src/utils/retries.ts +20 -0
- package/src/utils/safePath.ts +135 -54
- package/src/utils/session.ts +31 -2
- package/src/utils/transformers/toolRouterResponseTransform.ts +64 -25
- package/src/utils/transformers/usage.ts +1 -4
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
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
|
|
2
|
+
import { $ as ComposioAuthConfigNotFoundError, A as ComposioInvalidModifierError, B as ConnectionRequestFailedError, C as ValidationError, D as ToolkitErrorCodes, E as ComposioToolkitNotFoundError, F as ComposioToolNotFoundError, G as ComposioConnectedAccountRevocationNotSupportedError, H as ComposioAclOnlyForSharedError, I as ComposioToolVersionRequiredError, J as ComposioMultipleConnectedAccountsError, K as ComposioFailedToCreateConnectedAccountLink, L as ToolErrorCodes, M as ComposioProviderNotDefinedError, N as ComposioToolExecutionError, O as ComposioGlobalExecuteToolFnNotSetError, P as ComposioToolFetchError, Q as AuthConfigErrorCodes, R as handleToolExecutionError, S as JsonSchemaToZodError, T as ComposioToolkitFetchError, U as ComposioConnectedAccountNotFoundError, V as ConnectionRequestTimeoutError, W as ComposioConnectedAccountNotRevokableError, X as ComposioSharedConnectionNotAccessibleError, Y as ComposioSharedAccessDeniedError, Z as ConnectedAccountErrorCodes, _ as ComposioRequestCancelledError, a as RemoteFileDownloadError, b as isRequestAbortError, c as ComposioFailedToGetSDKRealtimeCredentialsError, d as ComposioTriggerTypeNotFoundError, f as ComposioWebhookPayloadError, g as ComposioNoAPIKeyError, h as ComposioAPIKeyKindError, i as ToolRouterErrorCodes, j as ComposioInvalidToolArgumentsError, k as ComposioInvalidExecuteFunctionError, l as ComposioFailedToSubscribeToPusherChannelError, m as TriggerErrorCodes, n as ComposioSessionConfigConflictError, o as RemoteFileErrorCodes, p as ComposioWebhookSignatureVerificationError, q as ComposioLegacyConnectedAccountsEndpointRetiredError, r as ComposioToolInputRequiredError, s as ComposioFailedToCreatePusherClientError, t as ComposioMCPDestinationError, u as ComposioFailedToUnsubscribeFromPusherChannelError, v as ComposioScopeConfigError, w as ValidationErrorCodes, x as JsonSchemaRefResolutionError, y as SDKErrorCodes, z as ConnectionRequestErrorCodes } from "./errors-BN15NcCW.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-BQibgpRG.mjs";
|
|
6
6
|
import { t as telemetry } from "./Telemetry-41JkqpZ7.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-
|
|
9
|
-
import ComposioClient, { APIError, BadRequestError, ConflictError } from "@composio/client";
|
|
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-CnJxXr07.mjs";
|
|
9
|
+
import ComposioClient, { APIError, BadRequestError, ConflictError, VERSION } from "@composio/client";
|
|
10
10
|
import { FileToolModifier } from "#file_tool_modifier";
|
|
11
11
|
import z, { z as z$1 } from "zod/v3";
|
|
12
12
|
import { CONFIG_DEFAULTS } from "#config_defaults";
|
|
13
13
|
import { platform } from "#platform";
|
|
14
14
|
import semver from "semver";
|
|
15
15
|
import { Files } from "#files";
|
|
16
|
+
import identity from "#client_identity" with { type: "json" };
|
|
17
|
+
import { z as z$2 } from "zod";
|
|
16
18
|
import { ssrfSafeFetch, ssrfSafeFetchWhereSupported } from "#ssrf_guard";
|
|
17
19
|
|
|
18
20
|
//#region src/types/authConfigs.types.ts
|
|
@@ -1069,6 +1071,11 @@ const ToolProxyParamsSchema = z$1.object({
|
|
|
1069
1071
|
})).optional(),
|
|
1070
1072
|
connectedAccountId: z$1.string().optional(),
|
|
1071
1073
|
/**
|
|
1074
|
+
* The user the connected account belongs to. Projects with 2FA enabled check it
|
|
1075
|
+
* against the connected account, and require it for orgs created on or after
|
|
1076
|
+
*/
|
|
1077
|
+
userId: z$1.string().optional(),
|
|
1078
|
+
/**
|
|
1072
1079
|
* @deprecated
|
|
1073
1080
|
*/
|
|
1074
1081
|
customConnectionData: CustomConnectionDataSchema.describe("DEPRECATED: This field is deprecated and will be removed in the future.").optional()
|
|
@@ -1182,1029 +1189,344 @@ function resolveEffectiveUploadAllowlist(userDirs) {
|
|
|
1182
1189
|
}
|
|
1183
1190
|
|
|
1184
1191
|
//#endregion
|
|
1185
|
-
//#region src/
|
|
1186
|
-
/**
|
|
1187
|
-
* Connected Account create parameters
|
|
1188
|
-
*/
|
|
1189
|
-
const ConnectedAccountStatuses = {
|
|
1190
|
-
INITIALIZING: "INITIALIZING",
|
|
1191
|
-
INITIATED: "INITIATED",
|
|
1192
|
-
ACTIVE: "ACTIVE",
|
|
1193
|
-
FAILED: "FAILED",
|
|
1194
|
-
EXPIRED: "EXPIRED",
|
|
1195
|
-
INACTIVE: "INACTIVE",
|
|
1196
|
-
REVOKED: "REVOKED"
|
|
1197
|
-
};
|
|
1198
|
-
const ConnectedAccountStatusSchema = z$1.enum([
|
|
1199
|
-
ConnectedAccountStatuses.INITIALIZING,
|
|
1200
|
-
ConnectedAccountStatuses.INITIATED,
|
|
1201
|
-
ConnectedAccountStatuses.ACTIVE,
|
|
1202
|
-
ConnectedAccountStatuses.FAILED,
|
|
1203
|
-
ConnectedAccountStatuses.EXPIRED,
|
|
1204
|
-
ConnectedAccountStatuses.INACTIVE,
|
|
1205
|
-
ConnectedAccountStatuses.REVOKED
|
|
1206
|
-
]);
|
|
1192
|
+
//#region src/utils/retries.ts
|
|
1207
1193
|
/**
|
|
1208
|
-
*
|
|
1194
|
+
* Request options for a call that executes a tool or proxies an API call: the
|
|
1195
|
+
* caller's options with retries disabled.
|
|
1209
1196
|
*
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1197
|
+
* These calls are non-idempotent writes. The client retries timeouts,
|
|
1198
|
+
* connection errors, and 408/409/429/5xx responses by default, and a retry
|
|
1199
|
+
* after the backend already acted duplicates the side effect (e.g. sends the
|
|
1200
|
+
* same email twice). The backend does not deduplicate executions, so every
|
|
1201
|
+
* execution path must go through this helper. Reads keep the default retries.
|
|
1202
|
+
* See https://github.com/ComposioHQ/composio/issues/3654.
|
|
1203
|
+
*
|
|
1204
|
+
* @internal
|
|
1215
1205
|
*/
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1206
|
+
function withoutRetries(requestOptions) {
|
|
1207
|
+
return {
|
|
1208
|
+
...requestOptions,
|
|
1209
|
+
maxRetries: 0
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
//#endregion
|
|
1214
|
+
//#region src/utils/transformers/toolRouterResponseTransform.ts
|
|
1215
|
+
/** The `result_type` values of a call that ran. `input_required` is raised before this is read. */
|
|
1216
|
+
const ExecutedResponseSchema = z.object({ result_type: z.enum(["completed", "failed"]) });
|
|
1221
1217
|
/**
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
*
|
|
1225
|
-
* Pass `aclConfigForShared` on create / PATCH to grant access; omit it
|
|
1226
|
-
* to leave the ACL unchanged (on PATCH) or to keep the default
|
|
1227
|
-
* deny-by-default state (on create). On responses, the field is
|
|
1228
|
-
* `undefined` when the caller isn't authorised to see the ACL —
|
|
1229
|
-
* distinguish that from an empty/default state explicitly.
|
|
1230
|
-
*
|
|
1231
|
-
* Resolution rule (deny wins):
|
|
1232
|
-
* 1. requesting `userId` in `notAllowedUserIds` → DENY
|
|
1233
|
-
* 2. `allowAllUsers === true` → ALLOW
|
|
1234
|
-
* 3. requesting `userId` in `allowedUserIds` → ALLOW
|
|
1235
|
-
* 4. otherwise → DENY (deny-by-default)
|
|
1236
|
-
*
|
|
1237
|
-
* Default state (block omitted or `{}`) means only the connection's
|
|
1238
|
-
* creator can use it. The creator must grant access explicitly.
|
|
1239
|
-
*
|
|
1240
|
-
* Limits: each list accepts up to 1000 entries; each `userId` is
|
|
1241
|
-
* 1..256 characters.
|
|
1218
|
+
* Whether a session tool execution succeeded. `resultType` decides: a `failed`
|
|
1219
|
+
* execution is not successful even when its `error` is `null` or empty.
|
|
1242
1220
|
*/
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
allowAllUsers: z$1.boolean().optional().describe("When true, any `userId` may use this SHARED connection (subject to the deny list). Default false."),
|
|
1247
|
-
allowedUserIds: z$1.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings allowed to use this SHARED connection. Default []."),
|
|
1248
|
-
notAllowedUserIds: z$1.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings denied access. Wins over allow on conflict. Default [].")
|
|
1249
|
-
});
|
|
1221
|
+
function isExecutionSuccessful(result) {
|
|
1222
|
+
return result.resultType === "completed";
|
|
1223
|
+
}
|
|
1250
1224
|
/**
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1225
|
+
* Narrows an execute-family response to the variants that carry a result.
|
|
1226
|
+
* `input_required` means the call did not run: it is raised as a
|
|
1227
|
+
* {@link ComposioToolInputRequiredError} instead of being returned as a result
|
|
1228
|
+
* it is not.
|
|
1229
|
+
*/
|
|
1230
|
+
function assertNotInputRequired(raw, subject) {
|
|
1231
|
+
if (raw.result_type !== "input_required") return;
|
|
1232
|
+
throw new ComposioToolInputRequiredError(subject, {
|
|
1233
|
+
inputRequests: Object.fromEntries(Object.entries(raw.input_requests).map(([id, request]) => [id, {
|
|
1234
|
+
type: request.type,
|
|
1235
|
+
mode: request.mode,
|
|
1236
|
+
message: request.message,
|
|
1237
|
+
requestedSchema: request.requested_schema
|
|
1238
|
+
}])),
|
|
1239
|
+
requestState: raw.request_state
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
function transformSearchResult(raw) {
|
|
1243
|
+
return {
|
|
1244
|
+
index: raw.index,
|
|
1245
|
+
useCase: raw.use_case,
|
|
1246
|
+
primaryToolSlugs: raw.primary_tool_slugs,
|
|
1247
|
+
relatedToolSlugs: raw.related_tool_slugs,
|
|
1248
|
+
toolkits: raw.toolkits,
|
|
1249
|
+
difficulty: raw.difficulty,
|
|
1250
|
+
error: raw.error,
|
|
1251
|
+
executionGuidance: raw.execution_guidance,
|
|
1252
|
+
knownPitfalls: raw.known_pitfalls,
|
|
1253
|
+
memory: raw.memory,
|
|
1254
|
+
planId: raw.plan_id,
|
|
1255
|
+
recommendedPlanSteps: raw.recommended_plan_steps,
|
|
1256
|
+
referenceWorkbenchSnippets: raw.reference_workbench_snippets
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
function transformToolSchema(raw) {
|
|
1260
|
+
return {
|
|
1261
|
+
toolSlug: raw.tool_slug,
|
|
1262
|
+
toolkit: raw.toolkit,
|
|
1263
|
+
description: raw.description,
|
|
1264
|
+
hasFullSchema: raw.hasFullSchema,
|
|
1265
|
+
inputSchema: raw.input_schema,
|
|
1266
|
+
outputSchema: raw.output_schema,
|
|
1267
|
+
schemaRef: raw.schemaRef ? {
|
|
1268
|
+
args: { toolSlugs: raw.schemaRef.args.tool_slugs },
|
|
1269
|
+
message: raw.schemaRef.message,
|
|
1270
|
+
tool: raw.schemaRef.tool
|
|
1271
|
+
} : void 0
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
function transformToolkitConnectionStatus(raw) {
|
|
1275
|
+
return {
|
|
1276
|
+
toolkit: raw.toolkit,
|
|
1277
|
+
description: raw.description,
|
|
1278
|
+
hasActiveConnection: raw.has_active_connection,
|
|
1279
|
+
statusMessage: raw.status_message,
|
|
1280
|
+
connectionDetails: raw.connection_details,
|
|
1281
|
+
currentUserInfo: raw.current_user_info,
|
|
1282
|
+
...raw.instant_account !== void 0 && { instantAccount: { allowedToolSlugs: raw.instant_account.allowed_tool_slugs } }
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Transforms a raw session search API response to camelCase.
|
|
1254
1287
|
*/
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1288
|
+
function transformSearchResponse(raw) {
|
|
1289
|
+
const toolSchemas = {};
|
|
1290
|
+
for (const [slug, schema] of Object.entries(raw.tool_schemas)) toolSchemas[slug] = transformToolSchema(schema);
|
|
1291
|
+
return {
|
|
1292
|
+
success: raw.success,
|
|
1293
|
+
error: raw.error,
|
|
1294
|
+
results: raw.results.map(transformSearchResult),
|
|
1295
|
+
toolSchemas,
|
|
1296
|
+
toolkitConnectionStatuses: raw.toolkit_connection_statuses.map(transformToolkitConnectionStatus),
|
|
1297
|
+
nextStepsGuidance: raw.next_steps_guidance,
|
|
1298
|
+
session: {
|
|
1299
|
+
id: raw.session.id,
|
|
1300
|
+
generateId: raw.session.generate_id,
|
|
1301
|
+
instructions: raw.session.instructions
|
|
1302
|
+
},
|
|
1303
|
+
timeInfo: {
|
|
1304
|
+
currentTimeUtc: raw.time_info.current_time_utc,
|
|
1305
|
+
currentTimeUtcEpochSeconds: raw.time_info.current_time_utc_epoch_seconds,
|
|
1306
|
+
message: raw.time_info.message
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1260
1310
|
/**
|
|
1261
|
-
*
|
|
1311
|
+
* Transforms a raw session execute API response to camelCase.
|
|
1262
1312
|
*
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1265
|
-
* experimental status is visible at every call site.
|
|
1313
|
+
* @throws {ComposioToolInputRequiredError} If the tool asked for user input instead of running
|
|
1314
|
+
* @throws {ValidationError} If the response carries no `result_type`, or one this SDK does not know
|
|
1266
1315
|
*/
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
});
|
|
1316
|
+
function transformExecuteResponse(raw, toolSlug) {
|
|
1317
|
+
assertNotInputRequired(raw, `Tool ${toolSlug}`);
|
|
1318
|
+
const executed = ExecutedResponseSchema.safeParse(raw);
|
|
1319
|
+
if (!executed.success) throw new ValidationError(`Tool ${toolSlug} returned an execute response without a known result_type`, { cause: executed.error });
|
|
1320
|
+
return {
|
|
1321
|
+
data: raw.data,
|
|
1322
|
+
error: raw.error,
|
|
1323
|
+
logId: raw.log_id,
|
|
1324
|
+
resultType: executed.data.result_type,
|
|
1325
|
+
...raw.instant_charge !== void 0 && { instantCharge: raw.instant_charge }
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
//#endregion
|
|
1330
|
+
//#region src/models/Tools.ts
|
|
1331
|
+
const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
|
|
1271
1332
|
/**
|
|
1272
|
-
*
|
|
1273
|
-
*
|
|
1274
|
-
*
|
|
1333
|
+
* Normalize a raw `input_parameters` / `output_parameters` payload returned by
|
|
1334
|
+
* the Composio API. Maps `null`, `undefined`, and empty `{}` — all of which
|
|
1335
|
+
* mean "no declared schema" — to `undefined` so the strict `ParametersSchema`
|
|
1336
|
+
* validator never sees them. Non-empty objects pass through unchanged and
|
|
1337
|
+
* remain subject to strict Zod validation.
|
|
1338
|
+
*
|
|
1339
|
+
* MCP-backed toolkits (granola_mcp, apify_mcp, tavily_mcp, …) have no
|
|
1340
|
+
* declared output schema and the API serializes that as `{}`, which would
|
|
1341
|
+
* otherwise trip `ParametersSchema`. See
|
|
1342
|
+
* https://github.com/ComposioHQ/composio/issues/3354.
|
|
1275
1343
|
*/
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
}
|
|
1280
|
-
const CreateConnectedAccountParamsSchema = z$1.object({
|
|
1281
|
-
authConfig: z$1.object({ id: z$1.string() }),
|
|
1282
|
-
connection: z$1.object({
|
|
1283
|
-
data: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1284
|
-
callbackUrl: z$1.string().optional(),
|
|
1285
|
-
userId: z$1.string().optional()
|
|
1286
|
-
})
|
|
1287
|
-
});
|
|
1288
|
-
const DefaultCreateConnectedAccountParamsSchema = z$1.object({
|
|
1289
|
-
auth_config: z$1.object({ id: z$1.string() }),
|
|
1290
|
-
connection: z$1.object({
|
|
1291
|
-
state: ConnectionDataSchema.optional(),
|
|
1292
|
-
data: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1293
|
-
callback_url: z$1.string().optional(),
|
|
1294
|
-
user_id: z$1.string().optional(),
|
|
1295
|
-
alias: z$1.string().optional()
|
|
1296
|
-
})
|
|
1297
|
-
});
|
|
1298
|
-
const CreateConnectedAccountOptionsSchema = z$1.object({
|
|
1299
|
-
allowMultiple: z$1.boolean().optional(),
|
|
1300
|
-
callbackUrl: z$1.string().optional(),
|
|
1301
|
-
config: ConnectionDataSchema.optional(),
|
|
1302
|
-
alias: z$1.string().optional()
|
|
1303
|
-
});
|
|
1344
|
+
function normalizeRawToolParameters(params) {
|
|
1345
|
+
if (params == null || Object.keys(params).length === 0) return void 0;
|
|
1346
|
+
return params;
|
|
1347
|
+
}
|
|
1304
1348
|
/**
|
|
1305
|
-
*
|
|
1349
|
+
* This class is used to manage tools in the Composio SDK.
|
|
1350
|
+
* It provides methods to list, get, and execute tools.
|
|
1306
1351
|
*/
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
id: z$1.string(),
|
|
1314
|
-
/** @deprecated Use `connectedAccount.state.authScheme` instead. */
|
|
1315
|
-
authScheme: AuthSchemeEnum.optional(),
|
|
1316
|
-
isComposioManaged: z$1.boolean(),
|
|
1317
|
-
isDisabled: z$1.boolean()
|
|
1318
|
-
});
|
|
1319
|
-
const ConnectedAccountRetrieveResponseSchema = z$1.object({
|
|
1320
|
-
id: z$1.string(),
|
|
1321
|
-
authConfig: ConnectedAccountAuthConfigSchema,
|
|
1322
|
-
wordId: z$1.string().nullable().optional(),
|
|
1323
|
-
alias: z$1.string().nullable().optional(),
|
|
1324
|
-
/**
|
|
1325
|
-
* @deprecated Use `connectedAccount.state` instead — `data` is a legacy raw credential field.
|
|
1326
|
-
*/
|
|
1327
|
-
data: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1352
|
+
var Tools = class {
|
|
1353
|
+
client;
|
|
1354
|
+
provider;
|
|
1355
|
+
autoUploadDownloadFiles;
|
|
1356
|
+
toolkitVersions;
|
|
1357
|
+
fileUploadPathOptions;
|
|
1328
1358
|
/**
|
|
1329
|
-
*
|
|
1359
|
+
* Tracks tool slugs we've already warned about to avoid spamming the log when
|
|
1360
|
+
* the same file-input tool is executed repeatedly while auto-upload is off.
|
|
1361
|
+
* Scoped per-instance so a fresh `Composio` starts with a clean slate.
|
|
1330
1362
|
*/
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1363
|
+
warnedAutoUploadDisabledForTool = /* @__PURE__ */ new Set();
|
|
1364
|
+
constructor(client, config) {
|
|
1365
|
+
if (!client) throw new Error("ComposioClient is required");
|
|
1366
|
+
if (!config?.provider) throw new ComposioProviderNotDefinedError("Provider not passed into Tools instance");
|
|
1367
|
+
this.client = client;
|
|
1368
|
+
this.provider = config.provider;
|
|
1369
|
+
this.autoUploadDownloadFiles = config?.dangerouslyAllowAutoUploadDownloadFiles === true;
|
|
1370
|
+
this.toolkitVersions = config?.toolkitVersions ?? CONFIG_DEFAULTS.toolkitVersions;
|
|
1371
|
+
this.fileUploadPathOptions = {
|
|
1372
|
+
sensitiveFileUploadProtection: config?.sensitiveFileUploadProtection,
|
|
1373
|
+
fileUploadPathDenySegments: config?.fileUploadPathDenySegments,
|
|
1374
|
+
fileUploadAllowlist: this.autoUploadDownloadFiles ? resolveEffectiveUploadAllowlist(config?.fileUploadDirs) : void 0,
|
|
1375
|
+
fileDownloadDir: config?.fileDownloadDir
|
|
1376
|
+
};
|
|
1377
|
+
this.execute = this.execute.bind(this);
|
|
1378
|
+
this.provider._setExecuteToolFn(this.createExecuteFnForProviders());
|
|
1379
|
+
this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
|
|
1380
|
+
this.getRawComposioTools = this.getRawComposioTools.bind(this);
|
|
1381
|
+
telemetry.instrument(this, "Tools");
|
|
1382
|
+
}
|
|
1350
1383
|
/**
|
|
1351
|
-
*
|
|
1352
|
-
*
|
|
1353
|
-
*
|
|
1354
|
-
*
|
|
1384
|
+
* Transforms tool data from snake_case API format to camelCase for internal SDK use.
|
|
1385
|
+
*
|
|
1386
|
+
* This method standardizes the property naming convention for tools retrieved from the Composio API,
|
|
1387
|
+
* making them more consistent with JavaScript/TypeScript conventions.
|
|
1388
|
+
*
|
|
1389
|
+
* @param {ToolRetrieveResponse | ComposioToolListResponse['items'][0]} tool - The tool object to transform
|
|
1390
|
+
* @returns {Tool} The transformed tool with camelCase properties
|
|
1391
|
+
*
|
|
1392
|
+
* @private
|
|
1355
1393
|
*/
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
});
|
|
1367
|
-
const CreateConnectedAccountLinkOptionsSchema = z$1.object({
|
|
1394
|
+
transformToolCases(tool) {
|
|
1395
|
+
return ToolSchema.parse({
|
|
1396
|
+
...tool,
|
|
1397
|
+
inputParameters: normalizeRawToolParameters(tool.input_parameters),
|
|
1398
|
+
outputParameters: normalizeRawToolParameters(tool.output_parameters),
|
|
1399
|
+
availableVersions: tool.available_versions,
|
|
1400
|
+
isDeprecated: tool.deprecated?.is_deprecated ?? false,
|
|
1401
|
+
isNoAuth: tool.no_auth
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1368
1404
|
/**
|
|
1369
|
-
*
|
|
1405
|
+
* Transforms tool execution response from snake_case API format to camelCase.
|
|
1370
1406
|
*
|
|
1371
|
-
*
|
|
1372
|
-
*
|
|
1407
|
+
* This method converts the response received from the Composio API to a standardized format
|
|
1408
|
+
* with consistent property naming that follows JavaScript/TypeScript conventions.
|
|
1373
1409
|
*
|
|
1374
|
-
* @
|
|
1410
|
+
* @param {ComposioToolExecuteResponse} response - The raw API response to transform
|
|
1411
|
+
* @returns {ToolExecuteResponse} The transformed response with camelCase properties
|
|
1375
1412
|
*
|
|
1413
|
+
* @private
|
|
1376
1414
|
*/
|
|
1377
|
-
|
|
1415
|
+
transformToolExecuteResponse(response) {
|
|
1416
|
+
return ToolExecuteResponseSchema.parse({
|
|
1417
|
+
data: response.data,
|
|
1418
|
+
error: response.error,
|
|
1419
|
+
successful: response.successful,
|
|
1420
|
+
logId: response.log_id,
|
|
1421
|
+
sessionInfo: response.session_info
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1378
1424
|
/**
|
|
1379
|
-
*
|
|
1425
|
+
* Applies the default schema modifiers to the tools.
|
|
1426
|
+
*
|
|
1427
|
+
* The `file_uploadable` transform (collapsing the backend's internal
|
|
1428
|
+
* `{ name, mimetype, s3key }` staging shape to `{ type: 'string',
|
|
1429
|
+
* format: 'path' }`) is **gated on `dangerouslyAllowAutoUploadDownloadFiles`**
|
|
1430
|
+
* — the collapsed shape is a promise that the SDK will stage local paths
|
|
1431
|
+
* on your behalf at execute time, and that's only true when the flag is on.
|
|
1432
|
+
*
|
|
1433
|
+
* When the flag is off, the raw schema is returned unchanged; callers are
|
|
1434
|
+
* expected to stage files themselves via `composio.files.upload()` and pass
|
|
1435
|
+
* the resulting descriptor into `tools.execute`. If an LLM ends up calling
|
|
1436
|
+
* a file-uploadable tool in this mode, the execute path emits a one-shot
|
|
1437
|
+
* warning per tool slug (see `applyBeforeExecuteModifiers`).
|
|
1438
|
+
*
|
|
1439
|
+
* @param tools - The tools to apply the default schema modifiers to
|
|
1440
|
+
* @returns The tools with the default schema modifiers applied
|
|
1380
1441
|
*/
|
|
1381
|
-
|
|
1442
|
+
async applyDefaultSchemaModifiers(tools) {
|
|
1443
|
+
if (!this.autoUploadDownloadFiles) return tools;
|
|
1444
|
+
const fileToolModifier = new FileToolModifier(this.client, this.fileUploadPathOptions);
|
|
1445
|
+
return await Promise.all(tools.map((tool) => fileToolModifier.modifyToolSchema(tool)));
|
|
1446
|
+
}
|
|
1382
1447
|
/**
|
|
1383
|
-
*
|
|
1384
|
-
*
|
|
1385
|
-
*
|
|
1386
|
-
*
|
|
1387
|
-
*
|
|
1448
|
+
* Applies the before execute modifiers to the tool execution params
|
|
1449
|
+
* @param options.toolSlug - The slug of the tool
|
|
1450
|
+
* @param options.toolkitSlug - The slug of the toolkit
|
|
1451
|
+
* @param options.params - The params of the tool execution
|
|
1452
|
+
* @param modifier - The modifier to apply
|
|
1453
|
+
* @returns The modified params
|
|
1388
1454
|
*/
|
|
1389
|
-
|
|
1455
|
+
async applyBeforeExecuteModifiers(tool, { toolSlug, toolkitSlug, params }, modifiers, requestOptions) {
|
|
1456
|
+
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
1457
|
+
let modifiedParams = await this.applyFileUploadModifiers(tool, {
|
|
1458
|
+
toolSlug,
|
|
1459
|
+
toolkitSlug,
|
|
1460
|
+
params
|
|
1461
|
+
}, modifiers?.beforeFileUpload, requestOptions);
|
|
1462
|
+
if (modifiers?.beforeExecute) {
|
|
1463
|
+
if (typeof modifiers.beforeExecute === "function") {
|
|
1464
|
+
modifiedParams = await modifiers.beforeExecute({
|
|
1465
|
+
toolSlug,
|
|
1466
|
+
toolkitSlug,
|
|
1467
|
+
params: modifiedParams
|
|
1468
|
+
});
|
|
1469
|
+
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
1470
|
+
} else throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
|
|
1471
|
+
}
|
|
1472
|
+
return modifiedParams;
|
|
1473
|
+
}
|
|
1390
1474
|
/**
|
|
1391
|
-
*
|
|
1392
|
-
*
|
|
1393
|
-
*
|
|
1394
|
-
*
|
|
1395
|
-
* Experimental — shape may change in future releases.
|
|
1396
|
-
*
|
|
1397
|
-
* `aclConfigForShared` is only valid when `accountType === 'SHARED'`;
|
|
1398
|
-
* raises `ComposioAclOnlyForSharedError` on a PRIVATE connection. Omit
|
|
1399
|
-
* the inner block (or pass `{}`) to keep the deny-by-default state: only
|
|
1400
|
-
* the creator can use the connection. Grant access by setting
|
|
1401
|
-
* `allowAllUsers: true` or listing user IDs in `allowedUserIds`.
|
|
1402
|
-
* `notAllowedUserIds` always wins over allow.
|
|
1475
|
+
* Applies schema-aware file preprocessing shared by direct and Tool Router
|
|
1476
|
+
* session execution. This always runs before the caller's `beforeExecute`
|
|
1477
|
+
* hook so the hook observes the exact arguments sent to the backend.
|
|
1403
1478
|
*/
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1479
|
+
async applyFileUploadModifiers(tool, { toolSlug, toolkitSlug, params }, beforeFileUpload, requestOptions) {
|
|
1480
|
+
let modifiedParams = params;
|
|
1481
|
+
if (this.autoUploadDownloadFiles) {
|
|
1482
|
+
modifiedParams = await new FileToolModifier(this.client, {
|
|
1483
|
+
...this.fileUploadPathOptions,
|
|
1484
|
+
beforeFileUpload
|
|
1485
|
+
}).fileUploadModifier(tool, {
|
|
1486
|
+
toolSlug,
|
|
1487
|
+
toolkitSlug,
|
|
1488
|
+
params: modifiedParams,
|
|
1489
|
+
signal: requestOptions?.signal
|
|
1490
|
+
});
|
|
1491
|
+
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
1492
|
+
} else if (tool.inputParameters && schemaHasFileUploadable(tool.inputParameters)) {
|
|
1493
|
+
if (modifiedParams.arguments) modifiedParams = {
|
|
1494
|
+
...modifiedParams,
|
|
1495
|
+
arguments: await dropEmptyFileUploads(modifiedParams.arguments, dereferenceJsonSchema(tool.inputParameters, { onUnresolved: "sentinel" }))
|
|
1496
|
+
};
|
|
1497
|
+
if (!this.warnedAutoUploadDisabledForTool.has(toolSlug)) {
|
|
1498
|
+
this.warnedAutoUploadDisabledForTool.add(toolSlug);
|
|
1499
|
+
logger.warn(`Tool "${toolSlug}" (toolkit "${toolkitSlug}") has a file-uploadable input, but \`dangerouslyAllowAutoUploadDownloadFiles\` is disabled. The SDK will forward the file argument as-is; if it isn't already a staged { name, mimetype, s3key } descriptor, the backend will reject the call. Either:\n 1) Stage the file yourself: \`const f = await composio.files.upload({ file, toolSlug, toolkitSlug }); await composio.tools.execute('${toolSlug}', { userId, arguments: { <fileField>: f } })\`, or\n 2) Enable auto-upload with a scoped allowlist: \`new Composio({ dangerouslyAllowAutoUploadDownloadFiles: true, fileUploadDirs: ['/safe/dir'] })\`.`);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
return modifiedParams;
|
|
1503
|
+
}
|
|
1409
1504
|
/**
|
|
1410
|
-
*
|
|
1411
|
-
*
|
|
1505
|
+
* Applies the after execute modifiers to the tool execution result
|
|
1506
|
+
* @param options.toolSlug - The slug of the tool
|
|
1507
|
+
* @param options.toolkitSlug - The slug of the toolkit
|
|
1508
|
+
* @param options.result - The result of the tool execution
|
|
1509
|
+
* @param modifier - The modifier to apply
|
|
1510
|
+
* @returns The modified result
|
|
1412
1511
|
*/
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
*/
|
|
1432
|
-
const ConnectedAccountRevokedTokenSchema = z$1.enum([
|
|
1433
|
-
"access_token",
|
|
1434
|
-
"refresh_token",
|
|
1435
|
-
"credential"
|
|
1436
|
-
]);
|
|
1437
|
-
const ConnectedAccountRevokeResponseSchema = z$1.object({
|
|
1438
|
-
/**
|
|
1439
|
-
* Tokens revoked at the provider on this call. An empty array means the
|
|
1440
|
-
* connection was already revoked (no upstream dispatch).
|
|
1441
|
-
*/
|
|
1442
|
-
revokedTokens: z$1.array(ConnectedAccountRevokedTokenSchema),
|
|
1443
|
-
connectedAccount: z$1.object({
|
|
1444
|
-
id: z$1.string(),
|
|
1445
|
-
/** The connection status after this call (`REVOKED` on success). */
|
|
1446
|
-
status: ConnectedAccountStatusSchema
|
|
1447
|
-
})
|
|
1448
|
-
});
|
|
1449
|
-
/**
|
|
1450
|
-
* Params for `composio.connectedAccounts.completeAuth()`.
|
|
1451
|
-
*/
|
|
1452
|
-
const ConnectedAccountCompleteAuthParamsSchema = z$1.object({
|
|
1453
|
-
/** The user the connection was initiated for. Must match the connection owner. */
|
|
1454
|
-
userId: z$1.string().min(1),
|
|
1455
|
-
/** The opaque, single-use session URI your OAuth callback verifier received. */
|
|
1456
|
-
sessionUri: z$1.string().min(1)
|
|
1457
|
-
});
|
|
1458
|
-
/**
|
|
1459
|
-
* Response of `composio.connectedAccounts.completeAuth()`.
|
|
1460
|
-
*/
|
|
1461
|
-
const ConnectedAccountCompleteAuthResponseSchema = z$1.object({
|
|
1462
|
-
/** The connection that was completed; it is now `ACTIVE`. */
|
|
1463
|
-
connectedAccountId: z$1.string(),
|
|
1464
|
-
/** The toolkit the connection belongs to. */
|
|
1465
|
-
toolkitSlug: z$1.string()
|
|
1466
|
-
});
|
|
1467
|
-
|
|
1468
|
-
//#endregion
|
|
1469
|
-
//#region src/lib/sessionConfigConflict.ts
|
|
1470
|
-
const SESSION_CONFIG_CONFLICT_MARKER = "sessionConfigConflict";
|
|
1471
|
-
/**
|
|
1472
|
-
* Adds the issue raised when a saved Session config (`experimental.sessionConfigId`)
|
|
1473
|
-
* is combined with inline access fields. `fields` lists every conflicting
|
|
1474
|
-
* field that was provided; nothing is added when it is empty.
|
|
1475
|
-
*/
|
|
1476
|
-
const addSessionConfigConflictIssue = (ctx, fields) => {
|
|
1477
|
-
if (fields.length === 0) return;
|
|
1478
|
-
ctx.addIssue({
|
|
1479
|
-
code: z$1.ZodIssueCode.custom,
|
|
1480
|
-
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`,
|
|
1481
|
-
path: ["experimental", "sessionConfigId"],
|
|
1482
|
-
params: { [SESSION_CONFIG_CONFLICT_MARKER]: true }
|
|
1483
|
-
});
|
|
1484
|
-
};
|
|
1485
|
-
/**
|
|
1486
|
-
* Parses session create or update input. A saved Session config combined with
|
|
1487
|
-
* inline access fields throws `ValidationError`; any other failure rethrows the
|
|
1488
|
-
* original `ZodError`, as `schema.parse()` would.
|
|
1489
|
-
*/
|
|
1490
|
-
const parseSessionConfigInput = (schema, input) => {
|
|
1491
|
-
const result = schema.safeParse(input);
|
|
1492
|
-
if (result.success) return result.data;
|
|
1493
|
-
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 });
|
|
1494
|
-
throw result.error;
|
|
1495
|
-
};
|
|
1496
|
-
|
|
1497
|
-
//#endregion
|
|
1498
|
-
//#region src/types/toolRouter.types.ts
|
|
1499
|
-
const SessionPreset = { DIRECT_TOOLS: "direct_tools" };
|
|
1500
|
-
const MCPServerTypeSchema = z.enum(["http", "sse"]);
|
|
1501
|
-
/**
|
|
1502
|
-
* Sandbox compute tier for the session sandbox.
|
|
1503
|
-
*
|
|
1504
|
-
* | Tier | vCPU | RAM |
|
|
1505
|
-
* | -------- | ---- | ----- |
|
|
1506
|
-
* | standard | 1 | 1 GB |
|
|
1507
|
-
* | medium | 2 | 2 GB |
|
|
1508
|
-
* | large | 4 | 4 GB |
|
|
1509
|
-
* | xlarge | 8 | 8 GB |
|
|
1510
|
-
*
|
|
1511
|
-
* Defaults to `standard` server-side when omitted.
|
|
1512
|
-
*/
|
|
1513
|
-
const SandboxSizeSchema = z.enum([
|
|
1514
|
-
"standard",
|
|
1515
|
-
"medium",
|
|
1516
|
-
"large",
|
|
1517
|
-
"xlarge"
|
|
1518
|
-
]);
|
|
1519
|
-
const ToolRouterSandboxConfigSchema = z.object({
|
|
1520
|
-
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."),
|
|
1521
|
-
enableProxyExecution: z.boolean().optional().describe("Whether to enable proxy execution in the session sandbox"),
|
|
1522
|
-
autoOffloadThreshold: z.number().optional().describe("The auto offload threshold in characters for tool execution to move into the sandbox"),
|
|
1523
|
-
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.")
|
|
1524
|
-
});
|
|
1525
|
-
const ToolRouterConfigManageConnectionsSchema = z.object({
|
|
1526
|
-
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"),
|
|
1527
|
-
callbackUrl: z.string().optional().describe("The callback uri to use in the tool router session"),
|
|
1528
|
-
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")
|
|
1529
|
-
}).strict();
|
|
1530
|
-
const ToolRouterToolkitsParamSchema = z.array(z.string()).describe("List of toolkits to enable in the tool router session");
|
|
1531
|
-
const ToolRouterToolkitsDisabledConfigSchema = z.object({ disable: ToolRouterToolkitsParamSchema.describe("List of toolkits to disable in the tool router session") }).strict();
|
|
1532
|
-
const ToolRouterToolkitsEnabledConfigSchema = z.object({ enable: ToolRouterToolkitsParamSchema.describe("List of toolkits to enable in the tool router session") }).strict();
|
|
1533
|
-
/** Experimental Instant usage policy for a Session. */
|
|
1534
|
-
const ToolRouterInstantSchema = z.union([z.literal(false), z.object({
|
|
1535
|
-
toolkits: z.union([ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsDisabledConfigSchema]).optional(),
|
|
1536
|
-
tools: z.record(z.string(), z.union([z.object({ enable: z.array(z.string()) }).strict(), z.object({ disable: z.array(z.string()) }).strict()])).optional(),
|
|
1537
|
-
/**
|
|
1538
|
-
* Return the actual Instant charge in Session tool responses. Controls
|
|
1539
|
-
* visibility only; on update, any policy object still re-enables Instant
|
|
1540
|
-
* usage on a Session set to `false`.
|
|
1541
|
-
*/
|
|
1542
|
-
returnInstantCharge: z.boolean().optional()
|
|
1543
|
-
}).strict()]);
|
|
1544
|
-
const ToolRouterManageConnectionsConfigSchema = z.object({
|
|
1545
|
-
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),
|
|
1546
|
-
callbackUrl: z.string().optional().describe("The callback url to use in the tool router session")
|
|
1547
|
-
});
|
|
1548
|
-
const ToolRouterTagsParamSchema = z.array(z.enum([
|
|
1549
|
-
"readOnlyHint",
|
|
1550
|
-
"destructiveHint",
|
|
1551
|
-
"idempotentHint",
|
|
1552
|
-
"openWorldHint"
|
|
1553
|
-
])).describe("The tags to filter the tools by");
|
|
1554
|
-
const ToolRouterTagsEnableDisableSchema = z.object({
|
|
1555
|
-
enable: ToolRouterTagsParamSchema.optional().describe("The tags to enable in the tool router session"),
|
|
1556
|
-
disable: ToolRouterTagsParamSchema.optional().describe("The tags to disable in the tool router session")
|
|
1557
|
-
}).strict();
|
|
1558
|
-
const ToolRouterConfigTagsSchema = z.union([ToolRouterTagsParamSchema, ToolRouterTagsEnableDisableSchema]).describe("The tags to use in the tool router session");
|
|
1559
|
-
/**
|
|
1560
|
-
* Tools config - Configure tools per toolkit using toolkit slug as key
|
|
1561
|
-
* @example
|
|
1562
|
-
* ```typescript
|
|
1563
|
-
* {
|
|
1564
|
-
* gmail: {
|
|
1565
|
-
* enable: ['gmail_search', 'gmail_send']
|
|
1566
|
-
* },
|
|
1567
|
-
* slack: {
|
|
1568
|
-
* disable: ['slack_delete_message']
|
|
1569
|
-
* }
|
|
1570
|
-
* }
|
|
1571
|
-
* ```
|
|
1572
|
-
*
|
|
1573
|
-
* @example
|
|
1574
|
-
* ```typescript
|
|
1575
|
-
* {
|
|
1576
|
-
* gmail: ['gmail_search', 'gmail_send'],
|
|
1577
|
-
* slack: { tags: ['readOnlyHint'] }
|
|
1578
|
-
* }
|
|
1579
|
-
* ```
|
|
1580
|
-
*/
|
|
1581
|
-
const ToolRouterToolsParamSchema = z.array(z.string()).describe("The tools to use in the tool router session");
|
|
1582
|
-
const ToolRouterConfigToolsSchema = z.union([
|
|
1583
|
-
ToolRouterToolsParamSchema,
|
|
1584
|
-
z.object({ enable: ToolRouterToolsParamSchema.describe("The tools to enable in the tool router session") }).strict(),
|
|
1585
|
-
z.object({ disable: ToolRouterToolsParamSchema.describe("The tools to disable in the tool router session") }).strict(),
|
|
1586
|
-
z.object({ tags: ToolRouterConfigTagsSchema.describe("The tags to filter the tools by, this will override the global tags") }).strict()
|
|
1587
|
-
]).superRefine((val, ctx) => {
|
|
1588
|
-
if (typeof val === "object" && !Array.isArray(val)) {
|
|
1589
|
-
const keys = Object.keys(val);
|
|
1590
|
-
if (keys.length > 1) ctx.addIssue({
|
|
1591
|
-
code: z.ZodIssueCode.custom,
|
|
1592
|
-
message: `Only one of 'enable', 'disable', or 'tags' can be specified, but found: ${keys.join(", ")}`,
|
|
1593
|
-
path: keys
|
|
1594
|
-
});
|
|
1595
|
-
}
|
|
1596
|
-
});
|
|
1597
|
-
const ToolRouterCreateSessionConfigBaseSchema = z.object({
|
|
1598
|
-
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."),
|
|
1599
|
-
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"),
|
|
1600
|
-
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).optional().describe("The tools to use in the tool router session"),
|
|
1601
|
-
tags: ToolRouterConfigTagsSchema.optional().describe("Global tags to filter the tools by"),
|
|
1602
|
-
toolkits: z.union([
|
|
1603
|
-
ToolRouterToolkitsParamSchema,
|
|
1604
|
-
ToolRouterToolkitsDisabledConfigSchema,
|
|
1605
|
-
ToolRouterToolkitsEnabledConfigSchema
|
|
1606
|
-
]).optional().describe("The toolkits to use in the tool router session"),
|
|
1607
|
-
instant: ToolRouterInstantSchema.optional().describe("Experimental Instant usage policy. Omission permits eligible tools when the project allows Instant usage; false disables it for this Session."),
|
|
1608
|
-
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({}),
|
|
1609
|
-
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({}),
|
|
1610
|
-
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."),
|
|
1611
|
-
sandbox: ToolRouterSandboxConfigSchema.optional().describe("The sandbox config for this session. Prefer this over workbench."),
|
|
1612
|
-
workbench: ToolRouterSandboxConfigSchema.optional().describe("Deprecated alias for sandbox. Accepted for backwards compatibility."),
|
|
1613
|
-
multiAccount: z.object({
|
|
1614
|
-
enable: z.boolean().default(false).describe("When true, enables multi-account mode for this session. Defaults to false."),
|
|
1615
|
-
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."),
|
|
1616
|
-
requireExplicitSelection: z.boolean().optional().describe("When true, require explicit account selection when multiple accounts are connected. When false (default), use the first/default account.")
|
|
1617
|
-
}).optional().describe("Multi-account configuration for this session"),
|
|
1618
|
-
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."),
|
|
1619
|
-
experimental: z.object({
|
|
1620
|
-
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"),
|
|
1621
|
-
customTools: z.array(z.custom()).optional().describe("Custom tools to include in this session. Created via createCustomTool() from @composio/core/experimental."),
|
|
1622
|
-
customToolkits: z.array(z.custom()).optional().describe("Custom toolkits to include in this session. Created via createCustomToolkit() from @composio/core/experimental."),
|
|
1623
|
-
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.")
|
|
1624
|
-
}).optional().describe("Experimental features configuration - not stable, may be modified or removed")
|
|
1625
|
-
}).partial().superRefine((config, ctx) => {
|
|
1626
|
-
if (config.experimental?.sessionConfigId !== void 0) addSessionConfigConflictIssue(ctx, [
|
|
1627
|
-
config.toolkits !== void 0 && "toolkits",
|
|
1628
|
-
config.tools !== void 0 && "tools",
|
|
1629
|
-
config.tags !== void 0 && "tags",
|
|
1630
|
-
config.experimental.customTools !== void 0 && "experimental.customTools",
|
|
1631
|
-
config.experimental.customToolkits !== void 0 && "experimental.customToolkits"
|
|
1632
|
-
].filter((field) => field !== false));
|
|
1633
|
-
if (config.sandbox !== void 0 && config.workbench !== void 0) ctx.addIssue({
|
|
1634
|
-
code: z.ZodIssueCode.custom,
|
|
1635
|
-
message: "Pass either sandbox or workbench, not both. workbench is a backwards-compatible alias for sandbox.",
|
|
1636
|
-
path: ["sandbox"]
|
|
1637
|
-
});
|
|
1638
|
-
}).describe("The config for the tool router session");
|
|
1639
|
-
const applyDirectToolsPresetDefaults = (value) => {
|
|
1640
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
1641
|
-
const config = value;
|
|
1642
|
-
if (config.sessionPreset !== SessionPreset.DIRECT_TOOLS) return value;
|
|
1643
|
-
const hasSandboxConfig = config.sandbox !== void 0 || config.workbench !== void 0;
|
|
1644
|
-
return {
|
|
1645
|
-
...config,
|
|
1646
|
-
manageConnections: config.manageConnections === void 0 ? false : config.manageConnections,
|
|
1647
|
-
...hasSandboxConfig ? {} : { sandbox: { enable: false } },
|
|
1648
|
-
preload: config.preload === void 0 ? { tools: "all" } : config.preload
|
|
1649
|
-
};
|
|
1650
|
-
};
|
|
1651
|
-
const ToolRouterCreateSessionConfigSchema = z.preprocess(applyDirectToolsPresetDefaults, ToolRouterCreateSessionConfigBaseSchema).describe("The config for the tool router session");
|
|
1652
|
-
const ToolkitConnectionStateSchema = z.object({
|
|
1653
|
-
slug: z.string().describe("The slug of a toolkit"),
|
|
1654
|
-
name: z.string().describe("The name of a toolkit"),
|
|
1655
|
-
logo: z.string().optional().describe("The logo of a toolkit"),
|
|
1656
|
-
isNoAuth: z.boolean().default(false).describe("Whether the toolkit is no auth or not"),
|
|
1657
|
-
connection: z.object({
|
|
1658
|
-
isActive: z.boolean().describe("Whether the connection is active or not"),
|
|
1659
|
-
authConfig: z.object({
|
|
1660
|
-
id: z.string().describe("The id of the auth config"),
|
|
1661
|
-
mode: z.string().describe("The auth scheme used by the auth config"),
|
|
1662
|
-
isComposioManaged: z.boolean().describe("Whether the auth config is managed by Composio")
|
|
1663
|
-
}).nullish().describe("The auth config of a toolkit"),
|
|
1664
|
-
connectedAccount: z.object({
|
|
1665
|
-
id: z.string().describe("The id of the connected account"),
|
|
1666
|
-
status: z.string().describe("The status of the connected account")
|
|
1667
|
-
}).optional().describe("The connected account of a toolkit")
|
|
1668
|
-
}).optional().describe("The connection of a toolkit")
|
|
1669
|
-
}).describe("The connection state of a toolkit");
|
|
1670
|
-
const ToolkitConnectionsDetailsSchema = z.object({
|
|
1671
|
-
items: z.array(ToolkitConnectionStateSchema),
|
|
1672
|
-
cursor: z.string().optional(),
|
|
1673
|
-
totalPages: z.number()
|
|
1674
|
-
});
|
|
1675
|
-
const ToolRouterMCPServerConfigSchema = z.object({
|
|
1676
|
-
type: MCPServerTypeSchema,
|
|
1677
|
-
url: z.string(),
|
|
1678
|
-
headers: z.record(z.string(), z.string()).optional()
|
|
1679
|
-
});
|
|
1680
|
-
const ToolRouterToolkitsOptionsSchema = z.object({
|
|
1681
|
-
toolkits: z.array(z.string()).optional(),
|
|
1682
|
-
cursor: z.string().optional(),
|
|
1683
|
-
limit: z.number().optional(),
|
|
1684
|
-
isConnected: z.boolean().optional(),
|
|
1685
|
-
search: z.string().optional()
|
|
1686
|
-
});
|
|
1687
|
-
const ToolRouterSessionSearchResultReferenceWorkbenchSnippetSchema = z.object({
|
|
1688
|
-
code: z.string(),
|
|
1689
|
-
description: z.string()
|
|
1690
|
-
});
|
|
1691
|
-
const ToolRouterSessionSearchResultSchema = z.object({
|
|
1692
|
-
index: z.number(),
|
|
1693
|
-
useCase: z.string(),
|
|
1694
|
-
primaryToolSlugs: z.array(z.string()),
|
|
1695
|
-
relatedToolSlugs: z.array(z.string()),
|
|
1696
|
-
toolkits: z.array(z.string()),
|
|
1697
|
-
difficulty: z.string().optional(),
|
|
1698
|
-
error: z.string().nullable().optional(),
|
|
1699
|
-
executionGuidance: z.string().optional(),
|
|
1700
|
-
knownPitfalls: z.array(z.string()).optional(),
|
|
1701
|
-
memory: z.record(z.string(), z.array(z.string())).optional(),
|
|
1702
|
-
planId: z.string().optional(),
|
|
1703
|
-
recommendedPlanSteps: z.array(z.string()).optional(),
|
|
1704
|
-
referenceWorkbenchSnippets: z.array(ToolRouterSessionSearchResultReferenceWorkbenchSnippetSchema).optional()
|
|
1705
|
-
});
|
|
1706
|
-
const ToolRouterSessionSearchSessionSchema = z.object({
|
|
1707
|
-
id: z.string(),
|
|
1708
|
-
generateId: z.boolean(),
|
|
1709
|
-
instructions: z.string()
|
|
1710
|
-
});
|
|
1711
|
-
const ToolRouterSessionSearchTimeInfoSchema = z.object({
|
|
1712
|
-
currentTimeUtc: z.string(),
|
|
1713
|
-
currentTimeUtcEpochSeconds: z.number(),
|
|
1714
|
-
message: z.string()
|
|
1715
|
-
});
|
|
1716
|
-
const ToolRouterSessionSearchToolSchemasSchemaRefSchema = z.object({
|
|
1717
|
-
args: z.object({ toolSlugs: z.array(z.string()) }),
|
|
1718
|
-
message: z.string().optional(),
|
|
1719
|
-
tool: z.literal("COMPOSIO_GET_TOOL_SCHEMAS")
|
|
1720
|
-
});
|
|
1721
|
-
const ToolRouterSessionSearchToolSchemaSchema = z.object({
|
|
1722
|
-
toolSlug: z.string(),
|
|
1723
|
-
toolkit: z.string(),
|
|
1724
|
-
description: z.string().optional(),
|
|
1725
|
-
hasFullSchema: z.boolean().optional(),
|
|
1726
|
-
inputSchema: z.record(z.string(), z.unknown()).optional(),
|
|
1727
|
-
outputSchema: z.record(z.string(), z.unknown()).optional(),
|
|
1728
|
-
schemaRef: ToolRouterSessionSearchToolSchemasSchemaRefSchema.optional()
|
|
1729
|
-
});
|
|
1730
|
-
const ToolRouterSessionSearchToolkitConnectionStatusSchema = z.object({
|
|
1731
|
-
toolkit: z.string(),
|
|
1732
|
-
description: z.string(),
|
|
1733
|
-
hasActiveConnection: z.boolean(),
|
|
1734
|
-
statusMessage: z.string(),
|
|
1735
|
-
connectionDetails: z.record(z.string(), z.unknown()).optional(),
|
|
1736
|
-
currentUserInfo: z.record(z.string(), z.unknown()).optional(),
|
|
1737
|
-
/** Present when the toolkit runs on a Composio Instant account; only these tools run on it. */
|
|
1738
|
-
instantAccount: z.object({ allowedToolSlugs: z.array(z.string()) }).optional()
|
|
1739
|
-
});
|
|
1740
|
-
const ToolRouterSessionSearchResponseSchema = z.object({
|
|
1741
|
-
success: z.boolean(),
|
|
1742
|
-
error: z.string().nullable(),
|
|
1743
|
-
results: z.array(ToolRouterSessionSearchResultSchema),
|
|
1744
|
-
toolSchemas: z.record(z.string(), ToolRouterSessionSearchToolSchemaSchema),
|
|
1745
|
-
toolkitConnectionStatuses: z.array(ToolRouterSessionSearchToolkitConnectionStatusSchema),
|
|
1746
|
-
nextStepsGuidance: z.array(z.string()),
|
|
1747
|
-
session: ToolRouterSessionSearchSessionSchema,
|
|
1748
|
-
timeInfo: ToolRouterSessionSearchTimeInfoSchema
|
|
1749
|
-
});
|
|
1750
|
-
const ToolRouterSessionExecuteResponseSchema = z.object({
|
|
1751
|
-
data: z.record(z.string(), z.unknown()),
|
|
1752
|
-
error: z.string().nullable(),
|
|
1753
|
-
logId: z.string(),
|
|
1754
|
-
/** Actual Instant usage charge when the Session opts into returning it. */
|
|
1755
|
-
instantCharge: z.unknown().optional()
|
|
1756
|
-
});
|
|
1757
|
-
const ToolRouterInstantResponseFilterSchema = z.union([z.object({ enabled: z.array(z.string()) }), z.object({ disabled: z.array(z.string()) })]);
|
|
1758
|
-
/** Instant policy in the server's Session config (wire field casing). */
|
|
1759
|
-
const ToolRouterInstantResponseSchema = z.object({
|
|
1760
|
-
toolkits: ToolRouterInstantResponseFilterSchema.optional(),
|
|
1761
|
-
tools: z.record(z.string(), ToolRouterInstantResponseFilterSchema).optional(),
|
|
1762
|
-
return_instant_charge: z.boolean()
|
|
1763
|
-
});
|
|
1764
|
-
const SessionProxyExecuteParamsSchema = z.object({
|
|
1765
|
-
/** The toolkit whose connected account to use for auth (e.g. 'gmail', 'github') */
|
|
1766
|
-
toolkit: z.string(),
|
|
1767
|
-
/** The API endpoint URL to call */
|
|
1768
|
-
endpoint: z.string(),
|
|
1769
|
-
/** HTTP method */
|
|
1770
|
-
method: z.enum([
|
|
1771
|
-
"GET",
|
|
1772
|
-
"POST",
|
|
1773
|
-
"PUT",
|
|
1774
|
-
"DELETE",
|
|
1775
|
-
"PATCH"
|
|
1776
|
-
]),
|
|
1777
|
-
/** Request body (for POST/PUT/PATCH) */
|
|
1778
|
-
body: z.unknown().optional(),
|
|
1779
|
-
/** Query params or headers to include */
|
|
1780
|
-
parameters: z.array(z.object({
|
|
1781
|
-
in: z.enum(["query", "header"]),
|
|
1782
|
-
name: z.string(),
|
|
1783
|
-
value: z.union([z.string(), z.number()])
|
|
1784
|
-
})).optional()
|
|
1785
|
-
});
|
|
1786
|
-
/**
|
|
1787
|
-
* `manageConnections` shape accepted by `session.update()`. Unlike the create
|
|
1788
|
-
* schema, `callbackUrl: null` removes the stored callback URL while leaving
|
|
1789
|
-
* the sibling connection settings untouched.
|
|
1790
|
-
*/
|
|
1791
|
-
const ToolRouterUpdateManageConnectionsSchema = z.object({
|
|
1792
|
-
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"),
|
|
1793
|
-
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"),
|
|
1794
|
-
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"),
|
|
1795
|
-
enableConnectionRemoval: z.boolean().nullable().optional().describe("Whether the session exposes the connection removal tool. `null` removes the stored override")
|
|
1796
|
-
}).strict();
|
|
1797
|
-
const ToolRouterElicitationDefaultSchema = z.enum([
|
|
1798
|
-
"allow_all",
|
|
1799
|
-
"ask_every_call",
|
|
1800
|
-
"ask_once_per_session"
|
|
1801
|
-
]);
|
|
1802
|
-
const ToolRouterElicitationOverrideSchema = z.enum([
|
|
1803
|
-
"always_allow",
|
|
1804
|
-
"always_deny",
|
|
1805
|
-
"ask_once",
|
|
1806
|
-
"ask_always"
|
|
1807
|
-
]);
|
|
1808
|
-
/**
|
|
1809
|
-
* `experimental` block accepted by `session.update()`. Each leaf follows the
|
|
1810
|
-
* PATCH contract of the API: omit to keep the stored value, `null` to remove
|
|
1811
|
-
* it, a value to replace it.
|
|
1812
|
-
*/
|
|
1813
|
-
const ToolRouterUpdateExperimentalSchema = z.object({
|
|
1814
|
-
permissions: z.object({
|
|
1815
|
-
default: ToolRouterElicitationDefaultSchema,
|
|
1816
|
-
overrides: z.record(z.string(), ToolRouterElicitationOverrideSchema).optional()
|
|
1817
|
-
}).strict().nullable().optional().describe("Per-tool elicitation permission config. `null` removes the stored block"),
|
|
1818
|
-
linkUrlOverwrite: z.string().nullable().optional().describe("Base URL override for connection link redirects. `null` removes the stored override"),
|
|
1819
|
-
fastMode: z.boolean().nullable().optional().describe("Fast search mode. `null` removes the stored override"),
|
|
1820
|
-
submitFeedback: z.object({ enable: z.boolean() }).strict().nullable().optional().describe("Exposes the COMPOSIO_SUBMIT_FEEDBACK helper tool. `null` removes the stored block"),
|
|
1821
|
-
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")
|
|
1822
|
-
}).strict();
|
|
1823
|
-
/**
|
|
1824
|
-
* Options for `session.update()`. For every policy block, omitting the key
|
|
1825
|
-
* preserves the stored value and `null` removes the stored override (which can
|
|
1826
|
-
* increase access: `toolkits: null` restores the unrestricted default, unlike
|
|
1827
|
-
* `toolkits: []`, which denies every app toolkit).
|
|
1828
|
-
*/
|
|
1829
|
-
const ToolRouterUpdateSessionConfigSchema = z.object({
|
|
1830
|
-
instant: ToolRouterInstantSchema.optional().describe("Experimental Instant usage policy. False disables it. Any supplied object, even one that only sets returnInstantCharge, re-enables it. Omitted subfields keep their stored values."),
|
|
1831
|
-
toolkits: z.union([
|
|
1832
|
-
ToolRouterToolkitsParamSchema,
|
|
1833
|
-
ToolRouterToolkitsDisabledConfigSchema,
|
|
1834
|
-
ToolRouterToolkitsEnabledConfigSchema
|
|
1835
|
-
]).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"),
|
|
1836
|
-
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).nullable().optional().describe("Replaces the entire stored tools map; `null` removes the override"),
|
|
1837
|
-
tags: ToolRouterConfigTagsSchema.nullable().optional().describe("Replaces the global tag policy; `null` removes the override"),
|
|
1838
|
-
authConfigs: z.record(z.string(), z.string()).nullable().optional().describe("Replaces the entire stored auth config map; `null` removes the override"),
|
|
1839
|
-
connectedAccounts: z.record(z.string(), z.union([z.string(), z.array(z.string())])).transform((rec) => {
|
|
1840
|
-
const out = {};
|
|
1841
|
-
for (const [k, v] of Object.entries(rec)) out[k] = typeof v === "string" ? [v] : v;
|
|
1842
|
-
return out;
|
|
1843
|
-
}).nullable().optional().describe("Replaces the entire stored connected accounts map; `null` removes the override"),
|
|
1844
|
-
manageConnections: z.union([z.boolean(), ToolRouterUpdateManageConnectionsSchema]).nullable().optional(),
|
|
1845
|
-
sandbox: ToolRouterSandboxConfigSchema.partial().nullable().optional(),
|
|
1846
|
-
workbench: ToolRouterSandboxConfigSchema.partial().nullable().optional(),
|
|
1847
|
-
multiAccount: z.object({
|
|
1848
|
-
enable: z.boolean().optional(),
|
|
1849
|
-
maxAccountsPerToolkit: z.number().int().min(2).max(10).nullable().optional().describe("`null` removes the stored maximum so the default applies again"),
|
|
1850
|
-
requireExplicitSelection: z.boolean().optional()
|
|
1851
|
-
}).nullable().optional().describe("`null` removes the session override; the mode then resolves to disabled"),
|
|
1852
|
-
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"),
|
|
1853
|
-
search: z.object({ enable: z.boolean().optional() }).strict().nullable().optional().describe("Replaces the search block; `null` removes it and restores the defaults"),
|
|
1854
|
-
execute: z.object({ enableMultiExecute: z.boolean().optional() }).strict().nullable().optional().describe("Replaces the execute block; `null` removes it and restores the defaults"),
|
|
1855
|
-
experimental: ToolRouterUpdateExperimentalSchema.nullable().optional().describe("Experimental settings; `null` removes the stored block"),
|
|
1856
|
-
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)")
|
|
1857
|
-
}).partial().superRefine((config, ctx) => {
|
|
1858
|
-
if (config.experimental?.sessionConfigId !== void 0) addSessionConfigConflictIssue(ctx, [
|
|
1859
|
-
config.toolkits !== void 0 && "toolkits",
|
|
1860
|
-
config.tools !== void 0 && "tools",
|
|
1861
|
-
config.tags !== void 0 && "tags"
|
|
1862
|
-
].filter((field) => field !== false));
|
|
1863
|
-
if (config.sandbox !== void 0 && config.workbench !== void 0) ctx.addIssue({
|
|
1864
|
-
code: z.ZodIssueCode.custom,
|
|
1865
|
-
message: "Pass either sandbox or workbench, not both. workbench is a backwards-compatible alias for sandbox.",
|
|
1866
|
-
path: ["sandbox"]
|
|
1867
|
-
});
|
|
1868
|
-
});
|
|
1869
|
-
const ToolRouterSessionDeleteResponseSchema = z.object({
|
|
1870
|
-
sessionId: z.string(),
|
|
1871
|
-
deleted: z.literal(true)
|
|
1872
|
-
});
|
|
1873
|
-
/**
|
|
1874
|
-
* Options for `session.listConfigHistory()`.
|
|
1875
|
-
*/
|
|
1876
|
-
const ToolRouterSessionListConfigHistoryOptionsSchema = z.object({
|
|
1877
|
-
/** Cursor from a previous response's `nextCursor`. */
|
|
1878
|
-
cursor: z.string().optional(),
|
|
1879
|
-
/** Number of items per page, max allowed is 100. */
|
|
1880
|
-
limit: z.number().optional()
|
|
1881
|
-
});
|
|
1882
|
-
const ToolRouterSessionEnsureConnectedOptionsSchema = z.object({
|
|
1883
|
-
callbackUrl: z.string().optional(),
|
|
1884
|
-
alias: z.string().optional(),
|
|
1885
|
-
experimental: ConnectedAccountExperimentalSchema.optional(),
|
|
1886
|
-
/** Max time to wait for a newly-initiated connection to become active, in milliseconds. Defaults to 60000. */
|
|
1887
|
-
timeout: z.number().int().positive().optional()
|
|
1888
|
-
});
|
|
1889
|
-
|
|
1890
|
-
//#endregion
|
|
1891
|
-
//#region src/utils/transformers/toolRouterResponseTransform.ts
|
|
1892
|
-
/**
|
|
1893
|
-
* Transforms snake_case Tool Router API responses to camelCase for SDK consumers.
|
|
1894
|
-
*/
|
|
1895
|
-
const SessionConfigInstantSchema = z$1.object({ instant: z$1.union([z$1.literal(false), ToolRouterInstantResponseSchema]).optional() });
|
|
1896
|
-
/** Session config retains its API casing, including `instant.return_instant_charge`. */
|
|
1897
|
-
function transformSessionConfig$1(raw) {
|
|
1898
|
-
const { instant } = SessionConfigInstantSchema.parse(raw);
|
|
1899
|
-
const { premium_usage: _previousPolicy, ...config } = raw;
|
|
1900
|
-
return {
|
|
1901
|
-
...config,
|
|
1902
|
-
...instant !== void 0 && { instant }
|
|
1903
|
-
};
|
|
1904
|
-
}
|
|
1905
|
-
function transformSearchResult(raw) {
|
|
1906
|
-
return {
|
|
1907
|
-
index: raw.index,
|
|
1908
|
-
useCase: raw.use_case,
|
|
1909
|
-
primaryToolSlugs: raw.primary_tool_slugs,
|
|
1910
|
-
relatedToolSlugs: raw.related_tool_slugs,
|
|
1911
|
-
toolkits: raw.toolkits,
|
|
1912
|
-
difficulty: raw.difficulty,
|
|
1913
|
-
error: raw.error,
|
|
1914
|
-
executionGuidance: raw.execution_guidance,
|
|
1915
|
-
knownPitfalls: raw.known_pitfalls,
|
|
1916
|
-
memory: raw.memory,
|
|
1917
|
-
planId: raw.plan_id,
|
|
1918
|
-
recommendedPlanSteps: raw.recommended_plan_steps,
|
|
1919
|
-
referenceWorkbenchSnippets: raw.reference_workbench_snippets
|
|
1920
|
-
};
|
|
1921
|
-
}
|
|
1922
|
-
function transformToolSchema(raw) {
|
|
1923
|
-
return {
|
|
1924
|
-
toolSlug: raw.tool_slug,
|
|
1925
|
-
toolkit: raw.toolkit,
|
|
1926
|
-
description: raw.description,
|
|
1927
|
-
hasFullSchema: raw.hasFullSchema,
|
|
1928
|
-
inputSchema: raw.input_schema,
|
|
1929
|
-
outputSchema: raw.output_schema,
|
|
1930
|
-
schemaRef: raw.schemaRef ? {
|
|
1931
|
-
args: { toolSlugs: raw.schemaRef.args.tool_slugs },
|
|
1932
|
-
message: raw.schemaRef.message,
|
|
1933
|
-
tool: raw.schemaRef.tool
|
|
1934
|
-
} : void 0
|
|
1935
|
-
};
|
|
1936
|
-
}
|
|
1937
|
-
function transformToolkitConnectionStatus(raw) {
|
|
1938
|
-
return {
|
|
1939
|
-
toolkit: raw.toolkit,
|
|
1940
|
-
description: raw.description,
|
|
1941
|
-
hasActiveConnection: raw.has_active_connection,
|
|
1942
|
-
statusMessage: raw.status_message,
|
|
1943
|
-
connectionDetails: raw.connection_details,
|
|
1944
|
-
currentUserInfo: raw.current_user_info,
|
|
1945
|
-
...raw.instant_account !== void 0 && { instantAccount: { allowedToolSlugs: raw.instant_account.allowed_tool_slugs } }
|
|
1946
|
-
};
|
|
1947
|
-
}
|
|
1948
|
-
/**
|
|
1949
|
-
* Transforms a raw session search API response to camelCase.
|
|
1950
|
-
*/
|
|
1951
|
-
function transformSearchResponse(raw) {
|
|
1952
|
-
const toolSchemas = {};
|
|
1953
|
-
for (const [slug, schema] of Object.entries(raw.tool_schemas)) toolSchemas[slug] = transformToolSchema(schema);
|
|
1954
|
-
return {
|
|
1955
|
-
success: raw.success,
|
|
1956
|
-
error: raw.error,
|
|
1957
|
-
results: raw.results.map(transformSearchResult),
|
|
1958
|
-
toolSchemas,
|
|
1959
|
-
toolkitConnectionStatuses: raw.toolkit_connection_statuses.map(transformToolkitConnectionStatus),
|
|
1960
|
-
nextStepsGuidance: raw.next_steps_guidance,
|
|
1961
|
-
session: {
|
|
1962
|
-
id: raw.session.id,
|
|
1963
|
-
generateId: raw.session.generate_id,
|
|
1964
|
-
instructions: raw.session.instructions
|
|
1965
|
-
},
|
|
1966
|
-
timeInfo: {
|
|
1967
|
-
currentTimeUtc: raw.time_info.current_time_utc,
|
|
1968
|
-
currentTimeUtcEpochSeconds: raw.time_info.current_time_utc_epoch_seconds,
|
|
1969
|
-
message: raw.time_info.message
|
|
1970
|
-
}
|
|
1971
|
-
};
|
|
1972
|
-
}
|
|
1973
|
-
/**
|
|
1974
|
-
* Transforms a raw session execute API response to camelCase.
|
|
1975
|
-
*/
|
|
1976
|
-
function transformExecuteResponse(raw) {
|
|
1977
|
-
return {
|
|
1978
|
-
data: raw.data,
|
|
1979
|
-
error: raw.error,
|
|
1980
|
-
logId: raw.log_id,
|
|
1981
|
-
...raw.instant_charge !== void 0 && { instantCharge: raw.instant_charge }
|
|
1982
|
-
};
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
//#endregion
|
|
1986
|
-
//#region src/models/Tools.ts
|
|
1987
|
-
const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
|
|
1988
|
-
/**
|
|
1989
|
-
* Normalize a raw `input_parameters` / `output_parameters` payload returned by
|
|
1990
|
-
* the Composio API. Maps `null`, `undefined`, and empty `{}` — all of which
|
|
1991
|
-
* mean "no declared schema" — to `undefined` so the strict `ParametersSchema`
|
|
1992
|
-
* validator never sees them. Non-empty objects pass through unchanged and
|
|
1993
|
-
* remain subject to strict Zod validation.
|
|
1994
|
-
*
|
|
1995
|
-
* MCP-backed toolkits (granola_mcp, apify_mcp, tavily_mcp, …) have no
|
|
1996
|
-
* declared output schema and the API serializes that as `{}`, which would
|
|
1997
|
-
* otherwise trip `ParametersSchema`. See
|
|
1998
|
-
* https://github.com/ComposioHQ/composio/issues/3354.
|
|
1999
|
-
*/
|
|
2000
|
-
function normalizeRawToolParameters(params) {
|
|
2001
|
-
if (params == null || Object.keys(params).length === 0) return void 0;
|
|
2002
|
-
return params;
|
|
2003
|
-
}
|
|
2004
|
-
/**
|
|
2005
|
-
* This class is used to manage tools in the Composio SDK.
|
|
2006
|
-
* It provides methods to list, get, and execute tools.
|
|
2007
|
-
*/
|
|
2008
|
-
var Tools = class {
|
|
2009
|
-
client;
|
|
2010
|
-
provider;
|
|
2011
|
-
autoUploadDownloadFiles;
|
|
2012
|
-
toolkitVersions;
|
|
2013
|
-
fileUploadPathOptions;
|
|
2014
|
-
/**
|
|
2015
|
-
* Tracks tool slugs we've already warned about to avoid spamming the log when
|
|
2016
|
-
* the same file-input tool is executed repeatedly while auto-upload is off.
|
|
2017
|
-
* Scoped per-instance so a fresh `Composio` starts with a clean slate.
|
|
2018
|
-
*/
|
|
2019
|
-
warnedAutoUploadDisabledForTool = /* @__PURE__ */ new Set();
|
|
2020
|
-
/**
|
|
2021
|
-
* Lazily-built sibling client with retries disabled; see `clientWithoutRetries`.
|
|
2022
|
-
*/
|
|
2023
|
-
clientWithoutRetriesCache;
|
|
2024
|
-
constructor(client, config) {
|
|
2025
|
-
if (!client) throw new Error("ComposioClient is required");
|
|
2026
|
-
if (!config?.provider) throw new ComposioProviderNotDefinedError("Provider not passed into Tools instance");
|
|
2027
|
-
this.client = client;
|
|
2028
|
-
this.provider = config.provider;
|
|
2029
|
-
this.autoUploadDownloadFiles = config?.dangerouslyAllowAutoUploadDownloadFiles === true;
|
|
2030
|
-
this.toolkitVersions = config?.toolkitVersions ?? CONFIG_DEFAULTS.toolkitVersions;
|
|
2031
|
-
this.fileUploadPathOptions = {
|
|
2032
|
-
sensitiveFileUploadProtection: config?.sensitiveFileUploadProtection,
|
|
2033
|
-
fileUploadPathDenySegments: config?.fileUploadPathDenySegments,
|
|
2034
|
-
fileUploadAllowlist: this.autoUploadDownloadFiles ? resolveEffectiveUploadAllowlist(config?.fileUploadDirs) : void 0,
|
|
2035
|
-
fileDownloadDir: config?.fileDownloadDir
|
|
2036
|
-
};
|
|
2037
|
-
this.execute = this.execute.bind(this);
|
|
2038
|
-
this.provider._setExecuteToolFn(this.createExecuteFnForProviders());
|
|
2039
|
-
this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
|
|
2040
|
-
this.getRawComposioTools = this.getRawComposioTools.bind(this);
|
|
2041
|
-
telemetry.instrument(this, "Tools");
|
|
2042
|
-
}
|
|
2043
|
-
/**
|
|
2044
|
-
* A cached sibling client that never retries requests, mirroring Python's
|
|
2045
|
-
* `client.without_retries`.
|
|
2046
|
-
*
|
|
2047
|
-
* Used for non-idempotent writes (`tools.execute` / `tools.proxy`), where a
|
|
2048
|
-
* silent retry after a read timeout can duplicate a side effect (e.g. send an
|
|
2049
|
-
* email twice). Reads keep the default retry behaviour, and so do other writes
|
|
2050
|
-
* (`toolRouter.session.execute`, auth-config and connected-account mutations):
|
|
2051
|
-
* the durable fix there is backend-honoured idempotency keys, tracked
|
|
2052
|
-
* separately.
|
|
2053
|
-
*
|
|
2054
|
-
* Cached rather than rebuilt per call because `withOptions` constructs a fresh
|
|
2055
|
-
* client; its options never change, so one per `Tools` instance suffices.
|
|
2056
|
-
*/
|
|
2057
|
-
get clientWithoutRetries() {
|
|
2058
|
-
if (!this.clientWithoutRetriesCache) this.clientWithoutRetriesCache = this.client.withOptions({ maxRetries: 0 });
|
|
2059
|
-
return this.clientWithoutRetriesCache;
|
|
2060
|
-
}
|
|
2061
|
-
/**
|
|
2062
|
-
* Transforms tool data from snake_case API format to camelCase for internal SDK use.
|
|
2063
|
-
*
|
|
2064
|
-
* This method standardizes the property naming convention for tools retrieved from the Composio API,
|
|
2065
|
-
* making them more consistent with JavaScript/TypeScript conventions.
|
|
2066
|
-
*
|
|
2067
|
-
* @param {ToolRetrieveResponse | ComposioToolListResponse['items'][0]} tool - The tool object to transform
|
|
2068
|
-
* @returns {Tool} The transformed tool with camelCase properties
|
|
2069
|
-
*
|
|
2070
|
-
* @private
|
|
2071
|
-
*/
|
|
2072
|
-
transformToolCases(tool) {
|
|
2073
|
-
return ToolSchema.parse({
|
|
2074
|
-
...tool,
|
|
2075
|
-
inputParameters: normalizeRawToolParameters(tool.input_parameters),
|
|
2076
|
-
outputParameters: normalizeRawToolParameters(tool.output_parameters),
|
|
2077
|
-
availableVersions: tool.available_versions,
|
|
2078
|
-
isDeprecated: tool.deprecated?.is_deprecated ?? false,
|
|
2079
|
-
isNoAuth: tool.no_auth
|
|
2080
|
-
});
|
|
2081
|
-
}
|
|
2082
|
-
/**
|
|
2083
|
-
* Transforms tool execution response from snake_case API format to camelCase.
|
|
2084
|
-
*
|
|
2085
|
-
* This method converts the response received from the Composio API to a standardized format
|
|
2086
|
-
* with consistent property naming that follows JavaScript/TypeScript conventions.
|
|
2087
|
-
*
|
|
2088
|
-
* @param {ComposioToolExecuteResponse} response - The raw API response to transform
|
|
2089
|
-
* @returns {ToolExecuteResponse} The transformed response with camelCase properties
|
|
2090
|
-
*
|
|
2091
|
-
* @private
|
|
2092
|
-
*/
|
|
2093
|
-
transformToolExecuteResponse(response) {
|
|
2094
|
-
return ToolExecuteResponseSchema.parse({
|
|
2095
|
-
data: response.data,
|
|
2096
|
-
error: response.error,
|
|
2097
|
-
successful: response.successful,
|
|
2098
|
-
logId: response.log_id,
|
|
2099
|
-
sessionInfo: response.session_info
|
|
2100
|
-
});
|
|
2101
|
-
}
|
|
2102
|
-
/**
|
|
2103
|
-
* Applies the default schema modifiers to the tools.
|
|
2104
|
-
*
|
|
2105
|
-
* The `file_uploadable` transform (collapsing the backend's internal
|
|
2106
|
-
* `{ name, mimetype, s3key }` staging shape to `{ type: 'string',
|
|
2107
|
-
* format: 'path' }`) is **gated on `dangerouslyAllowAutoUploadDownloadFiles`**
|
|
2108
|
-
* — the collapsed shape is a promise that the SDK will stage local paths
|
|
2109
|
-
* on your behalf at execute time, and that's only true when the flag is on.
|
|
2110
|
-
*
|
|
2111
|
-
* When the flag is off, the raw schema is returned unchanged; callers are
|
|
2112
|
-
* expected to stage files themselves via `composio.files.upload()` and pass
|
|
2113
|
-
* the resulting descriptor into `tools.execute`. If an LLM ends up calling
|
|
2114
|
-
* a file-uploadable tool in this mode, the execute path emits a one-shot
|
|
2115
|
-
* warning per tool slug (see `applyBeforeExecuteModifiers`).
|
|
2116
|
-
*
|
|
2117
|
-
* @param tools - The tools to apply the default schema modifiers to
|
|
2118
|
-
* @returns The tools with the default schema modifiers applied
|
|
2119
|
-
*/
|
|
2120
|
-
async applyDefaultSchemaModifiers(tools) {
|
|
2121
|
-
if (!this.autoUploadDownloadFiles) return tools;
|
|
2122
|
-
const fileToolModifier = new FileToolModifier(this.client, this.fileUploadPathOptions);
|
|
2123
|
-
return await Promise.all(tools.map((tool) => fileToolModifier.modifyToolSchema(tool)));
|
|
2124
|
-
}
|
|
2125
|
-
/**
|
|
2126
|
-
* Applies the before execute modifiers to the tool execution params
|
|
2127
|
-
* @param options.toolSlug - The slug of the tool
|
|
2128
|
-
* @param options.toolkitSlug - The slug of the toolkit
|
|
2129
|
-
* @param options.params - The params of the tool execution
|
|
2130
|
-
* @param modifier - The modifier to apply
|
|
2131
|
-
* @returns The modified params
|
|
2132
|
-
*/
|
|
2133
|
-
async applyBeforeExecuteModifiers(tool, { toolSlug, toolkitSlug, params }, modifiers, requestOptions) {
|
|
2134
|
-
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
2135
|
-
let modifiedParams = await this.applyFileUploadModifiers(tool, {
|
|
2136
|
-
toolSlug,
|
|
2137
|
-
toolkitSlug,
|
|
2138
|
-
params
|
|
2139
|
-
}, modifiers?.beforeFileUpload, requestOptions);
|
|
2140
|
-
if (modifiers?.beforeExecute) {
|
|
2141
|
-
if (typeof modifiers.beforeExecute === "function") {
|
|
2142
|
-
modifiedParams = await modifiers.beforeExecute({
|
|
2143
|
-
toolSlug,
|
|
2144
|
-
toolkitSlug,
|
|
2145
|
-
params: modifiedParams
|
|
2146
|
-
});
|
|
2147
|
-
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
2148
|
-
} else throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
|
|
2149
|
-
}
|
|
2150
|
-
return modifiedParams;
|
|
2151
|
-
}
|
|
2152
|
-
/**
|
|
2153
|
-
* Applies schema-aware file preprocessing shared by direct and Tool Router
|
|
2154
|
-
* session execution. This always runs before the caller's `beforeExecute`
|
|
2155
|
-
* hook so the hook observes the exact arguments sent to the backend.
|
|
2156
|
-
*/
|
|
2157
|
-
async applyFileUploadModifiers(tool, { toolSlug, toolkitSlug, params }, beforeFileUpload, requestOptions) {
|
|
2158
|
-
let modifiedParams = params;
|
|
2159
|
-
if (this.autoUploadDownloadFiles) {
|
|
2160
|
-
modifiedParams = await new FileToolModifier(this.client, {
|
|
2161
|
-
...this.fileUploadPathOptions,
|
|
2162
|
-
beforeFileUpload
|
|
2163
|
-
}).fileUploadModifier(tool, {
|
|
2164
|
-
toolSlug,
|
|
2165
|
-
toolkitSlug,
|
|
2166
|
-
params: modifiedParams,
|
|
2167
|
-
signal: requestOptions?.signal
|
|
2168
|
-
});
|
|
2169
|
-
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
2170
|
-
} else if (tool.inputParameters && schemaHasFileUploadable(tool.inputParameters)) {
|
|
2171
|
-
if (modifiedParams.arguments) modifiedParams = {
|
|
2172
|
-
...modifiedParams,
|
|
2173
|
-
arguments: await dropEmptyFileUploads(modifiedParams.arguments, dereferenceJsonSchema(tool.inputParameters, { onUnresolved: "sentinel" }))
|
|
2174
|
-
};
|
|
2175
|
-
if (!this.warnedAutoUploadDisabledForTool.has(toolSlug)) {
|
|
2176
|
-
this.warnedAutoUploadDisabledForTool.add(toolSlug);
|
|
2177
|
-
logger.warn(`Tool "${toolSlug}" (toolkit "${toolkitSlug}") has a file-uploadable input, but \`dangerouslyAllowAutoUploadDownloadFiles\` is disabled. The SDK will forward the file argument as-is; if it isn't already a staged { name, mimetype, s3key } descriptor, the backend will reject the call. Either:\n 1) Stage the file yourself: \`const f = await composio.files.upload({ file, toolSlug, toolkitSlug }); await composio.tools.execute('${toolSlug}', { userId, arguments: { <fileField>: f } })\`, or\n 2) Enable auto-upload with a scoped allowlist: \`new Composio({ dangerouslyAllowAutoUploadDownloadFiles: true, fileUploadDirs: ['/safe/dir'] })\`.`);
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
return modifiedParams;
|
|
2181
|
-
}
|
|
2182
|
-
/**
|
|
2183
|
-
* Applies the after execute modifiers to the tool execution result
|
|
2184
|
-
* @param options.toolSlug - The slug of the tool
|
|
2185
|
-
* @param options.toolkitSlug - The slug of the toolkit
|
|
2186
|
-
* @param options.result - The result of the tool execution
|
|
2187
|
-
* @param modifier - The modifier to apply
|
|
2188
|
-
* @returns The modified result
|
|
2189
|
-
*/
|
|
2190
|
-
async applyAfterExecuteModifiers(tool, { toolSlug, toolkitSlug, result }, modifier, requestOptions) {
|
|
2191
|
-
let modifiedResult = result;
|
|
2192
|
-
if (this.autoUploadDownloadFiles) modifiedResult = await new FileToolModifier(this.client, this.fileUploadPathOptions).fileDownloadModifier(tool, {
|
|
2193
|
-
toolSlug,
|
|
2194
|
-
toolkitSlug,
|
|
2195
|
-
result: modifiedResult,
|
|
2196
|
-
signal: requestOptions?.signal
|
|
2197
|
-
});
|
|
2198
|
-
if (modifier) {
|
|
2199
|
-
if (typeof modifier === "function") modifiedResult = await modifier({
|
|
2200
|
-
toolSlug,
|
|
2201
|
-
toolkitSlug,
|
|
2202
|
-
result: modifiedResult
|
|
2203
|
-
});
|
|
2204
|
-
else throw new ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
|
|
2205
|
-
}
|
|
2206
|
-
return modifiedResult;
|
|
2207
|
-
}
|
|
1512
|
+
async applyAfterExecuteModifiers(tool, { toolSlug, toolkitSlug, result }, modifier, requestOptions) {
|
|
1513
|
+
let modifiedResult = result;
|
|
1514
|
+
if (this.autoUploadDownloadFiles) modifiedResult = await new FileToolModifier(this.client, this.fileUploadPathOptions).fileDownloadModifier(tool, {
|
|
1515
|
+
toolSlug,
|
|
1516
|
+
toolkitSlug,
|
|
1517
|
+
result: modifiedResult,
|
|
1518
|
+
signal: requestOptions?.signal
|
|
1519
|
+
});
|
|
1520
|
+
if (modifier) {
|
|
1521
|
+
if (typeof modifier === "function") modifiedResult = await modifier({
|
|
1522
|
+
toolSlug,
|
|
1523
|
+
toolkitSlug,
|
|
1524
|
+
result: modifiedResult
|
|
1525
|
+
});
|
|
1526
|
+
else throw new ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
|
|
1527
|
+
}
|
|
1528
|
+
return modifiedResult;
|
|
1529
|
+
}
|
|
2208
1530
|
/**
|
|
2209
1531
|
* Lists Composio API tools available to the SDK.
|
|
2210
1532
|
*
|
|
@@ -2560,7 +1882,7 @@ var Tools = class {
|
|
|
2560
1882
|
version: toolkitVersion,
|
|
2561
1883
|
text: body.text
|
|
2562
1884
|
};
|
|
2563
|
-
const result = await withCancellation(() => this.
|
|
1885
|
+
const result = await withCancellation(() => this.client.tools.execute(tool.slug, executeBody, withoutRetries(requestOptions)), requestOptions?.signal);
|
|
2564
1886
|
return this.transformToolExecuteResponse(result);
|
|
2565
1887
|
} catch (error) {
|
|
2566
1888
|
if (error instanceof ComposioRequestCancelledError) throw error;
|
|
@@ -2712,12 +2034,12 @@ var Tools = class {
|
|
|
2712
2034
|
enable_auto_workbench_offload: true
|
|
2713
2035
|
};
|
|
2714
2036
|
if (options?.experimental) executePayload.experimental = options.experimental;
|
|
2715
|
-
const response = await withCancellation(() => this.client.toolRouter.session.execute(body.sessionId, executePayload, requestOptions), requestOptions?.signal);
|
|
2716
|
-
const { data, error, logId, instantCharge } = transformExecuteResponse(response);
|
|
2037
|
+
const response = await withCancellation(() => this.client.toolRouter.session.execute(body.sessionId, executePayload, withoutRetries(requestOptions)), requestOptions?.signal);
|
|
2038
|
+
const { data, error, logId, resultType, instantCharge } = transformExecuteResponse(response, toolSlug);
|
|
2717
2039
|
let result = {
|
|
2718
2040
|
data,
|
|
2719
2041
|
error,
|
|
2720
|
-
successful:
|
|
2042
|
+
successful: isExecutionSuccessful({ resultType }),
|
|
2721
2043
|
logId,
|
|
2722
2044
|
...instantCharge !== void 0 && { instantCharge }
|
|
2723
2045
|
};
|
|
@@ -2789,6 +2111,7 @@ var Tools = class {
|
|
|
2789
2111
|
* @param {string} body.endpoint - Path relative to the toolkit's base URL, or an absolute URL
|
|
2790
2112
|
* @param {'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'} body.method - HTTP method
|
|
2791
2113
|
* @param {string} [body.connectedAccountId] - The connected account to authenticate as
|
|
2114
|
+
* @param {string} [body.userId] - The user the connected account belongs to. Projects with 2FA enabled check it against the connected account and may require it
|
|
2792
2115
|
* @param {unknown} [body.body] - JSON request body
|
|
2793
2116
|
* @param {Array<{ in: 'query' | 'header'; name: string; value: string | number }>} [body.parameters] - Extra query parameters or headers
|
|
2794
2117
|
* @returns {Promise<ToolProxyResponse>} The upstream status, headers, and parsed body
|
|
@@ -2823,6 +2146,7 @@ var Tools = class {
|
|
|
2823
2146
|
method: toolProxyParams.data.method,
|
|
2824
2147
|
body: toolProxyParams.data.body,
|
|
2825
2148
|
connected_account_id: toolProxyParams.data.connectedAccountId,
|
|
2149
|
+
user_id: toolProxyParams.data.userId,
|
|
2826
2150
|
parameters,
|
|
2827
2151
|
/**
|
|
2828
2152
|
* @deprecated The `customConnectionData` proxy param is deprecated and will be
|
|
@@ -2830,7 +2154,7 @@ var Tools = class {
|
|
|
2830
2154
|
*/
|
|
2831
2155
|
custom_connection_data: toolProxyParams.data.customConnectionData
|
|
2832
2156
|
};
|
|
2833
|
-
return withCancellation(() => this.
|
|
2157
|
+
return withCancellation(() => this.client.tools.proxy(proxyBody, withoutRetries(requestOptions)), requestOptions?.signal);
|
|
2834
2158
|
}
|
|
2835
2159
|
};
|
|
2836
2160
|
|
|
@@ -3382,50 +2706,334 @@ var AuthConfigs = class {
|
|
|
3382
2706
|
* await composio.authConfigs.updateStatus('ENABLED', 'auth_abc123');
|
|
3383
2707
|
* ```
|
|
3384
2708
|
*/
|
|
3385
|
-
async updateStatus(status, nanoid, requestOptions) {
|
|
3386
|
-
return withCancellation(() => this.client.authConfigs.updateStatus(status, { nanoid }, requestOptions), requestOptions?.signal);
|
|
3387
|
-
}
|
|
2709
|
+
async updateStatus(status, nanoid, requestOptions) {
|
|
2710
|
+
return withCancellation(() => this.client.authConfigs.updateStatus(status, { nanoid }, requestOptions), requestOptions?.signal);
|
|
2711
|
+
}
|
|
2712
|
+
/**
|
|
2713
|
+
* Enables an authentication configuration.
|
|
2714
|
+
*
|
|
2715
|
+
* This is a convenience method that calls updateStatus with 'ENABLED'.
|
|
2716
|
+
* When enabled, the auth config can be used to create new connected accounts
|
|
2717
|
+
* and authenticate with third-party services.
|
|
2718
|
+
*
|
|
2719
|
+
* @param {string} nanoid - The unique identifier of the auth config to enable
|
|
2720
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
|
|
2721
|
+
* @throws {Error} If the auth config cannot be found or enabled
|
|
2722
|
+
*
|
|
2723
|
+
* @example
|
|
2724
|
+
* ```typescript
|
|
2725
|
+
* // Enable an auth config
|
|
2726
|
+
* await composio.authConfigs.enable('auth_abc123');
|
|
2727
|
+
* ```
|
|
2728
|
+
*/
|
|
2729
|
+
async enable(nanoid, requestOptions) {
|
|
2730
|
+
return withCancellation(() => this.client.authConfigs.updateStatus("ENABLED", { nanoid }, requestOptions), requestOptions?.signal);
|
|
2731
|
+
}
|
|
2732
|
+
/**
|
|
2733
|
+
* Disables an authentication configuration.
|
|
2734
|
+
*
|
|
2735
|
+
* This is a convenience method that calls updateStatus with 'DISABLED'.
|
|
2736
|
+
* When disabled, the auth config cannot be used to create new connected accounts
|
|
2737
|
+
* or authenticate with third-party services, but existing connections may continue to work.
|
|
2738
|
+
*
|
|
2739
|
+
* @param {string} nanoid - The unique identifier of the auth config to disable
|
|
2740
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
|
|
2741
|
+
* @throws {Error} If the auth config cannot be found or disabled
|
|
2742
|
+
*
|
|
2743
|
+
* @example
|
|
2744
|
+
* ```typescript
|
|
2745
|
+
* // Disable an auth config
|
|
2746
|
+
* await composio.authConfigs.disable('auth_abc123');
|
|
2747
|
+
* ```
|
|
2748
|
+
*/
|
|
2749
|
+
async disable(nanoid, requestOptions) {
|
|
2750
|
+
return withCancellation(() => this.client.authConfigs.updateStatus("DISABLED", { nanoid }, requestOptions), requestOptions?.signal);
|
|
2751
|
+
}
|
|
2752
|
+
};
|
|
2753
|
+
|
|
2754
|
+
//#endregion
|
|
2755
|
+
//#region src/types/connectedAccounts.types.ts
|
|
2756
|
+
/**
|
|
2757
|
+
* Connected Account create parameters
|
|
2758
|
+
*/
|
|
2759
|
+
const ConnectedAccountStatuses = {
|
|
2760
|
+
INITIALIZING: "INITIALIZING",
|
|
2761
|
+
INITIATED: "INITIATED",
|
|
2762
|
+
ACTIVE: "ACTIVE",
|
|
2763
|
+
FAILED: "FAILED",
|
|
2764
|
+
EXPIRED: "EXPIRED",
|
|
2765
|
+
INACTIVE: "INACTIVE",
|
|
2766
|
+
REVOKED: "REVOKED"
|
|
2767
|
+
};
|
|
2768
|
+
const ConnectedAccountStatusSchema = z$1.enum([
|
|
2769
|
+
ConnectedAccountStatuses.INITIALIZING,
|
|
2770
|
+
ConnectedAccountStatuses.INITIATED,
|
|
2771
|
+
ConnectedAccountStatuses.ACTIVE,
|
|
2772
|
+
ConnectedAccountStatuses.FAILED,
|
|
2773
|
+
ConnectedAccountStatuses.EXPIRED,
|
|
2774
|
+
ConnectedAccountStatuses.INACTIVE,
|
|
2775
|
+
ConnectedAccountStatuses.REVOKED
|
|
2776
|
+
]);
|
|
2777
|
+
/**
|
|
2778
|
+
* Sharing model for a connected account.
|
|
2779
|
+
*
|
|
2780
|
+
* - `PRIVATE` (default): only the owning `userId` can use the connection.
|
|
2781
|
+
* - `SHARED`: can be used by other `userId`s, but only when the connection
|
|
2782
|
+
* is explicitly pinned in a tool-router session's config and only when
|
|
2783
|
+
* the requesting `userId` passes the connection's ACL (see
|
|
2784
|
+
* `allowAllUsers` / `allowedUserIds` / `notAllowedUserIds`).
|
|
2785
|
+
*/
|
|
2786
|
+
const ConnectedAccountTypes = {
|
|
2787
|
+
PRIVATE: "PRIVATE",
|
|
2788
|
+
SHARED: "SHARED"
|
|
2789
|
+
};
|
|
2790
|
+
const ConnectedAccountTypeSchema = z$1.enum([ConnectedAccountTypes.PRIVATE, ConnectedAccountTypes.SHARED]);
|
|
2791
|
+
/**
|
|
2792
|
+
* Per-user access control for a SHARED connected account. Ignored for
|
|
2793
|
+
* PRIVATE.
|
|
2794
|
+
*
|
|
2795
|
+
* Pass `aclConfigForShared` on create / PATCH to grant access; omit it
|
|
2796
|
+
* to leave the ACL unchanged (on PATCH) or to keep the default
|
|
2797
|
+
* deny-by-default state (on create). On responses, the field is
|
|
2798
|
+
* `undefined` when the caller isn't authorised to see the ACL —
|
|
2799
|
+
* distinguish that from an empty/default state explicitly.
|
|
2800
|
+
*
|
|
2801
|
+
* Resolution rule (deny wins):
|
|
2802
|
+
* 1. requesting `userId` in `notAllowedUserIds` → DENY
|
|
2803
|
+
* 2. `allowAllUsers === true` → ALLOW
|
|
2804
|
+
* 3. requesting `userId` in `allowedUserIds` → ALLOW
|
|
2805
|
+
* 4. otherwise → DENY (deny-by-default)
|
|
2806
|
+
*
|
|
2807
|
+
* Default state (block omitted or `{}`) means only the connection's
|
|
2808
|
+
* creator can use it. The creator must grant access explicitly.
|
|
2809
|
+
*
|
|
2810
|
+
* Limits: each list accepts up to 1000 entries; each `userId` is
|
|
2811
|
+
* 1..256 characters.
|
|
2812
|
+
*/
|
|
2813
|
+
const ACL_LIST_MAX_LENGTH = 1e3;
|
|
2814
|
+
const aclUserIdString = z$1.string().min(1).max(256);
|
|
2815
|
+
const ConnectedAccountAclConfigSchema = z$1.object({
|
|
2816
|
+
allowAllUsers: z$1.boolean().optional().describe("When true, any `userId` may use this SHARED connection (subject to the deny list). Default false."),
|
|
2817
|
+
allowedUserIds: z$1.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings allowed to use this SHARED connection. Default []."),
|
|
2818
|
+
notAllowedUserIds: z$1.array(aclUserIdString).max(ACL_LIST_MAX_LENGTH).optional().describe("Explicit list of `userId` strings denied access. Wins over allow on conflict. Default [].")
|
|
2819
|
+
});
|
|
2820
|
+
/**
|
|
2821
|
+
* Resolved ACL as it appears on responses. All three fields are populated
|
|
2822
|
+
* when the field is visible; the field itself is `undefined` for callers
|
|
2823
|
+
* not authorised to see it.
|
|
2824
|
+
*/
|
|
2825
|
+
const ConnectedAccountAclConfigResponseSchema = z$1.object({
|
|
2826
|
+
allowAllUsers: z$1.boolean(),
|
|
2827
|
+
allowedUserIds: z$1.array(z$1.string()),
|
|
2828
|
+
notAllowedUserIds: z$1.array(z$1.string())
|
|
2829
|
+
});
|
|
2830
|
+
/**
|
|
2831
|
+
* Experimental options for SHARED connections, passed at create / link time.
|
|
2832
|
+
*
|
|
2833
|
+
* **Experimental — shape may change in future releases.** Wrapped under a
|
|
2834
|
+
* dedicated `experimental` block on every input and response so the
|
|
2835
|
+
* experimental status is visible at every call site.
|
|
2836
|
+
*/
|
|
2837
|
+
const ConnectedAccountExperimentalSchema = z$1.object({
|
|
2838
|
+
accountType: ConnectedAccountTypeSchema.optional(),
|
|
2839
|
+
aclConfigForShared: ConnectedAccountAclConfigSchema.optional()
|
|
2840
|
+
});
|
|
2841
|
+
/**
|
|
2842
|
+
* Resolved experimental block on retrieve / list responses. `accountType`
|
|
2843
|
+
* is always present when the block is; `aclConfigForShared` is only
|
|
2844
|
+
* present when the caller is authorised to see the ACL.
|
|
2845
|
+
*/
|
|
2846
|
+
const ConnectedAccountExperimentalResponseSchema = z$1.object({
|
|
2847
|
+
accountType: ConnectedAccountTypeSchema.optional(),
|
|
2848
|
+
aclConfigForShared: ConnectedAccountAclConfigResponseSchema.optional()
|
|
2849
|
+
});
|
|
2850
|
+
const CreateConnectedAccountParamsSchema = z$1.object({
|
|
2851
|
+
authConfig: z$1.object({ id: z$1.string() }),
|
|
2852
|
+
connection: z$1.object({
|
|
2853
|
+
data: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
2854
|
+
callbackUrl: z$1.string().optional(),
|
|
2855
|
+
userId: z$1.string().optional()
|
|
2856
|
+
})
|
|
2857
|
+
});
|
|
2858
|
+
const DefaultCreateConnectedAccountParamsSchema = z$1.object({
|
|
2859
|
+
auth_config: z$1.object({ id: z$1.string() }),
|
|
2860
|
+
connection: z$1.object({
|
|
2861
|
+
state: ConnectionDataSchema.optional(),
|
|
2862
|
+
data: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
2863
|
+
callback_url: z$1.string().optional(),
|
|
2864
|
+
user_id: z$1.string().optional(),
|
|
2865
|
+
alias: z$1.string().optional()
|
|
2866
|
+
})
|
|
2867
|
+
});
|
|
2868
|
+
const CreateConnectedAccountOptionsSchema = z$1.object({
|
|
2869
|
+
allowMultiple: z$1.boolean().optional(),
|
|
2870
|
+
callbackUrl: z$1.string().optional(),
|
|
2871
|
+
config: ConnectionDataSchema.optional(),
|
|
2872
|
+
alias: z$1.string().optional()
|
|
2873
|
+
});
|
|
2874
|
+
/**
|
|
2875
|
+
* Connected Account create response
|
|
2876
|
+
*/
|
|
2877
|
+
const CreateConnectedAccountResponseSchema = z$1.object({
|
|
2878
|
+
id: z$1.string(),
|
|
2879
|
+
status: ConnectedAccountStatusSchema,
|
|
2880
|
+
redirectUrl: z$1.string().nullable()
|
|
2881
|
+
});
|
|
2882
|
+
const ConnectedAccountAuthConfigSchema = z$1.object({
|
|
2883
|
+
id: z$1.string(),
|
|
2884
|
+
/** @deprecated Use `connectedAccount.state.authScheme` instead. */
|
|
2885
|
+
authScheme: AuthSchemeEnum.optional(),
|
|
2886
|
+
isComposioManaged: z$1.boolean(),
|
|
2887
|
+
isDisabled: z$1.boolean()
|
|
2888
|
+
});
|
|
2889
|
+
const ConnectedAccountRetrieveResponseSchema = z$1.object({
|
|
2890
|
+
id: z$1.string(),
|
|
2891
|
+
authConfig: ConnectedAccountAuthConfigSchema,
|
|
2892
|
+
wordId: z$1.string().nullable().optional(),
|
|
2893
|
+
alias: z$1.string().nullable().optional(),
|
|
2894
|
+
/**
|
|
2895
|
+
* @deprecated Use `connectedAccount.state` instead — `data` is a legacy raw credential field.
|
|
2896
|
+
*/
|
|
2897
|
+
data: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
2898
|
+
/**
|
|
2899
|
+
* @deprecated Use `connectedAccount.state` instead — `params` is a legacy raw credential field.
|
|
2900
|
+
*/
|
|
2901
|
+
params: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
2902
|
+
status: ConnectedAccountStatusSchema,
|
|
2903
|
+
statusReason: z$1.string().nullable(),
|
|
2904
|
+
toolkit: z$1.object({ slug: z$1.string() }),
|
|
2905
|
+
state: ConnectionDataSchema.optional(),
|
|
2906
|
+
testRequestEndpoint: z$1.string().optional(),
|
|
2907
|
+
isDisabled: z$1.boolean(),
|
|
2908
|
+
createdAt: z$1.string(),
|
|
2909
|
+
updatedAt: z$1.string(),
|
|
2910
|
+
experimental: ConnectedAccountExperimentalResponseSchema.optional()
|
|
2911
|
+
});
|
|
2912
|
+
const ConnectedAccountListParamsSchema = z$1.object({
|
|
2913
|
+
authConfigIds: z$1.array(z$1.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
|
|
2914
|
+
cursor: z$1.string().nullish().describe("The cursor to paginate through the connected accounts"),
|
|
2915
|
+
limit: z$1.number().nullable().optional().describe("The limit of the connected accounts to return"),
|
|
2916
|
+
orderBy: z$1.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
|
|
2917
|
+
statuses: z$1.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
|
|
2918
|
+
toolkitSlugs: z$1.array(z$1.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
|
|
2919
|
+
userIds: z$1.array(z$1.string()).nullable().optional().describe("The user ids of the connected accounts"),
|
|
2920
|
+
/**
|
|
2921
|
+
* Experimental — shape may change in future releases. Filter by sharing
|
|
2922
|
+
* model. Default (omitted) returns PRIVATE only. Pass `'SHARED'` for only
|
|
2923
|
+
* shared accounts, or `'ALL'` for `PRIVATE` + `SHARED`. Kept flat because
|
|
2924
|
+
* the wire is a query string and can't carry nested objects.
|
|
2925
|
+
*/
|
|
2926
|
+
accountType: z$1.enum([
|
|
2927
|
+
"PRIVATE",
|
|
2928
|
+
"SHARED",
|
|
2929
|
+
"ALL"
|
|
2930
|
+
]).optional()
|
|
2931
|
+
});
|
|
2932
|
+
const ConnectedAccountListResponseSchema = z$1.object({
|
|
2933
|
+
items: z$1.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
|
|
2934
|
+
nextCursor: z$1.string().nullish().describe("The next cursor to paginate through the connected accounts"),
|
|
2935
|
+
totalPages: z$1.number().describe("The total number of pages of connected accounts")
|
|
2936
|
+
});
|
|
2937
|
+
const CreateConnectedAccountLinkOptionsSchema = z$1.object({
|
|
3388
2938
|
/**
|
|
3389
|
-
*
|
|
2939
|
+
* The url to redirect the user to post connecting their account.
|
|
3390
2940
|
*
|
|
3391
|
-
*
|
|
3392
|
-
*
|
|
3393
|
-
* and authenticate with third-party services.
|
|
2941
|
+
* For successful connections, you will get a query param called status=success
|
|
2942
|
+
* And for failed connections you will get a query param called status=failed
|
|
3394
2943
|
*
|
|
3395
|
-
* @
|
|
3396
|
-
* @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
|
|
3397
|
-
* @throws {Error} If the auth config cannot be found or enabled
|
|
2944
|
+
* @example https://your-app.com/callback
|
|
3398
2945
|
*
|
|
3399
|
-
* @example
|
|
3400
|
-
* ```typescript
|
|
3401
|
-
* // Enable an auth config
|
|
3402
|
-
* await composio.authConfigs.enable('auth_abc123');
|
|
3403
|
-
* ```
|
|
3404
2946
|
*/
|
|
3405
|
-
|
|
3406
|
-
return withCancellation(() => this.client.authConfigs.updateStatus("ENABLED", { nanoid }, requestOptions), requestOptions?.signal);
|
|
3407
|
-
}
|
|
2947
|
+
callbackUrl: z$1.string().optional(),
|
|
3408
2948
|
/**
|
|
3409
|
-
*
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
*
|
|
2949
|
+
* Human-readable alias for the connected account. Must be unique per userId and toolkit within the project.
|
|
2950
|
+
*/
|
|
2951
|
+
alias: z$1.string().optional(),
|
|
2952
|
+
/**
|
|
2953
|
+
* Whether to allow multiple connected accounts for the same user and auth config.
|
|
2954
|
+
* When `false` (default), `link()` throws `ComposioMultipleConnectedAccountsError`
|
|
2955
|
+
* if the user already has an `ACTIVE` connection on this auth config — matching
|
|
2956
|
+
* the guard on `initiate()`. Pair with `alias` and a session-level
|
|
2957
|
+
* `multiAccount` config to disambiguate at execution time.
|
|
2958
|
+
*/
|
|
2959
|
+
allowMultiple: z$1.boolean().optional(),
|
|
2960
|
+
/**
|
|
2961
|
+
* Experimental options for SHARED connections. Pass `accountType: 'SHARED'`
|
|
2962
|
+
* (and optionally `aclConfigForShared`) to create a connection that can
|
|
2963
|
+
* be reached by other `userId`s when pinned in a session.
|
|
3414
2964
|
*
|
|
3415
|
-
*
|
|
3416
|
-
* @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
|
|
3417
|
-
* @throws {Error} If the auth config cannot be found or disabled
|
|
2965
|
+
* Experimental — shape may change in future releases.
|
|
3418
2966
|
*
|
|
3419
|
-
*
|
|
3420
|
-
*
|
|
3421
|
-
*
|
|
3422
|
-
*
|
|
3423
|
-
*
|
|
2967
|
+
* `aclConfigForShared` is only valid when `accountType === 'SHARED'`;
|
|
2968
|
+
* raises `ComposioAclOnlyForSharedError` on a PRIVATE connection. Omit
|
|
2969
|
+
* the inner block (or pass `{}`) to keep the deny-by-default state: only
|
|
2970
|
+
* the creator can use the connection. Grant access by setting
|
|
2971
|
+
* `allowAllUsers: true` or listing user IDs in `allowedUserIds`.
|
|
2972
|
+
* `notAllowedUserIds` always wins over allow.
|
|
3424
2973
|
*/
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
2974
|
+
experimental: ConnectedAccountExperimentalSchema.optional()
|
|
2975
|
+
});
|
|
2976
|
+
const CreateConnectedAccountLinkResponseSchema = z$1.object({ redirectUrl: z$1.string() });
|
|
2977
|
+
const ConnectedAccountRefreshOptionsSchema = z$1.object({
|
|
2978
|
+
redirectUrl: z$1.string().optional(),
|
|
2979
|
+
/**
|
|
2980
|
+
* @deprecated The Composio API no longer accepts this field. It is ignored
|
|
2981
|
+
* and `refresh()` logs a warning when it is set.
|
|
2982
|
+
*/
|
|
2983
|
+
validateCredentials: z$1.boolean().optional()
|
|
2984
|
+
});
|
|
2985
|
+
const UpdateConnectedAccountParamsSchema = z$1.object({ enabled: z$1.boolean() });
|
|
2986
|
+
/**
|
|
2987
|
+
* Params for `composio.connectedAccounts.updateAcl()`. Mirrors the inner
|
|
2988
|
+
* shape of the wire's `acl_config_for_shared` block — the SDK adds the
|
|
2989
|
+
* outer nesting at the boundary, so callers pass the three fields flat.
|
|
2990
|
+
*
|
|
2991
|
+
* PATCH-style semantics — omit a field to leave it unchanged; pass an
|
|
2992
|
+
* empty array to clear an allow/deny list. Raises
|
|
2993
|
+
* `ComposioAclOnlyForSharedError` on a PRIVATE connection.
|
|
2994
|
+
*
|
|
2995
|
+
* Each field is optional, but at least one must be provided — passing an
|
|
2996
|
+
* empty object is rejected as a no-op.
|
|
2997
|
+
*/
|
|
2998
|
+
const UpdateConnectedAccountAclParamsSchema = ConnectedAccountAclConfigSchema.refine((acl) => acl.allowAllUsers !== void 0 || acl.allowedUserIds !== void 0 || acl.notAllowedUserIds !== void 0, { message: "At least one of allowAllUsers, allowedUserIds, or notAllowedUserIds must be provided" });
|
|
2999
|
+
/**
|
|
3000
|
+
* Response of `composio.connectedAccounts.revoke()`.
|
|
3001
|
+
*/
|
|
3002
|
+
const ConnectedAccountRevokedTokenSchema = z$1.enum([
|
|
3003
|
+
"access_token",
|
|
3004
|
+
"refresh_token",
|
|
3005
|
+
"credential"
|
|
3006
|
+
]);
|
|
3007
|
+
const ConnectedAccountRevokeResponseSchema = z$1.object({
|
|
3008
|
+
/**
|
|
3009
|
+
* Tokens revoked at the provider on this call. An empty array means the
|
|
3010
|
+
* connection was already revoked (no upstream dispatch).
|
|
3011
|
+
*/
|
|
3012
|
+
revokedTokens: z$1.array(ConnectedAccountRevokedTokenSchema),
|
|
3013
|
+
connectedAccount: z$1.object({
|
|
3014
|
+
id: z$1.string(),
|
|
3015
|
+
/** The connection status after this call (`REVOKED` on success). */
|
|
3016
|
+
status: ConnectedAccountStatusSchema
|
|
3017
|
+
})
|
|
3018
|
+
});
|
|
3019
|
+
/**
|
|
3020
|
+
* Params for `composio.connectedAccounts.completeAuth()`.
|
|
3021
|
+
*/
|
|
3022
|
+
const ConnectedAccountCompleteAuthParamsSchema = z$1.object({
|
|
3023
|
+
/** The user the connection was initiated for. Must match the connection owner. */
|
|
3024
|
+
userId: z$1.string().min(1),
|
|
3025
|
+
/** The opaque, single-use session URI your OAuth callback verifier received. */
|
|
3026
|
+
sessionUri: z$1.string().min(1)
|
|
3027
|
+
});
|
|
3028
|
+
/**
|
|
3029
|
+
* Response of `composio.connectedAccounts.completeAuth()`.
|
|
3030
|
+
*/
|
|
3031
|
+
const ConnectedAccountCompleteAuthResponseSchema = z$1.object({
|
|
3032
|
+
/** The connection that was completed; it is now `ACTIVE`. */
|
|
3033
|
+
connectedAccountId: z$1.string(),
|
|
3034
|
+
/** The toolkit the connection belongs to. */
|
|
3035
|
+
toolkitSlug: z$1.string()
|
|
3036
|
+
});
|
|
3429
3037
|
|
|
3430
3038
|
//#endregion
|
|
3431
3039
|
//#region src/utils/transformers/connectedAccounts.ts
|
|
@@ -3707,14 +3315,13 @@ const transformUsageBreakdownParams = (params) => ({
|
|
|
3707
3315
|
filters: transformUsageFilters(params.filters)
|
|
3708
3316
|
});
|
|
3709
3317
|
const transformUsageSummaryResponse = (response) => {
|
|
3710
|
-
const { instant_charge } = z$1.object({ instant_charge: z$1.string() }).parse(response);
|
|
3711
3318
|
return transform(response).with(UsageSummaryResponseSchema).using((response) => ({
|
|
3712
3319
|
entities: Object.fromEntries(Object.entries(response.entities).map(([entityType, entity]) => [entityType, {
|
|
3713
3320
|
unit: entity.unit,
|
|
3714
3321
|
totalQuantity: entity.total_quantity,
|
|
3715
3322
|
eventCount: entity.event_count
|
|
3716
3323
|
}])),
|
|
3717
|
-
instantCharge: instant_charge
|
|
3324
|
+
instantCharge: response.instant_charge
|
|
3718
3325
|
}));
|
|
3719
3326
|
};
|
|
3720
3327
|
const transformUsageBreakdownResponse = (response) => {
|
|
@@ -4048,7 +3655,7 @@ var CustomToolkits = class {
|
|
|
4048
3655
|
* ```
|
|
4049
3656
|
*/
|
|
4050
3657
|
async delete(slug, requestOptions) {
|
|
4051
|
-
const result = await withCancellation(() => this.client.custom.deleteToolkit(slug, requestOptions), requestOptions?.signal);
|
|
3658
|
+
const result = await withCancellation(() => this.client.custom.deleteToolkit(slug, {}, requestOptions), requestOptions?.signal);
|
|
4052
3659
|
return transformCustomToolkitDeleteResponse(result);
|
|
4053
3660
|
}
|
|
4054
3661
|
};
|
|
@@ -7517,397 +7124,818 @@ var MCP = class {
|
|
|
7517
7124
|
return transformMCPItemResponse(await withCancellation(() => this.client.mcp.retrieve(serverId, requestOptions), requestOptions?.signal));
|
|
7518
7125
|
}
|
|
7519
7126
|
/**
|
|
7520
|
-
* Delete an MCP server configuration permanently
|
|
7521
|
-
* @param {string} serverId - The unique identifier of the MCP server to delete
|
|
7522
|
-
* @returns {Promise<{id: string; deleted: boolean}>} Confirmation object with server ID and deletion status
|
|
7127
|
+
* Delete an MCP server configuration permanently
|
|
7128
|
+
* @param {string} serverId - The unique identifier of the MCP server to delete
|
|
7129
|
+
* @returns {Promise<{id: string; deleted: boolean}>} Confirmation object with server ID and deletion status
|
|
7130
|
+
*
|
|
7131
|
+
* @example
|
|
7132
|
+
* ```typescript
|
|
7133
|
+
* // Delete an MCP server by ID
|
|
7134
|
+
* const result = await composio.experimental.mcp.delete("mcp_12345");
|
|
7135
|
+
*
|
|
7136
|
+
* if (result.deleted) {
|
|
7137
|
+
* console.log(`Server ${result.id} has been successfully deleted`);
|
|
7138
|
+
* } else {
|
|
7139
|
+
* console.log(`Failed to delete server ${result.id}`);
|
|
7140
|
+
* }
|
|
7141
|
+
*
|
|
7142
|
+
* // Example with error handling
|
|
7143
|
+
* try {
|
|
7144
|
+
* const result = await composio.experimental.mcp.delete("mcp_12345");
|
|
7145
|
+
* console.log("Deletion successful:", result);
|
|
7146
|
+
* } catch (error) {
|
|
7147
|
+
* console.error("Failed to delete MCP server:", error.message);
|
|
7148
|
+
* }
|
|
7149
|
+
*
|
|
7150
|
+
* // Delete and verify from list
|
|
7151
|
+
* await composio.experimental.mcp.delete("mcp_12345");
|
|
7152
|
+
* const servers = await composio.experimental.mcp.list({});
|
|
7153
|
+
* const serverExists = servers.items.some(server => server.id === "mcp_12345");
|
|
7154
|
+
* console.log("Server still exists:", serverExists); // Should be false
|
|
7155
|
+
* ```
|
|
7156
|
+
*
|
|
7157
|
+
* @throws {ValidationError} When the server ID is invalid or server not found
|
|
7158
|
+
* @throws {Error} When the server cannot be deleted due to active connections or other constraints
|
|
7159
|
+
*
|
|
7160
|
+
* @warning This operation is irreversible. Once deleted, the MCP server configuration and all its associated data will be permanently removed.
|
|
7161
|
+
*/
|
|
7162
|
+
async delete(serverId, requestOptions) {
|
|
7163
|
+
return withCancellation(() => this.client.mcp.delete(serverId, requestOptions), requestOptions?.signal);
|
|
7164
|
+
}
|
|
7165
|
+
/**
|
|
7166
|
+
* Update an existing MCP server configuration with new settings
|
|
7167
|
+
* @param {string} serverId - The unique identifier of the MCP server to update
|
|
7168
|
+
* @param {Object} config - Update configuration parameters
|
|
7169
|
+
* @param {string} [config.name] - New name for the MCP server
|
|
7170
|
+
* @param {Array} [config.toolkits] - Updated toolkit configurations
|
|
7171
|
+
* @param {string} [config.toolkits[].toolkit] - Toolkit identifier (e.g., "github", "slack")
|
|
7172
|
+
* @param {string} [config.toolkits[].authConfigId] - Auth configuration ID for the toolkit
|
|
7173
|
+
* @param {string[]} [config.toolkits[].allowedTools] - Specific tools to enable for this toolkit
|
|
7174
|
+
* @param {boolean} [config.manuallyManageConnections] - Whether to manually manage account connections
|
|
7175
|
+
* @returns {Promise<MCPItem>} Updated MCP server configuration with all details
|
|
7176
|
+
*
|
|
7177
|
+
* @example
|
|
7178
|
+
* ```typescript
|
|
7179
|
+
* // Update server name only
|
|
7180
|
+
* const updatedServer = await composio.experimental.mcp.update("mcp_12345", {
|
|
7181
|
+
* name: "My Updated MCP Server"
|
|
7182
|
+
* });
|
|
7183
|
+
*
|
|
7184
|
+
* // Update toolkits and tools
|
|
7185
|
+
* const serverWithNewTools = await composio.experimental.mcp.update("mcp_12345", {
|
|
7186
|
+
* toolkits: [
|
|
7187
|
+
* {
|
|
7188
|
+
* toolkit: "github",
|
|
7189
|
+
* authConfigId: "auth_abc123",
|
|
7190
|
+
* allowedTools: ["GITHUB_CREATE_ISSUE", "GITHUB_LIST_REPOS"]
|
|
7191
|
+
* },
|
|
7192
|
+
* {
|
|
7193
|
+
* toolkit: "slack",
|
|
7194
|
+
* authConfigId: "auth_xyz789",
|
|
7195
|
+
* allowedTools: ["SLACK_SEND_MESSAGE", "SLACK_LIST_CHANNELS"]
|
|
7196
|
+
* }
|
|
7197
|
+
* ]
|
|
7198
|
+
* });
|
|
7199
|
+
*
|
|
7200
|
+
* // Update connection management setting
|
|
7201
|
+
* const serverWithManualAuth = await composio.experimental.mcp.update("mcp_12345", {
|
|
7202
|
+
* name: "Manual Auth Server",
|
|
7203
|
+
* manuallyManageConnections: true
|
|
7204
|
+
* });
|
|
7205
|
+
*
|
|
7206
|
+
* // Complete update example
|
|
7207
|
+
* const fullyUpdatedServer = await composio.experimental.mcp.update("mcp_12345", {
|
|
7208
|
+
* name: "Production MCP Server",
|
|
7209
|
+
* toolkits: [
|
|
7210
|
+
* {
|
|
7211
|
+
* toolkit: "gmail",
|
|
7212
|
+
* authConfigId: "auth_gmail_prod",
|
|
7213
|
+
* }
|
|
7214
|
+
* ],
|
|
7215
|
+
* allowedTools: ["GMAIL_SEND_EMAIL", "GMAIL_FETCH_EMAILS"]
|
|
7216
|
+
* manuallyManageConnections: false
|
|
7217
|
+
* });
|
|
7218
|
+
*
|
|
7219
|
+
* console.log("Updated server:", fullyUpdatedServer.name);
|
|
7220
|
+
* console.log("New tools:", fullyUpdatedServer.allowedTools);
|
|
7221
|
+
* ```
|
|
7222
|
+
*
|
|
7223
|
+
* @throws {ValidationError} When the update parameters are invalid or malformed
|
|
7224
|
+
* @throws {Error} When the server ID doesn't exist or update fails
|
|
7225
|
+
*
|
|
7226
|
+
* @note Only provided fields will be updated. Omitted fields will retain their current values.
|
|
7227
|
+
* @note When updating toolkits, the entire toolkit configuration is replaced, not merged.
|
|
7228
|
+
*/
|
|
7229
|
+
async update(serverId, config, requestOptions) {
|
|
7230
|
+
const { data: params, error } = MCPUpdateParamsSchema.safeParse(config);
|
|
7231
|
+
if (error) throw new ValidationError("Failed to validate update params", { cause: error });
|
|
7232
|
+
const toolkits = [];
|
|
7233
|
+
const auth_config_ids = [];
|
|
7234
|
+
params.toolkits?.forEach((toolkit) => {
|
|
7235
|
+
if (typeof toolkit === "string") toolkits.push(toolkit);
|
|
7236
|
+
else {
|
|
7237
|
+
if (toolkit.toolkit) toolkits.push(toolkit.toolkit);
|
|
7238
|
+
if (toolkit.authConfigId) auth_config_ids.push(toolkit.authConfigId);
|
|
7239
|
+
}
|
|
7240
|
+
});
|
|
7241
|
+
const updateBody = {
|
|
7242
|
+
...params.name !== void 0 ? { name: params.name } : {},
|
|
7243
|
+
...params.toolkits !== void 0 ? {
|
|
7244
|
+
toolkits,
|
|
7245
|
+
auth_config_ids
|
|
7246
|
+
} : {},
|
|
7247
|
+
...params.allowedTools !== void 0 ? { allowed_tools: params.allowedTools } : {},
|
|
7248
|
+
...params.manuallyManageConnections !== void 0 ? { managed_auth_via_composio: !params.manuallyManageConnections } : {}
|
|
7249
|
+
};
|
|
7250
|
+
return transformMCPItemResponse(await withCancellation(() => this.client.mcp.update(serverId, updateBody, requestOptions), requestOptions?.signal));
|
|
7251
|
+
}
|
|
7252
|
+
/**
|
|
7253
|
+
* Get server URLs for an existing MCP server.
|
|
7254
|
+
* The response is wrapped according to the provider's specifications.
|
|
7523
7255
|
*
|
|
7524
7256
|
* @example
|
|
7525
7257
|
* ```typescript
|
|
7526
|
-
*
|
|
7527
|
-
* const result = await composio.experimental.mcp.delete("mcp_12345");
|
|
7528
|
-
*
|
|
7529
|
-
* if (result.deleted) {
|
|
7530
|
-
* console.log(`Server ${result.id} has been successfully deleted`);
|
|
7531
|
-
* } else {
|
|
7532
|
-
* console.log(`Failed to delete server ${result.id}`);
|
|
7533
|
-
* }
|
|
7534
|
-
*
|
|
7535
|
-
* // Example with error handling
|
|
7536
|
-
* try {
|
|
7537
|
-
* const result = await composio.experimental.mcp.delete("mcp_12345");
|
|
7538
|
-
* console.log("Deletion successful:", result);
|
|
7539
|
-
* } catch (error) {
|
|
7540
|
-
* console.error("Failed to delete MCP server:", error.message);
|
|
7541
|
-
* }
|
|
7258
|
+
* import { Composio } from "@composio/code";
|
|
7542
7259
|
*
|
|
7543
|
-
*
|
|
7544
|
-
* await composio.experimental.mcp.
|
|
7545
|
-
* const servers = await composio.experimental.mcp.list({});
|
|
7546
|
-
* const serverExists = servers.items.some(server => server.id === "mcp_12345");
|
|
7547
|
-
* console.log("Server still exists:", serverExists); // Should be false
|
|
7260
|
+
* const composio = new Composio();
|
|
7261
|
+
* const mcp = await composio.experimental.mcp.generate("default", "<mcp_config_id>");
|
|
7548
7262
|
* ```
|
|
7549
7263
|
*
|
|
7550
|
-
* @
|
|
7551
|
-
* @
|
|
7552
|
-
*
|
|
7553
|
-
* @
|
|
7264
|
+
* @param userId {string} external user id from your database for whom you want the server for
|
|
7265
|
+
* @param mcpConfigId {string} config id of the MCPConfig for which you want to create a server for
|
|
7266
|
+
* @param options {object} additional options
|
|
7267
|
+
* @param options.isChatAuth {boolean} Authenticate the users via chat when they use the MCP Server
|
|
7554
7268
|
*/
|
|
7555
|
-
async
|
|
7556
|
-
|
|
7269
|
+
async generate(userId, mcpConfigId, options, requestOptions) {
|
|
7270
|
+
const server = await withCancellation(() => this.client.mcp.retrieve(mcpConfigId, requestOptions), requestOptions?.signal);
|
|
7271
|
+
const params = MCPGetInstanceParamsSchema.safeParse(options ?? { manuallyManageConnections: false });
|
|
7272
|
+
if (params.error) throw new ValidationError("Invalid params passed for Get Instance Params", { cause: params.error });
|
|
7273
|
+
const urlBody = {
|
|
7274
|
+
mcp_server_id: mcpConfigId,
|
|
7275
|
+
user_ids: [userId],
|
|
7276
|
+
managed_auth_by_composio: options?.manuallyManageConnections ? false : true
|
|
7277
|
+
};
|
|
7278
|
+
const userIdsURL = (await withCancellation(() => this.client.mcp.generate.url(urlBody, requestOptions), requestOptions?.signal)).user_ids_url[0];
|
|
7279
|
+
const serverInstance = MCPServerInstanceSchema.safeParse({
|
|
7280
|
+
id: server.id,
|
|
7281
|
+
name: server.name,
|
|
7282
|
+
type: "streamable_http",
|
|
7283
|
+
url: userIdsURL,
|
|
7284
|
+
userId,
|
|
7285
|
+
allowedTools: server.allowed_tools,
|
|
7286
|
+
authConfigs: server.auth_config_ids
|
|
7287
|
+
});
|
|
7288
|
+
if (serverInstance.error) throw new ValidationError("Failed to parse MCP server instance", { cause: serverInstance.error });
|
|
7289
|
+
return serverInstance.data;
|
|
7557
7290
|
}
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7291
|
+
};
|
|
7292
|
+
|
|
7293
|
+
//#endregion
|
|
7294
|
+
//#region src/types/logs.types.ts
|
|
7295
|
+
/**
|
|
7296
|
+
* Fields a tool-execution log search can filter on.
|
|
7297
|
+
*/
|
|
7298
|
+
const LogSearchFilterFieldSchema = z$1.enum([
|
|
7299
|
+
"tool_slug",
|
|
7300
|
+
"toolkit_slug",
|
|
7301
|
+
"connected_account_id",
|
|
7302
|
+
"auth_config_id",
|
|
7303
|
+
"status",
|
|
7304
|
+
"user_id",
|
|
7305
|
+
"session_id",
|
|
7306
|
+
"sandbox_id",
|
|
7307
|
+
"request_id",
|
|
7308
|
+
"log_id"
|
|
7309
|
+
]);
|
|
7310
|
+
const LogSearchFilterOperatorSchema = z$1.enum([
|
|
7311
|
+
"==",
|
|
7312
|
+
"!=",
|
|
7313
|
+
"contains",
|
|
7314
|
+
"not_contains"
|
|
7315
|
+
]);
|
|
7316
|
+
const LogSearchFilterSchema = z$1.object({
|
|
7317
|
+
field: LogSearchFilterFieldSchema,
|
|
7318
|
+
operator: LogSearchFilterOperatorSchema,
|
|
7319
|
+
value: z$1.string()
|
|
7320
|
+
});
|
|
7321
|
+
const LogSearchTimeRangeSchema = z$1.object({
|
|
7322
|
+
/** Start time in epoch milliseconds (inclusive). */
|
|
7323
|
+
from: z$1.number(),
|
|
7324
|
+
/** End time in epoch milliseconds. */
|
|
7325
|
+
to: z$1.number()
|
|
7326
|
+
});
|
|
7327
|
+
/**
|
|
7328
|
+
* Params for `composio.logs.search()`.
|
|
7329
|
+
*/
|
|
7330
|
+
const LogSearchParamsSchema = z$1.object({
|
|
7331
|
+
limit: z$1.number().optional(),
|
|
7332
|
+
cursor: z$1.string().nullable().optional(),
|
|
7333
|
+
filters: z$1.array(LogSearchFilterSchema).optional(),
|
|
7334
|
+
timeRange: LogSearchTimeRangeSchema.optional()
|
|
7335
|
+
});
|
|
7336
|
+
const ToolExecutionLogStatusSchema = z$1.enum(["success", "failed"]);
|
|
7337
|
+
const ToolExecutionLogLevelSchema = z$1.enum([
|
|
7338
|
+
"info",
|
|
7339
|
+
"error",
|
|
7340
|
+
"warn"
|
|
7341
|
+
]);
|
|
7342
|
+
const ToolExecutionLogParentSchema = z$1.object({
|
|
7343
|
+
logId: z$1.string(),
|
|
7344
|
+
toolSlug: z$1.string()
|
|
7345
|
+
}).nullable();
|
|
7346
|
+
/** Tool log metadata, including the optional exact USD Instant charge. */
|
|
7347
|
+
const ToolExecutionLogMetadataSchema = z$1.object({ instant_charge: z$1.string().optional() }).catchall(z$1.unknown());
|
|
7348
|
+
/**
|
|
7349
|
+
* A tool-execution log entry as returned by `composio.logs.search()`.
|
|
7350
|
+
*/
|
|
7351
|
+
const ToolExecutionLogSchema = z$1.object({
|
|
7352
|
+
id: z$1.string(),
|
|
7353
|
+
/** ISO 8601 timestamp. */
|
|
7354
|
+
timestamp: z$1.string(),
|
|
7355
|
+
/** Log event type, e.g. `tool.execution`. */
|
|
7356
|
+
type: z$1.string(),
|
|
7357
|
+
status: ToolExecutionLogStatusSchema,
|
|
7358
|
+
level: ToolExecutionLogLevelSchema,
|
|
7359
|
+
message: z$1.string().optional(),
|
|
7360
|
+
metadata: ToolExecutionLogMetadataSchema,
|
|
7361
|
+
metrics: z$1.record(z$1.string(), z$1.unknown()),
|
|
7362
|
+
parent: ToolExecutionLogParentSchema
|
|
7363
|
+
});
|
|
7364
|
+
const LogSearchResponseSchema = z$1.object({
|
|
7365
|
+
logs: z$1.array(ToolExecutionLogSchema),
|
|
7366
|
+
nextCursor: z$1.string().nullable()
|
|
7367
|
+
});
|
|
7368
|
+
/**
|
|
7369
|
+
* A single tool-execution log with its full detail, as returned by
|
|
7370
|
+
* `composio.logs.get()`.
|
|
7371
|
+
*/
|
|
7372
|
+
const ToolExecutionLogDetailSchema = ToolExecutionLogSchema.extend({
|
|
7373
|
+
timings: z$1.object({
|
|
7374
|
+
/** Epoch milliseconds. */
|
|
7375
|
+
startTime: z$1.number(),
|
|
7376
|
+
/** Epoch milliseconds. */
|
|
7377
|
+
endTime: z$1.number()
|
|
7378
|
+
}).optional(),
|
|
7379
|
+
context: z$1.object({
|
|
7380
|
+
sessionId: z$1.string().optional(),
|
|
7381
|
+
traceId: z$1.string().optional(),
|
|
7382
|
+
requestId: z$1.string().optional()
|
|
7383
|
+
}),
|
|
7384
|
+
source: z$1.object({
|
|
7385
|
+
host: z$1.string().optional(),
|
|
7386
|
+
framework: z$1.string().optional(),
|
|
7387
|
+
language: z$1.string().optional()
|
|
7388
|
+
}),
|
|
7389
|
+
data: z$1.record(z$1.string(), z$1.unknown())
|
|
7390
|
+
});
|
|
7391
|
+
|
|
7392
|
+
//#endregion
|
|
7393
|
+
//#region src/utils/transformers/logs.ts
|
|
7394
|
+
const transformLogSearchParams = (params) => ({
|
|
7395
|
+
limit: params.limit,
|
|
7396
|
+
cursor: params.cursor,
|
|
7397
|
+
filters: params.filters,
|
|
7398
|
+
time_range: params.timeRange
|
|
7399
|
+
});
|
|
7400
|
+
const transformToolExecutionLog = (response) => {
|
|
7401
|
+
return transform(response).with(ToolExecutionLogSchema).using((response) => ({
|
|
7402
|
+
id: response.id,
|
|
7403
|
+
timestamp: response.timestamp,
|
|
7404
|
+
type: response.type,
|
|
7405
|
+
status: response.status,
|
|
7406
|
+
level: response.level,
|
|
7407
|
+
message: response.message,
|
|
7408
|
+
metadata: ToolExecutionLogMetadataSchema.parse(response.metadata),
|
|
7409
|
+
metrics: response.metrics,
|
|
7410
|
+
parent: response.parent ? {
|
|
7411
|
+
logId: response.parent.log_id,
|
|
7412
|
+
toolSlug: response.parent.tool_slug
|
|
7413
|
+
} : null
|
|
7414
|
+
}));
|
|
7415
|
+
};
|
|
7416
|
+
const transformLogSearchResponse = (response) => {
|
|
7417
|
+
return transform(response).with(LogSearchResponseSchema).using((response) => ({
|
|
7418
|
+
logs: response.logs.map(transformToolExecutionLog),
|
|
7419
|
+
nextCursor: response.next_cursor
|
|
7420
|
+
}));
|
|
7421
|
+
};
|
|
7422
|
+
const transformToolExecutionLogDetail = (response) => {
|
|
7423
|
+
return transform(response).with(ToolExecutionLogDetailSchema).using((response) => ({
|
|
7424
|
+
id: response.id,
|
|
7425
|
+
timestamp: response.timestamp,
|
|
7426
|
+
type: response.type,
|
|
7427
|
+
status: response.status,
|
|
7428
|
+
level: response.level,
|
|
7429
|
+
message: response.message,
|
|
7430
|
+
metadata: ToolExecutionLogMetadataSchema.parse(response.metadata),
|
|
7431
|
+
metrics: response.metrics,
|
|
7432
|
+
parent: response.parent ? {
|
|
7433
|
+
logId: response.parent.log_id,
|
|
7434
|
+
toolSlug: response.parent.tool_slug
|
|
7435
|
+
} : null,
|
|
7436
|
+
timings: response.timings ? {
|
|
7437
|
+
startTime: response.timings.start_time,
|
|
7438
|
+
endTime: response.timings.end_time
|
|
7439
|
+
} : void 0,
|
|
7440
|
+
context: {
|
|
7441
|
+
sessionId: response.context.session_id,
|
|
7442
|
+
traceId: response.context.trace_id,
|
|
7443
|
+
requestId: response.context.request_id
|
|
7444
|
+
},
|
|
7445
|
+
source: {
|
|
7446
|
+
host: response.source.host,
|
|
7447
|
+
framework: response.source.framework,
|
|
7448
|
+
language: response.source.language
|
|
7449
|
+
},
|
|
7450
|
+
data: response.data
|
|
7451
|
+
}));
|
|
7452
|
+
};
|
|
7453
|
+
|
|
7454
|
+
//#endregion
|
|
7455
|
+
//#region src/models/Logs.ts
|
|
7456
|
+
/**
|
|
7457
|
+
* `composio.logs` — tool-execution logs.
|
|
7458
|
+
*
|
|
7459
|
+
* @example
|
|
7460
|
+
* ```typescript
|
|
7461
|
+
* const { logs, nextCursor } = await composio.logs.search({
|
|
7462
|
+
* filters: [{ field: 'toolkit_slug', operator: '==', value: 'github' }],
|
|
7463
|
+
* limit: 20,
|
|
7464
|
+
* });
|
|
7465
|
+
* const detail = await composio.logs.get(logs[0].id);
|
|
7466
|
+
* ```
|
|
7467
|
+
*/
|
|
7468
|
+
var Logs = class {
|
|
7469
|
+
client;
|
|
7470
|
+
constructor(client) {
|
|
7471
|
+
this.client = client;
|
|
7472
|
+
telemetry.instrument(this, "Logs");
|
|
7473
|
+
}
|
|
7474
|
+
/**
|
|
7475
|
+
* Search tool-execution logs with filters, a time range and cursor
|
|
7476
|
+
* pagination.
|
|
7477
|
+
*
|
|
7478
|
+
* @param {LogSearchParams} [params] - Filters, `timeRange`, `limit` and `cursor`
|
|
7479
|
+
* @returns {Promise<LogSearchResponse>} Matching logs and the next cursor. Charged calls include `metadata.instant_charge` as an exact USD string.
|
|
7480
|
+
* @throws {ValidationError} If the params fail validation
|
|
7569
7481
|
*
|
|
7570
7482
|
* @example
|
|
7571
7483
|
* ```typescript
|
|
7572
|
-
*
|
|
7573
|
-
*
|
|
7574
|
-
*
|
|
7575
|
-
* }
|
|
7576
|
-
*
|
|
7577
|
-
* // Update toolkits and tools
|
|
7578
|
-
* const serverWithNewTools = await composio.experimental.mcp.update("mcp_12345", {
|
|
7579
|
-
* toolkits: [
|
|
7580
|
-
* {
|
|
7581
|
-
* toolkit: "github",
|
|
7582
|
-
* authConfigId: "auth_abc123",
|
|
7583
|
-
* allowedTools: ["GITHUB_CREATE_ISSUE", "GITHUB_LIST_REPOS"]
|
|
7584
|
-
* },
|
|
7585
|
-
* {
|
|
7586
|
-
* toolkit: "slack",
|
|
7587
|
-
* authConfigId: "auth_xyz789",
|
|
7588
|
-
* allowedTools: ["SLACK_SEND_MESSAGE", "SLACK_LIST_CHANNELS"]
|
|
7589
|
-
* }
|
|
7590
|
-
* ]
|
|
7591
|
-
* });
|
|
7592
|
-
*
|
|
7593
|
-
* // Update connection management setting
|
|
7594
|
-
* const serverWithManualAuth = await composio.experimental.mcp.update("mcp_12345", {
|
|
7595
|
-
* name: "Manual Auth Server",
|
|
7596
|
-
* manuallyManageConnections: true
|
|
7597
|
-
* });
|
|
7598
|
-
*
|
|
7599
|
-
* // Complete update example
|
|
7600
|
-
* const fullyUpdatedServer = await composio.experimental.mcp.update("mcp_12345", {
|
|
7601
|
-
* name: "Production MCP Server",
|
|
7602
|
-
* toolkits: [
|
|
7603
|
-
* {
|
|
7604
|
-
* toolkit: "gmail",
|
|
7605
|
-
* authConfigId: "auth_gmail_prod",
|
|
7606
|
-
* }
|
|
7484
|
+
* const { logs } = await composio.logs.search({
|
|
7485
|
+
* filters: [
|
|
7486
|
+
* { field: 'status', operator: '==', value: 'failed' },
|
|
7487
|
+
* { field: 'user_id', operator: '==', value: 'user_123' },
|
|
7607
7488
|
* ],
|
|
7608
|
-
*
|
|
7609
|
-
* manuallyManageConnections: false
|
|
7489
|
+
* timeRange: { from: Date.now() - 24 * 60 * 60 * 1000, to: Date.now() },
|
|
7610
7490
|
* });
|
|
7611
|
-
*
|
|
7612
|
-
* console.log("Updated server:", fullyUpdatedServer.name);
|
|
7613
|
-
* console.log("New tools:", fullyUpdatedServer.allowedTools);
|
|
7614
7491
|
* ```
|
|
7615
|
-
*
|
|
7616
|
-
* @throws {ValidationError} When the update parameters are invalid or malformed
|
|
7617
|
-
* @throws {Error} When the server ID doesn't exist or update fails
|
|
7618
|
-
*
|
|
7619
|
-
* @note Only provided fields will be updated. Omitted fields will retain their current values.
|
|
7620
|
-
* @note When updating toolkits, the entire toolkit configuration is replaced, not merged.
|
|
7621
7492
|
*/
|
|
7622
|
-
async
|
|
7623
|
-
const
|
|
7624
|
-
if (
|
|
7625
|
-
const
|
|
7626
|
-
const
|
|
7627
|
-
|
|
7628
|
-
if (typeof toolkit === "string") toolkits.push(toolkit);
|
|
7629
|
-
else {
|
|
7630
|
-
if (toolkit.toolkit) toolkits.push(toolkit.toolkit);
|
|
7631
|
-
if (toolkit.authConfigId) auth_config_ids.push(toolkit.authConfigId);
|
|
7632
|
-
}
|
|
7633
|
-
});
|
|
7634
|
-
const updateBody = {
|
|
7635
|
-
...params.name !== void 0 ? { name: params.name } : {},
|
|
7636
|
-
...params.toolkits !== void 0 ? {
|
|
7637
|
-
toolkits,
|
|
7638
|
-
auth_config_ids
|
|
7639
|
-
} : {},
|
|
7640
|
-
...params.allowedTools !== void 0 ? { allowed_tools: params.allowedTools } : {},
|
|
7641
|
-
...params.manuallyManageConnections !== void 0 ? { managed_auth_via_composio: !params.manuallyManageConnections } : {}
|
|
7642
|
-
};
|
|
7643
|
-
return transformMCPItemResponse(await withCancellation(() => this.client.mcp.update(serverId, updateBody, requestOptions), requestOptions?.signal));
|
|
7493
|
+
async search(params, requestOptions) {
|
|
7494
|
+
const parsedParams = LogSearchParamsSchema.safeParse(params ?? {});
|
|
7495
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse log search params", { cause: parsedParams.error });
|
|
7496
|
+
const body = transformLogSearchParams(parsedParams.data);
|
|
7497
|
+
const result = await withCancellation(() => this.client.logs.createToolExecution(body, requestOptions), requestOptions?.signal);
|
|
7498
|
+
return transformLogSearchResponse(result);
|
|
7644
7499
|
}
|
|
7645
7500
|
/**
|
|
7646
|
-
*
|
|
7647
|
-
*
|
|
7501
|
+
* Retrieve one tool-execution log with its full detail (timings, context,
|
|
7502
|
+
* source and raw `data`).
|
|
7503
|
+
*
|
|
7504
|
+
* @param {string} id - The log id
|
|
7505
|
+
* @returns {Promise<ToolExecutionLogDetail>} The log detail, with an optional exact USD charge in `metadata.instant_charge`
|
|
7648
7506
|
*
|
|
7649
7507
|
* @example
|
|
7650
7508
|
* ```typescript
|
|
7651
|
-
*
|
|
7652
|
-
*
|
|
7653
|
-
* const composio = new Composio();
|
|
7654
|
-
* const mcp = await composio.experimental.mcp.generate("default", "<mcp_config_id>");
|
|
7509
|
+
* const log = await composio.logs.get('log_abc123');
|
|
7510
|
+
* console.log(log.status, log.timings?.endTime);
|
|
7655
7511
|
* ```
|
|
7656
|
-
*
|
|
7657
|
-
* @param userId {string} external user id from your database for whom you want the server for
|
|
7658
|
-
* @param mcpConfigId {string} config id of the MCPConfig for which you want to create a server for
|
|
7659
|
-
* @param options {object} additional options
|
|
7660
|
-
* @param options.isChatAuth {boolean} Authenticate the users via chat when they use the MCP Server
|
|
7661
7512
|
*/
|
|
7662
|
-
async
|
|
7663
|
-
const
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7513
|
+
async get(id, requestOptions) {
|
|
7514
|
+
const result = await withCancellation(() => this.client.logs.retrieveToolExecution(id, requestOptions), requestOptions?.signal);
|
|
7515
|
+
return transformToolExecutionLogDetail(result);
|
|
7516
|
+
}
|
|
7517
|
+
};
|
|
7518
|
+
|
|
7519
|
+
//#endregion
|
|
7520
|
+
//#region src/lib/sessionConfigConflict.ts
|
|
7521
|
+
const SESSION_CONFIG_CONFLICT_MARKER = "sessionConfigConflict";
|
|
7522
|
+
/**
|
|
7523
|
+
* Adds the issue raised when a saved Session config (`experimental.sessionConfigId`)
|
|
7524
|
+
* is combined with inline access fields. `fields` lists every conflicting
|
|
7525
|
+
* field that was provided; nothing is added when it is empty.
|
|
7526
|
+
*/
|
|
7527
|
+
const addSessionConfigConflictIssue = (ctx, fields) => {
|
|
7528
|
+
if (fields.length === 0) return;
|
|
7529
|
+
ctx.addIssue({
|
|
7530
|
+
code: z$1.ZodIssueCode.custom,
|
|
7531
|
+
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`,
|
|
7532
|
+
path: ["experimental", "sessionConfigId"],
|
|
7533
|
+
params: { [SESSION_CONFIG_CONFLICT_MARKER]: true }
|
|
7534
|
+
});
|
|
7535
|
+
};
|
|
7536
|
+
/**
|
|
7537
|
+
* Parses session create or update input. A saved Session config combined with
|
|
7538
|
+
* inline access fields throws `ValidationError`; any other failure rethrows the
|
|
7539
|
+
* original `ZodError`, as `schema.parse()` would.
|
|
7540
|
+
*/
|
|
7541
|
+
const parseSessionConfigInput = (schema, input) => {
|
|
7542
|
+
const result = schema.safeParse(input);
|
|
7543
|
+
if (result.success) return result.data;
|
|
7544
|
+
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 });
|
|
7545
|
+
throw result.error;
|
|
7546
|
+
};
|
|
7547
|
+
|
|
7548
|
+
//#endregion
|
|
7549
|
+
//#region src/types/toolRouter.types.ts
|
|
7550
|
+
const SessionPreset = { DIRECT_TOOLS: "direct_tools" };
|
|
7551
|
+
const MCPServerTypeSchema = z.enum(["http", "sse"]);
|
|
7552
|
+
/**
|
|
7553
|
+
* Sandbox compute tier for the session sandbox.
|
|
7554
|
+
*
|
|
7555
|
+
* | Tier | vCPU | RAM |
|
|
7556
|
+
* | -------- | ---- | ----- |
|
|
7557
|
+
* | standard | 1 | 1 GB |
|
|
7558
|
+
* | medium | 2 | 2 GB |
|
|
7559
|
+
* | large | 4 | 4 GB |
|
|
7560
|
+
* | xlarge | 8 | 8 GB |
|
|
7561
|
+
*
|
|
7562
|
+
* Defaults to `standard` server-side when omitted.
|
|
7563
|
+
*/
|
|
7564
|
+
const SandboxSizeSchema = z.enum([
|
|
7565
|
+
"standard",
|
|
7566
|
+
"medium",
|
|
7567
|
+
"large",
|
|
7568
|
+
"xlarge"
|
|
7569
|
+
]);
|
|
7570
|
+
const ToolRouterSandboxConfigSchema = z.object({
|
|
7571
|
+
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."),
|
|
7572
|
+
enableProxyExecution: z.boolean().optional().describe("Whether to enable proxy execution in the session sandbox"),
|
|
7573
|
+
autoOffloadThreshold: z.number().optional().describe("The auto offload threshold in characters for tool execution to move into the sandbox"),
|
|
7574
|
+
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.")
|
|
7575
|
+
});
|
|
7576
|
+
const ToolRouterConfigManageConnectionsSchema = z.object({
|
|
7577
|
+
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"),
|
|
7578
|
+
callbackUrl: z.string().optional().describe("The callback uri to use in the tool router session"),
|
|
7579
|
+
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")
|
|
7580
|
+
}).strict();
|
|
7581
|
+
const ToolRouterToolkitsParamSchema = z.array(z.string()).describe("List of toolkits to enable in the tool router session");
|
|
7582
|
+
const ToolRouterToolkitsDisabledConfigSchema = z.object({ disable: ToolRouterToolkitsParamSchema.describe("List of toolkits to disable in the tool router session") }).strict();
|
|
7583
|
+
const ToolRouterToolkitsEnabledConfigSchema = z.object({ enable: ToolRouterToolkitsParamSchema.describe("List of toolkits to enable in the tool router session") }).strict();
|
|
7584
|
+
/** Experimental Instant usage policy for a Session. */
|
|
7585
|
+
const ToolRouterInstantSchema = z.union([z.literal(false), z.object({
|
|
7586
|
+
toolkits: z.union([ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsDisabledConfigSchema]).optional(),
|
|
7587
|
+
tools: z.record(z.string(), z.union([z.object({ enable: z.array(z.string()) }).strict(), z.object({ disable: z.array(z.string()) }).strict()])).optional(),
|
|
7588
|
+
/**
|
|
7589
|
+
* Return the actual Instant charge in Session tool responses. Controls
|
|
7590
|
+
* visibility only; on update, any policy object still re-enables Instant
|
|
7591
|
+
* usage on a Session set to `false`.
|
|
7592
|
+
*/
|
|
7593
|
+
returnInstantCharge: z.boolean().optional()
|
|
7594
|
+
}).strict()]);
|
|
7595
|
+
const ToolRouterManageConnectionsConfigSchema = z.object({
|
|
7596
|
+
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),
|
|
7597
|
+
callbackUrl: z.string().optional().describe("The callback url to use in the tool router session")
|
|
7598
|
+
});
|
|
7599
|
+
const ToolRouterTagsParamSchema = z.array(z.enum([
|
|
7600
|
+
"readOnlyHint",
|
|
7601
|
+
"destructiveHint",
|
|
7602
|
+
"idempotentHint",
|
|
7603
|
+
"openWorldHint"
|
|
7604
|
+
])).describe("The tags to filter the tools by");
|
|
7605
|
+
const ToolRouterTagsEnableDisableSchema = z.object({
|
|
7606
|
+
enable: ToolRouterTagsParamSchema.optional().describe("The tags to enable in the tool router session"),
|
|
7607
|
+
disable: ToolRouterTagsParamSchema.optional().describe("The tags to disable in the tool router session")
|
|
7608
|
+
}).strict();
|
|
7609
|
+
const ToolRouterConfigTagsSchema = z.union([ToolRouterTagsParamSchema, ToolRouterTagsEnableDisableSchema]).describe("The tags to use in the tool router session");
|
|
7610
|
+
/**
|
|
7611
|
+
* Tools config - Configure tools per toolkit using toolkit slug as key
|
|
7612
|
+
* @example
|
|
7613
|
+
* ```typescript
|
|
7614
|
+
* {
|
|
7615
|
+
* gmail: {
|
|
7616
|
+
* enable: ['gmail_search', 'gmail_send']
|
|
7617
|
+
* },
|
|
7618
|
+
* slack: {
|
|
7619
|
+
* disable: ['slack_delete_message']
|
|
7620
|
+
* }
|
|
7621
|
+
* }
|
|
7622
|
+
* ```
|
|
7623
|
+
*
|
|
7624
|
+
* @example
|
|
7625
|
+
* ```typescript
|
|
7626
|
+
* {
|
|
7627
|
+
* gmail: ['gmail_search', 'gmail_send'],
|
|
7628
|
+
* slack: { tags: ['readOnlyHint'] }
|
|
7629
|
+
* }
|
|
7630
|
+
* ```
|
|
7631
|
+
*/
|
|
7632
|
+
const ToolRouterToolsParamSchema = z.array(z.string()).describe("The tools to use in the tool router session");
|
|
7633
|
+
const ToolRouterConfigToolsSchema = z.union([
|
|
7634
|
+
ToolRouterToolsParamSchema,
|
|
7635
|
+
z.object({ enable: ToolRouterToolsParamSchema.describe("The tools to enable in the tool router session") }).strict(),
|
|
7636
|
+
z.object({ disable: ToolRouterToolsParamSchema.describe("The tools to disable in the tool router session") }).strict(),
|
|
7637
|
+
z.object({ tags: ToolRouterConfigTagsSchema.describe("The tags to filter the tools by, this will override the global tags") }).strict()
|
|
7638
|
+
]).superRefine((val, ctx) => {
|
|
7639
|
+
if (typeof val === "object" && !Array.isArray(val)) {
|
|
7640
|
+
const keys = Object.keys(val);
|
|
7641
|
+
if (keys.length > 1) ctx.addIssue({
|
|
7642
|
+
code: z.ZodIssueCode.custom,
|
|
7643
|
+
message: `Only one of 'enable', 'disable', or 'tags' can be specified, but found: ${keys.join(", ")}`,
|
|
7644
|
+
path: keys
|
|
7680
7645
|
});
|
|
7681
|
-
if (serverInstance.error) throw new ValidationError("Failed to parse MCP server instance", { cause: serverInstance.error });
|
|
7682
|
-
return serverInstance.data;
|
|
7683
7646
|
}
|
|
7647
|
+
});
|
|
7648
|
+
const ToolRouterCreateSessionConfigBaseSchema = z.object({
|
|
7649
|
+
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."),
|
|
7650
|
+
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"),
|
|
7651
|
+
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).optional().describe("The tools to use in the tool router session"),
|
|
7652
|
+
tags: ToolRouterConfigTagsSchema.optional().describe("Global tags to filter the tools by"),
|
|
7653
|
+
toolkits: z.union([
|
|
7654
|
+
ToolRouterToolkitsParamSchema,
|
|
7655
|
+
ToolRouterToolkitsDisabledConfigSchema,
|
|
7656
|
+
ToolRouterToolkitsEnabledConfigSchema
|
|
7657
|
+
]).optional().describe("The toolkits to use in the tool router session"),
|
|
7658
|
+
instant: ToolRouterInstantSchema.optional().describe("Experimental Instant usage policy. Omission permits eligible tools when the project allows Instant usage; false disables it for this Session."),
|
|
7659
|
+
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({}),
|
|
7660
|
+
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({}),
|
|
7661
|
+
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."),
|
|
7662
|
+
sandbox: ToolRouterSandboxConfigSchema.optional().describe("The sandbox config for this session. Prefer this over workbench."),
|
|
7663
|
+
workbench: ToolRouterSandboxConfigSchema.optional().describe("Deprecated alias for sandbox. Accepted for backwards compatibility."),
|
|
7664
|
+
multiAccount: z.object({
|
|
7665
|
+
enable: z.boolean().default(false).describe("When true, enables multi-account mode for this session. Defaults to false."),
|
|
7666
|
+
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."),
|
|
7667
|
+
requireExplicitSelection: z.boolean().optional().describe("When true, require explicit account selection when multiple accounts are connected. When false (default), use the first/default account.")
|
|
7668
|
+
}).optional().describe("Multi-account configuration for this session"),
|
|
7669
|
+
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."),
|
|
7670
|
+
experimental: z.object({
|
|
7671
|
+
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"),
|
|
7672
|
+
customTools: z.array(z.custom()).optional().describe("Custom tools to include in this session. Created via createCustomTool() from @composio/core/experimental."),
|
|
7673
|
+
customToolkits: z.array(z.custom()).optional().describe("Custom toolkits to include in this session. Created via createCustomToolkit() from @composio/core/experimental."),
|
|
7674
|
+
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.")
|
|
7675
|
+
}).optional().describe("Experimental features configuration - not stable, may be modified or removed")
|
|
7676
|
+
}).partial().superRefine((config, ctx) => {
|
|
7677
|
+
if (config.experimental?.sessionConfigId !== void 0) addSessionConfigConflictIssue(ctx, [
|
|
7678
|
+
config.toolkits !== void 0 && "toolkits",
|
|
7679
|
+
config.tools !== void 0 && "tools",
|
|
7680
|
+
config.tags !== void 0 && "tags",
|
|
7681
|
+
config.experimental.customTools !== void 0 && "experimental.customTools",
|
|
7682
|
+
config.experimental.customToolkits !== void 0 && "experimental.customToolkits"
|
|
7683
|
+
].filter((field) => field !== false));
|
|
7684
|
+
if (config.sandbox !== void 0 && config.workbench !== void 0) ctx.addIssue({
|
|
7685
|
+
code: z.ZodIssueCode.custom,
|
|
7686
|
+
message: "Pass either sandbox or workbench, not both. workbench is a backwards-compatible alias for sandbox.",
|
|
7687
|
+
path: ["sandbox"]
|
|
7688
|
+
});
|
|
7689
|
+
}).describe("The config for the tool router session");
|
|
7690
|
+
const applyDirectToolsPresetDefaults = (value) => {
|
|
7691
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
7692
|
+
const config = value;
|
|
7693
|
+
if (config.sessionPreset !== SessionPreset.DIRECT_TOOLS) return value;
|
|
7694
|
+
const hasSandboxConfig = config.sandbox !== void 0 || config.workbench !== void 0;
|
|
7695
|
+
return {
|
|
7696
|
+
...config,
|
|
7697
|
+
manageConnections: config.manageConnections === void 0 ? false : config.manageConnections,
|
|
7698
|
+
...hasSandboxConfig ? {} : { sandbox: { enable: false } },
|
|
7699
|
+
preload: config.preload === void 0 ? { tools: "all" } : config.preload
|
|
7700
|
+
};
|
|
7684
7701
|
};
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
]);
|
|
7709
|
-
const LogSearchFilterSchema = z$1.object({
|
|
7710
|
-
field: LogSearchFilterFieldSchema,
|
|
7711
|
-
operator: LogSearchFilterOperatorSchema,
|
|
7712
|
-
value: z$1.string()
|
|
7702
|
+
const ToolRouterCreateSessionConfigSchema = z.preprocess(applyDirectToolsPresetDefaults, ToolRouterCreateSessionConfigBaseSchema).describe("The config for the tool router session");
|
|
7703
|
+
const ToolkitConnectionStateSchema = z.object({
|
|
7704
|
+
slug: z.string().describe("The slug of a toolkit"),
|
|
7705
|
+
name: z.string().describe("The name of a toolkit"),
|
|
7706
|
+
logo: z.string().optional().describe("The logo of a toolkit"),
|
|
7707
|
+
isNoAuth: z.boolean().default(false).describe("Whether the toolkit is no auth or not"),
|
|
7708
|
+
connection: z.object({
|
|
7709
|
+
isActive: z.boolean().describe("Whether the connection is active or not"),
|
|
7710
|
+
authConfig: z.object({
|
|
7711
|
+
id: z.string().describe("The id of the auth config"),
|
|
7712
|
+
mode: z.string().describe("The auth scheme used by the auth config"),
|
|
7713
|
+
isComposioManaged: z.boolean().describe("Whether the auth config is managed by Composio")
|
|
7714
|
+
}).nullish().describe("The auth config of a toolkit"),
|
|
7715
|
+
connectedAccount: z.object({
|
|
7716
|
+
id: z.string().describe("The id of the connected account"),
|
|
7717
|
+
status: z.string().describe("The status of the connected account")
|
|
7718
|
+
}).optional().describe("The connected account of a toolkit")
|
|
7719
|
+
}).optional().describe("The connection of a toolkit")
|
|
7720
|
+
}).describe("The connection state of a toolkit");
|
|
7721
|
+
const ToolkitConnectionsDetailsSchema = z.object({
|
|
7722
|
+
items: z.array(ToolkitConnectionStateSchema),
|
|
7723
|
+
cursor: z.string().optional(),
|
|
7724
|
+
totalPages: z.number()
|
|
7713
7725
|
});
|
|
7714
|
-
const
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7726
|
+
const ToolRouterMCPServerConfigSchema = z.object({
|
|
7727
|
+
type: MCPServerTypeSchema,
|
|
7728
|
+
url: z.string(),
|
|
7729
|
+
headers: z.record(z.string(), z.string()).optional()
|
|
7730
|
+
});
|
|
7731
|
+
const ToolRouterToolkitsOptionsSchema = z.object({
|
|
7732
|
+
toolkits: z.array(z.string()).optional(),
|
|
7733
|
+
cursor: z.string().optional(),
|
|
7734
|
+
limit: z.number().optional(),
|
|
7735
|
+
isConnected: z.boolean().optional(),
|
|
7736
|
+
search: z.string().optional()
|
|
7737
|
+
});
|
|
7738
|
+
const ToolRouterSessionSearchResultReferenceWorkbenchSnippetSchema = z.object({
|
|
7739
|
+
code: z.string(),
|
|
7740
|
+
description: z.string()
|
|
7741
|
+
});
|
|
7742
|
+
const ToolRouterSessionSearchResultSchema = z.object({
|
|
7743
|
+
index: z.number(),
|
|
7744
|
+
useCase: z.string(),
|
|
7745
|
+
primaryToolSlugs: z.array(z.string()),
|
|
7746
|
+
relatedToolSlugs: z.array(z.string()),
|
|
7747
|
+
toolkits: z.array(z.string()),
|
|
7748
|
+
difficulty: z.string().optional(),
|
|
7749
|
+
error: z.string().nullable().optional(),
|
|
7750
|
+
executionGuidance: z.string().optional(),
|
|
7751
|
+
knownPitfalls: z.array(z.string()).optional(),
|
|
7752
|
+
memory: z.record(z.string(), z.array(z.string())).optional(),
|
|
7753
|
+
planId: z.string().optional(),
|
|
7754
|
+
recommendedPlanSteps: z.array(z.string()).optional(),
|
|
7755
|
+
referenceWorkbenchSnippets: z.array(ToolRouterSessionSearchResultReferenceWorkbenchSnippetSchema).optional()
|
|
7756
|
+
});
|
|
7757
|
+
const ToolRouterSessionSearchSessionSchema = z.object({
|
|
7758
|
+
id: z.string(),
|
|
7759
|
+
generateId: z.boolean(),
|
|
7760
|
+
instructions: z.string()
|
|
7761
|
+
});
|
|
7762
|
+
const ToolRouterSessionSearchTimeInfoSchema = z.object({
|
|
7763
|
+
currentTimeUtc: z.string(),
|
|
7764
|
+
currentTimeUtcEpochSeconds: z.number(),
|
|
7765
|
+
message: z.string()
|
|
7766
|
+
});
|
|
7767
|
+
const ToolRouterSessionSearchToolSchemasSchemaRefSchema = z.object({
|
|
7768
|
+
args: z.object({ toolSlugs: z.array(z.string()) }),
|
|
7769
|
+
message: z.string().optional(),
|
|
7770
|
+
tool: z.literal("COMPOSIO_GET_TOOL_SCHEMAS")
|
|
7771
|
+
});
|
|
7772
|
+
const ToolRouterSessionSearchToolSchemaSchema = z.object({
|
|
7773
|
+
toolSlug: z.string(),
|
|
7774
|
+
toolkit: z.string(),
|
|
7775
|
+
description: z.string().optional(),
|
|
7776
|
+
hasFullSchema: z.boolean().optional(),
|
|
7777
|
+
inputSchema: z.record(z.string(), z.unknown()).optional(),
|
|
7778
|
+
outputSchema: z.record(z.string(), z.unknown()).optional(),
|
|
7779
|
+
schemaRef: ToolRouterSessionSearchToolSchemasSchemaRefSchema.optional()
|
|
7780
|
+
});
|
|
7781
|
+
const ToolRouterSessionSearchToolkitConnectionStatusSchema = z.object({
|
|
7782
|
+
toolkit: z.string(),
|
|
7783
|
+
description: z.string(),
|
|
7784
|
+
hasActiveConnection: z.boolean(),
|
|
7785
|
+
statusMessage: z.string(),
|
|
7786
|
+
connectionDetails: z.record(z.string(), z.unknown()).optional(),
|
|
7787
|
+
currentUserInfo: z.record(z.string(), z.unknown()).optional(),
|
|
7788
|
+
/** Present when the toolkit runs on a Composio Instant account; only these tools run on it. */
|
|
7789
|
+
instantAccount: z.object({ allowedToolSlugs: z.array(z.string()) }).optional()
|
|
7790
|
+
});
|
|
7791
|
+
const ToolRouterSessionSearchResponseSchema = z.object({
|
|
7792
|
+
success: z.boolean(),
|
|
7793
|
+
error: z.string().nullable(),
|
|
7794
|
+
results: z.array(ToolRouterSessionSearchResultSchema),
|
|
7795
|
+
toolSchemas: z.record(z.string(), ToolRouterSessionSearchToolSchemaSchema),
|
|
7796
|
+
toolkitConnectionStatuses: z.array(ToolRouterSessionSearchToolkitConnectionStatusSchema),
|
|
7797
|
+
nextStepsGuidance: z.array(z.string()),
|
|
7798
|
+
session: ToolRouterSessionSearchSessionSchema,
|
|
7799
|
+
timeInfo: ToolRouterSessionSearchTimeInfoSchema
|
|
7800
|
+
});
|
|
7801
|
+
const ToolRouterSessionExecuteResponseSchema = z.object({
|
|
7802
|
+
data: z.record(z.string(), z.unknown()),
|
|
7803
|
+
error: z.string().nullable(),
|
|
7804
|
+
logId: z.string(),
|
|
7805
|
+
/**
|
|
7806
|
+
* Whether the tool ran and succeeded (`completed`) or ran and failed
|
|
7807
|
+
* (`failed`). A failed execution can carry a `null` or empty `error`, so
|
|
7808
|
+
* read this rather than `error` to tell the two apart.
|
|
7809
|
+
*/
|
|
7810
|
+
resultType: z.enum(["completed", "failed"]),
|
|
7811
|
+
/** Actual Instant usage charge when the Session opts into returning it. */
|
|
7812
|
+
instantCharge: z.unknown().optional()
|
|
7813
|
+
});
|
|
7814
|
+
const SessionProxyExecuteParamsSchema = z.object({
|
|
7815
|
+
/** The toolkit whose connected account to use for auth (e.g. 'gmail', 'github') */
|
|
7816
|
+
toolkit: z.string(),
|
|
7817
|
+
/** The API endpoint URL to call */
|
|
7818
|
+
endpoint: z.string(),
|
|
7819
|
+
/** HTTP method */
|
|
7820
|
+
method: z.enum([
|
|
7821
|
+
"GET",
|
|
7822
|
+
"POST",
|
|
7823
|
+
"PUT",
|
|
7824
|
+
"DELETE",
|
|
7825
|
+
"PATCH"
|
|
7826
|
+
]),
|
|
7827
|
+
/** Request body (for POST/PUT/PATCH) */
|
|
7828
|
+
body: z.unknown().optional(),
|
|
7829
|
+
/** Query params or headers to include */
|
|
7830
|
+
parameters: z.array(z.object({
|
|
7831
|
+
in: z.enum(["query", "header"]),
|
|
7832
|
+
name: z.string(),
|
|
7833
|
+
value: z.union([z.string(), z.number()])
|
|
7834
|
+
})).optional()
|
|
7719
7835
|
});
|
|
7720
7836
|
/**
|
|
7721
|
-
*
|
|
7837
|
+
* `manageConnections` shape accepted by `session.update()`. Unlike the create
|
|
7838
|
+
* schema, `callbackUrl: null` removes the stored callback URL while leaving
|
|
7839
|
+
* the sibling connection settings untouched.
|
|
7722
7840
|
*/
|
|
7723
|
-
const
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
});
|
|
7729
|
-
const
|
|
7730
|
-
|
|
7731
|
-
"
|
|
7732
|
-
"
|
|
7733
|
-
|
|
7841
|
+
const ToolRouterUpdateManageConnectionsSchema = z.object({
|
|
7842
|
+
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"),
|
|
7843
|
+
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"),
|
|
7844
|
+
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"),
|
|
7845
|
+
enableConnectionRemoval: z.boolean().nullable().optional().describe("Whether the session exposes the connection removal tool. `null` removes the stored override")
|
|
7846
|
+
}).strict();
|
|
7847
|
+
const ToolRouterElicitationDefaultSchema = z.enum([
|
|
7848
|
+
"allow_all",
|
|
7849
|
+
"ask_every_call",
|
|
7850
|
+
"ask_once_per_session"
|
|
7851
|
+
]);
|
|
7852
|
+
const ToolRouterElicitationOverrideSchema = z.enum([
|
|
7853
|
+
"always_allow",
|
|
7854
|
+
"always_deny",
|
|
7855
|
+
"ask_once",
|
|
7856
|
+
"ask_always"
|
|
7734
7857
|
]);
|
|
7735
|
-
const ToolExecutionLogParentSchema = z$1.object({
|
|
7736
|
-
logId: z$1.string(),
|
|
7737
|
-
toolSlug: z$1.string()
|
|
7738
|
-
}).nullable();
|
|
7739
|
-
/** Tool log metadata, including the optional exact USD Instant charge. */
|
|
7740
|
-
const ToolExecutionLogMetadataSchema = z$1.object({ instant_charge: z$1.string().optional() }).catchall(z$1.unknown());
|
|
7741
7858
|
/**
|
|
7742
|
-
*
|
|
7859
|
+
* `experimental` block accepted by `session.update()`. Each leaf follows the
|
|
7860
|
+
* PATCH contract of the API: omit to keep the stored value, `null` to remove
|
|
7861
|
+
* it, a value to replace it.
|
|
7743
7862
|
*/
|
|
7744
|
-
const
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
metrics: z$1.record(z$1.string(), z$1.unknown()),
|
|
7755
|
-
parent: ToolExecutionLogParentSchema
|
|
7756
|
-
});
|
|
7757
|
-
const LogSearchResponseSchema = z$1.object({
|
|
7758
|
-
logs: z$1.array(ToolExecutionLogSchema),
|
|
7759
|
-
nextCursor: z$1.string().nullable()
|
|
7760
|
-
});
|
|
7863
|
+
const ToolRouterUpdateExperimentalSchema = z.object({
|
|
7864
|
+
permissions: z.object({
|
|
7865
|
+
default: ToolRouterElicitationDefaultSchema,
|
|
7866
|
+
overrides: z.record(z.string(), ToolRouterElicitationOverrideSchema).optional()
|
|
7867
|
+
}).strict().nullable().optional().describe("Per-tool elicitation permission config. `null` removes the stored block"),
|
|
7868
|
+
linkUrlOverwrite: z.string().nullable().optional().describe("Base URL override for connection link redirects. `null` removes the stored override"),
|
|
7869
|
+
fastMode: z.boolean().nullable().optional().describe("Fast search mode. `null` removes the stored override"),
|
|
7870
|
+
submitFeedback: z.object({ enable: z.boolean() }).strict().nullable().optional().describe("Exposes the COMPOSIO_SUBMIT_FEEDBACK helper tool. `null` removes the stored block"),
|
|
7871
|
+
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")
|
|
7872
|
+
}).strict();
|
|
7761
7873
|
/**
|
|
7762
|
-
*
|
|
7763
|
-
* `
|
|
7874
|
+
* Options for `session.update()`. For every policy block, omitting the key
|
|
7875
|
+
* preserves the stored value and `null` removes the stored override (which can
|
|
7876
|
+
* increase access: `toolkits: null` restores the unrestricted default, unlike
|
|
7877
|
+
* `toolkits: []`, which denies every app toolkit).
|
|
7764
7878
|
*/
|
|
7765
|
-
const
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7879
|
+
const ToolRouterUpdateSessionConfigSchema = z.object({
|
|
7880
|
+
instant: ToolRouterInstantSchema.optional().describe("Experimental Instant usage policy. False disables it. Any supplied object, even one that only sets returnInstantCharge, re-enables it. Omitted subfields keep their stored values."),
|
|
7881
|
+
toolkits: z.union([
|
|
7882
|
+
ToolRouterToolkitsParamSchema,
|
|
7883
|
+
ToolRouterToolkitsDisabledConfigSchema,
|
|
7884
|
+
ToolRouterToolkitsEnabledConfigSchema
|
|
7885
|
+
]).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"),
|
|
7886
|
+
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).nullable().optional().describe("Replaces the entire stored tools map; `null` removes the override"),
|
|
7887
|
+
tags: ToolRouterConfigTagsSchema.nullable().optional().describe("Replaces the global tag policy; `null` removes the override"),
|
|
7888
|
+
authConfigs: z.record(z.string(), z.string()).nullable().optional().describe("Replaces the entire stored auth config map; `null` removes the override"),
|
|
7889
|
+
connectedAccounts: z.record(z.string(), z.union([z.string(), z.array(z.string())])).transform((rec) => {
|
|
7890
|
+
const out = {};
|
|
7891
|
+
for (const [k, v] of Object.entries(rec)) out[k] = typeof v === "string" ? [v] : v;
|
|
7892
|
+
return out;
|
|
7893
|
+
}).nullable().optional().describe("Replaces the entire stored connected accounts map; `null` removes the override"),
|
|
7894
|
+
manageConnections: z.union([z.boolean(), ToolRouterUpdateManageConnectionsSchema]).nullable().optional(),
|
|
7895
|
+
sandbox: ToolRouterSandboxConfigSchema.partial().nullable().optional(),
|
|
7896
|
+
workbench: ToolRouterSandboxConfigSchema.partial().nullable().optional(),
|
|
7897
|
+
multiAccount: z.object({
|
|
7898
|
+
enable: z.boolean().optional(),
|
|
7899
|
+
maxAccountsPerToolkit: z.number().int().min(2).max(10).nullable().optional().describe("`null` removes the stored maximum so the default applies again"),
|
|
7900
|
+
requireExplicitSelection: z.boolean().optional()
|
|
7901
|
+
}).nullable().optional().describe("`null` removes the session override; the mode then resolves to disabled"),
|
|
7902
|
+
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"),
|
|
7903
|
+
search: z.object({ enable: z.boolean().optional() }).strict().nullable().optional().describe("Replaces the search block; `null` removes it and restores the defaults"),
|
|
7904
|
+
execute: z.object({ enableMultiExecute: z.boolean().optional() }).strict().nullable().optional().describe("Replaces the execute block; `null` removes it and restores the defaults"),
|
|
7905
|
+
experimental: ToolRouterUpdateExperimentalSchema.nullable().optional().describe("Experimental settings; `null` removes the stored block"),
|
|
7906
|
+
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)")
|
|
7907
|
+
}).partial().superRefine((config, ctx) => {
|
|
7908
|
+
if (config.experimental?.sessionConfigId !== void 0) addSessionConfigConflictIssue(ctx, [
|
|
7909
|
+
config.toolkits !== void 0 && "toolkits",
|
|
7910
|
+
config.tools !== void 0 && "tools",
|
|
7911
|
+
config.tags !== void 0 && "tags"
|
|
7912
|
+
].filter((field) => field !== false));
|
|
7913
|
+
if (config.sandbox !== void 0 && config.workbench !== void 0) ctx.addIssue({
|
|
7914
|
+
code: z.ZodIssueCode.custom,
|
|
7915
|
+
message: "Pass either sandbox or workbench, not both. workbench is a backwards-compatible alias for sandbox.",
|
|
7916
|
+
path: ["sandbox"]
|
|
7917
|
+
});
|
|
7783
7918
|
});
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
const transformLogSearchParams = (params) => ({
|
|
7788
|
-
limit: params.limit,
|
|
7789
|
-
cursor: params.cursor,
|
|
7790
|
-
filters: params.filters,
|
|
7791
|
-
time_range: params.timeRange
|
|
7919
|
+
const ToolRouterSessionDeleteResponseSchema = z.object({
|
|
7920
|
+
sessionId: z.string(),
|
|
7921
|
+
deleted: z.literal(true)
|
|
7792
7922
|
});
|
|
7793
|
-
const transformToolExecutionLog = (response) => {
|
|
7794
|
-
return transform(response).with(ToolExecutionLogSchema).using((response) => ({
|
|
7795
|
-
id: response.id,
|
|
7796
|
-
timestamp: response.timestamp,
|
|
7797
|
-
type: response.type,
|
|
7798
|
-
status: response.status,
|
|
7799
|
-
level: response.level,
|
|
7800
|
-
message: response.message,
|
|
7801
|
-
metadata: ToolExecutionLogMetadataSchema.parse(response.metadata),
|
|
7802
|
-
metrics: response.metrics,
|
|
7803
|
-
parent: response.parent ? {
|
|
7804
|
-
logId: response.parent.log_id,
|
|
7805
|
-
toolSlug: response.parent.tool_slug
|
|
7806
|
-
} : null
|
|
7807
|
-
}));
|
|
7808
|
-
};
|
|
7809
|
-
const transformLogSearchResponse = (response) => {
|
|
7810
|
-
return transform(response).with(LogSearchResponseSchema).using((response) => ({
|
|
7811
|
-
logs: response.logs.map(transformToolExecutionLog),
|
|
7812
|
-
nextCursor: response.next_cursor
|
|
7813
|
-
}));
|
|
7814
|
-
};
|
|
7815
|
-
const transformToolExecutionLogDetail = (response) => {
|
|
7816
|
-
return transform(response).with(ToolExecutionLogDetailSchema).using((response) => ({
|
|
7817
|
-
id: response.id,
|
|
7818
|
-
timestamp: response.timestamp,
|
|
7819
|
-
type: response.type,
|
|
7820
|
-
status: response.status,
|
|
7821
|
-
level: response.level,
|
|
7822
|
-
message: response.message,
|
|
7823
|
-
metadata: ToolExecutionLogMetadataSchema.parse(response.metadata),
|
|
7824
|
-
metrics: response.metrics,
|
|
7825
|
-
parent: response.parent ? {
|
|
7826
|
-
logId: response.parent.log_id,
|
|
7827
|
-
toolSlug: response.parent.tool_slug
|
|
7828
|
-
} : null,
|
|
7829
|
-
timings: response.timings ? {
|
|
7830
|
-
startTime: response.timings.start_time,
|
|
7831
|
-
endTime: response.timings.end_time
|
|
7832
|
-
} : void 0,
|
|
7833
|
-
context: {
|
|
7834
|
-
sessionId: response.context.session_id,
|
|
7835
|
-
traceId: response.context.trace_id,
|
|
7836
|
-
requestId: response.context.request_id
|
|
7837
|
-
},
|
|
7838
|
-
source: {
|
|
7839
|
-
host: response.source.host,
|
|
7840
|
-
framework: response.source.framework,
|
|
7841
|
-
language: response.source.language
|
|
7842
|
-
},
|
|
7843
|
-
data: response.data
|
|
7844
|
-
}));
|
|
7845
|
-
};
|
|
7846
|
-
|
|
7847
|
-
//#endregion
|
|
7848
|
-
//#region src/models/Logs.ts
|
|
7849
7923
|
/**
|
|
7850
|
-
*
|
|
7851
|
-
*
|
|
7852
|
-
* @example
|
|
7853
|
-
* ```typescript
|
|
7854
|
-
* const { logs, nextCursor } = await composio.logs.search({
|
|
7855
|
-
* filters: [{ field: 'toolkit_slug', operator: '==', value: 'github' }],
|
|
7856
|
-
* limit: 20,
|
|
7857
|
-
* });
|
|
7858
|
-
* const detail = await composio.logs.get(logs[0].id);
|
|
7859
|
-
* ```
|
|
7924
|
+
* Options for `session.listConfigHistory()`.
|
|
7860
7925
|
*/
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
*
|
|
7875
|
-
* @example
|
|
7876
|
-
* ```typescript
|
|
7877
|
-
* const { logs } = await composio.logs.search({
|
|
7878
|
-
* filters: [
|
|
7879
|
-
* { field: 'status', operator: '==', value: 'failed' },
|
|
7880
|
-
* { field: 'user_id', operator: '==', value: 'user_123' },
|
|
7881
|
-
* ],
|
|
7882
|
-
* timeRange: { from: Date.now() - 24 * 60 * 60 * 1000, to: Date.now() },
|
|
7883
|
-
* });
|
|
7884
|
-
* ```
|
|
7885
|
-
*/
|
|
7886
|
-
async search(params, requestOptions) {
|
|
7887
|
-
const parsedParams = LogSearchParamsSchema.safeParse(params ?? {});
|
|
7888
|
-
if (!parsedParams.success) throw new ValidationError("Failed to parse log search params", { cause: parsedParams.error });
|
|
7889
|
-
const body = transformLogSearchParams(parsedParams.data);
|
|
7890
|
-
const result = await withCancellation(() => this.client.logs.createToolExecution(body, requestOptions), requestOptions?.signal);
|
|
7891
|
-
return transformLogSearchResponse(result);
|
|
7892
|
-
}
|
|
7893
|
-
/**
|
|
7894
|
-
* Retrieve one tool-execution log with its full detail (timings, context,
|
|
7895
|
-
* source and raw `data`).
|
|
7896
|
-
*
|
|
7897
|
-
* @param {string} id - The log id
|
|
7898
|
-
* @returns {Promise<ToolExecutionLogDetail>} The log detail, with an optional exact USD charge in `metadata.instant_charge`
|
|
7899
|
-
*
|
|
7900
|
-
* @example
|
|
7901
|
-
* ```typescript
|
|
7902
|
-
* const log = await composio.logs.get('log_abc123');
|
|
7903
|
-
* console.log(log.status, log.timings?.endTime);
|
|
7904
|
-
* ```
|
|
7905
|
-
*/
|
|
7906
|
-
async get(id, requestOptions) {
|
|
7907
|
-
const result = await withCancellation(() => this.client.logs.retrieveToolExecution(id, requestOptions), requestOptions?.signal);
|
|
7908
|
-
return transformToolExecutionLogDetail(result);
|
|
7909
|
-
}
|
|
7910
|
-
};
|
|
7926
|
+
const ToolRouterSessionListConfigHistoryOptionsSchema = z.object({
|
|
7927
|
+
/** Cursor from a previous response's `nextCursor`. */
|
|
7928
|
+
cursor: z.string().optional(),
|
|
7929
|
+
/** Number of items per page, max allowed is 100. */
|
|
7930
|
+
limit: z.number().optional()
|
|
7931
|
+
});
|
|
7932
|
+
const ToolRouterSessionEnsureConnectedOptionsSchema = z.object({
|
|
7933
|
+
callbackUrl: z.string().optional(),
|
|
7934
|
+
alias: z.string().optional(),
|
|
7935
|
+
experimental: ConnectedAccountExperimentalSchema.optional(),
|
|
7936
|
+
/** Max time to wait for a newly-initiated connection to become active, in milliseconds. Defaults to 60000. */
|
|
7937
|
+
timeout: z.number().int().positive().optional()
|
|
7938
|
+
});
|
|
7911
7939
|
|
|
7912
7940
|
//#endregion
|
|
7913
7941
|
//#region src/types/sessionConfigs.types.ts
|
|
@@ -8261,7 +8289,7 @@ var BaseProvider = class {
|
|
|
8261
8289
|
const result = await target.execute(toolSlug, arguments_);
|
|
8262
8290
|
return {
|
|
8263
8291
|
...result,
|
|
8264
|
-
successful: result
|
|
8292
|
+
successful: isExecutionSuccessful(result)
|
|
8265
8293
|
};
|
|
8266
8294
|
}
|
|
8267
8295
|
};
|
|
@@ -8481,7 +8509,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
8481
8509
|
|
|
8482
8510
|
//#endregion
|
|
8483
8511
|
//#region package.json
|
|
8484
|
-
var version = "0.
|
|
8512
|
+
var version = "0.23.0";
|
|
8485
8513
|
|
|
8486
8514
|
//#endregion
|
|
8487
8515
|
//#region src/utils/session.ts
|
|
@@ -8506,12 +8534,32 @@ function detectRuntime() {
|
|
|
8506
8534
|
return "UNKNOWN";
|
|
8507
8535
|
}
|
|
8508
8536
|
const RUNTIME_ENV = detectRuntime();
|
|
8537
|
+
const runtimeVersions = z$2.object({
|
|
8538
|
+
Bun: z$2.object({ version: z$2.string() }).optional(),
|
|
8539
|
+
Deno: z$2.object({ version: z$2.object({ deno: z$2.string() }) }).optional()
|
|
8540
|
+
}).safeParse(globalThis);
|
|
8541
|
+
const detectRuntimeVersion = () => {
|
|
8542
|
+
switch (RUNTIME_ENV) {
|
|
8543
|
+
case "BUN": return runtimeVersions.success ? runtimeVersions.data.Bun?.version : void 0;
|
|
8544
|
+
case "DENO": return runtimeVersions.success ? runtimeVersions.data.Deno?.version.deno : void 0;
|
|
8545
|
+
case "NODEJS": return process.versions.node;
|
|
8546
|
+
default: return;
|
|
8547
|
+
}
|
|
8548
|
+
};
|
|
8549
|
+
const RUNTIME_VERSION = detectRuntimeVersion();
|
|
8509
8550
|
function getSessionHeaders(provider) {
|
|
8510
8551
|
return {
|
|
8511
8552
|
"x-framework": provider?.name || "unknown",
|
|
8512
8553
|
"x-source": "TYPESCRIPT_SDK",
|
|
8513
8554
|
"x-runtime": RUNTIME_ENV,
|
|
8514
|
-
"x-
|
|
8555
|
+
"x-client-runtime": RUNTIME_ENV === "CLOUDFLARE_WORKERS" ? "cloudflare" : RUNTIME_ENV.toLowerCase(),
|
|
8556
|
+
"x-sdk-version": identity.version,
|
|
8557
|
+
"x-client-provenance": identity.name,
|
|
8558
|
+
"x-client-version": identity.version,
|
|
8559
|
+
"x-client-language": "typescript",
|
|
8560
|
+
"x-client-library": "@composio/client",
|
|
8561
|
+
"x-client-library-version": VERSION,
|
|
8562
|
+
...RUNTIME_VERSION ? { "x-runtime-version": RUNTIME_VERSION } : {}
|
|
8515
8563
|
};
|
|
8516
8564
|
}
|
|
8517
8565
|
const getDefaultHeaders = (headers, provider) => {
|
|
@@ -8832,13 +8880,19 @@ const FileDeleteResponseSchema = z.object({
|
|
|
8832
8880
|
*/
|
|
8833
8881
|
/**
|
|
8834
8882
|
* Upper bound on a filename, well under the 255-byte limit common to
|
|
8835
|
-
* ext4/APFS/NTFS.
|
|
8836
|
-
* `ENAMETOOLONG` mid-write. Matches
|
|
8883
|
+
* ext4/APFS/NTFS. A longer server-supplied name is truncated to fit rather
|
|
8884
|
+
* than failing with a raw `ENAMETOOLONG` mid-write. Matches
|
|
8885
|
+
* `MAX_COMPONENT_LENGTH` in the Python SDK.
|
|
8837
8886
|
*/
|
|
8838
8887
|
const MAX_FILENAME_BYTES = 128;
|
|
8839
8888
|
/**
|
|
8889
|
+
* Longest extension, in bytes and including its dot, that truncation keeps.
|
|
8890
|
+
* Anything longer is not a real extension and is truncated with the rest.
|
|
8891
|
+
*/
|
|
8892
|
+
const MAX_PRESERVED_EXTENSION_BYTES = 32;
|
|
8893
|
+
/**
|
|
8840
8894
|
* Reserved DOS device names. Writing to one on Windows targets the device
|
|
8841
|
-
* rather than a file.
|
|
8895
|
+
* rather than a file. Prefixed on every platform so behavior does not diverge
|
|
8842
8896
|
* between a POSIX developer machine and a Windows deployment.
|
|
8843
8897
|
*/
|
|
8844
8898
|
const WINDOWS_RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -8855,7 +8909,22 @@ const WINDOWS_RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
|
8855
8909
|
].flatMap((superscript) => [`COM${superscript}`, `LPT${superscript}`])
|
|
8856
8910
|
]);
|
|
8857
8911
|
/** Control characters and characters reserved by Windows. */
|
|
8858
|
-
const WINDOWS_INVALID_CHARS = /[\u0000-\u001f<>:"|?*]
|
|
8912
|
+
const WINDOWS_INVALID_CHARS = /[\u0000-\u001f<>:"|?*]/g;
|
|
8913
|
+
/** Windows drops trailing spaces and dots from a filename. */
|
|
8914
|
+
const TRAILING_SPACES_AND_DOTS = /[. ]+$/;
|
|
8915
|
+
const utf8Length = (value) => new TextEncoder().encode(value).length;
|
|
8916
|
+
const FNV_OFFSET_BASIS_64 = 14695981039346656037n;
|
|
8917
|
+
const FNV_PRIME_64 = 1099511628211n;
|
|
8918
|
+
const UINT64_MASK = 18446744073709551615n;
|
|
8919
|
+
/**
|
|
8920
|
+
* 64-bit FNV-1a of the UTF-8 bytes, as 16 hex digits. Pure and synchronous, so
|
|
8921
|
+
* it runs on every runtime; `_fnv1a64_hex` in the Python SDK matches it.
|
|
8922
|
+
*/
|
|
8923
|
+
function fnv1a64Hex(value) {
|
|
8924
|
+
let hash = FNV_OFFSET_BASIS_64;
|
|
8925
|
+
for (const byte of new TextEncoder().encode(value)) hash = (hash ^ BigInt(byte)) * FNV_PRIME_64 & UINT64_MASK;
|
|
8926
|
+
return hash.toString(16).padStart(16, "0");
|
|
8927
|
+
}
|
|
8859
8928
|
/**
|
|
8860
8929
|
* Python str.strip() whitespace: Unicode White_Space plus U+001C–U+001F.
|
|
8861
8930
|
* Unlike JavaScript trim(), this includes U+0085 and preserves U+FEFF.
|
|
@@ -8898,51 +8967,99 @@ function hasLoneSurrogate(value) {
|
|
|
8898
8967
|
}
|
|
8899
8968
|
return false;
|
|
8900
8969
|
}
|
|
8970
|
+
/** The longest prefix of `value`, by whole code points, that fits in `maxBytes`. */
|
|
8971
|
+
function truncateToBytes(value, maxBytes) {
|
|
8972
|
+
let truncated = "";
|
|
8973
|
+
let bytes = 0;
|
|
8974
|
+
for (const char of value) {
|
|
8975
|
+
bytes += utf8Length(char);
|
|
8976
|
+
if (bytes > maxBytes) break;
|
|
8977
|
+
truncated += char;
|
|
8978
|
+
}
|
|
8979
|
+
return truncated;
|
|
8980
|
+
}
|
|
8981
|
+
/** Splits off a short trailing extension (with its dot); a leading dot is not one. */
|
|
8982
|
+
function splitExtension(name) {
|
|
8983
|
+
const dot = name.lastIndexOf(".");
|
|
8984
|
+
const extension = dot > 0 ? name.slice(dot) : "";
|
|
8985
|
+
return extension && utf8Length(extension) <= MAX_PRESERVED_EXTENSION_BYTES ? [name.slice(0, dot), extension] : [name, ""];
|
|
8986
|
+
}
|
|
8987
|
+
/**
|
|
8988
|
+
* Truncates `name` to `maxBytes`, keeping a short extension so the file still
|
|
8989
|
+
* opens with the right application.
|
|
8990
|
+
*/
|
|
8991
|
+
function fitFilenameBytes(name, maxBytes = 128) {
|
|
8992
|
+
if (utf8Length(name) <= maxBytes) return name;
|
|
8993
|
+
const [stem, extension] = splitExtension(name);
|
|
8994
|
+
return truncateToBytes(stem, maxBytes - utf8Length(extension)) + extension;
|
|
8995
|
+
}
|
|
8996
|
+
/** Adds a copy number before the extension without exceeding the filename byte limit. */
|
|
8997
|
+
function numberedBasename(name, copy) {
|
|
8998
|
+
const suffix = `-${copy}`;
|
|
8999
|
+
const [stem, extension] = splitExtension(name);
|
|
9000
|
+
return truncateToBytes(stem, 128 - utf8Length(extension) - suffix.length) + suffix + extension;
|
|
9001
|
+
}
|
|
9002
|
+
/**
|
|
9003
|
+
* Tags a name that portability changed with a digest of the name it came
|
|
9004
|
+
* from, before the extension: `report?.png` and `report*.png` both become
|
|
9005
|
+
* `report_.png`, and two long names can share a truncated prefix, so without
|
|
9006
|
+
* the tag one download would overwrite the other in a shared directory.
|
|
9007
|
+
*/
|
|
9008
|
+
function tagWithOriginal(portable, original) {
|
|
9009
|
+
const tag = `-${fnv1a64Hex(original)}`;
|
|
9010
|
+
const [stem, extension] = splitExtension(fitFilenameBytes(portable, 128 - tag.length));
|
|
9011
|
+
return stem + tag + extension;
|
|
9012
|
+
}
|
|
8901
9013
|
/**
|
|
8902
|
-
* Collapses an untrusted filename to a bare
|
|
9014
|
+
* Collapses an untrusted filename to a bare basename that is safe to write on
|
|
9015
|
+
* every platform.
|
|
8903
9016
|
*
|
|
8904
|
-
*
|
|
8905
|
-
*
|
|
8906
|
-
*
|
|
8907
|
-
*
|
|
8908
|
-
*
|
|
8909
|
-
*
|
|
9017
|
+
* Names that cannot be written at all are refused: a NUL byte, invalid
|
|
9018
|
+
* Unicode, or no usable basename (empty or a run of dots). A response that
|
|
9019
|
+
* cannot name its own file is malformed or hostile, and inventing a name would
|
|
9020
|
+
* hide that. `""`, `"."` and `".."` make an output path equal to, or escape,
|
|
9021
|
+
* its own directory, which surfaces as a raw `EISDIR` at write time instead of
|
|
9022
|
+
* a validation error.
|
|
8910
9023
|
*
|
|
8911
|
-
* Names that
|
|
8912
|
-
*
|
|
8913
|
-
*
|
|
8914
|
-
*
|
|
8915
|
-
*
|
|
9024
|
+
* Names that are merely unportable are made portable instead, because ordinary
|
|
9025
|
+
* files have them (`report_2026-09-29T10:30:00.csv`, `What is this?.png`), on
|
|
9026
|
+
* every platform so a name does not depend on where the SDK runs:
|
|
9027
|
+
* control and Windows-reserved characters become `_`, names over
|
|
9028
|
+
* {@link MAX_FILENAME_BYTES} are truncated with their extension kept, trailing
|
|
9029
|
+
* spaces and dots are dropped as Windows would, and a resulting reserved
|
|
9030
|
+
* device name gets a `_` prefix. A name any of these rules changed is then
|
|
9031
|
+
* tagged with a digest of the original before its extension
|
|
9032
|
+
* (`report_-<16 hex>.png`) to distinguish ordinary normalization collisions;
|
|
9033
|
+
* a name that was already portable is returned unchanged. A result can still
|
|
9034
|
+
* equal a literal server name, so default saves create files exclusively.
|
|
9035
|
+
* `safe_basename` in
|
|
9036
|
+
* the Python SDK applies the same rules in the same order.
|
|
8916
9037
|
*
|
|
8917
|
-
*
|
|
8918
|
-
*
|
|
8919
|
-
*
|
|
8920
|
-
* hazard checks that follow run on the raw segment so a trailing ASCII space or
|
|
8921
|
-
* dot is refused, not trimmed away. Check the stripped value for trailing dots
|
|
8922
|
-
* too, since stripping whitespace can expose one.
|
|
9038
|
+
* Python-compatible stripping removes surrounding whitespace first, and the
|
|
9039
|
+
* usability check runs last, on the value that gets written, so neither
|
|
9040
|
+
* `"\u00a0.\u00a0"` nor `". ."` can be written as `.` or as its own directory.
|
|
8923
9041
|
*
|
|
8924
9042
|
* @param name - The untrusted filename or relative path to reduce.
|
|
8925
9043
|
* @param label - How the value is described in error messages.
|
|
8926
|
-
* @returns The
|
|
8927
|
-
* @throws ValidationError if `name`
|
|
9044
|
+
* @returns The bare basename to write, adjusted to be portable.
|
|
9045
|
+
* @throws ValidationError if `name` contains a NUL byte or invalid Unicode, or
|
|
9046
|
+
* leaves no usable basename.
|
|
8928
9047
|
*/
|
|
8929
9048
|
function safeBasename(name, label = "filename") {
|
|
8930
|
-
const
|
|
8931
|
-
|
|
8932
|
-
if (!basename || /^\.+$/.test(basename)) throw new ValidationError(`Path traversal detected: ${label} ${JSON.stringify(name)} leaves no usable basename to write to.`);
|
|
8933
|
-
if (rawBasename.includes("\0")) throw new ValidationError(`Refusing to write ${label} containing a NUL byte: ${JSON.stringify(name)}`);
|
|
8934
|
-
if (WINDOWS_INVALID_CHARS.test(rawBasename)) throw new ValidationError(`Refusing to write ${label} containing characters reserved by Windows: ${JSON.stringify(name)}`);
|
|
8935
|
-
if (rawBasename.endsWith(" ") || rawBasename.endsWith(".") || basename.endsWith(".")) throw new ValidationError(`Refusing to write ${label} ending in a space or dot: ${JSON.stringify(name)}`);
|
|
9049
|
+
const basename = untrustedBasename(name).replace(SURROUNDING_WHITESPACE, "");
|
|
9050
|
+
if (basename.includes("\0")) throw new ValidationError(`Refusing to write ${label} containing a NUL byte: ${JSON.stringify(name)}`);
|
|
8936
9051
|
if (hasLoneSurrogate(basename)) throw new ValidationError(`Refusing to write ${label} containing invalid Unicode: ${JSON.stringify(name)}`);
|
|
8937
|
-
const
|
|
8938
|
-
|
|
8939
|
-
const deviceName =
|
|
8940
|
-
if (WINDOWS_RESERVED_NAMES.has(deviceName))
|
|
8941
|
-
|
|
9052
|
+
const fit = (value) => fitFilenameBytes(value).replace(TRAILING_SPACES_AND_DOTS, "");
|
|
9053
|
+
let portable = fit(basename.replace(WINDOWS_INVALID_CHARS, "_"));
|
|
9054
|
+
const deviceName = portable.split(".", 1)[0].replace(/ +$/, "").toUpperCase();
|
|
9055
|
+
if (WINDOWS_RESERVED_NAMES.has(deviceName)) portable = fit(`_${portable}`);
|
|
9056
|
+
if (!portable) throw new ValidationError(`Path traversal detected: ${label} ${JSON.stringify(name)} leaves no usable basename to write to.`);
|
|
9057
|
+
return portable === basename ? portable : tagWithOriginal(portable, basename);
|
|
8942
9058
|
}
|
|
8943
9059
|
|
|
8944
9060
|
//#endregion
|
|
8945
9061
|
//#region src/models/RemoteFile.ts
|
|
9062
|
+
const existingFileError = z$2.object({ code: z$2.literal("EEXIST") });
|
|
8946
9063
|
function getParentDir(filePath) {
|
|
8947
9064
|
const lastSep = Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"));
|
|
8948
9065
|
if (lastSep <= 0) return "";
|
|
@@ -9078,6 +9195,7 @@ var RemoteFile = class RemoteFile {
|
|
|
9078
9195
|
* Requires a Node.js runtime with file system support (not available in Cloudflare Workers/Edge).
|
|
9079
9196
|
*
|
|
9080
9197
|
* @param path - Local path to save the file. If omitted, saves to the Composio temp directory using the filename from the mount path.
|
|
9198
|
+
* An existing default destination gets a copy number before its extension.
|
|
9081
9199
|
* @returns The absolute path where the file was saved
|
|
9082
9200
|
* @throws Error if file system is not supported or the save fails
|
|
9083
9201
|
* @throws ValidationError if `path` is omitted and the mount path yields no usable filename
|
|
@@ -9087,12 +9205,24 @@ var RemoteFile = class RemoteFile {
|
|
|
9087
9205
|
const homeDir = platform.homedir();
|
|
9088
9206
|
if (!homeDir) throw new Error("Cannot determine save location: home directory is not available");
|
|
9089
9207
|
const defaultDir = platform.joinPath(homeDir, COMPOSIO_DIR, TEMP_FILES_DIRECTORY_NAME);
|
|
9090
|
-
const
|
|
9208
|
+
const defaultName = path == null ? safeBasename(this.mountRelativePath, "mount path") : "";
|
|
9209
|
+
const savePath = path ?? platform.joinPath(defaultDir, defaultName);
|
|
9091
9210
|
const content = await this.buffer();
|
|
9092
9211
|
const dir = path != null ? getParentDir(savePath) : defaultDir;
|
|
9093
9212
|
if (dir && !platform.existsSync(dir)) platform.mkdirSync(dir);
|
|
9094
|
-
|
|
9095
|
-
|
|
9213
|
+
if (path != null) {
|
|
9214
|
+
platform.writeFileSync(savePath, content);
|
|
9215
|
+
return savePath;
|
|
9216
|
+
}
|
|
9217
|
+
for (let copy = 0;; copy++) {
|
|
9218
|
+
const destination = copy === 0 ? savePath : platform.joinPath(defaultDir, numberedBasename(defaultName, copy));
|
|
9219
|
+
try {
|
|
9220
|
+
platform.writeFileExclusiveSync(destination, content);
|
|
9221
|
+
return destination;
|
|
9222
|
+
} catch (error) {
|
|
9223
|
+
if (!existingFileError.safeParse(error).success) throw error;
|
|
9224
|
+
}
|
|
9225
|
+
}
|
|
9096
9226
|
}
|
|
9097
9227
|
};
|
|
9098
9228
|
|
|
@@ -9462,6 +9592,9 @@ function assertUnambiguousCustomToolSlug(map, slug) {
|
|
|
9462
9592
|
* and wraps the result into the standard response format.
|
|
9463
9593
|
*
|
|
9464
9594
|
* Callers provide a pre-built SessionContext (which may include sibling routing).
|
|
9595
|
+
*
|
|
9596
|
+
* @throws {ComposioToolInputRequiredError} If a call the tool made through the
|
|
9597
|
+
* session context needs user input before it can run
|
|
9465
9598
|
*/
|
|
9466
9599
|
async function executeCustomTool(entry, arguments_, sessionContext, options) {
|
|
9467
9600
|
const { handle } = entry;
|
|
@@ -9482,6 +9615,7 @@ async function executeCustomTool(entry, arguments_, sessionContext, options) {
|
|
|
9482
9615
|
};
|
|
9483
9616
|
} catch (err) {
|
|
9484
9617
|
if (err instanceof ComposioRequestCancelledError) throw err;
|
|
9618
|
+
if (err instanceof ComposioToolInputRequiredError) throw err;
|
|
9485
9619
|
if (options?.signal?.aborted && isRequestAbortError(err)) throw new ComposioRequestCancelledError(void 0, { cause: err instanceof Error ? err : void 0 });
|
|
9486
9620
|
return {
|
|
9487
9621
|
data: {},
|
|
@@ -9549,7 +9683,8 @@ var SessionContextImpl = class {
|
|
|
9549
9683
|
return ToolRouterSessionExecuteResponseSchema.parse({
|
|
9550
9684
|
data: result.data,
|
|
9551
9685
|
error: result.error,
|
|
9552
|
-
logId: ""
|
|
9686
|
+
logId: "",
|
|
9687
|
+
resultType: result.successful ? "completed" : "failed"
|
|
9553
9688
|
});
|
|
9554
9689
|
}
|
|
9555
9690
|
assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
|
|
@@ -9559,8 +9694,8 @@ var SessionContextImpl = class {
|
|
|
9559
9694
|
};
|
|
9560
9695
|
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
9561
9696
|
if (experimental) executeParams.experimental = experimental;
|
|
9562
|
-
const response = await withCancellation(() => this.client.toolRouter.session.execute(this.sessionId, executeParams, requestOptions), requestOptions?.signal);
|
|
9563
|
-
return ToolRouterSessionExecuteResponseSchema.parse(transformExecuteResponse(response));
|
|
9697
|
+
const response = await withCancellation(() => this.client.toolRouter.session.execute(this.sessionId, executeParams, withoutRetries(requestOptions)), requestOptions?.signal);
|
|
9698
|
+
return ToolRouterSessionExecuteResponseSchema.parse(transformExecuteResponse(response, toolSlug));
|
|
9564
9699
|
}
|
|
9565
9700
|
/**
|
|
9566
9701
|
* Proxy API calls through Composio's auth layer.
|
|
@@ -9572,7 +9707,8 @@ var SessionContextImpl = class {
|
|
|
9572
9707
|
const signal = this.signal;
|
|
9573
9708
|
const requestOptions = signal ? { signal } : void 0;
|
|
9574
9709
|
const clientParams = transformProxyParams(validated.data);
|
|
9575
|
-
const response = await withCancellation(() => this.client.toolRouter.session.proxyExecute(this.sessionId, clientParams, requestOptions), requestOptions?.signal);
|
|
9710
|
+
const response = await withCancellation(() => this.client.toolRouter.session.proxyExecute(this.sessionId, clientParams, withoutRetries(requestOptions)), requestOptions?.signal);
|
|
9711
|
+
assertNotInputRequired(response, `${validated.data.method} proxy call for toolkit ${validated.data.toolkit}`);
|
|
9576
9712
|
return {
|
|
9577
9713
|
status: response.status,
|
|
9578
9714
|
data: response.data,
|
|
@@ -9988,6 +10124,7 @@ var ToolRouterSession = class {
|
|
|
9988
10124
|
* @param options - Optional execution options
|
|
9989
10125
|
* @param options.account - Account identifier for direct app tool execution. Accepted on every project: in multi-account sessions it picks the account; on single-account projects it must match one of the session's active connections for the toolkit. Helper/meta tools either ignore this top-level field or define their own account-selection fields.
|
|
9990
10126
|
* @returns The tool execution result
|
|
10127
|
+
* @throws {ComposioToolInputRequiredError} If the tool needs input from the user (for example an approval) before it can run
|
|
9991
10128
|
*/
|
|
9992
10129
|
async execute(toolSlug, arguments_, options, requestOptions) {
|
|
9993
10130
|
const entry = findCustomTool(this.customToolsMap, toolSlug);
|
|
@@ -9997,7 +10134,8 @@ var ToolRouterSession = class {
|
|
|
9997
10134
|
return {
|
|
9998
10135
|
data: result.data,
|
|
9999
10136
|
error: result.error,
|
|
10000
|
-
logId: ""
|
|
10137
|
+
logId: "",
|
|
10138
|
+
resultType: result.successful ? "completed" : "failed"
|
|
10001
10139
|
};
|
|
10002
10140
|
}
|
|
10003
10141
|
assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
|
|
@@ -10008,8 +10146,8 @@ var ToolRouterSession = class {
|
|
|
10008
10146
|
if (options?.account) executeParams.account = options.account;
|
|
10009
10147
|
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
10010
10148
|
if (experimental) executeParams.experimental = experimental;
|
|
10011
|
-
const response = await withCancellation(() => this.client.toolRouter.session.execute(this.sessionId, executeParams, requestOptions), requestOptions?.signal);
|
|
10012
|
-
const transformed = transformExecuteResponse(response);
|
|
10149
|
+
const response = await withCancellation(() => this.client.toolRouter.session.execute(this.sessionId, executeParams, withoutRetries(requestOptions)), requestOptions?.signal);
|
|
10150
|
+
const transformed = transformExecuteResponse(response, toolSlug);
|
|
10013
10151
|
return ToolRouterSessionExecuteResponseSchema.parse(transformed);
|
|
10014
10152
|
}
|
|
10015
10153
|
/**
|
|
@@ -10018,12 +10156,14 @@ var ToolRouterSession = class {
|
|
|
10018
10156
|
*
|
|
10019
10157
|
* @param params - Proxy request parameters (toolkit, endpoint, method, body, headers/query params)
|
|
10020
10158
|
* @returns The proxied API response with status, data, headers
|
|
10159
|
+
* @throws {ComposioToolInputRequiredError} If the call needs input from the user before it can run
|
|
10021
10160
|
*/
|
|
10022
10161
|
async proxyExecute(params, requestOptions) {
|
|
10023
10162
|
const validated = SessionProxyExecuteParamsSchema.safeParse(params);
|
|
10024
10163
|
if (!validated.success) throw new ValidationError("Invalid proxy execute parameters", { cause: validated.error });
|
|
10025
10164
|
const clientParams = transformProxyParams(validated.data);
|
|
10026
|
-
const response = await withCancellation(() => this.client.toolRouter.session.proxyExecute(this.sessionId, clientParams, requestOptions), requestOptions?.signal);
|
|
10165
|
+
const response = await withCancellation(() => this.client.toolRouter.session.proxyExecute(this.sessionId, clientParams, withoutRetries(requestOptions)), requestOptions?.signal);
|
|
10166
|
+
assertNotInputRequired(response, `${validated.data.method} proxy call for toolkit ${validated.data.toolkit}`);
|
|
10027
10167
|
return {
|
|
10028
10168
|
status: response.status,
|
|
10029
10169
|
data: response.data,
|
|
@@ -10103,7 +10243,7 @@ var ToolRouterSession = class {
|
|
|
10103
10243
|
throw error;
|
|
10104
10244
|
}
|
|
10105
10245
|
this.configVersion = response.config_version;
|
|
10106
|
-
this.config =
|
|
10246
|
+
this.config = response.config;
|
|
10107
10247
|
this.preload = response.config.preload;
|
|
10108
10248
|
this.sandbox = response.config.workbench;
|
|
10109
10249
|
this.warnings = response.warnings ?? [];
|
|
@@ -10148,7 +10288,7 @@ var ToolRouterSession = class {
|
|
|
10148
10288
|
version: item.version,
|
|
10149
10289
|
createdAt: item.created_at,
|
|
10150
10290
|
isCurrent: item.is_current,
|
|
10151
|
-
config:
|
|
10291
|
+
config: item.config
|
|
10152
10292
|
})),
|
|
10153
10293
|
nextCursor: response.next_cursor ?? null,
|
|
10154
10294
|
totalPages: response.total_pages,
|
|
@@ -10224,6 +10364,7 @@ var ToolRouterSession = class {
|
|
|
10224
10364
|
const [localResults, remoteOutcome] = await Promise.all([Promise.all(localPromises), remotePromise ? remotePromise.then((result) => ({ result })).catch((error) => ({ error })) : void 0]);
|
|
10225
10365
|
const remoteTransportFailed = !!remoteOutcome && "error" in remoteOutcome;
|
|
10226
10366
|
const remoteTransportError = remoteTransportFailed ? remoteOutcome.error : null;
|
|
10367
|
+
if (remoteTransportError instanceof ComposioToolInputRequiredError) throw remoteTransportError;
|
|
10227
10368
|
const remoteErrorMessage = remoteTransportFailed ? (remoteTransportError instanceof Error ? remoteTransportError.message : String(remoteTransportError)) || "Remote tool execution failed" : null;
|
|
10228
10369
|
const remoteResult = remoteOutcome && "result" in remoteOutcome ? remoteOutcome.result : void 0;
|
|
10229
10370
|
if (remoteIndices.length === 0 && localResults.length === 1) return localResults[0].result;
|
|
@@ -10269,11 +10410,11 @@ var ToolRouterSession = class {
|
|
|
10269
10410
|
mergedData.error_count = failedCount;
|
|
10270
10411
|
}
|
|
10271
10412
|
const remoteError = remoteErrorMessage ?? (typeof remoteResult?.error === "string" ? remoteResult.error : null);
|
|
10272
|
-
const
|
|
10413
|
+
const hasAnyFailure = localResults.some((r) => !r.result.successful) || remoteResult?.successful === false || !!remoteError;
|
|
10273
10414
|
return {
|
|
10274
10415
|
data: mergedData,
|
|
10275
|
-
error:
|
|
10276
|
-
successful: !
|
|
10416
|
+
error: hasAnyFailure ? failedCount > 0 ? `${failedCount} out of ${allResults.length} tools failed` : remoteError : null,
|
|
10417
|
+
successful: !hasAnyFailure,
|
|
10277
10418
|
...remoteResult?.instantCharge !== void 0 && { instantCharge: remoteResult.instantCharge }
|
|
10278
10419
|
};
|
|
10279
10420
|
}
|
|
@@ -10283,7 +10424,7 @@ var ToolRouterSession = class {
|
|
|
10283
10424
|
//#region src/models/ToolRouter.ts
|
|
10284
10425
|
function getSessionMetadata(session) {
|
|
10285
10426
|
return {
|
|
10286
|
-
config:
|
|
10427
|
+
config: session.config,
|
|
10287
10428
|
preload: session.config.preload,
|
|
10288
10429
|
workbench: session.config.workbench,
|
|
10289
10430
|
configVersion: session.config_version,
|
|
@@ -11627,4 +11768,4 @@ const ComposioMcpUpdateResponseSchema = z$1.object({
|
|
|
11627
11768
|
});
|
|
11628
11769
|
|
|
11629
11770
|
//#endregion
|
|
11630
|
-
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, ToolExecutionLogMetadataSchema, ToolExecutionLogParentSchema, ToolExecutionLogSchema, ToolExecutionLogStatusSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterErrorCodes, ToolRouterInstantResponseSchema, ToolRouterInstantSchema, 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 };
|
|
11771
|
+
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, ComposioToolInputRequiredError, 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, ToolExecutionLogMetadataSchema, ToolExecutionLogParentSchema, ToolExecutionLogSchema, ToolExecutionLogStatusSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterErrorCodes, ToolRouterInstantSchema, 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 };
|