@composio/core 0.23.0 → 0.25.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.
Files changed (50) hide show
  1. package/dist/{CustomTool-CnJxXr07.mjs → CustomTool-BYHB7sPs.mjs} +1 -1
  2. package/dist/{CustomTool-CnHdegDK.d.mts → CustomTool-DZY1yLHN.d.mts} +1 -1
  3. package/dist/{cancellation-BQibgpRG.mjs → cancellation-D-tMPk48.mjs} +1 -1
  4. package/dist/{composio-Dq708dZS.d.mts → composio-B8AENilE.d.mts} +74 -62
  5. package/dist/{customTool.types-B8lVpHOP.d.mts → customTool.types-Bi6-keZC.d.mts} +612 -141
  6. package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +10 -10
  7. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +2 -2
  8. package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +22 -22
  9. package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +8 -8
  10. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +2 -2
  11. package/dist/docs/reference/sdk-reference/typescript/index.mdx +1 -1
  12. package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +2 -2
  13. package/dist/docs/reference/sdk-reference/typescript/logs.mdx +5 -5
  14. package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +15 -15
  15. package/dist/docs/reference/sdk-reference/typescript/meta.json +1 -1
  16. package/dist/docs/reference/sdk-reference/typescript/session-configs.mdx +5 -5
  17. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +10 -10
  18. package/dist/docs/reference/sdk-reference/typescript/session.mdx +56 -21
  19. package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +6 -6
  20. package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +22 -22
  21. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +18 -18
  22. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +25 -25
  23. package/dist/docs/reference/sdk-reference/typescript/usage.mdx +6 -6
  24. package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +14 -14
  25. package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +13 -13
  26. package/dist/{errors-BN15NcCW.mjs → errors-Cly0vXFh.mjs} +5 -5
  27. package/dist/experimental/index.d.mts +2 -2
  28. package/dist/experimental/index.mjs +1 -1
  29. package/dist/index.d.mts +31 -7
  30. package/dist/index.mjs +382 -147
  31. package/dist/{types-eTw8Yw7Y.d.mts → types-BGDMkEUl.d.mts} +2 -2
  32. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
  33. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
  34. package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
  35. package/dist/utils/modifiers/FileToolModifier.node.mjs +2 -2
  36. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  37. package/package.json +8 -8
  38. package/src/composio.ts +19 -16
  39. package/src/errors/ToolRouterErrors.ts +5 -5
  40. package/src/lib/toolRouterParams.ts +44 -16
  41. package/src/models/MCP.ts +20 -1
  42. package/src/models/ToolRouter.ts +9 -0
  43. package/src/models/ToolRouterSession.ts +68 -0
  44. package/src/models/Triggers.ts +8 -6
  45. package/src/services/pusher/Pusher.ts +159 -88
  46. package/src/types/pusher.types.ts +2 -0
  47. package/src/types/toolRouter.types.ts +190 -19
  48. package/src/utils/session.ts +25 -47
  49. package/src/utils/transformers/toolRouterResponseTransform.ts +8 -2
  50. package/src/utils/userCallback.ts +41 -0
@@ -1,5 +1,5 @@
1
- import { rr as BaseComposioProvider } from "./customTool.types-B8lVpHOP.mjs";
2
- import { n as ComposioConfig } from "./composio-Dq708dZS.mjs";
1
+ import { dr as BaseComposioProvider } from "./customTool.types-Bi6-keZC.mjs";
2
+ import { n as ComposioConfig } from "./composio-B8AENilE.mjs";
3
3
  //#region src/utils/config-defaults/types.d.ts
