Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
feat(core): add AbortSignal cancellation to public SDK methods + ComposioRequestCancelledError (#3463)
Zendfd7a0846d0a
diff --git a/.changeset/core-request-options-signal-timeout.md b/.changeset/core-request-options-signal-timeout.mdnew file mode 100644index 000000000..4a0df6596--- /dev/null+++ b/.changeset/core-request-options-signal-timeout.md@@ -0,0 +1,57 @@+---+"@composio/core": minor+---++Add per-request cancellation to public SDK methods via a new `ComposioRequestOptions` (`{ signal?: AbortSignal }`) trailing argument, plus a typed `ComposioRequestCancelledError` for detecting caller-initiated aborts.++Without this, a slow `tools.get` or `tools.execute` had no way to be cancelled — a 100s search would block the calling agent indefinitely. The new shape:++```typescript+try {+ const tools = await composio.tools.get(+ 'user_1',+ { search: 'send email', limit: 50 },+ { signal: AbortSignal.timeout(5_000) }+ );+} catch (err) {+ if (err instanceof ComposioRequestCancelledError) {+ return;+ }+ throw err;+}+```++The signal is forwarded to the underlying `@composio/client` fetch. Any abort error (`APIUserAbortError`, `AbortError`, or `DOMException(name='AbortError')`) coming back is normalized to `ComposioRequestCancelledError` so callers can `instanceof`-detect cancellation without unwrapping nested causes. Catch-and-wrap paths in `tools.execute` / `tools.getRawComposioToolBySlug` / `toolkits.get` re-throw the cancellation error rather than remapping it to `ComposioToolExecutionError` / `ComposioToolNotFoundError` / `ComposioToolkitFetchError`.++Wired through on:+- **Tools**: `get`, `getRawComposioTools`, `getRawComposioToolBySlug`, `getRawToolRouterSessionTools`, `execute`, `executeSessionTool`, `getToolsEnum`, `getInput`, `proxyExecute`+- **Toolkits**: `get`, `listCategories`+- **AuthConfigs**: `list`, `create`, `get`, `update`, `delete`, `updateStatus`, `enable`, `disable`+- **ConnectedAccounts**: `list`, `get`, `delete`, `refresh`, `updateStatus`, `enable`, `disable`, `update`+- **Triggers**: `listActive`, `create`, `update`, `delete`, `enable`, `disable`, `listTypes`, `getType`, `listEnum`+- **MCP**: `create`, `list`, `get`, `delete`, `update`, `generate`+- **ToolRouter** (`composio.create` / `composio.use`, `composio.toolRouter.create` / `.use`) — long-running session-creation paths+- **ToolRouterSession**: `authorize`, `toolkits`, `search`, `execute`, `proxyExecute`, `update`++### Custom-tool cooperative cancellation++Native tool execution is cancelled by the SDK (the underlying `fetch` is aborted). Custom tools are different — the SDK can't preempt user-supplied JavaScript. Two affordances are added so callers get sensible behavior anyway:++1. **Pre-execute signal check**: if `signal.aborted` is true before the user's `execute` runs, the SDK throws `ComposioRequestCancelledError` and never invokes user code.+2. **Cooperative signal forwarding**: the same `AbortSignal` is exposed via `SessionContext.signal` for Tool Router custom tools. Long-running implementations can wire `ctx.signal` into their own `fetch` (or any abortable IO) to abort mid-execution; the resulting `AbortError` is normalized to `ComposioRequestCancelledError` by the SDK.++```typescript+import { experimental_createTool } from '@composio/core';++const longRunningFetch = experimental_createTool('LONG_RUNNING_FETCH', {+ name: 'Long-running fetch',+ description: 'Fetches a URL with cooperative cancellation',+ inputParams: z.object({ url: z.string() }),+ execute: async (input, ctx) => {+ // Pass ctx.signal into fetch so a session.execute(...) abort cancels+ // the in-flight HTTP request mid-flight.+ const resp = await fetch(input.url, { signal: ctx.signal });+ return { result: await resp.json() };+ },+});+```diff --git a/ts/packages/core/src/composio.ts b/ts/packages/core/src/composio.tsindex 9995254f2..ea7fdc248 100644--- a/ts/packages/core/src/composio.ts+++ b/ts/packages/core/src/composio.ts@@ -15,6 +15,7 @@ import { checkForLatestVersionFromNPM } from './utils/version';import { OpenAIProvider } from './provider/OpenAIProvider';import { version } from '../package.json';import type { ComposioRequestHeaders } from './types/composio.types';+import type { ComposioRequestOptions } from './types/requestOptions.types';import { Files } from '#files';import { getDefaultHeaders } from './utils/session';import { ToolkitVersionParam } from './types/tool.types';@@ -237,18 +238,25 @@ export class Composio<*/create: (userId: string,- routerConfig?: ToolRouterCreateSessionConfig+ routerConfig?: ToolRouterCreateSessionConfig,+ requestOptions?: ComposioRequestOptions) => Promise<Session<unknown, unknown, TProvider>>;/*** Use an existing tool router session** @param id {string} The id of the session to use+ * @param options {object} Custom tools / toolkits to attach to the session+ * @param requestOptions {ComposioRequestOptions} Per-request cancellation+ * options. The supplied AbortSignal aborts the underlying session+ * retrieve/attach call only. Subsequent session method calls accept+ * their own per-call requestOptions.* @returns {Promise<Session<TToolCollection, TTool, TProvider>>} The tool router session*/use: (id: string,- options?: { customTools?: CustomTool[]; customToolkits?: CustomToolkit[] }+ options?: { customTools?: CustomTool[]; customToolkits?: CustomToolkit[] },+ requestOptions?: ComposioRequestOptions) => Promise<Session<unknown, unknown, TProvider>>;/**diff --git a/ts/packages/core/src/errors/SDKErrors.ts b/ts/packages/core/src/errors/SDKErrors.tsindex 956fe4885..067183321 100644--- a/ts/packages/core/src/errors/SDKErrors.ts+++ b/ts/packages/core/src/errors/SDKErrors.ts@@ -1,7 +1,9 @@+import { APIUserAbortError } from '@composio/client';import { ComposioError, ComposioErrorOptions } from './ComposioError';export const SDKErrorCodes = {NO_API_KEY_PROVIDED: 'NO_API_KEY_PROVIDED',+ REQUEST_CANCELLED: 'REQUEST_CANCELLED',};export class ComposioNoAPIKeyError extends ComposioError {@@ -26,3 +28,65 @@ export class ComposioNoAPIKeyError extends ComposioError {this.name = 'ComposioNoAPIKeyError';}}++/**+ * Thrown when an SDK call is cancelled via the caller-supplied `AbortSignal`.+ *+ * @example+ * ```typescript+ * try {+ * await composio.tools.execute(slug, body, { signal: AbortSignal.timeout(5_000) });+ * } catch (err) {+ * if (err instanceof ComposioRequestCancelledError) return;+ * throw err;+ * }+ * ```+ */+export class ComposioRequestCancelledError extends ComposioError {+ constructor(+ message: string = 'Request was cancelled by the caller',+ options: Omit<ComposioErrorOptions, 'code'> = {}+ ) {+ super(message, {+ ...options,+ code: SDKErrorCodes.REQUEST_CANCELLED,+ possibleFixes: options.possibleFixes ?? [+ 'This error is expected when you abort the request via AbortController. Handle it in your catch block to distinguish caller-initiated cancellation from other failures.',+ ],+ });+ this.name = 'ComposioRequestCancelledError';+ }+}++/**+ * `APIUserAbortError` has `.name === "Error"` at runtime (doesn't override it),+ * so we fall back to `constructor.name` for dual-package-hazard cases.+ * @internal+ */+export function isRequestAbortError(error: unknown): boolean {+ return _isRequestAbortErrorAt(error, /* depth= */ 0);+}++function _isRequestAbortErrorAt(error: unknown, depth: number): boolean {+ if (depth > 5) return false;+ if (error instanceof APIUserAbortError) return true;+ if (+ typeof DOMException !== 'undefined' &&+ error instanceof DOMException &&+ error.name === 'AbortError'+ ) {+ return true;+ }+ if (!(error instanceof Error)) return false;+ if (+ error.constructor.name === 'APIUserAbortError' ||+ error.name === 'AbortError' ||+ error.name === 'APIUserAbortError'+ ) {+ return true;+ }+ if ('cause' in error && error.cause !== undefined && error.cause !== null) {+ return _isRequestAbortErrorAt(error.cause, depth + 1);+ }+ return false;+}diff --git a/ts/packages/core/src/index.ts b/ts/packages/core/src/index.tsindex cedb08d5e..7395d56a1 100644--- a/ts/packages/core/src/index.ts+++ b/ts/packages/core/src/index.ts@@ -36,6 +36,7 @@ export * from './types/files.types';export * from './types/connectionRequest.types';export * from './types/toolRouter.types';export * from './types/ToolRouterSessionFilesMount.types';+export * from './types/requestOptions.types';export * as constants from './utils/constants';export { default as logger } from './utils/logger';diff --git a/ts/packages/core/src/models/AuthConfigs.ts b/ts/packages/core/src/models/AuthConfigs.tsindex f3987de7d..ec4ddc0cf 100644--- a/ts/packages/core/src/models/AuthConfigs.ts+++ b/ts/packages/core/src/models/AuthConfigs.ts@@ -29,6 +29,8 @@ import {transformAuthConfigRetrieveResponse,transformCreateAuthConfigResponse,} from '../utils/transformers/authConfigs';+import { ComposioRequestOptions } from '../types/requestOptions.types';+import { withCancellation } from '../utils/cancellation';/*** AuthConfigs class*@@ -84,16 +86,23 @@ export class AuthConfigs {* });* ```*/- async list(query?: AuthConfigListParams): Promise<AuthConfigListResponse> {+ async list(+ query?: AuthConfigListParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<AuthConfigListResponse> {const parsedQuery = query ? AuthConfigListParamsSchema.parse(query) : undefined;- const result = await this.client.authConfigs.list({+ const listParams = {cursor: parsedQuery?.cursor,is_composio_managed: parsedQuery?.isComposioManaged,limit: parsedQuery?.limit,search: parsedQuery?.search,show_disabled: parsedQuery?.showDisabled,toolkit_slug: parsedQuery?.toolkit,- });+ };+ const result = await withCancellation(+ () => this.client.authConfigs.list(listParams, requestOptions),+ requestOptions?.signal+ );return transformAuthConfigListResponse(result);}@@ -117,7 +126,8 @@ export class AuthConfigs {*/async create(toolkit: string,- options: CreateAuthConfigParams = { type: 'use_composio_managed_auth' }+ options: CreateAuthConfigParams = { type: 'use_composio_managed_auth' },+ requestOptions?: ComposioRequestOptions): Promise<CreateAuthConfigResponse> {const parsedOptions = CreateAuthConfigParamsSchema.safeParse(options);if (parsedOptions.error) {@@ -125,7 +135,7 @@ export class AuthConfigs {cause: parsedOptions.error,});}- const result = await this.client.authConfigs.create({+ const createBody = {toolkit: {slug: toolkit,},@@ -162,7 +172,11 @@ export class AuthConfigs {}: undefined,},- });+ };+ const result = await withCancellation(+ () => this.client.authConfigs.create(createBody, requestOptions),+ requestOptions?.signal+ );return transformCreateAuthConfigResponse(result);}@@ -185,8 +199,14 @@ export class AuthConfigs {* console.log(authConfig.toolkit.slug); // e.g., 'github'* ```*/- async get(nanoid: string): Promise<AuthConfigRetrieveResponse> {- const result = await this.client.authConfigs.retrieve(nanoid);+ async get(+ nanoid: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<AuthConfigRetrieveResponse> {+ const result = await withCancellation(+ () => this.client.authConfigs.retrieve(nanoid, requestOptions),+ requestOptions?.signal+ );return transformAuthConfigRetrieveResponse(result);}@@ -220,18 +240,21 @@ export class AuthConfigs {* });* ```*/- async update(nanoid: string, data: AuthConfigUpdateParams): Promise<AuthConfigUpdateResponse> {+ async update(+ nanoid: string,+ data: AuthConfigUpdateParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<AuthConfigUpdateResponse> {const parsedData = AuthConfigUpdateParamsSchema.safeParse(data);if (parsedData.error) {throw new ValidationError('Failed to parse auth config update data', {cause: parsedData.error,});}- return this.client.authConfigs.update(- nanoid,+ const updateBody =parsedData.data.type === 'custom'? {- type: 'custom',+ type: 'custom' as const,credentials: parsedData.data.credentials,is_enabled_for_tool_router: parsedData.data.isEnabledForToolRouter,tool_access_config: {@@ -243,7 +266,7 @@ export class AuthConfigs {},}: {- type: 'default',+ type: 'default' as const,scopes: parsedData.data.scopes,is_enabled_for_tool_router: parsedData.data.isEnabledForToolRouter,tool_access_config: {@@ -253,7 +276,10 @@ export class AuthConfigs {parsedData.data.toolAccessConfig?.toolsAvailableForExecution ??parsedData.data.restrictToFollowingTools,},- }+ };+ return withCancellation(+ () => this.client.authConfigs.update(nanoid, updateBody, requestOptions),+ requestOptions?.signal);}@@ -274,8 +300,14 @@ export class AuthConfigs {* await composio.authConfigs.delete('auth_abc123');* ```*/- async delete(nanoid: string): Promise<AuthConfigDeleteResponse> {- return this.client.authConfigs.delete(nanoid);+ async delete(+ nanoid: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<AuthConfigDeleteResponse> {+ return withCancellation(+ () => this.client.authConfigs.delete(nanoid, undefined, requestOptions),+ requestOptions?.signal+ );}/**@@ -301,9 +333,13 @@ export class AuthConfigs {*/async updateStatus(status: 'ENABLED' | 'DISABLED',- nanoid: string+ nanoid: string,+ requestOptions?: ComposioRequestOptions): Promise<AuthConfigUpdateStatusResponse> {- return this.client.authConfigs.updateStatus(status, { nanoid });+ return withCancellation(+ () => this.client.authConfigs.updateStatus(status, { nanoid }, requestOptions),+ requestOptions?.signal+ );}/**@@ -323,8 +359,14 @@ export class AuthConfigs {* await composio.authConfigs.enable('auth_abc123');* ```*/- async enable(nanoid: string): Promise<AuthConfigUpdateStatusResponse> {- return this.client.authConfigs.updateStatus('ENABLED', { nanoid });+ async enable(+ nanoid: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<AuthConfigUpdateStatusResponse> {+ return withCancellation(+ () => this.client.authConfigs.updateStatus('ENABLED', { nanoid }, requestOptions),+ requestOptions?.signal+ );}/**@@ -344,7 +386,13 @@ export class AuthConfigs {* await composio.authConfigs.disable('auth_abc123');* ```*/- async disable(nanoid: string): Promise<AuthConfigUpdateStatusResponse> {- return this.client.authConfigs.updateStatus('DISABLED', { nanoid });+ async disable(+ nanoid: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<AuthConfigUpdateStatusResponse> {+ return withCancellation(+ () => this.client.authConfigs.updateStatus('DISABLED', { nanoid }, requestOptions),+ requestOptions?.signal+ );}}diff --git a/ts/packages/core/src/models/ConnectedAccounts.ts b/ts/packages/core/src/models/ConnectedAccounts.tsindex 2a85825ca..11864a430 100644--- a/ts/packages/core/src/models/ConnectedAccounts.ts+++ b/ts/packages/core/src/models/ConnectedAccounts.ts@@ -48,6 +48,9 @@ import {} from '../errors';import logger from '../utils/logger';import { ConnectionData } from '../types/connectedAccountAuthStates.types';+import { ComposioRequestOptions } from '../types/requestOptions.types';+import { withCancellation } from '../utils/cancellation';+import { ComposioRequestCancelledError } from '../errors/SDKErrors';// One-time-per-process guard so long-running services don't spam the deprecation// warning on every initiate() call.@@ -91,7 +94,10 @@ export class ConnectedAccounts {* });* ```*/- async list(query?: ConnectedAccountListParams): Promise<ConnectedAccountListResponse> {+ async list(+ query?: ConnectedAccountListParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<ConnectedAccountListResponse> {let rawQuery: ConnectedAccountListParamsRaw | undefined = undefined;if (query) {@@ -119,7 +125,10 @@ export class ConnectedAccounts {};}- const result = await this.client.connectedAccounts.list(rawQuery);+ const result = await withCancellation(+ () => this.client.connectedAccounts.list(rawQuery, requestOptions),+ requestOptions?.signal+ );return transformConnectedAccountListResponse(result);}@@ -193,14 +202,18 @@ export class ConnectedAccounts {async initiate(userId: string,authConfigId: string,- options?: CreateConnectedAccountOptions+ options?: CreateConnectedAccountOptions,+ requestOptions?: ComposioRequestOptions): Promise<ConnectionRequest> {// Check if there are multiple connected accounts for the authConfig of the user- const connectedAccount = await this.list({- userIds: [userId],- authConfigIds: [authConfigId],- statuses: [ConnectedAccountStatuses.ACTIVE],- });+ const connectedAccount = await this.list(+ {+ userIds: [userId],+ authConfigIds: [authConfigId],+ statuses: [ConnectedAccountStatuses.ACTIVE],+ },+ requestOptions+ );if (connectedAccount.items.length > 0 && !options?.allowMultiple) {throw new ComposioMultipleConnectedAccountsError(`Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts.`@@ -244,25 +257,34 @@ export class ConnectedAccounts {// caller needs to migrate. Custom auth configs and non-OAuth schemes// never see the header, eliminating the false-positive warning that// an `auth_scheme`-only check produced for `link()`-unaffected callers.- const apiCall = this.client.connectedAccounts.create(createParams);+ const apiCall = this.client.connectedAccounts.create(createParams, requestOptions);if (typeof (apiCall as { withResponse?: unknown }).withResponse === 'function') {- const resolved = await (- apiCall as unknown as {- withResponse: () => Promise<{- data: ConnectedAccountCreateResponse;- response: Response;- }>;- }- ).withResponse();+ const resolved = await withCancellation(+ () =>+ (+ apiCall as unknown as {+ withResponse: () => Promise<{+ data: ConnectedAccountCreateResponse;+ response: Response;+ }>;+ }+ ).withResponse(),+ requestOptions?.signal+ );response = resolved.data;httpResponse = resolved.response;} else {// Test mocks may return a plain Promise without `withResponse`.// Fall back to a naked await; the deprecation gate below stays// off in that case (no header to read).- response = await apiCall;+ response = await withCancellation(() => apiCall, requestOptions?.signal);}} catch (error) {+ // Caller-initiated cancellation must surface as the typed error,+ // not get remapped to the legacy-endpoint error below.+ if (error instanceof ComposioRequestCancelledError) {+ throw error;+ }// When the server has flipped this org to the retired path, the legacy// endpoint returns 400 with a stable migration message. Surface it as// a typed error so callers get an actionable hint instead of a generic@@ -346,23 +368,29 @@ export class ConnectedAccounts {async link(userId: string,authConfigId: string,- options?: CreateConnectedAccountLinkOptions+ options?: CreateConnectedAccountLinkOptions,+ requestOptions?: ComposioRequestOptions): Promise<ConnectionRequest> {- const requestOptions = await CreateConnectedAccountLinkOptionsSchema.safeParse(options || {});- if (!requestOptions.success) {+ const parsedLinkOptions = CreateConnectedAccountLinkOptionsSchema.safeParse(options || {});+ if (!parsedLinkOptions.success) {throw new ValidationError('Failed to parse create connected account link options', {- cause: requestOptions.error,+ cause: parsedLinkOptions.error,});}// Mirror initiate(): guard against silently creating extra connections on- // the same auth config unless the caller explicitly opts in.- const existing = await this.list({- userIds: [userId],- authConfigIds: [authConfigId],- statuses: [ConnectedAccountStatuses.ACTIVE],- });- if (existing.items.length > 0 && !requestOptions.data.allowMultiple) {+ // the same auth config unless the caller explicitly opts in. The preflight+ // list call honors the caller's signal too — the whole composite is+ // cancellable as a single unit.+ const existing = await this.list(+ {+ userIds: [userId],+ authConfigIds: [authConfigId],+ statuses: [ConnectedAccountStatuses.ACTIVE],+ },+ requestOptions+ );+ if (existing.items.length > 0 && !parsedLinkOptions.data.allowMultiple) {throw new ComposioMultipleConnectedAccountsError(`Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts.`);@@ -372,7 +400,7 @@ export class ConnectedAccounts {);}- const opts = requestOptions.data;+ const opts = parsedLinkOptions.data;const experimentalWire = serializeExperimentalForWire(opts.experimental);const body: LinkCreateParams = {auth_config_id: authConfigId,@@ -383,7 +411,10 @@ export class ConnectedAccounts {};try {- const response = await this.client.link.create(body);+ const response = await withCancellation(+ () => this.client.link.create(body, requestOptions),+ requestOptions?.signal+ );const connectionRequest = createConnectionRequest(this.client,@@ -393,6 +424,11 @@ export class ConnectedAccounts {);return connectionRequest;} catch (error) {+ // Caller-initiated cancellation must surface as the typed error,+ // not get remapped to ComposioFailedToCreateConnectedAccountLink below.+ if (error instanceof ComposioRequestCancelledError) {+ throw error;+ }// The server rejects ACL on PRIVATE connections — surface that as a// typed error so callers can `instanceof` instead of grepping messages.if (@@ -459,8 +495,14 @@ export class ConnectedAccounts {* console.log(account.toolkit.slug); // e.g., 'github'* ```*/- async get(nanoid: string): Promise<ConnectedAccountRetrieveResponse> {- const response = await this.client.connectedAccounts.retrieve(nanoid);+ async get(+ nanoid: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<ConnectedAccountRetrieveResponse> {+ const response = await withCancellation(+ () => this.client.connectedAccounts.retrieve(nanoid, requestOptions),+ requestOptions?.signal+ );return transformConnectedAccountResponse(response);}@@ -480,8 +522,14 @@ export class ConnectedAccounts {* await composio.connectedAccounts.delete('conn_abc123');* ```*/- async delete(nanoid: string): Promise<ConnectedAccountDeleteResponse> {- return this.client.connectedAccounts.delete(nanoid);+ async delete(+ nanoid: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<ConnectedAccountDeleteResponse> {+ return withCancellation(+ () => this.client.connectedAccounts.delete(nanoid, undefined, requestOptions),+ requestOptions?.signal+ );}/**@@ -502,7 +550,8 @@ export class ConnectedAccounts {*/async refresh(nanoid: string,- options?: ConnectedAccountRefreshOptions+ options?: ConnectedAccountRefreshOptions,+ requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountRefreshResponse> {let params: ConnectedAccountRefreshParams | undefined = undefined;@@ -520,7 +569,10 @@ export class ConnectedAccounts {};}- return this.client.connectedAccounts.refresh(nanoid, params);+ return withCancellation(+ () => this.client.connectedAccounts.refresh(nanoid, params, requestOptions),+ requestOptions?.signal+ );}/**@@ -545,9 +597,13 @@ export class ConnectedAccounts {*/async updateStatus(nanoid: string,- params: ConnectedAccountUpdateStatusParams+ params: ConnectedAccountUpdateStatusParams,+ requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountUpdateStatusResponse> {- return this.client.connectedAccounts.updateStatus(nanoid, params);+ return withCancellation(+ () => this.client.connectedAccounts.updateStatus(nanoid, params, requestOptions),+ requestOptions?.signal+ );}/**@@ -562,8 +618,14 @@ export class ConnectedAccounts {* console.log(enabledAccount.isDisabled); // false* ```*/- async enable(nanoid: string): Promise<ConnectedAccountUpdateStatusResponse> {- return this.client.connectedAccounts.updateStatus(nanoid, { enabled: true });+ async enable(+ nanoid: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<ConnectedAccountUpdateStatusResponse> {+ return withCancellation(+ () => this.client.connectedAccounts.updateStatus(nanoid, { enabled: true }, requestOptions),+ requestOptions?.signal+ );}/**@@ -584,8 +646,14 @@ export class ConnectedAccounts {* // });* ```*/- async disable(nanoid: string): Promise<ConnectedAccountUpdateStatusResponse> {- return this.client.connectedAccounts.updateStatus(nanoid, { enabled: false });+ async disable(+ nanoid: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<ConnectedAccountUpdateStatusResponse> {+ return withCancellation(+ () => this.client.connectedAccounts.updateStatus(nanoid, { enabled: false }, requestOptions),+ requestOptions?.signal+ );}/**@@ -606,7 +674,8 @@ export class ConnectedAccounts {*/async update(nanoid: string,- params: UpdateConnectedAccountParams+ params: UpdateConnectedAccountParams,+ requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountUpdateStatusResponse> {const parsedParams = UpdateConnectedAccountParamsSchema.safeParse(params);if (!parsedParams.success) {@@ -615,6 +684,9 @@ export class ConnectedAccounts {});}- return this.client.connectedAccounts.updateStatus(nanoid, parsedParams.data);+ return withCancellation(+ () => this.client.connectedAccounts.updateStatus(nanoid, parsedParams.data, requestOptions),+ requestOptions?.signal+ );}}diff --git a/ts/packages/core/src/models/MCP.ts b/ts/packages/core/src/models/MCP.tsindex 8eef1ea73..f09b64180 100644--- a/ts/packages/core/src/models/MCP.ts+++ b/ts/packages/core/src/models/MCP.ts@@ -22,6 +22,8 @@ import { ValidationError } from '../errors/ValidationErrors';import { transform } from '../utils/transform';import { McpUpdateResponse } from '@composio/client/resources.js';import { McpRetrieveResponse } from '@composio/client/resources';+import { ComposioRequestOptions } from '../types/requestOptions.types';+import { withCancellation } from '../utils/cancellation';function transformMCPItemResponse(response: McpUpdateResponse | McpRetrieveResponse): MCPItem {return transform(response)@@ -77,7 +79,11 @@ export class MCP {* });* ```*/- async create(name: string, mcpConfig: MCPConfigCreationParams): Promise<MCPConfigCreateResponse> {+ async create(+ name: string,+ mcpConfig: MCPConfigCreationParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<MCPConfigCreateResponse> {const config = MCPConfigCreationParamsSchema.safeParse(mcpConfig);if (config.error) {throw new ValidationError('Invalid parameters passed to create mcp config', {@@ -100,14 +106,18 @@ export class MCP {}});- const server = await this.client.mcp.custom.create({+ const createBody = {name,toolkits,auth_config_ids,custom_tools,// if manually manage account is set to true, disable composio account management toolsmanaged_auth_via_composio: config.data.manuallyManageConnections ? false : true,- });+ };+ const server = await withCancellation(+ () => this.client.mcp.custom.create(createBody, requestOptions),+ requestOptions?.signal+ );const camelCaseServer = transform(server).with(MCPConfigResponseSchema)@@ -162,7 +172,10 @@ export class MCP {* });* ```*/- async list(options: MCPListParams): Promise<MCPListResponse> {+ async list(+ options: MCPListParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<MCPListResponse> {const { data: params, error } = MCPListParamsSchema.safeParse(options);if (error) {throw new ValidationError('Failed to validate list options', {@@ -170,13 +183,17 @@ export class MCP {});}- const listResponse = await this.client.mcp.list({+ const listParams = {page_no: params.page,limit: params.limit,toolkits: params.toolkits?.length > 0 ? params.toolkits.join(',') : undefined,auth_config_ids: params.authConfigs?.length > 0 ? params.authConfigs.join(',') : undefined,name: params.name,- });+ };+ const listResponse = await withCancellation(+ () => this.client.mcp.list(listParams, requestOptions),+ requestOptions?.signal+ );const transformedListResponse = transform(listResponse).with(MCPListResponseSchema)@@ -225,8 +242,11 @@ export class MCP {** @throws {ValidationError} When the server ID is invalid or server not found*/- async get(serverId: string): Promise<MCPItem> {- const response = await this.client.mcp.retrieve(serverId);+ async get(serverId: string, requestOptions?: ComposioRequestOptions): Promise<MCPItem> {+ const response = await withCancellation(+ () => this.client.mcp.retrieve(serverId, requestOptions),+ requestOptions?.signal+ );return transformMCPItemResponse(response);}@@ -266,8 +286,14 @@ export class MCP {** @warning This operation is irreversible. Once deleted, the MCP server configuration and all its associated data will be permanently removed.*/- async delete(serverId: string): Promise<{ id: string; deleted: boolean }> {- return await this.client.mcp.delete(serverId);+ async delete(+ serverId: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<{ id: string; deleted: boolean }> {+ return withCancellation(+ () => this.client.mcp.delete(serverId, requestOptions),+ requestOptions?.signal+ );}/**@@ -334,7 +360,11 @@ export class MCP {* @note Only provided fields will be updated. Omitted fields will retain their current values.* @note When updating toolkits, the entire toolkit configuration is replaced, not merged.*/- async update(serverId: string, config: MCPUpdateParams): Promise<MCPItem> {+ async update(+ serverId: string,+ config: MCPUpdateParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<MCPItem> {const { data: params, error } = MCPUpdateParamsSchema.safeParse(config);if (error) {throw new ValidationError('Failed to validate update params', {@@ -356,7 +386,7 @@ export class MCP {auth_config_ids.push(toolkit.authConfigId);}});- const response = await this.client.mcp.update(serverId, {+ const updateBody = {...{ name: params.name ?? undefined },...(params.toolkits? {@@ -366,7 +396,11 @@ export class MCP {}: {}),...{ managed_auth_via_composio: params.manuallyManageConnections ?? undefined },- });+ };+ const response = await withCancellation(+ () => this.client.mcp.update(serverId, updateBody, requestOptions),+ requestOptions?.signal+ );return transformMCPItemResponse(response);}@@ -390,9 +424,13 @@ export class MCP {async generate(userId: string,mcpConfigId: string,- options?: MCPGetInstanceParams+ options?: MCPGetInstanceParams,+ requestOptions?: ComposioRequestOptions): Promise<MCPServerInstance> {- const server = await this.client.mcp.retrieve(mcpConfigId);+ const server = await withCancellation(+ () => this.client.mcp.retrieve(mcpConfigId, requestOptions),+ requestOptions?.signal+ );const params = MCPGetInstanceParamsSchema.safeParse(options ?? { manuallyManageConnections: false });@@ -402,11 +440,15 @@ export class MCP {});}- const urlResponse = await this.client.mcp.generate.url({+ const urlBody = {mcp_server_id: mcpConfigId,user_ids: [userId],managed_auth_by_composio: options?.manuallyManageConnections ? false : true,- });+ };+ const urlResponse = await withCancellation(+ () => this.client.mcp.generate.url(urlBody, requestOptions),+ requestOptions?.signal+ );const userIdsURL = urlResponse.user_ids_url[0];const serverInstance = MCPServerInstanceSchema.safeParse({diff --git a/ts/packages/core/src/models/SessionContext.ts b/ts/packages/core/src/models/SessionContext.tsindex d338a69bb..4e9534905 100644--- a/ts/packages/core/src/models/SessionContext.ts+++ b/ts/packages/core/src/models/SessionContext.ts@@ -26,6 +26,7 @@ import {import { transformExecuteResponse } from '../utils/transformers/toolRouterResponseTransform';import type { SessionExecuteParams } from '@composio/client/resources/tool-router/session/session.mjs';import { inlineCustomToolsExperimental } from './inlineCustomToolsPayload';+import { withCancellation } from '../utils/cancellation';/*** Concrete implementation of SessionContext.@@ -39,6 +40,14 @@ import { inlineCustomToolsExperimental } from './inlineCustomToolsPayload';export class SessionContextImpl implements SessionContext {public readonly userId: string;+ /**+ * Per-execution AbortSignal. Never set on the base instance; `executeCustomTool`+ * grafts it onto a per-call `Object.create` child so concurrent executions+ * sharing this context don't observe each other's signal. Declared here (rather+ * than read via a cast) so the contract is explicit.+ */+ public readonly signal?: AbortSignal;+constructor(private readonly client: ComposioClient,userId: string,@@ -60,10 +69,12 @@ export class SessionContextImpl implements SessionContext {toolSlug: string,arguments_: Record<string, unknown>): Promise<ToolRouterSessionExecuteResponse> {- // Try local tool first (sibling routing)+ const signal = this.signal;+ const requestOptions = signal ? { signal } : undefined;+const entry = findCustomTool(this.customToolsMap, toolSlug);if (entry) {- const result = await executeCustomTool(entry, arguments_, this);+ const result = await executeCustomTool(entry, arguments_, this, { signal });return ToolRouterSessionExecuteResponseSchema.parse({data: result.data,error: result.error,@@ -72,7 +83,6 @@ export class SessionContextImpl implements SessionContext {}assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);- // Fall back to remote executionconst executeParams: SessionExecuteParams = {tool_slug: toolSlug,arguments: arguments_,@@ -84,7 +94,10 @@ export class SessionContextImpl implements SessionContext {executeParams.experimental = experimental;}- const response = await this.client.toolRouter.session.execute(this.sessionId, executeParams);+ const response = await withCancellation(+ () => this.client.toolRouter.session.execute(this.sessionId, executeParams, requestOptions),+ requestOptions?.signal+ );return ToolRouterSessionExecuteResponseSchema.parse(transformExecuteResponse(response));}@@ -100,10 +113,14 @@ export class SessionContextImpl implements SessionContext {throw new ValidationError('Invalid proxy execute parameters', { cause: validated.error });}+ const signal = this.signal;+ const requestOptions = signal ? { signal } : undefined;+const clientParams = transformProxyParams(validated.data);- const response = await this.client.toolRouter.session.proxyExecute(- this.sessionId,- clientParams+ const response = await withCancellation(+ () =>+ this.client.toolRouter.session.proxyExecute(this.sessionId, clientParams, requestOptions),+ requestOptions?.signal);return {diff --git a/ts/packages/core/src/models/ToolRouter.ts b/ts/packages/core/src/models/ToolRouter.tsindex 5623ff8db..4dc6f1e56 100644--- a/ts/packages/core/src/models/ToolRouter.ts+++ b/ts/packages/core/src/models/ToolRouter.ts@@ -52,6 +52,8 @@ import {} from '../lib/toolRouterParams';import { PRELOAD_TOOLS_ALL } from '../lib/toolRouterConstants';import { ToolRouterSession } from './ToolRouterSession';+import { ComposioRequestOptions } from '../types/requestOptions.types';+import { withCancellation } from '../utils/cancellation';import {assertNoCustomToolSlugsInPreload,buildCustomToolsMap,@@ -167,7 +169,8 @@ export class ToolRouter<*/async create(userId: string,- config?: ToolRouterCreateSessionConfig+ config?: ToolRouterCreateSessionConfig,+ requestOptions?: ComposioRequestOptions): Promise<Session<TToolCollection, TTool, TProvider>> {const routerConfig = ToolRouterCreateSessionConfigSchema.parse(config ?? {});const isDirectToolsPreset = routerConfig.sessionPreset === SessionPreset.DIRECT_TOOLS;@@ -231,7 +234,10 @@ export class ToolRouter<experimental: Object.keys(experimentalPayload).length > 0 ? experimentalPayload : undefined,};- const session = await this.client.toolRouter.session.create(payload);+ const session = await withCancellation(+ () => this.client.toolRouter.session.create(payload, requestOptions),+ requestOptions?.signal+ );// Build custom tools map from the response's slug/original_slug mapping// instead of computing LOCAL_ prefix client-side@@ -282,7 +288,8 @@ export class ToolRouter<*/async use(id: string,- options?: { customTools?: CustomTool[]; customToolkits?: CustomToolkit[] }+ options?: { customTools?: CustomTool[]; customToolkits?: CustomToolkit[] },+ requestOptions?: ComposioRequestOptions): Promise<Session<TToolCollection, TTool, TProvider>> {const customTools = options?.customTools;const customToolkits = options?.customToolkits;@@ -296,11 +303,16 @@ export class ToolRouter<let inlineCustomToolsPayload = attachInlineCustomToolsPayload;if (hasCustoms) {- session = await this.client.toolRouter.session.attach(id, {- experimental: attachInlineCustomToolsPayload,- });+ const attachBody = { experimental: attachInlineCustomToolsPayload };+ session = await withCancellation(+ () => this.client.toolRouter.session.attach(id, attachBody, requestOptions),+ requestOptions?.signal+ );} else {- session = await this.client.toolRouter.session.retrieve(id);+ session = await withCancellation(+ () => this.client.toolRouter.session.retrieve(id, requestOptions),+ requestOptions?.signal+ );}const defaultCustomPreload = preloadsAllCustomTools(session.config.preload);diff --git a/ts/packages/core/src/models/ToolRouterSession.ts b/ts/packages/core/src/models/ToolRouterSession.tsindex 4c148e6f3..d07c5a182 100644--- a/ts/packages/core/src/models/ToolRouterSession.ts+++ b/ts/packages/core/src/models/ToolRouterSession.ts@@ -2,6 +2,9 @@ import { telemetry } from '../telemetry/Telemetry';import { Composio as ComposioClient, BadRequestError } from '@composio/client';import { BaseComposioProvider } from '../provider/BaseProvider';import { ComposioConfig } from '../composio';+import { ComposioRequestOptions } from '../types/requestOptions.types';+import { withCancellation } from '../utils/cancellation';+import { ComposioRequestCancelledError } from '../errors/SDKErrors';import {ToolRouterMCPServerConfig,SessionExperimental,@@ -149,11 +152,15 @@ export class ToolRouterSession<* When custom tools are bound to the session, execution of COMPOSIO_MULTI_EXECUTE_TOOL* is intercepted: local tools are executed in-process, remote tools are sent to the backend.*/- async tools(modifiers?: SessionMetaToolOptions): Promise<ReturnType<TProvider['wrapTools']>> {+ async tools(+ modifiers?: SessionMetaToolOptions,+ requestOptions?: ComposioRequestOptions+ ): Promise<ReturnType<TProvider['wrapTools']>> {const ToolsModel = new Tools<TToolCollection, TTool, TProvider>(this.client, this.config);const tools = await ToolsModel.getRawToolRouterSessionTools(this.sessionId,- modifiers?.modifySchema ? { modifySchema: modifiers.modifySchema } : undefined+ modifiers?.modifySchema ? { modifySchema: modifiers.modifySchema } : undefined,+ requestOptions);const sessionTools = await this.addPreloadedCustomTools(tools, modifiers);const toolBySlug = new Map(sessionTools.map(tool => [tool.slug.toUpperCase(), tool]));@@ -346,15 +353,16 @@ export class ToolRouterSession<accountType?: ConnectedAccountType;aclConfigForShared?: ConnectedAccountAclConfig;};- }+ },+ requestOptions?: ComposioRequestOptions): Promise<ConnectionRequest> {- const requestOptions = AuthorizeOptionsSchema.safeParse(options ?? {});- if (!requestOptions.success) {+ const parsedAuthorizeOptions = AuthorizeOptionsSchema.safeParse(options ?? {});+ if (!parsedAuthorizeOptions.success) {throw new ValidationError('Failed to parse tool router authorize options', {- cause: requestOptions.error,+ cause: parsedAuthorizeOptions.error,});}- const opts = requestOptions.data;+ const opts = parsedAuthorizeOptions.data;const experimentalWire = serializeExperimentalForWire(opts.experimental);const body: SessionLinkParams = {toolkit,@@ -367,8 +375,16 @@ export class ToolRouterSession<let response;try {- response = await this.client.toolRouter.session.link(this.sessionId, body);+ response = await withCancellation(+ () => this.client.toolRouter.session.link(this.sessionId, body, requestOptions),+ requestOptions?.signal+ );} catch (error) {+ // Caller-initiated cancellation must surface as the typed error,+ // not get remapped to a domain error below.+ if (error instanceof ComposioRequestCancelledError) {+ throw error;+ }// The server rejects ACL on PRIVATE connections — surface that as a// typed error mirroring `composio.connectedAccounts.link()`.if (@@ -393,7 +409,7 @@ export class ToolRouterSession<* Query the connection state of toolkits in the session.* Supports pagination and filtering by toolkit slugs.*/- async toolkits(options?: ToolRouterToolkitsOptions) {+ async toolkits(options?: ToolRouterToolkitsOptions, requestOptions?: ComposioRequestOptions) {const toolkitOptions = ToolRouterToolkitsOptionsSchema.safeParse(options ?? {});if (!toolkitOptions.success) {throw new ValidationError('Failed to parse toolkits options', {@@ -401,13 +417,17 @@ export class ToolRouterSession<});}- const result = await this.client.toolRouter.session.toolkits(this.sessionId, {+ const toolkitsParams = {cursor: toolkitOptions.data.cursor,limit: toolkitOptions.data.limit,toolkits: toolkitOptions.data.toolkits,is_connected: toolkitOptions.data.isConnected,search: toolkitOptions.data.search,- });+ };+ const result = await withCancellation(+ () => this.client.toolRouter.session.toolkits(this.sessionId, toolkitsParams, requestOptions),+ requestOptions?.signal+ );const toolkitConnectedStates = result.items.map(item => {const connectedState = transform(item)@@ -448,10 +468,13 @@ export class ToolRouterSession<* Search for tools by semantic use case.* Returns relevant tools for the given query with schemas and guidance.*/- async search(params: {- query: string;- toolkits?: string[];- }): Promise<ToolRouterSessionSearchResponse> {+ async search(+ params: {+ query: string;+ toolkits?: string[];+ },+ requestOptions?: ComposioRequestOptions+ ): Promise<ToolRouterSessionSearchResponse> {const experimental = inlineCustomToolsExperimental<SessionSearchParams.Experimental>(this.inlineCustomToolsPayload);@@ -460,7 +483,10 @@ export class ToolRouterSession<...(params.toolkits?.length ? { toolkits: params.toolkits } : {}),...(experimental ? { experimental } : {}),};- const response = await this.client.toolRouter.session.search(this.sessionId, searchParams);+ const response = await withCancellation(+ () => this.client.toolRouter.session.search(this.sessionId, searchParams, requestOptions),+ requestOptions?.signal+ );const transformed = transformSearchResponse(response);return ToolRouterSessionSearchResponseSchema.parse(transformed);}@@ -481,12 +507,23 @@ export class ToolRouterSession<async execute(toolSlug: string,arguments_?: Record<string, unknown>,- options?: ToolRouterSessionExecuteOptions+ options?: ToolRouterSessionExecuteOptions,+ requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionExecuteResponse> {// Check if this is a local tool (by original or final slug)const entry = findCustomTool(this.customToolsMap, toolSlug);if (entry) {- const result = await executeCustomTool(entry, arguments_ ?? {}, this.sessionContext!);+ // Bail before invoking user code if the caller has already aborted.+ // Custom-tool execution is *cooperative*: long-running user code+ // won't observe later aborts unless the user wires the signal into+ // their own fetch/work — we pass it through via the executeCustomTool+ // session context so they can.+ if (requestOptions?.signal?.aborted) {+ throw new ComposioRequestCancelledError();+ }+ const result = await executeCustomTool(entry, arguments_ ?? {}, this.sessionContext!, {+ signal: requestOptions?.signal,+ });return {data: result.data,error: result.error,@@ -510,7 +547,10 @@ export class ToolRouterSession<executeParams.experimental = experimental;}- const response = await this.client.toolRouter.session.execute(this.sessionId, executeParams);+ const response = await withCancellation(+ () => this.client.toolRouter.session.execute(this.sessionId, executeParams, requestOptions),+ requestOptions?.signal+ );const transformed = transformExecuteResponse(response);return ToolRouterSessionExecuteResponseSchema.parse(transformed);}@@ -523,7 +563,8 @@ export class ToolRouterSession<* @returns The proxied API response with status, data, headers*/async proxyExecute(- params: SessionProxyExecuteParams+ params: SessionProxyExecuteParams,+ requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionProxyExecuteResponse> {const validated = SessionProxyExecuteParamsSchema.safeParse(params);if (!validated.success) {@@ -531,9 +572,10 @@ export class ToolRouterSession<}const clientParams = transformProxyParams(validated.data);- const response = await this.client.toolRouter.session.proxyExecute(- this.sessionId,- clientParams+ const response = await withCancellation(+ () =>+ this.client.toolRouter.session.proxyExecute(this.sessionId, clientParams, requestOptions),+ requestOptions?.signal);return {@@ -558,10 +600,16 @@ export class ToolRouterSession<* Only the fields provided will be changed; omitted fields are preserved.* Mutates this session's `configVersion`, `preload`, and `warnings` in-place.*/- async update(config: ToolRouterUpdateSessionConfig): Promise<void> {+ async update(+ config: ToolRouterUpdateSessionConfig,+ requestOptions?: ComposioRequestOptions+ ): Promise<void> {const parsed = ToolRouterUpdateSessionConfigSchema.parse(config);const params = transformToolRouterUpdateParams(parsed);- const response = await this.client.toolRouter.session.patch(this.sessionId, params);+ const response = await withCancellation(+ () => this.client.toolRouter.session.patch(this.sessionId, params, requestOptions),+ requestOptions?.signal+ );this.configVersion = response.config_version;this.preload = response.config.preload;this.warnings = response.warnings ?? [];diff --git a/ts/packages/core/src/models/Toolkits.ts b/ts/packages/core/src/models/Toolkits.tsindex e72a66e2c..086e87a5e 100644--- a/ts/packages/core/src/models/Toolkits.ts+++ b/ts/packages/core/src/models/Toolkits.ts@@ -22,6 +22,9 @@ import {transformToolkitRetrieveCategoriesResponse,transformToolkitRetrieveResponse,} from '../utils/transformers/toolkits';+import { ComposioRequestOptions } from '../types/requestOptions.types';+import { withCancellation } from '../utils/cancellation';+import { ComposioRequestCancelledError } from '../errors/SDKErrors';/*** Toolkits class*@@ -47,7 +50,10 @@ export class Toolkits {** @private*/- private async getToolkits(query: ToolkitListParams): Promise<ToolKitListResponse> {+ private async getToolkits(+ query: ToolkitListParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<ToolKitListResponse> {try {const parsedQuery = ToolkitsListParamsSchema.safeParse(query);if (!parsedQuery.success) {@@ -55,16 +61,23 @@ export class Toolkits {cause: parsedQuery.error,});}- const result = await this.client.toolkits.list({+ const listParams = {category: parsedQuery.data.category,managed_by: parsedQuery.data.managedBy,sort_by: parsedQuery.data.sortBy,cursor: parsedQuery.data.cursor,limit: parsedQuery.data.limit,- });+ };+ const result = await withCancellation(+ () => this.client.toolkits.list(listParams, requestOptions),+ requestOptions?.signal+ );return transformToolkitListResponse(result);} catch (error) {+ if (error instanceof ComposioRequestCancelledError) {+ throw error;+ }throw new ComposioToolkitFetchError('Failed to fetch toolkits', {cause: error,});@@ -83,11 +96,20 @@ export class Toolkits {** @private*/- protected async getToolkitBySlug(slug: string): Promise<ToolkitRetrieveResponse> {+ protected async getToolkitBySlug(+ slug: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<ToolkitRetrieveResponse> {try {- const result = await this.client.toolkits.retrieve(slug);+ const result = await withCancellation(+ () => this.client.toolkits.retrieve(slug, undefined, requestOptions),+ requestOptions?.signal+ );return transformToolkitRetrieveResponse(result);} catch (error) {+ if (error instanceof ComposioRequestCancelledError) {+ throw error;+ }if (error instanceof APIError && (error.status === 404 || error.status === 400)) {throw new ComposioToolkitNotFoundError(`Toolkit with slug ${slug} not found`, {meta: {@@ -120,7 +142,10 @@ export class Toolkits {* console.log(githubToolkit.authConfigDetails); // Authentication configuration details* ```*/- async get(slug: string): Promise<ToolkitRetrieveResponse>;+ async get(+ slug: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<ToolkitRetrieveResponse>;/*** Retrieves a list of toolkits based on the provided query parameters.@@ -144,21 +169,26 @@ export class Toolkits {* });* ```*/- async get(query?: ToolkitListParams): Promise<ToolKitListResponse>;+ async get(+ query?: ToolkitListParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<ToolKitListResponse>;/*** Implementation method that handles both overloads for retrieving toolkits.** @param {string | ToolkitListParams} arg - Either a toolkit slug or query parameters+ * @param {ComposioRequestOptions} [requestOptions] - Per-request cancellation/timeout options* @returns {Promise<ToolkitRetrieveResponse | ToolKitListResponse>} The toolkit or list of toolkits*/async get(- arg?: string | ToolkitListParams+ arg?: string | ToolkitListParams,+ requestOptions?: ComposioRequestOptions): Promise<ToolkitRetrieveResponse | ToolKitListResponse> {if (typeof arg === 'string') {- return this.getToolkitBySlug(arg);+ return this.getToolkitBySlug(arg, requestOptions);}- return this.getToolkits(arg ?? {});+ return this.getToolkits(arg ?? {}, requestOptions);}private async getAuthConfigFields(@@ -277,8 +307,13 @@ export class Toolkits {* console.log(categories.items); // Array of category objects* ```*/- async listCategories(): Promise<ToolkitRetrieveCategoriesResponse> {- const result = await this.client.toolkits.retrieveCategories();+ async listCategories(+ requestOptions?: ComposioRequestOptions+ ): Promise<ToolkitRetrieveCategoriesResponse> {+ const result = await withCancellation(+ () => this.client.toolkits.retrieveCategories(requestOptions),+ requestOptions?.signal+ );return transformToolkitRetrieveCategoriesResponse(result);}@@ -298,16 +333,24 @@ export class Toolkits {async authorize(userId: string,toolkitSlug: string,- authConfigId?: string+ authConfigId?: string,+ requestOptions?: ComposioRequestOptions): Promise<ConnectionRequest> {- const toolkit = await this.getToolkitBySlug(toolkitSlug);+ // High-level helper that fans out to 3-4 network calls (toolkit retrieve,+ // optional authConfigs list, optional authConfigs create, then+ // connectedAccounts.initiate). Forward the caller's signal to every+ // underlying call so the whole composite is cancellable as a single unit.+ const toolkit = await this.getToolkitBySlug(toolkitSlug, requestOptions);const composioAuthConfig = new AuthConfigs(this.client);let authConfigIdToUse: string | undefined = authConfigId;if (!authConfigIdToUse) {- const authConfig = await composioAuthConfig.list({- toolkit: toolkitSlug,- });+ const authConfig = await composioAuthConfig.list(+ {+ toolkit: toolkitSlug,+ },+ requestOptions+ );// pick the first auth config if none is passedauthConfigIdToUse = authConfig.items[0]?.id;}@@ -317,10 +360,14 @@ export class Toolkits {// create authConfig using composioManagedAuthSchemesif (toolkit.authConfigDetails && toolkit.authConfigDetails.length > 0) {try {- const authConfig = await composioAuthConfig.create(toolkitSlug, {- type: 'use_composio_managed_auth',- name: `${toolkit.name} Auth Config`,- });+ const authConfig = await composioAuthConfig.create(+ toolkitSlug,+ {+ type: 'use_composio_managed_auth',+ name: `${toolkit.name} Auth Config`,+ },+ requestOptions+ );authConfigIdToUse = authConfig.id;} catch (error) {if (error instanceof ComposioClient.APIError && error.status === 400) {@@ -352,9 +399,14 @@ export class Toolkits {}// create the auth configconst composioConnectedAccount = new ConnectedAccounts(this.client);- return await composioConnectedAccount.initiate(userId, authConfigIdToUse, {- // in this magic function we allow multiple connected accounts per user for an auth config- allowMultiple: true,- });+ return await composioConnectedAccount.initiate(+ userId,+ authConfigIdToUse,+ {+ // in this magic function we allow multiple connected accounts per user for an auth config+ allowMultiple: true,+ },+ requestOptions+ );}}diff --git a/ts/packages/core/src/models/Tools.ts b/ts/packages/core/src/models/Tools.tsindex 25ddb7493..808fc5dfd 100644--- a/ts/packages/core/src/models/Tools.ts+++ b/ts/packages/core/src/models/Tools.ts@@ -55,6 +55,9 @@ import type { SessionExecuteParams } from '@composio/client/resources/tool-routeimport { CONFIG_DEFAULTS } from '../utils/config-defaults';import { resolveEffectiveUploadAllowlist } from '../utils/fileDirs';import { schemaHasFileUploadable } from '../utils/modifiers/FileToolModifier.utils.neutral';+import { ComposioRequestOptions } from '../types/requestOptions.types';+import { withCancellation } from '../utils/cancellation';+import { ComposioRequestCancelledError } from '../errors/SDKErrors';const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;@@ -233,8 +236,12 @@ export class Tools<toolkitSlug: string;params: ToolExecuteParams;},- modifiers?: ExecuteToolModifiers+ modifiers?: ExecuteToolModifiers,+ requestOptions?: ComposioRequestOptions): Promise<ToolExecuteParams> {+ if (requestOptions?.signal?.aborted) {+ throw new ComposioRequestCancelledError();+ }let modifiedParams = params;// if auto upload download files is enabled, upload the files to the Composio APIif (this.autoUploadDownloadFiles) {@@ -246,7 +253,11 @@ export class Tools<toolSlug,toolkitSlug,params: modifiedParams,+ signal: requestOptions?.signal,});+ if (requestOptions?.signal?.aborted) {+ throw new ComposioRequestCancelledError();+ }} else if (schemaHasFileUploadable(tool.inputParameters) &&!this.warnedAutoUploadDisabledForTool.has(toolSlug)@@ -276,6 +287,9 @@ export class Tools<toolkitSlug,params: modifiedParams,});+ if (requestOptions?.signal?.aborted) {+ throw new ComposioRequestCancelledError();+ }} else {throw new ComposioInvalidModifierError('Invalid beforeExecute modifier. Not a function.');}@@ -302,8 +316,17 @@ export class Tools<toolkitSlug: string;result: ToolExecuteResponse;},- modifier?: afterExecuteModifier+ modifier?: afterExecuteModifier,+ requestOptions?: ComposioRequestOptions): Promise<ToolExecuteResponse> {+ // The tool already executed and may have mutated external state, so a late+ // abort does NOT short-circuit post-processing: skipping the caller's+ // afterExecute modifier here would leave a half-finished pipeline that+ // still looks like success-shaped data. Once the remote call has committed+ // we run file download + afterExecute to completion. The signal is still+ // forwarded to the download so a stuck transfer degrades gracefully+ // (file_downloaded: false) rather than blocking, but it never skips+ // afterExecute.let modifiedResult = result;// if auto upload download files is enabled, download the files from the Composio APIif (this.autoUploadDownloadFiles) {@@ -312,6 +335,7 @@ export class Tools<toolSlug,toolkitSlug,result: modifiedResult,+ signal: requestOptions?.signal,});}// apply the after execute modifiers@@ -391,7 +415,8 @@ export class Tools<*/async getRawComposioTools(query: ToolListParams,- options?: SchemaModifierOptions+ options?: SchemaModifierOptions,+ requestOptions?: ComposioRequestOptions): Promise<ToolList> {if ('tools' in query && 'toolkits' in query) {throw new ValidationError(@@ -456,7 +481,10 @@ export class Tools<logger.debug(`Fetching tools with filters: ${JSON.stringify(filters, null, 2)}`);- const tools = await this.client.tools.list(filters);+ const tools = await withCancellation(+ () => this.client.tools.list(filters, requestOptions),+ requestOptions?.signal+ );if (!tools) {return [];@@ -503,16 +531,21 @@ export class Tools<*/async getRawToolRouterSessionTools(sessionId: string,- options?: SchemaModifierOptions+ options?: SchemaModifierOptions,+ requestOptions?: ComposioRequestOptions): Promise<ToolList> {const tools: ToolList = [];let cursor: string | null | undefined;do {- const response = await this.client.toolRouter.session.tools(sessionId, {+ const sessionToolsParams = {limit: TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT,...(cursor ? { cursor } : {}),- });+ };+ const response = await withCancellation(+ () => this.client.toolRouter.session.tools(sessionId, sessionToolsParams, requestOptions),+ requestOptions?.signal+ );tools.push(...response.items.map(tool => this.transformToolCases(tool)));cursor = response.next_cursor;} while (cursor);@@ -588,7 +621,11 @@ export class Tools<* });* ```*/- async getRawComposioToolBySlug(slug: string, options?: ToolRetrievalOptions): Promise<Tool> {+ async getRawComposioToolBySlug(+ slug: string,+ options?: ToolRetrievalOptions,+ requestOptions?: ComposioRequestOptions+ ): Promise<Tool> {let tool: ToolRetrieveResponse;try {// Build API call parameters based on version source@@ -596,8 +633,14 @@ export class Tools<? { version: options.version } // Explicit version → use 'version' param: { toolkit_versions: this.toolkitVersions }; // SDK config → use 'toolkit_versions' param- tool = await this.client.tools.retrieve(slug, retrieveParams);+ tool = await withCancellation(+ () => this.client.tools.retrieve(slug, retrieveParams, requestOptions),+ requestOptions?.signal+ );} catch (error) {+ if (error instanceof ComposioRequestCancelledError) {+ throw error;+ }throw new ComposioToolNotFoundError(`Unable to retrieve tool with slug ${slug}`, {cause: error,});@@ -627,7 +670,7 @@ export class Tools<** @param {string} userId - The user id to get the tools for* @param {ToolListParams} filters - The filters to apply when fetching tools- * @param {ProviderOptions<TProvider>} [options] - Optional provider options including modifiers+ * @param {ProviderOptions<TProvider> & ComposioRequestOptions} [options] - Provider options, modifiers, and/or AbortSignal* @returns {Promise<ReturnType<T['wrapTools']>>} The wrapped tools collection** @example@@ -638,28 +681,16 @@ export class Tools<* limit: 10* });*- * // Get tools with search- * const searchTools = await composio.tools.get('default', {- * search: 'user',- * limit: 10- * });- *- * // Get a specific tool by slug- * const hackerNewsUserTool = await composio.tools.get('default', 'HACKERNEWS_GET_USER');- *- * // Get a tool with schema modifications- * const tool = await composio.tools.get('default', 'GITHUB_GET_REPOS', {- * modifySchema: (toolSlug, toolkitSlug, schema) => {- * // Customize the tool schema- * return {...schema, description: 'Custom description'};- * }- * });+ * // Timeout a slow search after 5s+ * const tools = await composio.tools.get('default', {+ * search: 'send email',+ * }, { signal: AbortSignal.timeout(5_000) });* ```*/async get<T extends TProvider>(userId: string,filters: ToolListParams,- options?: ProviderOptions<TProvider>+ options?: ProviderOptions<TProvider> & ComposioRequestOptions): Promise<ReturnType<T['wrapTools']>>;/**@@ -668,7 +699,7 @@ export class Tools<** @param {string} userId - The user id to get the tool for* @param {string} slug - The slug of the tool to fetch- * @param {ProviderOptions<TProvider>} [options] - Optional provider options including modifiers+ * @param {ProviderOptions<TProvider> & ComposioRequestOptions} [options] - Optional provider options including modifiers and signal* @returns {Promise<ReturnType<T['wrapTools']>>} The wrapped tool** @example@@ -683,51 +714,56 @@ export class Tools<* return {...schema, description: 'Custom description'};* }* });+ *+ * // Timeout after 5s+ * const tools = await composio.tools.get('user_1', { search: 'email' }, {+ * signal: AbortSignal.timeout(5_000)+ * });* ```*/async get<T extends TProvider>(userId: string,slug: string,- options?: ProviderOptions<TProvider>+ options?: ProviderOptions<TProvider> & ComposioRequestOptions): Promise<ReturnType<T['wrapTools']>>;- /**- * Get a tool or list of tools based on the provided arguments.- * This is an implementation method that handles all overloads.- *- * @param {string} userId - The user id to get the tool(s) for- * @param {ToolListParams | string} arg2 - Either a slug string or filters object- * @param {ProviderOptions<TProvider> | ToolkitVersion} [arg3] - Optional provider options or version string- * @param {ProviderOptions<TProvider>} [arg4] - Optional provider options (when arg3 is version)- * @returns {Promise<TToolCollection>} The tool collection- */async get(userId: string,arg2: ToolListParams | string,- arg3?: ProviderOptions<TProvider>+ arg3?: ProviderOptions<TProvider> & ComposioRequestOptions): Promise<TToolCollection> {- // Handle the two-parameter overloads- const options = arg3 as ProviderOptions<TProvider>;+ const options = arg3;+ const requestOptions: ComposioRequestOptions | undefined =+ options?.signal != null ? { signal: options.signal } : undefined;+ // Strip signal so it isn't captured in the provider execution closure —+ // an expired AbortSignal.timeout() would poison every future tool call.+ const { signal: _, ...modifiers } = options ?? {};- // if the second argument is a string, get a single toolif (typeof arg2 === 'string') {- const tool = await this.getRawComposioToolBySlug(arg2, {- modifySchema: options?.modifySchema as TransformToolSchemaModifier,- });+ const tool = await this.getRawComposioToolBySlug(+ arg2,+ {+ modifySchema: options?.modifySchema as TransformToolSchemaModifier,+ },+ requestOptions+ );return this.wrapToolsForProvider(userId,[tool],- options as ExecuteToolModifiers+ modifiers as ExecuteToolModifiers) as TToolCollection;} else {- // if the second argument is an object, get a list of tools- const tools = await this.getRawComposioTools(arg2, {- modifySchema: options?.modifySchema as TransformToolSchemaModifier,- });+ const tools = await this.getRawComposioTools(+ arg2,+ {+ modifySchema: options?.modifySchema as TransformToolSchemaModifier,+ },+ requestOptions+ );return this.wrapToolsForProvider(userId,tools,- options as ExecuteToolModifiers+ modifiers as ExecuteToolModifiers) as TToolCollection;}}@@ -851,7 +887,8 @@ export class Tools<*/private async executeComposioTool(tool: Tool,- body: ToolExecuteParams+ body: ToolExecuteParams,+ requestOptions?: ComposioRequestOptions): Promise<ToolExecuteResponse> {const toolkitVersion =body.version ?? getToolkitVersion(tool.toolkit?.slug ?? 'unknown', this.toolkitVersions);@@ -860,7 +897,7 @@ export class Tools<throw new ComposioToolVersionRequiredError();}try {- const result = await this.client.tools.execute(tool.slug, {+ const executeBody: ComposioToolExecuteParams = {allow_tracing: body.allowTracing,connected_account_id: body.connectedAccountId,custom_auth_params: body.customAuthParams@@ -883,10 +920,17 @@ export class Tools<user_id: body.userId,version: toolkitVersion,text: body.text,- });+ };+ const result = await withCancellation(+ () => this.client.tools.execute(tool.slug, executeBody, requestOptions),+ requestOptions?.signal+ );// transform the response to the ToolExecuteResponse formatreturn this.transformToolExecuteResponse(result);} catch (error) {+ if (error instanceof ComposioRequestCancelledError) {+ throw error;+ }const toolError = handleToolExecutionError(tool.slug, error as Error);throw toolError;}@@ -962,20 +1006,37 @@ export class Tools<* }* });* ```+ *+ * @example Execute with timeout+ * ```typescript+ * const result = await composio.tools.execute('HACKERNEWS_GET_FRONTPAGE', {+ * userId: 'default',+ * arguments: {},+ * dangerouslySkipVersionCheck: true,+ * }, { signal: AbortSignal.timeout(5_000) });+ * ```*/async execute(slug: string,body: ToolExecuteParams,- modifiers?: ExecuteToolModifiers+ options?: ExecuteToolModifiers & ComposioRequestOptions): Promise<ToolExecuteResponse> {const executeParams = ToolExecuteParamsSchema.safeParse(body);if (!executeParams.success) {throw new ValidationError('Invalid tool execute parameters', { cause: executeParams.error });}- const tool = await this.getRawComposioToolBySlug(slug, {- version: body.version,- });+ const requestOptions: ComposioRequestOptions | undefined =+ options?.signal != null ? { signal: options.signal } : undefined;+ const { signal: _, ...modifiers } = options ?? {};++ const tool = await this.getRawComposioToolBySlug(+ slug,+ {+ version: body.version,+ },+ requestOptions+ );const toolkitSlug = tool.toolkit?.slug ?? 'unknown';// Apply before execute modifiers@@ -986,10 +1047,11 @@ export class Tools<toolkitSlug,params: executeParams.data,},- modifiers+ modifiers as ExecuteToolModifiers,+ requestOptions);- let result = await this.executeComposioTool(tool, params);+ let result = await this.executeComposioTool(tool, params, requestOptions);// Apply after execute modifiersresult = await this.applyAfterExecuteModifiers(@@ -999,7 +1061,8 @@ export class Tools<toolkitSlug,result,},- modifiers?.afterExecute+ (modifiers as ExecuteToolModifiers).afterExecute,+ requestOptions);return result;@@ -1021,7 +1084,8 @@ export class Tools<body: ToolExecuteMetaParams,modifiers?: SessionExecuteMetaModifiers,tool?: Tool,- options?: ToolRouterSessionExecuteOptions+ options?: ToolRouterSessionExecuteOptions,+ requestOptions?: ComposioRequestOptions): Promise<ToolExecuteResponse> {const executeParams = ToolExecuteMetaParamsSchema.safeParse(body);if (!executeParams.success) {@@ -1053,7 +1117,10 @@ export class Tools<executePayload.experimental = options.experimental;}- const response = await this.client.toolRouter.session.execute(body.sessionId, executePayload);+ const response = await withCancellation(+ () => this.client.toolRouter.session.execute(body.sessionId, executePayload, requestOptions),+ requestOptions?.signal+ );// Prepare the resultlet result: ToolExecuteResponse = {@@ -1090,8 +1157,11 @@ export class Tools<* console.log(toolsEnum.items);* ```*/- async getToolsEnum(): Promise<ToolRetrieveEnumResponse> {- return this.client.tools.retrieveEnum();+ async getToolsEnum(requestOptions?: ComposioRequestOptions): Promise<ToolRetrieveEnumResponse> {+ return withCancellation(+ () => this.client.tools.retrieveEnum(requestOptions),+ requestOptions?.signal+ );}/**@@ -1112,8 +1182,15 @@ export class Tools<* console.log(inputParams.schema);* ```*/- async getInput(slug: string, body: ToolGetInputParams): Promise<ToolGetInputResponse> {- return this.client.tools.getInput(slug, body);+ async getInput(+ slug: string,+ body: ToolGetInputParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<ToolGetInputResponse> {+ return withCancellation(+ () => this.client.tools.getInput(slug, body, requestOptions),+ requestOptions?.signal+ );}/**@@ -1139,7 +1216,10 @@ export class Tools<* console.log(response.data);* ```*/- async proxyExecute(body: ToolProxyParams): Promise<ToolProxyResponse> {+ async proxyExecute(+ body: ToolProxyParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<ToolProxyResponse> {const toolProxyParams = ToolProxyParamsSchema.safeParse(body);if (!toolProxyParams.success) {throw new ValidationError('Invalid tool proxy parameters', { cause: toolProxyParams.error });@@ -1162,7 +1242,7 @@ export class Tools<);}- return this.client.tools.proxy({+ const proxyBody = {endpoint: toolProxyParams.data.endpoint,method: toolProxyParams.data.method,body: toolProxyParams.data.body,@@ -1177,6 +1257,10 @@ export class Tools<*/// @ts-ignorecustom_connection_data: toolProxyParams.data.customConnectionData,- });+ } as ComposioToolProxyParams;+ return withCancellation(+ () => this.client.tools.proxy(proxyBody, requestOptions),+ requestOptions?.signal+ );}}diff --git a/ts/packages/core/src/models/Triggers.ts b/ts/packages/core/src/models/Triggers.tsindex 18d09bc23..8582ca918 100644--- a/ts/packages/core/src/models/Triggers.ts+++ b/ts/packages/core/src/models/Triggers.ts@@ -53,6 +53,8 @@ import { ComposioConfig } from '../composio';import { BaseComposioProvider } from '../provider/BaseProvider';import { hmacSha256Base64, timingSafeEqual } from '../utils/crypto';import { CONFIG_DEFAULTS } from '../utils/config-defaults';+import { ComposioRequestOptions } from '../types/requestOptions.types';+import { withCancellation } from '../utils/cancellation';/*** Safely converts a value to a string, returning the default if the value is null, undefined, or empty.@@ -102,7 +104,8 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u* ```*/async listActive(- query?: TriggerInstanceListActiveParams+ query?: TriggerInstanceListActiveParams,+ requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceListActiveResponse> {// Validate the parameters if provided@@ -114,18 +117,20 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u});}- const result = await this.client.triggerInstances.listActive(- query- ? {- auth_config_ids: parsedParams.data.authConfigIds,- connected_account_ids: parsedParams.data.connectedAccountIds,- cursor: parsedParams.data.cursor,- limit: parsedParams.data.limit,- show_disabled: parsedParams.data.showDisabled,- trigger_ids: parsedParams.data.triggerIds,- trigger_names: parsedParams.data.triggerNames,- }- : undefined+ const listParams = query+ ? {+ auth_config_ids: parsedParams.data.authConfigIds,+ connected_account_ids: parsedParams.data.connectedAccountIds,+ cursor: parsedParams.data.cursor,+ limit: parsedParams.data.limit,+ show_disabled: parsedParams.data.showDisabled,+ trigger_ids: parsedParams.data.triggerIds,+ trigger_names: parsedParams.data.triggerNames,+ }+ : undefined;+ const result = await withCancellation(+ () => this.client.triggerInstances.listActive(listParams, requestOptions),+ requestOptions?.signal);return transformTriggerInstanceListActiveResponse(result);}@@ -142,7 +147,8 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, uasync create(userId: string,slug: string,- body?: TriggerInstanceUpsertParams+ body?: TriggerInstanceUpsertParams,+ requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceUpsertResponse> {const parsedBody = TriggerInstanceUpsertParamsSchema.safeParse(body ?? {});@@ -156,7 +162,7 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, ulet triggerType: TriggersTypeRetrieveResponse;let toolkitSlug: string;try {- triggerType = await this.getType(slug);+ triggerType = await this.getType(slug, requestOptions);toolkitSlug = triggerType.toolkit.slug;} catch (error) {// for some reason, the triggers types list endpoint returns 400 for invalid user ids@@ -178,10 +184,14 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, ulet connectedAccountId: string | undefined = body?.connectedAccountId;try {- const { items: connectedAccounts } = await this.client.connectedAccounts.list({+ const connectedAccountListParams = {user_ids: [userId],toolkit_slugs: [toolkitSlug],- });+ };+ const { items: connectedAccounts } = await withCancellation(+ () => this.client.connectedAccounts.list(connectedAccountListParams, requestOptions),+ requestOptions?.signal+ );if (connectedAccounts.length === 0) {throw new ComposioConnectedAccountNotFoundError(@@ -242,8 +252,10 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, utoolkit_versions: this.toolkitVersions,user_id: userId,};-- const result = await this.client.triggerInstances.upsert(slug, upsertParams);+ const result = await withCancellation(+ () => this.client.triggerInstances.upsert(slug, upsertParams, requestOptions),+ requestOptions?.signal+ );return {triggerId: result.trigger_id,@@ -259,9 +271,13 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u*/async update(triggerId: string,- body: TriggerInstanceManageUpdateParams+ body: TriggerInstanceManageUpdateParams,+ requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceManageUpdateResponse> {- return this.client.triggerInstances.manage.update(triggerId, body);+ return withCancellation(+ () => this.client.triggerInstances.manage.update(triggerId, body, requestOptions),+ requestOptions?.signal+ );}/**@@ -270,8 +286,14 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u* @param {string} triggerId - The slug of the trigger instance* @returns*/- async delete(triggerId: string): Promise<TriggerInstanceManageDeleteResponse> {- const result = await this.client.triggerInstances.manage.delete(triggerId);+ async delete(+ triggerId: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<TriggerInstanceManageDeleteResponse> {+ const result = await withCancellation(+ () => this.client.triggerInstances.manage.delete(triggerId, requestOptions),+ requestOptions?.signal+ );return {triggerId: result.trigger_id,};@@ -283,10 +305,12 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u* @param {string} triggerId - The id of the trigger instance* @returns {Promise<TriggerInstanceUpsertResponse>} The updated trigger instance*/- async disable(triggerId: string) {- return this.client.triggerInstances.manage.update(triggerId, {- status: 'disable',- });+ async disable(triggerId: string, requestOptions?: ComposioRequestOptions) {+ const body = { status: 'disable' as const };+ return withCancellation(+ () => this.client.triggerInstances.manage.update(triggerId, body, requestOptions),+ requestOptions?.signal+ );}/**@@ -295,10 +319,12 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u* @param {string} triggerId - The id of the trigger instance* @returns {Promise<TriggerInstanceUpsertResponse>} The updated trigger instance*/- async enable(triggerId: string) {- return this.client.triggerInstances.manage.update(triggerId, {- status: 'enable',- });+ async enable(triggerId: string, requestOptions?: ComposioRequestOptions) {+ const body = { status: 'enable' as const };+ return withCancellation(+ () => this.client.triggerInstances.manage.update(triggerId, body, requestOptions),+ requestOptions?.signal+ );}/**@@ -311,17 +337,24 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u* @param {RequestOptions} options - Request options* @returns {Promise<TriggersTypeListResponse>} The list of trigger types*/- async listTypes(query?: TriggersTypeListParams): Promise<TriggersTypeListResponse> {+ async listTypes(+ query?: TriggersTypeListParams,+ requestOptions?: ComposioRequestOptions+ ): Promise<TriggersTypeListResponse> {const parsedQuery = transform(query ?? {}).with(TriggersTypeListParamsSchema).using(raw => raw);- const result = await this.client.triggersTypes.list({+ const listParams = {cursor: parsedQuery.cursor,limit: parsedQuery.limit,toolkit_slugs: parsedQuery.toolkits,toolkit_versions: this.toolkitVersions,- });+ };+ const result = await withCancellation(+ () => this.client.triggersTypes.list(listParams, requestOptions),+ requestOptions?.signal+ );return transformTriggerTypeListResponse(result);}@@ -333,11 +366,18 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u* @param {string} slug - The slug of the trigger type* @returns {Promise<TriggersTypeRetrieveResponse>} The trigger type object*/- async getType(slug: string): Promise<TriggersTypeRetrieveResponse> {- const result = await this.client.triggersTypes.retrieve(slug, {+ async getType(+ slug: string,+ requestOptions?: ComposioRequestOptions+ ): Promise<TriggersTypeRetrieveResponse> {+ const retrieveParams = {// if the version is provided override the global versiontoolkit_versions: this.toolkitVersions,- });+ };+ const result = await withCancellation(+ () => this.client.triggersTypes.retrieve(slug, retrieveParams, requestOptions),+ requestOptions?.signal+ );return transformTriggerTypeRetrieveResponse(result);}@@ -347,8 +387,13 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u* This method is used by the CLI where filters are not required.* @returns*/- async listEnum(): Promise<TriggersTypeRetrieveEnumResponse> {- return this.client.triggersTypes.retrieveEnum();+ async listEnum(+ requestOptions?: ComposioRequestOptions+ ): Promise<TriggersTypeRetrieveEnumResponse> {+ return withCancellation(+ () => this.client.triggersTypes.retrieveEnum(requestOptions),+ requestOptions?.signal+ );}/**diff --git a/ts/packages/core/src/models/customToolExecution.ts b/ts/packages/core/src/models/customToolExecution.tsindex 803987610..58f38b088 100644--- a/ts/packages/core/src/models/customToolExecution.ts+++ b/ts/packages/core/src/models/customToolExecution.ts@@ -9,6 +9,7 @@ import type {} from '../types/customTool.types';import type { ToolExecuteResponse } from '../types/tool.types';import { ValidationError } from '../errors';+import { ComposioRequestCancelledError, isRequestAbortError } from '../errors/SDKErrors';/*** Find a custom tool entry by slug.@@ -62,10 +63,15 @@ export function assertUnambiguousCustomToolSlug(export async function executeCustomTool(entry: CustomToolsMapEntry,arguments_: Record<string, unknown>,- sessionContext: SessionContext+ sessionContext: SessionContext,+ options?: { signal?: AbortSignal }): Promise<ToolExecuteResponse> {const { handle } = entry;+ if (options?.signal?.aborted) {+ throw new ComposioRequestCancelledError();+ }+// Validate and transform input using the original Zod schema.// This applies defaults, coercions, and transforms (e.g. z.string().default('all')).const parsed = handle.inputParams.safeParse(arguments_);@@ -76,16 +82,32 @@ export async function executeCustomTool(successful: false,};}+ if (options?.signal?.aborted) {+ throw new ComposioRequestCancelledError();+ }try {- // User's execute returns data directly — we wrap into { data, error, successful }- const data = await handle.execute(parsed.data, sessionContext);+ // Object.create preserves prototype methods (execute, proxyExecute) that spread would drop+ const ctxWithSignal: SessionContext = options?.signal+ ? Object.assign(Object.create(sessionContext as object) as SessionContext, {+ signal: options.signal,+ })+ : sessionContext;+ const data = await handle.execute(parsed.data, ctxWithSignal);return {data: data ?? {},error: null,successful: true,};} catch (err: unknown) {+ if (err instanceof ComposioRequestCancelledError) {+ throw err;+ }+ if (options?.signal?.aborted && isRequestAbortError(err)) {+ throw new ComposioRequestCancelledError(undefined, {+ cause: err instanceof Error ? err : undefined,+ });+ }const message = err instanceof Error ? err.message : String(err);return {data: {},diff --git a/ts/packages/core/src/types/customTool.types.ts b/ts/packages/core/src/types/customTool.types.tsindex 20cacb605..fb358e35e 100644--- a/ts/packages/core/src/types/customTool.types.ts+++ b/ts/packages/core/src/types/customTool.types.ts@@ -35,6 +35,14 @@ export interface SessionContext {): Promise<ToolRouterSessionExecuteResponse>;/** Proxy API calls through Composio's auth layer (resolved from session toolkit). */proxyExecute(params: SessionProxyExecuteParams): Promise<ToolRouterSessionProxyExecuteResponse>;+ /**+ * Caller-supplied AbortSignal forwarded from `session.execute(..., { signal })`.+ * Custom-tool execution is cooperative: long-running user code that respects+ * this signal (e.g. by passing it into `fetch`) can abort mid-execution and+ * surface as `ComposioRequestCancelledError`. Undefined when the caller did+ * not pass `requestOptions`.+ */+ readonly signal?: AbortSignal;}/**diff --git a/ts/packages/core/src/types/requestOptions.types.ts b/ts/packages/core/src/types/requestOptions.types.tsnew file mode 100644index 000000000..0f9ab9787--- /dev/null+++ b/ts/packages/core/src/types/requestOptions.types.ts@@ -0,0 +1,62 @@+import type ComposioClient from '@composio/client';++/**+ * Per-request transport options for cancelling an SDK call.+ *+ * For `tools.get` and `tools.execute`, pass `signal` directly in the+ * options bag (3rd argument) alongside any modifiers or provider options.+ * For other methods (e.g. `toolkits.get`, `authConfigs.list`), pass as a+ * trailing argument. Forwarded to the underlying `@composio/client` request.+ *+ * If the underlying request is aborted via this signal, the SDK throws a+ * {@link ComposioRequestCancelledError} so callers can `instanceof`-detect+ * cancellation without unwrapping nested causes.+ *+ * @example Timeout after 5 seconds+ * ```typescript+ * await composio.tools.execute(+ * 'HACKERNEWS_GET_FRONTPAGE',+ * { userId: 'default', arguments: {} },+ * { signal: AbortSignal.timeout(5_000) }+ * );+ * ```+ *+ * @example Combine signal with modifiers+ * ```typescript+ * await composio.tools.execute('TOOL', body, {+ * signal: AbortSignal.timeout(10_000),+ * beforeExecute: ({ params }) => params,+ * });+ * ```+ */+export type ComposioRequestOptions = {+ /**+ * An `AbortSignal` used to cancel the in-flight HTTP request. When the+ * signal aborts, the underlying fetch is aborted and the SDK throws a+ * {@link ComposioRequestCancelledError} (subclass of {@link ComposioError}).+ */+ signal?: AbortSignal;+};++/**+ * The `@composio/client` per-request transport options, reached via a public+ * method whose only parameter is that type (`tools.retrieveEnum`). The+ * `internal/*` subpath that declares `RequestOptions` is not in the package's+ * `exports`, so we derive it structurally instead of deep-importing it.+ * @internal+ */+type ClientRequestOptions = NonNullable<Parameters<ComposioClient['tools']['retrieveEnum']>[0]>;++/**+ * Compile-time guards: {@link ComposioRequestOptions} is forwarded verbatim to+ * every `@composio/client` call, so it MUST stay a structural subset of the+ * client's request options. These constraints fail the build (TS2344) if a+ * field here is typed incompatibly with the client's same-named field, or if a+ * key is added that the client doesn't have — forcing the divergence to be+ * reconciled rather than discovered at runtime.+ * @internal+ */+type AssertValuesAssignable<_T extends ClientRequestOptions> = void;+type AssertKeysSubset<_K extends keyof ClientRequestOptions> = void;+type _RequestOptionsValuesStayCompatible = AssertValuesAssignable<ComposioRequestOptions>;+type _RequestOptionsKeysStaySubset = AssertKeysSubset<keyof ComposioRequestOptions>;diff --git a/ts/packages/core/src/utils/cancellation.ts b/ts/packages/core/src/utils/cancellation.tsnew file mode 100644index 000000000..ee92d2f14--- /dev/null+++ b/ts/packages/core/src/utils/cancellation.ts@@ -0,0 +1,22 @@+import { ComposioRequestCancelledError, isRequestAbortError } from '../errors/SDKErrors';++/** @internal */+export async function withCancellation<T>(+ call: () => Promise<T>,+ signal?: AbortSignal+): Promise<T> {+ try {+ return await call();+ } catch (error) {+ if (signal?.aborted && isRequestAbortError(error)) {+ const underlyingMessage = error instanceof Error ? error.message : '';+ const message = underlyingMessage+ ? `Request was cancelled by the caller: ${underlyingMessage}`+ : 'Request was cancelled by the caller';+ throw new ComposioRequestCancelledError(message, {+ cause: error instanceof Error ? error : undefined,+ });+ }+ throw error;+ }+}diff --git a/ts/packages/core/src/utils/fileUtils.node.ts b/ts/packages/core/src/utils/fileUtils.node.tsindex 57b04341b..50f2c8429 100644--- a/ts/packages/core/src/utils/fileUtils.node.ts+++ b/ts/packages/core/src/utils/fileUtils.node.ts@@ -36,6 +36,7 @@ export type GetFileDataAfterUploadingToS3Options = {* An empty array means "no paths are allowed" (fail-closed).*/fileUploadAllowlist?: string[];+ signal?: AbortSignal;};// Helper function to get file extension from MIME type@@ -146,9 +147,10 @@ const readFileContent = async (};const readFileContentFromURL = async (- path: string+ path: string,+ signal?: AbortSignal): Promise<{ fileName: string; content: string; mimeType: string }> => {- const response = await fetch(path);+ const response = await fetch(path, { signal });if (!response.ok) {throw new Error(`Failed to fetch file: ${response.statusText}`);}@@ -188,16 +190,20 @@ const uploadFileToS3 = async (toolSlug: string,toolkitSlug: string,mimeType: string,- client: ComposioClient+ client: ComposioClient,+ signal?: AbortSignal): Promise<string> => {const contentBytes = base64ToUint8Array(content);- const response = await client.files.createPresignedURL({- filename: fileName,- mimetype: mimeType,- md5: crypto.createHash('md5').update(contentBytes).digest('hex'),- tool_slug: toolSlug,- toolkit_slug: toolkitSlug,- });+ const response = await client.files.createPresignedURL(+ {+ filename: fileName,+ mimetype: mimeType,+ md5: crypto.createHash('md5').update(contentBytes).digest('hex'),+ tool_slug: toolSlug,+ toolkit_slug: toolkitSlug,+ },+ { signal }+ );const { key, new_presigned_url: signedURL } = response;@@ -217,6 +223,7 @@ const uploadFileToS3 = async (const uploadResponse = await fetch(signedURL, {method: 'PUT',body: uploadBuffer,+ signal,headers: {'Content-Type': mimeType,},@@ -230,10 +237,10 @@ const uploadFileToS3 = async (};const readFile = async (- file: File | string+ file: File | string,+ signal?: AbortSignal): Promise<{ fileName: string; content: string; mimeType: string }> => {if (file instanceof File) {- // if file is a File, read the content from the fileconst content = await file.arrayBuffer();return {fileName: file.name,@@ -242,7 +249,7 @@ const readFile = async (};} else if (typeof file === 'string') {if (file.startsWith('http')) {- return await readFileContentFromURL(file);+ return await readFileContentFromURL(file, signal);} else {return await readFileContent(file);}@@ -259,6 +266,7 @@ export const getFileDataAfterUploadingToS3 = async (sensitiveFileUploadProtection,fileUploadPathDenySegments,fileUploadAllowlist,+ signal,}: GetFileDataAfterUploadingToS3Options): Promise<FileUploadData> => {if (!file) {@@ -277,7 +285,7 @@ export const getFileDataAfterUploadingToS3 = async (});}- const fileData = await readFile(file);+ const fileData = await readFile(file, signal);logger.debug(`Uploading file to S3...`);const s3key = await uploadFileToS3(platform.basename(fileData.fileName),@@ -285,7 +293,8 @@ export const getFileDataAfterUploadingToS3 = async (toolSlug,toolkitSlug,fileData.mimeType,- client+ client,+ signal);logger.debug(`Done! File uploaded to S3: ${s3key}`, JSON.stringify(fileData, null, 2));@@ -301,6 +310,7 @@ export const downloadFileFromS3 = async ({s3Url,mimeType,fileDownloadDir,+ signal,}: {toolSlug: string;s3Url: string;@@ -310,8 +320,9 @@ export const downloadFileFromS3 = async ({* back to `<home>/.composio/files` (the legacy default).*/fileDownloadDir?: string;+ signal?: AbortSignal;}): Promise<FileDownloadData> => {- const response = await fetch(s3Url);+ const response = await fetch(s3Url, { signal });if (!response.ok) {throw new Error(`Failed to download file: ${response.statusText}`);}diff --git a/ts/packages/core/src/utils/modifiers/FileToolModifier.node.ts b/ts/packages/core/src/utils/modifiers/FileToolModifier.node.tsindex 501642351..545b37014 100644--- a/ts/packages/core/src/utils/modifiers/FileToolModifier.node.ts+++ b/ts/packages/core/src/utils/modifiers/FileToolModifier.node.ts@@ -13,6 +13,7 @@ import {ComposioFileUploadPathNotAllowedError,ComposioSensitiveFilePathBlockedError,} from '../../errors/FileModifierErrors';+import { ComposioRequestCancelledError } from '../../errors/SDKErrors';import type { beforeFileUploadModifier } from '../../types/modifiers.types';import {downloadFileFromS3,@@ -25,6 +26,7 @@ import {schemaHasFileProperty,} from './FileToolModifier.utils.neutral';import { dereferenceJsonSchema } from '../jsonSchema';+import { withCancellation } from '../cancellation';/*** Inlines internal `$ref` pointers so the file walkers below can see the@@ -109,7 +111,10 @@ const hydrateFiles = async (client: ComposioClient;} & Pick<GetFileDataAfterUploadingToS3Options,- 'sensitiveFileUploadProtection' | 'fileUploadPathDenySegments' | 'fileUploadAllowlist'+ | 'sensitiveFileUploadProtection'+ | 'fileUploadPathDenySegments'+ | 'fileUploadAllowlist'+ | 'signal'> & {beforeFileUpload?: beforeFileUploadModifier;}@@ -155,6 +160,7 @@ const hydrateFiles = async (sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,fileUploadAllowlist: ctx.fileUploadAllowlist,+ signal: ctx.signal,});}@@ -181,6 +187,7 @@ const hydrateFiles = async (sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,fileUploadAllowlist: ctx.fileUploadAllowlist,+ signal: ctx.signal,});}}@@ -192,6 +199,7 @@ const hydrateFiles = async (client: ctx.client,sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,+ signal: ctx.signal,});}@@ -245,7 +253,7 @@ const hydrateFiles = async (*/const downloadS3File = async (value: Record<string, unknown>,- ctx: { toolSlug: string; fileDownloadDir?: string }+ ctx: { toolSlug: string; fileDownloadDir?: string; signal?: AbortSignal }): Promise<unknown> => {const { s3url, mimetype } = value as {s3url: string;@@ -260,6 +268,7 @@ const downloadS3File = async (s3Url: s3url,mimeType: mimetype ?? 'application/octet-stream',fileDownloadDir: ctx.fileDownloadDir,+ signal: ctx.signal,});logger.debug(`Downloaded → ${dl.filePath}`);@@ -297,7 +306,7 @@ const downloadS3File = async (const hydrateDownloads = async (value: unknown,schema: JSONSchemaProperty | undefined,- ctx: { toolSlug: string; fileDownloadDir?: string }+ ctx: { toolSlug: string; fileDownloadDir?: string; signal?: AbortSignal }): Promise<unknown> => {// ──────────────────────────────────────────────────────────────────────────// 1. Direct S3 reference (data-driven detection)@@ -405,24 +414,30 @@ export class FileToolModifier {toolSlug: string;toolkitSlug?: string;params: ToolExecuteParams;+ signal?: AbortSignal;}): Promise<ToolExecuteParams> {- const { params, toolSlug, toolkitSlug = 'unknown' } = options;+ const { params, toolSlug, toolkitSlug = 'unknown', signal } = options;const { arguments: args } = params;if (!args || typeof args !== 'object') return params;- // Recursively transform the arguments tree without mutating the caller’s copytry {- const newArgs = await hydrateFiles(args, resolveFileSchema(tool.inputParameters), {- toolSlug,- toolkitSlug,- client: this.client,- ...this.fileUploadPathOptions,- });+ const newArgs = await withCancellation(+ () =>+ hydrateFiles(args, resolveFileSchema(tool.inputParameters), {+ toolSlug,+ toolkitSlug,+ client: this.client,+ ...this.fileUploadPathOptions,+ signal,+ }),+ signal+ );return { ...params, arguments: newArgs as ToolExecuteParams['arguments'] };} catch (error) {if (+ error instanceof ComposioRequestCancelledError ||error instanceof ComposioSensitiveFilePathBlockedError ||error instanceof ComposioFileUploadAbortedError ||error instanceof ComposioFileUploadPathNotAllowedError ||@@ -440,19 +455,20 @@ export class FileToolModifier {tool: Tool,options: {toolSlug: string;- toolkitSlug: string; // kept for API parity, unused here+ toolkitSlug: string;result: ToolExecuteResponse;+ signal?: AbortSignal;}): Promise<ToolExecuteResponse> {- const { result, toolSlug } = options;+ const { result, toolSlug, signal } = options;- // Walk result.data without mutating the original, using output schema for guidanceconst dataWithDownloads = await hydrateDownloads(result.data,resolveFileSchema(tool.outputParameters),{toolSlug,fileDownloadDir: this.fileUploadPathOptions.fileDownloadDir,+ signal,});diff --git a/ts/packages/core/src/utils/modifiers/FileToolModifier.workerd.ts b/ts/packages/core/src/utils/modifiers/FileToolModifier.workerd.tsindex c38c81e6c..5122f4aba 100644--- a/ts/packages/core/src/utils/modifiers/FileToolModifier.workerd.ts+++ b/ts/packages/core/src/utils/modifiers/FileToolModifier.workerd.ts@@ -31,6 +31,7 @@ export class FileToolModifier {toolSlug: string;toolkitSlug?: string;params: ToolExecuteParams;+ signal?: AbortSignal;}): Promise<ToolExecuteParams> {throw new Error(UNSUPPORTED_MESSAGE);@@ -42,6 +43,7 @@ export class FileToolModifier {toolSlug: string;toolkitSlug: string;result: ToolExecuteResponse;+ signal?: AbortSignal;}): Promise<ToolExecuteResponse> {throw new Error(UNSUPPORTED_MESSAGE);diff --git a/ts/packages/core/test/AuthConfigs/authConfigs.test.ts b/ts/packages/core/test/AuthConfigs/authConfigs.test.tsindex 21aee7f88..c38b88a85 100644--- a/ts/packages/core/test/AuthConfigs/authConfigs.test.ts+++ b/ts/packages/core/test/AuthConfigs/authConfigs.test.ts@@ -158,14 +158,17 @@ describe('AuthConfigs', () => {const result = await authConfigs.list();- expect(mockClient.authConfigs.list).toHaveBeenCalledWith({- cursor: undefined,- is_composio_managed: undefined,- limit: undefined,- search: undefined,- show_disabled: undefined,- toolkit_slug: undefined,- });+ expect(mockClient.authConfigs.list).toHaveBeenCalledWith(+ {+ cursor: undefined,+ is_composio_managed: undefined,+ limit: undefined,+ search: undefined,+ show_disabled: undefined,+ toolkit_slug: undefined,+ },+ undefined+ );expect(result).toEqual({items: [mockTransformedAuthConfigResponse],@@ -188,14 +191,17 @@ describe('AuthConfigs', () => {const result = await authConfigs.list(query);- expect(mockClient.authConfigs.list).toHaveBeenCalledWith({- cursor: 'cursor_123',- is_composio_managed: true,- limit: 10,- search: 'github config',- show_disabled: true,- toolkit_slug: 'github',- });+ expect(mockClient.authConfigs.list).toHaveBeenCalledWith(+ {+ cursor: 'cursor_123',+ is_composio_managed: true,+ limit: 10,+ search: 'github config',+ show_disabled: true,+ toolkit_slug: 'github',+ },+ undefined+ );expect(result).toEqual({items: [mockTransformedAuthConfigResponse],@@ -251,17 +257,20 @@ describe('AuthConfigs', () => {const result = await authConfigs.create('github');- expect(mockClient.authConfigs.create).toHaveBeenCalledWith({- toolkit: {- slug: 'github',- },- auth_config: {- type: 'use_composio_managed_auth',- credentials: undefined,- name: undefined,- tool_access_config: undefined,+ expect(mockClient.authConfigs.create).toHaveBeenCalledWith(+ {+ toolkit: {+ slug: 'github',+ },+ auth_config: {+ type: 'use_composio_managed_auth',+ credentials: undefined,+ name: undefined,+ tool_access_config: undefined,+ },},- });+ undefined+ );expect(result).toEqual({id: 'auth_12345',@@ -295,22 +304,25 @@ describe('AuthConfigs', () => {const result = await authConfigs.create('github', options);- expect(mockClient.authConfigs.create).toHaveBeenCalledWith({- toolkit: {- slug: 'github',- },- auth_config: {- type: 'use_custom_auth',- name: 'Custom GitHub Auth',- authScheme: 'OAUTH2',- credentials: {- client_id: 'test_client_id',- client_secret: 'test_client_secret',+ expect(mockClient.authConfigs.create).toHaveBeenCalledWith(+ {+ toolkit: {+ slug: 'github',+ },+ auth_config: {+ type: 'use_custom_auth',+ name: 'Custom GitHub Auth',+ authScheme: 'OAUTH2',+ credentials: {+ client_id: 'test_client_id',+ client_secret: 'test_client_secret',+ },+ proxy_config: undefined,+ tool_access_config: undefined,},- proxy_config: undefined,- tool_access_config: undefined,},- });+ undefined+ );expect(result).toEqual({id: 'auth_12345',@@ -336,19 +348,22 @@ describe('AuthConfigs', () => {const result = await authConfigs.create('github', options);- expect(mockClient.authConfigs.create).toHaveBeenCalledWith({- toolkit: {- slug: 'github',- },- auth_config: {- type: 'use_composio_managed_auth',- credentials: {- custom_field: 'value',+ expect(mockClient.authConfigs.create).toHaveBeenCalledWith(+ {+ toolkit: {+ slug: 'github',+ },+ auth_config: {+ type: 'use_composio_managed_auth',+ credentials: {+ custom_field: 'value',+ },+ name: 'My GitHub Config',+ tool_access_config: undefined,},- name: 'My GitHub Config',- tool_access_config: undefined,},- });+ undefined+ );expect(result).toEqual({id: 'auth_12345',@@ -380,7 +395,7 @@ describe('AuthConfigs', () => {const result = await authConfigs.get('auth_12345');- expect(mockClient.authConfigs.retrieve).toHaveBeenCalledWith('auth_12345');+ expect(mockClient.authConfigs.retrieve).toHaveBeenCalledWith('auth_12345', undefined);expect(result).toEqual(mockTransformedAuthConfigResponse);});@@ -447,16 +462,20 @@ describe('AuthConfigs', () => {const result = await authConfigs.update('auth_12345', updateData);- expect(mockClient.authConfigs.update).toHaveBeenCalledWith('auth_12345', {- type: 'custom',- credentials: {- client_id: 'new_client_id',- client_secret: 'new_client_secret',- },- tool_access_config: {- tools_for_connected_account_creation: undefined,+ expect(mockClient.authConfigs.update).toHaveBeenCalledWith(+ 'auth_12345',+ {+ type: 'custom',+ credentials: {+ client_id: 'new_client_id',+ client_secret: 'new_client_secret',+ },+ tool_access_config: {+ tools_for_connected_account_creation: undefined,+ },},- });+ undefined+ );expect(result).toEqual(mockUpdateResponse);});@@ -471,13 +490,17 @@ describe('AuthConfigs', () => {const result = await authConfigs.update('auth_12345', updateData);- expect(mockClient.authConfigs.update).toHaveBeenCalledWith('auth_12345', {- type: 'default',- scopes: 'read:user,repo',- tool_access_config: {- tools_for_connected_account_creation: undefined,+ expect(mockClient.authConfigs.update).toHaveBeenCalledWith(+ 'auth_12345',+ {+ type: 'default',+ scopes: 'read:user,repo',+ tool_access_config: {+ tools_for_connected_account_creation: undefined,+ },},- });+ undefined+ );expect(result).toEqual(mockUpdateResponse);});@@ -494,15 +517,19 @@ describe('AuthConfigs', () => {const result = await authConfigs.update('auth_12345', updateData);- expect(mockClient.authConfigs.update).toHaveBeenCalledWith('auth_12345', {- type: 'custom',- credentials: {- api_key: 'new_api_key',- },- tool_access_config: {- tools_for_connected_account_creation: undefined,+ expect(mockClient.authConfigs.update).toHaveBeenCalledWith(+ 'auth_12345',+ {+ type: 'custom',+ credentials: {+ api_key: 'new_api_key',+ },+ tool_access_config: {+ tools_for_connected_account_creation: undefined,+ },},- });+ undefined+ );expect(result).toEqual(mockUpdateResponse);});@@ -545,7 +572,11 @@ describe('AuthConfigs', () => {const result = await authConfigs.delete('auth_12345');- expect(mockClient.authConfigs.delete).toHaveBeenCalledWith('auth_12345');+ expect(mockClient.authConfigs.delete).toHaveBeenCalledWith(+ 'auth_12345',+ undefined,+ undefined+ );expect(result).toEqual(mockDeleteResponse);});@@ -568,9 +599,13 @@ describe('AuthConfigs', () => {const result = await authConfigs.updateStatus('ENABLED', 'auth_12345');- expect(mockClient.authConfigs.updateStatus).toHaveBeenCalledWith('ENABLED', {- nanoid: 'auth_12345',- });+ expect(mockClient.authConfigs.updateStatus).toHaveBeenCalledWith(+ 'ENABLED',+ {+ nanoid: 'auth_12345',+ },+ undefined+ );expect(result).toEqual(mockStatusUpdateResponse);});@@ -583,9 +618,13 @@ describe('AuthConfigs', () => {const result = await authConfigs.updateStatus('DISABLED', 'auth_12345');- expect(mockClient.authConfigs.updateStatus).toHaveBeenCalledWith('DISABLED', {- nanoid: 'auth_12345',- });+ expect(mockClient.authConfigs.updateStatus).toHaveBeenCalledWith(+ 'DISABLED',+ {+ nanoid: 'auth_12345',+ },+ undefined+ );expect(result).toEqual(disabledResponse);});@@ -610,9 +649,13 @@ describe('AuthConfigs', () => {const result = await authConfigs.enable('auth_12345');- expect(mockClient.authConfigs.updateStatus).toHaveBeenCalledWith('ENABLED', {- nanoid: 'auth_12345',- });+ expect(mockClient.authConfigs.updateStatus).toHaveBeenCalledWith(+ 'ENABLED',+ {+ nanoid: 'auth_12345',+ },+ undefined+ );expect(result).toEqual(mockStatusUpdateResponse);});@@ -635,9 +678,13 @@ describe('AuthConfigs', () => {const result = await authConfigs.disable('auth_12345');- expect(mockClient.authConfigs.updateStatus).toHaveBeenCalledWith('DISABLED', {- nanoid: 'auth_12345',- });+ expect(mockClient.authConfigs.updateStatus).toHaveBeenCalledWith(+ 'DISABLED',+ {+ nanoid: 'auth_12345',+ },+ undefined+ );expect(result).toEqual(mockStatusUpdateResponse);});@@ -745,13 +792,17 @@ describe('AuthConfigs', () => {const result = await authConfigs.update('auth_12345', updateData);- expect(mockClient.authConfigs.update).toHaveBeenCalledWith('auth_12345', {- type: 'custom',- credentials: largeCredentials,- tool_access_config: {- tools_for_connected_account_creation: undefined,+ expect(mockClient.authConfigs.update).toHaveBeenCalledWith(+ 'auth_12345',+ {+ type: 'custom',+ credentials: largeCredentials,+ tool_access_config: {+ tools_for_connected_account_creation: undefined,+ },},- });+ undefined+ );expect(result).toEqual(mockUpdateResponse);});@@ -773,13 +824,17 @@ describe('AuthConfigs', () => {const result = await authConfigs.update('auth_12345', updateData);- expect(mockClient.authConfigs.update).toHaveBeenCalledWith('auth_12345', {- type: 'default',- scopes: longScopes,- tool_access_config: {- tools_for_connected_account_creation: undefined,+ expect(mockClient.authConfigs.update).toHaveBeenCalledWith(+ 'auth_12345',+ {+ type: 'default',+ scopes: longScopes,+ tool_access_config: {+ tools_for_connected_account_creation: undefined,+ },},- });+ undefined+ );expect(result).toEqual(mockUpdateResponse);});diff --git a/ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts b/ts/packages/core/test/connectedAccounts/connectedAccounts.test.tsindex 5229d3cf9..95b6f98c7 100644--- a/ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts+++ b/ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts@@ -63,7 +63,7 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.list(query);- expect(extendedMockClient.connectedAccounts.list).toHaveBeenCalledWith(query);+ expect(extendedMockClient.connectedAccounts.list).toHaveBeenCalledWith(query, undefined);expect(result).toEqual({items: [],nextCursor: null,@@ -78,7 +78,7 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.list();- expect(extendedMockClient.connectedAccounts.list).toHaveBeenCalledWith(undefined);+ expect(extendedMockClient.connectedAccounts.list).toHaveBeenCalledWith(undefined, undefined);expect(result).toEqual({items: [],nextCursor: null,@@ -123,19 +123,23 @@ describe('ConnectedAccounts', () => {user_ids: [userId],auth_config_ids: [authConfigId],statuses: [ConnectedAccountStatuses.ACTIVE],- })+ }),+ undefined);- expect(extendedMockClient.connectedAccounts.create).toHaveBeenCalledWith({- auth_config: {- id: authConfigId,- },- connection: {- user_id: userId,- callback_url: options.callbackUrl,- state: undefined,+ expect(extendedMockClient.connectedAccounts.create).toHaveBeenCalledWith(+ {+ auth_config: {+ id: authConfigId,+ },+ connection: {+ user_id: userId,+ callback_url: options.callbackUrl,+ state: undefined,+ },},- });+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_123');expect(connectionRequest).toHaveProperty('waitForConnection');@@ -168,16 +172,19 @@ describe('ConnectedAccounts', () => {const connectionRequest = await connectedAccounts.initiate(userId, authConfigId);- expect(extendedMockClient.connectedAccounts.create).toHaveBeenCalledWith({- auth_config: {- id: authConfigId,- },- connection: {- user_id: userId,- callback_url: undefined,- state: undefined,+ expect(extendedMockClient.connectedAccounts.create).toHaveBeenCalledWith(+ {+ auth_config: {+ id: authConfigId,+ },+ connection: {+ user_id: userId,+ callback_url: undefined,+ state: undefined,+ },},- });+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_123');expect(connectionRequest).toHaveProperty('waitForConnection');@@ -215,7 +222,8 @@ describe('ConnectedAccounts', () => {expect.objectContaining({auth_config: { id: authConfigId },connection: expect.objectContaining({ user_id: userId, alias: 'work-gmail' }),- })+ }),+ undefined);});@@ -336,7 +344,8 @@ describe('ConnectedAccounts', () => {user_ids: [userId],auth_config_ids: [authConfigId],statuses: [ConnectedAccountStatuses.ACTIVE],- })+ }),+ undefined);});@@ -407,16 +416,19 @@ describe('ConnectedAccounts', () => {allowMultiple: true,});- expect(extendedMockClient.connectedAccounts.create).toHaveBeenCalledWith({- auth_config: {- id: authConfigId,- },- connection: {- user_id: userId,- callback_url: undefined,- state: undefined,+ expect(extendedMockClient.connectedAccounts.create).toHaveBeenCalledWith(+ {+ auth_config: {+ id: authConfigId,+ },+ connection: {+ user_id: userId,+ callback_url: undefined,+ state: undefined,+ },},- });+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_123');expect(connectionRequest).toHaveProperty('waitForConnection');@@ -455,16 +467,19 @@ describe('ConnectedAccounts', () => {const connectionRequest = await connectedAccounts.initiate(userId, authConfigId, options);- expect(extendedMockClient.connectedAccounts.create).toHaveBeenCalledWith({- auth_config: {- id: authConfigId,- },- connection: {- user_id: userId,- callback_url: options.callbackUrl,- state: options.config,+ expect(extendedMockClient.connectedAccounts.create).toHaveBeenCalledWith(+ {+ auth_config: {+ id: authConfigId,+ },+ connection: {+ user_id: userId,+ callback_url: options.callbackUrl,+ state: options.config,+ },},- });+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_123');expect(connectionRequest).toHaveProperty('status', ConnectionStatuses.ACTIVE);@@ -652,7 +667,7 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.get(nanoid);- expect(extendedMockClient.connectedAccounts.retrieve).toHaveBeenCalledWith(nanoid);+ expect(extendedMockClient.connectedAccounts.retrieve).toHaveBeenCalledWith(nanoid, undefined);expect(result).toEqual({id: 'nanoid',status: 'ACTIVE',@@ -750,7 +765,11 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.delete(nanoid);- expect(extendedMockClient.connectedAccounts.delete).toHaveBeenCalledWith(nanoid);+ expect(extendedMockClient.connectedAccounts.delete).toHaveBeenCalledWith(+ nanoid,+ undefined,+ undefined+ );expect(result).toEqual(mockResponse);});});@@ -764,7 +783,11 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.refresh(nanoid);- expect(extendedMockClient.connectedAccounts.refresh).toHaveBeenCalledWith(nanoid, undefined);+ expect(extendedMockClient.connectedAccounts.refresh).toHaveBeenCalledWith(+ nanoid,+ undefined,+ undefined+ );expect(result).toEqual(mockResponse);});@@ -777,10 +800,14 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.refresh(nanoid, { redirectUrl });- expect(extendedMockClient.connectedAccounts.refresh).toHaveBeenCalledWith(nanoid, {- query_redirect_url: redirectUrl,- validate_credentials: undefined,- });+ expect(extendedMockClient.connectedAccounts.refresh).toHaveBeenCalledWith(+ nanoid,+ {+ query_redirect_url: redirectUrl,+ validate_credentials: undefined,+ },+ undefined+ );expect(result).toEqual(mockResponse);});@@ -792,10 +819,14 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.refresh(nanoid, { validateCredentials: true });- expect(extendedMockClient.connectedAccounts.refresh).toHaveBeenCalledWith(nanoid, {- query_redirect_url: undefined,- validate_credentials: true,- });+ expect(extendedMockClient.connectedAccounts.refresh).toHaveBeenCalledWith(+ nanoid,+ {+ query_redirect_url: undefined,+ validate_credentials: true,+ },+ undefined+ );expect(result).toEqual(mockResponse);});@@ -811,10 +842,14 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.refresh(nanoid, options);- expect(extendedMockClient.connectedAccounts.refresh).toHaveBeenCalledWith(nanoid, {- query_redirect_url: options.redirectUrl,- validate_credentials: options.validateCredentials,- });+ expect(extendedMockClient.connectedAccounts.refresh).toHaveBeenCalledWith(+ nanoid,+ {+ query_redirect_url: options.redirectUrl,+ validate_credentials: options.validateCredentials,+ },+ undefined+ );expect(result).toEqual(mockResponse);});@@ -837,10 +872,14 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.refresh(nanoid, {});- expect(extendedMockClient.connectedAccounts.refresh).toHaveBeenCalledWith(nanoid, {- query_redirect_url: undefined,- validate_credentials: undefined,- });+ expect(extendedMockClient.connectedAccounts.refresh).toHaveBeenCalledWith(+ nanoid,+ {+ query_redirect_url: undefined,+ validate_credentials: undefined,+ },+ undefined+ );expect(result).toEqual(mockResponse);});});@@ -857,7 +896,8 @@ describe('ConnectedAccounts', () => {expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(nanoid,- params+ params,+ undefined);expect(result).toEqual(mockResponse);});@@ -872,9 +912,13 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.enable(nanoid);- expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(nanoid, {- enabled: true,- });+ expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(+ nanoid,+ {+ enabled: true,+ },+ undefined+ );expect(result).toEqual(mockResponse);});});@@ -888,9 +932,13 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.disable(nanoid);- expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(nanoid, {- enabled: false,- });+ expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(+ nanoid,+ {+ enabled: false,+ },+ undefined+ );expect(result).toEqual(mockResponse);});});@@ -1089,9 +1137,13 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.update(nanoid, { enabled: true });- expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(nanoid, {- enabled: true,- });+ expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(+ nanoid,+ {+ enabled: true,+ },+ undefined+ );expect(result).toEqual({ success: true, id: nanoid, status: 'ACTIVE' });});@@ -1103,9 +1155,13 @@ describe('ConnectedAccounts', () => {const result = await connectedAccounts.update(nanoid, { enabled: false });- expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(nanoid, {- enabled: false,- });+ expect(extendedMockClient.connectedAccounts.updateStatus).toHaveBeenCalledWith(+ nanoid,+ {+ enabled: false,+ },+ undefined+ );expect(result).toEqual({ success: true });});@@ -1142,10 +1198,13 @@ describe('ConnectedAccounts', () => {const connectionRequest = await connectedAccounts.link(userId, authConfigId);- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: authConfigId,- user_id: userId,- });+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: authConfigId,+ user_id: userId,+ },+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_456def');expect(connectionRequest).toHaveProperty('status', ConnectedAccountStatuses.INITIATED);@@ -1175,11 +1234,14 @@ describe('ConnectedAccounts', () => {const connectionRequest = await connectedAccounts.link(userId, authConfigId, options);- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: authConfigId,- user_id: userId,- callback_url: options.callbackUrl,- });+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: authConfigId,+ user_id: userId,+ callback_url: options.callbackUrl,+ },+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_456def');expect(connectionRequest).toHaveProperty('status', ConnectedAccountStatuses.INITIATED);@@ -1219,10 +1281,13 @@ describe('ConnectedAccounts', () => {const connectionRequest = await connectedAccounts.link(userId, authConfigId, undefined);- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: authConfigId,- user_id: userId,- });+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: authConfigId,+ user_id: userId,+ },+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_456def');expect(connectionRequest).toHaveProperty('status', ConnectedAccountStatuses.INITIATED);@@ -1248,10 +1313,13 @@ describe('ConnectedAccounts', () => {const connectionRequest = await connectedAccounts.link(userId, authConfigId, options);- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: authConfigId,- user_id: userId,- });+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: authConfigId,+ user_id: userId,+ },+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_456def');expect(connectionRequest).toHaveProperty('status', ConnectedAccountStatuses.INITIATED);@@ -1329,11 +1397,14 @@ describe('ConnectedAccounts', () => {const options = { callbackUrl };const connectionRequest = await connectedAccounts.link(userId, authConfigId, options);- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: authConfigId,- user_id: userId,- callback_url: callbackUrl,- });+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: authConfigId,+ user_id: userId,+ callback_url: callbackUrl,+ },+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_456def');expect(connectionRequest).toHaveProperty('status', ConnectedAccountStatuses.INITIATED);@@ -1407,10 +1478,13 @@ describe('ConnectedAccounts', () => {'Failed to create connected account link');- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: authConfigId,- user_id: userId,- });+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: authConfigId,+ user_id: userId,+ },+ undefined+ );});it('should not include callback_url in API call when callbackUrl is not provided', async () => {@@ -1428,10 +1502,13 @@ describe('ConnectedAccounts', () => {await connectedAccounts.link(userId, authConfigId, options);// Verify that callback_url is not included in the API call- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: authConfigId,- user_id: userId,- });+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: authConfigId,+ user_id: userId,+ },+ undefined+ );// Ensure callback_url key is not present at allconst callArgs = extendedMockClient.link.create.mock.calls[0][0];@@ -1454,11 +1531,14 @@ describe('ConnectedAccounts', () => {await connectedAccounts.link(userId, authConfigId, options);- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: authConfigId,- user_id: userId,- callback_url: 'https://example.com/callback',- });+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: authConfigId,+ user_id: userId,+ callback_url: 'https://example.com/callback',+ },+ undefined+ );});it('throws ComposioMultipleConnectedAccountsError when an active connection exists and allowMultiple is false', async () => {@@ -1513,11 +1593,14 @@ describe('ConnectedAccounts', () => {alias: 'work-gmail',});- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: authConfigId,- user_id: userId,- alias: 'work-gmail',- });+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: authConfigId,+ user_id: userId,+ alias: 'work-gmail',+ },+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_new');});});@@ -1546,17 +1629,20 @@ describe('ConnectedAccounts', () => {},});- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: 'auth_config_123',- user_id: 'user_123',- experimental: {- account_type: 'SHARED',- acl_config_for_shared: {- allow_all_users: true,- not_allowed_user_ids: ['user_bob'],+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: 'auth_config_123',+ user_id: 'user_123',+ experimental: {+ account_type: 'SHARED',+ acl_config_for_shared: {+ allow_all_users: true,+ not_allowed_user_ids: ['user_bob'],+ },},},- });+ undefined+ );});it('omits the inner acl block when aclConfigForShared is undefined', async () => {@@ -1584,14 +1670,17 @@ describe('ConnectedAccounts', () => {},});- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: 'auth_config_123',- user_id: 'user_123',- experimental: {- account_type: 'SHARED',- acl_config_for_shared: { allowed_user_ids: ['user_alice'] },+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: 'auth_config_123',+ user_id: 'user_123',+ experimental: {+ account_type: 'SHARED',+ acl_config_for_shared: { allowed_user_ids: ['user_alice'] },+ },},- });+ undefined+ );});it('preserves explicit empty arrays in the serialized body', async () => {@@ -1602,17 +1691,20 @@ describe('ConnectedAccounts', () => {},});- expect(extendedMockClient.link.create).toHaveBeenCalledWith({- auth_config_id: 'auth_config_123',- user_id: 'user_123',- experimental: {- account_type: 'SHARED',- acl_config_for_shared: {- allowed_user_ids: [],- not_allowed_user_ids: [],+ expect(extendedMockClient.link.create).toHaveBeenCalledWith(+ {+ auth_config_id: 'auth_config_123',+ user_id: 'user_123',+ experimental: {+ account_type: 'SHARED',+ acl_config_for_shared: {+ allowed_user_ids: [],+ not_allowed_user_ids: [],+ },},},- });+ undefined+ );});it('maps 400 AclOnlyForShared to ComposioAclOnlyForSharedError', async () => {diff --git a/ts/packages/core/test/models/customTool.test.ts b/ts/packages/core/test/models/customTool.test.tsindex 2b3028781..0ba670bfa 100644--- a/ts/packages/core/test/models/customTool.test.ts+++ b/ts/packages/core/test/models/customTool.test.ts@@ -640,10 +640,14 @@ describe('SessionContextImpl', () => {const ctx = new SessionContextImpl(mockClient as any, 'user_1', 'sess_1');const result = await ctx.execute('GMAIL_SEND_EMAIL', { to: '[email protected]' });- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith('sess_1', {- tool_slug: 'GMAIL_SEND_EMAIL',- arguments: { to: '[email protected]' },- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ 'sess_1',+ {+ tool_slug: 'GMAIL_SEND_EMAIL',+ arguments: { to: '[email protected]' },+ },+ undefined+ );expect(result).toEqual({data: { result: 'ok' },error: null,@@ -670,13 +674,17 @@ describe('SessionContextImpl', () => {});await ctx.execute('GMAIL_SEND_EMAIL', { to: '[email protected]' });- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith('sess_1', {- tool_slug: 'GMAIL_SEND_EMAIL',- arguments: { to: '[email protected]' },- experimental: {- custom_tools: [expect.objectContaining({ slug: 'GREP' })],+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ 'sess_1',+ {+ tool_slug: 'GMAIL_SEND_EMAIL',+ arguments: { to: '[email protected]' },+ experimental: {+ custom_tools: [expect.objectContaining({ slug: 'GREP' })],+ },},- });+ undefined+ );});it('should preserve logId and error when execute() returns an error', async () => {@@ -707,12 +715,16 @@ describe('SessionContextImpl', () => {parameters: [{ in: 'header' as const, name: 'X-Custom', value: 'val' }],});- expect(mockClient.toolRouter.session.proxyExecute).toHaveBeenCalledWith('sess_1', {- toolkit_slug: 'github',- endpoint: 'https://api.github.com/user',- method: 'GET',- parameters: [{ name: 'X-Custom', type: 'header', value: 'val' }],- });+ expect(mockClient.toolRouter.session.proxyExecute).toHaveBeenCalledWith(+ 'sess_1',+ {+ toolkit_slug: 'github',+ endpoint: 'https://api.github.com/user',+ method: 'GET',+ parameters: [{ name: 'X-Custom', type: 'header', value: 'val' }],+ },+ undefined+ );expect(result).toEqual({status: 200,data: { proxy_result: true },@@ -765,10 +777,14 @@ describe('SessionContextImpl', () => {const ctx = new SessionContextImpl(mockClient as any, 'user_1', 'sess_1', customToolsMap);const result = await ctx.execute('REMOTE_TOOL', { key: 'val' });- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith('sess_1', {- tool_slug: 'REMOTE_TOOL',- arguments: { key: 'val' },- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ 'sess_1',+ {+ tool_slug: 'REMOTE_TOOL',+ arguments: { key: 'val' },+ },+ undefined+ );expect(result).toEqual({ data: { remote: true }, error: null, logId: 'log_3' });});diff --git a/ts/packages/core/test/models/customToolRouting.test.ts b/ts/packages/core/test/models/customToolRouting.test.tsindex 6b8fe90fa..d4a66e42d 100644--- a/ts/packages/core/test/models/customToolRouting.test.ts+++ b/ts/packages/core/test/models/customToolRouting.test.ts@@ -308,10 +308,14 @@ describe('ToolRouterSession execution routing', () => {await session.execute('GMAIL_SEND_EMAIL', { to: '[email protected]' });- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith('sess_123', {- tool_slug: 'GMAIL_SEND_EMAIL',- arguments: { to: '[email protected]' },- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ 'sess_123',+ {+ tool_slug: 'GMAIL_SEND_EMAIL',+ arguments: { to: '[email protected]' },+ },+ undefined+ );expect(localExecute).not.toHaveBeenCalled();});@@ -336,12 +340,16 @@ describe('ToolRouterSession execution routing', () => {parameters: [{ in: 'header', name: 'X-Test', value: '1' }],});- expect(mockClient.toolRouter.session.proxyExecute).toHaveBeenCalledWith('sess_123', {- toolkit_slug: 'github',- endpoint: 'https://api.github.com/user',- method: 'GET',- parameters: [{ name: 'X-Test', type: 'header', value: '1' }],- });+ expect(mockClient.toolRouter.session.proxyExecute).toHaveBeenCalledWith(+ 'sess_123',+ {+ toolkit_slug: 'github',+ endpoint: 'https://api.github.com/user',+ method: 'GET',+ parameters: [{ name: 'X-Test', type: 'header', value: '1' }],+ },+ undefined+ );expect(result).toEqual({status: 200,data: { ok: true },@@ -380,10 +388,14 @@ describe('ToolRouterSession execution routing', () => {const session = createSession(mockClient, [chainedTool]);await session.execute('CHAINED_TOOL', { to: '[email protected]' });- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith('sess_123', {- tool_slug: 'GMAIL_SEND_EMAIL',- arguments: { to: '[email protected]' },- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ 'sess_123',+ {+ tool_slug: 'GMAIL_SEND_EMAIL',+ arguments: { to: '[email protected]' },+ },+ undefined+ );});it('should route sibling local tools in-process without hitting the API', async () => {diff --git a/ts/packages/core/test/models/mcp.test.ts b/ts/packages/core/test/models/mcp.test.tsindex 7b133e68a..eae5cc435 100644--- a/ts/packages/core/test/models/mcp.test.ts+++ b/ts/packages/core/test/models/mcp.test.ts@@ -75,13 +75,16 @@ describe('MCP', () => {expect(result).toHaveProperty('name', 'test-server');expect(result).toHaveProperty('generate');expect(typeof result.generate).toBe('function');- expect(mockClient.mcp.custom.create).toHaveBeenCalledWith({- name: 'test-server',- toolkits: ['gmail'],- auth_config_ids: [],- custom_tools: [],- managed_auth_via_composio: true,- });+ expect(mockClient.mcp.custom.create).toHaveBeenCalledWith(+ {+ name: 'test-server',+ toolkits: ['gmail'],+ auth_config_ids: [],+ custom_tools: [],+ managed_auth_via_composio: true,+ },+ undefined+ );});it('should handle toolkits with auth config IDs', async () => {@@ -104,13 +107,16 @@ describe('MCP', () => {toolkits: [{ toolkit: 'gmail', authConfigId: 'auth_456' }],});- expect(mockClient.mcp.custom.create).toHaveBeenCalledWith({- name: 'test-server',- toolkits: ['gmail'],- auth_config_ids: [],- custom_tools: [],- managed_auth_via_composio: true,- });+ expect(mockClient.mcp.custom.create).toHaveBeenCalledWith(+ {+ name: 'test-server',+ toolkits: ['gmail'],+ auth_config_ids: [],+ custom_tools: [],+ managed_auth_via_composio: true,+ },+ undefined+ );});it('should validate configuration', async () => {@@ -150,13 +156,16 @@ describe('MCP', () => {expect(result).toHaveProperty('currentPage', 1);expect(result).toHaveProperty('totalPages', 1);expect(result.items).toHaveLength(1);- expect(mockClient.mcp.list).toHaveBeenCalledWith({- page_no: 1,- limit: 10,- toolkits: undefined,- auth_config_ids: undefined,- name: undefined,- });+ expect(mockClient.mcp.list).toHaveBeenCalledWith(+ {+ page_no: 1,+ limit: 10,+ toolkits: undefined,+ auth_config_ids: undefined,+ name: undefined,+ },+ undefined+ );});it('should list MCP servers with filters', async () => {@@ -176,13 +185,16 @@ describe('MCP', () => {name: 'test',});- expect(mockClient.mcp.list).toHaveBeenCalledWith({- page_no: 2,- limit: 20,- toolkits: 'gmail,slack',- auth_config_ids: 'auth_1',- name: 'test',- });+ expect(mockClient.mcp.list).toHaveBeenCalledWith(+ {+ page_no: 2,+ limit: 20,+ toolkits: 'gmail,slack',+ auth_config_ids: 'auth_1',+ name: 'test',+ },+ undefined+ );});it('should handle validation errors', async () => {@@ -215,7 +227,7 @@ describe('MCP', () => {expect(result).toHaveProperty('id', 'mcp_123');expect(result).toHaveProperty('name', 'test-server');expect(result).toHaveProperty('serverInstanceCount', 5);- expect(mockClient.mcp.retrieve).toHaveBeenCalledWith('mcp_123');+ expect(mockClient.mcp.retrieve).toHaveBeenCalledWith('mcp_123', undefined);});});@@ -231,7 +243,7 @@ describe('MCP', () => {const result = await mcp.delete('mcp_123');expect(result).toEqual(mockResponse);- expect(mockClient.mcp.delete).toHaveBeenCalledWith('mcp_123');+ expect(mockClient.mcp.delete).toHaveBeenCalledWith('mcp_123', undefined);});});@@ -262,12 +274,16 @@ describe('MCP', () => {expect(result).toHaveProperty('id', 'mcp_123');expect(result).toHaveProperty('name', 'updated-server');- expect(mockClient.mcp.update).toHaveBeenCalledWith('mcp_123', {- name: 'updated-server',- custom_tools: undefined,- toolkits: ['slack'],- auth_config_ids: [],- });+ expect(mockClient.mcp.update).toHaveBeenCalledWith(+ 'mcp_123',+ {+ name: 'updated-server',+ custom_tools: undefined,+ toolkits: ['slack'],+ auth_config_ids: [],+ },+ undefined+ );});it('should validate update parameters', async () => {@@ -301,11 +317,14 @@ describe('MCP', () => {expect(result).toHaveProperty('userId', 'user123');expect(result).toHaveProperty('type', 'streamable_http');expect(result).toHaveProperty('url', 'https://mcp.example.com/instance/user123');- expect(mockClient.mcp.generate.url).toHaveBeenCalledWith({- mcp_server_id: 'mcp_123',- user_ids: ['user123'],- managed_auth_by_composio: true,- });+ expect(mockClient.mcp.generate.url).toHaveBeenCalledWith(+ {+ mcp_server_id: 'mcp_123',+ user_ids: ['user123'],+ managed_auth_by_composio: true,+ },+ undefined+ );});it('should handle manual connection management', async () => {@@ -329,11 +348,14 @@ describe('MCP', () => {manuallyManageConnections: true,});- expect(mockClient.mcp.generate.url).toHaveBeenCalledWith({- mcp_server_id: 'mcp_123',- user_ids: ['user123'],- managed_auth_by_composio: false,- });+ expect(mockClient.mcp.generate.url).toHaveBeenCalledWith(+ {+ mcp_server_id: 'mcp_123',+ user_ids: ['user123'],+ managed_auth_by_composio: false,+ },+ undefined+ );});it('should validate parameters', async () => {diff --git a/ts/packages/core/test/models/toolRouter.test.ts b/ts/packages/core/test/models/toolRouter.test.tsindex 96883cadf..b5497f242 100644--- a/ts/packages/core/test/models/toolRouter.test.ts+++ b/ts/packages/core/test/models/toolRouter.test.ts@@ -199,16 +199,19 @@ describe('ToolRouter', () => {const session = await toolRouter.create(userId);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ },+ undefined+ );expect(session).toHaveProperty('sessionId', 'session_123');expect(session).toHaveProperty('mcp');@@ -229,16 +232,19 @@ describe('ToolRouter', () => {const session = await toolRouter.create(userId, {});- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ },+ undefined+ );expect(session.sessionId).toBe('session_123');expect(session.preload.tools).toEqual([]);@@ -259,19 +265,22 @@ describe('ToolRouter', () => {preload: { tools: ['GMAIL_FETCH_EMAILS'] },});- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: {- enable: ['gmail'],- },- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- preload: { tools: ['GMAIL_FETCH_EMAILS'] },- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: {+ enable: ['gmail'],+ },+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ preload: { tools: ['GMAIL_FETCH_EMAILS'] },+ },+ undefined+ );expect(session.preload.tools).toEqual(['GMAIL_FETCH_EMAILS']);expect(session.configVersion).toBe(2);@@ -291,19 +300,22 @@ describe('ToolRouter', () => {preload: { tools: 'all' },});- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: {- enable: ['github'],- },- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- preload: { tools: 'all' },- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: {+ enable: ['github'],+ },+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ preload: { tools: 'all' },+ },+ undefined+ );expect(session.preload.tools).toBe('all');});@@ -338,23 +350,26 @@ describe('ToolRouter', () => {toolkits: ['github'],});- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: {- enable: ['github'],- },- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: { enable: false },- workbench: { enable: false },- multi_account: undefined,- preload: { tools: 'all' },- search: { enable: false },- execute: { enable_multi_execute: false },- experimental: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: {+ enable: ['github'],+ },+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: { enable: false },+ workbench: { enable: false },+ multi_account: undefined,+ preload: { tools: 'all' },+ search: { enable: false },+ execute: { enable_multi_execute: false },+ experimental: undefined,+ },+ undefined+ );expect(session.preload.tools).toBe('all');});@@ -374,23 +389,26 @@ describe('ToolRouter', () => {preload: { tools: ['GITHUB_CREATE_ISSUE'] },});- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: {- enable: ['github'],+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: {+ enable: ['github'],+ },+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: { enable: true },+ workbench: { enable: true },+ multi_account: undefined,+ preload: { tools: ['GITHUB_CREATE_ISSUE'] },+ search: { enable: false },+ execute: { enable_multi_execute: false },+ experimental: undefined,},- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: { enable: true },- workbench: { enable: true },- multi_account: undefined,- preload: { tools: ['GITHUB_CREATE_ISSUE'] },- search: { enable: false },- execute: { enable_multi_execute: false },- experimental: undefined,- });+ undefined+ );expect(session.preload.tools).toEqual(['GITHUB_CREATE_ISSUE']);});@@ -450,18 +468,21 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: {- enable: ['gmail', 'slack', 'github'],- },- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: {+ enable: ['gmail', 'slack', 'github'],+ },+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ },+ undefined+ );});it('should create a session with enable toolkits configuration', async () => {@@ -475,18 +496,21 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: {- enable: ['gmail', 'slack'],- },- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: {+ enable: ['gmail', 'slack'],+ },+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ },+ undefined+ );});it('should create a session with disable toolkits configuration', async () => {@@ -500,18 +524,21 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: {- disable: ['notion', 'trello'],- },- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: {+ disable: ['notion', 'trello'],+ },+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ },+ undefined+ );});});@@ -525,18 +552,21 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: {- enable: ['readOnlyHint', 'idempotentHint'],+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: {+ enable: ['readOnlyHint', 'idempotentHint'],+ },+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,},- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ undefined+ );});it('should create a session with tags object with enable property', async () => {@@ -550,18 +580,21 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: {- enable: ['readOnlyHint', 'idempotentHint'],+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: {+ enable: ['readOnlyHint', 'idempotentHint'],+ },+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,},- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ undefined+ );});it('should create a session with tags object with disable property', async () => {@@ -575,19 +608,22 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: {- enable: undefined,- disable: ['destructiveHint'],+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: {+ enable: undefined,+ disable: ['destructiveHint'],+ },+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,},- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ undefined+ );});it('should create a session with tags object with both enable and disable properties', async () => {@@ -602,19 +638,22 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: {- enable: ['readOnlyHint', 'idempotentHint'],- disable: ['destructiveHint'],+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: {+ enable: ['readOnlyHint', 'idempotentHint'],+ disable: ['destructiveHint'],+ },+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,},- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ undefined+ );});it('should create a session with single tag in array', async () => {@@ -626,18 +665,21 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: {- enable: ['readOnlyHint'],+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: {+ enable: ['readOnlyHint'],+ },+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,},- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ undefined+ );});it('should create a session with all tag types', async () => {@@ -649,18 +691,21 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: {- enable: ['readOnlyHint', 'destructiveHint', 'idempotentHint', 'openWorldHint'],+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: {+ enable: ['readOnlyHint', 'destructiveHint', 'idempotentHint', 'openWorldHint'],+ },+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,},- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ undefined+ );});it('should create a session with tags combined with toolkits', async () => {@@ -673,20 +718,23 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: {- enable: ['gmail', 'slack'],- },- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: {- enable: ['readOnlyHint'],+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: {+ enable: ['gmail', 'slack'],+ },+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: {+ enable: ['readOnlyHint'],+ },+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,},- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ undefined+ );});});@@ -904,16 +952,19 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections({ enable: true }),- workbench: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections({ enable: true }),+ workbench: undefined,+ },+ undefined+ );});it('should create a session with manageConnections as boolean (false)', async () => {@@ -925,16 +976,19 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections({ enable: false }),- workbench: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections({ enable: false }),+ workbench: undefined,+ },+ undefined+ );});it('should create a session with manageConnections as object with enable', async () => {@@ -948,16 +1002,19 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections({ enable: true }),- workbench: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections({ enable: true }),+ workbench: undefined,+ },+ undefined+ );});it('should create a session with manageConnections object with callbackUrl', async () => {@@ -972,19 +1029,22 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections({- enable: true,- callbackUrl: 'https://myapp.com/callback',- }),- workbench: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections({+ enable: true,+ callbackUrl: 'https://myapp.com/callback',+ }),+ workbench: undefined,+ },+ undefined+ );});it('should create a session with full manageConnections configuration', async () => {@@ -999,19 +1059,22 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections({- enable: true,- callbackUrl: 'https://myapp.com/callback',- }),- workbench: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections({+ enable: true,+ callbackUrl: 'https://myapp.com/callback',+ }),+ workbench: undefined,+ },+ undefined+ );});});@@ -1028,19 +1091,22 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: {- gmail: 'auth_config_123',- slack: 'auth_config_456',+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: {+ gmail: 'auth_config_123',+ slack: 'auth_config_456',+ },+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,},- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ undefined+ );});it('should create a session with connectedAccounts (string coerced to array)', async () => {@@ -1055,19 +1121,22 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: {- gmail: ['conn_123'],- slack: ['conn_456'],+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: {+ gmail: ['conn_123'],+ slack: ['conn_456'],+ },+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,},- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ undefined+ );});it('should create a session with both authConfigs and connectedAccounts', async () => {@@ -1084,20 +1153,23 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: {- gmail: 'auth_config_123',- },- connected_accounts: {- slack: ['conn_456'],+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: {+ gmail: 'auth_config_123',+ },+ connected_accounts: {+ slack: ['conn_456'],+ },+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,},- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- });+ undefined+ );});});@@ -1113,20 +1185,23 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: {- enable: true,- enable_proxy_execution: true,- auto_offload_threshold: undefined,+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: {+ enable: true,+ enable_proxy_execution: true,+ auto_offload_threshold: undefined,+ },},- });+ undefined+ );});it('should create a session with autoOffloadThreshold only', async () => {@@ -1140,20 +1215,23 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: {- enable: true,- enable_proxy_execution: undefined,- auto_offload_threshold: 1000,+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: {+ enable: true,+ enable_proxy_execution: undefined,+ auto_offload_threshold: 1000,+ },},- });+ undefined+ );});it('should create a session with full workbench configuration', async () => {@@ -1168,20 +1246,23 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: {- enable: true,- enable_proxy_execution: true,- auto_offload_threshold: 500,+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: {+ enable: true,+ enable_proxy_execution: true,+ auto_offload_threshold: 500,+ },},- });+ undefined+ );});it('should create a session with workbench proxy and offload disabled', async () => {@@ -1196,20 +1277,23 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: {- enable: true,- enable_proxy_execution: false,- auto_offload_threshold: 0,+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: {+ enable: true,+ enable_proxy_execution: false,+ auto_offload_threshold: 0,+ },},- });+ undefined+ );});it('should create a session with workbench entirely disabled', async () => {@@ -1223,20 +1307,23 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: {- enable: false,- enable_proxy_execution: undefined,- auto_offload_threshold: undefined,+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: {+ enable: false,+ enable_proxy_execution: undefined,+ auto_offload_threshold: undefined,+ },},- });+ undefined+ );});it('should create a session with workbench explicitly enabled', async () => {@@ -1252,20 +1339,23 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: {- enable: true,- enable_proxy_execution: true,- auto_offload_threshold: 20000,+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: {+ enable: true,+ enable_proxy_execution: true,+ auto_offload_threshold: 20000,+ },},- });+ undefined+ );});it('forwards sandboxSize as snake_case sandbox_size on the wire', async () => {@@ -1457,7 +1547,8 @@ describe('ToolRouter', () => {max_accounts_per_toolkit: undefined,require_explicit_selection: true,},- })+ }),+ undefined);});@@ -1482,7 +1573,8 @@ describe('ToolRouter', () => {max_accounts_per_toolkit: 3,require_explicit_selection: true,},- })+ }),+ undefined);});@@ -1517,7 +1609,8 @@ describe('ToolRouter', () => {max_accounts_per_toolkit: 5,require_explicit_selection: true,},- })+ }),+ undefined);});});@@ -1536,21 +1629,24 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- experimental: {- assistive_prompt_config: {- user_timezone: 'America/New_York',+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ experimental: {+ assistive_prompt_config: {+ user_timezone: 'America/New_York',+ },},},- });+ undefined+ );});it('should not include experimental in payload when assistivePrompt is not provided', async () => {@@ -1562,17 +1658,20 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- experimental: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ experimental: undefined,+ },+ undefined+ );});it('should not include experimental in payload when userTimezone is not provided', async () => {@@ -1586,17 +1685,20 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: undefined,- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- experimental: undefined,- });+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: undefined,+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ experimental: undefined,+ },+ undefined+ );});it('should create a session with experimental config combined with other options', async () => {@@ -1613,23 +1715,26 @@ describe('ToolRouter', () => {await toolRouter.create(userId, config);- expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({- user_id: userId,- toolkits: {- enable: ['gmail', 'slack'],- },- auth_configs: undefined,- connected_accounts: undefined,- tools: undefined,- tags: undefined,- manage_connections: createExpectedManageConnections(),- workbench: undefined,- experimental: {- assistive_prompt_config: {- user_timezone: 'Europe/London',+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(+ {+ user_id: userId,+ toolkits: {+ enable: ['gmail', 'slack'],+ },+ auth_configs: undefined,+ connected_accounts: undefined,+ tools: undefined,+ tags: undefined,+ manage_connections: createExpectedManageConnections(),+ workbench: undefined,+ experimental: {+ assistive_prompt_config: {+ user_timezone: 'Europe/London',+ },},},- });+ undefined+ );});it('should transform experimental assistive_prompt from API response to SDK format', async () => {@@ -1698,7 +1803,8 @@ describe('ToolRouter', () => {expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith(expect.objectContaining({user_id: '',- })+ }),+ undefined);});});@@ -1770,9 +1876,13 @@ describe('ToolRouter', () => {const session = await toolRouter.create(userId);const connectionRequest = await session.authorize(toolkit);- expect(mockClient.toolRouter.session.link).toHaveBeenCalledWith(sessionId, {- toolkit,- });+ expect(mockClient.toolRouter.session.link).toHaveBeenCalledWith(+ sessionId,+ {+ toolkit,+ },+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_456');expect(connectionRequest).toHaveProperty('status', ConnectedAccountStatuses.INITIATED);@@ -1787,10 +1897,14 @@ describe('ToolRouter', () => {callbackUrl: 'https://myapp.com/callback',});- expect(mockClient.toolRouter.session.link).toHaveBeenCalledWith(sessionId, {- toolkit,- callback_url: 'https://myapp.com/callback',- });+ expect(mockClient.toolRouter.session.link).toHaveBeenCalledWith(+ sessionId,+ {+ toolkit,+ callback_url: 'https://myapp.com/callback',+ },+ undefined+ );expect(connectionRequest.id).toBe('conn_456');expect(connectionRequest.redirectUrl).toBe('https://composio.dev/auth/redirect');@@ -1826,9 +1940,13 @@ describe('ToolRouter', () => {'Authorization failed: Invalid toolkit');- expect(mockClient.toolRouter.session.link).toHaveBeenCalledWith(sessionId, {- toolkit,- });+ expect(mockClient.toolRouter.session.link).toHaveBeenCalledWith(+ sessionId,+ {+ toolkit,+ },+ undefined+ );});it('should handle network errors during authorization', async () => {@@ -1869,16 +1987,20 @@ describe('ToolRouter', () => {},});- expect(mockClient.toolRouter.session.link).toHaveBeenCalledWith(sessionId, {- toolkit,- experimental: {- account_type: 'SHARED',- acl_config_for_shared: {- allow_all_users: true,- not_allowed_user_ids: ['user_bob'],+ expect(mockClient.toolRouter.session.link).toHaveBeenCalledWith(+ sessionId,+ {+ toolkit,+ experimental: {+ account_type: 'SHARED',+ acl_config_for_shared: {+ allow_all_users: true,+ not_allowed_user_ids: ['user_bob'],+ },},},- });+ undefined+ );});it('omits the experimental block entirely when not provided', async () => {@@ -1953,12 +2075,16 @@ describe('ToolRouter', () => {const session = await toolRouter.create(userId);const result = await session.toolkits();- expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(sessionId, {- cursor: undefined,- limit: undefined,- toolkits: undefined,- is_connected: undefined,- });+ expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(+ sessionId,+ {+ cursor: undefined,+ limit: undefined,+ toolkits: undefined,+ is_connected: undefined,+ },+ undefined+ );expect(result).toHaveProperty('items');expect(result).toHaveProperty('cursor', 'cursor_789');@@ -1975,12 +2101,16 @@ describe('ToolRouter', () => {cursor: 'cursor_abc',});- expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(sessionId, {- cursor: 'cursor_abc',- limit: 10,- toolkits: undefined,- is_connected: undefined,- });+ expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(+ sessionId,+ {+ cursor: 'cursor_abc',+ limit: 10,+ toolkits: undefined,+ is_connected: undefined,+ },+ undefined+ );expect(result.items).toHaveLength(3);});@@ -1993,12 +2123,16 @@ describe('ToolRouter', () => {toolkits: ['gmail', 'slack'],});- expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(sessionId, {- cursor: undefined,- limit: undefined,- toolkits: ['gmail', 'slack'],- is_connected: undefined,- });+ expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(+ sessionId,+ {+ cursor: undefined,+ limit: undefined,+ toolkits: ['gmail', 'slack'],+ is_connected: undefined,+ },+ undefined+ );expect(result.items).toHaveLength(3);});@@ -2011,12 +2145,16 @@ describe('ToolRouter', () => {isConnected: true,});- expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(sessionId, {- cursor: undefined,- limit: undefined,- toolkits: undefined,- is_connected: true,- });+ expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(+ sessionId,+ {+ cursor: undefined,+ limit: undefined,+ toolkits: undefined,+ is_connected: true,+ },+ undefined+ );expect(result.items).toHaveLength(3);});@@ -2031,12 +2169,16 @@ describe('ToolRouter', () => {toolkits: ['github'],});- expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(sessionId, {- cursor: 'cursor_xyz',- limit: 5,- toolkits: ['github'],- is_connected: undefined,- });+ expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(+ sessionId,+ {+ cursor: 'cursor_xyz',+ limit: 5,+ toolkits: ['github'],+ is_connected: undefined,+ },+ undefined+ );expect(result.items).toHaveLength(3);});@@ -2052,12 +2194,16 @@ describe('ToolRouter', () => {isConnected: false,});- expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(sessionId, {- cursor: 'cursor_xyz',- limit: 5,- toolkits: ['github', 'gmail'],- is_connected: false,- });+ expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(+ sessionId,+ {+ cursor: 'cursor_xyz',+ limit: 5,+ toolkits: ['github', 'gmail'],+ is_connected: false,+ },+ undefined+ );expect(result.items).toHaveLength(3);});@@ -2289,9 +2435,13 @@ describe('ToolRouter', () => {const session = await toolRouter.create(userId);const result = await session.search({ query: 'send emails' });- expect(mockClient.toolRouter.session.search).toHaveBeenCalledWith(sessionId, {- queries: [{ use_case: 'send emails' }],- });+ expect(mockClient.toolRouter.session.search).toHaveBeenCalledWith(+ sessionId,+ {+ queries: [{ use_case: 'send emails' }],+ },+ undefined+ );expect(result.success).toBe(true);expect(result.results[0].useCase).toBe('send emails');expect(result.results[0].primaryToolSlugs).toEqual(['GMAIL_SEND_EMAIL']);@@ -2308,10 +2458,14 @@ describe('ToolRouter', () => {const session = await toolRouter.create(userId);await session.search({ query: 'send emails', toolkits: ['gmail', 'slack'] });- expect(mockClient.toolRouter.session.search).toHaveBeenCalledWith(sessionId, {- queries: [{ use_case: 'send emails' }],- toolkits: ['gmail', 'slack'],- });+ expect(mockClient.toolRouter.session.search).toHaveBeenCalledWith(+ sessionId,+ {+ queries: [{ use_case: 'send emails' }],+ toolkits: ['gmail', 'slack'],+ },+ undefined+ );});it('should pass inline custom tools to search', async () => {@@ -2341,17 +2495,21 @@ describe('ToolRouter', () => {});await session.search({ query: 'search local text' });- expect(mockClient.toolRouter.session.search).toHaveBeenCalledWith(sessionId, {- queries: [{ use_case: 'search local text' }],- experimental: {- custom_tools: [- expect.objectContaining({- slug: 'GREP',- preload: true,- }),- ],+ expect(mockClient.toolRouter.session.search).toHaveBeenCalledWith(+ sessionId,+ {+ queries: [{ use_case: 'search local text' }],+ experimental: {+ custom_tools: [+ expect.objectContaining({+ slug: 'GREP',+ preload: true,+ }),+ ],+ },},- });+ undefined+ );});it('should propagate search API errors', async () => {@@ -2385,10 +2543,14 @@ describe('ToolRouter', () => {body: 'Hello',});- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(sessionId, {- tool_slug: 'GMAIL_SEND_EMAIL',- arguments: { to: '[email protected]', subject: 'Hi', body: 'Hello' },- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ sessionId,+ {+ tool_slug: 'GMAIL_SEND_EMAIL',+ arguments: { to: '[email protected]', subject: 'Hi', body: 'Hello' },+ },+ undefined+ );expect(result.data).toEqual({ tool_slug: 'GMAIL_SEND_EMAIL', id: 'msg_123' });expect(result.error).toBeNull();expect(result.logId).toBe('log_abc');@@ -2410,10 +2572,14 @@ describe('ToolRouter', () => {const session = await toolRouter.create(userId);await session.execute('HACKERNEWS_GET_USER');- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(sessionId, {- tool_slug: 'HACKERNEWS_GET_USER',- arguments: {},- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ sessionId,+ {+ tool_slug: 'HACKERNEWS_GET_USER',+ arguments: {},+ },+ undefined+ );});it('should pass account option to session execute', async () => {@@ -2423,11 +2589,15 @@ describe('ToolRouter', () => {const session = await toolRouter.create(userId);await session.execute('GMAIL_SEND_EMAIL', { to: '[email protected]' }, { account: 'work' });- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(sessionId, {- tool_slug: 'GMAIL_SEND_EMAIL',- arguments: { to: '[email protected]' },- account: 'work',- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ sessionId,+ {+ tool_slug: 'GMAIL_SEND_EMAIL',+ arguments: { to: '[email protected]' },+ account: 'work',+ },+ undefined+ );});it('should pass inline custom tools to remote execute when custom tools are bound', async () => {@@ -2456,13 +2626,17 @@ describe('ToolRouter', () => {});await session.execute('GMAIL_SEND_EMAIL', { to: '[email protected]' });- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(sessionId, {- tool_slug: 'GMAIL_SEND_EMAIL',- arguments: { to: '[email protected]' },- experimental: {- custom_tools: [expect.objectContaining({ slug: 'GREP' })],+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ sessionId,+ {+ tool_slug: 'GMAIL_SEND_EMAIL',+ arguments: { to: '[email protected]' },+ experimental: {+ custom_tools: [expect.objectContaining({ slug: 'GREP' })],+ },},- });+ undefined+ );});});@@ -2496,7 +2670,11 @@ describe('ToolRouter', () => {});const toolsInstance = (Tools as any).mock.results[0].value;- expect(toolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith(sessionId, undefined);+ expect(toolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith(+ sessionId,+ undefined,+ undefined+ );expect(toolsInstance.wrapToolsForToolRouter).toHaveBeenCalledWith(sessionId,[{ slug: 'COMPOSIO_SEARCH_TOOLS' }],@@ -2521,9 +2699,11 @@ describe('ToolRouter', () => {const tools = await session.tools(modifiers);const toolsInstance = (Tools as any).mock.results[0].value;- expect(toolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith(sessionId, {- modifySchema: modifiers.modifySchema,- });+ expect(toolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith(+ sessionId,+ { modifySchema: modifiers.modifySchema },+ undefined+ );expect(toolsInstance.wrapToolsForToolRouter).toHaveBeenCalledWith(sessionId,[{ slug: 'COMPOSIO_SEARCH_TOOLS' }],@@ -2853,9 +3033,11 @@ describe('ToolRouter', () => {expect(Tools).toHaveBeenCalledTimes(2);const firstToolsInstance = (Tools as any).mock.results[0].value;- expect(firstToolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith(sessionId, {- modifySchema: modifier1.modifySchema,- });+ expect(firstToolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith(+ sessionId,+ { modifySchema: modifier1.modifySchema },+ undefined+ );expect(firstToolsInstance.wrapToolsForToolRouter).toHaveBeenCalledWith(sessionId,[{ slug: 'COMPOSIO_SEARCH_TOOLS' }],@@ -2863,9 +3045,11 @@ describe('ToolRouter', () => {);const secondToolsInstance = (Tools as any).mock.results[1].value;- expect(secondToolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith(sessionId, {- modifySchema: modifier2.modifySchema,- });+ expect(secondToolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith(+ sessionId,+ { modifySchema: modifier2.modifySchema },+ undefined+ );expect(secondToolsInstance.wrapToolsForToolRouter).toHaveBeenCalledWith(sessionId,[{ slug: 'COMPOSIO_SEARCH_TOOLS' }],@@ -2892,6 +3076,7 @@ describe('ToolRouter', () => {const toolsInstance = (Tools as any).mock.results[0].value;expect(toolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith('custom_session_123',+ undefined,undefined);expect(toolsInstance.wrapToolsForToolRouter).toHaveBeenCalledWith(@@ -2920,6 +3105,7 @@ describe('ToolRouter', () => {const toolsInstance = (Tools as any).mock.results[0].value;expect(toolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith('empty_session_123',+ undefined,undefined);expect(toolsInstance.wrapToolsForToolRouter).toHaveBeenCalledWith(@@ -2991,18 +3177,26 @@ describe('ToolRouter', () => {await session1.toolkits();await session2.toolkits();- expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith('session_1', {- cursor: undefined,- limit: undefined,- toolkits: undefined,- is_connected: undefined,- });- expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith('session_2', {- cursor: undefined,- limit: undefined,- toolkits: undefined,- is_connected: undefined,- });+ expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(+ 'session_1',+ {+ cursor: undefined,+ limit: undefined,+ toolkits: undefined,+ is_connected: undefined,+ },+ undefined+ );+ expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(+ 'session_2',+ {+ cursor: undefined,+ limit: undefined,+ toolkits: undefined,+ is_connected: undefined,+ },+ undefined+ );});it('should handle rapid successive calls', async () => {@@ -3033,7 +3227,7 @@ describe('ToolRouter', () => {const session = await toolRouter.use(sessionId);- expect(mockClient.toolRouter.session.retrieve).toHaveBeenCalledWith(sessionId);+ expect(mockClient.toolRouter.session.retrieve).toHaveBeenCalledWith(sessionId, undefined);expect(mockClient.toolRouter.session.attach).not.toHaveBeenCalled();expect(mockClient.post).not.toHaveBeenCalled();expect(session).toHaveProperty('sessionId', 'session_123');@@ -3075,11 +3269,15 @@ describe('ToolRouter', () => {const session = await toolRouter.use(sessionId, { customTools: [grepTool] });- expect(mockClient.toolRouter.session.attach).toHaveBeenCalledWith(sessionId, {- experimental: {- custom_tools: [expect.objectContaining({ slug: 'GREP' })],+ expect(mockClient.toolRouter.session.attach).toHaveBeenCalledWith(+ sessionId,+ {+ experimental: {+ custom_tools: [expect.objectContaining({ slug: 'GREP' })],+ },},- });+ undefined+ );expect(mockClient.toolRouter.session.attach.mock.calls[0][1].experimental).not.toHaveProperty('custom_toolkits');@@ -3122,7 +3320,11 @@ describe('ToolRouter', () => {expect(Tools).toHaveBeenCalled();const toolsInstance = (Tools as any).mock.results[0].value;- expect(toolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith(sessionId, undefined);+ expect(toolsInstance.getRawToolRouterSessionTools).toHaveBeenCalledWith(+ sessionId,+ undefined,+ undefined+ );expect(toolsInstance.wrapToolsForToolRouter).toHaveBeenCalledWith(sessionId,[{ slug: 'COMPOSIO_SEARCH_TOOLS' }],@@ -3138,9 +3340,13 @@ describe('ToolRouter', () => {const connectionRequest = await session.authorize('github');- expect(mockClient.toolRouter.session.link).toHaveBeenCalledWith(sessionId, {- toolkit: 'github',- });+ expect(mockClient.toolRouter.session.link).toHaveBeenCalledWith(+ sessionId,+ {+ toolkit: 'github',+ },+ undefined+ );expect(connectionRequest).toHaveProperty('redirectUrl', 'https://composio.dev/auth/redirect');expect(connectionRequest).toHaveProperty('status', ConnectedAccountStatuses.INITIATED);});@@ -3153,12 +3359,16 @@ describe('ToolRouter', () => {const toolkitsResult = await session.toolkits();- expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(sessionId, {- cursor: undefined,- limit: undefined,- toolkits: undefined,- is_connected: undefined,- });+ expect(mockClient.toolRouter.session.toolkits).toHaveBeenCalledWith(+ sessionId,+ {+ cursor: undefined,+ limit: undefined,+ toolkits: undefined,+ is_connected: undefined,+ },+ undefined+ );expect(toolkitsResult.items).toHaveLength(3);expect(toolkitsResult.items[0].slug).toBe('gmail');});@@ -3189,11 +3399,15 @@ describe('ToolRouter', () => {const session = await toolRouter.use(sessionId, { customTools: [grepTool] });await session.tools();- expect(mockClient.toolRouter.session.attach).toHaveBeenCalledWith(sessionId, {- experimental: {- custom_tools: [expect.objectContaining({ slug: 'GREP', preload: true })],+ expect(mockClient.toolRouter.session.attach).toHaveBeenCalledWith(+ sessionId,+ {+ experimental: {+ custom_tools: [expect.objectContaining({ slug: 'GREP', preload: true })],+ },},- });+ undefined+ );expect(mockClient.post).not.toHaveBeenCalled();expect(mockClient.toolRouter.session.retrieve).not.toHaveBeenCalled();const wrappedTools = mockProvider.wrapTools.mock.calls[0][0] as Array<{ slug: string }>;@@ -3250,12 +3464,16 @@ describe('ToolRouter', () => {const wrappedTools = mockProvider.wrapTools.mock.calls[0][0] as Array<{ slug: string }>;expect(wrappedTools.map(tool => tool.slug)).toEqual(['COMPOSIO_SEARCH_TOOLS', 'LOCAL_GREP']);- expect(mockClient.toolRouter.session.search).toHaveBeenCalledWith(sessionId, {- queries: [{ use_case: 'search local text' }],- experimental: {- custom_tools: [expect.objectContaining({ slug: 'GREP', preload: true })],+ expect(mockClient.toolRouter.session.search).toHaveBeenCalledWith(+ sessionId,+ {+ queries: [{ use_case: 'search local text' }],+ experimental: {+ custom_tools: [expect.objectContaining({ slug: 'GREP', preload: true })],+ },},- });+ undefined+ );});it('should handle different session IDs', async () => {const session1Response = {@@ -3278,8 +3496,16 @@ describe('ToolRouter', () => {expect(session1.sessionId).toBe('session_1');expect(session2.sessionId).toBe('session_2');expect(mockClient.toolRouter.session.retrieve).toHaveBeenCalledTimes(2);- expect(mockClient.toolRouter.session.retrieve).toHaveBeenNthCalledWith(1, 'session_1');- expect(mockClient.toolRouter.session.retrieve).toHaveBeenNthCalledWith(2, 'session_2');+ expect(mockClient.toolRouter.session.retrieve).toHaveBeenNthCalledWith(+ 1,+ 'session_1',+ undefined+ );+ expect(mockClient.toolRouter.session.retrieve).toHaveBeenNthCalledWith(+ 2,+ 'session_2',+ undefined+ );expect(mockClient.post).not.toHaveBeenCalled();});@@ -3297,7 +3523,7 @@ describe('ToolRouter', () => {mockClient.toolRouter.session.retrieve.mockRejectedValueOnce(error);await expect(toolRouter.use(sessionId)).rejects.toThrow('Session not found');- expect(mockClient.toolRouter.session.retrieve).toHaveBeenCalledWith(sessionId);+ expect(mockClient.toolRouter.session.retrieve).toHaveBeenCalledWith(sessionId, undefined);expect(mockClient.post).not.toHaveBeenCalled();});diff --git a/ts/packages/core/test/models/toolkits.test.ts b/ts/packages/core/test/models/toolkits.test.tsindex 5abb6a1bd..2657d3f3c 100644--- a/ts/packages/core/test/models/toolkits.test.ts+++ b/ts/packages/core/test/models/toolkits.test.ts@@ -133,7 +133,7 @@ describe('Toolkits', () => {noAuth: false,},]);- expect(mockClient.toolkits.list).toHaveBeenCalledWith({});+ expect(mockClient.toolkits.list).toHaveBeenCalledWith({}, undefined);});it('should get a single toolkit by slug', async () => {@@ -174,7 +174,7 @@ describe('Toolkits', () => {getCurrentUserEndpoint: '/user',getCurrentUserEndpointMethod: 'GET',});- expect(mockClient.toolkits.retrieve).toHaveBeenCalledWith('github');+ expect(mockClient.toolkits.retrieve).toHaveBeenCalledWith('github', undefined, undefined);});it('should handle toolkit without getCurrentUserEndpointMethod', async () => {@@ -354,29 +354,38 @@ describe('Toolkits', () => {const connectionRequest = await toolkits.authorize(userId, toolkitSlug);// Verify the flow- expect(mockClient.toolkits.retrieve).toHaveBeenCalledWith(toolkitSlug);- expect(mockClient.authConfigs.list).toHaveBeenCalledWith({- toolkit_slug: toolkitSlug,- });- expect(mockClient.authConfigs.create).toHaveBeenCalledWith({- toolkit: {- slug: toolkitSlug,- },- auth_config: {- type: 'use_composio_managed_auth',- credentials: undefined,- name: 'Test Toolkit Auth Config',- tool_access_config: undefined,+ expect(mockClient.toolkits.retrieve).toHaveBeenCalledWith(toolkitSlug, undefined, undefined);+ expect(mockClient.authConfigs.list).toHaveBeenCalledWith(+ {+ toolkit_slug: toolkitSlug,},- });- expect(mockClient.connectedAccounts.create).toHaveBeenCalledWith({- auth_config: {- id: 'auth_config_123',+ undefined+ );+ expect(mockClient.authConfigs.create).toHaveBeenCalledWith(+ {+ toolkit: {+ slug: toolkitSlug,+ },+ auth_config: {+ type: 'use_composio_managed_auth',+ credentials: undefined,+ name: 'Test Toolkit Auth Config',+ tool_access_config: undefined,+ },},- connection: {- user_id: userId,+ undefined+ );+ expect(mockClient.connectedAccounts.create).toHaveBeenCalledWith(+ {+ auth_config: {+ id: 'auth_config_123',+ },+ connection: {+ user_id: userId,+ },},- });+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_123');expect(connectionRequest).toHaveProperty('waitForConnection');expect(typeof connectionRequest.waitForConnection).toBe('function');@@ -431,19 +440,25 @@ describe('Toolkits', () => {const connectionRequest = await toolkits.authorize(userId, toolkitSlug);// Verify the flow- expect(mockClient.toolkits.retrieve).toHaveBeenCalledWith(toolkitSlug);- expect(mockClient.authConfigs.list).toHaveBeenCalledWith({- toolkit_slug: toolkitSlug,- });- expect(mockClient.authConfigs.create).not.toHaveBeenCalled();- expect(mockClient.connectedAccounts.create).toHaveBeenCalledWith({- auth_config: {- id: 'existing_auth_123',+ expect(mockClient.toolkits.retrieve).toHaveBeenCalledWith(toolkitSlug, undefined, undefined);+ expect(mockClient.authConfigs.list).toHaveBeenCalledWith(+ {+ toolkit_slug: toolkitSlug,},- connection: {- user_id: userId,+ undefined+ );+ expect(mockClient.authConfigs.create).not.toHaveBeenCalled();+ expect(mockClient.connectedAccounts.create).toHaveBeenCalledWith(+ {+ auth_config: {+ id: 'existing_auth_123',+ },+ connection: {+ user_id: userId,+ },},- });+ undefined+ );expect(connectionRequest).toHaveProperty('id', 'conn_123');expect(connectionRequest).toHaveProperty('waitForConnection');expect(typeof connectionRequest.waitForConnection).toBe('function');diff --git a/ts/packages/core/test/models/triggers.test.ts b/ts/packages/core/test/models/triggers.test.tsindex 439749a54..2b03d3106 100644--- a/ts/packages/core/test/models/triggers.test.ts+++ b/ts/packages/core/test/models/triggers.test.ts@@ -246,7 +246,7 @@ describe('Triggers', () => {const result = await triggers.listActive();- expect(mockClient.triggerInstances.listActive).toHaveBeenCalledWith(undefined);+ expect(mockClient.triggerInstances.listActive).toHaveBeenCalledWith(undefined, undefined);expect(result).toEqual({items: mockTriggerInstances.items.map(item => ({id: item.id,@@ -279,15 +279,18 @@ describe('Triggers', () => {await triggers.listActive(query);- expect(mockClient.triggerInstances.listActive).toHaveBeenCalledWith({- auth_config_ids: query.authConfigIds,- connected_account_ids: query.connectedAccountIds,- limit: query.limit,- cursor: query.cursor,- show_disabled: query.showDisabled,- trigger_ids: query.triggerIds,- trigger_names: query.triggerNames,- });+ expect(mockClient.triggerInstances.listActive).toHaveBeenCalledWith(+ {+ auth_config_ids: query.authConfigIds,+ connected_account_ids: query.connectedAccountIds,+ limit: query.limit,+ cursor: query.cursor,+ show_disabled: query.showDisabled,+ trigger_ids: query.triggerIds,+ trigger_names: query.triggerNames,+ },+ undefined+ );});});@@ -311,19 +314,30 @@ describe('Triggers', () => {const result = await triggers.create(userId, slug, body);- expect(mockClient.triggersTypes.retrieve).toHaveBeenCalledWith(slug, {- toolkit_versions: 'latest',- });- expect(mockClient.connectedAccounts.list).toHaveBeenCalledWith({- user_ids: [userId],- toolkit_slugs: [mockTriggerType.toolkit.slug],- });- expect(mockClient.triggerInstances.upsert).toHaveBeenCalledWith(slug, {- connected_account_id: body.connectedAccountId,- trigger_config: body.triggerConfig,- toolkit_versions: 'latest',- user_id: userId,- });+ expect(mockClient.triggersTypes.retrieve).toHaveBeenCalledWith(+ slug,+ {+ toolkit_versions: 'latest',+ },+ undefined+ );+ expect(mockClient.connectedAccounts.list).toHaveBeenCalledWith(+ {+ user_ids: [userId],+ toolkit_slugs: [mockTriggerType.toolkit.slug],+ },+ undefined+ );+ expect(mockClient.triggerInstances.upsert).toHaveBeenCalledWith(+ slug,+ {+ connected_account_id: body.connectedAccountId,+ trigger_config: body.triggerConfig,+ toolkit_versions: 'latest',+ user_id: userId,+ },+ undefined+ );expect(result).toEqual({ triggerId: mockTriggerUpsertResponse.trigger_id });});@@ -337,12 +351,16 @@ describe('Triggers', () => {const result = await triggers.create(userId, slug, bodyWithoutConnectedAccount);- expect(mockClient.triggerInstances.upsert).toHaveBeenCalledWith(slug, {- connected_account_id: 'conn-456',- trigger_config: bodyWithoutConnectedAccount.triggerConfig,- toolkit_versions: 'latest',- user_id: userId,- });+ expect(mockClient.triggerInstances.upsert).toHaveBeenCalledWith(+ slug,+ {+ connected_account_id: 'conn-456',+ trigger_config: bodyWithoutConnectedAccount.triggerConfig,+ toolkit_versions: 'latest',+ user_id: userId,+ },+ undefined+ );expect(logger.warn).toHaveBeenCalledWith(`[Warn] Multiple connected accounts found for user ${userId}, using the first one. Pass connectedAccountId to select a specific account.`);@@ -414,7 +432,11 @@ describe('Triggers', () => {const result = await triggers.update(triggerId, body);- expect(mockClient.triggerInstances.manage.update).toHaveBeenCalledWith(triggerId, body);+ expect(mockClient.triggerInstances.manage.update).toHaveBeenCalledWith(+ triggerId,+ body,+ undefined+ );expect(result).toEqual(mockTriggerUpdateResponse);});});@@ -426,7 +448,7 @@ describe('Triggers', () => {const result = await triggers.delete(triggerId);- expect(mockClient.triggerInstances.manage.delete).toHaveBeenCalledWith(triggerId);+ expect(mockClient.triggerInstances.manage.delete).toHaveBeenCalledWith(triggerId, undefined);expect(result).toEqual({ triggerId: mockTriggerDeleteResponse.trigger_id });});});@@ -438,9 +460,13 @@ describe('Triggers', () => {const result = await triggers.disable(triggerId);- expect(mockClient.triggerInstances.manage.update).toHaveBeenCalledWith(triggerId, {- status: 'disable',- });+ expect(mockClient.triggerInstances.manage.update).toHaveBeenCalledWith(+ triggerId,+ {+ status: 'disable',+ },+ undefined+ );expect(result).toEqual(mockTriggerUpdateResponse);});});@@ -452,9 +478,13 @@ describe('Triggers', () => {const result = await triggers.enable(triggerId);- expect(mockClient.triggerInstances.manage.update).toHaveBeenCalledWith(triggerId, {- status: 'enable',- });+ expect(mockClient.triggerInstances.manage.update).toHaveBeenCalledWith(+ triggerId,+ {+ status: 'enable',+ },+ undefined+ );expect(result).toEqual(mockTriggerUpdateResponse);});});@@ -465,12 +495,15 @@ describe('Triggers', () => {const result = await triggers.listTypes();- expect(mockClient.triggersTypes.list).toHaveBeenCalledWith({- cursor: undefined,- limit: undefined,- toolkit_slugs: undefined,- toolkit_versions: 'latest',- });+ expect(mockClient.triggersTypes.list).toHaveBeenCalledWith(+ {+ cursor: undefined,+ limit: undefined,+ toolkit_slugs: undefined,+ toolkit_versions: 'latest',+ },+ undefined+ );expect(result).toEqual({items: mockTriggerTypes.items.map(item => ({...item,@@ -487,12 +520,15 @@ describe('Triggers', () => {const result = await triggers.listTypes(query);- expect(mockClient.triggersTypes.list).toHaveBeenCalledWith({- cursor: undefined,- limit: query.limit,- toolkit_slugs: query.toolkits,- toolkit_versions: 'latest',- });+ expect(mockClient.triggersTypes.list).toHaveBeenCalledWith(+ {+ cursor: undefined,+ limit: query.limit,+ toolkit_slugs: query.toolkits,+ toolkit_versions: 'latest',+ },+ undefined+ );expect(result).toEqual({items: mockTriggerTypes.items,nextCursor: mockTriggerTypes.next_cursor,@@ -508,9 +544,13 @@ describe('Triggers', () => {const result = await triggers.getType(slug);- expect(mockClient.triggersTypes.retrieve).toHaveBeenCalledWith(slug, {- toolkit_versions: 'latest', // Uses global default- });+ expect(mockClient.triggersTypes.retrieve).toHaveBeenCalledWith(+ slug,+ {+ toolkit_versions: 'latest', // Uses global default+ },+ undefined+ );expect(result).toEqual(mockTriggerType);});@@ -525,9 +565,13 @@ describe('Triggers', () => {const result = await customTriggers.getType(slug);- expect(mockClient.triggersTypes.retrieve).toHaveBeenCalledWith(slug, {- toolkit_versions: customToolkitVersions, // Uses configured global versions- });+ expect(mockClient.triggersTypes.retrieve).toHaveBeenCalledWith(+ slug,+ {+ toolkit_versions: customToolkitVersions, // Uses configured global versions+ },+ undefined+ );expect(result).toEqual(mockTriggerType);});@@ -537,9 +581,13 @@ describe('Triggers', () => {const result = await triggers.getType(slug);- expect(mockClient.triggersTypes.retrieve).toHaveBeenCalledWith(slug, {- toolkit_versions: 'latest', // Default to latest- });+ expect(mockClient.triggersTypes.retrieve).toHaveBeenCalledWith(+ slug,+ {+ toolkit_versions: 'latest', // Default to latest+ },+ undefined+ );expect(result).toEqual(mockTriggerType);});});diff --git a/ts/packages/core/test/tools/fileModifiers.test.ts b/ts/packages/core/test/tools/fileModifiers.test.tsindex 600f03784..86cabc4fe 100644--- a/ts/packages/core/test/tools/fileModifiers.test.ts+++ b/ts/packages/core/test/tools/fileModifiers.test.ts@@ -6,6 +6,7 @@ import {ComposioFileUploadAbortedError,ComposioFileUploadError,} from '../../src/errors/FileModifierErrors';+import { ComposioRequestCancelledError } from '../../src/errors/SDKErrors';import * as fileUtils from '../../src/utils/fileUtils.node';import { Tools } from '../../src/models/Tools';import { createTestContext, setupTest, mockToolExecution } from '../utils/toolExecuteUtils';@@ -481,6 +482,32 @@ describe('FileToolModifier', () => {).rejects.toThrow(ComposioFileUploadError);});+ it('should throw ComposioRequestCancelledError on caller-aborted upload', async () => {+ const controller = new AbortController();+ vi.mocked(fileUtils.getFileDataAfterUploadingToS3).mockImplementationOnce(async () => {+ controller.abort();+ const error = new Error('The operation was aborted');+ error.name = 'AbortError';+ throw error;+ });++ const params = {+ arguments: {+ file: '/path/to/file.txt',+ },+ userId: 'test-user',+ };++ await expect(+ fileToolModifier.fileUploadModifier(mockTool, {+ toolSlug: 'test-tool',+ toolkitSlug: 'test-toolkit',+ params,+ signal: controller.signal,+ })+ ).rejects.toBeInstanceOf(ComposioRequestCancelledError);+ });+it('should handle File object for file_uploadable parameters', async () => {const mockFileData = {name: 'file.txt',@@ -1982,18 +2009,22 @@ describe('Tools with dangerouslyAllowAutoUploadDownloadFiles', () => {});expect(fileUtils.getFileDataAfterUploadingToS3).not.toHaveBeenCalled();- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- arguments: {- file: '/path/to/file.txt',+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ arguments: {+ file: '/path/to/file.txt',+ },+ allow_tracing: undefined,+ connected_account_id: undefined,+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ text: undefined,+ user_id: 'test-user',+ version: 'latest',},- allow_tracing: undefined,- connected_account_id: undefined,- custom_auth_params: undefined,- custom_connection_data: undefined,- text: undefined,- user_id: 'test-user',- version: 'latest',- });+ undefined+ );});it('warns once per tool when auto-upload is off and the tool has a file-uploadable input', async () => {diff --git a/ts/packages/core/test/tools/modifiers.test.ts b/ts/packages/core/test/tools/modifiers.test.tsindex 21caebc74..0f2442561 100644--- a/ts/packages/core/test/tools/modifiers.test.ts+++ b/ts/packages/core/test/tools/modifiers.test.ts@@ -98,7 +98,8 @@ describe('Tools Modifiers', () => {slug,expect.objectContaining({arguments: { limit: 10 },- })+ }),+ undefined);});@@ -240,9 +241,13 @@ describe('Tools Modifiers', () => {});// Verify schema modification- expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(slug, {- modifySchema: schemaModifier,- });+ expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(+ slug,+ {+ modifySchema: schemaModifier,+ },+ undefined+ );expect(mockTool.description).toBe('Enhanced GITHUB_GET_REPOS for better context');expect(mockTool.tags).toContain('enhanced');expect(mockTool.tags).toContain('modified');diff --git a/ts/packages/core/test/tools/requestOptions.test.ts b/ts/packages/core/test/tools/requestOptions.test.tsnew file mode 100644index 000000000..12a3d427f--- /dev/null+++ b/ts/packages/core/test/tools/requestOptions.test.ts@@ -0,0 +1,458 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { mockClient } from '../utils/mocks/client.mock';+import { toolMocks } from '../utils/mocks/data.mock';+import { Tools } from '../../src/models/Tools';+import ComposioClient, { APIUserAbortError } from '@composio/client';+import { MockProvider } from '../utils/mocks/provider.mock';+import { ComposioRequestCancelledError } from '../../src/errors/SDKErrors';+import type { SessionContext } from '../../src/types/customTool.types';+import { ComposioToolExecutionError } from '../../src/errors/ToolErrors';++describe('Cancellation — error normalization', () => {+ let tools: Tools<unknown, unknown, MockProvider>;++ beforeEach(() => {+ vi.clearAllMocks();+ tools = new Tools(mockClient as unknown as ComposioClient, { provider: new MockProvider() });+ });++ it('translates a real APIUserAbortError (which inherits name==="Error") into ComposioRequestCancelledError', async () => {+ const realAbort = new APIUserAbortError();+ expect(realAbort.name).toBe('Error');++ mockClient.tools.list.mockImplementationOnce(async () => {+ throw realAbort;+ });++ await expect(+ tools.getRawComposioTools({ search: 'send email' }, undefined, {+ signal: AbortSignal.abort(),+ })+ ).rejects.toBeInstanceOf(ComposioRequestCancelledError);+ });++ it('translates a generic AbortError into ComposioRequestCancelledError', async () => {+ mockClient.tools.list.mockImplementationOnce(async () => {+ const err = new Error('The operation was aborted');+ err.name = 'AbortError';+ throw err;+ });++ await expect(+ tools.getRawComposioTools({ search: 'send email' }, undefined, {+ signal: AbortSignal.abort(),+ })+ ).rejects.toBeInstanceOf(ComposioRequestCancelledError);+ });++ it('walks error.cause to detect a wrapped abort', async () => {+ mockClient.tools.list.mockImplementationOnce(async () => {+ const inner = new APIUserAbortError();+ const outer = new Error('Request failed during retry', { cause: inner });+ outer.name = 'APIError';+ throw outer;+ });++ await expect(+ tools.getRawComposioTools({ search: 'send email' }, undefined, {+ signal: AbortSignal.abort(),+ })+ ).rejects.toBeInstanceOf(ComposioRequestCancelledError);+ });++ it('does NOT relabel an unrelated failure as cancellation even if the signal aborts after it', async () => {+ // TOCTOU guard: classification keys on the error being abort-shaped, not just+ // on signal.aborted. A genuine failure (e.g. a 500) that happens to coincide+ // with a late abort must surface as-is, never as a caller cancellation.+ const controller = new AbortController();+ const serverError = new Error('Internal Server Error');+ mockClient.tools.list.mockImplementationOnce(async () => {+ controller.abort();+ throw serverError;+ });++ await expect(+ tools.getRawComposioTools({ search: 'send email' }, undefined, {+ signal: controller.signal,+ })+ ).rejects.toBe(serverError);+ });++ it('abort during execute surfaces as ComposioRequestCancelledError, not ComposioToolExecutionError', async () => {+ const controller = new AbortController();+ vi.spyOn(tools, 'getRawComposioToolBySlug').mockResolvedValueOnce(+ toolMocks.transformedTool as never+ );+ mockClient.tools.execute.mockImplementationOnce(async () => {+ controller.abort();+ const err = new Error('Request was aborted');+ err.name = 'APIUserAbortError';+ throw err;+ });++ try {+ await tools.execute(+ 'COMPOSIO_TOOL',+ { userId: 'user_1', arguments: {}, dangerouslySkipVersionCheck: true },+ { signal: controller.signal }+ );+ throw new Error('expected throw');+ } catch (err) {+ expect(err).toBeInstanceOf(ComposioRequestCancelledError);+ expect(err).not.toBeInstanceOf(ComposioToolExecutionError);+ }+ });++ it('abort during schema retrieval surfaces as ComposioRequestCancelledError, not ComposioToolNotFoundError', async () => {+ mockClient.tools.retrieve.mockReset();+ mockClient.tools.retrieve.mockImplementationOnce(async () => {+ const err = new Error('Request was aborted');+ err.name = 'APIUserAbortError';+ throw err;+ });++ await expect(+ tools.getRawComposioToolBySlug('GITHUB_GET_REPOS', undefined, {+ signal: AbortSignal.abort(),+ })+ ).rejects.toBeInstanceOf(ComposioRequestCancelledError);+ });++ it('ComposioRequestCancelledError carries a non-empty message', async () => {+ mockClient.tools.list.mockReset();+ mockClient.tools.list.mockImplementationOnce(async () => {+ const err = new Error('The operation was aborted');+ err.name = 'APIUserAbortError';+ throw err;+ });++ try {+ await tools.getRawComposioTools({ search: 'send email' }, undefined, {+ signal: AbortSignal.abort(),+ });+ throw new Error('expected throw');+ } catch (err) {+ expect(err).toBeInstanceOf(ComposioRequestCancelledError);+ expect((err as Error).message).toMatch(/cancelled/i);+ }+ });+});++describe('Cancellation — execute signal forwarding', () => {+ let tools: Tools<unknown, unknown, MockProvider>;++ beforeEach(() => {+ vi.clearAllMocks();+ tools = new Tools(mockClient as unknown as ComposioClient, { provider: new MockProvider() });+ });++ it('forwards signal to client.tools.execute and schema lookup', async () => {+ const controller = new AbortController();+ const requestOptions = { signal: controller.signal };++ const getRawSpy = vi.spyOn(tools, 'getRawComposioToolBySlug');+ getRawSpy.mockResolvedValueOnce(toolMocks.transformedTool as never);+ mockClient.tools.execute.mockResolvedValueOnce(toolMocks.rawToolExecuteResponse);++ await tools.execute(+ 'COMPOSIO_TOOL',+ { userId: 'user_1', arguments: {}, dangerouslySkipVersionCheck: true },+ requestOptions+ );++ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ expect.any(Object),+ requestOptions+ );+ expect(getRawSpy).toHaveBeenCalledWith('COMPOSIO_TOOL', expect.any(Object), requestOptions);+ });++ it('pre-aborted signal short-circuits before modifiers run', async () => {+ vi.spyOn(tools, 'getRawComposioToolBySlug').mockResolvedValueOnce(+ toolMocks.transformedTool as never+ );++ const controller = new AbortController();+ controller.abort();++ await expect(+ tools.execute(+ 'COMPOSIO_TOOL',+ { userId: 'user_1', arguments: {}, dangerouslySkipVersionCheck: true },+ { beforeExecute: vi.fn(p => p.params), signal: controller.signal }+ )+ ).rejects.toBeInstanceOf(ComposioRequestCancelledError);+ });++ it('runs afterExecute to completion when the signal fires after the tool already executed', async () => {+ const controller = new AbortController();++ vi.spyOn(tools, 'getRawComposioToolBySlug').mockResolvedValueOnce(+ toolMocks.transformedTool as never+ );+ // The remote tool executes successfully, then the caller's signal fires+ // (e.g. an AbortSignal.timeout) before post-processing runs.+ mockClient.tools.execute.mockImplementationOnce(async () => {+ controller.abort();+ return toolMocks.rawToolExecuteResponse;+ });++ const afterExecute = vi.fn(({ result }) => result);++ const result = await tools.execute(+ 'COMPOSIO_TOOL',+ { userId: 'user_1', arguments: {}, dangerouslySkipVersionCheck: true },+ { afterExecute, signal: controller.signal }+ );++ // The tool already committed (the side effect happened), so the abort lost+ // the race: afterExecute MUST still run rather than being silently skipped.+ expect(afterExecute).toHaveBeenCalledTimes(1);+ expect(result).toBeDefined();+ });+});++describe('Cancellation — custom-tool AbortError classification', () => {+ it('AbortError from tool internal abort (signal NOT fired) is NOT misclassified as cancellation', async () => {+ const { z } = await import('zod');+ const { createCustomTool } = await import('../../src/models/CustomTool');+ const { executeCustomTool } = await import('../../src/models/customToolExecution');+ const customTool = createCustomTool('OWN_ABORT_TOOL', {+ name: 'Own abort',+ description: 'test',+ inputParams: z.object({}),+ execute: async () => {+ const err = new Error('Tool internal timeout');+ err.name = 'AbortError';+ throw err;+ },+ });++ const controller = new AbortController();+ const result = await executeCustomTool(+ { handle: customTool, finalSlug: 'LOCAL_OWN_ABORT_TOOL' } as never,+ {},+ createSessionContext(),+ { signal: controller.signal }+ );++ expect(result.successful).toBe(false);+ expect(result.error).toBe('Tool internal timeout');+ });++ it('AbortError after caller abort IS classified as cancellation', async () => {+ const { z } = await import('zod');+ const { createCustomTool } = await import('../../src/models/CustomTool');+ const { executeCustomTool } = await import('../../src/models/customToolExecution');+ const controller = new AbortController();++ const customTool = createCustomTool('COOP_CANCEL_TOOL', {+ name: 'Coop cancel',+ description: 'test',+ inputParams: z.object({}),+ execute: async () => {+ controller.abort();+ const err = new Error('The operation was aborted');+ err.name = 'AbortError';+ throw err;+ },+ });++ await expect(+ executeCustomTool(+ { handle: customTool, finalSlug: 'LOCAL_COOP_CANCEL_TOOL' } as never,+ {},+ createSessionContext(),+ { signal: controller.signal }+ )+ ).rejects.toBeInstanceOf(ComposioRequestCancelledError);+ });++ it('pre-aborted signal short-circuits before custom-tool user code runs', async () => {+ const { z } = await import('zod');+ const { createCustomTool } = await import('../../src/models/CustomTool');+ const { executeCustomTool } = await import('../../src/models/customToolExecution');+ const userExecute = vi.fn();+ const customTool = createCustomTool('CUSTOM_TOOL', {+ name: 'Custom tool',+ description: 'test',+ inputParams: z.object({}),+ execute: async () => {+ await userExecute();+ return {};+ },+ });++ const controller = new AbortController();+ controller.abort();++ await expect(+ executeCustomTool(+ { handle: customTool, finalSlug: 'LOCAL_CUSTOM_TOOL' } as never,+ {},+ createSessionContext(),+ { signal: controller.signal }+ )+ ).rejects.toBeInstanceOf(ComposioRequestCancelledError);+ expect(userExecute).not.toHaveBeenCalled();+ });+});++function createSessionContext(): SessionContext {+ return {+ userId: 'user_1',+ execute: vi.fn(),+ proxyExecute: vi.fn(),+ };+}++describe('Cancellation — SessionContext signal forwarding', () => {+ it('ctx.execute aborts are normalized so in-tool try/catch detects ComposioRequestCancelledError', async () => {+ const { SessionContextImpl } = await import('../../src/models/SessionContext');+ const { executeCustomTool: execCustomTool } =+ await import('../../src/models/customToolExecution');++ const controller = new AbortController();+ const sessionExecuteSpy = vi.fn().mockImplementation(async () => {+ controller.abort();+ throw new APIUserAbortError();+ });+ const fakeClient = {+ toolRouter: { session: { execute: sessionExecuteSpy, proxyExecute: vi.fn() } },+ };+ const ctxInstance = new SessionContextImpl(fakeClient as never, 'u', 's');++ let observedInToolError: unknown = undefined;+ const { z } = await import('zod');+ const customToolEntry = {+ handle: {+ slug: 'INTOOL_CATCH',+ name: 'in-tool catch',+ inputParams: z.object({}),+ execute: async (_input: unknown, ctx: SessionContext) => {+ try {+ await ctx.execute('SOMETHING', {});+ return { reached: true };+ } catch (err) {+ observedInToolError = err;+ throw err;+ }+ },+ },+ };++ await expect(+ execCustomTool(customToolEntry as never, {}, ctxInstance, {+ signal: controller.signal,+ })+ ).rejects.toBeInstanceOf(ComposioRequestCancelledError);++ expect(observedInToolError).toBeInstanceOf(ComposioRequestCancelledError);+ });+});++describe('Cancellation — composite operation forwarding', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ });++ it('toolkits.authorize forwards signal through every preflight call', async () => {+ const { Toolkits } = await import('../../src/models/Toolkits');+ const toolkits = new Toolkits(mockClient as unknown as ComposioClient);++ const getToolkitBySlugSpy = vi+ .spyOn(+ toolkits as unknown as { getToolkitBySlug: (...args: unknown[]) => Promise<unknown> },+ 'getToolkitBySlug'+ )+ .mockResolvedValue({+ slug: 'github',+ name: 'GitHub',+ authConfigDetails: [{ mode: 'OAUTH2', fields: {} }],+ } as never);+ const { AuthConfigs } = await import('../../src/models/AuthConfigs');+ const authConfigsListSpy = vi+ .spyOn(AuthConfigs.prototype, 'list')+ .mockImplementation(async (_query, reqOpts) => {+ await mockClient.authConfigs.list({} as never, reqOpts);+ return { items: [{ id: 'ac_existing' } as never], nextCursor: null, totalPages: 1 };+ });+ mockClient.authConfigs.list.mockResolvedValueOnce({+ items: [{ id: 'ac_existing' }],+ totalPages: 1,+ } as never);+ mockClient.connectedAccounts.list.mockResolvedValueOnce({+ items: [],+ totalPages: 1,+ } as never);+ mockClient.connectedAccounts.create = vi.fn().mockResolvedValue({+ id: 'ca_new',+ connectionData: { val: { status: 'INITIATED', redirectUrl: null } },+ });++ const requestOptions = { signal: new AbortController().signal };+ await toolkits.authorize('user_1', 'github', undefined, requestOptions);++ expect(getToolkitBySlugSpy).toHaveBeenCalledWith('github', requestOptions);+ expect(authConfigsListSpy).toHaveBeenCalledWith({ toolkit: 'github' }, requestOptions);+ expect(mockClient.connectedAccounts.list).toHaveBeenCalledWith(+ expect.any(Object),+ requestOptions+ );+ expect(mockClient.connectedAccounts.create).toHaveBeenCalledWith(+ expect.any(Object),+ requestOptions+ );+ });++ it('connectedAccounts.initiate forwards signal to list preflight and create', async () => {+ const { ConnectedAccounts } = await import('../../src/models/ConnectedAccounts');+ const connectedAccounts = new ConnectedAccounts(mockClient as unknown as ComposioClient);++ mockClient.connectedAccounts.list.mockResolvedValueOnce({+ items: [],+ totalPages: 1,+ } as never);+ mockClient.connectedAccounts.create = vi.fn().mockResolvedValue({+ id: 'ca_new',+ connectionData: { val: { status: 'INITIATED', redirectUrl: null } },+ });++ const requestOptions = { signal: new AbortController().signal };+ await connectedAccounts.initiate('user_1', 'ac_1', { allowMultiple: true }, requestOptions);++ expect(mockClient.connectedAccounts.list).toHaveBeenCalledWith(+ expect.any(Object),+ requestOptions+ );+ expect(mockClient.connectedAccounts.create).toHaveBeenCalledWith(+ expect.any(Object),+ requestOptions+ );+ });++ it('connectedAccounts.link forwards signal to list preflight and link.create', async () => {+ const { ConnectedAccounts } = await import('../../src/models/ConnectedAccounts');+ const linkCreate = vi.fn().mockResolvedValue({+ connected_account_id: 'ca_new',+ redirect_url: 'https://example.test/cb',+ });+ const extendedClient = { ...mockClient, link: { create: linkCreate } };+ const connectedAccounts = new ConnectedAccounts(extendedClient as unknown as ComposioClient);++ mockClient.connectedAccounts.list.mockResolvedValueOnce({+ items: [],+ totalPages: 1,+ } as never);++ const requestOptions = { signal: new AbortController().signal };+ await connectedAccounts.link('user_1', 'ac_1', { allowMultiple: true }, requestOptions);++ expect(mockClient.connectedAccounts.list).toHaveBeenCalledWith(+ expect.any(Object),+ requestOptions+ );+ expect(linkCreate).toHaveBeenCalledWith(expect.any(Object), requestOptions);+ });+});diff --git a/ts/packages/core/test/tools/tools.test.ts b/ts/packages/core/test/tools/tools.test.tsindex 994672d5f..f34577f1e 100644--- a/ts/packages/core/test/tools/tools.test.ts+++ b/ts/packages/core/test/tools/tools.test.ts@@ -62,11 +62,14 @@ describe('Tools', () => {await context.tools.getRawComposioTools(query);- expect(mockClient.tools.list).toHaveBeenCalledWith({- tool_slugs: 'TOOL1,TOOL2',- limit: 9999,- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ tool_slugs: 'TOOL1,TOOL2',+ limit: 9999,+ toolkit_versions: 'latest',+ },+ undefined+ );});it('should handle toolkit query parameters correctly', async () => {@@ -81,11 +84,14 @@ describe('Tools', () => {await context.tools.getRawComposioTools(query);- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- important: 'true',- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ important: 'true',+ toolkit_versions: 'latest',+ },+ undefined+ );});it('should respect explicit important=false to opt-out', async () => {@@ -102,11 +108,14 @@ describe('Tools', () => {await context.tools.getRawComposioTools(query);- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- limit: 10,- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ limit: 10,+ toolkit_versions: 'latest',+ },+ undefined+ );});it('should handle toolkit search parameters correctly', async () => {@@ -123,12 +132,15 @@ describe('Tools', () => {await context.tools.getRawComposioTools(query);- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- limit: 10,- search: 'test',- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ limit: 10,+ search: 'test',+ toolkit_versions: 'latest',+ },+ undefined+ );});it('should handle toolkit scopes parameters correctly', async () => {@@ -144,12 +156,15 @@ describe('Tools', () => {await context.tools.getRawComposioTools(query);- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'todoist',- important: 'true',- scopes: ['task:add', 'task:read'],- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'todoist',+ important: 'true',+ scopes: ['task:add', 'task:read'],+ toolkit_versions: 'latest',+ },+ undefined+ );});it('should handle toolkit scopes with search parameters correctly', async () => {@@ -167,13 +182,16 @@ describe('Tools', () => {await context.tools.getRawComposioTools(query);- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'todoist',- limit: 10,- search: 'add task',- scopes: ['task:add'],- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'todoist',+ limit: 10,+ search: 'add task',+ scopes: ['task:add'],+ toolkit_versions: 'latest',+ },+ undefined+ );});it('should respect explicit important=true', async () => {@@ -190,12 +208,15 @@ describe('Tools', () => {await context.tools.getRawComposioTools(query);- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- important: 'true',- limit: 10,- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ important: 'true',+ limit: 10,+ toolkit_versions: 'latest',+ },+ undefined+ );});it('should NOT auto-apply important when tags are passed with values', async () => {@@ -212,12 +233,15 @@ describe('Tools', () => {await context.tools.getRawComposioTools(query);- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- tags: ['important', 'custom'],- limit: 10,- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ tags: ['important', 'custom'],+ limit: 10,+ toolkit_versions: 'latest',+ },+ undefined+ );// Should NOT include important: 'true' when tags are provided});@@ -234,11 +258,14 @@ describe('Tools', () => {await context.tools.getRawComposioTools(query);- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- tags: [],- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ tags: [],+ toolkit_versions: 'latest',+ },+ undefined+ );// Should NOT include important: 'true' when tags array is present (even if empty)});@@ -255,11 +282,14 @@ describe('Tools', () => {await context.tools.getRawComposioTools(query);- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- limit: 10,- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ limit: 10,+ toolkit_versions: 'latest',+ },+ undefined+ );// Should NOT include important: 'true' when limit is provided});@@ -355,13 +385,23 @@ describe('Tools', () => {const result = await context.tools.getRawToolRouterSessionTools('session_123');expect(result.map(tool => tool.slug)).toEqual(['FIRST_TOOL', 'SECOND_TOOL']);- expect(mockClient.toolRouter.session.tools).toHaveBeenNthCalledWith(1, 'session_123', {- limit: 500,- });- expect(mockClient.toolRouter.session.tools).toHaveBeenNthCalledWith(2, 'session_123', {- limit: 500,- cursor: 'next_page',- });+ expect(mockClient.toolRouter.session.tools).toHaveBeenNthCalledWith(+ 1,+ 'session_123',+ {+ limit: 500,+ },+ undefined+ );+ expect(mockClient.toolRouter.session.tools).toHaveBeenNthCalledWith(+ 2,+ 'session_123',+ {+ limit: 500,+ cursor: 'next_page',+ },+ undefined+ );});});@@ -373,7 +413,11 @@ describe('Tools', () => {const result = await context.tools.getRawComposioToolBySlug(slug);- expect(mockClient.tools.retrieve).toHaveBeenCalledWith(slug, { toolkit_versions: 'latest' });+ expect(mockClient.tools.retrieve).toHaveBeenCalledWith(+ slug,+ { toolkit_versions: 'latest' },+ undefined+ );expect(result.slug).toEqual(toolMocks.transformedTool.slug);});@@ -414,9 +458,13 @@ describe('Tools', () => {});// Should use 'version' param, not 'toolkit_versions'- expect(mockClient.tools.retrieve).toHaveBeenCalledWith(slug, {- version: explicitVersion,- });+ expect(mockClient.tools.retrieve).toHaveBeenCalledWith(+ slug,+ {+ version: explicitVersion,+ },+ undefined+ );});it('should use version parameter when provided (latest string)', async () => {@@ -429,9 +477,13 @@ describe('Tools', () => {});// Should use 'version' param with 'latest'- expect(mockClient.tools.retrieve).toHaveBeenCalledWith(slug, {- version: 'latest',- });+ expect(mockClient.tools.retrieve).toHaveBeenCalledWith(+ slug,+ {+ version: 'latest',+ },+ undefined+ );});it('should use version parameter when provided (version mapping object)', async () => {@@ -449,9 +501,13 @@ describe('Tools', () => {await toolsWithVersions.getRawComposioToolBySlug(slug);// Should use 'toolkit_versions' param with mapping object (not 'version')- expect(mockClient.tools.retrieve).toHaveBeenCalledWith(slug, {- toolkit_versions: versionMapping,- });+ expect(mockClient.tools.retrieve).toHaveBeenCalledWith(+ slug,+ {+ toolkit_versions: versionMapping,+ },+ undefined+ );});it('should fallback to SDK toolkitVersions when version not provided', async () => {@@ -463,9 +519,13 @@ describe('Tools', () => {await context.tools.getRawComposioToolBySlug(slug);// Should use 'toolkit_versions' param with SDK-level config- expect(mockClient.tools.retrieve).toHaveBeenCalledWith(slug, {- toolkit_versions: 'latest',- });+ expect(mockClient.tools.retrieve).toHaveBeenCalledWith(+ slug,+ {+ toolkit_versions: 'latest',+ },+ undefined+ );});it('should prioritize explicit version over SDK toolkitVersions', async () => {@@ -485,9 +545,13 @@ describe('Tools', () => {});// Explicit version should take precedence, using 'version' param- expect(mockClient.tools.retrieve).toHaveBeenCalledWith(slug, {- version: explicitVersion,- });+ expect(mockClient.tools.retrieve).toHaveBeenCalledWith(+ slug,+ {+ version: explicitVersion,+ },+ undefined+ );});it('should support combining version and modifySchema options', async () => {@@ -505,9 +569,13 @@ describe('Tools', () => {});// Should use version param- expect(mockClient.tools.retrieve).toHaveBeenCalledWith(slug, {- version: explicitVersion,- });+ expect(mockClient.tools.retrieve).toHaveBeenCalledWith(+ slug,+ {+ version: explicitVersion,+ },+ undefined+ );// Should also apply schema modifierexpect(schemaModifier).toHaveBeenCalled();expect(result.description).toEqual('Modified description');@@ -657,9 +725,13 @@ describe('Tools', () => {const result = await context.tools.get(userId, slug);- expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(slug, {- modifySchema: undefined,- });+ expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(+ slug,+ {+ modifySchema: undefined,+ },+ undefined+ );expect(context.mockProvider.wrapTools).toHaveBeenCalledWith([toolMocks.transformedTool],expect.any(Function)@@ -678,7 +750,11 @@ describe('Tools', () => {const result = await context.tools.get(userId, filters);- expect(getRawComposioToolsSpy).toHaveBeenCalledWith(filters, { modifySchema: undefined });+ expect(getRawComposioToolsSpy).toHaveBeenCalledWith(+ filters,+ { modifySchema: undefined },+ undefined+ );expect(context.mockProvider.wrapTools).toHaveBeenCalled();expect(result).toEqual('wrapped-tools-collection');});@@ -697,9 +773,13 @@ describe('Tools', () => {await context.tools.get(userId, slug, { modifySchema: schemaModifier });- expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(slug, {- modifySchema: schemaModifier,- });+ expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(+ slug,+ {+ modifySchema: schemaModifier,+ },+ undefined+ );});});@@ -717,16 +797,20 @@ describe('Tools', () => {const result = await context.tools.execute(slug, body);- expect(mockClient.tools.execute).toHaveBeenCalledWith(slug, {- allow_tracing: undefined,- connected_account_id: undefined,- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: body.arguments,- user_id: body.userId,- version: 'latest',- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ slug,+ {+ allow_tracing: undefined,+ connected_account_id: undefined,+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: body.arguments,+ user_id: body.userId,+ version: 'latest',+ text: undefined,+ },+ undefined+ );expect(result).toEqual(toolMocks.toolExecuteResponse);});@@ -743,16 +827,20 @@ describe('Tools', () => {const result = await context.tools.execute(slug, body);- expect(mockClient.tools.execute).toHaveBeenCalledWith(slug, {- allow_tracing: undefined,- connected_account_id: 'test-connected-account-id',- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: body.arguments,- user_id: body.userId,- version: 'latest',- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ slug,+ {+ allow_tracing: undefined,+ connected_account_id: 'test-connected-account-id',+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: body.arguments,+ user_id: body.userId,+ version: 'latest',+ text: undefined,+ },+ undefined+ );expect(result).toEqual(toolMocks.toolExecuteResponse);});@@ -774,20 +862,24 @@ describe('Tools', () => {const result = await context.tools.execute(slug, body);- expect(mockClient.tools.execute).toHaveBeenCalledWith(slug, {- allow_tracing: undefined,- connected_account_id: 'test-connected-account-id',- custom_auth_params: {- base_url: 'https://custom-api.example.com',- parameters: [{ name: 'x-api-key', value: 'test-key', in: 'header' }],- body: { extra: 'data' },+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ slug,+ {+ allow_tracing: undefined,+ connected_account_id: 'test-connected-account-id',+ custom_auth_params: {+ base_url: 'https://custom-api.example.com',+ parameters: [{ name: 'x-api-key', value: 'test-key', in: 'header' }],+ body: { extra: 'data' },+ },+ custom_connection_data: undefined,+ arguments: body.arguments,+ user_id: body.userId,+ version: 'latest',+ text: undefined,},- custom_connection_data: undefined,- arguments: body.arguments,- user_id: body.userId,- version: 'latest',- text: undefined,- });+ undefined+ );expect(result).toEqual(toolMocks.toolExecuteResponse);});@@ -805,16 +897,21 @@ describe('Tools', () => {await context.tools.execute(slug, body);// Verify getRawComposioToolBySlug was called with version- expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(slug, {- version: explicitVersion,- });+ expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(+ slug,+ {+ version: explicitVersion,+ },+ undefined+ );// Verify the API execute call received the versionexpect(mockClient.tools.execute).toHaveBeenCalledWith(slug,expect.objectContaining({version: explicitVersion,- })+ }),+ undefined);});@@ -832,9 +929,13 @@ describe('Tools', () => {await context.tools.execute(slug, body);// Verify getRawComposioToolBySlug was called with version: 'latest'- expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(slug, {- version: 'latest',- });+ expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(+ slug,+ {+ version: 'latest',+ },+ undefined+ );});it('should not pass version to getRawComposioToolBySlug() when not provided in execute()', async () => {@@ -850,9 +951,13 @@ describe('Tools', () => {await context.tools.execute(slug, body);// Verify getRawComposioToolBySlug was called without version (should fallback to SDK config)- expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(slug, {- version: undefined,- });+ expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(+ slug,+ {+ version: undefined,+ },+ undefined+ );});});@@ -896,34 +1001,37 @@ describe('Tools', () => {const result = await context.tools.proxyExecute(proxyParams);- expect(mockClient.tools.proxy).toHaveBeenCalledWith({- endpoint: '/api/test',- method: 'POST',- body: { data: 'test' },- connected_account_id: 'test-account-id',- parameters: [- {- name: 'Authorization',- type: 'header',- value: 'Bearer token123',- },- {- name: 'Content-Type',- type: 'header',- value: 'application/json',- },- {- name: 'page',- type: 'query',- value: '1',- },- {- name: 'limit',- type: 'query',- value: '10',- },- ],- });+ expect(mockClient.tools.proxy).toHaveBeenCalledWith(+ {+ endpoint: '/api/test',+ method: 'POST',+ body: { data: 'test' },+ connected_account_id: 'test-account-id',+ parameters: [+ {+ name: 'Authorization',+ type: 'header',+ value: 'Bearer token123',+ },+ {+ name: 'Content-Type',+ type: 'header',+ value: 'application/json',+ },+ {+ name: 'page',+ type: 'query',+ value: '1',+ },+ {+ name: 'limit',+ type: 'query',+ value: '10',+ },+ ],+ },+ undefined+ );expect(result).toEqual(expectedProxyResponse);});@@ -955,24 +1063,27 @@ describe('Tools', () => {const result = await context.tools.proxyExecute(proxyParams);- expect(mockClient.tools.proxy).toHaveBeenCalledWith({- endpoint: '/api/headers-only',- method: 'GET',- body: undefined,- connected_account_id: undefined,- parameters: [- {- name: 'Authorization',- type: 'header',- value: 'Bearer token123',- },- {- name: 'Accept',- type: 'header',- value: 'application/json',- },- ],- });+ expect(mockClient.tools.proxy).toHaveBeenCalledWith(+ {+ endpoint: '/api/headers-only',+ method: 'GET',+ body: undefined,+ connected_account_id: undefined,+ parameters: [+ {+ name: 'Authorization',+ type: 'header',+ value: 'Bearer token123',+ },+ {+ name: 'Accept',+ type: 'header',+ value: 'application/json',+ },+ ],+ },+ undefined+ );expect(result).toEqual(expectedProxyResponse);});@@ -1004,24 +1115,27 @@ describe('Tools', () => {const result = await context.tools.proxyExecute(proxyParams);- expect(mockClient.tools.proxy).toHaveBeenCalledWith({- endpoint: '/api/search',- method: 'GET',- body: undefined,- connected_account_id: undefined,- parameters: [- {- name: 'q',- type: 'query',- value: 'test search',- },- {- name: 'page',- type: 'query',- value: '2',- },- ],- });+ expect(mockClient.tools.proxy).toHaveBeenCalledWith(+ {+ endpoint: '/api/search',+ method: 'GET',+ body: undefined,+ connected_account_id: undefined,+ parameters: [+ {+ name: 'q',+ type: 'query',+ value: 'test search',+ },+ {+ name: 'page',+ type: 'query',+ value: '2',+ },+ ],+ },+ undefined+ );expect(result).toEqual(expectedProxyResponse);});@@ -1043,13 +1157,16 @@ describe('Tools', () => {const result = await context.tools.proxyExecute(proxyParams);- expect(mockClient.tools.proxy).toHaveBeenCalledWith({- endpoint: '/api/no-params',- method: 'PUT',- body: { update: 'data' },- connected_account_id: 'test-account-id',- parameters: [],- });+ expect(mockClient.tools.proxy).toHaveBeenCalledWith(+ {+ endpoint: '/api/no-params',+ method: 'PUT',+ body: { update: 'data' },+ connected_account_id: 'test-account-id',+ parameters: [],+ },+ undefined+ );expect(result).toEqual(expectedProxyResponse);});@@ -1081,24 +1198,27 @@ describe('Tools', () => {const result = await context.tools.proxyExecute(proxyParams);- expect(mockClient.tools.proxy).toHaveBeenCalledWith({- endpoint: '/api/numeric',- method: 'GET',- body: undefined,- connected_account_id: undefined,- parameters: [- {- name: 'count',- type: 'query',- value: '42',- },- {- name: 'Version',- type: 'header',- value: '1.5',- },- ],- });+ expect(mockClient.tools.proxy).toHaveBeenCalledWith(+ {+ endpoint: '/api/numeric',+ method: 'GET',+ body: undefined,+ connected_account_id: undefined,+ parameters: [+ {+ name: 'count',+ type: 'query',+ value: '42',+ },+ {+ name: 'Version',+ type: 'header',+ value: '1.5',+ },+ ],+ },+ undefined+ );expect(result).toEqual(expectedProxyResponse);});@@ -1141,11 +1261,15 @@ describe('Tools', () => {const result = await context.tools.executeSessionTool(toolSlug, body);- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(sessionId, {- tool_slug: toolSlug,- arguments: body.arguments,- enable_auto_workbench_offload: true,- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ sessionId,+ {+ tool_slug: toolSlug,+ arguments: body.arguments,+ enable_auto_workbench_offload: true,+ },+ undefined+ );expect(result).toEqual({data: { results: true },error: null,@@ -1180,14 +1304,18 @@ describe('Tools', () => {},});- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(sessionId, {- tool_slug: toolSlug,- arguments: body.arguments,- enable_auto_workbench_offload: true,- experimental: {- custom_tools: [expect.objectContaining({ slug: 'GREP' })],+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ sessionId,+ {+ tool_slug: toolSlug,+ arguments: body.arguments,+ enable_auto_workbench_offload: true,+ experimental: {+ custom_tools: [expect.objectContaining({ slug: 'GREP' })],+ },},- });+ undefined+ );});it('should throw validation error for invalid parameters', async () => {@@ -1250,11 +1378,15 @@ describe('Tools', () => {params: { query: 'original' },});- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(sessionId, {- tool_slug: toolSlug,- arguments: { query: 'modified' },- enable_auto_workbench_offload: true,- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ sessionId,+ {+ tool_slug: toolSlug,+ arguments: { query: 'modified' },+ enable_auto_workbench_offload: true,+ },+ undefined+ );});it('should apply afterExecute modifier', async () => {@@ -1394,11 +1526,15 @@ describe('Tools', () => {// Call the captured execute functionconst result = await capturedExecuteFn!('COMPOSIO_TOOL', { query: 'test' });- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(sessionId, {- tool_slug: 'COMPOSIO_TOOL',- arguments: { query: 'test' },- enable_auto_workbench_offload: true,- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ sessionId,+ {+ tool_slug: 'COMPOSIO_TOOL',+ arguments: { query: 'test' },+ enable_auto_workbench_offload: true,+ },+ undefined+ );expect(result).toEqual({data: { results: true },error: null,@@ -1435,11 +1571,15 @@ describe('Tools', () => {await capturedExecuteFn!('COMPOSIO_TOOL', { query: 'test' });expect(modifiers.beforeExecute).toHaveBeenCalled();- expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(sessionId, {- tool_slug: 'COMPOSIO_TOOL',- arguments: { query: 'test', modified: true },- enable_auto_workbench_offload: true,- });+ expect(mockClient.toolRouter.session.execute).toHaveBeenCalledWith(+ sessionId,+ {+ tool_slug: 'COMPOSIO_TOOL',+ arguments: { query: 'test', modified: true },+ enable_auto_workbench_offload: true,+ },+ undefined+ );});it('should handle multiple tools', async () => {@@ -1481,11 +1621,14 @@ describe('Tools', () => {await context.tools.getRawComposioTools({ tools: ['TEST_TOOL'] });- expect(mockClient.tools.list).toHaveBeenCalledWith({- tool_slugs: 'TEST_TOOL',- limit: 9999,- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ tool_slugs: 'TEST_TOOL',+ limit: 9999,+ toolkit_versions: 'latest',+ },+ undefined+ );});it('should pass global version string when configured', async () => {@@ -1502,11 +1645,14 @@ describe('Tools', () => {await tools.getRawComposioTools({ toolkits: ['github'] });- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- important: 'true',- toolkit_versions: '20251201_03',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ important: 'true',+ toolkit_versions: '20251201_03',+ },+ undefined+ );});it('should pass toolkit-specific versions when configured as object', async () => {@@ -1527,15 +1673,18 @@ describe('Tools', () => {await tools.getRawComposioTools({ toolkits: ['github'] });- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- important: 'true',- toolkit_versions: {- github: '20251201_01',- slack: 'latest',- gmail: '20251201_05',+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ important: 'true',+ toolkit_versions: {+ github: '20251201_01',+ slack: 'latest',+ gmail: '20251201_05',+ },},- });+ undefined+ );});it('should pass versions when fetching tools by tool slugs', async () => {@@ -1555,14 +1704,17 @@ describe('Tools', () => {await tools.getRawComposioTools({ tools: ['GITHUB_CREATE_ISSUE', 'SLACK_SEND_MESSAGE'] });- expect(mockClient.tools.list).toHaveBeenCalledWith({- tool_slugs: 'GITHUB_CREATE_ISSUE,SLACK_SEND_MESSAGE',- limit: 9999,- toolkit_versions: {- github: '20251201_01',- slack: 'latest',+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ tool_slugs: 'GITHUB_CREATE_ISSUE,SLACK_SEND_MESSAGE',+ limit: 9999,+ toolkit_versions: {+ github: '20251201_01',+ slack: 'latest',+ },},- });+ undefined+ );});it('should pass versions when searching tools', async () => {@@ -1579,10 +1731,13 @@ describe('Tools', () => {await tools.getRawComposioTools({ search: 'create issue' });- expect(mockClient.tools.list).toHaveBeenCalledWith({- search: 'create issue',- toolkit_versions: 'latest',- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ search: 'create issue',+ toolkit_versions: 'latest',+ },+ undefined+ );});});@@ -1594,9 +1749,13 @@ describe('Tools', () => {await context.tools.getRawComposioToolBySlug('GITHUB_CREATE_ISSUE');- expect(mockClient.tools.retrieve).toHaveBeenCalledWith('GITHUB_CREATE_ISSUE', {- toolkit_versions: 'latest',- });+ expect(mockClient.tools.retrieve).toHaveBeenCalledWith(+ 'GITHUB_CREATE_ISSUE',+ {+ toolkit_versions: 'latest',+ },+ undefined+ );});it('should pass global version when retrieving single tool', async () => {@@ -1610,9 +1769,13 @@ describe('Tools', () => {await tools.getRawComposioToolBySlug('GITHUB_CREATE_ISSUE');- expect(mockClient.tools.retrieve).toHaveBeenCalledWith('GITHUB_CREATE_ISSUE', {- toolkit_versions: '20251201_03',- });+ expect(mockClient.tools.retrieve).toHaveBeenCalledWith(+ 'GITHUB_CREATE_ISSUE',+ {+ toolkit_versions: '20251201_03',+ },+ undefined+ );});it('should pass toolkit-specific versions when retrieving single tool', async () => {@@ -1630,13 +1793,17 @@ describe('Tools', () => {await tools.getRawComposioToolBySlug('SLACK_SEND_MESSAGE');- expect(mockClient.tools.retrieve).toHaveBeenCalledWith('SLACK_SEND_MESSAGE', {- toolkit_versions: {- github: '20251201_01',- slack: 'latest',- gmail: '20251201_05',+ expect(mockClient.tools.retrieve).toHaveBeenCalledWith(+ 'SLACK_SEND_MESSAGE',+ {+ toolkit_versions: {+ github: '20251201_01',+ slack: 'latest',+ gmail: '20251201_05',+ },},- });+ undefined+ );});});@@ -1653,16 +1820,20 @@ describe('Tools', () => {await context.tools.execute('GITHUB_CREATE_ISSUE', executeParams);- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- allow_tracing: undefined,- connected_account_id: 'test-account',- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: { title: 'Test Issue' },- user_id: undefined,- version: 'latest', // should use latest as default- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ allow_tracing: undefined,+ connected_account_id: 'test-account',+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: { title: 'Test Issue' },+ user_id: undefined,+ version: 'latest', // should use latest as default+ text: undefined,+ },+ undefined+ );});it('should use global version when configured', async () => {@@ -1680,16 +1851,20 @@ describe('Tools', () => {await tools.execute('GITHUB_CREATE_ISSUE', executeParams);- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- allow_tracing: undefined,- connected_account_id: 'test-account',- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: { title: 'Test Issue' },- user_id: undefined,- version: '20251201_03', // should use global version- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ allow_tracing: undefined,+ connected_account_id: 'test-account',+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: { title: 'Test Issue' },+ user_id: undefined,+ version: '20251201_03', // should use global version+ text: undefined,+ },+ undefined+ );});it('should use toolkit-specific version when configured as object', async () => {@@ -1721,16 +1896,20 @@ describe('Tools', () => {await tools.execute('GITHUB_CREATE_ISSUE', executeParams);- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- allow_tracing: undefined,- connected_account_id: 'test-account',- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: { title: 'Test Issue' },- user_id: undefined,- version: '20251201_01', // should use test-toolkit-specific version- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ allow_tracing: undefined,+ connected_account_id: 'test-account',+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: { title: 'Test Issue' },+ user_id: undefined,+ version: '20251201_01', // should use test-toolkit-specific version+ text: undefined,+ },+ undefined+ );});it('should use fallback to "latest" when toolkit not in version mapping', async () => {@@ -1760,16 +1939,20 @@ describe('Tools', () => {await tools.execute('NOTION_CREATE_PAGE', executeParams);- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- allow_tracing: undefined,- connected_account_id: 'test-account',- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: { title: 'Test Page' },- user_id: undefined,- version: 'latest', // should fallback to latest for unknown toolkit- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ allow_tracing: undefined,+ connected_account_id: 'test-account',+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: { title: 'Test Page' },+ user_id: undefined,+ version: 'latest', // should fallback to latest for unknown toolkit+ text: undefined,+ },+ undefined+ );});it('should prioritize explicit version parameter over configured versions', async () => {@@ -1792,16 +1975,20 @@ describe('Tools', () => {await tools.execute('GITHUB_CREATE_ISSUE', executeParams);- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- allow_tracing: undefined,- connected_account_id: 'test-account',- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: { title: 'Test Issue' },- user_id: undefined,- version: '20251201_03', // explicit version takes precedence- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ allow_tracing: undefined,+ connected_account_id: 'test-account',+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: { title: 'Test Issue' },+ user_id: undefined,+ version: '20251201_03', // explicit version takes precedence+ text: undefined,+ },+ undefined+ );});it('should handle tool without toolkit gracefully', async () => {@@ -1832,16 +2019,20 @@ describe('Tools', () => {await tools.execute('SOME_CUSTOM_TOOL', executeParams);- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- allow_tracing: undefined,- connected_account_id: 'test-account',- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: { query: 'test' },- user_id: undefined,- version: 'latest', // should fallback to latest for unknown toolkit- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ allow_tracing: undefined,+ connected_account_id: 'test-account',+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: { query: 'test' },+ user_id: undefined,+ version: 'latest', // should fallback to latest for unknown toolkit+ text: undefined,+ },+ undefined+ );});});@@ -1878,14 +2069,17 @@ describe('Tools', () => {await tools.getRawComposioTools({ toolkits: ['github'] });- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- important: 'true',- toolkit_versions: {- github: '20251201_08',- slack: 'latest',+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ important: 'true',+ toolkit_versions: {+ github: '20251201_08',+ slack: 'latest',+ },},- });+ undefined+ );});it('should prioritize user config over environment variables', async () => {@@ -1909,14 +2103,17 @@ describe('Tools', () => {await tools.getRawComposioTools({ toolkits: ['github'] });- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- important: 'true',- toolkit_versions: {- github: '20251201_04', // user config wins- gmail: '20251201_05', // from user config+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ important: 'true',+ toolkit_versions: {+ github: '20251201_04', // user config wins+ gmail: '20251201_05', // from user config+ },},- });+ undefined+ );});it('should use global version string to override everything', async () => {@@ -1937,11 +2134,14 @@ describe('Tools', () => {await tools.getRawComposioTools({ toolkits: ['github'] });- expect(mockClient.tools.list).toHaveBeenCalledWith({- toolkit_slug: 'github',- important: 'true',- toolkit_versions: '20251201_09', // global version ignores env vars- });+ expect(mockClient.tools.list).toHaveBeenCalledWith(+ {+ toolkit_slug: 'github',+ important: 'true',+ toolkit_versions: '20251201_09', // global version ignores env vars+ },+ undefined+ );});});@@ -1989,16 +2189,20 @@ describe('Tools', () => {const result = await context.tools.execute('GITHUB_CREATE_ISSUE', executeParams);expect(result).toEqual(toolMocks.toolExecuteResponse);- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- allow_tracing: undefined,- connected_account_id: 'test-account',- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: { title: 'Test Issue' },- user_id: undefined,- version: 'latest',- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ allow_tracing: undefined,+ connected_account_id: 'test-account',+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: { title: 'Test Issue' },+ user_id: undefined,+ version: 'latest',+ text: undefined,+ },+ undefined+ );});it('should succeed when executing with a specific version (not "latest") without dangerouslySkipVersionCheck', async () => {@@ -2028,16 +2232,20 @@ describe('Tools', () => {const result = await tools.execute('GITHUB_CREATE_ISSUE', executeParams);expect(result).toEqual(toolMocks.toolExecuteResponse);- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- allow_tracing: undefined,- connected_account_id: 'test-account',- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: { title: 'Test Issue' },- user_id: undefined,- version: '20251201_01', // specific version should work without skip flag- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ allow_tracing: undefined,+ connected_account_id: 'test-account',+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: { title: 'Test Issue' },+ user_id: undefined,+ version: '20251201_01', // specific version should work without skip flag+ text: undefined,+ },+ undefined+ );});it('should succeed when explicit version parameter overrides "latest" config', async () => {@@ -2054,16 +2262,20 @@ describe('Tools', () => {const result = await context.tools.execute('GITHUB_CREATE_ISSUE', executeParams);expect(result).toEqual(toolMocks.toolExecuteResponse);- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- allow_tracing: undefined,- connected_account_id: 'test-account',- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: { title: 'Test Issue' },- user_id: undefined,- version: '20251201_03',- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ allow_tracing: undefined,+ connected_account_id: 'test-account',+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: { title: 'Test Issue' },+ user_id: undefined,+ version: '20251201_03',+ text: undefined,+ },+ undefined+ );});it('should throw error when explicit version parameter is "latest" without dangerouslySkipVersionCheck', async () => {@@ -2173,16 +2385,20 @@ describe('Tools', () => {const result = await storedExecuteToolFn('GITHUB_CREATE_ISSUE', { title: 'Test Issue' });expect(result).toEqual(toolMocks.toolExecuteResponse);- expect(mockClient.tools.execute).toHaveBeenCalledWith('COMPOSIO_TOOL', {- allow_tracing: undefined,- connected_account_id: undefined,- custom_auth_params: undefined,- custom_connection_data: undefined,- arguments: { title: 'Test Issue' },- user_id: userId,- version: 'latest',- text: undefined,- });+ expect(mockClient.tools.execute).toHaveBeenCalledWith(+ 'COMPOSIO_TOOL',+ {+ allow_tracing: undefined,+ connected_account_id: undefined,+ custom_auth_params: undefined,+ custom_connection_data: undefined,+ arguments: { title: 'Test Issue' },+ user_id: userId,+ version: 'latest',+ text: undefined,+ },+ undefined+ );});});});diff --git a/ts/packages/core/test/utils/fileUtils.test.ts b/ts/packages/core/test/utils/fileUtils.test.tsindex d413fb616..78060673f 100644--- a/ts/packages/core/test/utils/fileUtils.test.ts+++ b/ts/packages/core/test/utils/fileUtils.test.ts@@ -107,7 +107,7 @@ describe('fileUtils', () => {});expect(result.name).toBe('document.pdf');- expect(mockFetch).toHaveBeenCalledWith(urlWithQuery);+ expect(mockFetch).toHaveBeenCalledWith(urlWithQuery, { signal: undefined });});it('should generate filename when URL has no filename', async () => {diff --git a/ts/packages/core/test/utils/mocks/client.mock.ts b/ts/packages/core/test/utils/mocks/client.mock.tsindex 8c8e2bcb7..c1f09f88a 100644--- a/ts/packages/core/test/utils/mocks/client.mock.ts+++ b/ts/packages/core/test/utils/mocks/client.mock.ts@@ -12,9 +12,23 @@ export const mockClient = {connectedAccounts: {list: vi.fn(),get: vi.fn(),+ retrieve: vi.fn(),+ delete: vi.fn(),+ refresh: vi.fn(),+ updateStatus: vi.fn(),},toolkits: {+ list: vi.fn(),+ retrieve: vi.fn(),+ retrieveCategories: vi.fn(),+ },+ authConfigs: {+ list: vi.fn(),+ create: vi.fn(),retrieve: vi.fn(),+ update: vi.fn(),+ delete: vi.fn(),+ updateStatus: vi.fn(),},toolRouter: {session: {