@composio/core 0.12.0 → 0.13.1
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/{BaseProvider-BBnsv9kS.d.mts → BaseProvider-Brb3o86-.d.mts} +80 -80
- package/dist/{CustomTool-DEB4BQPl.mjs → CustomTool-D9qwyMrv.mjs} +1 -1
- package/dist/{CustomTool-DH18rVQu.d.mts → CustomTool-DLf7JeKt.d.mts} +1 -1
- package/dist/CustomTool-NpHpqdnU.d.mts +74 -0
- package/dist/{composio-CHnEggnv.d.mts → composio-BHSQwOUz.d.mts} +503 -319
- package/dist/composio-DfPD7BAi.d.mts +5666 -0
- package/dist/{customTool.types-DpIdOJjL.d.mts → customTool.types-9yFqPjdw.d.mts} +448 -76
- package/dist/customTool.types-D-6YqFdW.d.mts +2826 -0
- package/dist/docs/error-consistency.md +97 -0
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +306 -0
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +205 -0
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +488 -0
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +94 -0
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +67 -0
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +304 -0
- package/dist/docs/reference/sdk-reference/typescript/meta.json +17 -0
- package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +107 -0
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +163 -0
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +252 -0
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +155 -0
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +169 -0
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +453 -0
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +434 -0
- package/dist/{errors-D5f4pfvI.mjs → errors-DSIlYfl5.mjs} +2 -2
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/index.d.mts +36 -6
- package/dist/index.mjs +455 -123
- package/dist/{jsonSchema-daqF3S3d.mjs → jsonSchema-CFKdONpP.mjs} +1 -1
- package/dist/{types-CaI5Z4PA.d.mts → types-BJLCRj9q.d.mts} +2 -2
- package/dist/types-CCh8qvui.d.mts +12 -0
- 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 +2 -2
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/docs/error-consistency.md +97 -0
- package/package.json +4 -3
- package/src/composio.ts +509 -0
- package/src/errors/AuthConfigErrors.ts +23 -0
- package/src/errors/ComposioError.ts +408 -0
- package/src/errors/ConnectedAccountsErrors.ts +158 -0
- package/src/errors/ConnectionRequestErrors.ts +32 -0
- package/src/errors/FileModifierErrors.ts +100 -0
- package/src/errors/PusherErrors.ts +28 -0
- package/src/errors/RemoteFileErrors.ts +62 -0
- package/src/errors/SDKErrors.ts +92 -0
- package/src/errors/ToolErrors.ts +244 -0
- package/src/errors/ToolkitErrors.ts +39 -0
- package/src/errors/TriggerErrors.ts +120 -0
- package/src/errors/ValidationErrors.ts +99 -0
- package/src/errors/index.ts +41 -0
- package/src/experimental/index.ts +28 -0
- package/src/index.ts +64 -0
- package/src/lib/toolRouterConstants.ts +1 -0
- package/src/lib/toolRouterParams.ts +306 -0
- package/src/lib/toolRouterSessionDelete.ts +30 -0
- package/src/models/AuthConfigs.ts +398 -0
- package/src/models/AuthScheme.ts +206 -0
- package/src/models/ConnectedAccounts.ts +735 -0
- package/src/models/ConnectionRequest.ts +150 -0
- package/src/models/CustomTool.ts +676 -0
- package/src/models/Experimental.ts +202 -0
- package/src/models/Files.node.ts +93 -0
- package/src/models/Files.workerd.ts +49 -0
- package/src/models/MCP.ts +478 -0
- package/src/models/RemoteFile.ts +172 -0
- package/src/models/SessionContext.ts +147 -0
- package/src/models/Sessions.ts +21 -0
- package/src/models/ToolRouter.ts +406 -0
- package/src/models/ToolRouterSession.ts +839 -0
- package/src/models/ToolRouterSessionFileMount.ts +389 -0
- package/src/models/Toolkits.ts +412 -0
- package/src/models/Tools.ts +1260 -0
- package/src/models/Triggers.ts +1381 -0
- package/src/models/customToolExecution.ts +118 -0
- package/src/models/inlineCustomToolsPayload.ts +17 -0
- package/src/models/proxyParamsTransform.ts +26 -0
- package/src/provider/BaseProvider.ts +138 -0
- package/src/provider/ComposioProvider.ts +29 -0
- package/src/provider/OpenAIProvider.ts +547 -0
- package/src/services/internal/InternalService.ts +50 -0
- package/src/services/internal/InternalService.types.ts +14 -0
- package/src/services/pusher/Pusher.ts +230 -0
- package/src/services/telemetry/TelemetryService.ts +48 -0
- package/src/services/telemetry/TelemetryService.types.ts +67 -0
- package/src/telemetry/BatchProcessor.ts +77 -0
- package/src/telemetry/README.md +123 -0
- package/src/telemetry/Telemetry.ts +356 -0
- package/src/types/ToolRouterSessionFilesMount.types.ts +96 -0
- package/src/types/authConfigs.types.ts +174 -0
- package/src/types/composio.types.ts +1 -0
- package/src/types/connectedAccountAuthStates.types.ts +852 -0
- package/src/types/connectedAccounts.types.ts +395 -0
- package/src/types/connectionRequest.types.ts +16 -0
- package/src/types/customTool.types.ts +261 -0
- package/src/types/files.types.ts +15 -0
- package/src/types/mcp.experimental.types.ts +163 -0
- package/src/types/mcp.types.ts +362 -0
- package/src/types/modifiers.types.ts +663 -0
- package/src/types/org.types.ts +0 -0
- package/src/types/provider.types.ts +41 -0
- package/src/types/pusher.types.ts +18 -0
- package/src/types/requestOptions.types.ts +62 -0
- package/src/types/telemetry.types.ts +89 -0
- package/src/types/tool.types.ts +408 -0
- package/src/types/toolRouter.types.ts +774 -0
- package/src/types/toolkit.types.ts +130 -0
- package/src/types/triggers.types.ts +401 -0
- package/src/types/webhookEvents.types.ts +219 -0
- package/src/utils/buffer.ts +30 -0
- package/src/utils/cancellation.ts +22 -0
- package/src/utils/config-defaults/ConfigDefaults.node.ts +7 -0
- package/src/utils/config-defaults/ConfigDefaults.workerd.ts +10 -0
- package/src/utils/config-defaults/index.ts +1 -0
- package/src/utils/config-defaults/types.ts +14 -0
- package/src/utils/constants.ts +22 -0
- package/src/utils/crypto.ts +34 -0
- package/src/utils/env.ts +34 -0
- package/src/utils/fileDirs.ts +81 -0
- package/src/utils/fileUtils.node.ts +458 -0
- package/src/utils/json-schema.ts +1 -0
- package/src/utils/jsonSchema.ts +355 -0
- package/src/utils/logger.ts +99 -0
- package/src/utils/mime.ts +75 -0
- package/src/utils/modifiers/FileToolModifier.node.ts +477 -0
- package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +132 -0
- package/src/utils/modifiers/FileToolModifier.workerd.ts +51 -0
- package/src/utils/pagination.ts +73 -0
- package/src/utils/pusher.ts +286 -0
- package/src/utils/schemaPropertyKeys.ts +433 -0
- package/src/utils/sdk.ts +110 -0
- package/src/utils/sensitiveFileUploadPaths.node.ts +105 -0
- package/src/utils/session.ts +114 -0
- package/src/utils/toolArguments.ts +73 -0
- package/src/utils/toolkitVersion.ts +26 -0
- package/src/utils/transform.ts +42 -0
- package/src/utils/transformers/authConfigs.ts +107 -0
- package/src/utils/transformers/connectedAccounts.ts +119 -0
- package/src/utils/transformers/mcp.ts +164 -0
- package/src/utils/transformers/toolRouterResponseTransform.ts +160 -0
- package/src/utils/transformers/toolkits.ts +100 -0
- package/src/utils/transformers/triggers.ts +118 -0
- package/src/utils/uploadDirAllowlist.node.ts +178 -0
- package/src/utils/uuid.ts +7 -0
- package/src/utils/version.ts +58 -0
- package/src/utils/zodSchema.ts +90 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Error Class Consistency in Composio SDK
|
|
2
|
+
|
|
3
|
+
This document outlines the standardized pattern for error classes in the Composio SDK.
|
|
4
|
+
|
|
5
|
+
## Standardized Error Class Pattern
|
|
6
|
+
|
|
7
|
+
All error classes in the Composio SDK follow this standard pattern:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
export class SomeSpecificError extends ComposioError {
|
|
11
|
+
constructor(
|
|
12
|
+
message: string = 'Default error message',
|
|
13
|
+
options: Omit<ComposioErrorOptions, 'code'> = {}
|
|
14
|
+
) {
|
|
15
|
+
super(message, {
|
|
16
|
+
...options,
|
|
17
|
+
code: ERROR_CODE_CONSTANT,
|
|
18
|
+
possibleFixes: options.possibleFixes || [
|
|
19
|
+
'Default fix suggestion 1',
|
|
20
|
+
'Default fix suggestion 2',
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
this.name = 'SomeSpecificError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Key Standardization Points
|
|
29
|
+
|
|
30
|
+
1. **Message Parameter**: All constructors accept a message string with a default value.
|
|
31
|
+
2. **Options Object**: All constructors take an options object (rather than individual properties).
|
|
32
|
+
3. **Default Values**: Default values are provided for both the message and options parameters.
|
|
33
|
+
4. **Preserving Options**: All options are preserved with `...options` and only specific properties are overridden.
|
|
34
|
+
5. **Default Fixes**: Default `possibleFixes` are provided but can be overridden.
|
|
35
|
+
6. **Name Property**: Each error class sets its `name` property to match the class name.
|
|
36
|
+
|
|
37
|
+
## Special Cases
|
|
38
|
+
|
|
39
|
+
Some error classes have specific requirements:
|
|
40
|
+
|
|
41
|
+
1. **ValidationError**: Accepts a `zodError` in the options.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
new ValidationError('Message', { cause: someZodError });
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
2. **ComposioToolExecutionError**: Accepts an `originalError` in the options.
|
|
48
|
+
```typescript
|
|
49
|
+
new ComposioToolExecutionError('Message', { originalError: someError });
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Using Error Classes
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// Basic usage
|
|
56
|
+
throw new ComposioNoAPIKeyError();
|
|
57
|
+
|
|
58
|
+
// With custom message
|
|
59
|
+
throw new ComposioToolNotFoundError('Could not find the specified tool');
|
|
60
|
+
|
|
61
|
+
// With additional options
|
|
62
|
+
throw new ComposioConnectedAccountNotFoundError('Account not found', {
|
|
63
|
+
meta: {
|
|
64
|
+
accountId: '12345',
|
|
65
|
+
userId: 'user123',
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Special cases
|
|
70
|
+
try {
|
|
71
|
+
// Some code that might throw
|
|
72
|
+
} catch (error) {
|
|
73
|
+
// Handle tool execution errors
|
|
74
|
+
throw new ComposioToolExecutionError('Tool failed', {
|
|
75
|
+
originalError: error,
|
|
76
|
+
meta: { toolId: 'some-tool' },
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Handle validation errors
|
|
80
|
+
throw new ValidationError('Validation failed', {
|
|
81
|
+
zodError: someZodError,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Utility Methods
|
|
87
|
+
|
|
88
|
+
All error classes inherit these helpful methods from `ComposioError`:
|
|
89
|
+
|
|
90
|
+
1. **toString()**: Returns a formatted string representation
|
|
91
|
+
2. **prettyPrint()**: Prints a formatted error message to the console
|
|
92
|
+
3. **toJSON()**: Returns a JSON representation of the error
|
|
93
|
+
|
|
94
|
+
## Static Factory Methods
|
|
95
|
+
|
|
96
|
+
1. **ComposioError.createAndPrint()**: Creates and prints an error in one step
|
|
97
|
+
2. **ComposioError.handle()**: Generic error handler for any error type
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "AuthConfigs"
|
|
3
|
+
description: "AuthConfigs class This class is used to manage authentication configurations in the Composio SDK. Auth configs are used to configure authentication providers and settings."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
Access this class through the `composio.authConfigs` property:
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
12
|
+
const result = await composio.authConfigs.list();
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### create()
|
|
18
|
+
|
|
19
|
+
Create a new auth config
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
async create(toolkit: string, options: CreateAuthConfigParams, requestOptions?: ComposioRequestOptions): Promise<CreateAuthConfigResponse>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Parameters**
|
|
26
|
+
|
|
27
|
+
| Name | Type | Description |
|
|
28
|
+
|------|------|-------------|
|
|
29
|
+
| `toolkit` | `string` | Unique identifier of the toolkit |
|
|
30
|
+
| `options` | `CreateAuthConfigParams` | Options for creating a new auth config |
|
|
31
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
32
|
+
|
|
33
|
+
**Returns**
|
|
34
|
+
|
|
35
|
+
`Promise<CreateAuthConfigResponse>` — Created auth config
|
|
36
|
+
|
|
37
|
+
**Example**
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
const authConfig = await authConfigs.create('my-toolkit', {
|
|
41
|
+
type: AuthConfigTypes.CUSTOM,
|
|
42
|
+
name: 'My Custom Auth Config',
|
|
43
|
+
authScheme: AuthSchemeTypes.API_KEY,
|
|
44
|
+
credentials: {
|
|
45
|
+
apiKey: '1234567890',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
### delete()
|
|
53
|
+
|
|
54
|
+
Deletes an authentication configuration.
|
|
55
|
+
|
|
56
|
+
This method permanently removes an auth config from the Composio platform.
|
|
57
|
+
This action cannot be undone and will prevent any connected accounts that use
|
|
58
|
+
this auth config from functioning.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
async delete(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<AuthConfigDeleteResponse>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Parameters**
|
|
65
|
+
|
|
66
|
+
| Name | Type | Description |
|
|
67
|
+
|------|------|-------------|
|
|
68
|
+
| `nanoid` | `string` | The unique identifier of the auth config to delete |
|
|
69
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
70
|
+
|
|
71
|
+
**Returns**
|
|
72
|
+
|
|
73
|
+
`Promise<AuthConfigDeleteResponse>` — The deletion response
|
|
74
|
+
|
|
75
|
+
**Example**
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
// Delete an auth config
|
|
79
|
+
await composio.authConfigs.delete('auth_abc123');
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
### disable()
|
|
85
|
+
|
|
86
|
+
Disables an authentication configuration.
|
|
87
|
+
|
|
88
|
+
This is a convenience method that calls updateStatus with 'DISABLED'.
|
|
89
|
+
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
|
|
93
|
+
async disable(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<AuthConfigUpdateStatusResponse>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Parameters**
|
|
97
|
+
|
|
98
|
+
| Name | Type | Description |
|
|
99
|
+
|------|------|-------------|
|
|
100
|
+
| `nanoid` | `string` | The unique identifier of the auth config to disable |
|
|
101
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
102
|
+
|
|
103
|
+
**Returns**
|
|
104
|
+
|
|
105
|
+
`Promise<AuthConfigUpdateStatusResponse>` — The updated auth config details
|
|
106
|
+
|
|
107
|
+
**Example**
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
// Disable an auth config
|
|
111
|
+
await composio.authConfigs.disable('auth_abc123');
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### enable()
|
|
117
|
+
|
|
118
|
+
Enables an authentication configuration.
|
|
119
|
+
|
|
120
|
+
This is a convenience method that calls updateStatus with 'ENABLED'.
|
|
121
|
+
When enabled, the auth config can be used to create new connected accounts
|
|
122
|
+
and authenticate with third-party services.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
async enable(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<AuthConfigUpdateStatusResponse>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Parameters**
|
|
129
|
+
|
|
130
|
+
| Name | Type | Description |
|
|
131
|
+
|------|------|-------------|
|
|
132
|
+
| `nanoid` | `string` | The unique identifier of the auth config to enable |
|
|
133
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
134
|
+
|
|
135
|
+
**Returns**
|
|
136
|
+
|
|
137
|
+
`Promise<AuthConfigUpdateStatusResponse>` — The updated auth config details
|
|
138
|
+
|
|
139
|
+
**Example**
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
// Enable an auth config
|
|
143
|
+
await composio.authConfigs.enable('auth_abc123');
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### get()
|
|
149
|
+
|
|
150
|
+
Retrieves a specific authentication configuration by its ID.
|
|
151
|
+
|
|
152
|
+
This method fetches detailed information about a single auth config
|
|
153
|
+
and transforms the response to the SDK's standardized format.
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
async get(nanoid: string, requestOptions?: ComposioRequestOptions): Promise<AuthConfigRetrieveResponse>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Parameters**
|
|
160
|
+
|
|
161
|
+
| Name | Type | Description |
|
|
162
|
+
|------|------|-------------|
|
|
163
|
+
| `nanoid` | `string` | The unique identifier of the auth config to retrieve |
|
|
164
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
165
|
+
|
|
166
|
+
**Returns**
|
|
167
|
+
|
|
168
|
+
`Promise<AuthConfigRetrieveResponse>` — The auth config details
|
|
169
|
+
|
|
170
|
+
**Example**
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
// Get an auth config by ID
|
|
174
|
+
const authConfig = await composio.authConfigs.get('auth_abc123');
|
|
175
|
+
console.log(authConfig.name); // e.g., 'GitHub Auth'
|
|
176
|
+
console.log(authConfig.toolkit.slug); // e.g., 'github'
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### list()
|
|
182
|
+
|
|
183
|
+
Lists authentication configurations based on provided filter criteria.
|
|
184
|
+
|
|
185
|
+
This method retrieves auth configs from the Composio API, transforms them to the SDK format,
|
|
186
|
+
and supports filtering by various parameters.
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
async list(query?: AuthConfigListParams, requestOptions?: ComposioRequestOptions): Promise<AuthConfigListResponse>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Parameters**
|
|
193
|
+
|
|
194
|
+
| Name | Type | Description |
|
|
195
|
+
|------|------|-------------|
|
|
196
|
+
| `query?` | `AuthConfigListParams` | Optional query parameters for filtering auth configs |
|
|
197
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
198
|
+
|
|
199
|
+
**Returns**
|
|
200
|
+
|
|
201
|
+
`Promise<AuthConfigListResponse>` — A paginated list of auth configurations
|
|
202
|
+
|
|
203
|
+
**Example**
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// List all auth configs
|
|
207
|
+
const allConfigs = await composio.authConfigs.list();
|
|
208
|
+
|
|
209
|
+
// List auth configs for a specific toolkit
|
|
210
|
+
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
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### update()
|
|
229
|
+
|
|
230
|
+
Updates an existing authentication configuration.
|
|
231
|
+
|
|
232
|
+
This method allows you to modify properties of an auth config such as credentials,
|
|
233
|
+
scopes, or tool restrictions. The update type (custom or default) determines which
|
|
234
|
+
fields can be updated.
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
async update(nanoid: string, data: AuthConfigUpdateParams, requestOptions?: ComposioRequestOptions): Promise<AuthConfigUpdateResponse>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Parameters**
|
|
241
|
+
|
|
242
|
+
| Name | Type | Description |
|
|
243
|
+
|------|------|-------------|
|
|
244
|
+
| `nanoid` | `string` | The unique identifier of the auth config to update |
|
|
245
|
+
| `data` | `AuthConfigUpdateParams` | The data to update, which can be either custom or default type |
|
|
246
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
247
|
+
|
|
248
|
+
**Returns**
|
|
249
|
+
|
|
250
|
+
`Promise<AuthConfigUpdateResponse>` — The updated auth config
|
|
251
|
+
|
|
252
|
+
**Example**
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
// Update a custom auth config with new credentials
|
|
256
|
+
const updatedConfig = await composio.authConfigs.update('auth_abc123', {
|
|
257
|
+
type: 'custom',
|
|
258
|
+
credentials: {
|
|
259
|
+
apiKey: 'new-api-key-value'
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// Update a default auth config with new scopes
|
|
264
|
+
const updatedConfig = await composio.authConfigs.update('auth_abc123', {
|
|
265
|
+
type: 'default',
|
|
266
|
+
scopes: ['read:user', 'repo']
|
|
267
|
+
});
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
### updateStatus()
|
|
273
|
+
|
|
274
|
+
Updates the status of an authentication configuration.
|
|
275
|
+
|
|
276
|
+
This method allows you to enable or disable an auth config. When disabled,
|
|
277
|
+
the auth config cannot be used to create new connected accounts or authenticate
|
|
278
|
+
with third-party services.
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
async updateStatus(status: 'ENABLED' | 'DISABLED', nanoid: string, requestOptions?: ComposioRequestOptions): Promise<AuthConfigUpdateStatusResponse>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Parameters**
|
|
285
|
+
|
|
286
|
+
| Name | Type | Description |
|
|
287
|
+
|------|------|-------------|
|
|
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
|
+
|
|
294
|
+
`Promise<AuthConfigUpdateStatusResponse>` — The updated auth config details
|
|
295
|
+
|
|
296
|
+
**Example**
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
// Disable an auth config
|
|
300
|
+
await composio.authConfigs.updateStatus('DISABLED', 'auth_abc123');
|
|
301
|
+
|
|
302
|
+
// Enable an auth config
|
|
303
|
+
await composio.authConfigs.updateStatus('ENABLED', 'auth_abc123');
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
---
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Composio"
|
|
3
|
+
description: "This is the core class for Composio. It is used to initialize the Composio SDK and provide a global configuration."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Constructor
|
|
7
|
+
|
|
8
|
+
### constructor()
|
|
9
|
+
|
|
10
|
+
Creates a new instance of the Composio SDK.
|
|
11
|
+
|
|
12
|
+
The constructor initializes the SDK with the provided configuration options,
|
|
13
|
+
sets up the API client, and initializes all core models (tools, toolkits, etc.).
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
constructor(config?: ComposioConfig): Composio
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Parameters**
|
|
20
|
+
|
|
21
|
+
| Name | Type | Description |
|
|
22
|
+
|------|------|-------------|
|
|
23
|
+
| `config?` | `ComposioConfig` | Configuration options for the Composio SDK |
|
|
24
|
+
|
|
25
|
+
**Returns**
|
|
26
|
+
|
|
27
|
+
`Composio`
|
|
28
|
+
|
|
29
|
+
**Example**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
// Initialize with default configuration
|
|
33
|
+
const composio = new Composio();
|
|
34
|
+
|
|
35
|
+
// Initialize with custom API key and base URL
|
|
36
|
+
const composio = new Composio({
|
|
37
|
+
apiKey: 'your-api-key',
|
|
38
|
+
baseURL: 'https://api.composio.dev'
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Initialize with custom provider
|
|
42
|
+
const composio = new Composio({
|
|
43
|
+
apiKey: 'your-api-key',
|
|
44
|
+
provider: new CustomProvider()
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Properties
|
|
51
|
+
|
|
52
|
+
| Name | Type | Description |
|
|
53
|
+
|------|------|-------------|
|
|
54
|
+
| `authConfigs` | `AuthConfigs` | Manage authentication configurations for toolkits |
|
|
55
|
+
| `connectedAccounts` | `ConnectedAccounts` | Manage authenticated connections |
|
|
56
|
+
| `create` | `(userId: string, config: \{ authConfigs?: Record<string, string>; connectedAccounts?: Record<string, string \| ...[]>; experimental?: \{ assistivePrompt?: \{ userTimezone?: string \}; customToolkits?: CustomToolkit[]; customTools?: CustomTool[] \}; manageConnections?: boolean \| \{ callbackUrl?: string; enable?: boolean; waitForConnections?: boolean \}; mcp?: boolean; multiAccount?: \{ enable: boolean; maxAccountsPerToolkit?: number; requireExplicitSelection?: boolean \}; preload?: \{ tools?: ...[] \| 'all' \}; sandbox?: \{ autoOffloadThreshold?: number; enable: boolean; enableProxyExecution?: boolean; sandboxSize?: 'standard' \| 'medium' \| 'large' \| 'xlarge' \}; sessionPreset?: 'direct_tools'; tags?: ... \| ... \| ... \| ...[] \| \{ disable?: ...[]; enable?: ...[] \}; toolkits?: string[] \| \{ disable: ...[] \} \| \{ enable: ...[] \}; tools?: Record<string, ...[] \| \{ enable: ... \} \| \{ disable: ... \} \| \{ tags: ... \}>; workbench?: \{ autoOffloadThreshold?: number; enable: boolean; enableProxyExecution?: boolean; sandboxSize?: 'standard' \| 'medium' \| 'large' \| 'xlarge' \} \} & \{ mcp: true \}, 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.
|
|
60
|
+
Prefer domain-specific mounts (for example
|
|
61
|
+
`composio.connectedAccounts.updateAcl(...)`) when available; this
|
|
62
|
+
namespace keeps compatibility aliases while APIs are experimental.
|
|
63
|
+
Stateless experimental factories (e.g. `experimental_createTool`) stay
|
|
64
|
+
at the top level. |
|
|
65
|
+
| `files` | `Files` | Upload and download files |
|
|
66
|
+
| `mcp` | `MCP` | Model Context Protocol server management. |
|
|
67
|
+
| `provider` | `TProvider` | The tool provider instance used for wrapping tools in framework-specific formats |
|
|
68
|
+
| `sessions` | `Sessions` | Create and reuse Composio sessions.
|
|
69
|
+
|
|
70
|
+
Prefer `composio.sessions.create(...)` for new code. The top-level
|
|
71
|
+
`composio.create(...)` method is kept as an alias. |
|
|
72
|
+
| `toolkits` | `Toolkits` | Retrieve toolkit metadata and authorize user connections |
|
|
73
|
+
| `toolRouter` | `ToolRouter` | Legacy alias for `composio.sessions`. |
|
|
74
|
+
| `tools` | `Tools` | List, retrieve, and execute tools |
|
|
75
|
+
| `triggers` | `Triggers` | Manage webhook triggers and event subscriptions |
|
|
76
|
+
| `use` | `(id: string, options: \{ customToolkits?: CustomToolkit[]; customTools?: CustomTool[]; mcp: true \}, requestOptions: ComposioRequestOptions) => Promise<Session>` | Use an existing tool router session |
|
|
77
|
+
|
|
78
|
+
## Methods
|
|
79
|
+
|
|
80
|
+
### createSession() (deprecated)
|
|
81
|
+
|
|
82
|
+
<Callout type="warn" title="Deprecated">
|
|
83
|
+
Will be removed in a future version of the SDK. Instead, construct a new
|
|
84
|
+
instance directly with the headers you need: `new Composio(\{ ...existingConfig, defaultHeaders \})`.
|
|
85
|
+
For one-off overrides, pass per-call `requestOptions` where supported.
|
|
86
|
+
</Callout>
|
|
87
|
+
|
|
88
|
+
Creates a new instance of the Composio SDK with custom request options while preserving the existing configuration.
|
|
89
|
+
This method is particularly useful when you need to:
|
|
90
|
+
- Add custom headers for specific requests
|
|
91
|
+
- Track request contexts with unique identifiers
|
|
92
|
+
- Override default request behavior for a subset of operations
|
|
93
|
+
|
|
94
|
+
The new instance inherits all configuration from the parent instance (apiKey, baseURL, provider, etc.)
|
|
95
|
+
but allows you to specify custom request options that will be used for all API calls made through this session.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
createSession(options?: { headers?: ComposioRequestHeaders }): Composio
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Parameters**
|
|
102
|
+
|
|
103
|
+
| Name | Type |
|
|
104
|
+
|------|------|
|
|
105
|
+
| `options?` | `\{ headers?: ComposioRequestHeaders \}` |
|
|
106
|
+
|
|
107
|
+
**Returns**
|
|
108
|
+
|
|
109
|
+
`Composio` — A new Composio instance with the custom request options applied.
|
|
110
|
+
|
|
111
|
+
**Example**
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
// Create a base Composio instance
|
|
115
|
+
const composio = new Composio({
|
|
116
|
+
apiKey: 'your-api-key'
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Create a session with request tracking headers
|
|
120
|
+
const composioWithCustomHeaders = composio.createSession({
|
|
121
|
+
headers: {
|
|
122
|
+
'x-request-id': '1234567890',
|
|
123
|
+
'x-correlation-id': 'session-abc-123',
|
|
124
|
+
'x-custom-header': 'custom-value'
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Use the session for making API calls with the custom headers
|
|
129
|
+
await composioWithCustomHeaders.tools.list();
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### flush()
|
|
135
|
+
|
|
136
|
+
Flush any pending telemetry and wait for it to complete.
|
|
137
|
+
|
|
138
|
+
In Node.js-compatible environments, telemetry is automatically flushed on process exit.
|
|
139
|
+
However, in environments like Cloudflare Workers that don't support process exit events,
|
|
140
|
+
you should call this method manually to ensure all telemetry is sent.
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
async flush(): Promise<void>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Returns**
|
|
147
|
+
|
|
148
|
+
`Promise<void>` — A promise that resolves when all pending telemetry has been sent.
|
|
149
|
+
|
|
150
|
+
**Example**
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
// In a Cloudflare Worker, use ctx.waitUntil to ensure telemetry is flushed
|
|
154
|
+
export default {
|
|
155
|
+
async fetch(request: Request, env: Env, ctx: ExecutionContext) {
|
|
156
|
+
const composio = new Composio({ apiKey: env.COMPOSIO_API_KEY });
|
|
157
|
+
|
|
158
|
+
// Do your work...
|
|
159
|
+
const result = await composio.tools.execute(...);
|
|
160
|
+
|
|
161
|
+
// Ensure telemetry flushes before worker terminates
|
|
162
|
+
ctx.waitUntil(composio.flush());
|
|
163
|
+
|
|
164
|
+
return new Response(JSON.stringify(result));
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### getClient()
|
|
172
|
+
|
|
173
|
+
Get the Composio SDK client.
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
getClient(): ComposioClient
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Returns**
|
|
180
|
+
|
|
181
|
+
`ComposioClient` — The Composio API client.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
### getConfig()
|
|
186
|
+
|
|
187
|
+
Get the configuration SDK is initialized with.
|
|
188
|
+
|
|
189
|
+
Returns a frozen shallow clone — the SDK has already snapshotted
|
|
190
|
+
configuration values such as `dangerouslyAllowAutoUploadDownloadFiles`,
|
|
191
|
+
`fileUploadDirs`, and `fileDownloadDir` into its internal models, so
|
|
192
|
+
mutating the live config object would silently no-op. Freezing makes
|
|
193
|
+
that contract visible at the call site instead of letting the mutation
|
|
194
|
+
appear successful.
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
getConfig(): Readonly<ComposioConfig>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Returns**
|
|
201
|
+
|
|
202
|
+
`Readonly<ComposioConfig>` — The frozen configuration
|
|
203
|
+
the SDK is initialized with.
|
|
204
|
+
|
|
205
|
+
---
|