4
4
  /**
5
5
  * Configuration defaults for Composio.
@@ -1,4 +1,4 @@
1
- import { t as ConfigDefaults } from "../../types-eTw8Yw7Y.mjs";
1
+ import { t as ConfigDefaults } from "../../types-BGDMkEUl.mjs";
2
2
  //#region src/utils/config-defaults/ConfigDefaults.node.d.ts
3
3
  export declare const CONFIG_DEFAULTS: ConfigDefaults;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { t as ConfigDefaults } from "../../types-eTw8Yw7Y.mjs";
1
+ import { t as ConfigDefaults } from "../../types-BGDMkEUl.mjs";
2
2
  //#region src/utils/config-defaults/ConfigDefaults.workerd.d.ts
3
3
  export declare const CONFIG_DEFAULTS: ConfigDefaults;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { Sa as ToolExecuteParams, wa as ToolExecuteResponse, ya as Tool } from "../../customTool.types-B8lVpHOP.mjs";
1
+ import { Aa as ToolExecuteParams, Da as Tool, Ma as ToolExecuteResponse } from "../../customTool.types-Bi6-keZC.mjs";
2
2
  import ComposioClient from "@composio/client";
3
3
  //#region src/utils/modifiers/FileToolModifier.node.d.ts
4
4
  export declare class FileToolModifier {
@@ -1,8 +1,8 @@
1
1
  import { i as logger } from "../../SsrfErrors-DiQldIdC.mjs";
2
- import { _ as ComposioRequestCancelledError } from "../../errors-BN15NcCW.mjs";
2
+ import { _ as ComposioRequestCancelledError } from "../../errors-Cly0vXFh.mjs";
3
3
  import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "../../FileModifierErrors-CdGSABoq.mjs";
4
4
  import { a as isEmptyFileValue, c as transformProperties, i as getSchemaVariants, l as walkFileUploadableLeaves, o as isPlainObject, r as findSchemaVariantWithFileProperty, t as DELETE_VALUE } from "../../FileToolModifier.utils.neutral-DWFpnsj2.mjs";
5
- import { r as dereferenceJsonSchema, t as withCancellation } from "../../cancellation-BQibgpRG.mjs";
5
+ import { r as dereferenceJsonSchema, t as withCancellation } from "../../cancellation-D-tMPk48.mjs";
6
6
  import { n as getFileDataAfterUploadingToS3, r as isHttpUrl, t as downloadFileFromS3 } from "../../fileUtils.node-DNLhLg0W.mjs";
7
7
 
8
8
  //#region src/utils/modifiers/FileToolModifier.node.ts
@@ -1,4 +1,4 @@
1
- import { Sa as ToolExecuteParams, wa as ToolExecuteResponse, ya as Tool } from "../../customTool.types-B8lVpHOP.mjs";
1
+ import { Aa as ToolExecuteParams, Da as Tool, Ma as ToolExecuteResponse } from "../../customTool.types-Bi6-keZC.mjs";
2
2
  import ComposioClient from "@composio/client";
3
3
  //#region src/utils/modifiers/FileToolModifier.workerd.d.ts
4
4
  export declare class FileToolModifier {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "engines": {
5
5
  "node": ">=22.22.3"
6
6
  },
7
- "version": "0.23.0",
7
+ "version": "0.25.0",
8
8
  "description": "",
9
9
  "main": "dist/index.mjs",
10
10
  "publishConfig": {
@@ -111,31 +111,31 @@
111
111
  ],
112
112
  "license": "ISC",
113
113
  "devDependencies": {
114
- "@hono/node-server": "^2.1.1",
114
+ "@hono/node-server": "^2.1.4",
115
115
  "@type-challenges/utils": "^0.1.1",
116
116
  "@types/semver": "^7.8.0",
117
117
  "ajv": "^8.20.0",
118
118
  "fast-check": "^4.10.2",
119
- "hono": "^4.13.8",
120
- "tsdown": "^0.23.0",
119
+ "hono": "^4.13.13",
120
+ "tsdown": "^0.23.1",
121
121
  "tsx": "^4.23.15",
122
122
  "typedoc": "^0.28.20",
123
123
  "typescript": "npm:@typescript/typescript6@^6.0.2",
124
- "vitest": "^5.0.1",
124
+ "vitest": "^5.0.3",
125
125
  "zod": "^4.5.4"
126
126
  },
127
127
  "peerDependencies": {
128
128
  "zod": ">=3.25.76 <5"
129
129
  },
130
130
  "dependencies": {
131
- "@composio/client": "2.0.0-rc.11",
131
+ "@composio/client": "2.0.0-rc.17",
132
132
  "@types/json-schema": "^7.0.15",
133
133
  "is-fs-case-sensitive": "^2.0.0",
134
- "openai": "^7.21.0",
134
+ "openai": "^7.32.0",
135
135
  "picocolors": "^1.1.1",
136
136
  "pusher-js": "^8.6.0",
137
137
  "semver": "^7.8.5",
138
- "undici": "^7.29.1",
138
+ "undici": "^7.30.0",
139
139
  "zod-to-json-schema": "^3.25.2",
140
140
  "@composio/json-schema-to-zod": "0.3.4"
141
141
  },
package/src/composio.ts CHANGED
@@ -31,7 +31,7 @@ import { version } from '../package.json';
31
31
  import type { ComposioRequestHeaders } from './types/composio.types';
32
32
  import type { ComposioRequestOptions } from './types/requestOptions.types';
33
33
  import { Files } from '#files';
34
- import { getDefaultHeaders } from './utils/session';
34
+ import { getClientIdentity } from './utils/session';
35
35
  import { ToolkitVersionParam } from './types/tool.types';
36
36
  import { ToolRouter } from './models/ToolRouter';
37
37
  import { Sessions } from './models/Sessions';
@@ -171,8 +171,15 @@ export type ComposioConfig<
171
171
  * `x-user-api-key` is the one header the SDK treats as a credential: together
172
172
  * with `apiKey: null` it authenticates requests with a Composio user API key
173
173
  * instead of a project key. The project key is only ever set from `apiKey`:
174
- * an `x-api-key` entry is rejected when `apiKey` is `null`. Every other
175
- * header is passed through untouched.
174
+ * an `x-api-key` entry is rejected when `apiKey` is `null`.
175
+ *
176
+ * The SDK reports itself through the API client's identity headers
177
+ * (`x-client-provenance`, `x-client-version`, `x-client-library`,
178
+ * `x-client-library-version`, `x-client-language`, `x-client-runtime`,
179
+ * `x-sdk-version`, `x-source`, `x-framework`, `x-runtime` and
180
+ * `x-runtime-version`); an entry naming one of them is rejected with a
181
+ * `ComposioError` from `@composio/client`. Every other header is passed
182
+ * through untouched.
176
183
  * @example
177
184
  * ```typescript
178
185
  * const composio = new Composio({
@@ -514,14 +521,12 @@ export class Composio<
514
521
 
515
522
  // The resolved scope is the single source of the x-org-id / x-project-id
516
523
  // headers: it travels via `this.config` to clones and to the MCP export.
517
- const defaultHeaders = getDefaultHeaders(
518
- { ...this.config.defaultHeaders, ...getScopeHeaders(scope) },
519
- this.provider
520
- );
524
+ const defaultHeaders = { ...this.config.defaultHeaders, ...getScopeHeaders(scope) };
521
525
 
522
526
  /**
523
527
  * Initialize the Composio SDK client.
524
- * The client is used to make API calls to the Composio API.
528
+ * The client is used to make API calls to the Composio API. It sends the
529
+ * SDK's identity headers from `identity`, and refuses them in `defaultHeaders`.
525
530
  */
