@composio/mastra 0.1.12-alpha.12

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/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # @composio/mastra
2
+
3
+ Agentic Provider for Mastra in Composio SDK.
4
+
5
+ ## Features
6
+
7
+ - **Full Modifier Support**: Support for both schema and execution modifiers
8
+ - **Tool Execution**: Execute tools with proper parameter handling
9
+ - **Type Safety**: Full TypeScript support with proper type definitions
10
+ - **Agentic Capabilities**: Full support for autonomous agent behavior
11
+ - **Streaming Support**: First-class support for streaming responses
12
+ - **Custom Execution**: Support for custom tool execution strategies
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @composio/core @composio/mastra
18
+ # or
19
+ yarn add @composio/core @composio/mastra
20
+ # or
21
+ pnpm add @composio/core @composio/mastra
22
+ ```
23
+
24
+ ## Environment Variables
25
+
26
+ Required environment variables:
27
+
28
+ - `COMPOSIO_API_KEY`: Your Composio API key
29
+ - `MASTRA_API_KEY`: Your Mastra API key
30
+
31
+ Optional environment variables:
32
+
33
+ - `MASTRA_API_URL`: Custom API base URL (defaults to Mastra's API)
34
+ - `MASTRA_DEBUG`: Enable debug logging (set to "true")
35
+
36
+ ## Quick Start
37
+
38
+ ```typescript
39
+ import { Composio } from '@composio/core';
40
+ import { MastraProvider } from '@composio/mastra';
41
+
42
+ // Initialize Composio with Mastra provider
43
+ const composio = new Composio({
44
+ apiKey: process.env.COMPOSIO_API_KEY,
45
+ provider: new MastraProvider({
46
+ apiKey: process.env.MASTRA_API_KEY,
47
+ }),
48
+ });
49
+
50
+ // Get available tools
51
+ const tools = await composio.tools.get('user123', {
52
+ toolkits: ['gmail', 'googlecalendar'],
53
+ limit: 10,
54
+ });
55
+ ```
56
+
57
+ ## Examples
58
+
59
+ Check out our complete example implementations:
60
+
61
+ - [Basic Mastra Integration](../../examples/mastra/src/index.ts)
62
+
63
+ ## Provider Configuration
64
+
65
+ The Mastra provider can be configured with various options:
66
+
67
+ ```typescript
68
+ const provider = new MastraProvider({
69
+ // API configuration
70
+ apiKey: process.env.MASTRA_API_KEY,
71
+ apiUrl: 'https://custom-api.mastra.ai',
72
+ // Debug mode
73
+ debug: true,
74
+ // Custom execution modifiers
75
+ modifiers: {
76
+ beforeExecute: params => {
77
+ // Transform parameters before execution
78
+ return params;
79
+ },
80
+ afterExecute: response => {
81
+ // Transform response after execution
82
+ return response;
83
+ },
84
+ },
85
+ // Custom tool execution strategy
86
+ executionStrategy: {
87
+ maxRetries: 3,
88
+ retryDelay: 1000,
89
+ timeout: 30000,
90
+ },
91
+ });
92
+ ```
93
+
94
+ ## API Reference
95
+
96
+ ### MastraProvider Class
97
+
98
+ The `MastraProvider` class extends `BaseAgenticProvider` and provides Mastra-specific functionality.
99
+
100
+ #### Constructor
101
+
102
+ ```typescript
103
+ new MastraProvider(options?: MastraProviderOptions)
104
+ ```
105
+
106
+ Options:
107
+
108
+ - `apiKey`: Your Mastra API key
109
+ - `apiUrl`: Custom API base URL
110
+ - `debug`: Enable debug logging
111
+ - `modifiers`: Custom execution modifiers
112
+ - `executionStrategy`: Custom tool execution strategy
113
+
114
+ #### Methods
115
+
116
+ ##### `wrapTool(tool: Tool, executeTool: ExecuteToolFn): MastraTool`
117
+
118
+ Wraps a tool in the Mastra format.
119
+
120
+ ```typescript
121
+ const tool = provider.wrapTool(composioTool, executeTool);
122
+ ```
123
+
124
+ ##### `wrapTools(tools: Tool[], executeTool: ExecuteToolFn): MastraToolCollection`
125
+
126
+ Wraps multiple tools in the Mastra format.
127
+
128
+ ```typescript
129
+ const tools = provider.wrapTools(composioTools, executeTool);
130
+ ```
131
+
132
+ ##### `executeToolCall(userId: string, toolCall: MastraToolCall, options?: ExecuteToolFnOptions): Promise<string>`
133
+
134
+ Executes a tool call from Mastra and returns the result.
135
+
136
+ ```typescript
137
+ const result = await provider.executeToolCall('user123', toolCall, {
138
+ connectedAccountId: 'account123',
139
+ });
140
+ ```
141
+
142
+ ## Contributing
143
+
144
+ We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
145
+
146
+ ## License
147
+
148
+ ISC License
149
+
150
+ ## Support
151
+
152
+ For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
package/dist/index.cjs ADDED
@@ -0,0 +1,53 @@
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);
19
+
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
+ wrapTool(tool, executeTool) {
31
+ const mastraTool = (0, import_core2.createTool)({
32
+ id: tool.slug,
33
+ description: tool.description ?? "",
34
+ inputSchema: tool.inputParameters ? (0, import_core.jsonSchemaToZodSchema)(tool.inputParameters) : void 0,
35
+ outputSchema: tool.outputParameters ? (0, import_core.jsonSchemaToZodSchema)(tool.outputParameters) : void 0,
36
+ execute: async ({ context }) => {
37
+ const result = await executeTool(tool.slug, context);
38
+ return result;
39
+ }
40
+ });
41
+ return mastraTool;
42
+ }
43
+ wrapTools(tools, executeTool) {
44
+ return tools.reduce((acc, tool) => {
45
+ acc[tool.slug] = this.wrapTool(tool, executeTool);
46
+ return acc;
47
+ }, {});
48
+ }
49
+ };
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ MastraProvider
53
+ });
@@ -0,0 +1,23 @@
1
+ import { BaseAgenticProvider, 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
+ declare class MastraProvider extends BaseAgenticProvider<MastraToolCollection, MastraTool> {
18
+ readonly name = "mastra";
19
+ wrapTool(tool: Tool, executeTool: ExecuteToolFn): MastraTool;
20
+ wrapTools(tools: Tool[], executeTool: ExecuteToolFn): MastraToolCollection;
21
+ }
22
+
23
+ export { MastraProvider, type MastraTool, type MastraToolCollection };
@@ -0,0 +1,23 @@
1
+ import { BaseAgenticProvider, 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
+ declare class MastraProvider extends BaseAgenticProvider<MastraToolCollection, MastraTool> {
18
+ readonly name = "mastra";
19
+ wrapTool(tool: Tool, executeTool: ExecuteToolFn): MastraTool;
20
+ wrapTools(tools: Tool[], executeTool: ExecuteToolFn): MastraToolCollection;
21
+ }
22
+
23
+ export { MastraProvider, type MastraTool, type MastraToolCollection };
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ // src/index.ts
2
+ import { BaseAgenticProvider, jsonSchemaToZodSchema } from "@composio/core";
3
+ import { createTool } from "@mastra/core";
4
+ var MastraProvider = class extends BaseAgenticProvider {
5
+ name = "mastra";
6
+ wrapTool(tool, executeTool) {
7
+ const mastraTool = createTool({
8
+ id: tool.slug,
9
+ description: tool.description ?? "",
10
+ inputSchema: tool.inputParameters ? jsonSchemaToZodSchema(tool.inputParameters) : void 0,
11
+ outputSchema: tool.outputParameters ? jsonSchemaToZodSchema(tool.outputParameters) : void 0,
12
+ execute: async ({ context }) => {
13
+ const result = await executeTool(tool.slug, context);
14
+ return result;
15
+ }
16
+ });
17
+ return mastraTool;
18
+ }
19
+ wrapTools(tools, executeTool) {
20
+ return tools.reduce((acc, tool) => {
21
+ acc[tool.slug] = this.wrapTool(tool, executeTool);
22
+ return acc;
23
+ }, {});
24
+ }
25
+ };
26
+ export {
27
+ MastraProvider
28
+ };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@composio/mastra",
3
+ "version": "0.1.12-alpha.12",
4
+ "description": "Agentic Provider for mastra in Composio SDK",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "README.md",
19
+ "dist"
20
+ ],
21
+ "keywords": [
22
+ "composio",
23
+ "provider",
24
+ "mastra"
25
+ ],
26
+ "author": "",
27
+ "license": "ISC",
28
+ "peerDependencies": {
29
+ "@composio/core": "0.1.12-alpha.12",
30
+ "@mastra/core": "^0.10.0"
31
+ },
32
+ "devDependencies": {
33
+ "tsup": "^8.4.0",
34
+ "typescript": "^5.8.3",
35
+ "vitest": "^3.1.4",
36
+ "@composio/core": "0.1.12-alpha.12"
37
+ },
38
+ "scripts": {
39
+ "build": "tsup",
40
+ "test": "vitest run"
41
+ },
42
+ "types": "dist/index.d.ts"
43
+ }