@composio/core 0.1.13 → 0.1.15
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 +60 -115
- package/dist/index.d.cts +44 -7
- package/dist/index.d.ts +44 -7
- package/dist/index.js +59 -115
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,7 @@ __export(index_exports, {
|
|
|
56
56
|
ConnectionRequestFailedError: () => ConnectionRequestFailedError,
|
|
57
57
|
ConnectionRequestTimeoutError: () => ConnectionRequestTimeoutError,
|
|
58
58
|
ConsoleTelemetryTransport: () => ConsoleTelemetryTransport,
|
|
59
|
+
JsonSchemaToZodError: () => JsonSchemaToZodError,
|
|
59
60
|
OpenAIProvider: () => OpenAIProvider,
|
|
60
61
|
SDKErrorCodes: () => SDKErrorCodes,
|
|
61
62
|
ToolErrorCodes: () => ToolErrorCodes,
|
|
@@ -102,7 +103,7 @@ var ParametersSchema = import_zod.z.object({
|
|
|
102
103
|
required: import_zod.z.array(import_zod.z.string()).optional(),
|
|
103
104
|
title: import_zod.z.string().optional(),
|
|
104
105
|
description: import_zod.z.string().optional(),
|
|
105
|
-
additionalProperties: import_zod.z.boolean().optional()
|
|
106
|
+
additionalProperties: import_zod.z.boolean().default(false).optional()
|
|
106
107
|
});
|
|
107
108
|
var ToolSchema = import_zod.z.object({
|
|
108
109
|
slug: import_zod.z.string().describe('The slug of the tool. eg. "GOOGLE_SEARCH"'),
|
|
@@ -127,13 +128,19 @@ var ToolListFilterByToolkitsSchema = import_zod.z.object({
|
|
|
127
128
|
important: import_zod.z.boolean().optional(),
|
|
128
129
|
cursor: import_zod.z.string().optional(),
|
|
129
130
|
limit: import_zod.z.number().optional(),
|
|
130
|
-
search: import_zod.z.string().optional()
|
|
131
|
+
search: import_zod.z.string().optional(),
|
|
132
|
+
strict: import_zod.z.boolean().optional().describe(
|
|
133
|
+
"If true, all the non-required fields will be removed from the input/output params of the tool"
|
|
134
|
+
)
|
|
131
135
|
});
|
|
132
136
|
var ToolListFilterBySearchSchema = import_zod.z.object({
|
|
133
137
|
search: import_zod.z.string(),
|
|
134
138
|
toolkits: import_zod.z.array(import_zod.z.string()).optional(),
|
|
135
139
|
cursor: import_zod.z.string().optional(),
|
|
136
|
-
limit: import_zod.z.number().optional()
|
|
140
|
+
limit: import_zod.z.number().optional(),
|
|
141
|
+
strict: import_zod.z.boolean().optional().describe(
|
|
142
|
+
"If true, all the non-required fields will be removed from the input/output params of the tool"
|
|
143
|
+
)
|
|
137
144
|
});
|
|
138
145
|
var ToolListParamsSchema = import_zod.z.union([
|
|
139
146
|
ToolListFilterByToolsSchema,
|
|
@@ -1529,7 +1536,8 @@ var ComposioToolkitFetchError = class extends ComposioError {
|
|
|
1529
1536
|
// src/errors/ValidationErrors.ts
|
|
1530
1537
|
var import_zod5 = require("zod");
|
|
1531
1538
|
var ValidationErrorCodes = {
|
|
1532
|
-
VALIDATION_ERROR: "VALIDATION_ERROR"
|
|
1539
|
+
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
1540
|
+
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
|
|
1533
1541
|
};
|
|
1534
1542
|
var ValidationError = class extends ComposioError {
|
|
1535
1543
|
constructor(message = "Input validation failed", options = {}) {
|
|
@@ -1572,6 +1580,14 @@ var ValidationError = class extends ComposioError {
|
|
|
1572
1580
|
return "Please check your input parameters";
|
|
1573
1581
|
}
|
|
1574
1582
|
};
|
|
1583
|
+
var JsonSchemaToZodError = class extends ComposioError {
|
|
1584
|
+
constructor(message = "Failed to convert JSON schema to Zod schema", options = {}) {
|
|
1585
|
+
super(message, {
|
|
1586
|
+
...options,
|
|
1587
|
+
code: options.code || ValidationErrorCodes.JSON_SCHEMA_TO_ZOD_ERROR
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1575
1591
|
|
|
1576
1592
|
// src/errors/SDKErrors.ts
|
|
1577
1593
|
var SDKErrorCodes = {
|
|
@@ -1880,6 +1896,36 @@ var CustomTools = class {
|
|
|
1880
1896
|
}
|
|
1881
1897
|
};
|
|
1882
1898
|
|
|
1899
|
+
// src/utils/jsonSchema.ts
|
|
1900
|
+
var import_json_schema_to_zod = require("@composio/json-schema-to-zod");
|
|
1901
|
+
var removeNonRequiredProperties = (schema) => {
|
|
1902
|
+
if (schema && schema.type === "object" && schema.required?.length) {
|
|
1903
|
+
schema.properties = Object.fromEntries(
|
|
1904
|
+
Object.entries(schema.properties || {}).filter(
|
|
1905
|
+
([key]) => schema.required.includes(key)
|
|
1906
|
+
)
|
|
1907
|
+
);
|
|
1908
|
+
}
|
|
1909
|
+
return schema;
|
|
1910
|
+
};
|
|
1911
|
+
function jsonSchemaToZodSchema(jsonSchema, { strict } = {
|
|
1912
|
+
strict: false
|
|
1913
|
+
}) {
|
|
1914
|
+
try {
|
|
1915
|
+
let schema = jsonSchema;
|
|
1916
|
+
if (strict && schema) {
|
|
1917
|
+
schema = removeNonRequiredProperties(
|
|
1918
|
+
schema
|
|
1919
|
+
);
|
|
1920
|
+
}
|
|
1921
|
+
return (0, import_json_schema_to_zod.jsonSchemaToZod)(schema);
|
|
1922
|
+
} catch (error) {
|
|
1923
|
+
throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", {
|
|
1924
|
+
cause: error
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1883
1929
|
// src/models/Tools.ts
|
|
1884
1930
|
var Tools = class {
|
|
1885
1931
|
client;
|
|
@@ -2140,7 +2186,14 @@ var Tools = class {
|
|
|
2140
2186
|
const tool = await this.getRawComposioToolBySlug(userId, arg2, options?.modifySchema);
|
|
2141
2187
|
return this.provider.wrapTools([tool], executeToolFn);
|
|
2142
2188
|
} else {
|
|
2143
|
-
|
|
2189
|
+
let tools = await this.getRawComposioTools(userId, arg2, options?.modifySchema);
|
|
2190
|
+
if (arg2?.strict) {
|
|
2191
|
+
tools = tools.map((tool) => ({
|
|
2192
|
+
...tool,
|
|
2193
|
+
inputParameters: tool.inputParameters ? removeNonRequiredProperties(tool.inputParameters) : void 0,
|
|
2194
|
+
outputParameters: tool.outputParameters ? removeNonRequiredProperties(tool.outputParameters) : void 0
|
|
2195
|
+
}));
|
|
2196
|
+
}
|
|
2144
2197
|
return this.provider.wrapTools(tools, executeToolFn);
|
|
2145
2198
|
}
|
|
2146
2199
|
}
|
|
@@ -4704,7 +4757,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
4704
4757
|
};
|
|
4705
4758
|
|
|
4706
4759
|
// package.json
|
|
4707
|
-
var version = "0.1.
|
|
4760
|
+
var version = "0.1.15";
|
|
4708
4761
|
|
|
4709
4762
|
// src/composio.ts
|
|
4710
4763
|
var Composio = class _Composio {
|
|
@@ -4882,115 +4935,6 @@ var ConsoleTelemetryTransport = class {
|
|
|
4882
4935
|
return Promise.resolve();
|
|
4883
4936
|
}
|
|
4884
4937
|
};
|
|
4885
|
-
|
|
4886
|
-
// src/utils/jsonSchema.ts
|
|
4887
|
-
var import_zod10 = require("zod");
|
|
4888
|
-
function jsonSchemaPropertiesToTSTypes(value) {
|
|
4889
|
-
if (!value.type) {
|
|
4890
|
-
return import_zod10.z.object({});
|
|
4891
|
-
}
|
|
4892
|
-
let zodType;
|
|
4893
|
-
switch (value.type) {
|
|
4894
|
-
case "string":
|
|
4895
|
-
zodType = import_zod10.z.string().describe(
|
|
4896
|
-
(value.description || "") + (value.examples ? `
|
|
4897
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4898
|
-
);
|
|
4899
|
-
break;
|
|
4900
|
-
case "number":
|
|
4901
|
-
zodType = import_zod10.z.number().describe(
|
|
4902
|
-
(value.description || "") + (value.examples ? `
|
|
4903
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4904
|
-
);
|
|
4905
|
-
break;
|
|
4906
|
-
case "integer":
|
|
4907
|
-
zodType = import_zod10.z.number().int().describe(
|
|
4908
|
-
(value.description || "") + (value.examples ? `
|
|
4909
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4910
|
-
);
|
|
4911
|
-
break;
|
|
4912
|
-
case "boolean":
|
|
4913
|
-
zodType = import_zod10.z.boolean().describe(
|
|
4914
|
-
(value.description || "") + (value.examples ? `
|
|
4915
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4916
|
-
);
|
|
4917
|
-
break;
|
|
4918
|
-
case "array":
|
|
4919
|
-
zodType = import_zod10.z.array(
|
|
4920
|
-
jsonSchemaPropertiesToTSTypes(
|
|
4921
|
-
value.items
|
|
4922
|
-
)
|
|
4923
|
-
).describe(
|
|
4924
|
-
(value.description || "") + (value.examples ? `
|
|
4925
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4926
|
-
);
|
|
4927
|
-
break;
|
|
4928
|
-
case "object":
|
|
4929
|
-
zodType = jsonSchemaToZodSchema(value).describe(
|
|
4930
|
-
(value.description || "") + (value.examples ? `
|
|
4931
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4932
|
-
);
|
|
4933
|
-
break;
|
|
4934
|
-
case "null":
|
|
4935
|
-
zodType = import_zod10.z.null().describe(value.description || "");
|
|
4936
|
-
break;
|
|
4937
|
-
default:
|
|
4938
|
-
throw new Error(`Unsupported JSON schema type: ${value.type}`);
|
|
4939
|
-
}
|
|
4940
|
-
return zodType;
|
|
4941
|
-
}
|
|
4942
|
-
function jsonSchemaToZodSchema(jsonSchema) {
|
|
4943
|
-
const properties = jsonSchema.properties;
|
|
4944
|
-
const requiredFields = jsonSchema.required || [];
|
|
4945
|
-
if (!properties) {
|
|
4946
|
-
return import_zod10.z.object({});
|
|
4947
|
-
}
|
|
4948
|
-
const zodSchema = {};
|
|
4949
|
-
for (const [key, _] of Object.entries(properties)) {
|
|
4950
|
-
const value = _;
|
|
4951
|
-
let zodType;
|
|
4952
|
-
if (value.anyOf) {
|
|
4953
|
-
const anyOfTypes = value.anyOf.map(
|
|
4954
|
-
(schema) => jsonSchemaPropertiesToTSTypes(
|
|
4955
|
-
schema
|
|
4956
|
-
)
|
|
4957
|
-
);
|
|
4958
|
-
zodType = import_zod10.z.union(anyOfTypes).describe(
|
|
4959
|
-
(value.description || "") + (value.examples ? `
|
|
4960
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4961
|
-
);
|
|
4962
|
-
} else if (value.allOf) {
|
|
4963
|
-
const allOfTypes = value.allOf.map(
|
|
4964
|
-
(schema) => jsonSchemaPropertiesToTSTypes(
|
|
4965
|
-
schema
|
|
4966
|
-
)
|
|
4967
|
-
);
|
|
4968
|
-
zodType = import_zod10.z.intersection(
|
|
4969
|
-
allOfTypes[0],
|
|
4970
|
-
allOfTypes.slice(1).reduce((acc, schema) => acc.and(schema), allOfTypes[0])
|
|
4971
|
-
).describe(
|
|
4972
|
-
(value.description || "") + (value.examples ? `
|
|
4973
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4974
|
-
);
|
|
4975
|
-
} else {
|
|
4976
|
-
if (!value.type) {
|
|
4977
|
-
value.type = "string";
|
|
4978
|
-
}
|
|
4979
|
-
zodType = jsonSchemaPropertiesToTSTypes(
|
|
4980
|
-
value
|
|
4981
|
-
);
|
|
4982
|
-
}
|
|
4983
|
-
if (value.description) {
|
|
4984
|
-
zodType = zodType.describe(value.description);
|
|
4985
|
-
}
|
|
4986
|
-
if (requiredFields.includes(key)) {
|
|
4987
|
-
zodSchema[key] = zodType;
|
|
4988
|
-
} else {
|
|
4989
|
-
zodSchema[key] = zodType.optional();
|
|
4990
|
-
}
|
|
4991
|
-
}
|
|
4992
|
-
return import_zod10.z.object(zodSchema);
|
|
4993
|
-
}
|
|
4994
4938
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4995
4939
|
0 && (module.exports = {
|
|
4996
4940
|
AuthConfigErrorCodes,
|
|
@@ -5019,6 +4963,7 @@ Examples: ${value.examples.join(", ")}` : "")
|
|
|
5019
4963
|
ConnectionRequestFailedError,
|
|
5020
4964
|
ConnectionRequestTimeoutError,
|
|
5021
4965
|
ConsoleTelemetryTransport,
|
|
4966
|
+
JsonSchemaToZodError,
|
|
5022
4967
|
OpenAIProvider,
|
|
5023
4968
|
SDKErrorCodes,
|
|
5024
4969
|
ToolErrorCodes,
|
package/dist/index.d.cts
CHANGED
|
@@ -23,7 +23,7 @@ declare const ToolSchema: z.ZodObject<{
|
|
|
23
23
|
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
24
24
|
title: z.ZodOptional<z.ZodString>;
|
|
25
25
|
description: z.ZodOptional<z.ZodString>;
|
|
26
|
-
additionalProperties: z.ZodOptional<z.ZodBoolean
|
|
26
|
+
additionalProperties: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
27
27
|
}, "strip", z.ZodTypeAny, {
|
|
28
28
|
type: "object";
|
|
29
29
|
properties: Record<string, unknown>;
|
|
@@ -45,7 +45,7 @@ declare const ToolSchema: z.ZodObject<{
|
|
|
45
45
|
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
46
46
|
title: z.ZodOptional<z.ZodString>;
|
|
47
47
|
description: z.ZodOptional<z.ZodString>;
|
|
48
|
-
additionalProperties: z.ZodOptional<z.ZodBoolean
|
|
48
|
+
additionalProperties: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
49
49
|
}, "strip", z.ZodTypeAny, {
|
|
50
50
|
type: "object";
|
|
51
51
|
properties: Record<string, unknown>;
|
|
@@ -143,6 +143,7 @@ type ToolsOnlyParams = {
|
|
|
143
143
|
cursor?: never;
|
|
144
144
|
limit?: never;
|
|
145
145
|
search?: never;
|
|
146
|
+
strict?: boolean;
|
|
146
147
|
};
|
|
147
148
|
type ToolkitsOnlyParams = {
|
|
148
149
|
tools?: never;
|
|
@@ -151,6 +152,7 @@ type ToolkitsOnlyParams = {
|
|
|
151
152
|
cursor?: string;
|
|
152
153
|
limit?: number;
|
|
153
154
|
search?: never;
|
|
155
|
+
strict?: boolean;
|
|
154
156
|
};
|
|
155
157
|
type ToolkitSearchOnlyParams = {
|
|
156
158
|
tools?: never;
|
|
@@ -159,6 +161,7 @@ type ToolkitSearchOnlyParams = {
|
|
|
159
161
|
cursor?: string;
|
|
160
162
|
limit?: number;
|
|
161
163
|
search?: string;
|
|
164
|
+
strict?: boolean;
|
|
162
165
|
};
|
|
163
166
|
/**
|
|
164
167
|
* ToolListParams is the parameters for the list of tools.
|
|
@@ -177,33 +180,39 @@ declare const ToolListParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
177
180
|
cursor: z.ZodOptional<z.ZodString>;
|
|
178
181
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
179
182
|
search: z.ZodOptional<z.ZodString>;
|
|
183
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
180
184
|
}, "strip", z.ZodTypeAny, {
|
|
181
185
|
toolkits: string[];
|
|
182
186
|
important?: boolean | undefined;
|
|
183
187
|
cursor?: string | undefined;
|
|
184
188
|
limit?: number | undefined;
|
|
185
189
|
search?: string | undefined;
|
|
190
|
+
strict?: boolean | undefined;
|
|
186
191
|
}, {
|
|
187
192
|
toolkits: string[];
|
|
188
193
|
important?: boolean | undefined;
|
|
189
194
|
cursor?: string | undefined;
|
|
190
195
|
limit?: number | undefined;
|
|
191
196
|
search?: string | undefined;
|
|
197
|
+
strict?: boolean | undefined;
|
|
192
198
|
}>, z.ZodObject<{
|
|
193
199
|
search: z.ZodString;
|
|
194
200
|
toolkits: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
195
201
|
cursor: z.ZodOptional<z.ZodString>;
|
|
196
202
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
203
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
197
204
|
}, "strip", z.ZodTypeAny, {
|
|
198
205
|
search: string;
|
|
199
206
|
toolkits?: string[] | undefined;
|
|
200
207
|
cursor?: string | undefined;
|
|
201
208
|
limit?: number | undefined;
|
|
209
|
+
strict?: boolean | undefined;
|
|
202
210
|
}, {
|
|
203
211
|
search: string;
|
|
204
212
|
toolkits?: string[] | undefined;
|
|
205
213
|
cursor?: string | undefined;
|
|
206
214
|
limit?: number | undefined;
|
|
215
|
+
strict?: boolean | undefined;
|
|
207
216
|
}>]>;
|
|
208
217
|
/**
|
|
209
218
|
* CustomAuthParams is the parameters for the custom authentication.
|
|
@@ -560,7 +569,7 @@ type BaseComposioProvider<TToolCollection, TTool> = BaseNonAgenticProvider<TTool
|
|
|
560
569
|
* };
|
|
561
570
|
* ```
|
|
562
571
|
*/
|
|
563
|
-
type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => Promise<ToolExecuteParams
|
|
572
|
+
type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => Promise<ToolExecuteParams> | ToolExecuteParams;
|
|
564
573
|
/**
|
|
565
574
|
* Modifier for altering the tool execution response after execution completes.
|
|
566
575
|
*
|
|
@@ -611,7 +620,7 @@ type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecute
|
|
|
611
620
|
* };
|
|
612
621
|
* ```
|
|
613
622
|
*/
|
|
614
|
-
type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => Promise<ToolExecuteResponse
|
|
623
|
+
type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => Promise<ToolExecuteResponse> | ToolExecuteResponse;
|
|
615
624
|
/**
|
|
616
625
|
* Modifier for altering the tool schema before it's exposed to consumers.
|
|
617
626
|
*
|
|
@@ -802,7 +811,7 @@ type AgenticToolOptions = ToolOptions & ExecuteToolModifiers;
|
|
|
802
811
|
* });
|
|
803
812
|
* ```
|
|
804
813
|
*/
|
|
805
|
-
type ProviderOptions<
|
|
814
|
+
type ProviderOptions<TProvider> = TProvider extends BaseComposioProvider<infer TToolCollection, infer TTool> ? TProvider extends BaseAgenticProvider<TToolCollection, TTool> ? AgenticToolOptions : ToolOptions : never;
|
|
806
815
|
|
|
807
816
|
/**
|
|
808
817
|
* This class is used to manage tools in the Composio SDK.
|
|
@@ -31729,8 +31738,11 @@ declare class ComposioProvider extends BaseNonAgenticProvider<Array<CustomTool>,
|
|
|
31729
31738
|
/**
|
|
31730
31739
|
* Convert a JSON schema to a Zod schema
|
|
31731
31740
|
* @param jsonSchema - The JSON schema to convert
|
|
31741
|
+
* @param strict - Eliminates all non-required properties from the schema
|
|
31732
31742
|
* @returns The Zod schema
|
|
31733
31743
|
*
|
|
31744
|
+
* @throws {JsonSchemaToZodError} If the JSON schema is invalid
|
|
31745
|
+
*
|
|
31734
31746
|
* @example
|
|
31735
31747
|
* ```ts
|
|
31736
31748
|
* const zodSchema = jsonSchemaToZodSchema({
|
|
@@ -31742,8 +31754,29 @@ declare class ComposioProvider extends BaseNonAgenticProvider<Array<CustomTool>,
|
|
|
31742
31754
|
*
|
|
31743
31755
|
* console.log(zodSchema);
|
|
31744
31756
|
* ```
|
|
31757
|
+
*
|
|
31758
|
+
* @example
|
|
31759
|
+
* ```ts
|
|
31760
|
+
* const zodSchema = jsonSchemaToZodSchema({
|
|
31761
|
+
* type: 'object',
|
|
31762
|
+
* properties: {
|
|
31763
|
+
* name: { type: 'string' },
|
|
31764
|
+
* age: { type: 'number' },
|
|
31765
|
+
* },
|
|
31766
|
+
* required: ['name'],
|
|
31767
|
+
* }, { strict: true });
|
|
31768
|
+
*
|
|
31769
|
+
* console.log(zodSchema);
|
|
31770
|
+
*
|
|
31771
|
+
* // Output:
|
|
31772
|
+
* // z.object({
|
|
31773
|
+
* // name: z.string(),
|
|
31774
|
+
* // })
|
|
31775
|
+
* ```
|
|
31745
31776
|
*/
|
|
31746
|
-
declare function jsonSchemaToZodSchema(jsonSchema: Record<string, unknown
|
|
31777
|
+
declare function jsonSchemaToZodSchema(jsonSchema: Record<string, unknown>, { strict }?: {
|
|
31778
|
+
strict?: boolean;
|
|
31779
|
+
}): z.ZodObject<Record<string, z.ZodTypeAny>>;
|
|
31747
31780
|
|
|
31748
31781
|
declare const LOG_LEVELS: {
|
|
31749
31782
|
readonly silent: -1;
|
|
@@ -31953,11 +31986,15 @@ declare class ComposioToolkitFetchError extends ComposioError {
|
|
|
31953
31986
|
*/
|
|
31954
31987
|
declare const ValidationErrorCodes: {
|
|
31955
31988
|
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
31989
|
+
readonly JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR";
|
|
31956
31990
|
};
|
|
31957
31991
|
declare class ValidationError extends ComposioError {
|
|
31958
31992
|
constructor(message?: string, options?: ComposioErrorOptions);
|
|
31959
31993
|
private generateUserFriendlyMessage;
|
|
31960
31994
|
}
|
|
31995
|
+
declare class JsonSchemaToZodError extends ComposioError {
|
|
31996
|
+
constructor(message?: string, options?: ComposioErrorOptions);
|
|
31997
|
+
}
|
|
31961
31998
|
|
|
31962
31999
|
declare const SDKErrorCodes: {
|
|
31963
32000
|
NO_API_KEY_PROVIDED: string;
|
|
@@ -31966,4 +32003,4 @@ declare class ComposioNoAPIKeyError extends ComposioError {
|
|
|
31966
32003
|
constructor(message?: string, options?: Omit<ComposioErrorOptions, 'code' | 'statusCode'>);
|
|
31967
32004
|
}
|
|
31968
32005
|
|
|
31969
|
-
export { type AgenticToolOptions, AuthConfigErrorCodes, type AuthConfigType, AuthConfigTypes, type AuthSchemeType, AuthSchemeTypes, BaseAgenticProvider, type BaseComposioProvider, BaseNonAgenticProvider, BaseTelemetryTransport, Composio, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomToolsNotInitializedError, ComposioError, type ComposioErrorOptions, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ConnectedAccountErrorCodes, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConsoleTelemetryTransport, type ErrorHandleOptions, type ExecuteMetadata, type ExecuteToolFn, type ExecuteToolFnOptions, type ExecuteToolModifiers, OpenAIProvider, type Provider, SDKErrorCodes, type Tool, ToolErrorCodes, type ToolExecuteParams, type ToolListParams, ToolListParamsSchema, type ToolOptions, ToolkitErrorCodes, type TransformToolSchemaModifier, ValidationError, ValidationErrorCodes, type afterExecuteModifier, type beforeExecuteModifier, jsonSchemaToZodSchema, logger };
|
|
32006
|
+
export { type AgenticToolOptions, AuthConfigErrorCodes, type AuthConfigType, AuthConfigTypes, type AuthSchemeType, AuthSchemeTypes, BaseAgenticProvider, type BaseComposioProvider, BaseNonAgenticProvider, BaseTelemetryTransport, Composio, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomToolsNotInitializedError, ComposioError, type ComposioErrorOptions, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ConnectedAccountErrorCodes, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConsoleTelemetryTransport, type ErrorHandleOptions, type ExecuteMetadata, type ExecuteToolFn, type ExecuteToolFnOptions, type ExecuteToolModifiers, JsonSchemaToZodError, OpenAIProvider, type Provider, SDKErrorCodes, type Tool, ToolErrorCodes, type ToolExecuteParams, type ToolListParams, ToolListParamsSchema, type ToolOptions, ToolkitErrorCodes, type TransformToolSchemaModifier, ValidationError, ValidationErrorCodes, type afterExecuteModifier, type beforeExecuteModifier, jsonSchemaToZodSchema, logger };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ declare const ToolSchema: z.ZodObject<{
|
|
|
23
23
|
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
24
24
|
title: z.ZodOptional<z.ZodString>;
|
|
25
25
|
description: z.ZodOptional<z.ZodString>;
|
|
26
|
-
additionalProperties: z.ZodOptional<z.ZodBoolean
|
|
26
|
+
additionalProperties: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
27
27
|
}, "strip", z.ZodTypeAny, {
|
|
28
28
|
type: "object";
|
|
29
29
|
properties: Record<string, unknown>;
|
|
@@ -45,7 +45,7 @@ declare const ToolSchema: z.ZodObject<{
|
|
|
45
45
|
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
46
46
|
title: z.ZodOptional<z.ZodString>;
|
|
47
47
|
description: z.ZodOptional<z.ZodString>;
|
|
48
|
-
additionalProperties: z.ZodOptional<z.ZodBoolean
|
|
48
|
+
additionalProperties: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
49
49
|
}, "strip", z.ZodTypeAny, {
|
|
50
50
|
type: "object";
|
|
51
51
|
properties: Record<string, unknown>;
|
|
@@ -143,6 +143,7 @@ type ToolsOnlyParams = {
|
|
|
143
143
|
cursor?: never;
|
|
144
144
|
limit?: never;
|
|
145
145
|
search?: never;
|
|
146
|
+
strict?: boolean;
|
|
146
147
|
};
|
|
147
148
|
type ToolkitsOnlyParams = {
|
|
148
149
|
tools?: never;
|
|
@@ -151,6 +152,7 @@ type ToolkitsOnlyParams = {
|
|
|
151
152
|
cursor?: string;
|
|
152
153
|
limit?: number;
|
|
153
154
|
search?: never;
|
|
155
|
+
strict?: boolean;
|
|
154
156
|
};
|
|
155
157
|
type ToolkitSearchOnlyParams = {
|
|
156
158
|
tools?: never;
|
|
@@ -159,6 +161,7 @@ type ToolkitSearchOnlyParams = {
|
|
|
159
161
|
cursor?: string;
|
|
160
162
|
limit?: number;
|
|
161
163
|
search?: string;
|
|
164
|
+
strict?: boolean;
|
|
162
165
|
};
|
|
163
166
|
/**
|
|
164
167
|
* ToolListParams is the parameters for the list of tools.
|
|
@@ -177,33 +180,39 @@ declare const ToolListParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
177
180
|
cursor: z.ZodOptional<z.ZodString>;
|
|
178
181
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
179
182
|
search: z.ZodOptional<z.ZodString>;
|
|
183
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
180
184
|
}, "strip", z.ZodTypeAny, {
|
|
181
185
|
toolkits: string[];
|
|
182
186
|
important?: boolean | undefined;
|
|
183
187
|
cursor?: string | undefined;
|
|
184
188
|
limit?: number | undefined;
|
|
185
189
|
search?: string | undefined;
|
|
190
|
+
strict?: boolean | undefined;
|
|
186
191
|
}, {
|
|
187
192
|
toolkits: string[];
|
|
188
193
|
important?: boolean | undefined;
|
|
189
194
|
cursor?: string | undefined;
|
|
190
195
|
limit?: number | undefined;
|
|
191
196
|
search?: string | undefined;
|
|
197
|
+
strict?: boolean | undefined;
|
|
192
198
|
}>, z.ZodObject<{
|
|
193
199
|
search: z.ZodString;
|
|
194
200
|
toolkits: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
195
201
|
cursor: z.ZodOptional<z.ZodString>;
|
|
196
202
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
203
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
197
204
|
}, "strip", z.ZodTypeAny, {
|
|
198
205
|
search: string;
|
|
199
206
|
toolkits?: string[] | undefined;
|
|
200
207
|
cursor?: string | undefined;
|
|
201
208
|
limit?: number | undefined;
|
|
209
|
+
strict?: boolean | undefined;
|
|
202
210
|
}, {
|
|
203
211
|
search: string;
|
|
204
212
|
toolkits?: string[] | undefined;
|
|
205
213
|
cursor?: string | undefined;
|
|
206
214
|
limit?: number | undefined;
|
|
215
|
+
strict?: boolean | undefined;
|
|
207
216
|
}>]>;
|
|
208
217
|
/**
|
|
209
218
|
* CustomAuthParams is the parameters for the custom authentication.
|
|
@@ -560,7 +569,7 @@ type BaseComposioProvider<TToolCollection, TTool> = BaseNonAgenticProvider<TTool
|
|
|
560
569
|
* };
|
|
561
570
|
* ```
|
|
562
571
|
*/
|
|
563
|
-
type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => Promise<ToolExecuteParams
|
|
572
|
+
type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => Promise<ToolExecuteParams> | ToolExecuteParams;
|
|
564
573
|
/**
|
|
565
574
|
* Modifier for altering the tool execution response after execution completes.
|
|
566
575
|
*
|
|
@@ -611,7 +620,7 @@ type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecute
|
|
|
611
620
|
* };
|
|
612
621
|
* ```
|
|
613
622
|
*/
|
|
614
|
-
type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => Promise<ToolExecuteResponse
|
|
623
|
+
type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => Promise<ToolExecuteResponse> | ToolExecuteResponse;
|
|
615
624
|
/**
|
|
616
625
|
* Modifier for altering the tool schema before it's exposed to consumers.
|
|
617
626
|
*
|
|
@@ -802,7 +811,7 @@ type AgenticToolOptions = ToolOptions & ExecuteToolModifiers;
|
|
|
802
811
|
* });
|
|
803
812
|
* ```
|
|
804
813
|
*/
|
|
805
|
-
type ProviderOptions<
|
|
814
|
+
type ProviderOptions<TProvider> = TProvider extends BaseComposioProvider<infer TToolCollection, infer TTool> ? TProvider extends BaseAgenticProvider<TToolCollection, TTool> ? AgenticToolOptions : ToolOptions : never;
|
|
806
815
|
|
|
807
816
|
/**
|
|
808
817
|
* This class is used to manage tools in the Composio SDK.
|
|
@@ -31729,8 +31738,11 @@ declare class ComposioProvider extends BaseNonAgenticProvider<Array<CustomTool>,
|
|
|
31729
31738
|
/**
|
|
31730
31739
|
* Convert a JSON schema to a Zod schema
|
|
31731
31740
|
* @param jsonSchema - The JSON schema to convert
|
|
31741
|
+
* @param strict - Eliminates all non-required properties from the schema
|
|
31732
31742
|
* @returns The Zod schema
|
|
31733
31743
|
*
|
|
31744
|
+
* @throws {JsonSchemaToZodError} If the JSON schema is invalid
|
|
31745
|
+
*
|
|
31734
31746
|
* @example
|
|
31735
31747
|
* ```ts
|
|
31736
31748
|
* const zodSchema = jsonSchemaToZodSchema({
|
|
@@ -31742,8 +31754,29 @@ declare class ComposioProvider extends BaseNonAgenticProvider<Array<CustomTool>,
|
|
|
31742
31754
|
*
|
|
31743
31755
|
* console.log(zodSchema);
|
|
31744
31756
|
* ```
|
|
31757
|
+
*
|
|
31758
|
+
* @example
|
|
31759
|
+
* ```ts
|
|
31760
|
+
* const zodSchema = jsonSchemaToZodSchema({
|
|
31761
|
+
* type: 'object',
|
|
31762
|
+
* properties: {
|
|
31763
|
+
* name: { type: 'string' },
|
|
31764
|
+
* age: { type: 'number' },
|
|
31765
|
+
* },
|
|
31766
|
+
* required: ['name'],
|
|
31767
|
+
* }, { strict: true });
|
|
31768
|
+
*
|
|
31769
|
+
* console.log(zodSchema);
|
|
31770
|
+
*
|
|
31771
|
+
* // Output:
|
|
31772
|
+
* // z.object({
|
|
31773
|
+
* // name: z.string(),
|
|
31774
|
+
* // })
|
|
31775
|
+
* ```
|
|
31745
31776
|
*/
|
|
31746
|
-
declare function jsonSchemaToZodSchema(jsonSchema: Record<string, unknown
|
|
31777
|
+
declare function jsonSchemaToZodSchema(jsonSchema: Record<string, unknown>, { strict }?: {
|
|
31778
|
+
strict?: boolean;
|
|
31779
|
+
}): z.ZodObject<Record<string, z.ZodTypeAny>>;
|
|
31747
31780
|
|
|
31748
31781
|
declare const LOG_LEVELS: {
|
|
31749
31782
|
readonly silent: -1;
|
|
@@ -31953,11 +31986,15 @@ declare class ComposioToolkitFetchError extends ComposioError {
|
|
|
31953
31986
|
*/
|
|
31954
31987
|
declare const ValidationErrorCodes: {
|
|
31955
31988
|
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
31989
|
+
readonly JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR";
|
|
31956
31990
|
};
|
|
31957
31991
|
declare class ValidationError extends ComposioError {
|
|
31958
31992
|
constructor(message?: string, options?: ComposioErrorOptions);
|
|
31959
31993
|
private generateUserFriendlyMessage;
|
|
31960
31994
|
}
|
|
31995
|
+
declare class JsonSchemaToZodError extends ComposioError {
|
|
31996
|
+
constructor(message?: string, options?: ComposioErrorOptions);
|
|
31997
|
+
}
|
|
31961
31998
|
|
|
31962
31999
|
declare const SDKErrorCodes: {
|
|
31963
32000
|
NO_API_KEY_PROVIDED: string;
|
|
@@ -31966,4 +32003,4 @@ declare class ComposioNoAPIKeyError extends ComposioError {
|
|
|
31966
32003
|
constructor(message?: string, options?: Omit<ComposioErrorOptions, 'code' | 'statusCode'>);
|
|
31967
32004
|
}
|
|
31968
32005
|
|
|
31969
|
-
export { type AgenticToolOptions, AuthConfigErrorCodes, type AuthConfigType, AuthConfigTypes, type AuthSchemeType, AuthSchemeTypes, BaseAgenticProvider, type BaseComposioProvider, BaseNonAgenticProvider, BaseTelemetryTransport, Composio, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomToolsNotInitializedError, ComposioError, type ComposioErrorOptions, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ConnectedAccountErrorCodes, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConsoleTelemetryTransport, type ErrorHandleOptions, type ExecuteMetadata, type ExecuteToolFn, type ExecuteToolFnOptions, type ExecuteToolModifiers, OpenAIProvider, type Provider, SDKErrorCodes, type Tool, ToolErrorCodes, type ToolExecuteParams, type ToolListParams, ToolListParamsSchema, type ToolOptions, ToolkitErrorCodes, type TransformToolSchemaModifier, ValidationError, ValidationErrorCodes, type afterExecuteModifier, type beforeExecuteModifier, jsonSchemaToZodSchema, logger };
|
|
32006
|
+
export { type AgenticToolOptions, AuthConfigErrorCodes, type AuthConfigType, AuthConfigTypes, type AuthSchemeType, AuthSchemeTypes, BaseAgenticProvider, type BaseComposioProvider, BaseNonAgenticProvider, BaseTelemetryTransport, Composio, ComposioAuthConfigNotFoundError, ComposioConnectedAccountNotFoundError, ComposioCustomToolsNotInitializedError, ComposioError, type ComposioErrorOptions, ComposioGlobalExecuteToolFnNotSetError, ComposioInvalidExecuteFunctionError, ComposioInvalidModifierError, ComposioNoAPIKeyError, ComposioProvider, ComposioProviderNotDefinedError, ComposioToolExecutionError, ComposioToolNotFoundError, ComposioToolkitFetchError, ComposioToolkitNotFoundError, ConnectedAccountErrorCodes, ConnectionRequestErrorCodes, ConnectionRequestFailedError, ConnectionRequestTimeoutError, ConsoleTelemetryTransport, type ErrorHandleOptions, type ExecuteMetadata, type ExecuteToolFn, type ExecuteToolFnOptions, type ExecuteToolModifiers, JsonSchemaToZodError, OpenAIProvider, type Provider, SDKErrorCodes, type Tool, ToolErrorCodes, type ToolExecuteParams, type ToolListParams, ToolListParamsSchema, type ToolOptions, ToolkitErrorCodes, type TransformToolSchemaModifier, ValidationError, ValidationErrorCodes, type afterExecuteModifier, type beforeExecuteModifier, jsonSchemaToZodSchema, logger };
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var ParametersSchema = z.object({
|
|
|
39
39
|
required: z.array(z.string()).optional(),
|
|
40
40
|
title: z.string().optional(),
|
|
41
41
|
description: z.string().optional(),
|
|
42
|
-
additionalProperties: z.boolean().optional()
|
|
42
|
+
additionalProperties: z.boolean().default(false).optional()
|
|
43
43
|
});
|
|
44
44
|
var ToolSchema = z.object({
|
|
45
45
|
slug: z.string().describe('The slug of the tool. eg. "GOOGLE_SEARCH"'),
|
|
@@ -64,13 +64,19 @@ var ToolListFilterByToolkitsSchema = z.object({
|
|
|
64
64
|
important: z.boolean().optional(),
|
|
65
65
|
cursor: z.string().optional(),
|
|
66
66
|
limit: z.number().optional(),
|
|
67
|
-
search: z.string().optional()
|
|
67
|
+
search: z.string().optional(),
|
|
68
|
+
strict: z.boolean().optional().describe(
|
|
69
|
+
"If true, all the non-required fields will be removed from the input/output params of the tool"
|
|
70
|
+
)
|
|
68
71
|
});
|
|
69
72
|
var ToolListFilterBySearchSchema = z.object({
|
|
70
73
|
search: z.string(),
|
|
71
74
|
toolkits: z.array(z.string()).optional(),
|
|
72
75
|
cursor: z.string().optional(),
|
|
73
|
-
limit: z.number().optional()
|
|
76
|
+
limit: z.number().optional(),
|
|
77
|
+
strict: z.boolean().optional().describe(
|
|
78
|
+
"If true, all the non-required fields will be removed from the input/output params of the tool"
|
|
79
|
+
)
|
|
74
80
|
});
|
|
75
81
|
var ToolListParamsSchema = z.union([
|
|
76
82
|
ToolListFilterByToolsSchema,
|
|
@@ -1466,7 +1472,8 @@ var ComposioToolkitFetchError = class extends ComposioError {
|
|
|
1466
1472
|
// src/errors/ValidationErrors.ts
|
|
1467
1473
|
import { ZodError as ZodError2 } from "zod";
|
|
1468
1474
|
var ValidationErrorCodes = {
|
|
1469
|
-
VALIDATION_ERROR: "VALIDATION_ERROR"
|
|
1475
|
+
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
1476
|
+
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
|
|
1470
1477
|
};
|
|
1471
1478
|
var ValidationError = class extends ComposioError {
|
|
1472
1479
|
constructor(message = "Input validation failed", options = {}) {
|
|
@@ -1509,6 +1516,14 @@ var ValidationError = class extends ComposioError {
|
|
|
1509
1516
|
return "Please check your input parameters";
|
|
1510
1517
|
}
|
|
1511
1518
|
};
|
|
1519
|
+
var JsonSchemaToZodError = class extends ComposioError {
|
|
1520
|
+
constructor(message = "Failed to convert JSON schema to Zod schema", options = {}) {
|
|
1521
|
+
super(message, {
|
|
1522
|
+
...options,
|
|
1523
|
+
code: options.code || ValidationErrorCodes.JSON_SCHEMA_TO_ZOD_ERROR
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1512
1527
|
|
|
1513
1528
|
// src/errors/SDKErrors.ts
|
|
1514
1529
|
var SDKErrorCodes = {
|
|
@@ -1817,6 +1832,36 @@ var CustomTools = class {
|
|
|
1817
1832
|
}
|
|
1818
1833
|
};
|
|
1819
1834
|
|
|
1835
|
+
// src/utils/jsonSchema.ts
|
|
1836
|
+
import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
|
|
1837
|
+
var removeNonRequiredProperties = (schema) => {
|
|
1838
|
+
if (schema && schema.type === "object" && schema.required?.length) {
|
|
1839
|
+
schema.properties = Object.fromEntries(
|
|
1840
|
+
Object.entries(schema.properties || {}).filter(
|
|
1841
|
+
([key]) => schema.required.includes(key)
|
|
1842
|
+
)
|
|
1843
|
+
);
|
|
1844
|
+
}
|
|
1845
|
+
return schema;
|
|
1846
|
+
};
|
|
1847
|
+
function jsonSchemaToZodSchema(jsonSchema, { strict } = {
|
|
1848
|
+
strict: false
|
|
1849
|
+
}) {
|
|
1850
|
+
try {
|
|
1851
|
+
let schema = jsonSchema;
|
|
1852
|
+
if (strict && schema) {
|
|
1853
|
+
schema = removeNonRequiredProperties(
|
|
1854
|
+
schema
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
return jsonSchemaToZod(schema);
|
|
1858
|
+
} catch (error) {
|
|
1859
|
+
throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", {
|
|
1860
|
+
cause: error
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1820
1865
|
// src/models/Tools.ts
|
|
1821
1866
|
var Tools = class {
|
|
1822
1867
|
client;
|
|
@@ -2077,7 +2122,14 @@ var Tools = class {
|
|
|
2077
2122
|
const tool = await this.getRawComposioToolBySlug(userId, arg2, options?.modifySchema);
|
|
2078
2123
|
return this.provider.wrapTools([tool], executeToolFn);
|
|
2079
2124
|
} else {
|
|
2080
|
-
|
|
2125
|
+
let tools = await this.getRawComposioTools(userId, arg2, options?.modifySchema);
|
|
2126
|
+
if (arg2?.strict) {
|
|
2127
|
+
tools = tools.map((tool) => ({
|
|
2128
|
+
...tool,
|
|
2129
|
+
inputParameters: tool.inputParameters ? removeNonRequiredProperties(tool.inputParameters) : void 0,
|
|
2130
|
+
outputParameters: tool.outputParameters ? removeNonRequiredProperties(tool.outputParameters) : void 0
|
|
2131
|
+
}));
|
|
2132
|
+
}
|
|
2081
2133
|
return this.provider.wrapTools(tools, executeToolFn);
|
|
2082
2134
|
}
|
|
2083
2135
|
}
|
|
@@ -4641,7 +4693,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
4641
4693
|
};
|
|
4642
4694
|
|
|
4643
4695
|
// package.json
|
|
4644
|
-
var version = "0.1.
|
|
4696
|
+
var version = "0.1.15";
|
|
4645
4697
|
|
|
4646
4698
|
// src/composio.ts
|
|
4647
4699
|
var Composio = class _Composio {
|
|
@@ -4819,115 +4871,6 @@ var ConsoleTelemetryTransport = class {
|
|
|
4819
4871
|
return Promise.resolve();
|
|
4820
4872
|
}
|
|
4821
4873
|
};
|
|
4822
|
-
|
|
4823
|
-
// src/utils/jsonSchema.ts
|
|
4824
|
-
import { z as z8 } from "zod";
|
|
4825
|
-
function jsonSchemaPropertiesToTSTypes(value) {
|
|
4826
|
-
if (!value.type) {
|
|
4827
|
-
return z8.object({});
|
|
4828
|
-
}
|
|
4829
|
-
let zodType;
|
|
4830
|
-
switch (value.type) {
|
|
4831
|
-
case "string":
|
|
4832
|
-
zodType = z8.string().describe(
|
|
4833
|
-
(value.description || "") + (value.examples ? `
|
|
4834
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4835
|
-
);
|
|
4836
|
-
break;
|
|
4837
|
-
case "number":
|
|
4838
|
-
zodType = z8.number().describe(
|
|
4839
|
-
(value.description || "") + (value.examples ? `
|
|
4840
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4841
|
-
);
|
|
4842
|
-
break;
|
|
4843
|
-
case "integer":
|
|
4844
|
-
zodType = z8.number().int().describe(
|
|
4845
|
-
(value.description || "") + (value.examples ? `
|
|
4846
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4847
|
-
);
|
|
4848
|
-
break;
|
|
4849
|
-
case "boolean":
|
|
4850
|
-
zodType = z8.boolean().describe(
|
|
4851
|
-
(value.description || "") + (value.examples ? `
|
|
4852
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4853
|
-
);
|
|
4854
|
-
break;
|
|
4855
|
-
case "array":
|
|
4856
|
-
zodType = z8.array(
|
|
4857
|
-
jsonSchemaPropertiesToTSTypes(
|
|
4858
|
-
value.items
|
|
4859
|
-
)
|
|
4860
|
-
).describe(
|
|
4861
|
-
(value.description || "") + (value.examples ? `
|
|
4862
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4863
|
-
);
|
|
4864
|
-
break;
|
|
4865
|
-
case "object":
|
|
4866
|
-
zodType = jsonSchemaToZodSchema(value).describe(
|
|
4867
|
-
(value.description || "") + (value.examples ? `
|
|
4868
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4869
|
-
);
|
|
4870
|
-
break;
|
|
4871
|
-
case "null":
|
|
4872
|
-
zodType = z8.null().describe(value.description || "");
|
|
4873
|
-
break;
|
|
4874
|
-
default:
|
|
4875
|
-
throw new Error(`Unsupported JSON schema type: ${value.type}`);
|
|
4876
|
-
}
|
|
4877
|
-
return zodType;
|
|
4878
|
-
}
|
|
4879
|
-
function jsonSchemaToZodSchema(jsonSchema) {
|
|
4880
|
-
const properties = jsonSchema.properties;
|
|
4881
|
-
const requiredFields = jsonSchema.required || [];
|
|
4882
|
-
if (!properties) {
|
|
4883
|
-
return z8.object({});
|
|
4884
|
-
}
|
|
4885
|
-
const zodSchema = {};
|
|
4886
|
-
for (const [key, _] of Object.entries(properties)) {
|
|
4887
|
-
const value = _;
|
|
4888
|
-
let zodType;
|
|
4889
|
-
if (value.anyOf) {
|
|
4890
|
-
const anyOfTypes = value.anyOf.map(
|
|
4891
|
-
(schema) => jsonSchemaPropertiesToTSTypes(
|
|
4892
|
-
schema
|
|
4893
|
-
)
|
|
4894
|
-
);
|
|
4895
|
-
zodType = z8.union(anyOfTypes).describe(
|
|
4896
|
-
(value.description || "") + (value.examples ? `
|
|
4897
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4898
|
-
);
|
|
4899
|
-
} else if (value.allOf) {
|
|
4900
|
-
const allOfTypes = value.allOf.map(
|
|
4901
|
-
(schema) => jsonSchemaPropertiesToTSTypes(
|
|
4902
|
-
schema
|
|
4903
|
-
)
|
|
4904
|
-
);
|
|
4905
|
-
zodType = z8.intersection(
|
|
4906
|
-
allOfTypes[0],
|
|
4907
|
-
allOfTypes.slice(1).reduce((acc, schema) => acc.and(schema), allOfTypes[0])
|
|
4908
|
-
).describe(
|
|
4909
|
-
(value.description || "") + (value.examples ? `
|
|
4910
|
-
Examples: ${value.examples.join(", ")}` : "")
|
|
4911
|
-
);
|
|
4912
|
-
} else {
|
|
4913
|
-
if (!value.type) {
|
|
4914
|
-
value.type = "string";
|
|
4915
|
-
}
|
|
4916
|
-
zodType = jsonSchemaPropertiesToTSTypes(
|
|
4917
|
-
value
|
|
4918
|
-
);
|
|
4919
|
-
}
|
|
4920
|
-
if (value.description) {
|
|
4921
|
-
zodType = zodType.describe(value.description);
|
|
4922
|
-
}
|
|
4923
|
-
if (requiredFields.includes(key)) {
|
|
4924
|
-
zodSchema[key] = zodType;
|
|
4925
|
-
} else {
|
|
4926
|
-
zodSchema[key] = zodType.optional();
|
|
4927
|
-
}
|
|
4928
|
-
}
|
|
4929
|
-
return z8.object(zodSchema);
|
|
4930
|
-
}
|
|
4931
4874
|
export {
|
|
4932
4875
|
AuthConfigErrorCodes,
|
|
4933
4876
|
AuthConfigTypes,
|
|
@@ -4955,6 +4898,7 @@ export {
|
|
|
4955
4898
|
ConnectionRequestFailedError,
|
|
4956
4899
|
ConnectionRequestTimeoutError,
|
|
4957
4900
|
ConsoleTelemetryTransport,
|
|
4901
|
+
JsonSchemaToZodError,
|
|
4958
4902
|
OpenAIProvider,
|
|
4959
4903
|
SDKErrorCodes,
|
|
4960
4904
|
ToolErrorCodes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,10 +26,12 @@
|
|
|
26
26
|
"tsup": "^8.4.0",
|
|
27
27
|
"tsx": "^4.19.3",
|
|
28
28
|
"typescript": "^5.8.3",
|
|
29
|
-
"vitest": "^3.1.4"
|
|
29
|
+
"vitest": "^3.1.4",
|
|
30
|
+
"@composio/json-schema-to-zod": "0.1.1"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"@composio/client": "0.1.0-alpha.16",
|
|
34
|
+
"@composio/json-schema-to-zod": "0.1.1",
|
|
33
35
|
"chalk": "^5.4.1",
|
|
34
36
|
"openai": "^4.94.0",
|
|
35
37
|
"pusher-js": "^8.4.0",
|