@composio/mastra 0.3.4 → 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 +75 -95
- package/dist/index.d.cts +3201 -49
- package/dist/index.d.mts +3214 -0
- package/dist/index.mjs +77 -0
- package/package.json +19 -11
- package/dist/index.d.ts +0 -62
- package/dist/index.js +0 -76
package/dist/index.cjs
CHANGED
|
@@ -1,97 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
exports.MastraProvider = MastraProvider;
|