@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.
- package/dist/{CustomTool-9Vlb4XaS.mjs → CustomTool-B4dQn2M5.mjs} +1 -1
- package/dist/{CustomTool-Dzk3iqfP.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-CpJbzxT6.d.mts → customTool.types-BSbIG1OG.d.mts} +306 -83
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +28 -11
- 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 +54 -43
- 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 +18 -20
- 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 +10 -15
- package/dist/index.mjs +582 -242
- 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-DQdUb7OG.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 +4 -4
- 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 +18 -2
- 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 +44 -36
- 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 +6 -10
- 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/authConfigs.types.ts +14 -0
- 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/tool.types.ts +1 -1
- package/src/types/toolRouter.types.ts +33 -4
- package/src/types/toolkit.types.ts +21 -0
- 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 +6 -3
- package/src/utils/transformers/toolkits.ts +7 -0
- package/src/utils/userCallback.ts +3 -1
- package/src/utils/webhookVerification.ts +211 -0
- package/dist/composio-DaokW5sV.d.mts +0 -9593
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as JsonSchemaToZodError, h as JsonSchemaRefResolutionError } from "./errors-
|
|
2
|
-
import {
|
|
1
|
+
import { g as JsonSchemaToZodError, h as JsonSchemaRefResolutionError } from "./errors-CtIKA9BH.mjs";
|
|
2
|
+
import { l as logger } from "./SsrfErrors-BekZPeWY.mjs";
|
|
3
3
|
import { o as isPlainObject } from "./FileToolModifier.utils.neutral-BQP85ZJj.mjs";
|
|
4
4
|
import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-
|
|
2
|
-
import {
|
|
3
|
-
import { t as telemetry } from "../Telemetry-
|
|
1
|
+
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-BJUYMEph.mjs";
|
|
2
|
+
import { p as withCancellation } from "../sensitiveFileUploadPaths-CcbMAYCC.mjs";
|
|
3
|
+
import { t as telemetry } from "../Telemetry-BWKZmDxM.mjs";
|
|
4
4
|
|
|
5
5
|
// src/models/Files.node.ts
|
|
6
6
|
var Files = class {
|
package/dist/{sensitiveFileUploadPaths-CSyJ3Ku8.mjs → sensitiveFileUploadPaths-CcbMAYCC.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ComposioSensitiveFilePathBlockedError, f as isRequestAbortError, l as ComposioRequestCancelledError } from "./FileModifierErrors-
|
|
1
|
+
import { a as ComposioSensitiveFilePathBlockedError, f as isRequestAbortError, l as ComposioRequestCancelledError } from "./FileModifierErrors-D-AKc3ds.mjs";
|
|
2
2
|
import { platform } from "#platform";
|
|
3
3
|
|
|
4
4
|
// src/utils/uuid.ts
|
|
@@ -50,25 +50,28 @@ const uint8ArrayToBase64 = (bytes) => {
|
|
|
50
50
|
/** Maximum size accepted for files fetched from user-supplied URLs (100 MiB). */
|
|
51
51
|
const MAX_URL_UPLOAD_SIZE_BYTES = 104857600;
|
|
52
52
|
const sizeLimitError = (actualSize, maxBytes) => /* @__PURE__ */ new Error(`File size (${actualSize} bytes) exceeds maximum allowed size (${maxBytes} bytes)`);
|
|
53
|
+
const assertValidBodyLimit = (maxBytes) => {
|
|
54
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0) throw new RangeError("maxBytes must be a non-negative safe integer");
|
|
55
|
+
};
|
|
53
56
|
/**
|
|
54
|
-
* Read a
|
|
57
|
+
* Read a Fetch request or response within a byte limit.
|
|
55
58
|
*
|
|
56
59
|
* `Content-Length` is checked as an early rejection, but the streamed byte
|
|
57
60
|
* count is authoritative because the header can be absent or dishonest.
|
|
58
61
|
*/
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const contentLength =
|
|
62
|
+
const readBodyWithLimit = async ({ body, headers }, maxBytes, makeSizeLimitError) => {
|
|
63
|
+
assertValidBodyLimit(maxBytes);
|
|
64
|
+
const contentLength = headers.get("content-length")?.trim();
|
|
62
65
|
if (contentLength && /^\d+$/.test(contentLength)) {
|
|
63
66
|
const declaredSize = Number(contentLength);
|
|
64
67
|
if (!Number.isSafeInteger(declaredSize) || declaredSize > maxBytes) {
|
|
65
|
-
const error =
|
|
66
|
-
|
|
68
|
+
const error = makeSizeLimitError(declaredSize, maxBytes);
|
|
69
|
+
body?.cancel(error).catch(() => void 0);
|
|
67
70
|
throw error;
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
|
-
if (!
|
|
71
|
-
const reader =
|
|
73
|
+
if (!body) return /* @__PURE__ */ new Uint8Array();
|
|
74
|
+
const reader = body.getReader();
|
|
72
75
|
const chunks = [];
|
|
73
76
|
let totalBytes = 0;
|
|
74
77
|
try {
|
|
@@ -78,22 +81,25 @@ const readResponseBodyWithLimit = async (response, maxBytes = MAX_URL_UPLOAD_SIZ
|
|
|
78
81
|
if (!value || value.byteLength === 0) continue;
|
|
79
82
|
totalBytes += value.byteLength;
|
|
80
83
|
if (totalBytes > maxBytes) {
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
const error = makeSizeLimitError(totalBytes, maxBytes);
|
|
85
|
+
reader.cancel(error).catch(() => void 0);
|
|
86
|
+
throw error;
|
|
83
87
|
}
|
|
84
88
|
chunks.push(value);
|
|
85
89
|
}
|
|
86
90
|
} finally {
|
|
87
91
|
reader.releaseLock();
|
|
88
92
|
}
|
|
89
|
-
const
|
|
93
|
+
const bytes = new Uint8Array(totalBytes);
|
|
90
94
|
let offset = 0;
|
|
91
95
|
for (const chunk of chunks) {
|
|
92
|
-
|
|
96
|
+
bytes.set(chunk, offset);
|
|
93
97
|
offset += chunk.byteLength;
|
|
94
98
|
}
|
|
95
|
-
return
|
|
99
|
+
return bytes;
|
|
96
100
|
};
|
|
101
|
+
/** Read a Fetch response within the file size limit. */
|
|
102
|
+
const readResponseBodyWithLimit = (response, maxBytes = MAX_URL_UPLOAD_SIZE_BYTES) => readBodyWithLimit(response, maxBytes, sizeLimitError);
|
|
97
103
|
|
|
98
104
|
// src/utils/mime.ts
|
|
99
105
|
/**
|
|
@@ -595,4 +601,4 @@ function assertSafeFileUploadPath(filePath, options) {
|
|
|
595
601
|
}
|
|
596
602
|
}
|
|
597
603
|
|
|
598
|
-
export { getMimeTypeFromFileName as a,
|
|
604
|
+
export { getMimeTypeFromFileName as a, readBodyWithLimit as c, base64ToUint8Array as d, uint8ArrayToBase64 as f, getRandomUUID as h, getExtensionFromMimeType as i, readResponseBodyWithLimit as l, getRandomShortId as m, assertSafeFileUploadPath as n, MAX_URL_UPLOAD_SIZE_BYTES as o, withCancellation as p, isBlockedSensitiveFileUploadPath as r, assertValidBodyLimit as s, BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS as t, arrayBufferToBase64 as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ComposioBlockedInternalUrlError } from "./SsrfErrors-
|
|
1
|
+
import { t as ComposioBlockedInternalUrlError } from "./SsrfErrors-BekZPeWY.mjs";
|
|
2
2
|
import { lookup } from "node:dns/promises";
|
|
3
3
|
import { isIP } from "node:net";
|
|
4
4
|
import { request } from "node:http";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as ComposioConfig } from "./composio-
|
|
2
|
-
import {
|
|
1
|
+
import { n as ComposioConfig } from "./composio-CPf6NHnB.mjs";
|
|
2
|
+
import { Nr as BaseComposioProvider } from "./customTool.types-BSbIG1OG.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Configuration defaults for Composio.
|
|
5
5
|
* These are the required fields that must have default values.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as ConfigDefaults } from "../../types-
|
|
1
|
+
import { t as ConfigDefaults } from "../../types-ns3Q_WrP.mjs";
|
|
2
2
|
export declare const CONFIG_DEFAULTS: ConfigDefaults;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as ConfigDefaults } from "../../types-
|
|
1
|
+
import { t as ConfigDefaults } from "../../types-ns3Q_WrP.mjs";
|
|
2
2
|
export declare const CONFIG_DEFAULTS: ConfigDefaults;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Qa as
|
|
1
|
+
import { Qa as ToolExecuteParams, Ya as Tool, eo as ToolExecuteResponse } from "../../customTool.types-BSbIG1OG.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
3
|
export declare class FileToolModifier {
|
|
4
4
|
private client;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, l as ComposioRequestCancelledError, n as ComposioFileUploadAbortedError, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "../../FileModifierErrors-
|
|
3
|
-
import { n as getFileDataAfterUploadingToS3, r as isHttpUrl, t as downloadFileFromS3 } from "../../fileUtils.node-
|
|
1
|
+
import { l as logger } from "../../SsrfErrors-BekZPeWY.mjs";
|
|
2
|
+
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, l as ComposioRequestCancelledError, n as ComposioFileUploadAbortedError, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "../../FileModifierErrors-D-AKc3ds.mjs";
|
|
3
|
+
import { n as getFileDataAfterUploadingToS3, r as isHttpUrl, t as downloadFileFromS3 } from "../../fileUtils.node-BJUYMEph.mjs";
|
|
4
4
|
import { a as isEmptyFileValue, c as transformProperties, i as getSchemaVariants, l as walkFileUploadableLeaves, o as isPlainObject, r as findSchemaVariantWithFileProperty, t as DELETE_VALUE } from "../../FileToolModifier.utils.neutral-BQP85ZJj.mjs";
|
|
5
|
-
import { n as dereferenceJsonSchema } from "../../jsonSchema-
|
|
6
|
-
import {
|
|
5
|
+
import { n as dereferenceJsonSchema } from "../../jsonSchema-BZoXGUCr.mjs";
|
|
6
|
+
import { p as withCancellation } from "../../sensitiveFileUploadPaths-CcbMAYCC.mjs";
|
|
7
7
|
|
|
8
8
|
// src/utils/modifiers/FileToolModifier.node.ts
|
|
9
9
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Qa as
|
|
1
|
+
import { Qa as ToolExecuteParams, Ya as Tool, eo as ToolExecuteResponse } from "../../customTool.types-BSbIG1OG.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
3
|
export declare class FileToolModifier {
|
|
4
4
|
constructor(_client: ComposioClient);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as ssrfSafeFetchWhereSupported, n as isBlockedIp, r as ssrfSafeFetch, t as assertSafeFetchTarget } from "../ssrfGuard.node-
|
|
1
|
+
import { i as ssrfSafeFetchWhereSupported, n as isBlockedIp, r as ssrfSafeFetch, t as assertSafeFetchTarget } from "../ssrfGuard.node-B749ae5Q.mjs";
|
|
2
2
|
|
|
3
3
|
export { assertSafeFetchTarget, isBlockedIp, ssrfSafeFetch, ssrfSafeFetchWhereSupported };
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=22.22.3"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.32.0",
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "dist/index.mjs",
|
|
10
10
|
"publishConfig": {
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
],
|
|
112
112
|
"license": "ISC",
|
|
113
113
|
"devDependencies": {
|
|
114
|
-
"@hono/node-server": "^2.1.
|
|
114
|
+
"@hono/node-server": "^2.1.8",
|
|
115
115
|
"@types/semver": "^7.8.0",
|
|
116
116
|
"ajv": "^8.20.0",
|
|
117
117
|
"fast-check": "^4.10.2",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"zod": ">=3.25.76 <5"
|
|
129
129
|
},
|
|
130
130
|
"dependencies": {
|
|
131
|
-
"@composio/client": "2.1.
|
|
131
|
+
"@composio/client": "2.1.36",
|
|
132
132
|
"@types/json-schema": "^7.0.15",
|
|
133
133
|
"is-fs-case-sensitive": "^2.0.0",
|
|
134
134
|
"openai": "^7.55.0",
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
"semver": "^7.8.6",
|
|
138
138
|
"undici": "^7.30.2",
|
|
139
139
|
"zod-to-json-schema": "^3.25.2",
|
|
140
|
-
"@composio/json-schema-to-zod": "0.4.
|
|
140
|
+
"@composio/json-schema-to-zod": "0.4.2"
|
|
141
141
|
},
|
|
142
142
|
"gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064",
|
|
143
143
|
"repository": {
|
package/src/composio.ts
CHANGED
|
@@ -31,7 +31,6 @@ import { checkForLatestVersionFromNPM } from './utils/version';
|
|
|
31
31
|
import { OpenAIProvider } from './provider/OpenAIProvider';
|
|
32
32
|
import { version } from '../package.json';
|
|
33
33
|
import type { ComposioRequestHeaders } from './types/composio.types';
|
|
34
|
-
import type { ComposioRequestOptions } from './types/requestOptions.types';
|
|
35
34
|
import { Files } from '#files';
|
|
36
35
|
import { getClientIdentity } from './utils/session';
|
|
37
36
|
import { ToolkitVersionParam } from './types/tool.types';
|
|
@@ -460,19 +459,31 @@ export class Composio<
|
|
|
460
459
|
*
|
|
461
460
|
* @example
|
|
462
461
|
* ```typescript
|
|
462
|
+
* import { Composio } from '@composio/core';
|
|
463
|
+
*
|
|
463
464
|
* // Initialize with default configuration
|
|
464
465
|
* const composio = new Composio();
|
|
466
|
+
* ```
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```typescript
|
|
470
|
+
* import { Composio } from '@composio/core';
|
|
465
471
|
*
|
|
466
472
|
* // Initialize with custom API key and base URL
|
|
467
473
|
* const composio = new Composio({
|
|
468
474
|
* apiKey: 'your-api-key',
|
|
469
475
|
* baseURL: 'https://api.composio.dev'
|
|
470
476
|
* });
|
|
477
|
+
* ```
|
|
471
478
|
*
|
|
472
|
-
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```typescript
|
|
481
|
+
* import { Composio, OpenAIProvider } from '@composio/core';
|
|
482
|
+
*
|
|
483
|
+
* // Initialize with an explicit provider
|
|
473
484
|
* const composio = new Composio({
|
|
474
485
|
* apiKey: 'your-api-key',
|
|
475
|
-
* provider: new
|
|
486
|
+
* provider: new OpenAIProvider()
|
|
476
487
|
* });
|
|
477
488
|
* ```
|
|
478
489
|
*/
|
|
@@ -626,7 +637,7 @@ export class Composio<
|
|
|
626
637
|
|
|
627
638
|
// Check for the latest version of the Composio SDK from NPM.
|
|
628
639
|
if (!this.config.disableVersionCheck) {
|
|
629
|
-
checkForLatestVersionFromNPM(version);
|
|
640
|
+
void checkForLatestVersionFromNPM(version);
|
|
630
641
|
}
|
|
631
642
|
}
|
|
632
643
|
|
|
@@ -678,6 +689,8 @@ export class Composio<
|
|
|
678
689
|
*
|
|
679
690
|
* @example
|
|
680
691
|
* ```typescript
|
|
692
|
+
* import { Composio } from '@composio/core';
|
|
693
|
+
*
|
|
681
694
|
* // Create a base Composio instance
|
|
682
695
|
* const composio = new Composio({
|
|
683
696
|
* apiKey: 'your-api-key'
|
|
@@ -693,7 +706,7 @@ export class Composio<
|
|
|
693
706
|
* });
|
|
694
707
|
*
|
|
695
708
|
* // Use the session for making API calls with the custom headers
|
|
696
|
-
* await composioWithCustomHeaders.tools.
|
|
709
|
+
* await composioWithCustomHeaders.tools.getRawComposioTools({ toolkits: ['github'] });
|
|
697
710
|
* ```
|
|
698
711
|
*/
|
|
699
712
|
createSession(options?: { headers?: ComposioRequestHeaders }): Composio<TProvider> {
|
|
@@ -717,14 +730,20 @@ export class Composio<
|
|
|
717
730
|
* @returns {Promise<void>} A promise that resolves when all pending telemetry has been sent.
|
|
718
731
|
*
|
|
719
732
|
* @example
|
|
720
|
-
* ```typescript
|
|
733
|
+
* ```typescript nocheck="Cloudflare Worker handler; the checker has no Workers Env or ExecutionContext types"
|
|
734
|
+
* import { Composio } from '@composio/core';
|
|
735
|
+
*
|
|
721
736
|
* // In a Cloudflare Worker, use ctx.waitUntil to ensure telemetry is flushed
|
|
722
737
|
* export default {
|
|
723
738
|
* async fetch(request: Request, env: Env, ctx: ExecutionContext) {
|
|
724
739
|
* const composio = new Composio({ apiKey: env.COMPOSIO_API_KEY });
|
|
725
740
|
*
|
|
726
741
|
* // Do your work...
|
|
727
|
-
* const result = await composio.tools.execute(
|
|
742
|
+
* const result = await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
743
|
+
* userId: 'user_123',
|
|
744
|
+
* version: '20250909_00',
|
|
745
|
+
* arguments: { owner: 'composio' },
|
|
746
|
+
* });
|
|
728
747
|
*
|
|
729
748
|
* // Ensure telemetry flushes before worker terminates
|
|
730
749
|
* ctx.waitUntil(composio.flush());
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @module errors/ComposioError
|
|
9
9
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
|
|
10
10
|
*/
|
|
11
|
+
import { describeThrown } from '../utils/userCallback';
|
|
11
12
|
import pc from 'picocolors';
|
|
12
13
|
import { ZodError } from 'zod/v3';
|
|
13
14
|
import { APIError } from '@composio/client';
|
|
@@ -183,7 +184,7 @@ export class ComposioError extends Error {
|
|
|
183
184
|
? sanitizeApiErrorText(rawCause.message)
|
|
184
185
|
: rawCause instanceof Error
|
|
185
186
|
? rawCause.message
|
|
186
|
-
: sanitizeApiErrorText(
|
|
187
|
+
: sanitizeApiErrorText(describeThrown(rawCause));
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
// Add code if exists
|
|
@@ -424,7 +425,7 @@ export class ComposioError extends Error {
|
|
|
424
425
|
|
|
425
426
|
if (error !== null && error !== undefined) {
|
|
426
427
|
logger.error(pc.gray('Error details:'));
|
|
427
|
-
logger.error(' ' + pc.white(
|
|
428
|
+
logger.error(' ' + pc.white(describeThrown(error)));
|
|
428
429
|
}
|
|
429
430
|
|
|
430
431
|
logger.error(''); // Add a trailing empty line
|
package/src/index.ts
CHANGED
|
@@ -54,6 +54,7 @@ export { RemoteFile } from './models/RemoteFile';
|
|
|
54
54
|
export { createConnectionRequest } from './models/ConnectionRequest';
|
|
55
55
|
export { ToolRouterSession } from './models/ToolRouterSession';
|
|
56
56
|
export { Sessions } from './models/Sessions';
|
|
57
|
+
export { SessionWebhooks } from './models/SessionWebhooks';
|
|
57
58
|
export { SessionConfigs } from './models/SessionConfigs';
|
|
58
59
|
export * from './types/provider.types';
|
|
59
60
|
export * from './types/customTool.types';
|
|
@@ -66,6 +67,24 @@ export * from './types/toolkit.types';
|
|
|
66
67
|
export * from './types/triggers.types';
|
|
67
68
|
export * from './types/webhookEvents.types';
|
|
68
69
|
export * from './types/webhooks.types';
|
|
70
|
+
export { SessionWebhookEventTypes } from './types/sessionWebhooks.types';
|
|
71
|
+
export type {
|
|
72
|
+
ParseSessionWebhookParams,
|
|
73
|
+
SessionWebhookAfterExecuteEvent,
|
|
74
|
+
SessionWebhookAfterExecuteResponse,
|
|
75
|
+
SessionWebhookBeforeExecuteEvent,
|
|
76
|
+
SessionWebhookBeforeExecuteResponse,
|
|
77
|
+
SessionWebhookBlockResponse,
|
|
78
|
+
SessionWebhookEvent,
|
|
79
|
+
SessionWebhookEventType,
|
|
80
|
+
SessionWebhookHttpRequest,
|
|
81
|
+
SessionWebhookHttpRequestOverride,
|
|
82
|
+
SessionWebhookHttpResponse,
|
|
83
|
+
SessionWebhookHttpResponseOverride,
|
|
84
|
+
SessionWebhookMetadata,
|
|
85
|
+
SessionWebhookToolCall,
|
|
86
|
+
SessionWebhookToolResponse,
|
|
87
|
+
} from './types/sessionWebhooks.types';
|
|
69
88
|
export * from './types/logs.types';
|
|
70
89
|
export * from './types/usage.types';
|
|
71
90
|
export * from './types/keyring.types';
|
|
@@ -9,9 +9,6 @@ import {
|
|
|
9
9
|
ToolRouterToolsParam,
|
|
10
10
|
ToolRouterConfigManageConnectionsSchema,
|
|
11
11
|
ToolRouterCreateSessionConfigSchema,
|
|
12
|
-
ToolRouterToolkitsParamSchema,
|
|
13
|
-
ToolRouterToolkitsDisabledConfigSchema,
|
|
14
|
-
ToolRouterToolkitsEnabledConfigSchema,
|
|
15
12
|
ToolRouterUpdateSessionConfigSchema,
|
|
16
13
|
ToolRouterUpdateManageConnectionsConfig,
|
|
17
14
|
ToolRouterUpdateManageConnectionsSchema,
|
|
@@ -41,7 +38,7 @@ const requireApprovalParam = <T extends string>(
|
|
|
41
38
|
requireApproval !== undefined ? { require_approval: requireApproval } : {};
|
|
42
39
|
|
|
43
40
|
export const transformToolRouterToolsParams = (
|
|
44
|
-
params?: Record<string, ToolRouterToolsParam | ToolRouterConfigTools>
|
|
41
|
+
params?: Record<string, ToolRouterToolsParam | ToolRouterConfigTools>
|
|
45
42
|
): Record<string, SessionToolsEntry> | undefined => {
|
|
46
43
|
if (!params) {
|
|
47
44
|
return undefined;
|
|
@@ -104,7 +101,7 @@ export const transformToolRouterTagsParams = (
|
|
|
104
101
|
};
|
|
105
102
|
|
|
106
103
|
export const transformToolRouterManageConnectionsParams = (
|
|
107
|
-
params?:
|
|
104
|
+
params?: z.infer<typeof ToolRouterConfigManageConnectionsSchema>
|
|
108
105
|
): NonNullable<SessionCreateParams['manage_connections']> => {
|
|
109
106
|
if (params === undefined) {
|
|
110
107
|
// Default case when params is undefined
|
|
@@ -137,7 +134,7 @@ export const transformToolRouterManageConnectionsParams = (
|
|
|
137
134
|
|
|
138
135
|
export const resolveToolRouterSandboxConfig = (
|
|
139
136
|
config: Pick<ParsedCreateSessionConfig, 'sandbox' | 'workbench'>
|
|
140
|
-
): ParsedCreateSessionConfig['sandbox']
|
|
137
|
+
): ParsedCreateSessionConfig['sandbox'] => {
|
|
141
138
|
if (config.sandbox !== undefined && config.workbench !== undefined) {
|
|
142
139
|
throw new ValidationError(
|
|
143
140
|
'Pass either sandbox or workbench, not both. workbench is a backwards-compatible alias for sandbox.'
|
|
@@ -186,7 +183,7 @@ export const resolveLocalToolsOptions = (
|
|
|
186
183
|
};
|
|
187
184
|
|
|
188
185
|
export const transformToolRouterSandboxParams = (
|
|
189
|
-
params?: ParsedCreateSessionConfig['sandbox']
|
|
186
|
+
params?: ParsedCreateSessionConfig['sandbox']
|
|
190
187
|
): NonNullable<SessionCreateParams['workbench']> | undefined => {
|
|
191
188
|
if (!params) {
|
|
192
189
|
return undefined;
|
|
@@ -235,14 +232,40 @@ export type SessionPatchExperimentalBody = WithNull<
|
|
|
235
232
|
'permissions' | 'link_url_overwrite' | 'fast_mode' | 'submit_feedback'
|
|
236
233
|
>;
|
|
237
234
|
|
|
235
|
+
type GeneratedSessionHook = NonNullable<SessionCreateParams['hooks']>[number];
|
|
236
|
+
|
|
237
|
+
type SessionWebhookHandlerBody = {
|
|
238
|
+
type: 'webhook';
|
|
239
|
+
fallback_action: 'block' | 'continue';
|
|
240
|
+
timeout_ms?: number;
|
|
241
|
+
};
|
|
242
|
+
|
|
238
243
|
/**
|
|
239
|
-
* `hooks` as sent on create and update
|
|
240
|
-
*
|
|
244
|
+
* `hooks` as sent on create and update. Wider than the generated type by the
|
|
245
|
+
* `webhook` handler, which `@composio/client` does not declare until it picks
|
|
246
|
+
* up ComposioHQ/platform#15328.
|
|
241
247
|
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
248
|
+
type SessionHooksBody = Array<
|
|
249
|
+
Omit<GeneratedSessionHook, 'handler'> & {
|
|
250
|
+
handler: GeneratedSessionHook['handler'] | SessionWebhookHandlerBody;
|
|
251
|
+
}
|
|
252
|
+
>;
|
|
253
|
+
|
|
254
|
+
export const transformToolRouterHooksParams = (hooks: ToolRouterHook[]): SessionHooksBody =>
|
|
255
|
+
hooks.map(({ appliesTo, handler, ...hook }) => ({
|
|
256
|
+
...hook,
|
|
257
|
+
applies_to: appliesTo,
|
|
258
|
+
handler:
|
|
259
|
+
handler.type === 'webhook'
|
|
260
|
+
? {
|
|
261
|
+
type: handler.type,
|
|
262
|
+
fallback_action: handler.fallbackAction,
|
|
263
|
+
...(handler.timeoutMs !== undefined && { timeout_ms: handler.timeoutMs }),
|
|
264
|
+
}
|
|
265
|
+
: handler,
|
|
266
|
+
}));
|
|
267
|
+
|
|
268
|
+
export type SessionCreateBody = Omit<SessionCreateParams, 'hooks'> & { hooks?: SessionHooksBody };
|
|
246
269
|
|
|
247
270
|
/**
|
|
248
271
|
* Request body of `session.update()`. Extends the generated `SessionPatchParams`
|
|
@@ -255,8 +278,9 @@ export type SessionPatchBody = Omit<
|
|
|
255
278
|
SessionPatchParams,
|
|
256
279
|
'toolkits' | 'tools' | 'tags' | 'auth_configs' | 'preload' | 'search' | 'execute'
|
|
257
280
|
>,
|
|
258
|
-
'manage_connections' | 'multi_account' | 'experimental'
|
|
281
|
+
'manage_connections' | 'multi_account' | 'experimental' | 'hooks'
|
|
259
282
|
> & {
|
|
283
|
+
hooks?: SessionHooksBody | null;
|
|
260
284
|
manage_connections?: SessionPatchManageConnectionsBody | null;
|
|
261
285
|
multi_account?: SessionPatchMultiAccountBody | null;
|
|
262
286
|
experimental?: SessionPatchExperimentalBody | null;
|
|
@@ -104,7 +104,19 @@ export class AuthConfigs {
|
|
|
104
104
|
* @returns {Promise<CreateAuthConfigResponse>} Created auth config
|
|
105
105
|
*
|
|
106
106
|
* @example
|
|
107
|
-
*
|
|
107
|
+
* import { AuthConfigTypes } from '@composio/core';
|
|
108
|
+
*
|
|
109
|
+
* // Use a specific Composio-managed app; omit managedAppId for the toolkit's default
|
|
110
|
+
* const { composioManagedAuth } = await composio.toolkits.get('slack');
|
|
111
|
+
* const slackAuthConfig = await composio.authConfigs.create('slack', {
|
|
112
|
+
* type: AuthConfigTypes.COMPOSIO_MANAGED,
|
|
113
|
+
* managedAppId: composioManagedAuth?.find(app => !app.isDefault)?.managedAppId,
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* import { AuthConfigTypes, AuthSchemeTypes } from '@composio/core';
|
|
118
|
+
*
|
|
119
|
+
* const authConfig = await composio.authConfigs.create('my-toolkit', {
|
|
108
120
|
* type: AuthConfigTypes.CUSTOM,
|
|
109
121
|
* name: 'My Custom Auth Config',
|
|
110
122
|
* authScheme: AuthSchemeTypes.API_KEY,
|
|
@@ -162,6 +174,7 @@ export class AuthConfigs {
|
|
|
162
174
|
parsedOptions.data.toolAccessConfig.toolsForConnectedAccountCreation,
|
|
163
175
|
}
|
|
164
176
|
: undefined,
|
|
177
|
+
managed_app_id: parsedOptions.data.managedAppId,
|
|
165
178
|
},
|
|
166
179
|
};
|
|
167
180
|
const result = await withCancellation(
|
|
@@ -223,11 +236,14 @@ export class AuthConfigs {
|
|
|
223
236
|
* apiKey: 'new-api-key-value'
|
|
224
237
|
* }
|
|
225
238
|
* });
|
|
239
|
+
* ```
|
|
226
240
|
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
227
243
|
* // Update a default auth config with new scopes
|
|
228
244
|
* const updatedConfig = await composio.authConfigs.update('auth_abc123', {
|
|
229
245
|
* type: 'default',
|
|
230
|
-
* scopes:
|
|
246
|
+
* scopes: 'read:user,repo'
|
|
231
247
|
* });
|
|
232
248
|
* ```
|
|
233
249
|
*/
|
|
@@ -171,6 +171,8 @@ export class ConnectedAccounts {
|
|
|
171
171
|
*
|
|
172
172
|
* @example
|
|
173
173
|
* ```typescript
|
|
174
|
+
* import { AuthScheme } from '@composio/core';
|
|
175
|
+
*
|
|
174
176
|
* // For OAuth2 authentication
|
|
175
177
|
* const connectionRequest = await composio.connectedAccounts.initiate(
|
|
176
178
|
* 'user_123',
|
|
@@ -183,17 +185,27 @@ export class ConnectedAccounts {
|
|
|
183
185
|
* })
|
|
184
186
|
* }
|
|
185
187
|
* );
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* import { AuthScheme } from '@composio/core';
|
|
186
193
|
*
|
|
187
194
|
* // For API Key authentication
|
|
188
195
|
* const connectionRequest = await composio.connectedAccounts.initiate(
|
|
189
196
|
* 'user_123',
|
|
190
197
|
* 'auth_config_123',
|
|
191
198
|
* {
|
|
192
|
-
* config: AuthScheme.
|
|
199
|
+
* config: AuthScheme.APIKey({
|
|
193
200
|
* api_key: 'your_api_key'
|
|
194
201
|
* })
|
|
195
202
|
* }
|
|
196
203
|
* );
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* import { AuthScheme } from '@composio/core';
|
|
197
209
|
*
|
|
198
210
|
* // For Basic authentication
|
|
199
211
|
* const connectionRequest = await composio.connectedAccounts.initiate(
|
|
@@ -470,7 +482,10 @@ export class ConnectedAccounts {
|
|
|
470
482
|
* ```typescript
|
|
471
483
|
* // Wait for a connection to complete with default timeout
|
|
472
484
|
* const connectedAccount = await composio.connectedAccounts.waitForConnection('conn_123abc');
|
|
485
|
+
* ```
|
|
473
486
|
*
|
|
487
|
+
* @example
|
|
488
|
+
* ```typescript
|
|
474
489
|
* // Wait with a custom timeout of 2 minutes
|
|
475
490
|
* const connectedAccount = await composio.connectedAccounts.waitForConnection('conn_123abc', 120000);
|
|
476
491
|
* ```
|
|
@@ -658,11 +673,16 @@ export class ConnectedAccounts {
|
|
|
658
673
|
*
|
|
659
674
|
* @example
|
|
660
675
|
* ```typescript
|
|
661
|
-
* //
|
|
662
|
-
*
|
|
663
|
-
*
|
|
664
|
-
* sessionUri
|
|
665
|
-
* }
|
|
676
|
+
* // Your verifier route, after authenticating the user
|
|
677
|
+
* export async function GET(request: Request) {
|
|
678
|
+
* // The session URI arrives as the `session_uri` query parameter of the verifier redirect
|
|
679
|
+
* const sessionUri = new URL(request.url).searchParams.get('session_uri') ?? '';
|
|
680
|
+
* const { connectedAccountId, toolkitSlug } = await composio.connectedAccounts.completeAuth({
|
|
681
|
+
* userId: 'user_123',
|
|
682
|
+
* sessionUri,
|
|
683
|
+
* });
|
|
684
|
+
* return new Response(`Connected ${toolkitSlug}: ${connectedAccountId}`);
|
|
685
|
+
* }
|
|
666
686
|
* ```
|
|
667
687
|
*/
|
|
668
688
|
async completeAuth(
|
|
@@ -702,10 +722,9 @@ export class ConnectedAccounts {
|
|
|
702
722
|
* enabled: true
|
|
703
723
|
* });
|
|
704
724
|
*
|
|
705
|
-
* // Disable a connected account
|
|
725
|
+
* // Disable a connected account
|
|
706
726
|
* const disabledAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
|
|
707
|
-
* enabled: false
|
|
708
|
-
* reason: 'Token expired'
|
|
727
|
+
* enabled: false
|
|
709
728
|
* });
|
|
710
729
|
* ```
|
|
711
730
|
*/
|
|
@@ -729,7 +748,7 @@ export class ConnectedAccounts {
|
|
|
729
748
|
* ```typescript
|
|
730
749
|
* // Enable a previously disabled connected account
|
|
731
750
|
* const enabledAccount = await composio.connectedAccounts.enable('conn_abc123');
|
|
732
|
-
* console.log(enabledAccount.
|
|
751
|
+
* console.log(enabledAccount.success); // true
|
|
733
752
|
* ```
|
|
734
753
|
*/
|
|
735
754
|
async enable(
|
|
@@ -751,13 +770,7 @@ export class ConnectedAccounts {
|
|
|
751
770
|
* ```typescript
|
|
752
771
|
* // Disable a connected account
|
|
753
772
|
* const disabledAccount = await composio.connectedAccounts.disable('conn_abc123');
|
|
754
|
-
* console.log(disabledAccount.
|
|
755
|
-
*
|
|
756
|
-
* // You can also use updateStatus with a reason
|
|
757
|
-
* // const disabledAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
|
|
758
|
-
* // enabled: false,
|
|
759
|
-
* // reason: 'No longer needed'
|
|
760
|
-
* // });
|
|
773
|
+
* console.log(disabledAccount.success); // true
|
|
761
774
|
* ```
|
|
762
775
|
*/
|
|
763
776
|
async disable(
|
package/src/models/CustomTool.ts
CHANGED
|
@@ -52,16 +52,6 @@ export const LOCAL_TOOL_PREFIX = 'LOCAL_';
|
|
|
52
52
|
/** Maximum allowed length for the final prefixed slug. */
|
|
53
53
|
const MAX_SLUG_LENGTH = 60;
|
|
54
54
|
|
|
55
|
-
type InputParamsSchema = {
|
|
56
|
-
definitions: {
|
|
57
|
-
input: {
|
|
58
|
-
type: string;
|
|
59
|
-
properties: Record<string, unknown>;
|
|
60
|
-
required?: string[];
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
|
|
65
55
|
/**
|
|
66
56
|
* Compute the final slug length for a tool given its context.
|
|
67
57
|
* Returns the expected length of LOCAL_[TOOLKIT_]SLUG.
|
package/src/models/Keyring.ts
CHANGED
|
@@ -43,9 +43,10 @@ export class Keyring {
|
|
|
43
43
|
* @returns {Promise<KeyringTransferKeysResponse>} The active key ID and every accepted public JWK, newest first
|
|
44
44
|
*
|
|
45
45
|
* @example
|
|
46
|
-
* ```typescript
|
|
46
|
+
* ```typescript nocheck="Seals with the jose library, whose types the checker does not load"
|
|
47
47
|
* import { CompactEncrypt, importJWK } from 'jose';
|
|
48
48
|
*
|
|
49
|
+
* const secret = 'my-client-secret';
|
|
49
50
|
* const { activeKid, keys } = await composio.keyring.listTransferKeys();
|
|
50
51
|
* const jwk = keys.find(key => key.kid === activeKid)!;
|
|
51
52
|
* const sealed = await new CompactEncrypt(new TextEncoder().encode(secret))
|