@composio/mastra 0.10.1 → 0.10.2

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.
Files changed (2) hide show
  1. package/README.md +34 -90
  2. package/package.json +7 -6
package/README.md CHANGED
@@ -1,121 +1,65 @@
1
1
  # @composio/mastra
2
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
3
+ The Mastra provider turns Composio tools into Mastra's tool format with built-in execution, ready to pass to a Mastra `Agent`.
13
4
 
14
5
  ## Installation
15
6
 
16
7
  ```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
8
+ npm install @composio/core @composio/mastra @mastra/core @ai-sdk/openai
22
9
  ```
23
10
 
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
11
+ Set `COMPOSIO_API_KEY` with your API key from [the dashboard](https://dashboard.composio.dev/settings), and `OPENAI_API_KEY` (or your LLM provider's key).
30
12
 
31
- Optional environment variables:
13
+ ## Quickstart
32
14
 
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
15
+ Create a session for your user, fetch its tools, and hand them to an agent:
37
16
 
38
17
  ```typescript
39
18
  import { Composio } from '@composio/core';
40
19
  import { MastraProvider } from '@composio/mastra';
20
+ import { Agent } from '@mastra/core/agent';
21
+ import { openai } from '@ai-sdk/openai';
41
22
 
42
- // Initialize Composio with Mastra provider
43
23
  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,
24
+ provider: new MastraProvider(),
54
25
  });
55
- ```
56
26
 
57
- ## Examples
27
+ // Create a session for your user
28
+ const session = await composio.create('user_123');
29
+ const tools = await session.tools();
58
30
 
59
- Check out our complete example implementations:
60
-
61
- - [Basic Mastra Integration](../../examples/mastra/src/index.ts)
62
-
63
- ## API Reference
64
-
65
- ### MastraProvider Class
66
-
67
- The `MastraProvider` class extends `BaseAgenticProvider` and provides Mastra-specific functionality.
68
-
69
- #### Constructor
70
-
71
- ```typescript
72
- new MastraProvider(options?: MastraProviderOptions)
73
- ```
74
-
75
- Options:
76
-
77
- - `apiKey`: Your Mastra API key
78
- - `apiUrl`: Custom API base URL
79
- - `debug`: Enable debug logging
80
- - `modifiers`: Custom execution modifiers
81
- - `executionStrategy`: Custom tool execution strategy
82
-
83
- #### Methods
84
-
85
- ##### `wrapTool(tool: Tool, executeTool: ExecuteToolFn): MastraTool`
31
+ const agent = new Agent({
32
+ id: 'my-agent',
33
+ name: 'My Agent',
34
+ instructions: 'You are a helpful assistant.',
35
+ model: openai('gpt-5.2'),
36
+ tools,
37
+ });
86
38
 
87
- Wraps a tool in the Mastra format.
39
+ const { text } = await agent.generate([
40
+ {
41
+ role: 'user',
42
+ content:
43
+ "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'",
44
+ },
45
+ ]);
88
46
 
89
- ```typescript
90
- const tool = provider.wrapTool(composioTool, executeTool);
47
+ console.log(text);
91
48
  ```
92
49
 
93
- ##### `wrapTools(tools: Tool[], executeTool: ExecuteToolFn): MastraToolCollection`
50
+ Each tool gets both an input and an output schema, so Mastra can validate tool results as well as arguments.
94
51
 
95
- Wraps multiple tools in the Mastra format.
52
+ ## Strict mode
96
53
 
97
- ```typescript
98
- const tools = provider.wrapTools(composioTools, executeTool);
99
- ```
100
-
101
- ##### `executeToolCall(userId: string, toolCall: MastraToolCall, options?: ExecuteToolFnOptions): Promise<string>`
102
-
103
- Executes a tool call from Mastra and returns the result.
54
+ Pass `strict: true` to drop every non-required property from each tool's input schema before Mastra compiles it:
104
55
 
105
56
  ```typescript
106
- const result = await provider.executeToolCall('user123', toolCall, {
107
- connectedAccountId: 'account123',
57
+ const composio = new Composio({
58
+ provider: new MastraProvider({ strict: true }),
108
59
  });
109
60
  ```
110
61
 
111
- ## Contributing
112
-
113
- We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
114
-
115
- ## License
116
-
117
- ISC License
118
-
119
- ## Support
62
+ ## Links
120
63
 
121
- For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
64
+ - [Mastra provider docs](https://docs.composio.dev/docs/providers/mastra)
65
+ - [Composio documentation](https://docs.composio.dev)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/mastra",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "Agentic Provider for mastra in Composio SDK",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",
@@ -12,7 +12,7 @@
12
12
  "bugs": {
13
13
  "url": "https://github.com/ComposioHQ/composio/issues"
14
14
  },
15
- "homepage": "https://github.com/ComposioHQ/composio/tree/main/ts/packages/providers/mastra#readme",
15
+ "homepage": "https://github.com/ComposioHQ/composio/tree/next/ts/packages/providers/mastra#readme",
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },
@@ -39,15 +39,16 @@
39
39
  "zod": "^3.25 || ^4"
40
40
  },
41
41
  "devDependencies": {
42
- "@mastra/core": "^1.46.0",
42
+ "@mastra/core": "^1.50.1",
43
+ "ai": "^6.0.219",
43
44
  "tsdown": "^0.22.3",
44
45
  "typescript": "^6.0.3",
45
- "vitest": "^4.1.9",
46
+ "vitest": "^4.1.10",
46
47
  "zod": "^4.4.3",
47
- "@composio/core": "0.13.1"
48
+ "@composio/core": "0.14.0"
48
49
  },
49
50
  "dependencies": {
50
- "@mastra/schema-compat": "^1.2.9"
51
+ "@mastra/schema-compat": "^1.3.3"
51
52
  },
52
53
  "scripts": {
53
54
  "clean": "git clean -xdf node_modules",