@composio/core 0.1.31 → 0.1.33
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/index.cjs +173 -150
- package/dist/index.d.cts +10593 -271
- package/dist/index.d.ts +10593 -271
- package/dist/index.js +158 -146
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -695,13 +695,18 @@ var TelemetryService = class {
|
|
|
695
695
|
* @returns The response from the Telemetry API.
|
|
696
696
|
*/
|
|
697
697
|
static async sendMetric(payload) {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
698
|
+
try {
|
|
699
|
+
const result = await fetch(`${TELEMETRY_URL2}/metrics/invocations`, {
|
|
700
|
+
method: "POST",
|
|
701
|
+
headers: {
|
|
702
|
+
"Content-Type": "application/json"
|
|
703
|
+
},
|
|
704
|
+
body: JSON.stringify(payload)
|
|
705
|
+
});
|
|
706
|
+
return result;
|
|
707
|
+
} catch (error) {
|
|
708
|
+
logger_default.debug("Error sending metric telemetry", error);
|
|
709
|
+
}
|
|
705
710
|
}
|
|
706
711
|
/**
|
|
707
712
|
* Sends an error log to the Telemetry API.
|
|
@@ -709,13 +714,18 @@ var TelemetryService = class {
|
|
|
709
714
|
* @returns The response from the Telemetry API.
|
|
710
715
|
*/
|
|
711
716
|
static async sendErrorLog(payload) {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
717
|
+
try {
|
|
718
|
+
const result = await fetch(`${TELEMETRY_URL2}/errors`, {
|
|
719
|
+
method: "POST",
|
|
720
|
+
headers: {
|
|
721
|
+
"Content-Type": "application/json"
|
|
722
|
+
},
|
|
723
|
+
body: JSON.stringify(payload)
|
|
724
|
+
});
|
|
725
|
+
return result;
|
|
726
|
+
} catch (error) {
|
|
727
|
+
logger_default.debug("Error sending error telemetry", error);
|
|
728
|
+
}
|
|
719
729
|
}
|
|
720
730
|
};
|
|
721
731
|
|
|
@@ -1926,6 +1936,7 @@ var readFileContent = async (path) => {
|
|
|
1926
1936
|
try {
|
|
1927
1937
|
const content = __require("fs").readFileSync(path);
|
|
1928
1938
|
return {
|
|
1939
|
+
fileName: path,
|
|
1929
1940
|
content: content.toString("base64"),
|
|
1930
1941
|
mimeType: "application/octet-stream"
|
|
1931
1942
|
};
|
|
@@ -1943,7 +1954,8 @@ var readFileContentFromURL = async (path) => {
|
|
|
1943
1954
|
const mimeType = response.headers.get("content-type") || "application/octet-stream";
|
|
1944
1955
|
return {
|
|
1945
1956
|
content: content.toString("base64"),
|
|
1946
|
-
mimeType
|
|
1957
|
+
mimeType,
|
|
1958
|
+
fileName: path
|
|
1947
1959
|
};
|
|
1948
1960
|
};
|
|
1949
1961
|
var uploadFileToS3 = async (fileName, content, toolSlug, toolkitSlug, mimeType, client) => {
|
|
@@ -1975,17 +1987,35 @@ var uploadFileToS3 = async (fileName, content, toolSlug, toolkitSlug, mimeType,
|
|
|
1975
1987
|
}
|
|
1976
1988
|
return key;
|
|
1977
1989
|
};
|
|
1978
|
-
var
|
|
1979
|
-
|
|
1990
|
+
var readFile = async (file) => {
|
|
1991
|
+
if (file instanceof File) {
|
|
1992
|
+
const content = await file.arrayBuffer();
|
|
1993
|
+
return {
|
|
1994
|
+
fileName: file.name,
|
|
1995
|
+
content: Buffer.from(content).toString("base64"),
|
|
1996
|
+
mimeType: file.type
|
|
1997
|
+
};
|
|
1998
|
+
} else if (typeof file === "string") {
|
|
1999
|
+
if (file.startsWith("http")) {
|
|
2000
|
+
return await readFileContentFromURL(file);
|
|
2001
|
+
} else {
|
|
2002
|
+
return await readFileContent(file);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
throw new Error("Invalid file type");
|
|
2006
|
+
};
|
|
2007
|
+
var getFileDataAfterUploadingToS3 = async (file, {
|
|
1980
2008
|
toolSlug,
|
|
1981
2009
|
toolkitSlug,
|
|
1982
2010
|
client
|
|
1983
2011
|
}) => {
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2012
|
+
if (!file) {
|
|
2013
|
+
throw new Error("Either path or blob must be provided");
|
|
2014
|
+
}
|
|
2015
|
+
const fileData = await readFile(file);
|
|
2016
|
+
logger_default.debug(`Uploading file to S3...`);
|
|
1987
2017
|
const s3key = await uploadFileToS3(
|
|
1988
|
-
pathModule.basename(
|
|
2018
|
+
pathModule.basename(fileData.fileName),
|
|
1989
2019
|
fileData.content,
|
|
1990
2020
|
toolSlug,
|
|
1991
2021
|
toolkitSlug,
|
|
@@ -1994,7 +2024,7 @@ var getFileDataAfterUploadingToS3 = async ({
|
|
|
1994
2024
|
);
|
|
1995
2025
|
logger_default.debug(`Done! File uploaded to S3: ${s3key}`, JSON.stringify(fileData, null, 2));
|
|
1996
2026
|
return {
|
|
1997
|
-
name:
|
|
2027
|
+
name: fileData.fileName,
|
|
1998
2028
|
mimetype: fileData.mimeType,
|
|
1999
2029
|
s3key
|
|
2000
2030
|
};
|
|
@@ -2061,6 +2091,7 @@ var saveFile = (file, content, isTempFile = false) => {
|
|
|
2061
2091
|
}
|
|
2062
2092
|
return filePath;
|
|
2063
2093
|
} catch (_error) {
|
|
2094
|
+
logger_default.debug(`Error saving file: ${_error}`);
|
|
2064
2095
|
return null;
|
|
2065
2096
|
}
|
|
2066
2097
|
};
|
|
@@ -2090,10 +2121,9 @@ var transformProperties = (properties) => {
|
|
|
2090
2121
|
};
|
|
2091
2122
|
var hydrateFiles = async (value, schema, ctx) => {
|
|
2092
2123
|
if (schema?.file_uploadable) {
|
|
2093
|
-
if (typeof value !== "string") return value;
|
|
2124
|
+
if (typeof value !== "string" && !(value instanceof File)) return value;
|
|
2094
2125
|
logger_default.debug(`Uploading file "${value}"`);
|
|
2095
|
-
return getFileDataAfterUploadingToS3({
|
|
2096
|
-
path: value,
|
|
2126
|
+
return getFileDataAfterUploadingToS3(value, {
|
|
2097
2127
|
toolSlug: ctx.toolSlug,
|
|
2098
2128
|
toolkitSlug: ctx.toolkitSlug,
|
|
2099
2129
|
client: ctx.client
|
|
@@ -2127,7 +2157,7 @@ var hydrateDownloads = async (value, ctx) => {
|
|
|
2127
2157
|
logger_default.debug(`Downloaded \u2192 ${dl.filePath}`);
|
|
2128
2158
|
return {
|
|
2129
2159
|
uri: dl.filePath,
|
|
2130
|
-
file_downloaded: true,
|
|
2160
|
+
file_downloaded: dl.filePath ? true : false,
|
|
2131
2161
|
s3url,
|
|
2132
2162
|
mimeType: dl.mimeType
|
|
2133
2163
|
};
|
|
@@ -3299,58 +3329,27 @@ var AuthConfigs = class {
|
|
|
3299
3329
|
|
|
3300
3330
|
// src/models/ConnectionRequest.ts
|
|
3301
3331
|
import ComposioClient from "@composio/client";
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
this.status = status || ConnectedAccountStatuses.INITIATED;
|
|
3311
|
-
this.redirectUrl = redirectUrl;
|
|
3312
|
-
telemetry.instrument(this);
|
|
3313
|
-
}
|
|
3314
|
-
/**
|
|
3315
|
-
* Waits for the connection request to complete and become active.
|
|
3316
|
-
*
|
|
3317
|
-
* This method continuously polls the Composio API to check the status of the connection request
|
|
3318
|
-
* until it either becomes active, enters a terminal error state, or times out.
|
|
3319
|
-
*
|
|
3320
|
-
* @param {number} [timeout=60000] - Maximum time to wait in milliseconds before timing out (default: 60 seconds)
|
|
3321
|
-
* @returns {Promise<ConnectedAccountRetrieveResponse>} The final connected account response when successful
|
|
3322
|
-
* @throws {ComposioConnectedAccountNotFoundError} If the connected account cannot be found
|
|
3323
|
-
* @throws {ConnectionRequestFailedError} If the connection enters a failed, expired, or deleted state
|
|
3324
|
-
* @throws {ConnectionRequestTimeoutError} If the connection request does not complete within the timeout period
|
|
3325
|
-
*
|
|
3326
|
-
* @example
|
|
3327
|
-
* ```typescript
|
|
3328
|
-
* // Wait for connection with default timeout (60 seconds)
|
|
3329
|
-
* try {
|
|
3330
|
-
* const connection = await connectionRequest.waitForConnection();
|
|
3331
|
-
* console.log('Connection established:', connection.id);
|
|
3332
|
-
* } catch (error) {
|
|
3333
|
-
* console.error('Connection failed:', error.message);
|
|
3334
|
-
* }
|
|
3335
|
-
*
|
|
3336
|
-
* // Wait for connection with custom timeout (2 minutes)
|
|
3337
|
-
* const connection = await connectionRequest.waitForConnection(120000);
|
|
3338
|
-
* ```
|
|
3339
|
-
*/
|
|
3340
|
-
async waitForConnection(timeout = 6e4) {
|
|
3332
|
+
function createConnectionRequest(client, connectedAccountId, status, redirectUrl) {
|
|
3333
|
+
const state = {
|
|
3334
|
+
id: connectedAccountId,
|
|
3335
|
+
status: status || ConnectedAccountStatuses.INITIATED,
|
|
3336
|
+
redirectUrl
|
|
3337
|
+
};
|
|
3338
|
+
telemetry.instrument(state);
|
|
3339
|
+
async function waitForConnection(timeout = 6e4) {
|
|
3341
3340
|
try {
|
|
3342
|
-
const response = await
|
|
3341
|
+
const response = await client.connectedAccounts.retrieve(state.id);
|
|
3343
3342
|
if (response.status === ConnectedAccountStatuses.ACTIVE) {
|
|
3344
|
-
|
|
3343
|
+
state.status = ConnectedAccountStatuses.ACTIVE;
|
|
3345
3344
|
return transformConnectedAccountResponse(response);
|
|
3346
3345
|
}
|
|
3347
3346
|
} catch (error) {
|
|
3348
3347
|
if (error instanceof ComposioClient.NotFoundError) {
|
|
3349
3348
|
throw new ComposioConnectedAccountNotFoundError(
|
|
3350
|
-
`Connected account with id ${
|
|
3349
|
+
`Connected account with id ${state.id} not found`,
|
|
3351
3350
|
{
|
|
3352
3351
|
meta: {
|
|
3353
|
-
connectedAccountId:
|
|
3352
|
+
connectedAccountId: state.id
|
|
3354
3353
|
}
|
|
3355
3354
|
}
|
|
3356
3355
|
);
|
|
@@ -3366,8 +3365,8 @@ var ConnectionRequest = class {
|
|
|
3366
3365
|
const pollInterval = 1e3;
|
|
3367
3366
|
while (Date.now() - start < timeout) {
|
|
3368
3367
|
try {
|
|
3369
|
-
const response = await
|
|
3370
|
-
|
|
3368
|
+
const response = await client.connectedAccounts.retrieve(state.id);
|
|
3369
|
+
state.status = response.status;
|
|
3371
3370
|
if (response.status === ConnectedAccountStatuses.ACTIVE) {
|
|
3372
3371
|
return transformConnectedAccountResponse(response);
|
|
3373
3372
|
}
|
|
@@ -3376,7 +3375,7 @@ var ConnectionRequest = class {
|
|
|
3376
3375
|
`Connection request failed with status: ${response.status}${response.status_reason ? `, reason: ${response.status_reason}` : ""}`,
|
|
3377
3376
|
{
|
|
3378
3377
|
meta: {
|
|
3379
|
-
connectedAccountId:
|
|
3378
|
+
connectedAccountId: state.id,
|
|
3380
3379
|
status: response.status,
|
|
3381
3380
|
statusReason: response.status_reason
|
|
3382
3381
|
}
|
|
@@ -3388,26 +3387,15 @@ var ConnectionRequest = class {
|
|
|
3388
3387
|
throw error;
|
|
3389
3388
|
}
|
|
3390
3389
|
}
|
|
3391
|
-
throw new ConnectionRequestTimeoutError(`Connection request timed out for ${
|
|
3392
|
-
}
|
|
3393
|
-
/**
|
|
3394
|
-
* Returns a JSON-serializable representation of the connection request
|
|
3395
|
-
* Excludes the private client property to avoid cyclic reference issues
|
|
3396
|
-
*/
|
|
3397
|
-
toJSON() {
|
|
3398
|
-
return {
|
|
3399
|
-
id: this.id,
|
|
3400
|
-
status: this.status,
|
|
3401
|
-
redirectUrl: this.redirectUrl
|
|
3402
|
-
};
|
|
3390
|
+
throw new ConnectionRequestTimeoutError(`Connection request timed out for ${state.id}`);
|
|
3403
3391
|
}
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
}
|
|
3410
|
-
}
|
|
3392
|
+
return {
|
|
3393
|
+
...state,
|
|
3394
|
+
waitForConnection,
|
|
3395
|
+
toJSON: () => ({ ...state }),
|
|
3396
|
+
toString: () => JSON.stringify(state, null, 2)
|
|
3397
|
+
};
|
|
3398
|
+
}
|
|
3411
3399
|
|
|
3412
3400
|
// src/models/ConnectedAccounts.ts
|
|
3413
3401
|
var ConnectedAccounts = class {
|
|
@@ -3548,7 +3536,7 @@ var ConnectedAccounts = class {
|
|
|
3548
3536
|
}
|
|
3549
3537
|
});
|
|
3550
3538
|
const redirectUrl = typeof response.connectionData?.val?.redirectUrl === "string" ? response.connectionData.val.redirectUrl : null;
|
|
3551
|
-
return
|
|
3539
|
+
return createConnectionRequest(
|
|
3552
3540
|
this.client,
|
|
3553
3541
|
response.id,
|
|
3554
3542
|
response.connectionData.val.status,
|
|
@@ -3578,7 +3566,7 @@ var ConnectedAccounts = class {
|
|
|
3578
3566
|
* ```
|
|
3579
3567
|
*/
|
|
3580
3568
|
async waitForConnection(connectedAccountId, timeout = 6e4) {
|
|
3581
|
-
const connectionRequest =
|
|
3569
|
+
const connectionRequest = createConnectionRequest(this.client, connectedAccountId);
|
|
3582
3570
|
return connectionRequest.waitForConnection(timeout);
|
|
3583
3571
|
}
|
|
3584
3572
|
/**
|
|
@@ -3703,6 +3691,7 @@ var ConnectedAccounts = class {
|
|
|
3703
3691
|
};
|
|
3704
3692
|
|
|
3705
3693
|
// src/models/Toolkits.ts
|
|
3694
|
+
import { APIError } from "openai";
|
|
3706
3695
|
var Toolkits = class {
|
|
3707
3696
|
client;
|
|
3708
3697
|
constructor(client) {
|
|
@@ -3823,7 +3812,7 @@ var Toolkits = class {
|
|
|
3823
3812
|
}
|
|
3824
3813
|
return parsedResult.data;
|
|
3825
3814
|
} catch (error) {
|
|
3826
|
-
if (error instanceof
|
|
3815
|
+
if (error instanceof APIError && (error.status === 404 || error.status === 400)) {
|
|
3827
3816
|
throw new ComposioToolkitNotFoundError(`Toolkit with slug ${slug} not found`, {
|
|
3828
3817
|
meta: {
|
|
3829
3818
|
slug
|
|
@@ -4025,7 +4014,7 @@ var Toolkits = class {
|
|
|
4025
4014
|
};
|
|
4026
4015
|
|
|
4027
4016
|
// src/models/Triggers.ts
|
|
4028
|
-
import { APIError } from "@composio/client";
|
|
4017
|
+
import { APIError as APIError2 } from "@composio/client";
|
|
4029
4018
|
|
|
4030
4019
|
// src/types/triggers.types.ts
|
|
4031
4020
|
import { z as z6 } from "zod";
|
|
@@ -4482,7 +4471,7 @@ var Triggers = class {
|
|
|
4482
4471
|
triggerType = await this.getType(slug);
|
|
4483
4472
|
toolkitSlug = triggerType.toolkit.slug;
|
|
4484
4473
|
} catch (error) {
|
|
4485
|
-
if (error instanceof
|
|
4474
|
+
if (error instanceof APIError2 && (error.status === 400 || error.status === 404)) {
|
|
4486
4475
|
throw new ComposioTriggerTypeNotFoundError(`Trigger type ${slug} not found`, {
|
|
4487
4476
|
cause: error,
|
|
4488
4477
|
possibleFixes: [
|
|
@@ -4531,7 +4520,7 @@ var Triggers = class {
|
|
|
4531
4520
|
);
|
|
4532
4521
|
}
|
|
4533
4522
|
} catch (error) {
|
|
4534
|
-
if (error instanceof
|
|
4523
|
+
if (error instanceof APIError2 && [400, 404].includes(error.status)) {
|
|
4535
4524
|
throw new ComposioConnectedAccountNotFoundError(
|
|
4536
4525
|
`No connected account found for user ${userId} for toolkit ${toolkitSlug}`,
|
|
4537
4526
|
{
|
|
@@ -4807,7 +4796,7 @@ var MCPGenerateURLParamsSchema = z8.object({
|
|
|
4807
4796
|
connectedAccountIds: z8.array(z8.string()).optional(),
|
|
4808
4797
|
useComposioManagedAuth: z8.boolean().optional()
|
|
4809
4798
|
});
|
|
4810
|
-
var
|
|
4799
|
+
var ComposioGenerateURLParamsSchema = z8.object({
|
|
4811
4800
|
user_ids: z8.array(z8.string()).optional(),
|
|
4812
4801
|
connected_account_ids: z8.array(z8.string()).optional(),
|
|
4813
4802
|
mcp_server_id: z8.string(),
|
|
@@ -4817,14 +4806,14 @@ var GenerateURLParamsSchema = z8.object({
|
|
|
4817
4806
|
userIds: z8.array(z8.string()).optional(),
|
|
4818
4807
|
connectedAccountIds: z8.array(z8.string()).optional(),
|
|
4819
4808
|
mcpServerId: z8.string(),
|
|
4820
|
-
|
|
4809
|
+
composioManagedAuth: z8.boolean().optional()
|
|
4821
4810
|
});
|
|
4822
|
-
var
|
|
4811
|
+
var GenerateURLResponseSchema = z8.object({
|
|
4823
4812
|
connectedAccountUrls: z8.array(z8.string()).optional(),
|
|
4824
4813
|
userIdsUrl: z8.array(z8.string()).optional(),
|
|
4825
4814
|
mcpUrl: z8.string().min(1, "MCP URL cannot be empty")
|
|
4826
4815
|
});
|
|
4827
|
-
var
|
|
4816
|
+
var ComposioGenerateURLResponseSchema = z8.object({
|
|
4828
4817
|
connected_account_urls: z8.array(z8.string()).optional(),
|
|
4829
4818
|
user_ids_url: z8.array(z8.string()).optional(),
|
|
4830
4819
|
mcp_url: z8.string().min(1, "MCP URL cannot be empty")
|
|
@@ -4859,21 +4848,21 @@ var MCPServerUpdateParamsSchema = z8.object({
|
|
|
4859
4848
|
allowedTools: z8.array(z8.string()).optional().describe("Updated list of allowed tools")
|
|
4860
4849
|
});
|
|
4861
4850
|
var MCPServerCreateResponseSchema = MCPServerSchema;
|
|
4862
|
-
var
|
|
4851
|
+
var CustomCreateResponseSchema = z8.object({
|
|
4863
4852
|
id: z8.string().min(1, "Server ID cannot be empty"),
|
|
4864
4853
|
name: z8.string().min(1, "Server name cannot be empty"),
|
|
4865
4854
|
createdAt: z8.string().nullish(),
|
|
4866
4855
|
updatedAt: z8.string().nullish(),
|
|
4867
4856
|
status: z8.string().nullish()
|
|
4868
4857
|
});
|
|
4869
|
-
var
|
|
4858
|
+
var ComposioCustomCreateResponseSchema = z8.object({
|
|
4870
4859
|
id: z8.string().min(1, "Server ID cannot be empty"),
|
|
4871
4860
|
name: z8.string().min(1, "Server name cannot be empty"),
|
|
4872
4861
|
created_at: z8.string().nullish(),
|
|
4873
4862
|
updated_at: z8.string().nullish(),
|
|
4874
4863
|
status: z8.string().nullish()
|
|
4875
4864
|
});
|
|
4876
|
-
var
|
|
4865
|
+
var McpListResponseSchema = z8.object({
|
|
4877
4866
|
items: z8.array(
|
|
4878
4867
|
z8.object({
|
|
4879
4868
|
id: z8.string().min(1, "Server ID cannot be empty"),
|
|
@@ -4884,7 +4873,7 @@ var McpListResponseCamelCaseSchema = z8.object({
|
|
|
4884
4873
|
})
|
|
4885
4874
|
).optional()
|
|
4886
4875
|
});
|
|
4887
|
-
var
|
|
4876
|
+
var ComposioMcpListResponseSchema = z8.object({
|
|
4888
4877
|
items: z8.array(
|
|
4889
4878
|
z8.object({
|
|
4890
4879
|
id: z8.string().min(1, "Server ID cannot be empty"),
|
|
@@ -4895,7 +4884,7 @@ var McpListResponseSchema = z8.object({
|
|
|
4895
4884
|
})
|
|
4896
4885
|
).optional()
|
|
4897
4886
|
});
|
|
4898
|
-
var
|
|
4887
|
+
var McpRetrieveResponseSchema = z8.object({
|
|
4899
4888
|
id: z8.string().min(1, "Server ID cannot be empty"),
|
|
4900
4889
|
name: z8.string().min(1, "Server name cannot be empty"),
|
|
4901
4890
|
createdAt: z8.string().optional(),
|
|
@@ -4905,7 +4894,7 @@ var McpRetrieveResponseCamelCaseSchema = z8.object({
|
|
|
4905
4894
|
tools: z8.array(z8.string()).optional(),
|
|
4906
4895
|
managedAuthViaComposio: z8.boolean().optional()
|
|
4907
4896
|
});
|
|
4908
|
-
var
|
|
4897
|
+
var ComposioMcpRetrieveResponseSchema = z8.object({
|
|
4909
4898
|
id: z8.string().min(1, "Server ID cannot be empty"),
|
|
4910
4899
|
name: z8.string().min(1, "Server name cannot be empty"),
|
|
4911
4900
|
created_at: z8.string().optional(),
|
|
@@ -4915,17 +4904,17 @@ var McpRetrieveResponseSchema = z8.object({
|
|
|
4915
4904
|
tools: z8.array(z8.string()).optional(),
|
|
4916
4905
|
managed_auth_via_composio: z8.boolean().optional()
|
|
4917
4906
|
});
|
|
4918
|
-
var
|
|
4907
|
+
var McpDeleteResponseSchema = z8.object({
|
|
4919
4908
|
id: z8.string().min(1, "Server ID cannot be empty"),
|
|
4920
4909
|
deleted: z8.boolean().optional(),
|
|
4921
4910
|
message: z8.string().optional()
|
|
4922
4911
|
});
|
|
4923
|
-
var
|
|
4912
|
+
var ComposioMcpDeleteResponseSchema = z8.object({
|
|
4924
4913
|
id: z8.string().min(1, "Server ID cannot be empty"),
|
|
4925
4914
|
deleted: z8.boolean().optional(),
|
|
4926
4915
|
message: z8.string().optional()
|
|
4927
4916
|
});
|
|
4928
|
-
var
|
|
4917
|
+
var McpUpdateResponseSchema = z8.object({
|
|
4929
4918
|
id: z8.string().min(1, "Server ID cannot be empty"),
|
|
4930
4919
|
name: z8.string().min(1, "Server name cannot be empty"),
|
|
4931
4920
|
createdAt: z8.string().optional(),
|
|
@@ -4934,7 +4923,7 @@ var McpUpdateResponseCamelCaseSchema = z8.object({
|
|
|
4934
4923
|
toolkits: z8.array(z8.string()).optional(),
|
|
4935
4924
|
tools: z8.array(z8.string()).optional()
|
|
4936
4925
|
});
|
|
4937
|
-
var
|
|
4926
|
+
var ComposioMcpUpdateResponseSchema = z8.object({
|
|
4938
4927
|
id: z8.string().min(1, "Server ID cannot be empty"),
|
|
4939
4928
|
name: z8.string().min(1, "Server name cannot be empty"),
|
|
4940
4929
|
created_at: z8.string().optional(),
|
|
@@ -4946,7 +4935,7 @@ var McpUpdateResponseSchema = z8.object({
|
|
|
4946
4935
|
|
|
4947
4936
|
// src/utils/transformers/mcp.ts
|
|
4948
4937
|
function transformMcpCreateResponse(response) {
|
|
4949
|
-
const result =
|
|
4938
|
+
const result = CustomCreateResponseSchema.safeParse({
|
|
4950
4939
|
id: response.id,
|
|
4951
4940
|
name: response.name,
|
|
4952
4941
|
createdAt: response.created_at,
|
|
@@ -4968,7 +4957,7 @@ function transformMcpListResponse(response) {
|
|
|
4968
4957
|
updatedAt: item.updated_at,
|
|
4969
4958
|
status: item.status
|
|
4970
4959
|
}));
|
|
4971
|
-
const result =
|
|
4960
|
+
const result = McpListResponseSchema.safeParse({
|
|
4972
4961
|
items: transformedItems
|
|
4973
4962
|
});
|
|
4974
4963
|
if (!result.success) {
|
|
@@ -4979,7 +4968,7 @@ function transformMcpListResponse(response) {
|
|
|
4979
4968
|
return result.data;
|
|
4980
4969
|
}
|
|
4981
4970
|
function transformMcpRetrieveResponse(response) {
|
|
4982
|
-
const result =
|
|
4971
|
+
const result = McpRetrieveResponseSchema.safeParse({
|
|
4983
4972
|
id: response.id,
|
|
4984
4973
|
name: response.name,
|
|
4985
4974
|
createdAt: response.created_at,
|
|
@@ -4997,7 +4986,7 @@ function transformMcpRetrieveResponse(response) {
|
|
|
4997
4986
|
return result.data;
|
|
4998
4987
|
}
|
|
4999
4988
|
function transformMcpDeleteResponse(response) {
|
|
5000
|
-
const result =
|
|
4989
|
+
const result = McpDeleteResponseSchema.safeParse({
|
|
5001
4990
|
id: response.id,
|
|
5002
4991
|
deleted: response.deleted,
|
|
5003
4992
|
message: response.message
|
|
@@ -5010,7 +4999,7 @@ function transformMcpDeleteResponse(response) {
|
|
|
5010
4999
|
return result.data;
|
|
5011
5000
|
}
|
|
5012
5001
|
function transformMcpUpdateResponse(response) {
|
|
5013
|
-
const result =
|
|
5002
|
+
const result = McpUpdateResponseSchema.safeParse({
|
|
5014
5003
|
id: response.id,
|
|
5015
5004
|
name: response.name,
|
|
5016
5005
|
createdAt: response.created_at,
|
|
@@ -5027,7 +5016,7 @@ function transformMcpUpdateResponse(response) {
|
|
|
5027
5016
|
return result.data;
|
|
5028
5017
|
}
|
|
5029
5018
|
function transformMcpGenerateUrlResponse(response) {
|
|
5030
|
-
const result =
|
|
5019
|
+
const result = GenerateURLResponseSchema.safeParse({
|
|
5031
5020
|
connectedAccountUrls: response.connected_account_urls,
|
|
5032
5021
|
userIdsUrl: response.user_ids_url,
|
|
5033
5022
|
mcpUrl: response.mcp_url
|
|
@@ -5121,7 +5110,7 @@ var MCP = class {
|
|
|
5121
5110
|
cause: error
|
|
5122
5111
|
});
|
|
5123
5112
|
}
|
|
5124
|
-
const serverResponseResult =
|
|
5113
|
+
const serverResponseResult = ComposioCustomCreateResponseSchema.safeParse(mcpServerCreatedResponse);
|
|
5125
5114
|
if (serverResponseResult.error) {
|
|
5126
5115
|
throw new ValidationError("Failed to parse MCP server creation response", {
|
|
5127
5116
|
cause: serverResponseResult.error
|
|
@@ -5185,7 +5174,7 @@ var MCP = class {
|
|
|
5185
5174
|
cause: error
|
|
5186
5175
|
});
|
|
5187
5176
|
}
|
|
5188
|
-
const urlResponseResult =
|
|
5177
|
+
const urlResponseResult = ComposioGenerateURLResponseSchema.safeParse(data);
|
|
5189
5178
|
if (urlResponseResult.error) {
|
|
5190
5179
|
throw new ValidationError("Failed to parse MCP URL generation response", {
|
|
5191
5180
|
cause: urlResponseResult.error
|
|
@@ -5241,7 +5230,7 @@ var MCP = class {
|
|
|
5241
5230
|
cause: error
|
|
5242
5231
|
});
|
|
5243
5232
|
}
|
|
5244
|
-
const listResponseResult =
|
|
5233
|
+
const listResponseResult = ComposioMcpListResponseSchema.safeParse(listResponse);
|
|
5245
5234
|
if (listResponseResult.error) {
|
|
5246
5235
|
throw new ValidationError("Failed to parse MCP server list response", {
|
|
5247
5236
|
cause: listResponseResult.error
|
|
@@ -5252,7 +5241,7 @@ var MCP = class {
|
|
|
5252
5241
|
/**
|
|
5253
5242
|
* Get details of a specific MCP server
|
|
5254
5243
|
* @param {string} id - Server UUID
|
|
5255
|
-
* @returns {Promise<
|
|
5244
|
+
* @returns {Promise<McpRetrieveResponse>} Server details
|
|
5256
5245
|
*
|
|
5257
5246
|
* @example
|
|
5258
5247
|
* ```typescript
|
|
@@ -5279,7 +5268,7 @@ var MCP = class {
|
|
|
5279
5268
|
/**
|
|
5280
5269
|
* Delete an MCP server
|
|
5281
5270
|
* @param {string} id - Server UUID
|
|
5282
|
-
* @returns {Promise<
|
|
5271
|
+
* @returns {Promise<McpDeleteResponse>} Deletion response
|
|
5283
5272
|
*
|
|
5284
5273
|
* @example
|
|
5285
5274
|
* ```typescript
|
|
@@ -5295,7 +5284,7 @@ var MCP = class {
|
|
|
5295
5284
|
cause: error
|
|
5296
5285
|
});
|
|
5297
5286
|
}
|
|
5298
|
-
const deleteResponseResult =
|
|
5287
|
+
const deleteResponseResult = ComposioMcpDeleteResponseSchema.safeParse(deleteResponse);
|
|
5299
5288
|
if (deleteResponseResult.error) {
|
|
5300
5289
|
throw new ValidationError("Failed to parse MCP server delete response", {
|
|
5301
5290
|
cause: deleteResponseResult.error
|
|
@@ -5309,7 +5298,7 @@ var MCP = class {
|
|
|
5309
5298
|
* @param {string} name - New unique name for the server
|
|
5310
5299
|
* @param {MCPToolkitConfig[]} toolkitConfigs - Array of toolkit configurations
|
|
5311
5300
|
* @param {MCPAuthOptions} [authOptions] - Updated authentication options
|
|
5312
|
-
* @returns {Promise<
|
|
5301
|
+
* @returns {Promise<McpUpdateResponse>} Updated server details
|
|
5313
5302
|
*
|
|
5314
5303
|
* @example
|
|
5315
5304
|
* ```typescript
|
|
@@ -5345,7 +5334,7 @@ var MCP = class {
|
|
|
5345
5334
|
cause: error
|
|
5346
5335
|
});
|
|
5347
5336
|
}
|
|
5348
|
-
const updateResponseResult =
|
|
5337
|
+
const updateResponseResult = ComposioMcpUpdateResponseSchema.safeParse(updateResponse);
|
|
5349
5338
|
if (updateResponseResult.error) {
|
|
5350
5339
|
throw new ValidationError("Failed to parse MCP server update response", {
|
|
5351
5340
|
cause: updateResponseResult.error
|
|
@@ -5356,20 +5345,20 @@ var MCP = class {
|
|
|
5356
5345
|
/**
|
|
5357
5346
|
* Generate URL for an MCP server
|
|
5358
5347
|
* @param {GenerateURLParams} params - Parameters for URL generation
|
|
5359
|
-
* @returns {Promise<
|
|
5348
|
+
* @returns {Promise<GenerateURLResponse>} Generated URL response
|
|
5360
5349
|
*
|
|
5361
5350
|
* @example
|
|
5362
5351
|
* ```typescript
|
|
5363
5352
|
* const urlResponse = await composio.mcp.generateUrl({
|
|
5364
|
-
*
|
|
5365
|
-
*
|
|
5366
|
-
*
|
|
5367
|
-
*
|
|
5353
|
+
* userIds: ['user123'],
|
|
5354
|
+
* connectedAccountIds: ['account456'],
|
|
5355
|
+
* mcpServerId: 'server-uuid',
|
|
5356
|
+
* composioManagedAuth: true
|
|
5368
5357
|
* });
|
|
5369
5358
|
* ```
|
|
5370
5359
|
*/
|
|
5371
5360
|
async generateUrl(params) {
|
|
5372
|
-
const paramsResult =
|
|
5361
|
+
const paramsResult = GenerateURLParamsSchema.safeParse(params);
|
|
5373
5362
|
if (paramsResult.error) {
|
|
5374
5363
|
throw new ValidationError("Failed to parse generateUrl parameters", {
|
|
5375
5364
|
cause: paramsResult.error
|
|
@@ -5377,13 +5366,18 @@ var MCP = class {
|
|
|
5377
5366
|
}
|
|
5378
5367
|
let urlResponse;
|
|
5379
5368
|
try {
|
|
5380
|
-
urlResponse = await this.client.mcp.generate.url(
|
|
5369
|
+
urlResponse = await this.client.mcp.generate.url({
|
|
5370
|
+
mcp_server_id: params.mcpServerId,
|
|
5371
|
+
user_ids: params.userIds,
|
|
5372
|
+
connected_account_ids: params.connectedAccountIds,
|
|
5373
|
+
managed_auth_by_composio: params.composioManagedAuth
|
|
5374
|
+
});
|
|
5381
5375
|
} catch (error) {
|
|
5382
5376
|
throw new ValidationError("Failed to generate MCP URL", {
|
|
5383
5377
|
cause: error
|
|
5384
5378
|
});
|
|
5385
5379
|
}
|
|
5386
|
-
const responseResult =
|
|
5380
|
+
const responseResult = ComposioGenerateURLResponseSchema.safeParse(urlResponse);
|
|
5387
5381
|
if (responseResult.error) {
|
|
5388
5382
|
throw new ValidationError("Failed to parse MCP URL generation response", {
|
|
5389
5383
|
cause: responseResult.error
|
|
@@ -5752,9 +5746,17 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5752
5746
|
const outputs = [];
|
|
5753
5747
|
for (const message of chatCompletion.choices) {
|
|
5754
5748
|
if (message.message.tool_calls) {
|
|
5755
|
-
|
|
5756
|
-
|
|
5749
|
+
const toolResult = await this.executeToolCall(
|
|
5750
|
+
userId,
|
|
5751
|
+
message.message.tool_calls[0],
|
|
5752
|
+
options,
|
|
5753
|
+
modifiers
|
|
5757
5754
|
);
|
|
5755
|
+
outputs.push({
|
|
5756
|
+
role: "tool",
|
|
5757
|
+
tool_call_id: message.message.tool_calls[0].id,
|
|
5758
|
+
content: toolResult
|
|
5759
|
+
});
|
|
5758
5760
|
}
|
|
5759
5761
|
}
|
|
5760
5762
|
return outputs;
|
|
@@ -5974,7 +5976,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5974
5976
|
};
|
|
5975
5977
|
|
|
5976
5978
|
// package.json
|
|
5977
|
-
var version = "0.1.
|
|
5979
|
+
var version = "0.1.33";
|
|
5978
5980
|
|
|
5979
5981
|
// src/models/Files.ts
|
|
5980
5982
|
var Files = class {
|
|
@@ -5990,12 +5992,11 @@ var Files = class {
|
|
|
5990
5992
|
* @returns The file data.
|
|
5991
5993
|
*/
|
|
5992
5994
|
async upload({
|
|
5993
|
-
|
|
5995
|
+
file,
|
|
5994
5996
|
toolSlug,
|
|
5995
5997
|
toolkitSlug
|
|
5996
5998
|
}) {
|
|
5997
|
-
const fileData = await getFileDataAfterUploadingToS3({
|
|
5998
|
-
path: filePath,
|
|
5999
|
+
const fileData = await getFileDataAfterUploadingToS3(file, {
|
|
5999
6000
|
toolSlug,
|
|
6000
6001
|
toolkitSlug,
|
|
6001
6002
|
client: this.client
|
|
@@ -6386,12 +6387,19 @@ export {
|
|
|
6386
6387
|
Composio,
|
|
6387
6388
|
ComposioAuthConfigNotFoundError,
|
|
6388
6389
|
ComposioConnectedAccountNotFoundError,
|
|
6390
|
+
ComposioCustomCreateResponseSchema,
|
|
6389
6391
|
ComposioCustomToolsNotInitializedError,
|
|
6390
6392
|
ComposioError,
|
|
6393
|
+
ComposioGenerateURLParamsSchema,
|
|
6394
|
+
ComposioGenerateURLResponseSchema,
|
|
6391
6395
|
ComposioGlobalExecuteToolFnNotSetError,
|
|
6392
6396
|
ComposioInvalidExecuteFunctionError,
|
|
6393
6397
|
ComposioInvalidModifierError,
|
|
6394
6398
|
ComposioLinkConnectionDataSchema,
|
|
6399
|
+
ComposioMcpDeleteResponseSchema,
|
|
6400
|
+
ComposioMcpListResponseSchema,
|
|
6401
|
+
ComposioMcpRetrieveResponseSchema,
|
|
6402
|
+
ComposioMcpUpdateResponseSchema,
|
|
6395
6403
|
ComposioMultipleConnectedAccountsError,
|
|
6396
6404
|
ComposioNoAPIKeyError,
|
|
6397
6405
|
ComposioProvider,
|
|
@@ -6400,7 +6408,13 @@ export {
|
|
|
6400
6408
|
ComposioToolNotFoundError,
|
|
6401
6409
|
ComposioToolkitFetchError,
|
|
6402
6410
|
ComposioToolkitNotFoundError,
|
|
6411
|
+
ConnectedAccountAuthConfigSchema,
|
|
6403
6412
|
ConnectedAccountErrorCodes,
|
|
6413
|
+
ConnectedAccountListParamsSchema,
|
|
6414
|
+
ConnectedAccountListResponseSchema,
|
|
6415
|
+
ConnectedAccountRetrieveResponseSchema,
|
|
6416
|
+
ConnectedAccountStatusSchema,
|
|
6417
|
+
ConnectedAccountStatuses,
|
|
6404
6418
|
ConnectionDataSchema,
|
|
6405
6419
|
ConnectionRequestErrorCodes,
|
|
6406
6420
|
ConnectionRequestFailedError,
|
|
@@ -6409,13 +6423,14 @@ export {
|
|
|
6409
6423
|
CreateAuthConfigParamsSchema,
|
|
6410
6424
|
CreateAuthConfigResponseSchema,
|
|
6411
6425
|
CreateComposioManagedAuthConfigParamsSchema,
|
|
6426
|
+
CreateConnectedAccountOptionsSchema,
|
|
6427
|
+
CreateConnectedAccountParamsSchema,
|
|
6428
|
+
CreateConnectedAccountResponseSchema,
|
|
6412
6429
|
CreateCustomAuthConfigParamsSchema,
|
|
6413
6430
|
CustomAuthParamsSchema,
|
|
6414
|
-
CustomCreateResponseCamelCaseSchema,
|
|
6415
6431
|
CustomCreateResponseSchema,
|
|
6432
|
+
DefaultCreateConnectedAccountParamsSchema,
|
|
6416
6433
|
GenerateURLParamsSchema,
|
|
6417
|
-
GenerateURLParamsSnakeCaseSchema,
|
|
6418
|
-
GenerateURLResponseCamelCaseSchema,
|
|
6419
6434
|
GenerateURLResponseSchema,
|
|
6420
6435
|
IncomingTriggerPayloadSchema,
|
|
6421
6436
|
JSONSchemaPropertySchema,
|
|
@@ -6432,13 +6447,9 @@ export {
|
|
|
6432
6447
|
MCPSingleAppServerSchema,
|
|
6433
6448
|
MCPToolkitConfigSchema,
|
|
6434
6449
|
MCPToolkitConfigsArraySchema,
|
|
6435
|
-
McpDeleteResponseCamelCaseSchema,
|
|
6436
6450
|
McpDeleteResponseSchema,
|
|
6437
|
-
McpListResponseCamelCaseSchema,
|
|
6438
6451
|
McpListResponseSchema,
|
|
6439
|
-
McpRetrieveResponseCamelCaseSchema,
|
|
6440
6452
|
McpRetrieveResponseSchema,
|
|
6441
|
-
McpUpdateResponseCamelCaseSchema,
|
|
6442
6453
|
McpUpdateResponseSchema,
|
|
6443
6454
|
Oauth1ActiveConnectionDataSchema,
|
|
6444
6455
|
Oauth1ConnectionDataSchema,
|
|
@@ -6490,6 +6501,7 @@ export {
|
|
|
6490
6501
|
ValidationError,
|
|
6491
6502
|
ValidationErrorCodes,
|
|
6492
6503
|
constants_exports as constants,
|
|
6504
|
+
createConnectionRequest,
|
|
6493
6505
|
jsonSchemaToZodSchema,
|
|
6494
6506
|
logger_default as logger,
|
|
6495
6507
|
removeNonRequiredProperties
|