526
531
  this.client = new ComposioClient({
527
532
  apiKey: apiKeyParsed,
@@ -529,6 +534,7 @@ export class Composio<
529
534
  orgApiKey: config?.orgApiKey,
530
535
  baseURL: baseURLParsed,
531
536
  defaultHeaders: defaultHeaders,
537
+ identity: getClientIdentity(this.provider),
532
538
  logger: clientLoggerAdapter,
533
539
  logLevel: toClientLogLevel(logger.getLevel()),
534
540
  });
@@ -638,8 +644,8 @@ export class Composio<
638
644
  * instance directly with the headers you need: `new Composio({ ...existingConfig, defaultHeaders })`.
639
645
  * For one-off overrides, pass per-call `requestOptions` where supported.
640
646
  *
641
- * @param {MergedRequestInit} fetchOptions - Custom request options to be used for all API calls in this session.
642
- * This follows the Fetch API RequestInit interface with additional options.
647
+ * @param {object} [options] - Options for the new instance.
648
+ * @param {ComposioRequestHeaders} [options.headers] - Headers sent with every API call the new instance makes.
643
649
  * @returns {Composio<TProvider>} A new Composio instance with the custom request options applied.
644
650
  *
645
651
  * @example
@@ -669,12 +675,9 @@ export class Composio<
669
675
  const userApiKeyHeader = getUserApiKeyHeader(options?.headers)
670
676
  ? undefined
671
677
  : getUserApiKeyHeader(this.config.defaultHeaders);
