@composio/core 0.30.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.
Files changed (88) hide show
  1. package/dist/{CustomTool-9Vlb4XaS.mjs → CustomTool-B4dQn2M5.mjs} +1 -1
  2. package/dist/{CustomTool-Dzk3iqfP.d.mts → CustomTool-CBx9kzea.d.mts} +1 -1
  3. package/dist/{FileModifierErrors-WrqokuIF.mjs → FileModifierErrors-D-AKc3ds.mjs} +1 -1
  4. package/dist/{SsrfErrors-BSVMW915.mjs → SsrfErrors-BekZPeWY.mjs} +59 -12
  5. package/dist/{Telemetry-a7SOQXcg.mjs → Telemetry-BWKZmDxM.mjs} +2 -2
  6. package/dist/composio-CPf6NHnB.d.mts +20334 -0
  7. package/dist/{customTool.types-CpJbzxT6.d.mts → customTool.types-BSbIG1OG.d.mts} +306 -83
  8. package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +28 -11
  9. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +28 -10
  10. package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +44 -32
  11. package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +8 -6
  12. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +4 -3
  13. package/dist/docs/reference/sdk-reference/typescript/index.mdx +4 -2
  14. package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +6 -3
  15. package/dist/docs/reference/sdk-reference/typescript/logs.mdx +5 -3
  16. package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +54 -43
  17. package/dist/docs/reference/sdk-reference/typescript/meta.json +1 -0
  18. package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +5 -14
  19. package/dist/docs/reference/sdk-reference/typescript/session-configs.mdx +5 -3
  20. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +7 -5
  21. package/dist/docs/reference/sdk-reference/typescript/session-webhooks.mdx +64 -0
  22. package/dist/docs/reference/sdk-reference/typescript/session.mdx +16 -16
  23. package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +36 -8
  24. package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +14 -11
  25. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +18 -20
  26. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +42 -30
  27. package/dist/docs/reference/sdk-reference/typescript/usage.mdx +6 -4
  28. package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +9 -7
  29. package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +13 -9
  30. package/dist/docs/reference/sdk-reference/typescript/webhooks.mdx +3 -1
  31. package/dist/{errors-xC13uvaA.mjs → errors-CtIKA9BH.mjs} +2 -2
  32. package/dist/experimental/index.d.mts +2 -2
  33. package/dist/experimental/index.mjs +1 -1
  34. package/dist/{fileUtils.node-CAwIbWYH.mjs → fileUtils.node-BJUYMEph.mjs} +7 -7
  35. package/dist/index.d.mts +10 -15
  36. package/dist/index.mjs +582 -242
  37. package/dist/{jsonSchema-Cc4EtHRw.mjs → jsonSchema-BZoXGUCr.mjs} +2 -2
  38. package/dist/models/Files.node.mjs +3 -3
  39. package/dist/{sensitiveFileUploadPaths-CSyJ3Ku8.mjs → sensitiveFileUploadPaths-CcbMAYCC.mjs} +21 -15
  40. package/dist/{ssrfGuard.node-CdIkwqVu.mjs → ssrfGuard.node-B749ae5Q.mjs} +1 -1
  41. package/dist/{types-DQdUb7OG.d.mts → types-ns3Q_WrP.d.mts} +2 -2
  42. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
  43. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
  44. package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
  45. package/dist/utils/modifiers/FileToolModifier.node.mjs +5 -5
  46. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  47. package/dist/utils/ssrfGuard.node.mjs +1 -1
  48. package/dist/utils/ssrfGuard.workerd.mjs +1 -1
  49. package/package.json +4 -4
  50. package/src/composio.ts +26 -7
  51. package/src/errors/ComposioError.ts +3 -2
  52. package/src/index.ts +19 -0
  53. package/src/lib/toolRouterParams.ts +38 -14
  54. package/src/models/AuthConfigs.ts +18 -2
  55. package/src/models/ConnectedAccounts.ts +30 -17
  56. package/src/models/CustomTool.ts +0 -10
  57. package/src/models/Keyring.ts +2 -1
  58. package/src/models/MCP.ts +44 -36
  59. package/src/models/SessionWebhooks.ts +136 -0
  60. package/src/models/ToolRouter.ts +39 -4
  61. package/src/models/ToolRouterSession.ts +2 -2
  62. package/src/models/ToolRouterSessionFileMount.ts +3 -1
  63. package/src/models/Toolkits.ts +1 -0
  64. package/src/models/Tools.ts +6 -10
  65. package/src/models/Triggers.ts +48 -213
  66. package/src/models/Webhooks.ts +2 -0
  67. package/src/provider/ComposioProvider.ts +0 -1
  68. package/src/telemetry/BatchProcessor.ts +1 -1
  69. package/src/telemetry/Telemetry.ts +1 -1
  70. package/src/types/authConfigs.types.ts +14 -0
  71. package/src/types/connectedAccountAuthStates.types.ts +0 -1
  72. package/src/types/provider.types.ts +0 -1
  73. package/src/types/sessionWebhooks.types.ts +292 -0
  74. package/src/types/tool.types.ts +1 -1
  75. package/src/types/toolRouter.types.ts +33 -4
  76. package/src/types/toolkit.types.ts +21 -0
  77. package/src/types/triggers.types.ts +4 -0
  78. package/src/utils/crypto.ts +6 -5
  79. package/src/utils/env.ts +2 -5
  80. package/src/utils/fileUtils.node.ts +4 -3
  81. package/src/utils/logger.ts +19 -9
  82. package/src/utils/pusher.ts +5 -2
  83. package/src/utils/readResponseBody.ts +30 -17
  84. package/src/utils/transformers/authConfigs.ts +6 -3
  85. package/src/utils/transformers/toolkits.ts +7 -0
  86. package/src/utils/userCallback.ts +3 -1
  87. package/src/utils/webhookVerification.ts +211 -0
  88. package/dist/composio-DaokW5sV.d.mts +0 -9593
