@mastra/client-js 1.13.2-alpha.1 → 1.13.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 1.13.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed the client JS Responses types to allow omitting the model override. ([#15140](https://github.com/mastra-ai/mastra/pull/15140))
8
+
9
+ - Updated dependencies [[`8db7663`](https://github.com/mastra-ai/mastra/commit/8db7663c9a9c735828094c359d2e327fd4f8fba3), [`153e864`](https://github.com/mastra-ai/mastra/commit/153e86476b425db7cd0dc8490050096e92964a38), [`715710d`](https://github.com/mastra-ai/mastra/commit/715710d12fa47cf88e09d41f13843eddc29327b0), [`378c6c4`](https://github.com/mastra-ai/mastra/commit/378c6c4755726e8d8cf83a14809b350b90d46c62), [`9f91fd5`](https://github.com/mastra-ai/mastra/commit/9f91fd538ab2a44f8cc740bcad8e51205f74fbea), [`ba6fa9c`](https://github.com/mastra-ai/mastra/commit/ba6fa9cc0f3e1912c49fd70d4c3bb8c44903ddaa)]:
10
+ - @mastra/core@1.24.0
11
+
3
12
  ## 1.13.2-alpha.1
4
13
 
5
14
  ### Patch 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.13.2-alpha.1"
6
+ version: "1.13.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -16,6 +16,7 @@ Read the individual reference documents for detailed explanations and code examp
16
16
 
17
17
  ### Docs
18
18
 
19
+ - [Editor overview](references/docs-editor-overview.md) - Let non-technical team members iterate on agents, version every change, and run experiments without redeploying.
19
20
  - [Auth0](references/docs-server-auth-auth0.md) - Documentation for the @mastra/auth-auth0 package, which authenticates Mastra applications using Auth0 authentication.
20
21
  - [Clerk](references/docs-server-auth-clerk.md) - Documentation for the `@mastra/auth-clerk` package, which authenticates Mastra applications using Clerk authentication.
21
22
  - [Firebase](references/docs-server-auth-firebase.md) - Documentation for the `@mastra/auth-firebase` package, which authenticates Mastra applications using Firebase Authentication.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.13.2-alpha.1",
2
+ "version": "1.13.2",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -0,0 +1,155 @@
1
+ # Editor overview
2
+
3
+ The editor is a CMS-style system that separates agent configuration from code. Subject-matter experts, prompt engineers, and product teams can iterate on agents directly while developers keep the codebase stable.
4
+
5
+ The editor manages two types of resources alongside agents:
6
+
7
+ - [**Prompts**](https://mastra.ai/docs/editor/prompts): Reusable, versioned instruction templates with template variables and display conditions.
8
+ - [**Tools**](https://mastra.ai/docs/editor/tools): Add tools from integration providers, MCP servers, and override tool descriptions at runtime.
9
+
10
+ ## When to use the editor
11
+
12
+ Use the editor when you want to:
13
+
14
+ - **Let non-developers iterate**: Give subject-matter experts and prompt engineers a way to tune agent behavior without touching code or waiting for deploys.
15
+ - **Version everything**: Every save creates a snapshot so you can compare changes, roll back instantly, and audit what changed and when.
16
+ - **Run experiments**: Route different users or requests to different agent versions for A/B testing, canary rollouts, or prompt experimentation.
17
+ - **Target specific versions**: Pin a version per request, per user, or per environment so production stays stable while new versions are tested.
18
+ - **Manage tools at runtime**: Add integration tools from Composio or Arcade, or connect MCP servers, without updating code.
19
+ - **Override code agents**: Change the instructions, tools, or variables of a code-defined agent while keeping the original code as the baseline.
20
+
21
+ For building agents entirely in code, see the [Agents overview](https://mastra.ai/docs/agents/overview).
22
+
23
+ ## Quickstart
24
+
25
+ Add `@mastra/editor` to your project:
26
+
27
+ **npm**:
28
+
29
+ ```bash
30
+ npm install @mastra/editor
31
+ ```
32
+
33
+ **pnpm**:
34
+
35
+ ```bash
36
+ pnpm add @mastra/editor
37
+ ```
38
+
39
+ **Yarn**:
40
+
41
+ ```bash
42
+ yarn add @mastra/editor
43
+ ```
44
+
45
+ **Bun**:
46
+
47
+ ```bash
48
+ bun add @mastra/editor
49
+ ```
50
+
51
+ Pass a `MastraEditor` instance to your Mastra configuration with your existing agents:
52
+
53
+ ```typescript
54
+ import { Mastra } from '@mastra/core'
55
+ import { MastraEditor } from '@mastra/editor'
56
+
57
+ export const mastra = new Mastra({
58
+ agents: {
59
+ /* your existing agents */
60
+ },
61
+ editor: new MastraEditor(),
62
+ })
63
+ ```
64
+
65
+ Once registered, you can manage agents through [Studio](https://mastra.ai/docs/studio/overview) or programmatically through the server API and Client SDK.
66
+
67
+ > **Note:** See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for all configuration options.
68
+
69
+ ## Studio
70
+
71
+ Go to the **Agents** tab in Studio and select an agent to edit. Select the **Editor** tab. You'll be taken to the editor interface, where you can modify the agent's instructions, tools, and variables.
72
+
73
+ Modify the system prompt and save a new draft version. Afterwards, publish the draft to make it the active version.
74
+
75
+ ## What can be overridden
76
+
77
+ When you edit a code-defined agent through the editor, only specific fields can be changed:
78
+
79
+ | Field | Description |
80
+ | ------------ | ------------------------------------------------------------------------------------------------------------- |
81
+ | Instructions | Replace or extend the agent's system prompt using [prompt blocks](https://mastra.ai/docs/editor/prompts). |
82
+ | Tools | Add tools from the tool registry, integration providers, or MCP clients. Code-defined tools remain available. |
83
+
84
+ Fields like the agent's `id`, `name`, and `model` come from your code and can't be changed through the editor for code-defined agents. The variables are also read-only.
85
+
86
+ ## Versioning
87
+
88
+ Every time you save changes to an agent or prompt block, a new version snapshot is created. Versions give you a full history of your agent's configuration. You can roll back to any previous state, compare what changed between two snapshots, and target specific versions per request for A/B testing or gradual rollouts.
89
+
90
+ Version management is available through the server Studio, REST API, the Client SDK, and the React SDK. See the [Client SDK agents reference](https://mastra.ai/reference/client-js/agents) for endpoints, SDK methods, and code examples.
91
+
92
+ ### Version lifecycle
93
+
94
+ Each version has one of three statuses:
95
+
96
+ | Status | Description |
97
+ | --------- | ----------------------------------------------------------------------------------- |
98
+ | Draft | The latest working copy. Every save creates a new draft version. |
99
+ | Published | The active version used in production. Only one version can be published at a time. |
100
+ | Archived | A previous version that is no longer active. You can restore any archived version. |
101
+
102
+ The typical flow is: Edit the draft, test it, then activate it to make it the published version. The previously published version becomes archived so you can restore it if needed. You can do this through Studio or programmatically through the API.
103
+
104
+ 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.
105
+
106
+ ### Version targeting and experimentation
107
+
108
+ Because every version has a unique ID, you can route different requests to different agent configurations. This opens up several patterns:
109
+
110
+ - **A/B testing**: Split traffic between two published versions and compare performance metrics.
111
+ - **Canary rollouts**: Send a small percentage of requests to a new version before promoting it.
112
+ - **Per-user targeting**: Pin specific users or accounts to a version while others use the default.
113
+ - **Environment separation**: Use the draft version in staging and the published version in production.
114
+
115
+ 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.
116
+
117
+ ### Version selection
118
+
119
+ By default, [`mastra.getAgentById()`](https://mastra.ai/reference/core/getAgentById) loads the published (active) version of the stored override. You can request a specific version, which is useful for testing a draft before publishing, running A/B experiments, or pinning a user to a known-good configuration:
120
+
121
+ ```typescript
122
+ // Load the published version (default)
123
+ const agent = mastra.getAgentById('support-agent')
124
+
125
+ // Load the latest draft
126
+ const agent = mastra.getAgentById('support-agent', {
127
+ status: 'draft',
128
+ })
129
+
130
+ // Load a specific version
131
+ const agent = mastra.getAgentById('support-agent', {
132
+ versionId: 'abc-123',
133
+ })
134
+ ```
135
+
136
+ When calling the agent through the Mastra server, pass version parameters as query strings:
137
+
138
+ ```bash
139
+ # Published version (default)
140
+ curl http://localhost:4111/agents/support-agent
141
+
142
+ # Latest draft
143
+ curl http://localhost:4111/agents/support-agent?status=draft
144
+
145
+ # Specific version
146
+ curl http://localhost:4111/agents/support-agent?versionId=abc-123
147
+ ```
148
+
149
+ See the [Client SDK agents reference](https://mastra.ai/reference/client-js/agents) for API methods.
150
+
151
+ ## Next steps
152
+
153
+ - Set up [prompts](https://mastra.ai/docs/editor/prompts) to build reusable instruction templates.
154
+ - Add [tools](https://mastra.ai/docs/editor/tools) from integration providers and MCP servers.
155
+ - Explore the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for all configuration options.
@@ -439,4 +439,140 @@ Delete a stored agent:
439
439
  ```typescript
440
440
  const result = await storedAgent.delete()
441
441
  console.log(result.success) // true
442
+ ```
443
+
444
+ ## Version management
445
+
446
+ Both `Agent` (code-defined) and `StoredAgent` instances have methods for managing configuration versions. See the [Editor overview](https://mastra.ai/docs/editor/overview) for an introduction to version management.
447
+
448
+ ### Server endpoints
449
+
450
+ Version management is also available through the stored agents REST API:
451
+
452
+ | Method | Endpoint | Description |
453
+ | -------- | ------------------------------------------------------------ | --------------------------------------- |
454
+ | `GET` | `/stored/agents/:agentId/versions` | List all versions. |
455
+ | `POST` | `/stored/agents/:agentId/versions` | Create a new version. |
456
+ | `GET` | `/stored/agents/:agentId/versions/:versionId` | Get a specific version. |
457
+ | `POST` | `/stored/agents/:agentId/versions/:versionId/activate` | Set the active version. |
458
+ | `POST` | `/stored/agents/:agentId/versions/:versionId/restore` | Restore a version (creates a new copy). |
459
+ | `DELETE` | `/stored/agents/:agentId/versions/:versionId` | Delete a version. |
460
+ | `GET` | `/stored/agents/:agentId/versions/compare?from=<id>&to=<id>` | Compare two versions. |
461
+
462
+ ### Getting an agent with a specific version
463
+
464
+ Pass a version identifier when getting an agent:
465
+
466
+ ```typescript
467
+ // Load the published version (default)
468
+ const agent = mastraClient.getAgent('support-agent')
469
+
470
+ // Load the latest draft
471
+ const draftAgent = mastraClient.getAgent('support-agent', { status: 'draft' })
472
+
473
+ // Load a specific version
474
+ const versionedAgent = mastraClient.getAgent('support-agent', { versionId: 'abc-123' })
475
+ ```
476
+
477
+ For stored agents, pass a status option to `details()`:
478
+
479
+ ```typescript
480
+ const storedAgent = mastraClient.getStoredAgent('my-agent')
481
+ const draft = await storedAgent.details(undefined, { status: 'draft' })
482
+ ```
483
+
484
+ ### `listVersions()`
485
+
486
+ List all versions for an agent:
487
+
488
+ ```typescript
489
+ const versions = await agent.listVersions()
490
+ console.log(versions.items) // Array of version snapshots
491
+ console.log(versions.total)
492
+ ```
493
+
494
+ With pagination and sorting:
495
+
496
+ ```typescript
497
+ const versions = await agent.listVersions({
498
+ page: 0,
499
+ perPage: 10,
500
+ orderBy: {
501
+ field: 'createdAt',
502
+ direction: 'DESC',
503
+ },
504
+ })
505
+ ```
506
+
507
+ ### `createVersion()`
508
+
509
+ Create a new version snapshot:
510
+
511
+ ```typescript
512
+ const version = await agent.createVersion({
513
+ changeMessage: 'Updated tone to be more friendly',
514
+ })
515
+ ```
516
+
517
+ ### `getVersion()`
518
+
519
+ Get a specific version by ID:
520
+
521
+ ```typescript
522
+ const version = await agent.getVersion('version-123')
523
+ console.log(version.versionNumber)
524
+ console.log(version.changedFields)
525
+ console.log(version.createdAt)
526
+ ```
527
+
528
+ ### `activateVersion()`
529
+
530
+ Set a version as the active published version:
531
+
532
+ ```typescript
533
+ await agent.activateVersion('version-123')
534
+ ```
535
+
536
+ ### `restoreVersion()`
537
+
538
+ Restore a previous version by creating a new version with the same configuration:
539
+
540
+ ```typescript
541
+ await agent.restoreVersion('version-456')
542
+ ```
543
+
544
+ ### `deleteVersion()`
545
+
546
+ Delete a version:
547
+
548
+ ```typescript
549
+ await agent.deleteVersion('version-789')
550
+ ```
551
+
552
+ ### `compareVersions()`
553
+
554
+ Compare two versions and return their differences:
555
+
556
+ ```typescript
557
+ const diff = await agent.compareVersions('version-123', 'version-456')
558
+ console.log(diff.changes) // Fields that changed between versions
559
+ ```
560
+
561
+ ### React SDK
562
+
563
+ In the React SDK, pass an `agentVersionId` through `requestContext` when using the `useChat` hook:
564
+
565
+ ```typescript
566
+ import { useChat } from '@mastra/react'
567
+
568
+ function Chat() {
569
+ const { messages, input, handleInputChange, handleSubmit } = useChat({
570
+ agentId: 'support-agent',
571
+ requestContext: {
572
+ agentVersionId: 'abc-123',
573
+ },
574
+ })
575
+
576
+ // ... render chat UI
577
+ }
442
578
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "1.13.2-alpha.1",
3
+ "version": "1.13.2",
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.24.0-alpha.1",
41
- "@mastra/schema-compat": "1.2.7"
40
+ "@mastra/schema-compat": "1.2.7",
41
+ "@mastra/core": "1.24.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-v4": "0.0.27",
57
- "@internal/ai-sdk-v5": "0.0.27",
58
- "@internal/types-builder": "0.0.55",
59
- "@internal/lint": "0.0.80"
56
+ "@internal/ai-sdk-v4": "0.0.28",
57
+ "@internal/types-builder": "0.0.56",
58
+ "@internal/ai-sdk-v5": "0.0.28",
59
+ "@internal/lint": "0.0.81"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">=22.13.0"