672
- const sessionHeaders = getDefaultHeaders(
673
- userApiKeyHeader
674
- ? { [userApiKeyHeader.name]: userApiKeyHeader.value, ...options?.headers }
675
- : options?.headers,
676
- this.provider
677
- );
678
+ const sessionHeaders = userApiKeyHeader
679
+ ? { [userApiKeyHeader.name]: userApiKeyHeader.value, ...options?.headers }
680
+ : options?.headers;
678
681
  return new Composio({
679
682
  ...this.config,
680
683
  defaultHeaders: sessionHeaders,
@@ -80,9 +80,9 @@ export class ComposioSessionConfigConflictError extends ComposioError {
80
80
  *
81
81
  * `inputRequests` holds the questions, keyed by the ID the answers must
82
82
  * reuse. `requestState` is the opaque `request_state` the API returned; when
83
- * present it must be sent back unchanged together with the answers. The SDK
84
- * does not submit answers yet, so nothing was executed and the call is not
85
- * retried.
83
+ * present it must be sent back unchanged together with the answers. Nothing
84
+ * was executed and the call is not retried: to answer, repeat the same call
85
+ * with `inputResponses` and `requestState` in its options.
86
86
  */
87
87
  export class ComposioToolInputRequiredError extends ComposioError {
88
88
  /** Questions for the user, keyed by the ID the answers must reuse. */
@@ -104,12 +104,12 @@ export class ComposioToolInputRequiredError extends ComposioError {
104
104
  const count = Object.keys(details.inputRequests).length;
105
105
  super(
106
106
  `${subject} requires user input before it can run (${count} input request${count === 1 ? '' : 's'}) and was not executed. ` +
107
- 'The questions are on `inputRequests` and the opaque `request_state` to send back with the answers is on `requestState`.',
107
+ "The questions are on `inputRequests`. Repeat the call with the answers in `inputResponses` and this error's `requestState`.",
108
108
  {
109
109
  ...options,
110
110
  code: ToolRouterErrorCodes.TOOL_INPUT_REQUIRED,
111
111
  possibleFixes: options.possibleFixes ?? [
112
- 'Collect the answers described by `inputRequests`, then call the session execute endpoint again with `input_responses` and the unchanged `request_state`',
112
+ 'Collect the answers described by `inputRequests`, then repeat the same call with `{ inputResponses, requestState }` in its options',
113
113
  'Remove the tool, its toolkit or its tags from the `require_approval` lists of the session configuration if no approval is intended',
114
114
  ],
115
115
  }
@@ -18,6 +18,7 @@ import {
18
18
  ToolRouterUpdateExperimentalConfig,
19
19
  ToolRouterSandboxConfig,
20
20
  ToolRouterInstant,
21
+ ToolRouterProxyExecute,
21
22
  } from '../types/toolRouter.types';
22
23
  import { ValidationError } from '../errors';
23
24
  import { z } from 'zod';
@@ -28,14 +29,18 @@ type ParsedCreateSessionConfig = TypeOf<typeof ToolRouterCreateSessionConfigSche
28
29
  /** Parsed update input; the public `ToolRouterUpdateSessionConfig` is a union over it. */
29
30
  type ParsedUpdateSessionConfig = TypeOf<typeof ToolRouterUpdateSessionConfigSchema>;
30
31
 
32
+ /** A toolkit's entry in the session `tools` map, as sent on create and update. */
33
+ type SessionToolsEntry = NonNullable<SessionCreateParams['tools']>[string];
34
+
35
+ /** `require_approval` when the caller set an approval list, nothing otherwise. */
36
+ const requireApprovalParam = <T extends string>(
37
+ requireApproval: T[] | undefined
38
+ ): { require_approval?: T[] } =>
39
+ requireApproval !== undefined ? { require_approval: requireApproval } : {};
40
+
31
41
  export const transformToolRouterToolsParams = (
32
42
  params?: Record<string, ToolRouterToolsParam | ToolRouterConfigTools> | undefined
33
- ):
34
- | Record<
35
- string,
36
- SessionCreateParams.Enable | SessionCreateParams.Disable | SessionCreateParams.Tags
37
- >
38
- | undefined => {
43
+ ): Record<string, SessionToolsEntry> | undefined => {
39
44
  if (!params) {
40
45
  return undefined;
41
46
  }
@@ -52,14 +57,16 @@ export const transformToolRouterToolsParams = (
52
57
  if (Array.isArray(data)) {
53
58
  acc[key] = { enable: data };
54
59
  } else if ('enable' in data) {
55
- acc[key] = { enable: data.enable };
60
+ acc[key] = { enable: data.enable, ...requireApprovalParam(data.requireApproval) };
56
61
  } else if ('disable' in data) {
57
- acc[key] = { disable: data.disable };
62
+ acc[key] = { disable: data.disable, ...requireApprovalParam(data.requireApproval) };
58
63
  } else if ('tags' in data) {
59
64
  const tags = transformToolRouterTagsParams(data.tags);
60
65
  if (tags) {
61
- acc[key] = { tags };
66
+ acc[key] = { tags, ...requireApprovalParam(data.requireApproval) };
62
67
  }
68
+ } else {
69
+ acc[key] = { require_approval: data.requireApproval };
63
70
  }
64
71
  } else {
65
72
  throw new ValidationError(parsedResult.error.message);
@@ -69,10 +76,7 @@ export const transformToolRouterToolsParams = (
69
76
  }
70
77
  return acc;
71
78
  },
72
- {} as Record<
73
- string,
74
- SessionCreateParams.Enable | SessionCreateParams.Disable | SessionCreateParams.Tags
75
- >
79
+ {} as Record<string, SessionToolsEntry>
76
80
  );
77
81
  return result;
78
82
  }
@@ -90,6 +94,7 @@ export const transformToolRouterTagsParams = (
90
94
  return {
91
95
  enable: params.enable,
92
96
  disable: params.disable,
97
+ ...requireApprovalParam(params.requireApproval),
93
98
  };
94
99
  }
95
100
  };
@@ -203,6 +208,12 @@ export type SessionPatchBody = Omit<
203
208
  expected_config_version?: number;
204
209
  };
205
210
 
211
+ /** `proxy_execute` as sent on create and update: a boolean becomes `{ enable }`. */
212
+ export const transformToolRouterProxyExecuteParams = (
213
+ config: ToolRouterProxyExecute
214
+ ): NonNullable<SessionCreateParams['proxy_execute']> =>
215
+ typeof config === 'boolean' ? { enable: config } : config;
216
+
206
217
  export const transformToolRouterInstantParams = (
207
218
  config: ToolRouterInstant
208
219
  ): NonNullable<SessionCreateParams['instant']> => {
@@ -213,6 +224,9 @@ export const transformToolRouterInstantParams = (
213
224
  ...(config.returnInstantCharge !== undefined && {
214
225
  return_instant_charge: config.returnInstantCharge,
215
226
  }),
227
+ ...(config.returnPricesInSearch !== undefined && {
228
+ return_prices_in_search: config.returnPricesInSearch,
229
+ }),
216
230
  };
217
231
  };
218
232
 
@@ -266,6 +280,9 @@ const transformToolRouterUpdateExperimentalParams = (
266
280
  if (config.sessionConfigId !== undefined) {
267
281
  result.session_config_id = config.sessionConfigId;
268
282
  }
283
+ if (config.noElicitationSupportFallback !== undefined) {
284
+ result.no_elicitation_support_fallback = config.noElicitationSupportFallback;
285
+ }
269
286
  return result;
270
287
  };
271
288
 
@@ -322,7 +339,7 @@ export const transformToolRouterMultiAccountParams = (
322
339
 
323
340
  export const transformToolRouterToolkitsParams = (
324
341
  params?: ParsedCreateSessionConfig['toolkits']
325
- ): SessionCreateParams.Enable | SessionCreateParams.Disable | undefined => {
342
+ ): NonNullable<SessionCreateParams['toolkits']> | undefined => {
326
343
  if (!params) {
327
344
  return undefined;
328
345
  }
@@ -332,8 +349,13 @@ export const transformToolRouterToolkitsParams = (
332
349
  return { enable: params };
333
350
  }
334
351
 
335
- // Otherwise return as-is (already in enable/disable format)
336
- return params as SessionCreateParams.Enable | SessionCreateParams.Disable;
352
+ if ('enable' in params) {
353
+ return { enable: params.enable, ...requireApprovalParam(params.requireApproval) };
354
+ }
355
+ if ('disable' in params) {
356
+ return { disable: params.disable, ...requireApprovalParam(params.requireApproval) };
357
+ }
358
+ return { require_approval: params.requireApproval };
337
359
  };
338
360
 
339
361
  /**
@@ -391,6 +413,12 @@ export const transformToolRouterUpdateParams = (
391
413
  params.multi_account = ma;
392
414
  }
393
415
  }
416
+ if (config.proxyExecute !== undefined) {
417
+ params.proxy_execute =
418
+ config.proxyExecute === null
419
+ ? null
420
+ : transformToolRouterProxyExecuteParams(config.proxyExecute);
421
+ }
394
422
  if (config.preload !== undefined) {
395
423
  params.preload = config.preload;
396
424
  }
package/src/models/MCP.ts CHANGED
@@ -24,6 +24,7 @@ import { McpUpdateResponse } from '@composio/client/resources.js';
24
24
  import { McpRetrieveResponse } from '@composio/client/resources';
25
25
  import { ComposioRequestOptions } from '../types/requestOptions.types';
26
26
  import { withCancellation } from '../utils/cancellation';
27
+ import logger from '../utils/logger';
27
28
 
28
29
  function transformMCPItemResponse(response: McpUpdateResponse | McpRetrieveResponse): MCPItem {
29
30
  return transform(response)
@@ -40,6 +41,19 @@ function transformMCPItemResponse(response: McpUpdateResponse | McpRetrieveRespo
40
41
  toolkits: raw.toolkits,
41
42
  }));
42
43
  }
44
+
45
+ // `managed_auth_by_composio` is deprecated upstream, but dropping it would strip
46
+ // the connection-management tools from generated URLs. Keep sending it, silence
47
+ // the API client's notice (it names an internal call), and warn once per process
48
+ // in SDK terms instead.
49
+ const MANAGED_AUTH_DEPRECATION =
50
+ '[Deprecation] composio.mcp.generate() returns URLs that rely on the deprecated ' +
51
+ 'include_composio_helper_actions query parameter, which the API will remove in a ' +
52
+ 'future version. Switch to a session MCP endpoint: composio.create(userId, { mcp: true }) ' +
53
+ 'exposes session.mcp.url with connection-management tools built in. ' +
54
+ 'https://docs.composio.dev/docs/sessions-via-mcp';
55
+ let _managedAuthDeprecationWarned = false;
56
+
43
57
  /**
44
58
  * MCP (Model Control Protocol) class
45
59
  * Handles MCP server operations.
@@ -465,8 +479,13 @@ export class MCP {
465
479
  user_ids: [userId],
466
480
  managed_auth_by_composio: options?.manuallyManageConnections ? false : true,
467
481
  };
482
+ if (urlBody.managed_auth_by_composio && !_managedAuthDeprecationWarned) {
483
+ _managedAuthDeprecationWarned = true;
484
+ logger.warn(MANAGED_AUTH_DEPRECATION);
485
+ }
468
486
  const urlResponse = await withCancellation(
469
- () => this.client.mcp.generate.url(urlBody, requestOptions),
487
+ () =>
488
+ this.client.withOptions({ logLevel: 'error' }).mcp.generate.url(urlBody, requestOptions),
470
489
  requestOptions?.signal
471
490
  );
472
491
 
@@ -51,6 +51,7 @@ import {
51
51
  transformToolRouterToolkitsParams,
52
52
  transformToolRouterMultiAccountParams,
53
53
  transformToolRouterInstantParams,
54
+ transformToolRouterProxyExecuteParams,
54
55
  resolveToolRouterSandboxConfig,
55
56
  } from '../lib/toolRouterParams';
56
57
  import { PRELOAD_TOOLS_ALL } from '../lib/toolRouterConstants';
@@ -239,6 +240,11 @@ export class ToolRouter<
239
240
  experimentalPayload.session_config_id = routerConfig.experimental.sessionConfigId;
240
241
  }
241
242
 
243
+ if (routerConfig.experimental?.noElicitationSupportFallback !== undefined) {
244
+ experimentalPayload.no_elicitation_support_fallback =
245
+ routerConfig.experimental.noElicitationSupportFallback;
246
+ }
247
+
242
248
  if (routerConfig.experimental?.assistivePrompt?.userTimezone) {
243
249
  experimentalPayload.assistive_prompt_config = {
244
250
  user_timezone: routerConfig.experimental.assistivePrompt.userTimezone,
@@ -282,6 +288,9 @@ export class ToolRouter<
282
288
  ),
283
289
  workbench: sandboxPayload,
284
290
  multi_account: multiAccountPayload,
291
+ ...(routerConfig.proxyExecute !== undefined && {
292
+ proxy_execute: transformToolRouterProxyExecuteParams(routerConfig.proxyExecute),
293
+ }),
285
294
  preload: routerConfig.preload,
286
295
  ...(isDirectToolsPreset && {
287
296
  search: { enable: false },
@@ -21,6 +21,8 @@ import {
21
21
  ToolRouterSessionExecuteResponseSchema,
22
22
  ToolRouterSessionProxyExecuteResponse,
23
23
  ToolRouterSessionExecuteOptions,
24
+ ToolRouterSessionExecuteMetaOptions,
25
+ ToolRouterSessionMetaToolSlug,
24
26
  ToolRouterSessionConfig,
25
27
  ToolRouterSessionMetadata,
26
28
  ToolRouterSessionPreloadConfig,
@@ -71,6 +73,7 @@ import type {
71
73
  import { ToolSchema, type Tool, type ToolExecuteResponse } from '../types/tool.types';
72
74
  import type { SessionProxyExecuteParams } from '../types/toolRouter.types';
73
75
  import type {
76
+ SessionExecuteMetaParams,
74
77
  SessionExecuteParams,
75
78
  SessionLinkParams,
76
79
  SessionPatchParams,
@@ -96,6 +99,16 @@ import { getSourceSessionConfig } from '../lib/toolRouterSourceSessionConfig';
96
99
  import { deleteToolRouterSession } from '../lib/toolRouterSessionDelete';
97
100
 
98
101
  const COMPOSIO_MULTI_EXECUTE_TOOL = 'COMPOSIO_MULTI_EXECUTE_TOOL';
102
+
103
+ /** The request fields that carry the user's answers to an earlier `input_required` call. */
104
+ function inputResponseParams(
105
+ options: ToolRouterSessionExecuteMetaOptions | undefined
106
+ ): Pick<SessionExecuteParams, 'input_responses' | 'request_state'> {
107
+ return {
108
+ ...(options?.inputResponses !== undefined && { input_responses: options.inputResponses }),
109
+ ...(options?.requestState !== undefined && { request_state: options.requestState }),
110
+ };
111
+ }
99
112
  export const DIRECT_CUSTOM_TOOL_DESCRIPTION_PREFIX =
100
113
  '[Direct tool - call directly, no search needed beforehand.]';
101
114
 
@@ -682,6 +695,8 @@ export class ToolRouterSession<
682
695
  * @param arguments_ - Optional tool arguments
683
696
  * @param options - Optional execution options
684
697
  * @param options.account - Account identifier for direct app tool execution. Accepted on every project: in multi-account sessions it picks the account; on single-account projects it must match one of the session's active connections for the toolkit. Helper/meta tools either ignore this top-level field or define their own account-selection fields.
698
+ * @param options.inputResponses - Experimental. The user's answers to an earlier `ComposioToolInputRequiredError`, keyed by the IDs in its `inputRequests`. Repeat the same call with them.
699
+ * @param options.requestState - Experimental. The `requestState` of that error, sent back unchanged.
685
700
  * @returns The tool execution result
686
701
  * @throws {ComposioToolInputRequiredError} If the tool needs input from the user (for example an approval) before it can run
687
702
  */
@@ -718,6 +733,7 @@ export class ToolRouterSession<
718
733
  const executeParams: SessionExecuteParams = {
719
734
  tool_slug: toolSlug,
720
735
  arguments: arguments_ ?? {},
736
+ ...inputResponseParams(options),
721
737
  };
722
738
  if (options?.account) {
723
739
  executeParams.account = options.account;
@@ -742,6 +758,58 @@ export class ToolRouterSession<
742
758
  return ToolRouterSessionExecuteResponseSchema.parse(transformed);
743
759
  }
744
760
 
761
+ /**
762
+ * Execute a Composio meta tool (`COMPOSIO_*`) within the session.
763
+ *
764
+ * `session.execute()` also runs meta tools. This method only accepts meta
765
+ * tool slugs, so a typo is a type error instead of a failed request. The call
766
+ * is sent to the Composio backend as is: custom tools named in a
767
+ * `COMPOSIO_MULTI_EXECUTE_TOOL` call are not run in-process here.
768
+ *
769
+ * @param slug - The meta tool slug to execute
770
+ * @param arguments_ - Optional meta tool arguments
771
+ * @param options - Experimental. The user's answers to an earlier `ComposioToolInputRequiredError` (`inputResponses`) and its `requestState`, as in `session.execute()`
772
+ * @returns The tool execution result, in the same shape as `session.execute()`
773
+ * @throws {ComposioToolInputRequiredError} If the tool needs input from the user (for example an approval) before it can run
774
+ *
775
+ * @example
776
+ * ```typescript
777
+ * const { data, resultType } = await session.executeMeta('COMPOSIO_SEARCH_TOOLS', {
778
+ * queries: [{ use_case: 'send an email' }],
779
+ * });
780
+ * ```
781
+ */
782
+ async executeMeta(
783
+ slug: ToolRouterSessionMetaToolSlug,
784
+ arguments_?: Record<string, unknown>,
785
+ options?: ToolRouterSessionExecuteMetaOptions,
786
+ requestOptions?: ComposioRequestOptions
787
+ ): Promise<ToolRouterSessionExecuteResponse> {
788
+ const executeMetaParams: SessionExecuteMetaParams = {
789
+ slug,
790
+ arguments: arguments_ ?? {},
791
+ ...inputResponseParams(options),
792
+ };
793
+ const experimental = inlineCustomToolsExperimental<SessionExecuteMetaParams.Experimental>(
794
+ this.inlineCustomToolsPayload
795
+ );
796
+ if (experimental) {
797
+ executeMetaParams.experimental = experimental;
798
+ }
799
+
800
+ const response = await withCancellation(
801
+ () =>
802
+ this.client.toolRouter.session.executeMeta(
803
+ this.sessionId,
804
+ executeMetaParams,
805
+ withoutRetries(requestOptions)
806
+ ),
807
+ requestOptions?.signal
808
+ );
809
+ const transformed = transformExecuteResponse(response, slug);
810
+ return ToolRouterSessionExecuteResponseSchema.parse(transformed);
811
+ }
812
+
745
813
  /**
746
814
  * Proxy an API call through Composio's auth layer using the session's connected account.
747
815
  * The backend resolves the connected account from the toolkit within the session.
@@ -60,6 +60,7 @@ import { hmacSha256Base64, timingSafeEqual } from '../utils/crypto';
60
60
  import { CONFIG_DEFAULTS } from '../utils/config-defaults';
61
61
  import { ComposioRequestOptions } from '../types/requestOptions.types';
62
62
  import { withCancellation } from '../utils/cancellation';
63
+ import { invokeUserCallback } from '../utils/userCallback';
63
64
 
64
65
  /**
65
66
  * Safely converts a value to a string, returning the default if the value is null, undefined, or empty.
@@ -525,7 +526,8 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
525
526
  /**
526
527
  * Subscribe to all the triggers
527
528
  *
528
- * @param fn - The function to call when a trigger is received
529
+ * @param fn - The function to call when a trigger is received. It may be `async`. Errors
530
+ * thrown from — or promises rejected by — the function are contained and logged.
529
531
  * @param filters - The filters to apply to the triggers
530
532
  * @param onSubscriptionError - Optional callback invoked with the raw Pusher payload when
531
533
  * the underlying subscription fails (for example on auth or permission rejection). The
@@ -563,11 +565,7 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
563
565
  const parsedData = this.parsePusherPayload(_data);
564
566
 
565
567
  if (this.shouldSendTriggerAfterFilters(parsedFilters.data, parsedData)) {
566
- try {
567
- fn(parsedData);
568
- } catch (error) {
569
- logger.error('❌ Error in trigger callback:', error);
570
- }
568
+ invokeUserCallback('❌ Error in trigger callback:', () => fn(parsedData));
571
569
  } else {
572
570
  logger.debug('Trigger does not match filters', JSON.stringify(parsedFilters.data, null, 2));
573
571
  }
@@ -700,6 +698,10 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
700
698
  /**
701
699
  * Unsubscribe from all the triggers
702
700
  *
701
+ * Ends every subscription made with {@link subscribe} on this instance, including one that is
702
+ * still connecting, and closes the realtime connection so that a script can exit. A later
703
+ * `subscribe()` opens a new connection.
704
+ *
703
705
  * @returns {Promise<void>}
704
706
  *
705
707
  * @example