@mastra/client-js 1.9.0 → 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 CHANGED
@@ -1,5 +1,13 @@
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
+
3
11
  ## 1.9.0
4
12
 
5
13
  ### Minor Changes
@@ -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.0"
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
- - [MastraAuthAuth0 class](references/docs-server-auth-auth0.md) - Documentation for the MastraAuthAuth0 class, which authenticates Mastra applications using Auth0 authentication.
20
- - [MastraAuthClerk class](references/docs-server-auth-clerk.md) - Documentation for the MastraAuthClerk class, which authenticates Mastra applications using Clerk authentication.
21
- - [MastraAuthFirebase class](references/docs-server-auth-firebase.md) - Documentation for the MastraAuthFirebase class, which authenticates Mastra applications using Firebase Authentication.
22
- - [MastraJwtAuth class](references/docs-server-auth-jwt.md) - Documentation for the MastraJwtAuth class, which authenticates Mastra applications using JSON Web Tokens.
23
- - [MastraAuthSupabase class](references/docs-server-auth-supabase.md) - Documentation for the MastraAuthSupabase class, which authenticates Mastra applications using Supabase Auth.
24
- - [MastraAuthWorkos class](references/docs-server-auth-workos.md) - Documentation for the MastraAuthWorkos class, which authenticates Mastra applications using WorkOS authentication.
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,5 +1,5 @@
1
1
  {
2
- "version": "1.9.0",
2
+ "version": "1.9.1-alpha.0",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -1,6 +1,6 @@
1
- # MastraAuthAuth0 class
1
+ # Auth0
2
2
 
3
- The `MastraAuthAuth0` class 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.
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
- # MastraAuthClerk class
1
+ # Clerk
2
2
 
3
- The `MastraAuthClerk` class 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.
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
- # MastraAuthFirebase class
1
+ # Firebase
2
2
 
3
- The `MastraAuthFirebase` class 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.
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
- # MastraJwtAuth class
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
- # MastraAuthSupabase class
1
+ # Supabase
2
2
 
3
- The `MastraAuthSupabase` class 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.
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
- # MastraAuthWorkos class
1
+ # WorkOS
2
2
 
3
- The `MastraAuthWorkos` class provides authentication for Mastra using WorkOS. It verifies incoming requests using WorkOS access tokens and integrates with the Mastra server using the `auth` option.
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.0",
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.14.0",
41
- "@mastra/schema-compat": "1.2.5"
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"