@mastra/client-js 1.35.1-alpha.1 → 1.36.0-alpha.3

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,43 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 1.36.0-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`723aa54`](https://github.com/mastra-ai/mastra/commit/723aa5437106bdb708ae03c0ef6b77aa11291e73), [`723aa54`](https://github.com/mastra-ai/mastra/commit/723aa5437106bdb708ae03c0ef6b77aa11291e73), [`723aa54`](https://github.com/mastra-ai/mastra/commit/723aa5437106bdb708ae03c0ef6b77aa11291e73)]:
8
+ - @mastra/core@1.55.0-alpha.3
9
+
10
+ ## 1.36.0-alpha.2
11
+
12
+ ### Minor Changes
13
+
14
+ - Added the `autoPublish` option to `createStoredAgent()` so SDK users can create an unpublished initial draft. ([#20381](https://github.com/mastra-ai/mastra/pull/20381))
15
+
16
+ ```typescript
17
+ await mastraClient.createStoredAgent({
18
+ id: 'support-agent',
19
+ name: 'Support agent',
20
+ instructions: 'Help customers with support questions.',
21
+ model: { provider: 'openai', name: 'gpt-5' },
22
+ autoPublish: false,
23
+ });
24
+ ```
25
+
26
+ ### Patch Changes
27
+
28
+ - Added `TraceInsightResponse` for typed entity-learning trace summaries. ([#20405](https://github.com/mastra-ai/mastra/pull/20405))
29
+
30
+ ```ts
31
+ import type { TraceInsightResponse } from '@mastra/client-js';
32
+
33
+ const traceId = (insight: TraceInsightResponse) => insight.traceId;
34
+ ```
35
+
36
+ - Added Trace Intelligence progress types and improved the onboarding state with processing progress, clearer copy, accessible markup, mobile polish, and the dedicated documentation link. ([#20401](https://github.com/mastra-ai/mastra/pull/20401))
37
+
38
+ - Updated dependencies [[`55c9e24`](https://github.com/mastra-ai/mastra/commit/55c9e248c27c1d72b5bb7e94ea6b8a3999eee49f), [`07f5b4b`](https://github.com/mastra-ai/mastra/commit/07f5b4ba9d608d88865030732e580298296adf99)]:
39
+ - @mastra/core@1.55.0-alpha.2
40
+
3
41
  ## 1.35.1-alpha.1
4
42
 
5
43
  ### Patch Changes
@@ -1,4 +1,14 @@
1
1
  export type TraceSignalName = 'goal' | 'sentiment' | 'behavior' | 'outcome';
2
+ export type EntityLearningProgressStatus = 'collecting' | 'processing' | 'ready';
3
+ export interface EntityLearningProgressResponse {
4
+ status: EntityLearningProgressStatus;
5
+ traceCount: number;
6
+ signals: Record<TraceSignalName, {
7
+ generated: number;
8
+ embedded: number;
9
+ }>;
10
+ availableSignals: TraceSignalName[];
11
+ }
2
12
  export interface ThemeLearningEntity {
3
13
  entityId: string;
4
14
  entityType: string;
@@ -148,4 +158,20 @@ export interface NoiseResponse {
148
158
  coverage: number;
149
159
  };
150
160
  }
161
+ export interface TraceInsightSummary {
162
+ version: string;
163
+ summary: string;
164
+ observations: string[];
165
+ currentTask?: string;
166
+ degenerate?: boolean;
167
+ createdAt: string;
168
+ }
169
+ export interface TraceInsightResponse {
170
+ traceId: string;
171
+ summary?: TraceInsightSummary;
172
+ signals: Array<{
173
+ signalName: TraceSignalName;
174
+ signalText: string;
175
+ }>;
176
+ }
151
177
  //# sourceMappingURL=agent-learning.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-learning.d.ts","sourceRoot":"","sources":["../src/agent-learning.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAE5E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,YAAY,CAAC,EAAE;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,O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WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,OAAO,EAAE,KAAK,CAAC;QACb,UAAU,EAAE,eAAe,CAAC;QAC5B,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;CACJ"}
@@ -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.35.1-alpha.1"
6
+ version: "1.36.0-alpha.3"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.35.1-alpha.1",
2
+ "version": "1.36.0-alpha.3",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -215,48 +215,50 @@ Version management is available through the server Studio, REST API, the Client
215
215
 
216
216
  ### Version lifecycle
217
217
 
218
- Each version has one of three statuses:
218
+ Version snapshots don't store a lifecycle status. Instead, the agent or prompt block stores an `activeVersionId` that identifies its published version.
219
219
 
220
- | Status | Description |
221
- | --------- | ----------------------------------------------------------------------------------- |
222
- | Draft | The latest working copy. Every save creates a new draft version. |
223
- | Published | The active version used in production. Only one version can be published at a time. |
224
- | Archived | A previous version that's no longer active. You can restore any archived version. |
220
+ | Term | Description |
221
+ | ---------- | ----------------------------------------------------------------------------------------------------------------------------------- |
222
+ | Latest | The most recently saved version snapshot. |
223
+ | Published | The version whose ID matches `activeVersionId`. Only one version can be active at a time. |
224
+ | Draft | The latest version when it differs from the active version. If `activeVersionId` isn't set, the latest version remains unpublished. |
225
+ | Historical | Any other saved version. Historical versions remain available for comparison, direct selection, and restoration. |
225
226
 
226
- The typical flow is: Edit the draft and test it, plus then activate it to make it the published version.
227
+ Saving a database-backed resource creates a new latest version. If an active version already exists, it continues to handle requests until you publish the new version. Publishing sets `activeVersionId` to the selected version without deleting or changing the previous active version.
227
228
 
228
- The previously published version becomes archived so you can restore it if needed. You can do this through Studio or programmatically through the API.
229
-
230
- This lifecycle makes it safe to experiment. Non-technical team members can iterate on a draft without affecting production traffic, then publish when ready. If something goes wrong, restoring a previous version is a single API call.
229
+ Restoring a historical version copies its configuration into a new draft that remains inactive until you publish it.
231
230
 
232
231
  ### Version targeting and experimentation
233
232
 
234
- Because every version has a unique ID, you can route different requests to different agent configurations. This opens up several patterns:
233
+ Because every version has a unique ID, you can route different requests to different agent configurations. This supports several patterns:
235
234
 
236
- - **A/B testing**: Split traffic between two published versions and compare performance metrics.
237
- - **Canary rollouts**: Send a small percentage of requests to a new version before promoting it.
238
- - **Per-user targeting**: Pin specific users or accounts to a version while others use the default.
239
- - **Environment separation**: Use the draft version in staging and the published version in production.
235
+ - **A/B testing**: Split traffic between specific version IDs and compare performance metrics.
236
+ - **Canary rollouts**: Send a small percentage of requests to a draft or historical version before publishing it.
237
+ - **Per-user targeting**: Pin specific users or accounts to a version while others use the active version.
238
+ - **Environment separation**: Use the latest version in staging and the active version in production.
240
239
 
241
- Pass a `versionId` or `status` when calling the agent through the Client SDK, server query parameters, or React SDK `requestContext`, and the correct version is loaded automatically.
240
+ Pass a `versionId` or `status` when calling the agent through the Client SDK, server query parameters, or React SDK `requestContext`. A `versionId` selects that exact snapshot, `status: 'draft'` selects the latest snapshot, and `status: 'published'` selects the active snapshot.
242
241
 
243
242
  ### Version selection
244
243
 
245
- By default, [`mastra.getAgentById()`](https://mastra.ai/reference/core/getAgentById) loads the published (active) version of the stored override.
246
-
247
- Use a specific version to test a draft before publishing or run an A/B experiment. You can also pin a user to a known-good configuration:
244
+ Calling [`mastra.getAgentById()`](https://mastra.ai/reference/core/getAgentById) without a version selector returns the registered code-defined agent. Pass a selector to apply a published, draft, or specific stored override:
248
245
 
249
246
  ```typescript
250
- // Load the published version (default)
251
- const agent = mastra.getAgentById('support-agent')
247
+ // Load the registered code-defined agent without stored overrides
248
+ const codeAgent = mastra.getAgentById('support-agent')
249
+
250
+ // Load the active published override
251
+ const publishedAgent = await mastra.getAgentById('support-agent', {
252
+ status: 'published',
253
+ })
252
254
 
253
- // Load the latest draft
254
- const agent = mastra.getAgentById('support-agent', {
255
+ // Load the latest override
256
+ const draftAgent = await mastra.getAgentById('support-agent', {
255
257
  status: 'draft',
256
258
  })
257
259
 
258
260
  // Load a specific version
259
- const agent = mastra.getAgentById('support-agent', {
261
+ const versionedAgent = await mastra.getAgentById('support-agent', {
260
262
  versionId: 'abc-123',
261
263
  })
262
264
  ```
@@ -727,6 +727,23 @@ const agent = await mastraClient.createStoredAgent({
727
727
  })
728
728
  ```
729
729
 
730
+ By default, `createStoredAgent()` publishes the initial version immediately. Set `autoPublish` to `false` to create an unpublished draft that you can review before calling [`activateVersion()`](#activateversion):
731
+
732
+ ```typescript
733
+ const draft = await mastraClient.createStoredAgent({
734
+ id: 'draft-agent',
735
+ name: 'Draft Assistant',
736
+ instructions: 'You are a helpful assistant.',
737
+ model: {
738
+ provider: 'openai',
739
+ name: 'gpt-5',
740
+ },
741
+ autoPublish: false,
742
+ })
743
+ ```
744
+
745
+ Editors configured with the `code` source always publish the initial version because saving writes the agent configuration to the file system.
746
+
730
747
  With all options:
731
748
 
732
749
  ```typescript