@composio/core 0.31.0 → 0.32.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-9Vlb4XaS.mjs → CustomTool-B4dQn2M5.mjs} +1 -1
- package/dist/{CustomTool-Ds5aLDth.d.mts → CustomTool-CBx9kzea.d.mts} +1 -1
- package/dist/{FileModifierErrors-WrqokuIF.mjs → FileModifierErrors-D-AKc3ds.mjs} +1 -1
- package/dist/{SsrfErrors-BSVMW915.mjs → SsrfErrors-BekZPeWY.mjs} +59 -12
- package/dist/{Telemetry-a7SOQXcg.mjs → Telemetry-BWKZmDxM.mjs} +2 -2
- package/dist/composio-CPf6NHnB.d.mts +20334 -0
- package/dist/{customTool.types-DHxXBU6E.d.mts → customTool.types-BSbIG1OG.d.mts} +291 -68
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +20 -12
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +28 -10
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +44 -32
- package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +8 -6
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +4 -3
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +4 -2
- package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +6 -3
- package/dist/docs/reference/sdk-reference/typescript/logs.mdx +5 -3
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +53 -42
- package/dist/docs/reference/sdk-reference/typescript/meta.json +1 -0
- package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +5 -14
- package/dist/docs/reference/sdk-reference/typescript/session-configs.mdx +5 -3
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +7 -5
- package/dist/docs/reference/sdk-reference/typescript/session-webhooks.mdx +64 -0
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +16 -16
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +36 -8
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +14 -11
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +16 -18
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +42 -30
- package/dist/docs/reference/sdk-reference/typescript/usage.mdx +6 -4
- package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +9 -7
- package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +13 -9
- package/dist/docs/reference/sdk-reference/typescript/webhooks.mdx +3 -1
- package/dist/{errors-xC13uvaA.mjs → errors-CtIKA9BH.mjs} +2 -2
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-CAwIbWYH.mjs → fileUtils.node-BJUYMEph.mjs} +7 -7
- package/dist/index.d.mts +6 -11
- package/dist/index.mjs +526 -233
- package/dist/{jsonSchema-Cc4EtHRw.mjs → jsonSchema-BZoXGUCr.mjs} +2 -2
- package/dist/models/Files.node.mjs +3 -3
- package/dist/{sensitiveFileUploadPaths-CSyJ3Ku8.mjs → sensitiveFileUploadPaths-CcbMAYCC.mjs} +21 -15
- package/dist/{ssrfGuard.node-CdIkwqVu.mjs → ssrfGuard.node-B749ae5Q.mjs} +1 -1
- package/dist/{types-DcdZy5Nc.d.mts → types-ns3Q_WrP.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 +2 -2
- package/src/composio.ts +26 -7
- package/src/errors/ComposioError.ts +3 -2
- package/src/index.ts +19 -0
- package/src/lib/toolRouterParams.ts +38 -14
- package/src/models/AuthConfigs.ts +10 -3
- package/src/models/ConnectedAccounts.ts +30 -17
- package/src/models/CustomTool.ts +0 -10
- package/src/models/Keyring.ts +2 -1
- package/src/models/MCP.ts +43 -35
- package/src/models/SessionWebhooks.ts +136 -0
- package/src/models/ToolRouter.ts +39 -4
- package/src/models/ToolRouterSession.ts +2 -2
- package/src/models/ToolRouterSessionFileMount.ts +3 -1
- package/src/models/Toolkits.ts +1 -0
- package/src/models/Tools.ts +4 -8
- package/src/models/Triggers.ts +48 -213
- package/src/models/Webhooks.ts +2 -0
- package/src/provider/ComposioProvider.ts +0 -1
- package/src/telemetry/BatchProcessor.ts +1 -1
- package/src/telemetry/Telemetry.ts +1 -1
- package/src/types/connectedAccountAuthStates.types.ts +0 -1
- package/src/types/provider.types.ts +0 -1
- package/src/types/sessionWebhooks.types.ts +292 -0
- package/src/types/toolRouter.types.ts +33 -4
- package/src/types/triggers.types.ts +4 -0
- package/src/utils/crypto.ts +6 -5
- package/src/utils/env.ts +2 -5
- package/src/utils/fileUtils.node.ts +4 -3
- package/src/utils/logger.ts +19 -9
- package/src/utils/pusher.ts +5 -2
- package/src/utils/readResponseBody.ts +30 -17
- package/src/utils/transformers/authConfigs.ts +0 -1
- package/src/utils/userCallback.ts +3 -1
- package/src/utils/webhookVerification.ts +211 -0
- package/dist/composio-Ba89XGHL.d.mts +0 -9736
|
@@ -13,11 +13,15 @@ backwards compatibility. Prefer the session MCP endpoint; do not generate new co
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
+
The `composio.mcp` property is deprecated.
|
|
17
|
+
|
|
16
18
|
Access this class through the `composio.mcp` property:
|
|
17
19
|
|
|
18
20
|
```typescript
|
|
21
|
+
import { Composio } from '@composio/core';
|
|
22
|
+
|
|
19
23
|
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
20
|
-
const
|
|
24
|
+
const mcp = composio.mcp;
|
|
21
25
|
```
|
|
22
26
|
|
|
23
27
|
## Properties
|
|
@@ -32,7 +36,7 @@ const result = await composio.mcp.list();
|
|
|
32
36
|
|
|
33
37
|
Create a new MCP configuration.
|
|
34
38
|
|
|
35
|
-
```typescript
|
|
39
|
+
```typescript signature
|
|
36
40
|
async create(name: string, mcpConfig: MCPConfigCreationParams, requestOptions?: ComposioRequestOptions): Promise<MCPConfigCreateResponse>
|
|
37
41
|
```
|
|
38
42
|
|
|
@@ -51,18 +55,18 @@ async create(name: string, mcpConfig: MCPConfigCreationParams, requestOptions?:
|
|
|
51
55
|
**Example**
|
|
52
56
|
|
|
53
57
|
```typescript
|
|
54
|
-
const server = await composio.
|
|
58
|
+
const server = await composio.mcp.create("personal-mcp-server", {
|
|
55
59
|
toolkits: ["github", "slack"],
|
|
56
|
-
allowedTools: ["
|
|
60
|
+
allowedTools: ["GITHUB_CREATE_AN_ISSUE", "SLACK_SEND_MESSAGE"],
|
|
57
61
|
manuallyManageConnections: false
|
|
58
|
-
}
|
|
59
62
|
});
|
|
63
|
+
```
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
```typescript
|
|
66
|
+
const server = await composio.mcp.create("personal-mcp-server", {
|
|
62
67
|
toolkits: [{ toolkit: "gmail", authConfigId: "ac_243434343" }],
|
|
63
68
|
allowedTools: ["GMAIL_FETCH_EMAILS"],
|
|
64
69
|
manuallyManageConnections: false
|
|
65
|
-
}
|
|
66
70
|
});
|
|
67
71
|
```
|
|
68
72
|
|
|
@@ -72,7 +76,7 @@ const server = await composio.mcpConfig.create("personal-mcp-server", {
|
|
|
72
76
|
|
|
73
77
|
Delete an MCP server configuration permanently
|
|
74
78
|
|
|
75
|
-
```typescript
|
|
79
|
+
```typescript signature
|
|
76
80
|
async delete(serverId: string, requestOptions?: ComposioRequestOptions): Promise<{ id: string; deleted: boolean }>
|
|
77
81
|
```
|
|
78
82
|
|
|
@@ -91,7 +95,7 @@ async delete(serverId: string, requestOptions?: ComposioRequestOptions): Promise
|
|
|
91
95
|
|
|
92
96
|
```typescript
|
|
93
97
|
// Delete an MCP server by ID
|
|
94
|
-
const result = await composio.
|
|
98
|
+
const result = await composio.mcp.delete("mcp_12345");
|
|
95
99
|
|
|
96
100
|
if (result.deleted) {
|
|
97
101
|
console.log(`Server ${result.id} has been successfully deleted`);
|
|
@@ -101,15 +105,15 @@ if (result.deleted) {
|
|
|
101
105
|
|
|
102
106
|
// Example with error handling
|
|
103
107
|
try {
|
|
104
|
-
const result = await composio.
|
|
108
|
+
const result = await composio.mcp.delete("mcp_12345");
|
|
105
109
|
console.log("Deletion successful:", result);
|
|
106
110
|
} catch (error) {
|
|
107
|
-
console.error("Failed to delete MCP server:", error
|
|
111
|
+
console.error("Failed to delete MCP server:", error);
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
// Delete and verify from list
|
|
111
|
-
await composio.
|
|
112
|
-
const servers = await composio.
|
|
115
|
+
await composio.mcp.delete("mcp_12345");
|
|
116
|
+
const servers = await composio.mcp.list({ page: 1, limit: 10, toolkits: [], authConfigs: [] });
|
|
113
117
|
const serverExists = servers.items.some(server => server.id === "mcp_12345");
|
|
114
118
|
console.log("Server still exists:", serverExists); // Should be false
|
|
115
119
|
```
|
|
@@ -121,7 +125,7 @@ console.log("Server still exists:", serverExists); // Should be false
|
|
|
121
125
|
Get server URLs for an existing MCP server.
|
|
122
126
|
The response is wrapped according to the provider's specifications.
|
|
123
127
|
|
|
124
|
-
```typescript
|
|
128
|
+
```typescript signature
|
|
125
129
|
async generate(userId: string, mcpConfigId: string, options?: MCPGetInstanceParams, requestOptions?: ComposioRequestOptions): Promise<MCPServerInstance>
|
|
126
130
|
```
|
|
127
131
|
|
|
@@ -141,10 +145,10 @@ async generate(userId: string, mcpConfigId: string, options?: MCPGetInstancePara
|
|
|
141
145
|
**Example**
|
|
142
146
|
|
|
143
147
|
```typescript
|
|
144
|
-
import { Composio } from "@composio/
|
|
148
|
+
import { Composio } from "@composio/core";
|
|
145
149
|
|
|
146
150
|
const composio = new Composio();
|
|
147
|
-
const mcp = await composio.
|
|
151
|
+
const mcp = await composio.mcp.generate("default", "<mcp_config_id>");
|
|
148
152
|
```
|
|
149
153
|
|
|
150
154
|
---
|
|
@@ -153,7 +157,7 @@ const mcp = await composio.experimental.mcp.generate("default", "<mcp_config_id>
|
|
|
153
157
|
|
|
154
158
|
Retrieve detailed information about a specific MCP server by its ID
|
|
155
159
|
|
|
156
|
-
```typescript
|
|
160
|
+
```typescript signature
|
|
157
161
|
async get(serverId: string, requestOptions?: ComposioRequestOptions): Promise<MCPItem>
|
|
158
162
|
```
|
|
159
163
|
|
|
@@ -172,7 +176,7 @@ async get(serverId: string, requestOptions?: ComposioRequestOptions): Promise<MC
|
|
|
172
176
|
|
|
173
177
|
```typescript
|
|
174
178
|
// Get a specific MCP server by ID
|
|
175
|
-
const server = await composio.
|
|
179
|
+
const server = await composio.mcp.get("mcp_12345");
|
|
176
180
|
|
|
177
181
|
console.log(server.name); // "My Personal MCP Server"
|
|
178
182
|
console.log(server.allowedTools); // ["GITHUB_CREATE_AN_ISSUE", "SLACK_SEND_MESSAGE"]
|
|
@@ -194,7 +198,7 @@ const mcpUrl = server.MCPUrl;
|
|
|
194
198
|
|
|
195
199
|
List the MCP servers with optional filtering and pagination
|
|
196
200
|
|
|
197
|
-
```typescript
|
|
201
|
+
```typescript signature
|
|
198
202
|
async list(options: MCPListParams, requestOptions?: ComposioRequestOptions): Promise<MCPListResponse>
|
|
199
203
|
```
|
|
200
204
|
|
|
@@ -212,22 +216,31 @@ async list(options: MCPListParams, requestOptions?: ComposioRequestOptions): Pro
|
|
|
212
216
|
**Example**
|
|
213
217
|
|
|
214
218
|
```typescript
|
|
215
|
-
// List
|
|
216
|
-
const allServers = await composio.
|
|
219
|
+
// List the first page of MCP servers
|
|
220
|
+
const allServers = await composio.mcp.list({ page: 1, limit: 10, toolkits: [], authConfigs: [] });
|
|
217
221
|
|
|
218
222
|
// List with pagination
|
|
219
|
-
const pagedServers = await composio.
|
|
223
|
+
const pagedServers = await composio.mcp.list({
|
|
220
224
|
page: 2,
|
|
221
|
-
limit: 5
|
|
225
|
+
limit: 5,
|
|
226
|
+
toolkits: [],
|
|
227
|
+
authConfigs: []
|
|
222
228
|
});
|
|
223
229
|
|
|
224
230
|
// Filter by toolkit
|
|
225
|
-
const githubServers = await composio.
|
|
226
|
-
|
|
231
|
+
const githubServers = await composio.mcp.list({
|
|
232
|
+
page: 1,
|
|
233
|
+
limit: 10,
|
|
234
|
+
toolkits: ['github', 'slack'],
|
|
235
|
+
authConfigs: []
|
|
227
236
|
});
|
|
228
237
|
|
|
229
238
|
// Filter by name
|
|
230
|
-
const namedServers = await composio.
|
|
239
|
+
const namedServers = await composio.mcp.list({
|
|
240
|
+
page: 1,
|
|
241
|
+
limit: 10,
|
|
242
|
+
toolkits: [],
|
|
243
|
+
authConfigs: [],
|
|
231
244
|
name: 'personal'
|
|
232
245
|
});
|
|
233
246
|
```
|
|
@@ -238,7 +251,7 @@ const namedServers = await composio.experimental.mcp.list({
|
|
|
238
251
|
|
|
239
252
|
Update an existing MCP server configuration with new settings
|
|
240
253
|
|
|
241
|
-
```typescript
|
|
254
|
+
```typescript signature
|
|
242
255
|
async update(serverId: string, config: MCPUpdateParams, requestOptions?: ComposioRequestOptions): Promise<MCPItem>
|
|
243
256
|
```
|
|
244
257
|
|
|
@@ -258,34 +271,32 @@ async update(serverId: string, config: MCPUpdateParams, requestOptions?: Composi
|
|
|
258
271
|
|
|
259
272
|
```typescript
|
|
260
273
|
// Update server name only
|
|
261
|
-
const updatedServer = await composio.
|
|
274
|
+
const updatedServer = await composio.mcp.update("mcp_12345", {
|
|
262
275
|
name: "My Updated MCP Server"
|
|
263
276
|
});
|
|
264
277
|
|
|
265
278
|
// Update toolkits and tools
|
|
266
|
-
const serverWithNewTools = await composio.
|
|
279
|
+
const serverWithNewTools = await composio.mcp.update("mcp_12345", {
|
|
267
280
|
toolkits: [
|
|
268
|
-
{
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
allowedTools: ["SLACK_SEND_MESSAGE", "SLACK_LIST_CHANNELS"]
|
|
277
|
-
}
|
|
281
|
+
{ toolkit: "github", authConfigId: "auth_abc123" },
|
|
282
|
+
{ toolkit: "slack", authConfigId: "auth_xyz789" }
|
|
283
|
+
],
|
|
284
|
+
allowedTools: [
|
|
285
|
+
"GITHUB_CREATE_AN_ISSUE",
|
|
286
|
+
"GITHUB_LIST_REPOS",
|
|
287
|
+
"SLACK_SEND_MESSAGE",
|
|
288
|
+
"SLACK_LIST_CHANNELS"
|
|
278
289
|
]
|
|
279
290
|
});
|
|
280
291
|
|
|
281
292
|
// Update connection management setting
|
|
282
|
-
const serverWithManualAuth = await composio.
|
|
293
|
+
const serverWithManualAuth = await composio.mcp.update("mcp_12345", {
|
|
283
294
|
name: "Manual Auth Server",
|
|
284
295
|
manuallyManageConnections: true
|
|
285
296
|
});
|
|
286
297
|
|
|
287
298
|
// Complete update example
|
|
288
|
-
const fullyUpdatedServer = await composio.
|
|
299
|
+
const fullyUpdatedServer = await composio.mcp.update("mcp_12345", {
|
|
289
300
|
name: "Production MCP Server",
|
|
290
301
|
toolkits: [
|
|
291
302
|
{
|
|
@@ -293,7 +304,7 @@ const fullyUpdatedServer = await composio.experimental.mcp.update("mcp_12345", {
|
|
|
293
304
|
authConfigId: "auth_gmail_prod",
|
|
294
305
|
}
|
|
295
306
|
],
|
|
296
|
-
allowedTools: ["GMAIL_SEND_EMAIL", "GMAIL_FETCH_EMAILS"]
|
|
307
|
+
allowedTools: ["GMAIL_SEND_EMAIL", "GMAIL_FETCH_EMAILS"],
|
|
297
308
|
manuallyManageConnections: false
|
|
298
309
|
});
|
|
299
310
|
|
|
@@ -3,15 +3,6 @@ title: "RemoteFile"
|
|
|
3
3
|
description: "Represents a file stored in a tool router session's file mount. Provides methods to fetch, save, and work with the file content."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
## Usage
|
|
7
|
-
|
|
8
|
-
Access this class through the `composio.remoteFile` property:
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
12
|
-
const result = await composio.remoteFile.list();
|
|
13
|
-
```
|
|
14
|
-
|
|
15
6
|
## Properties
|
|
16
7
|
|
|
17
8
|
| Name | Type | Description |
|
|
@@ -27,7 +18,7 @@ const result = await composio.remoteFile.list();
|
|
|
27
18
|
|
|
28
19
|
Fetches the file content as a Blob.
|
|
29
20
|
|
|
30
|
-
```typescript
|
|
21
|
+
```typescript signature
|
|
31
22
|
async blob(): Promise<Blob>
|
|
32
23
|
```
|
|
33
24
|
|
|
@@ -41,7 +32,7 @@ async blob(): Promise<Blob>
|
|
|
41
32
|
|
|
42
33
|
Fetches the file content as a buffer.
|
|
43
34
|
|
|
44
|
-
```typescript
|
|
35
|
+
```typescript signature
|
|
45
36
|
async buffer(): Promise<Uint8Array>
|
|
46
37
|
```
|
|
47
38
|
|
|
@@ -56,7 +47,7 @@ async buffer(): Promise<Uint8Array>
|
|
|
56
47
|
Downloads and saves the file to the local filesystem.
|
|
57
48
|
Requires a Node.js runtime with file system support (not available in Cloudflare Workers/Edge).
|
|
58
49
|
|
|
59
|
-
```typescript
|
|
50
|
+
```typescript signature
|
|
60
51
|
async save(path?: string): Promise<string>
|
|
61
52
|
```
|
|
62
53
|
|
|
@@ -76,7 +67,7 @@ async save(path?: string): Promise<string>
|
|
|
76
67
|
|
|
77
68
|
Fetches the file content as UTF-8 text.
|
|
78
69
|
|
|
79
|
-
```typescript
|
|
70
|
+
```typescript signature
|
|
80
71
|
async text(): Promise<string>
|
|
81
72
|
```
|
|
82
73
|
|
|
@@ -90,7 +81,7 @@ async text(): Promise<string>
|
|
|
90
81
|
|
|
91
82
|
Parses an API response (snake_case) and returns a RemoteFile instance.
|
|
92
83
|
|
|
93
|
-
```typescript
|
|
84
|
+
```typescript signature
|
|
94
85
|
parse(data: unknown): RemoteFile
|
|
95
86
|
```
|
|
96
87
|
|
|
@@ -8,8 +8,10 @@ description: "`composio.sessionConfigs` — saved, reusable Session configs. A
|
|
|
8
8
|
Access this class through the `composio.sessionConfigs` property:
|
|
9
9
|
|
|
10
10
|
```typescript
|
|
11
|
+
import { Composio } from '@composio/core';
|
|
12
|
+
|
|
11
13
|
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
12
|
-
const
|
|
14
|
+
const sessionConfigs = composio.sessionConfigs;
|
|
13
15
|
```
|
|
14
16
|
|
|
15
17
|
## Methods
|
|
@@ -21,7 +23,7 @@ policy. A missing or cross-project id surfaces as the backend's 404.
|
|
|
21
23
|
|
|
22
24
|
Requires Session configs to be enabled for the project.
|
|
23
25
|
|
|
24
|
-
```typescript
|
|
26
|
+
```typescript signature
|
|
25
27
|
async get(id: string, requestOptions?: ComposioRequestOptions): Promise<SessionConfig>
|
|
26
28
|
```
|
|
27
29
|
|
|
@@ -54,7 +56,7 @@ archived ones. The backend defaults `limit` to 20 and caps it at 100.
|
|
|
54
56
|
|
|
55
57
|
Requires Session configs to be enabled for the project.
|
|
56
58
|
|
|
57
|
-
```typescript
|
|
59
|
+
```typescript signature
|
|
58
60
|
async list(params?: SessionConfigListParams, requestOptions?: ComposioRequestOptions): Promise<SessionConfigListResponse>
|
|
59
61
|
```
|
|
60
62
|
|
|
@@ -12,7 +12,7 @@ Deletes a file or directory at the specified path on the session's file mount.
|
|
|
12
12
|
Removes the file or directory from the virtual filesystem. Use with caution:
|
|
13
13
|
deletion is typically irreversible. Ensure the path exists and is intended for removal.
|
|
14
14
|
|
|
15
|
-
```typescript
|
|
15
|
+
```typescript signature
|
|
16
16
|
async delete(remotePath: string, options?: ToolRouterSessionFilesMountDeleteOptions): Promise<FileDeleteResponse>
|
|
17
17
|
```
|
|
18
18
|
|
|
@@ -50,7 +50,7 @@ Downloads a file from the session's file mount to the local filesystem.
|
|
|
50
50
|
Retrieves a file stored in the session's virtual filesystem (e.g., one produced
|
|
51
51
|
by a tool or previously uploaded) and saves it to the specified local path.
|
|
52
52
|
|
|
53
|
-
```typescript
|
|
53
|
+
```typescript signature
|
|
54
54
|
async download(filePath: string, options?: ToolRouterSessionFilesMountDownloadOptions): Promise<RemoteFile>
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -89,7 +89,7 @@ Use this to browse the virtual filesystem attached to the tool router session.
|
|
|
89
89
|
The path is relative to the mount root (e.g., `"/"` for root, `"/documents"` for a subdirectory).
|
|
90
90
|
Supports cursor-based pagination via `cursor` and `limit` options.
|
|
91
91
|
|
|
92
|
-
```typescript
|
|
92
|
+
```typescript signature
|
|
93
93
|
async list(options?: ToolRouterSessionFilesMountListOptions): Promise<FileListResponse>
|
|
94
94
|
```
|
|
95
95
|
|
|
@@ -129,7 +129,7 @@ The file is stored in the virtual filesystem associated with the tool router ses
|
|
|
129
129
|
URL inputs require a Node.js or Bun runtime so the destination can be DNS-validated;
|
|
130
130
|
edge runtimes must fetch the file themselves and pass a File or ArrayBuffer.
|
|
131
131
|
|
|
132
|
-
```typescript
|
|
132
|
+
```typescript signature
|
|
133
133
|
async upload(input: string | File | ArrayBuffer | Uint8Array, options?: ToolRouterSessionFilesMountUploadOptions): Promise<RemoteFile>
|
|
134
134
|
```
|
|
135
135
|
|
|
@@ -154,11 +154,13 @@ await session.experimental.files.upload('https://example.com/file.pdf');
|
|
|
154
154
|
|
|
155
155
|
```typescript
|
|
156
156
|
// From native File (e.g. from input[type=file])
|
|
157
|
-
|
|
157
|
+
const file = new File(['hello world'], 'hello.txt', { type: 'text/plain' });
|
|
158
|
+
await session.experimental.files.upload(file);
|
|
158
159
|
```
|
|
159
160
|
|
|
160
161
|
```typescript
|
|
161
162
|
// From raw buffer
|
|
163
|
+
const buffer = new TextEncoder().encode(JSON.stringify({ hello: 'world' }));
|
|
162
164
|
await session.experimental.files.upload(buffer, { remotePath: 'data.json', mimetype: 'application/json' });
|
|
163
165
|
```
|
|
164
166
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "SessionWebhooks"
|
|
3
|
+
description: "`composio.sessions.webhooks` — for the endpoint at a project's session webhook URL, which answers session hooks that have a `webhook` handler."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
Access this class through the `composio.sessions.webhooks` property:
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import { Composio } from '@composio/core';
|
|
12
|
+
|
|
13
|
+
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
14
|
+
const webhooks = composio.sessions.webhooks;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Methods
|
|
18
|
+
|
|
19
|
+
### parse()
|
|
20
|
+
|
|
21
|
+
Verify and parse an event Composio sent to the session webhook URL.
|
|
22
|
+
|
|
23
|
+
Composio sends one before or after each tool or proxy call that a hook
|
|
24
|
+
with a `webhook` handler applies to, and waits for the endpoint's answer.
|
|
25
|
+
The signature is always verified, with the project's session webhook
|
|
26
|
+
secret. The event is returned as Composio sent it, with the field names of
|
|
27
|
+
the webhook reference.
|
|
28
|
+
|
|
29
|
+
Pass the raw, unparsed request body: the signature covers its exact bytes.
|
|
30
|
+
|
|
31
|
+
```typescript signature
|
|
32
|
+
async parse(params: ParseSessionWebhookParams): Promise<SessionWebhookEvent>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Parameters**
|
|
36
|
+
|
|
37
|
+
| Name | Type | Description |
|
|
38
|
+
|------|------|-------------|
|
|
39
|
+
| `params` | `ParseSessionWebhookParams` | The request and how to verify it |
|
|
40
|
+
|
|
41
|
+
**Returns**
|
|
42
|
+
|
|
43
|
+
`Promise<SessionWebhookEvent>` — The verified event
|
|
44
|
+
|
|
45
|
+
**Example**
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// Next.js App Router, at the project's session webhook URL
|
|
49
|
+
export async function POST(request: Request) {
|
|
50
|
+
const hook = await composio.sessions.webhooks.parse({
|
|
51
|
+
body: await request.text(),
|
|
52
|
+
headers: request.headers,
|
|
53
|
+
verifySecret: process.env.COMPOSIO_SESSION_WEBHOOK_SECRET!,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Keep a confidential project out of every call and every result
|
|
57
|
+
if (JSON.stringify(hook.data).includes('Project Titan')) {
|
|
58
|
+
return Response.json({ action: 'block', message: 'Project Titan is confidential' });
|
|
59
|
+
}
|
|
60
|
+
return Response.json({ action: 'continue' });
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
@@ -34,7 +34,7 @@ Experimental — shape may change in future releases.
|
|
|
34
34
|
`userId` 1..256 characters). Invalid input throws `ValidationError`
|
|
35
35
|
at the SDK boundary.
|
|
36
36
|
|
|
37
|
-
```typescript
|
|
37
|
+
```typescript signature
|
|
38
38
|
async authorize(toolkit: string, options?: { callbackUrl?: string; alias?: string; experimental?: { accountType?: ConnectedAccountType; aclConfigForShared?: ConnectedAccountAclConfig; }; }, requestOptions?: ComposioRequestOptions): Promise<ConnectionRequest>
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -58,7 +58,7 @@ async authorize(toolkit: string, options?: { callbackUrl?: string; alias?: strin
|
|
|
58
58
|
Use `localToolkits()` instead.
|
|
59
59
|
</Callout>
|
|
60
60
|
|
|
61
|
-
```typescript
|
|
61
|
+
```typescript signature
|
|
62
62
|
customToolkits(): RegisteredLocalToolkit[]
|
|
63
63
|
```
|
|
64
64
|
|
|
@@ -74,7 +74,7 @@ customToolkits(): RegisteredLocalToolkit[]
|
|
|
74
74
|
Use `localTools()` instead.
|
|
75
75
|
</Callout>
|
|
76
76
|
|
|
77
|
-
```typescript
|
|
77
|
+
```typescript signature
|
|
78
78
|
customTools(options?: { toolkit?: string }): RegisteredLocalTool[]
|
|
79
79
|
```
|
|
80
80
|
|
|
@@ -97,7 +97,7 @@ Delete this session.
|
|
|
97
97
|
Deleted sessions immediately stop being retrievable or executable. Deleting
|
|
98
98
|
an already-deleted session surfaces the backend 404.
|
|
99
99
|
|
|
100
|
-
```typescript
|
|
100
|
+
```typescript signature
|
|
101
101
|
async delete(requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionDeleteResponse>
|
|
102
102
|
```
|
|
103
103
|
|
|
@@ -127,7 +127,7 @@ for the new connection to become ACTIVE.
|
|
|
127
127
|
For interactive flows that should surface the redirect URL instead of
|
|
128
128
|
blocking, use `authorize()` and its `waitForConnection()` directly.
|
|
129
129
|
|
|
130
|
-
```typescript
|
|
130
|
+
```typescript signature
|
|
131
131
|
async ensureConnected(toolkit: string, options?: ToolRouterSessionEnsureConnectedOptions, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionEnsureConnectedResult>
|
|
132
132
|
```
|
|
133
133
|
|
|
@@ -147,7 +147,7 @@ async ensureConnected(toolkit: string, options?: ToolRouterSessionEnsureConnecte
|
|
|
147
147
|
**Example**
|
|
148
148
|
|
|
149
149
|
```typescript
|
|
150
|
-
const session = await composio.sessions.create({ toolkits: ['github'] });
|
|
150
|
+
const session = await composio.sessions.create('user_123', { toolkits: ['github'] });
|
|
151
151
|
const { wasConnected, connectedAccount } = await session.ensureConnected('github');
|
|
152
152
|
if (!wasConnected) console.log('Newly linked:', connectedAccount?.id);
|
|
153
153
|
```
|
|
@@ -163,7 +163,7 @@ original slug (e.g. "GREP") when that original slug is unique across
|
|
|
163
163
|
the session's custom tools and toolkits. Custom tools are executed
|
|
164
164
|
in-process; remote tools are sent to the Composio backend.
|
|
165
165
|
|
|
166
|
-
```typescript
|
|
166
|
+
```typescript signature
|
|
167
167
|
async execute(toolSlug: string, arguments_?: Record<string, unknown>, options?: ToolRouterSessionExecuteOptions, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionExecuteResponse>
|
|
168
168
|
```
|
|
169
169
|
|
|
@@ -191,7 +191,7 @@ tool slugs, so a typo is a type error instead of a failed request. The call
|
|
|
191
191
|
is sent to the Composio backend as is: custom tools named in a
|
|
192
192
|
`COMPOSIO_MULTI_EXECUTE_TOOL` call are not run in-process here.
|
|
193
193
|
|
|
194
|
-
```typescript
|
|
194
|
+
```typescript signature
|
|
195
195
|
async executeMeta(slug: ToolRouterSessionMetaToolSlug, arguments_?: Record<string, unknown>, options?: ToolRouterSessionExecuteMetaOptions, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionExecuteResponse>
|
|
196
196
|
```
|
|
197
197
|
|
|
@@ -224,7 +224,7 @@ Page through this session's configuration history, newest first. The
|
|
|
224
224
|
first page starts with the live config (`isCurrent: true`); every
|
|
225
225
|
`session.update()` archives the previous version as a history row.
|
|
226
226
|
|
|
227
|
-
```typescript
|
|
227
|
+
```typescript signature
|
|
228
228
|
async listConfigHistory(options?: ToolRouterSessionListConfigHistoryOptions, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionListConfigHistoryResponse>
|
|
229
229
|
```
|
|
230
230
|
|
|
@@ -254,7 +254,7 @@ console.log(items[1].config.toolkits);
|
|
|
254
254
|
List all toolkits of local tools registered in this session.
|
|
255
255
|
Returns toolkits with their tools showing final slugs.
|
|
256
256
|
|
|
257
|
-
```typescript
|
|
257
|
+
```typescript signature
|
|
258
258
|
localToolkits(): RegisteredLocalToolkit[]
|
|
259
259
|
```
|
|
260
260
|
|
|
@@ -269,7 +269,7 @@ localToolkits(): RegisteredLocalToolkit[]
|
|
|
269
269
|
List all local tools registered in this session.
|
|
270
270
|
Returns tools with their final slugs, schemas, and resolved toolkit.
|
|
271
271
|
|
|
272
|
-
```typescript
|
|
272
|
+
```typescript signature
|
|
273
273
|
localTools(options?: { toolkit?: string }): RegisteredLocalTool[]
|
|
274
274
|
```
|
|
275
275
|
|
|
@@ -290,7 +290,7 @@ localTools(options?: { toolkit?: string }): RegisteredLocalTool[]
|
|
|
290
290
|
Proxy an API call through Composio's auth layer using the session's connected account.
|
|
291
291
|
The backend resolves the connected account from the toolkit within the session.
|
|
292
292
|
|
|
293
|
-
```typescript
|
|
293
|
+
```typescript signature
|
|
294
294
|
async proxyExecute(params: SessionProxyExecuteParams, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionProxyExecuteResponse>
|
|
295
295
|
```
|
|
296
296
|
|
|
@@ -312,7 +312,7 @@ async proxyExecute(params: SessionProxyExecuteParams, requestOptions?: ComposioR
|
|
|
312
312
|
Search for tools by semantic use case.
|
|
313
313
|
Returns relevant tools for the given query with schemas and guidance.
|
|
314
314
|
|
|
315
|
-
```typescript
|
|
315
|
+
```typescript signature
|
|
316
316
|
async search(params: { query: string; toolkits?: string[]; }, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionSearchResponse>
|
|
317
317
|
```
|
|
318
318
|
|
|
@@ -334,7 +334,7 @@ async search(params: { query: string; toolkits?: string[]; }, requestOptions?: C
|
|
|
334
334
|
Query the connection state of toolkits in the session.
|
|
335
335
|
Supports pagination and filtering by toolkit slugs.
|
|
336
336
|
|
|
337
|
-
```typescript
|
|
337
|
+
```typescript signature
|
|
338
338
|
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 }>
|
|
339
339
|
```
|
|
340
340
|
|
|
@@ -359,7 +359,7 @@ Requires a provider to be configured in the Composio constructor.
|
|
|
359
359
|
When custom tools are bound to the session, execution of COMPOSIO_MULTI_EXECUTE_TOOL
|
|
360
360
|
is intercepted: local tools are executed in-process, remote tools are sent to the backend.
|
|
361
361
|
|
|
362
|
-
```typescript
|
|
362
|
+
```typescript signature
|
|
363
363
|
async tools(modifiers?: SessionMetaToolOptions, requestOptions?: ComposioRequestOptions): Promise<ReturnType<TProvider['wrapTools']>>
|
|
364
364
|
```
|
|
365
365
|
|
|
@@ -411,7 +411,7 @@ for example for an archived or missing config, surface unchanged.
|
|
|
411
411
|
`experimental.sourceSessionConfig` are refreshed in place only after a
|
|
412
412
|
successful response, and the updated `config` is returned.
|
|
413
413
|
|
|
414
|
-
```typescript
|
|
414
|
+
```typescript signature
|
|
415
415
|
async update(config: ToolRouterUpdateSessionConfig, requestOptions?: ComposioRequestOptions): Promise<ToolRouterSessionConfig>
|
|
416
416
|
```
|
|
417
417
|
|