@devries-cameron20 / composio-1 / commits / f6b550573
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(core): preserve SDK reference types

Alberto Schiabel committed Jun 25, 2026 at 03:56 UTC f6b550573905787518056e3bd96e7d1f6165f0f8
14 files changed +730 -199
docs/content/reference/sdk-reference/typescript/auth-configs.mdx
+33 -19
@@ -19,7 +19,7 @@ const result = await composio.authConfigs.list();
19 Create a new auth config
20
21 ```typescript
22 -async create(toolkit: string, options: object): Promise<{ authScheme: string; id: string; isComposioManaged: boolean; toolkit: string }>
22 +async create(toolkit: string, options: CreateAuthConfigParams, requestOptions?: ComposioRequestOptions): Promise<CreateAuthConfigResponse>
23 ```
24
25 **Parameters**
@@ -27,11 +27,12 @@ async create(toolkit: string, options: object): Promise<{ authScheme: string; id
27 | Name | Type | Description |
28 |------|------|-------------|
29 | `toolkit` | `string` | Unique identifier of the toolkit |
30 -| `options` | `object` | Options for creating a new auth config |
30 +| `options` | `CreateAuthConfigParams` | Options for creating a new auth config |
31 +| `requestOptions?` | `ComposioRequestOptions` | |
32
33 **Returns**
34
34 -`Promise<...>` — Created auth config
35 +`Promise<CreateAuthConfigResponse>` — Created auth config
36
37 **Example**
38
@@ -57,7 +58,7 @@ This action cannot be undone and will prevent any connected accounts that use
58 this auth config from functioning.
59
60 ```typescript
60 -async delete(nanoid: string): Promise<AuthConfigDeleteResponse>
61 +async delete(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<AuthConfigDeleteResponse>
62 ```
63
64 **Parameters**
@@ -65,6 +66,7 @@ async delete(nanoid: string): Promise<AuthConfigDeleteResponse>
66 | Name | Type | Description |
67 |------|------|-------------|
68 | `nanoid` | `string` | The unique identifier of the auth config to delete |
69 +| `requestOptions?` | `ComposioRequestOptions` | |
70
71 **Returns**
72
@@ -88,7 +90,7 @@ When disabled, the auth config cannot be used to create new connected accounts
90 or authenticate with third-party services, but existing connections may continue to work.
91
92 ```typescript
91 -async disable(nanoid: string): Promise
93 +async disable(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<AuthConfigUpdateStatusResponse>
94 ```
95
96 **Parameters**
@@ -96,10 +98,11 @@ async disable(nanoid: string): Promise
98 | Name | Type | Description |
99 |------|------|-------------|
100 | `nanoid` | `string` | The unique identifier of the auth config to disable |
101 +| `requestOptions?` | `ComposioRequestOptions` | |
102
103 **Returns**
104
102 -`Promise` — The updated auth config details
105 +`Promise<AuthConfigUpdateStatusResponse>` — The updated auth config details
106
107 **Example**
108
@@ -119,7 +122,7 @@ When enabled, the auth config can be used to create new connected accounts
122 and authenticate with third-party services.
123
124 ```typescript
122 -async enable(nanoid: string): Promise
125 +async enable(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<AuthConfigUpdateStatusResponse>
126 ```
127
128 **Parameters**
@@ -127,10 +130,11 @@ async enable(nanoid: string): Promise
130 | Name | Type | Description |
131 |------|------|-------------|
132 | `nanoid` | `string` | The unique identifier of the auth config to enable |
133 +| `requestOptions?` | `ComposioRequestOptions` | |
134
135 **Returns**
136
133 -`Promise` — The updated auth config details
137 +`Promise<AuthConfigUpdateStatusResponse>` — The updated auth config details
138
139 **Example**
140
@@ -149,7 +153,7 @@ This method fetches detailed information about a single auth config
153 and transforms the response to the SDK's standardized format.
154
155 ```typescript
152 -async get(nanoid: string): Promise<...>
156 +async get(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<AuthConfigRetrieveResponse>
157 ```
158
159 **Parameters**
@@ -157,10 +161,11 @@ async get(nanoid: string): Promise<...>
161 | Name | Type | Description |
162 |------|------|-------------|
163 | `nanoid` | `string` | The unique identifier of the auth config to retrieve |
164 +| `requestOptions?` | `ComposioRequestOptions` | |
165
166 **Returns**
167
163 -`Promise<...>` — The auth config details
168 +`Promise<AuthConfigRetrieveResponse>` — The auth config details
169
170 **Example**
171
@@ -181,18 +186,19 @@ This method retrieves auth configs from the Composio API, transforms them to the
186 and supports filtering by various parameters.
187
188 ```typescript
184 -async list(query?: { cursor?: string; isComposioManaged?: boolean; limit?: number; toolkit?: string }): Promise<...>
189 +async list(query?: AuthConfigListParams, requestOptions?: ComposioRequestOptions): Promise<AuthConfigListResponse>
190 ```
191
192 **Parameters**
193
194 | Name | Type | Description |
195 |------|------|-------------|
191 -| `query?` | `object` | Optional query parameters for filtering auth configs |
196 +| `query?` | `AuthConfigListParams` | Optional query parameters for filtering auth configs |
197 +| `requestOptions?` | `ComposioRequestOptions` | |
198
199 **Returns**
200
195 -`Promise<...>` — A paginated list of auth configurations
201 +`Promise<AuthConfigListResponse>` — A paginated list of auth configurations
202
203 **Example**
204
@@ -205,6 +211,12 @@ const githubConfigs = await composio.authConfigs.list({
211 toolkit: 'github'
212 });
213
214 +// Search auth configs by name or id
215 +const searchedConfigs = await composio.authConfigs.list({
216 + search: 'github',
217 + showDisabled: true
218 +});
219 +
220 // List Composio-managed auth configs
221 const managedConfigs = await composio.authConfigs.list({
222 isComposioManaged: true
@@ -222,7 +234,7 @@ scopes, or tool restrictions. The update type (custom or default) determines whi
234 fields can be updated.
235
236 ```typescript
225 -async update(nanoid: string, data: object): Promise
237 +async update(nanoid: string, data: AuthConfigUpdateParams, requestOptions?: ComposioRequestOptions): Promise<AuthConfigUpdateResponse>
238 ```
239
240 **Parameters**
@@ -230,11 +242,12 @@ async update(nanoid: string, data: object): Promise
242 | Name | Type | Description |
243 |------|------|-------------|
244 | `nanoid` | `string` | The unique identifier of the auth config to update |
233 -| `data` | `object` | The data to update, which can be either custom or default type |
245 +| `data` | `AuthConfigUpdateParams` | The data to update, which can be either custom or default type |
246 +| `requestOptions?` | `ComposioRequestOptions` | |
247
248 **Returns**
249
237 -`Promise` — The updated auth config
250 +`Promise<AuthConfigUpdateResponse>` — The updated auth config
251
252 **Example**
253
@@ -265,19 +278,20 @@ the auth config cannot be used to create new connected accounts or authenticate
278 with third-party services.
279
280 ```typescript
268 -async updateStatus(status: 'ENABLED' | 'DISABLED', nanoid: string): Promise
281 +async updateStatus(status: 'ENABLED' | 'DISABLED', nanoid: string, requestOptions?: ComposioRequestOptions): Promise<AuthConfigUpdateStatusResponse>
282 ```
283
284 **Parameters**
285
286 | Name | Type | Description |
287 |------|------|-------------|
275 -| `status` | `'ENABLED' | 'DISABLED'` | The status to set ('ENABLED' or 'DISABLED') |
288 +| `status` | `'ENABLED' \| 'DISABLED'` | The status to set ('ENABLED' or 'DISABLED') |
289 | `nanoid` | `string` | The unique identifier of the auth config |
290 +| `requestOptions?` | `ComposioRequestOptions` | |
291
292 **Returns**
293
280 -`Promise` — The updated auth config details
294 +`Promise<AuthConfigUpdateStatusResponse>` — The updated auth config details
295
296 **Example**
297
docs/content/reference/sdk-reference/typescript/composio.mdx
+5 -5
@@ -53,7 +53,7 @@ const composio = new Composio({
53 |------|------|-------------|
54 | `authConfigs` | `AuthConfigs` | Manage authentication configurations for toolkits |
55 | `connectedAccounts` | `ConnectedAccounts` | Manage authenticated connections |
56 -| `create` | `object` | Creates a new tool router session for a user.
56 +| `create` | `(userId: string, routerConfig: \{ authConfigs?: Record<string, string>; connectedAccounts?: Record<string, string \| string[]>; experimental?: \{ assistivePrompt?: \{ userTimezone?: string \}; customToolkits?: CustomToolkit[]; customTools?: CustomTool[] \}; manageConnections?: boolean \| \{ callbackUrl?: string; enable?: boolean; waitForConnections?: boolean \}; multiAccount?: \{ enable: boolean; maxAccountsPerToolkit?: number; requireExplicitSelection?: boolean \}; preload?: \{ tools?: string[] \| 'all' \}; sessionPreset?: 'direct_tools'; tags?: 'readOnlyHint' \| 'destructiveHint' \| 'idempotentHint' \| 'openWorldHint'[] \| \{ disable?: ... \| ... \| ... \| ...[]; enable?: ... \| ... \| ... \| ...[] \}; toolkits?: string[] \| \{ disable: string[] \} \| \{ enable: string[] \}; tools?: Record<string, string[] \| \{ enable: ...[] \} \| \{ disable: ...[] \} \| \{ tags: ... \| ... \}>; workbench?: \{ autoOffloadThreshold?: number; enable: boolean; enableProxyExecution?: boolean; sandboxSize?: 'standard' \| 'medium' \| 'large' \| 'xlarge' \} \}, requestOptions: ComposioRequestOptions) => Promise<Session>` | Creates a new tool router session for a user.
57 Use `sessionPreset: SessionPreset.DIRECT_TOOLS` when all needed tools
58 should be exposed directly; see `ToolRouterCreateSessionConfig`. |
59 | `experimental` | `Experimental` | Experimental SDK methods whose shape may change in future releases.
@@ -67,7 +67,7 @@ take a client and perform I/O. Stateless experimental factories
67 | `toolRouter` | `ToolRouter` | Experimental feature, use with caution |
68 | `tools` | `Tools` | List, retrieve, and execute tools |
69 | `triggers` | `Triggers` | Manage webhook triggers and event subscriptions |
70 -| `use` | `object` | Use an existing tool router session |
70 +| `use` | `(id: string, options: \{ customToolkits?: CustomToolkit[]; customTools?: CustomTool[] \}, requestOptions: ComposioRequestOptions) => Promise<Session>` | Use an existing tool router session |
71
72 ## Methods
73
@@ -90,7 +90,7 @@ createSession(options?: { headers?: ComposioRequestHeaders }): Composio
90
91 | Name | Type |
92 |------|------|
93 -| `options?` | `object` |
93 +| `options?` | `\{ headers?: ComposioRequestHeaders \}` |
94
95 **Returns**
96
@@ -161,12 +161,12 @@ export default {
161 Get the Composio SDK client.
162
163 ```typescript
164 -getClient(): Composio
164 +getClient(): ComposioClient
165 ```
166
167 **Returns**
168
169 -`Composio` — The Composio API client.
169 +`ComposioClient` — The Composio API client.
170
171 ---
172
docs/content/reference/sdk-reference/typescript/connected-accounts.mdx
+29 -19
@@ -22,7 +22,7 @@ This method permanently removes a connected account from the Composio platform.
22 This action cannot be undone and will revoke any access tokens associated with the account.
23
24 ```typescript
25 -async delete(nanoid: string): Promise<ConnectedAccountDeleteResponse>
25 +async delete(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountDeleteResponse>
26 ```
27
28 **Parameters**
@@ -30,6 +30,7 @@ async delete(nanoid: string): Promise<ConnectedAccountDeleteResponse>
30 | Name | Type | Description |
31 |------|------|-------------|
32 | `nanoid` | `string` | The unique identifier of the connected account to delete |
33 +| `requestOptions?` | `ComposioRequestOptions` | |
34
35 **Returns**
36
@@ -49,7 +50,7 @@ await composio.connectedAccounts.delete('conn_abc123');
50 Disable a connected account
51
52 ```typescript
52 -async disable(nanoid: string): Promise<ConnectedAccountUpdateStatusResponse>
53 +async disable(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountUpdateStatusResponse>
54 ```
55
56 **Parameters**
@@ -57,6 +58,7 @@ async disable(nanoid: string): Promise<ConnectedAccountUpdateStatusResponse>
58 | Name | Type | Description |
59 |------|------|-------------|
60 | `nanoid` | `string` | Unique identifier of the connected account |
61 +| `requestOptions?` | `ComposioRequestOptions` | |
62
63 **Returns**
64
@@ -83,7 +85,7 @@ console.log(disabledAccount.isDisabled); // true
85 Enable a connected account
86
87 ```typescript
86 -async enable(nanoid: string): Promise<ConnectedAccountUpdateStatusResponse>
88 +async enable(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountUpdateStatusResponse>
89 ```
90
91 **Parameters**
@@ -91,6 +93,7 @@ async enable(nanoid: string): Promise<ConnectedAccountUpdateStatusResponse>
93 | Name | Type | Description |
94 |------|------|-------------|
95 | `nanoid` | `string` | Unique identifier of the connected account |
96 +| `requestOptions?` | `ComposioRequestOptions` | |
97
98 **Returns**
99
@@ -114,7 +117,7 @@ This method fetches detailed information about a single connected account
117 and transforms the response to the SDK's standardized format.
118
119 ```typescript
117 -async get(nanoid: string): Promise<...>
120 +async get(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountRetrieveResponse>
121 ```
122
123 **Parameters**
@@ -122,10 +125,11 @@ async get(nanoid: string): Promise<...>
125 | Name | Type | Description |
126 |------|------|-------------|
127 | `nanoid` | `string` | The unique identifier of the connected account |
128 +| `requestOptions?` | `ComposioRequestOptions` | |
129
130 **Returns**
131
128 -`Promise<...>` — The connected account details
132 +`Promise<ConnectedAccountRetrieveResponse>` — The connected account details
133
134 **Example**
135
@@ -161,7 +165,7 @@ bearer token, basic auth) are unaffected and continue to work on
165 `initiate()`. See https://docs.composio.dev/docs/changelog/2026/04/24
166
167 ```typescript
164 -async initiate(userId: string, authConfigId: string, options?: object): Promise<ConnectionRequest>
168 +async initiate(userId: string, authConfigId: string, options?: CreateConnectedAccountOptions, requestOptions?: ComposioRequestOptions): Promise<ConnectionRequest>
169 ```
170
171 **Parameters**
@@ -170,7 +174,8 @@ async initiate(userId: string, authConfigId: string, options?: object): Promise<
174 |------|------|-------------|
175 | `userId` | `string` | User ID of the connected account |
176 | `authConfigId` | `string` | Auth config ID of the connected account |
173 -| `options?` | `object` | Options for creating a new connected account |
177 +| `options?` | `CreateConnectedAccountOptions` | Options for creating a new connected account |
178 +| `requestOptions?` | `ComposioRequestOptions` | |
179
180 **Returns**
181
@@ -221,7 +226,7 @@ const connectionRequest = await composio.connectedAccounts.initiate(
226 ### link()
227
228 ```typescript
224 -async link(userId: string, authConfigId: string, options?: object): Promise<ConnectionRequest>
229 +async link(userId: string, authConfigId: string, options?: CreateConnectedAccountLinkOptions, requestOptions?: ComposioRequestOptions): Promise<ConnectionRequest>
230 ```
231
232 **Parameters**
@@ -230,7 +235,8 @@ async link(userId: string, authConfigId: string, options?: object): Promise<Conn
235 |------|------|-------------|
236 | `userId` | `string` | \{string\} - The external user ID to create the connected account for. |
237 | `authConfigId` | `string` | \{string\} - The auth config ID to create the connected account for. |
233 -| `options?` | `object` | \{CreateConnectedAccountOptions\} - Options for creating a new connected account. |
238 +| `options?` | `CreateConnectedAccountLinkOptions` | \{CreateConnectedAccountOptions\} - Options for creating a new connected account. |
239 +| `requestOptions?` | `ComposioRequestOptions` | |
240
241 **Returns**
242
@@ -269,18 +275,19 @@ Lists all connected accounts based on provided filter criteria.
275 This method retrieves connected accounts from the Composio API with optional filtering.
276
277 ```typescript
272 -async list(query?: object): Promise<...>
278 +async list(query?: ConnectedAccountListParams, requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountListResponse>
279 ```
280
281 **Parameters**
282
283 | Name | Type | Description |
284 |------|------|-------------|
279 -| `query?` | `object` | Optional query parameters for filtering connected accounts |
285 +| `query?` | `ConnectedAccountListParams` | Optional query parameters for filtering connected accounts |
286 +| `requestOptions?` | `ComposioRequestOptions` | |
287
288 **Returns**
289
283 -`Promise<...>` — A paginated list of connected accounts
290 +`Promise<ConnectedAccountListResponse>` — A paginated list of connected accounts
291
292 **Example**
293
@@ -309,7 +316,7 @@ This method attempts to refresh OAuth tokens or other credentials associated wit
316 the connected account. This is useful when a token has expired or is about to expire.
317
318 ```typescript
312 -async refresh(nanoid: string, options?: { redirectUrl?: string; validateCredentials?: boolean }): Promise<ConnectedAccountRefreshResponse>
319 +async refresh(nanoid: string, options?: ConnectedAccountRefreshOptions, requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountRefreshResponse>
320 ```
321
322 **Parameters**
@@ -317,7 +324,8 @@ async refresh(nanoid: string, options?: { redirectUrl?: string; validateCredenti
324 | Name | Type | Description |
325 |------|------|-------------|
326 | `nanoid` | `string` | The unique identifier of the connected account to refresh |
320 -| `options?` | `object` | |
327 +| `options?` | `ConnectedAccountRefreshOptions` | |
328 +| `requestOptions?` | `ComposioRequestOptions` | |
329
330 **Returns**
331
@@ -340,7 +348,7 @@ For ACL writes on SHARED connections, see
348 `composio.experimental.updateAcl()`.
349
350 ```typescript
343 -async update(nanoid: string, params: ConnectedAccountUpdateStatusParams): Promise<ConnectedAccountUpdateStatusResponse>
351 +async update(nanoid: string, params: UpdateConnectedAccountParams, requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountUpdateStatusResponse>
352 ```
353
354 **Parameters**
@@ -348,7 +356,8 @@ async update(nanoid: string, params: ConnectedAccountUpdateStatusParams): Promis
356 | Name | Type | Description |
357 |------|------|-------------|
358 | `nanoid` | `string` | The unique identifier of the connected account |
351 -| `params` | `ConnectedAccountUpdateStatusParams` | The update parameters |
359 +| `params` | `UpdateConnectedAccountParams` | The update parameters |
360 +| `requestOptions?` | `ComposioRequestOptions` | |
361
362 **Returns**
363
@@ -368,7 +377,7 @@ await composio.connectedAccounts.update('ca_abc123', { enabled: false });
377 Update the status of a connected account
378
379 ```typescript
371 -async updateStatus(nanoid: string, params: ConnectedAccountUpdateStatusParams): Promise<ConnectedAccountUpdateStatusResponse>
380 +async updateStatus(nanoid: string, params: ConnectedAccountUpdateStatusParams, requestOptions?: ComposioRequestOptions): Promise<ConnectedAccountUpdateStatusResponse>
381 ```
382
383 **Parameters**
@@ -377,6 +386,7 @@ async updateStatus(nanoid: string, params: ConnectedAccountUpdateStatusParams):
386 |------|------|-------------|
387 | `nanoid` | `string` | Unique identifier of the connected account |
388 | `params` | `ConnectedAccountUpdateStatusParams` | Parameters for updating the status |
389 +| `requestOptions?` | `ComposioRequestOptions` | |
390
391 **Returns**
392
@@ -407,7 +417,7 @@ This method continuously polls the Composio API to check the status of a connect
417 until it either becomes active, enters a terminal error state, or times out.
418
419 ```typescript
410 -async waitForConnection(connectedAccountId: string, timeout?: number): Promise<...>
420 +async waitForConnection(connectedAccountId: string, timeout?: number): Promise<ConnectedAccountRetrieveResponse>
421 ```
422
423 **Parameters**
@@ -419,7 +429,7 @@ async waitForConnection(connectedAccountId: string, timeout?: number): Promise<.
429
430 **Returns**
431
422 -`Promise<...>` — The finalized connected account data
432 +`Promise<ConnectedAccountRetrieveResponse>` — The finalized connected account data
433
434 **Example**
435
docs/content/reference/sdk-reference/typescript/experimental.mdx
+2 -2
@@ -34,7 +34,7 @@ Resolution rule (deny wins):
34 4. otherwise → DENY
35
36 ```typescript
37 -async updateAcl(nanoid: string, params: { allowAllUsers?: boolean; allowedUserIds?: string[]; notAllowedUserIds?: string[] }): Promise<ConnectedAccountPatchResponse>
37 +async updateAcl(nanoid: string, params: UpdateConnectedAccountAclParams): Promise<ConnectedAccountPatchResponse>
38 ```
39
40 **Parameters**
@@ -42,7 +42,7 @@ async updateAcl(nanoid: string, params: { allowAllUsers?: boolean; allowedUserId
42 | Name | Type |
43 |------|------|
44 | `nanoid` | `string` |
45 -| `params` | `object` |
45 +| `params` | `UpdateConnectedAccountAclParams` |
46
47 **Returns**
48
docs/content/reference/sdk-reference/typescript/mcp.mdx
+21 -15
@@ -25,7 +25,7 @@ const result = await composio.mcp.list();
25 Create a new MCP configuration.
26
27 ```typescript
28 -async create(name: string, mcpConfig: object): Promise<MCPConfigCreateResponse>
28 +async create(name: string, mcpConfig: MCPConfigCreationParams, requestOptions?: ComposioRequestOptions): Promise<MCPConfigCreateResponse>
29 ```
30
31 **Parameters**
@@ -33,7 +33,8 @@ async create(name: string, mcpConfig: object): Promise<MCPConfigCreateResponse>
33 | Name | Type |
34 |------|------|
35 | `name` | `string` |
36 -| `mcpConfig` | `object` |
36 +| `mcpConfig` | `MCPConfigCreationParams` |
37 +| `requestOptions?` | `ComposioRequestOptions` |
38
39 **Returns**
40
@@ -64,7 +65,7 @@ const server = await composio.mcpConfig.create("personal-mcp-server", {
65 Delete an MCP server configuration permanently
66
67 ```typescript
67 -async delete(serverId: string): Promise<{ deleted: boolean; id: string }>
68 +async delete(serverId: string, requestOptions?: ComposioRequestOptions): Promise<{ id: string; deleted: boolean }>
69 ```
70
71 **Parameters**
@@ -72,10 +73,11 @@ async delete(serverId: string): Promise<{ deleted: boolean; id: string }>
73 | Name | Type | Description |
74 |------|------|-------------|
75 | `serverId` | `string` | The unique identifier of the MCP server to delete |
76 +| `requestOptions?` | `ComposioRequestOptions` | |
77
78 **Returns**
79
78 -`Promise<...>` — Confirmation object with server ID and deletion status
80 +`Promise<\{ id: string; deleted: boolean \}>` — Confirmation object with server ID and deletion status
81
82 **Example**
83
@@ -112,7 +114,7 @@ Get server URLs for an existing MCP server.
114 The response is wrapped according to the provider's specifications.
115
116 ```typescript
115 -async generate(userId: string, mcpConfigId: string, options?: { manuallyManageConnections?: boolean }): Promise<...>
117 +async generate(userId: string, mcpConfigId: string, options?: MCPGetInstanceParams, requestOptions?: ComposioRequestOptions): Promise<MCPServerInstance>
118 ```
119
120 **Parameters**
@@ -121,11 +123,12 @@ async generate(userId: string, mcpConfigId: string, options?: { manuallyManageCo
123 |------|------|-------------|
124 | `userId` | `string` | \{string\} external user id from your database for whom you want the server for |
125 | `mcpConfigId` | `string` | \{string\} config id of the MCPConfig for which you want to create a server for |
124 -| `options?` | `object` | \{object\} additional options |
126 +| `options?` | `MCPGetInstanceParams` | \{object\} additional options |
127 +| `requestOptions?` | `ComposioRequestOptions` | |
128
129 **Returns**
130
128 -`Promise<...>`
131 +`Promise<MCPServerInstance>`
132
133 **Example**
134
@@ -143,7 +146,7 @@ const mcp = await composio.experimental.mcp.generate("default", "<mcp_config_id>
146 Retrieve detailed information about a specific MCP server by its ID
147
148 ```typescript
146 -async get(serverId: string): Promise<...>
149 +async get(serverId: string, requestOptions?: ComposioRequestOptions): Promise<MCPItem>
150 ```
151
152 **Parameters**
@@ -151,10 +154,11 @@ async get(serverId: string): Promise<...>
154 | Name | Type | Description |
155 |------|------|-------------|
156 | `serverId` | `string` | The unique identifier of the MCP server to retrieve |
157 +| `requestOptions?` | `ComposioRequestOptions` | |
158
159 **Returns**
160
157 -`Promise<...>` — Complete MCP server details including configuration, tools, and metadata
161 +`Promise<MCPItem>` — Complete MCP server details including configuration, tools, and metadata
162
163 **Example**
164
@@ -183,18 +187,19 @@ const mcpUrl = server.MCPUrl;
187 List the MCP servers with optional filtering and pagination
188
189 ```typescript
186 -async list(options: { authConfigs: string[]; limit: number; name?: string; page: number; toolkits: string[] }): Promise<...>
190 +async list(options: MCPListParams, requestOptions?: ComposioRequestOptions): Promise<MCPListResponse>
191 ```
192
193 **Parameters**
194
195 | Name | Type | Description |
196 |------|------|-------------|
193 -| `options` | `object` | Filtering and pagination options |
197 +| `options` | `MCPListParams` | Filtering and pagination options |
198 +| `requestOptions?` | `ComposioRequestOptions` | |
199
200 **Returns**
201
197 -`Promise<...>` — Paginated list of MCP servers with metadata
202 +`Promise<MCPListResponse>` — Paginated list of MCP servers with metadata
203
204 **Example**
205
@@ -226,7 +231,7 @@ const namedServers = await composio.experimental.mcp.list({
231 Update an existing MCP server configuration with new settings
232
233 ```typescript
229 -async update(serverId: string, config: object): Promise<...>
234 +async update(serverId: string, config: MCPUpdateParams, requestOptions?: ComposioRequestOptions): Promise<MCPItem>
235 ```
236
237 **Parameters**
@@ -234,11 +239,12 @@ async update(serverId: string, config: object): Promise<...>
239 | Name | Type | Description |
240 |------|------|-------------|
241 | `serverId` | `string` | The unique identifier of the MCP server to update |
237 -| `config` | `object` | Update configuration parameters |
242 +| `config` | `MCPUpdateParams` | Update configuration parameters |
243 +| `requestOptions?` | `ComposioRequestOptions` | |
244
245 **Returns**
246
241 -`Promise<...>` — Updated MCP server configuration with all details
247 +`Promise<MCPItem>` — Updated MCP server configuration with all details
248
249 **Example**
250
docs/content/reference/sdk-reference/typescript/session-context-impl.mdx
+8 -4
@@ -16,6 +16,10 @@ const result = await composio.sessionContextImpl.list();
16
17 | Name | Type | Description |
18 |------|------|-------------|
19 +| `signal` | `AbortSignal` | Per-execution AbortSignal. Never set on the base instance; `executeCustomTool`
20 +grafts it onto a per-call `Object.create` child so concurrent executions
21 +sharing this context don't observe each other's signal. Declared here (rather
22 +than read via a cast) so the contract is explicit. |
23 | `userId` | `string` | The user ID for this session |
24
25 ## Methods
@@ -29,7 +33,7 @@ otherwise delegates to the backend API.
33 Returns the same response shape as session.execute().
34
35 ```typescript
32 -async execute(toolSlug: string, arguments_: Record<string, unknown>): Promise<{ data: Record<string, unknown>; error: string | null; logId: string }>
36 +async execute(toolSlug: string, arguments_: Record<string, unknown>): Promise<ToolRouterSessionExecuteResponse>
37 ```
38
39 **Parameters**
@@ -41,7 +45,7 @@ async execute(toolSlug: string, arguments_: Record<string, unknown>): Promise<{
45
46 **Returns**
47
44 -`Promise<...>`
48 +`Promise<ToolRouterSessionExecuteResponse>`
49
50 ---
51
@@ -51,14 +55,14 @@ Proxy API calls through Composio's auth layer.
55 The backend resolves the connected account from the toolkit within the session.
56
57 ```typescript
54 -async proxyExecute(params: object): Promise<ToolRouterSessionProxyExecuteResponse>
58 +async proxyExecute(params: SessionProxyExecuteParams): Promise<ToolRouterSessionProxyExecuteResponse>
59 ```
60
61 **Parameters**
62
63 | Name | Type |
64 |------|------|
61 -| `params` | `object` |
65 +| `params` | `SessionProxyExecuteParams` |
66
67 **Returns**
68
docs/content/reference/sdk-reference/typescript/tool-router-session-files-mount.mdx
+11 -11
@@ -22,7 +22,7 @@ Removes the file or directory from the virtual filesystem. Use with caution:
22 deletion is typically irreversible. Ensure the path exists and is intended for removal.
23
24 ```typescript
25 -async delete(remotePath: string, options?: { mountId?: string }): Promise<{ mountRelativePath: string; sandboxMountPrefix: string }>
25 +async delete(remotePath: string, options?: ToolRouterSessionFilesMountDeleteOptions): Promise<FileDeleteResponse>
26 ```
27
28 **Parameters**
@@ -30,11 +30,11 @@ async delete(remotePath: string, options?: { mountId?: string }): Promise<{ moun
30 | Name | Type | Description |
31 |------|------|-------------|
32 | `remotePath` | `string` | The path of the file or directory to delete on the mount. |
33 -| `options?` | `object` | Optional configuration for the delete operation. |
33 +| `options?` | `ToolRouterSessionFilesMountDeleteOptions` | Optional configuration for the delete operation. |
34
35 **Returns**
36
37 -`Promise<...>` — Confirmation of deletion (implementation-specific).
37 +`Promise<FileDeleteResponse>` — Confirmation of deletion (implementation-specific).
38
39 **Example**
40
@@ -60,7 +60,7 @@ Retrieves a file stored in the session's virtual filesystem (e.g., one produced
60 by a tool or previously uploaded) and saves it to the specified local path.
61
62 ```typescript
63 -async download(filePath: string, options?: { mountId?: string }): Promise<RemoteFile>
63 +async download(filePath: string, options?: ToolRouterSessionFilesMountDownloadOptions): Promise<RemoteFile>
64 ```
65
66 **Parameters**
@@ -68,7 +68,7 @@ async download(filePath: string, options?: { mountId?: string }): Promise<Remote
68 | Name | Type | Description |
69 |------|------|-------------|
70 | `filePath` | `string` | The path of the file on the mount to download, or the local path where the file should be saved (implementation-specific). |
71 -| `options?` | `object` | Optional configuration for the download. |
71 +| `options?` | `ToolRouterSessionFilesMountDownloadOptions` | Optional configuration for the download. |
72
73 **Returns**
74
@@ -99,18 +99,18 @@ The path is relative to the mount root (e.g., `"/"` for root, `"/documents"` for
99 Supports cursor-based pagination via `cursor` and `limit` options.
100
101 ```typescript
102 -async list(options?: { cursor?: string; limit?: number; mountId?: string; path?: string }): Promise<...>
102 +async list(options?: ToolRouterSessionFilesMountListOptions): Promise<FileListResponse>
103 ```
104
105 **Parameters**
106
107 | Name | Type | Description |
108 |------|------|-------------|
109 -| `options?` | `object` | Optional configuration for the list operation. |
109 +| `options?` | `ToolRouterSessionFilesMountListOptions` | Optional configuration for the list operation. |
110
111 **Returns**
112
113 -`Promise<...>` — List of files with nextCursor for pagination.
113 +`Promise<FileListResponse>` — List of files with nextCursor for pagination.
114
115 **Example**
116
@@ -137,15 +137,15 @@ Accepts a file path (local or URL), a native File object, or a raw buffer.
137 The file is stored in the virtual filesystem associated with the tool router session.
138
139 ```typescript
140 -async upload(input: string | File | ArrayBuffer | Uint8Array, options?: { mimetype?: string; mountId?: string; remotePath?: string }): Promise<RemoteFile>
140 +async upload(input: string | File | ArrayBuffer | Uint8Array, options?: ToolRouterSessionFilesMountUploadOptions): Promise<RemoteFile>
141 ```
142
143 **Parameters**
144
145 | Name | Type | Description |
146 |------|------|-------------|
147 -| `input` | `string | File | ArrayBuffer | Uint8Array` | File path (string), native File, or raw buffer (ArrayBuffer | Uint8Array). |
148 -| `options?` | `object` | Optional configuration. When passing a buffer, remotePath is required. |
147 +| `input` | `string \| File \| ArrayBuffer \| Uint8Array` | File path (string), native File, or raw buffer (ArrayBuffer | Uint8Array). |
148 +| `options?` | `ToolRouterSessionFilesMountUploadOptions` | Optional configuration. When passing a buffer, remotePath is required. |
149
150 **Returns**
151
docs/content/reference/sdk-reference/typescript/tool-router-session.mdx
+25 -18
@@ -18,7 +18,7 @@ const result = await composio.toolRouterSession.list();
18 |------|------|
19 | `configVersion` | `number` |
20 | `experimental` | `SessionExperimental` |
21 -| `mcp` | `object` |
21 +| `mcp` | `\{ headers?: Record<string, string>; type: 'http' \| 'sse'; url: string \}` |
22 | `preload` | `Preload` |
23 | `sessionId` | `string` |
24 | `warnings` | `Warning[]` |
@@ -42,7 +42,7 @@ Experimental — shape may change in future releases.
42 at the SDK boundary.
43
44 ```typescript
45 -async authorize(toolkit: string, options?: object): Promise<ConnectionRequest>
45 +async authorize(toolkit: string, options?: { callbackUrl?: string; alias?: string; experimental?: { accountType?: ConnectedAccountType; aclConfigForShared?: ConnectedAccountAclConfig; }; }, requestOptions?: ComposioRequestOptions): Promise<ConnectionRequest>
46 ```
47
48 **Parameters**
@@ -50,7 +50,8 @@ async authorize(toolkit: string, options?: object): Promise<ConnectionRequest>
50 | Name | Type |
51 |------|------|
52 | `toolkit` | `string` |
53 -| `options?` | `object` |
53 +| `options?` | `\{ callbackUrl?: string; alias?: string; experimental?: \{ accountType?: ConnectedAccountType; aclConfigForShared?: ConnectedAccountAclConfig; \}; \}` |
54 +| `requestOptions?` | `ComposioRequestOptions` |
55
56 **Returns**
57
@@ -86,7 +87,7 @@ customTools(options?: { toolkit?: string }): RegisteredCustomTool[]
87
88 | Name | Type |
89 |------|------|
89 -| `options?` | `object` |
90 +| `options?` | `\{ toolkit?: string \}` |
91
92 **Returns**
93
@@ -103,7 +104,7 @@ full slug (e.g. "LOCAL_GREP"). Custom tools are executed in-process;
104 remote tools are sent to the Composio backend.
105
106 ```typescript
106 -async execute(toolSlug: string, arguments_?: Record<string, unknown>, options?: ToolRouterSessionExecuteOptions): Promise<{ data: Record<string, unknown>; error: string | null; logId: string }>
107 +async execute(toolSlug: string, arguments_?: Record<string, unknown>, options?: ToolRouterSessionExecuteOptions, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionExecuteResponse>
108 ```
109
110 **Parameters**
@@ -113,10 +114,11 @@ async execute(toolSlug: string, arguments_?: Record<string, unknown>, options?:
114 | `toolSlug` | `string` | The tool slug to execute |
115 | `arguments_?` | `Record<string, unknown>` | Optional tool arguments |
116 | `options?` | `ToolRouterSessionExecuteOptions` | Optional execution options |
117 +| `requestOptions?` | `ComposioRequestOptions` | |
118
119 **Returns**
120
119 -`Promise<...>` — The tool execution result
121 +`Promise<ToolRouterSessionExecuteResponse>` — The tool execution result
122
123 ---
124
@@ -126,14 +128,15 @@ Proxy an API call through Composio's auth layer using the session's connected ac
128 The backend resolves the connected account from the toolkit within the session.
129
130 ```typescript
129 -async proxyExecute(params: object): Promise<ToolRouterSessionProxyExecuteResponse>
131 +async proxyExecute(params: SessionProxyExecuteParams, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionProxyExecuteResponse>
132 ```
133
134 **Parameters**
135
136 | Name | Type | Description |
137 |------|------|-------------|
136 -| `params` | `object` | Proxy request parameters (toolkit, endpoint, method, body, headers/query params) |
138 +| `params` | `SessionProxyExecuteParams` | Proxy request parameters (toolkit, endpoint, method, body, headers/query params) |
139 +| `requestOptions?` | `ComposioRequestOptions` | |
140
141 **Returns**
142
@@ -147,18 +150,19 @@ Search for tools by semantic use case.
150 Returns relevant tools for the given query with schemas and guidance.
151
152 ```typescript
150 -async search(params: { query: string; toolkits?: string[] }): Promise<...>
153 +async search(params: { query: string; toolkits?: string[]; }, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionSearchResponse>
154 ```
155
156 **Parameters**
157
158 | Name | Type |
159 |------|------|
157 -| `params` | `object` |
160 +| `params` | `\{ query: string; toolkits?: string[]; \}` |
161 +| `requestOptions?` | `ComposioRequestOptions` |
162
163 **Returns**
164
161 -`Promise<...>`
165 +`Promise<ToolRouterSessionSearchResponse>`
166
167 ---
168
@@ -168,18 +172,19 @@ Query the connection state of toolkits in the session.
172 Supports pagination and filtering by toolkit slugs.
173
174 ```typescript
171 -async toolkits(options?: { cursor?: string; isConnected?: boolean; limit?: number; search?: string; toolkits?: string[] }): Promise<...>
175 +async toolkits(options?: ToolRouterToolkitsOptions, requestOptions?: ComposioRequestOptions): Promise<{ cursor: string | undefined; items: { connection?: { authConfig?: ... | ...; connectedAccount?: { id: ...; status: ... }; isActive: boolean }; isNoAuth: boolean; logo?: string; name: string; slug: string }[]; totalPages: number }>
176 ```
177
178 **Parameters**
179
180 | Name | Type |
181 |------|------|
178 -| `options?` | `object` |
182 +| `options?` | `ToolRouterToolkitsOptions` |
183 +| `requestOptions?` | `ComposioRequestOptions` |
184
185 **Returns**
186
182 -`Promise<...>`
187 +`Promise<\{ cursor: string \| undefined; items: \{ connection?: \{ authConfig?: ... \| ...; connectedAccount?: \{ id: ...; status: ... \}; isActive: boolean \}; isNoAuth: boolean; logo?: string; name: string; slug: string \}[]; totalPages: number \}>`
188
189 ---
190
@@ -192,7 +197,7 @@ When custom tools are bound to the session, execution of COMPOSIO_MULTI_EXECUTE_
197 is intercepted: local tools are executed in-process, remote tools are sent to the backend.
198
199 ```typescript
195 -async tools(modifiers?: SessionMetaToolOptions): Promise<ReturnType>
200 +async tools(modifiers?: SessionMetaToolOptions, requestOptions?: ComposioRequestOptions): Promise<ReturnType<TProvider['wrapTools']>>
201 ```
202
203 **Parameters**
@@ -200,10 +205,11 @@ async tools(modifiers?: SessionMetaToolOptions): Promise<ReturnType>
205 | Name | Type |
206 |------|------|
207 | `modifiers?` | `SessionMetaToolOptions` |
208 +| `requestOptions?` | `ComposioRequestOptions` |
209
210 **Returns**
211
206 -`Promise<ReturnType>`
212 +`Promise<ReturnType<TProvider['wrapTools']>>`
213
214 ---
215
@@ -214,14 +220,15 @@ Only the fields provided will be changed; omitted fields are preserved.
220 Mutates this session's `configVersion`, `preload`, and `warnings` in-place.
221
222 ```typescript
217 -async update(config: object): Promise<void>
223 +async update(config: ToolRouterUpdateSessionConfig, requestOptions?: ComposioRequestOptions): Promise<void>
224 ```
225
226 **Parameters**
227
228 | Name | Type |
229 |------|------|
224 -| `config` | `object` |
230 +| `config` | `ToolRouterUpdateSessionConfig` |
231 +| `requestOptions?` | `ComposioRequestOptions` |
232
233 **Returns**
234
docs/content/reference/sdk-reference/typescript/toolkits.mdx
+23 -14
@@ -20,7 +20,7 @@ Authorizes a user to use a toolkit.
20 This method will create an auth config if one doesn't exist and initiate a connection request.
21
22 ```typescript
23 -async authorize(userId: string, toolkitSlug: string, authConfigId?: string): Promise<ConnectionRequest>
23 +async authorize(userId: string, toolkitSlug: string, authConfigId?: string, requestOptions?: ComposioRequestOptions): Promise<ConnectionRequest>
24 ```
25
26 **Parameters**
@@ -30,6 +30,7 @@ async authorize(userId: string, toolkitSlug: string, authConfigId?: string): Pro
30 | `userId` | `string` | The user id of the user to authorize |
31 | `toolkitSlug` | `string` | The slug of the toolkit to authorize |
32 | `authConfigId?` | `string` | |
33 +| `requestOptions?` | `ComposioRequestOptions` | |
34
35 **Returns**
36
@@ -50,7 +51,7 @@ Retrieves a specific toolkit by its slug identifier.
51 **Overload 1**
52
53 ```typescript
53 -async get(slug: string): Promise<...>
54 +async get(slug: string, requestOptions?: ComposioRequestOptions): Promise<ToolkitRetrieveResponse>
55 ```
56
57 **Parameters**
@@ -58,26 +59,28 @@ async get(slug: string): Promise<...>
59 | Name | Type | Description |
60 |------|------|-------------|
61 | `slug` | `string` | The unique slug identifier of the toolkit to retrieve |
62 +| `requestOptions?` | `ComposioRequestOptions` | |
63
64 **Returns**
65
64 -`Promise<...>` — The toolkit object with detailed information
66 +`Promise<ToolkitRetrieveResponse>` — The toolkit object with detailed information
67
68 **Overload 2**
69
70 ```typescript
69 -async get(query?: object): Promise<...>
71 +async get(query?: ToolkitListParams, requestOptions?: ComposioRequestOptions): Promise<ToolKitListResponse>
72 ```
73
74 **Parameters**
75
76 | Name | Type | Description |
77 |------|------|-------------|
76 -| `query?` | `object` | The query parameters to filter toolkits |
78 +| `query?` | `ToolkitListParams` | The query parameters to filter toolkits |
79 +| `requestOptions?` | `ComposioRequestOptions` | |
80
81 **Returns**
82
80 -`Promise<...>` — A paginated list of toolkits matching the query criteria
83 +`Promise<ToolKitListResponse>` — A paginated list of toolkits matching the query criteria
84
85 **Example**
86
@@ -95,7 +98,7 @@ console.log(githubToolkit.authConfigDetails); // Authentication configuration de
98 Retrieves the fields required for creating an auth config for a toolkit.
99
100 ```typescript
98 -async getAuthConfigCreationFields(toolkitSlug: string, authScheme: AuthSchemeType, options: { requiredOnly?: boolean }): Promise<...>
101 +async getAuthConfigCreationFields(toolkitSlug: string, authScheme: AuthSchemeType, options: { requiredOnly?: boolean }): Promise<ToolkitAuthFieldsResponse>
102 ```
103
104 **Parameters**
@@ -104,11 +107,11 @@ async getAuthConfigCreationFields(toolkitSlug: string, authScheme: AuthSchemeTyp
107 |------|------|-------------|
108 | `toolkitSlug` | `string` | The slug of the toolkit to retrieve the fields for |
109 | `authScheme` | `AuthSchemeType` | The auth scheme to retrieve the fields for |
107 -| `options` | `object` | |
110 +| `options` | `\{ requiredOnly?: boolean \}` | |
111
112 **Returns**
113
111 -`Promise<...>` — The fields required for creating an auth config
114 +`Promise<ToolkitAuthFieldsResponse>` — The fields required for creating an auth config
115
116 ---
117
@@ -117,7 +120,7 @@ async getAuthConfigCreationFields(toolkitSlug: string, authScheme: AuthSchemeTyp
120 Retrieves the fields required for initiating a connected account for a toolkit.
121
122 ```typescript
120 -async getConnectedAccountInitiationFields(toolkitSlug: string, authScheme: AuthSchemeType, options: { requiredOnly?: boolean }): Promise<...>
123 +async getConnectedAccountInitiationFields(toolkitSlug: string, authScheme: AuthSchemeType, options: { requiredOnly?: boolean }): Promise<ToolkitAuthFieldsResponse>
124 ```
125
126 **Parameters**
@@ -126,11 +129,11 @@ async getConnectedAccountInitiationFields(toolkitSlug: string, authScheme: AuthS
129 |------|------|-------------|
130 | `toolkitSlug` | `string` | The slug of the toolkit to retrieve the fields for |
131 | `authScheme` | `AuthSchemeType` | The auth scheme to retrieve the fields for |
129 -| `options` | `object` | |
132 +| `options` | `\{ requiredOnly?: boolean \}` | |
133
134 **Returns**
135
133 -`Promise<...>` — The fields required for initiating a connected account
136 +`Promise<ToolkitAuthFieldsResponse>` — The fields required for initiating a connected account
137
138 ---
139
@@ -142,12 +145,18 @@ This method fetches the complete list of categories from the Composio API
145 and transforms the response to use camelCase property naming.
146
147 ```typescript
145 -async listCategories(): Promise<...>
148 +async listCategories(requestOptions?: ComposioRequestOptions): Promise<ToolkitRetrieveCategoriesResponse>
149 ```
150
151 +**Parameters**
152 +
153 +| Name | Type |
154 +|------|------|
155 +| `requestOptions?` | `ComposioRequestOptions` |
156 +
157 **Returns**
158
150 -`Promise<...>` — The list of toolkit categories
159 +`Promise<ToolkitRetrieveCategoriesResponse>` — The list of toolkit categories
160
161 **Example**
162
docs/content/reference/sdk-reference/typescript/tools.mdx
+46 -38
@@ -26,7 +26,7 @@ the execution will throw a `ComposioToolVersionRequiredError` unless `dangerousl
26 This helps prevent unexpected behavior when new toolkit versions are released.
27
28 ```typescript
29 -async execute(slug: string, body: object, modifiers?: ExecuteToolModifiers): Promise<...>
29 +async execute(slug: string, body: ToolExecuteParams, options?: ExecuteToolModifiers & ComposioRequestOptions): Promise<ToolExecuteResponse>
30 ```
31
32 **Parameters**
@@ -34,12 +34,12 @@ async execute(slug: string, body: object, modifiers?: ExecuteToolModifiers): Pro
34 | Name | Type | Description |
35 |------|------|-------------|
36 | `slug` | `string` | The slug/ID of the tool to be executed |
37 -| `body` | `object` | The parameters to be passed to the tool |
38 -| `modifiers?` | `ExecuteToolModifiers` | Optional modifiers to transform the request or response |
37 +| `body` | `ToolExecuteParams` | The parameters to be passed to the tool |
38 +| `options?` | `ExecuteToolModifiers & ComposioRequestOptions` | Optional modifiers and request options |
39
40 **Returns**
41
42 -`Promise<...>` — - The response from the tool execution
42 +`Promise<ToolExecuteResponse>` — The response from the tool execution
43
44 **Example**
45
@@ -85,6 +85,14 @@ const result = await composio.tools.execute('GITHUB_GET_ISSUES', {
85 });
86 ```
87
88 +```typescript
89 +const result = await composio.tools.execute('HACKERNEWS_GET_FRONTPAGE', {
90 + userId: 'default',
91 + arguments: {},
92 + dangerouslySkipVersionCheck: true,
93 +}, { signal: AbortSignal.timeout(5_000) });
94 +```
95 +
96 ---
97
98 ### executeSessionTool()
@@ -92,7 +100,7 @@ const result = await composio.tools.execute('GITHUB_GET_ISSUES', {
100 Executes a tool based on a tool router session.
101
102 ```typescript
95 -async executeSessionTool(toolSlug: string, body: { arguments?: Record<string, unknown>; sessionId: string }, modifiers?: SessionExecuteMetaModifiers, tool?: object, options?: ToolRouterSessionExecuteOptions): Promise<...>
103 +async executeSessionTool(toolSlug: string, body: ToolExecuteMetaParams, modifiers?: SessionExecuteMetaModifiers, tool?: Tool, options?: ToolRouterSessionExecuteOptions, requestOptions?: ComposioRequestOptions): Promise<ToolExecuteResponse>
104 ```
105
106 **Parameters**
@@ -100,14 +108,15 @@ async executeSessionTool(toolSlug: string, body: { arguments?: Record<string, un
108 | Name | Type | Description |
109 |------|------|-------------|
110 | `toolSlug` | `string` | The slug of the tool to execute |
103 -| `body` | `object` | The execution parameters |
111 +| `body` | `ToolExecuteMetaParams` | The execution parameters |
112 | `modifiers?` | `SessionExecuteMetaModifiers` | The modifiers to apply to the tool |
105 -| `tool?` | `object` | Optional tool schema used to resolve toolkit metadata for modifiers |
113 +| `tool?` | `Tool` | Optional tool schema used to resolve toolkit metadata for modifiers |
114 | `options?` | `ToolRouterSessionExecuteOptions` | |
115 +| `requestOptions?` | `ComposioRequestOptions` | |
116
117 **Returns**
118
110 -`Promise<...>` — The response from the tool execution
119 +`Promise<ToolExecuteResponse>` — The response from the tool execution
120
121 ---
122
@@ -119,7 +128,7 @@ This method fetches the tools from the Composio API and wraps them using the pro
128 **Overload 1**
129
130 ```typescript
122 -async get(userId: string, filters: ToolListParams, options?: ProviderOptions): Promise<ReturnType>
131 +async get(userId: string, filters: ToolListParams, options?: ProviderOptions & ComposioRequestOptions): Promise<ReturnType<T['wrapTools']>>
132 ```
133
134 **Parameters**
@@ -128,16 +137,16 @@ async get(userId: string, filters: ToolListParams, options?: ProviderOptions): P
137 |------|------|-------------|
138 | `userId` | `string` | The user id to get the tools for |
139 | `filters` | `ToolListParams` | The filters to apply when fetching tools |
131 -| `options?` | `ProviderOptions` | Optional provider options including modifiers |
140 +| `options?` | `ProviderOptions & ComposioRequestOptions` | Provider options, modifiers, and/or AbortSignal |
141
142 **Returns**
143
135 -`Promise<ReturnType>` — The wrapped tools collection
144 +`Promise<ReturnType<T['wrapTools']>>` — The wrapped tools collection
145
146 **Overload 2**
147
148 ```typescript
140 -async get(userId: string, slug: string, options?: ProviderOptions): Promise<ReturnType>
149 +async get(userId: string, slug: string, options?: ProviderOptions & ComposioRequestOptions): Promise<ReturnType<T['wrapTools']>>
150 ```
151
152 **Parameters**
@@ -146,11 +155,11 @@ async get(userId: string, slug: string, options?: ProviderOptions): Promise<Retu
155 |------|------|-------------|
156 | `userId` | `string` | The user id to get the tool for |
157 | `slug` | `string` | The slug of the tool to fetch |
149 -| `options?` | `ProviderOptions` | Optional provider options including modifiers |
158 +| `options?` | `ProviderOptions & ComposioRequestOptions` | Optional provider options including modifiers and signal |
159
160 **Returns**
161
153 -`Promise<ReturnType>` — The wrapped tool
162 +`Promise<ReturnType<T['wrapTools']>>` — The wrapped tool
163
164 **Example**
165
@@ -161,22 +170,10 @@ const tools = await composio.tools.get('default', {
170 limit: 10
171 });
172
164 -// Get tools with search
165 -const searchTools = await composio.tools.get('default', {
166 - search: 'user',
167 - limit: 10
168 -});
169 -
170 -// Get a specific tool by slug
171 -const hackerNewsUserTool = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
172 -
173 -// Get a tool with schema modifications
174 -const tool = await composio.tools.get('default', 'GITHUB_GET_REPOS', {
175 - modifySchema: (toolSlug, toolkitSlug, schema) => {
176 - // Customize the tool schema
177 - return {...schema, description: 'Custom description'};
178 - }
179 -});
173 +// Timeout a slow search after 5s
174 +const emailTools = await composio.tools.get('default', {
175 + search: 'send email',
176 +}, { signal: AbortSignal.timeout(5_000) });
177 ```
178
179 ---
@@ -188,7 +185,7 @@ Fetches the input parameters for a given tool.
185 This method is used to get the input parameters for a tool before executing it.
186
187 ```typescript
191 -async getInput(slug: string, body: ToolGetInputParams): Promise<ToolGetInputResponse>
188 +async getInput(slug: string, body: ToolGetInputParams, requestOptions?: ComposioRequestOptions): Promise<ToolGetInputResponse>
189 ```
190
191 **Parameters**
@@ -197,6 +194,7 @@ async getInput(slug: string, body: ToolGetInputParams): Promise<ToolGetInputResp
194 |------|------|-------------|
195 | `slug` | `string` | The ID of the tool to find input for |
196 | `body` | `ToolGetInputParams` | The parameters to be passed to the tool |
197 +| `requestOptions?` | `ComposioRequestOptions` | |
198
199 **Returns**
200
@@ -226,7 +224,7 @@ Tool Router session, then use `session.tools()`, `session.customTools()`, or
224 `session.execute()`.
225
226 ```typescript
229 -async getRawComposioToolBySlug(slug: string, options?: ToolRetrievalOptions): Promise<...>
227 +async getRawComposioToolBySlug(slug: string, options?: ToolRetrievalOptions, requestOptions?: ComposioRequestOptions): Promise<Tool>
228 ```
229
230 **Parameters**
@@ -235,10 +233,11 @@ async getRawComposioToolBySlug(slug: string, options?: ToolRetrievalOptions): Pr
233 |------|------|-------------|
234 | `slug` | `string` | The unique identifier of the tool (e.g., 'GITHUB_GET_REPOS') |
235 | `options?` | `ToolRetrievalOptions` | Optional configuration for tool retrieval |
236 +| `requestOptions?` | `ComposioRequestOptions` | |
237
238 **Returns**
239
241 -`Promise<...>` — The requested tool with its complete schema and metadata
240 +`Promise<Tool>` — The requested tool with its complete schema and metadata
241
242 **Example**
243
@@ -289,7 +288,7 @@ them when creating or reusing a Tool Router session, then use `session.tools()`,
288 It provides access to the underlying tool data without provider-specific wrapping.
289
290 ```typescript
292 -async getRawComposioTools(query: ToolListParams, options?: SchemaModifierOptions): Promise<ToolList>
291 +async getRawComposioTools(query: ToolListParams, options?: SchemaModifierOptions, requestOptions?: ComposioRequestOptions): Promise<ToolList>
292 ```
293
294 **Parameters**
@@ -298,6 +297,7 @@ async getRawComposioTools(query: ToolListParams, options?: SchemaModifierOptions
297 |------|------|-------------|
298 | `query` | `ToolListParams` | Query parameters to filter the tools (required) |
299 | `options?` | `SchemaModifierOptions` | Optional configuration for tool retrieval |
300 +| `requestOptions?` | `ComposioRequestOptions` | |
301
302 **Returns**
303
@@ -358,7 +358,7 @@ This includes helper/meta tools plus any tools preloaded into the session.
358 It provides access to the underlying tool data without provider-specific wrapping.
359
360 ```typescript
361 -async getRawToolRouterSessionTools(sessionId: string, options?: SchemaModifierOptions): Promise<ToolList>
361 +async getRawToolRouterSessionTools(sessionId: string, options?: SchemaModifierOptions, requestOptions?: ComposioRequestOptions): Promise<ToolList>
362 ```
363
364 **Parameters**
@@ -367,6 +367,7 @@ async getRawToolRouterSessionTools(sessionId: string, options?: SchemaModifierOp
367 |------|------|-------------|
368 | `sessionId` | `string` | \{string\} The session id to get tools for |
369 | `options?` | `SchemaModifierOptions` | \{SchemaModifierOptions\} Optional configuration for tool retrieval |
370 +| `requestOptions?` | `ComposioRequestOptions` | |
371
372 **Returns**
373
@@ -389,9 +390,15 @@ This method is mostly used by the CLI to get the list of tools.
390 No filtering is done on the tools, the list is cached in the backend, no further optimization is required.
391
392 ```typescript
392 -async getToolsEnum(): Promise<ToolRetrieveEnumResponse>
393 +async getToolsEnum(requestOptions?: ComposioRequestOptions): Promise<ToolRetrieveEnumResponse>
394 ```
395
396 +**Parameters**
397 +
398 +| Name | Type |
399 +|------|------|
400 +| `requestOptions?` | `ComposioRequestOptions` |
401 +
402 **Returns**
403
404 `Promise<ToolRetrieveEnumResponse>` — The complete list of all available tools with their metadata
@@ -414,14 +421,15 @@ This method allows sending custom requests to a specific toolkit or integration
421 when you need more flexibility than the standard tool execution methods provide.
422
423 ```typescript
417 -async proxyExecute(body: object): Promise<ToolProxyResponse>
424 +async proxyExecute(body: ToolProxyParams, requestOptions?: ComposioRequestOptions): Promise<ToolProxyResponse>
425 ```
426
427 **Parameters**
428
429 | Name | Type | Description |
430 |------|------|-------------|
424 -| `body` | `object` | The parameters for the proxy request including toolkit slug and custom data |
431 +| `body` | `ToolProxyParams` | The parameters for the proxy request including toolkit slug and custom data |
432 +| `requestOptions?` | `ComposioRequestOptions` | |
433
434 **Returns**
435
docs/content/reference/sdk-reference/typescript/triggers.mdx
+38 -24
@@ -20,7 +20,7 @@ Create a new trigger instance for a user
20 If the connected account id is not provided, the first connected account for the user and toolkit will be used
21
22 ```typescript
23 -async create(userId: string, slug: string, body?: { connectedAccountId?: string; triggerConfig?: Record<string, unknown> }): Promise<{ triggerId: string }>
23 +async create(userId: string, slug: string, body?: TriggerInstanceUpsertParams, requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceUpsertResponse>
24 ```
25
26 **Parameters**
@@ -29,11 +29,12 @@ async create(userId: string, slug: string, body?: { connectedAccountId?: string;
29 |------|------|-------------|
30 | `userId` | `string` | The user id of the trigger instance |
31 | `slug` | `string` | The slug of the trigger instance |
32 -| `body?` | `object` | The parameters to create the trigger instance |
32 +| `body?` | `TriggerInstanceUpsertParams` | The parameters to create the trigger instance |
33 +| `requestOptions?` | `ComposioRequestOptions` | |
34
35 **Returns**
36
36 -`Promise<...>` — The created trigger instance
37 +`Promise<TriggerInstanceUpsertResponse>` — The created trigger instance
38
39 ---
40
@@ -42,7 +43,7 @@ async create(userId: string, slug: string, body?: { connectedAccountId?: string;
43 Delete a trigger instance
44
45 ```typescript
45 -async delete(triggerId: string): Promise<{ triggerId: string }>
46 +async delete(triggerId: string, requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceManageDeleteResponse>
47 ```
48
49 **Parameters**
@@ -50,10 +51,11 @@ async delete(triggerId: string): Promise<{ triggerId: string }>
51 | Name | Type | Description |
52 |------|------|-------------|
53 | `triggerId` | `string` | The slug of the trigger instance |
54 +| `requestOptions?` | `ComposioRequestOptions` | |
55
56 **Returns**
57
56 -`Promise<...>`
58 +`Promise<TriggerInstanceManageDeleteResponse>`
59
60 ---
61
@@ -62,7 +64,7 @@ async delete(triggerId: string): Promise<{ triggerId: string }>
64 Disable a trigger instance
65
66 ```typescript
65 -async disable(triggerId: string): Promise<ManageUpdateResponse>
67 +async disable(triggerId: string, requestOptions?: ComposioRequestOptions): Promise<ManageUpdateResponse>
68 ```
69
70 **Parameters**
@@ -70,6 +72,7 @@ async disable(triggerId: string): Promise<ManageUpdateResponse>
72 | Name | Type | Description |
73 |------|------|-------------|
74 | `triggerId` | `string` | The id of the trigger instance |
75 +| `requestOptions?` | `ComposioRequestOptions` | |
76
77 **Returns**
78
@@ -82,7 +85,7 @@ async disable(triggerId: string): Promise<ManageUpdateResponse>
85 Enable a trigger instance
86
87 ```typescript
85 -async enable(triggerId: string): Promise<ManageUpdateResponse>
88 +async enable(triggerId: string, requestOptions?: ComposioRequestOptions): Promise<ManageUpdateResponse>
89 ```
90
91 **Parameters**
@@ -90,6 +93,7 @@ async enable(triggerId: string): Promise<ManageUpdateResponse>
93 | Name | Type | Description |
94 |------|------|-------------|
95 | `triggerId` | `string` | The id of the trigger instance |
96 +| `requestOptions?` | `ComposioRequestOptions` | |
97
98 **Returns**
99
@@ -103,7 +107,7 @@ Retrieve a trigger type by its slug for the provided version of the app
107 Use the global toolkit versions param when initializing composio to pass a toolkitversion
108
109 ```typescript
106 -async getType(slug: string): Promise<...>
110 +async getType(slug: string, requestOptions?: ComposioRequestOptions): Promise<TriggersTypeRetrieveResponse>
111 ```
112
113 **Parameters**
@@ -111,10 +115,11 @@ async getType(slug: string): Promise<...>
115 | Name | Type | Description |
116 |------|------|-------------|
117 | `slug` | `string` | The slug of the trigger type |
118 +| `requestOptions?` | `ComposioRequestOptions` | |
119
120 **Returns**
121
117 -`Promise<...>` — The trigger type object
122 +`Promise<TriggersTypeRetrieveResponse>` — The trigger type object
123
124 ---
125
@@ -123,18 +128,19 @@ async getType(slug: string): Promise<...>
128 Fetch list of all the active triggers
129
130 ```typescript
126 -async listActive(query?: object): Promise<...>
131 +async listActive(query?: TriggerInstanceListActiveParams, requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceListActiveResponse>
132 ```
133
134 **Parameters**
135
136 | Name | Type | Description |
137 |------|------|-------------|
133 -| `query?` | `object` | The query parameters to filter the trigger instances |
138 +| `query?` | `TriggerInstanceListActiveParams` | The query parameters to filter the trigger instances |
139 +| `requestOptions?` | `ComposioRequestOptions` | |
140
141 **Returns**
142
137 -`Promise<...>` — List of trigger instances
143 +`Promise<TriggerInstanceListActiveResponse>` — List of trigger instances
144
145 **Example**
146
@@ -154,9 +160,15 @@ Fetches the list of all the available trigger enums
160 This method is used by the CLI where filters are not required.
161
162 ```typescript
157 -async listEnum(): Promise<TriggersTypeRetrieveEnumResponse>
163 +async listEnum(requestOptions?: ComposioRequestOptions): Promise<TriggersTypeRetrieveEnumResponse>
164 ```
165
166 +**Parameters**
167 +
168 +| Name | Type |
169 +|------|------|
170 +| `requestOptions?` | `ComposioRequestOptions` |
171 +
172 **Returns**
173
174 `Promise<TriggersTypeRetrieveEnumResponse>`
@@ -168,18 +180,19 @@ async listEnum(): Promise<TriggersTypeRetrieveEnumResponse>
180 List all the trigger types
181
182 ```typescript
171 -async listTypes(query?: { cursor?: string; limit?: number | null; toolkits?: string[] | null }): Promise<...>
183 +async listTypes(query?: TriggersTypeListParams, requestOptions?: ComposioRequestOptions): Promise<TriggersTypeListResponse>
184 ```
185
186 **Parameters**
187
188 | Name | Type | Description |
189 |------|------|-------------|
178 -| `query?` | `object` | The query parameters to filter the trigger types |
190 +| `query?` | `TriggersTypeListParams` | The query parameters to filter the trigger types |
191 +| `requestOptions?` | `ComposioRequestOptions` | |
192
193 **Returns**
194
182 -`Promise<...>` — The list of trigger types
195 +`Promise<TriggersTypeListResponse>` — The list of trigger types
196
197 ---
198
@@ -188,15 +201,15 @@ async listTypes(query?: { cursor?: string; limit?: number | null; toolkits?: str
201 Subscribe to all the triggers
202
203 ```typescript
191 -async subscribe(fn: object, filters: object): Promise<void>
204 +async subscribe(fn: (_data: IncomingTriggerPayload) => void, filters: TriggerSubscribeParams): Promise<void>
205 ```
206
207 **Parameters**
208
209 | Name | Type | Description |
210 |------|------|-------------|
198 -| `fn` | `object` | The function to call when a trigger is received |
199 -| `filters` | `object` | The filters to apply to the triggers |
211 +| `fn` | `(_data: IncomingTriggerPayload) => void` | The function to call when a trigger is received |
212 +| `filters` | `TriggerSubscribeParams` | The filters to apply to the triggers |
213
214 **Returns**
215
@@ -241,7 +254,7 @@ await triggers.unsubscribe();
254 Update an existing trigger instance
255
256 ```typescript
244 -async update(triggerId: string, body: { status: 'enable' | 'disable' }): Promise<{ status: 'success' }>
257 +async update(triggerId: string, body: TriggerInstanceManageUpdateParams, requestOptions?: ComposioRequestOptions): Promise<TriggerInstanceManageUpdateResponse>
258 ```
259
260 **Parameters**
@@ -249,11 +262,12 @@ async update(triggerId: string, body: { status: 'enable' | 'disable' }): Promise
262 | Name | Type | Description |
263 |------|------|-------------|
264 | `triggerId` | `string` | The Id of the trigger instance |
252 -| `body` | `object` | The parameters to update the trigger instance |
265 +| `body` | `TriggerInstanceManageUpdateParams` | The parameters to update the trigger instance |
266 +| `requestOptions?` | `ComposioRequestOptions` | |
267
268 **Returns**
269
256 -`Promise<...>` — The updated trigger instance response
270 +`Promise<TriggerInstanceManageUpdateResponse>` — The updated trigger instance response
271
272 ---
273
@@ -269,14 +283,14 @@ The signature is computed as: `HMAC-SHA256(${webhookId}.${webhookTimestamp}.${pa
283 and is expected in the format: `v1,base64EncodedSignature`
284
285 ```typescript
272 -async verifyWebhook(params: object): Promise<VerifyWebhookResult>
286 +async verifyWebhook(params: VerifyWebhookParams): Promise<VerifyWebhookResult>
287 ```
288
289 **Parameters**
290
291 | Name | Type | Description |
292 |------|------|-------------|
279 -| `params` | `object` | The verification parameters |
293 +| `params` | `VerifyWebhookParams` | The verification parameters |
294
295 **Returns**
296
ts/packages/core/scripts/generate-docs.ts
+372 -27
@@ -7,10 +7,11 @@
7 * Run: pnpm --filter @composio/core generate:docs
8 */
9
10 +import { readFileSync } from 'fs';
11 import { mkdir, writeFile, rm, readdir, readFile } from 'fs/promises';
11 -import { join, dirname } from 'path';
12 +import { join, dirname, resolve } from 'path';
13 import { execSync } from 'child_process';
13 -import { fileURLToPath } from 'url';
14 +import { fileURLToPath, pathToFileURL } from 'url';
15
16 // Paths (relative to ts/packages/core)
17 const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
@@ -139,6 +140,7 @@ interface TypeDocSignature {
140 parameters?: TypeDocParameter[];
141 type?: TypeDocType;
142 typeParameter?: TypeDocTypeParameter[];
143 + sources?: Array<{ fileName: string; line: number }>;
144 }
145
146 interface TypeDocParameter {
@@ -214,6 +216,13 @@ interface ClassDoc {
216 source?: { file: string; line: number };
217 }
218
219 +interface SourceSignatureTypes {
220 + parameters: Map<string, string>;
221 + returnType?: string;
222 +}
223 +
224 +const sourceFileCache = new Map<string, string>();
225 +
226 function extractText(content?: Array<{ kind: string; text: string }>): string {
227 if (!content) return '';
228 return content
@@ -250,6 +259,326 @@ function extractTag(comment: TypeDocReflection['comment'] | undefined, tagName:
259 return comment.blockTags.filter(t => t.tag === tagName).map(t => extractText(t.content));
260 }
261
262 +function getSourceFileText(fileName: string): string | undefined {
263 + const filePath = join(PACKAGE_DIR, 'src', fileName);
264 + const cached = sourceFileCache.get(filePath);
265 + if (cached !== undefined) return cached;
266 +
267 + try {
268 + const text = readFileSync(filePath, 'utf-8');
269 + sourceFileCache.set(filePath, text);
270 + return text;
271 + } catch {
272 + return undefined;
273 + }
274 +}
275 +
276 +function getLineOffset(text: string, line: number): number {
277 + let offset = 0;
278 + for (let currentLine = 1; currentLine < line; currentLine++) {
279 + const nextLine = text.indexOf('\n', offset);
280 + if (nextLine === -1) return text.length;
281 + offset = nextLine + 1;
282 + }
283 + return offset;
284 +}
285 +
286 +function updateTypeDepth(
287 + char: string,
288 + depth: { angle: number; brace: number; bracket: number; paren: number }
289 +) {
290 + switch (char) {
291 + case '<':
292 + depth.angle++;
293 + break;
294 + case '>':
295 + depth.angle = Math.max(0, depth.angle - 1);
296 + break;
297 + case '{':
298 + depth.brace++;
299 + break;
300 + case '}':
301 + depth.brace = Math.max(0, depth.brace - 1);
302 + break;
303 + case '[':
304 + depth.bracket++;
305 + break;
306 + case ']':
307 + depth.bracket = Math.max(0, depth.bracket - 1);
308 + break;
309 + case '(':
310 + depth.paren++;
311 + break;
312 + case ')':
313 + depth.paren = Math.max(0, depth.paren - 1);
314 + break;
315 + }
316 +}
317 +
318 +function splitTopLevel(input: string, delimiter: string): string[] {
319 + const parts: string[] = [];
320 + const depth = { angle: 0, brace: 0, bracket: 0, paren: 0 };
321 + let quote: string | null = null;
322 + let start = 0;
323 +
324 + for (let i = 0; i < input.length; i++) {
325 + const char = input[i];
326 + const prev = input[i - 1];
327 +
328 + if (quote) {
329 + if (char === quote && prev !== '\\') {
330 + quote = null;
331 + }
332 + continue;
333 + }
334 +
335 + if (char === "'" || char === '"' || char === '`') {
336 + quote = char;
337 + continue;
338 + }
339 +
340 + updateTypeDepth(char, depth);
341 +
342 + if (
343 + char === delimiter &&
344 + depth.angle === 0 &&
345 + depth.brace === 0 &&
346 + depth.bracket === 0 &&
347 + depth.paren === 0
348 + ) {
349 + parts.push(input.slice(start, i).trim());
350 + start = i + 1;
351 + }
352 + }
353 +
354 + const finalPart = input.slice(start).trim();
355 + if (finalPart) {
356 + parts.push(finalPart);
357 + }
358 + return parts;
359 +}
360 +
361 +function findMatchingParen(text: string, openIndex: number): number {
362 + const depth = { angle: 0, brace: 0, bracket: 0, paren: 0 };
363 + let quote: string | null = null;
364 +
365 + for (let i = openIndex; i < text.length; i++) {
366 + const char = text[i];
367 + const prev = text[i - 1];
368 +
369 + if (quote) {
370 + if (char === quote && prev !== '\\') {
371 + quote = null;
372 + }
373 + continue;
374 + }
375 +
376 + if (char === "'" || char === '"' || char === '`') {
377 + quote = char;
378 + continue;
379 + }
380 +
381 + if (char === '(') {
382 + depth.paren++;
383 + } else if (char === ')') {
384 + depth.paren--;
385 + if (depth.paren === 0) return i;
386 + } else {
387 + updateTypeDepth(char, depth);
388 + }
389 + }
390 +
391 + return -1;
392 +}
393 +
394 +function findTopLevelChar(input: string, target: string): number {
395 + const depth = { angle: 0, brace: 0, bracket: 0, paren: 0 };
396 + let quote: string | null = null;
397 +
398 + for (let i = 0; i < input.length; i++) {
399 + const char = input[i];
400 + const prev = input[i - 1];
401 +
402 + if (quote) {
403 + if (char === quote && prev !== '\\') {
404 + quote = null;
405 + }
406 + continue;
407 + }
408 +
409 + if (char === "'" || char === '"' || char === '`') {
410 + quote = char;
411 + continue;
412 + }
413 +
414 + if (
415 + char === target &&
416 + !(target === '=' && input[i + 1] === '>') &&
417 + depth.angle === 0 &&
418 + depth.brace === 0 &&
419 + depth.bracket === 0 &&
420 + depth.paren === 0
421 + ) {
422 + return i;
423 + }
424 +
425 + updateTypeDepth(char, depth);
426 + }
427 +
428 + return -1;
429 +}
430 +
431 +function findReturnTypeColon(text: string, start: number): number {
432 + const depth = { angle: 0, brace: 0, bracket: 0, paren: 0 };
433 + let quote: string | null = null;
434 +
435 + for (let i = start; i < text.length; i++) {
436 + const char = text[i];
437 + const prev = text[i - 1];
438 +
439 + if (quote) {
440 + if (char === quote && prev !== '\\') {
441 + quote = null;
442 + }
443 + continue;
444 + }
445 +
446 + if (char === "'" || char === '"' || char === '`') {
447 + quote = char;
448 + continue;
449 + }
450 +
451 + const isTopLevel =
452 + depth.angle === 0 && depth.brace === 0 && depth.bracket === 0 && depth.paren === 0;
453 + if (isTopLevel) {
454 + if (char === ':') return i;
455 + if (char === '{' || char === ';') return -1;
456 + }
457 +
458 + updateTypeDepth(char, depth);
459 + }
460 +
461 + return -1;
462 +}
463 +
464 +function findSignatureEnd(text: string, start: number): number {
465 + const depth = { angle: 0, brace: 0, bracket: 0, paren: 0 };
466 + let quote: string | null = null;
467 +
468 + for (let i = start; i < text.length; i++) {
469 + const char = text[i];
470 + const prev = text[i - 1];
471 +
472 + if (quote) {
473 + if (char === quote && prev !== '\\') {
474 + quote = null;
475 + }
476 + continue;
477 + }
478 +
479 + if (char === "'" || char === '"' || char === '`') {
480 + quote = char;
481 + continue;
482 + }
483 +
484 + const isTopLevel =
485 + depth.angle === 0 && depth.brace === 0 && depth.bracket === 0 && depth.paren === 0;
486 + const startsInlineObjectType =
487 + char === '{' &&
488 + [':', '|', '&', '(', ',', '='].includes(previousNonWhitespace(text, i - 1) ?? '');
489 +
490 + if ((char === ';' || (char === '{' && !startsInlineObjectType)) && isTopLevel) {
491 + return i;
492 + }
493 +
494 + updateTypeDepth(char, depth);
495 + }
496 +
497 + return -1;
498 +}
499 +
500 +function previousNonWhitespace(text: string, index: number): string | undefined {
501 + for (let i = index; i >= 0; i--) {
502 + const char = text[i];
503 + if (!/\s/.test(char)) {
504 + return char;
505 + }
506 + }
507 + return undefined;
508 +}
509 +
510 +function normalizeSourceParamName(name: string): string | undefined {
511 + const normalized = name
512 + .trim()
513 + .replace(/^\.\.\./, '')
514 + .split(/\s+/)
515 + .pop()
516 + ?.replace(/\?$/, '');
517 +
518 + if (!normalized || normalized.startsWith('{') || normalized.startsWith('[')) {
519 + return undefined;
520 + }
521 + return normalized;
522 +}
523 +
524 +function parseSourceParameter(param: string): [string, string] | undefined {
525 + const colonIndex = findTopLevelChar(param, ':');
526 + if (colonIndex === -1) return undefined;
527 +
528 + const name = normalizeSourceParamName(param.slice(0, colonIndex));
529 + if (!name) return undefined;
530 +
531 + let type = param.slice(colonIndex + 1).trim();
532 + const defaultIndex = findTopLevelChar(type, '=');
533 + if (defaultIndex !== -1) {
534 + type = type.slice(0, defaultIndex).trim();
535 + }
536 + return [name, type];
537 +}
538 +
539 +export function parseSourceSignatureTypesAtLine(
540 + text: string,
541 + line: number
542 +): SourceSignatureTypes | undefined {
543 + const lineOffset = getLineOffset(text, line);
544 + const openParen = text.indexOf('(', lineOffset);
545 + if (openParen === -1) return undefined;
546 +
547 + const closeParen = findMatchingParen(text, openParen);
548 + if (closeParen === -1) return undefined;
549 +
550 + const parameters = new Map<string, string>();
551 + const paramsText = text.slice(openParen + 1, closeParen).trim();
552 + for (const param of splitTopLevel(paramsText, ',')) {
553 + const parsed = parseSourceParameter(param);
554 + if (parsed) {
555 + parameters.set(parsed[0], parsed[1]);
556 + }
557 + }
558 +
559 + const colonIndex = findReturnTypeColon(text, closeParen + 1);
560 + if (colonIndex === -1) return { parameters };
561 +
562 + const absoluteReturnStart = colonIndex + 1;
563 + const returnEnd = findSignatureEnd(text, absoluteReturnStart);
564 + const returnType =
565 + returnEnd === -1
566 + ? text.slice(absoluteReturnStart).trim()
567 + : text.slice(absoluteReturnStart, returnEnd).trim();
568 +
569 + return { parameters, returnType };
570 +}
571 +
572 +function getSourceSignatureTypes(signature: TypeDocSignature): SourceSignatureTypes | undefined {
573 + const source = signature.sources?.[0];
574 + if (!source) return undefined;
575 +
576 + const text = getSourceFileText(source.fileName);
577 + if (!text) return undefined;
578 +
579 + return parseSourceSignatureTypesAtLine(text, source.line);
580 +}
581 +
582 function formatYamlFrontmatterString(value: string): string {
583 return JSON.stringify(value);
584 }
@@ -331,10 +660,11 @@ function extractMethod(reflection: TypeDocReflection): MethodDoc | null {
660 }
661
662 const signatures = reflection.signatures.map(sig => {
663 + const sourceTypes = getSourceSignatureTypes(sig);
664 const parameters = (sig.parameters || []).map(param => ({
665 // Clean up ugly TypeScript internal names
666 name: param.name.startsWith('__') ? 'options' : param.name,
337 - type: formatType(param.type),
667 + type: sourceTypes?.parameters.get(param.name) ?? formatType(param.type),
668 required: !param.flags?.isOptional,
669 description: extractDescription(param.comment),
670 default: param.defaultValue,
@@ -342,7 +672,7 @@ function extractMethod(reflection: TypeDocReflection): MethodDoc | null {
672
673 return {
674 parameters,
345 - returnType: formatType(sig.type),
675 + returnType: sourceTypes?.returnType ?? formatType(sig.type),
676 returnDescription: extractTag(sig.comment, '@returns')[0],
677 };
678 });
@@ -357,7 +687,9 @@ function extractMethod(reflection: TypeDocReflection): MethodDoc | null {
687 description,
688 signatures,
689 examples,
360 - isAsync: formatType(primarySig.type).startsWith('Promise'),
690 + isAsync:
691 + signatures[0]?.returnType.startsWith('Promise') ??
692 + formatType(primarySig.type).startsWith('Promise'),
693 source: reflection.sources?.[0]
694 ? { file: reflection.sources[0].fileName, line: reflection.sources[0].line }
695 : undefined,
@@ -646,29 +978,36 @@ function cleanupGenericTypes(type: string): string {
978 }
979
980 // Escape type strings for safe use in MDX backtick code spans.
649 -// Escapes curly braces which MDX interprets as JSX expressions.
650 -function escapeTypeForMdx(type: string): string {
651 - return type.replace(/\{/g, '\\{').replace(/\}/g, '\\}');
981 +// Escapes backslashes first so later Markdown escapes cannot be neutralized.
982 +export function escapeTypeForMdx(type: string): string {
983 + return type
984 + .replace(/\\/g, '\\\\')
985 + .replace(/\{/g, '\\{')
986 + .replace(/\}/g, '\\}')
987 + .replace(/\|/g, '\\|');
988 +}
989 +
990 +function isInlineObjectType(type: string): boolean {
991 + return type.startsWith('{') || type.includes(': {');
992 }
993
654 -// Simplify complex types for table display (aggressive)
655 -function simplifyTypeForTable(type: string): string {
994 +// Simplify complex types for table display while preserving public object shapes.
995 +export function simplifyTypeForTable(type: string): string {
996 // First clean up internal generics
997 const cleaned = cleanupGenericTypes(type);
998
999 + if (isInlineObjectType(cleaned)) {
1000 + return cleaned;
1001 + }
1002 +
1003 // If type is too long or complex, simplify it
660 - if (cleaned.length > 80 || (cleaned.includes('{') && cleaned.includes('}'))) {
1004 + if (cleaned.length > 80) {
1005 // Extract just the outer type name if it's a generic
1006 const genericMatch = cleaned.match(/^([A-Za-z]+)<.*>$/);
1007 if (genericMatch) {
1008 return `${genericMatch[1]}<...>`;
1009 }
1010
667 - // For object types, just show 'object'
668 - if (cleaned.startsWith('{') || cleaned.includes(': {')) {
669 - return 'object';
670 - }
671 -
1011 // For function types, simplify
1012 if (cleaned.includes('=>')) {
1013 const returnMatch = cleaned.match(/=>\s*(.+)$/);
@@ -685,12 +1024,16 @@ function simplifyTypeForTable(type: string): string {
1024 }
1025
1026 // Simplify types for code block display (less aggressive, preserves structure)
688 -function simplifyTypeForSignature(type: string): string {
1027 +export function simplifyTypeForSignature(type: string): string {
1028 // First clean up internal generics
1029 const cleaned = cleanupGenericTypes(type);
1030
1031 + if (isInlineObjectType(cleaned)) {
1032 + return cleaned;
1033 + }
1034 +
1035 // Keep types under 100 chars as-is
693 - if (cleaned.length <= 100 && !cleaned.includes(': {')) {
1036 + if (cleaned.length <= 100) {
1037 return cleaned;
1038 }
1039
@@ -712,11 +1055,6 @@ function simplifyTypeForSignature(type: string): string {
1055 }
1056 }
1057
715 - // For inline object types in signatures
716 - if (cleaned.includes(': {') || (cleaned.startsWith('{') && cleaned.length > 60)) {
717 - return 'object';
718 - }
719 -
1058 // Truncate very long types
1059 if (cleaned.length > 100) {
1060 return cleaned.substring(0, 97) + '...';
@@ -897,7 +1235,14 @@ const result = await composio.tools.execute('GITHUB_GET_REPOS', {
1235 console.log(` Files generated: ${documented.length + 2}`); // +2 for index.mdx and meta.json
1236 }
1237
900 -main().catch(error => {
901 - console.error('Fatal error:', error);
902 - process.exit(1);
903 -});
1238 +function isDirectRun(): boolean {
1239 + const entrypoint = process.argv[1];
1240 + return Boolean(entrypoint && import.meta.url === pathToFileURL(resolve(entrypoint)).href);
1241 +}
1242 +
1243 +if (isDirectRun()) {
1244 + main().catch(error => {
1245 + console.error('Fatal error:', error);
1246 + process.exit(1);
1247 + });
1248 +}
ts/packages/core/src/models/Tools.ts
+3 -3
@@ -682,7 +682,7 @@ export class Tools<
682 * });
683 *
684 * // Timeout a slow search after 5s
685 - * const tools = await composio.tools.get('default', {
685 + * const emailTools = await composio.tools.get('default', {
686 * search: 'send email',
687 * }, { signal: AbortSignal.timeout(5_000) });
688 * ```
@@ -953,8 +953,8 @@ export class Tools<
953 * @param {string} [body.userId] - The user ID to execute the tool for
954 * @param {string} [body.connectedAccountId] - The connected account ID to use for authenticated tools
955 * @param {Record<string, unknown>} [body.arguments] - The arguments to pass to the tool
956 - * @param {ExecuteToolModifiers} [modifiers] - Optional modifiers to transform the request or response
957 - * @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
956 + * @param {ExecuteToolModifiers & ComposioRequestOptions} [options] - Optional modifiers and request options
957 + * @returns {Promise<ToolExecuteResponse>} The response from the tool execution
958 *
959 * @throws {ComposioConnectedAccountNotFoundError} If the connected account is not found
960 * @throws {ComposioToolNotFoundError} If the tool with the given slug is not found
ts/packages/core/test/scripts/generate-docs.test.ts new
+114
@@ -0,0 +1,114 @@
1 +import { describe, expect, it } from 'vitest';
2 +import {
3 + escapeTypeForMdx,
4 + parseSourceSignatureTypesAtLine,
5 + simplifyTypeForSignature,
6 + simplifyTypeForTable,
7 +} from '../../scripts/generate-docs';
8 +
9 +describe('generate-docs type rendering', () => {
10 + it('preserves inline object shapes in signatures', () => {
11 + const type =
12 + '{ cursor?: string; isComposioManaged?: boolean; limit?: number; toolkit?: string }';
13 +
14 + expect(simplifyTypeForSignature(type)).toBe(type);
15 + });
16 +
17 + it('preserves inline object shapes in parameter tables', () => {
18 + const type = '{ arguments?: Record<string, unknown>; sessionId: string }';
19 +
20 + expect(simplifyTypeForTable(type)).toBe(type);
21 + });
22 +
23 + it('preserves nested object shapes instead of collapsing them to object', () => {
24 + const type = '{ account?: { id?: string; label?: string }; timeout?: number }';
25 +
26 + expect(simplifyTypeForSignature(type)).toBe(type);
27 + expect(simplifyTypeForTable(type)).toBe(type);
28 + });
29 +
30 + it('escapes pipes and braces for MDX tables', () => {
31 + expect(escapeTypeForMdx("{ status: 'enable' | 'disable' }")).toBe(
32 + "\\{ status: 'enable' \\| 'disable' \\}"
33 + );
34 + });
35 +
36 + it('escapes existing backslashes before adding MDX table escapes', () => {
37 + expect(escapeTypeForMdx(String.raw`{ pattern: '\|' }`)).toBe(String.raw`\{ pattern: '\\\|' \}`);
38 + });
39 +
40 + it('reads named parameter and return types from source signatures', () => {
41 + const source = `
42 +class Example {
43 + async list(
44 + query?: AuthConfigListParams,
45 + requestOptions?: ComposioRequestOptions
46 + ): Promise<AuthConfigListResponse> {
47 + return undefined as never;
48 + }
49 +}
50 +`;
51 + const line = source.split('\n').findIndex(line => line.includes('async list(')) + 1;
52 +
53 + const signature = parseSourceSignatureTypesAtLine(source, line);
54 +
55 + expect(signature?.parameters.get('query')).toBe('AuthConfigListParams');
56 + expect(signature?.parameters.get('requestOptions')).toBe('ComposioRequestOptions');
57 + expect(signature?.returnType).toBe('Promise<AuthConfigListResponse>');
58 + });
59 +
60 + it('reads authored inline object types from source signatures', () => {
61 + const source = `
62 +class Example {
63 + getResult(input: { id: string; mode?: 'fast' | 'safe' }): { ok: boolean; value?: string } {
64 + return { ok: true };
65 + }
66 +}
67 +`;
68 + const line = source.split('\n').findIndex(line => line.includes('getResult(')) + 1;
69 +
70 + const signature = parseSourceSignatureTypesAtLine(source, line);
71 +
72 + expect(signature?.parameters.get('input')).toBe("{ id: string; mode?: 'fast' | 'safe' }");
73 + expect(signature?.returnType).toBe('{ ok: boolean; value?: string }');
74 + });
75 +
76 + it('does not infer a return type when the source signature omits one', () => {
77 + const source = `
78 +class Example {
79 + async toolkits(options?: ToolRouterToolkitsOptions, requestOptions?: ComposioRequestOptions) {
80 + const params = { search: options?.search };
81 + return params;
82 + }
83 +
84 + async search(params: { query: string }): Promise<ToolRouterSessionSearchResponse> {
85 + return undefined as never;
86 + }
87 +}
88 +`;
89 + const line = source.split('\n').findIndex(line => line.includes('async toolkits(')) + 1;
90 +
91 + const signature = parseSourceSignatureTypesAtLine(source, line);
92 +
93 + expect(signature?.parameters.get('options')).toBe('ToolRouterToolkitsOptions');
94 + expect(signature?.parameters.get('requestOptions')).toBe('ComposioRequestOptions');
95 + expect(signature?.returnType).toBeUndefined();
96 + });
97 +
98 + it('keeps arrow function parameter types intact', () => {
99 + const source = `
100 +class Example {
101 + subscribe(fn: (event: TriggerEvent) => void, filters?: TriggerSubscribeParams): void {
102 + fn(undefined as never);
103 + }
104 +}
105 +`;
106 + const line = source.split('\n').findIndex(line => line.includes('subscribe(')) + 1;
107 +
108 + const signature = parseSourceSignatureTypesAtLine(source, line);
109 +
110 + expect(signature?.parameters.get('fn')).toBe('(event: TriggerEvent) => void');
111 + expect(signature?.parameters.get('filters')).toBe('TriggerSubscribeParams');
112 + expect(signature?.returnType).toBe('void');
113 + });
114 +});