@composio/core 0.18.1 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CustomTool-Bz0f52QR.mjs → CustomTool-CM-roKk7.mjs} +1 -1
- package/dist/{CustomTool-VRfWzMix.d.mts → CustomTool-yMQjEyMz.d.mts} +1 -1
- package/dist/{FileModifierErrors-CwB-Inm9.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
- package/dist/{FileToolModifier.utils.neutral-D_YkHwZP.mjs → FileToolModifier.utils.neutral-DWFpnsj2.mjs} +4 -2
- package/dist/{SsrfErrors-xhdVE4yw.mjs → SsrfErrors-DiQldIdC.mjs} +32 -17
- package/dist/{Telemetry-Dw9W5RSp.mjs → Telemetry-JRJJYS4I.mjs} +2 -2
- package/dist/{cancellation-P5YUlcfz.mjs → cancellation-BEpFk2S8.mjs} +7 -5
- package/dist/{composio-Cb3d1jFe.d.mts → composio-BVNJTVYa.d.mts} +2449 -118
- package/dist/{customTool.types-B6ej_8XZ.d.mts → customTool.types-CY5SXFfF.d.mts} +118 -5
- package/dist/{errors-Ue9wMrPK.mjs → errors-CvZjP9CH.mjs} +39 -4
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-KE5Fa-af.mjs → fileUtils.node-HQsywtTj.mjs} +8 -6
- package/dist/index.d.mts +292 -140
- package/dist/index.mjs +1914 -160
- package/dist/models/Files.node.d.mts +2 -3
- package/dist/models/Files.node.mjs +2 -2
- package/dist/models/Files.workerd.d.mts +2 -3
- package/dist/platform/node.d.mts +2 -3
- package/dist/platform/workerd.d.mts +2 -3
- package/dist/{sensitiveFileUploadPaths-QN7w4n8v.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +10 -7
- package/dist/{ssrfGuard.node-BLX6b-Rf.mjs → ssrfGuard.node-BK50mYTq.mjs} +94 -8
- package/dist/{types-CGdgK442.d.mts → types-CqGfjlZg.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +3 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.node.mjs +6 -6
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/dist/utils/ssrfGuard.node.d.mts +7 -7
- package/dist/utils/ssrfGuard.node.mjs +1 -1
- package/dist/utils/ssrfGuard.workerd.d.mts +3 -4
- package/dist/utils/ssrfGuard.workerd.mjs +1 -1
- package/package.json +7 -7
- package/src/composio.ts +86 -2
- package/src/errors/ConnectedAccountsErrors.ts +47 -0
- package/src/index.ts +15 -0
- package/src/models/ConnectedAccounts.ts +118 -2
- package/src/models/CustomToolkits.ts +169 -0
- package/src/models/Experimental.ts +27 -0
- package/src/models/Keyring.ts +65 -0
- package/src/models/Logs.ts +101 -0
- package/src/models/ToolRouterSession.ts +51 -0
- package/src/models/Toolkits.ts +180 -0
- package/src/models/Tools.ts +3 -1
- package/src/models/Triggers.ts +2 -87
- package/src/models/Usage.ts +119 -0
- package/src/models/Webhooks.ts +520 -0
- package/src/types/authConfigs.types.ts +2 -0
- package/src/types/connectedAccounts.types.ts +54 -0
- package/src/types/customToolkits.types.ts +102 -0
- package/src/types/keyring.types.ts +32 -0
- package/src/types/logs.types.ts +108 -0
- package/src/types/toolRouter.types.ts +49 -1
- package/src/types/toolkit.types.ts +131 -0
- package/src/types/usage.types.ts +81 -0
- package/src/types/webhooks.types.ts +143 -0
- package/src/utils/constants.ts +1 -5
- package/src/utils/jsonSchema.ts +4 -1
- package/src/utils/logger.ts +39 -7
- package/src/utils/ssrfGuard.node.ts +98 -7
- package/src/utils/transformers/connectedAccounts.ts +37 -2
- package/src/utils/transformers/customToolkits.ts +98 -0
- package/src/utils/transformers/keyring.ts +24 -0
- package/src/utils/transformers/logs.ts +85 -0
- package/src/utils/transformers/toolkits.ts +100 -1
- package/src/utils/transformers/triggers.ts +2 -2
- package/src/utils/transformers/usage.ts +77 -0
- package/src/utils/transformers/webhooks.ts +139 -0
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { A as ToolErrorCodes, B as
|
|
3
|
-
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, o as FileModifierErrorCodes, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "./FileModifierErrors-
|
|
4
|
-
import { n as dropEmptyFileUploads, o as isPlainObject, s as schemaHasFileUploadable } from "./FileToolModifier.utils.neutral-
|
|
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-
|
|
6
|
-
import { t as telemetry } from "./Telemetry-
|
|
7
|
-
import { a as
|
|
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 } from "@composio/client";
|
|
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 ToolErrorCodes, B as ComposioLegacyConnectedAccountsEndpointRetiredError, C as ComposioInvalidExecuteFunctionError, D as ComposioToolExecutionError, E as ComposioProviderNotDefinedError, F as ComposioAclOnlyForSharedError, G as AuthConfigErrorCodes, H as ComposioSharedAccessDeniedError, I as ComposioConnectedAccountNotFoundError, K as ComposioAuthConfigNotFoundError, L as ComposioConnectedAccountNotRevokableError, M as ConnectionRequestErrorCodes, N as ConnectionRequestFailedError, O as ComposioToolNotFoundError, P as ConnectionRequestTimeoutError, R as ComposioConnectedAccountRevocationNotSupportedError, S as ComposioGlobalExecuteToolFnNotSetError, T as ComposioInvalidToolArgumentsError, U as ComposioSharedConnectionNotAccessibleError, V as ComposioMultipleConnectedAccountsError, W as ConnectedAccountErrorCodes, _ as ValidationError, a as ComposioFailedToSubscribeToPusherChannelError, b as ComposioToolkitNotFoundError, c as ComposioWebhookPayloadError, d as ComposioNoAPIKeyError, f as ComposioRequestCancelledError, g as JsonSchemaToZodError, h as JsonSchemaRefResolutionError, i as ComposioFailedToGetSDKRealtimeCredentialsError, j as handleToolExecutionError, k as ComposioToolVersionRequiredError, l as ComposioWebhookSignatureVerificationError, m as isRequestAbortError, n as RemoteFileErrorCodes, o as ComposioFailedToUnsubscribeFromPusherChannelError, p as SDKErrorCodes, r as ComposioFailedToCreatePusherClientError, s as ComposioTriggerTypeNotFoundError, t as RemoteFileDownloadError, u as TriggerErrorCodes, v as ValidationErrorCodes, w as ComposioInvalidModifierError, x as ToolkitErrorCodes, y as ComposioToolkitFetchError, z as ComposioFailedToCreateConnectedAccountLink } from "./errors-CvZjP9CH.mjs";
|
|
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
|
+
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-BEpFk2S8.mjs";
|
|
6
|
+
import { t as telemetry } from "./Telemetry-JRJJYS4I.mjs";
|
|
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-CM-roKk7.mjs";
|
|
9
|
+
import ComposioClient, { APIError, BadRequestError, ConflictError } from "@composio/client";
|
|
10
10
|
import { FileToolModifier } from "#file_tool_modifier";
|
|
11
11
|
import z, { z as z$1 } from "zod/v3";
|
|
12
12
|
import { CONFIG_DEFAULTS } from "#config_defaults";
|
|
@@ -35,6 +35,7 @@ const AuthSchemeTypes = {
|
|
|
35
35
|
SERVICE_ACCOUNT: "SERVICE_ACCOUNT",
|
|
36
36
|
SAML: "SAML",
|
|
37
37
|
DCR_OAUTH: "DCR_OAUTH",
|
|
38
|
+
CIMD_OAUTH: "CIMD_OAUTH",
|
|
38
39
|
S2S_OAUTH2: "S2S_OAUTH2"
|
|
39
40
|
};
|
|
40
41
|
const AuthConfigCreationToolAccessConfigSchema = z$1.object({ toolsForConnectedAccountCreation: z$1.array(z$1.string()).optional() });
|
|
@@ -56,6 +57,7 @@ const AuthSchemeEnum = z$1.enum([
|
|
|
56
57
|
"SERVICE_ACCOUNT",
|
|
57
58
|
"SAML",
|
|
58
59
|
"DCR_OAUTH",
|
|
60
|
+
"CIMD_OAUTH",
|
|
59
61
|
"S2S_OAUTH2"
|
|
60
62
|
]);
|
|
61
63
|
const CreateCustomAuthConfigParamsSchema = z$1.object({
|
|
@@ -1333,14 +1335,16 @@ var Tools = class {
|
|
|
1333
1335
|
toolkitSlug,
|
|
1334
1336
|
params
|
|
1335
1337
|
}, modifiers?.beforeFileUpload, requestOptions);
|
|
1336
|
-
if (modifiers?.beforeExecute)
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1338
|
+
if (modifiers?.beforeExecute) {
|
|
1339
|
+
if (typeof modifiers.beforeExecute === "function") {
|
|
1340
|
+
modifiedParams = await modifiers.beforeExecute({
|
|
1341
|
+
toolSlug,
|
|
1342
|
+
toolkitSlug,
|
|
1343
|
+
params: modifiedParams
|
|
1344
|
+
});
|
|
1345
|
+
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
1346
|
+
} else throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
|
|
1347
|
+
}
|
|
1344
1348
|
return modifiedParams;
|
|
1345
1349
|
}
|
|
1346
1350
|
/**
|
|
@@ -1389,12 +1393,14 @@ var Tools = class {
|
|
|
1389
1393
|
result: modifiedResult,
|
|
1390
1394
|
signal: requestOptions?.signal
|
|
1391
1395
|
});
|
|
1392
|
-
if (modifier)
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1396
|
+
if (modifier) {
|
|
1397
|
+
if (typeof modifier === "function") modifiedResult = await modifier({
|
|
1398
|
+
toolSlug,
|
|
1399
|
+
toolkitSlug,
|
|
1400
|
+
result: modifiedResult
|
|
1401
|
+
});
|
|
1402
|
+
else throw new ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
|
|
1403
|
+
}
|
|
1398
1404
|
return modifiedResult;
|
|
1399
1405
|
}
|
|
1400
1406
|
/**
|
|
@@ -1471,7 +1477,7 @@ var Tools = class {
|
|
|
1471
1477
|
...limit ? { limit } : {},
|
|
1472
1478
|
..."tags" in queryParams.data ? { tags: queryParams.data.tags } : {},
|
|
1473
1479
|
..."scopes" in queryParams.data ? { scopes: queryParams.data.scopes } : {},
|
|
1474
|
-
..."search" in queryParams.data ? {
|
|
1480
|
+
..."search" in queryParams.data ? { query: queryParams.data.search } : {},
|
|
1475
1481
|
..."authConfigIds" in queryParams.data ? { auth_config_ids: queryParams.data.authConfigIds } : {},
|
|
1476
1482
|
...effectiveImportant ? { important: "true" } : {},
|
|
1477
1483
|
toolkit_versions: this.toolkitVersions
|
|
@@ -2017,6 +2023,12 @@ const ToolkitsListParamsSchema = z$1.object({
|
|
|
2017
2023
|
limit: z$1.number().optional()
|
|
2018
2024
|
});
|
|
2019
2025
|
/**
|
|
2026
|
+
* Toolkit getMany params — the slugs to fetch plus the same filters `list`
|
|
2027
|
+
* accepts.
|
|
2028
|
+
*/
|
|
2029
|
+
const ToolkitGetManySlugsSchema = z$1.array(z$1.string().min(1)).min(1);
|
|
2030
|
+
const ToolkitsGetManyParamsSchema = ToolkitsListParamsSchema;
|
|
2031
|
+
/**
|
|
2020
2032
|
* Toolkits response
|
|
2021
2033
|
*/
|
|
2022
2034
|
const ToolKitMetaSchema = z$1.object({
|
|
@@ -2092,6 +2104,108 @@ const ToolkitRetrieveCategoriesResponseSchema = z$1.object({
|
|
|
2092
2104
|
nextCursor: z$1.string().nullable(),
|
|
2093
2105
|
totalPages: z$1.number()
|
|
2094
2106
|
});
|
|
2107
|
+
/**
|
|
2108
|
+
* Toolkit changelog response
|
|
2109
|
+
*/
|
|
2110
|
+
const ToolkitVersionChangelogSchema = z$1.object({
|
|
2111
|
+
version: z$1.string(),
|
|
2112
|
+
changelog: z$1.string()
|
|
2113
|
+
});
|
|
2114
|
+
const ToolkitChangelogItemSchema = z$1.object({
|
|
2115
|
+
slug: z$1.string(),
|
|
2116
|
+
name: z$1.string(),
|
|
2117
|
+
displayName: z$1.string(),
|
|
2118
|
+
/** Most recent versions first; the API returns up to the last 10 per toolkit. */
|
|
2119
|
+
versions: z$1.array(ToolkitVersionChangelogSchema)
|
|
2120
|
+
});
|
|
2121
|
+
const ToolkitChangelogResponseSchema = z$1.object({ items: z$1.array(ToolkitChangelogItemSchema) });
|
|
2122
|
+
/**
|
|
2123
|
+
* Params for `composio.toolkits.recommendScopes()`.
|
|
2124
|
+
* **Experimental — shape may change in future releases.**
|
|
2125
|
+
*/
|
|
2126
|
+
const ToolkitRecommendScopesParamsSchema = z$1.object({
|
|
2127
|
+
/** Tool slugs to cover. Pass `[]` to cover every tool in the toolkit. */
|
|
2128
|
+
tools: z$1.array(z$1.string()),
|
|
2129
|
+
/** Auth scheme the connection will use. The API defaults to `OAUTH2`. */
|
|
2130
|
+
authScheme: AuthSchemeEnum.optional(),
|
|
2131
|
+
/** Toolkit version to compute from. The API defaults to the latest published version. */
|
|
2132
|
+
toolkitVersion: z$1.string().min(1).optional(),
|
|
2133
|
+
/**
|
|
2134
|
+
* Context the scopes will be granted in, as dimension → selected value,
|
|
2135
|
+
* for example `{ account_type: 'Google Workspace' }`. Discover the
|
|
2136
|
+
* dimensions with `composio.toolkits.listGrantContexts()`.
|
|
2137
|
+
*/
|
|
2138
|
+
grantContext: z$1.record(z$1.string(), z$1.string()).optional(),
|
|
2139
|
+
/** Scopes the recommendation must include, whether or not the tools need them. */
|
|
2140
|
+
include: z$1.array(z$1.string()).optional(),
|
|
2141
|
+
/** Scopes the recommendation must not include; the API picks documented alternatives or fails. */
|
|
2142
|
+
exclude: z$1.array(z$1.string()).optional(),
|
|
2143
|
+
/** Scopes your OAuth app can request. The recommendation never goes outside this list. */
|
|
2144
|
+
availableScopes: z$1.array(z$1.string()).optional()
|
|
2145
|
+
});
|
|
2146
|
+
const ToolkitConditionalScopeSchema = z$1.object({
|
|
2147
|
+
/** The scope needed only when the `when` guard matches. */
|
|
2148
|
+
scope: z$1.string(),
|
|
2149
|
+
/** Input field name → qualifying values. Any value matches within a field; all fields must match. */
|
|
2150
|
+
when: z$1.record(z$1.string(), z$1.array(z$1.string())),
|
|
2151
|
+
/** Tool slugs that need this scope under the guard. */
|
|
2152
|
+
for: z$1.array(z$1.string())
|
|
2153
|
+
});
|
|
2154
|
+
/**
|
|
2155
|
+
* Response of `composio.toolkits.recommendScopes()`.
|
|
2156
|
+
* **Experimental — shape may change in future releases.**
|
|
2157
|
+
*/
|
|
2158
|
+
const ToolkitRecommendScopesResponseSchema = z$1.object({
|
|
2159
|
+
/** Auth scheme the recommendation was computed under. */
|
|
2160
|
+
authScheme: z$1.string(),
|
|
2161
|
+
/** Concrete toolkit version the answer was computed from; pass it back as `toolkitVersion` to pin. */
|
|
2162
|
+
toolkitVersion: z$1.string(),
|
|
2163
|
+
/** The effective grant context: the toolkit default overlaid with your overrides. */
|
|
2164
|
+
grantContext: z$1.record(z$1.string(), z$1.string()),
|
|
2165
|
+
scopes: z$1.object({
|
|
2166
|
+
/** Narrowest documented option per requirement. */
|
|
2167
|
+
leastPrivilege: z$1.array(z$1.string()),
|
|
2168
|
+
/** Smallest scope set covering all requirements. */
|
|
2169
|
+
fewest: z$1.array(z$1.string()),
|
|
2170
|
+
/**
|
|
2171
|
+
* Scopes needed only for particular call-time inputs. Both lists above
|
|
2172
|
+
* already include them, so a caller that knows its inputs may drop the rest.
|
|
2173
|
+
*/
|
|
2174
|
+
conditional: z$1.array(ToolkitConditionalScopeSchema)
|
|
2175
|
+
})
|
|
2176
|
+
});
|
|
2177
|
+
/**
|
|
2178
|
+
* Params for `composio.toolkits.listGrantContexts()`.
|
|
2179
|
+
* **Experimental — shape may change in future releases.**
|
|
2180
|
+
*/
|
|
2181
|
+
const ToolkitListGrantContextsParamsSchema = z$1.object({
|
|
2182
|
+
/** Auth scheme the connection will use. The API defaults to `OAUTH2`. */
|
|
2183
|
+
authScheme: AuthSchemeEnum.optional(),
|
|
2184
|
+
/** Toolkit version to read the scope catalog from. The API defaults to the latest published version. */
|
|
2185
|
+
toolkitVersion: z$1.string().min(1).optional()
|
|
2186
|
+
});
|
|
2187
|
+
const ToolkitGrantContextDimensionSchema = z$1.object({
|
|
2188
|
+
/** Dimension name to use as a `grantContext` key. */
|
|
2189
|
+
dimension: z$1.string(),
|
|
2190
|
+
/** What the dimension means and when to pass it. */
|
|
2191
|
+
description: z$1.string(),
|
|
2192
|
+
/** Values the dimension can take. */
|
|
2193
|
+
values: z$1.array(z$1.string())
|
|
2194
|
+
});
|
|
2195
|
+
/**
|
|
2196
|
+
* Response of `composio.toolkits.listGrantContexts()`.
|
|
2197
|
+
* **Experimental — shape may change in future releases.**
|
|
2198
|
+
*/
|
|
2199
|
+
const ToolkitListGrantContextsResponseSchema = z$1.object({
|
|
2200
|
+
/** Auth scheme whose scope catalog the dimensions were read from. */
|
|
2201
|
+
authScheme: z$1.string(),
|
|
2202
|
+
/** Concrete toolkit version the answer was computed from. */
|
|
2203
|
+
toolkitVersion: z$1.string(),
|
|
2204
|
+
/** Dimensions the toolkit accepts in `grantContext`; empty when no scope depends on one. */
|
|
2205
|
+
grantContextDimensions: z$1.array(ToolkitGrantContextDimensionSchema),
|
|
2206
|
+
/** The grant context assumed when you pass none. */
|
|
2207
|
+
defaultGrantContext: z$1.record(z$1.string(), z$1.string())
|
|
2208
|
+
});
|
|
2095
2209
|
const ToolkitAuthFieldsResponseSchema = z$1.array(ToolkitAuthFieldSchema.extend({ required: z$1.boolean().optional() }));
|
|
2096
2210
|
|
|
2097
2211
|
//#endregion
|
|
@@ -2252,7 +2366,8 @@ var AuthConfigs = class {
|
|
|
2252
2366
|
show_disabled: parsedQuery?.showDisabled,
|
|
2253
2367
|
toolkit_slug: parsedQuery?.toolkit
|
|
2254
2368
|
};
|
|
2255
|
-
|
|
2369
|
+
const result = await withCancellation(() => this.client.authConfigs.list(listParams, requestOptions), requestOptions?.signal);
|
|
2370
|
+
return transformAuthConfigListResponse(result);
|
|
2256
2371
|
}
|
|
2257
2372
|
/**
|
|
2258
2373
|
* Create a new auth config
|
|
@@ -2296,7 +2411,8 @@ var AuthConfigs = class {
|
|
|
2296
2411
|
tool_access_config: parsedOptions.data.toolAccessConfig ? { tools_for_connected_account_creation: parsedOptions.data.toolAccessConfig.toolsForConnectedAccountCreation } : void 0
|
|
2297
2412
|
}
|
|
2298
2413
|
};
|
|
2299
|
-
|
|
2414
|
+
const result = await withCancellation(() => this.client.authConfigs.create(createBody, requestOptions), requestOptions?.signal);
|
|
2415
|
+
return transformCreateAuthConfigResponse(result);
|
|
2300
2416
|
}
|
|
2301
2417
|
/**
|
|
2302
2418
|
* Retrieves a specific authentication configuration by its ID.
|
|
@@ -2318,7 +2434,8 @@ var AuthConfigs = class {
|
|
|
2318
2434
|
* ```
|
|
2319
2435
|
*/
|
|
2320
2436
|
async get(nanoid, requestOptions) {
|
|
2321
|
-
|
|
2437
|
+
const result = await withCancellation(() => this.client.authConfigs.retrieve(nanoid, requestOptions), requestOptions?.signal);
|
|
2438
|
+
return transformAuthConfigRetrieveResponse(result);
|
|
2322
2439
|
}
|
|
2323
2440
|
/**
|
|
2324
2441
|
* Updates an existing authentication configuration.
|
|
@@ -2683,6 +2800,10 @@ const CreateConnectedAccountLinkOptionsSchema = z$1.object({
|
|
|
2683
2800
|
const CreateConnectedAccountLinkResponseSchema = z$1.object({ redirectUrl: z$1.string() });
|
|
2684
2801
|
const ConnectedAccountRefreshOptionsSchema = z$1.object({
|
|
2685
2802
|
redirectUrl: z$1.string().optional(),
|
|
2803
|
+
/**
|
|
2804
|
+
* @deprecated The Composio API no longer accepts this field. It is ignored
|
|
2805
|
+
* and `refresh()` logs a warning when it is set.
|
|
2806
|
+
*/
|
|
2686
2807
|
validateCredentials: z$1.boolean().optional()
|
|
2687
2808
|
});
|
|
2688
2809
|
const UpdateConnectedAccountParamsSchema = z$1.object({ enabled: z$1.boolean() });
|
|
@@ -2699,6 +2820,44 @@ const UpdateConnectedAccountParamsSchema = z$1.object({ enabled: z$1.boolean() }
|
|
|
2699
2820
|
* empty object is rejected as a no-op.
|
|
2700
2821
|
*/
|
|
2701
2822
|
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" });
|
|
2823
|
+
/**
|
|
2824
|
+
* Response of `composio.connectedAccounts.revoke()`.
|
|
2825
|
+
*/
|
|
2826
|
+
const ConnectedAccountRevokedTokenSchema = z$1.enum([
|
|
2827
|
+
"access_token",
|
|
2828
|
+
"refresh_token",
|
|
2829
|
+
"credential"
|
|
2830
|
+
]);
|
|
2831
|
+
const ConnectedAccountRevokeResponseSchema = z$1.object({
|
|
2832
|
+
/**
|
|
2833
|
+
* Tokens revoked at the provider on this call. An empty array means the
|
|
2834
|
+
* connection was already revoked (no upstream dispatch).
|
|
2835
|
+
*/
|
|
2836
|
+
revokedTokens: z$1.array(ConnectedAccountRevokedTokenSchema),
|
|
2837
|
+
connectedAccount: z$1.object({
|
|
2838
|
+
id: z$1.string(),
|
|
2839
|
+
/** The connection status after this call (`REVOKED` on success). */
|
|
2840
|
+
status: ConnectedAccountStatusSchema
|
|
2841
|
+
})
|
|
2842
|
+
});
|
|
2843
|
+
/**
|
|
2844
|
+
* Params for `composio.connectedAccounts.completeAuth()`.
|
|
2845
|
+
*/
|
|
2846
|
+
const ConnectedAccountCompleteAuthParamsSchema = z$1.object({
|
|
2847
|
+
/** The user the connection was initiated for. Must match the connection owner. */
|
|
2848
|
+
userId: z$1.string().min(1),
|
|
2849
|
+
/** The opaque, single-use session URI your OAuth callback verifier received. */
|
|
2850
|
+
sessionUri: z$1.string().min(1)
|
|
2851
|
+
});
|
|
2852
|
+
/**
|
|
2853
|
+
* Response of `composio.connectedAccounts.completeAuth()`.
|
|
2854
|
+
*/
|
|
2855
|
+
const ConnectedAccountCompleteAuthResponseSchema = z$1.object({
|
|
2856
|
+
/** The connection that was completed; it is now `ACTIVE`. */
|
|
2857
|
+
connectedAccountId: z$1.string(),
|
|
2858
|
+
/** The toolkit the connection belongs to. */
|
|
2859
|
+
toolkitSlug: z$1.string()
|
|
2860
|
+
});
|
|
2702
2861
|
|
|
2703
2862
|
//#endregion
|
|
2704
2863
|
//#region src/utils/transformers/connectedAccounts.ts
|
|
@@ -2772,6 +2931,21 @@ function transformConnectedAccountListResponse(response) {
|
|
|
2772
2931
|
totalPages: response.total_pages
|
|
2773
2932
|
}));
|
|
2774
2933
|
}
|
|
2934
|
+
const transformConnectedAccountRevokeResponse = (response) => {
|
|
2935
|
+
return transform(response).with(ConnectedAccountRevokeResponseSchema).using((response) => ({
|
|
2936
|
+
revokedTokens: response.revoked_tokens,
|
|
2937
|
+
connectedAccount: {
|
|
2938
|
+
id: response.connected_account.id,
|
|
2939
|
+
status: response.connected_account.status
|
|
2940
|
+
}
|
|
2941
|
+
}));
|
|
2942
|
+
};
|
|
2943
|
+
const transformConnectedAccountCompleteAuthResponse = (response) => {
|
|
2944
|
+
return transform(response).with(ConnectedAccountCompleteAuthResponseSchema).using((response) => ({
|
|
2945
|
+
connectedAccountId: response.connected_account_id,
|
|
2946
|
+
toolkitSlug: response.toolkit_slug
|
|
2947
|
+
}));
|
|
2948
|
+
};
|
|
2775
2949
|
|
|
2776
2950
|
//#endregion
|
|
2777
2951
|
//#region src/models/ConnectionRequest.ts
|
|
@@ -2870,6 +3044,440 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
|
|
|
2870
3044
|
};
|
|
2871
3045
|
}
|
|
2872
3046
|
|
|
3047
|
+
//#endregion
|
|
3048
|
+
//#region src/types/usage.types.ts
|
|
3049
|
+
/**
|
|
3050
|
+
* Filters shared by the usage summary and breakdown queries.
|
|
3051
|
+
* **Experimental — shape may change in future releases.**
|
|
3052
|
+
*/
|
|
3053
|
+
const UsageFiltersSchema = z$1.object({
|
|
3054
|
+
/** Only count events for these external end-user IDs (OR logic). */
|
|
3055
|
+
userId: z$1.array(z$1.string()).nullable().optional(),
|
|
3056
|
+
/** Only count events for these session IDs (OR logic). */
|
|
3057
|
+
sessionId: z$1.array(z$1.string()).nullable().optional()
|
|
3058
|
+
});
|
|
3059
|
+
/**
|
|
3060
|
+
* Params for `composio.experimental.usage.summary()`.
|
|
3061
|
+
* **Experimental — shape may change in future releases.**
|
|
3062
|
+
*/
|
|
3063
|
+
const UsageSummaryParamsSchema = z$1.object({
|
|
3064
|
+
/** Inclusive range start (Unix epoch milliseconds). Defaults to 30 days before `to`. */
|
|
3065
|
+
from: z$1.number().optional(),
|
|
3066
|
+
/** Exclusive range end (Unix epoch milliseconds). Defaults to now. */
|
|
3067
|
+
to: z$1.number().optional(),
|
|
3068
|
+
/** Restrict to these metering entity types. Omit for all types. */
|
|
3069
|
+
entityTypes: z$1.array(z$1.string()).optional(),
|
|
3070
|
+
filters: UsageFiltersSchema.optional()
|
|
3071
|
+
});
|
|
3072
|
+
const UsageOrderBySchema = z$1.enum([
|
|
3073
|
+
"key",
|
|
3074
|
+
"total_quantity",
|
|
3075
|
+
"event_count"
|
|
3076
|
+
]);
|
|
3077
|
+
const UsageOrderDirectionSchema = z$1.enum(["asc", "desc"]);
|
|
3078
|
+
/**
|
|
3079
|
+
* Params for `composio.experimental.usage.breakdown()`.
|
|
3080
|
+
* **Experimental — shape may change in future releases.**
|
|
3081
|
+
*/
|
|
3082
|
+
const UsageBreakdownParamsSchema = z$1.object({
|
|
3083
|
+
/** Inclusive range start (Unix epoch milliseconds). Defaults to 30 days before `to`. */
|
|
3084
|
+
from: z$1.number().optional(),
|
|
3085
|
+
/** Exclusive range end (Unix epoch milliseconds). Defaults to now. */
|
|
3086
|
+
to: z$1.number().optional(),
|
|
3087
|
+
/** Dimension to group by. Defaults to `tool_slug` for tool_calls and `user_id` for sessions. */
|
|
3088
|
+
groupBy: z$1.string().optional(),
|
|
3089
|
+
/** Field to order groups by. Defaults to `total_quantity`. */
|
|
3090
|
+
orderBy: UsageOrderBySchema.optional(),
|
|
3091
|
+
/** Sort direction. Defaults to `desc`. */
|
|
3092
|
+
orderDirection: UsageOrderDirectionSchema.optional(),
|
|
3093
|
+
/** Maximum number of groups to return. Defaults to 100, max 1000. */
|
|
3094
|
+
limit: z$1.number().optional(),
|
|
3095
|
+
filters: UsageFiltersSchema.optional()
|
|
3096
|
+
});
|
|
3097
|
+
const UsageEntitySummarySchema = z$1.object({
|
|
3098
|
+
unit: z$1.string(),
|
|
3099
|
+
totalQuantity: z$1.string(),
|
|
3100
|
+
eventCount: z$1.number()
|
|
3101
|
+
});
|
|
3102
|
+
const UsageSummaryResponseSchema = z$1.object({
|
|
3103
|
+
/** Aggregates keyed by metering entity type (e.g. `tool_calls`, `sessions`). */
|
|
3104
|
+
entities: z$1.record(z$1.string(), UsageEntitySummarySchema) });
|
|
3105
|
+
const UsageBreakdownGroupSchema = z$1.object({
|
|
3106
|
+
key: z$1.string(),
|
|
3107
|
+
totalQuantity: z$1.string(),
|
|
3108
|
+
eventCount: z$1.number()
|
|
3109
|
+
});
|
|
3110
|
+
const UsageBreakdownResponseSchema = z$1.object({
|
|
3111
|
+
entityType: z$1.string(),
|
|
3112
|
+
unit: z$1.string(),
|
|
3113
|
+
totalQuantity: z$1.string(),
|
|
3114
|
+
eventCount: z$1.number(),
|
|
3115
|
+
groups: z$1.array(UsageBreakdownGroupSchema)
|
|
3116
|
+
});
|
|
3117
|
+
|
|
3118
|
+
//#endregion
|
|
3119
|
+
//#region src/utils/transformers/usage.ts
|
|
3120
|
+
const transformUsageFilters = (filters) => filters ? {
|
|
3121
|
+
user_id: filters.userId,
|
|
3122
|
+
session_id: filters.sessionId
|
|
3123
|
+
} : void 0;
|
|
3124
|
+
const transformUsageSummaryParams = (params) => ({
|
|
3125
|
+
from: params.from,
|
|
3126
|
+
to: params.to,
|
|
3127
|
+
entity_types: params.entityTypes,
|
|
3128
|
+
filters: transformUsageFilters(params.filters)
|
|
3129
|
+
});
|
|
3130
|
+
const transformUsageBreakdownParams = (params) => ({
|
|
3131
|
+
from: params.from,
|
|
3132
|
+
to: params.to,
|
|
3133
|
+
group_by: params.groupBy,
|
|
3134
|
+
order_by: params.orderBy,
|
|
3135
|
+
order_direction: params.orderDirection,
|
|
3136
|
+
limit: params.limit,
|
|
3137
|
+
filters: transformUsageFilters(params.filters)
|
|
3138
|
+
});
|
|
3139
|
+
const transformUsageSummaryResponse = (response) => {
|
|
3140
|
+
return transform(response).with(UsageSummaryResponseSchema).using((response) => ({ entities: Object.fromEntries(Object.entries(response.entities).map(([entityType, entity]) => [entityType, {
|
|
3141
|
+
unit: entity.unit,
|
|
3142
|
+
totalQuantity: entity.total_quantity,
|
|
3143
|
+
eventCount: entity.event_count
|
|
3144
|
+
}])) }));
|
|
3145
|
+
};
|
|
3146
|
+
const transformUsageBreakdownResponse = (response) => {
|
|
3147
|
+
return transform(response).with(UsageBreakdownResponseSchema).using((response) => ({
|
|
3148
|
+
entityType: response.entity_type,
|
|
3149
|
+
unit: response.unit,
|
|
3150
|
+
totalQuantity: response.total_quantity,
|
|
3151
|
+
eventCount: response.event_count,
|
|
3152
|
+
groups: response.groups.map((group) => ({
|
|
3153
|
+
key: group.key,
|
|
3154
|
+
totalQuantity: group.total_quantity,
|
|
3155
|
+
eventCount: group.event_count
|
|
3156
|
+
}))
|
|
3157
|
+
}));
|
|
3158
|
+
};
|
|
3159
|
+
|
|
3160
|
+
//#endregion
|
|
3161
|
+
//#region src/models/Usage.ts
|
|
3162
|
+
/**
|
|
3163
|
+
* `composio.experimental.usage` — metering for the project the API key
|
|
3164
|
+
* belongs to. **Experimental — shape may change in future releases.**
|
|
3165
|
+
*
|
|
3166
|
+
* @example
|
|
3167
|
+
* ```typescript
|
|
3168
|
+
* const summary = await composio.experimental.usage.summary();
|
|
3169
|
+
* console.log(summary.entities.tool_calls?.totalQuantity);
|
|
3170
|
+
*
|
|
3171
|
+
* const byTool = await composio.experimental.usage.breakdown('tool_calls', {
|
|
3172
|
+
* groupBy: 'tool_slug',
|
|
3173
|
+
* limit: 10,
|
|
3174
|
+
* });
|
|
3175
|
+
* ```
|
|
3176
|
+
*/
|
|
3177
|
+
var Usage = class {
|
|
3178
|
+
client;
|
|
3179
|
+
constructor(client) {
|
|
3180
|
+
this.client = client;
|
|
3181
|
+
telemetry.instrument(this, "Usage");
|
|
3182
|
+
}
|
|
3183
|
+
/**
|
|
3184
|
+
* Usage totals per metering entity type for a time range.
|
|
3185
|
+
* **Experimental — shape may change in future releases.**
|
|
3186
|
+
*
|
|
3187
|
+
* @param {UsageSummaryParams} [params] - Optional range, `entityTypes` and filters
|
|
3188
|
+
* @returns {Promise<UsageSummaryResponse>} Totals keyed by entity type
|
|
3189
|
+
* @throws {ValidationError} If the params fail validation
|
|
3190
|
+
*
|
|
3191
|
+
* @example
|
|
3192
|
+
* ```typescript
|
|
3193
|
+
* const summary = await composio.experimental.usage.summary({
|
|
3194
|
+
* from: Date.now() - 7 * 24 * 60 * 60 * 1000,
|
|
3195
|
+
* filters: { userId: ['user_123'] },
|
|
3196
|
+
* });
|
|
3197
|
+
* ```
|
|
3198
|
+
*/
|
|
3199
|
+
async summary(params, requestOptions) {
|
|
3200
|
+
const parsedParams = UsageSummaryParamsSchema.safeParse(params ?? {});
|
|
3201
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse usage summary params", { cause: parsedParams.error });
|
|
3202
|
+
const body = transformUsageSummaryParams(parsedParams.data);
|
|
3203
|
+
const result = await withCancellation(() => this.client.project.usage.retrieveSummary(body, requestOptions), requestOptions?.signal);
|
|
3204
|
+
return transformUsageSummaryResponse(result);
|
|
3205
|
+
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Usage for one metering entity type, grouped by a dimension.
|
|
3208
|
+
* **Experimental — shape may change in future releases.**
|
|
3209
|
+
*
|
|
3210
|
+
* @param {string} entityType - Entity type to break down (e.g. `tool_calls`, `sessions`)
|
|
3211
|
+
* @param {UsageBreakdownParams} [params] - Optional range, `groupBy`, ordering, `limit` and filters
|
|
3212
|
+
* @returns {Promise<UsageBreakdownResponse>} Totals plus per-group rows
|
|
3213
|
+
* @throws {ValidationError} If the params fail validation
|
|
3214
|
+
*
|
|
3215
|
+
* @example
|
|
3216
|
+
* ```typescript
|
|
3217
|
+
* const byUser = await composio.experimental.usage.breakdown('sessions', {
|
|
3218
|
+
* groupBy: 'user_id',
|
|
3219
|
+
* orderBy: 'event_count',
|
|
3220
|
+
* });
|
|
3221
|
+
* ```
|
|
3222
|
+
*/
|
|
3223
|
+
async breakdown(entityType, params, requestOptions) {
|
|
3224
|
+
const parsedParams = UsageBreakdownParamsSchema.safeParse(params ?? {});
|
|
3225
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse usage breakdown params", { cause: parsedParams.error });
|
|
3226
|
+
const body = transformUsageBreakdownParams(parsedParams.data);
|
|
3227
|
+
const result = await withCancellation(() => this.client.project.usage.retrieve(entityType, body, requestOptions), requestOptions?.signal);
|
|
3228
|
+
return transformUsageBreakdownResponse(result);
|
|
3229
|
+
}
|
|
3230
|
+
};
|
|
3231
|
+
|
|
3232
|
+
//#endregion
|
|
3233
|
+
//#region src/types/customToolkits.types.ts
|
|
3234
|
+
/**
|
|
3235
|
+
* How end users authenticate to a custom toolkit.
|
|
3236
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3237
|
+
*/
|
|
3238
|
+
const CustomToolkitAuthSchemeSchema = z$1.discriminatedUnion("mode", [
|
|
3239
|
+
z$1.object({ mode: z$1.literal("NO_AUTH") }),
|
|
3240
|
+
z$1.object({
|
|
3241
|
+
mode: z$1.literal("API_KEY"),
|
|
3242
|
+
/**
|
|
3243
|
+
* Headers sent with each request. Write `{{generic_api_key}}` where the
|
|
3244
|
+
* end user's API key goes, for example
|
|
3245
|
+
* `{ Authorization: 'Bearer {{generic_api_key}}' }`.
|
|
3246
|
+
*/
|
|
3247
|
+
headers: z$1.record(z$1.string(), z$1.string()),
|
|
3248
|
+
/** End-user copy for the API key input on the connect page. */
|
|
3249
|
+
apiKeyField: z$1.object({
|
|
3250
|
+
displayName: z$1.string().min(1).max(100).optional(),
|
|
3251
|
+
description: z$1.string().min(1).max(500).optional()
|
|
3252
|
+
}).optional()
|
|
3253
|
+
}),
|
|
3254
|
+
z$1.object({
|
|
3255
|
+
mode: z$1.literal("DCR_OAUTH"),
|
|
3256
|
+
/**
|
|
3257
|
+
* Where to fetch the full auth scheme, usually the
|
|
3258
|
+
* `/.well-known/oauth-authorization-server` path of your MCP URL.
|
|
3259
|
+
*/
|
|
3260
|
+
discoveryUrl: z$1.string().url()
|
|
3261
|
+
})
|
|
3262
|
+
]);
|
|
3263
|
+
/**
|
|
3264
|
+
* Params for `composio.experimental.customToolkits.upsert()`.
|
|
3265
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3266
|
+
*/
|
|
3267
|
+
const CustomToolkitUpsertParamsSchema = z$1.object({
|
|
3268
|
+
/**
|
|
3269
|
+
* Letters, digits, underscores or spaces, up to 30 characters. The API
|
|
3270
|
+
* prefixes it with `CUSTOM_` and turns spaces into underscores.
|
|
3271
|
+
*/
|
|
3272
|
+
slug: z$1.string().min(1).max(30).regex(/^[a-zA-Z0-9_\s]+$/),
|
|
3273
|
+
toolkitConfig: z$1.object({
|
|
3274
|
+
/** Human-readable toolkit name. */
|
|
3275
|
+
name: z$1.string().min(1).max(200),
|
|
3276
|
+
/** The app URL. For an MCP app, the MCP server URL. */
|
|
3277
|
+
appUrl: z$1.string().url(),
|
|
3278
|
+
/** Square PNG or JPEG logo (256-1024px, max 3MB), base64-encoded. Defaults to the Composio logo. */
|
|
3279
|
+
logoFile: z$1.object({
|
|
3280
|
+
content: z$1.string().min(1),
|
|
3281
|
+
mimeType: z$1.enum(["image/png", "image/jpeg"])
|
|
3282
|
+
}).optional(),
|
|
3283
|
+
/** At least one scheme. The schemes cannot change once the toolkit exists. */
|
|
3284
|
+
authSchemes: z$1.array(CustomToolkitAuthSchemeSchema).min(1)
|
|
3285
|
+
})
|
|
3286
|
+
});
|
|
3287
|
+
const CustomToolkitUpsertResponseSchema = z$1.object({
|
|
3288
|
+
/** Slug of the created or updated toolkit. */
|
|
3289
|
+
slug: z$1.string() });
|
|
3290
|
+
/**
|
|
3291
|
+
* Params for `composio.experimental.customToolkits.sync()`.
|
|
3292
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3293
|
+
*/
|
|
3294
|
+
const CustomToolkitSyncParamsSchema = z$1.object({
|
|
3295
|
+
/** Connected account to use when fetching the remote tool definitions. */
|
|
3296
|
+
connectedAccountId: z$1.string().optional() });
|
|
3297
|
+
const CustomToolkitSyncResponseSchema = z$1.object({
|
|
3298
|
+
slug: z$1.string(),
|
|
3299
|
+
/** Toolkit version after the sync. */
|
|
3300
|
+
version: z$1.string(),
|
|
3301
|
+
/** Number of tools synced. */
|
|
3302
|
+
syncedCount: z$1.number()
|
|
3303
|
+
});
|
|
3304
|
+
const CustomToolkitDeleteResponseSchema = z$1.object({
|
|
3305
|
+
/** Slug of the deleted toolkit. */
|
|
3306
|
+
slug: z$1.string(),
|
|
3307
|
+
deleted: z$1.boolean(),
|
|
3308
|
+
/** Background jobs revoking the credentials of the toolkit's connected accounts. */
|
|
3309
|
+
revokeJobIds: z$1.array(z$1.string()),
|
|
3310
|
+
authConfigsDeleted: z$1.number(),
|
|
3311
|
+
connectedAccountsDeleted: z$1.number()
|
|
3312
|
+
});
|
|
3313
|
+
|
|
3314
|
+
//#endregion
|
|
3315
|
+
//#region src/utils/transformers/customToolkits.ts
|
|
3316
|
+
const transformCustomToolkitAuthScheme = (scheme) => {
|
|
3317
|
+
switch (scheme.mode) {
|
|
3318
|
+
case "NO_AUTH": return { mode: "NO_AUTH" };
|
|
3319
|
+
case "API_KEY": return {
|
|
3320
|
+
mode: "API_KEY",
|
|
3321
|
+
headers: scheme.headers,
|
|
3322
|
+
api_key_field: scheme.apiKeyField && {
|
|
3323
|
+
display_name: scheme.apiKeyField.displayName,
|
|
3324
|
+
description: scheme.apiKeyField.description
|
|
3325
|
+
}
|
|
3326
|
+
};
|
|
3327
|
+
case "DCR_OAUTH": return {
|
|
3328
|
+
mode: "DCR_OAUTH",
|
|
3329
|
+
discovery_url: scheme.discoveryUrl
|
|
3330
|
+
};
|
|
3331
|
+
}
|
|
3332
|
+
};
|
|
3333
|
+
const transformCustomToolkitUpsertParams = (params) => ({
|
|
3334
|
+
slug: params.slug,
|
|
3335
|
+
toolkit_config: {
|
|
3336
|
+
name: params.toolkitConfig.name,
|
|
3337
|
+
app_url: params.toolkitConfig.appUrl,
|
|
3338
|
+
logo_file: params.toolkitConfig.logoFile && {
|
|
3339
|
+
content: params.toolkitConfig.logoFile.content,
|
|
3340
|
+
mime_type: params.toolkitConfig.logoFile.mimeType
|
|
3341
|
+
},
|
|
3342
|
+
auth_schemes: params.toolkitConfig.authSchemes.map(transformCustomToolkitAuthScheme)
|
|
3343
|
+
}
|
|
3344
|
+
});
|
|
3345
|
+
const transformCustomToolkitUpsertResponse = (response) => {
|
|
3346
|
+
return transform(response).with(CustomToolkitUpsertResponseSchema).using((response) => ({ slug: response.slug }));
|
|
3347
|
+
};
|
|
3348
|
+
const transformCustomToolkitSyncParams = (slug, params) => ({
|
|
3349
|
+
slug,
|
|
3350
|
+
connected_account_id: params.connectedAccountId
|
|
3351
|
+
});
|
|
3352
|
+
const transformCustomToolkitSyncResponse = (response) => {
|
|
3353
|
+
return transform(response).with(CustomToolkitSyncResponseSchema).using((response) => ({
|
|
3354
|
+
slug: response.slug,
|
|
3355
|
+
version: response.version,
|
|
3356
|
+
syncedCount: response.synced_count
|
|
3357
|
+
}));
|
|
3358
|
+
};
|
|
3359
|
+
const transformCustomToolkitDeleteResponse = (response) => {
|
|
3360
|
+
return transform(response).with(CustomToolkitDeleteResponseSchema).using((response) => ({
|
|
3361
|
+
slug: response.slug,
|
|
3362
|
+
deleted: response.deleted,
|
|
3363
|
+
revokeJobIds: response.revoke_job_ids,
|
|
3364
|
+
authConfigsDeleted: response.auth_configs_deleted,
|
|
3365
|
+
connectedAccountsDeleted: response.connected_accounts_deleted
|
|
3366
|
+
}));
|
|
3367
|
+
};
|
|
3368
|
+
|
|
3369
|
+
//#endregion
|
|
3370
|
+
//#region src/models/CustomToolkits.ts
|
|
3371
|
+
/**
|
|
3372
|
+
* `composio.experimental.customToolkits` — toolkits your project registers
|
|
3373
|
+
* from its own app or MCP server, with their own auth configs and connected
|
|
3374
|
+
* accounts. **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3375
|
+
*
|
|
3376
|
+
* These live on the Composio platform. They are unrelated to the in-process
|
|
3377
|
+
* toolkits built with `experimental_createToolkit()`, which run inside your
|
|
3378
|
+
* application.
|
|
3379
|
+
*
|
|
3380
|
+
* @example
|
|
3381
|
+
* ```typescript
|
|
3382
|
+
* const { slug } = await composio.experimental.customToolkits.upsert({
|
|
3383
|
+
* slug: 'MY_TOOLKIT',
|
|
3384
|
+
* toolkitConfig: {
|
|
3385
|
+
* name: 'My Toolkit',
|
|
3386
|
+
* appUrl: 'https://mcp.example.com/mcp',
|
|
3387
|
+
* authSchemes: [{ mode: 'DCR_OAUTH', discoveryUrl: 'https://mcp.example.com/.well-known/oauth-authorization-server' }],
|
|
3388
|
+
* },
|
|
3389
|
+
* });
|
|
3390
|
+
* await composio.experimental.customToolkits.sync(slug);
|
|
3391
|
+
* ```
|
|
3392
|
+
*/
|
|
3393
|
+
var CustomToolkits = class {
|
|
3394
|
+
client;
|
|
3395
|
+
constructor(client) {
|
|
3396
|
+
this.client = client;
|
|
3397
|
+
telemetry.instrument(this, "CustomToolkits");
|
|
3398
|
+
}
|
|
3399
|
+
/**
|
|
3400
|
+
* Creates a custom toolkit, or updates its display metadata (name, API key
|
|
3401
|
+
* field copy) when the project already owns a toolkit with this slug.
|
|
3402
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3403
|
+
*
|
|
3404
|
+
* `appUrl` and `authSchemes` cannot change on an existing toolkit:
|
|
3405
|
+
* re-sending them unchanged is a no-op, and changing them fails with a 409.
|
|
3406
|
+
* Delete and re-register the toolkit instead, which revokes its connections.
|
|
3407
|
+
*
|
|
3408
|
+
* @param {CustomToolkitUpsertParams} params - The slug and toolkit configuration
|
|
3409
|
+
* @returns {Promise<CustomToolkitUpsertResponse>} The toolkit's slug
|
|
3410
|
+
* @throws {ValidationError} If the params fail validation
|
|
3411
|
+
*
|
|
3412
|
+
* @example
|
|
3413
|
+
* ```typescript
|
|
3414
|
+
* await composio.experimental.customToolkits.upsert({
|
|
3415
|
+
* slug: 'INTERNAL_API',
|
|
3416
|
+
* toolkitConfig: {
|
|
3417
|
+
* name: 'Internal API',
|
|
3418
|
+
* appUrl: 'https://mcp.internal.example.com/mcp',
|
|
3419
|
+
* authSchemes: [
|
|
3420
|
+
* { mode: 'API_KEY', headers: { Authorization: 'Bearer {{generic_api_key}}' } },
|
|
3421
|
+
* ],
|
|
3422
|
+
* },
|
|
3423
|
+
* });
|
|
3424
|
+
* ```
|
|
3425
|
+
*/
|
|
3426
|
+
async upsert(params, requestOptions) {
|
|
3427
|
+
const parsedParams = CustomToolkitUpsertParamsSchema.safeParse(params);
|
|
3428
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse custom toolkit upsert params", { cause: parsedParams.error });
|
|
3429
|
+
const body = transformCustomToolkitUpsertParams(parsedParams.data);
|
|
3430
|
+
const result = await withCancellation(() => this.client.custom.upsert(body, requestOptions), requestOptions?.signal);
|
|
3431
|
+
return transformCustomToolkitUpsertResponse(result);
|
|
3432
|
+
}
|
|
3433
|
+
/**
|
|
3434
|
+
* Re-fetches the tool definitions of a custom toolkit from its remote MCP
|
|
3435
|
+
* server. Call it when automatic sync fails or the remote tools change.
|
|
3436
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3437
|
+
*
|
|
3438
|
+
* @param {string} slug - The custom toolkit slug (`CUSTOM_...`)
|
|
3439
|
+
* @param {CustomToolkitSyncParams} [params] - Optional connected account to fetch the definitions with
|
|
3440
|
+
* @returns {Promise<CustomToolkitSyncResponse>} The toolkit version and number of tools synced
|
|
3441
|
+
* @throws {ValidationError} If the params fail validation
|
|
3442
|
+
*
|
|
3443
|
+
* @example
|
|
3444
|
+
* ```typescript
|
|
3445
|
+
* const { version, syncedCount } = await composio.experimental.customToolkits.sync(
|
|
3446
|
+
* 'CUSTOM_MY_TOOLKIT',
|
|
3447
|
+
* { connectedAccountId: 'ca_abc123' }
|
|
3448
|
+
* );
|
|
3449
|
+
* ```
|
|
3450
|
+
*/
|
|
3451
|
+
async sync(slug, params, requestOptions) {
|
|
3452
|
+
const parsedParams = CustomToolkitSyncParamsSchema.safeParse(params ?? {});
|
|
3453
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse custom toolkit sync params", { cause: parsedParams.error });
|
|
3454
|
+
const body = transformCustomToolkitSyncParams(slug, parsedParams.data);
|
|
3455
|
+
const result = await withCancellation(() => this.client.custom.sync(body, requestOptions), requestOptions?.signal);
|
|
3456
|
+
return transformCustomToolkitSyncResponse(result);
|
|
3457
|
+
}
|
|
3458
|
+
/**
|
|
3459
|
+
* Deletes a custom toolkit owned by the project, with its tools, auth
|
|
3460
|
+
* configs and connected accounts. The credentials behind those connected
|
|
3461
|
+
* accounts are revoked in background jobs (`revokeJobIds`).
|
|
3462
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3463
|
+
*
|
|
3464
|
+
* Composio-managed toolkits cannot be deleted; the API answers 403.
|
|
3465
|
+
*
|
|
3466
|
+
* @param {string} slug - The custom toolkit slug (`CUSTOM_...`)
|
|
3467
|
+
* @returns {Promise<CustomToolkitDeleteResponse>} What was deleted
|
|
3468
|
+
*
|
|
3469
|
+
* @example
|
|
3470
|
+
* ```typescript
|
|
3471
|
+
* const result = await composio.experimental.customToolkits.delete('CUSTOM_MY_TOOLKIT');
|
|
3472
|
+
* console.log(result.connectedAccountsDeleted);
|
|
3473
|
+
* ```
|
|
3474
|
+
*/
|
|
3475
|
+
async delete(slug, requestOptions) {
|
|
3476
|
+
const result = await withCancellation(() => this.client.custom.deleteToolkit(slug, requestOptions), requestOptions?.signal);
|
|
3477
|
+
return transformCustomToolkitDeleteResponse(result);
|
|
3478
|
+
}
|
|
3479
|
+
};
|
|
3480
|
+
|
|
2873
3481
|
//#endregion
|
|
2874
3482
|
//#region src/models/Experimental.ts
|
|
2875
3483
|
/**
|
|
@@ -2935,8 +3543,31 @@ async function updateConnectedAccountAcl(client, nanoid, params) {
|
|
|
2935
3543
|
}
|
|
2936
3544
|
var Experimental = class {
|
|
2937
3545
|
client;
|
|
3546
|
+
/**
|
|
3547
|
+
* Project-scoped usage metering (`summary()` / `breakdown()`).
|
|
3548
|
+
* **Experimental — shape may change in future releases.**
|
|
3549
|
+
*
|
|
3550
|
+
* @example
|
|
3551
|
+
* ```typescript
|
|
3552
|
+
* const summary = await composio.experimental.usage.summary();
|
|
3553
|
+
* const byTool = await composio.experimental.usage.breakdown('tool_calls');
|
|
3554
|
+
* ```
|
|
3555
|
+
*/
|
|
3556
|
+
usage;
|
|
3557
|
+
/**
|
|
3558
|
+
* Register and manage project-owned custom toolkits (`upsert()` / `sync()` / `delete()`).
|
|
3559
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3560
|
+
*
|
|
3561
|
+
* @example
|
|
3562
|
+
* ```typescript
|
|
3563
|
+
* await composio.experimental.customToolkits.sync('CUSTOM_MY_TOOLKIT');
|
|
3564
|
+
* ```
|
|
3565
|
+
*/
|
|
3566
|
+
customToolkits;
|
|
2938
3567
|
constructor(client) {
|
|
2939
3568
|
this.client = client;
|
|
3569
|
+
this.usage = new Usage(client);
|
|
3570
|
+
this.customToolkits = new CustomToolkits(client);
|
|
2940
3571
|
telemetry.instrument(this, "Experimental");
|
|
2941
3572
|
}
|
|
2942
3573
|
/**
|
|
@@ -3065,7 +3696,8 @@ var ConnectedAccounts = class {
|
|
|
3065
3696
|
...parsedQuery.data.accountType !== void 0 && { account_type: parsedQuery.data.accountType }
|
|
3066
3697
|
};
|
|
3067
3698
|
}
|
|
3068
|
-
|
|
3699
|
+
const result = await withCancellation(() => this.client.connectedAccounts.list(rawQuery, requestOptions), requestOptions?.signal);
|
|
3700
|
+
return transformConnectedAccountListResponse(result);
|
|
3069
3701
|
}
|
|
3070
3702
|
/**
|
|
3071
3703
|
* Compound function to create a new connected account.
|
|
@@ -3280,7 +3912,8 @@ var ConnectedAccounts = class {
|
|
|
3280
3912
|
* ```
|
|
3281
3913
|
*/
|
|
3282
3914
|
async get(nanoid, requestOptions) {
|
|
3283
|
-
|
|
3915
|
+
const response = await withCancellation(() => this.client.connectedAccounts.retrieve(nanoid, requestOptions), requestOptions?.signal);
|
|
3916
|
+
return transformConnectedAccountResponse(response);
|
|
3284
3917
|
}
|
|
3285
3918
|
/**
|
|
3286
3919
|
* Deletes a connected account.
|
|
@@ -3316,20 +3949,95 @@ var ConnectedAccounts = class {
|
|
|
3316
3949
|
* // Refresh a connected account's credentials
|
|
3317
3950
|
* const refreshedAccount = await composio.connectedAccounts.refresh('conn_abc123');
|
|
3318
3951
|
* ```
|
|
3952
|
+
*
|
|
3953
|
+
* @deprecated The `POST /connected_accounts/{id}/refresh` endpoint is deprecated by the
|
|
3954
|
+
* Composio API. Re-initiate authentication instead: `composio.connectedAccounts.link(userId, authConfigId)`
|
|
3955
|
+
* for a fresh connection, or `session.authorize(toolkit)` from a session. Behaviour is unchanged
|
|
3956
|
+
* while the endpoint remains available; do not generate new code against `refresh`.
|
|
3319
3957
|
*/
|
|
3320
3958
|
async refresh(nanoid, options, requestOptions) {
|
|
3321
3959
|
let params = void 0;
|
|
3322
3960
|
if (options) {
|
|
3323
3961
|
const parsedOptions = ConnectedAccountRefreshOptionsSchema.safeParse(options);
|
|
3324
3962
|
if (!parsedOptions.success) throw new ValidationError("Failed to parse connected account refresh options", { cause: parsedOptions.error });
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
validate_credentials: parsedOptions.data.validateCredentials
|
|
3328
|
-
};
|
|
3963
|
+
if (parsedOptions.data.validateCredentials !== void 0) logger.warn("connectedAccounts.refresh(): the Composio API no longer accepts `validateCredentials`; the option is ignored.");
|
|
3964
|
+
params = { query_redirect_url: parsedOptions.data.redirectUrl };
|
|
3329
3965
|
}
|
|
3330
3966
|
return withCancellation(() => this.client.connectedAccounts.refresh(nanoid, params, requestOptions), requestOptions?.signal);
|
|
3331
3967
|
}
|
|
3332
3968
|
/**
|
|
3969
|
+
* Revoke a connected account at the upstream provider.
|
|
3970
|
+
*
|
|
3971
|
+
* Best-effort upstream revocation of the stored tokens/credentials; on
|
|
3972
|
+
* success the connection status becomes `REVOKED`. Revoking an already
|
|
3973
|
+
* revoked connection returns an empty `revokedTokens` list without an
|
|
3974
|
+
* upstream call.
|
|
3975
|
+
*
|
|
3976
|
+
* @param {string} nanoid - The unique identifier of the connected account to revoke
|
|
3977
|
+
* @returns {Promise<ConnectedAccountRevokeResponse>} Which tokens were revoked and the resulting status
|
|
3978
|
+
* @throws {ComposioConnectedAccountRevocationNotSupportedError} If the toolkit does not support programmatic revocation (400)
|
|
3979
|
+
* @throws {ComposioConnectedAccountNotRevokableError} If the connection is not in a revokable state (409)
|
|
3980
|
+
*
|
|
3981
|
+
* @example
|
|
3982
|
+
* ```typescript
|
|
3983
|
+
* const result = await composio.connectedAccounts.revoke('conn_abc123');
|
|
3984
|
+
* console.log(result.connectedAccount.status); // 'REVOKED'
|
|
3985
|
+
* console.log(result.revokedTokens); // e.g. ['access_token', 'refresh_token']
|
|
3986
|
+
* ```
|
|
3987
|
+
*/
|
|
3988
|
+
async revoke(nanoid, requestOptions) {
|
|
3989
|
+
try {
|
|
3990
|
+
const result = await withCancellation(() => this.client.connectedAccounts.revoke(nanoid, requestOptions), requestOptions?.signal);
|
|
3991
|
+
return transformConnectedAccountRevokeResponse(result);
|
|
3992
|
+
} catch (error) {
|
|
3993
|
+
if (error instanceof BadRequestError) throw new ComposioConnectedAccountRevocationNotSupportedError(`Connected account ${nanoid} cannot be revoked programmatically: ${error.message}`, {
|
|
3994
|
+
cause: error,
|
|
3995
|
+
meta: { nanoid }
|
|
3996
|
+
});
|
|
3997
|
+
if (error instanceof ConflictError) throw new ComposioConnectedAccountNotRevokableError(`Connected account ${nanoid} is not in a revokable state: ${error.message}`, {
|
|
3998
|
+
cause: error,
|
|
3999
|
+
meta: { nanoid }
|
|
4000
|
+
});
|
|
4001
|
+
throw error;
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
/**
|
|
4005
|
+
* Complete a deferred OAuth connection once you have verified the user's
|
|
4006
|
+
* identity.
|
|
4007
|
+
*
|
|
4008
|
+
* When your project has an OAuth callback verifier configured, Composio
|
|
4009
|
+
* does not activate a new OAuth connection by itself: it redirects to your
|
|
4010
|
+
* verifier with a single-use session URI. After confirming who the user is,
|
|
4011
|
+
* redeem that session URI here; Composio checks that your project owns the
|
|
4012
|
+
* pending connection and that `userId` is its owner, completes the token
|
|
4013
|
+
* exchange, and the connection becomes `ACTIVE`.
|
|
4014
|
+
*
|
|
4015
|
+
* The session URI is single-use: redeeming it twice, or after it expires,
|
|
4016
|
+
* fails with a 404 from the API.
|
|
4017
|
+
*
|
|
4018
|
+
* @param {ConnectedAccountCompleteAuthParams} params - `userId` the connection was initiated for and the verifier's `sessionUri`
|
|
4019
|
+
* @returns {Promise<ConnectedAccountCompleteAuthResponse>} The completed connection's ID and toolkit
|
|
4020
|
+
* @throws {ValidationError} If the params fail validation
|
|
4021
|
+
*
|
|
4022
|
+
* @example
|
|
4023
|
+
* ```typescript
|
|
4024
|
+
* // In your verifier route, after authenticating the user:
|
|
4025
|
+
* const { connectedAccountId, toolkitSlug } = await composio.connectedAccounts.completeAuth({
|
|
4026
|
+
* userId: 'user_123',
|
|
4027
|
+
* sessionUri, // the session URI from the verifier redirect
|
|
4028
|
+
* });
|
|
4029
|
+
* ```
|
|
4030
|
+
*/
|
|
4031
|
+
async completeAuth(params, requestOptions) {
|
|
4032
|
+
const parsedParams = ConnectedAccountCompleteAuthParamsSchema.safeParse(params);
|
|
4033
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse connected account completeAuth params", { cause: parsedParams.error });
|
|
4034
|
+
const result = await withCancellation(() => this.client.connectedAccounts.completeAuth({
|
|
4035
|
+
user_id: parsedParams.data.userId,
|
|
4036
|
+
session_uri: parsedParams.data.sessionUri
|
|
4037
|
+
}, requestOptions), requestOptions?.signal);
|
|
4038
|
+
return transformConnectedAccountCompleteAuthResponse(result);
|
|
4039
|
+
}
|
|
4040
|
+
/**
|
|
3333
4041
|
* Update the status of a connected account
|
|
3334
4042
|
* @param {string} nanoid - Unique identifier of the connected account
|
|
3335
4043
|
* @param {ConnectedAccountUpdateStatusParams} params - Parameters for updating the status
|
|
@@ -3445,6 +4153,10 @@ var ConnectedAccounts = class {
|
|
|
3445
4153
|
|
|
3446
4154
|
//#endregion
|
|
3447
4155
|
//#region src/utils/transformers/toolkits.ts
|
|
4156
|
+
/**
|
|
4157
|
+
* `GET /toolkits` and `POST /toolkits/multi` return the same item shape; the
|
|
4158
|
+
* generated client only names them differently per operation.
|
|
4159
|
+
*/
|
|
3448
4160
|
const transformToolkitListResponse = (response) => {
|
|
3449
4161
|
return transform(response).with(ToolKitListResponseSchema).using((response) => response.items.map((item) => ({
|
|
3450
4162
|
name: item.name,
|
|
@@ -3501,6 +4213,17 @@ const transformToolkitRetrieveResponse = (response) => {
|
|
|
3501
4213
|
getCurrentUserEndpointMethod: response.get_current_user_endpoint_method
|
|
3502
4214
|
}));
|
|
3503
4215
|
};
|
|
4216
|
+
const transformToolkitChangelogResponse = (response) => {
|
|
4217
|
+
return transform(response).with(ToolkitChangelogResponseSchema).using((response) => ({ items: response.items.map((item) => ({
|
|
4218
|
+
slug: item.slug,
|
|
4219
|
+
name: item.name,
|
|
4220
|
+
displayName: item.display_name,
|
|
4221
|
+
versions: item.versions.map((version) => ({
|
|
4222
|
+
version: version.version,
|
|
4223
|
+
changelog: version.changelog
|
|
4224
|
+
}))
|
|
4225
|
+
})) }));
|
|
4226
|
+
};
|
|
3504
4227
|
const transformToolkitRetrieveCategoriesResponse = (response) => {
|
|
3505
4228
|
return transform(response).with(ToolkitRetrieveCategoriesResponseSchema).using((response) => ({
|
|
3506
4229
|
items: response.items.map((item) => ({
|
|
@@ -3511,6 +4234,47 @@ const transformToolkitRetrieveCategoriesResponse = (response) => {
|
|
|
3511
4234
|
totalPages: response.total_pages
|
|
3512
4235
|
}));
|
|
3513
4236
|
};
|
|
4237
|
+
const transformToolkitRecommendScopesParams = (params) => ({
|
|
4238
|
+
tools: params.tools,
|
|
4239
|
+
auth_scheme: params.authScheme,
|
|
4240
|
+
toolkit_version: params.toolkitVersion,
|
|
4241
|
+
grant_context: params.grantContext,
|
|
4242
|
+
include: params.include,
|
|
4243
|
+
exclude: params.exclude,
|
|
4244
|
+
available_scopes: params.availableScopes
|
|
4245
|
+
});
|
|
4246
|
+
const transformToolkitRecommendScopesResponse = (response) => {
|
|
4247
|
+
return transform(response).with(ToolkitRecommendScopesResponseSchema).using((response) => ({
|
|
4248
|
+
authScheme: response.auth_scheme,
|
|
4249
|
+
toolkitVersion: response.toolkit_version,
|
|
4250
|
+
grantContext: response.grant_context,
|
|
4251
|
+
scopes: {
|
|
4252
|
+
leastPrivilege: response.scopes.least_privilege,
|
|
4253
|
+
fewest: response.scopes.fewest,
|
|
4254
|
+
conditional: response.scopes.conditional.map((condition) => ({
|
|
4255
|
+
scope: condition.scope,
|
|
4256
|
+
when: condition.when,
|
|
4257
|
+
for: condition.for
|
|
4258
|
+
}))
|
|
4259
|
+
}
|
|
4260
|
+
}));
|
|
4261
|
+
};
|
|
4262
|
+
const transformToolkitListGrantContextsParams = (params) => ({
|
|
4263
|
+
auth_scheme: params.authScheme,
|
|
4264
|
+
toolkit_version: params.toolkitVersion
|
|
4265
|
+
});
|
|
4266
|
+
const transformToolkitListGrantContextsResponse = (response) => {
|
|
4267
|
+
return transform(response).with(ToolkitListGrantContextsResponseSchema).using((response) => ({
|
|
4268
|
+
authScheme: response.auth_scheme,
|
|
4269
|
+
toolkitVersion: response.toolkit_version,
|
|
4270
|
+
grantContextDimensions: response.grant_context_dimensions.map((dimension) => ({
|
|
4271
|
+
dimension: dimension.dimension,
|
|
4272
|
+
description: dimension.description,
|
|
4273
|
+
values: dimension.values
|
|
4274
|
+
})),
|
|
4275
|
+
defaultGrantContext: response.default_grant_context
|
|
4276
|
+
}));
|
|
4277
|
+
};
|
|
3514
4278
|
|
|
3515
4279
|
//#endregion
|
|
3516
4280
|
//#region src/models/Toolkits.ts
|
|
@@ -3549,7 +4313,8 @@ var Toolkits = class {
|
|
|
3549
4313
|
cursor: parsedQuery.data.cursor,
|
|
3550
4314
|
limit: parsedQuery.data.limit
|
|
3551
4315
|
};
|
|
3552
|
-
|
|
4316
|
+
const result = await withCancellation(() => this.client.toolkits.list(listParams, requestOptions), requestOptions?.signal);
|
|
4317
|
+
return transformToolkitListResponse(result);
|
|
3553
4318
|
} catch (error) {
|
|
3554
4319
|
if (error instanceof ComposioRequestCancelledError) throw error;
|
|
3555
4320
|
throw new ComposioToolkitFetchError("Failed to fetch toolkits", { cause: error });
|
|
@@ -3570,7 +4335,8 @@ var Toolkits = class {
|
|
|
3570
4335
|
*/
|
|
3571
4336
|
async getToolkitBySlug(slug, requestOptions) {
|
|
3572
4337
|
try {
|
|
3573
|
-
|
|
4338
|
+
const result = await withCancellation(() => this.client.toolkits.retrieve(slug, void 0, requestOptions), requestOptions?.signal);
|
|
4339
|
+
return transformToolkitRetrieveResponse(result);
|
|
3574
4340
|
} catch (error) {
|
|
3575
4341
|
if (error instanceof ComposioRequestCancelledError) throw error;
|
|
3576
4342
|
if (error instanceof APIError$1 && (error.status === 404 || error.status === 400)) throw new ComposioToolkitNotFoundError(`Toolkit with slug ${slug} not found`, {
|
|
@@ -3594,6 +4360,125 @@ var Toolkits = class {
|
|
|
3594
4360
|
if (typeof arg === "string") return this.getToolkitBySlug(arg, requestOptions);
|
|
3595
4361
|
return this.getToolkits(arg ?? {}, requestOptions);
|
|
3596
4362
|
}
|
|
4363
|
+
/**
|
|
4364
|
+
* Retrieves several toolkits by slug in a single request.
|
|
4365
|
+
*
|
|
4366
|
+
* Returns the same transformed shape as `composio.toolkits.get({ ... })`.
|
|
4367
|
+
* Unknown slugs are simply absent from the result.
|
|
4368
|
+
*
|
|
4369
|
+
* @param {string[]} slugs - The toolkit slugs to retrieve (at least one)
|
|
4370
|
+
* @param {ToolkitGetManyParams} [params] - Optional filters and pagination, as for `list`
|
|
4371
|
+
* @returns {Promise<ToolKitListResponse>} The matching toolkits
|
|
4372
|
+
* @throws {ValidationError} If `slugs` is empty or the params fail validation
|
|
4373
|
+
* @throws {ComposioToolkitFetchError} If the request fails
|
|
4374
|
+
*
|
|
4375
|
+
* @example
|
|
4376
|
+
* ```typescript
|
|
4377
|
+
* const toolkits = await composio.toolkits.getMany(['github', 'slack']);
|
|
4378
|
+
* console.log(toolkits.map(toolkit => toolkit.name)); // ['GitHub', 'Slack']
|
|
4379
|
+
* ```
|
|
4380
|
+
*/
|
|
4381
|
+
async getMany(slugs, params, requestOptions) {
|
|
4382
|
+
const parsedSlugs = ToolkitGetManySlugsSchema.safeParse(slugs);
|
|
4383
|
+
if (!parsedSlugs.success) throw new ValidationError("Failed to parse toolkit slugs", { cause: parsedSlugs.error });
|
|
4384
|
+
const parsedParams = ToolkitsGetManyParamsSchema.safeParse(params ?? {});
|
|
4385
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse toolkit getMany params", { cause: parsedParams.error });
|
|
4386
|
+
const body = {
|
|
4387
|
+
toolkits: parsedSlugs.data,
|
|
4388
|
+
category: parsedParams.data.category,
|
|
4389
|
+
managed_by: parsedParams.data.managedBy,
|
|
4390
|
+
sort_by: parsedParams.data.sortBy,
|
|
4391
|
+
cursor: parsedParams.data.cursor,
|
|
4392
|
+
limit: parsedParams.data.limit
|
|
4393
|
+
};
|
|
4394
|
+
try {
|
|
4395
|
+
const result = await withCancellation(() => this.client.toolkits.retrieveMulti(body, requestOptions), requestOptions?.signal);
|
|
4396
|
+
return transformToolkitListResponse(result);
|
|
4397
|
+
} catch (error) {
|
|
4398
|
+
if (error instanceof ComposioRequestCancelledError) throw error;
|
|
4399
|
+
throw new ComposioToolkitFetchError("Failed to fetch toolkits", {
|
|
4400
|
+
meta: { slugs: parsedSlugs.data },
|
|
4401
|
+
cause: error
|
|
4402
|
+
});
|
|
4403
|
+
}
|
|
4404
|
+
}
|
|
4405
|
+
/**
|
|
4406
|
+
* Retrieves the version changelog of every toolkit (the last 10 versions
|
|
4407
|
+
* per toolkit).
|
|
4408
|
+
*
|
|
4409
|
+
* @returns {Promise<ToolkitChangelogResponse>} Toolkits with their recent version changelogs
|
|
4410
|
+
*
|
|
4411
|
+
* @example
|
|
4412
|
+
* ```typescript
|
|
4413
|
+
* const { items } = await composio.toolkits.changelog();
|
|
4414
|
+
* const github = items.find(item => item.slug === 'github');
|
|
4415
|
+
* console.log(github?.versions[0]); // { version: '20250909_00', changelog: '...' }
|
|
4416
|
+
* ```
|
|
4417
|
+
*/
|
|
4418
|
+
async changelog(requestOptions) {
|
|
4419
|
+
const result = await withCancellation(() => this.client.toolkits.retrieveChangelog(requestOptions), requestOptions?.signal);
|
|
4420
|
+
return transformToolkitChangelogResponse(result);
|
|
4421
|
+
}
|
|
4422
|
+
/**
|
|
4423
|
+
* Recommends the OAuth scopes to request so a connection can run the given
|
|
4424
|
+
* tools.
|
|
4425
|
+
* **Experimental — the API marks this endpoint beta; shape may change.**
|
|
4426
|
+
*
|
|
4427
|
+
* The answer comes in two variants: `leastPrivilege` (narrowest documented
|
|
4428
|
+
* scope per requirement) and `fewest` (smallest set covering everything).
|
|
4429
|
+
* Pass `toolkitVersion` from a previous answer to pin the computation.
|
|
4430
|
+
*
|
|
4431
|
+
* @param {string} toolkitSlug - The toolkit to recommend scopes for
|
|
4432
|
+
* @param {ToolkitRecommendScopesParams} params - Tools to cover (`[]` for the whole toolkit), auth scheme, grant context and scope constraints
|
|
4433
|
+
* @returns {Promise<ToolkitRecommendScopesResponse>} The recommended scope sets
|
|
4434
|
+
* @throws {ValidationError} If the params fail validation
|
|
4435
|
+
*
|
|
4436
|
+
* @example
|
|
4437
|
+
* ```typescript
|
|
4438
|
+
* const { scopes } = await composio.toolkits.recommendScopes('gmail', {
|
|
4439
|
+
* tools: ['GMAIL_SEND_EMAIL', 'GMAIL_FETCH_EMAILS'],
|
|
4440
|
+
* });
|
|
4441
|
+
* console.log(scopes.leastPrivilege);
|
|
4442
|
+
* ```
|
|
4443
|
+
*/
|
|
4444
|
+
async recommendScopes(toolkitSlug, params, requestOptions) {
|
|
4445
|
+
const parsedParams = ToolkitRecommendScopesParamsSchema.safeParse(params);
|
|
4446
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse toolkit recommendScopes params", { cause: parsedParams.error });
|
|
4447
|
+
const body = transformToolkitRecommendScopesParams(parsedParams.data);
|
|
4448
|
+
const result = await withCancellation(() => this.client.toolkits.recommendScopes(toolkitSlug, body, requestOptions), requestOptions?.signal);
|
|
4449
|
+
return transformToolkitRecommendScopesResponse(result);
|
|
4450
|
+
}
|
|
4451
|
+
/**
|
|
4452
|
+
* Lists the grant-context dimensions a toolkit's scope recommendation
|
|
4453
|
+
* depends on (for example the Google account type), with their allowed
|
|
4454
|
+
* values and the default the API assumes.
|
|
4455
|
+
* **Experimental — the API marks this endpoint beta; shape may change.**
|
|
4456
|
+
*
|
|
4457
|
+
* Pass a dimension and a value as `grantContext` to
|
|
4458
|
+
* `composio.toolkits.recommendScopes()` to tailor the recommendation.
|
|
4459
|
+
*
|
|
4460
|
+
* @param {string} toolkitSlug - The toolkit to list grant contexts for
|
|
4461
|
+
* @param {ToolkitListGrantContextsParams} [params] - Optional auth scheme and toolkit version
|
|
4462
|
+
* @returns {Promise<ToolkitListGrantContextsResponse>} The dimensions and the default grant context
|
|
4463
|
+
* @throws {ValidationError} If the params fail validation
|
|
4464
|
+
*
|
|
4465
|
+
* @example
|
|
4466
|
+
* ```typescript
|
|
4467
|
+
* const { grantContextDimensions } = await composio.toolkits.listGrantContexts('gmail');
|
|
4468
|
+
* const [accountType] = grantContextDimensions;
|
|
4469
|
+
* const { scopes } = await composio.toolkits.recommendScopes('gmail', {
|
|
4470
|
+
* tools: ['GMAIL_SEND_EMAIL'],
|
|
4471
|
+
* grantContext: { [accountType.dimension]: accountType.values[0] },
|
|
4472
|
+
* });
|
|
4473
|
+
* ```
|
|
4474
|
+
*/
|
|
4475
|
+
async listGrantContexts(toolkitSlug, params, requestOptions) {
|
|
4476
|
+
const parsedParams = ToolkitListGrantContextsParamsSchema.safeParse(params ?? {});
|
|
4477
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse toolkit listGrantContexts params", { cause: parsedParams.error });
|
|
4478
|
+
const query = transformToolkitListGrantContextsParams(parsedParams.data);
|
|
4479
|
+
const result = await withCancellation(() => this.client.toolkits.retrieveScopesGrantContext(toolkitSlug, query, requestOptions), requestOptions?.signal);
|
|
4480
|
+
return transformToolkitListGrantContextsResponse(result);
|
|
4481
|
+
}
|
|
3597
4482
|
async getAuthConfigFields(toolkitSlug, authScheme, authConfigType, requiredOnly) {
|
|
3598
4483
|
const toolkit = await this.getToolkitBySlug(toolkitSlug);
|
|
3599
4484
|
if (!toolkit.authConfigDetails) throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", { meta: { toolkitSlug } });
|
|
@@ -3650,7 +4535,8 @@ var Toolkits = class {
|
|
|
3650
4535
|
* ```
|
|
3651
4536
|
*/
|
|
3652
4537
|
async listCategories(requestOptions) {
|
|
3653
|
-
|
|
4538
|
+
const result = await withCancellation(() => this.client.toolkits.retrieveCategories(requestOptions), requestOptions?.signal);
|
|
4539
|
+
return transformToolkitRetrieveCategoriesResponse(result);
|
|
3654
4540
|
}
|
|
3655
4541
|
/**
|
|
3656
4542
|
* Authorizes a user to use a toolkit.
|
|
@@ -3670,20 +4556,22 @@ var Toolkits = class {
|
|
|
3670
4556
|
const composioAuthConfig = new AuthConfigs(this.client);
|
|
3671
4557
|
let authConfigIdToUse = authConfigId;
|
|
3672
4558
|
if (!authConfigIdToUse) authConfigIdToUse = (await composioAuthConfig.list({ toolkit: toolkitSlug }, requestOptions)).items[0]?.id;
|
|
3673
|
-
if (!authConfigIdToUse)
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
4559
|
+
if (!authConfigIdToUse) {
|
|
4560
|
+
if (toolkit.authConfigDetails && toolkit.authConfigDetails.length > 0) try {
|
|
4561
|
+
authConfigIdToUse = (await composioAuthConfig.create(toolkitSlug, {
|
|
4562
|
+
type: "use_composio_managed_auth",
|
|
4563
|
+
name: `${toolkit.name} Auth Config`
|
|
4564
|
+
}, requestOptions)).id;
|
|
4565
|
+
} catch (error) {
|
|
4566
|
+
if (error instanceof ComposioClient.APIError && error.status === 400) throw new ComposioAuthConfigNotFoundError(`No Default auth config found for toolkit ${toolkitSlug}`, {
|
|
4567
|
+
meta: { toolkitSlug },
|
|
4568
|
+
cause: error,
|
|
4569
|
+
possibleFixes: [`Please Create an auth config for the toolkit ${toolkitSlug} via the dashboard`]
|
|
4570
|
+
});
|
|
4571
|
+
throw error;
|
|
4572
|
+
}
|
|
4573
|
+
else throw new ComposioAuthConfigNotFoundError(`No auth configs found for toolkit ${toolkitSlug}`, { meta: { toolkitSlug } });
|
|
3685
4574
|
}
|
|
3686
|
-
else throw new ComposioAuthConfigNotFoundError(`No auth configs found for toolkit ${toolkitSlug}`, { meta: { toolkitSlug } });
|
|
3687
4575
|
return await new ConnectedAccounts(this.client).initiate(userId, authConfigIdToUse, { allowMultiple: true }, requestOptions);
|
|
3688
4576
|
}
|
|
3689
4577
|
};
|
|
@@ -3846,65 +4734,538 @@ const WebhookVersions = {
|
|
|
3846
4734
|
V2: "V2",
|
|
3847
4735
|
V3: "V3"
|
|
3848
4736
|
};
|
|
3849
|
-
const DefaultWebhookSubscriptionEvents = ["composio.trigger.message"];
|
|
3850
|
-
const SetWebhookSubscriptionParamsSchema = z$1.object({
|
|
3851
|
-
/** HTTPS URL to receive webhook events. */
|
|
3852
|
-
webhookUrl: z$1.string().min(1),
|
|
3853
|
-
/** Event types to subscribe to. Defaults to trigger messages. */
|
|
3854
|
-
enabledEvents: z$1.array(z$1.string()).min(1).optional(),
|
|
3855
|
-
/** Webhook payload version. Defaults to V3. */
|
|
3856
|
-
version: z$1.enum([
|
|
3857
|
-
"V1",
|
|
3858
|
-
"V2",
|
|
3859
|
-
"V3"
|
|
3860
|
-
]).optional()
|
|
3861
|
-
});
|
|
4737
|
+
const DefaultWebhookSubscriptionEvents = ["composio.trigger.message"];
|
|
4738
|
+
const SetWebhookSubscriptionParamsSchema = z$1.object({
|
|
4739
|
+
/** HTTPS URL to receive webhook events. */
|
|
4740
|
+
webhookUrl: z$1.string().min(1),
|
|
4741
|
+
/** Event types to subscribe to. Defaults to trigger messages. */
|
|
4742
|
+
enabledEvents: z$1.array(z$1.string()).min(1).optional(),
|
|
4743
|
+
/** Webhook payload version. Defaults to V3. */
|
|
4744
|
+
version: z$1.enum([
|
|
4745
|
+
"V1",
|
|
4746
|
+
"V2",
|
|
4747
|
+
"V3"
|
|
4748
|
+
]).optional()
|
|
4749
|
+
});
|
|
4750
|
+
/**
|
|
4751
|
+
* Parameters for verifying a webhook signature
|
|
4752
|
+
*/
|
|
4753
|
+
const VerifyWebhookParamsSchema = z$1.object({
|
|
4754
|
+
/**
|
|
4755
|
+
* The webhook message ID from the 'webhook-id' header.
|
|
4756
|
+
* Format: 'msg_xxx'
|
|
4757
|
+
*/
|
|
4758
|
+
id: z$1.string({
|
|
4759
|
+
required_error: "Missing 'id' parameter. Pass the value of the 'webhook-id' HTTP header.",
|
|
4760
|
+
invalid_type_error: "Invalid 'id' parameter. Expected string from 'webhook-id' HTTP header."
|
|
4761
|
+
}),
|
|
4762
|
+
/** The raw webhook payload as a string (request body) */
|
|
4763
|
+
payload: z$1.string({
|
|
4764
|
+
required_error: "Missing 'payload' parameter. Pass the raw request body as a string (do not parse it).",
|
|
4765
|
+
invalid_type_error: "Invalid 'payload' parameter. Expected string (raw request body)."
|
|
4766
|
+
}),
|
|
4767
|
+
/** The webhook secret used to sign the payload (from Composio dashboard) */
|
|
4768
|
+
secret: z$1.string({
|
|
4769
|
+
required_error: "Missing 'secret' parameter. Get your webhook secret from the Composio dashboard.",
|
|
4770
|
+
invalid_type_error: "Invalid 'secret' parameter. Expected string."
|
|
4771
|
+
}),
|
|
4772
|
+
/**
|
|
4773
|
+
* The signature from the 'webhook-signature' header.
|
|
4774
|
+
* Format: 'v1,base64EncodedSignature'
|
|
4775
|
+
*/
|
|
4776
|
+
signature: z$1.string({
|
|
4777
|
+
required_error: "Missing 'signature' parameter. Pass the value of the 'webhook-signature' HTTP header.",
|
|
4778
|
+
invalid_type_error: "Invalid 'signature' parameter. Expected string from 'webhook-signature' HTTP header."
|
|
4779
|
+
}),
|
|
4780
|
+
/**
|
|
4781
|
+
* The webhook timestamp from the 'webhook-timestamp' header.
|
|
4782
|
+
* This is the Unix timestamp in seconds when the webhook was sent.
|
|
4783
|
+
*/
|
|
4784
|
+
timestamp: z$1.string({
|
|
4785
|
+
required_error: "Missing 'timestamp' parameter. Pass the value of the 'webhook-timestamp' HTTP header.",
|
|
4786
|
+
invalid_type_error: "Invalid 'timestamp' parameter. Expected string from 'webhook-timestamp' HTTP header."
|
|
4787
|
+
}),
|
|
4788
|
+
/**
|
|
4789
|
+
* Maximum allowed age of the webhook in seconds.
|
|
4790
|
+
* If the webhook timestamp is older than this, verification will fail.
|
|
4791
|
+
* Set to 0 to disable timestamp validation.
|
|
4792
|
+
* @default 300 (5 minutes)
|
|
4793
|
+
*/
|
|
4794
|
+
tolerance: z$1.number().optional().default(300)
|
|
4795
|
+
});
|
|
4796
|
+
|
|
4797
|
+
//#endregion
|
|
4798
|
+
//#region src/types/webhooks.types.ts
|
|
4799
|
+
/**
|
|
4800
|
+
* Webhook payload versions accepted by the webhook subscription endpoints.
|
|
4801
|
+
*/
|
|
4802
|
+
const WebhookVersionSchema = z$1.enum([
|
|
4803
|
+
"V1",
|
|
4804
|
+
"V2",
|
|
4805
|
+
"V3"
|
|
4806
|
+
]);
|
|
4807
|
+
/**
|
|
4808
|
+
* A project webhook subscription in the SDK's camelCase shape. The signing
|
|
4809
|
+
* `secret` is returned by the API on every subscription read/write.
|
|
4810
|
+
*/
|
|
4811
|
+
const WebhookSubscriptionSchema = z$1.object({
|
|
4812
|
+
id: z$1.string(),
|
|
4813
|
+
webhookUrl: z$1.string(),
|
|
4814
|
+
version: WebhookVersionSchema,
|
|
4815
|
+
enabledEvents: z$1.array(z$1.string()),
|
|
4816
|
+
secret: z$1.string().optional(),
|
|
4817
|
+
createdAt: z$1.string().optional(),
|
|
4818
|
+
updatedAt: z$1.string().optional()
|
|
4819
|
+
});
|
|
4820
|
+
const WebhookSubscriptionListParamsSchema = z$1.object({
|
|
4821
|
+
/** Number of items per page, max allowed is 50. */
|
|
4822
|
+
limit: z$1.number().optional(),
|
|
4823
|
+
/** Cursor for pagination, taken from a previous response's `nextCursor`. */
|
|
4824
|
+
cursor: z$1.string().optional()
|
|
4825
|
+
});
|
|
4826
|
+
const WebhookSubscriptionListResponseSchema = z$1.object({
|
|
4827
|
+
items: z$1.array(WebhookSubscriptionSchema),
|
|
4828
|
+
nextCursor: z$1.string().nullable(),
|
|
4829
|
+
totalPages: z$1.number(),
|
|
4830
|
+
currentPage: z$1.number(),
|
|
4831
|
+
totalItems: z$1.number()
|
|
4832
|
+
});
|
|
4833
|
+
/**
|
|
4834
|
+
* Params for `composio.webhooks.subscriptions.set()`. Identical to the
|
|
4835
|
+
* params accepted by `composio.triggers.setWebhookSubscription()`.
|
|
4836
|
+
*/
|
|
4837
|
+
const WebhookSubscriptionSetParamsSchema = SetWebhookSubscriptionParamsSchema;
|
|
4838
|
+
const WebhookSubscriptionUpdateParamsSchema = z$1.object({
|
|
4839
|
+
/** HTTPS URL to receive webhook events. */
|
|
4840
|
+
webhookUrl: z$1.string().min(1).optional(),
|
|
4841
|
+
/** Event types to subscribe to. */
|
|
4842
|
+
enabledEvents: z$1.array(z$1.string()).min(1).optional(),
|
|
4843
|
+
/** Webhook payload version. */
|
|
4844
|
+
version: WebhookVersionSchema.optional()
|
|
4845
|
+
});
|
|
4846
|
+
const WebhookSubscriptionDeleteResponseSchema = z$1.object({ success: z$1.boolean() });
|
|
4847
|
+
const WebhookSubscriptionRotateSecretResponseSchema = z$1.object({
|
|
4848
|
+
id: z$1.string(),
|
|
4849
|
+
/** The new signing secret. Store it — the previous secret stops validating. */
|
|
4850
|
+
secret: z$1.string()
|
|
4851
|
+
});
|
|
4852
|
+
const WebhookSubscriptionEventTypeSchema = z$1.object({
|
|
4853
|
+
eventType: z$1.string(),
|
|
4854
|
+
description: z$1.string(),
|
|
4855
|
+
supportedVersions: z$1.array(WebhookVersionSchema)
|
|
4856
|
+
});
|
|
4857
|
+
const WebhookSubscriptionEventTypesResponseSchema = z$1.object({ items: z$1.array(WebhookSubscriptionEventTypeSchema) });
|
|
4858
|
+
const WebhookEndpointListParamsSchema = z$1.object({
|
|
4859
|
+
/** Only return endpoints for this toolkit slug. */
|
|
4860
|
+
toolkitSlug: z$1.string().optional() });
|
|
4861
|
+
const WebhookEndpointListItemSchema = z$1.object({
|
|
4862
|
+
id: z$1.string(),
|
|
4863
|
+
toolkitSlug: z$1.string(),
|
|
4864
|
+
clientId: z$1.string().nullable()
|
|
4865
|
+
});
|
|
4866
|
+
const WebhookEndpointListResponseSchema = z$1.object({ items: z$1.array(WebhookEndpointListItemSchema) });
|
|
4867
|
+
const WebhookEndpointSchema = z$1.object({
|
|
4868
|
+
id: z$1.string(),
|
|
4869
|
+
toolkitSlug: z$1.string(),
|
|
4870
|
+
clientId: z$1.string().nullable(),
|
|
4871
|
+
/** The inbound URL to register with the third-party provider. */
|
|
4872
|
+
webhookUrl: z$1.string(),
|
|
4873
|
+
/** Configured setup fields with secret values masked. */
|
|
4874
|
+
data: z$1.record(z$1.string(), z$1.string()).nullable(),
|
|
4875
|
+
createdAt: z$1.string()
|
|
4876
|
+
});
|
|
4877
|
+
const WebhookEndpointCreateParamsSchema = z$1.object({
|
|
4878
|
+
/** Toolkit identifier (e.g. `slack`, `discord`). */
|
|
4879
|
+
toolkitSlug: z$1.string().min(1),
|
|
4880
|
+
/** OAuth app client ID — identifies which app this endpoint is for. */
|
|
4881
|
+
clientId: z$1.string().min(1)
|
|
4882
|
+
});
|
|
4883
|
+
const WebhookEndpointReplaceParamsSchema = z$1.object({
|
|
4884
|
+
/** Key-value pairs for ALL required setup fields of the toolkit. */
|
|
4885
|
+
data: z$1.record(z$1.string(), z$1.string()) });
|
|
4886
|
+
const WebhookEndpointUpdateParamsSchema = z$1.object({
|
|
4887
|
+
/** Key-value pairs to merge into the setup fields. Omitted fields are preserved. */
|
|
4888
|
+
data: z$1.record(z$1.string(), z$1.string()) });
|
|
4889
|
+
|
|
4890
|
+
//#endregion
|
|
4891
|
+
//#region src/utils/transformers/webhooks.ts
|
|
4892
|
+
const transformWebhookSubscription = (response) => {
|
|
4893
|
+
return transform(response).with(WebhookSubscriptionSchema).using((response) => ({
|
|
4894
|
+
id: response.id,
|
|
4895
|
+
webhookUrl: response.webhook_url,
|
|
4896
|
+
version: response.version,
|
|
4897
|
+
enabledEvents: response.enabled_events,
|
|
4898
|
+
secret: response.secret,
|
|
4899
|
+
createdAt: response.created_at,
|
|
4900
|
+
updatedAt: response.updated_at
|
|
4901
|
+
}));
|
|
4902
|
+
};
|
|
4903
|
+
const transformWebhookSubscriptionListResponse = (response) => {
|
|
4904
|
+
return transform(response).with(WebhookSubscriptionListResponseSchema).using((response) => ({
|
|
4905
|
+
items: response.items.map(transformWebhookSubscription),
|
|
4906
|
+
nextCursor: response.next_cursor ?? null,
|
|
4907
|
+
totalPages: response.total_pages,
|
|
4908
|
+
currentPage: response.current_page,
|
|
4909
|
+
totalItems: response.total_items
|
|
4910
|
+
}));
|
|
4911
|
+
};
|
|
4912
|
+
const transformWebhookSubscriptionDeleteResponse = (response) => {
|
|
4913
|
+
return transform(response).with(WebhookSubscriptionDeleteResponseSchema).using((response) => ({ success: response.success }));
|
|
4914
|
+
};
|
|
4915
|
+
const transformWebhookSubscriptionRotateSecretResponse = (response) => {
|
|
4916
|
+
return transform(response).with(WebhookSubscriptionRotateSecretResponseSchema).using((response) => ({
|
|
4917
|
+
id: response.id,
|
|
4918
|
+
secret: response.secret
|
|
4919
|
+
}));
|
|
4920
|
+
};
|
|
4921
|
+
const transformWebhookSubscriptionEventTypesResponse = (response) => {
|
|
4922
|
+
return transform(response).with(WebhookSubscriptionEventTypesResponseSchema).using((response) => ({ items: response.items.map((item) => ({
|
|
4923
|
+
eventType: item.event_type,
|
|
4924
|
+
description: item.description,
|
|
4925
|
+
supportedVersions: item.supported_versions
|
|
4926
|
+
})) }));
|
|
4927
|
+
};
|
|
4928
|
+
const transformWebhookEndpoint = (response) => {
|
|
4929
|
+
return transform(response).with(WebhookEndpointSchema).using((response) => ({
|
|
4930
|
+
id: response.id,
|
|
4931
|
+
toolkitSlug: response.toolkit_slug,
|
|
4932
|
+
clientId: response.client_id,
|
|
4933
|
+
webhookUrl: response.webhook_url,
|
|
4934
|
+
data: response.data,
|
|
4935
|
+
createdAt: response.created_at
|
|
4936
|
+
}));
|
|
4937
|
+
};
|
|
4938
|
+
const transformWebhookEndpointListResponse = (response) => {
|
|
4939
|
+
return transform(response).with(WebhookEndpointListResponseSchema).using((response) => ({ items: response.items.map((item) => ({
|
|
4940
|
+
id: item.id,
|
|
4941
|
+
toolkitSlug: item.toolkit_slug,
|
|
4942
|
+
clientId: item.client_id
|
|
4943
|
+
})) }));
|
|
4944
|
+
};
|
|
4945
|
+
|
|
4946
|
+
//#endregion
|
|
4947
|
+
//#region src/models/Webhooks.ts
|
|
4948
|
+
/**
|
|
4949
|
+
* The only part of the `list({ limit: 1 })` probe the upsert needs: the id of
|
|
4950
|
+
* the first (and, since the API allows one subscription per project, only)
|
|
4951
|
+
* subscription. Parsed at the boundary so a malformed payload never reaches
|
|
4952
|
+
* the update path.
|
|
4953
|
+
*/
|
|
4954
|
+
const FirstWebhookSubscriptionIdSchema = z$1.object({ items: z$1.array(z$1.object({ id: z$1.string().min(1) }).passthrough()).optional() }).passthrough().transform((response) => response.items?.[0]?.id);
|
|
4955
|
+
/**
|
|
4956
|
+
* Create-or-update the project webhook subscription.
|
|
4957
|
+
*
|
|
4958
|
+
* Shared by `composio.webhooks.subscriptions.set()` and the legacy
|
|
4959
|
+
* `composio.triggers.setWebhookSubscription()` so both issue the exact same
|
|
4960
|
+
* call sequence: `webhookSubscriptions.list({ limit: 1 })`, then
|
|
4961
|
+
* `webhookSubscriptions.update(id, body)` when a subscription exists,
|
|
4962
|
+
* otherwise `webhookSubscriptions.create(body)`.
|
|
4963
|
+
*
|
|
4964
|
+
* @internal
|
|
4965
|
+
*/
|
|
4966
|
+
async function upsertWebhookSubscription(client, params, requestOptions) {
|
|
4967
|
+
const parsedParams = WebhookSubscriptionSetParamsSchema.safeParse(params);
|
|
4968
|
+
if (!parsedParams.success) throw new ValidationError(`Invalid parameters passed to set webhook subscription`, { cause: parsedParams.error });
|
|
4969
|
+
const body = {
|
|
4970
|
+
webhook_url: parsedParams.data.webhookUrl,
|
|
4971
|
+
enabled_events: parsedParams.data.enabledEvents ?? [...DefaultWebhookSubscriptionEvents],
|
|
4972
|
+
version: parsedParams.data.version ?? WebhookVersions.V3
|
|
4973
|
+
};
|
|
4974
|
+
const existing = await withCancellation(() => client.webhookSubscriptions.list({ limit: 1 }, requestOptions), requestOptions?.signal);
|
|
4975
|
+
const parsedExisting = FirstWebhookSubscriptionIdSchema.safeParse(existing);
|
|
4976
|
+
if (!parsedExisting.success) throw new ValidationError("Failed to parse webhook subscription list response", { cause: parsedExisting.error });
|
|
4977
|
+
const subscriptionId = parsedExisting.data;
|
|
4978
|
+
const subscription = await withCancellation(() => subscriptionId ? client.webhookSubscriptions.update(subscriptionId, body, requestOptions) : client.webhookSubscriptions.create(body, requestOptions), requestOptions?.signal);
|
|
4979
|
+
return transformWebhookSubscription(subscription);
|
|
4980
|
+
}
|
|
4981
|
+
/**
|
|
4982
|
+
* `composio.webhooks.subscriptions` — the project's outbound webhook
|
|
4983
|
+
* subscription. The API allows one subscription per project; every response
|
|
4984
|
+
* includes the signing `secret` used to verify deliveries with
|
|
4985
|
+
* `composio.triggers.verifyWebhook()` / `composio.triggers.parse()`.
|
|
4986
|
+
*/
|
|
4987
|
+
var WebhookSubscriptions = class {
|
|
4988
|
+
client;
|
|
4989
|
+
constructor(client) {
|
|
4990
|
+
this.client = client;
|
|
4991
|
+
telemetry.instrument(this, "WebhookSubscriptions");
|
|
4992
|
+
}
|
|
4993
|
+
/**
|
|
4994
|
+
* List the project's webhook subscriptions.
|
|
4995
|
+
*
|
|
4996
|
+
* @param {WebhookSubscriptionListParams} [query] - Pagination options
|
|
4997
|
+
* @returns {Promise<WebhookSubscriptionListResponse>} Paginated subscriptions
|
|
4998
|
+
*
|
|
4999
|
+
* @example
|
|
5000
|
+
* ```typescript
|
|
5001
|
+
* const { items } = await composio.webhooks.subscriptions.list();
|
|
5002
|
+
* console.log(items[0]?.webhookUrl);
|
|
5003
|
+
* ```
|
|
5004
|
+
*/
|
|
5005
|
+
async list(query, requestOptions) {
|
|
5006
|
+
const parsedQuery = WebhookSubscriptionListParamsSchema.safeParse(query ?? {});
|
|
5007
|
+
if (!parsedQuery.success) throw new ValidationError("Failed to parse webhook subscription list query", { cause: parsedQuery.error });
|
|
5008
|
+
const listParams = {
|
|
5009
|
+
limit: parsedQuery.data.limit,
|
|
5010
|
+
cursor: parsedQuery.data.cursor
|
|
5011
|
+
};
|
|
5012
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.list(listParams, requestOptions), requestOptions?.signal);
|
|
5013
|
+
return transformWebhookSubscriptionListResponse(result);
|
|
5014
|
+
}
|
|
5015
|
+
/**
|
|
5016
|
+
* Retrieve a webhook subscription by id.
|
|
5017
|
+
*
|
|
5018
|
+
* @param {string} id - The subscription id
|
|
5019
|
+
* @returns {Promise<WebhookSubscription>} The subscription, including its signing secret
|
|
5020
|
+
*
|
|
5021
|
+
* @example
|
|
5022
|
+
* ```typescript
|
|
5023
|
+
* const subscription = await composio.webhooks.subscriptions.get('whs_abc123');
|
|
5024
|
+
* console.log(subscription.enabledEvents);
|
|
5025
|
+
* ```
|
|
5026
|
+
*/
|
|
5027
|
+
async get(id, requestOptions) {
|
|
5028
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.retrieve(id, requestOptions), requestOptions?.signal);
|
|
5029
|
+
return transformWebhookSubscription(result);
|
|
5030
|
+
}
|
|
5031
|
+
/**
|
|
5032
|
+
* Create or update the project webhook subscription.
|
|
5033
|
+
*
|
|
5034
|
+
* If a subscription already exists it is updated in place, otherwise a new
|
|
5035
|
+
* one is created. By default this subscribes to V3 trigger message events.
|
|
5036
|
+
*
|
|
5037
|
+
* @param {WebhookSubscriptionSetParams} params - `webhookUrl`, optional `enabledEvents` and `version`
|
|
5038
|
+
* @returns {Promise<WebhookSubscription>} The resulting subscription
|
|
5039
|
+
* @throws {ValidationError} If the params fail validation
|
|
5040
|
+
*
|
|
5041
|
+
* @example
|
|
5042
|
+
* ```typescript
|
|
5043
|
+
* const subscription = await composio.webhooks.subscriptions.set({
|
|
5044
|
+
* webhookUrl: `${APP_URL}/webhooks/composio`,
|
|
5045
|
+
* enabledEvents: ['composio.trigger.message', 'composio.connected_account.expired'],
|
|
5046
|
+
* });
|
|
5047
|
+
* process.env.COMPOSIO_WEBHOOK_SECRET = subscription.secret;
|
|
5048
|
+
* ```
|
|
5049
|
+
*/
|
|
5050
|
+
async set(params, requestOptions) {
|
|
5051
|
+
return upsertWebhookSubscription(this.client, params, requestOptions);
|
|
5052
|
+
}
|
|
5053
|
+
/**
|
|
5054
|
+
* Update an existing webhook subscription. Only the provided fields change.
|
|
5055
|
+
*
|
|
5056
|
+
* @param {string} id - The subscription id
|
|
5057
|
+
* @param {WebhookSubscriptionUpdateParams} params - Fields to update
|
|
5058
|
+
* @returns {Promise<WebhookSubscription>} The updated subscription
|
|
5059
|
+
* @throws {ValidationError} If the params fail validation
|
|
5060
|
+
*
|
|
5061
|
+
* @example
|
|
5062
|
+
* ```typescript
|
|
5063
|
+
* await composio.webhooks.subscriptions.update('whs_abc123', {
|
|
5064
|
+
* enabledEvents: ['composio.trigger.message'],
|
|
5065
|
+
* });
|
|
5066
|
+
* ```
|
|
5067
|
+
*/
|
|
5068
|
+
async update(id, params, requestOptions) {
|
|
5069
|
+
const parsedParams = WebhookSubscriptionUpdateParamsSchema.safeParse(params);
|
|
5070
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse webhook subscription update params", { cause: parsedParams.error });
|
|
5071
|
+
const body = {
|
|
5072
|
+
webhook_url: parsedParams.data.webhookUrl,
|
|
5073
|
+
enabled_events: parsedParams.data.enabledEvents,
|
|
5074
|
+
version: parsedParams.data.version
|
|
5075
|
+
};
|
|
5076
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.update(id, body, requestOptions), requestOptions?.signal);
|
|
5077
|
+
return transformWebhookSubscription(result);
|
|
5078
|
+
}
|
|
5079
|
+
/**
|
|
5080
|
+
* Delete a webhook subscription. Deliveries stop immediately.
|
|
5081
|
+
*
|
|
5082
|
+
* @param {string} id - The subscription id
|
|
5083
|
+
* @returns {Promise<WebhookSubscriptionDeleteResponse>} `{ success }`
|
|
5084
|
+
*
|
|
5085
|
+
* @example
|
|
5086
|
+
* ```typescript
|
|
5087
|
+
* await composio.webhooks.subscriptions.delete('whs_abc123');
|
|
5088
|
+
* ```
|
|
5089
|
+
*/
|
|
5090
|
+
async delete(id, requestOptions) {
|
|
5091
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.delete(id, requestOptions), requestOptions?.signal);
|
|
5092
|
+
return transformWebhookSubscriptionDeleteResponse(result);
|
|
5093
|
+
}
|
|
5094
|
+
/**
|
|
5095
|
+
* Rotate the signing secret of a webhook subscription. The previous secret
|
|
5096
|
+
* stops validating, so update your verifier with the returned `secret`.
|
|
5097
|
+
*
|
|
5098
|
+
* @param {string} id - The subscription id
|
|
5099
|
+
* @returns {Promise<WebhookSubscriptionRotateSecretResponse>} `{ id, secret }`
|
|
5100
|
+
*
|
|
5101
|
+
* @example
|
|
5102
|
+
* ```typescript
|
|
5103
|
+
* const { secret } = await composio.webhooks.subscriptions.rotateSecret('whs_abc123');
|
|
5104
|
+
* ```
|
|
5105
|
+
*/
|
|
5106
|
+
async rotateSecret(id, requestOptions) {
|
|
5107
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.rotateSecret(id, requestOptions), requestOptions?.signal);
|
|
5108
|
+
return transformWebhookSubscriptionRotateSecretResponse(result);
|
|
5109
|
+
}
|
|
5110
|
+
/**
|
|
5111
|
+
* List the event types a subscription can enable, with the payload
|
|
5112
|
+
* versions each one supports.
|
|
5113
|
+
*
|
|
5114
|
+
* @returns {Promise<WebhookSubscriptionEventTypesResponse>} The available event types
|
|
5115
|
+
*
|
|
5116
|
+
* @example
|
|
5117
|
+
* ```typescript
|
|
5118
|
+
* const { items } = await composio.webhooks.subscriptions.listEventTypes();
|
|
5119
|
+
* console.log(items.map(item => item.eventType));
|
|
5120
|
+
* ```
|
|
5121
|
+
*/
|
|
5122
|
+
async listEventTypes(requestOptions) {
|
|
5123
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.listEventTypes(requestOptions), requestOptions?.signal);
|
|
5124
|
+
return transformWebhookSubscriptionEventTypesResponse(result);
|
|
5125
|
+
}
|
|
5126
|
+
};
|
|
3862
5127
|
/**
|
|
3863
|
-
*
|
|
5128
|
+
* `composio.webhooks.endpoints` — inbound webhook endpoints. Each endpoint is
|
|
5129
|
+
* the ingress URL Composio exposes for one toolkit + OAuth app pair, which you
|
|
5130
|
+
* register with the third-party provider so it can push events to Composio.
|
|
3864
5131
|
*/
|
|
3865
|
-
|
|
5132
|
+
var WebhookEndpoints = class {
|
|
5133
|
+
client;
|
|
5134
|
+
constructor(client) {
|
|
5135
|
+
this.client = client;
|
|
5136
|
+
telemetry.instrument(this, "WebhookEndpoints");
|
|
5137
|
+
}
|
|
3866
5138
|
/**
|
|
3867
|
-
*
|
|
3868
|
-
*
|
|
5139
|
+
* List webhook endpoints, optionally filtered by toolkit.
|
|
5140
|
+
*
|
|
5141
|
+
* @param {WebhookEndpointListParams} [query] - Optional `toolkitSlug` filter
|
|
5142
|
+
* @returns {Promise<WebhookEndpointListResponse>} The endpoints
|
|
5143
|
+
*
|
|
5144
|
+
* @example
|
|
5145
|
+
* ```typescript
|
|
5146
|
+
* const { items } = await composio.webhooks.endpoints.list({ toolkitSlug: 'slack' });
|
|
5147
|
+
* ```
|
|
3869
5148
|
*/
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
invalid_type_error: "Invalid 'payload' parameter. Expected string (raw request body)."
|
|
3878
|
-
}),
|
|
3879
|
-
/** The webhook secret used to sign the payload (from Composio dashboard) */
|
|
3880
|
-
secret: z$1.string({
|
|
3881
|
-
required_error: "Missing 'secret' parameter. Get your webhook secret from the Composio dashboard.",
|
|
3882
|
-
invalid_type_error: "Invalid 'secret' parameter. Expected string."
|
|
3883
|
-
}),
|
|
5149
|
+
async list(query, requestOptions) {
|
|
5150
|
+
const parsedQuery = WebhookEndpointListParamsSchema.safeParse(query ?? {});
|
|
5151
|
+
if (!parsedQuery.success) throw new ValidationError("Failed to parse webhook endpoint list query", { cause: parsedQuery.error });
|
|
5152
|
+
const listParams = { toolkit_slug: parsedQuery.data.toolkitSlug };
|
|
5153
|
+
const result = await withCancellation(() => this.client.webhookEndpoints.list(listParams, requestOptions), requestOptions?.signal);
|
|
5154
|
+
return transformWebhookEndpointListResponse(result);
|
|
5155
|
+
}
|
|
3884
5156
|
/**
|
|
3885
|
-
*
|
|
3886
|
-
*
|
|
5157
|
+
* Retrieve a webhook endpoint by its nano id.
|
|
5158
|
+
*
|
|
5159
|
+
* @param {string} nanoId - The endpoint nano id (e.g. `we_abc123`)
|
|
5160
|
+
* @returns {Promise<WebhookEndpoint>} The endpoint, with secret setup values masked
|
|
5161
|
+
*
|
|
5162
|
+
* @example
|
|
5163
|
+
* ```typescript
|
|
5164
|
+
* const endpoint = await composio.webhooks.endpoints.get('we_abc123');
|
|
5165
|
+
* console.log(endpoint.webhookUrl);
|
|
5166
|
+
* ```
|
|
3887
5167
|
*/
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
}
|
|
5168
|
+
async get(nanoId, requestOptions) {
|
|
5169
|
+
const result = await withCancellation(() => this.client.webhookEndpoints.retrieve(nanoId, requestOptions), requestOptions?.signal);
|
|
5170
|
+
return transformWebhookEndpoint(result);
|
|
5171
|
+
}
|
|
3892
5172
|
/**
|
|
3893
|
-
*
|
|
3894
|
-
*
|
|
5173
|
+
* Create a webhook endpoint for a toolkit + OAuth app pair. Returns the
|
|
5174
|
+
* existing endpoint when one already exists for that pair.
|
|
5175
|
+
*
|
|
5176
|
+
* @param {WebhookEndpointCreateParams} params - `toolkitSlug` and `clientId`
|
|
5177
|
+
* @returns {Promise<WebhookEndpoint>} The endpoint; register `webhookUrl` with the provider
|
|
5178
|
+
* @throws {ValidationError} If the params fail validation
|
|
5179
|
+
*
|
|
5180
|
+
* @example
|
|
5181
|
+
* ```typescript
|
|
5182
|
+
* const endpoint = await composio.webhooks.endpoints.create({
|
|
5183
|
+
* toolkitSlug: 'slack',
|
|
5184
|
+
* clientId: 'my-slack-app-client-id',
|
|
5185
|
+
* });
|
|
5186
|
+
* ```
|
|
3895
5187
|
*/
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
5188
|
+
async create(params, requestOptions) {
|
|
5189
|
+
const parsedParams = WebhookEndpointCreateParamsSchema.safeParse(params);
|
|
5190
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse webhook endpoint create params", { cause: parsedParams.error });
|
|
5191
|
+
const body = {
|
|
5192
|
+
toolkit_slug: parsedParams.data.toolkitSlug,
|
|
5193
|
+
client_id: parsedParams.data.clientId
|
|
5194
|
+
};
|
|
5195
|
+
const result = await withCancellation(() => this.client.webhookEndpoints.create(body, requestOptions), requestOptions?.signal);
|
|
5196
|
+
return transformWebhookEndpoint(result);
|
|
5197
|
+
}
|
|
3900
5198
|
/**
|
|
3901
|
-
*
|
|
3902
|
-
*
|
|
3903
|
-
*
|
|
3904
|
-
* @
|
|
5199
|
+
* Replace the setup fields of a webhook endpoint. All required setup fields
|
|
5200
|
+
* for the toolkit must be provided — this is the initial configuration.
|
|
5201
|
+
*
|
|
5202
|
+
* @param {string} nanoId - The endpoint nano id
|
|
5203
|
+
* @param {WebhookEndpointReplaceParams} params - `data` with every required setup field
|
|
5204
|
+
* @returns {Promise<WebhookEndpoint>} The configured endpoint
|
|
5205
|
+
* @throws {ValidationError} If the params fail validation
|
|
5206
|
+
*
|
|
5207
|
+
* @example
|
|
5208
|
+
* ```typescript
|
|
5209
|
+
* await composio.webhooks.endpoints.replace('we_abc123', {
|
|
5210
|
+
* data: { signing_secret: process.env.SLACK_SIGNING_SECRET! },
|
|
5211
|
+
* });
|
|
5212
|
+
* ```
|
|
3905
5213
|
*/
|
|
3906
|
-
|
|
3907
|
-
|
|
5214
|
+
async replace(nanoId, params, requestOptions) {
|
|
5215
|
+
const parsedParams = WebhookEndpointReplaceParamsSchema.safeParse(params);
|
|
5216
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse webhook endpoint replace params", { cause: parsedParams.error });
|
|
5217
|
+
const result = await withCancellation(() => this.client.webhookEndpoints.replace(nanoId, { data: parsedParams.data.data }, requestOptions), requestOptions?.signal);
|
|
5218
|
+
return transformWebhookEndpoint(result);
|
|
5219
|
+
}
|
|
5220
|
+
/**
|
|
5221
|
+
* Merge setup fields into a webhook endpoint. Omitted fields are preserved.
|
|
5222
|
+
*
|
|
5223
|
+
* @param {string} nanoId - The endpoint nano id
|
|
5224
|
+
* @param {WebhookEndpointUpdateParams} params - `data` with the fields to change
|
|
5225
|
+
* @returns {Promise<WebhookEndpoint>} The updated endpoint
|
|
5226
|
+
* @throws {ValidationError} If the params fail validation
|
|
5227
|
+
*
|
|
5228
|
+
* @example
|
|
5229
|
+
* ```typescript
|
|
5230
|
+
* await composio.webhooks.endpoints.update('we_abc123', {
|
|
5231
|
+
* data: { signing_secret: 'rotated-secret' },
|
|
5232
|
+
* });
|
|
5233
|
+
* ```
|
|
5234
|
+
*/
|
|
5235
|
+
async update(nanoId, params, requestOptions) {
|
|
5236
|
+
const parsedParams = WebhookEndpointUpdateParamsSchema.safeParse(params);
|
|
5237
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse webhook endpoint update params", { cause: parsedParams.error });
|
|
5238
|
+
const result = await withCancellation(() => this.client.webhookEndpoints.update(nanoId, { data: parsedParams.data.data }, requestOptions), requestOptions?.signal);
|
|
5239
|
+
return transformWebhookEndpoint(result);
|
|
5240
|
+
}
|
|
5241
|
+
};
|
|
5242
|
+
/**
|
|
5243
|
+
* `composio.webhooks` namespace.
|
|
5244
|
+
*
|
|
5245
|
+
* - `subscriptions`: the project's outbound webhook subscription (where
|
|
5246
|
+
* Composio delivers trigger and lifecycle events).
|
|
5247
|
+
* - `endpoints`: inbound ingress URLs for third-party providers, one per
|
|
5248
|
+
* toolkit + OAuth app pair.
|
|
5249
|
+
*
|
|
5250
|
+
* @example
|
|
5251
|
+
* ```typescript
|
|
5252
|
+
* const subscription = await composio.webhooks.subscriptions.set({
|
|
5253
|
+
* webhookUrl: 'https://example.com/webhooks/composio',
|
|
5254
|
+
* });
|
|
5255
|
+
* const endpoints = await composio.webhooks.endpoints.list({ toolkitSlug: 'slack' });
|
|
5256
|
+
* ```
|
|
5257
|
+
*/
|
|
5258
|
+
var Webhooks = class {
|
|
5259
|
+
/** Manage the project's outbound webhook subscription. */
|
|
5260
|
+
subscriptions;
|
|
5261
|
+
/** Manage inbound webhook endpoints per toolkit + OAuth app. */
|
|
5262
|
+
endpoints;
|
|
5263
|
+
constructor(client) {
|
|
5264
|
+
this.subscriptions = new WebhookSubscriptions(client);
|
|
5265
|
+
this.endpoints = new WebhookEndpoints(client);
|
|
5266
|
+
telemetry.instrument(this, "Webhooks");
|
|
5267
|
+
}
|
|
5268
|
+
};
|
|
3908
5269
|
|
|
3909
5270
|
//#endregion
|
|
3910
5271
|
//#region src/services/internal/InternalService.types.ts
|
|
@@ -4153,8 +5514,8 @@ function transformTriggerInstanceListActiveItem(response) {
|
|
|
4153
5514
|
id: response.id,
|
|
4154
5515
|
connectedAccountId: response.connected_account_id,
|
|
4155
5516
|
disabledAt: response.disabled_at,
|
|
4156
|
-
state: response.state,
|
|
4157
|
-
triggerConfig: response.trigger_config,
|
|
5517
|
+
state: response.state ?? {},
|
|
5518
|
+
triggerConfig: response.trigger_config ?? {},
|
|
4158
5519
|
triggerName: response.trigger_name,
|
|
4159
5520
|
updatedAt: response.updated_at,
|
|
4160
5521
|
triggerData: response.trigger_data,
|
|
@@ -4182,7 +5543,8 @@ async function hmacSha256Base64(secret, message) {
|
|
|
4182
5543
|
hash: "SHA-256"
|
|
4183
5544
|
}, false, ["sign"]);
|
|
4184
5545
|
const signatureData = encoder.encode(message);
|
|
4185
|
-
|
|
5546
|
+
const signatureBuffer = await globalThis.crypto.subtle.sign("HMAC", key, signatureData);
|
|
5547
|
+
return arrayBufferToBase64(signatureBuffer);
|
|
4186
5548
|
}
|
|
4187
5549
|
/**
|
|
4188
5550
|
* Constant-time comparison of two strings to prevent timing attacks
|
|
@@ -4206,26 +5568,6 @@ const toStringOrDefault = (value, defaultValue) => {
|
|
|
4206
5568
|
const str = String(value);
|
|
4207
5569
|
return str.length > 0 ? str : defaultValue;
|
|
4208
5570
|
};
|
|
4209
|
-
const WEBHOOK_SUBSCRIPTIONS_PATH = "/api/v3.1/webhook_subscriptions";
|
|
4210
|
-
const asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
4211
|
-
const firstString = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
4212
|
-
const stringArray = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
4213
|
-
const transformWebhookSubscription = (subscription) => {
|
|
4214
|
-
const raw = asRecord(subscription);
|
|
4215
|
-
return {
|
|
4216
|
-
id: firstString(raw.id) ?? "",
|
|
4217
|
-
webhookUrl: firstString(raw.webhook_url) ?? firstString(raw.webhookUrl) ?? "",
|
|
4218
|
-
version: firstString(raw.version) ?? WebhookVersions.V3,
|
|
4219
|
-
enabledEvents: stringArray(raw.enabled_events).length ? stringArray(raw.enabled_events) : stringArray(raw.enabledEvents),
|
|
4220
|
-
secret: firstString(raw.secret),
|
|
4221
|
-
createdAt: firstString(raw.created_at) ?? firstString(raw.createdAt),
|
|
4222
|
-
updatedAt: firstString(raw.updated_at) ?? firstString(raw.updatedAt)
|
|
4223
|
-
};
|
|
4224
|
-
};
|
|
4225
|
-
const firstWebhookSubscriptionId = (response) => {
|
|
4226
|
-
const firstItem = Array.isArray(response.items) ? response.items[0] : void 0;
|
|
4227
|
-
return firstString(asRecord(firstItem).id);
|
|
4228
|
-
};
|
|
4229
5571
|
/**
|
|
4230
5572
|
* The signature header names Composio sends with every webhook delivery.
|
|
4231
5573
|
* @private
|
|
@@ -4297,17 +5639,7 @@ var Triggers = class {
|
|
|
4297
5639
|
* ```
|
|
4298
5640
|
*/
|
|
4299
5641
|
async setWebhookSubscription(params) {
|
|
4300
|
-
|
|
4301
|
-
if (!parsedParams.success) throw new ValidationError(`Invalid parameters passed to set webhook subscription`, { cause: parsedParams.error });
|
|
4302
|
-
const body = {
|
|
4303
|
-
webhook_url: parsedParams.data.webhookUrl,
|
|
4304
|
-
enabled_events: parsedParams.data.enabledEvents ?? [...DefaultWebhookSubscriptionEvents],
|
|
4305
|
-
version: parsedParams.data.version ?? WebhookVersions.V3
|
|
4306
|
-
};
|
|
4307
|
-
const existing = await this.client.get(WEBHOOK_SUBSCRIPTIONS_PATH, { query: { limit: 1 } });
|
|
4308
|
-
const subscriptionId = firstWebhookSubscriptionId(existing);
|
|
4309
|
-
const subscription = subscriptionId ? await this.client.patch(`${WEBHOOK_SUBSCRIPTIONS_PATH}/${encodeURIComponent(subscriptionId)}`, { body }) : await this.client.post(WEBHOOK_SUBSCRIPTIONS_PATH, { body });
|
|
4310
|
-
return transformWebhookSubscription(subscription);
|
|
5642
|
+
return upsertWebhookSubscription(this.client, params);
|
|
4311
5643
|
}
|
|
4312
5644
|
/**
|
|
4313
5645
|
* Fetch list of all the active triggers
|
|
@@ -4338,7 +5670,8 @@ var Triggers = class {
|
|
|
4338
5670
|
trigger_ids: parsedParams.data.triggerIds,
|
|
4339
5671
|
trigger_names: parsedParams.data.triggerNames
|
|
4340
5672
|
} : void 0;
|
|
4341
|
-
|
|
5673
|
+
const result = await withCancellation(() => this.client.triggerInstances.listActive(listParams, requestOptions), requestOptions?.signal);
|
|
5674
|
+
return transformTriggerInstanceListActiveResponse(result);
|
|
4342
5675
|
}
|
|
4343
5676
|
/**
|
|
4344
5677
|
* Create a new trigger instance for a user
|
|
@@ -4431,7 +5764,8 @@ var Triggers = class {
|
|
|
4431
5764
|
toolkit_slugs: parsedQuery.toolkits,
|
|
4432
5765
|
toolkit_versions: this.toolkitVersions
|
|
4433
5766
|
};
|
|
4434
|
-
|
|
5767
|
+
const result = await withCancellation(() => this.client.triggersTypes.list(listParams, requestOptions), requestOptions?.signal);
|
|
5768
|
+
return transformTriggerTypeListResponse(result);
|
|
4435
5769
|
}
|
|
4436
5770
|
/**
|
|
4437
5771
|
* Retrieve a trigger type by its slug for the provided version of the app
|
|
@@ -4442,7 +5776,8 @@ var Triggers = class {
|
|
|
4442
5776
|
*/
|
|
4443
5777
|
async getType(slug, requestOptions) {
|
|
4444
5778
|
const retrieveParams = { toolkit_versions: this.toolkitVersions };
|
|
4445
|
-
|
|
5779
|
+
const result = await withCancellation(() => this.client.triggersTypes.retrieve(slug, retrieveParams, requestOptions), requestOptions?.signal);
|
|
5780
|
+
return transformTriggerTypeRetrieveResponse(result);
|
|
4446
5781
|
}
|
|
4447
5782
|
/**
|
|
4448
5783
|
* Fetches the list of all the available trigger enums
|
|
@@ -4711,11 +6046,14 @@ var Triggers = class {
|
|
|
4711
6046
|
const id = getHeader(headers, WEBHOOK_HEADERS.id);
|
|
4712
6047
|
const timestamp = getHeader(headers, WEBHOOK_HEADERS.timestamp);
|
|
4713
6048
|
const signature = getHeader(headers, WEBHOOK_HEADERS.signature);
|
|
4714
|
-
if (!id || !timestamp || !signature)
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
6049
|
+
if (!id || !timestamp || !signature) {
|
|
6050
|
+
const missing = [
|
|
6051
|
+
!id ? `'${WEBHOOK_HEADERS.id}'` : void 0,
|
|
6052
|
+
!timestamp ? `'${WEBHOOK_HEADERS.timestamp}'` : void 0,
|
|
6053
|
+
!signature ? `'${WEBHOOK_HEADERS.signature}'` : void 0
|
|
6054
|
+
].filter((header) => header !== void 0);
|
|
6055
|
+
throw new ValidationError(`Cannot verify webhook: missing signature header(s) ${missing.join(", ")}. Pass the raw, unparsed request body and ensure the Composio signature headers (${WEBHOOK_HEADERS.id}, ${WEBHOOK_HEADERS.timestamp}, ${WEBHOOK_HEADERS.signature}) are forwarded to triggers.parse(). To parse without verifying, omit 'verifySecret'.`);
|
|
6056
|
+
}
|
|
4719
6057
|
return this.verifyWebhook({
|
|
4720
6058
|
payload: body,
|
|
4721
6059
|
signature,
|
|
@@ -4963,7 +6301,8 @@ var Triggers = class {
|
|
|
4963
6301
|
if (version === "v1" && value) v1Signatures.push(value);
|
|
4964
6302
|
}
|
|
4965
6303
|
if (v1Signatures.length === 0) throw new ComposioWebhookSignatureVerificationError("No valid v1 signature found in the webhook-signature header. Expected format: 'v1,base64EncodedSignature'");
|
|
4966
|
-
const
|
|
6304
|
+
const toSign = `${webhookId}.${webhookTimestamp}.${payload}`;
|
|
6305
|
+
const expectedSignature = await hmacSha256Base64(secret, toSign);
|
|
4967
6306
|
let isValid = false;
|
|
4968
6307
|
for (const providedSignature of v1Signatures) if (timingSafeEqual(providedSignature, expectedSignature)) {
|
|
4969
6308
|
isValid = true;
|
|
@@ -5220,7 +6559,8 @@ var MCP = class {
|
|
|
5220
6559
|
auth_config_ids: params.authConfigs?.length > 0 ? params.authConfigs.join(",") : void 0,
|
|
5221
6560
|
name: params.name
|
|
5222
6561
|
};
|
|
5223
|
-
|
|
6562
|
+
const listResponse = await withCancellation(() => this.client.mcp.list(listParams, requestOptions), requestOptions?.signal);
|
|
6563
|
+
return transform(listResponse).with(MCPListResponseSchema).using((raw) => ({
|
|
5224
6564
|
currentPage: raw.current_page,
|
|
5225
6565
|
totalPages: raw.total_pages,
|
|
5226
6566
|
items: raw.items.map((item) => ({
|
|
@@ -5431,6 +6771,324 @@ var MCP = class {
|
|
|
5431
6771
|
}
|
|
5432
6772
|
};
|
|
5433
6773
|
|
|
6774
|
+
//#endregion
|
|
6775
|
+
//#region src/types/logs.types.ts
|
|
6776
|
+
/**
|
|
6777
|
+
* Fields a tool-execution log search can filter on.
|
|
6778
|
+
*/
|
|
6779
|
+
const LogSearchFilterFieldSchema = z$1.enum([
|
|
6780
|
+
"tool_slug",
|
|
6781
|
+
"toolkit_slug",
|
|
6782
|
+
"connected_account_id",
|
|
6783
|
+
"auth_config_id",
|
|
6784
|
+
"status",
|
|
6785
|
+
"user_id",
|
|
6786
|
+
"session_id",
|
|
6787
|
+
"sandbox_id",
|
|
6788
|
+
"request_id",
|
|
6789
|
+
"log_id"
|
|
6790
|
+
]);
|
|
6791
|
+
const LogSearchFilterOperatorSchema = z$1.enum([
|
|
6792
|
+
"==",
|
|
6793
|
+
"!=",
|
|
6794
|
+
"contains",
|
|
6795
|
+
"not_contains"
|
|
6796
|
+
]);
|
|
6797
|
+
const LogSearchFilterSchema = z$1.object({
|
|
6798
|
+
field: LogSearchFilterFieldSchema,
|
|
6799
|
+
operator: LogSearchFilterOperatorSchema,
|
|
6800
|
+
value: z$1.string()
|
|
6801
|
+
});
|
|
6802
|
+
const LogSearchTimeRangeSchema = z$1.object({
|
|
6803
|
+
/** Start time in epoch milliseconds (inclusive). */
|
|
6804
|
+
from: z$1.number(),
|
|
6805
|
+
/** End time in epoch milliseconds. */
|
|
6806
|
+
to: z$1.number()
|
|
6807
|
+
});
|
|
6808
|
+
/**
|
|
6809
|
+
* Params for `composio.logs.search()`.
|
|
6810
|
+
*/
|
|
6811
|
+
const LogSearchParamsSchema = z$1.object({
|
|
6812
|
+
limit: z$1.number().optional(),
|
|
6813
|
+
cursor: z$1.string().nullable().optional(),
|
|
6814
|
+
filters: z$1.array(LogSearchFilterSchema).optional(),
|
|
6815
|
+
timeRange: LogSearchTimeRangeSchema.optional()
|
|
6816
|
+
});
|
|
6817
|
+
const ToolExecutionLogStatusSchema = z$1.enum(["success", "failed"]);
|
|
6818
|
+
const ToolExecutionLogLevelSchema = z$1.enum([
|
|
6819
|
+
"info",
|
|
6820
|
+
"error",
|
|
6821
|
+
"warn"
|
|
6822
|
+
]);
|
|
6823
|
+
const ToolExecutionLogParentSchema = z$1.object({
|
|
6824
|
+
logId: z$1.string(),
|
|
6825
|
+
toolSlug: z$1.string()
|
|
6826
|
+
}).nullable();
|
|
6827
|
+
/**
|
|
6828
|
+
* A tool-execution log entry as returned by `composio.logs.search()`.
|
|
6829
|
+
*/
|
|
6830
|
+
const ToolExecutionLogSchema = z$1.object({
|
|
6831
|
+
id: z$1.string(),
|
|
6832
|
+
/** ISO 8601 timestamp. */
|
|
6833
|
+
timestamp: z$1.string(),
|
|
6834
|
+
/** Log event type, e.g. `tool.execution`. */
|
|
6835
|
+
type: z$1.string(),
|
|
6836
|
+
status: ToolExecutionLogStatusSchema,
|
|
6837
|
+
level: ToolExecutionLogLevelSchema,
|
|
6838
|
+
message: z$1.string().optional(),
|
|
6839
|
+
metadata: z$1.record(z$1.string(), z$1.unknown()),
|
|
6840
|
+
metrics: z$1.record(z$1.string(), z$1.unknown()),
|
|
6841
|
+
parent: ToolExecutionLogParentSchema
|
|
6842
|
+
});
|
|
6843
|
+
const LogSearchResponseSchema = z$1.object({
|
|
6844
|
+
logs: z$1.array(ToolExecutionLogSchema),
|
|
6845
|
+
nextCursor: z$1.string().nullable()
|
|
6846
|
+
});
|
|
6847
|
+
/**
|
|
6848
|
+
* A single tool-execution log with its full detail, as returned by
|
|
6849
|
+
* `composio.logs.get()`.
|
|
6850
|
+
*/
|
|
6851
|
+
const ToolExecutionLogDetailSchema = ToolExecutionLogSchema.extend({
|
|
6852
|
+
timings: z$1.object({
|
|
6853
|
+
/** Epoch milliseconds. */
|
|
6854
|
+
startTime: z$1.number(),
|
|
6855
|
+
/** Epoch milliseconds. */
|
|
6856
|
+
endTime: z$1.number()
|
|
6857
|
+
}).optional(),
|
|
6858
|
+
context: z$1.object({
|
|
6859
|
+
sessionId: z$1.string().optional(),
|
|
6860
|
+
traceId: z$1.string().optional(),
|
|
6861
|
+
requestId: z$1.string().optional()
|
|
6862
|
+
}),
|
|
6863
|
+
source: z$1.object({
|
|
6864
|
+
host: z$1.string().optional(),
|
|
6865
|
+
framework: z$1.string().optional(),
|
|
6866
|
+
language: z$1.string().optional()
|
|
6867
|
+
}),
|
|
6868
|
+
data: z$1.record(z$1.string(), z$1.unknown())
|
|
6869
|
+
});
|
|
6870
|
+
|
|
6871
|
+
//#endregion
|
|
6872
|
+
//#region src/utils/transformers/logs.ts
|
|
6873
|
+
const transformLogSearchParams = (params) => ({
|
|
6874
|
+
limit: params.limit,
|
|
6875
|
+
cursor: params.cursor,
|
|
6876
|
+
filters: params.filters,
|
|
6877
|
+
time_range: params.timeRange
|
|
6878
|
+
});
|
|
6879
|
+
const transformToolExecutionLog = (response) => {
|
|
6880
|
+
return transform(response).with(ToolExecutionLogSchema).using((response) => ({
|
|
6881
|
+
id: response.id,
|
|
6882
|
+
timestamp: response.timestamp,
|
|
6883
|
+
type: response.type,
|
|
6884
|
+
status: response.status,
|
|
6885
|
+
level: response.level,
|
|
6886
|
+
message: response.message,
|
|
6887
|
+
metadata: response.metadata,
|
|
6888
|
+
metrics: response.metrics,
|
|
6889
|
+
parent: response.parent ? {
|
|
6890
|
+
logId: response.parent.log_id,
|
|
6891
|
+
toolSlug: response.parent.tool_slug
|
|
6892
|
+
} : null
|
|
6893
|
+
}));
|
|
6894
|
+
};
|
|
6895
|
+
const transformLogSearchResponse = (response) => {
|
|
6896
|
+
return transform(response).with(LogSearchResponseSchema).using((response) => ({
|
|
6897
|
+
logs: response.logs.map(transformToolExecutionLog),
|
|
6898
|
+
nextCursor: response.next_cursor
|
|
6899
|
+
}));
|
|
6900
|
+
};
|
|
6901
|
+
const transformToolExecutionLogDetail = (response) => {
|
|
6902
|
+
return transform(response).with(ToolExecutionLogDetailSchema).using((response) => ({
|
|
6903
|
+
id: response.id,
|
|
6904
|
+
timestamp: response.timestamp,
|
|
6905
|
+
type: response.type,
|
|
6906
|
+
status: response.status,
|
|
6907
|
+
level: response.level,
|
|
6908
|
+
message: response.message,
|
|
6909
|
+
metadata: response.metadata,
|
|
6910
|
+
metrics: response.metrics,
|
|
6911
|
+
parent: response.parent ? {
|
|
6912
|
+
logId: response.parent.log_id,
|
|
6913
|
+
toolSlug: response.parent.tool_slug
|
|
6914
|
+
} : null,
|
|
6915
|
+
timings: response.timings ? {
|
|
6916
|
+
startTime: response.timings.start_time,
|
|
6917
|
+
endTime: response.timings.end_time
|
|
6918
|
+
} : void 0,
|
|
6919
|
+
context: {
|
|
6920
|
+
sessionId: response.context.session_id,
|
|
6921
|
+
traceId: response.context.trace_id,
|
|
6922
|
+
requestId: response.context.request_id
|
|
6923
|
+
},
|
|
6924
|
+
source: {
|
|
6925
|
+
host: response.source.host,
|
|
6926
|
+
framework: response.source.framework,
|
|
6927
|
+
language: response.source.language
|
|
6928
|
+
},
|
|
6929
|
+
data: response.data
|
|
6930
|
+
}));
|
|
6931
|
+
};
|
|
6932
|
+
|
|
6933
|
+
//#endregion
|
|
6934
|
+
//#region src/models/Logs.ts
|
|
6935
|
+
/**
|
|
6936
|
+
* `composio.logs` — tool-execution logs.
|
|
6937
|
+
*
|
|
6938
|
+
* @example
|
|
6939
|
+
* ```typescript
|
|
6940
|
+
* const { logs, nextCursor } = await composio.logs.search({
|
|
6941
|
+
* filters: [{ field: 'toolkit_slug', operator: '==', value: 'github' }],
|
|
6942
|
+
* limit: 20,
|
|
6943
|
+
* });
|
|
6944
|
+
* const detail = await composio.logs.get(logs[0].id);
|
|
6945
|
+
* ```
|
|
6946
|
+
*/
|
|
6947
|
+
var Logs = class {
|
|
6948
|
+
client;
|
|
6949
|
+
constructor(client) {
|
|
6950
|
+
this.client = client;
|
|
6951
|
+
telemetry.instrument(this, "Logs");
|
|
6952
|
+
}
|
|
6953
|
+
/**
|
|
6954
|
+
* Search tool-execution logs with filters, a time range and cursor
|
|
6955
|
+
* pagination.
|
|
6956
|
+
*
|
|
6957
|
+
* @param {LogSearchParams} [params] - Filters, `timeRange`, `limit` and `cursor`
|
|
6958
|
+
* @returns {Promise<LogSearchResponse>} Matching logs and the next cursor
|
|
6959
|
+
* @throws {ValidationError} If the params fail validation
|
|
6960
|
+
*
|
|
6961
|
+
* @example
|
|
6962
|
+
* ```typescript
|
|
6963
|
+
* const { logs } = await composio.logs.search({
|
|
6964
|
+
* filters: [
|
|
6965
|
+
* { field: 'status', operator: '==', value: 'failed' },
|
|
6966
|
+
* { field: 'user_id', operator: '==', value: 'user_123' },
|
|
6967
|
+
* ],
|
|
6968
|
+
* timeRange: { from: Date.now() - 24 * 60 * 60 * 1000, to: Date.now() },
|
|
6969
|
+
* });
|
|
6970
|
+
* ```
|
|
6971
|
+
*/
|
|
6972
|
+
async search(params, requestOptions) {
|
|
6973
|
+
const parsedParams = LogSearchParamsSchema.safeParse(params ?? {});
|
|
6974
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse log search params", { cause: parsedParams.error });
|
|
6975
|
+
const body = transformLogSearchParams(parsedParams.data);
|
|
6976
|
+
const result = await withCancellation(() => this.client.logs.createToolExecution(body, requestOptions), requestOptions?.signal);
|
|
6977
|
+
return transformLogSearchResponse(result);
|
|
6978
|
+
}
|
|
6979
|
+
/**
|
|
6980
|
+
* Retrieve one tool-execution log with its full detail (timings, context,
|
|
6981
|
+
* source and raw `data`).
|
|
6982
|
+
*
|
|
6983
|
+
* @param {string} id - The log id
|
|
6984
|
+
* @returns {Promise<ToolExecutionLogDetail>} The log detail
|
|
6985
|
+
*
|
|
6986
|
+
* @example
|
|
6987
|
+
* ```typescript
|
|
6988
|
+
* const log = await composio.logs.get('log_abc123');
|
|
6989
|
+
* console.log(log.status, log.timings?.endTime);
|
|
6990
|
+
* ```
|
|
6991
|
+
*/
|
|
6992
|
+
async get(id, requestOptions) {
|
|
6993
|
+
const result = await withCancellation(() => this.client.logs.retrieveToolExecution(id, requestOptions), requestOptions?.signal);
|
|
6994
|
+
return transformToolExecutionLogDetail(result);
|
|
6995
|
+
}
|
|
6996
|
+
};
|
|
6997
|
+
|
|
6998
|
+
//#endregion
|
|
6999
|
+
//#region src/types/keyring.types.ts
|
|
7000
|
+
/**
|
|
7001
|
+
* A public JWK a secret can be sealed to. Fields keep their JWK names so a
|
|
7002
|
+
* key can be handed straight to WebCrypto or a JOSE library.
|
|
7003
|
+
*/
|
|
7004
|
+
const KeyringTransferKeySchema = z$1.object({
|
|
7005
|
+
/** Key type. Always `RSA`. */
|
|
7006
|
+
kty: z$1.string(),
|
|
7007
|
+
/** RSA modulus, base64url-encoded. */
|
|
7008
|
+
n: z$1.string(),
|
|
7009
|
+
/** RSA public exponent, base64url-encoded. */
|
|
7010
|
+
e: z$1.string(),
|
|
7011
|
+
/** Key-management algorithm for the JWE (`RSA-OAEP-256`). Pair it with `A256GCM` content encryption. */
|
|
7012
|
+
alg: z$1.string(),
|
|
7013
|
+
/** Key use. Always `enc`. */
|
|
7014
|
+
use: z$1.string(),
|
|
7015
|
+
/** Key identifier. Put it in the JWE protected header. */
|
|
7016
|
+
kid: z$1.string()
|
|
7017
|
+
});
|
|
7018
|
+
/**
|
|
7019
|
+
* Response of `composio.keyring.listTransferKeys()`.
|
|
7020
|
+
*/
|
|
7021
|
+
const KeyringTransferKeysResponseSchema = z$1.object({
|
|
7022
|
+
/** The `kid` of the key to seal new secrets to. */
|
|
7023
|
+
activeKid: z$1.string(),
|
|
7024
|
+
/** Every currently accepted transfer key, newest first. */
|
|
7025
|
+
keys: z$1.array(KeyringTransferKeySchema)
|
|
7026
|
+
});
|
|
7027
|
+
|
|
7028
|
+
//#endregion
|
|
7029
|
+
//#region src/utils/transformers/keyring.ts
|
|
7030
|
+
const transformKeyringTransferKeysResponse = (response) => {
|
|
7031
|
+
return transform(response).with(KeyringTransferKeysResponseSchema).using((response) => ({
|
|
7032
|
+
activeKid: response.active_kid,
|
|
7033
|
+
keys: response.keys.map((key) => ({
|
|
7034
|
+
kty: key.kty,
|
|
7035
|
+
n: key.n,
|
|
7036
|
+
e: key.e,
|
|
7037
|
+
alg: key.alg,
|
|
7038
|
+
use: key.use,
|
|
7039
|
+
kid: key.kid
|
|
7040
|
+
}))
|
|
7041
|
+
}));
|
|
7042
|
+
};
|
|
7043
|
+
|
|
7044
|
+
//#endregion
|
|
7045
|
+
//#region src/models/Keyring.ts
|
|
7046
|
+
/**
|
|
7047
|
+
* `composio.keyring` — the organization's customer-managed keyring.
|
|
7048
|
+
*
|
|
7049
|
+
* @example
|
|
7050
|
+
* ```typescript
|
|
7051
|
+
* const { activeKid, keys } = await composio.keyring.listTransferKeys();
|
|
7052
|
+
* const sealingKey = keys.find(key => key.kid === activeKid);
|
|
7053
|
+
* ```
|
|
7054
|
+
*/
|
|
7055
|
+
var Keyring = class {
|
|
7056
|
+
client;
|
|
7057
|
+
constructor(client) {
|
|
7058
|
+
this.client = client;
|
|
7059
|
+
telemetry.instrument(this, "Keyring");
|
|
7060
|
+
}
|
|
7061
|
+
/**
|
|
7062
|
+
* Lists the public transfer keys of the organization's active customer
|
|
7063
|
+
* keyring, the keys a secret is sealed to before it is sent to Composio.
|
|
7064
|
+
*
|
|
7065
|
+
* Always seal new secrets to the key whose `kid` is `activeKid`: a JWE with
|
|
7066
|
+
* `RSA-OAEP-256` key management, `A256GCM` content encryption, and the
|
|
7067
|
+
* `kid` in the protected header. Older keys stay listed so values sealed to
|
|
7068
|
+
* them remain openable.
|
|
7069
|
+
*
|
|
7070
|
+
* The organization behind the API key must have an ACTIVE customer keyring
|
|
7071
|
+
* instance; otherwise the API answers 404.
|
|
7072
|
+
*
|
|
7073
|
+
* @returns {Promise<KeyringTransferKeysResponse>} The active key ID and every accepted public JWK, newest first
|
|
7074
|
+
*
|
|
7075
|
+
* @example
|
|
7076
|
+
* ```typescript
|
|
7077
|
+
* import { CompactEncrypt, importJWK } from 'jose';
|
|
7078
|
+
*
|
|
7079
|
+
* const { activeKid, keys } = await composio.keyring.listTransferKeys();
|
|
7080
|
+
* const jwk = keys.find(key => key.kid === activeKid)!;
|
|
7081
|
+
* const sealed = await new CompactEncrypt(new TextEncoder().encode(secret))
|
|
7082
|
+
* .setProtectedHeader({ alg: 'RSA-OAEP-256', enc: 'A256GCM', kid: activeKid })
|
|
7083
|
+
* .encrypt(await importJWK(jwk, 'RSA-OAEP-256'));
|
|
7084
|
+
* ```
|
|
7085
|
+
*/
|
|
7086
|
+
async listTransferKeys(requestOptions) {
|
|
7087
|
+
const result = await withCancellation(() => this.client.keyring.listTransferKeys(requestOptions), requestOptions?.signal);
|
|
7088
|
+
return transformKeyringTransferKeysResponse(result);
|
|
7089
|
+
}
|
|
7090
|
+
};
|
|
7091
|
+
|
|
5434
7092
|
//#endregion
|
|
5435
7093
|
//#region src/utils/sdk.ts
|
|
5436
7094
|
const userDataPath = () => {
|
|
@@ -6017,7 +7675,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
6017
7675
|
|
|
6018
7676
|
//#endregion
|
|
6019
7677
|
//#region package.json
|
|
6020
|
-
var version = "0.
|
|
7678
|
+
var version = "1.0.0-beta.1";
|
|
6021
7679
|
|
|
6022
7680
|
//#endregion
|
|
6023
7681
|
//#region src/utils/session.ts
|
|
@@ -6350,6 +8008,15 @@ const ToolRouterSessionDeleteResponseSchema = z.object({
|
|
|
6350
8008
|
sessionId: z.string(),
|
|
6351
8009
|
deleted: z.literal(true)
|
|
6352
8010
|
});
|
|
8011
|
+
/**
|
|
8012
|
+
* Options for `session.configHistory()`.
|
|
8013
|
+
*/
|
|
8014
|
+
const ToolRouterSessionConfigHistoryOptionsSchema = z.object({
|
|
8015
|
+
/** Cursor from a previous response's `nextCursor`. */
|
|
8016
|
+
cursor: z.string().optional(),
|
|
8017
|
+
/** Number of items per page, max allowed is 100. */
|
|
8018
|
+
limit: z.number().optional()
|
|
8019
|
+
});
|
|
6353
8020
|
|
|
6354
8021
|
//#endregion
|
|
6355
8022
|
//#region src/lib/toolRouterParams.ts
|
|
@@ -6459,18 +8126,24 @@ const transformToolRouterUpdateParams = (config) => {
|
|
|
6459
8126
|
for (const [k, v] of Object.entries(config.connectedAccounts)) coerced[k] = typeof v === "string" ? [v] : v;
|
|
6460
8127
|
params.connected_accounts = coerced;
|
|
6461
8128
|
}
|
|
6462
|
-
if (config.manageConnections !== void 0)
|
|
6463
|
-
|
|
8129
|
+
if (config.manageConnections !== void 0) {
|
|
8130
|
+
if (config.manageConnections === null) params.manage_connections = null;
|
|
8131
|
+
else params.manage_connections = transformToolRouterUpdateManageConnectionsParams(config.manageConnections);
|
|
8132
|
+
}
|
|
6464
8133
|
const sandboxConfig = config.sandbox !== void 0 ? config.sandbox : config.workbench;
|
|
6465
|
-
if (sandboxConfig !== void 0)
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
if (config.multiAccount
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
8134
|
+
if (sandboxConfig !== void 0) {
|
|
8135
|
+
if (sandboxConfig === null) params.workbench = null;
|
|
8136
|
+
else params.workbench = transformToolRouterUpdateSandboxParams(sandboxConfig);
|
|
8137
|
+
}
|
|
8138
|
+
if (config.multiAccount !== void 0) {
|
|
8139
|
+
if (config.multiAccount === null) params.multi_account = null;
|
|
8140
|
+
else {
|
|
8141
|
+
const ma = {};
|
|
8142
|
+
if (config.multiAccount.enable !== void 0) ma.enable = config.multiAccount.enable;
|
|
8143
|
+
if (config.multiAccount.maxAccountsPerToolkit !== void 0) ma.max_accounts_per_toolkit = config.multiAccount.maxAccountsPerToolkit;
|
|
8144
|
+
if (config.multiAccount.requireExplicitSelection !== void 0) ma.require_explicit_selection = config.multiAccount.requireExplicitSelection;
|
|
8145
|
+
params.multi_account = ma;
|
|
8146
|
+
}
|
|
6474
8147
|
}
|
|
6475
8148
|
if (config.preload !== void 0) params.preload = config.preload;
|
|
6476
8149
|
return params;
|
|
@@ -7546,7 +9219,8 @@ var ToolRouterSession = class {
|
|
|
7546
9219
|
...params.toolkits?.length ? { toolkits: params.toolkits } : {},
|
|
7547
9220
|
...experimental ? { experimental } : {}
|
|
7548
9221
|
};
|
|
7549
|
-
const
|
|
9222
|
+
const response = await withCancellation(() => this.client.toolRouter.session.search(this.sessionId, searchParams, requestOptions), requestOptions?.signal);
|
|
9223
|
+
const transformed = transformSearchResponse(response);
|
|
7550
9224
|
return ToolRouterSessionSearchResponseSchema.parse(transformed);
|
|
7551
9225
|
}
|
|
7552
9226
|
/**
|
|
@@ -7582,7 +9256,8 @@ var ToolRouterSession = class {
|
|
|
7582
9256
|
if (options?.account) executeParams.account = options.account;
|
|
7583
9257
|
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
7584
9258
|
if (experimental) executeParams.experimental = experimental;
|
|
7585
|
-
const
|
|
9259
|
+
const response = await withCancellation(() => this.client.toolRouter.session.execute(this.sessionId, executeParams, requestOptions), requestOptions?.signal);
|
|
9260
|
+
const transformed = transformExecuteResponse(response);
|
|
7586
9261
|
return ToolRouterSessionExecuteResponseSchema.parse(transformed);
|
|
7587
9262
|
}
|
|
7588
9263
|
/**
|
|
@@ -7615,7 +9290,8 @@ var ToolRouterSession = class {
|
|
|
7615
9290
|
* Mutates this session's `configVersion`, `preload`, and `warnings` in-place.
|
|
7616
9291
|
*/
|
|
7617
9292
|
async update(config, requestOptions) {
|
|
7618
|
-
const
|
|
9293
|
+
const parsed = ToolRouterUpdateSessionConfigSchema.parse(config);
|
|
9294
|
+
const params = transformToolRouterUpdateParams(parsed);
|
|
7619
9295
|
const response = await withCancellation(() => this.client.toolRouter.session.patch(this.sessionId, params, requestOptions), requestOptions?.signal);
|
|
7620
9296
|
this.configVersion = response.config_version;
|
|
7621
9297
|
this.preload = response.config.preload;
|
|
@@ -7631,6 +9307,43 @@ var ToolRouterSession = class {
|
|
|
7631
9307
|
async delete(requestOptions) {
|
|
7632
9308
|
return deleteToolRouterSession(this.client, this.sessionId, requestOptions);
|
|
7633
9309
|
}
|
|
9310
|
+
/**
|
|
9311
|
+
* Page through this session's configuration history, newest first. The
|
|
9312
|
+
* first page starts with the live config (`isCurrent: true`); every
|
|
9313
|
+
* `session.update()` archives the previous version as a history row.
|
|
9314
|
+
*
|
|
9315
|
+
* @param options - Optional `cursor` and `limit` (max 100)
|
|
9316
|
+
* @returns The config versions on this page plus pagination info
|
|
9317
|
+
* @throws {ValidationError} If the options fail validation
|
|
9318
|
+
*
|
|
9319
|
+
* @example
|
|
9320
|
+
* ```typescript
|
|
9321
|
+
* const { items, nextCursor } = await session.configHistory({ limit: 10 });
|
|
9322
|
+
* console.log(items[0].version, items[0].isCurrent); // e.g. 3, true
|
|
9323
|
+
* console.log(items[1].config.toolkits);
|
|
9324
|
+
* ```
|
|
9325
|
+
*/
|
|
9326
|
+
async configHistory(options, requestOptions) {
|
|
9327
|
+
const parsedOptions = ToolRouterSessionConfigHistoryOptionsSchema.safeParse(options ?? {});
|
|
9328
|
+
if (!parsedOptions.success) throw new ValidationError("Failed to parse config history options", { cause: parsedOptions.error });
|
|
9329
|
+
const query = {
|
|
9330
|
+
cursor: parsedOptions.data.cursor,
|
|
9331
|
+
limit: parsedOptions.data.limit
|
|
9332
|
+
};
|
|
9333
|
+
const response = await withCancellation(() => this.client.toolRouter.session.configHistory(this.sessionId, query, requestOptions), requestOptions?.signal);
|
|
9334
|
+
return {
|
|
9335
|
+
items: response.items.map((item) => ({
|
|
9336
|
+
version: item.version,
|
|
9337
|
+
createdAt: item.created_at,
|
|
9338
|
+
isCurrent: item.is_current,
|
|
9339
|
+
config: item.config
|
|
9340
|
+
})),
|
|
9341
|
+
nextCursor: response.next_cursor ?? null,
|
|
9342
|
+
totalPages: response.total_pages,
|
|
9343
|
+
currentPage: response.current_page,
|
|
9344
|
+
totalItems: response.total_items
|
|
9345
|
+
};
|
|
9346
|
+
}
|
|
7634
9347
|
/** Check if this session has any custom tools bound. */
|
|
7635
9348
|
hasCustomTools() {
|
|
7636
9349
|
return (this.customToolsMap?.byFinalSlug.size ?? 0) > 0;
|
|
@@ -7768,7 +9481,8 @@ function preloadsAllCustomTools(preload) {
|
|
|
7768
9481
|
}
|
|
7769
9482
|
function prepareInlineCustomTools(options) {
|
|
7770
9483
|
const { customTools, customToolkits, defaultPreload = false, preloadTools } = options;
|
|
7771
|
-
|
|
9484
|
+
const localCustomToolsMap = !!(customTools?.length || customToolkits?.length) ? buildCustomToolsMap(customTools ?? [], customToolkits) : void 0;
|
|
9485
|
+
assertNoCustomToolSlugsInPreload(preloadTools, localCustomToolsMap);
|
|
7772
9486
|
const serializedTools = customTools?.length ? serializeCustomTools(customTools, { defaultPreload }) : void 0;
|
|
7773
9487
|
const serializedToolkits = customToolkits?.length ? serializeCustomToolkits(customToolkits, { defaultPreload }) : void 0;
|
|
7774
9488
|
return serializedTools || serializedToolkits ? {
|
|
@@ -7900,6 +9614,29 @@ var Sessions = class extends ToolRouter {
|
|
|
7900
9614
|
//#endregion
|
|
7901
9615
|
//#region src/composio.ts
|
|
7902
9616
|
/**
|
|
9617
|
+
* Level for the API client given the SDK level. The client logs each request's
|
|
9618
|
+
* lifecycle at `info`, which is debug-grade for SDK users, so the client stays
|
|
9619
|
+
* at `warn` unless the SDK is at `debug`. The client's `LogLevel` has
|
|
9620
|
+
* `'off'` where the SDK has `'silent'`.
|
|
9621
|
+
*/
|
|
9622
|
+
const toClientLogLevel = (level) => {
|
|
9623
|
+
if (level === "silent") return "off";
|
|
9624
|
+
if (level === "info") return "warn";
|
|
9625
|
+
return level;
|
|
9626
|
+
};
|
|
9627
|
+
/**
|
|
9628
|
+
* Forwards the API client's log records to the SDK singleton so they pick up
|
|
9629
|
+
* the SDK's formatting, redaction, and configured sink. Methods are looked up
|
|
9630
|
+
* at call time so a later `logger.configure()` is honoured. The client's
|
|
9631
|
+
* `info` records (per-request lifecycle) are forwarded as SDK `debug`.
|
|
9632
|
+
*/
|
|
9633
|
+
const clientLoggerAdapter = {
|
|
9634
|
+
error: (...args) => logger.error(...args),
|
|
9635
|
+
warn: (...args) => logger.warn(...args),
|
|
9636
|
+
info: (...args) => logger.debug(...args),
|
|
9637
|
+
debug: (...args) => logger.debug(...args)
|
|
9638
|
+
};
|
|
9639
|
+
/**
|
|
7903
9640
|
* This is the core class for Composio.
|
|
7904
9641
|
* It is used to initialize the Composio SDK and provide a global configuration.
|
|
7905
9642
|
*/
|
|
@@ -7932,6 +9669,15 @@ var Composio = class Composio {
|
|
|
7932
9669
|
/** Manage authenticated connections */
|
|
7933
9670
|
connectedAccounts;
|
|
7934
9671
|
/**
|
|
9672
|
+
* Manage the project's webhook subscription (`webhooks.subscriptions`) and
|
|
9673
|
+
* inbound per-toolkit webhook endpoints (`webhooks.endpoints`).
|
|
9674
|
+
*/
|
|
9675
|
+
webhooks;
|
|
9676
|
+
/** Search and inspect tool-execution logs */
|
|
9677
|
+
logs;
|
|
9678
|
+
/** Public transfer keys of the organization's customer-managed keyring */
|
|
9679
|
+
keyring;
|
|
9680
|
+
/**
|
|
7935
9681
|
* Experimental SDK methods whose shape may change in future releases.
|
|
7936
9682
|
* Prefer domain-specific mounts (for example
|
|
7937
9683
|
* `composio.connectedAccounts.updateAcl(...)`) when available; this
|
|
@@ -8037,6 +9783,10 @@ var Composio = class Composio {
|
|
|
8037
9783
|
*/
|
|
8038
9784
|
constructor(config) {
|
|
8039
9785
|
const { baseURL: baseURLParsed, apiKey: apiKeyParsed } = getSDKConfig(config?.baseURL, config?.apiKey);
|
|
9786
|
+
if (config?.logger !== void 0 || config?.logLevel !== void 0) logger.configure({
|
|
9787
|
+
level: config.logLevel,
|
|
9788
|
+
sink: config.logger
|
|
9789
|
+
});
|
|
8040
9790
|
if (IS_DEVELOPMENT_OR_CI) logger.debug(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
|
|
8041
9791
|
/**
|
|
8042
9792
|
* Set the default provider, if not provided by the user.
|
|
@@ -8068,7 +9818,8 @@ var Composio = class Composio {
|
|
|
8068
9818
|
apiKey: apiKeyParsed,
|
|
8069
9819
|
baseURL: baseURLParsed,
|
|
8070
9820
|
defaultHeaders,
|
|
8071
|
-
|
|
9821
|
+
logger: clientLoggerAdapter,
|
|
9822
|
+
logLevel: toClientLogLevel(logger.getLevel())
|
|
8072
9823
|
});
|
|
8073
9824
|
this.tools = new Tools(this.client, this.config);
|
|
8074
9825
|
this.mcp = new MCP(this.client);
|
|
@@ -8081,6 +9832,9 @@ var Composio = class Composio {
|
|
|
8081
9832
|
fileDownloadDir: this.config.fileDownloadDir
|
|
8082
9833
|
});
|
|
8083
9834
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
9835
|
+
this.webhooks = new Webhooks(this.client);
|
|
9836
|
+
this.logs = new Logs(this.client);
|
|
9837
|
+
this.keyring = new Keyring(this.client);
|
|
8084
9838
|
this.experimental = new Experimental(this.client);
|
|
8085
9839
|
this.sessions = new Sessions(this.client, this.config);
|
|
8086
9840
|
this.toolRouter = this.sessions;
|
|
@@ -9004,4 +10758,4 @@ const ComposioMcpUpdateResponseSchema = z$1.object({
|
|
|
9004
10758
|
});
|
|
9005
10759
|
|
|
9006
10760
|
//#endregion
|
|
9007
|
-
export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAclOnlyForSharedError, ComposioAuthConfigNotFoundError, ComposioBlockedInternalUrlError, ComposioConnectedAccountNotFoundError, ComposioCustomCreateResponseSchema, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioFileNotFoundError, ComposioFileUploadAbortedError, ComposioFileUploadError, ComposioFileUploadPathNotAllowedError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioInvalidToolArgumentsError, ComposioLegacyConnectedAccountsEndpointRetiredError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioRequestCancelledError, ComposioSensitiveFilePathBlockedError, ComposioSharedAccessDeniedError, ComposioSharedConnectionNotAccessibleError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAclConfigResponseSchema, ConnectedAccountAclConfigSchema, ConnectedAccountAuthConfigSchema, ConnectedAccountErrorCodes, ConnectedAccountExperimentalResponseSchema, ConnectedAccountExperimentalSchema, ConnectedAccountListParamsSchema, ConnectedAccountListResponseSchema, ConnectedAccountRefreshOptionsSchema, ConnectedAccountRetrieveResponseSchema, ConnectedAccountStatusSchema, ConnectedAccountStatuses, ConnectedAccountTypeSchema, ConnectedAccountTypes, ConnectionDataSchema, ConnectionExpiredEventSchema, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConnectionStatus, ConnectionStatuses, CreateAuthConfigParamsSchema, CreateAuthConfigResponseSchema, CreateComposioManagedAuthConfigParamsSchema, CreateConnectedAccountLinkOptionsSchema, CreateConnectedAccountLinkResponseSchema, CreateConnectedAccountOptionsSchema, CreateConnectedAccountParamsSchema, CreateConnectedAccountResponseSchema, CreateCustomAuthConfigParamsSchema, CreateCustomToolBaseSchema, CreateCustomToolkitBaseSchema, CustomAuthParamsSchema, CustomConnectionDataSchema, CustomCreateResponseSchema, CustomOauth1ConnectionDataSchema, CustomOauth2ConnectionDataSchema, CustomToolSlugSchema, DefaultCreateConnectedAccountParamsSchema, DefaultWebhookSubscriptionEvents, Experimental, FileDeleteResponseSchema, FileListResponseSchema, FileModifierErrorCodes, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, JsonSchemaRefResolutionError, JsonSchemaToZodError, MCP, MCPAuthOptionsSchema, MCPGenerateURLParamsSchema, MCPGetServerParamsSchema, MCPMultiAppServerSchema, MCPServerCreateResponseSchema, MCPServerListResponseSchema, MCPServerSchema, MCPServerTypeSchema, MCPServerUpdateParamsSchema, MCPSingleAppServerSchema, MCPToolkitConfigSchema, MCPToolkitConfigsArraySchema, McpDeleteResponseSchema, McpListResponseSchema, McpRetrieveResponseSchema, McpUpdateResponseSchema, Oauth1ActiveConnectionDataSchema, Oauth1ConnectionDataSchema, Oauth1ExpiredConnectionDataSchema, Oauth1FailedConnectionDataSchema, Oauth1InactiveConnectionDataSchema, Oauth1InitiatedConnectionDataSchema, Oauth1InitiatingConnectionDataSchema, Oauth2ActiveConnectionDataSchema, Oauth2ConnectionDataSchema, Oauth2ExpiredConnectionDataSchema, Oauth2FailedConnectionDataSchema, Oauth2InactiveConnectionDataSchema, Oauth2InitiatedConnectionDataSchema, Oauth2InitiatingConnectionDataSchema, Oauth2RevokedConnectionDataSchema, OpenAIProvider, RedirectableAuthSchemeSchema, RemoteFile, RemoteFileDataSchema, RemoteFileDownloadError, RemoteFileErrorCodes, SDKErrorCodes, SandboxSizeSchema, SessionPreset, SessionProxyExecuteParamsSchema, Sessions, SetWebhookSubscriptionParamsSchema, SingleConnectedAccountDetailedResponseSchema, SsrfErrorCodes, ToolErrorCodes, ToolExecuteMetaParamsSchema, ToolExecuteParamsSchema, ToolExecuteResponseSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterSandboxConfigSchema, ToolRouterSession, ToolRouterSessionDeleteResponseSchema, ToolRouterSessionExecuteResponseSchema, ToolRouterSessionFilesMountDeleteOptionsSchema, ToolRouterSessionFilesMountDownloadOptionsSchema, ToolRouterSessionFilesMountListOptionsSchema, ToolRouterSessionFilesMountUploadOptionsSchema, ToolRouterSessionSearchResponseSchema, ToolRouterTagsEnableDisableSchema, ToolRouterTagsParamSchema, ToolRouterToolkitsDisabledConfigSchema, ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsOptionsSchema, ToolRouterToolkitsParamSchema, ToolRouterToolsParamSchema, ToolRouterUpdateSessionConfigSchema, ToolSchema, ToolkitAuthConfigDetailsSchema, ToolkitAuthFieldSchema, ToolkitAuthFieldsResponseSchema, ToolkitCategorySchema, ToolkitConnectionStateSchema, ToolkitConnectionsDetailsSchema, ToolkitErrorCodes, ToolkitLatestVersionSchema, ToolkitMangedByEnumSchema, ToolkitRetrieveCategoriesResponseSchema, ToolkitRetrieveResponseSchema, ToolkitSchema, ToolkitSortByEnumSchema, ToolkitVersionParamSchema, ToolkitVersionSchema, ToolkitVersionsSchema, ToolkitsListParamsSchema, TriggerErrorCodes, TriggerInstanceListActiveParamsSchema, TriggerInstanceListActiveResponseItemSchema, TriggerInstanceListActiveResponseSchema, TriggerInstanceManageDeleteResponseSchema, TriggerInstanceManageUpdateParamsSchema, TriggerInstanceManageUpdateResponseSchema, TriggerInstanceUpsertParamsSchema, TriggerInstanceUpsertResponseSchema, TriggerStatusEnum, TriggerStatuses, TriggerSubscribeParamSchema, TriggerTypeSchema, TriggersTypeListParamsSchema, TriggersTypeListResponseSchema, UpdateConnectedAccountAclParamsSchema, UpdateConnectedAccountParamsSchema, ValidationError, ValidationErrorCodes, VerifyWebhookParamsSchema, WebhookConnectedAccountAuthConfigSchema, WebhookConnectionMetadataSchema, WebhookConnectionStateSchema, WebhookEventSchema, WebhookEventTypes, WebhookPayloadSchema, WebhookPayloadV1Schema, WebhookPayloadV2Schema, WebhookPayloadV3Schema, WebhookTriggerPayloadV3Schema, WebhookVersions, 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, removeNonRequiredProperties, restoreOriginalKeys, sanitizeSchemaPropertyKeys, telemetry, toStrictJsonSchema };
|
|
10761
|
+
export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAclOnlyForSharedError, ComposioAuthConfigNotFoundError, ComposioBlockedInternalUrlError, ComposioConnectedAccountNotFoundError, ComposioConnectedAccountNotRevokableError, ComposioConnectedAccountRevocationNotSupportedError, ComposioCustomCreateResponseSchema, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioFileNotFoundError, ComposioFileUploadAbortedError, ComposioFileUploadError, ComposioFileUploadPathNotAllowedError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioInvalidToolArgumentsError, ComposioLegacyConnectedAccountsEndpointRetiredError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioRequestCancelledError, ComposioSensitiveFilePathBlockedError, ComposioSharedAccessDeniedError, ComposioSharedConnectionNotAccessibleError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAclConfigResponseSchema, ConnectedAccountAclConfigSchema, ConnectedAccountAuthConfigSchema, ConnectedAccountCompleteAuthParamsSchema, ConnectedAccountCompleteAuthResponseSchema, ConnectedAccountErrorCodes, ConnectedAccountExperimentalResponseSchema, ConnectedAccountExperimentalSchema, ConnectedAccountListParamsSchema, ConnectedAccountListResponseSchema, ConnectedAccountRefreshOptionsSchema, ConnectedAccountRetrieveResponseSchema, ConnectedAccountRevokeResponseSchema, ConnectedAccountRevokedTokenSchema, ConnectedAccountStatusSchema, ConnectedAccountStatuses, ConnectedAccountTypeSchema, ConnectedAccountTypes, ConnectionDataSchema, ConnectionExpiredEventSchema, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConnectionStatus, ConnectionStatuses, CreateAuthConfigParamsSchema, CreateAuthConfigResponseSchema, CreateComposioManagedAuthConfigParamsSchema, CreateConnectedAccountLinkOptionsSchema, CreateConnectedAccountLinkResponseSchema, CreateConnectedAccountOptionsSchema, CreateConnectedAccountParamsSchema, CreateConnectedAccountResponseSchema, CreateCustomAuthConfigParamsSchema, CreateCustomToolBaseSchema, CreateCustomToolkitBaseSchema, CustomAuthParamsSchema, CustomConnectionDataSchema, CustomCreateResponseSchema, CustomOauth1ConnectionDataSchema, CustomOauth2ConnectionDataSchema, CustomToolSlugSchema, CustomToolkitAuthSchemeSchema, CustomToolkitDeleteResponseSchema, CustomToolkitSyncParamsSchema, CustomToolkitSyncResponseSchema, CustomToolkitUpsertParamsSchema, CustomToolkitUpsertResponseSchema, CustomToolkits, DefaultCreateConnectedAccountParamsSchema, DefaultWebhookSubscriptionEvents, Experimental, FileDeleteResponseSchema, FileListResponseSchema, FileModifierErrorCodes, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, JsonSchemaRefResolutionError, JsonSchemaToZodError, Keyring, KeyringTransferKeySchema, KeyringTransferKeysResponseSchema, LogSearchFilterFieldSchema, LogSearchFilterOperatorSchema, LogSearchFilterSchema, LogSearchParamsSchema, LogSearchResponseSchema, LogSearchTimeRangeSchema, Logs, MAX_URL_UPLOAD_SIZE_BYTES, MCP, MCPAuthOptionsSchema, MCPGenerateURLParamsSchema, MCPGetServerParamsSchema, MCPMultiAppServerSchema, MCPServerCreateResponseSchema, MCPServerListResponseSchema, MCPServerSchema, MCPServerTypeSchema, MCPServerUpdateParamsSchema, MCPSingleAppServerSchema, MCPToolkitConfigSchema, MCPToolkitConfigsArraySchema, McpDeleteResponseSchema, McpListResponseSchema, McpRetrieveResponseSchema, McpUpdateResponseSchema, Oauth1ActiveConnectionDataSchema, Oauth1ConnectionDataSchema, Oauth1ExpiredConnectionDataSchema, Oauth1FailedConnectionDataSchema, Oauth1InactiveConnectionDataSchema, Oauth1InitiatedConnectionDataSchema, Oauth1InitiatingConnectionDataSchema, Oauth2ActiveConnectionDataSchema, Oauth2ConnectionDataSchema, Oauth2ExpiredConnectionDataSchema, Oauth2FailedConnectionDataSchema, Oauth2InactiveConnectionDataSchema, Oauth2InitiatedConnectionDataSchema, Oauth2InitiatingConnectionDataSchema, Oauth2RevokedConnectionDataSchema, OpenAIProvider, RedirectableAuthSchemeSchema, RemoteFile, RemoteFileDataSchema, RemoteFileDownloadError, RemoteFileErrorCodes, SDKErrorCodes, SandboxSizeSchema, SessionPreset, SessionProxyExecuteParamsSchema, Sessions, SetWebhookSubscriptionParamsSchema, SingleConnectedAccountDetailedResponseSchema, SsrfErrorCodes, ToolErrorCodes, ToolExecuteMetaParamsSchema, ToolExecuteParamsSchema, ToolExecuteResponseSchema, ToolExecutionLogDetailSchema, ToolExecutionLogLevelSchema, ToolExecutionLogParentSchema, ToolExecutionLogSchema, ToolExecutionLogStatusSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterSandboxConfigSchema, ToolRouterSession, ToolRouterSessionConfigHistoryOptionsSchema, ToolRouterSessionDeleteResponseSchema, ToolRouterSessionExecuteResponseSchema, ToolRouterSessionFilesMountDeleteOptionsSchema, ToolRouterSessionFilesMountDownloadOptionsSchema, ToolRouterSessionFilesMountListOptionsSchema, ToolRouterSessionFilesMountUploadOptionsSchema, ToolRouterSessionSearchResponseSchema, ToolRouterTagsEnableDisableSchema, ToolRouterTagsParamSchema, ToolRouterToolkitsDisabledConfigSchema, ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsOptionsSchema, ToolRouterToolkitsParamSchema, ToolRouterToolsParamSchema, 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 };
|