@composio/core 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CustomTool-BMlZfJVz.mjs → CustomTool-B-_VjWpy.mjs} +1 -1
- package/dist/{CustomTool-CB5vm1Jc.d.mts → CustomTool-BHOYxLZX.d.mts} +1 -1
- package/dist/{FileModifierErrors-BqFmpRsm.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
- package/dist/{SsrfErrors-C91YhASE.mjs → SsrfErrors-DiQldIdC.mjs} +18 -7
- package/dist/{Telemetry-HlftxMx6.mjs → Telemetry-JRJJYS4I.mjs} +2 -2
- package/dist/{cancellation-CXpfmiVo.mjs → cancellation-DV8CIi52.mjs} +2 -2
- package/dist/{composio-DLGaeN70.d.mts → composio-BTZsFajb.d.mts} +3149 -117
- package/dist/{customTool.types-BAmEh3MB.d.mts → customTool.types-D_w21L56.d.mts} +784 -56
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +7 -3
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +101 -18
- package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +123 -0
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +9 -2
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +8 -0
- package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +56 -0
- package/dist/docs/reference/sdk-reference/typescript/logs.mdx +78 -0
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +15 -15
- package/dist/docs/reference/sdk-reference/typescript/meta.json +9 -1
- package/dist/docs/reference/sdk-reference/typescript/session-configs.mdx +83 -0
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +86 -27
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +26 -6
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +149 -12
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +18 -18
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +25 -25
- package/dist/docs/reference/sdk-reference/typescript/usage.mdx +78 -0
- package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +162 -0
- package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +218 -0
- package/dist/docs/reference/sdk-reference/typescript/webhooks.mdx +20 -0
- package/dist/{errors-BuEKehbI.mjs → errors-Dyiu3ifQ.mjs} +127 -4
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-L7XD8UPr.mjs → fileUtils.node-DNLhLg0W.mjs} +4 -4
- package/dist/index.d.mts +281 -55
- package/dist/index.mjs +3552 -949
- package/dist/models/Files.node.mjs +2 -2
- package/dist/{sensitiveFileUploadPaths-B6pBt9lO.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +1 -1
- package/dist/{ssrfGuard.node-B9xQB4za.mjs → ssrfGuard.node-BZ270bcu.mjs} +1 -1
- package/dist/{types-CxLPO0Xq.d.mts → types-CgRsUGqm.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +5 -5
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/dist/utils/ssrfGuard.node.mjs +1 -1
- package/dist/utils/ssrfGuard.workerd.mjs +1 -1
- package/package.json +4 -2
- package/src/composio.ts +215 -10
- package/src/errors/ConnectedAccountsErrors.ts +47 -0
- package/src/errors/SDKErrors.ts +52 -0
- package/src/errors/ToolRouterErrors.ts +61 -0
- package/src/errors/index.ts +3 -0
- package/src/index.ts +13 -0
- package/src/lib/sessionConfigConflict.ts +43 -0
- package/src/lib/toolRouterMcp.ts +132 -0
- package/src/lib/toolRouterParams.ts +149 -37
- package/src/lib/toolRouterSourceSessionConfig.ts +12 -0
- package/src/models/ConnectedAccounts.ts +118 -2
- package/src/models/CustomToolkits.ts +169 -0
- package/src/models/Experimental.ts +27 -0
- package/src/models/Keyring.ts +65 -0
- package/src/models/Logs.ts +101 -0
- package/src/models/RemoteFile.ts +25 -8
- package/src/models/SessionConfigs.ts +117 -0
- package/src/models/ToolRouter.ts +61 -17
- package/src/models/ToolRouterSession.ts +149 -14
- package/src/models/Toolkits.ts +180 -0
- package/src/models/Tools.ts +10 -6
- package/src/models/Triggers.ts +3 -88
- package/src/models/Usage.ts +119 -0
- package/src/models/Webhooks.ts +520 -0
- package/src/services/pusher/Pusher.ts +17 -6
- package/src/types/authConfigs.types.ts +2 -0
- package/src/types/connectedAccounts.types.ts +54 -0
- package/src/types/customToolkits.types.ts +102 -0
- package/src/types/keyring.types.ts +32 -0
- package/src/types/logs.types.ts +108 -0
- package/src/types/sessionConfigs.types.ts +81 -0
- package/src/types/tool.types.ts +2 -0
- package/src/types/toolRouter.types.ts +352 -16
- package/src/types/toolkit.types.ts +144 -0
- package/src/types/usage.types.ts +81 -0
- package/src/types/webhooks.types.ts +143 -0
- package/src/utils/constants.ts +1 -5
- package/src/utils/logger.ts +39 -7
- package/src/utils/safePath.ts +172 -0
- package/src/utils/sdk.ts +385 -22
- package/src/utils/transformers/connectedAccounts.ts +37 -2
- package/src/utils/transformers/customToolkits.ts +98 -0
- package/src/utils/transformers/keyring.ts +24 -0
- package/src/utils/transformers/logs.ts +85 -0
- package/src/utils/transformers/sessionConfigs.ts +54 -0
- package/src/utils/transformers/toolRouterResponseTransform.ts +6 -0
- package/src/utils/transformers/toolkits.ts +106 -3
- package/src/utils/transformers/triggers.ts +2 -2
- package/src/utils/transformers/usage.ts +77 -0
- package/src/utils/transformers/webhooks.ts +139 -0
|
@@ -7,14 +7,14 @@ description: "A Composio session — the object returned by `composio.sessions.c
|
|
|
7
7
|
|
|
8
8
|
| Name | Type | Description |
|
|
9
9
|
|------|------|-------------|
|
|
10
|
-
| `config` | `Config` |
|
|
11
|
-
| `configVersion` | `number` |
|
|
10
|
+
| `config` | `Config` | The session's current configuration (policy snapshot and runtime settings). Refreshed in place by `update()`. For saved, reusable Session configs, see `composio.sessionConfigs`. |
|
|
11
|
+
| `configVersion` | `number` | Version of the server-side configuration this object last observed. Refreshed in place by `update()`. Pass it as `expectedConfigVersion` to make an update conditional. |
|
|
12
12
|
| `experimental` | `SessionExperimental` | |
|
|
13
13
|
| `mcp` | `\{ headers?: Record<string, string>; type: 'http' \| 'sse'; url: string \}` | Hosted MCP endpoint (`session.mcp.url` / `session.mcp.headers`). Exists on every session at runtime, but only surfaced in the type when the session is created with `\{ mcp: true \}` (which returns `Session`); the default `SessionWithoutMcp` omits `mcp`, so MCP is an explicit opt-in. See https://docs.composio.dev/docs/sessions-via-mcp |
|
|
14
|
-
| `preload` | `
|
|
15
|
-
| `sandbox` | `
|
|
14
|
+
| `preload` | `\{ tools: string[] \| 'all' \}` | |
|
|
15
|
+
| `sandbox` | `\{ auto_offload_threshold?: number; enable?: boolean; proxy_execution_enabled?: boolean; sandbox_size?: 'standard' \| 'medium' \| 'large' \| 'xlarge'; tool_execution_enabled?: boolean \}` | Resolved sandbox (code-execution) config returned by the API. `enable` defaults to `true` server-side. |
|
|
16
16
|
| `sessionId` | `string` | |
|
|
17
|
-
| `warnings` |
|
|
17
|
+
| `warnings` | `\{ code: 'PRELOAD_TOOLS_HIGH_CONTEXT_USAGE'; message: string \}[]` | |
|
|
18
18
|
|
|
19
19
|
## Methods
|
|
20
20
|
|
|
@@ -35,7 +35,7 @@ Experimental — shape may change in future releases.
|
|
|
35
35
|
at the SDK boundary.
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
|
-
async authorize(toolkit: string, options?: {
|
|
38
|
+
async authorize(toolkit: string, options?: { alias?: string; callbackUrl?: string; experimental?: { accountType?: ConnectedAccountType; aclConfigForShared?: { allowAllUsers?: boolean; allowedUserIds?: string[]; notAllowedUserIds?: string[] } } }, requestOptions?: ComposioRequestOptions): Promise<ConnectionRequest>
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
**Parameters**
|
|
@@ -43,7 +43,7 @@ async authorize(toolkit: string, options?: { callbackUrl?: string; alias?: strin
|
|
|
43
43
|
| Name | Type |
|
|
44
44
|
|------|------|
|
|
45
45
|
| `toolkit` | `string` |
|
|
46
|
-
| `options?` | `\{
|
|
46
|
+
| `options?` | `\{ alias?: string; callbackUrl?: string; experimental?: \{ accountType?: ConnectedAccountType; aclConfigForShared?: \{ allowAllUsers?: boolean; allowedUserIds?: string[]; notAllowedUserIds?: string[] \} \} \}` |
|
|
47
47
|
| `requestOptions?` | `ComposioRequestOptions` |
|
|
48
48
|
|
|
49
49
|
**Returns**
|
|
@@ -96,7 +96,7 @@ Deleted sessions immediately stop being retrievable or executable. Deleting
|
|
|
96
96
|
an already-deleted session surfaces the backend 404.
|
|
97
97
|
|
|
98
98
|
```typescript
|
|
99
|
-
async delete(requestOptions?: ComposioRequestOptions): Promise<
|
|
99
|
+
async delete(requestOptions?: ComposioRequestOptions): Promise<{ deleted: true; sessionId: string }>
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
**Parameters**
|
|
@@ -107,7 +107,7 @@ async delete(requestOptions?: ComposioRequestOptions): Promise<ToolRouterSession
|
|
|
107
107
|
|
|
108
108
|
**Returns**
|
|
109
109
|
|
|
110
|
-
`Promise
|
|
110
|
+
`Promise<\{ deleted: true; sessionId: string \}>`
|
|
111
111
|
|
|
112
112
|
---
|
|
113
113
|
|
|
@@ -126,7 +126,7 @@ For interactive flows that should surface the redirect URL instead of
|
|
|
126
126
|
blocking, use `authorize()` and its `waitForConnection()` directly.
|
|
127
127
|
|
|
128
128
|
```typescript
|
|
129
|
-
async ensureConnected(toolkit: string, options?:
|
|
129
|
+
async ensureConnected(toolkit: string, options?: { alias?: string; callbackUrl?: string; experimental?: { accountType?: 'PRIVATE' | 'SHARED'; aclConfigForShared?: { allowAllUsers?: boolean; allowedUserIds?: string[]; notAllowedUserIds?: string[] } }; timeout?: number }, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionEnsureConnectedResult>
|
|
130
130
|
```
|
|
131
131
|
|
|
132
132
|
**Parameters**
|
|
@@ -134,7 +134,7 @@ async ensureConnected(toolkit: string, options?: ToolRouterSessionEnsureConnecte
|
|
|
134
134
|
| Name | Type | Description |
|
|
135
135
|
|------|------|-------------|
|
|
136
136
|
| `toolkit` | `string` | The toolkit slug to ensure a connection for (e.g. 'github') |
|
|
137
|
-
| `options?` | `
|
|
137
|
+
| `options?` | `\{ alias?: string; callbackUrl?: string; experimental?: \{ accountType?: 'PRIVATE' \| 'SHARED'; aclConfigForShared?: \{ allowAllUsers?: boolean; allowedUserIds?: string[]; notAllowedUserIds?: string[] \} \}; timeout?: number \}` | Optional authorization options plus `timeout` (ms to wait for a newly-initiated connection, default 60000) |
|
|
138
138
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
139
139
|
|
|
140
140
|
**Returns**
|
|
@@ -162,7 +162,7 @@ the session's custom tools and toolkits. Custom tools are executed
|
|
|
162
162
|
in-process; remote tools are sent to the Composio backend.
|
|
163
163
|
|
|
164
164
|
```typescript
|
|
165
|
-
async execute(toolSlug: string, arguments_?: Record<string, unknown>, options?: ToolRouterSessionExecuteOptions, requestOptions?: ComposioRequestOptions): Promise
|
|
165
|
+
async execute(toolSlug: string, arguments_?: Record<string, unknown>, options?: ToolRouterSessionExecuteOptions, requestOptions?: ComposioRequestOptions): Promise<...>
|
|
166
166
|
```
|
|
167
167
|
|
|
168
168
|
**Parameters**
|
|
@@ -176,7 +176,38 @@ async execute(toolSlug: string, arguments_?: Record<string, unknown>, options?:
|
|
|
176
176
|
|
|
177
177
|
**Returns**
|
|
178
178
|
|
|
179
|
-
`Promise
|
|
179
|
+
`Promise<...>` — The tool execution result
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### listConfigHistory()
|
|
184
|
+
|
|
185
|
+
Page through this session's configuration history, newest first. The
|
|
186
|
+
first page starts with the live config (`isCurrent: true`); every
|
|
187
|
+
`session.update()` archives the previous version as a history row.
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
async listConfigHistory(options?: { cursor?: string; limit?: number }, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionListConfigHistoryResponse>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Parameters**
|
|
194
|
+
|
|
195
|
+
| Name | Type | Description |
|
|
196
|
+
|------|------|-------------|
|
|
197
|
+
| `options?` | `\{ cursor?: string; limit?: number \}` | Optional `cursor` and `limit` (max 100) |
|
|
198
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
199
|
+
|
|
200
|
+
**Returns**
|
|
201
|
+
|
|
202
|
+
`Promise<ToolRouterSessionListConfigHistoryResponse>` — The config versions on this page plus pagination info
|
|
203
|
+
|
|
204
|
+
**Example**
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const { items, nextCursor } = await session.listConfigHistory({ limit: 10 });
|
|
208
|
+
console.log(items[0].version, items[0].isCurrent); // e.g. 3, true
|
|
209
|
+
console.log(items[1].config.toolkits);
|
|
210
|
+
```
|
|
180
211
|
|
|
181
212
|
---
|
|
182
213
|
|
|
@@ -186,14 +217,14 @@ Proxy an API call through Composio's auth layer using the session's connected ac
|
|
|
186
217
|
The backend resolves the connected account from the toolkit within the session.
|
|
187
218
|
|
|
188
219
|
```typescript
|
|
189
|
-
async proxyExecute(params:
|
|
220
|
+
async proxyExecute(params: { body?: unknown; endpoint: string; method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; parameters?: { in: 'query' | 'header'; name: string; value: string | number }[]; toolkit: string }, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionProxyExecuteResponse>
|
|
190
221
|
```
|
|
191
222
|
|
|
192
223
|
**Parameters**
|
|
193
224
|
|
|
194
225
|
| Name | Type | Description |
|
|
195
226
|
|------|------|-------------|
|
|
196
|
-
| `params` | `
|
|
227
|
+
| `params` | `\{ body?: unknown; endpoint: string; method: 'GET' \| 'POST' \| 'PUT' \| 'DELETE' \| 'PATCH'; parameters?: \{ in: 'query' \| 'header'; name: string; value: string \| number \}[]; toolkit: string \}` | Proxy request parameters (toolkit, endpoint, method, body, headers/query params) |
|
|
197
228
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
198
229
|
|
|
199
230
|
**Returns**
|
|
@@ -208,19 +239,19 @@ Search for tools by semantic use case.
|
|
|
208
239
|
Returns relevant tools for the given query with schemas and guidance.
|
|
209
240
|
|
|
210
241
|
```typescript
|
|
211
|
-
async search(params: { query: string; toolkits?: string[]
|
|
242
|
+
async search(params: { query: string; toolkits?: string[] }, requestOptions?: ComposioRequestOptions): Promise<{ error: string | null; nextStepsGuidance: string[]; results: { difficulty?: string; error?: string | null; executionGuidance?: string; index: number; knownPitfalls?: string[]; memory?: Record<string, ...[]>; planId?: string; primaryToolSlugs: string[]; recommendedPlanSteps?: string[]; referenceWorkbenchSnippets?: { code: ...; description: ... }[]; relatedToolSlugs: string[]; toolkits: string[]; useCase: string }[]; session: { generateId: boolean; id: string; instructions: string }; success: boolean; timeInfo: { currentTimeUtc: string; currentTimeUtcEpochSeconds: number; message: string }; toolkitConnectionStatuses: { connectionDetails?: Record<string, unknown>; currentUserInfo?: Record<string, unknown>; description: string; hasActiveConnection: boolean; hostedAccount?: { allowedToolSlugs: ...[] }; statusMessage: string; toolkit: string }[]; toolSchemas: Record<string, { description?: string; hasFullSchema?: boolean; inputSchema?: Record<string, unknown>; outputSchema?: Record<string, unknown>; schemaRef?: { args: { toolSlugs: ... }; message?: string; tool: 'COMPOSIO_GET_TOOL_SCHEMAS' }; toolkit: string; toolSlug: string }> }>
|
|
212
243
|
```
|
|
213
244
|
|
|
214
245
|
**Parameters**
|
|
215
246
|
|
|
216
247
|
| Name | Type |
|
|
217
248
|
|------|------|
|
|
218
|
-
| `params` | `\{ query: string; toolkits?: string[]
|
|
249
|
+
| `params` | `\{ query: string; toolkits?: string[] \}` |
|
|
219
250
|
| `requestOptions?` | `ComposioRequestOptions` |
|
|
220
251
|
|
|
221
252
|
**Returns**
|
|
222
253
|
|
|
223
|
-
`Promise<
|
|
254
|
+
`Promise<\{ error: string \| null; nextStepsGuidance: string[]; results: \{ difficulty?: string; error?: string \| null; executionGuidance?: string; index: number; knownPitfalls?: string[]; memory?: Record<string, ...[]>; planId?: string; primaryToolSlugs: string[]; recommendedPlanSteps?: string[]; referenceWorkbenchSnippets?: \{ code: ...; description: ... \}[]; relatedToolSlugs: string[]; toolkits: string[]; useCase: string \}[]; session: \{ generateId: boolean; id: string; instructions: string \}; success: boolean; timeInfo: \{ currentTimeUtc: string; currentTimeUtcEpochSeconds: number; message: string \}; toolkitConnectionStatuses: \{ connectionDetails?: Record<string, unknown>; currentUserInfo?: Record<string, unknown>; description: string; hasActiveConnection: boolean; hostedAccount?: \{ allowedToolSlugs: ...[] \}; statusMessage: string; toolkit: string \}[]; toolSchemas: Record<string, \{ description?: string; hasFullSchema?: boolean; inputSchema?: Record<string, unknown>; outputSchema?: Record<string, unknown>; schemaRef?: \{ args: \{ toolSlugs: ... \}; message?: string; tool: 'COMPOSIO_GET_TOOL_SCHEMAS' \}; toolkit: string; toolSlug: string \}> \}>`
|
|
224
255
|
|
|
225
256
|
---
|
|
226
257
|
|
|
@@ -230,14 +261,14 @@ Query the connection state of toolkits in the session.
|
|
|
230
261
|
Supports pagination and filtering by toolkit slugs.
|
|
231
262
|
|
|
232
263
|
```typescript
|
|
233
|
-
async toolkits(options?:
|
|
264
|
+
async toolkits(options?: { cursor?: string; isConnected?: boolean; limit?: number; search?: string; toolkits?: string[] }, requestOptions?: ComposioRequestOptions): Promise<{ cursor: string | undefined; items: { connection?: { authConfig?: ... | ...; connectedAccount?: { id: ...; status: ... }; isActive: boolean }; isNoAuth: boolean; logo?: string; name: string; slug: string }[]; totalPages: number }>
|
|
234
265
|
```
|
|
235
266
|
|
|
236
267
|
**Parameters**
|
|
237
268
|
|
|
238
269
|
| Name | Type |
|
|
239
270
|
|------|------|
|
|
240
|
-
| `options?` | `
|
|
271
|
+
| `options?` | `\{ cursor?: string; isConnected?: boolean; limit?: number; search?: string; toolkits?: string[] \}` |
|
|
241
272
|
| `requestOptions?` | `ComposioRequestOptions` |
|
|
242
273
|
|
|
243
274
|
**Returns**
|
|
@@ -255,7 +286,7 @@ When custom tools are bound to the session, execution of COMPOSIO_MULTI_EXECUTE_
|
|
|
255
286
|
is intercepted: local tools are executed in-process, remote tools are sent to the backend.
|
|
256
287
|
|
|
257
288
|
```typescript
|
|
258
|
-
async tools(modifiers?: SessionMetaToolOptions, requestOptions?: ComposioRequestOptions): Promise<ReturnType
|
|
289
|
+
async tools(modifiers?: SessionMetaToolOptions, requestOptions?: ComposioRequestOptions): Promise<ReturnType>
|
|
259
290
|
```
|
|
260
291
|
|
|
261
292
|
**Parameters**
|
|
@@ -267,19 +298,47 @@ async tools(modifiers?: SessionMetaToolOptions, requestOptions?: ComposioRequest
|
|
|
267
298
|
|
|
268
299
|
**Returns**
|
|
269
300
|
|
|
270
|
-
`Promise<ReturnType
|
|
301
|
+
`Promise<ReturnType>`
|
|
271
302
|
|
|
272
303
|
---
|
|
273
304
|
|
|
274
305
|
### update()
|
|
275
306
|
|
|
276
307
|
Partially update the session configuration.
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
308
|
+
|
|
309
|
+
Only the fields provided are changed; omitted fields are preserved. For
|
|
310
|
+
each policy block `null` removes the stored override (which can increase
|
|
311
|
+
access: `toolkits: null` restores the unrestricted default, while
|
|
312
|
+
`toolkits: []` denies every app toolkit and is sent as-is). Supplied
|
|
313
|
+
`tools`, `authConfigs` and `connectedAccounts` maps replace the stored
|
|
314
|
+
map entirely. `manageConnections.callbackUrl: null` removes only the
|
|
315
|
+
stored callback URL.
|
|
316
|
+
|
|
317
|
+
By default the request carries no precondition: the last writer wins.
|
|
318
|
+
Pass `expectedConfigVersion` (for example `session.configVersion`) to make
|
|
319
|
+
the update conditional: the API then applies it only when the stored
|
|
320
|
+
version still matches, and a concurrent change surfaces as
|
|
321
|
+
ComposioSessionConfigConflictError (HTTP 409) instead of being
|
|
322
|
+
overwritten. The API must support the `expected_config_version` field;
|
|
323
|
+
otherwise it rejects the request with a 400. `expectedConfigVersion: false`
|
|
324
|
+
is the same as omitting it. The PATCH is never retried by the transport,
|
|
325
|
+
so a 409 is reported exactly once. On conflict this object is left
|
|
326
|
+
unchanged: re-fetch the session with `sessions.use(sessionId)` and retry
|
|
327
|
+
against the fresh `configVersion`.
|
|
328
|
+
|
|
329
|
+
`experimental.sessionConfigId` applies a saved Session config: it
|
|
330
|
+
replaces the session's toolkit, tool and tag access and cannot be combined
|
|
331
|
+
with `toolkits`, `tools` or `tags` (a `ValidationError` is thrown before
|
|
332
|
+
any request). A 409 while applying it means the session or the config
|
|
333
|
+
changed; re-fetch the session and retry. Backend 400, 403 and 404 errors,
|
|
334
|
+
for example for an archived or missing config, surface unchanged.
|
|
335
|
+
|
|
336
|
+
`config`, `configVersion`, `preload`, `sandbox`, `warnings` and
|
|
337
|
+
`experimental.sourceSessionConfig` are refreshed in place only after a
|
|
338
|
+
successful response, and the updated `config` is returned.
|
|
280
339
|
|
|
281
340
|
```typescript
|
|
282
|
-
async update(config: ToolRouterUpdateSessionConfig, requestOptions?: ComposioRequestOptions): Promise<
|
|
341
|
+
async update(config: ToolRouterUpdateSessionConfig, requestOptions?: ComposioRequestOptions): Promise<Config>
|
|
283
342
|
```
|
|
284
343
|
|
|
285
344
|
**Parameters**
|
|
@@ -291,6 +350,6 @@ async update(config: ToolRouterUpdateSessionConfig, requestOptions?: ComposioReq
|
|
|
291
350
|
|
|
292
351
|
**Returns**
|
|
293
352
|
|
|
294
|
-
`Promise<
|
|
353
|
+
`Promise<Config>`
|
|
295
354
|
|
|
296
355
|
---
|
|
@@ -20,6 +20,13 @@ Creates a new tool router session for a user.
|
|
|
20
20
|
Use `sessionPreset: SessionPreset.DIRECT_TOOLS` when all needed tools
|
|
21
21
|
should be exposed directly; see `ToolRouterCreateSessionConfig`.
|
|
22
22
|
|
|
23
|
+
The session's MCP config carries the session credential only when the
|
|
24
|
+
MCP URL shares the origin of the configured API base URL. When it does
|
|
25
|
+
not, `mcp: true` makes the call throw `ComposioMCPDestinationError`
|
|
26
|
+
(naming both origins, never a key); without `mcp: true` the session is
|
|
27
|
+
returned with `session.mcp.headers` empty and a warning naming both
|
|
28
|
+
origins is logged, so native tools keep working.
|
|
29
|
+
|
|
23
30
|
**Overload 1**
|
|
24
31
|
|
|
25
32
|
```typescript
|
|
@@ -71,6 +78,12 @@ const session = await composio.sessions.create('user_123', {
|
|
|
71
78
|
customToolkits: [myToolkit],
|
|
72
79
|
},
|
|
73
80
|
});
|
|
81
|
+
|
|
82
|
+
// Start from a saved Session config instead of inline access fields
|
|
83
|
+
const configured = await composio.sessions.create('user_123', {
|
|
84
|
+
authConfigs: { github: 'ac_123' },
|
|
85
|
+
experimental: { sessionConfigId: 'sc_123' },
|
|
86
|
+
});
|
|
74
87
|
```
|
|
75
88
|
|
|
76
89
|
---
|
|
@@ -83,7 +96,7 @@ Deleted sessions immediately stop being retrievable or executable. Deleting
|
|
|
83
96
|
a missing or already-deleted session surfaces the backend 404.
|
|
84
97
|
|
|
85
98
|
```typescript
|
|
86
|
-
async delete(id: string, requestOptions?: ComposioRequestOptions): Promise<
|
|
99
|
+
async delete(id: string, requestOptions?: ComposioRequestOptions): Promise<{ deleted: true; sessionId: string }>
|
|
87
100
|
```
|
|
88
101
|
|
|
89
102
|
**Parameters**
|
|
@@ -95,7 +108,7 @@ async delete(id: string, requestOptions?: ComposioRequestOptions): Promise<ToolR
|
|
|
95
108
|
|
|
96
109
|
**Returns**
|
|
97
110
|
|
|
98
|
-
`Promise
|
|
111
|
+
`Promise<\{ deleted: true; sessionId: string \}>`
|
|
99
112
|
|
|
100
113
|
---
|
|
101
114
|
|
|
@@ -103,10 +116,17 @@ async delete(id: string, requestOptions?: ComposioRequestOptions): Promise<ToolR
|
|
|
103
116
|
|
|
104
117
|
Use an existing session
|
|
105
118
|
|
|
119
|
+
The session's MCP config carries the session credential only when the
|
|
120
|
+
MCP URL shares the origin of the configured API base URL. When it does
|
|
121
|
+
not, `mcp: true` makes the call throw `ComposioMCPDestinationError`
|
|
122
|
+
(naming both origins, never a key); without `mcp: true` the session is
|
|
123
|
+
returned with `session.mcp.headers` empty and a warning naming both
|
|
124
|
+
origins is logged, so native tools keep working.
|
|
125
|
+
|
|
106
126
|
**Overload 1**
|
|
107
127
|
|
|
108
128
|
```typescript
|
|
109
|
-
async use(id: string, options: {
|
|
129
|
+
async use(id: string, options: { customToolkits?: CustomToolkit[]; customTools?: CustomTool[]; mcp: true }, requestOptions?: ComposioRequestOptions): Promise<Session<TToolCollection, TTool, TProvider>>
|
|
110
130
|
```
|
|
111
131
|
|
|
112
132
|
**Parameters**
|
|
@@ -114,7 +134,7 @@ async use(id: string, options: { customTools?: CustomTool[]; customToolkits?: Cu
|
|
|
114
134
|
| Name | Type | Description |
|
|
115
135
|
|------|------|-------------|
|
|
116
136
|
| `id` | `string` | \{string\} The id of the session to use |
|
|
117
|
-
| `options` | `\{
|
|
137
|
+
| `options` | `\{ customToolkits?: CustomToolkit[]; customTools?: CustomTool[]; mcp: true \}` | |
|
|
118
138
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
119
139
|
|
|
120
140
|
**Returns**
|
|
@@ -124,7 +144,7 @@ async use(id: string, options: { customTools?: CustomTool[]; customToolkits?: Cu
|
|
|
124
144
|
**Overload 2**
|
|
125
145
|
|
|
126
146
|
```typescript
|
|
127
|
-
async use(id: string, options?: {
|
|
147
|
+
async use(id: string, options?: { customToolkits?: CustomToolkit[]; customTools?: CustomTool[]; mcp?: boolean }, requestOptions?: ComposioRequestOptions): Promise<SessionWithoutMcp<TToolCollection, TTool, TProvider>>
|
|
128
148
|
```
|
|
129
149
|
|
|
130
150
|
**Parameters**
|
|
@@ -132,7 +152,7 @@ async use(id: string, options?: { customTools?: CustomTool[]; customToolkits?: C
|
|
|
132
152
|
| Name | Type | Description |
|
|
133
153
|
|------|------|-------------|
|
|
134
154
|
| `id` | `string` | \{string\} The id of the session to use |
|
|
135
|
-
| `options?` | `\{
|
|
155
|
+
| `options?` | `\{ customToolkits?: CustomToolkit[]; customTools?: CustomTool[]; mcp?: boolean \}` | |
|
|
136
156
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
137
157
|
|
|
138
158
|
**Returns**
|
|
@@ -9,7 +9,7 @@ Access this class through the `composio.toolkits` property:
|
|
|
9
9
|
|
|
10
10
|
```typescript
|
|
11
11
|
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
12
|
-
const result = await composio.toolkits.
|
|
12
|
+
const result = await composio.toolkits.get({});
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
@@ -44,6 +44,35 @@ const connectionRequest = await composio.toolkits.authorize(userId, 'github');
|
|
|
44
44
|
|
|
45
45
|
---
|
|
46
46
|
|
|
47
|
+
### changelog()
|
|
48
|
+
|
|
49
|
+
Retrieves the version changelog of every toolkit (the last 10 versions
|
|
50
|
+
per toolkit).
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
async changelog(requestOptions?: ComposioRequestOptions): Promise<{ items: { displayName: string; name: string; slug: string; versions: { changelog: ...; version: ... }[] }[] }>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Parameters**
|
|
57
|
+
|
|
58
|
+
| Name | Type |
|
|
59
|
+
|------|------|
|
|
60
|
+
| `requestOptions?` | `ComposioRequestOptions` |
|
|
61
|
+
|
|
62
|
+
**Returns**
|
|
63
|
+
|
|
64
|
+
`Promise<\{ items: \{ displayName: string; name: string; slug: string; versions: \{ changelog: ...; version: ... \}[] \}[] \}>` — Toolkits with their recent version changelogs
|
|
65
|
+
|
|
66
|
+
**Example**
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const { items } = await composio.toolkits.changelog();
|
|
70
|
+
const github = items.find(item => item.slug === 'github');
|
|
71
|
+
console.log(github?.versions[0]); // { version: '20250909_00', changelog: '...' }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
47
76
|
### get()
|
|
48
77
|
|
|
49
78
|
Retrieves a specific toolkit by its slug identifier.
|
|
@@ -51,7 +80,7 @@ Retrieves a specific toolkit by its slug identifier.
|
|
|
51
80
|
**Overload 1**
|
|
52
81
|
|
|
53
82
|
```typescript
|
|
54
|
-
async get(slug: string, requestOptions?: ComposioRequestOptions): Promise<
|
|
83
|
+
async get(slug: string, requestOptions?: ComposioRequestOptions): Promise<{ authConfigDetails?: { authHintUrl?: string | null; fields: { authConfigCreation: { optional: ...; required: ... }; connectedAccountInitiation: { optional: ...; required: ... } }; mode: string; name: string; proxy?: { baseUrl?: string }; requiredScopes?: string[] }[]; baseUrl?: string; composioManagedAuthSchemes?: string[]; getCurrentUserEndpoint?: string; getCurrentUserEndpointMethod?: string; isLocalToolkit: boolean; meta: { appUrl?: string; availableVersions?: string[]; categories?: { name: string; slug: string }[]; createdAt?: string; description?: string; logo?: string; toolsCount?: number; triggersCount?: number; updatedAt?: string }; name: string; slug: string }>
|
|
55
84
|
```
|
|
56
85
|
|
|
57
86
|
**Parameters**
|
|
@@ -63,24 +92,24 @@ async get(slug: string, requestOptions?: ComposioRequestOptions): Promise<Toolki
|
|
|
63
92
|
|
|
64
93
|
**Returns**
|
|
65
94
|
|
|
66
|
-
`Promise
|
|
95
|
+
`Promise<\{ authConfigDetails?: \{ authHintUrl?: string \| null; fields: \{ authConfigCreation: \{ optional: ...; required: ... \}; connectedAccountInitiation: \{ optional: ...; required: ... \} \}; mode: string; name: string; proxy?: \{ baseUrl?: string \}; requiredScopes?: string[] \}[]; baseUrl?: string; composioManagedAuthSchemes?: string[]; getCurrentUserEndpoint?: string; getCurrentUserEndpointMethod?: string; isLocalToolkit: boolean; meta: \{ appUrl?: string; availableVersions?: string[]; categories?: \{ name: string; slug: string \}[]; createdAt?: string; description?: string; logo?: string; toolsCount?: number; triggersCount?: number; updatedAt?: string \}; name: string; slug: string \}>` — The toolkit object with detailed information
|
|
67
96
|
|
|
68
97
|
**Overload 2**
|
|
69
98
|
|
|
70
99
|
```typescript
|
|
71
|
-
async get(query?:
|
|
100
|
+
async get(query?: { category?: string; cursor?: string; limit?: number; managedBy?: 'all' | 'composio' | 'project'; sortBy?: 'usage' | 'alphabetically' }, requestOptions?: ComposioRequestOptions): Promise<{ authSchemes?: string[]; composioManagedAuthSchemes?: string[]; isLocalToolkit: boolean; meta: { appUrl?: string; availableVersions?: string[]; categories?: { name: ...; slug: ... }[]; createdAt?: string; description?: string; logo?: string; toolsCount?: number; triggersCount?: number; updatedAt?: string }; name: string; noAuth?: boolean; slug: string }[]>
|
|
72
101
|
```
|
|
73
102
|
|
|
74
103
|
**Parameters**
|
|
75
104
|
|
|
76
105
|
| Name | Type | Description |
|
|
77
106
|
|------|------|-------------|
|
|
78
|
-
| `query?` | `
|
|
107
|
+
| `query?` | `\{ category?: string; cursor?: string; limit?: number; managedBy?: 'all' \| 'composio' \| 'project'; sortBy?: 'usage' \| 'alphabetically' \}` | The query parameters to filter toolkits |
|
|
79
108
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
80
109
|
|
|
81
110
|
**Returns**
|
|
82
111
|
|
|
83
|
-
`Promise
|
|
112
|
+
`Promise<\{ authSchemes?: string[]; composioManagedAuthSchemes?: string[]; isLocalToolkit: boolean; meta: \{ appUrl?: string; availableVersions?: string[]; categories?: \{ name: ...; slug: ... \}[]; createdAt?: string; description?: string; logo?: string; toolsCount?: number; triggersCount?: number; updatedAt?: string \}; name: string; noAuth?: boolean; slug: string \}[]>` — A paginated list of toolkits matching the query criteria
|
|
84
113
|
|
|
85
114
|
**Example**
|
|
86
115
|
|
|
@@ -98,7 +127,7 @@ console.log(githubToolkit.authConfigDetails); // Authentication configuration de
|
|
|
98
127
|
Retrieves the fields required for creating an auth config for a toolkit.
|
|
99
128
|
|
|
100
129
|
```typescript
|
|
101
|
-
async getAuthConfigCreationFields(toolkitSlug: string, authScheme: AuthSchemeType, options?: { requiredOnly?: boolean }): Promise
|
|
130
|
+
async getAuthConfigCreationFields(toolkitSlug: string, authScheme: AuthSchemeType, options?: { requiredOnly?: boolean }): Promise<...>
|
|
102
131
|
```
|
|
103
132
|
|
|
104
133
|
**Parameters**
|
|
@@ -111,7 +140,7 @@ async getAuthConfigCreationFields(toolkitSlug: string, authScheme: AuthSchemeTyp
|
|
|
111
140
|
|
|
112
141
|
**Returns**
|
|
113
142
|
|
|
114
|
-
`Promise
|
|
143
|
+
`Promise<...>` — The fields required for creating an auth config
|
|
115
144
|
|
|
116
145
|
---
|
|
117
146
|
|
|
@@ -120,7 +149,7 @@ async getAuthConfigCreationFields(toolkitSlug: string, authScheme: AuthSchemeTyp
|
|
|
120
149
|
Retrieves the fields required for initiating a connected account for a toolkit.
|
|
121
150
|
|
|
122
151
|
```typescript
|
|
123
|
-
async getConnectedAccountInitiationFields(toolkitSlug: string, authScheme: AuthSchemeType, options?: { requiredOnly?: boolean }): Promise
|
|
152
|
+
async getConnectedAccountInitiationFields(toolkitSlug: string, authScheme: AuthSchemeType, options?: { requiredOnly?: boolean }): Promise<...>
|
|
124
153
|
```
|
|
125
154
|
|
|
126
155
|
**Parameters**
|
|
@@ -133,7 +162,39 @@ async getConnectedAccountInitiationFields(toolkitSlug: string, authScheme: AuthS
|
|
|
133
162
|
|
|
134
163
|
**Returns**
|
|
135
164
|
|
|
136
|
-
`Promise
|
|
165
|
+
`Promise<...>` — The fields required for initiating a connected account
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### getMany()
|
|
170
|
+
|
|
171
|
+
Retrieves several toolkits by slug in a single request.
|
|
172
|
+
|
|
173
|
+
Returns the same transformed shape as `composio.toolkits.get({ ... })`.
|
|
174
|
+
Unknown slugs are simply absent from the result.
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
async getMany(slugs: string[], params?: { category?: string; cursor?: string; limit?: number; managedBy?: 'all' | 'composio' | 'project'; sortBy?: 'usage' | 'alphabetically' }, requestOptions?: ComposioRequestOptions): Promise<{ authSchemes?: string[]; composioManagedAuthSchemes?: string[]; isLocalToolkit: boolean; meta: { appUrl?: string; availableVersions?: string[]; categories?: { name: ...; slug: ... }[]; createdAt?: string; description?: string; logo?: string; toolsCount?: number; triggersCount?: number; updatedAt?: string }; name: string; noAuth?: boolean; slug: string }[]>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Parameters**
|
|
181
|
+
|
|
182
|
+
| Name | Type | Description |
|
|
183
|
+
|------|------|-------------|
|
|
184
|
+
| `slugs` | `string[]` | The toolkit slugs to retrieve (at least one) |
|
|
185
|
+
| `params?` | `\{ category?: string; cursor?: string; limit?: number; managedBy?: 'all' \| 'composio' \| 'project'; sortBy?: 'usage' \| 'alphabetically' \}` | Optional filters and pagination, as for `list` |
|
|
186
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
187
|
+
|
|
188
|
+
**Returns**
|
|
189
|
+
|
|
190
|
+
`Promise<\{ authSchemes?: string[]; composioManagedAuthSchemes?: string[]; isLocalToolkit: boolean; meta: \{ appUrl?: string; availableVersions?: string[]; categories?: \{ name: ...; slug: ... \}[]; createdAt?: string; description?: string; logo?: string; toolsCount?: number; triggersCount?: number; updatedAt?: string \}; name: string; noAuth?: boolean; slug: string \}[]>` — The matching toolkits
|
|
191
|
+
|
|
192
|
+
**Example**
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
const toolkits = await composio.toolkits.getMany(['github', 'slack']);
|
|
196
|
+
console.log(toolkits.map(toolkit => toolkit.name)); // ['GitHub', 'Slack']
|
|
197
|
+
```
|
|
137
198
|
|
|
138
199
|
---
|
|
139
200
|
|
|
@@ -145,7 +206,7 @@ This method fetches the complete list of categories from the Composio API
|
|
|
145
206
|
and transforms the response to use camelCase property naming.
|
|
146
207
|
|
|
147
208
|
```typescript
|
|
148
|
-
async listCategories(requestOptions?: ComposioRequestOptions): Promise<
|
|
209
|
+
async listCategories(requestOptions?: ComposioRequestOptions): Promise<{ items: { id: string; name: string }[]; nextCursor: string | null; totalPages: number }>
|
|
149
210
|
```
|
|
150
211
|
|
|
151
212
|
**Parameters**
|
|
@@ -156,7 +217,7 @@ async listCategories(requestOptions?: ComposioRequestOptions): Promise<ToolkitRe
|
|
|
156
217
|
|
|
157
218
|
**Returns**
|
|
158
219
|
|
|
159
|
-
`Promise
|
|
220
|
+
`Promise<\{ items: \{ id: string; name: string \}[]; nextCursor: string \| null; totalPages: number \}>` — The list of toolkit categories
|
|
160
221
|
|
|
161
222
|
**Example**
|
|
162
223
|
|
|
@@ -167,3 +228,79 @@ console.log(categories.items); // Array of category objects
|
|
|
167
228
|
```
|
|
168
229
|
|
|
169
230
|
---
|
|
231
|
+
|
|
232
|
+
### listGrantContexts()
|
|
233
|
+
|
|
234
|
+
Lists the grant-context dimensions a toolkit's scope recommendation
|
|
235
|
+
depends on (for example the Google account type), with their allowed
|
|
236
|
+
values and the default the API assumes.
|
|
237
|
+
**Experimental — the API marks this endpoint beta; shape may change.**
|
|
238
|
+
|
|
239
|
+
Pass a dimension and a value as `grantContext` to
|
|
240
|
+
`composio.toolkits.recommendScopes()` to tailor the recommendation.
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
async listGrantContexts(toolkitSlug: string, params?: { authScheme?: 'OAUTH2' | 'OAUTH1' | 'API_KEY' | 'BASIC' | 'BILLCOM_AUTH' | 'BEARER_TOKEN' | 'GOOGLE_SERVICE_ACCOUNT' | 'NO_AUTH' | 'BASIC_WITH_JWT' | 'CALCOM_AUTH' | 'SERVICE_ACCOUNT' | 'SAML' | 'DCR_OAUTH' | 'CIMD_OAUTH' | 'S2S_OAUTH2'; toolkitVersion?: string }, requestOptions?: ComposioRequestOptions): Promise<{ authScheme: string; defaultGrantContext: Record<string, string>; grantContextDimensions: { description: string; dimension: string; values: string[] }[]; toolkitVersion: string }>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Parameters**
|
|
247
|
+
|
|
248
|
+
| Name | Type | Description |
|
|
249
|
+
|------|------|-------------|
|
|
250
|
+
| `toolkitSlug` | `string` | The toolkit to list grant contexts for |
|
|
251
|
+
| `params?` | `\{ authScheme?: 'OAUTH2' \| 'OAUTH1' \| 'API_KEY' \| 'BASIC' \| 'BILLCOM_AUTH' \| 'BEARER_TOKEN' \| 'GOOGLE_SERVICE_ACCOUNT' \| 'NO_AUTH' \| 'BASIC_WITH_JWT' \| 'CALCOM_AUTH' \| 'SERVICE_ACCOUNT' \| 'SAML' \| 'DCR_OAUTH' \| 'CIMD_OAUTH' \| 'S2S_OAUTH2'; toolkitVersion?: string \}` | Optional auth scheme and toolkit version |
|
|
252
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
253
|
+
|
|
254
|
+
**Returns**
|
|
255
|
+
|
|
256
|
+
`Promise<\{ authScheme: string; defaultGrantContext: Record<string, string>; grantContextDimensions: \{ description: string; dimension: string; values: string[] \}[]; toolkitVersion: string \}>` — The dimensions and the default grant context
|
|
257
|
+
|
|
258
|
+
**Example**
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
const { grantContextDimensions } = await composio.toolkits.listGrantContexts('gmail');
|
|
262
|
+
const [accountType] = grantContextDimensions;
|
|
263
|
+
const { scopes } = await composio.toolkits.recommendScopes('gmail', {
|
|
264
|
+
tools: ['GMAIL_SEND_EMAIL'],
|
|
265
|
+
grantContext: { [accountType.dimension]: accountType.values[0] },
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
### recommendScopes()
|
|
272
|
+
|
|
273
|
+
Recommends the OAuth scopes to request so a connection can run the given
|
|
274
|
+
tools.
|
|
275
|
+
**Experimental — the API marks this endpoint beta; shape may change.**
|
|
276
|
+
|
|
277
|
+
The answer comes in two variants: `leastPrivilege` (narrowest documented
|
|
278
|
+
scope per requirement) and `fewest` (smallest set covering everything).
|
|
279
|
+
Pass `toolkitVersion` from a previous answer to pin the computation.
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
async recommendScopes(toolkitSlug: string, params: { authScheme?: 'OAUTH2' | 'OAUTH1' | 'API_KEY' | 'BASIC' | 'BILLCOM_AUTH' | 'BEARER_TOKEN' | 'GOOGLE_SERVICE_ACCOUNT' | 'NO_AUTH' | 'BASIC_WITH_JWT' | 'CALCOM_AUTH' | 'SERVICE_ACCOUNT' | 'SAML' | 'DCR_OAUTH' | 'CIMD_OAUTH' | 'S2S_OAUTH2'; availableScopes?: string[]; exclude?: string[]; grantContext?: Record<string, string>; include?: string[]; toolkitVersion?: string; tools: string[] }, requestOptions?: ComposioRequestOptions): Promise<{ authScheme: string; grantContext: Record<string, string>; scopes: { conditional: { for: ...[]; scope: string; when: Record<..., ...> }[]; fewest: string[]; leastPrivilege: string[] }; toolkitVersion: string }>
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Parameters**
|
|
286
|
+
|
|
287
|
+
| Name | Type | Description |
|
|
288
|
+
|------|------|-------------|
|
|
289
|
+
| `toolkitSlug` | `string` | The toolkit to recommend scopes for |
|
|
290
|
+
| `params` | `\{ authScheme?: 'OAUTH2' \| 'OAUTH1' \| 'API_KEY' \| 'BASIC' \| 'BILLCOM_AUTH' \| 'BEARER_TOKEN' \| 'GOOGLE_SERVICE_ACCOUNT' \| 'NO_AUTH' \| 'BASIC_WITH_JWT' \| 'CALCOM_AUTH' \| 'SERVICE_ACCOUNT' \| 'SAML' \| 'DCR_OAUTH' \| 'CIMD_OAUTH' \| 'S2S_OAUTH2'; availableScopes?: string[]; exclude?: string[]; grantContext?: Record<string, string>; include?: string[]; toolkitVersion?: string; tools: string[] \}` | Tools to cover (`[]` for the whole toolkit), auth scheme, grant context and scope constraints |
|
|
291
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
292
|
+
|
|
293
|
+
**Returns**
|
|
294
|
+
|
|
295
|
+
`Promise<\{ authScheme: string; grantContext: Record<string, string>; scopes: \{ conditional: \{ for: ...[]; scope: string; when: Record<..., ...> \}[]; fewest: string[]; leastPrivilege: string[] \}; toolkitVersion: string \}>` — The recommended scope sets
|
|
296
|
+
|
|
297
|
+
**Example**
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
const { scopes } = await composio.toolkits.recommendScopes('gmail', {
|
|
301
|
+
tools: ['GMAIL_SEND_EMAIL', 'GMAIL_FETCH_EMAILS'],
|
|
302
|
+
});
|
|
303
|
+
console.log(scopes.leastPrivilege);
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
---
|