@composio/core 0.29.0 → 0.30.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/README.md +23 -0
- package/dist/{CustomTool-Bd1KdWvo.mjs → CustomTool-9Vlb4XaS.mjs} +4 -7
- package/dist/{CustomTool-CMW-d2ZN.d.mts → CustomTool-Dzk3iqfP.d.mts} +2 -4
- package/dist/FileModifierErrors-WrqokuIF.mjs +199 -0
- package/dist/{FileToolModifier.utils.neutral-DWFpnsj2.mjs → FileToolModifier.utils.neutral-BQP85ZJj.mjs} +1 -2
- package/dist/{SsrfErrors-DiQldIdC.mjs → SsrfErrors-BSVMW915.mjs} +49 -26
- package/dist/{Telemetry-D2PJwXKx.mjs → Telemetry-a7SOQXcg.mjs} +6 -10
- package/dist/{composio-D5UV5HXN.d.mts → composio-DaokW5sV.d.mts} +229 -284
- package/dist/{customTool.types-B9fs34dv.d.mts → customTool.types-CpJbzxT6.d.mts} +182 -245
- package/dist/docs/error-consistency.md +3 -3
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +1 -0
- package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +6 -11
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +1 -1
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +1 -1
- package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +1 -1
- package/dist/{errors-BK6Xc7Ia.mjs → errors-xC13uvaA.mjs} +56 -139
- package/dist/experimental/index.d.mts +16 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-ILI1IjnZ.mjs → fileUtils.node-CAwIbWYH.mjs} +6 -8
- package/dist/{files.types-DeMC_mAW.d.mts → files.types-Dg6HcEzs.d.mts} +0 -2
- package/dist/index.d.mts +40 -75
- package/dist/index.mjs +281 -243
- package/dist/{cancellation-BoJjs34Y.mjs → jsonSchema-Cc4EtHRw.mjs} +5 -22
- package/dist/models/Files.node.d.mts +32 -13
- package/dist/models/Files.node.mjs +36 -19
- package/dist/models/Files.workerd.d.mts +8 -3
- package/dist/models/Files.workerd.mjs +1 -2
- package/dist/platform/node.d.mts +2 -4
- package/dist/platform/node.mjs +15 -16
- package/dist/platform/workerd.d.mts +2 -4
- package/dist/platform/workerd.mjs +1 -2
- package/dist/requestOptions.types-DWrTcbss.d.mts +38 -0
- package/dist/rolldown-runtime-ad2WFvuA.mjs +17 -0
- package/dist/{sensitiveFileUploadPaths-BaEORC7-.mjs → sensitiveFileUploadPaths-CSyJ3Ku8.mjs} +22 -12
- package/dist/{ssrfGuard.node-BZ270bcu.mjs → ssrfGuard.node-CdIkwqVu.mjs} +3 -5
- package/dist/{types-CaP2SytR.d.mts → types-DQdUb7OG.d.mts} +2 -4
- package/dist/{types-DuVZKrXO.d.mts → types-Ds6XbK1m.d.mts} +0 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +2 -4
- package/dist/utils/config-defaults/ConfigDefaults.node.mjs +1 -2
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +2 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +1 -2
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +2 -4
- package/dist/utils/modifiers/FileToolModifier.node.mjs +7 -8
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +2 -4
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +2 -3
- package/dist/utils/ssrfGuard.node.d.mts +1 -3
- package/dist/utils/ssrfGuard.node.mjs +1 -1
- package/dist/utils/ssrfGuard.workerd.d.mts +1 -3
- package/dist/utils/ssrfGuard.workerd.mjs +2 -3
- package/docs/error-consistency.md +3 -3
- package/package.json +12 -13
- package/src/composio.ts +12 -0
- package/src/errors/ComposioError.ts +40 -16
- package/src/errors/ConnectedAccountsErrors.ts +2 -2
- package/src/errors/ToolErrors.ts +107 -30
- package/src/errors/apiErrorDetails.ts +40 -0
- package/src/models/ConnectionRequest.ts +12 -4
- package/src/models/CustomToolkits.ts +11 -17
- package/src/models/Experimental.ts +2 -7
- package/src/models/Files.node.ts +68 -37
- package/src/models/RemoteFile.ts +22 -16
- package/src/models/SessionContext.ts +6 -7
- package/src/models/ToolRouterSession.ts +16 -23
- package/src/models/Tools.ts +218 -20
- package/src/models/Triggers.ts +8 -2
- package/src/types/customToolkits.types.ts +4 -9
- package/src/utils/cancellation.ts +5 -1
- package/dist/FileModifierErrors-CdGSABoq.mjs +0 -97
- package/dist/rolldown-runtime-w6R9maHv.mjs +0 -18
- package/src/models/inlineCustomToolsPayload.ts +0 -17
|
@@ -44,9 +44,9 @@ Some error classes have specific requirements:
|
|
|
44
44
|
new ValidationError('Message', { cause: someZodError });
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
2. **ComposioToolExecutionError**:
|
|
47
|
+
2. **ComposioToolExecutionError**: Keeps the failure it wraps as `cause`. The base `ComposioError` reads `statusCode`, `requestId`, and `apiErrorCode` from an `APIError` cause.
|
|
48
48
|
```typescript
|
|
49
|
-
new ComposioToolExecutionError('Message', {
|
|
49
|
+
new ComposioToolExecutionError('Message', { cause: someError });
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
## Using Error Classes
|
|
@@ -72,7 +72,7 @@ try {
|
|
|
72
72
|
} catch (error) {
|
|
73
73
|
// Handle tool execution errors
|
|
74
74
|
throw new ComposioToolExecutionError('Tool failed', {
|
|
75
|
-
|
|
75
|
+
cause: error,
|
|
76
76
|
meta: { toolId: 'some-tool' },
|
|
77
77
|
});
|
|
78
78
|
|
|
@@ -54,6 +54,7 @@ const composio = new Composio({
|
|
|
54
54
|
| `authConfigs` | `AuthConfigs` | Manage authentication configurations for toolkits |
|
|
55
55
|
| `connectedAccounts` | `ConnectedAccounts` | Manage authenticated connections |
|
|
56
56
|
| `create` | `(...) => Promise<Session>` | Creates a new tool router session for a user. Use `sessionPreset: SessionPreset.DIRECT_TOOLS` when all needed tools should be exposed directly; see `ToolRouterCreateSessionConfig`. |
|
|
57
|
+
| `customToolkits` | `CustomToolkits` | Register and manage project-owned custom toolkits, such as a remote MCP server (`create()` / `update()` / `sync()` / `delete()`). |
|
|
57
58
|
| `experimental` | `Experimental` | Experimental SDK methods whose shape may change in future releases. Prefer domain-specific mounts (for example `composio.connectedAccounts.updateAcl(...)`) when available; this namespace keeps compatibility aliases while APIs are experimental. Stateless experimental factories (e.g. `experimental_createTool`) stay at the top level. |
|
|
58
59
|
| `files` | `Files` | Upload and download files |
|
|
59
60
|
| `keyring` | `Keyring` | Public transfer keys of the organization's customer-managed keyring |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "CustomToolkits"
|
|
3
|
-
description: "`composio.
|
|
3
|
+
description: "`composio.customToolkits` — toolkits your project registers from its own app or MCP server, with their own auth configs and connected accounts. These live on the Composio platform. They are unrelated to the in-process toolkits built with `experimental_createToolkit()`, which run inside your application."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Usage
|
|
@@ -17,7 +17,6 @@ const result = await composio.customToolkits.list();
|
|
|
17
17
|
### create()
|
|
18
18
|
|
|
19
19
|
Creates a custom MCP toolkit and returns its generated slug.
|
|
20
|
-
**Experimental — custom toolkits are in pilot; shape may change.**
|
|
21
20
|
|
|
22
21
|
Set `userId` to `'all'` to share the toolkit with every user in the
|
|
23
22
|
project, or to a user ID to make it private to that user. `mcpUrl`,
|
|
@@ -43,7 +42,7 @@ async create(params: CustomToolkitCreateParams, requestOptions?: ComposioRequest
|
|
|
43
42
|
**Example**
|
|
44
43
|
|
|
45
44
|
```typescript
|
|
46
|
-
const { slug, connectLink } = await composio.
|
|
45
|
+
const { slug, connectLink } = await composio.customToolkits.create({
|
|
47
46
|
name: 'Internal API',
|
|
48
47
|
mcpUrl: 'https://mcp.internal.example.com/mcp',
|
|
49
48
|
authSchemes: [
|
|
@@ -60,7 +59,6 @@ const { slug, connectLink } = await composio.experimental.customToolkits.create(
|
|
|
60
59
|
Deletes a custom toolkit owned by the project, with its tools, auth
|
|
61
60
|
configs and connected accounts. The credentials behind those connected
|
|
62
61
|
accounts are revoked in background jobs (`revokeJobIds`).
|
|
63
|
-
**Experimental — custom toolkits are in pilot; shape may change.**
|
|
64
62
|
|
|
65
63
|
Composio-managed toolkits cannot be deleted; the API answers 403.
|
|
66
64
|
|
|
@@ -82,7 +80,7 @@ async delete(slug: string, requestOptions?: ComposioRequestOptions): Promise<Cus
|
|
|
82
80
|
**Example**
|
|
83
81
|
|
|
84
82
|
```typescript
|
|
85
|
-
const result = await composio.
|
|
83
|
+
const result = await composio.customToolkits.delete('CUSTOM_MY_TOOLKIT');
|
|
86
84
|
console.log(result.connectedAccountsDeleted);
|
|
87
85
|
```
|
|
88
86
|
|
|
@@ -92,7 +90,6 @@ console.log(result.connectedAccountsDeleted);
|
|
|
92
90
|
|
|
93
91
|
Re-fetches the tool definitions of a custom toolkit from its remote MCP
|
|
94
92
|
server. Call it when automatic sync fails or the remote tools change.
|
|
95
|
-
**Experimental — custom toolkits are in pilot; shape may change.**
|
|
96
93
|
|
|
97
94
|
```typescript
|
|
98
95
|
async sync(slug: string, params?: CustomToolkitSyncParams, requestOptions?: ComposioRequestOptions): Promise<CustomToolkitSyncResponse>
|
|
@@ -113,7 +110,7 @@ async sync(slug: string, params?: CustomToolkitSyncParams, requestOptions?: Comp
|
|
|
113
110
|
**Example**
|
|
114
111
|
|
|
115
112
|
```typescript
|
|
116
|
-
const { version, syncedCount } = await composio.
|
|
113
|
+
const { version, syncedCount } = await composio.customToolkits.sync(
|
|
117
114
|
'CUSTOM_MY_TOOLKIT',
|
|
118
115
|
{ connectedAccountId: 'ca_abc123' }
|
|
119
116
|
);
|
|
@@ -125,7 +122,6 @@ const { version, syncedCount } = await composio.experimental.customToolkits.sync
|
|
|
125
122
|
|
|
126
123
|
Updates a custom toolkit's name, logo or API key field copy. Omitted
|
|
127
124
|
fields keep their current value.
|
|
128
|
-
**Experimental — custom toolkits are in pilot; shape may change.**
|
|
129
125
|
|
|
130
126
|
On a project with 2FA enabled, updating a private toolkit requires the
|
|
131
127
|
`userId` it is private to.
|
|
@@ -149,7 +145,7 @@ async update(slug: string, params: CustomToolkitUpdateParams, requestOptions?: C
|
|
|
149
145
|
**Example**
|
|
150
146
|
|
|
151
147
|
```typescript
|
|
152
|
-
await composio.
|
|
148
|
+
await composio.customToolkits.update('CUSTOM_INTERNAL_API_K7F2Q', {
|
|
153
149
|
name: 'Internal API (prod)',
|
|
154
150
|
userId: 'user_123',
|
|
155
151
|
});
|
|
@@ -167,7 +163,6 @@ Use `create()` for a new toolkit and `update(slug, ...)` to change
|
|
|
167
163
|
|
|
168
164
|
Creates a custom toolkit, or updates its display metadata (name, API key
|
|
169
165
|
field copy) when the project already owns a toolkit with this slug.
|
|
170
|
-
**Experimental — custom toolkits are in pilot; shape may change.**
|
|
171
166
|
|
|
172
167
|
`mcpUrl` and `authSchemes` cannot change on an existing toolkit:
|
|
173
168
|
re-sending them unchanged is a no-op, and changing them fails with a 409.
|
|
@@ -191,7 +186,7 @@ async upsert(params: CustomToolkitUpsertParams, requestOptions?: ComposioRequest
|
|
|
191
186
|
**Example**
|
|
192
187
|
|
|
193
188
|
```typescript
|
|
194
|
-
await composio.
|
|
189
|
+
await composio.customToolkits.upsert({
|
|
195
190
|
slug: 'INTERNAL_API',
|
|
196
191
|
toolkitConfig: {
|
|
197
192
|
name: 'Internal API',
|
|
@@ -16,7 +16,7 @@ const result = await composio.experimental.list();
|
|
|
16
16
|
|
|
17
17
|
| Name | Type | Description |
|
|
18
18
|
|------|------|-------------|
|
|
19
|
-
| `customToolkits` | `CustomToolkits` |
|
|
19
|
+
| `customToolkits` | `CustomToolkits` | Same object as `composio.customToolkits`. |
|
|
20
20
|
| `usage` | `Usage` | Project-scoped usage metering (`summary()` / `breakdown()`). **Experimental — shape may change in future releases.** |
|
|
21
21
|
|
|
22
22
|
## Methods
|
|
@@ -14,7 +14,7 @@ description: "Complete API reference for the Composio TypeScript SDK (@composio/
|
|
|
14
14
|
| [`Composio`](/reference/sdk-reference/typescript/composio) | This is the core class for Composio. |
|
|
15
15
|
| [`AuthConfigs`](/reference/sdk-reference/typescript/auth-configs) | AuthConfigs class |
|
|
16
16
|
| [`ConnectedAccounts`](/reference/sdk-reference/typescript/connected-accounts) | ConnectedAccounts class |
|
|
17
|
-
| [`CustomToolkits`](/reference/sdk-reference/typescript/custom-toolkits) | `composio.
|
|
17
|
+
| [`CustomToolkits`](/reference/sdk-reference/typescript/custom-toolkits) | `composio.customToolkits` — toolkits your project registers |
|
|
18
18
|
| [`Keyring`](/reference/sdk-reference/typescript/keyring) | `composio.keyring` — the organization's customer-managed keyring. |
|
|
19
19
|
| [`Logs`](/reference/sdk-reference/typescript/logs) | `composio.logs` — tool-execution logs. |
|
|
20
20
|
| [`SessionConfigs`](/reference/sdk-reference/typescript/session-configs) | `composio.sessionConfigs` — saved, reusable Session configs. |
|
|
@@ -64,7 +64,7 @@ async save(path?: string): Promise<string>
|
|
|
64
64
|
|
|
65
65
|
| Name | Type | Description |
|
|
66
66
|
|------|------|-------------|
|
|
67
|
-
| `path?` | `string` | Local path to save the file. If omitted, saves to the Composio temp directory using the filename from the mount path. An existing default destination gets a copy number before its extension. |
|
|
67
|
+
| `path?` | `string` | Local path to save the file. An explicit path does not require a home directory. If omitted, saves to the Composio temp directory using the filename from the mount path. An existing default destination gets a copy number before its extension. |
|
|
68
68
|
|
|
69
69
|
**Returns**
|
|
70
70
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { r as ComposioError$1 } from "./SsrfErrors-
|
|
2
|
-
import "./FileModifierErrors-
|
|
3
|
-
import { APIError
|
|
1
|
+
import { a as sanitizeApiErrorText, i as apiErrorSuggestedFixes, o as withApiErrorMessage, r as ComposioError$1 } from "./SsrfErrors-BSVMW915.mjs";
|
|
2
|
+
import "./FileModifierErrors-WrqokuIF.mjs";
|
|
3
|
+
import { APIError } from "@composio/client";
|
|
4
4
|
import { ZodError } from "zod/v3";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/errors/AuthConfigErrors.ts
|
|
7
7
|
const AuthConfigErrorCodes = { AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND" };
|
|
8
8
|
var ComposioAuthConfigNotFoundError = class extends ComposioError$1 {
|
|
9
9
|
constructor(message = "Auth config not found", options = {}) {
|
|
@@ -20,8 +20,7 @@ var ComposioAuthConfigNotFoundError = class extends ComposioError$1 {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
//#region src/errors/ConnectedAccountsErrors.ts
|
|
23
|
+
// src/errors/ConnectedAccountsErrors.ts
|
|
25
24
|
const ConnectedAccountErrorCodes = {
|
|
26
25
|
CONNECTED_ACCOUNT_NOT_FOUND: "CONNECTED_ACCOUNT_NOT_FOUND",
|
|
27
26
|
MULTIPLE_CONNECTED_ACCOUNTS: "MULTIPLE_CONNECTED_ACCOUNTS",
|
|
@@ -38,7 +37,7 @@ var ComposioConnectedAccountNotFoundError = class extends ComposioError$1 {
|
|
|
38
37
|
super(message, {
|
|
39
38
|
...options,
|
|
40
39
|
code: ConnectedAccountErrorCodes.CONNECTED_ACCOUNT_NOT_FOUND,
|
|
41
|
-
statusCode: 404,
|
|
40
|
+
statusCode: options.statusCode ?? 404,
|
|
42
41
|
possibleFixes: options.possibleFixes || ["Ensure the connected account exists and is active in your Composio dashboard"]
|
|
43
42
|
});
|
|
44
43
|
this.name = "ComposioConnectedAccountNotFoundError";
|
|
@@ -173,8 +172,7 @@ var ComposioConnectedAccountNotRevokableError = class extends ComposioError$1 {
|
|
|
173
172
|
}
|
|
174
173
|
};
|
|
175
174
|
|
|
176
|
-
|
|
177
|
-
//#region src/errors/ConnectionRequestErrors.ts
|
|
175
|
+
// src/errors/ConnectionRequestErrors.ts
|
|
178
176
|
const ConnectionRequestErrorCodes = {
|
|
179
177
|
CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
|
|
180
178
|
CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
|
|
@@ -198,8 +196,7 @@ var ConnectionRequestFailedError = class extends ComposioError$1 {
|
|
|
198
196
|
}
|
|
199
197
|
};
|
|
200
198
|
|
|
201
|
-
|
|
202
|
-
//#region src/utils/rateLimit.ts
|
|
199
|
+
// src/utils/rateLimit.ts
|
|
203
200
|
/** Whether a client error is the API rejecting the request with a 429. */
|
|
204
201
|
function isRateLimitResponse(error) {
|
|
205
202
|
return error instanceof APIError && error.status === 429;
|
|
@@ -219,12 +216,12 @@ function getRetryAfterSeconds(error) {
|
|
|
219
216
|
return Number.isNaN(date) ? void 0 : Math.max(0, (date - Date.now()) / 1e3);
|
|
220
217
|
}
|
|
221
218
|
|
|
222
|
-
|
|
223
|
-
//#region src/errors/ToolErrors.ts
|
|
219
|
+
// src/errors/ToolErrors.ts
|
|
224
220
|
const ToolErrorCodes = {
|
|
225
221
|
TOOLSET_NOT_DEFINED: "TOOLSET_NOT_DEFINED",
|
|
226
222
|
TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
|
|
227
223
|
TOOL_FETCH_ERROR: "TOOL_FETCH_ERROR",
|
|
224
|
+
TOOL_SCHEMA_INVALID: "TOOL_SCHEMA_INVALID",
|
|
228
225
|
INVALID_MODIFIER: "INVALID_MODIFIER",
|
|
229
226
|
TOOL_EXECUTION_ERROR: "TOOL_EXECUTION_ERROR",
|
|
230
227
|
INVALID_TOOL_ARGUMENTS: "INVALID_TOOL_ARGUMENTS",
|
|
@@ -271,6 +268,23 @@ var ComposioToolFetchError = class extends ComposioError$1 {
|
|
|
271
268
|
this.name = "ComposioToolFetchError";
|
|
272
269
|
}
|
|
273
270
|
};
|
|
271
|
+
/**
|
|
272
|
+
* Error thrown when a tool was retrieved but its declared parameters cannot be
|
|
273
|
+
* parsed, so the tool cannot be offered. Distinct from
|
|
274
|
+
* `ComposioToolNotFoundError`: the tool exists, its schema is what is broken,
|
|
275
|
+
* and a caller that treats `TOOL_NOT_FOUND` as "no such tool" would otherwise
|
|
276
|
+
* report a real tool as missing.
|
|
277
|
+
*/
|
|
278
|
+
var ComposioToolSchemaInvalidError = class extends ComposioError$1 {
|
|
279
|
+
constructor(message = "Tool schema is invalid", options = {}) {
|
|
280
|
+
super(message, {
|
|
281
|
+
...options,
|
|
282
|
+
code: ToolErrorCodes.TOOL_SCHEMA_INVALID,
|
|
283
|
+
possibleFixes: options.possibleFixes || ["The tool exists but its declared input schema could not be parsed", "Report the tool slug to Composio so the schema can be corrected"]
|
|
284
|
+
});
|
|
285
|
+
this.name = "ComposioToolSchemaInvalidError";
|
|
286
|
+
}
|
|
287
|
+
};
|
|
274
288
|
/** Error options for a 429. Leaves out an unknown wait, as `ComposioError` does for unset fields. */
|
|
275
289
|
const rateLimitOptions = (cause, meta) => {
|
|
276
290
|
const retryAfterSeconds = getRetryAfterSeconds(cause);
|
|
@@ -282,7 +296,7 @@ const rateLimitOptions = (cause, meta) => {
|
|
|
282
296
|
...meta,
|
|
283
297
|
retryAfterSeconds
|
|
284
298
|
},
|
|
285
|
-
possibleFixes: [retryAfterSeconds === void 0 ? "Wait before retrying" : `Wait ${Math.ceil(retryAfterSeconds)} seconds, then retry`, "Reduce how many requests your organization sends per minute"]
|
|
299
|
+
possibleFixes: apiErrorSuggestedFixes(cause.details) ?? [retryAfterSeconds === void 0 ? "Wait before retrying" : `Wait ${Math.ceil(retryAfterSeconds)} seconds, then retry`, "Reduce how many requests your organization sends per minute"]
|
|
286
300
|
};
|
|
287
301
|
};
|
|
288
302
|
/**
|
|
@@ -442,23 +456,34 @@ var ComposioToolVersionRequiredError = class extends ComposioError$1 {
|
|
|
442
456
|
this.name = "ComposioToolVersionRequiredError";
|
|
443
457
|
}
|
|
444
458
|
};
|
|
445
|
-
const ERROR_CODE_HANDLERS = /* @__PURE__ */ new Map([[1803, (
|
|
459
|
+
const ERROR_CODE_HANDLERS = /* @__PURE__ */ new Map([[1803, (details, cause) => new ComposioConnectedAccountNotFoundError(sanitizeApiErrorText(details.message || "An error occurred"), {
|
|
460
|
+
cause,
|
|
461
|
+
statusCode: cause.status,
|
|
462
|
+
possibleFixes: apiErrorSuggestedFixes(details)
|
|
463
|
+
})]]);
|
|
464
|
+
/** What to try when the API rejected an execution without a `suggested_fix`, by HTTP status. */
|
|
465
|
+
const fallbackExecutionFixes = (status) => {
|
|
466
|
+
if (status === 401) return ["Ensure you are using a valid Composio API key for this project"];
|
|
467
|
+
if (status === 402) return ["Check the plan and billing limits of your Composio organization"];
|
|
468
|
+
if (status === 403) return ["Ensure your API key and the connected account are allowed to run this tool"];
|
|
469
|
+
if (status === 410) return ["The tool or the resource it acts on is no longer available; see the error message"];
|
|
470
|
+
if (status !== void 0 && status >= 500) return ["The Composio API failed to process the request; retry later", "If it keeps failing, contact Composio support with the request id"];
|
|
471
|
+
return ["Ensure the tool slug is correct and the input arguments for the tool is valid"];
|
|
472
|
+
};
|
|
446
473
|
const handleToolExecutionError = (tool, actualError) => {
|
|
447
|
-
if (actualError instanceof
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
return new ComposioToolExecutionError(`Error executing the tool ${tool}`, {
|
|
474
|
+
if (actualError instanceof ComposioError$1) return actualError;
|
|
475
|
+
const apiError = actualError instanceof APIError ? actualError : void 0;
|
|
476
|
+
const details = apiError?.details;
|
|
477
|
+
if (apiError && details && ERROR_CODE_HANDLERS.has(details.code)) return ERROR_CODE_HANDLERS.get(details.code)(details, apiError);
|
|
478
|
+
if (isRateLimitResponse(actualError)) return new ComposioToolExecutionRateLimitError(withApiErrorMessage(`Rate limited while executing the tool ${tool}`, actualError.details), actualError, { slug: tool });
|
|
479
|
+
const originalMessage = apiError?.status === void 0 ? actualError.message : void 0;
|
|
480
|
+
return new ComposioToolExecutionError(withApiErrorMessage(`Error executing the tool ${tool}`, details, originalMessage), {
|
|
455
481
|
cause: actualError,
|
|
456
|
-
possibleFixes:
|
|
482
|
+
possibleFixes: apiErrorSuggestedFixes(details) ?? fallbackExecutionFixes(apiError?.status)
|
|
457
483
|
});
|
|
458
484
|
};
|
|
459
485
|
|
|
460
|
-
|
|
461
|
-
//#region src/errors/ToolkitErrors.ts
|
|
486
|
+
// src/errors/ToolkitErrors.ts
|
|
462
487
|
const ToolkitErrorCodes = { TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND" };
|
|
463
488
|
var ComposioToolkitNotFoundError = class extends ComposioError$1 {
|
|
464
489
|
constructor(message = "Toolkit not found", options = {}) {
|
|
@@ -485,8 +510,7 @@ var ComposioToolkitFetchError = class extends ComposioError$1 {
|
|
|
485
510
|
}
|
|
486
511
|
};
|
|
487
512
|
|
|
488
|
-
|
|
489
|
-
//#region src/errors/ValidationErrors.ts
|
|
513
|
+
// src/errors/ValidationErrors.ts
|
|
490
514
|
/**
|
|
491
515
|
* Represents an input validation error using Zod.
|
|
492
516
|
*/
|
|
@@ -550,111 +574,7 @@ var JsonSchemaRefResolutionError = class extends ComposioError$1 {
|
|
|
550
574
|
}
|
|
551
575
|
};
|
|
552
576
|
|
|
553
|
-
|
|
554
|
-
//#region src/errors/SDKErrors.ts
|
|
555
|
-
const SDKErrorCodes = {
|
|
556
|
-
NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED",
|
|
557
|
-
API_KEY_KIND_MISMATCH: "API_KEY_KIND_MISMATCH",
|
|
558
|
-
SCOPE_CONFIG_INVALID: "SCOPE_CONFIG_INVALID",
|
|
559
|
-
REQUEST_CANCELLED: "REQUEST_CANCELLED"
|
|
560
|
-
};
|
|
561
|
-
var ComposioNoAPIKeyError = class extends ComposioError$1 {
|
|
562
|
-
constructor(message = "No Composio API key provided", options = {}) {
|
|
563
|
-
const defaultCause = "Couldn't find an API key in the params, environment variables or in the user config file";
|
|
564
|
-
super(message, {
|
|
565
|
-
...options,
|
|
566
|
-
code: SDKErrorCodes.NO_API_KEY_PROVIDED,
|
|
567
|
-
cause: options.cause || defaultCause,
|
|
568
|
-
possibleFixes: options.possibleFixes || [
|
|
569
|
-
"Ensure you have an API key passed in the params, or in environment variable (COMPOSIO_API_KEY) or in the user config file",
|
|
570
|
-
"To get an API key, please sign up at https://composio.dev/signup",
|
|
571
|
-
"You can also use the Composio CLI to create a project and get an API key"
|
|
572
|
-
],
|
|
573
|
-
statusCode: 401
|
|
574
|
-
});
|
|
575
|
-
this.name = "ComposioNoAPIKeyError";
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
/**
|
|
579
|
-
* Thrown when the organization/project scope of an SDK instance is
|
|
580
|
-
* inconsistent: only one of `orgId` / `projectId` was supplied, or a scope
|
|
581
|
-
* option disagrees with the same header placed in `defaultHeaders`.
|
|
582
|
-
*/
|
|
583
|
-
var ComposioScopeConfigError = class extends ComposioError$1 {
|
|
584
|
-
constructor(message = "Invalid organization/project scope configuration", options = {}) {
|
|
585
|
-
super(message, {
|
|
586
|
-
...options,
|
|
587
|
-
code: SDKErrorCodes.SCOPE_CONFIG_INVALID,
|
|
588
|
-
possibleFixes: options.possibleFixes || ["Pass both `orgId` and `projectId` (the organization and consumer project nano IDs), or neither", "Supply the scope through the options or through the `x-org-id` / `x-project-id` default headers, not both with different values"]
|
|
589
|
-
});
|
|
590
|
-
this.name = "ComposioScopeConfigError";
|
|
591
|
-
}
|
|
592
|
-
};
|
|
593
|
-
/**
|
|
594
|
-
* Thrown when the only API key the SDK could find is a Composio user key
|
|
595
|
-
* (`uak_...`, as stored by `composio login`) rather than a project key.
|
|
596
|
-
* User keys authenticate a person, not a project, so the SDK refuses to send
|
|
597
|
-
* one as `x-api-key`. The error never includes the key value.
|
|
598
|
-
*/
|
|
599
|
-
var ComposioAPIKeyKindError = class extends ComposioError$1 {
|
|
600
|
-
constructor(message = "The stored Composio API key is a user API key, not a project API key", options = {}) {
|
|
601
|
-
super(message, {
|
|
602
|
-
...options,
|
|
603
|
-
code: SDKErrorCodes.API_KEY_KIND_MISMATCH,
|
|
604
|
-
cause: options.cause || "The user config file holds a user API key written by the Composio CLI; it cannot authenticate SDK requests as a project",
|
|
605
|
-
possibleFixes: options.possibleFixes || [
|
|
606
|
-
"Pass a project API key via `apiKey` or the COMPOSIO_API_KEY environment variable",
|
|
607
|
-
"Create a project API key in the Composio dashboard at https://platform.composio.dev",
|
|
608
|
-
"To authenticate with the user API key instead, pass `apiKey: null` together with `userApiKey`"
|
|
609
|
-
],
|
|
610
|
-
statusCode: 401
|
|
611
|
-
});
|
|
612
|
-
this.name = "ComposioAPIKeyKindError";
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
/**
|
|
616
|
-
* Thrown when an SDK call is cancelled via the caller-supplied `AbortSignal`.
|
|
617
|
-
*
|
|
618
|
-
* @example
|
|
619
|
-
* ```typescript
|
|
620
|
-
* try {
|
|
621
|
-
* await composio.tools.execute(slug, body, { signal: AbortSignal.timeout(5_000) });
|
|
622
|
-
* } catch (err) {
|
|
623
|
-
* if (err instanceof ComposioRequestCancelledError) return;
|
|
624
|
-
* throw err;
|
|
625
|
-
* }
|
|
626
|
-
* ```
|
|
627
|
-
*/
|
|
628
|
-
var ComposioRequestCancelledError = class extends ComposioError$1 {
|
|
629
|
-
constructor(message = "Request was cancelled by the caller", options = {}) {
|
|
630
|
-
super(message, {
|
|
631
|
-
...options,
|
|
632
|
-
code: SDKErrorCodes.REQUEST_CANCELLED,
|
|
633
|
-
possibleFixes: options.possibleFixes ?? ["This error is expected when you abort the request via AbortController. Handle it in your catch block to distinguish caller-initiated cancellation from other failures."]
|
|
634
|
-
});
|
|
635
|
-
this.name = "ComposioRequestCancelledError";
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
/**
|
|
639
|
-
* `APIUserAbortError` has `.name === "Error"` at runtime (doesn't override it),
|
|
640
|
-
* so we fall back to `constructor.name` for dual-package-hazard cases.
|
|
641
|
-
* @internal
|
|
642
|
-
*/
|
|
643
|
-
function isRequestAbortError(error) {
|
|
644
|
-
return _isRequestAbortErrorAt(error, 0);
|
|
645
|
-
}
|
|
646
|
-
function _isRequestAbortErrorAt(error, depth) {
|
|
647
|
-
if (depth > 5) return false;
|
|
648
|
-
if (error instanceof APIUserAbortError) return true;
|
|
649
|
-
if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
|
|
650
|
-
if (!(error instanceof Error)) return false;
|
|
651
|
-
if (error.constructor.name === "APIUserAbortError" || error.name === "AbortError" || error.name === "APIUserAbortError") return true;
|
|
652
|
-
if ("cause" in error && error.cause !== void 0 && error.cause !== null) return _isRequestAbortErrorAt(error.cause, depth + 1);
|
|
653
|
-
return false;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
//#endregion
|
|
657
|
-
//#region src/errors/TriggerErrors.ts
|
|
577
|
+
// src/errors/TriggerErrors.ts
|
|
658
578
|
const TriggerErrorCodes = {
|
|
659
579
|
TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS: "TRIGGER_FAILED_TO_GET_SDK_REALTIME_CREDENTIALS",
|
|
660
580
|
TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT: "TRIGGER_FAILED_TO_CREATE_PUSHER_CLIENT",
|
|
@@ -742,8 +662,7 @@ var ComposioWebhookPayloadError = class extends ComposioError$1 {
|
|
|
742
662
|
}
|
|
743
663
|
};
|
|
744
664
|
|
|
745
|
-
|
|
746
|
-
//#region src/errors/RemoteFileErrors.ts
|
|
665
|
+
// src/errors/RemoteFileErrors.ts
|
|
747
666
|
const RemoteFileErrorCodes = { DOWNLOAD_FAILED: "REMOTE_FILE_DOWNLOAD_FAILED" };
|
|
748
667
|
/**
|
|
749
668
|
* Error thrown when fetching a remote file from a tool router session mount fails.
|
|
@@ -775,8 +694,7 @@ var RemoteFileDownloadError = class extends ComposioError$1 {
|
|
|
775
694
|
}
|
|
776
695
|
};
|
|
777
696
|
|
|
778
|
-
|
|
779
|
-
//#region src/errors/ToolRouterErrors.ts
|
|
697
|
+
// src/errors/ToolRouterErrors.ts
|
|
780
698
|
const ToolRouterErrorCodes = {
|
|
781
699
|
MCP_DESTINATION_REJECTED: "MCP_DESTINATION_REJECTED",
|
|
782
700
|
SESSION_CONFIG_CONFLICT: "SESSION_CONFIG_CONFLICT",
|
|
@@ -856,5 +774,4 @@ var ComposioToolInputRequiredError = class extends ComposioError$1 {
|
|
|
856
774
|
}
|
|
857
775
|
};
|
|
858
776
|
|
|
859
|
-
|
|
860
|
-
export { ComposioMultipleConnectedAccountsError as $, ComposioInvalidModifierError as A, handleToolExecutionError as B, ValidationError as C, ToolkitErrorCodes as D, ComposioToolkitNotFoundError as E, ComposioToolFetchError as F, ConnectionRequestFailedError as G, getRetryAfterSeconds as H, ComposioToolFetchRateLimitError as I, ComposioConnectedAccountNotFoundError as J, ConnectionRequestTimeoutError as K, ComposioToolNotFoundError as L, ComposioProviderNotDefinedError as M, ComposioToolExecutionError as N, ComposioGlobalExecuteToolFnNotSetError as O, ComposioToolExecutionRateLimitError as P, ComposioLegacyConnectedAccountsEndpointRetiredError as Q, ComposioToolVersionRequiredError as R, JsonSchemaToZodError as S, ComposioToolkitFetchError as T, isRateLimitResponse as U, isComposioRateLimitError as V, ConnectionRequestErrorCodes as W, ComposioConnectedAccountRevocationNotSupportedError as X, ComposioConnectedAccountNotRevokableError as Y, ComposioFailedToCreateConnectedAccountLink as Z, ComposioRequestCancelledError as _, RemoteFileDownloadError as a, isRequestAbortError as b, ComposioFailedToGetSDKRealtimeCredentialsError as c, ComposioTriggerTypeNotFoundError as d, ComposioSharedAccessDeniedError as et, ComposioWebhookPayloadError as f, ComposioNoAPIKeyError as g, ComposioAPIKeyKindError as h, ToolRouterErrorCodes as i, ComposioAuthConfigNotFoundError as it, ComposioInvalidToolArgumentsError as j, ComposioInvalidExecuteFunctionError as k, ComposioFailedToSubscribeToPusherChannelError as l, TriggerErrorCodes as m, ComposioSessionConfigConflictError as n, ConnectedAccountErrorCodes as nt, RemoteFileErrorCodes as o, ComposioWebhookSignatureVerificationError as p, ComposioAclOnlyForSharedError as q, ComposioToolInputRequiredError as r, AuthConfigErrorCodes as rt, ComposioFailedToCreatePusherClientError as s, ComposioMCPDestinationError as t, ComposioSharedConnectionNotAccessibleError as tt, ComposioFailedToUnsubscribeFromPusherChannelError as u, ComposioScopeConfigError as v, ValidationErrorCodes as w, JsonSchemaRefResolutionError as x, SDKErrorCodes as y, ToolErrorCodes as z };
|
|
777
|
+
export { ComposioAuthConfigNotFoundError as $, ComposioToolFetchRateLimitError as A, ConnectionRequestFailedError as B, ComposioInvalidExecuteFunctionError as C, ComposioToolExecutionError as D, ComposioProviderNotDefinedError as E, handleToolExecutionError as F, ComposioConnectedAccountRevocationNotSupportedError as G, ComposioAclOnlyForSharedError as H, isComposioRateLimitError as I, ComposioMultipleConnectedAccountsError as J, ComposioFailedToCreateConnectedAccountLink as K, getRetryAfterSeconds as L, ComposioToolSchemaInvalidError as M, ComposioToolVersionRequiredError as N, ComposioToolExecutionRateLimitError as O, ToolErrorCodes as P, AuthConfigErrorCodes as Q, isRateLimitResponse as R, ComposioGlobalExecuteToolFnNotSetError as S, ComposioInvalidToolArgumentsError as T, ComposioConnectedAccountNotFoundError as U, ConnectionRequestTimeoutError as V, ComposioConnectedAccountNotRevokableError as W, ComposioSharedConnectionNotAccessibleError as X, ComposioSharedAccessDeniedError as Y, ConnectedAccountErrorCodes as Z, ValidationError as _, RemoteFileDownloadError as a, ComposioToolkitNotFoundError as b, ComposioFailedToGetSDKRealtimeCredentialsError as c, ComposioTriggerTypeNotFoundError as d, ComposioWebhookPayloadError as f, JsonSchemaToZodError as g, JsonSchemaRefResolutionError as h, ToolRouterErrorCodes as i, ComposioToolNotFoundError as j, ComposioToolFetchError as k, ComposioFailedToSubscribeToPusherChannelError as l, TriggerErrorCodes as m, ComposioSessionConfigConflictError as n, RemoteFileErrorCodes as o, ComposioWebhookSignatureVerificationError as p, ComposioLegacyConnectedAccountsEndpointRetiredError as q, ComposioToolInputRequiredError as r, ComposioFailedToCreatePusherClientError as s, ComposioMCPDestinationError as t, ComposioFailedToUnsubscribeFromPusherChannelError as u, ValidationErrorCodes as v, ComposioInvalidModifierError as w, ToolkitErrorCodes as x, ComposioToolkitFetchError as y, ConnectionRequestErrorCodes as z };
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Experimental APIs for `@composio/core`, exposed on the
|
|
3
|
+
* `@composio/core/experimental` subpath. **Experimental — shape may change in
|
|
4
|
+
* future releases.**
|
|
5
|
+
*
|
|
6
|
+
* The stateless tool/toolkit factories (`experimental_createTool`,
|
|
7
|
+
* `experimental_createToolkit`) are ALSO re-exported from the package root, so
|
|
8
|
+
* for those prefer the shorter import:
|
|
9
|
+
* `import { experimental_createTool, experimental_createToolkit } from '@composio/core';`
|
|
10
|
+
*
|
|
11
|
+
* The experimental local workbench helpers now live in the standalone
|
|
12
|
+
* `@composio/experimental` package, on the `@composio/experimental/workbench`
|
|
13
|
+
* subpath — they are no longer part of `@composio/core`.
|
|
14
|
+
*/
|
|
15
|
+
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-Dzk3iqfP.mjs";
|
|
16
|
+
import { C as LocalToolExecuteFn, S as LocalTool, a as CreateCustomToolkitParams, c as CustomTool, k as SessionContext, m as CustomToolkit, o as CreateLocalToolParams, r as CreateCustomToolParams, s as CreateLocalToolkitParams, u as CustomToolExecuteFn, w as LocalToolkit } from "../customTool.types-CpJbzxT6.mjs";
|
|
3
17
|
export { type CreateCustomToolParams, type CreateCustomToolkitParams, type CreateLocalToolParams, type CreateLocalToolkitParams, type CustomTool, type CustomToolExecuteFn, type CustomToolkit, type LocalTool, type LocalToolExecuteFn, type LocalToolkit, type SessionContext, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as createCustomToolkit, i as createCustomTool } from "../CustomTool-
|
|
1
|
+
import { a as createCustomToolkit, i as createCustomTool } from "../CustomTool-9Vlb4XaS.mjs";
|
|
2
2
|
|
|
3
3
|
export { createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { r as ssrfSafeFetch } from "./ssrfGuard.node-
|
|
1
|
+
import { l as COMPOSIO_DIR, p as TEMP_FILES_DIRECTORY_NAME, s as logger } from "./SsrfErrors-BSVMW915.mjs";
|
|
2
|
+
import { a as getMimeTypeFromFileName, f as getRandomShortId, l as base64ToUint8Array, n as assertSafeFileUploadPath, s as readResponseBodyWithLimit, u as uint8ArrayToBase64 } from "./sensitiveFileUploadPaths-CSyJ3Ku8.mjs";
|
|
3
|
+
import { i as ComposioFileUploadPathNotAllowedError, t as ComposioFileNotFoundError } from "./FileModifierErrors-WrqokuIF.mjs";
|
|
4
|
+
import { r as ssrfSafeFetch } from "./ssrfGuard.node-CdIkwqVu.mjs";
|
|
5
5
|
import { platform } from "#platform";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import crypto from "node:crypto";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// src/utils/uploadDirAllowlist.node.ts
|
|
11
11
|
/**
|
|
12
12
|
* Allowlist for automatic file upload during tool execution.
|
|
13
13
|
*
|
|
@@ -151,8 +151,7 @@ function assertPathInsideUploadDirs(filePath, allowlist) {
|
|
|
151
151
|
} });
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
//#region src/utils/fileUtils.node.ts
|
|
154
|
+
// src/utils/fileUtils.node.ts
|
|
156
155
|
/**
|
|
157
156
|
* Checks whether `value` is an absolute http(s) URL rather than a local path.
|
|
158
157
|
*
|
|
@@ -416,5 +415,4 @@ const saveFile = (file, content, options = {}) => {
|
|
|
416
415
|
}
|
|
417
416
|
};
|
|
418
417
|
|
|
419
|
-
//#endregion
|
|
420
418
|
export { getFileDataAfterUploadingToS3 as n, isHttpUrl as r, downloadFileFromS3 as t };
|