@mastra/libsql 1.19.0-alpha.1 → 1.19.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,85 @@
1
1
  # @mastra/libsql
2
2
 
3
+ ## 1.19.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added persistence for dataset item undeclared tool policies. ([#19643](https://github.com/mastra-ai/mastra/pull/19643))
8
+
9
+ ```typescript
10
+ await dataset.addItem({
11
+ input: 'What is the weather?',
12
+ unmockedToolPolicy: 'deny',
13
+ });
14
+ ```
15
+
16
+ ### Patch Changes
17
+
18
+ - Added a comment column to experiment results so review comments persist. The column is added automatically and non-destructively on startup for existing databases (https://github.com/mastra-ai/mastra/issues/19857). ([#19865](https://github.com/mastra-ai/mastra/pull/19865))
19
+
20
+ - Dataset item scorer selections now persist across LibSQL writes and reads. Setting `scorerIds` to `null` clears an item override, while `[]` remains an explicit override with no scorers. ([#20191](https://github.com/mastra-ai/mastra/pull/20191))
21
+
22
+ ```typescript
23
+ await dataset.addItem({
24
+ input: 'Evaluate this response',
25
+ scorerIds: [],
26
+ });
27
+ ```
28
+
29
+ - Stored workflow definitions now persist across restarts on every major database backend. ([#20471](https://github.com/mastra-ai/mastra/pull/20471))
30
+
31
+ Implement the `workflowDefinitions` storage domain for libsql, pg, mysql, mssql, mongodb, and spanner. Previously the stored-workflow persistence path (`POST /stored/workflows`, `Mastra.addStoredWorkflow`) only worked against `@mastra/core`'s in-memory store. Persistent adapters returned `undefined` from `storage.getStore('workflowDefinitions')` and threw when the HTTP handler tried to read/write a workflow.
32
+
33
+ ```ts
34
+ const workflowDefinitions = await storage.getStore('workflowDefinitions');
35
+ if (!workflowDefinitions) {
36
+ throw new Error('This storage adapter does not support the workflowDefinitions domain');
37
+ }
38
+
39
+ await workflowDefinitions.upsert({
40
+ id: 'greeting-workflow',
41
+ inputSchema: { type: 'object', properties: { name: { type: 'string' } }, required: ['name'] },
42
+ outputSchema: { type: 'object', properties: { text: { type: 'string' } }, required: ['text'] },
43
+ graph: [{ type: 'agent', id: 'greet', agentId: 'greeter-agent' }],
44
+ });
45
+
46
+ const { definitions, total } = await workflowDefinitions.list({ status: 'active' });
47
+ const definition = await workflowDefinitions.get('greeting-workflow');
48
+ await workflowDefinitions.delete('greeting-workflow');
49
+ ```
50
+
51
+ Each adapter now ships a `WorkflowDefinitions*` domain that:
52
+
53
+ - Creates the shared `mastra_workflow_definitions` table (or Mongo collection) from `WORKFLOW_DEFINITIONS_SCHEMA` during `init()`, plus a default index on `status`.
54
+ - Implements `upsert` / `get` / `list` / `delete` matching `WorkflowDefinitionsStorage` semantics (`list` supports `status` and `authorId` filters and orders by `updatedAt` desc). Partial upserts preserve unspecified fields, including `authorId` updates and `createdAt` / `updatedAt` semantics.
55
+ - Handles concurrent first-writes race-safely: if two callers upsert the same new id simultaneously, the losing insert detects the duplicate key, re-reads the row, and applies the partial-update path instead of failing.
56
+ - Round-trips the JSON columns (`inputSchema`, `outputSchema`, `stateSchema`, `requestContextSchema`, `metadata`, `graph`) through each adapter's JSON handling, so declarative workflow graphs rehydrate identically no matter which backend they were stored in. Malformed persisted JSON surfaces as an actionable error naming the row and column instead of hydrating raw strings.
57
+
58
+ Exported class names by adapter: `WorkflowDefinitionsLibSQL`, `WorkflowDefinitionsPG`, `WorkflowDefinitionsMySQL`, `WorkflowDefinitionsMSSQL`, `MongoDBWorkflowDefinitionsStore`, `WorkflowDefinitionsSpanner`. The composite stores (`LibSQLStore`, `PostgresStore`, `MySQLStore`, `MSSQLStore`, `MongoDBStore`, `SpannerStore`) auto-wire the new domain, so callers do not need to construct it manually — `storage.getStore('workflowDefinitions')` now returns a live handle.
59
+
60
+ The pg adapter reads `createdAt` / `updatedAt` from the auto-added `createdAtZ` / `updatedAtZ` `timestamptz` companion columns to avoid the naive-timestamp / local-TZ drift that a plain `TIMESTAMP` read exhibits under node-pg.
61
+
62
+ `@mastra/clickhouse` and `@mastra/cloudflare` register the new `mastra_workflow_definitions` table in their table/type maps so shared table constants stay exhaustive (no workflow-definitions domain implementation yet).
63
+
64
+ - Updated dependencies [[`4844167`](https://github.com/mastra-ai/mastra/commit/4844167cff2d5ec5004e94edd34970833040fa3f), [`c5e56ff`](https://github.com/mastra-ai/mastra/commit/c5e56ff3bcabdf062708f2d48744fec304df6792), [`594f7b2`](https://github.com/mastra-ai/mastra/commit/594f7b28f5263fb9982fd50d95c471fb971ea984), [`7f4e26d`](https://github.com/mastra-ai/mastra/commit/7f4e26dd57bd9b23c278ea21235ab823a3810a6c), [`311f943`](https://github.com/mastra-ai/mastra/commit/311f943bee60e8fdf5c84499ea50e884276c936c), [`322daa6`](https://github.com/mastra-ai/mastra/commit/322daa6d90552909204044790d850958f6745fed), [`db4e6ff`](https://github.com/mastra-ai/mastra/commit/db4e6ff744503112eb64deeaf6c2b54bf26a54c7), [`5faf93f`](https://github.com/mastra-ai/mastra/commit/5faf93f03e19daea394b9e2a923f2e4f833407f2), [`82201f7`](https://github.com/mastra-ai/mastra/commit/82201f75fae8e050a8de2df08b74875ee74c6b83), [`cadaa13`](https://github.com/mastra-ai/mastra/commit/cadaa1372e1077c8e85eb64c5499ba8803caa323), [`0c89896`](https://github.com/mastra-ai/mastra/commit/0c8989673fb7d106837098398131e570c6023b68), [`6d19a65`](https://github.com/mastra-ai/mastra/commit/6d19a6517f5da3911023d446b7e2d5dad8adb1cb), [`23b4238`](https://github.com/mastra-ai/mastra/commit/23b423844ad0bcf2a502a68dd62866d6160f9f6d), [`80ad891`](https://github.com/mastra-ai/mastra/commit/80ad891f8cd10379aa5b5af7510c763783b2ab56), [`fb18da5`](https://github.com/mastra-ai/mastra/commit/fb18da56fc35689ae370621a8f10b5b0d8606e20), [`fb18da5`](https://github.com/mastra-ai/mastra/commit/fb18da56fc35689ae370621a8f10b5b0d8606e20), [`e320a76`](https://github.com/mastra-ai/mastra/commit/e320a763feaf65c6be3cebecf746defcbde161b3), [`03b4918`](https://github.com/mastra-ai/mastra/commit/03b4918c80d188ce375334c393e131c6e94bd7eb), [`14ef73a`](https://github.com/mastra-ai/mastra/commit/14ef73a4bbd73e7808414816eb0628ce1d80b5d7), [`b582f7f`](https://github.com/mastra-ai/mastra/commit/b582f7fa2f9c1f87d19efc63d344fbe5dda2608c), [`0a6598b`](https://github.com/mastra-ai/mastra/commit/0a6598bde80bde008986ad6616bed9632b9294cb), [`06000d7`](https://github.com/mastra-ai/mastra/commit/06000d73712911572e913b8a83339270296d0a22), [`1d677d5`](https://github.com/mastra-ai/mastra/commit/1d677d5f99d7db403f7828585e8c25f299f72628), [`9e1dad8`](https://github.com/mastra-ai/mastra/commit/9e1dad8f7b1cab2bb7ade90e5b7561f24577b88a), [`2f43145`](https://github.com/mastra-ai/mastra/commit/2f4314504c03cbba280414ac81ba3197448ee6b0), [`4e35a56`](https://github.com/mastra-ai/mastra/commit/4e35a56cdf8d74a5ff6d5eda01f2c1deaf6cc7be), [`d94b8e1`](https://github.com/mastra-ai/mastra/commit/d94b8e1cee67416d518a8c30099040061bef6a1c), [`93e28ec`](https://github.com/mastra-ai/mastra/commit/93e28ecce9031c02397e0ae8406593e5c7a95883), [`729dab4`](https://github.com/mastra-ai/mastra/commit/729dab408faccfaef0cbb048e5a4338f9172847e), [`484003d`](https://github.com/mastra-ai/mastra/commit/484003d33ff59330c86b19863e4a38732d7e4155), [`3de0188`](https://github.com/mastra-ai/mastra/commit/3de0188bfaf9a9c09c95fe322b53838cf52c70b6), [`34d34d8`](https://github.com/mastra-ai/mastra/commit/34d34d8c811df512fef4dd5459f79b7821be1866), [`b582f7f`](https://github.com/mastra-ai/mastra/commit/b582f7fa2f9c1f87d19efc63d344fbe5dda2608c), [`933d291`](https://github.com/mastra-ai/mastra/commit/933d291146b789c19442ad206f94da3e4be90c64), [`a1cb98d`](https://github.com/mastra-ai/mastra/commit/a1cb98d11990b560b98482292a1f34aa1a2d9092), [`598ad82`](https://github.com/mastra-ai/mastra/commit/598ad82d41c41389a686338a1d0e50b7400e1938), [`1fd6aad`](https://github.com/mastra-ai/mastra/commit/1fd6aad1ea4a9d32f65efa832307c35e981a4c0a)]:
65
+ - @mastra/core@1.56.0
66
+
67
+ ## 1.19.0-alpha.2
68
+
69
+ ### Patch Changes
70
+
71
+ - Dataset item scorer selections now persist across LibSQL writes and reads. Setting `scorerIds` to `null` clears an item override, while `[]` remains an explicit override with no scorers. ([#20191](https://github.com/mastra-ai/mastra/pull/20191))
72
+
73
+ ```typescript
74
+ await dataset.addItem({
75
+ input: 'Evaluate this response',
76
+ scorerIds: [],
77
+ });
78
+ ```
79
+
80
+ - Updated dependencies [[`82201f7`](https://github.com/mastra-ai/mastra/commit/82201f75fae8e050a8de2df08b74875ee74c6b83), [`fb18da5`](https://github.com/mastra-ai/mastra/commit/fb18da56fc35689ae370621a8f10b5b0d8606e20), [`fb18da5`](https://github.com/mastra-ai/mastra/commit/fb18da56fc35689ae370621a8f10b5b0d8606e20), [`0a6598b`](https://github.com/mastra-ai/mastra/commit/0a6598bde80bde008986ad6616bed9632b9294cb), [`9e1dad8`](https://github.com/mastra-ai/mastra/commit/9e1dad8f7b1cab2bb7ade90e5b7561f24577b88a), [`2f43145`](https://github.com/mastra-ai/mastra/commit/2f4314504c03cbba280414ac81ba3197448ee6b0), [`34d34d8`](https://github.com/mastra-ai/mastra/commit/34d34d8c811df512fef4dd5459f79b7821be1866)]:
81
+ - @mastra/core@1.56.0-alpha.6
82
+
3
83
  ## 1.19.0-alpha.1
4
84
 
5
85
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-libsql
3
3
  description: Documentation for @mastra/libsql. Use when working with @mastra/libsql APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/libsql"
6
- version: "1.19.0-alpha.1"
6
+ version: "1.19.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -16,24 +16,23 @@ Read the individual reference documents for detailed explanations and code examp
16
16
 
17
17
  ### Docs
18
18
 
19
- - [Deploying](references/docs-agent-builder-deploying.md) - Swap local Agent Builder primitives for cloud-backed storage, filesystems, sandboxes, an EE license, auth, and a public channel URL for production.
20
- - [Agent Builder overview](references/docs-agent-builder-overview.md) - Let teammates create, configure, and operate Mastra agents from a browser, with admin-pinned defaults, RBAC, and channel integrations.
21
19
  - [Agent approval](references/docs-agents-agent-approval.md) - Learn how to require approvals and suspend tool execution, plus automatically resume suspended tools while keeping humans in control of agent workflows.
22
20
  - [Agent networks](references/docs-agents-networks.md) - Coordinate multiple agents, workflows, and tools using agent networks for complex, non-deterministic task execution.
23
21
  - [Workers](references/docs-deployment-workers.md) - Separate background processing from the API layer by running workflow execution, cron schedules, and background tasks in dedicated worker processes.
22
+ - [Editor](references/docs-editor-overview.md) - Let collaborators update an agent in Studio, test their changes, and publish without editing code.
24
23
  - [Memory processors](references/docs-memory-memory-processors.md) - Learn how to use memory processors in Mastra to filter, trim, and transform messages before they're sent to the language model to manage context window limits.
25
24
  - [Message history](references/docs-memory-message-history.md) - Learn how to configure message history in Mastra to store recent messages from the current conversation.
26
25
  - [Multi-user threads](references/docs-memory-multi-user-threads.md) - Share one Mastra thread between multiple users by carrying speaker identity in the message body.
27
26
  - [Memory overview](references/docs-memory-overview.md) - Learn how Mastra's memory system works with working memory, message history, semantic recall, and observational memory.
28
27
  - [Semantic recall](references/docs-memory-semantic-recall.md) - Learn how to use semantic recall in Mastra to retrieve relevant messages from past conversations using vector search and embeddings.
29
28
  - [Working memory](references/docs-memory-working-memory.md) - Learn how to configure working memory in Mastra to store persistent user data, preferences.
30
- - [Retrieval, semantic search, reranking](references/docs-rag-retrieval.md) - Guide on retrieval processes in Mastra's RAG systems, including semantic search, filtering, and re-ranking.
31
29
  - [Storage overview](references/docs-storage-overview.md) - Configure storage for Mastra to persist runtime state across agents, workflows, observability, evals, schedules, and memory.
32
30
  - [Snapshots](references/docs-workflows-snapshots.md) - Learn how to save and resume workflow execution state with snapshots in Mastra
33
31
 
34
32
  ### Guides
35
33
 
36
34
  - [AI SDK](references/guides-agent-frameworks-ai-sdk.md) - Use Mastra processors and memory with the Vercel AI SDK
35
+ - [Retrieval, semantic search, reranking](references/guides-rag-retrieval.md) - Guide on retrieval processes in Mastra's RAG systems, including semantic search, filtering, and re-ranking.
37
36
 
38
37
  ### Reference
39
38
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.0-alpha.1",
2
+ "version": "1.19.0",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -0,0 +1,349 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Editor
4
+
5
+ Editor works like a CMS for Mastra agents. Collaborators can change an agent's instructions and tools in Studio without accessing the codebase or writing code. They can test changes before making them live.
6
+
7
+ TypeScript defines the agent's default values. Editor saves changes separately instead of updating the source code, so collaborators can improve the agent while developers retain control over its model, identity, and runtime.
8
+
9
+ A [deployed Studio](https://mastra.ai/docs/studio/deployment) makes Editor available to collaborators outside local development.
10
+
11
+ > **📹 Watch:** Watch the [Mastra Editor workshop](https://www.youtube.com/watch?v=XTjuRoI7t_k\&pp=ygUWbWFzdHJhIGVkaXRvciB3b3Jrc2hvcA%3D%3D) for a guided walkthrough.
12
+
13
+ ## When to use Editor
14
+
15
+ Use Editor when an agent is defined in code but the people responsible for its behavior shouldn't edit the codebase. It works well when instructions or tools change often and need testing before they reach users. If developers own every change and release agent configuration with the application, keep the [agent configuration in code](https://mastra.ai/docs/agents/overview) instead.
16
+
17
+ ## Quickstart
18
+
19
+ Install `@mastra/editor`. This quickstart uses LibSQL to store Editor changes:
20
+
21
+ **npm**:
22
+
23
+ ```bash
24
+ npm install @mastra/editor @mastra/libsql
25
+ ```
26
+
27
+ **pnpm**:
28
+
29
+ ```bash
30
+ pnpm add @mastra/editor @mastra/libsql
31
+ ```
32
+
33
+ **Yarn**:
34
+
35
+ ```bash
36
+ yarn add @mastra/editor @mastra/libsql
37
+ ```
38
+
39
+ **Bun**:
40
+
41
+ ```bash
42
+ bun add @mastra/editor @mastra/libsql
43
+ ```
44
+
45
+ Add `MastraEditor` and storage to the `Mastra` instance. Existing storage can be reused instead of adding the LibSQL store shown here.
46
+
47
+ ```typescript
48
+ import { Mastra } from '@mastra/core'
49
+ import { MastraEditor } from '@mastra/editor'
50
+ import { LibSQLStore } from '@mastra/libsql'
51
+
52
+ export const mastra = new Mastra({
53
+ agents: {/* existing agents */},
54
+ storage: new LibSQLStore({
55
+ id: 'mastra-storage',
56
+ url: 'file:./mastra.db',
57
+ }),
58
+ editor: new MastraEditor(),
59
+ })
60
+ ```
61
+
62
+ ## Use Editor in Studio
63
+
64
+ In [Studio](https://mastra.ai/docs/studio/overview), open **Agents**, select an agent, then select **Editor**. Collaborators can update the agent's instructions and tools based on its Editor permissions.
65
+
66
+ With database storage, save changes as a draft to test them without affecting the live agent. Publish the draft when it's ready to use.
67
+
68
+ ## Instructions
69
+
70
+ The **Instructions** section shows the agent's system prompt defined in code. Collaborators can override it or add instruction blocks.
71
+
72
+ An instruction block can include values from the current request. For example, `{{userName}}` inserts a name supplied through [request context](https://mastra.ai/docs/server/request-context). A [display condition](https://mastra.ai/reference/editor/prompt-blocks) can show a block only for a customer, role, or feature flag.
73
+
74
+ ### Prompt blocks
75
+
76
+ A prompt block is a saved piece of instruction text that can be used by more than one agent. Create one under **Prompts**, publish it, then open an agent's **Instructions** section and select **Add block**.
77
+
78
+ For example, agents for support, returns, and order status may all need the same refund policy. Save the policy as a prompt block and add it to each agent. When the policy changes, update and publish the block once instead of editing three agents.
79
+
80
+ When a prompt block changes, every agent that references its published version receives the update. Draft changes are used only while previewing, so they don't affect the live agents until the block is published.
81
+
82
+ See the [prompt blocks reference](https://mastra.ai/reference/editor/prompt-blocks) for template syntax, conditions, versions, and APIs.
83
+
84
+ ## Tools
85
+
86
+ Tools let an agent take actions. Collaborators choose from the tools available to Editor, but they can't implement new tools in Studio. How tools become available depends on their source:
87
+
88
+ - **Project tools** must be implemented and registered in the Mastra project by a developer.
89
+ - **Integration tools** become available after a developer registers a provider such as Composio or Arcade. Collaborators can then browse the provider's catalog and add tools without each tool being added in code first.
90
+ - **MCP tools** become available when an MCP client is configured. A collaborator with access can create the client in Studio, then choose from the tools exposed by its servers.
91
+
92
+ In the agent's **Tools** section, collaborators can add the tools it needs or rewrite a tool's description for that agent. A more specific description helps the agent understand when to use the tool without changing the tool itself.
93
+
94
+ ### Project tools
95
+
96
+ Developers can register a project tool on the `Mastra` instance to make it available in Editor:
97
+
98
+ ```typescript
99
+ import { Mastra } from '@mastra/core'
100
+ import { MastraEditor } from '@mastra/editor'
101
+ import { searchOrders } from './tools/search-orders'
102
+
103
+ export const mastra = new Mastra({
104
+ tools: {
105
+ searchOrders,
106
+ },
107
+ agents: {/* agents */},
108
+ editor: new MastraEditor(),
109
+ })
110
+ ```
111
+
112
+ The Studio tool picker lists the tool. A collaborator can add it to an agent when that agent allows tool editing. The agent's Editor view also lists tools attached in code.
113
+
114
+ ### Composio
115
+
116
+ [Composio](https://composio.dev) provides tools for services such as GitHub, Slack, and Gmail. Register the provider with a Composio API key to make its tool catalog available in Editor:
117
+
118
+ ```typescript
119
+ import { Mastra } from '@mastra/core'
120
+ import { MastraEditor } from '@mastra/editor'
121
+ import { ComposioToolProvider } from '@mastra/editor/composio'
122
+
123
+ export const mastra = new Mastra({
124
+ agents: {/* agents */},
125
+ editor: new MastraEditor({
126
+ toolProviders: {
127
+ composio: new ComposioToolProvider({
128
+ apiKey: process.env.COMPOSIO_API_KEY!,
129
+ }),
130
+ },
131
+ }),
132
+ })
133
+ ```
134
+
135
+ Composio tool IDs look like `GITHUB_CREATE_ISSUE`. By default, a selected tool uses the connection associated with the agent's author. See [connection scope](https://agent-builder.mastra.ai/tool-providers#connection-scope) to use each caller's connection instead.
136
+
137
+ ### Arcade
138
+
139
+ [Arcade](https://arcade.dev) provides another catalog of tools with built-in authentication. Register it with an Arcade API key:
140
+
141
+ ```typescript
142
+ import { Mastra } from '@mastra/core'
143
+ import { MastraEditor } from '@mastra/editor'
144
+ import { ArcadeToolProvider } from '@mastra/editor/arcade'
145
+
146
+ export const mastra = new Mastra({
147
+ agents: {/* agents */},
148
+ editor: new MastraEditor({
149
+ toolProviders: {
150
+ arcade: new ArcadeToolProvider({
151
+ apiKey: process.env.ARCADE_API_KEY!,
152
+ }),
153
+ },
154
+ }),
155
+ })
156
+ ```
157
+
158
+ Arcade tool IDs use `Toolkit.ToolName` format, such as `Github.GetRepository`.
159
+
160
+ ### MCP clients
161
+
162
+ Collaborators can also create a reusable MCP client in Studio and add its tools to an agent. Stored clients can start a local `stdio` server or connect to a remote HTTP server. Tool filters let each agent use only the tools it needs from that server.
163
+
164
+ See the [Editor tools reference](https://mastra.ai/reference/editor/tools) for MCP configuration, conditions, filtering, and resolution order. See [`ToolProvider`](https://mastra.ai/reference/editor/tool-provider) for provider options.
165
+
166
+ ## Decide what collaborators can edit
167
+
168
+ By default, collaborators can change an agent's instructions and manage its tools, including their descriptions. The agent's `id`, `name`, and `model` always come from code.
169
+
170
+ Use the agent's `editor` field to limit what can be changed:
171
+
172
+ ```typescript
173
+ import { Agent } from '@mastra/core/agent'
174
+
175
+ export const supportAgent = new Agent({
176
+ id: 'support-agent',
177
+ name: 'Support agent',
178
+ instructions: 'Help customers with Acme products.',
179
+ model: 'openai/gpt-5.6-sol',
180
+ editor: {
181
+ instructions: true,
182
+ tools: {
183
+ description: true,
184
+ },
185
+ },
186
+ })
187
+ ```
188
+
189
+ This agent lets collaborators change its instructions and improve the descriptions of tools already attached to it. They can't add or remove tools.
190
+
191
+ | `editor` value | What collaborators can change |
192
+ | ---------------------------------- | ------------------------------------------- |
193
+ | Omitted | Instructions, tools, and tool descriptions |
194
+ | `false` | Nothing |
195
+ | `{ instructions: true }` | Instructions |
196
+ | `{ tools: true }` | Tools and tool descriptions |
197
+ | `{ tools: { description: true } }` | Descriptions of tools already added in code |
198
+
199
+ Studio shows everything else as read-only. See [editor overrides](https://mastra.ai/reference/agents/agent) for the complete configuration.
200
+
201
+ ## Choose where changes are stored
202
+
203
+ Editor can save changes in the configured database or as files in the repository.
204
+
205
+ ### Database storage
206
+
207
+ The database option is the default. Editor uses the storage configured on the `Mastra` instance, so the application and Editor can share the same backend.
208
+
209
+ To use a separate backend for Editor data, set the `editor` option on [`MastraCompositeStore`](https://mastra.ai/reference/storage/composite). Storage domains without an explicit route continue to use its `default` store.
210
+
211
+ The following example keeps application and Editor data in separate LibSQL files:
212
+
213
+ ```typescript
214
+ import { Mastra } from '@mastra/core'
215
+ import { MastraCompositeStore } from '@mastra/core/storage'
216
+ import { MastraEditor } from '@mastra/editor'
217
+ import { LibSQLStore } from '@mastra/libsql'
218
+
219
+ export const mastra = new Mastra({
220
+ agents: {/* existing agents */},
221
+ storage: new MastraCompositeStore({
222
+ id: 'mastra-storage',
223
+ default: new LibSQLStore({
224
+ id: 'app-storage',
225
+ url: 'file:./mastra.db',
226
+ }),
227
+ editor: new LibSQLStore({
228
+ id: 'editor-storage',
229
+ url: 'file:./editor.db',
230
+ }),
231
+ }),
232
+ editor: new MastraEditor(),
233
+ })
234
+ ```
235
+
236
+ ### Repository files
237
+
238
+ Use the code source to keep overrides alongside application code. Developers can review the files in pull requests and deploy them with the application:
239
+
240
+ ```typescript
241
+ import { Mastra } from '@mastra/core'
242
+ import { MastraEditor } from '@mastra/editor'
243
+
244
+ export const mastra = new Mastra({
245
+ agents: {/* existing agents */},
246
+ editor: new MastraEditor({
247
+ source: 'code',
248
+ codePath: './mastra/editor',
249
+ }),
250
+ })
251
+ ```
252
+
253
+ In this mode, each edited agent has one JSON override file. Editor doesn't generate TypeScript or change the file where the agent was created. By default, an agent with the ID `support-agent` gets this file:
254
+
255
+ ```text
256
+ mastra/editor/agents/support-agent.json
257
+ ```
258
+
259
+ The file contains only the parts managed by Editor. For example:
260
+
261
+ ```json
262
+ {
263
+ "instructions": "Help customers with Acme products and answer in their language.",
264
+ "tools": {
265
+ "searchOrders": {
266
+ "description": "Look up an order by its number"
267
+ }
268
+ }
269
+ }
270
+ ```
271
+
272
+ The agent's model, name, and other code-owned fields stay in its TypeScript file. Mastra reads the JSON and applies these values when the agent runs.
273
+
274
+ When a collaborator saves in Studio, they can write the file to the local filesystem or download it. With a source-control integration, Studio can open a pull request instead. Git then provides the review and version history.
275
+
276
+ See [`MastraEditor`](https://mastra.ai/reference/editor/mastra-editor) for file locations and source options.
277
+
278
+ ## Versioning
279
+
280
+ Database-backed agents and prompt blocks use draft and published versions. Saving creates a draft while the live agent continues using the published version. Publishing makes the draft live. Restoring an older version creates a draft that collaborators can test before publishing.
281
+
282
+ Code-backed agent overrides use JSON files and Git history.
283
+
284
+ ### Select a version
285
+
286
+ An application can choose a stored version for each request by passing a status (`published` or `draft`) or an exact version ID:
287
+
288
+ ```typescript
289
+ const publishedAgent = await mastra.getAgentById('support-agent', {
290
+ status: 'published',
291
+ })
292
+
293
+ const draftAgent = await mastra.getAgentById('support-agent', {
294
+ status: 'draft',
295
+ })
296
+
297
+ const versionedAgent = await mastra.getAgentById('support-agent', {
298
+ versionId: 'abc-123',
299
+ })
300
+ ```
301
+
302
+ Version selection supports:
303
+
304
+ - Compare two versions in an A/B test.
305
+ - Give a draft to a small group before publishing it for everyone.
306
+ - Keep production on the published version while staging uses the latest draft.
307
+ - Pin a customer to a particular version.
308
+
309
+ The same version controls work when a supervisor calls sub-agents. Developers can test a draft sub-agent without changing the rest of the system.
310
+
311
+ See the [Editor versioning reference](https://mastra.ai/reference/editor/versioning) for version selection, sub-agent behavior, REST endpoints, and SDK methods.
312
+
313
+ ## Programmatic access
314
+
315
+ Everything available in Studio is also available programmatically through [`mastra.getEditor()`](https://mastra.ai/reference/core/getEditor), the REST API, or the Client SDK. Use it to script bulk updates or seed stored configurations from code. It can also power automation that tunes agents based on [evaluation results](https://mastra.ai/docs/datasets/running-experiments).
316
+
317
+ Call `mastra.getEditor()` when application code has access to the Mastra instance:
318
+
319
+ ```typescript
320
+ import { mastra } from '../mastra'
321
+
322
+ const editor = mastra.getEditor()!
323
+
324
+ await editor.agent.update({
325
+ id: 'support-agent',
326
+ instructions: 'Help customers with Acme products. Reply in their language.',
327
+ })
328
+ ```
329
+
330
+ The direct `editor.agent.update()` method activates the new version immediately. To create a draft without changing the live agent, use the stored-agent REST API or Client SDK instead:
331
+
332
+ ```bash
333
+ curl -X PATCH http://localhost:4111/api/stored/agents/support-agent \
334
+ -H "Content-Type: application/json" \
335
+ -d '{
336
+ "instructions": "Help customers with Acme products. Reply in their language."
337
+ }'
338
+ ```
339
+
340
+ The default server prefix is `/api`. Developers can set a custom prefix in the server configuration.
341
+
342
+ See the [`MastraEditor` namespaces](https://mastra.ai/reference/editor/mastra-editor) and [Client SDK agents API](https://mastra.ai/reference/client-js/agents) for available operations.
343
+
344
+ ## Next steps
345
+
346
+ - [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor)
347
+ - [Prompt blocks reference](https://mastra.ai/reference/editor/prompt-blocks)
348
+ - [Editor tools reference](https://mastra.ai/reference/editor/tools)
349
+ - [Editor versioning reference](https://mastra.ai/reference/editor/versioning)
@@ -517,4 +517,4 @@ The re-ranked results combine vector similarity with semantic understanding to i
517
517
 
518
518
  For more details about re-ranking, see the [rerank()](https://mastra.ai/reference/rag/rerankWithScorer) method.
519
519
 
520
- For graph-based retrieval that follows connections between chunks, see the [GraphRAG](https://mastra.ai/docs/rag/graph-rag) documentation.
520
+ For graph-based retrieval that follows connections between chunks, see the [GraphRAG](https://mastra.ai/guides/rag/graph-rag) documentation.
@@ -97,7 +97,7 @@ Visit the [Configuration reference](https://mastra.ai/reference/configuration) f
97
97
 
98
98
  **notifications.dispatch.batchSize** (`number`): Maximum number of due notification records to process per dispatch run.
99
99
 
100
- **versions** (`VersionOverrides`): Global version overrides for sub-agent delegation. When a supervisor agent delegates to a sub-agent, these overrides determine which stored version of that sub-agent to use instead of the code-defined default. Requires the editor package to be configured. See Sub-agent versioning for details.
100
+ **versions** (`VersionOverrides`): Global version overrides for sub-agent delegation. When a supervisor agent delegates to a sub-agent, these overrides determine which stored version of that sub-agent to use instead of the code-defined default. Requires the editor package to be configured. See Editor versioning for details.
101
101
 
102
102
  **versions.agents** (`Record<string, VersionSelector>`): A map of agent IDs to their version selectors. Each selector can target a specific version by ID or by publication status.
103
103
 
@@ -188,6 +188,8 @@ export const mastra = new Mastra({
188
188
 
189
189
  **default** (`MastraCompositeStore`): Default storage adapter. Domains not explicitly specified in domains will use this storage's domains as fallbacks.
190
190
 
191
+ **editor** (`MastraCompositeStore`): Storage adapter for Editor-owned domains, including agents, prompt blocks, scorers, MCP clients and servers, workspaces, and skills. Takes precedence over default storage but not explicit domain overrides.
192
+
191
193
  **disableInit** (`boolean`): When true, automatic initialization is disabled. You must call init() explicitly.
192
194
 
193
195
  **domains** (`object`): Individual domain overrides. Each domain can come from a different storage adapter. These take precedence over both editor and default storage. Set a domain to false to disable it entirely; a disabled domain does not fall back to editor or default.