@mastra/ai-sdk 0.2.0-alpha.2 → 0.2.1-alpha.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/CHANGELOG.md +38 -0
- package/README.md +65 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
+
## 0.2.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Update README to include more usage examples ([#8817](https://github.com/mastra-ai/mastra/pull/8817))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`ca85c93`](https://github.com/mastra-ai/mastra/commit/ca85c932b232e6ad820c811ec176d98e68c59b0a), [`a1d40f8`](https://github.com/mastra-ai/mastra/commit/a1d40f88d4ce42c4508774ad22e38ac582157af2), [`01c4a25`](https://github.com/mastra-ai/mastra/commit/01c4a2506c514d5e861c004d3d2fb3791c6391f3), [`cce8aad`](https://github.com/mastra-ai/mastra/commit/cce8aad878a0dd98e5647680f3765caba0b1701c)]:
|
|
10
|
+
- @mastra/core@0.21.1-alpha.0
|
|
11
|
+
|
|
12
|
+
## 0.2.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- Update peer dependencies to match core package version bump (0.20.3) ([#8672](https://github.com/mastra-ai/mastra/pull/8672))
|
|
17
|
+
|
|
18
|
+
- Update peer dependencies to match core package version bump (0.20.3) ([#8614](https://github.com/mastra-ai/mastra/pull/8614))
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- pass runtimeContext to agent stream options in chatRoute ([#8641](https://github.com/mastra-ai/mastra/pull/8641))
|
|
23
|
+
|
|
24
|
+
- Update peer dependencies to match core package version bump (0.21.0) ([#8619](https://github.com/mastra-ai/mastra/pull/8619))
|
|
25
|
+
|
|
26
|
+
- Improve types for networkRoute and workflowRoute functions ([#8844](https://github.com/mastra-ai/mastra/pull/8844))
|
|
27
|
+
|
|
28
|
+
- ai-sdk workflow route, agent network route ([#8672](https://github.com/mastra-ai/mastra/pull/8672))
|
|
29
|
+
|
|
30
|
+
- Update peer dependencies to match core package version bump (0.21.0) ([#8557](https://github.com/mastra-ai/mastra/pull/8557))
|
|
31
|
+
|
|
32
|
+
- Update peer dependencies to match core package version bump (0.21.0) ([#8626](https://github.com/mastra-ai/mastra/pull/8626))
|
|
33
|
+
|
|
34
|
+
- Update peer dependencies to match core package version bump (0.21.0) ([#8686](https://github.com/mastra-ai/mastra/pull/8686))
|
|
35
|
+
|
|
36
|
+
- nested ai-sdk workflows and networks streaming support ([#8614](https://github.com/mastra-ai/mastra/pull/8614))
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [[`1ed9670`](https://github.com/mastra-ai/mastra/commit/1ed9670d3ca50cb60dc2e517738c5eef3968ed27), [`b5a66b7`](https://github.com/mastra-ai/mastra/commit/b5a66b748a14fc8b3f63b04642ddb9621fbcc9e0), [`f59fc1e`](https://github.com/mastra-ai/mastra/commit/f59fc1e406b8912e692f6bff6cfd4754cc8d165c), [`158381d`](https://github.com/mastra-ai/mastra/commit/158381d39335be934b81ef8a1947bccace492c25), [`a1799bc`](https://github.com/mastra-ai/mastra/commit/a1799bcc1b5a1cdc188f2ac0165f17a1c4ac6f7b), [`6ff6094`](https://github.com/mastra-ai/mastra/commit/6ff60946f4ecfebdeef6e21d2b230c2204f2c9b8), [`fb703b9`](https://github.com/mastra-ai/mastra/commit/fb703b9634eeaff1a6eb2b5531ce0f9e8fb04727), [`37a2314`](https://github.com/mastra-ai/mastra/commit/37a23148e0e5a3b40d4f9f098b194671a8a49faf), [`7b1ef57`](https://github.com/mastra-ai/mastra/commit/7b1ef57fc071c2aa2a2e32905b18cd88719c5a39), [`05a9dee`](https://github.com/mastra-ai/mastra/commit/05a9dee3d355694d28847bfffb6289657fcf7dfa), [`e3c1077`](https://github.com/mastra-ai/mastra/commit/e3c107763aedd1643d3def5df450c235da9ff76c), [`1908ca0`](https://github.com/mastra-ai/mastra/commit/1908ca0521f90e43779cc29ab590173ca560443c), [`1bccdb3`](https://github.com/mastra-ai/mastra/commit/1bccdb33eb90cbeba2dc5ece1c2561fb774b26b6), [`5ef944a`](https://github.com/mastra-ai/mastra/commit/5ef944a3721d93105675cac2b2311432ff8cc393), [`d6b186f`](https://github.com/mastra-ai/mastra/commit/d6b186fb08f1caf1b86f73d3a5ee88fb999ca3be), [`ee68e82`](https://github.com/mastra-ai/mastra/commit/ee68e8289ea4408d29849e899bc6e78b3bd4e843), [`228228b`](https://github.com/mastra-ai/mastra/commit/228228b0b1de9291cb8887587f5cea1a8757ebad), [`ea33930`](https://github.com/mastra-ai/mastra/commit/ea339301e82d6318257720d811b043014ee44064), [`65493b3`](https://github.com/mastra-ai/mastra/commit/65493b31c36f6fdb78f9679f7e1ecf0c250aa5ee), [`a998b8f`](https://github.com/mastra-ai/mastra/commit/a998b8f858091c2ec47683e60766cf12d03001e4), [`b5a66b7`](https://github.com/mastra-ai/mastra/commit/b5a66b748a14fc8b3f63b04642ddb9621fbcc9e0), [`8a37bdd`](https://github.com/mastra-ai/mastra/commit/8a37bddb6d8614a32c5b70303d583d80c620ea61), [`135d6f2`](https://github.com/mastra-ai/mastra/commit/135d6f22a326ed1dffff858700669dff09d2c9eb)]:
|
|
39
|
+
- @mastra/core@0.21.0
|
|
40
|
+
|
|
3
41
|
## 0.2.0-alpha.2
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
-
`@mastra/ai-sdk`
|
|
3
|
+
The recommended way of using Mastra and AI SDK together is by installing the `@mastra/ai-sdk` package. `@mastra/ai-sdk` provides custom API routes and utilities for streaming Mastra agents in AI SDK-compatible formats. Including chat, workflow, and network route handlers, along with utilities and exported types for UI integrations.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -47,9 +47,73 @@ After defining a dynamic route with `:agentId` you can use the `useChat()` hook
|
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
49
|
type MyMessage = {};
|
|
50
|
+
|
|
50
51
|
const { error, status, sendMessage, messages, regenerate, stop } = useChat<MyMessage>({
|
|
51
52
|
transport: new DefaultChatTransport({
|
|
52
53
|
api: 'http://localhost:4111/chat/weatherAgent',
|
|
53
54
|
}),
|
|
54
55
|
});
|
|
55
56
|
```
|
|
57
|
+
|
|
58
|
+
### Workflow route
|
|
59
|
+
|
|
60
|
+
Stream a workflow in AI SDK-compatible format.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { workflowRoute } from '@mastra/ai-sdk';
|
|
64
|
+
|
|
65
|
+
export const mastra = new Mastra({
|
|
66
|
+
server: {
|
|
67
|
+
apiRoutes: [
|
|
68
|
+
workflowRoute({
|
|
69
|
+
path: '/workflow',
|
|
70
|
+
agent: 'weatherAgent',
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Network route
|
|
78
|
+
|
|
79
|
+
Stream agent networks (routing + nested agent/workflow/tool executions) in AI SDK-compatible format.
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { networkRoute } from '@mastra/ai-sdk';
|
|
83
|
+
|
|
84
|
+
export const mastra = new Mastra({
|
|
85
|
+
server: {
|
|
86
|
+
apiRoutes: [
|
|
87
|
+
networkRoute({
|
|
88
|
+
path: '/network',
|
|
89
|
+
agent: 'weatherAgent',
|
|
90
|
+
}),
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Manual transformation
|
|
97
|
+
|
|
98
|
+
If you have a raw Mastra `stream`, you can manually transform it to AI SDK UI message parts:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { toAISdkFormat } from '@mastra/ai-sdk';
|
|
102
|
+
import { createUIMessageStream, createUIMessageStreamResponse } from 'ai';
|
|
103
|
+
|
|
104
|
+
export async function POST(req: Request) {
|
|
105
|
+
const { messages } = await req.json();
|
|
106
|
+
const agent = mastra.getAgent('weatherAgent');
|
|
107
|
+
const stream = await agent.stream(messages);
|
|
108
|
+
|
|
109
|
+
const uiMessageStream = createUIMessageStream({
|
|
110
|
+
execute: async ({ writer }) => {
|
|
111
|
+
for await (const part of toAISdkFormat(stream, { from: 'agent' })!) {
|
|
112
|
+
writer.write(part);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return createUIMessageStreamResponse({ stream: uiMessageStream });
|
|
118
|
+
}
|
|
119
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/ai-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-alpha.0",
|
|
4
4
|
"description": "Adds custom API routes to be compatible with the AI SDK UI parts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"typescript": "^5.8.3",
|
|
33
33
|
"vitest": "^3.2.4",
|
|
34
34
|
"zod": "^3.25.76",
|
|
35
|
-
"@internal/lint": "0.0.
|
|
36
|
-
"@internal/types-builder": "0.0.
|
|
37
|
-
"@mastra/core": "0.21.
|
|
35
|
+
"@internal/lint": "0.0.49",
|
|
36
|
+
"@internal/types-builder": "0.0.24",
|
|
37
|
+
"@mastra/core": "0.21.1-alpha.0"
|
|
38
38
|
},
|
|
39
39
|
"keywords": [
|
|
40
40
|
"mastra",
|