@composio/core 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CustomTool-CB5vm1Jc.d.mts → CustomTool-B3m-188G.d.mts} +1 -1
- package/dist/{CustomTool-BMlZfJVz.mjs → CustomTool-fYEFjSLM.mjs} +1 -1
- package/dist/{FileModifierErrors-BqFmpRsm.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
- package/dist/{SsrfErrors-C91YhASE.mjs → SsrfErrors-DiQldIdC.mjs} +18 -7
- package/dist/{Telemetry-HlftxMx6.mjs → Telemetry-JRJJYS4I.mjs} +2 -2
- package/dist/{cancellation-CXpfmiVo.mjs → cancellation-Dwa9lGHA.mjs} +2 -2
- package/dist/{composio-DLGaeN70.d.mts → composio-B36OXii1.d.mts} +2691 -119
- package/dist/{customTool.types-BAmEh3MB.d.mts → customTool.types-C436M_D0.d.mts} +431 -98
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +5 -2
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +101 -18
- package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +123 -0
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +9 -2
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +7 -0
- package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +56 -0
- package/dist/docs/reference/sdk-reference/typescript/logs.mdx +78 -0
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +15 -15
- package/dist/docs/reference/sdk-reference/typescript/meta.json +8 -1
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +77 -27
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +24 -10
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +149 -12
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +18 -18
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +25 -25
- package/dist/docs/reference/sdk-reference/typescript/usage.mdx +78 -0
- package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +162 -0
- package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +218 -0
- package/dist/docs/reference/sdk-reference/typescript/webhooks.mdx +20 -0
- package/dist/{errors-BuEKehbI.mjs → errors-D_A4b2c2.mjs} +123 -4
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-L7XD8UPr.mjs → fileUtils.node-DNLhLg0W.mjs} +4 -4
- package/dist/index.d.mts +264 -51
- package/dist/index.mjs +2338 -168
- package/dist/models/Files.node.mjs +2 -2
- package/dist/{sensitiveFileUploadPaths-B6pBt9lO.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +1 -1
- package/dist/{ssrfGuard.node-B9xQB4za.mjs → ssrfGuard.node-BZ270bcu.mjs} +1 -1
- package/dist/{types-CxLPO0Xq.d.mts → types-Br3GBya5.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +5 -5
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/dist/utils/ssrfGuard.node.mjs +1 -1
- package/dist/utils/ssrfGuard.workerd.mjs +1 -1
- package/package.json +2 -2
- package/src/composio.ts +207 -10
- package/src/errors/ConnectedAccountsErrors.ts +47 -0
- package/src/errors/SDKErrors.ts +52 -0
- package/src/errors/ToolRouterErrors.ts +57 -0
- package/src/errors/index.ts +3 -0
- package/src/index.ts +11 -0
- package/src/lib/toolRouterMcp.ts +132 -0
- package/src/lib/toolRouterParams.ts +116 -29
- 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/ToolRouter.ts +42 -14
- package/src/models/ToolRouterSession.ts +120 -9
- package/src/models/Toolkits.ts +180 -0
- package/src/models/Tools.ts +3 -1
- package/src/models/Triggers.ts +3 -88
- package/src/models/Usage.ts +119 -0
- package/src/models/Webhooks.ts +520 -0
- package/src/services/pusher/Pusher.ts +17 -6
- 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 +205 -11
- package/src/types/toolkit.types.ts +144 -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/logger.ts +39 -7
- package/src/utils/sdk.ts +385 -22
- 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 +106 -3
- 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
|
|
3
|
-
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, o as FileModifierErrorCodes, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "./FileModifierErrors-
|
|
1
|
+
import { c as DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID, d as USER_DATA_FILE_NAME, f as constants_exports, i as logger, l as IS_DEVELOPMENT_OR_CI, m as getEnvsWithPrefix, n as SsrfErrorCodes, o as COMPOSIO_DIR, p as getEnvVariable, r as ComposioError, s as DEFAULT_BASE_URL, t as ComposioBlockedInternalUrlError, u as TEMP_FILES_DIRECTORY_NAME } from "./SsrfErrors-DiQldIdC.mjs";
|
|
2
|
+
import { A as ComposioInvalidToolArgumentsError, B as ConnectionRequestTimeoutError, C as ValidationErrorCodes, D as ComposioGlobalExecuteToolFnNotSetError, E as ToolkitErrorCodes, F as ComposioToolVersionRequiredError, G as ComposioFailedToCreateConnectedAccountLink, H as ComposioConnectedAccountNotFoundError, I as ToolErrorCodes, J as ComposioSharedAccessDeniedError, K as ComposioLegacyConnectedAccountsEndpointRetiredError, L as handleToolExecutionError, M as ComposioToolExecutionError, N as ComposioToolFetchError, O as ComposioInvalidExecuteFunctionError, P as ComposioToolNotFoundError, Q as ComposioAuthConfigNotFoundError, R as ConnectionRequestErrorCodes, S as ValidationError, T as ComposioToolkitNotFoundError, U as ComposioConnectedAccountNotRevokableError, V as ComposioAclOnlyForSharedError, W as ComposioConnectedAccountRevocationNotSupportedError, X as ConnectedAccountErrorCodes, Y as ComposioSharedConnectionNotAccessibleError, Z as AuthConfigErrorCodes, _ as ComposioScopeConfigError, a as RemoteFileErrorCodes, b as JsonSchemaRefResolutionError, c as ComposioFailedToSubscribeToPusherChannelError, d as ComposioWebhookPayloadError, f as ComposioWebhookSignatureVerificationError, g as ComposioRequestCancelledError, h as ComposioNoAPIKeyError, i as RemoteFileDownloadError, j as ComposioProviderNotDefinedError, k as ComposioInvalidModifierError, l as ComposioFailedToUnsubscribeFromPusherChannelError, m as ComposioAPIKeyKindError, n as ComposioSessionConfigConflictError, o as ComposioFailedToCreatePusherClientError, p as TriggerErrorCodes, q as ComposioMultipleConnectedAccountsError, r as ToolRouterErrorCodes, s as ComposioFailedToGetSDKRealtimeCredentialsError, t as ComposioMCPDestinationError, u as ComposioTriggerTypeNotFoundError, v as SDKErrorCodes, w as ComposioToolkitFetchError, x as JsonSchemaToZodError, y as isRequestAbortError, z as ConnectionRequestFailedError } from "./errors-D_A4b2c2.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
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-
|
|
6
|
-
import { t as telemetry } from "./Telemetry-
|
|
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-
|
|
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";
|
|
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-Dwa9lGHA.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-fYEFjSLM.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";
|
|
@@ -34,6 +34,7 @@ const AuthSchemeTypes = {
|
|
|
34
34
|
SERVICE_ACCOUNT: "SERVICE_ACCOUNT",
|
|
35
35
|
SAML: "SAML",
|
|
36
36
|
DCR_OAUTH: "DCR_OAUTH",
|
|
37
|
+
CIMD_OAUTH: "CIMD_OAUTH",
|
|
37
38
|
S2S_OAUTH2: "S2S_OAUTH2"
|
|
38
39
|
};
|
|
39
40
|
const AuthConfigCreationToolAccessConfigSchema = z$1.object({ toolsForConnectedAccountCreation: z$1.array(z$1.string()).optional() });
|
|
@@ -55,6 +56,7 @@ const AuthSchemeEnum = z$1.enum([
|
|
|
55
56
|
"SERVICE_ACCOUNT",
|
|
56
57
|
"SAML",
|
|
57
58
|
"DCR_OAUTH",
|
|
59
|
+
"CIMD_OAUTH",
|
|
58
60
|
"S2S_OAUTH2"
|
|
59
61
|
]);
|
|
60
62
|
const CreateCustomAuthConfigParamsSchema = z$1.object({
|
|
@@ -1474,7 +1476,7 @@ var Tools = class {
|
|
|
1474
1476
|
...limit ? { limit } : {},
|
|
1475
1477
|
..."tags" in queryParams.data ? { tags: queryParams.data.tags } : {},
|
|
1476
1478
|
..."scopes" in queryParams.data ? { scopes: queryParams.data.scopes } : {},
|
|
1477
|
-
..."search" in queryParams.data ? {
|
|
1479
|
+
..."search" in queryParams.data ? { query: queryParams.data.search } : {},
|
|
1478
1480
|
..."authConfigIds" in queryParams.data ? { auth_config_ids: queryParams.data.authConfigIds } : {},
|
|
1479
1481
|
...effectiveImportant ? { important: "true" } : {},
|
|
1480
1482
|
toolkit_versions: this.toolkitVersions
|
|
@@ -2046,6 +2048,12 @@ const ToolkitsListParamsSchema = z$1.object({
|
|
|
2046
2048
|
limit: z$1.number().optional()
|
|
2047
2049
|
});
|
|
2048
2050
|
/**
|
|
2051
|
+
* Toolkit getMany params — the slugs to fetch plus the same filters `list`
|
|
2052
|
+
* accepts.
|
|
2053
|
+
*/
|
|
2054
|
+
const ToolkitGetManySlugsSchema = z$1.array(z$1.string().min(1)).min(1);
|
|
2055
|
+
const ToolkitsGetManyParamsSchema = ToolkitsListParamsSchema;
|
|
2056
|
+
/**
|
|
2049
2057
|
* Toolkits response
|
|
2050
2058
|
*/
|
|
2051
2059
|
const ToolKitMetaSchema = z$1.object({
|
|
@@ -2093,7 +2101,14 @@ const ToolkitAuthFieldSchema = z$1.object({
|
|
|
2093
2101
|
* `legacy_template_name`. The API declares it as an optional string without
|
|
2094
2102
|
* further documenting its semantics.
|
|
2095
2103
|
*/
|
|
2096
|
-
legacyTemplateName: z$1.string().optional()
|
|
2104
|
+
legacyTemplateName: z$1.string().optional(),
|
|
2105
|
+
/**
|
|
2106
|
+
* Whether the hosted connect flow shows this field to the end user, mapped
|
|
2107
|
+
* from `user_visible`. A field with `false` is never required: its `default`
|
|
2108
|
+
* applies unless the auth config supplies a value. Absent when the API omits
|
|
2109
|
+
* the flag.
|
|
2110
|
+
*/
|
|
2111
|
+
userVisible: z$1.boolean().optional()
|
|
2097
2112
|
});
|
|
2098
2113
|
const ToolkitAuthConfigDetailsSchema = z$1.object({
|
|
2099
2114
|
name: z$1.string(),
|
|
@@ -2103,6 +2118,12 @@ const ToolkitAuthConfigDetailsSchema = z$1.object({
|
|
|
2103
2118
|
* authentication method, e.g. `https://github.com/settings/tokens`.
|
|
2104
2119
|
*/
|
|
2105
2120
|
authHintUrl: z$1.string().nullable().optional(),
|
|
2121
|
+
/**
|
|
2122
|
+
* OAuth scopes always requested for this auth method regardless of the
|
|
2123
|
+
* tool-specific scopes, such as token refresh (`offline_access`) and identity
|
|
2124
|
+
* scopes. Mapped from `required_scopes`; absent when the API omits it.
|
|
2125
|
+
*/
|
|
2126
|
+
requiredScopes: z$1.array(z$1.string()).optional(),
|
|
2106
2127
|
fields: z$1.object({
|
|
2107
2128
|
authConfigCreation: z$1.object({
|
|
2108
2129
|
optional: z$1.array(ToolkitAuthFieldSchema),
|
|
@@ -2138,6 +2159,108 @@ const ToolkitRetrieveCategoriesResponseSchema = z$1.object({
|
|
|
2138
2159
|
nextCursor: z$1.string().nullable(),
|
|
2139
2160
|
totalPages: z$1.number()
|
|
2140
2161
|
});
|
|
2162
|
+
/**
|
|
2163
|
+
* Toolkit changelog response
|
|
2164
|
+
*/
|
|
2165
|
+
const ToolkitVersionChangelogSchema = z$1.object({
|
|
2166
|
+
version: z$1.string(),
|
|
2167
|
+
changelog: z$1.string()
|
|
2168
|
+
});
|
|
2169
|
+
const ToolkitChangelogItemSchema = z$1.object({
|
|
2170
|
+
slug: z$1.string(),
|
|
2171
|
+
name: z$1.string(),
|
|
2172
|
+
displayName: z$1.string(),
|
|
2173
|
+
/** Most recent versions first; the API returns up to the last 10 per toolkit. */
|
|
2174
|
+
versions: z$1.array(ToolkitVersionChangelogSchema)
|
|
2175
|
+
});
|
|
2176
|
+
const ToolkitChangelogResponseSchema = z$1.object({ items: z$1.array(ToolkitChangelogItemSchema) });
|
|
2177
|
+
/**
|
|
2178
|
+
* Params for `composio.toolkits.recommendScopes()`.
|
|
2179
|
+
* **Experimental — shape may change in future releases.**
|
|
2180
|
+
*/
|
|
2181
|
+
const ToolkitRecommendScopesParamsSchema = z$1.object({
|
|
2182
|
+
/** Tool slugs to cover. Pass `[]` to cover every tool in the toolkit. */
|
|
2183
|
+
tools: z$1.array(z$1.string()),
|
|
2184
|
+
/** Auth scheme the connection will use. The API defaults to `OAUTH2`. */
|
|
2185
|
+
authScheme: AuthSchemeEnum.optional(),
|
|
2186
|
+
/** Toolkit version to compute from. The API defaults to the latest published version. */
|
|
2187
|
+
toolkitVersion: z$1.string().min(1).optional(),
|
|
2188
|
+
/**
|
|
2189
|
+
* Context the scopes will be granted in, as dimension → selected value,
|
|
2190
|
+
* for example `{ account_type: 'Google Workspace' }`. Discover the
|
|
2191
|
+
* dimensions with `composio.toolkits.listGrantContexts()`.
|
|
2192
|
+
*/
|
|
2193
|
+
grantContext: z$1.record(z$1.string(), z$1.string()).optional(),
|
|
2194
|
+
/** Scopes the recommendation must include, whether or not the tools need them. */
|
|
2195
|
+
include: z$1.array(z$1.string()).optional(),
|
|
2196
|
+
/** Scopes the recommendation must not include; the API picks documented alternatives or fails. */
|
|
2197
|
+
exclude: z$1.array(z$1.string()).optional(),
|
|
2198
|
+
/** Scopes your OAuth app can request. The recommendation never goes outside this list. */
|
|
2199
|
+
availableScopes: z$1.array(z$1.string()).optional()
|
|
2200
|
+
});
|
|
2201
|
+
const ToolkitConditionalScopeSchema = z$1.object({
|
|
2202
|
+
/** The scope needed only when the `when` guard matches. */
|
|
2203
|
+
scope: z$1.string(),
|
|
2204
|
+
/** Input field name → qualifying values. Any value matches within a field; all fields must match. */
|
|
2205
|
+
when: z$1.record(z$1.string(), z$1.array(z$1.string())),
|
|
2206
|
+
/** Tool slugs that need this scope under the guard. */
|
|
2207
|
+
for: z$1.array(z$1.string())
|
|
2208
|
+
});
|
|
2209
|
+
/**
|
|
2210
|
+
* Response of `composio.toolkits.recommendScopes()`.
|
|
2211
|
+
* **Experimental — shape may change in future releases.**
|
|
2212
|
+
*/
|
|
2213
|
+
const ToolkitRecommendScopesResponseSchema = z$1.object({
|
|
2214
|
+
/** Auth scheme the recommendation was computed under. */
|
|
2215
|
+
authScheme: z$1.string(),
|
|
2216
|
+
/** Concrete toolkit version the answer was computed from; pass it back as `toolkitVersion` to pin. */
|
|
2217
|
+
toolkitVersion: z$1.string(),
|
|
2218
|
+
/** The effective grant context: the toolkit default overlaid with your overrides. */
|
|
2219
|
+
grantContext: z$1.record(z$1.string(), z$1.string()),
|
|
2220
|
+
scopes: z$1.object({
|
|
2221
|
+
/** Narrowest documented option per requirement. */
|
|
2222
|
+
leastPrivilege: z$1.array(z$1.string()),
|
|
2223
|
+
/** Smallest scope set covering all requirements. */
|
|
2224
|
+
fewest: z$1.array(z$1.string()),
|
|
2225
|
+
/**
|
|
2226
|
+
* Scopes needed only for particular call-time inputs. Both lists above
|
|
2227
|
+
* already include them, so a caller that knows its inputs may drop the rest.
|
|
2228
|
+
*/
|
|
2229
|
+
conditional: z$1.array(ToolkitConditionalScopeSchema)
|
|
2230
|
+
})
|
|
2231
|
+
});
|
|
2232
|
+
/**
|
|
2233
|
+
* Params for `composio.toolkits.listGrantContexts()`.
|
|
2234
|
+
* **Experimental — shape may change in future releases.**
|
|
2235
|
+
*/
|
|
2236
|
+
const ToolkitListGrantContextsParamsSchema = z$1.object({
|
|
2237
|
+
/** Auth scheme the connection will use. The API defaults to `OAUTH2`. */
|
|
2238
|
+
authScheme: AuthSchemeEnum.optional(),
|
|
2239
|
+
/** Toolkit version to read the scope catalog from. The API defaults to the latest published version. */
|
|
2240
|
+
toolkitVersion: z$1.string().min(1).optional()
|
|
2241
|
+
});
|
|
2242
|
+
const ToolkitGrantContextDimensionSchema = z$1.object({
|
|
2243
|
+
/** Dimension name to use as a `grantContext` key. */
|
|
2244
|
+
dimension: z$1.string(),
|
|
2245
|
+
/** What the dimension means and when to pass it. */
|
|
2246
|
+
description: z$1.string(),
|
|
2247
|
+
/** Values the dimension can take. */
|
|
2248
|
+
values: z$1.array(z$1.string())
|
|
2249
|
+
});
|
|
2250
|
+
/**
|
|
2251
|
+
* Response of `composio.toolkits.listGrantContexts()`.
|
|
2252
|
+
* **Experimental — shape may change in future releases.**
|
|
2253
|
+
*/
|
|
2254
|
+
const ToolkitListGrantContextsResponseSchema = z$1.object({
|
|
2255
|
+
/** Auth scheme whose scope catalog the dimensions were read from. */
|
|
2256
|
+
authScheme: z$1.string(),
|
|
2257
|
+
/** Concrete toolkit version the answer was computed from. */
|
|
2258
|
+
toolkitVersion: z$1.string(),
|
|
2259
|
+
/** Dimensions the toolkit accepts in `grantContext`; empty when no scope depends on one. */
|
|
2260
|
+
grantContextDimensions: z$1.array(ToolkitGrantContextDimensionSchema),
|
|
2261
|
+
/** The grant context assumed when you pass none. */
|
|
2262
|
+
defaultGrantContext: z$1.record(z$1.string(), z$1.string())
|
|
2263
|
+
});
|
|
2141
2264
|
const ToolkitAuthFieldsResponseSchema = z$1.array(ToolkitAuthFieldSchema.extend({ required: z$1.boolean().optional() }));
|
|
2142
2265
|
|
|
2143
2266
|
//#endregion
|
|
@@ -2732,6 +2855,10 @@ const CreateConnectedAccountLinkOptionsSchema = z$1.object({
|
|
|
2732
2855
|
const CreateConnectedAccountLinkResponseSchema = z$1.object({ redirectUrl: z$1.string() });
|
|
2733
2856
|
const ConnectedAccountRefreshOptionsSchema = z$1.object({
|
|
2734
2857
|
redirectUrl: z$1.string().optional(),
|
|
2858
|
+
/**
|
|
2859
|
+
* @deprecated The Composio API no longer accepts this field. It is ignored
|
|
2860
|
+
* and `refresh()` logs a warning when it is set.
|
|
2861
|
+
*/
|
|
2735
2862
|
validateCredentials: z$1.boolean().optional()
|
|
2736
2863
|
});
|
|
2737
2864
|
const UpdateConnectedAccountParamsSchema = z$1.object({ enabled: z$1.boolean() });
|
|
@@ -2748,6 +2875,44 @@ const UpdateConnectedAccountParamsSchema = z$1.object({ enabled: z$1.boolean() }
|
|
|
2748
2875
|
* empty object is rejected as a no-op.
|
|
2749
2876
|
*/
|
|
2750
2877
|
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" });
|
|
2878
|
+
/**
|
|
2879
|
+
* Response of `composio.connectedAccounts.revoke()`.
|
|
2880
|
+
*/
|
|
2881
|
+
const ConnectedAccountRevokedTokenSchema = z$1.enum([
|
|
2882
|
+
"access_token",
|
|
2883
|
+
"refresh_token",
|
|
2884
|
+
"credential"
|
|
2885
|
+
]);
|
|
2886
|
+
const ConnectedAccountRevokeResponseSchema = z$1.object({
|
|
2887
|
+
/**
|
|
2888
|
+
* Tokens revoked at the provider on this call. An empty array means the
|
|
2889
|
+
* connection was already revoked (no upstream dispatch).
|
|
2890
|
+
*/
|
|
2891
|
+
revokedTokens: z$1.array(ConnectedAccountRevokedTokenSchema),
|
|
2892
|
+
connectedAccount: z$1.object({
|
|
2893
|
+
id: z$1.string(),
|
|
2894
|
+
/** The connection status after this call (`REVOKED` on success). */
|
|
2895
|
+
status: ConnectedAccountStatusSchema
|
|
2896
|
+
})
|
|
2897
|
+
});
|
|
2898
|
+
/**
|
|
2899
|
+
* Params for `composio.connectedAccounts.completeAuth()`.
|
|
2900
|
+
*/
|
|
2901
|
+
const ConnectedAccountCompleteAuthParamsSchema = z$1.object({
|
|
2902
|
+
/** The user the connection was initiated for. Must match the connection owner. */
|
|
2903
|
+
userId: z$1.string().min(1),
|
|
2904
|
+
/** The opaque, single-use session URI your OAuth callback verifier received. */
|
|
2905
|
+
sessionUri: z$1.string().min(1)
|
|
2906
|
+
});
|
|
2907
|
+
/**
|
|
2908
|
+
* Response of `composio.connectedAccounts.completeAuth()`.
|
|
2909
|
+
*/
|
|
2910
|
+
const ConnectedAccountCompleteAuthResponseSchema = z$1.object({
|
|
2911
|
+
/** The connection that was completed; it is now `ACTIVE`. */
|
|
2912
|
+
connectedAccountId: z$1.string(),
|
|
2913
|
+
/** The toolkit the connection belongs to. */
|
|
2914
|
+
toolkitSlug: z$1.string()
|
|
2915
|
+
});
|
|
2751
2916
|
|
|
2752
2917
|
//#endregion
|
|
2753
2918
|
//#region src/utils/transformers/connectedAccounts.ts
|
|
@@ -2821,6 +2986,21 @@ function transformConnectedAccountListResponse(response) {
|
|
|
2821
2986
|
totalPages: response.total_pages
|
|
2822
2987
|
}));
|
|
2823
2988
|
}
|
|
2989
|
+
const transformConnectedAccountRevokeResponse = (response) => {
|
|
2990
|
+
return transform(response).with(ConnectedAccountRevokeResponseSchema).using((response) => ({
|
|
2991
|
+
revokedTokens: response.revoked_tokens,
|
|
2992
|
+
connectedAccount: {
|
|
2993
|
+
id: response.connected_account.id,
|
|
2994
|
+
status: response.connected_account.status
|
|
2995
|
+
}
|
|
2996
|
+
}));
|
|
2997
|
+
};
|
|
2998
|
+
const transformConnectedAccountCompleteAuthResponse = (response) => {
|
|
2999
|
+
return transform(response).with(ConnectedAccountCompleteAuthResponseSchema).using((response) => ({
|
|
3000
|
+
connectedAccountId: response.connected_account_id,
|
|
3001
|
+
toolkitSlug: response.toolkit_slug
|
|
3002
|
+
}));
|
|
3003
|
+
};
|
|
2824
3004
|
|
|
2825
3005
|
//#endregion
|
|
2826
3006
|
//#region src/models/ConnectionRequest.ts
|
|
@@ -2919,6 +3099,440 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
|
|
|
2919
3099
|
};
|
|
2920
3100
|
}
|
|
2921
3101
|
|
|
3102
|
+
//#endregion
|
|
3103
|
+
//#region src/types/usage.types.ts
|
|
3104
|
+
/**
|
|
3105
|
+
* Filters shared by the usage summary and breakdown queries.
|
|
3106
|
+
* **Experimental — shape may change in future releases.**
|
|
3107
|
+
*/
|
|
3108
|
+
const UsageFiltersSchema = z$1.object({
|
|
3109
|
+
/** Only count events for these external end-user IDs (OR logic). */
|
|
3110
|
+
userId: z$1.array(z$1.string()).nullable().optional(),
|
|
3111
|
+
/** Only count events for these session IDs (OR logic). */
|
|
3112
|
+
sessionId: z$1.array(z$1.string()).nullable().optional()
|
|
3113
|
+
});
|
|
3114
|
+
/**
|
|
3115
|
+
* Params for `composio.experimental.usage.summary()`.
|
|
3116
|
+
* **Experimental — shape may change in future releases.**
|
|
3117
|
+
*/
|
|
3118
|
+
const UsageSummaryParamsSchema = z$1.object({
|
|
3119
|
+
/** Inclusive range start (Unix epoch milliseconds). Defaults to 30 days before `to`. */
|
|
3120
|
+
from: z$1.number().optional(),
|
|
3121
|
+
/** Exclusive range end (Unix epoch milliseconds). Defaults to now. */
|
|
3122
|
+
to: z$1.number().optional(),
|
|
3123
|
+
/** Restrict to these metering entity types. Omit for all types. */
|
|
3124
|
+
entityTypes: z$1.array(z$1.string()).optional(),
|
|
3125
|
+
filters: UsageFiltersSchema.optional()
|
|
3126
|
+
});
|
|
3127
|
+
const UsageOrderBySchema = z$1.enum([
|
|
3128
|
+
"key",
|
|
3129
|
+
"total_quantity",
|
|
3130
|
+
"event_count"
|
|
3131
|
+
]);
|
|
3132
|
+
const UsageOrderDirectionSchema = z$1.enum(["asc", "desc"]);
|
|
3133
|
+
/**
|
|
3134
|
+
* Params for `composio.experimental.usage.breakdown()`.
|
|
3135
|
+
* **Experimental — shape may change in future releases.**
|
|
3136
|
+
*/
|
|
3137
|
+
const UsageBreakdownParamsSchema = z$1.object({
|
|
3138
|
+
/** Inclusive range start (Unix epoch milliseconds). Defaults to 30 days before `to`. */
|
|
3139
|
+
from: z$1.number().optional(),
|
|
3140
|
+
/** Exclusive range end (Unix epoch milliseconds). Defaults to now. */
|
|
3141
|
+
to: z$1.number().optional(),
|
|
3142
|
+
/** Dimension to group by. Defaults to `tool_slug` for tool_calls and `user_id` for sessions. */
|
|
3143
|
+
groupBy: z$1.string().optional(),
|
|
3144
|
+
/** Field to order groups by. Defaults to `total_quantity`. */
|
|
3145
|
+
orderBy: UsageOrderBySchema.optional(),
|
|
3146
|
+
/** Sort direction. Defaults to `desc`. */
|
|
3147
|
+
orderDirection: UsageOrderDirectionSchema.optional(),
|
|
3148
|
+
/** Maximum number of groups to return. Defaults to 100, max 1000. */
|
|
3149
|
+
limit: z$1.number().optional(),
|
|
3150
|
+
filters: UsageFiltersSchema.optional()
|
|
3151
|
+
});
|
|
3152
|
+
const UsageEntitySummarySchema = z$1.object({
|
|
3153
|
+
unit: z$1.string(),
|
|
3154
|
+
totalQuantity: z$1.string(),
|
|
3155
|
+
eventCount: z$1.number()
|
|
3156
|
+
});
|
|
3157
|
+
const UsageSummaryResponseSchema = z$1.object({
|
|
3158
|
+
/** Aggregates keyed by metering entity type (e.g. `tool_calls`, `sessions`). */
|
|
3159
|
+
entities: z$1.record(z$1.string(), UsageEntitySummarySchema) });
|
|
3160
|
+
const UsageBreakdownGroupSchema = z$1.object({
|
|
3161
|
+
key: z$1.string(),
|
|
3162
|
+
totalQuantity: z$1.string(),
|
|
3163
|
+
eventCount: z$1.number()
|
|
3164
|
+
});
|
|
3165
|
+
const UsageBreakdownResponseSchema = z$1.object({
|
|
3166
|
+
entityType: z$1.string(),
|
|
3167
|
+
unit: z$1.string(),
|
|
3168
|
+
totalQuantity: z$1.string(),
|
|
3169
|
+
eventCount: z$1.number(),
|
|
3170
|
+
groups: z$1.array(UsageBreakdownGroupSchema)
|
|
3171
|
+
});
|
|
3172
|
+
|
|
3173
|
+
//#endregion
|
|
3174
|
+
//#region src/utils/transformers/usage.ts
|
|
3175
|
+
const transformUsageFilters = (filters) => filters ? {
|
|
3176
|
+
user_id: filters.userId,
|
|
3177
|
+
session_id: filters.sessionId
|
|
3178
|
+
} : void 0;
|
|
3179
|
+
const transformUsageSummaryParams = (params) => ({
|
|
3180
|
+
from: params.from,
|
|
3181
|
+
to: params.to,
|
|
3182
|
+
entity_types: params.entityTypes,
|
|
3183
|
+
filters: transformUsageFilters(params.filters)
|
|
3184
|
+
});
|
|
3185
|
+
const transformUsageBreakdownParams = (params) => ({
|
|
3186
|
+
from: params.from,
|
|
3187
|
+
to: params.to,
|
|
3188
|
+
group_by: params.groupBy,
|
|
3189
|
+
order_by: params.orderBy,
|
|
3190
|
+
order_direction: params.orderDirection,
|
|
3191
|
+
limit: params.limit,
|
|
3192
|
+
filters: transformUsageFilters(params.filters)
|
|
3193
|
+
});
|
|
3194
|
+
const transformUsageSummaryResponse = (response) => {
|
|
3195
|
+
return transform(response).with(UsageSummaryResponseSchema).using((response) => ({ entities: Object.fromEntries(Object.entries(response.entities).map(([entityType, entity]) => [entityType, {
|
|
3196
|
+
unit: entity.unit,
|
|
3197
|
+
totalQuantity: entity.total_quantity,
|
|
3198
|
+
eventCount: entity.event_count
|
|
3199
|
+
}])) }));
|
|
3200
|
+
};
|
|
3201
|
+
const transformUsageBreakdownResponse = (response) => {
|
|
3202
|
+
return transform(response).with(UsageBreakdownResponseSchema).using((response) => ({
|
|
3203
|
+
entityType: response.entity_type,
|
|
3204
|
+
unit: response.unit,
|
|
3205
|
+
totalQuantity: response.total_quantity,
|
|
3206
|
+
eventCount: response.event_count,
|
|
3207
|
+
groups: response.groups.map((group) => ({
|
|
3208
|
+
key: group.key,
|
|
3209
|
+
totalQuantity: group.total_quantity,
|
|
3210
|
+
eventCount: group.event_count
|
|
3211
|
+
}))
|
|
3212
|
+
}));
|
|
3213
|
+
};
|
|
3214
|
+
|
|
3215
|
+
//#endregion
|
|
3216
|
+
//#region src/models/Usage.ts
|
|
3217
|
+
/**
|
|
3218
|
+
* `composio.experimental.usage` — metering for the project the API key
|
|
3219
|
+
* belongs to. **Experimental — shape may change in future releases.**
|
|
3220
|
+
*
|
|
3221
|
+
* @example
|
|
3222
|
+
* ```typescript
|
|
3223
|
+
* const summary = await composio.experimental.usage.summary();
|
|
3224
|
+
* console.log(summary.entities.tool_calls?.totalQuantity);
|
|
3225
|
+
*
|
|
3226
|
+
* const byTool = await composio.experimental.usage.breakdown('tool_calls', {
|
|
3227
|
+
* groupBy: 'tool_slug',
|
|
3228
|
+
* limit: 10,
|
|
3229
|
+
* });
|
|
3230
|
+
* ```
|
|
3231
|
+
*/
|
|
3232
|
+
var Usage = class {
|
|
3233
|
+
client;
|
|
3234
|
+
constructor(client) {
|
|
3235
|
+
this.client = client;
|
|
3236
|
+
telemetry.instrument(this, "Usage");
|
|
3237
|
+
}
|
|
3238
|
+
/**
|
|
3239
|
+
* Usage totals per metering entity type for a time range.
|
|
3240
|
+
* **Experimental — shape may change in future releases.**
|
|
3241
|
+
*
|
|
3242
|
+
* @param {UsageSummaryParams} [params] - Optional range, `entityTypes` and filters
|
|
3243
|
+
* @returns {Promise<UsageSummaryResponse>} Totals keyed by entity type
|
|
3244
|
+
* @throws {ValidationError} If the params fail validation
|
|
3245
|
+
*
|
|
3246
|
+
* @example
|
|
3247
|
+
* ```typescript
|
|
3248
|
+
* const summary = await composio.experimental.usage.summary({
|
|
3249
|
+
* from: Date.now() - 7 * 24 * 60 * 60 * 1000,
|
|
3250
|
+
* filters: { userId: ['user_123'] },
|
|
3251
|
+
* });
|
|
3252
|
+
* ```
|
|
3253
|
+
*/
|
|
3254
|
+
async summary(params, requestOptions) {
|
|
3255
|
+
const parsedParams = UsageSummaryParamsSchema.safeParse(params ?? {});
|
|
3256
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse usage summary params", { cause: parsedParams.error });
|
|
3257
|
+
const body = transformUsageSummaryParams(parsedParams.data);
|
|
3258
|
+
const result = await withCancellation(() => this.client.project.usage.retrieveSummary(body, requestOptions), requestOptions?.signal);
|
|
3259
|
+
return transformUsageSummaryResponse(result);
|
|
3260
|
+
}
|
|
3261
|
+
/**
|
|
3262
|
+
* Usage for one metering entity type, grouped by a dimension.
|
|
3263
|
+
* **Experimental — shape may change in future releases.**
|
|
3264
|
+
*
|
|
3265
|
+
* @param {string} entityType - Entity type to break down (e.g. `tool_calls`, `sessions`)
|
|
3266
|
+
* @param {UsageBreakdownParams} [params] - Optional range, `groupBy`, ordering, `limit` and filters
|
|
3267
|
+
* @returns {Promise<UsageBreakdownResponse>} Totals plus per-group rows
|
|
3268
|
+
* @throws {ValidationError} If the params fail validation
|
|
3269
|
+
*
|
|
3270
|
+
* @example
|
|
3271
|
+
* ```typescript
|
|
3272
|
+
* const byUser = await composio.experimental.usage.breakdown('sessions', {
|
|
3273
|
+
* groupBy: 'user_id',
|
|
3274
|
+
* orderBy: 'event_count',
|
|
3275
|
+
* });
|
|
3276
|
+
* ```
|
|
3277
|
+
*/
|
|
3278
|
+
async breakdown(entityType, params, requestOptions) {
|
|
3279
|
+
const parsedParams = UsageBreakdownParamsSchema.safeParse(params ?? {});
|
|
3280
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse usage breakdown params", { cause: parsedParams.error });
|
|
3281
|
+
const body = transformUsageBreakdownParams(parsedParams.data);
|
|
3282
|
+
const result = await withCancellation(() => this.client.project.usage.retrieve(entityType, body, requestOptions), requestOptions?.signal);
|
|
3283
|
+
return transformUsageBreakdownResponse(result);
|
|
3284
|
+
}
|
|
3285
|
+
};
|
|
3286
|
+
|
|
3287
|
+
//#endregion
|
|
3288
|
+
//#region src/types/customToolkits.types.ts
|
|
3289
|
+
/**
|
|
3290
|
+
* How end users authenticate to a custom toolkit.
|
|
3291
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3292
|
+
*/
|
|
3293
|
+
const CustomToolkitAuthSchemeSchema = z$1.discriminatedUnion("mode", [
|
|
3294
|
+
z$1.object({ mode: z$1.literal("NO_AUTH") }),
|
|
3295
|
+
z$1.object({
|
|
3296
|
+
mode: z$1.literal("API_KEY"),
|
|
3297
|
+
/**
|
|
3298
|
+
* Headers sent with each request. Write `{{generic_api_key}}` where the
|
|
3299
|
+
* end user's API key goes, for example
|
|
3300
|
+
* `{ Authorization: 'Bearer {{generic_api_key}}' }`.
|
|
3301
|
+
*/
|
|
3302
|
+
headers: z$1.record(z$1.string(), z$1.string()),
|
|
3303
|
+
/** End-user copy for the API key input on the connect page. */
|
|
3304
|
+
apiKeyField: z$1.object({
|
|
3305
|
+
displayName: z$1.string().min(1).max(100).optional(),
|
|
3306
|
+
description: z$1.string().min(1).max(500).optional()
|
|
3307
|
+
}).optional()
|
|
3308
|
+
}),
|
|
3309
|
+
z$1.object({
|
|
3310
|
+
mode: z$1.literal("DCR_OAUTH"),
|
|
3311
|
+
/**
|
|
3312
|
+
* Where to fetch the full auth scheme, usually the
|
|
3313
|
+
* `/.well-known/oauth-authorization-server` path of your MCP URL.
|
|
3314
|
+
*/
|
|
3315
|
+
discoveryUrl: z$1.string().url()
|
|
3316
|
+
})
|
|
3317
|
+
]);
|
|
3318
|
+
/**
|
|
3319
|
+
* Params for `composio.experimental.customToolkits.upsert()`.
|
|
3320
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3321
|
+
*/
|
|
3322
|
+
const CustomToolkitUpsertParamsSchema = z$1.object({
|
|
3323
|
+
/**
|
|
3324
|
+
* Letters, digits, underscores or spaces, up to 30 characters. The API
|
|
3325
|
+
* prefixes it with `CUSTOM_` and turns spaces into underscores.
|
|
3326
|
+
*/
|
|
3327
|
+
slug: z$1.string().min(1).max(30).regex(/^[a-zA-Z0-9_\s]+$/),
|
|
3328
|
+
toolkitConfig: z$1.object({
|
|
3329
|
+
/** Human-readable toolkit name. */
|
|
3330
|
+
name: z$1.string().min(1).max(200),
|
|
3331
|
+
/** The app URL. For an MCP app, the MCP server URL. */
|
|
3332
|
+
appUrl: z$1.string().url(),
|
|
3333
|
+
/** Square PNG or JPEG logo (256-1024px, max 3MB), base64-encoded. Defaults to the Composio logo. */
|
|
3334
|
+
logoFile: z$1.object({
|
|
3335
|
+
content: z$1.string().min(1),
|
|
3336
|
+
mimeType: z$1.enum(["image/png", "image/jpeg"])
|
|
3337
|
+
}).optional(),
|
|
3338
|
+
/** At least one scheme. The schemes cannot change once the toolkit exists. */
|
|
3339
|
+
authSchemes: z$1.array(CustomToolkitAuthSchemeSchema).min(1)
|
|
3340
|
+
})
|
|
3341
|
+
});
|
|
3342
|
+
const CustomToolkitUpsertResponseSchema = z$1.object({
|
|
3343
|
+
/** Slug of the created or updated toolkit. */
|
|
3344
|
+
slug: z$1.string() });
|
|
3345
|
+
/**
|
|
3346
|
+
* Params for `composio.experimental.customToolkits.sync()`.
|
|
3347
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3348
|
+
*/
|
|
3349
|
+
const CustomToolkitSyncParamsSchema = z$1.object({
|
|
3350
|
+
/** Connected account to use when fetching the remote tool definitions. */
|
|
3351
|
+
connectedAccountId: z$1.string().optional() });
|
|
3352
|
+
const CustomToolkitSyncResponseSchema = z$1.object({
|
|
3353
|
+
slug: z$1.string(),
|
|
3354
|
+
/** Toolkit version after the sync. */
|
|
3355
|
+
version: z$1.string(),
|
|
3356
|
+
/** Number of tools synced. */
|
|
3357
|
+
syncedCount: z$1.number()
|
|
3358
|
+
});
|
|
3359
|
+
const CustomToolkitDeleteResponseSchema = z$1.object({
|
|
3360
|
+
/** Slug of the deleted toolkit. */
|
|
3361
|
+
slug: z$1.string(),
|
|
3362
|
+
deleted: z$1.boolean(),
|
|
3363
|
+
/** Background jobs revoking the credentials of the toolkit's connected accounts. */
|
|
3364
|
+
revokeJobIds: z$1.array(z$1.string()),
|
|
3365
|
+
authConfigsDeleted: z$1.number(),
|
|
3366
|
+
connectedAccountsDeleted: z$1.number()
|
|
3367
|
+
});
|
|
3368
|
+
|
|
3369
|
+
//#endregion
|
|
3370
|
+
//#region src/utils/transformers/customToolkits.ts
|
|
3371
|
+
const transformCustomToolkitAuthScheme = (scheme) => {
|
|
3372
|
+
switch (scheme.mode) {
|
|
3373
|
+
case "NO_AUTH": return { mode: "NO_AUTH" };
|
|
3374
|
+
case "API_KEY": return {
|
|
3375
|
+
mode: "API_KEY",
|
|
3376
|
+
headers: scheme.headers,
|
|
3377
|
+
api_key_field: scheme.apiKeyField && {
|
|
3378
|
+
display_name: scheme.apiKeyField.displayName,
|
|
3379
|
+
description: scheme.apiKeyField.description
|
|
3380
|
+
}
|
|
3381
|
+
};
|
|
3382
|
+
case "DCR_OAUTH": return {
|
|
3383
|
+
mode: "DCR_OAUTH",
|
|
3384
|
+
discovery_url: scheme.discoveryUrl
|
|
3385
|
+
};
|
|
3386
|
+
}
|
|
3387
|
+
};
|
|
3388
|
+
const transformCustomToolkitUpsertParams = (params) => ({
|
|
3389
|
+
slug: params.slug,
|
|
3390
|
+
toolkit_config: {
|
|
3391
|
+
name: params.toolkitConfig.name,
|
|
3392
|
+
app_url: params.toolkitConfig.appUrl,
|
|
3393
|
+
logo_file: params.toolkitConfig.logoFile && {
|
|
3394
|
+
content: params.toolkitConfig.logoFile.content,
|
|
3395
|
+
mime_type: params.toolkitConfig.logoFile.mimeType
|
|
3396
|
+
},
|
|
3397
|
+
auth_schemes: params.toolkitConfig.authSchemes.map(transformCustomToolkitAuthScheme)
|
|
3398
|
+
}
|
|
3399
|
+
});
|
|
3400
|
+
const transformCustomToolkitUpsertResponse = (response) => {
|
|
3401
|
+
return transform(response).with(CustomToolkitUpsertResponseSchema).using((response) => ({ slug: response.slug }));
|
|
3402
|
+
};
|
|
3403
|
+
const transformCustomToolkitSyncParams = (slug, params) => ({
|
|
3404
|
+
slug,
|
|
3405
|
+
connected_account_id: params.connectedAccountId
|
|
3406
|
+
});
|
|
3407
|
+
const transformCustomToolkitSyncResponse = (response) => {
|
|
3408
|
+
return transform(response).with(CustomToolkitSyncResponseSchema).using((response) => ({
|
|
3409
|
+
slug: response.slug,
|
|
3410
|
+
version: response.version,
|
|
3411
|
+
syncedCount: response.synced_count
|
|
3412
|
+
}));
|
|
3413
|
+
};
|
|
3414
|
+
const transformCustomToolkitDeleteResponse = (response) => {
|
|
3415
|
+
return transform(response).with(CustomToolkitDeleteResponseSchema).using((response) => ({
|
|
3416
|
+
slug: response.slug,
|
|
3417
|
+
deleted: response.deleted,
|
|
3418
|
+
revokeJobIds: response.revoke_job_ids,
|
|
3419
|
+
authConfigsDeleted: response.auth_configs_deleted,
|
|
3420
|
+
connectedAccountsDeleted: response.connected_accounts_deleted
|
|
3421
|
+
}));
|
|
3422
|
+
};
|
|
3423
|
+
|
|
3424
|
+
//#endregion
|
|
3425
|
+
//#region src/models/CustomToolkits.ts
|
|
3426
|
+
/**
|
|
3427
|
+
* `composio.experimental.customToolkits` — toolkits your project registers
|
|
3428
|
+
* from its own app or MCP server, with their own auth configs and connected
|
|
3429
|
+
* accounts. **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3430
|
+
*
|
|
3431
|
+
* These live on the Composio platform. They are unrelated to the in-process
|
|
3432
|
+
* toolkits built with `experimental_createToolkit()`, which run inside your
|
|
3433
|
+
* application.
|
|
3434
|
+
*
|
|
3435
|
+
* @example
|
|
3436
|
+
* ```typescript
|
|
3437
|
+
* const { slug } = await composio.experimental.customToolkits.upsert({
|
|
3438
|
+
* slug: 'MY_TOOLKIT',
|
|
3439
|
+
* toolkitConfig: {
|
|
3440
|
+
* name: 'My Toolkit',
|
|
3441
|
+
* appUrl: 'https://mcp.example.com/mcp',
|
|
3442
|
+
* authSchemes: [{ mode: 'DCR_OAUTH', discoveryUrl: 'https://mcp.example.com/.well-known/oauth-authorization-server' }],
|
|
3443
|
+
* },
|
|
3444
|
+
* });
|
|
3445
|
+
* await composio.experimental.customToolkits.sync(slug);
|
|
3446
|
+
* ```
|
|
3447
|
+
*/
|
|
3448
|
+
var CustomToolkits = class {
|
|
3449
|
+
client;
|
|
3450
|
+
constructor(client) {
|
|
3451
|
+
this.client = client;
|
|
3452
|
+
telemetry.instrument(this, "CustomToolkits");
|
|
3453
|
+
}
|
|
3454
|
+
/**
|
|
3455
|
+
* Creates a custom toolkit, or updates its display metadata (name, API key
|
|
3456
|
+
* field copy) when the project already owns a toolkit with this slug.
|
|
3457
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3458
|
+
*
|
|
3459
|
+
* `appUrl` and `authSchemes` cannot change on an existing toolkit:
|
|
3460
|
+
* re-sending them unchanged is a no-op, and changing them fails with a 409.
|
|
3461
|
+
* Delete and re-register the toolkit instead, which revokes its connections.
|
|
3462
|
+
*
|
|
3463
|
+
* @param {CustomToolkitUpsertParams} params - The slug and toolkit configuration
|
|
3464
|
+
* @returns {Promise<CustomToolkitUpsertResponse>} The toolkit's slug
|
|
3465
|
+
* @throws {ValidationError} If the params fail validation
|
|
3466
|
+
*
|
|
3467
|
+
* @example
|
|
3468
|
+
* ```typescript
|
|
3469
|
+
* await composio.experimental.customToolkits.upsert({
|
|
3470
|
+
* slug: 'INTERNAL_API',
|
|
3471
|
+
* toolkitConfig: {
|
|
3472
|
+
* name: 'Internal API',
|
|
3473
|
+
* appUrl: 'https://mcp.internal.example.com/mcp',
|
|
3474
|
+
* authSchemes: [
|
|
3475
|
+
* { mode: 'API_KEY', headers: { Authorization: 'Bearer {{generic_api_key}}' } },
|
|
3476
|
+
* ],
|
|
3477
|
+
* },
|
|
3478
|
+
* });
|
|
3479
|
+
* ```
|
|
3480
|
+
*/
|
|
3481
|
+
async upsert(params, requestOptions) {
|
|
3482
|
+
const parsedParams = CustomToolkitUpsertParamsSchema.safeParse(params);
|
|
3483
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse custom toolkit upsert params", { cause: parsedParams.error });
|
|
3484
|
+
const body = transformCustomToolkitUpsertParams(parsedParams.data);
|
|
3485
|
+
const result = await withCancellation(() => this.client.custom.upsert(body, requestOptions), requestOptions?.signal);
|
|
3486
|
+
return transformCustomToolkitUpsertResponse(result);
|
|
3487
|
+
}
|
|
3488
|
+
/**
|
|
3489
|
+
* Re-fetches the tool definitions of a custom toolkit from its remote MCP
|
|
3490
|
+
* server. Call it when automatic sync fails or the remote tools change.
|
|
3491
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3492
|
+
*
|
|
3493
|
+
* @param {string} slug - The custom toolkit slug (`CUSTOM_...`)
|
|
3494
|
+
* @param {CustomToolkitSyncParams} [params] - Optional connected account to fetch the definitions with
|
|
3495
|
+
* @returns {Promise<CustomToolkitSyncResponse>} The toolkit version and number of tools synced
|
|
3496
|
+
* @throws {ValidationError} If the params fail validation
|
|
3497
|
+
*
|
|
3498
|
+
* @example
|
|
3499
|
+
* ```typescript
|
|
3500
|
+
* const { version, syncedCount } = await composio.experimental.customToolkits.sync(
|
|
3501
|
+
* 'CUSTOM_MY_TOOLKIT',
|
|
3502
|
+
* { connectedAccountId: 'ca_abc123' }
|
|
3503
|
+
* );
|
|
3504
|
+
* ```
|
|
3505
|
+
*/
|
|
3506
|
+
async sync(slug, params, requestOptions) {
|
|
3507
|
+
const parsedParams = CustomToolkitSyncParamsSchema.safeParse(params ?? {});
|
|
3508
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse custom toolkit sync params", { cause: parsedParams.error });
|
|
3509
|
+
const body = transformCustomToolkitSyncParams(slug, parsedParams.data);
|
|
3510
|
+
const result = await withCancellation(() => this.client.custom.sync(body, requestOptions), requestOptions?.signal);
|
|
3511
|
+
return transformCustomToolkitSyncResponse(result);
|
|
3512
|
+
}
|
|
3513
|
+
/**
|
|
3514
|
+
* Deletes a custom toolkit owned by the project, with its tools, auth
|
|
3515
|
+
* configs and connected accounts. The credentials behind those connected
|
|
3516
|
+
* accounts are revoked in background jobs (`revokeJobIds`).
|
|
3517
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3518
|
+
*
|
|
3519
|
+
* Composio-managed toolkits cannot be deleted; the API answers 403.
|
|
3520
|
+
*
|
|
3521
|
+
* @param {string} slug - The custom toolkit slug (`CUSTOM_...`)
|
|
3522
|
+
* @returns {Promise<CustomToolkitDeleteResponse>} What was deleted
|
|
3523
|
+
*
|
|
3524
|
+
* @example
|
|
3525
|
+
* ```typescript
|
|
3526
|
+
* const result = await composio.experimental.customToolkits.delete('CUSTOM_MY_TOOLKIT');
|
|
3527
|
+
* console.log(result.connectedAccountsDeleted);
|
|
3528
|
+
* ```
|
|
3529
|
+
*/
|
|
3530
|
+
async delete(slug, requestOptions) {
|
|
3531
|
+
const result = await withCancellation(() => this.client.custom.deleteToolkit(slug, requestOptions), requestOptions?.signal);
|
|
3532
|
+
return transformCustomToolkitDeleteResponse(result);
|
|
3533
|
+
}
|
|
3534
|
+
};
|
|
3535
|
+
|
|
2922
3536
|
//#endregion
|
|
2923
3537
|
//#region src/models/Experimental.ts
|
|
2924
3538
|
/**
|
|
@@ -2984,8 +3598,31 @@ async function updateConnectedAccountAcl(client, nanoid, params) {
|
|
|
2984
3598
|
}
|
|
2985
3599
|
var Experimental = class {
|
|
2986
3600
|
client;
|
|
3601
|
+
/**
|
|
3602
|
+
* Project-scoped usage metering (`summary()` / `breakdown()`).
|
|
3603
|
+
* **Experimental — shape may change in future releases.**
|
|
3604
|
+
*
|
|
3605
|
+
* @example
|
|
3606
|
+
* ```typescript
|
|
3607
|
+
* const summary = await composio.experimental.usage.summary();
|
|
3608
|
+
* const byTool = await composio.experimental.usage.breakdown('tool_calls');
|
|
3609
|
+
* ```
|
|
3610
|
+
*/
|
|
3611
|
+
usage;
|
|
3612
|
+
/**
|
|
3613
|
+
* Register and manage project-owned custom toolkits (`upsert()` / `sync()` / `delete()`).
|
|
3614
|
+
* **Experimental — custom toolkits are in pilot; shape may change.**
|
|
3615
|
+
*
|
|
3616
|
+
* @example
|
|
3617
|
+
* ```typescript
|
|
3618
|
+
* await composio.experimental.customToolkits.sync('CUSTOM_MY_TOOLKIT');
|
|
3619
|
+
* ```
|
|
3620
|
+
*/
|
|
3621
|
+
customToolkits;
|
|
2987
3622
|
constructor(client) {
|
|
2988
3623
|
this.client = client;
|
|
3624
|
+
this.usage = new Usage(client);
|
|
3625
|
+
this.customToolkits = new CustomToolkits(client);
|
|
2989
3626
|
telemetry.instrument(this, "Experimental");
|
|
2990
3627
|
}
|
|
2991
3628
|
/**
|
|
@@ -3367,20 +4004,95 @@ var ConnectedAccounts = class {
|
|
|
3367
4004
|
* // Refresh a connected account's credentials
|
|
3368
4005
|
* const refreshedAccount = await composio.connectedAccounts.refresh('conn_abc123');
|
|
3369
4006
|
* ```
|
|
4007
|
+
*
|
|
4008
|
+
* @deprecated The `POST /connected_accounts/{id}/refresh` endpoint is deprecated by the
|
|
4009
|
+
* Composio API. Re-initiate authentication instead: `composio.connectedAccounts.link(userId, authConfigId)`
|
|
4010
|
+
* for a fresh connection, or `session.authorize(toolkit)` from a session. Behaviour is unchanged
|
|
4011
|
+
* while the endpoint remains available; do not generate new code against `refresh`.
|
|
3370
4012
|
*/
|
|
3371
4013
|
async refresh(nanoid, options, requestOptions) {
|
|
3372
4014
|
let params = void 0;
|
|
3373
4015
|
if (options) {
|
|
3374
4016
|
const parsedOptions = ConnectedAccountRefreshOptionsSchema.safeParse(options);
|
|
3375
4017
|
if (!parsedOptions.success) throw new ValidationError("Failed to parse connected account refresh options", { cause: parsedOptions.error });
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
validate_credentials: parsedOptions.data.validateCredentials
|
|
3379
|
-
};
|
|
4018
|
+
if (parsedOptions.data.validateCredentials !== void 0) logger.warn("connectedAccounts.refresh(): the Composio API no longer accepts `validateCredentials`; the option is ignored.");
|
|
4019
|
+
params = { query_redirect_url: parsedOptions.data.redirectUrl };
|
|
3380
4020
|
}
|
|
3381
4021
|
return withCancellation(() => this.client.connectedAccounts.refresh(nanoid, params, requestOptions), requestOptions?.signal);
|
|
3382
4022
|
}
|
|
3383
4023
|
/**
|
|
4024
|
+
* Revoke a connected account at the upstream provider.
|
|
4025
|
+
*
|
|
4026
|
+
* Best-effort upstream revocation of the stored tokens/credentials; on
|
|
4027
|
+
* success the connection status becomes `REVOKED`. Revoking an already
|
|
4028
|
+
* revoked connection returns an empty `revokedTokens` list without an
|
|
4029
|
+
* upstream call.
|
|
4030
|
+
*
|
|
4031
|
+
* @param {string} nanoid - The unique identifier of the connected account to revoke
|
|
4032
|
+
* @returns {Promise<ConnectedAccountRevokeResponse>} Which tokens were revoked and the resulting status
|
|
4033
|
+
* @throws {ComposioConnectedAccountRevocationNotSupportedError} If the toolkit does not support programmatic revocation (400)
|
|
4034
|
+
* @throws {ComposioConnectedAccountNotRevokableError} If the connection is not in a revokable state (409)
|
|
4035
|
+
*
|
|
4036
|
+
* @example
|
|
4037
|
+
* ```typescript
|
|
4038
|
+
* const result = await composio.connectedAccounts.revoke('conn_abc123');
|
|
4039
|
+
* console.log(result.connectedAccount.status); // 'REVOKED'
|
|
4040
|
+
* console.log(result.revokedTokens); // e.g. ['access_token', 'refresh_token']
|
|
4041
|
+
* ```
|
|
4042
|
+
*/
|
|
4043
|
+
async revoke(nanoid, requestOptions) {
|
|
4044
|
+
try {
|
|
4045
|
+
const result = await withCancellation(() => this.client.connectedAccounts.revoke(nanoid, requestOptions), requestOptions?.signal);
|
|
4046
|
+
return transformConnectedAccountRevokeResponse(result);
|
|
4047
|
+
} catch (error) {
|
|
4048
|
+
if (error instanceof BadRequestError) throw new ComposioConnectedAccountRevocationNotSupportedError(`Connected account ${nanoid} cannot be revoked programmatically: ${error.message}`, {
|
|
4049
|
+
cause: error,
|
|
4050
|
+
meta: { nanoid }
|
|
4051
|
+
});
|
|
4052
|
+
if (error instanceof ConflictError) throw new ComposioConnectedAccountNotRevokableError(`Connected account ${nanoid} is not in a revokable state: ${error.message}`, {
|
|
4053
|
+
cause: error,
|
|
4054
|
+
meta: { nanoid }
|
|
4055
|
+
});
|
|
4056
|
+
throw error;
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
/**
|
|
4060
|
+
* Complete a deferred OAuth connection once you have verified the user's
|
|
4061
|
+
* identity.
|
|
4062
|
+
*
|
|
4063
|
+
* When your project has an OAuth callback verifier configured, Composio
|
|
4064
|
+
* does not activate a new OAuth connection by itself: it redirects to your
|
|
4065
|
+
* verifier with a single-use session URI. After confirming who the user is,
|
|
4066
|
+
* redeem that session URI here; Composio checks that your project owns the
|
|
4067
|
+
* pending connection and that `userId` is its owner, completes the token
|
|
4068
|
+
* exchange, and the connection becomes `ACTIVE`.
|
|
4069
|
+
*
|
|
4070
|
+
* The session URI is single-use: redeeming it twice, or after it expires,
|
|
4071
|
+
* fails with a 404 from the API.
|
|
4072
|
+
*
|
|
4073
|
+
* @param {ConnectedAccountCompleteAuthParams} params - `userId` the connection was initiated for and the verifier's `sessionUri`
|
|
4074
|
+
* @returns {Promise<ConnectedAccountCompleteAuthResponse>} The completed connection's ID and toolkit
|
|
4075
|
+
* @throws {ValidationError} If the params fail validation
|
|
4076
|
+
*
|
|
4077
|
+
* @example
|
|
4078
|
+
* ```typescript
|
|
4079
|
+
* // In your verifier route, after authenticating the user:
|
|
4080
|
+
* const { connectedAccountId, toolkitSlug } = await composio.connectedAccounts.completeAuth({
|
|
4081
|
+
* userId: 'user_123',
|
|
4082
|
+
* sessionUri, // the session URI from the verifier redirect
|
|
4083
|
+
* });
|
|
4084
|
+
* ```
|
|
4085
|
+
*/
|
|
4086
|
+
async completeAuth(params, requestOptions) {
|
|
4087
|
+
const parsedParams = ConnectedAccountCompleteAuthParamsSchema.safeParse(params);
|
|
4088
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse connected account completeAuth params", { cause: parsedParams.error });
|
|
4089
|
+
const result = await withCancellation(() => this.client.connectedAccounts.completeAuth({
|
|
4090
|
+
user_id: parsedParams.data.userId,
|
|
4091
|
+
session_uri: parsedParams.data.sessionUri
|
|
4092
|
+
}, requestOptions), requestOptions?.signal);
|
|
4093
|
+
return transformConnectedAccountCompleteAuthResponse(result);
|
|
4094
|
+
}
|
|
4095
|
+
/**
|
|
3384
4096
|
* Update the status of a connected account
|
|
3385
4097
|
* @param {string} nanoid - Unique identifier of the connected account
|
|
3386
4098
|
* @param {ConnectedAccountUpdateStatusParams} params - Parameters for updating the status
|
|
@@ -3504,7 +4216,8 @@ const transformToolkitAuthField = (field) => ({
|
|
|
3504
4216
|
required: field.required,
|
|
3505
4217
|
...field.default !== void 0 && { default: field.default },
|
|
3506
4218
|
...field.is_secret !== void 0 && { isSecret: field.is_secret },
|
|
3507
|
-
...field.legacy_template_name !== void 0 && { legacyTemplateName: field.legacy_template_name }
|
|
4219
|
+
...field.legacy_template_name !== void 0 && { legacyTemplateName: field.legacy_template_name },
|
|
4220
|
+
...field.user_visible !== void 0 && { userVisible: field.user_visible }
|
|
3508
4221
|
});
|
|
3509
4222
|
/**
|
|
3510
4223
|
* Normalize one field group to empty lists when the API omits it, the way this
|
|
@@ -3522,6 +4235,10 @@ const transformToolkitAuthFieldGroup = (group) => ({
|
|
|
3522
4235
|
required: (group?.required ?? []).map(transformToolkitAuthField),
|
|
3523
4236
|
optional: (group?.optional ?? []).map(transformToolkitAuthField)
|
|
3524
4237
|
});
|
|
4238
|
+
/**
|
|
4239
|
+
* `GET /toolkits` and `POST /toolkits/multi` return the same item shape; the
|
|
4240
|
+
* generated client only names them differently per operation.
|
|
4241
|
+
*/
|
|
3525
4242
|
const transformToolkitListResponse = (response) => {
|
|
3526
4243
|
return transform(response).with(ToolKitListResponseSchema).using((response) => response.items.map((item) => ({
|
|
3527
4244
|
name: item.name,
|
|
@@ -3568,6 +4285,7 @@ const transformToolkitRetrieveResponse = (response) => {
|
|
|
3568
4285
|
name: authConfig.name,
|
|
3569
4286
|
mode: authConfig.mode,
|
|
3570
4287
|
...authConfig.auth_hint_url !== void 0 && { authHintUrl: authConfig.auth_hint_url },
|
|
4288
|
+
...authConfig.required_scopes !== void 0 && { requiredScopes: authConfig.required_scopes },
|
|
3571
4289
|
fields: {
|
|
3572
4290
|
authConfigCreation: transformToolkitAuthFieldGroup(authConfig.fields?.auth_config_creation),
|
|
3573
4291
|
connectedAccountInitiation: transformToolkitAuthFieldGroup(authConfig.fields?.connected_account_initiation)
|
|
@@ -3579,6 +4297,17 @@ const transformToolkitRetrieveResponse = (response) => {
|
|
|
3579
4297
|
getCurrentUserEndpointMethod: response.get_current_user_endpoint_method
|
|
3580
4298
|
}));
|
|
3581
4299
|
};
|
|
4300
|
+
const transformToolkitChangelogResponse = (response) => {
|
|
4301
|
+
return transform(response).with(ToolkitChangelogResponseSchema).using((response) => ({ items: response.items.map((item) => ({
|
|
4302
|
+
slug: item.slug,
|
|
4303
|
+
name: item.name,
|
|
4304
|
+
displayName: item.display_name,
|
|
4305
|
+
versions: item.versions.map((version) => ({
|
|
4306
|
+
version: version.version,
|
|
4307
|
+
changelog: version.changelog
|
|
4308
|
+
}))
|
|
4309
|
+
})) }));
|
|
4310
|
+
};
|
|
3582
4311
|
const transformToolkitRetrieveCategoriesResponse = (response) => {
|
|
3583
4312
|
return transform(response).with(ToolkitRetrieveCategoriesResponseSchema).using((response) => ({
|
|
3584
4313
|
items: response.items.map((item) => ({
|
|
@@ -3589,12 +4318,53 @@ const transformToolkitRetrieveCategoriesResponse = (response) => {
|
|
|
3589
4318
|
totalPages: response.total_pages
|
|
3590
4319
|
}));
|
|
3591
4320
|
};
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
4321
|
+
const transformToolkitRecommendScopesParams = (params) => ({
|
|
4322
|
+
tools: params.tools,
|
|
4323
|
+
auth_scheme: params.authScheme,
|
|
4324
|
+
toolkit_version: params.toolkitVersion,
|
|
4325
|
+
grant_context: params.grantContext,
|
|
4326
|
+
include: params.include,
|
|
4327
|
+
exclude: params.exclude,
|
|
4328
|
+
available_scopes: params.availableScopes
|
|
4329
|
+
});
|
|
4330
|
+
const transformToolkitRecommendScopesResponse = (response) => {
|
|
4331
|
+
return transform(response).with(ToolkitRecommendScopesResponseSchema).using((response) => ({
|
|
4332
|
+
authScheme: response.auth_scheme,
|
|
4333
|
+
toolkitVersion: response.toolkit_version,
|
|
4334
|
+
grantContext: response.grant_context,
|
|
4335
|
+
scopes: {
|
|
4336
|
+
leastPrivilege: response.scopes.least_privilege,
|
|
4337
|
+
fewest: response.scopes.fewest,
|
|
4338
|
+
conditional: response.scopes.conditional.map((condition) => ({
|
|
4339
|
+
scope: condition.scope,
|
|
4340
|
+
when: condition.when,
|
|
4341
|
+
for: condition.for
|
|
4342
|
+
}))
|
|
4343
|
+
}
|
|
4344
|
+
}));
|
|
4345
|
+
};
|
|
4346
|
+
const transformToolkitListGrantContextsParams = (params) => ({
|
|
4347
|
+
auth_scheme: params.authScheme,
|
|
4348
|
+
toolkit_version: params.toolkitVersion
|
|
4349
|
+
});
|
|
4350
|
+
const transformToolkitListGrantContextsResponse = (response) => {
|
|
4351
|
+
return transform(response).with(ToolkitListGrantContextsResponseSchema).using((response) => ({
|
|
4352
|
+
authScheme: response.auth_scheme,
|
|
4353
|
+
toolkitVersion: response.toolkit_version,
|
|
4354
|
+
grantContextDimensions: response.grant_context_dimensions.map((dimension) => ({
|
|
4355
|
+
dimension: dimension.dimension,
|
|
4356
|
+
description: dimension.description,
|
|
4357
|
+
values: dimension.values
|
|
4358
|
+
})),
|
|
4359
|
+
defaultGrantContext: response.default_grant_context
|
|
4360
|
+
}));
|
|
4361
|
+
};
|
|
4362
|
+
|
|
4363
|
+
//#endregion
|
|
4364
|
+
//#region src/models/Toolkits.ts
|
|
4365
|
+
/**
|
|
4366
|
+
* Toolkits class
|
|
4367
|
+
*
|
|
3598
4368
|
* Toolkits are a collection of tools that can be used to perform various tasks.
|
|
3599
4369
|
* This is similar/replacement of `apps` in the Composio API.
|
|
3600
4370
|
*/
|
|
@@ -3674,6 +4444,125 @@ var Toolkits = class {
|
|
|
3674
4444
|
if (typeof arg === "string") return this.getToolkitBySlug(arg, requestOptions);
|
|
3675
4445
|
return this.getToolkits(arg ?? {}, requestOptions);
|
|
3676
4446
|
}
|
|
4447
|
+
/**
|
|
4448
|
+
* Retrieves several toolkits by slug in a single request.
|
|
4449
|
+
*
|
|
4450
|
+
* Returns the same transformed shape as `composio.toolkits.get({ ... })`.
|
|
4451
|
+
* Unknown slugs are simply absent from the result.
|
|
4452
|
+
*
|
|
4453
|
+
* @param {string[]} slugs - The toolkit slugs to retrieve (at least one)
|
|
4454
|
+
* @param {ToolkitGetManyParams} [params] - Optional filters and pagination, as for `list`
|
|
4455
|
+
* @returns {Promise<ToolKitListResponse>} The matching toolkits
|
|
4456
|
+
* @throws {ValidationError} If `slugs` is empty or the params fail validation
|
|
4457
|
+
* @throws {ComposioToolkitFetchError} If the request fails
|
|
4458
|
+
*
|
|
4459
|
+
* @example
|
|
4460
|
+
* ```typescript
|
|
4461
|
+
* const toolkits = await composio.toolkits.getMany(['github', 'slack']);
|
|
4462
|
+
* console.log(toolkits.map(toolkit => toolkit.name)); // ['GitHub', 'Slack']
|
|
4463
|
+
* ```
|
|
4464
|
+
*/
|
|
4465
|
+
async getMany(slugs, params, requestOptions) {
|
|
4466
|
+
const parsedSlugs = ToolkitGetManySlugsSchema.safeParse(slugs);
|
|
4467
|
+
if (!parsedSlugs.success) throw new ValidationError("Failed to parse toolkit slugs", { cause: parsedSlugs.error });
|
|
4468
|
+
const parsedParams = ToolkitsGetManyParamsSchema.safeParse(params ?? {});
|
|
4469
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse toolkit getMany params", { cause: parsedParams.error });
|
|
4470
|
+
const body = {
|
|
4471
|
+
toolkits: parsedSlugs.data,
|
|
4472
|
+
category: parsedParams.data.category,
|
|
4473
|
+
managed_by: parsedParams.data.managedBy,
|
|
4474
|
+
sort_by: parsedParams.data.sortBy,
|
|
4475
|
+
cursor: parsedParams.data.cursor,
|
|
4476
|
+
limit: parsedParams.data.limit
|
|
4477
|
+
};
|
|
4478
|
+
try {
|
|
4479
|
+
const result = await withCancellation(() => this.client.toolkits.retrieveMulti(body, requestOptions), requestOptions?.signal);
|
|
4480
|
+
return transformToolkitListResponse(result);
|
|
4481
|
+
} catch (error) {
|
|
4482
|
+
if (error instanceof ComposioRequestCancelledError) throw error;
|
|
4483
|
+
throw new ComposioToolkitFetchError("Failed to fetch toolkits", {
|
|
4484
|
+
meta: { slugs: parsedSlugs.data },
|
|
4485
|
+
cause: error
|
|
4486
|
+
});
|
|
4487
|
+
}
|
|
4488
|
+
}
|
|
4489
|
+
/**
|
|
4490
|
+
* Retrieves the version changelog of every toolkit (the last 10 versions
|
|
4491
|
+
* per toolkit).
|
|
4492
|
+
*
|
|
4493
|
+
* @returns {Promise<ToolkitChangelogResponse>} Toolkits with their recent version changelogs
|
|
4494
|
+
*
|
|
4495
|
+
* @example
|
|
4496
|
+
* ```typescript
|
|
4497
|
+
* const { items } = await composio.toolkits.changelog();
|
|
4498
|
+
* const github = items.find(item => item.slug === 'github');
|
|
4499
|
+
* console.log(github?.versions[0]); // { version: '20250909_00', changelog: '...' }
|
|
4500
|
+
* ```
|
|
4501
|
+
*/
|
|
4502
|
+
async changelog(requestOptions) {
|
|
4503
|
+
const result = await withCancellation(() => this.client.toolkits.retrieveChangelog(requestOptions), requestOptions?.signal);
|
|
4504
|
+
return transformToolkitChangelogResponse(result);
|
|
4505
|
+
}
|
|
4506
|
+
/**
|
|
4507
|
+
* Recommends the OAuth scopes to request so a connection can run the given
|
|
4508
|
+
* tools.
|
|
4509
|
+
* **Experimental — the API marks this endpoint beta; shape may change.**
|
|
4510
|
+
*
|
|
4511
|
+
* The answer comes in two variants: `leastPrivilege` (narrowest documented
|
|
4512
|
+
* scope per requirement) and `fewest` (smallest set covering everything).
|
|
4513
|
+
* Pass `toolkitVersion` from a previous answer to pin the computation.
|
|
4514
|
+
*
|
|
4515
|
+
* @param {string} toolkitSlug - The toolkit to recommend scopes for
|
|
4516
|
+
* @param {ToolkitRecommendScopesParams} params - Tools to cover (`[]` for the whole toolkit), auth scheme, grant context and scope constraints
|
|
4517
|
+
* @returns {Promise<ToolkitRecommendScopesResponse>} The recommended scope sets
|
|
4518
|
+
* @throws {ValidationError} If the params fail validation
|
|
4519
|
+
*
|
|
4520
|
+
* @example
|
|
4521
|
+
* ```typescript
|
|
4522
|
+
* const { scopes } = await composio.toolkits.recommendScopes('gmail', {
|
|
4523
|
+
* tools: ['GMAIL_SEND_EMAIL', 'GMAIL_FETCH_EMAILS'],
|
|
4524
|
+
* });
|
|
4525
|
+
* console.log(scopes.leastPrivilege);
|
|
4526
|
+
* ```
|
|
4527
|
+
*/
|
|
4528
|
+
async recommendScopes(toolkitSlug, params, requestOptions) {
|
|
4529
|
+
const parsedParams = ToolkitRecommendScopesParamsSchema.safeParse(params);
|
|
4530
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse toolkit recommendScopes params", { cause: parsedParams.error });
|
|
4531
|
+
const body = transformToolkitRecommendScopesParams(parsedParams.data);
|
|
4532
|
+
const result = await withCancellation(() => this.client.toolkits.recommendScopes(toolkitSlug, body, requestOptions), requestOptions?.signal);
|
|
4533
|
+
return transformToolkitRecommendScopesResponse(result);
|
|
4534
|
+
}
|
|
4535
|
+
/**
|
|
4536
|
+
* Lists the grant-context dimensions a toolkit's scope recommendation
|
|
4537
|
+
* depends on (for example the Google account type), with their allowed
|
|
4538
|
+
* values and the default the API assumes.
|
|
4539
|
+
* **Experimental — the API marks this endpoint beta; shape may change.**
|
|
4540
|
+
*
|
|
4541
|
+
* Pass a dimension and a value as `grantContext` to
|
|
4542
|
+
* `composio.toolkits.recommendScopes()` to tailor the recommendation.
|
|
4543
|
+
*
|
|
4544
|
+
* @param {string} toolkitSlug - The toolkit to list grant contexts for
|
|
4545
|
+
* @param {ToolkitListGrantContextsParams} [params] - Optional auth scheme and toolkit version
|
|
4546
|
+
* @returns {Promise<ToolkitListGrantContextsResponse>} The dimensions and the default grant context
|
|
4547
|
+
* @throws {ValidationError} If the params fail validation
|
|
4548
|
+
*
|
|
4549
|
+
* @example
|
|
4550
|
+
* ```typescript
|
|
4551
|
+
* const { grantContextDimensions } = await composio.toolkits.listGrantContexts('gmail');
|
|
4552
|
+
* const [accountType] = grantContextDimensions;
|
|
4553
|
+
* const { scopes } = await composio.toolkits.recommendScopes('gmail', {
|
|
4554
|
+
* tools: ['GMAIL_SEND_EMAIL'],
|
|
4555
|
+
* grantContext: { [accountType.dimension]: accountType.values[0] },
|
|
4556
|
+
* });
|
|
4557
|
+
* ```
|
|
4558
|
+
*/
|
|
4559
|
+
async listGrantContexts(toolkitSlug, params, requestOptions) {
|
|
4560
|
+
const parsedParams = ToolkitListGrantContextsParamsSchema.safeParse(params ?? {});
|
|
4561
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse toolkit listGrantContexts params", { cause: parsedParams.error });
|
|
4562
|
+
const query = transformToolkitListGrantContextsParams(parsedParams.data);
|
|
4563
|
+
const result = await withCancellation(() => this.client.toolkits.retrieveScopesGrantContext(toolkitSlug, query, requestOptions), requestOptions?.signal);
|
|
4564
|
+
return transformToolkitListGrantContextsResponse(result);
|
|
4565
|
+
}
|
|
3677
4566
|
async getAuthConfigFields(toolkitSlug, authScheme, authConfigType, requiredOnly) {
|
|
3678
4567
|
const toolkit = await this.getToolkitBySlug(toolkitSlug);
|
|
3679
4568
|
if (!toolkit.authConfigDetails) throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", { meta: { toolkitSlug } });
|
|
@@ -3989,6 +4878,479 @@ const VerifyWebhookParamsSchema = z$1.object({
|
|
|
3989
4878
|
tolerance: z$1.number().optional().default(300)
|
|
3990
4879
|
});
|
|
3991
4880
|
|
|
4881
|
+
//#endregion
|
|
4882
|
+
//#region src/types/webhooks.types.ts
|
|
4883
|
+
/**
|
|
4884
|
+
* Webhook payload versions accepted by the webhook subscription endpoints.
|
|
4885
|
+
*/
|
|
4886
|
+
const WebhookVersionSchema = z$1.enum([
|
|
4887
|
+
"V1",
|
|
4888
|
+
"V2",
|
|
4889
|
+
"V3"
|
|
4890
|
+
]);
|
|
4891
|
+
/**
|
|
4892
|
+
* A project webhook subscription in the SDK's camelCase shape. The signing
|
|
4893
|
+
* `secret` is returned by the API on every subscription read/write.
|
|
4894
|
+
*/
|
|
4895
|
+
const WebhookSubscriptionSchema = z$1.object({
|
|
4896
|
+
id: z$1.string(),
|
|
4897
|
+
webhookUrl: z$1.string(),
|
|
4898
|
+
version: WebhookVersionSchema,
|
|
4899
|
+
enabledEvents: z$1.array(z$1.string()),
|
|
4900
|
+
secret: z$1.string().optional(),
|
|
4901
|
+
createdAt: z$1.string().optional(),
|
|
4902
|
+
updatedAt: z$1.string().optional()
|
|
4903
|
+
});
|
|
4904
|
+
const WebhookSubscriptionListParamsSchema = z$1.object({
|
|
4905
|
+
/** Number of items per page, max allowed is 50. */
|
|
4906
|
+
limit: z$1.number().optional(),
|
|
4907
|
+
/** Cursor for pagination, taken from a previous response's `nextCursor`. */
|
|
4908
|
+
cursor: z$1.string().optional()
|
|
4909
|
+
});
|
|
4910
|
+
const WebhookSubscriptionListResponseSchema = z$1.object({
|
|
4911
|
+
items: z$1.array(WebhookSubscriptionSchema),
|
|
4912
|
+
nextCursor: z$1.string().nullable(),
|
|
4913
|
+
totalPages: z$1.number(),
|
|
4914
|
+
currentPage: z$1.number(),
|
|
4915
|
+
totalItems: z$1.number()
|
|
4916
|
+
});
|
|
4917
|
+
/**
|
|
4918
|
+
* Params for `composio.webhooks.subscriptions.set()`. Identical to the
|
|
4919
|
+
* params accepted by `composio.triggers.setWebhookSubscription()`.
|
|
4920
|
+
*/
|
|
4921
|
+
const WebhookSubscriptionSetParamsSchema = SetWebhookSubscriptionParamsSchema;
|
|
4922
|
+
const WebhookSubscriptionUpdateParamsSchema = z$1.object({
|
|
4923
|
+
/** HTTPS URL to receive webhook events. */
|
|
4924
|
+
webhookUrl: z$1.string().min(1).optional(),
|
|
4925
|
+
/** Event types to subscribe to. */
|
|
4926
|
+
enabledEvents: z$1.array(z$1.string()).min(1).optional(),
|
|
4927
|
+
/** Webhook payload version. */
|
|
4928
|
+
version: WebhookVersionSchema.optional()
|
|
4929
|
+
});
|
|
4930
|
+
const WebhookSubscriptionDeleteResponseSchema = z$1.object({ success: z$1.boolean() });
|
|
4931
|
+
const WebhookSubscriptionRotateSecretResponseSchema = z$1.object({
|
|
4932
|
+
id: z$1.string(),
|
|
4933
|
+
/** The new signing secret. Store it — the previous secret stops validating. */
|
|
4934
|
+
secret: z$1.string()
|
|
4935
|
+
});
|
|
4936
|
+
const WebhookSubscriptionEventTypeSchema = z$1.object({
|
|
4937
|
+
eventType: z$1.string(),
|
|
4938
|
+
description: z$1.string(),
|
|
4939
|
+
supportedVersions: z$1.array(WebhookVersionSchema)
|
|
4940
|
+
});
|
|
4941
|
+
const WebhookSubscriptionEventTypesResponseSchema = z$1.object({ items: z$1.array(WebhookSubscriptionEventTypeSchema) });
|
|
4942
|
+
const WebhookEndpointListParamsSchema = z$1.object({
|
|
4943
|
+
/** Only return endpoints for this toolkit slug. */
|
|
4944
|
+
toolkitSlug: z$1.string().optional() });
|
|
4945
|
+
const WebhookEndpointListItemSchema = z$1.object({
|
|
4946
|
+
id: z$1.string(),
|
|
4947
|
+
toolkitSlug: z$1.string(),
|
|
4948
|
+
clientId: z$1.string().nullable()
|
|
4949
|
+
});
|
|
4950
|
+
const WebhookEndpointListResponseSchema = z$1.object({ items: z$1.array(WebhookEndpointListItemSchema) });
|
|
4951
|
+
const WebhookEndpointSchema = z$1.object({
|
|
4952
|
+
id: z$1.string(),
|
|
4953
|
+
toolkitSlug: z$1.string(),
|
|
4954
|
+
clientId: z$1.string().nullable(),
|
|
4955
|
+
/** The inbound URL to register with the third-party provider. */
|
|
4956
|
+
webhookUrl: z$1.string(),
|
|
4957
|
+
/** Configured setup fields with secret values masked. */
|
|
4958
|
+
data: z$1.record(z$1.string(), z$1.string()).nullable(),
|
|
4959
|
+
createdAt: z$1.string()
|
|
4960
|
+
});
|
|
4961
|
+
const WebhookEndpointCreateParamsSchema = z$1.object({
|
|
4962
|
+
/** Toolkit identifier (e.g. `slack`, `discord`). */
|
|
4963
|
+
toolkitSlug: z$1.string().min(1),
|
|
4964
|
+
/** OAuth app client ID — identifies which app this endpoint is for. */
|
|
4965
|
+
clientId: z$1.string().min(1)
|
|
4966
|
+
});
|
|
4967
|
+
const WebhookEndpointReplaceParamsSchema = z$1.object({
|
|
4968
|
+
/** Key-value pairs for ALL required setup fields of the toolkit. */
|
|
4969
|
+
data: z$1.record(z$1.string(), z$1.string()) });
|
|
4970
|
+
const WebhookEndpointUpdateParamsSchema = z$1.object({
|
|
4971
|
+
/** Key-value pairs to merge into the setup fields. Omitted fields are preserved. */
|
|
4972
|
+
data: z$1.record(z$1.string(), z$1.string()) });
|
|
4973
|
+
|
|
4974
|
+
//#endregion
|
|
4975
|
+
//#region src/utils/transformers/webhooks.ts
|
|
4976
|
+
const transformWebhookSubscription = (response) => {
|
|
4977
|
+
return transform(response).with(WebhookSubscriptionSchema).using((response) => ({
|
|
4978
|
+
id: response.id,
|
|
4979
|
+
webhookUrl: response.webhook_url,
|
|
4980
|
+
version: response.version,
|
|
4981
|
+
enabledEvents: response.enabled_events,
|
|
4982
|
+
secret: response.secret,
|
|
4983
|
+
createdAt: response.created_at,
|
|
4984
|
+
updatedAt: response.updated_at
|
|
4985
|
+
}));
|
|
4986
|
+
};
|
|
4987
|
+
const transformWebhookSubscriptionListResponse = (response) => {
|
|
4988
|
+
return transform(response).with(WebhookSubscriptionListResponseSchema).using((response) => ({
|
|
4989
|
+
items: response.items.map(transformWebhookSubscription),
|
|
4990
|
+
nextCursor: response.next_cursor ?? null,
|
|
4991
|
+
totalPages: response.total_pages,
|
|
4992
|
+
currentPage: response.current_page,
|
|
4993
|
+
totalItems: response.total_items
|
|
4994
|
+
}));
|
|
4995
|
+
};
|
|
4996
|
+
const transformWebhookSubscriptionDeleteResponse = (response) => {
|
|
4997
|
+
return transform(response).with(WebhookSubscriptionDeleteResponseSchema).using((response) => ({ success: response.success }));
|
|
4998
|
+
};
|
|
4999
|
+
const transformWebhookSubscriptionRotateSecretResponse = (response) => {
|
|
5000
|
+
return transform(response).with(WebhookSubscriptionRotateSecretResponseSchema).using((response) => ({
|
|
5001
|
+
id: response.id,
|
|
5002
|
+
secret: response.secret
|
|
5003
|
+
}));
|
|
5004
|
+
};
|
|
5005
|
+
const transformWebhookSubscriptionEventTypesResponse = (response) => {
|
|
5006
|
+
return transform(response).with(WebhookSubscriptionEventTypesResponseSchema).using((response) => ({ items: response.items.map((item) => ({
|
|
5007
|
+
eventType: item.event_type,
|
|
5008
|
+
description: item.description,
|
|
5009
|
+
supportedVersions: item.supported_versions
|
|
5010
|
+
})) }));
|
|
5011
|
+
};
|
|
5012
|
+
const transformWebhookEndpoint = (response) => {
|
|
5013
|
+
return transform(response).with(WebhookEndpointSchema).using((response) => ({
|
|
5014
|
+
id: response.id,
|
|
5015
|
+
toolkitSlug: response.toolkit_slug,
|
|
5016
|
+
clientId: response.client_id,
|
|
5017
|
+
webhookUrl: response.webhook_url,
|
|
5018
|
+
data: response.data,
|
|
5019
|
+
createdAt: response.created_at
|
|
5020
|
+
}));
|
|
5021
|
+
};
|
|
5022
|
+
const transformWebhookEndpointListResponse = (response) => {
|
|
5023
|
+
return transform(response).with(WebhookEndpointListResponseSchema).using((response) => ({ items: response.items.map((item) => ({
|
|
5024
|
+
id: item.id,
|
|
5025
|
+
toolkitSlug: item.toolkit_slug,
|
|
5026
|
+
clientId: item.client_id
|
|
5027
|
+
})) }));
|
|
5028
|
+
};
|
|
5029
|
+
|
|
5030
|
+
//#endregion
|
|
5031
|
+
//#region src/models/Webhooks.ts
|
|
5032
|
+
/**
|
|
5033
|
+
* The only part of the `list({ limit: 1 })` probe the upsert needs: the id of
|
|
5034
|
+
* the first (and, since the API allows one subscription per project, only)
|
|
5035
|
+
* subscription. Parsed at the boundary so a malformed payload never reaches
|
|
5036
|
+
* the update path.
|
|
5037
|
+
*/
|
|
5038
|
+
const FirstWebhookSubscriptionIdSchema = z$1.object({ items: z$1.array(z$1.object({ id: z$1.string().min(1) }).passthrough()) }).passthrough().transform((response) => response.items[0]?.id);
|
|
5039
|
+
/**
|
|
5040
|
+
* Create-or-update the project webhook subscription.
|
|
5041
|
+
*
|
|
5042
|
+
* Shared by `composio.webhooks.subscriptions.set()` and the legacy
|
|
5043
|
+
* `composio.triggers.setWebhookSubscription()` so both issue the exact same
|
|
5044
|
+
* call sequence: `webhookSubscriptions.list({ limit: 1 })`, then
|
|
5045
|
+
* `webhookSubscriptions.update(id, body)` when a subscription exists,
|
|
5046
|
+
* otherwise `webhookSubscriptions.create(body)`.
|
|
5047
|
+
*
|
|
5048
|
+
* @internal
|
|
5049
|
+
*/
|
|
5050
|
+
async function upsertWebhookSubscription(client, params, requestOptions) {
|
|
5051
|
+
const parsedParams = WebhookSubscriptionSetParamsSchema.safeParse(params);
|
|
5052
|
+
if (!parsedParams.success) throw new ValidationError(`Invalid parameters passed to set webhook subscription`, { cause: parsedParams.error });
|
|
5053
|
+
const body = {
|
|
5054
|
+
webhook_url: parsedParams.data.webhookUrl,
|
|
5055
|
+
enabled_events: parsedParams.data.enabledEvents ?? [...DefaultWebhookSubscriptionEvents],
|
|
5056
|
+
version: parsedParams.data.version ?? WebhookVersions.V3
|
|
5057
|
+
};
|
|
5058
|
+
const existing = await withCancellation(() => client.webhookSubscriptions.list({ limit: 1 }, requestOptions), requestOptions?.signal);
|
|
5059
|
+
const parsedExisting = FirstWebhookSubscriptionIdSchema.safeParse(existing);
|
|
5060
|
+
if (!parsedExisting.success) throw new ValidationError("Failed to parse webhook subscription list response", { cause: parsedExisting.error });
|
|
5061
|
+
const subscriptionId = parsedExisting.data;
|
|
5062
|
+
const subscription = await withCancellation(() => subscriptionId ? client.webhookSubscriptions.update(subscriptionId, body, requestOptions) : client.webhookSubscriptions.create(body, requestOptions), requestOptions?.signal);
|
|
5063
|
+
return transformWebhookSubscription(subscription);
|
|
5064
|
+
}
|
|
5065
|
+
/**
|
|
5066
|
+
* `composio.webhooks.subscriptions` — the project's outbound webhook
|
|
5067
|
+
* subscription. The API allows one subscription per project; every response
|
|
5068
|
+
* includes the signing `secret` used to verify deliveries with
|
|
5069
|
+
* `composio.triggers.verifyWebhook()` / `composio.triggers.parse()`.
|
|
5070
|
+
*/
|
|
5071
|
+
var WebhookSubscriptions = class {
|
|
5072
|
+
client;
|
|
5073
|
+
constructor(client) {
|
|
5074
|
+
this.client = client;
|
|
5075
|
+
telemetry.instrument(this, "WebhookSubscriptions");
|
|
5076
|
+
}
|
|
5077
|
+
/**
|
|
5078
|
+
* List the project's webhook subscriptions.
|
|
5079
|
+
*
|
|
5080
|
+
* @param {WebhookSubscriptionListParams} [query] - Pagination options
|
|
5081
|
+
* @returns {Promise<WebhookSubscriptionListResponse>} Paginated subscriptions
|
|
5082
|
+
*
|
|
5083
|
+
* @example
|
|
5084
|
+
* ```typescript
|
|
5085
|
+
* const { items } = await composio.webhooks.subscriptions.list();
|
|
5086
|
+
* console.log(items[0]?.webhookUrl);
|
|
5087
|
+
* ```
|
|
5088
|
+
*/
|
|
5089
|
+
async list(query, requestOptions) {
|
|
5090
|
+
const parsedQuery = WebhookSubscriptionListParamsSchema.safeParse(query ?? {});
|
|
5091
|
+
if (!parsedQuery.success) throw new ValidationError("Failed to parse webhook subscription list query", { cause: parsedQuery.error });
|
|
5092
|
+
const listParams = {
|
|
5093
|
+
limit: parsedQuery.data.limit,
|
|
5094
|
+
cursor: parsedQuery.data.cursor
|
|
5095
|
+
};
|
|
5096
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.list(listParams, requestOptions), requestOptions?.signal);
|
|
5097
|
+
return transformWebhookSubscriptionListResponse(result);
|
|
5098
|
+
}
|
|
5099
|
+
/**
|
|
5100
|
+
* Retrieve a webhook subscription by id.
|
|
5101
|
+
*
|
|
5102
|
+
* @param {string} id - The subscription id
|
|
5103
|
+
* @returns {Promise<WebhookSubscription>} The subscription, including its signing secret
|
|
5104
|
+
*
|
|
5105
|
+
* @example
|
|
5106
|
+
* ```typescript
|
|
5107
|
+
* const subscription = await composio.webhooks.subscriptions.get('whs_abc123');
|
|
5108
|
+
* console.log(subscription.enabledEvents);
|
|
5109
|
+
* ```
|
|
5110
|
+
*/
|
|
5111
|
+
async get(id, requestOptions) {
|
|
5112
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.retrieve(id, requestOptions), requestOptions?.signal);
|
|
5113
|
+
return transformWebhookSubscription(result);
|
|
5114
|
+
}
|
|
5115
|
+
/**
|
|
5116
|
+
* Create or update the project webhook subscription.
|
|
5117
|
+
*
|
|
5118
|
+
* If a subscription already exists it is updated in place, otherwise a new
|
|
5119
|
+
* one is created. By default this subscribes to V3 trigger message events.
|
|
5120
|
+
*
|
|
5121
|
+
* @param {WebhookSubscriptionSetParams} params - `webhookUrl`, optional `enabledEvents` and `version`
|
|
5122
|
+
* @returns {Promise<WebhookSubscription>} The resulting subscription
|
|
5123
|
+
* @throws {ValidationError} If the params fail validation
|
|
5124
|
+
*
|
|
5125
|
+
* @example
|
|
5126
|
+
* ```typescript
|
|
5127
|
+
* const subscription = await composio.webhooks.subscriptions.set({
|
|
5128
|
+
* webhookUrl: `${APP_URL}/webhooks/composio`,
|
|
5129
|
+
* enabledEvents: ['composio.trigger.message', 'composio.connected_account.expired'],
|
|
5130
|
+
* });
|
|
5131
|
+
* process.env.COMPOSIO_WEBHOOK_SECRET = subscription.secret;
|
|
5132
|
+
* ```
|
|
5133
|
+
*/
|
|
5134
|
+
async set(params, requestOptions) {
|
|
5135
|
+
return upsertWebhookSubscription(this.client, params, requestOptions);
|
|
5136
|
+
}
|
|
5137
|
+
/**
|
|
5138
|
+
* Update an existing webhook subscription. Only the provided fields change.
|
|
5139
|
+
*
|
|
5140
|
+
* @param {string} id - The subscription id
|
|
5141
|
+
* @param {WebhookSubscriptionUpdateParams} params - Fields to update
|
|
5142
|
+
* @returns {Promise<WebhookSubscription>} The updated subscription
|
|
5143
|
+
* @throws {ValidationError} If the params fail validation
|
|
5144
|
+
*
|
|
5145
|
+
* @example
|
|
5146
|
+
* ```typescript
|
|
5147
|
+
* await composio.webhooks.subscriptions.update('whs_abc123', {
|
|
5148
|
+
* enabledEvents: ['composio.trigger.message'],
|
|
5149
|
+
* });
|
|
5150
|
+
* ```
|
|
5151
|
+
*/
|
|
5152
|
+
async update(id, params, requestOptions) {
|
|
5153
|
+
const parsedParams = WebhookSubscriptionUpdateParamsSchema.safeParse(params);
|
|
5154
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse webhook subscription update params", { cause: parsedParams.error });
|
|
5155
|
+
const body = {
|
|
5156
|
+
webhook_url: parsedParams.data.webhookUrl,
|
|
5157
|
+
enabled_events: parsedParams.data.enabledEvents,
|
|
5158
|
+
version: parsedParams.data.version
|
|
5159
|
+
};
|
|
5160
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.update(id, body, requestOptions), requestOptions?.signal);
|
|
5161
|
+
return transformWebhookSubscription(result);
|
|
5162
|
+
}
|
|
5163
|
+
/**
|
|
5164
|
+
* Delete a webhook subscription. Deliveries stop immediately.
|
|
5165
|
+
*
|
|
5166
|
+
* @param {string} id - The subscription id
|
|
5167
|
+
* @returns {Promise<WebhookSubscriptionDeleteResponse>} `{ success }`
|
|
5168
|
+
*
|
|
5169
|
+
* @example
|
|
5170
|
+
* ```typescript
|
|
5171
|
+
* await composio.webhooks.subscriptions.delete('whs_abc123');
|
|
5172
|
+
* ```
|
|
5173
|
+
*/
|
|
5174
|
+
async delete(id, requestOptions) {
|
|
5175
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.delete(id, requestOptions), requestOptions?.signal);
|
|
5176
|
+
return transformWebhookSubscriptionDeleteResponse(result);
|
|
5177
|
+
}
|
|
5178
|
+
/**
|
|
5179
|
+
* Rotate the signing secret of a webhook subscription. The previous secret
|
|
5180
|
+
* stops validating, so update your verifier with the returned `secret`.
|
|
5181
|
+
*
|
|
5182
|
+
* @param {string} id - The subscription id
|
|
5183
|
+
* @returns {Promise<WebhookSubscriptionRotateSecretResponse>} `{ id, secret }`
|
|
5184
|
+
*
|
|
5185
|
+
* @example
|
|
5186
|
+
* ```typescript
|
|
5187
|
+
* const { secret } = await composio.webhooks.subscriptions.rotateSecret('whs_abc123');
|
|
5188
|
+
* ```
|
|
5189
|
+
*/
|
|
5190
|
+
async rotateSecret(id, requestOptions) {
|
|
5191
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.rotateSecret(id, requestOptions), requestOptions?.signal);
|
|
5192
|
+
return transformWebhookSubscriptionRotateSecretResponse(result);
|
|
5193
|
+
}
|
|
5194
|
+
/**
|
|
5195
|
+
* List the event types a subscription can enable, with the payload
|
|
5196
|
+
* versions each one supports.
|
|
5197
|
+
*
|
|
5198
|
+
* @returns {Promise<WebhookSubscriptionEventTypesResponse>} The available event types
|
|
5199
|
+
*
|
|
5200
|
+
* @example
|
|
5201
|
+
* ```typescript
|
|
5202
|
+
* const { items } = await composio.webhooks.subscriptions.listEventTypes();
|
|
5203
|
+
* console.log(items.map(item => item.eventType));
|
|
5204
|
+
* ```
|
|
5205
|
+
*/
|
|
5206
|
+
async listEventTypes(requestOptions) {
|
|
5207
|
+
const result = await withCancellation(() => this.client.webhookSubscriptions.listEventTypes(requestOptions), requestOptions?.signal);
|
|
5208
|
+
return transformWebhookSubscriptionEventTypesResponse(result);
|
|
5209
|
+
}
|
|
5210
|
+
};
|
|
5211
|
+
/**
|
|
5212
|
+
* `composio.webhooks.endpoints` — inbound webhook endpoints. Each endpoint is
|
|
5213
|
+
* the ingress URL Composio exposes for one toolkit + OAuth app pair, which you
|
|
5214
|
+
* register with the third-party provider so it can push events to Composio.
|
|
5215
|
+
*/
|
|
5216
|
+
var WebhookEndpoints = class {
|
|
5217
|
+
client;
|
|
5218
|
+
constructor(client) {
|
|
5219
|
+
this.client = client;
|
|
5220
|
+
telemetry.instrument(this, "WebhookEndpoints");
|
|
5221
|
+
}
|
|
5222
|
+
/**
|
|
5223
|
+
* List webhook endpoints, optionally filtered by toolkit.
|
|
5224
|
+
*
|
|
5225
|
+
* @param {WebhookEndpointListParams} [query] - Optional `toolkitSlug` filter
|
|
5226
|
+
* @returns {Promise<WebhookEndpointListResponse>} The endpoints
|
|
5227
|
+
*
|
|
5228
|
+
* @example
|
|
5229
|
+
* ```typescript
|
|
5230
|
+
* const { items } = await composio.webhooks.endpoints.list({ toolkitSlug: 'slack' });
|
|
5231
|
+
* ```
|
|
5232
|
+
*/
|
|
5233
|
+
async list(query, requestOptions) {
|
|
5234
|
+
const parsedQuery = WebhookEndpointListParamsSchema.safeParse(query ?? {});
|
|
5235
|
+
if (!parsedQuery.success) throw new ValidationError("Failed to parse webhook endpoint list query", { cause: parsedQuery.error });
|
|
5236
|
+
const listParams = { toolkit_slug: parsedQuery.data.toolkitSlug };
|
|
5237
|
+
const result = await withCancellation(() => this.client.webhookEndpoints.list(listParams, requestOptions), requestOptions?.signal);
|
|
5238
|
+
return transformWebhookEndpointListResponse(result);
|
|
5239
|
+
}
|
|
5240
|
+
/**
|
|
5241
|
+
* Retrieve a webhook endpoint by its nano id.
|
|
5242
|
+
*
|
|
5243
|
+
* @param {string} nanoId - The endpoint nano id (e.g. `we_abc123`)
|
|
5244
|
+
* @returns {Promise<WebhookEndpoint>} The endpoint, with secret setup values masked
|
|
5245
|
+
*
|
|
5246
|
+
* @example
|
|
5247
|
+
* ```typescript
|
|
5248
|
+
* const endpoint = await composio.webhooks.endpoints.get('we_abc123');
|
|
5249
|
+
* console.log(endpoint.webhookUrl);
|
|
5250
|
+
* ```
|
|
5251
|
+
*/
|
|
5252
|
+
async get(nanoId, requestOptions) {
|
|
5253
|
+
const result = await withCancellation(() => this.client.webhookEndpoints.retrieve(nanoId, requestOptions), requestOptions?.signal);
|
|
5254
|
+
return transformWebhookEndpoint(result);
|
|
5255
|
+
}
|
|
5256
|
+
/**
|
|
5257
|
+
* Create a webhook endpoint for a toolkit + OAuth app pair. Returns the
|
|
5258
|
+
* existing endpoint when one already exists for that pair.
|
|
5259
|
+
*
|
|
5260
|
+
* @param {WebhookEndpointCreateParams} params - `toolkitSlug` and `clientId`
|
|
5261
|
+
* @returns {Promise<WebhookEndpoint>} The endpoint; register `webhookUrl` with the provider
|
|
5262
|
+
* @throws {ValidationError} If the params fail validation
|
|
5263
|
+
*
|
|
5264
|
+
* @example
|
|
5265
|
+
* ```typescript
|
|
5266
|
+
* const endpoint = await composio.webhooks.endpoints.create({
|
|
5267
|
+
* toolkitSlug: 'slack',
|
|
5268
|
+
* clientId: 'my-slack-app-client-id',
|
|
5269
|
+
* });
|
|
5270
|
+
* ```
|
|
5271
|
+
*/
|
|
5272
|
+
async create(params, requestOptions) {
|
|
5273
|
+
const parsedParams = WebhookEndpointCreateParamsSchema.safeParse(params);
|
|
5274
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse webhook endpoint create params", { cause: parsedParams.error });
|
|
5275
|
+
const body = {
|
|
5276
|
+
toolkit_slug: parsedParams.data.toolkitSlug,
|
|
5277
|
+
client_id: parsedParams.data.clientId
|
|
5278
|
+
};
|
|
5279
|
+
const result = await withCancellation(() => this.client.webhookEndpoints.create(body, requestOptions), requestOptions?.signal);
|
|
5280
|
+
return transformWebhookEndpoint(result);
|
|
5281
|
+
}
|
|
5282
|
+
/**
|
|
5283
|
+
* Replace the setup fields of a webhook endpoint. All required setup fields
|
|
5284
|
+
* for the toolkit must be provided — this is the initial configuration.
|
|
5285
|
+
*
|
|
5286
|
+
* @param {string} nanoId - The endpoint nano id
|
|
5287
|
+
* @param {WebhookEndpointReplaceParams} params - `data` with every required setup field
|
|
5288
|
+
* @returns {Promise<WebhookEndpoint>} The configured endpoint
|
|
5289
|
+
* @throws {ValidationError} If the params fail validation
|
|
5290
|
+
*
|
|
5291
|
+
* @example
|
|
5292
|
+
* ```typescript
|
|
5293
|
+
* await composio.webhooks.endpoints.replace('we_abc123', {
|
|
5294
|
+
* data: { signing_secret: process.env.SLACK_SIGNING_SECRET! },
|
|
5295
|
+
* });
|
|
5296
|
+
* ```
|
|
5297
|
+
*/
|
|
5298
|
+
async replace(nanoId, params, requestOptions) {
|
|
5299
|
+
const parsedParams = WebhookEndpointReplaceParamsSchema.safeParse(params);
|
|
5300
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse webhook endpoint replace params", { cause: parsedParams.error });
|
|
5301
|
+
const result = await withCancellation(() => this.client.webhookEndpoints.replace(nanoId, { data: parsedParams.data.data }, requestOptions), requestOptions?.signal);
|
|
5302
|
+
return transformWebhookEndpoint(result);
|
|
5303
|
+
}
|
|
5304
|
+
/**
|
|
5305
|
+
* Merge setup fields into a webhook endpoint. Omitted fields are preserved.
|
|
5306
|
+
*
|
|
5307
|
+
* @param {string} nanoId - The endpoint nano id
|
|
5308
|
+
* @param {WebhookEndpointUpdateParams} params - `data` with the fields to change
|
|
5309
|
+
* @returns {Promise<WebhookEndpoint>} The updated endpoint
|
|
5310
|
+
* @throws {ValidationError} If the params fail validation
|
|
5311
|
+
*
|
|
5312
|
+
* @example
|
|
5313
|
+
* ```typescript
|
|
5314
|
+
* await composio.webhooks.endpoints.update('we_abc123', {
|
|
5315
|
+
* data: { signing_secret: 'rotated-secret' },
|
|
5316
|
+
* });
|
|
5317
|
+
* ```
|
|
5318
|
+
*/
|
|
5319
|
+
async update(nanoId, params, requestOptions) {
|
|
5320
|
+
const parsedParams = WebhookEndpointUpdateParamsSchema.safeParse(params);
|
|
5321
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse webhook endpoint update params", { cause: parsedParams.error });
|
|
5322
|
+
const result = await withCancellation(() => this.client.webhookEndpoints.update(nanoId, { data: parsedParams.data.data }, requestOptions), requestOptions?.signal);
|
|
5323
|
+
return transformWebhookEndpoint(result);
|
|
5324
|
+
}
|
|
5325
|
+
};
|
|
5326
|
+
/**
|
|
5327
|
+
* `composio.webhooks` namespace.
|
|
5328
|
+
*
|
|
5329
|
+
* - `subscriptions`: the project's outbound webhook subscription (where
|
|
5330
|
+
* Composio delivers trigger and lifecycle events).
|
|
5331
|
+
* - `endpoints`: inbound ingress URLs for third-party providers, one per
|
|
5332
|
+
* toolkit + OAuth app pair.
|
|
5333
|
+
*
|
|
5334
|
+
* @example
|
|
5335
|
+
* ```typescript
|
|
5336
|
+
* const subscription = await composio.webhooks.subscriptions.set({
|
|
5337
|
+
* webhookUrl: 'https://example.com/webhooks/composio',
|
|
5338
|
+
* });
|
|
5339
|
+
* const endpoints = await composio.webhooks.endpoints.list({ toolkitSlug: 'slack' });
|
|
5340
|
+
* ```
|
|
5341
|
+
*/
|
|
5342
|
+
var Webhooks = class {
|
|
5343
|
+
/** Manage the project's outbound webhook subscription. */
|
|
5344
|
+
subscriptions;
|
|
5345
|
+
/** Manage inbound webhook endpoints per toolkit + OAuth app. */
|
|
5346
|
+
endpoints;
|
|
5347
|
+
constructor(client) {
|
|
5348
|
+
this.subscriptions = new WebhookSubscriptions(client);
|
|
5349
|
+
this.endpoints = new WebhookEndpoints(client);
|
|
5350
|
+
telemetry.instrument(this, "Webhooks");
|
|
5351
|
+
}
|
|
5352
|
+
};
|
|
5353
|
+
|
|
3992
5354
|
//#endregion
|
|
3993
5355
|
//#region src/services/internal/InternalService.types.ts
|
|
3994
5356
|
const SDKRealtimeCredentialsResponseSchema = z$1.object({
|
|
@@ -4026,6 +5388,290 @@ var InternalService = class {
|
|
|
4026
5388
|
}
|
|
4027
5389
|
};
|
|
4028
5390
|
|
|
5391
|
+
//#endregion
|
|
5392
|
+
//#region src/utils/sdk.ts
|
|
5393
|
+
/**
|
|
5394
|
+
* Header that carries a Composio user API key (`uak_...`) instead of a project
|
|
5395
|
+
* API key. It is the only default header the credential resolver reads.
|
|
5396
|
+
*/
|
|
5397
|
+
const USER_API_KEY_HEADER = "x-user-api-key";
|
|
5398
|
+
/** Prefix of Composio user API keys as issued by `composio login`. */
|
|
5399
|
+
const USER_API_KEY_PREFIX = "uak_";
|
|
5400
|
+
/**
|
|
5401
|
+
* Header that carries the project API key. The SDK only ever sets it from the
|
|
5402
|
+
* resolved `apiKey`; a caller-placed entry in `defaultHeaders` is rejected
|
|
5403
|
+
* when project-key auth is disabled.
|
|
5404
|
+
*/
|
|
5405
|
+
const PROJECT_API_KEY_HEADER = "x-api-key";
|
|
5406
|
+
/** Header carrying the organization nano ID that scopes user-key requests. */
|
|
5407
|
+
const ORG_ID_HEADER = "x-org-id";
|
|
5408
|
+
/** Header carrying the project nano ID that scopes user-key requests. */
|
|
5409
|
+
const PROJECT_ID_HEADER = "x-project-id";
|
|
5410
|
+
const userDataPath = () => {
|
|
5411
|
+
try {
|
|
5412
|
+
const homeDir = platform.homedir();
|
|
5413
|
+
if (!homeDir) return null;
|
|
5414
|
+
return platform.joinPath(homeDir, COMPOSIO_DIR, USER_DATA_FILE_NAME);
|
|
5415
|
+
} catch (_error) {
|
|
5416
|
+
logger.debug("Environment", `Unable to get user data path`);
|
|
5417
|
+
return null;
|
|
5418
|
+
}
|
|
5419
|
+
};
|
|
5420
|
+
/**
|
|
5421
|
+
* Shape of `~/.composio/user_data.json`. The file is written by the Composio
|
|
5422
|
+
* CLI; only the two fields the SDK consumes are validated, everything else is
|
|
5423
|
+
* carried through untouched.
|
|
5424
|
+
*/
|
|
5425
|
+
const UserDataFileSchema = z$1.object({
|
|
5426
|
+
api_key: z$1.string().nullish(),
|
|
5427
|
+
base_url: z$1.string().nullish()
|
|
5428
|
+
}).passthrough();
|
|
5429
|
+
/**
|
|
5430
|
+
* Reads and validates the user data JSON file from the Composio directory.
|
|
5431
|
+
* File contents never appear in the returned diagnostics.
|
|
5432
|
+
*/
|
|
5433
|
+
const readUserDataFile = () => {
|
|
5434
|
+
if (!platform.supportsFileSystem) return { status: "missing" };
|
|
5435
|
+
const dataPath = userDataPath();
|
|
5436
|
+
if (!dataPath) return { status: "missing" };
|
|
5437
|
+
let raw;
|
|
5438
|
+
try {
|
|
5439
|
+
raw = platform.readFileSync(dataPath, "utf8");
|
|
5440
|
+
} catch (_error) {
|
|
5441
|
+
logger.debug("Environment", "No user data file found");
|
|
5442
|
+
return { status: "missing" };
|
|
5443
|
+
}
|
|
5444
|
+
let json;
|
|
5445
|
+
try {
|
|
5446
|
+
json = JSON.parse(typeof raw === "string" ? raw : new TextDecoder().decode(raw));
|
|
5447
|
+
} catch (_error) {
|
|
5448
|
+
logger.debug("Environment", `User data file at ${dataPath} could not be parsed as JSON`);
|
|
5449
|
+
return {
|
|
5450
|
+
status: "malformed",
|
|
5451
|
+
path: dataPath,
|
|
5452
|
+
reason: "could not be parsed as JSON"
|
|
5453
|
+
};
|
|
5454
|
+
}
|
|
5455
|
+
const parsed = UserDataFileSchema.safeParse(json);
|
|
5456
|
+
if (!parsed.success) {
|
|
5457
|
+
const fields = parsed.error.issues.map((issue) => issue.path.join(".")).filter(Boolean).join(", ");
|
|
5458
|
+
const reason = fields ? `has an unexpected shape (invalid field${fields.includes(",") ? "s" : ""}: ${fields})` : "has an unexpected shape (expected a JSON object)";
|
|
5459
|
+
logger.debug("Environment", `User data file at ${dataPath} ${reason}`);
|
|
5460
|
+
return {
|
|
5461
|
+
status: "malformed",
|
|
5462
|
+
path: dataPath,
|
|
5463
|
+
reason
|
|
5464
|
+
};
|
|
5465
|
+
}
|
|
5466
|
+
return {
|
|
5467
|
+
status: "ok",
|
|
5468
|
+
path: dataPath,
|
|
5469
|
+
data: parsed.data
|
|
5470
|
+
};
|
|
5471
|
+
};
|
|
5472
|
+
const findHeader = (headers, name) => {
|
|
5473
|
+
if (!headers) return;
|
|
5474
|
+
const wanted = name.toLowerCase();
|
|
5475
|
+
for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === wanted) return {
|
|
5476
|
+
name: key,
|
|
5477
|
+
value
|
|
5478
|
+
};
|
|
5479
|
+
};
|
|
5480
|
+
/**
|
|
5481
|
+
* Returns the `x-user-api-key` entry from a header map, if it carries a
|
|
5482
|
+
* non-empty value. Matches the header name case-insensitively and ignores
|
|
5483
|
+
* every other header.
|
|
5484
|
+
*/
|
|
5485
|
+
const getUserApiKeyHeader = (headers) => {
|
|
5486
|
+
const header = findHeader(headers, USER_API_KEY_HEADER);
|
|
5487
|
+
return header && typeof header.value === "string" && header.value.length > 0 ? header : void 0;
|
|
5488
|
+
};
|
|
5489
|
+
/**
|
|
5490
|
+
* The single credential header that mirrors what the API client puts on the
|
|
5491
|
+
* wire for an SDK instance. A non-empty `x-user-api-key` entry in the default
|
|
5492
|
+
* headers wins: the client treats a caller-placed credential header as the
|
|
5493
|
+
* credential and suppresses the configured keys. Otherwise the project key
|
|
5494
|
+
* travels as `x-api-key`, otherwise the resolved user API key as
|
|
5495
|
+
* `x-user-api-key`. Empty when no credential is held. The environment is
|
|
5496
|
+
* never consulted here.
|
|
5497
|
+
*/
|
|
5498
|
+
const resolveCredentialHeaders = (input) => {
|
|
5499
|
+
const userApiKeyHeader = getUserApiKeyHeader(input.defaultHeaders);
|
|
5500
|
+
if (userApiKeyHeader) return { [USER_API_KEY_HEADER]: userApiKeyHeader.value };
|
|
5501
|
+
if (hasValue(input.apiKey)) return { [PROJECT_API_KEY_HEADER]: input.apiKey };
|
|
5502
|
+
if (hasValue(input.userApiKey)) return { [USER_API_KEY_HEADER]: input.userApiKey };
|
|
5503
|
+
return {};
|
|
5504
|
+
};
|
|
5505
|
+
const resolveScopeValue = (option, headers, headerName, optionName) => {
|
|
5506
|
+
const header = findHeader(headers, headerName);
|
|
5507
|
+
const headerValue = header && header.value.length > 0 ? header.value : void 0;
|
|
5508
|
+
const optionValue = hasValue(option) ? option : void 0;
|
|
5509
|
+
if (optionValue !== void 0 && headerValue !== void 0 && optionValue !== headerValue) throw new ComposioScopeConfigError(`\`${optionName}\` and the \`${headerName}\` default header disagree`, {
|
|
5510
|
+
cause: `The ${optionName} option and the ${headerName} entry in defaultHeaders carry different values; the SDK keeps a single scope source`,
|
|
5511
|
+
meta: {
|
|
5512
|
+
option: optionName,
|
|
5513
|
+
header: headerName
|
|
5514
|
+
}
|
|
5515
|
+
});
|
|
5516
|
+
return optionValue ?? headerValue;
|
|
5517
|
+
};
|
|
5518
|
+
/**
|
|
5519
|
+
* Resolves the organization/project scope of an SDK instance.
|
|
5520
|
+
*
|
|
5521
|
+
* The scope comes from the `orgId` / `projectId` options, or from the
|
|
5522
|
+
* `x-org-id` / `x-project-id` default headers when the options are omitted.
|
|
5523
|
+
* A value present in both places must agree, and the two IDs must be supplied
|
|
5524
|
+
* together: a user API key without an explicit scope keeps the API default
|
|
5525
|
+
* (the developer project), so a half-configured scope is rejected instead of
|
|
5526
|
+
* silently selecting a project.
|
|
5527
|
+
*/
|
|
5528
|
+
function resolveSDKScope(options) {
|
|
5529
|
+
const orgId = resolveScopeValue(options.orgId, options.defaultHeaders, ORG_ID_HEADER, "orgId");
|
|
5530
|
+
const projectId = resolveScopeValue(options.projectId, options.defaultHeaders, PROJECT_ID_HEADER, "projectId");
|
|
5531
|
+
if (orgId === void 0 !== (projectId === void 0)) throw new ComposioScopeConfigError(orgId === void 0 ? "`projectId` requires `orgId`: the organization and project nano IDs scope requests together" : "`orgId` requires `projectId`: the organization and project nano IDs scope requests together", {
|
|
5532
|
+
cause: "Only one of the two scope identifiers was configured",
|
|
5533
|
+
meta: {
|
|
5534
|
+
orgId: orgId !== void 0,
|
|
5535
|
+
projectId: projectId !== void 0
|
|
5536
|
+
}
|
|
5537
|
+
});
|
|
5538
|
+
return orgId === void 0 || projectId === void 0 ? {} : {
|
|
5539
|
+
orgId,
|
|
5540
|
+
projectId
|
|
5541
|
+
};
|
|
5542
|
+
}
|
|
5543
|
+
/** The `x-org-id` / `x-project-id` headers for a resolved scope. */
|
|
5544
|
+
const getScopeHeaders = (scope) => scope.orgId && scope.projectId ? {
|
|
5545
|
+
[ORG_ID_HEADER]: scope.orgId,
|
|
5546
|
+
[PROJECT_ID_HEADER]: scope.projectId
|
|
5547
|
+
} : {};
|
|
5548
|
+
const hasValue = (value) => typeof value === "string" && value.length > 0;
|
|
5549
|
+
/**
|
|
5550
|
+
* Mirrors how the API client resolves `userApiKey` / `orgApiKey`: an explicit
|
|
5551
|
+
* value (including `null`) is final, `undefined` falls back to the environment.
|
|
5552
|
+
*/
|
|
5553
|
+
const resolveAlternateCredential = (explicit, envName) => {
|
|
5554
|
+
if (explicit !== void 0) return hasValue(explicit) ? explicit : void 0;
|
|
5555
|
+
const fromEnv = getEnvVariable(envName);
|
|
5556
|
+
return hasValue(fromEnv) ? fromEnv : void 0;
|
|
5557
|
+
};
|
|
5558
|
+
/**
|
|
5559
|
+
* The user API key the API client will hold: the `userApiKey` option when it
|
|
5560
|
+
* was passed (including `null`, which disables the fallback), otherwise
|
|
5561
|
+
* `COMPOSIO_USER_API_KEY`.
|
|
5562
|
+
*/
|
|
5563
|
+
const resolveUserApiKey = (userApiKey) => resolveAlternateCredential(userApiKey, "COMPOSIO_USER_API_KEY");
|
|
5564
|
+
/**
|
|
5565
|
+
* Whether the instance holds a credential other than the project key: a user
|
|
5566
|
+
* or organization API key (explicit or environment-resolved, as the API client
|
|
5567
|
+
* will see it), or a user API key placed in the default headers.
|
|
5568
|
+
*/
|
|
5569
|
+
const hasAlternateCredential = (options) => resolveUserApiKey(options.userApiKey) !== void 0 || resolveAlternateCredential(options.orgApiKey, "COMPOSIO_ORG_API_KEY") !== void 0 || getUserApiKeyHeader(options.defaultHeaders) !== void 0;
|
|
5570
|
+
/**
|
|
5571
|
+
* Resolves the base URL and project API key the SDK will use.
|
|
5572
|
+
*
|
|
5573
|
+
* Project key resolution distinguishes three caller intents:
|
|
5574
|
+
* - a non-empty string is used as-is and nothing else is consulted;
|
|
5575
|
+
* - `undefined` (or an empty string) falls back to `COMPOSIO_API_KEY`, then to
|
|
5576
|
+
* the `api_key` stored by the CLI in `~/.composio/user_data.json`;
|
|
5577
|
+
* - `null` disables project-key auth: neither `COMPOSIO_API_KEY` nor the stored
|
|
5578
|
+
* `api_key` is read, and the resolver only succeeds when the instance holds
|
|
5579
|
+
* another credential: a `userApiKey` or `orgApiKey` (explicit, or resolved
|
|
5580
|
+
* from `COMPOSIO_USER_API_KEY` / `COMPOSIO_ORG_API_KEY` the way the API
|
|
5581
|
+
* client does), or a non-empty `x-user-api-key` entry in `defaultHeaders`.
|
|
5582
|
+
* An `x-api-key` entry in `defaultHeaders` (any letter case) is rejected in
|
|
5583
|
+
* that mode: the project credential is only ever set from `apiKey`.
|
|
5584
|
+
*
|
|
5585
|
+
* A stored `uak_` user key is never used as a project key: when it is the only
|
|
5586
|
+
* candidate the resolver throws a {@link ComposioAPIKeyKindError} that names the
|
|
5587
|
+
* problem without echoing the key.
|
|
5588
|
+
*/
|
|
5589
|
+
function getSDKConfig(baseUrl, apiKey, options = {}) {
|
|
5590
|
+
let userData;
|
|
5591
|
+
const readUserData = () => {
|
|
5592
|
+
userData ??= readUserDataFile();
|
|
5593
|
+
return userData;
|
|
5594
|
+
};
|
|
5595
|
+
const userDataValue = (field) => {
|
|
5596
|
+
const read = readUserData();
|
|
5597
|
+
return read.status === "ok" && hasValue(read.data[field]) ? read.data[field] : void 0;
|
|
5598
|
+
};
|
|
5599
|
+
const resolveApiKey = () => {
|
|
5600
|
+
if (apiKey === null) {
|
|
5601
|
+
const projectKeyHeader = findHeader(options.defaultHeaders, PROJECT_API_KEY_HEADER);
|
|
5602
|
+
if (projectKeyHeader) throw new ComposioNoAPIKeyError(`Project API key resolution is disabled, but \`defaultHeaders\` carries a \`${projectKeyHeader.name}\` entry`, {
|
|
5603
|
+
cause: "`apiKey: null` sends no project key, so a raw x-api-key default header would bypass that choice; the SDK keeps a single source for the project credential",
|
|
5604
|
+
possibleFixes: [`Pass the project API key via \`apiKey\` instead of a raw \`${PROJECT_API_KEY_HEADER}\` default header`, `Remove the \`${projectKeyHeader.name}\` entry from \`defaultHeaders\` to authenticate with the user or organization API key alone`]
|
|
5605
|
+
});
|
|
5606
|
+
if (hasAlternateCredential(options)) return null;
|
|
5607
|
+
throw new ComposioNoAPIKeyError("Project API key resolution is disabled", {
|
|
5608
|
+
cause: "`apiKey: null` turns off the COMPOSIO_API_KEY and user config file fallbacks, and no user or organization API key was configured",
|
|
5609
|
+
possibleFixes: [
|
|
5610
|
+
"Pass a project API key via `apiKey`, or omit it to fall back to COMPOSIO_API_KEY",
|
|
5611
|
+
"To authenticate with a user API key instead, keep `apiKey: null` and pass `userApiKey` (or set COMPOSIO_USER_API_KEY)",
|
|
5612
|
+
`Alternatively, keep \`apiKey: null\` and set the \`${USER_API_KEY_HEADER}\` default header`
|
|
5613
|
+
]
|
|
5614
|
+
});
|
|
5615
|
+
}
|
|
5616
|
+
if (hasValue(apiKey)) return apiKey;
|
|
5617
|
+
const envApiKey = getEnvVariable("COMPOSIO_API_KEY");
|
|
5618
|
+
if (hasValue(envApiKey)) return envApiKey;
|
|
5619
|
+
const read = readUserData();
|
|
5620
|
+
const storedApiKey = userDataValue("api_key");
|
|
5621
|
+
if (read.status === "ok" && hasValue(storedApiKey)) {
|
|
5622
|
+
if (storedApiKey.startsWith(USER_API_KEY_PREFIX)) throw new ComposioAPIKeyKindError(void 0, {
|
|
5623
|
+
cause: `The user config file at ${read.path} holds a user API key written by the Composio CLI; it cannot authenticate SDK requests as a project`,
|
|
5624
|
+
meta: { userDataFilePath: read.path }
|
|
5625
|
+
});
|
|
5626
|
+
return storedApiKey;
|
|
5627
|
+
}
|
|
5628
|
+
if (read.status === "malformed") throw new ComposioNoAPIKeyError("No Composio API key provided", { cause: `No API key was passed in the params or in COMPOSIO_API_KEY, and the user config file at ${read.path} ${read.reason}` });
|
|
5629
|
+
throw new ComposioNoAPIKeyError();
|
|
5630
|
+
};
|
|
5631
|
+
let apiKeyParsed;
|
|
5632
|
+
try {
|
|
5633
|
+
apiKeyParsed = resolveApiKey();
|
|
5634
|
+
} catch (error) {
|
|
5635
|
+
ComposioError.handleAndThrow(error);
|
|
5636
|
+
}
|
|
5637
|
+
const baseURLParsed = (hasValue(baseUrl) ? baseUrl : void 0) ?? getEnvVariable("COMPOSIO_BASE_URL") ?? userDataValue("base_url") ?? "https://backend.composio.dev";
|
|
5638
|
+
logger.debug("Environment", apiKeyParsed === null ? "API Key: [DISABLED]" : "API Key: [REDACTED]");
|
|
5639
|
+
logger.debug("Environment", `Base URL: ${baseURLParsed}`);
|
|
5640
|
+
return {
|
|
5641
|
+
baseURL: baseURLParsed,
|
|
5642
|
+
apiKey: apiKeyParsed
|
|
5643
|
+
};
|
|
5644
|
+
}
|
|
5645
|
+
/**
|
|
5646
|
+
* Gets toolkit versions configuration by merging environment variables, user-provided defaults, and fallbacks.
|
|
5647
|
+
*
|
|
5648
|
+
* Priority order:
|
|
5649
|
+
* 1. If defaultVersions is a string, use it as global version for all toolkits
|
|
5650
|
+
* 2. User-provided toolkit version mappings (defaultVersions object)
|
|
5651
|
+
* 3. Environment variables (COMPOSIO_TOOLKIT_VERSION_<TOOLKIT_NAME>)
|
|
5652
|
+
* 4. Fallback to 'latest' if no versions are configured
|
|
5653
|
+
*
|
|
5654
|
+
* @param defaultVersions - Optional default versions configuration (string for global version or object mapping toolkit names to versions)
|
|
5655
|
+
* @returns Toolkit versions configuration - either a global version string, toolkit-specific version mapping, or 'latest'
|
|
5656
|
+
*/
|
|
5657
|
+
function getToolkitVersionsFromEnv(defaultVersions) {
|
|
5658
|
+
if (defaultVersions && typeof defaultVersions === "string") return defaultVersions;
|
|
5659
|
+
const envPrefixedVersions = getEnvsWithPrefix(`COMPOSIO_TOOLKIT_VERSION_`);
|
|
5660
|
+
const toolkitVersionsFromEnv = Object.entries(envPrefixedVersions).reduce((acc, [key, value]) => {
|
|
5661
|
+
const toolkitName = key.replace("COMPOSIO_TOOLKIT_VERSION_", "");
|
|
5662
|
+
acc[normalizeToolkitSlug(toolkitName)] = value;
|
|
5663
|
+
return acc;
|
|
5664
|
+
}, {});
|
|
5665
|
+
let userProvidedToolkitVersions = {};
|
|
5666
|
+
if (defaultVersions && typeof defaultVersions === "object") userProvidedToolkitVersions = Object.fromEntries(Object.entries(defaultVersions).map(([key, value]) => [normalizeToolkitSlug(key), value]));
|
|
5667
|
+
const toolkitVersions = {
|
|
5668
|
+
...toolkitVersionsFromEnv,
|
|
5669
|
+
...userProvidedToolkitVersions
|
|
5670
|
+
};
|
|
5671
|
+
if (Object.keys(toolkitVersions).length === 0) return "latest";
|
|
5672
|
+
return toolkitVersions;
|
|
5673
|
+
}
|
|
5674
|
+
|
|
4029
5675
|
//#endregion
|
|
4030
5676
|
//#region src/services/pusher/Pusher.ts
|
|
4031
5677
|
var PusherService = class {
|
|
@@ -4034,13 +5680,17 @@ var PusherService = class {
|
|
|
4034
5680
|
pusherCluster;
|
|
4035
5681
|
pusherChannel;
|
|
4036
5682
|
pusherBaseURL;
|
|
4037
|
-
|
|
5683
|
+
authHeaders;
|
|
4038
5684
|
pusherClient;
|
|
4039
5685
|
composioClient;
|
|
4040
|
-
constructor(client) {
|
|
5686
|
+
constructor(client, options = {}) {
|
|
4041
5687
|
this.composioClient = client;
|
|
4042
5688
|
this.pusherBaseURL = client.baseURL;
|
|
4043
|
-
this.
|
|
5689
|
+
this.authHeaders = resolveCredentialHeaders({
|
|
5690
|
+
apiKey: client.apiKey,
|
|
5691
|
+
userApiKey: client.userApiKey,
|
|
5692
|
+
defaultHeaders: options.defaultHeaders
|
|
5693
|
+
});
|
|
4044
5694
|
telemetry.instrument(this, "PusherService");
|
|
4045
5695
|
}
|
|
4046
5696
|
/**
|
|
@@ -4069,7 +5719,7 @@ var PusherService = class {
|
|
|
4069
5719
|
cluster: this.pusherCluster,
|
|
4070
5720
|
channelAuthorization: {
|
|
4071
5721
|
endpoint: `${this.pusherBaseURL}/api/v3/internal/sdk/realtime/auth`,
|
|
4072
|
-
headers: {
|
|
5722
|
+
headers: { ...this.authHeaders },
|
|
4073
5723
|
transport: "ajax"
|
|
4074
5724
|
}
|
|
4075
5725
|
});
|
|
@@ -4249,8 +5899,8 @@ function transformTriggerInstanceListActiveItem(response) {
|
|
|
4249
5899
|
id: response.id,
|
|
4250
5900
|
connectedAccountId: response.connected_account_id,
|
|
4251
5901
|
disabledAt: response.disabled_at,
|
|
4252
|
-
state: response.state,
|
|
4253
|
-
triggerConfig: response.trigger_config,
|
|
5902
|
+
state: response.state ?? {},
|
|
5903
|
+
triggerConfig: response.trigger_config ?? {},
|
|
4254
5904
|
triggerName: response.trigger_name,
|
|
4255
5905
|
updatedAt: response.updated_at,
|
|
4256
5906
|
triggerData: response.trigger_data,
|
|
@@ -4303,26 +5953,6 @@ const toStringOrDefault = (value, defaultValue) => {
|
|
|
4303
5953
|
const str = String(value);
|
|
4304
5954
|
return str.length > 0 ? str : defaultValue;
|
|
4305
5955
|
};
|
|
4306
|
-
const WEBHOOK_SUBSCRIPTIONS_PATH = "/api/v3.1/webhook_subscriptions";
|
|
4307
|
-
const asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
4308
|
-
const firstString = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
4309
|
-
const stringArray = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
4310
|
-
const transformWebhookSubscription = (subscription) => {
|
|
4311
|
-
const raw = asRecord(subscription);
|
|
4312
|
-
return {
|
|
4313
|
-
id: firstString(raw.id) ?? "",
|
|
4314
|
-
webhookUrl: firstString(raw.webhook_url) ?? firstString(raw.webhookUrl) ?? "",
|
|
4315
|
-
version: firstString(raw.version) ?? WebhookVersions.V3,
|
|
4316
|
-
enabledEvents: stringArray(raw.enabled_events).length ? stringArray(raw.enabled_events) : stringArray(raw.enabledEvents),
|
|
4317
|
-
secret: firstString(raw.secret),
|
|
4318
|
-
createdAt: firstString(raw.created_at) ?? firstString(raw.createdAt),
|
|
4319
|
-
updatedAt: firstString(raw.updated_at) ?? firstString(raw.updatedAt)
|
|
4320
|
-
};
|
|
4321
|
-
};
|
|
4322
|
-
const firstWebhookSubscriptionId = (response) => {
|
|
4323
|
-
const firstItem = Array.isArray(response.items) ? response.items[0] : void 0;
|
|
4324
|
-
return firstString(asRecord(firstItem).id);
|
|
4325
|
-
};
|
|
4326
5956
|
/**
|
|
4327
5957
|
* The signature header names Composio sends with every webhook delivery.
|
|
4328
5958
|
* @private
|
|
@@ -4376,7 +6006,7 @@ var Triggers = class {
|
|
|
4376
6006
|
toolkitVersions;
|
|
4377
6007
|
constructor(client, config) {
|
|
4378
6008
|
this.client = client;
|
|
4379
|
-
this.pusherService = new PusherService(client);
|
|
6009
|
+
this.pusherService = new PusherService(client, { defaultHeaders: config?.defaultHeaders });
|
|
4380
6010
|
this.toolkitVersions = config?.toolkitVersions ?? CONFIG_DEFAULTS.toolkitVersions;
|
|
4381
6011
|
telemetry.instrument(this, "Triggers");
|
|
4382
6012
|
}
|
|
@@ -4394,17 +6024,7 @@ var Triggers = class {
|
|
|
4394
6024
|
* ```
|
|
4395
6025
|
*/
|
|
4396
6026
|
async setWebhookSubscription(params) {
|
|
4397
|
-
|
|
4398
|
-
if (!parsedParams.success) throw new ValidationError(`Invalid parameters passed to set webhook subscription`, { cause: parsedParams.error });
|
|
4399
|
-
const body = {
|
|
4400
|
-
webhook_url: parsedParams.data.webhookUrl,
|
|
4401
|
-
enabled_events: parsedParams.data.enabledEvents ?? [...DefaultWebhookSubscriptionEvents],
|
|
4402
|
-
version: parsedParams.data.version ?? WebhookVersions.V3
|
|
4403
|
-
};
|
|
4404
|
-
const existing = await this.client.get(WEBHOOK_SUBSCRIPTIONS_PATH, { query: { limit: 1 } });
|
|
4405
|
-
const subscriptionId = firstWebhookSubscriptionId(existing);
|
|
4406
|
-
const subscription = subscriptionId ? await this.client.patch(`${WEBHOOK_SUBSCRIPTIONS_PATH}/${encodeURIComponent(subscriptionId)}`, { body }) : await this.client.post(WEBHOOK_SUBSCRIPTIONS_PATH, { body });
|
|
4407
|
-
return transformWebhookSubscription(subscription);
|
|
6027
|
+
return upsertWebhookSubscription(this.client, params);
|
|
4408
6028
|
}
|
|
4409
6029
|
/**
|
|
4410
6030
|
* Fetch list of all the active triggers
|
|
@@ -5544,74 +7164,322 @@ var MCP = class {
|
|
|
5544
7164
|
};
|
|
5545
7165
|
|
|
5546
7166
|
//#endregion
|
|
5547
|
-
//#region src/
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
7167
|
+
//#region src/types/logs.types.ts
|
|
7168
|
+
/**
|
|
7169
|
+
* Fields a tool-execution log search can filter on.
|
|
7170
|
+
*/
|
|
7171
|
+
const LogSearchFilterFieldSchema = z$1.enum([
|
|
7172
|
+
"tool_slug",
|
|
7173
|
+
"toolkit_slug",
|
|
7174
|
+
"connected_account_id",
|
|
7175
|
+
"auth_config_id",
|
|
7176
|
+
"status",
|
|
7177
|
+
"user_id",
|
|
7178
|
+
"session_id",
|
|
7179
|
+
"sandbox_id",
|
|
7180
|
+
"request_id",
|
|
7181
|
+
"log_id"
|
|
7182
|
+
]);
|
|
7183
|
+
const LogSearchFilterOperatorSchema = z$1.enum([
|
|
7184
|
+
"==",
|
|
7185
|
+
"!=",
|
|
7186
|
+
"contains",
|
|
7187
|
+
"not_contains"
|
|
7188
|
+
]);
|
|
7189
|
+
const LogSearchFilterSchema = z$1.object({
|
|
7190
|
+
field: LogSearchFilterFieldSchema,
|
|
7191
|
+
operator: LogSearchFilterOperatorSchema,
|
|
7192
|
+
value: z$1.string()
|
|
7193
|
+
});
|
|
7194
|
+
const LogSearchTimeRangeSchema = z$1.object({
|
|
7195
|
+
/** Start time in epoch milliseconds (inclusive). */
|
|
7196
|
+
from: z$1.number(),
|
|
7197
|
+
/** End time in epoch milliseconds. */
|
|
7198
|
+
to: z$1.number()
|
|
7199
|
+
});
|
|
7200
|
+
/**
|
|
7201
|
+
* Params for `composio.logs.search()`.
|
|
7202
|
+
*/
|
|
7203
|
+
const LogSearchParamsSchema = z$1.object({
|
|
7204
|
+
limit: z$1.number().optional(),
|
|
7205
|
+
cursor: z$1.string().nullable().optional(),
|
|
7206
|
+
filters: z$1.array(LogSearchFilterSchema).optional(),
|
|
7207
|
+
timeRange: LogSearchTimeRangeSchema.optional()
|
|
7208
|
+
});
|
|
7209
|
+
const ToolExecutionLogStatusSchema = z$1.enum(["success", "failed"]);
|
|
7210
|
+
const ToolExecutionLogLevelSchema = z$1.enum([
|
|
7211
|
+
"info",
|
|
7212
|
+
"error",
|
|
7213
|
+
"warn"
|
|
7214
|
+
]);
|
|
7215
|
+
const ToolExecutionLogParentSchema = z$1.object({
|
|
7216
|
+
logId: z$1.string(),
|
|
7217
|
+
toolSlug: z$1.string()
|
|
7218
|
+
}).nullable();
|
|
7219
|
+
/**
|
|
7220
|
+
* A tool-execution log entry as returned by `composio.logs.search()`.
|
|
7221
|
+
*/
|
|
7222
|
+
const ToolExecutionLogSchema = z$1.object({
|
|
7223
|
+
id: z$1.string(),
|
|
7224
|
+
/** ISO 8601 timestamp. */
|
|
7225
|
+
timestamp: z$1.string(),
|
|
7226
|
+
/** Log event type, e.g. `tool.execution`. */
|
|
7227
|
+
type: z$1.string(),
|
|
7228
|
+
status: ToolExecutionLogStatusSchema,
|
|
7229
|
+
level: ToolExecutionLogLevelSchema,
|
|
7230
|
+
message: z$1.string().optional(),
|
|
7231
|
+
metadata: z$1.record(z$1.string(), z$1.unknown()),
|
|
7232
|
+
metrics: z$1.record(z$1.string(), z$1.unknown()),
|
|
7233
|
+
parent: ToolExecutionLogParentSchema
|
|
7234
|
+
});
|
|
7235
|
+
const LogSearchResponseSchema = z$1.object({
|
|
7236
|
+
logs: z$1.array(ToolExecutionLogSchema),
|
|
7237
|
+
nextCursor: z$1.string().nullable()
|
|
7238
|
+
});
|
|
7239
|
+
/**
|
|
7240
|
+
* A single tool-execution log with its full detail, as returned by
|
|
7241
|
+
* `composio.logs.get()`.
|
|
7242
|
+
*/
|
|
7243
|
+
const ToolExecutionLogDetailSchema = ToolExecutionLogSchema.extend({
|
|
7244
|
+
timings: z$1.object({
|
|
7245
|
+
/** Epoch milliseconds. */
|
|
7246
|
+
startTime: z$1.number(),
|
|
7247
|
+
/** Epoch milliseconds. */
|
|
7248
|
+
endTime: z$1.number()
|
|
7249
|
+
}).optional(),
|
|
7250
|
+
context: z$1.object({
|
|
7251
|
+
sessionId: z$1.string().optional(),
|
|
7252
|
+
traceId: z$1.string().optional(),
|
|
7253
|
+
requestId: z$1.string().optional()
|
|
7254
|
+
}),
|
|
7255
|
+
source: z$1.object({
|
|
7256
|
+
host: z$1.string().optional(),
|
|
7257
|
+
framework: z$1.string().optional(),
|
|
7258
|
+
language: z$1.string().optional()
|
|
7259
|
+
}),
|
|
7260
|
+
data: z$1.record(z$1.string(), z$1.unknown())
|
|
7261
|
+
});
|
|
7262
|
+
|
|
7263
|
+
//#endregion
|
|
7264
|
+
//#region src/utils/transformers/logs.ts
|
|
7265
|
+
const transformLogSearchParams = (params) => ({
|
|
7266
|
+
limit: params.limit,
|
|
7267
|
+
cursor: params.cursor,
|
|
7268
|
+
filters: params.filters,
|
|
7269
|
+
time_range: params.timeRange
|
|
7270
|
+
});
|
|
7271
|
+
const transformToolExecutionLog = (response) => {
|
|
7272
|
+
return transform(response).with(ToolExecutionLogSchema).using((response) => ({
|
|
7273
|
+
id: response.id,
|
|
7274
|
+
timestamp: response.timestamp,
|
|
7275
|
+
type: response.type,
|
|
7276
|
+
status: response.status,
|
|
7277
|
+
level: response.level,
|
|
7278
|
+
message: response.message,
|
|
7279
|
+
metadata: response.metadata,
|
|
7280
|
+
metrics: response.metrics,
|
|
7281
|
+
parent: response.parent ? {
|
|
7282
|
+
logId: response.parent.log_id,
|
|
7283
|
+
toolSlug: response.parent.tool_slug
|
|
7284
|
+
} : null
|
|
7285
|
+
}));
|
|
7286
|
+
};
|
|
7287
|
+
const transformLogSearchResponse = (response) => {
|
|
7288
|
+
return transform(response).with(LogSearchResponseSchema).using((response) => ({
|
|
7289
|
+
logs: response.logs.map(transformToolExecutionLog),
|
|
7290
|
+
nextCursor: response.next_cursor
|
|
7291
|
+
}));
|
|
7292
|
+
};
|
|
7293
|
+
const transformToolExecutionLogDetail = (response) => {
|
|
7294
|
+
return transform(response).with(ToolExecutionLogDetailSchema).using((response) => ({
|
|
7295
|
+
id: response.id,
|
|
7296
|
+
timestamp: response.timestamp,
|
|
7297
|
+
type: response.type,
|
|
7298
|
+
status: response.status,
|
|
7299
|
+
level: response.level,
|
|
7300
|
+
message: response.message,
|
|
7301
|
+
metadata: response.metadata,
|
|
7302
|
+
metrics: response.metrics,
|
|
7303
|
+
parent: response.parent ? {
|
|
7304
|
+
logId: response.parent.log_id,
|
|
7305
|
+
toolSlug: response.parent.tool_slug
|
|
7306
|
+
} : null,
|
|
7307
|
+
timings: response.timings ? {
|
|
7308
|
+
startTime: response.timings.start_time,
|
|
7309
|
+
endTime: response.timings.end_time
|
|
7310
|
+
} : void 0,
|
|
7311
|
+
context: {
|
|
7312
|
+
sessionId: response.context.session_id,
|
|
7313
|
+
traceId: response.context.trace_id,
|
|
7314
|
+
requestId: response.context.request_id
|
|
7315
|
+
},
|
|
7316
|
+
source: {
|
|
7317
|
+
host: response.source.host,
|
|
7318
|
+
framework: response.source.framework,
|
|
7319
|
+
language: response.source.language
|
|
7320
|
+
},
|
|
7321
|
+
data: response.data
|
|
7322
|
+
}));
|
|
5557
7323
|
};
|
|
7324
|
+
|
|
7325
|
+
//#endregion
|
|
7326
|
+
//#region src/models/Logs.ts
|
|
5558
7327
|
/**
|
|
5559
|
-
*
|
|
7328
|
+
* `composio.logs` — tool-execution logs.
|
|
5560
7329
|
*
|
|
5561
|
-
* @
|
|
7330
|
+
* @example
|
|
7331
|
+
* ```typescript
|
|
7332
|
+
* const { logs, nextCursor } = await composio.logs.search({
|
|
7333
|
+
* filters: [{ field: 'toolkit_slug', operator: '==', value: 'github' }],
|
|
7334
|
+
* limit: 20,
|
|
7335
|
+
* });
|
|
7336
|
+
* const detail = await composio.logs.get(logs[0].id);
|
|
7337
|
+
* ```
|
|
5562
7338
|
*/
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
7339
|
+
var Logs = class {
|
|
7340
|
+
client;
|
|
7341
|
+
constructor(client) {
|
|
7342
|
+
this.client = client;
|
|
7343
|
+
telemetry.instrument(this, "Logs");
|
|
7344
|
+
}
|
|
7345
|
+
/**
|
|
7346
|
+
* Search tool-execution logs with filters, a time range and cursor
|
|
7347
|
+
* pagination.
|
|
7348
|
+
*
|
|
7349
|
+
* @param {LogSearchParams} [params] - Filters, `timeRange`, `limit` and `cursor`
|
|
7350
|
+
* @returns {Promise<LogSearchResponse>} Matching logs and the next cursor
|
|
7351
|
+
* @throws {ValidationError} If the params fail validation
|
|
7352
|
+
*
|
|
7353
|
+
* @example
|
|
7354
|
+
* ```typescript
|
|
7355
|
+
* const { logs } = await composio.logs.search({
|
|
7356
|
+
* filters: [
|
|
7357
|
+
* { field: 'status', operator: '==', value: 'failed' },
|
|
7358
|
+
* { field: 'user_id', operator: '==', value: 'user_123' },
|
|
7359
|
+
* ],
|
|
7360
|
+
* timeRange: { from: Date.now() - 24 * 60 * 60 * 1000, to: Date.now() },
|
|
7361
|
+
* });
|
|
7362
|
+
* ```
|
|
7363
|
+
*/
|
|
7364
|
+
async search(params, requestOptions) {
|
|
7365
|
+
const parsedParams = LogSearchParamsSchema.safeParse(params ?? {});
|
|
7366
|
+
if (!parsedParams.success) throw new ValidationError("Failed to parse log search params", { cause: parsedParams.error });
|
|
7367
|
+
const body = transformLogSearchParams(parsedParams.data);
|
|
7368
|
+
const result = await withCancellation(() => this.client.logs.createToolExecution(body, requestOptions), requestOptions?.signal);
|
|
7369
|
+
return transformLogSearchResponse(result);
|
|
7370
|
+
}
|
|
7371
|
+
/**
|
|
7372
|
+
* Retrieve one tool-execution log with its full detail (timings, context,
|
|
7373
|
+
* source and raw `data`).
|
|
7374
|
+
*
|
|
7375
|
+
* @param {string} id - The log id
|
|
7376
|
+
* @returns {Promise<ToolExecutionLogDetail>} The log detail
|
|
7377
|
+
*
|
|
7378
|
+
* @example
|
|
7379
|
+
* ```typescript
|
|
7380
|
+
* const log = await composio.logs.get('log_abc123');
|
|
7381
|
+
* console.log(log.status, log.timings?.endTime);
|
|
7382
|
+
* ```
|
|
7383
|
+
*/
|
|
7384
|
+
async get(id, requestOptions) {
|
|
7385
|
+
const result = await withCancellation(() => this.client.logs.retrieveToolExecution(id, requestOptions), requestOptions?.signal);
|
|
7386
|
+
return transformToolExecutionLogDetail(result);
|
|
5572
7387
|
}
|
|
5573
7388
|
};
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
const apiKeyParsed = apiKey || getEnvVariable("COMPOSIO_API_KEY") || apiKeyFromUserConfig || "";
|
|
5578
|
-
if (!apiKeyParsed) ComposioError.handleAndThrow(new ComposioNoAPIKeyError());
|
|
5579
|
-
logger.debug("Environment", "API Key: [REDACTED]");
|
|
5580
|
-
logger.debug("Environment", `Base URL: ${baseURLParsed}`);
|
|
5581
|
-
return {
|
|
5582
|
-
baseURL: baseURLParsed,
|
|
5583
|
-
apiKey: apiKeyParsed
|
|
5584
|
-
};
|
|
5585
|
-
}
|
|
7389
|
+
|
|
7390
|
+
//#endregion
|
|
7391
|
+
//#region src/types/keyring.types.ts
|
|
5586
7392
|
/**
|
|
5587
|
-
*
|
|
5588
|
-
*
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
7393
|
+
* A public JWK a secret can be sealed to. Fields keep their JWK names so a
|
|
7394
|
+
* key can be handed straight to WebCrypto or a JOSE library.
|
|
7395
|
+
*/
|
|
7396
|
+
const KeyringTransferKeySchema = z$1.object({
|
|
7397
|
+
/** Key type. Always `RSA`. */
|
|
7398
|
+
kty: z$1.string(),
|
|
7399
|
+
/** RSA modulus, base64url-encoded. */
|
|
7400
|
+
n: z$1.string(),
|
|
7401
|
+
/** RSA public exponent, base64url-encoded. */
|
|
7402
|
+
e: z$1.string(),
|
|
7403
|
+
/** Key-management algorithm for the JWE (`RSA-OAEP-256`). Pair it with `A256GCM` content encryption. */
|
|
7404
|
+
alg: z$1.string(),
|
|
7405
|
+
/** Key use. Always `enc`. */
|
|
7406
|
+
use: z$1.string(),
|
|
7407
|
+
/** Key identifier. Put it in the JWE protected header. */
|
|
7408
|
+
kid: z$1.string()
|
|
7409
|
+
});
|
|
7410
|
+
/**
|
|
7411
|
+
* Response of `composio.keyring.listTransferKeys()`.
|
|
7412
|
+
*/
|
|
7413
|
+
const KeyringTransferKeysResponseSchema = z$1.object({
|
|
7414
|
+
/** The `kid` of the key to seal new secrets to. */
|
|
7415
|
+
activeKid: z$1.string(),
|
|
7416
|
+
/** Every currently accepted transfer key, newest first. */
|
|
7417
|
+
keys: z$1.array(KeyringTransferKeySchema)
|
|
7418
|
+
});
|
|
7419
|
+
|
|
7420
|
+
//#endregion
|
|
7421
|
+
//#region src/utils/transformers/keyring.ts
|
|
7422
|
+
const transformKeyringTransferKeysResponse = (response) => {
|
|
7423
|
+
return transform(response).with(KeyringTransferKeysResponseSchema).using((response) => ({
|
|
7424
|
+
activeKid: response.active_kid,
|
|
7425
|
+
keys: response.keys.map((key) => ({
|
|
7426
|
+
kty: key.kty,
|
|
7427
|
+
n: key.n,
|
|
7428
|
+
e: key.e,
|
|
7429
|
+
alg: key.alg,
|
|
7430
|
+
use: key.use,
|
|
7431
|
+
kid: key.kid
|
|
7432
|
+
}))
|
|
7433
|
+
}));
|
|
7434
|
+
};
|
|
7435
|
+
|
|
7436
|
+
//#endregion
|
|
7437
|
+
//#region src/models/Keyring.ts
|
|
7438
|
+
/**
|
|
7439
|
+
* `composio.keyring` — the organization's customer-managed keyring.
|
|
5594
7440
|
*
|
|
5595
|
-
* @
|
|
5596
|
-
*
|
|
7441
|
+
* @example
|
|
7442
|
+
* ```typescript
|
|
7443
|
+
* const { activeKid, keys } = await composio.keyring.listTransferKeys();
|
|
7444
|
+
* const sealingKey = keys.find(key => key.kid === activeKid);
|
|
7445
|
+
* ```
|
|
5597
7446
|
*/
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
7447
|
+
var Keyring = class {
|
|
7448
|
+
client;
|
|
7449
|
+
constructor(client) {
|
|
7450
|
+
this.client = client;
|
|
7451
|
+
telemetry.instrument(this, "Keyring");
|
|
7452
|
+
}
|
|
7453
|
+
/**
|
|
7454
|
+
* Lists the public transfer keys of the organization's active customer
|
|
7455
|
+
* keyring, the keys a secret is sealed to before it is sent to Composio.
|
|
7456
|
+
*
|
|
7457
|
+
* Always seal new secrets to the key whose `kid` is `activeKid`: a JWE with
|
|
7458
|
+
* `RSA-OAEP-256` key management, `A256GCM` content encryption, and the
|
|
7459
|
+
* `kid` in the protected header. Older keys stay listed so values sealed to
|
|
7460
|
+
* them remain openable.
|
|
7461
|
+
*
|
|
7462
|
+
* The organization behind the API key must have an ACTIVE customer keyring
|
|
7463
|
+
* instance; otherwise the API answers 404.
|
|
7464
|
+
*
|
|
7465
|
+
* @returns {Promise<KeyringTransferKeysResponse>} The active key ID and every accepted public JWK, newest first
|
|
7466
|
+
*
|
|
7467
|
+
* @example
|
|
7468
|
+
* ```typescript
|
|
7469
|
+
* import { CompactEncrypt, importJWK } from 'jose';
|
|
7470
|
+
*
|
|
7471
|
+
* const { activeKid, keys } = await composio.keyring.listTransferKeys();
|
|
7472
|
+
* const jwk = keys.find(key => key.kid === activeKid)!;
|
|
7473
|
+
* const sealed = await new CompactEncrypt(new TextEncoder().encode(secret))
|
|
7474
|
+
* .setProtectedHeader({ alg: 'RSA-OAEP-256', enc: 'A256GCM', kid: activeKid })
|
|
7475
|
+
* .encrypt(await importJWK(jwk, 'RSA-OAEP-256'));
|
|
7476
|
+
* ```
|
|
7477
|
+
*/
|
|
7478
|
+
async listTransferKeys(requestOptions) {
|
|
7479
|
+
const result = await withCancellation(() => this.client.keyring.listTransferKeys(requestOptions), requestOptions?.signal);
|
|
7480
|
+
return transformKeyringTransferKeysResponse(result);
|
|
7481
|
+
}
|
|
7482
|
+
};
|
|
5615
7483
|
|
|
5616
7484
|
//#endregion
|
|
5617
7485
|
//#region src/utils/version.ts
|
|
@@ -6129,7 +7997,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
6129
7997
|
|
|
6130
7998
|
//#endregion
|
|
6131
7999
|
//#region package.json
|
|
6132
|
-
var version = "0.
|
|
8000
|
+
var version = "0.20.0";
|
|
6133
8001
|
|
|
6134
8002
|
//#endregion
|
|
6135
8003
|
//#region src/utils/session.ts
|
|
@@ -6261,7 +8129,7 @@ const ToolRouterConfigToolsSchema = z.union([
|
|
|
6261
8129
|
});
|
|
6262
8130
|
const ToolRouterCreateSessionConfigBaseSchema = z.object({
|
|
6263
8131
|
sessionPreset: z.literal(SessionPreset.DIRECT_TOOLS).optional().describe("Shortcut to expose every tool allowed by the session filters directly in session.tools() and the MCP tool list. This disables meta tools by default (search, multi-execute, manage-connections, and workbench). Use when all tools are known upfront and helper/meta tools are not needed. Without this preset, ToolRouter uses its default configuration with meta tools enabled."),
|
|
6264
|
-
mcp: z.boolean().optional().describe("When true, the returned session surfaces its hosted MCP endpoint (`session.mcp.url` / `session.mcp.headers`) in the type. The endpoint exists on every session at runtime regardless of this flag, but is only typed when `mcp: true` is passed. Default native tools (`session.tools()`) are unaffected. See https://docs.composio.dev/docs/sessions-via-mcp"),
|
|
8132
|
+
mcp: z.boolean().optional().describe("When true, the returned session surfaces its hosted MCP endpoint (`session.mcp.url` / `session.mcp.headers`) in the type, and an MCP URL that is not on the API base URL origin throws `ComposioMCPDestinationError` instead of leaving `session.mcp.headers` empty with a warning. The endpoint exists on every session at runtime regardless of this flag, but is only typed when `mcp: true` is passed. Default native tools (`session.tools()`) are unaffected. See https://docs.composio.dev/docs/sessions-via-mcp"),
|
|
6265
8133
|
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).optional().describe("The tools to use in the tool router session"),
|
|
6266
8134
|
tags: ToolRouterConfigTagsSchema.optional().describe("Global tags to filter the tools by"),
|
|
6267
8135
|
toolkits: z.union([
|
|
@@ -6428,29 +8296,76 @@ const SessionProxyExecuteParamsSchema = z.object({
|
|
|
6428
8296
|
value: z.union([z.string(), z.number()])
|
|
6429
8297
|
})).optional()
|
|
6430
8298
|
});
|
|
8299
|
+
/**
|
|
8300
|
+
* `manageConnections` shape accepted by `session.update()`. Unlike the create
|
|
8301
|
+
* schema, `callbackUrl: null` removes the stored callback URL while leaving
|
|
8302
|
+
* the sibling connection settings untouched.
|
|
8303
|
+
*/
|
|
8304
|
+
const ToolRouterUpdateManageConnectionsSchema = z.object({
|
|
8305
|
+
enable: z.boolean().optional().describe("Whether to use tools to manage connections in the tool router session. Defaults to true, if set to false, you need to manage connections manually"),
|
|
8306
|
+
callbackUrl: z.string().nullable().optional().describe("The callback url to use in the tool router session. `null` removes the stored callback url; sibling settings are untouched"),
|
|
8307
|
+
waitForConnections: z.boolean().optional().describe("Whether to wait for users to finish authenticating connections before proceeding to the next step. Defaults to false, if set to true, a wait for connections tool call will happen and finish when the connections are ready"),
|
|
8308
|
+
enableConnectionRemoval: z.boolean().nullable().optional().describe("Whether the session exposes the connection removal tool. `null` removes the stored override")
|
|
8309
|
+
}).strict();
|
|
8310
|
+
const ToolRouterElicitationDefaultSchema = z.enum([
|
|
8311
|
+
"allow_all",
|
|
8312
|
+
"ask_every_call",
|
|
8313
|
+
"ask_once_per_session"
|
|
8314
|
+
]);
|
|
8315
|
+
const ToolRouterElicitationOverrideSchema = z.enum([
|
|
8316
|
+
"always_allow",
|
|
8317
|
+
"always_deny",
|
|
8318
|
+
"ask_once",
|
|
8319
|
+
"ask_always"
|
|
8320
|
+
]);
|
|
8321
|
+
/**
|
|
8322
|
+
* `experimental` block accepted by `session.update()`. Each leaf follows the
|
|
8323
|
+
* PATCH contract of the API: omit to keep the stored value, `null` to remove
|
|
8324
|
+
* it, a value to replace it.
|
|
8325
|
+
*/
|
|
8326
|
+
const ToolRouterUpdateExperimentalSchema = z.object({
|
|
8327
|
+
permissions: z.object({
|
|
8328
|
+
default: ToolRouterElicitationDefaultSchema,
|
|
8329
|
+
overrides: z.record(z.string(), ToolRouterElicitationOverrideSchema).optional()
|
|
8330
|
+
}).strict().nullable().optional().describe("Per-tool elicitation permission config. `null` removes the stored block"),
|
|
8331
|
+
linkUrlOverwrite: z.string().nullable().optional().describe("Base URL override for connection link redirects. `null` removes the stored override"),
|
|
8332
|
+
fastMode: z.boolean().nullable().optional().describe("Fast search mode. `null` removes the stored override"),
|
|
8333
|
+
submitFeedback: z.object({ enable: z.boolean() }).strict().nullable().optional().describe("Exposes the COMPOSIO_SUBMIT_FEEDBACK helper tool. `null` removes the stored block"),
|
|
8334
|
+
sessionConfigId: z.string().optional().describe("Apply the latest active Session config from this project to this session")
|
|
8335
|
+
}).strict();
|
|
8336
|
+
/**
|
|
8337
|
+
* Options for `session.update()`. For every policy block, omitting the key
|
|
8338
|
+
* preserves the stored value and `null` removes the stored override (which can
|
|
8339
|
+
* increase access: `toolkits: null` restores the unrestricted default, unlike
|
|
8340
|
+
* `toolkits: []`, which denies every app toolkit).
|
|
8341
|
+
*/
|
|
6431
8342
|
const ToolRouterUpdateSessionConfigSchema = z.object({
|
|
6432
8343
|
toolkits: z.union([
|
|
6433
8344
|
ToolRouterToolkitsParamSchema,
|
|
6434
8345
|
ToolRouterToolkitsDisabledConfigSchema,
|
|
6435
8346
|
ToolRouterToolkitsEnabledConfigSchema
|
|
6436
|
-
]).optional(),
|
|
6437
|
-
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).optional(),
|
|
6438
|
-
tags: ToolRouterConfigTagsSchema.optional(),
|
|
6439
|
-
authConfigs: z.record(z.string(), z.string()).optional(),
|
|
8347
|
+
]).nullable().optional().describe("Toolkit policy. An empty allowlist (`[]` or `{ enable: [] }`) is sent as-is and denies every app toolkit; `null` removes the stored policy and restores the unrestricted default"),
|
|
8348
|
+
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).nullable().optional().describe("Replaces the entire stored tools map; `null` removes the override"),
|
|
8349
|
+
tags: ToolRouterConfigTagsSchema.nullable().optional().describe("Replaces the global tag policy; `null` removes the override"),
|
|
8350
|
+
authConfigs: z.record(z.string(), z.string()).nullable().optional().describe("Replaces the entire stored auth config map; `null` removes the override"),
|
|
6440
8351
|
connectedAccounts: z.record(z.string(), z.union([z.string(), z.array(z.string())])).transform((rec) => {
|
|
6441
8352
|
const out = {};
|
|
6442
8353
|
for (const [k, v] of Object.entries(rec)) out[k] = typeof v === "string" ? [v] : v;
|
|
6443
8354
|
return out;
|
|
6444
|
-
}).optional(),
|
|
6445
|
-
manageConnections: z.union([z.boolean(),
|
|
8355
|
+
}).nullable().optional().describe("Replaces the entire stored connected accounts map; `null` removes the override"),
|
|
8356
|
+
manageConnections: z.union([z.boolean(), ToolRouterUpdateManageConnectionsSchema]).nullable().optional(),
|
|
6446
8357
|
sandbox: ToolRouterSandboxConfigSchema.partial().nullable().optional(),
|
|
6447
8358
|
workbench: ToolRouterSandboxConfigSchema.partial().nullable().optional(),
|
|
6448
8359
|
multiAccount: z.object({
|
|
6449
8360
|
enable: z.boolean().optional(),
|
|
6450
|
-
maxAccountsPerToolkit: z.number().int().min(2).max(10).optional(),
|
|
8361
|
+
maxAccountsPerToolkit: z.number().int().min(2).max(10).nullable().optional().describe("`null` removes the stored maximum so the default applies again"),
|
|
6451
8362
|
requireExplicitSelection: z.boolean().optional()
|
|
6452
|
-
}).nullable().optional(),
|
|
6453
|
-
preload: z.object({ tools: z.union([z.array(z.string()), z.literal("all")]).optional() }).strict().optional()
|
|
8363
|
+
}).nullable().optional().describe("`null` removes the session override; the mode then resolves to disabled"),
|
|
8364
|
+
preload: z.object({ tools: z.union([z.array(z.string()), z.literal("all")]).optional() }).strict().nullable().optional().describe("Replaces the stored preload; `null` removes it"),
|
|
8365
|
+
search: z.object({ enable: z.boolean().optional() }).strict().nullable().optional().describe("Replaces the search block; `null` removes it and restores the defaults"),
|
|
8366
|
+
execute: z.object({ enableMultiExecute: z.boolean().optional() }).strict().nullable().optional().describe("Replaces the execute block; `null` removes it and restores the defaults"),
|
|
8367
|
+
experimental: ToolRouterUpdateExperimentalSchema.nullable().optional().describe("Experimental settings; `null` removes the stored block"),
|
|
8368
|
+
expectedConfigVersion: z.union([z.number().int().positive(), z.literal(false)]).optional().describe("Precondition sent as `expected_config_version`. Omitted: the session sends the configVersion it last observed, so a concurrent change surfaces as ComposioSessionConfigConflictError instead of being overwritten. A positive integer sends that version instead. `false` sends no precondition (last writer wins)")
|
|
6454
8369
|
}).partial().superRefine((config, ctx) => {
|
|
6455
8370
|
if (config.sandbox !== void 0 && config.workbench !== void 0) ctx.addIssue({
|
|
6456
8371
|
code: z.ZodIssueCode.custom,
|
|
@@ -6462,6 +8377,15 @@ const ToolRouterSessionDeleteResponseSchema = z.object({
|
|
|
6462
8377
|
sessionId: z.string(),
|
|
6463
8378
|
deleted: z.literal(true)
|
|
6464
8379
|
});
|
|
8380
|
+
/**
|
|
8381
|
+
* Options for `session.listConfigHistory()`.
|
|
8382
|
+
*/
|
|
8383
|
+
const ToolRouterSessionListConfigHistoryOptionsSchema = z.object({
|
|
8384
|
+
/** Cursor from a previous response's `nextCursor`. */
|
|
8385
|
+
cursor: z.string().optional(),
|
|
8386
|
+
/** Number of items per page, max allowed is 100. */
|
|
8387
|
+
limit: z.number().optional()
|
|
8388
|
+
});
|
|
6465
8389
|
const ToolRouterSessionEnsureConnectedOptionsSchema = z.object({
|
|
6466
8390
|
callbackUrl: z.string().optional(),
|
|
6467
8391
|
alias: z.string().optional(),
|
|
@@ -6525,19 +8449,25 @@ const transformToolRouterSandboxParams = (params) => {
|
|
|
6525
8449
|
sandbox_size: params.sandboxSize
|
|
6526
8450
|
};
|
|
6527
8451
|
};
|
|
6528
|
-
/**
|
|
6529
|
-
* PATCH-safe variant of transformToolRouterManageConnectionsParams.
|
|
6530
|
-
* Does NOT apply defaults — only includes fields explicitly present in the input.
|
|
6531
|
-
*/
|
|
6532
8452
|
const transformToolRouterUpdateManageConnectionsParams = (params) => {
|
|
6533
8453
|
if (typeof params === "boolean") return { enable: params };
|
|
6534
|
-
const parsedResult =
|
|
8454
|
+
const parsedResult = ToolRouterUpdateManageConnectionsSchema.safeParse(params);
|
|
6535
8455
|
if (!parsedResult.success) throw new ValidationError("Failed to parse manage connections config", { cause: parsedResult.error });
|
|
6536
8456
|
const config = parsedResult.data;
|
|
6537
8457
|
const result = {};
|
|
6538
8458
|
if (config.enable !== void 0) result.enable = config.enable;
|
|
6539
8459
|
if (config.callbackUrl !== void 0) result.callback_url = config.callbackUrl;
|
|
6540
8460
|
if (config.waitForConnections !== void 0) result.enable_wait_for_connections = config.waitForConnections;
|
|
8461
|
+
if (config.enableConnectionRemoval !== void 0) result.enable_connection_removal = config.enableConnectionRemoval;
|
|
8462
|
+
return result;
|
|
8463
|
+
};
|
|
8464
|
+
const transformToolRouterUpdateExperimentalParams = (config) => {
|
|
8465
|
+
const result = {};
|
|
8466
|
+
if (config.permissions !== void 0) result.permissions = config.permissions;
|
|
8467
|
+
if (config.linkUrlOverwrite !== void 0) result.link_url_overwrite = config.linkUrlOverwrite;
|
|
8468
|
+
if (config.fastMode !== void 0) result.fast_mode = config.fastMode;
|
|
8469
|
+
if (config.submitFeedback !== void 0) result.submit_feedback = config.submitFeedback;
|
|
8470
|
+
if (config.sessionConfigId !== void 0) result.session_config_id = config.sessionConfigId;
|
|
6541
8471
|
return result;
|
|
6542
8472
|
};
|
|
6543
8473
|
/**
|
|
@@ -6567,26 +8497,23 @@ const transformToolRouterToolkitsParams = (params) => {
|
|
|
6567
8497
|
if (Array.isArray(params)) return { enable: params };
|
|
6568
8498
|
return params;
|
|
6569
8499
|
};
|
|
8500
|
+
/**
|
|
8501
|
+
* Request body of `session.update()`. Every key present in `config` is sent,
|
|
8502
|
+
* including `null` (remove the stored override) and empty collections (an
|
|
8503
|
+
* empty toolkit allowlist denies every app toolkit). The
|
|
8504
|
+
* `expectedConfigVersion` option is not a body field here: the session
|
|
8505
|
+
* resolves the precondition against its observed `configVersion`.
|
|
8506
|
+
*/
|
|
6570
8507
|
const transformToolRouterUpdateParams = (config) => {
|
|
6571
8508
|
const params = {};
|
|
6572
|
-
if (config.toolkits !== void 0) params.toolkits = transformToolRouterToolkitsParams(config.toolkits);
|
|
6573
|
-
if (config.tools !== void 0) params.tools = transformToolRouterToolsParams(config.tools);
|
|
6574
|
-
if (config.tags !== void 0) params.tags = transformToolRouterTagsParams(config.tags);
|
|
8509
|
+
if (config.toolkits !== void 0) params.toolkits = config.toolkits === null ? null : transformToolRouterToolkitsParams(config.toolkits);
|
|
8510
|
+
if (config.tools !== void 0) params.tools = config.tools === null ? null : transformToolRouterToolsParams(config.tools);
|
|
8511
|
+
if (config.tags !== void 0) params.tags = config.tags === null ? null : transformToolRouterTagsParams(config.tags);
|
|
6575
8512
|
if (config.authConfigs !== void 0) params.auth_configs = config.authConfigs;
|
|
6576
|
-
if (config.connectedAccounts !== void 0)
|
|
6577
|
-
|
|
6578
|
-
for (const [k, v] of Object.entries(config.connectedAccounts)) coerced[k] = typeof v === "string" ? [v] : v;
|
|
6579
|
-
params.connected_accounts = coerced;
|
|
6580
|
-
}
|
|
6581
|
-
if (config.manageConnections !== void 0) {
|
|
6582
|
-
if (config.manageConnections === null) params.manage_connections = null;
|
|
6583
|
-
else params.manage_connections = transformToolRouterUpdateManageConnectionsParams(config.manageConnections);
|
|
6584
|
-
}
|
|
8513
|
+
if (config.connectedAccounts !== void 0) params.connected_accounts = config.connectedAccounts;
|
|
8514
|
+
if (config.manageConnections !== void 0) params.manage_connections = config.manageConnections === null ? null : transformToolRouterUpdateManageConnectionsParams(config.manageConnections);
|
|
6585
8515
|
const sandboxConfig = config.sandbox !== void 0 ? config.sandbox : config.workbench;
|
|
6586
|
-
if (sandboxConfig !== void 0)
|
|
6587
|
-
if (sandboxConfig === null) params.workbench = null;
|
|
6588
|
-
else params.workbench = transformToolRouterUpdateSandboxParams(sandboxConfig);
|
|
6589
|
-
}
|
|
8516
|
+
if (sandboxConfig !== void 0) params.workbench = sandboxConfig === null ? null : transformToolRouterUpdateSandboxParams(sandboxConfig);
|
|
6590
8517
|
if (config.multiAccount !== void 0) {
|
|
6591
8518
|
if (config.multiAccount === null) params.multi_account = null;
|
|
6592
8519
|
else {
|
|
@@ -6598,9 +8525,90 @@ const transformToolRouterUpdateParams = (config) => {
|
|
|
6598
8525
|
}
|
|
6599
8526
|
}
|
|
6600
8527
|
if (config.preload !== void 0) params.preload = config.preload;
|
|
8528
|
+
if (config.search !== void 0) params.search = config.search;
|
|
8529
|
+
if (config.execute !== void 0) params.execute = config.execute === null ? null : config.execute.enableMultiExecute === void 0 ? {} : { enable_multi_execute: config.execute.enableMultiExecute };
|
|
8530
|
+
if (config.experimental !== void 0) params.experimental = config.experimental === null ? null : transformToolRouterUpdateExperimentalParams(config.experimental);
|
|
6601
8531
|
return params;
|
|
6602
8532
|
};
|
|
6603
8533
|
|
|
8534
|
+
//#endregion
|
|
8535
|
+
//#region src/lib/toolRouterMcp.ts
|
|
8536
|
+
/**
|
|
8537
|
+
* Returns the tuple origin (`scheme://host[:port]`) of an absolute URL.
|
|
8538
|
+
*
|
|
8539
|
+
* URLs without a tuple origin (`data:`, `file:`, `blob:` without a base, and
|
|
8540
|
+
* similar) serialize their origin as the opaque string `null`. Two such URLs
|
|
8541
|
+
* would compare equal, so they are rejected before any comparison happens.
|
|
8542
|
+
*/
|
|
8543
|
+
const parseOrigin = (url, role) => {
|
|
8544
|
+
let parsed;
|
|
8545
|
+
try {
|
|
8546
|
+
parsed = new URL(url);
|
|
8547
|
+
} catch (_error) {
|
|
8548
|
+
return { error: new ComposioMCPDestinationError(`The ${role} is not a valid absolute URL`, { meta: { role } }) };
|
|
8549
|
+
}
|
|
8550
|
+
if (parsed.origin === "null") return { error: new ComposioMCPDestinationError(`The ${role} has an opaque origin`, { meta: { role } }) };
|
|
8551
|
+
return { origin: parsed.origin };
|
|
8552
|
+
};
|
|
8553
|
+
/**
|
|
8554
|
+
* Returns the error describing why the MCP URL must not receive the session
|
|
8555
|
+
* credential, or `undefined` when it shares the API origin.
|
|
8556
|
+
*/
|
|
8557
|
+
const destinationRejection = (apiBaseURL, mcpUrl) => {
|
|
8558
|
+
const api = parseOrigin(apiBaseURL, "API base URL");
|
|
8559
|
+
if ("error" in api) return api.error;
|
|
8560
|
+
const mcp = parseOrigin(mcpUrl, "MCP URL");
|
|
8561
|
+
if ("error" in mcp) return mcp.error;
|
|
8562
|
+
if (mcp.origin === api.origin) return;
|
|
8563
|
+
return new ComposioMCPDestinationError(`The session MCP endpoint origin ${mcp.origin} does not match the API origin ${api.origin}; the session credential was not attached`, { meta: {
|
|
8564
|
+
mcpOrigin: mcp.origin,
|
|
8565
|
+
apiOrigin: api.origin
|
|
8566
|
+
} });
|
|
8567
|
+
};
|
|
8568
|
+
/**
|
|
8569
|
+
* Builds the MCP server config exported on a session.
|
|
8570
|
+
*
|
|
8571
|
+
* The headers mirror the effective auth context of the session request: the
|
|
8572
|
+
* project key as `x-api-key` when one is configured, otherwise the resolved
|
|
8573
|
+
* user API key (the `userApiKey` option, then the `x-user-api-key` default
|
|
8574
|
+
* header) as `x-user-api-key`, plus `x-org-id` / `x-project-id` when the
|
|
8575
|
+
* instance carries an explicit scope. No other default header is copied and
|
|
8576
|
+
* the environment is never re-read.
|
|
8577
|
+
*
|
|
8578
|
+
* The headers are only attached when the MCP URL has the same origin as the
|
|
8579
|
+
* API base URL the session was created against, whatever scheme the caller
|
|
8580
|
+
* configured: that origin already receives them on every SDK request. Any
|
|
8581
|
+
* other destination (a different origin, an opaque origin, or a URL that does
|
|
8582
|
+
* not parse) never receives the credential. When the caller asked for MCP
|
|
8583
|
+
* (`mcpRequested`), that raises {@link ComposioMCPDestinationError} naming
|
|
8584
|
+
* both origins; otherwise the session is returned with empty `headers` and a
|
|
8585
|
+
* warning naming both origins is logged, so callers who only use the native
|
|
8586
|
+
* tools are not blocked by an endpoint they never consume. The SDK itself
|
|
8587
|
+
* never connects to the MCP URL and does not follow redirects for it; an MCP
|
|
8588
|
+
* client consuming this config must not forward these headers to a different
|
|
8589
|
+
* origin.
|
|
8590
|
+
*/
|
|
8591
|
+
const buildMCPServerConfig = (input) => {
|
|
8592
|
+
const rejection = destinationRejection(input.apiBaseURL, input.url);
|
|
8593
|
+
if (rejection) {
|
|
8594
|
+
if (input.mcpRequested) throw rejection;
|
|
8595
|
+
logger.warn(`${rejection.message}. session.mcp.headers was left empty; pass \`mcp: true\` to make this an error`);
|
|
8596
|
+
return {
|
|
8597
|
+
type: input.type,
|
|
8598
|
+
url: input.url,
|
|
8599
|
+
headers: {}
|
|
8600
|
+
};
|
|
8601
|
+
}
|
|
8602
|
+
const headers = resolveCredentialHeaders(input);
|
|
8603
|
+
if (input.orgId) headers[ORG_ID_HEADER] = input.orgId;
|
|
8604
|
+
if (input.projectId) headers[PROJECT_ID_HEADER] = input.projectId;
|
|
8605
|
+
return {
|
|
8606
|
+
type: input.type,
|
|
8607
|
+
url: input.url,
|
|
8608
|
+
headers
|
|
8609
|
+
};
|
|
8610
|
+
};
|
|
8611
|
+
|
|
6604
8612
|
//#endregion
|
|
6605
8613
|
//#region src/utils/transformers/toolRouterResponseTransform.ts
|
|
6606
8614
|
function transformSearchResult(raw) {
|
|
@@ -7428,6 +9436,11 @@ var ToolRouterSession = class {
|
|
|
7428
9436
|
preload;
|
|
7429
9437
|
/** Resolved sandbox (code-execution) config returned by the API. `enable` defaults to `true` server-side. */
|
|
7430
9438
|
sandbox;
|
|
9439
|
+
/**
|
|
9440
|
+
* Version of the server-side configuration this object last observed.
|
|
9441
|
+
* Refreshed in place by `update()`, which sends it as the
|
|
9442
|
+
* `expected_config_version` precondition by default.
|
|
9443
|
+
*/
|
|
7431
9444
|
configVersion;
|
|
7432
9445
|
warnings;
|
|
7433
9446
|
preloadedCustomToolSlugs;
|
|
@@ -7443,7 +9456,8 @@ var ToolRouterSession = class {
|
|
|
7443
9456
|
user_id: userId ?? "",
|
|
7444
9457
|
execute: {},
|
|
7445
9458
|
search: {},
|
|
7446
|
-
preload: { tools: [] }
|
|
9459
|
+
preload: { tools: [] },
|
|
9460
|
+
premium_usage: false
|
|
7447
9461
|
};
|
|
7448
9462
|
if (customToolsMap && !userId) throw new Error("userId is required when custom tools are bound to a session.");
|
|
7449
9463
|
this.sessionId = sessionId;
|
|
@@ -7814,14 +9828,50 @@ var ToolRouterSession = class {
|
|
|
7814
9828
|
}
|
|
7815
9829
|
/**
|
|
7816
9830
|
* Partially update the session configuration.
|
|
7817
|
-
*
|
|
7818
|
-
*
|
|
7819
|
-
*
|
|
9831
|
+
*
|
|
9832
|
+
* Only the fields provided are changed; omitted fields are preserved. For
|
|
9833
|
+
* each policy block `null` removes the stored override (which can increase
|
|
9834
|
+
* access: `toolkits: null` restores the unrestricted default, while
|
|
9835
|
+
* `toolkits: []` denies every app toolkit and is sent as-is). Supplied
|
|
9836
|
+
* `tools`, `authConfigs` and `connectedAccounts` maps replace the stored
|
|
9837
|
+
* map entirely. `manageConnections.callbackUrl: null` removes only the
|
|
9838
|
+
* stored callback URL.
|
|
9839
|
+
*
|
|
9840
|
+
* The request carries the `configVersion` this object last observed as the
|
|
9841
|
+
* `expected_config_version` precondition, so a concurrent change surfaces as
|
|
9842
|
+
* {@link ComposioSessionConfigConflictError} (HTTP 409) instead of being
|
|
9843
|
+
* overwritten. Pass `expectedConfigVersion` to send another version, or
|
|
9844
|
+
* `expectedConfigVersion: false` to send no precondition (last writer
|
|
9845
|
+
* wins). The PATCH is never retried by the transport, so a 409 is reported
|
|
9846
|
+
* exactly once. On conflict this object is left unchanged: re-fetch the
|
|
9847
|
+
* session with `sessions.use(sessionId)` and retry against the fresh
|
|
9848
|
+
* `configVersion`.
|
|
9849
|
+
*
|
|
9850
|
+
* `config`, `configVersion`, `preload`, `sandbox` and `warnings` are
|
|
9851
|
+
* refreshed in place only after a successful response, and the updated
|
|
9852
|
+
* `config` is returned.
|
|
7820
9853
|
*/
|
|
7821
9854
|
async update(config, requestOptions) {
|
|
7822
9855
|
const parsed = ToolRouterUpdateSessionConfigSchema.parse(config);
|
|
7823
|
-
const
|
|
7824
|
-
const
|
|
9856
|
+
const body = transformToolRouterUpdateParams(parsed);
|
|
9857
|
+
const expectedConfigVersion = parsed.expectedConfigVersion === false ? void 0 : parsed.expectedConfigVersion ?? this.configVersion;
|
|
9858
|
+
if (expectedConfigVersion !== void 0) body.expected_config_version = expectedConfigVersion;
|
|
9859
|
+
let response;
|
|
9860
|
+
try {
|
|
9861
|
+
response = await withCancellation(() => this.client.toolRouter.session.patch(this.sessionId, body, {
|
|
9862
|
+
...requestOptions,
|
|
9863
|
+
maxRetries: 0
|
|
9864
|
+
}), requestOptions?.signal);
|
|
9865
|
+
} catch (error) {
|
|
9866
|
+
if (error instanceof ConflictError) throw new ComposioSessionConfigConflictError(expectedConfigVersion === void 0 ? `Session ${this.sessionId} configuration changed while this update was in flight; re-fetch the session and retry the update` : `Session ${this.sessionId} configuration is no longer at version ${expectedConfigVersion}; re-fetch the session and retry the update`, {
|
|
9867
|
+
cause: error,
|
|
9868
|
+
meta: {
|
|
9869
|
+
sessionId: this.sessionId,
|
|
9870
|
+
expectedConfigVersion
|
|
9871
|
+
}
|
|
9872
|
+
});
|
|
9873
|
+
throw error;
|
|
9874
|
+
}
|
|
7825
9875
|
this.configVersion = response.config_version;
|
|
7826
9876
|
this.config = response.config;
|
|
7827
9877
|
this.preload = response.config.preload;
|
|
@@ -7838,6 +9888,43 @@ var ToolRouterSession = class {
|
|
|
7838
9888
|
async delete(requestOptions) {
|
|
7839
9889
|
return deleteToolRouterSession(this.client, this.sessionId, requestOptions);
|
|
7840
9890
|
}
|
|
9891
|
+
/**
|
|
9892
|
+
* Page through this session's configuration history, newest first. The
|
|
9893
|
+
* first page starts with the live config (`isCurrent: true`); every
|
|
9894
|
+
* `session.update()` archives the previous version as a history row.
|
|
9895
|
+
*
|
|
9896
|
+
* @param options - Optional `cursor` and `limit` (max 100)
|
|
9897
|
+
* @returns The config versions on this page plus pagination info
|
|
9898
|
+
* @throws {ValidationError} If the options fail validation
|
|
9899
|
+
*
|
|
9900
|
+
* @example
|
|
9901
|
+
* ```typescript
|
|
9902
|
+
* const { items, nextCursor } = await session.listConfigHistory({ limit: 10 });
|
|
9903
|
+
* console.log(items[0].version, items[0].isCurrent); // e.g. 3, true
|
|
9904
|
+
* console.log(items[1].config.toolkits);
|
|
9905
|
+
* ```
|
|
9906
|
+
*/
|
|
9907
|
+
async listConfigHistory(options, requestOptions) {
|
|
9908
|
+
const parsedOptions = ToolRouterSessionListConfigHistoryOptionsSchema.safeParse(options ?? {});
|
|
9909
|
+
if (!parsedOptions.success) throw new ValidationError("Failed to parse config history options", { cause: parsedOptions.error });
|
|
9910
|
+
const query = {
|
|
9911
|
+
cursor: parsedOptions.data.cursor,
|
|
9912
|
+
limit: parsedOptions.data.limit
|
|
9913
|
+
};
|
|
9914
|
+
const response = await withCancellation(() => this.client.toolRouter.session.configHistory(this.sessionId, query, requestOptions), requestOptions?.signal);
|
|
9915
|
+
return {
|
|
9916
|
+
items: response.items.map((item) => ({
|
|
9917
|
+
version: item.version,
|
|
9918
|
+
createdAt: item.created_at,
|
|
9919
|
+
isCurrent: item.is_current,
|
|
9920
|
+
config: item.config
|
|
9921
|
+
})),
|
|
9922
|
+
nextCursor: response.next_cursor ?? null,
|
|
9923
|
+
totalPages: response.total_pages,
|
|
9924
|
+
currentPage: response.current_page,
|
|
9925
|
+
totalItems: response.total_items
|
|
9926
|
+
};
|
|
9927
|
+
}
|
|
7841
9928
|
/** Check if this session has any custom tools bound. */
|
|
7842
9929
|
hasCustomTools() {
|
|
7843
9930
|
return (this.customToolsMap?.byFinalSlug.size ?? 0) > 0;
|
|
@@ -7993,12 +10080,27 @@ var ToolRouter = class {
|
|
|
7993
10080
|
this.config = config;
|
|
7994
10081
|
telemetry.instrument(this, "ToolRouter");
|
|
7995
10082
|
}
|
|
7996
|
-
|
|
7997
|
-
|
|
10083
|
+
/**
|
|
10084
|
+
* Derives the MCP config for a session from the auth context the session
|
|
10085
|
+
* request was made with: the project key when one is configured, otherwise
|
|
10086
|
+
* the resolved user API key, plus the org/project scope when configured.
|
|
10087
|
+
* Headers are only attached when the MCP URL shares the client's API
|
|
10088
|
+
* origin. Any other destination throws when the caller passed `mcp: true`
|
|
10089
|
+
* and otherwise yields empty headers plus a warning; see
|
|
10090
|
+
* `buildMCPServerConfig`.
|
|
10091
|
+
*/
|
|
10092
|
+
createMCPServerConfig({ type, url }, mcpRequested) {
|
|
10093
|
+
return buildMCPServerConfig({
|
|
7998
10094
|
type,
|
|
7999
10095
|
url,
|
|
8000
|
-
|
|
8001
|
-
|
|
10096
|
+
apiBaseURL: this.client.baseURL,
|
|
10097
|
+
apiKey: this.config?.apiKey,
|
|
10098
|
+
userApiKey: this.config?.userApiKey,
|
|
10099
|
+
defaultHeaders: this.config?.defaultHeaders,
|
|
10100
|
+
orgId: this.config?.orgId,
|
|
10101
|
+
projectId: this.config?.projectId,
|
|
10102
|
+
mcpRequested
|
|
10103
|
+
});
|
|
8002
10104
|
}
|
|
8003
10105
|
async create(userId, config, requestOptions) {
|
|
8004
10106
|
const routerConfig = ToolRouterCreateSessionConfigSchema.parse(config ?? {});
|
|
@@ -8045,7 +10147,7 @@ var ToolRouter = class {
|
|
|
8045
10147
|
inlineCustomToolsPayload
|
|
8046
10148
|
};
|
|
8047
10149
|
const assistivePrompt = session.experimental?.assistive_prompt;
|
|
8048
|
-
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), { assistivePrompt }, customToolsMap, userId, metadata);
|
|
10150
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp, routerConfig.mcp === true), { assistivePrompt }, customToolsMap, userId, metadata);
|
|
8049
10151
|
}
|
|
8050
10152
|
async use(id, options, requestOptions) {
|
|
8051
10153
|
const customTools = options?.customTools;
|
|
@@ -8078,7 +10180,7 @@ var ToolRouter = class {
|
|
|
8078
10180
|
preloadedCustomToolSlugs: getPreloadedCustomToolSlugs(customToolsMap, defaultCustomPreload),
|
|
8079
10181
|
inlineCustomToolsPayload
|
|
8080
10182
|
};
|
|
8081
|
-
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp), void 0, customToolsMap, userId, metadata);
|
|
10183
|
+
return new ToolRouterSession(this.client, this.config, session.session_id, this.createMCPServerConfig(session.mcp, options?.mcp === true), void 0, customToolsMap, userId, metadata);
|
|
8082
10184
|
}
|
|
8083
10185
|
/**
|
|
8084
10186
|
* Delete a tool router session by ID.
|
|
@@ -8109,6 +10211,29 @@ var Sessions = class extends ToolRouter {
|
|
|
8109
10211
|
//#endregion
|
|
8110
10212
|
//#region src/composio.ts
|
|
8111
10213
|
/**
|
|
10214
|
+
* Level for the API client given the SDK level. The client logs each request's
|
|
10215
|
+
* lifecycle at `info`, which is debug-grade for SDK users, so the client stays
|
|
10216
|
+
* at `warn` unless the SDK is at `debug`. The client's `LogLevel` has
|
|
10217
|
+
* `'off'` where the SDK has `'silent'`.
|
|
10218
|
+
*/
|
|
10219
|
+
const toClientLogLevel = (level) => {
|
|
10220
|
+
if (level === "silent") return "off";
|
|
10221
|
+
if (level === "info") return "warn";
|
|
10222
|
+
return level;
|
|
10223
|
+
};
|
|
10224
|
+
/**
|
|
10225
|
+
* Forwards the API client's log records to the SDK singleton so they pick up
|
|
10226
|
+
* the SDK's formatting, redaction, and configured sink. Methods are looked up
|
|
10227
|
+
* at call time so a later `logger.configure()` is honoured. The client's
|
|
10228
|
+
* `info` records (per-request lifecycle) are forwarded as SDK `debug`.
|
|
10229
|
+
*/
|
|
10230
|
+
const clientLoggerAdapter = {
|
|
10231
|
+
error: (...args) => logger.error(...args),
|
|
10232
|
+
warn: (...args) => logger.warn(...args),
|
|
10233
|
+
info: (...args) => logger.debug(...args),
|
|
10234
|
+
debug: (...args) => logger.debug(...args)
|
|
10235
|
+
};
|
|
10236
|
+
/**
|
|
8112
10237
|
* This is the core class for Composio.
|
|
8113
10238
|
* It is used to initialize the Composio SDK and provide a global configuration.
|
|
8114
10239
|
*/
|
|
@@ -8141,6 +10266,15 @@ var Composio = class Composio {
|
|
|
8141
10266
|
/** Manage authenticated connections */
|
|
8142
10267
|
connectedAccounts;
|
|
8143
10268
|
/**
|
|
10269
|
+
* Manage the project's webhook subscription (`webhooks.subscriptions`) and
|
|
10270
|
+
* inbound per-toolkit webhook endpoints (`webhooks.endpoints`).
|
|
10271
|
+
*/
|
|
10272
|
+
webhooks;
|
|
10273
|
+
/** Search and inspect tool-execution logs */
|
|
10274
|
+
logs;
|
|
10275
|
+
/** Public transfer keys of the organization's customer-managed keyring */
|
|
10276
|
+
keyring;
|
|
10277
|
+
/**
|
|
8144
10278
|
* Experimental SDK methods whose shape may change in future releases.
|
|
8145
10279
|
* Prefer domain-specific mounts (for example
|
|
8146
10280
|
* `composio.connectedAccounts.updateAcl(...)`) when available; this
|
|
@@ -8245,7 +10379,25 @@ var Composio = class Composio {
|
|
|
8245
10379
|
* ```
|
|
8246
10380
|
*/
|
|
8247
10381
|
constructor(config) {
|
|
8248
|
-
const
|
|
10382
|
+
const scope = resolveSDKScope({
|
|
10383
|
+
orgId: config?.orgId,
|
|
10384
|
+
projectId: config?.projectId,
|
|
10385
|
+
defaultHeaders: config?.defaultHeaders
|
|
10386
|
+
});
|
|
10387
|
+
const { baseURL: baseURLParsed, apiKey: apiKeyParsed } = getSDKConfig(config?.baseURL, config?.apiKey, {
|
|
10388
|
+
defaultHeaders: config?.defaultHeaders,
|
|
10389
|
+
userApiKey: config?.userApiKey,
|
|
10390
|
+
orgApiKey: config?.orgApiKey
|
|
10391
|
+
});
|
|
10392
|
+
const userApiKey = apiKeyParsed === null ? resolveUserApiKey(config?.userApiKey) : void 0;
|
|
10393
|
+
const defaultHeadersInput = userApiKey !== void 0 && !getUserApiKeyHeader(config?.defaultHeaders) ? {
|
|
10394
|
+
...config?.defaultHeaders,
|
|
10395
|
+
[USER_API_KEY_HEADER]: userApiKey
|
|
10396
|
+
} : config?.defaultHeaders;
|
|
10397
|
+
if (config?.logger !== void 0 || config?.logLevel !== void 0) logger.configure({
|
|
10398
|
+
level: config.logLevel,
|
|
10399
|
+
sink: config.logger
|
|
10400
|
+
});
|
|
8249
10401
|
if (IS_DEVELOPMENT_OR_CI) logger.debug(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
|
|
8250
10402
|
/**
|
|
8251
10403
|
* Set the default provider, if not provided by the user.
|
|
@@ -8259,6 +10411,7 @@ var Composio = class Composio {
|
|
|
8259
10411
|
...config,
|
|
8260
10412
|
baseURL: baseURLParsed,
|
|
8261
10413
|
apiKey: apiKeyParsed,
|
|
10414
|
+
defaultHeaders: defaultHeadersInput,
|
|
8262
10415
|
toolkitVersions: getToolkitVersionsFromEnv(config?.toolkitVersions),
|
|
8263
10416
|
allowTracking: config?.allowTracking ?? CONFIG_DEFAULTS.allowTracking,
|
|
8264
10417
|
dangerouslyAllowAutoUploadDownloadFiles: config?.dangerouslyAllowAutoUploadDownloadFiles ?? CONFIG_DEFAULTS.dangerouslyAllowAutoUploadDownloadFiles,
|
|
@@ -8266,19 +10419,29 @@ var Composio = class Composio {
|
|
|
8266
10419
|
fileUploadPathDenySegments: config?.fileUploadPathDenySegments,
|
|
8267
10420
|
fileUploadDirs: expandHomeAndResolveMany(config?.fileUploadDirs),
|
|
8268
10421
|
fileDownloadDir: expandHomeAndResolve(config?.fileDownloadDir),
|
|
8269
|
-
provider: config?.provider ?? this.provider
|
|
10422
|
+
provider: config?.provider ?? this.provider,
|
|
10423
|
+
orgId: scope.orgId,
|
|
10424
|
+
projectId: scope.projectId
|
|
8270
10425
|
};
|
|
8271
|
-
const defaultHeaders = getDefaultHeaders(
|
|
10426
|
+
const defaultHeaders = getDefaultHeaders({
|
|
10427
|
+
...this.config.defaultHeaders,
|
|
10428
|
+
...getScopeHeaders(scope)
|
|
10429
|
+
}, this.provider);
|
|
8272
10430
|
/**
|
|
8273
10431
|
* Initialize the Composio SDK client.
|
|
8274
10432
|
* The client is used to make API calls to the Composio API.
|
|
8275
10433
|
*/
|
|
8276
10434
|
this.client = new ComposioClient({
|
|
8277
10435
|
apiKey: apiKeyParsed,
|
|
10436
|
+
userApiKey: config?.userApiKey,
|
|
10437
|
+
orgApiKey: config?.orgApiKey,
|
|
8278
10438
|
baseURL: baseURLParsed,
|
|
8279
10439
|
defaultHeaders,
|
|
8280
|
-
|
|
10440
|
+
logger: clientLoggerAdapter,
|
|
10441
|
+
logLevel: toClientLogLevel(logger.getLevel())
|
|
8281
10442
|
});
|
|
10443
|
+
this.config.userApiKey = this.client.userApiKey;
|
|
10444
|
+
this.config.orgApiKey = this.client.orgApiKey;
|
|
8282
10445
|
this.tools = new Tools(this.client, this.config);
|
|
8283
10446
|
this.mcp = new MCP(this.client);
|
|
8284
10447
|
this.toolkits = new Toolkits(this.client);
|
|
@@ -8290,6 +10453,9 @@ var Composio = class Composio {
|
|
|
8290
10453
|
fileDownloadDir: this.config.fileDownloadDir
|
|
8291
10454
|
});
|
|
8292
10455
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
10456
|
+
this.webhooks = new Webhooks(this.client);
|
|
10457
|
+
this.logs = new Logs(this.client);
|
|
10458
|
+
this.keyring = new Keyring(this.client);
|
|
8293
10459
|
this.experimental = new Experimental(this.client);
|
|
8294
10460
|
this.sessions = new Sessions(this.client, this.config);
|
|
8295
10461
|
this.toolRouter = this.sessions;
|
|
@@ -8378,7 +10544,11 @@ var Composio = class Composio {
|
|
|
8378
10544
|
* ```
|
|
8379
10545
|
*/
|
|
8380
10546
|
createSession(options) {
|
|
8381
|
-
const
|
|
10547
|
+
const userApiKeyHeader = getUserApiKeyHeader(options?.headers) ? void 0 : getUserApiKeyHeader(this.config.defaultHeaders);
|
|
10548
|
+
const sessionHeaders = getDefaultHeaders(userApiKeyHeader ? {
|
|
10549
|
+
[userApiKeyHeader.name]: userApiKeyHeader.value,
|
|
10550
|
+
...options?.headers
|
|
10551
|
+
} : options?.headers, this.provider);
|
|
8382
10552
|
return new Composio({
|
|
8383
10553
|
...this.config,
|
|
8384
10554
|
defaultHeaders: sessionHeaders
|
|
@@ -9213,4 +11383,4 @@ const ComposioMcpUpdateResponseSchema = z$1.object({
|
|
|
9213
11383
|
});
|
|
9214
11384
|
|
|
9215
11385
|
//#endregion
|
|
9216
|
-
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, ComposioToolFetchError, 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, 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, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterSandboxConfigSchema, ToolRouterSession, ToolRouterSessionDeleteResponseSchema, ToolRouterSessionEnsureConnectedOptionsSchema, 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, readResponseBodyWithLimit, removeNonRequiredProperties, restoreOriginalKeys, sanitizeSchemaPropertyKeys, telemetry, toStrictJsonSchema };
|
|
11386
|
+
export { AuthConfigCreationToolAccessConfigSchema, AuthConfigErrorCodes, AuthConfigListParamsSchema, AuthConfigListResponseSchema, AuthConfigRetrieveResponseSchema, AuthConfigToolAccessConfigSchema, AuthConfigTypes, AuthConfigUpdateParamsSchema, AuthCustomConfigUpdateParamsSchema, AuthDefaultConfigUpdateParamsSchema, AuthScheme, AuthSchemeEnum, AuthSchemeTypes, BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS, BaseAgenticProvider, BaseNonAgenticProvider, BillcomAuthConnectionDataSchema, Composio, ComposioAPIKeyKindError, ComposioAclOnlyForSharedError, ComposioAuthConfigNotFoundError, ComposioBlockedInternalUrlError, ComposioConnectedAccountNotFoundError, ComposioConnectedAccountNotRevokableError, ComposioConnectedAccountRevocationNotSupportedError, ComposioCustomCreateResponseSchema, ComposioError, ComposioFailedToCreateConnectedAccountLink, ComposioFailedToCreatePusherClientError, ComposioFailedToGetSDKRealtimeCredentialsError, ComposioFailedToSubscribeToPusherChannelError, ComposioFailedToUnsubscribeFromPusherChannelError, ComposioFileNotFoundError, ComposioFileUploadAbortedError, ComposioFileUploadError, ComposioFileUploadPathNotAllowedError, ComposioGenerateURLParamsSchema, ComposioGenerateURLResponseSchema, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioInvalidToolArgumentsError, ComposioLegacyConnectedAccountsEndpointRetiredError, ComposioMCPDestinationError, ComposioMcpDeleteResponseSchema, ComposioMcpListResponseSchema, ComposioMcpRetrieveResponseSchema, ComposioMcpUpdateResponseSchema, ComposioMultipleConnectedAccountsError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioRequestCancelledError, ComposioScopeConfigError, ComposioSensitiveFilePathBlockedError, ComposioSessionConfigConflictError, ComposioSharedAccessDeniedError, ComposioSharedConnectionNotAccessibleError, ComposioToolExecutionError, ComposioToolFetchError, ComposioToolNotFoundError, ComposioToolVersionRequiredError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ComposioTriggerTypeNotFoundError, ComposioWebhookPayloadError, ComposioWebhookSignatureVerificationError, ConnectedAccountAclConfigResponseSchema, ConnectedAccountAclConfigSchema, ConnectedAccountAuthConfigSchema, ConnectedAccountCompleteAuthParamsSchema, ConnectedAccountCompleteAuthResponseSchema, ConnectedAccountErrorCodes, ConnectedAccountExperimentalResponseSchema, ConnectedAccountExperimentalSchema, ConnectedAccountListParamsSchema, ConnectedAccountListResponseSchema, ConnectedAccountRefreshOptionsSchema, ConnectedAccountRetrieveResponseSchema, ConnectedAccountRevokeResponseSchema, ConnectedAccountRevokedTokenSchema, ConnectedAccountStatusSchema, ConnectedAccountStatuses, ConnectedAccountTypeSchema, ConnectedAccountTypes, ConnectionDataSchema, ConnectionExpiredEventSchema, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConnectionStatus, ConnectionStatuses, CreateAuthConfigParamsSchema, CreateAuthConfigResponseSchema, CreateComposioManagedAuthConfigParamsSchema, CreateConnectedAccountLinkOptionsSchema, CreateConnectedAccountLinkResponseSchema, CreateConnectedAccountOptionsSchema, CreateConnectedAccountParamsSchema, CreateConnectedAccountResponseSchema, CreateCustomAuthConfigParamsSchema, CreateCustomToolBaseSchema, CreateCustomToolkitBaseSchema, CustomAuthParamsSchema, CustomConnectionDataSchema, CustomCreateResponseSchema, CustomOauth1ConnectionDataSchema, CustomOauth2ConnectionDataSchema, CustomToolSlugSchema, CustomToolkitAuthSchemeSchema, CustomToolkitDeleteResponseSchema, CustomToolkitSyncParamsSchema, CustomToolkitSyncResponseSchema, CustomToolkitUpsertParamsSchema, CustomToolkitUpsertResponseSchema, CustomToolkits, DefaultCreateConnectedAccountParamsSchema, DefaultWebhookSubscriptionEvents, Experimental, FileDeleteResponseSchema, FileListResponseSchema, FileModifierErrorCodes, GenerateURLParamsSchema, GenerateURLResponseSchema, IncomingTriggerPayloadSchema, JSONSchemaPropertySchema, JsonSchemaRefResolutionError, JsonSchemaToZodError, Keyring, KeyringTransferKeySchema, KeyringTransferKeysResponseSchema, LogSearchFilterFieldSchema, LogSearchFilterOperatorSchema, LogSearchFilterSchema, LogSearchParamsSchema, LogSearchResponseSchema, LogSearchTimeRangeSchema, Logs, MAX_URL_UPLOAD_SIZE_BYTES, MCP, MCPAuthOptionsSchema, MCPGenerateURLParamsSchema, MCPGetServerParamsSchema, MCPMultiAppServerSchema, MCPServerCreateResponseSchema, MCPServerListResponseSchema, MCPServerSchema, MCPServerTypeSchema, MCPServerUpdateParamsSchema, MCPSingleAppServerSchema, MCPToolkitConfigSchema, MCPToolkitConfigsArraySchema, McpDeleteResponseSchema, McpListResponseSchema, McpRetrieveResponseSchema, McpUpdateResponseSchema, Oauth1ActiveConnectionDataSchema, Oauth1ConnectionDataSchema, Oauth1ExpiredConnectionDataSchema, Oauth1FailedConnectionDataSchema, Oauth1InactiveConnectionDataSchema, Oauth1InitiatedConnectionDataSchema, Oauth1InitiatingConnectionDataSchema, Oauth2ActiveConnectionDataSchema, Oauth2ConnectionDataSchema, Oauth2ExpiredConnectionDataSchema, Oauth2FailedConnectionDataSchema, Oauth2InactiveConnectionDataSchema, Oauth2InitiatedConnectionDataSchema, Oauth2InitiatingConnectionDataSchema, Oauth2RevokedConnectionDataSchema, OpenAIProvider, RedirectableAuthSchemeSchema, RemoteFile, RemoteFileDataSchema, RemoteFileDownloadError, RemoteFileErrorCodes, SDKErrorCodes, SandboxSizeSchema, SessionPreset, SessionProxyExecuteParamsSchema, Sessions, SetWebhookSubscriptionParamsSchema, SingleConnectedAccountDetailedResponseSchema, SsrfErrorCodes, ToolErrorCodes, ToolExecuteMetaParamsSchema, ToolExecuteParamsSchema, ToolExecuteResponseSchema, ToolExecutionLogDetailSchema, ToolExecutionLogLevelSchema, ToolExecutionLogParentSchema, ToolExecutionLogSchema, ToolExecutionLogStatusSchema, ToolKitItemSchema, ToolKitListResponseSchema, ToolKitMetaSchema, ToolListParamsSchema, ToolListResponseSchema, ToolProxyParamsSchema, ToolRouterConfigManageConnectionsSchema, ToolRouterConfigTagsSchema, ToolRouterConfigToolsSchema, ToolRouterCreateSessionConfigSchema, ToolRouterErrorCodes, ToolRouterMCPServerConfigSchema, ToolRouterManageConnectionsConfigSchema, ToolRouterSandboxConfigSchema, ToolRouterSession, ToolRouterSessionDeleteResponseSchema, ToolRouterSessionEnsureConnectedOptionsSchema, ToolRouterSessionExecuteResponseSchema, ToolRouterSessionFilesMountDeleteOptionsSchema, ToolRouterSessionFilesMountDownloadOptionsSchema, ToolRouterSessionFilesMountListOptionsSchema, ToolRouterSessionFilesMountUploadOptionsSchema, ToolRouterSessionListConfigHistoryOptionsSchema, ToolRouterSessionSearchResponseSchema, ToolRouterTagsEnableDisableSchema, ToolRouterTagsParamSchema, ToolRouterToolkitsDisabledConfigSchema, ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsOptionsSchema, ToolRouterToolkitsParamSchema, ToolRouterToolsParamSchema, ToolRouterUpdateExperimentalSchema, ToolRouterUpdateManageConnectionsSchema, ToolRouterUpdateSessionConfigSchema, ToolSchema, ToolkitAuthConfigDetailsSchema, ToolkitAuthFieldSchema, ToolkitAuthFieldsResponseSchema, ToolkitCategorySchema, ToolkitChangelogItemSchema, ToolkitChangelogResponseSchema, ToolkitConditionalScopeSchema, ToolkitConnectionStateSchema, ToolkitConnectionsDetailsSchema, ToolkitErrorCodes, ToolkitGetManySlugsSchema, ToolkitGrantContextDimensionSchema, ToolkitLatestVersionSchema, ToolkitListGrantContextsParamsSchema, ToolkitListGrantContextsResponseSchema, ToolkitMangedByEnumSchema, ToolkitRecommendScopesParamsSchema, ToolkitRecommendScopesResponseSchema, ToolkitRetrieveCategoriesResponseSchema, ToolkitRetrieveResponseSchema, ToolkitSchema, ToolkitSortByEnumSchema, ToolkitVersionChangelogSchema, ToolkitVersionParamSchema, ToolkitVersionSchema, ToolkitVersionsSchema, ToolkitsGetManyParamsSchema, ToolkitsListParamsSchema, TriggerErrorCodes, TriggerInstanceListActiveParamsSchema, TriggerInstanceListActiveResponseItemSchema, TriggerInstanceListActiveResponseSchema, TriggerInstanceManageDeleteResponseSchema, TriggerInstanceManageUpdateParamsSchema, TriggerInstanceManageUpdateResponseSchema, TriggerInstanceUpsertParamsSchema, TriggerInstanceUpsertResponseSchema, TriggerStatusEnum, TriggerStatuses, TriggerSubscribeParamSchema, TriggerTypeSchema, TriggersTypeListParamsSchema, TriggersTypeListResponseSchema, UpdateConnectedAccountAclParamsSchema, UpdateConnectedAccountParamsSchema, Usage, UsageBreakdownGroupSchema, UsageBreakdownParamsSchema, UsageBreakdownResponseSchema, UsageEntitySummarySchema, UsageFiltersSchema, UsageOrderBySchema, UsageOrderDirectionSchema, UsageSummaryParamsSchema, UsageSummaryResponseSchema, ValidationError, ValidationErrorCodes, VerifyWebhookParamsSchema, WebhookConnectedAccountAuthConfigSchema, WebhookConnectionMetadataSchema, WebhookConnectionStateSchema, WebhookEndpointCreateParamsSchema, WebhookEndpointListItemSchema, WebhookEndpointListParamsSchema, WebhookEndpointListResponseSchema, WebhookEndpointReplaceParamsSchema, WebhookEndpointSchema, WebhookEndpointUpdateParamsSchema, WebhookEndpoints, WebhookEventSchema, WebhookEventTypes, WebhookPayloadSchema, WebhookPayloadV1Schema, WebhookPayloadV2Schema, WebhookPayloadV3Schema, WebhookSubscriptionDeleteResponseSchema, WebhookSubscriptionEventTypeSchema, WebhookSubscriptionEventTypesResponseSchema, WebhookSubscriptionListParamsSchema, WebhookSubscriptionListResponseSchema, WebhookSubscriptionRotateSecretResponseSchema, WebhookSubscriptionSchema, WebhookSubscriptionSetParamsSchema, WebhookSubscriptionUpdateParamsSchema, WebhookSubscriptions, WebhookTriggerPayloadV3Schema, WebhookVersionSchema, WebhookVersions, Webhooks, assertSafeFileUploadPath, constants_exports as constants, createConnectionRequest, deduplicateJsonSchemaRequiredArrays, dereferenceJsonSchema, ensureObjectTypeOnProperties, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit, getExtensionFromMimeType, handleToolExecutionError, isBlockedSensitiveFileUploadPath, isRequestAbortError, jsonSchemaToZodSchema, logger, mappingHasRenames, normalizeToolArguments, omitNullToolArguments, readResponseBodyWithLimit, removeNonRequiredProperties, restoreOriginalKeys, sanitizeSchemaPropertyKeys, telemetry, toStrictJsonSchema };
|