@composio/core 0.1.13 → 0.1.14
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 +21 -107
- package/dist/index.d.cts +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.js +20 -107
- 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"'),
|
|
@@ -1529,7 +1530,8 @@ var ComposioToolkitFetchError = class extends ComposioError {
|
|
|
1529
1530
|
// src/errors/ValidationErrors.ts
|
|
1530
1531
|
var import_zod5 = require("zod");
|
|
1531
1532
|
var ValidationErrorCodes = {
|
|
1532
|
-
VALIDATION_ERROR: "VALIDATION_ERROR"
|
|
1533
|
+
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
1534
|
+
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
|
|
1533
1535
|
};
|
|
1534
1536
|
var ValidationError = class extends ComposioError {
|
|
1535
1537
|
constructor(message = "Input validation failed", options = {}) {
|
|
@@ -1572,6 +1574,14 @@ var ValidationError = class extends ComposioError {
|
|
|
1572
1574
|
return "Please check your input parameters";
|
|
1573
1575
|
}
|
|
1574
1576
|
};
|
|
1577
|
+
var JsonSchemaToZodError = class extends ComposioError {
|
|
1578
|
+
constructor(message = "Failed to convert JSON schema to Zod schema", options = {}) {
|
|
1579
|
+
super(message, {
|
|
1580
|
+
...options,
|
|
1581
|
+
code: options.code || ValidationErrorCodes.JSON_SCHEMA_TO_ZOD_ERROR
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1575
1585
|
|
|
1576
1586
|
// src/errors/SDKErrors.ts
|
|
1577
1587
|
var SDKErrorCodes = {
|
|
@@ -4704,7 +4714,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
4704
4714
|
};
|
|
4705
4715
|
|
|
4706
4716
|
// package.json
|
|
4707
|
-
var version = "0.1.
|
|
4717
|
+
var version = "0.1.14";
|
|
4708
4718
|
|
|
4709
4719
|
// src/composio.ts
|
|
4710
4720
|
var Composio = class _Composio {
|
|
@@ -4884,112 +4894,15 @@ var ConsoleTelemetryTransport = class {
|
|
|
4884
4894
|
};
|
|
4885
4895
|
|
|
4886
4896
|
// src/utils/jsonSchema.ts
|
|
4887
|
-
var
|
|
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
|
-
}
|
|
4897
|
+
var import_json_schema_to_zod = require("@composio/json-schema-to-zod");
|
|
4942
4898
|
function jsonSchemaToZodSchema(jsonSchema) {
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
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
|
-
}
|
|
4899
|
+
try {
|
|
4900
|
+
return (0, import_json_schema_to_zod.jsonSchemaToZod)(jsonSchema);
|
|
4901
|
+
} catch (error) {
|
|
4902
|
+
throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", {
|
|
4903
|
+
cause: error
|
|
4904
|
+
});
|
|
4991
4905
|
}
|
|
4992
|
-
return import_zod10.z.object(zodSchema);
|
|
4993
4906
|
}
|
|
4994
4907
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4995
4908
|
0 && (module.exports = {
|
|
@@ -5019,6 +4932,7 @@ Examples: ${value.examples.join(", ")}` : "")
|
|
|
5019
4932
|
ConnectionRequestFailedError,
|
|
5020
4933
|
ConnectionRequestTimeoutError,
|
|
5021
4934
|
ConsoleTelemetryTransport,
|
|
4935
|
+
JsonSchemaToZodError,
|
|
5022
4936
|
OpenAIProvider,
|
|
5023
4937
|
SDKErrorCodes,
|
|
5024
4938
|
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>;
|
|
@@ -560,7 +560,7 @@ type BaseComposioProvider<TToolCollection, TTool> = BaseNonAgenticProvider<TTool
|
|
|
560
560
|
* };
|
|
561
561
|
* ```
|
|
562
562
|
*/
|
|
563
|
-
type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => Promise<ToolExecuteParams
|
|
563
|
+
type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => Promise<ToolExecuteParams> | ToolExecuteParams;
|
|
564
564
|
/**
|
|
565
565
|
* Modifier for altering the tool execution response after execution completes.
|
|
566
566
|
*
|
|
@@ -611,7 +611,7 @@ type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecute
|
|
|
611
611
|
* };
|
|
612
612
|
* ```
|
|
613
613
|
*/
|
|
614
|
-
type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => Promise<ToolExecuteResponse
|
|
614
|
+
type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => Promise<ToolExecuteResponse> | ToolExecuteResponse;
|
|
615
615
|
/**
|
|
616
616
|
* Modifier for altering the tool schema before it's exposed to consumers.
|
|
617
617
|
*
|
|
@@ -802,7 +802,7 @@ type AgenticToolOptions = ToolOptions & ExecuteToolModifiers;
|
|
|
802
802
|
* });
|
|
803
803
|
* ```
|
|
804
804
|
*/
|
|
805
|
-
type ProviderOptions<
|
|
805
|
+
type ProviderOptions<TProvider> = TProvider extends BaseComposioProvider<infer TToolCollection, infer TTool> ? TProvider extends BaseAgenticProvider<TToolCollection, TTool> ? AgenticToolOptions : ToolOptions : never;
|
|
806
806
|
|
|
807
807
|
/**
|
|
808
808
|
* This class is used to manage tools in the Composio SDK.
|
|
@@ -31731,6 +31731,8 @@ declare class ComposioProvider extends BaseNonAgenticProvider<Array<CustomTool>,
|
|
|
31731
31731
|
* @param jsonSchema - The JSON schema to convert
|
|
31732
31732
|
* @returns The Zod schema
|
|
31733
31733
|
*
|
|
31734
|
+
* @throws {JsonSchemaToZodError} If the JSON schema is invalid
|
|
31735
|
+
*
|
|
31734
31736
|
* @example
|
|
31735
31737
|
* ```ts
|
|
31736
31738
|
* const zodSchema = jsonSchemaToZodSchema({
|
|
@@ -31953,11 +31955,15 @@ declare class ComposioToolkitFetchError extends ComposioError {
|
|
|
31953
31955
|
*/
|
|
31954
31956
|
declare const ValidationErrorCodes: {
|
|
31955
31957
|
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
31958
|
+
readonly JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR";
|
|
31956
31959
|
};
|
|
31957
31960
|
declare class ValidationError extends ComposioError {
|
|
31958
31961
|
constructor(message?: string, options?: ComposioErrorOptions);
|
|
31959
31962
|
private generateUserFriendlyMessage;
|
|
31960
31963
|
}
|
|
31964
|
+
declare class JsonSchemaToZodError extends ComposioError {
|
|
31965
|
+
constructor(message?: string, options?: ComposioErrorOptions);
|
|
31966
|
+
}
|
|
31961
31967
|
|
|
31962
31968
|
declare const SDKErrorCodes: {
|
|
31963
31969
|
NO_API_KEY_PROVIDED: string;
|
|
@@ -31966,4 +31972,4 @@ declare class ComposioNoAPIKeyError extends ComposioError {
|
|
|
31966
31972
|
constructor(message?: string, options?: Omit<ComposioErrorOptions, 'code' | 'statusCode'>);
|
|
31967
31973
|
}
|
|
31968
31974
|
|
|
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 };
|
|
31975
|
+
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>;
|
|
@@ -560,7 +560,7 @@ type BaseComposioProvider<TToolCollection, TTool> = BaseNonAgenticProvider<TTool
|
|
|
560
560
|
* };
|
|
561
561
|
* ```
|
|
562
562
|
*/
|
|
563
|
-
type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => Promise<ToolExecuteParams
|
|
563
|
+
type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => Promise<ToolExecuteParams> | ToolExecuteParams;
|
|
564
564
|
/**
|
|
565
565
|
* Modifier for altering the tool execution response after execution completes.
|
|
566
566
|
*
|
|
@@ -611,7 +611,7 @@ type beforeExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecute
|
|
|
611
611
|
* };
|
|
612
612
|
* ```
|
|
613
613
|
*/
|
|
614
|
-
type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => Promise<ToolExecuteResponse
|
|
614
|
+
type afterExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => Promise<ToolExecuteResponse> | ToolExecuteResponse;
|
|
615
615
|
/**
|
|
616
616
|
* Modifier for altering the tool schema before it's exposed to consumers.
|
|
617
617
|
*
|
|
@@ -802,7 +802,7 @@ type AgenticToolOptions = ToolOptions & ExecuteToolModifiers;
|
|
|
802
802
|
* });
|
|
803
803
|
* ```
|
|
804
804
|
*/
|
|
805
|
-
type ProviderOptions<
|
|
805
|
+
type ProviderOptions<TProvider> = TProvider extends BaseComposioProvider<infer TToolCollection, infer TTool> ? TProvider extends BaseAgenticProvider<TToolCollection, TTool> ? AgenticToolOptions : ToolOptions : never;
|
|
806
806
|
|
|
807
807
|
/**
|
|
808
808
|
* This class is used to manage tools in the Composio SDK.
|
|
@@ -31731,6 +31731,8 @@ declare class ComposioProvider extends BaseNonAgenticProvider<Array<CustomTool>,
|
|
|
31731
31731
|
* @param jsonSchema - The JSON schema to convert
|
|
31732
31732
|
* @returns The Zod schema
|
|
31733
31733
|
*
|
|
31734
|
+
* @throws {JsonSchemaToZodError} If the JSON schema is invalid
|
|
31735
|
+
*
|
|
31734
31736
|
* @example
|
|
31735
31737
|
* ```ts
|
|
31736
31738
|
* const zodSchema = jsonSchemaToZodSchema({
|
|
@@ -31953,11 +31955,15 @@ declare class ComposioToolkitFetchError extends ComposioError {
|
|
|
31953
31955
|
*/
|
|
31954
31956
|
declare const ValidationErrorCodes: {
|
|
31955
31957
|
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
31958
|
+
readonly JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR";
|
|
31956
31959
|
};
|
|
31957
31960
|
declare class ValidationError extends ComposioError {
|
|
31958
31961
|
constructor(message?: string, options?: ComposioErrorOptions);
|
|
31959
31962
|
private generateUserFriendlyMessage;
|
|
31960
31963
|
}
|
|
31964
|
+
declare class JsonSchemaToZodError extends ComposioError {
|
|
31965
|
+
constructor(message?: string, options?: ComposioErrorOptions);
|
|
31966
|
+
}
|
|
31961
31967
|
|
|
31962
31968
|
declare const SDKErrorCodes: {
|
|
31963
31969
|
NO_API_KEY_PROVIDED: string;
|
|
@@ -31966,4 +31972,4 @@ declare class ComposioNoAPIKeyError extends ComposioError {
|
|
|
31966
31972
|
constructor(message?: string, options?: Omit<ComposioErrorOptions, 'code' | 'statusCode'>);
|
|
31967
31973
|
}
|
|
31968
31974
|
|
|
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 };
|
|
31975
|
+
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"'),
|
|
@@ -1466,7 +1466,8 @@ var ComposioToolkitFetchError = class extends ComposioError {
|
|
|
1466
1466
|
// src/errors/ValidationErrors.ts
|
|
1467
1467
|
import { ZodError as ZodError2 } from "zod";
|
|
1468
1468
|
var ValidationErrorCodes = {
|
|
1469
|
-
VALIDATION_ERROR: "VALIDATION_ERROR"
|
|
1469
|
+
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
1470
|
+
JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
|
|
1470
1471
|
};
|
|
1471
1472
|
var ValidationError = class extends ComposioError {
|
|
1472
1473
|
constructor(message = "Input validation failed", options = {}) {
|
|
@@ -1509,6 +1510,14 @@ var ValidationError = class extends ComposioError {
|
|
|
1509
1510
|
return "Please check your input parameters";
|
|
1510
1511
|
}
|
|
1511
1512
|
};
|
|
1513
|
+
var JsonSchemaToZodError = class extends ComposioError {
|
|
1514
|
+
constructor(message = "Failed to convert JSON schema to Zod schema", options = {}) {
|
|
1515
|
+
super(message, {
|
|
1516
|
+
...options,
|
|
1517
|
+
code: options.code || ValidationErrorCodes.JSON_SCHEMA_TO_ZOD_ERROR
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1512
1521
|
|
|
1513
1522
|
// src/errors/SDKErrors.ts
|
|
1514
1523
|
var SDKErrorCodes = {
|
|
@@ -4641,7 +4650,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
4641
4650
|
};
|
|
4642
4651
|
|
|
4643
4652
|
// package.json
|
|
4644
|
-
var version = "0.1.
|
|
4653
|
+
var version = "0.1.14";
|
|
4645
4654
|
|
|
4646
4655
|
// src/composio.ts
|
|
4647
4656
|
var Composio = class _Composio {
|
|
@@ -4821,112 +4830,15 @@ var ConsoleTelemetryTransport = class {
|
|
|
4821
4830
|
};
|
|
4822
4831
|
|
|
4823
4832
|
// src/utils/jsonSchema.ts
|
|
4824
|
-
import {
|
|
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
|
-
}
|
|
4833
|
+
import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
|
|
4879
4834
|
function jsonSchemaToZodSchema(jsonSchema) {
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
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
|
-
}
|
|
4835
|
+
try {
|
|
4836
|
+
return jsonSchemaToZod(jsonSchema);
|
|
4837
|
+
} catch (error) {
|
|
4838
|
+
throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", {
|
|
4839
|
+
cause: error
|
|
4840
|
+
});
|
|
4928
4841
|
}
|
|
4929
|
-
return z8.object(zodSchema);
|
|
4930
4842
|
}
|
|
4931
4843
|
export {
|
|
4932
4844
|
AuthConfigErrorCodes,
|
|
@@ -4955,6 +4867,7 @@ export {
|
|
|
4955
4867
|
ConnectionRequestFailedError,
|
|
4956
4868
|
ConnectionRequestTimeoutError,
|
|
4957
4869
|
ConsoleTelemetryTransport,
|
|
4870
|
+
JsonSchemaToZodError,
|
|
4958
4871
|
OpenAIProvider,
|
|
4959
4872
|
SDKErrorCodes,
|
|
4960
4873
|
ToolErrorCodes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
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",
|