@mastra/client-js 1.9.0-alpha.3 → 1.9.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 +20 -0
- package/dist/docs/SKILL.md +7 -7
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-server-auth-auth0.md +42 -2
- package/dist/docs/references/docs-server-auth-clerk.md +22 -2
- package/dist/docs/references/docs-server-auth-firebase.md +22 -2
- package/dist/docs/references/docs-server-auth-jwt.md +18 -14
- package/dist/docs/references/docs-server-auth-supabase.md +22 -2
- package/dist/docs/references/docs-server-auth-workos.md +42 -2
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-stream.md +34 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.9.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`cb611a1`](https://github.com/mastra-ai/mastra/commit/cb611a1e89a4f4cf74c97b57e0c27bb56f2eceb5), [`b71bce1`](https://github.com/mastra-ai/mastra/commit/b71bce144912ed33f76c52a94e594988a649c3e1), [`62d1d3c`](https://github.com/mastra-ai/mastra/commit/62d1d3cc08fe8182e7080237fd975de862ec8c91), [`8681ecb`](https://github.com/mastra-ai/mastra/commit/8681ecb86184d5907267000e4576cc442a9a83fc), [`28d0249`](https://github.com/mastra-ai/mastra/commit/28d0249295782277040ad1e0d243e695b7ab1ce4), [`bb0f09d`](https://github.com/mastra-ai/mastra/commit/bb0f09dbac58401b36069f483acf5673202db5b5), [`5f7e9d0`](https://github.com/mastra-ai/mastra/commit/5f7e9d0db664020e1f3d97d7d18c6b0b9d4843d0)]:
|
|
8
|
+
- @mastra/core@1.15.0-alpha.0
|
|
9
|
+
- @mastra/schema-compat@1.2.6-alpha.0
|
|
10
|
+
|
|
11
|
+
## 1.9.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- Added new observability API endpoints and client methods for logs, scores, feedback, metrics (aggregate, breakdown, time series, percentiles), and discovery (metric names, label keys/values, entity types/names, service names, environments, tags) ([#14270](https://github.com/mastra-ai/mastra/pull/14270))
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`51970b3`](https://github.com/mastra-ai/mastra/commit/51970b3828494d59a8dd4df143b194d37d31e3f5), [`4444280`](https://github.com/mastra-ai/mastra/commit/444428094253e916ec077e66284e685fde67021e), [`4a7ce05`](https://github.com/mastra-ai/mastra/commit/4a7ce05125b8d3d260f68f1fc4a6c6866d22ba24), [`085e371`](https://github.com/mastra-ai/mastra/commit/085e3718a7d0fe9a210fe7dd1c867b9bdfe8d16b), [`b77aa19`](https://github.com/mastra-ai/mastra/commit/b77aa1981361c021f2c881bee8f0c703687f00da), [`dbb879a`](https://github.com/mastra-ai/mastra/commit/dbb879af0b809c668e9b3a9d8bac97d806caa267), [`8b4ce84`](https://github.com/mastra-ai/mastra/commit/8b4ce84aed0808b9805cc4fd7147c1f8a2ef7a36), [`8d4cfe6`](https://github.com/mastra-ai/mastra/commit/8d4cfe6b9a7157d3876206227ec9f04cde6dbc4a), [`dd6ca1c`](https://github.com/mastra-ai/mastra/commit/dd6ca1cdea3b8b6182f4cf61df41070ba0cc0deb), [`ce26fe2`](https://github.com/mastra-ai/mastra/commit/ce26fe2166dd90254f8bee5776e55977143e97de), [`68a019d`](https://github.com/mastra-ai/mastra/commit/68a019d30d22251ddd628a2947d60215c03c350a), [`4cb4edf`](https://github.com/mastra-ai/mastra/commit/4cb4edf3c909d197ec356c1790d13270514ffef6), [`8de3555`](https://github.com/mastra-ai/mastra/commit/8de355572c6fd838f863a3e7e6fe24d0947b774f), [`b26307f`](https://github.com/mastra-ai/mastra/commit/b26307f050df39629511b0e831b8fc26973ce8b1), [`68a019d`](https://github.com/mastra-ai/mastra/commit/68a019d30d22251ddd628a2947d60215c03c350a)]:
|
|
20
|
+
- @mastra/core@1.14.0
|
|
21
|
+
- @mastra/schema-compat@1.2.5
|
|
22
|
+
|
|
3
23
|
## 1.9.0-alpha.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-client-js
|
|
|
3
3
|
description: Documentation for @mastra/client-js. Use when working with @mastra/client-js APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/client-js"
|
|
6
|
-
version: "1.9.
|
|
6
|
+
version: "1.9.1-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -16,12 +16,12 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
16
16
|
|
|
17
17
|
### Docs
|
|
18
18
|
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
19
|
+
- [Auth0](references/docs-server-auth-auth0.md) - Documentation for the @mastra/auth-auth0 package, which authenticates Mastra applications using Auth0 authentication.
|
|
20
|
+
- [Clerk](references/docs-server-auth-clerk.md) - Documentation for the `@mastra/auth-clerk` package, which authenticates Mastra applications using Clerk authentication.
|
|
21
|
+
- [Firebase](references/docs-server-auth-firebase.md) - Documentation for the `@mastra/auth-firebase` package, which authenticates Mastra applications using Firebase Authentication.
|
|
22
|
+
- [JSON Web Token](references/docs-server-auth-jwt.md) - Documentation for JSON Web Token usage inside Mastra.
|
|
23
|
+
- [Supabase](references/docs-server-auth-supabase.md) - Documentation for the `@mastra/auth-supabase` package, which authenticates Mastra applications using Supabase Auth.
|
|
24
|
+
- [WorkOS](references/docs-server-auth-workos.md) - Documentation for the `@mastra/auth-workos` package, which authenticates Mastra applications using WorkOS authentication.
|
|
25
25
|
- [Mastra client SDK](references/docs-server-mastra-client.md) - Learn how to set up and use the Mastra Client SDK
|
|
26
26
|
|
|
27
27
|
### Reference
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Auth0
|
|
2
2
|
|
|
3
|
-
The `
|
|
3
|
+
The `@mastra/auth-auth0` package provides authentication for Mastra using Auth0. It verifies incoming requests using Auth0-issued JWT tokens and integrates with the Mastra server using the `auth` option.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -24,10 +24,30 @@ AUTH0_AUDIENCE=your-api-identifier
|
|
|
24
24
|
|
|
25
25
|
Before you can use the `MastraAuthAuth0` class you have to install the `@mastra/auth-auth0` package.
|
|
26
26
|
|
|
27
|
+
**npm**:
|
|
28
|
+
|
|
27
29
|
```bash
|
|
28
30
|
npm install @mastra/auth-auth0@latest
|
|
29
31
|
```
|
|
30
32
|
|
|
33
|
+
**pnpm**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pnpm add @mastra/auth-auth0@latest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Yarn**:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
yarn add @mastra/auth-auth0@latest
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Bun**:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
bun add @mastra/auth-auth0@latest
|
|
49
|
+
```
|
|
50
|
+
|
|
31
51
|
## Usage examples
|
|
32
52
|
|
|
33
53
|
### Basic usage with environment variables
|
|
@@ -93,10 +113,30 @@ When using Auth0 auth, you'll need to set up the Auth0 React SDK, authenticate u
|
|
|
93
113
|
|
|
94
114
|
First, install and configure the Auth0 React SDK in your application:
|
|
95
115
|
|
|
116
|
+
**npm**:
|
|
117
|
+
|
|
96
118
|
```bash
|
|
97
119
|
npm install @auth0/auth0-react
|
|
98
120
|
```
|
|
99
121
|
|
|
122
|
+
**pnpm**:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pnpm add @auth0/auth0-react
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Yarn**:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
yarn add @auth0/auth0-react
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Bun**:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
bun add @auth0/auth0-react
|
|
138
|
+
```
|
|
139
|
+
|
|
100
140
|
```typescript
|
|
101
141
|
import React from 'react'
|
|
102
142
|
import { Auth0Provider } from '@auth0/auth0-react'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Clerk
|
|
2
2
|
|
|
3
|
-
The `
|
|
3
|
+
The `@mastra/auth-clerk` package provides authentication for Mastra using Clerk. It verifies incoming requests using Clerk's authentication system and integrates with the Mastra server using the `auth` option.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -18,10 +18,30 @@ CLERK_JWKS_URI=https://your-clerk-domain.clerk.accounts.dev/.well-known/jwks.jso
|
|
|
18
18
|
|
|
19
19
|
Before you can use the `MastraAuthClerk` class you have to install the `@mastra/auth-clerk` package.
|
|
20
20
|
|
|
21
|
+
**npm**:
|
|
22
|
+
|
|
21
23
|
```bash
|
|
22
24
|
npm install @mastra/auth-clerk@latest
|
|
23
25
|
```
|
|
24
26
|
|
|
27
|
+
**pnpm**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @mastra/auth-clerk@latest
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Yarn**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
yarn add @mastra/auth-clerk@latest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Bun**:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
bun add @mastra/auth-clerk@latest
|
|
43
|
+
```
|
|
44
|
+
|
|
25
45
|
## Usage example
|
|
26
46
|
|
|
27
47
|
```typescript
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Firebase
|
|
2
2
|
|
|
3
|
-
The `
|
|
3
|
+
The `@mastra/auth-firebase` package provides authentication for Mastra using Firebase Authentication. It verifies incoming requests using Firebase ID tokens and integrates with the Mastra server using the `auth` option.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -24,10 +24,30 @@ FIRESTORE_DATABASE_ID=(default)
|
|
|
24
24
|
|
|
25
25
|
Before you can use the `MastraAuthFirebase` class you have to install the `@mastra/auth-firebase` package.
|
|
26
26
|
|
|
27
|
+
**npm**:
|
|
28
|
+
|
|
27
29
|
```bash
|
|
28
30
|
npm install @mastra/auth-firebase@latest
|
|
29
31
|
```
|
|
30
32
|
|
|
33
|
+
**pnpm**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pnpm add @mastra/auth-firebase@latest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Yarn**:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
yarn add @mastra/auth-firebase@latest
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Bun**:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
bun add @mastra/auth-firebase@latest
|
|
49
|
+
```
|
|
50
|
+
|
|
31
51
|
## Usage examples
|
|
32
52
|
|
|
33
53
|
### Basic usage with environment variables
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# JSON Web Token
|
|
2
2
|
|
|
3
3
|
The `MastraJwtAuth` class provides a lightweight authentication mechanism for Mastra using JSON Web Tokens (JWTs). It verifies incoming requests based on a shared secret and integrates with the Mastra server using the `auth` option.
|
|
4
4
|
|
|
@@ -30,8 +30,22 @@ yarn add @mastra/auth@latest
|
|
|
30
30
|
bun add @mastra/auth@latest
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
## Creating a JWT
|
|
34
|
+
|
|
35
|
+
To authenticate requests to your Mastra server, you'll need a valid JSON Web Token (JWT) signed with your `MASTRA_JWT_SECRET`.
|
|
36
|
+
|
|
37
|
+
The easiest way to generate one is using [jwt.io](https://www.jwt.io/):
|
|
38
|
+
|
|
39
|
+
1. Select **JWT Encoder**.
|
|
40
|
+
2. Scroll down to the **Sign JWT: Secret** section.
|
|
41
|
+
3. Enter your secret (for example: `supersecretdevkeythatishs256safe!`).
|
|
42
|
+
4. Click **Generate example** to create a valid JWT.
|
|
43
|
+
5. Copy the generated token and set it as `MASTRA_JWT_TOKEN` in your `.env` file.
|
|
44
|
+
|
|
33
45
|
## Usage example
|
|
34
46
|
|
|
47
|
+
Take your generated JWT and use it to configure `MastraJwtAuth` in your Mastra server:
|
|
48
|
+
|
|
35
49
|
```typescript
|
|
36
50
|
import { Mastra } from '@mastra/core'
|
|
37
51
|
import { MastraJwtAuth } from '@mastra/auth'
|
|
@@ -47,6 +61,8 @@ export const mastra = new Mastra({
|
|
|
47
61
|
|
|
48
62
|
> **Info:** Visit [MastraJwtAuth](https://mastra.ai/reference/auth/jwt) for all available configuration options.
|
|
49
63
|
|
|
64
|
+
Inside [Studio](https://mastra.ai/docs/getting-started/studio), go to **Settings** and under **Headers** select the **"Add Header"** button. Enter `Authorization` as the header name and `Bearer <your-jwt>` as the value.
|
|
65
|
+
|
|
50
66
|
## Configuring `MastraClient`
|
|
51
67
|
|
|
52
68
|
When `auth` is enabled, all requests made with `MastraClient` must include a valid JWT in the `Authorization` header:
|
|
@@ -95,16 +111,4 @@ curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
|
95
111
|
-d '{
|
|
96
112
|
"messages": "Weather in London"
|
|
97
113
|
}'
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Creating a JWT
|
|
101
|
-
|
|
102
|
-
To authenticate requests to your Mastra server, you'll need a valid JSON Web Token (JWT) signed with your `MASTRA_JWT_SECRET`.
|
|
103
|
-
|
|
104
|
-
The easiest way to generate one is using [jwt.io](https://www.jwt.io/):
|
|
105
|
-
|
|
106
|
-
1. Select **JWT Encoder**.
|
|
107
|
-
2. Scroll down to the **Sign JWT: Secret** section.
|
|
108
|
-
3. Enter your secret (for example: `supersecretdevkeythatishs256safe!`).
|
|
109
|
-
4. Click **Generate example** to create a valid JWT.
|
|
110
|
-
5. Copy the generated token and set it as `MASTRA_JWT_TOKEN` in your `.env` file.
|
|
114
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Supabase
|
|
2
2
|
|
|
3
|
-
The `
|
|
3
|
+
The `@mastra/auth-supabase` package provides authentication for Mastra using Supabase Auth. It verifies incoming requests using Supabase's authentication system and integrates with the Mastra server using the `auth` option.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -17,10 +17,30 @@ SUPABASE_ANON_KEY=your-anon-key
|
|
|
17
17
|
|
|
18
18
|
Before you can use the `MastraAuthSupabase` class you have to install the `@mastra/auth-supabase` package.
|
|
19
19
|
|
|
20
|
+
**npm**:
|
|
21
|
+
|
|
20
22
|
```bash
|
|
21
23
|
npm install @mastra/auth-supabase@latest
|
|
22
24
|
```
|
|
23
25
|
|
|
26
|
+
**pnpm**:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm add @mastra/auth-supabase@latest
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Yarn**:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
yarn add @mastra/auth-supabase@latest
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Bun**:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
bun add @mastra/auth-supabase@latest
|
|
42
|
+
```
|
|
43
|
+
|
|
24
44
|
## Usage example
|
|
25
45
|
|
|
26
46
|
```typescript
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# WorkOS
|
|
2
2
|
|
|
3
|
-
The `
|
|
3
|
+
The `@mastra/auth-workos` package provides authentication for Mastra using WorkOS. It verifies incoming requests using WorkOS access tokens and integrates with the Mastra server using the `auth` option.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -24,10 +24,30 @@ WORKOS_CLIENT_ID=client_...
|
|
|
24
24
|
|
|
25
25
|
Before you can use the `MastraAuthWorkos` class you have to install the `@mastra/auth-workos` package.
|
|
26
26
|
|
|
27
|
+
**npm**:
|
|
28
|
+
|
|
27
29
|
```bash
|
|
28
30
|
npm install @mastra/auth-workos@latest
|
|
29
31
|
```
|
|
30
32
|
|
|
33
|
+
**pnpm**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pnpm add @mastra/auth-workos@latest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Yarn**:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
yarn add @mastra/auth-workos@latest
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Bun**:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
bun add @mastra/auth-workos@latest
|
|
49
|
+
```
|
|
50
|
+
|
|
31
51
|
## Usage examples
|
|
32
52
|
|
|
33
53
|
### Basic usage with environment variables
|
|
@@ -94,10 +114,30 @@ When using WorkOS auth, you'll need to implement the WorkOS authentication flow
|
|
|
94
114
|
|
|
95
115
|
First, install the WorkOS SDK in your application:
|
|
96
116
|
|
|
117
|
+
**npm**:
|
|
118
|
+
|
|
97
119
|
```bash
|
|
98
120
|
npm install @workos-inc/node
|
|
99
121
|
```
|
|
100
122
|
|
|
123
|
+
**pnpm**:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pnpm add @workos-inc/node
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Yarn**:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
yarn add @workos-inc/node
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Bun**:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
bun add @workos-inc/node
|
|
139
|
+
```
|
|
140
|
+
|
|
101
141
|
### Exchanging code for access token
|
|
102
142
|
|
|
103
143
|
After users complete the WorkOS authentication flow and return with an authorization code, exchange it for an access token:
|
|
@@ -4,6 +4,8 @@ Converts Mastra streams (agent, network, or workflow) to AI SDK-compatible strea
|
|
|
4
4
|
|
|
5
5
|
This is useful when building custom streaming endpoints outside Mastra's provided route helpers such as [`chatRoute()`](https://mastra.ai/reference/ai-sdk/chat-route) or [`workflowRoute()`](https://mastra.ai/reference/ai-sdk/workflow-route).
|
|
6
6
|
|
|
7
|
+
`toAISdkStream()` keeps the existing AI SDK v5/default behavior. If your app is typed against AI SDK v6, pass `version: 'v6'` in the options object.
|
|
8
|
+
|
|
7
9
|
## Usage example
|
|
8
10
|
|
|
9
11
|
Next.js App Router example:
|
|
@@ -45,6 +47,8 @@ The first parameter is the Mastra stream to convert. It can be one of:
|
|
|
45
47
|
|
|
46
48
|
The second parameter is an options object:
|
|
47
49
|
|
|
50
|
+
**version** (`'v5' | 'v6'`): Selects the AI SDK stream contract to emit. Omit it or pass \`'v5'\` for the existing default behavior. Pass \`'v6'\` when your app is typed against AI SDK v6 response helpers. (Default: `'v5'`)
|
|
51
|
+
|
|
48
52
|
**from** (`'agent' | 'network' | 'workflow'`): The type of Mastra stream being converted. (Default: `'agent'`)
|
|
49
53
|
|
|
50
54
|
**lastMessageId** (`string`): (Agent only) The ID of the last message in the conversation.
|
|
@@ -152,6 +156,36 @@ export async function POST(req: Request) {
|
|
|
152
156
|
}
|
|
153
157
|
```
|
|
154
158
|
|
|
159
|
+
### Converting an agent stream for AI SDK v6
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { mastra } from '../../mastra'
|
|
163
|
+
import { createUIMessageStream, createUIMessageStreamResponse } from 'ai'
|
|
164
|
+
import { toAISdkStream } from '@mastra/ai-sdk'
|
|
165
|
+
|
|
166
|
+
export async function POST(req: Request) {
|
|
167
|
+
const { messages } = await req.json()
|
|
168
|
+
const myAgent = mastra.getAgent('weatherAgent')
|
|
169
|
+
const stream = await myAgent.stream(messages)
|
|
170
|
+
|
|
171
|
+
const uiMessageStream = createUIMessageStream({
|
|
172
|
+
originalMessages: messages,
|
|
173
|
+
execute: async ({ writer }) => {
|
|
174
|
+
for await (const part of toAISdkStream(stream, {
|
|
175
|
+
from: 'agent',
|
|
176
|
+
version: 'v6',
|
|
177
|
+
})) {
|
|
178
|
+
await writer.write(part)
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
return createUIMessageStreamResponse({
|
|
184
|
+
stream: uiMessageStream,
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
155
189
|
### Using `messageMetadata`
|
|
156
190
|
|
|
157
191
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/client-js",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1-alpha.0",
|
|
4
4
|
"description": "The official TypeScript library for the Mastra Client API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"type": "module",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@ai-sdk/ui-utils": "^1.2.11",
|
|
38
38
|
"@lukeed/uuid": "^2.0.1",
|
|
39
39
|
"json-schema": "^0.4.0",
|
|
40
|
-
"@mastra/core": "1.
|
|
41
|
-
"@mastra/schema-compat": "1.2.
|
|
40
|
+
"@mastra/core": "1.15.0-alpha.0",
|
|
41
|
+
"@mastra/schema-compat": "1.2.6-alpha.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"zod": "^3.25.0 || ^4.0.0"
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"typescript": "^5.9.3",
|
|
54
54
|
"vitest": "4.0.18",
|
|
55
55
|
"zod": "^4.3.6",
|
|
56
|
-
"@internal/ai-sdk-
|
|
57
|
-
"@internal/ai-sdk-
|
|
58
|
-
"@internal/
|
|
59
|
-
"@internal/
|
|
56
|
+
"@internal/ai-sdk-v4": "0.0.19",
|
|
57
|
+
"@internal/ai-sdk-v5": "0.0.19",
|
|
58
|
+
"@internal/lint": "0.0.72",
|
|
59
|
+
"@internal/types-builder": "0.0.47"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=22.13.0"
|