@@ -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 result = await composio.mcp.list();
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.mcpConfig.create("personal-mcp-server", {
58
+ const server = await composio.mcp.create("personal-mcp-server", {
55
59
  toolkits: ["github", "slack"],
56
- allowedTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"],
60
+ allowedTools: ["GITHUB_CREATE_AN_ISSUE", "SLACK_SEND_MESSAGE"],
57
61
  manuallyManageConnections: false
58
- }
59
62
  });
63
+ ```
60
64
 
61
- const server = await composio.mcpConfig.create("personal-mcp-server", {
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.experimental.mcp.delete("mcp_12345");
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.experimental.mcp.delete("mcp_12345");
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.message);
111
+ console.error("Failed to delete MCP server:", error);
108
112
  }
109
113
 
110
114
  // Delete and verify from list
111
- await composio.experimental.mcp.delete("mcp_12345");
112
- const servers = await composio.experimental.mcp.list({});
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/code";
148
+ import { Composio } from "@composio/core";
145
149
 
146
150
  const composio = new Composio();
147
- const mcp = await composio.experimental.mcp.generate("default", "<mcp_config_id>");
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,10 +176,10 @@ 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.experimental.mcp.get("mcp_12345");
179
+ const server = await composio.mcp.get("mcp_12345");
176
180
 
177
181
  console.log(server.name); // "My Personal MCP Server"
178
- console.log(server.allowedTools); // ["GITHUB_CREATE_ISSUE", "SLACK_SEND_MESSAGE"]
182
+ console.log(server.allowedTools); // ["GITHUB_CREATE_AN_ISSUE", "SLACK_SEND_MESSAGE"]
179
183
  console.log(server.toolkits); // ["github", "slack"]
180
184
  console.log(server.serverInstanceCount); // 3
181
185
 
@@ -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 all MCP servers
216
- const allServers = await composio.experimental.mcp.list({});
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.experimental.mcp.list({
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.experimental.mcp.list({
226
- toolkits: ['github', 'slack']
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.experimental.mcp.list({
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.experimental.mcp.update("mcp_12345", {
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.experimental.mcp.update("mcp_12345", {
279
+ const serverWithNewTools = await composio.mcp.update("mcp_12345", {
267
280
  toolkits: [
268
- {
269
- toolkit: "github",
270
- authConfigId: "auth_abc123",
271
- allowedTools: ["GITHUB_CREATE_ISSUE", "GITHUB_LIST_REPOS"]
272
- },
273
- {
274
- toolkit: "slack",
275
- authConfigId: "auth_xyz789",
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.experimental.mcp.update("mcp_12345", {
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.experimental.mcp.update("mcp_12345", {
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
 
@@ -8,6 +8,7 @@
8
8
  "keyring",
9
9
  "logs",
10
10
  "session-configs",
11
+ "session-webhooks",
11
12
  "experimental",
12
13
  "mcp",
13
14
  "remote-file",
@@ -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 result = await composio.sessionConfigs.list();
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
- await session.experimental.files.upload(fileInput.files[0]);
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