@composio/core 0.18.0 → 0.19.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-C4tv-GL1.mjs → CustomTool-BMlZfJVz.mjs} +16 -6
- package/dist/{CustomTool-BKhHv2hJ.d.mts → CustomTool-CB5vm1Jc.d.mts} +1 -1
- package/dist/{FileModifierErrors-B8V8_3VE.mjs → FileModifierErrors-BqFmpRsm.mjs} +1 -1
- package/dist/{FileToolModifier.utils.neutral-D_YkHwZP.mjs → FileToolModifier.utils.neutral-DWFpnsj2.mjs} +4 -2
- package/dist/{SsrfErrors-DNJt57GL.mjs → SsrfErrors-C91YhASE.mjs} +137 -13
- package/dist/{Telemetry-CBtSnWrm.mjs → Telemetry-HlftxMx6.mjs} +2 -34
- package/dist/{cancellation-jUVItfHw.mjs → cancellation-CXpfmiVo.mjs} +7 -5
- package/dist/{composio-CldtZUyC.d.mts → composio-DLGaeN70.d.mts} +333 -32
- package/dist/{customTool.types-DC5fPOOi.d.mts → customTool.types-BAmEh3MB.d.mts} +131 -38
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +2 -2
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +3 -13
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +50 -6
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +4 -4
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +33 -23
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +3 -2
- package/dist/{errors-DyZt79fi.mjs → errors-BuEKehbI.mjs} +23 -3
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-BwpUOF0s.mjs → fileUtils.node-L7XD8UPr.mjs} +11 -9
- package/dist/index.d.mts +164 -104
- package/dist/index.mjs +382 -153
- package/dist/models/Files.node.d.mts +2 -3
- package/dist/models/Files.node.mjs +2 -2
- package/dist/models/Files.workerd.d.mts +2 -3
- package/dist/platform/node.d.mts +2 -3
- package/dist/platform/workerd.d.mts +2 -3
- package/dist/{sensitiveFileUploadPaths-B0w8dqpv.mjs → sensitiveFileUploadPaths-B6pBt9lO.mjs} +10 -7
- package/dist/{ssrfGuard.node-DlxO8uzr.mjs → ssrfGuard.node-B9xQB4za.mjs} +197 -30
- package/dist/{types-BgsRW-XH.d.mts → types-CxLPO0Xq.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +3 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.node.mjs +6 -6
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/dist/utils/ssrfGuard.node.d.mts +19 -10
- package/dist/utils/ssrfGuard.node.mjs +1 -1
- package/dist/utils/ssrfGuard.workerd.d.mts +12 -4
- package/dist/utils/ssrfGuard.workerd.mjs +2 -2
- package/package.json +26 -8
- package/src/errors/ToolErrors.ts +24 -0
- package/src/index.ts +4 -0
- package/src/models/CustomTool.ts +41 -6
- package/src/models/MCP.ts +29 -15
- package/src/models/RemoteFile.ts +54 -36
- package/src/models/ToolRouter.ts +1 -0
- package/src/models/ToolRouterSession.ts +115 -13
- package/src/models/Toolkits.ts +1 -2
- package/src/models/Tools.ts +55 -25
- package/src/models/Triggers.ts +22 -2
- package/src/services/pusher/Pusher.ts +29 -10
- package/src/telemetry/redact.ts +133 -6
- package/src/types/toolRouter.types.ts +54 -3
- package/src/types/toolkit.types.ts +17 -0
- package/src/utils/fileUtils.node.ts +10 -2
- package/src/utils/jsonSchema.ts +4 -1
- package/src/utils/logger.ts +6 -6
- package/src/utils/pinnedDispatcher.node.ts +109 -13
- package/src/utils/sdk.ts +1 -1
- package/src/utils/ssrfGuard.node.ts +153 -27
- package/src/utils/ssrfGuard.workerd.ts +15 -1
- package/src/utils/transformers/toolkits.ts +79 -2
|
@@ -44,6 +44,10 @@ async execute(slug: string, body: ToolExecuteParams, options?: ExecuteToolModifi
|
|
|
44
44
|
**Example**
|
|
45
45
|
|
|
46
46
|
```typescript
|
|
47
|
+
// Look up the tool's current version once, then pin that string in your code or config
|
|
48
|
+
const { version } = await composio.tools.getRawComposioToolBySlug('GITHUB_GET_REPOS');
|
|
49
|
+
console.log(version); // e.g. '20250909_00'
|
|
50
|
+
|
|
47
51
|
const result = await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
48
52
|
userId: 'default',
|
|
49
53
|
version: '20250909_00',
|
|
@@ -180,9 +184,10 @@ const emailTools = await composio.tools.get('default', {
|
|
|
180
184
|
|
|
181
185
|
### getInput()
|
|
182
186
|
|
|
183
|
-
|
|
187
|
+
Generates arguments for a tool from a natural-language description of the task.
|
|
184
188
|
|
|
185
|
-
|
|
189
|
+
Composio uses an LLM to fill the tool's input parameters from `text`. Review the
|
|
190
|
+
generated arguments before passing them to `tools.execute()`.
|
|
186
191
|
|
|
187
192
|
```typescript
|
|
188
193
|
async getInput(slug: string, body: ToolGetInputParams, requestOptions?: ComposioRequestOptions): Promise<ToolGetInputResponse>
|
|
@@ -192,22 +197,23 @@ async getInput(slug: string, body: ToolGetInputParams, requestOptions?: Composio
|
|
|
192
197
|
|
|
193
198
|
| Name | Type | Description |
|
|
194
199
|
|------|------|-------------|
|
|
195
|
-
| `slug` | `string` | The
|
|
196
|
-
| `body` | `ToolGetInputParams` | The
|
|
200
|
+
| `slug` | `string` | The slug of the tool to generate arguments for |
|
|
201
|
+
| `body` | `ToolGetInputParams` | The generation request |
|
|
197
202
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
198
203
|
|
|
199
204
|
**Returns**
|
|
200
205
|
|
|
201
|
-
`Promise<ToolGetInputResponse>` — The
|
|
206
|
+
`Promise<ToolGetInputResponse>` — The generated `arguments`, or an `error` when generation fails
|
|
202
207
|
|
|
203
208
|
**Example**
|
|
204
209
|
|
|
205
210
|
```typescript
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
const { arguments: args, error } = await composio.tools.getInput('GITHUB_CREATE_ISSUE', {
|
|
212
|
+
text: 'Open an issue in composiohq/composio titled "Docs typo" describing the broken link',
|
|
213
|
+
version: '20250909_00',
|
|
209
214
|
});
|
|
210
|
-
|
|
215
|
+
if (error) throw new Error(error);
|
|
216
|
+
console.log(args); // { owner: 'composiohq', repo: 'composio', title: 'Docs typo', ... }
|
|
211
217
|
```
|
|
212
218
|
|
|
213
219
|
---
|
|
@@ -415,10 +421,16 @@ console.log(toolsEnum.items);
|
|
|
415
421
|
|
|
416
422
|
### proxyExecute()
|
|
417
423
|
|
|
418
|
-
|
|
424
|
+
Sends an HTTP request to a toolkit's API, authenticated as a connected account.
|
|
425
|
+
|
|
426
|
+
Use it to call an endpoint that no predefined tool covers. Composio injects the
|
|
427
|
+
connected account's credentials on the server side.
|
|
419
428
|
|
|
420
|
-
|
|
421
|
-
|
|
429
|
+
A relative `endpoint` is appended to the toolkit's base URL, and that base URL can
|
|
430
|
+
already include a path. Google Calendar's base URL is
|
|
431
|
+
`https://www.googleapis.com/calendar/v3`, so pass `/users/me/calendarList`, not
|
|
432
|
+
`/calendar/v3/users/me/calendarList` (which resolves to `/calendar/v3/calendar/v3/...`
|
|
433
|
+
and returns a 404 from Google). An absolute URL on the same domain is sent as-is.
|
|
422
434
|
|
|
423
435
|
```typescript
|
|
424
436
|
async proxyExecute(body: ToolProxyParams, requestOptions?: ComposioRequestOptions): Promise<ToolProxyResponse>
|
|
@@ -428,26 +440,24 @@ async proxyExecute(body: ToolProxyParams, requestOptions?: ComposioRequestOption
|
|
|
428
440
|
|
|
429
441
|
| Name | Type | Description |
|
|
430
442
|
|------|------|-------------|
|
|
431
|
-
| `body` | `ToolProxyParams` | The
|
|
443
|
+
| `body` | `ToolProxyParams` | The proxy request |
|
|
432
444
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
433
445
|
|
|
434
446
|
**Returns**
|
|
435
447
|
|
|
436
|
-
`Promise<ToolProxyResponse>` — The
|
|
448
|
+
`Promise<ToolProxyResponse>` — The upstream status, headers, and parsed body
|
|
437
449
|
|
|
438
450
|
**Example**
|
|
439
451
|
|
|
440
452
|
```typescript
|
|
441
|
-
//
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
method: 'GET'
|
|
448
|
-
}
|
|
453
|
+
// Google Calendar's base URL is https://www.googleapis.com/calendar/v3
|
|
454
|
+
const { status, data } = await composio.tools.proxyExecute({
|
|
455
|
+
endpoint: '/users/me/calendarList',
|
|
456
|
+
method: 'GET',
|
|
457
|
+
connectedAccountId: 'ca_...',
|
|
458
|
+
parameters: [{ in: 'query', name: 'maxResults', value: 10 }],
|
|
449
459
|
});
|
|
450
|
-
console.log(
|
|
460
|
+
console.log(status, data);
|
|
451
461
|
```
|
|
452
462
|
|
|
453
463
|
---
|
|
@@ -311,7 +311,7 @@ await composio.triggers.setWebhookSubscription({
|
|
|
311
311
|
Subscribe to all the triggers
|
|
312
312
|
|
|
313
313
|
```typescript
|
|
314
|
-
async subscribe(fn: (_data: IncomingTriggerPayload) => void, filters:
|
|
314
|
+
async subscribe(fn: (_data: IncomingTriggerPayload) => void, filters?: TriggerSubscribeParams, onSubscriptionError?: (data: Record<string, unknown>) => void): Promise<void>
|
|
315
315
|
```
|
|
316
316
|
|
|
317
317
|
**Parameters**
|
|
@@ -319,7 +319,8 @@ async subscribe(fn: (_data: IncomingTriggerPayload) => void, filters: TriggerSub
|
|
|
319
319
|
| Name | Type | Description |
|
|
320
320
|
|------|------|-------------|
|
|
321
321
|
| `fn` | `(_data: IncomingTriggerPayload) => void` | The function to call when a trigger is received |
|
|
322
|
-
| `filters
|
|
322
|
+
| `filters?` | `TriggerSubscribeParams` | The filters to apply to the triggers |
|
|
323
|
+
| `onSubscriptionError?` | `(data: Record<string, unknown>) => void` | Optional callback invoked with the raw Pusher payload when the underlying subscription fails (for example on auth or permission rejection). The subscribe promise still resolves; this is the only programmatic signal of the failure. Errors thrown from — or promises rejected by — the callback are contained and logged. |
|
|
323
324
|
|
|
324
325
|
**Returns**
|
|
325
326
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as ComposioError$1 } from "./SsrfErrors-
|
|
2
|
-
import "./FileModifierErrors-
|
|
1
|
+
import { r as ComposioError$1 } from "./SsrfErrors-C91YhASE.mjs";
|
|
2
|
+
import "./FileModifierErrors-BqFmpRsm.mjs";
|
|
3
3
|
import { APIError, APIUserAbortError } from "@composio/client";
|
|
4
4
|
import { ZodError } from "zod/v3";
|
|
5
5
|
|
|
@@ -168,6 +168,7 @@ var ConnectionRequestFailedError = class extends ComposioError$1 {
|
|
|
168
168
|
const ToolErrorCodes = {
|
|
169
169
|
TOOLSET_NOT_DEFINED: "TOOLSET_NOT_DEFINED",
|
|
170
170
|
TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
|
|
171
|
+
TOOL_FETCH_ERROR: "TOOL_FETCH_ERROR",
|
|
171
172
|
INVALID_MODIFIER: "INVALID_MODIFIER",
|
|
172
173
|
TOOL_EXECUTION_ERROR: "TOOL_EXECUTION_ERROR",
|
|
173
174
|
INVALID_TOOL_ARGUMENTS: "INVALID_TOOL_ARGUMENTS",
|
|
@@ -195,6 +196,25 @@ var ComposioToolNotFoundError = class extends ComposioError$1 {
|
|
|
195
196
|
this.name = "ComposioToolNotFoundError";
|
|
196
197
|
}
|
|
197
198
|
};
|
|
199
|
+
/**
|
|
200
|
+
* Error thrown when a tool schema could not be fetched for a reason other than
|
|
201
|
+
* the tool not existing (for example an invalid API key, a server error, or a
|
|
202
|
+
* network failure). The underlying client error is preserved as `cause`.
|
|
203
|
+
*/
|
|
204
|
+
var ComposioToolFetchError = class extends ComposioError$1 {
|
|
205
|
+
constructor(message = "Failed to fetch tool", options = {}) {
|
|
206
|
+
super(message, {
|
|
207
|
+
...options,
|
|
208
|
+
code: ToolErrorCodes.TOOL_FETCH_ERROR,
|
|
209
|
+
possibleFixes: options.possibleFixes || [
|
|
210
|
+
"Ensure the tool slug is valid",
|
|
211
|
+
"Ensure you are using the correct API key",
|
|
212
|
+
"Ensure you are using the correct API endpoint / Base URL and it is working"
|
|
213
|
+
]
|
|
214
|
+
});
|
|
215
|
+
this.name = "ComposioToolFetchError";
|
|
216
|
+
}
|
|
217
|
+
};
|
|
198
218
|
var ComposioInvalidModifierError = class extends ComposioError$1 {
|
|
199
219
|
constructor(message = "Invalid modifier", options = {}) {
|
|
200
220
|
super(message, {
|
|
@@ -618,4 +638,4 @@ var RemoteFileDownloadError = class extends ComposioError$1 {
|
|
|
618
638
|
};
|
|
619
639
|
|
|
620
640
|
//#endregion
|
|
621
|
-
export {
|
|
641
|
+
export { ComposioToolVersionRequiredError as A, ComposioMultipleConnectedAccountsError as B, ComposioInvalidExecuteFunctionError as C, ComposioToolExecutionError as D, ComposioProviderNotDefinedError as E, ConnectionRequestTimeoutError as F, ComposioAuthConfigNotFoundError as G, ComposioSharedConnectionNotAccessibleError as H, ComposioAclOnlyForSharedError as I, ComposioConnectedAccountNotFoundError as L, handleToolExecutionError as M, ConnectionRequestErrorCodes as N, ComposioToolFetchError as O, ConnectionRequestFailedError as P, ComposioFailedToCreateConnectedAccountLink as R, ComposioGlobalExecuteToolFnNotSetError as S, ComposioInvalidToolArgumentsError as T, ConnectedAccountErrorCodes as U, ComposioSharedAccessDeniedError as V, AuthConfigErrorCodes as W, ValidationError as _, ComposioFailedToSubscribeToPusherChannelError as a, ComposioToolkitNotFoundError as b, ComposioWebhookPayloadError as c, ComposioNoAPIKeyError as d, ComposioRequestCancelledError as f, JsonSchemaToZodError as g, JsonSchemaRefResolutionError as h, ComposioFailedToGetSDKRealtimeCredentialsError as i, ToolErrorCodes as j, ComposioToolNotFoundError as k, ComposioWebhookSignatureVerificationError as l, isRequestAbortError as m, RemoteFileErrorCodes as n, ComposioFailedToUnsubscribeFromPusherChannelError as o, SDKErrorCodes as p, ComposioFailedToCreatePusherClientError as r, ComposioTriggerTypeNotFoundError as s, RemoteFileDownloadError as t, TriggerErrorCodes as u, ValidationErrorCodes as v, ComposioInvalidModifierError as w, ToolkitErrorCodes as x, ComposioToolkitFetchError as y, ComposioLegacyConnectedAccountsEndpointRetiredError as z };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as SessionContext, a as CreateCustomToolkitParams, c as CustomToolExecuteFn, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams } from "../customTool.types-
|
|
2
|
-
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-
|
|
1
|
+
import { S as SessionContext, a as CreateCustomToolkitParams, c as CustomToolExecuteFn, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams } from "../customTool.types-BAmEh3MB.mjs";
|
|
2
|
+
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-CB5vm1Jc.mjs";
|
|
3
3
|
export { type CreateCustomToolParams, type CreateCustomToolkitParams, type CustomTool, type CustomToolExecuteFn, type CustomToolkit, 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-BMlZfJVz.mjs";
|
|
2
2
|
|
|
3
3
|
export { createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as ComposioFileUploadPathNotAllowedError, t as ComposioFileNotFoundError } from "./FileModifierErrors-
|
|
3
|
-
import {
|
|
4
|
-
import { r as ssrfSafeFetch } from "./ssrfGuard.node-
|
|
1
|
+
import { d as TEMP_FILES_DIRECTORY_NAME, i as logger, o as COMPOSIO_DIR } from "./SsrfErrors-C91YhASE.mjs";
|
|
2
|
+
import { i as ComposioFileUploadPathNotAllowedError, t as ComposioFileNotFoundError } from "./FileModifierErrors-BqFmpRsm.mjs";
|
|
3
|
+
import { a as readResponseBodyWithLimit, c as uint8ArrayToBase64, l as getRandomShortId, n as assertSafeFileUploadPath, s as base64ToUint8Array } from "./sensitiveFileUploadPaths-B6pBt9lO.mjs";
|
|
4
|
+
import { r as ssrfSafeFetch } from "./ssrfGuard.node-B9xQB4za.mjs";
|
|
5
5
|
import { platform } from "#platform";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
@@ -302,8 +302,10 @@ const readFile = async (file, signal) => {
|
|
|
302
302
|
content: uint8ArrayToBase64(new Uint8Array(content)),
|
|
303
303
|
mimeType: file.type
|
|
304
304
|
};
|
|
305
|
-
} else if (typeof file === "string")
|
|
306
|
-
|
|
305
|
+
} else if (typeof file === "string") {
|
|
306
|
+
if (isHttpUrl(file)) return await readFileContentFromURL(file, signal);
|
|
307
|
+
else return await readFileContent(file);
|
|
308
|
+
}
|
|
307
309
|
throw new Error("Invalid file type");
|
|
308
310
|
};
|
|
309
311
|
const getFileDataAfterUploadingToS3 = async (file, { toolSlug, toolkitSlug, client, sensitiveFileUploadProtection, fileUploadPathDenySegments, fileUploadAllowlist, signal }) => {
|
|
@@ -321,10 +323,10 @@ const getFileDataAfterUploadingToS3 = async (file, { toolSlug, toolkitSlug, clie
|
|
|
321
323
|
s3key
|
|
322
324
|
};
|
|
323
325
|
};
|
|
324
|
-
const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType, fileDownloadDir, signal }) => {
|
|
326
|
+
const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType, fileDownloadDir, signal, maxDownloadBytes }) => {
|
|
325
327
|
const response = await ssrfSafeFetch(s3Url, { signal });
|
|
326
328
|
if (!response.ok) throw new Error(`Failed to download file: ${response.statusText}`);
|
|
327
|
-
const data = await response
|
|
329
|
+
const data = await readResponseBodyWithLimit(response, maxDownloadBytes);
|
|
328
330
|
const extension = getExtensionFromMimeType(mimeType);
|
|
329
331
|
const fileName = generateTimestampedFilename(extension, `${toolSlug}_`);
|
|
330
332
|
return {
|
|
@@ -334,7 +336,7 @@ const downloadFileFromS3 = async ({ toolSlug, s3Url, mimeType, fileDownloadDir,
|
|
|
334
336
|
/**
|
|
335
337
|
* @todo: fix in follow-up PR.
|
|
336
338
|
*/
|
|
337
|
-
filePath: saveFile(fileName,
|
|
339
|
+
filePath: saveFile(fileName, data, {
|
|
338
340
|
isTempFile: fileDownloadDir === void 0,
|
|
339
341
|
outputDir: fileDownloadDir
|
|
340
342
|
})
|