@composio/core 0.1.51 → 0.1.52
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 +1 -0
- package/dist/index.cjs +199 -90
- package/dist/index.d.cts +142 -35
- package/dist/index.d.ts +142 -35
- package/dist/index.js +199 -90
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -678,10 +678,11 @@ var ToolSchema = z3.object({
|
|
|
678
678
|
description: z3.string().optional().describe("The description of the tool"),
|
|
679
679
|
inputParameters: ParametersSchema.optional().describe("The input parameters of the tool"),
|
|
680
680
|
outputParameters: ParametersSchema.optional().describe("The output parameters of the tool"),
|
|
681
|
-
tags: z3.
|
|
682
|
-
toolkit:
|
|
683
|
-
version: z3.
|
|
684
|
-
|
|
681
|
+
tags: z3.array(z3.string()).describe("The tags of the tool. eg: Important").default([]).optional(),
|
|
682
|
+
toolkit: ToolkitSchema.describe("The toolkit of the tool").optional(),
|
|
683
|
+
version: z3.string().describe('The version of the tool, e.g. "20250909_00"').optional(),
|
|
684
|
+
availableVersions: z3.array(z3.string()).describe("Available versions of the tool.").default([]).optional(),
|
|
685
|
+
scopes: z3.array(z3.string()).describe('The scopes of the tool. eg: ["task:add"]').optional()
|
|
685
686
|
});
|
|
686
687
|
var ToolListResponseSchema = z3.object({
|
|
687
688
|
items: z3.array(ToolSchema),
|
|
@@ -715,8 +716,8 @@ var ToolExecuteParamsSchema = z3.object({
|
|
|
715
716
|
customConnectionData: CustomConnectionDataSchema.optional(),
|
|
716
717
|
arguments: z3.record(z3.string(), z3.unknown()).optional(),
|
|
717
718
|
userId: z3.string().optional(),
|
|
718
|
-
//
|
|
719
|
-
version: z3.string().optional(),
|
|
719
|
+
// we have no auth apps which can be execute
|
|
720
|
+
version: z3.union([z3.literal("latest"), z3.string()]).optional(),
|
|
720
721
|
text: z3.string().optional()
|
|
721
722
|
});
|
|
722
723
|
var ToolExecuteResponseSchema = z3.object({
|
|
@@ -769,6 +770,19 @@ var getEnvVariable = (name, defaultValue = void 0) => {
|
|
|
769
770
|
return defaultValue;
|
|
770
771
|
}
|
|
771
772
|
};
|
|
773
|
+
var getEnvsWithPrefix = (prefix) => {
|
|
774
|
+
try {
|
|
775
|
+
if (process && process.env) {
|
|
776
|
+
return Object.fromEntries(
|
|
777
|
+
Object.entries(process.env).filter(([key]) => key.startsWith(prefix))
|
|
778
|
+
);
|
|
779
|
+
} else {
|
|
780
|
+
return {};
|
|
781
|
+
}
|
|
782
|
+
} catch (error) {
|
|
783
|
+
return {};
|
|
784
|
+
}
|
|
785
|
+
};
|
|
772
786
|
|
|
773
787
|
// src/utils/constants.ts
|
|
774
788
|
var COMPOSIO_DIR = ".composio";
|
|
@@ -2508,13 +2522,26 @@ var FileToolModifier = class {
|
|
|
2508
2522
|
}
|
|
2509
2523
|
};
|
|
2510
2524
|
|
|
2525
|
+
// src/utils/toolkitVersion.ts
|
|
2526
|
+
var getToolkitVersion = (toolkitSlug, toolkitVersions) => {
|
|
2527
|
+
if (typeof toolkitVersions === "string") {
|
|
2528
|
+
return toolkitVersions;
|
|
2529
|
+
}
|
|
2530
|
+
const hasToolkitVersion = toolkitVersions && Object.keys(toolkitVersions).length > 0;
|
|
2531
|
+
if (hasToolkitVersion) {
|
|
2532
|
+
return toolkitVersions[toolkitSlug] ?? "latest";
|
|
2533
|
+
}
|
|
2534
|
+
return "latest";
|
|
2535
|
+
};
|
|
2536
|
+
|
|
2511
2537
|
// src/models/Tools.ts
|
|
2512
2538
|
var Tools = class {
|
|
2513
2539
|
client;
|
|
2514
2540
|
customTools;
|
|
2515
2541
|
provider;
|
|
2516
2542
|
autoUploadDownloadFiles;
|
|
2517
|
-
|
|
2543
|
+
toolkitVersions;
|
|
2544
|
+
constructor(client, provider, config) {
|
|
2518
2545
|
if (!client) {
|
|
2519
2546
|
throw new Error("ComposioClient is required");
|
|
2520
2547
|
}
|
|
@@ -2524,7 +2551,8 @@ var Tools = class {
|
|
|
2524
2551
|
this.client = client;
|
|
2525
2552
|
this.customTools = new CustomTools(client);
|
|
2526
2553
|
this.provider = provider;
|
|
2527
|
-
this.autoUploadDownloadFiles =
|
|
2554
|
+
this.autoUploadDownloadFiles = config?.autoUploadDownloadFiles ?? true;
|
|
2555
|
+
this.toolkitVersions = config?.toolkitVersions ?? "latest";
|
|
2528
2556
|
this.execute = this.execute.bind(this);
|
|
2529
2557
|
this.provider._setExecuteToolFn(this.execute);
|
|
2530
2558
|
this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
|
|
@@ -2546,7 +2574,8 @@ var Tools = class {
|
|
|
2546
2574
|
return ToolSchema.parse({
|
|
2547
2575
|
...tool,
|
|
2548
2576
|
inputParameters: tool.input_parameters,
|
|
2549
|
-
outputParameters: tool.output_parameters
|
|
2577
|
+
outputParameters: tool.output_parameters,
|
|
2578
|
+
availableVersions: tool.available_versions
|
|
2550
2579
|
});
|
|
2551
2580
|
}
|
|
2552
2581
|
/**
|
|
@@ -2569,46 +2598,6 @@ var Tools = class {
|
|
|
2569
2598
|
sessionInfo: response.session_info
|
|
2570
2599
|
});
|
|
2571
2600
|
}
|
|
2572
|
-
/**
|
|
2573
|
-
* Check if the connected account exists for the given tools.
|
|
2574
|
-
* @param {string} userId - The user id.
|
|
2575
|
-
* @param {ToolList} tools - The tools to check.
|
|
2576
|
-
* @returns {Promise<boolean>} True if the connected account exists for the given tools, false otherwise.
|
|
2577
|
-
*/
|
|
2578
|
-
async checkIfConnectedAccountExistsForTools(userIds, tools) {
|
|
2579
|
-
if (!tools.length) {
|
|
2580
|
-
return true;
|
|
2581
|
-
}
|
|
2582
|
-
const connectedAccounts = await this.client.connectedAccounts.list({
|
|
2583
|
-
user_ids: userIds
|
|
2584
|
-
});
|
|
2585
|
-
if (connectedAccounts.items.length === 0) {
|
|
2586
|
-
return false;
|
|
2587
|
-
}
|
|
2588
|
-
const connectedToolkitSlugs = connectedAccounts.items.reduce(
|
|
2589
|
-
(acc, account) => {
|
|
2590
|
-
if (account.toolkit.slug) {
|
|
2591
|
-
acc[account.toolkit.slug] = true;
|
|
2592
|
-
}
|
|
2593
|
-
return acc;
|
|
2594
|
-
},
|
|
2595
|
-
{}
|
|
2596
|
-
);
|
|
2597
|
-
const toolSlugs = tools.reduce(
|
|
2598
|
-
(acc, tool) => {
|
|
2599
|
-
acc[tool.slug] = true;
|
|
2600
|
-
return acc;
|
|
2601
|
-
},
|
|
2602
|
-
{}
|
|
2603
|
-
);
|
|
2604
|
-
for (const tool of Object.keys(toolSlugs)) {
|
|
2605
|
-
if (!connectedToolkitSlugs[tool]) {
|
|
2606
|
-
logger_default.warn(`Tool ${tool} requires a connected account but no connected account was found`);
|
|
2607
|
-
return false;
|
|
2608
|
-
}
|
|
2609
|
-
}
|
|
2610
|
-
return true;
|
|
2611
|
-
}
|
|
2612
2601
|
/**
|
|
2613
2602
|
* Get the connected account id for a given tool
|
|
2614
2603
|
* @param {string} userId - The user id
|
|
@@ -2734,32 +2723,59 @@ var Tools = class {
|
|
|
2734
2723
|
*
|
|
2735
2724
|
* This method fetches tools from the Composio API in raw format and combines them with
|
|
2736
2725
|
* any registered custom tools. The response can be filtered and modified as needed.
|
|
2726
|
+
* It provides access to the underlying tool data without provider-specific wrapping.
|
|
2737
2727
|
*
|
|
2738
|
-
* @param {ToolListParams}
|
|
2739
|
-
* @param {
|
|
2728
|
+
* @param {ToolListParams} query - Query parameters to filter the tools (required)
|
|
2729
|
+
* @param {GetRawComposioToolsOptions} [options] - Optional configuration for tool retrieval
|
|
2730
|
+
* @param {TransformToolSchemaModifier} [options.modifySchema] - Function to transform tool schemas
|
|
2740
2731
|
* @returns {Promise<ToolList>} List of tools matching the query criteria
|
|
2741
2732
|
*
|
|
2742
2733
|
* @example
|
|
2743
2734
|
* ```typescript
|
|
2744
|
-
* // Get
|
|
2745
|
-
* const
|
|
2735
|
+
* // Get tools from specific toolkits
|
|
2736
|
+
* const githubTools = await composio.tools.getRawComposioTools({
|
|
2737
|
+
* toolkits: ['github'],
|
|
2738
|
+
* limit: 10
|
|
2739
|
+
* });
|
|
2746
2740
|
*
|
|
2747
|
-
* // Get tools
|
|
2741
|
+
* // Get specific tools by slug
|
|
2742
|
+
* const specificTools = await composio.tools.getRawComposioTools({
|
|
2743
|
+
* tools: ['GITHUB_GET_REPOS', 'HACKERNEWS_GET_USER']
|
|
2744
|
+
* });
|
|
2745
|
+
*
|
|
2746
|
+
* // Get tools from specific toolkits
|
|
2748
2747
|
* const githubTools = await composio.tools.getRawComposioTools({
|
|
2749
2748
|
* toolkits: ['github'],
|
|
2750
2749
|
* limit: 10
|
|
2751
2750
|
* });
|
|
2752
2751
|
*
|
|
2753
2752
|
* // Get tools with schema transformation
|
|
2754
|
-
* const
|
|
2755
|
-
*
|
|
2753
|
+
* const customizedTools = await composio.tools.getRawComposioTools({
|
|
2754
|
+
* toolkits: ['github'],
|
|
2755
|
+
* limit: 5
|
|
2756
|
+
* }, {
|
|
2757
|
+
* modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
|
|
2756
2758
|
* // Add custom properties to tool schema
|
|
2757
|
-
* return {
|
|
2759
|
+
* return {
|
|
2760
|
+
* ...schema,
|
|
2761
|
+
* customProperty: `Modified ${toolSlug} from ${toolkitSlug}`,
|
|
2762
|
+
* tags: [...(schema.tags || []), 'customized']
|
|
2763
|
+
* };
|
|
2758
2764
|
* }
|
|
2759
|
-
* );
|
|
2765
|
+
* });
|
|
2766
|
+
*
|
|
2767
|
+
* // Search for tools
|
|
2768
|
+
* const searchResults = await composio.tools.getRawComposioTools({
|
|
2769
|
+
* search: 'user management'
|
|
2770
|
+
* });
|
|
2771
|
+
*
|
|
2772
|
+
* // Get tools by authentication config
|
|
2773
|
+
* const authSpecificTools = await composio.tools.getRawComposioTools({
|
|
2774
|
+
* authConfigIds: ['auth_config_123']
|
|
2775
|
+
* });
|
|
2760
2776
|
* ```
|
|
2761
2777
|
*/
|
|
2762
|
-
async getRawComposioTools(query,
|
|
2778
|
+
async getRawComposioTools(query, options) {
|
|
2763
2779
|
if ("tools" in query && "toolkits" in query) {
|
|
2764
2780
|
throw new ValidationError(
|
|
2765
2781
|
"Invalid tool list parameters. You should not use tools and toolkits filter together."
|
|
@@ -2787,7 +2803,8 @@ var Tools = class {
|
|
|
2787
2803
|
..."tags" in queryParams.data ? { tags: queryParams.data.tags } : {},
|
|
2788
2804
|
..."scopes" in queryParams.data ? { scopes: queryParams.data.scopes } : {},
|
|
2789
2805
|
..."search" in queryParams.data ? { search: queryParams.data.search } : {},
|
|
2790
|
-
..."authConfigIds" in queryParams.data ? { auth_config_ids: queryParams.data.authConfigIds } : {}
|
|
2806
|
+
..."authConfigIds" in queryParams.data ? { auth_config_ids: queryParams.data.authConfigIds } : {},
|
|
2807
|
+
...{ toolkit_versions: this.toolkitVersions }
|
|
2791
2808
|
};
|
|
2792
2809
|
logger_default.debug(`Fetching tools with filters: ${JSON.stringify(filters, null, 2)}`);
|
|
2793
2810
|
const tools = await this.client.tools.list(filters);
|
|
@@ -2802,7 +2819,8 @@ var Tools = class {
|
|
|
2802
2819
|
...caseTransformedTools,
|
|
2803
2820
|
...customTools
|
|
2804
2821
|
]);
|
|
2805
|
-
if (
|
|
2822
|
+
if (options?.modifySchema) {
|
|
2823
|
+
const modifier = options.modifySchema;
|
|
2806
2824
|
if (typeof modifier === "function") {
|
|
2807
2825
|
const modifiedPromises = modifiedTools.map(
|
|
2808
2826
|
(tool) => modifier({
|
|
@@ -2819,17 +2837,56 @@ var Tools = class {
|
|
|
2819
2837
|
return modifiedTools;
|
|
2820
2838
|
}
|
|
2821
2839
|
/**
|
|
2822
|
-
* Retrieves a tool by its
|
|
2823
|
-
*
|
|
2824
|
-
*
|
|
2825
|
-
*
|
|
2840
|
+
* Retrieves a specific tool by its slug from the Composio API.
|
|
2841
|
+
*
|
|
2842
|
+
* This method fetches a single tool in raw format without provider-specific wrapping,
|
|
2843
|
+
* providing direct access to the tool's schema and metadata. Tool versions are controlled
|
|
2844
|
+
* at the Composio SDK initialization level through the `toolkitVersions` configuration.
|
|
2845
|
+
*
|
|
2846
|
+
* @param {string} slug - The unique identifier of the tool (e.g., 'GITHUB_GET_REPOS')
|
|
2847
|
+
* @param {GetRawComposioToolBySlugOptions} [options] - Optional configuration for tool retrieval
|
|
2848
|
+
* @param {TransformToolSchemaModifier} [options.modifySchema] - Function to transform the tool schema
|
|
2849
|
+
* @returns {Promise<Tool>} The requested tool with its complete schema and metadata
|
|
2826
2850
|
*
|
|
2827
2851
|
* @example
|
|
2828
|
-
* ```
|
|
2829
|
-
*
|
|
2852
|
+
* ```typescript
|
|
2853
|
+
* // Get a tool by slug
|
|
2854
|
+
* const tool = await composio.tools.getRawComposioToolBySlug('GITHUB_GET_REPOS');
|
|
2855
|
+
* console.log(tool.name, tool.description);
|
|
2856
|
+
*
|
|
2857
|
+
* // Get a tool with schema transformation
|
|
2858
|
+
* const customizedTool = await composio.tools.getRawComposioToolBySlug(
|
|
2859
|
+
* 'SLACK_SEND_MESSAGE',
|
|
2860
|
+
* {
|
|
2861
|
+
* modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
|
|
2862
|
+
* return {
|
|
2863
|
+
* ...schema,
|
|
2864
|
+
* description: `Enhanced ${schema.description} with custom modifications`,
|
|
2865
|
+
* customMetadata: {
|
|
2866
|
+
* lastModified: new Date().toISOString(),
|
|
2867
|
+
* toolkit: toolkitSlug
|
|
2868
|
+
* }
|
|
2869
|
+
* };
|
|
2870
|
+
* }
|
|
2871
|
+
* }
|
|
2872
|
+
* );
|
|
2873
|
+
*
|
|
2874
|
+
* // Get a custom tool (will check custom tools first)
|
|
2875
|
+
* const customTool = await composio.tools.getRawComposioToolBySlug('MY_CUSTOM_TOOL');
|
|
2876
|
+
*
|
|
2877
|
+
* // Access tool properties
|
|
2878
|
+
* const githubTool = await composio.tools.getRawComposioToolBySlug('GITHUB_CREATE_ISSUE');
|
|
2879
|
+
* console.log({
|
|
2880
|
+
* slug: githubTool.slug,
|
|
2881
|
+
* name: githubTool.name,
|
|
2882
|
+
* toolkit: githubTool.toolkit?.name,
|
|
2883
|
+
* version: githubTool.version,
|
|
2884
|
+
* availableVersions: githubTool.availableVersions,
|
|
2885
|
+
* inputParameters: githubTool.inputParameters
|
|
2886
|
+
* });
|
|
2830
2887
|
* ```
|
|
2831
2888
|
*/
|
|
2832
|
-
async getRawComposioToolBySlug(slug,
|
|
2889
|
+
async getRawComposioToolBySlug(slug, options) {
|
|
2833
2890
|
const customTool = await this.customTools.getCustomToolBySlug(slug);
|
|
2834
2891
|
if (customTool) {
|
|
2835
2892
|
logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
|
|
@@ -2839,14 +2896,17 @@ var Tools = class {
|
|
|
2839
2896
|
}
|
|
2840
2897
|
let tool;
|
|
2841
2898
|
try {
|
|
2842
|
-
tool = await this.client.tools.retrieve(slug
|
|
2899
|
+
tool = await this.client.tools.retrieve(slug, {
|
|
2900
|
+
toolkit_versions: this.toolkitVersions
|
|
2901
|
+
});
|
|
2843
2902
|
} catch (error) {
|
|
2844
2903
|
throw new ComposioToolNotFoundError(`Unable to retrieve tool with slug ${slug}`, {
|
|
2845
2904
|
cause: error
|
|
2846
2905
|
});
|
|
2847
2906
|
}
|
|
2848
2907
|
let [modifiedTool] = await this.applyDefaultSchemaModifiers([this.transformToolCases(tool)]);
|
|
2849
|
-
if (
|
|
2908
|
+
if (options?.modifySchema) {
|
|
2909
|
+
const modifier = options.modifySchema;
|
|
2850
2910
|
if (typeof modifier === "function") {
|
|
2851
2911
|
modifiedTool = await modifier({
|
|
2852
2912
|
toolSlug: slug,
|
|
@@ -2861,20 +2921,26 @@ var Tools = class {
|
|
|
2861
2921
|
}
|
|
2862
2922
|
/**
|
|
2863
2923
|
* Get a tool or list of tools based on the provided arguments.
|
|
2864
|
-
* This is an implementation method that handles
|
|
2924
|
+
* This is an implementation method that handles all overloads.
|
|
2865
2925
|
*
|
|
2866
2926
|
* @param {string} userId - The user id to get the tool(s) for
|
|
2867
2927
|
* @param {ToolListParams | string} arg2 - Either a slug string or filters object
|
|
2868
|
-
* @param {ProviderOptions<TProvider>} [
|
|
2928
|
+
* @param {ProviderOptions<TProvider> | ToolkitVersion} [arg3] - Optional provider options or version string
|
|
2929
|
+
* @param {ProviderOptions<TProvider>} [arg4] - Optional provider options (when arg3 is version)
|
|
2869
2930
|
* @returns {Promise<TToolCollection>} The tool collection
|
|
2870
2931
|
*/
|
|
2871
|
-
async get(userId, arg2,
|
|
2932
|
+
async get(userId, arg2, arg3) {
|
|
2933
|
+
const options = arg3;
|
|
2872
2934
|
const executeToolFn = this.createExecuteToolFn(userId, options);
|
|
2873
2935
|
if (typeof arg2 === "string") {
|
|
2874
|
-
const tool = await this.getRawComposioToolBySlug(arg2,
|
|
2936
|
+
const tool = await this.getRawComposioToolBySlug(arg2, {
|
|
2937
|
+
modifySchema: options?.modifySchema
|
|
2938
|
+
});
|
|
2875
2939
|
return this.provider.wrapTools([tool], executeToolFn);
|
|
2876
2940
|
} else {
|
|
2877
|
-
const tools = await this.getRawComposioTools(arg2,
|
|
2941
|
+
const tools = await this.getRawComposioTools(arg2, {
|
|
2942
|
+
modifySchema: options?.modifySchema
|
|
2943
|
+
});
|
|
2878
2944
|
return this.provider.wrapTools(tools, executeToolFn);
|
|
2879
2945
|
}
|
|
2880
2946
|
}
|
|
@@ -2964,7 +3030,7 @@ var Tools = class {
|
|
|
2964
3030
|
custom_connection_data: body.customConnectionData,
|
|
2965
3031
|
arguments: body.arguments,
|
|
2966
3032
|
user_id: body.userId,
|
|
2967
|
-
version: body.version,
|
|
3033
|
+
version: body.version ?? getToolkitVersion(tool.toolkit?.slug ?? "unknown", this.toolkitVersions),
|
|
2968
3034
|
text: body.text
|
|
2969
3035
|
});
|
|
2970
3036
|
result = this.transformToolExecuteResponse(result);
|
|
@@ -3024,25 +3090,34 @@ var Tools = class {
|
|
|
3024
3090
|
"CustomTools not initialized. Make sure Tools class is properly constructed."
|
|
3025
3091
|
);
|
|
3026
3092
|
}
|
|
3093
|
+
const executeParams = ToolExecuteParamsSchema.safeParse(body);
|
|
3094
|
+
if (!executeParams.success) {
|
|
3095
|
+
throw new ValidationError("Invalid tool execute parameters", { cause: executeParams.error });
|
|
3096
|
+
}
|
|
3027
3097
|
try {
|
|
3028
3098
|
const customTool = await this.customTools.getCustomToolBySlug(slug);
|
|
3029
3099
|
if (customTool) {
|
|
3030
|
-
return this.handleCustomToolExecution(customTool,
|
|
3100
|
+
return this.handleCustomToolExecution(customTool, executeParams.data, modifiers);
|
|
3031
3101
|
} else {
|
|
3032
3102
|
const composioTool = await this.getRawComposioToolBySlug(slug);
|
|
3033
3103
|
if (!composioTool) {
|
|
3034
|
-
throw new ComposioToolNotFoundError(
|
|
3104
|
+
throw new ComposioToolNotFoundError(
|
|
3105
|
+
`Tool with slug ${slug} version:${executeParams.data.version} not found`
|
|
3106
|
+
);
|
|
3035
3107
|
}
|
|
3036
|
-
return this.handleComposioToolExecution(composioTool,
|
|
3108
|
+
return this.handleComposioToolExecution(composioTool, executeParams.data, modifiers);
|
|
3037
3109
|
}
|
|
3038
3110
|
} catch (error) {
|
|
3039
|
-
throw new ComposioToolExecutionError(
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3111
|
+
throw new ComposioToolExecutionError(
|
|
3112
|
+
`Error executing tool ${slug} version:${executeParams.data.version}`,
|
|
3113
|
+
{
|
|
3114
|
+
originalError: error,
|
|
3115
|
+
meta: {
|
|
3116
|
+
toolSlug: slug,
|
|
3117
|
+
body
|
|
3118
|
+
}
|
|
3044
3119
|
}
|
|
3045
|
-
|
|
3120
|
+
);
|
|
3046
3121
|
}
|
|
3047
3122
|
}
|
|
3048
3123
|
/**
|
|
@@ -6067,6 +6142,31 @@ function getSDKConfig(baseUrl, apiKey) {
|
|
|
6067
6142
|
logger_default.debug("Environment", `Base URL: ${baseURLParsed}`);
|
|
6068
6143
|
return { baseURL: baseURLParsed, apiKey: apiKeyParsed };
|
|
6069
6144
|
}
|
|
6145
|
+
function getToolkitVersionsFromEnv(defaultVersions) {
|
|
6146
|
+
if (defaultVersions && typeof defaultVersions === "string") {
|
|
6147
|
+
return defaultVersions;
|
|
6148
|
+
}
|
|
6149
|
+
const envPrefixedVersions = getEnvsWithPrefix(`COMPOSIO_TOOLKIT_VERSION_`);
|
|
6150
|
+
const toolkitVersionsFromEnv = Object.entries(envPrefixedVersions).reduce((acc, [key, value]) => {
|
|
6151
|
+
const toolkitName = key.replace("COMPOSIO_TOOLKIT_VERSION_", "");
|
|
6152
|
+
acc[toolkitName.toLowerCase()] = value;
|
|
6153
|
+
return acc;
|
|
6154
|
+
}, {});
|
|
6155
|
+
let userProvidedToolkitVersions = {};
|
|
6156
|
+
if (defaultVersions && typeof defaultVersions === "object") {
|
|
6157
|
+
userProvidedToolkitVersions = Object.fromEntries(
|
|
6158
|
+
Object.entries(defaultVersions).map(([key, value]) => [key.toLowerCase(), value])
|
|
6159
|
+
);
|
|
6160
|
+
}
|
|
6161
|
+
const toolkitVersions = {
|
|
6162
|
+
...toolkitVersionsFromEnv,
|
|
6163
|
+
...userProvidedToolkitVersions
|
|
6164
|
+
};
|
|
6165
|
+
if (Object.keys(toolkitVersions).length === 0) {
|
|
6166
|
+
return "latest";
|
|
6167
|
+
}
|
|
6168
|
+
return toolkitVersions;
|
|
6169
|
+
}
|
|
6070
6170
|
|
|
6071
6171
|
// src/utils/version.ts
|
|
6072
6172
|
import semver from "semver";
|
|
@@ -6588,7 +6688,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
6588
6688
|
};
|
|
6589
6689
|
|
|
6590
6690
|
// package.json
|
|
6591
|
-
var version = "0.1.
|
|
6691
|
+
var version = "0.1.52";
|
|
6592
6692
|
|
|
6593
6693
|
// src/models/Files.ts
|
|
6594
6694
|
var Files = class {
|
|
@@ -6711,7 +6811,11 @@ var Composio = class _Composio {
|
|
|
6711
6811
|
}
|
|
6712
6812
|
this.config = {
|
|
6713
6813
|
...config,
|
|
6714
|
-
|
|
6814
|
+
baseURL: baseURLParsed,
|
|
6815
|
+
apiKey: apiKeyParsed,
|
|
6816
|
+
toolkitVersions: getToolkitVersionsFromEnv(config?.toolkitVersions),
|
|
6817
|
+
allowTracking: config?.allowTracking ?? true,
|
|
6818
|
+
autoUploadDownloadFiles: config?.autoUploadDownloadFiles ?? true
|
|
6715
6819
|
};
|
|
6716
6820
|
this.provider = config?.provider ?? new OpenAIProvider();
|
|
6717
6821
|
const defaultHeaders = getDefaultHeaders(this.config.defaultHeaders, this.provider);
|
|
@@ -6721,9 +6825,7 @@ var Composio = class _Composio {
|
|
|
6721
6825
|
defaultHeaders,
|
|
6722
6826
|
logLevel: COMPOSIO_LOG_LEVEL
|
|
6723
6827
|
});
|
|
6724
|
-
this.tools = new Tools(this.client, this.provider,
|
|
6725
|
-
autoUploadDownloadFiles: config?.autoUploadDownloadFiles ?? true
|
|
6726
|
-
});
|
|
6828
|
+
this.tools = new Tools(this.client, this.provider, this.config);
|
|
6727
6829
|
this.mcp = new MCP(this.client, this.provider);
|
|
6728
6830
|
this.toolkits = new Toolkits(this.client);
|
|
6729
6831
|
this.triggers = new Triggers(this.client);
|
|
@@ -6757,6 +6859,13 @@ var Composio = class _Composio {
|
|
|
6757
6859
|
}
|
|
6758
6860
|
return this.client;
|
|
6759
6861
|
}
|
|
6862
|
+
/**
|
|
6863
|
+
* Get the configuration SDK is initialized with
|
|
6864
|
+
* @returns {ComposioConfig<TProvider>} The configuration SDK is initialized with
|
|
6865
|
+
*/
|
|
6866
|
+
getConfig() {
|
|
6867
|
+
return this.config;
|
|
6868
|
+
}
|
|
6760
6869
|
/**
|
|
6761
6870
|
* Creates a new instance of the Composio SDK with custom request options while preserving the existing configuration.
|
|
6762
6871
|
* This method is particularly useful when you need to:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@composio/json-schema-to-zod": "0.1.15"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@composio/client": "0.1.0-alpha.
|
|
38
|
+
"@composio/client": "0.1.0-alpha.36",
|
|
39
39
|
"@composio/json-schema-to-zod": "0.1.15",
|
|
40
40
|
"@types/json-schema": "^7.0.15",
|
|
41
41
|
"chalk": "^4.1.2",
|