@mastra/client-js 1.17.0-alpha.1 → 1.17.0-alpha.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.
- package/CHANGELOG.md +11 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-server-auth-workos.md +52 -9
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/route-types.generated.d.ts +42286 -0
- package/dist/route-types.generated.d.ts.map +1 -0
- package/dist/types.d.ts +64 -288
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.17.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed client stream handling for step completion and finish chunks that omit step result details. ([#9146](https://github.com/mastra-ai/mastra/pull/9146))
|
|
8
|
+
|
|
9
|
+
- Added server-generated route contract types for the JavaScript client SDK and updated the SDK to use those generated request and response types. ([#15519](https://github.com/mastra-ai/mastra/pull/15519))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`86c0298`](https://github.com/mastra-ai/mastra/commit/86c0298e647306423c842f9d5ac827bd616bd13d), [`7fce309`](https://github.com/mastra-ai/mastra/commit/7fce30912b14170bfc41f0ac736cca0f39fe0cd4), [`7997c2e`](https://github.com/mastra-ai/mastra/commit/7997c2e55ddd121562a4098cd8d2b89c68433bf1), [`e97ccb9`](https://github.com/mastra-ai/mastra/commit/e97ccb900f8b7a390ce82c9f8eb8d6eb2c5e3777), [`c5daf48`](https://github.com/mastra-ai/mastra/commit/c5daf48556e98c46ae06caf00f92c249912007e9), [`cd96779`](https://github.com/mastra-ai/mastra/commit/cd9677937f113b2856dc8b9f3d4bdabcee58bb2e)]:
|
|
12
|
+
- @mastra/core@1.32.0-alpha.2
|
|
13
|
+
|
|
3
14
|
## 1.17.0-alpha.1
|
|
4
15
|
|
|
5
16
|
### Minor 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.17.0-alpha.
|
|
6
|
+
version: "1.17.0-alpha.2"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -81,16 +81,34 @@ export const mastra = new Mastra({
|
|
|
81
81
|
|
|
82
82
|
## Configuration
|
|
83
83
|
|
|
84
|
-
###
|
|
84
|
+
### Default authorization
|
|
85
85
|
|
|
86
|
-
By default, `MastraAuthWorkos`
|
|
86
|
+
By default, `MastraAuthWorkos` grants access to any authenticated WorkOS user. The authorization check succeeds when the resolved user object contains both a Mastra user ID and a WorkOS user ID.
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
2. Extracts all roles from their memberships
|
|
90
|
-
3. Checks if any role has the slug 'admin'
|
|
91
|
-
4. Grants access only if the user has admin role in at least one organization
|
|
88
|
+
### FGA membership loading
|
|
92
89
|
|
|
93
|
-
|
|
90
|
+
Set `fetchMemberships: true` when you use [`MastraFGAWorkos`](https://mastra.ai/docs/server/auth/fga). This tells the auth provider to load the user's WorkOS organization memberships during authentication so FGA checks can resolve the correct organization membership ID.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { MastraAuthWorkos, MastraFGAWorkos } from '@mastra/auth-workos'
|
|
94
|
+
|
|
95
|
+
const workosAuth = new MastraAuthWorkos({
|
|
96
|
+
apiKey: process.env.WORKOS_API_KEY,
|
|
97
|
+
clientId: process.env.WORKOS_CLIENT_ID,
|
|
98
|
+
fetchMemberships: true,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const workosFga = new MastraFGAWorkos({
|
|
102
|
+
apiKey: process.env.WORKOS_API_KEY,
|
|
103
|
+
clientId: process.env.WORKOS_CLIENT_ID,
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
When `fetchMemberships` is `false`, Mastra skips the extra WorkOS `listOrganizationMemberships()` call on each authenticated request.
|
|
108
|
+
|
|
109
|
+
### Service tokens and custom JWT templates
|
|
110
|
+
|
|
111
|
+
For machine-to-machine or service-account access, you can configure `MastraAuthWorkos` to trust verified bearer-token claims from a WorkOS custom JWT template.
|
|
94
112
|
|
|
95
113
|
```typescript
|
|
96
114
|
import { MastraAuthWorkos } from '@mastra/auth-workos'
|
|
@@ -98,12 +116,37 @@ import { MastraAuthWorkos } from '@mastra/auth-workos'
|
|
|
98
116
|
const workosAuth = new MastraAuthWorkos({
|
|
99
117
|
apiKey: process.env.WORKOS_API_KEY,
|
|
100
118
|
clientId: process.env.WORKOS_CLIENT_ID,
|
|
101
|
-
|
|
102
|
-
|
|
119
|
+
redirectUri: process.env.WORKOS_REDIRECT_URI,
|
|
120
|
+
trustJwtClaims: true,
|
|
121
|
+
jwtClaims: {
|
|
122
|
+
organizationId: 'org_id',
|
|
123
|
+
organizationMembershipId: 'urn:mastra:organization_membership_id',
|
|
103
124
|
},
|
|
104
125
|
})
|
|
105
126
|
```
|
|
106
127
|
|
|
128
|
+
This is useful when your JWT template already includes the exact FGA context Mastra needs, such as `organizationMembershipId`, tenant IDs, or service-principal identifiers. When `trustJwtClaims` is enabled, Mastra can fall back to those verified claims if a bearer token is not meant to round-trip through `workos.userManagement.getUser()`.
|
|
129
|
+
|
|
130
|
+
### Custom authorization
|
|
131
|
+
|
|
132
|
+
If you need stricter authorization, subclass `MastraAuthWorkos` and override `authorizeUser()`:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { MastraAuthWorkos } from '@mastra/auth-workos'
|
|
136
|
+
import type { HonoRequest } from 'hono'
|
|
137
|
+
|
|
138
|
+
class AdminOnlyWorkosAuth extends MastraAuthWorkos {
|
|
139
|
+
async authorizeUser(user: any, _request: HonoRequest): Promise<boolean> {
|
|
140
|
+
return user?.metadata?.role === 'admin'
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const workosAuth = new AdminOnlyWorkosAuth({
|
|
145
|
+
apiKey: process.env.WORKOS_API_KEY,
|
|
146
|
+
clientId: process.env.WORKOS_CLIENT_ID,
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
107
150
|
> **Info:** Visit [MastraAuthWorkos](https://mastra.ai/reference/auth/workos) for all available configuration options.
|
|
108
151
|
|
|
109
152
|
## Client-side setup
|
package/dist/index.cjs
CHANGED
|
@@ -1188,15 +1188,15 @@ var Agent = class extends BaseResource {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
case "step-finish": {
|
|
1190
1190
|
step += 1;
|
|
1191
|
-
currentTextPart = chunk.payload
|
|
1191
|
+
currentTextPart = chunk.payload?.stepResult?.isContinued ? currentTextPart : void 0;
|
|
1192
1192
|
currentReasoningPart = void 0;
|
|
1193
1193
|
currentReasoningTextDetail = void 0;
|
|
1194
1194
|
execUpdate();
|
|
1195
1195
|
break;
|
|
1196
1196
|
}
|
|
1197
1197
|
case "finish": {
|
|
1198
|
-
finishReason = chunk.payload
|
|
1199
|
-
if (chunk.payload
|
|
1198
|
+
finishReason = chunk.payload?.stepResult?.reason ?? finishReason;
|
|
1199
|
+
if (chunk.payload?.usage != null) {
|
|
1200
1200
|
usage = chunk.payload.usage;
|
|
1201
1201
|
}
|
|
1202
1202
|
break;
|