@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 +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.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { BaseAgenticProvider, jsonSchemaToZodSchema, removeNonRequiredProperties } from "@composio/core";
|
|
2
|
+
import { createTool } from "@mastra/core";
|
|
3
|
+
|
|
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 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" ? removeNonRequiredProperties(inputParams) : inputParams ?? {};
|
|
58
|
+
return createTool({
|
|
59
|
+
id: tool.slug,
|
|
60
|
+
description: tool.description ?? "",
|
|
61
|
+
inputSchema: parameters ? jsonSchemaToZodSchema(parameters) : void 0,
|
|
62
|
+
outputSchema: tool.outputParameters ? 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
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
export { MastraProvider };
|
package/package.json
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/mastra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Agentic Provider for mastra in Composio SDK",
|
|
5
|
-
"main": "dist/index.
|
|
6
|
-
"type": "module",
|
|
5
|
+
"main": "dist/index.mjs",
|
|
7
6
|
"publishConfig": {
|
|
8
7
|
"access": "public"
|
|
9
8
|
},
|
|
10
9
|
"exports": {
|
|
11
10
|
".": {
|
|
12
|
-
"import":
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
},
|
|
19
|
+
"default": {
|
|
20
|
+
"types": "./dist/index.d.cts",
|
|
21
|
+
"default": "./dist/index.cjs"
|
|
22
|
+
}
|
|
15
23
|
}
|
|
16
24
|
},
|
|
17
25
|
"files": [
|
|
@@ -26,21 +34,21 @@
|
|
|
26
34
|
"author": "",
|
|
27
35
|
"license": "ISC",
|
|
28
36
|
"peerDependencies": {
|
|
29
|
-
"@composio/core": "0.
|
|
37
|
+
"@composio/core": "0.5.0",
|
|
30
38
|
"@mastra/core": "^0.21.1",
|
|
31
39
|
"@mastra/mcp": "^0.12.0"
|
|
32
40
|
},
|
|
33
41
|
"devDependencies": {
|
|
34
|
-
"
|
|
42
|
+
"tsdown": "^0.18.4",
|
|
35
43
|
"typescript": "^5.9.2",
|
|
36
44
|
"vitest": "^3.1.4",
|
|
37
45
|
"zod": "^4.1.0",
|
|
38
|
-
"@composio/core": "0.
|
|
46
|
+
"@composio/core": "0.5.0"
|
|
39
47
|
},
|
|
40
48
|
"scripts": {
|
|
41
49
|
"clean": "git clean -xdf node_modules",
|
|
42
|
-
"build": "
|
|
50
|
+
"build": "tsdown",
|
|
43
51
|
"test": "vitest run"
|
|
44
52
|
},
|
|
45
|
-
"types": "dist/index.d.
|
|
53
|
+
"types": "dist/index.d.mts"
|
|
46
54
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { BaseAgenticProvider, McpUrlResponse, Tool, ExecuteToolFn } from '@composio/core';
|
|
2
|
-
import { createTool } from '@mastra/core';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Mastra Provider
|
|
6
|
-
*
|
|
7
|
-
* This provider provides a set of tools for interacting with Mastra.ai
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
* @module providers/mastra
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
type MastraTool = ReturnType<typeof createTool>;
|
|
14
|
-
interface MastraToolCollection {
|
|
15
|
-
[key: string]: MastraTool;
|
|
16
|
-
}
|
|
17
|
-
interface MastraUrlMap {
|
|
18
|
-
[name: string]: {
|
|
19
|
-
url: string;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
declare class MastraProvider extends BaseAgenticProvider<MastraToolCollection, MastraTool, MastraUrlMap> {
|
|
23
|
-
readonly name = "mastra";
|
|
24
|
-
private strict;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a new instance of the MastraProvider.
|
|
27
|
-
*
|
|
28
|
-
* This provider enables integration with the Mastra AI SDK,
|
|
29
|
-
* allowing Composio tools to be used with Mastra AI applications.
|
|
30
|
-
*
|
|
31
|
-
* @param param0
|
|
32
|
-
* @param param0.strict - Whether to use strict mode for tool execution
|
|
33
|
-
* @returns A new instance of the MastraProvider
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* import { Composio } from '@composio/core';
|
|
38
|
-
* import { MastraProvider } from '@composio/mastra';
|
|
39
|
-
*
|
|
40
|
-
* const composio = new Composio({
|
|
41
|
-
* apiKey: 'your-composio-api-key',
|
|
42
|
-
* provider: new MastraProvider(),
|
|
43
|
-
* });
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
constructor({ strict }?: {
|
|
47
|
-
strict?: boolean;
|
|
48
|
-
});
|
|
49
|
-
/**
|
|
50
|
-
* Transform MCP URL response into Anthropic-specific format.
|
|
51
|
-
* By default, Anthropic uses the standard format (same as default),
|
|
52
|
-
* but this method is here to show providers can customize if needed.
|
|
53
|
-
*
|
|
54
|
-
* @param data - The MCP URL response data
|
|
55
|
-
* @returns Standard MCP server response format
|
|
56
|
-
*/
|
|
57
|
-
wrapMcpServerResponse(data: McpUrlResponse): MastraUrlMap;
|
|
58
|
-
wrapTool(tool: Tool, executeTool: ExecuteToolFn): MastraTool;
|
|
59
|
-
wrapTools(tools: Tool[], executeTool: ExecuteToolFn): MastraToolCollection;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export { MastraProvider, type MastraTool, type MastraToolCollection, type MastraUrlMap };
|
package/dist/index.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import {
|
|
3
|
-
BaseAgenticProvider,
|
|
4
|
-
jsonSchemaToZodSchema,
|
|
5
|
-
removeNonRequiredProperties
|
|
6
|
-
} from "@composio/core";
|
|
7
|
-
import { createTool } from "@mastra/core";
|
|
8
|
-
var MastraProvider = class extends BaseAgenticProvider {
|
|
9
|
-
name = "mastra";
|
|
10
|
-
strict;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new instance of the MastraProvider.
|
|
13
|
-
*
|
|
14
|
-
* This provider enables integration with the Mastra AI SDK,
|
|
15
|
-
* allowing Composio tools to be used with Mastra AI applications.
|
|
16
|
-
*
|
|
17
|
-
* @param param0
|
|
18
|
-
* @param param0.strict - Whether to use strict mode for tool execution
|
|
19
|
-
* @returns A new instance of the MastraProvider
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* import { Composio } from '@composio/core';
|
|
24
|
-
* import { MastraProvider } from '@composio/mastra';
|
|
25
|
-
*
|
|
26
|
-
* const composio = new Composio({
|
|
27
|
-
* apiKey: 'your-composio-api-key',
|
|
28
|
-
* provider: new MastraProvider(),
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
constructor({ strict = false } = {}) {
|
|
33
|
-
super();
|
|
34
|
-
this.strict = strict;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Transform MCP URL response into Anthropic-specific format.
|
|
38
|
-
* By default, Anthropic uses the standard format (same as default),
|
|
39
|
-
* but this method is here to show providers can customize if needed.
|
|
40
|
-
*
|
|
41
|
-
* @param data - The MCP URL response data
|
|
42
|
-
* @returns Standard MCP server response format
|
|
43
|
-
*/
|
|
44
|
-
wrapMcpServerResponse(data) {
|
|
45
|
-
return data.reduce((acc, item) => {
|
|
46
|
-
acc[item.name] = { url: item.url };
|
|
47
|
-
return acc;
|
|
48
|
-
}, {});
|
|
49
|
-
}
|
|
50
|
-
wrapTool(tool, executeTool) {
|
|
51
|
-
const inputParams = tool.inputParameters;
|
|
52
|
-
const parameters = this.strict && inputParams?.type === "object" ? removeNonRequiredProperties(
|
|
53
|
-
inputParams
|
|
54
|
-
) : inputParams ?? {};
|
|
55
|
-
const mastraTool = createTool({
|
|
56
|
-
id: tool.slug,
|
|
57
|
-
description: tool.description ?? "",
|
|
58
|
-
inputSchema: parameters ? jsonSchemaToZodSchema(parameters) : void 0,
|
|
59
|
-
outputSchema: tool.outputParameters ? jsonSchemaToZodSchema(tool.outputParameters) : void 0,
|
|
60
|
-
execute: async ({ context }) => {
|
|
61
|
-
const result = await executeTool(tool.slug, context);
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return mastraTool;
|
|
66
|
-
}
|
|
67
|
-
wrapTools(tools, executeTool) {
|
|
68
|
-
return tools.reduce((acc, tool) => {
|
|
69
|
-
acc[tool.slug] = this.wrapTool(tool, executeTool);
|
|
70
|
-
return acc;
|
|
71
|
-
}, {});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
export {
|
|
75
|
-
MastraProvider
|
|
76
|
-
};
|