@composio/mastra 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,97 +1,77 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ let _composio_core = require("@composio/core");
2
+ let _mastra_core = require("@mastra/core");
19
3
 
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- MastraProvider: () => MastraProvider
24
- });
25
- module.exports = __toCommonJS(index_exports);
26
- var import_core = require("@composio/core");
27
- var import_core2 = require("@mastra/core");
28
- var MastraProvider = class extends import_core.BaseAgenticProvider {
29
- name = "mastra";
30
- strict;
31
- /**
32
- * Creates a new instance of the MastraProvider.
33
- *
34
- * This provider enables integration with the Mastra AI SDK,
35
- * allowing Composio tools to be used with Mastra AI applications.
36
- *
37
- * @param param0
38
- * @param param0.strict - Whether to use strict mode for tool execution
39
- * @returns A new instance of the MastraProvider
40
- *
41
- * @example
42
- * ```typescript
43
- * import { Composio } from '@composio/core';
44
- * import { MastraProvider } from '@composio/mastra';
45
- *
46
- * const composio = new Composio({
47
- * apiKey: 'your-composio-api-key',
48
- * provider: new MastraProvider(),
49
- * });
50
- * ```
51
- */
52
- constructor({ strict = false } = {}) {
53
- super();
54
- this.strict = strict;
55
- }
56
- /**
57
- * Transform MCP URL response into Anthropic-specific format.
58
- * By default, Anthropic uses the standard format (same as default),
59
- * but this method is here to show providers can customize if needed.
60
- *
61
- * @param data - The MCP URL response data
62
- * @returns Standard MCP server response format
63
- */
64
- wrapMcpServerResponse(data) {
65
- return data.reduce((acc, item) => {
66
- acc[item.name] = { url: item.url };
67
- return acc;
68
- }, {});
69
- }
70
- wrapTool(tool, executeTool) {
71
- const inputParams = tool.inputParameters;
72
- const parameters = this.strict && inputParams?.type === "object" ? (0, import_core.removeNonRequiredProperties)(
73
- inputParams
74
- ) : inputParams ?? {};
75
- const mastraTool = (0, import_core2.createTool)({
76
- id: tool.slug,
77
- description: tool.description ?? "",
78
- inputSchema: parameters ? (0, import_core.jsonSchemaToZodSchema)(parameters) : void 0,
79
- outputSchema: tool.outputParameters ? (0, import_core.jsonSchemaToZodSchema)(tool.outputParameters) : void 0,
80
- execute: async ({ context }) => {
81
- const result = await executeTool(tool.slug, context);
82
- return result;
83
- }
84
- });
85
- return mastraTool;
86
- }
87
- wrapTools(tools, executeTool) {
88
- return tools.reduce((acc, tool) => {
89
- acc[tool.slug] = this.wrapTool(tool, executeTool);
90
- return acc;
91
- }, {});
92
- }
4
+ //#region src/index.ts
5
+ /**
6
+ * Mastra Provider
7
+ *
8
+ * This provider provides a set of tools for interacting with Mastra.ai
9
+ *
10
+ * @packageDocumentation
11
+ * @module providers/mastra
12
+ */
13
+ var MastraProvider = class extends _composio_core.BaseAgenticProvider {
14
+ name = "mastra";
15
+ strict;
16
+ /**
17
+ * Creates a new instance of the MastraProvider.
18
+ *
19
+ * This provider enables integration with the Mastra AI SDK,
20
+ * allowing Composio tools to be used with Mastra AI applications.
21
+ *
22
+ * @param param0
23
+ * @param param0.strict - Whether to use strict mode for tool execution
24
+ * @returns A new instance of the MastraProvider
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * import { Composio } from '@composio/core';
29
+ * import { MastraProvider } from '@composio/mastra';
30
+ *
31
+ * const composio = new Composio({
32
+ * apiKey: 'your-composio-api-key',
33
+ * provider: new MastraProvider(),
34
+ * });
35
+ * ```
36
+ */
37
+ constructor({ strict = false } = {}) {
38
+ super();
39
+ this.strict = strict;
40
+ }
41
+ /**
42
+ * Transform MCP URL response into Anthropic-specific format.
43
+ * By default, Anthropic uses the standard format (same as default),
44
+ * but this method is here to show providers can customize if needed.
45
+ *
46
+ * @param data - The MCP URL response data
47
+ * @returns Standard MCP server response format
48
+ */
49
+ wrapMcpServerResponse(data) {
50
+ return data.reduce((acc, item) => {
51
+ acc[item.name] = { url: item.url };
52
+ return acc;
53
+ }, {});
54
+ }
55
+ wrapTool(tool, executeTool) {
56
+ const inputParams = tool.inputParameters;
57
+ const parameters = this.strict && inputParams?.type === "object" ? (0, _composio_core.removeNonRequiredProperties)(inputParams) : inputParams ?? {};
58
+ return (0, _mastra_core.createTool)({
59
+ id: tool.slug,
60
+ description: tool.description ?? "",
61
+ inputSchema: parameters ? (0, _composio_core.jsonSchemaToZodSchema)(parameters) : void 0,
62
+ outputSchema: tool.outputParameters ? (0, _composio_core.jsonSchemaToZodSchema)(tool.outputParameters) : void 0,
63
+ execute: async ({ context }) => {
64
+ return await executeTool(tool.slug, context);
65
+ }
66
+ });
67
+ }
68
+ wrapTools(tools, executeTool) {
69
+ return tools.reduce((acc, tool) => {
70
+ acc[tool.slug] = this.wrapTool(tool, executeTool);
71
+ return acc;
72
+ }, {});
73
+ }
93
74
  };
94
- // Annotate the CommonJS export names for ESM import in node:
95
- 0 && (module.exports = {
96
- MastraProvider
97
- });
75
+
76
+ //#endregion
77
+ exports.MastraProvider = MastraProvider;