@mastra/libsql 1.19.0-alpha.0 → 1.19.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 CHANGED
@@ -1,5 +1,63 @@
1
1
  # @mastra/libsql
2
2
 
3
+ ## 1.19.0-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 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))
8
+
9
+ ```typescript
10
+ await dataset.addItem({
11
+ input: 'Evaluate this response',
12
+ scorerIds: [],
13
+ });
14
+ ```
15
+
16
+ - 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)]:
17
+ - @mastra/core@1.56.0-alpha.6
18
+
19
+ ## 1.19.0-alpha.1
20
+
21
+ ### Patch Changes
22
+
23
+ - Stored workflow definitions now persist across restarts on every major database backend. ([#20471](https://github.com/mastra-ai/mastra/pull/20471))
24
+
25
+ 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.
26
+
27
+ ```ts
28
+ const workflowDefinitions = await storage.getStore('workflowDefinitions');
29
+ if (!workflowDefinitions) {
30
+ throw new Error('This storage adapter does not support the workflowDefinitions domain');
31
+ }
32
+
33
+ await workflowDefinitions.upsert({
34
+ id: 'greeting-workflow',
35
+ inputSchema: { type: 'object', properties: { name: { type: 'string' } }, required: ['name'] },
36
+ outputSchema: { type: 'object', properties: { text: { type: 'string' } }, required: ['text'] },
37
+ graph: [{ type: 'agent', id: 'greet', agentId: 'greeter-agent' }],
38
+ });
39
+
40
+ const { definitions, total } = await workflowDefinitions.list({ status: 'active' });
41
+ const definition = await workflowDefinitions.get('greeting-workflow');
42
+ await workflowDefinitions.delete('greeting-workflow');
43
+ ```
44
+
45
+ Each adapter now ships a `WorkflowDefinitions*` domain that:
46
+
47
+ - Creates the shared `mastra_workflow_definitions` table (or Mongo collection) from `WORKFLOW_DEFINITIONS_SCHEMA` during `init()`, plus a default index on `status`.
48
+ - 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.
49
+ - 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.
50
+ - 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.
51
+
52
+ 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.
53
+
54
+ 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.
55
+
56
+ `@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).
57
+
58
+ - Updated dependencies [[`4844167`](https://github.com/mastra-ai/mastra/commit/4844167cff2d5ec5004e94edd34970833040fa3f), [`5faf93f`](https://github.com/mastra-ai/mastra/commit/5faf93f03e19daea394b9e2a923f2e4f833407f2), [`80ad891`](https://github.com/mastra-ai/mastra/commit/80ad891f8cd10379aa5b5af7510c763783b2ab56), [`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)]:
59
+ - @mastra/core@1.56.0-alpha.4
60
+
3
61
  ## 1.19.0-alpha.0
4
62
 
5
63
  ### Minor 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.0"
6
+ version: "1.19.0-alpha.2"
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.0",
2
+ "version": "1.19.0-alpha.2",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -108,7 +108,7 @@ A tool's own `requireApproval` setting takes precedence over the function above.
108
108
 
109
109
  For sensitive tools, bind the approval to the exact tool name and arguments that were shown to the reviewer. If those arguments drift before execution, the tool shouldn't run under the old approval.
110
110
 
111
- The `tool-call-approval` chunk already includes `toolName`, `toolCallId`, and `args`. You can fingerprint those fields when the approval request is shown. The example below uses a simple JSON string as the fingerprint, but in production you should use a stable hash of the tool name and arguments:
111
+ The `tool-call-approval` chunk already includes `toolName`, `toolCallId`, and `args`. You can fingerprint those fields when the approval request is shown. The example below uses a JSON string as the fingerprint, but in production you should use a stable hash of the tool name and arguments:
112
112
 
113
113
  ```typescript
114
114
  import { Agent } from '@mastra/core/agent'
@@ -174,7 +174,7 @@ async function approveReviewedToolCall(runId: string, toolCallId: string, finger
174
174
  await consumeApprovalStream(stream)
175
175
  ```
176
176
 
177
- In production, store the approved fingerprint in durable storage scoped to the user, run, tool call, and policy version. The `Set` above is intentionally small so the boundary is easy to see: the approval is consumed once, and only for the same canonical tool arguments that were reviewed.
177
+ In production, store the approved fingerprint in durable storage scoped to the user, run, tool call, and policy version. The `Set` above is intentionally small so the boundary is clear: the approval is consumed once, and only for the same canonical tool arguments that were reviewed.
178
178
 
179
179
  ### Runtime suspension with `suspend()`
180
180
 
@@ -17,7 +17,7 @@ Workers matter when any of these apply:
17
17
  - Different parts of the system need to scale independently (e.g., more orchestration capacity without more API instances)
18
18
  - Background tool calls should run on dedicated compute
19
19
 
20
- If your application handles light traffic and workflows complete quickly, the default in-process setup works fine. Skip the worker infrastructure until you need it.
20
+ If your application handles light traffic and workflows complete fast, the default in-process setup works fine. Skip the worker infrastructure until you need it.
21
21
 
22
22
  ## Worker types
23
23
 
@@ -33,11 +33,11 @@ The orchestration worker requires a PubSub backend that supports pull mode (e.g.
33
33
 
34
34
  ### Scheduler worker
35
35
 
36
- Polls storage for due cron schedules and publishes `workflow.start` events. It is a producer only, meaning it creates work for the orchestration worker to pick up.
36
+ Polls storage for due cron schedules and publishes `workflow.start` events. It's a producer only, meaning it creates work for the orchestration worker to pick up.
37
37
 
38
38
  The scheduler reads declarative `schedule` fields from your workflow definitions automatically. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows) for how to declare schedules.
39
39
 
40
- **Do not run more than one scheduler instance.** Multiple schedulers polling the same storage would fire duplicate events for the same schedule.
40
+ **Don't run more than one scheduler instance.** Multiple schedulers polling the same storage would fire duplicate events for the same schedule.
41
41
 
42
42
  ### Background task worker
43
43
 
@@ -47,7 +47,7 @@ The background task worker manages concurrency limits, task lifecycle, and resul
47
47
 
48
48
  ## How workers run
49
49
 
50
- ### In-process (default)
50
+ ### In-process mode (default)
51
51
 
52
52
  With no configuration, Mastra creates and starts workers inside the API process. Events flow through an in-memory PubSub, and everything shares a single Node.js runtime.
53
53
 
@@ -64,7 +64,7 @@ This setup needs no external infrastructure beyond your storage adapter. It does
64
64
 
65
65
  ### Split processes
66
66
 
67
- To run workers separately, configure a distributed [PubSub](https://mastra.ai/docs/server/pubsub) backend and use the `MASTRA_WORKERS` environment variable to control which workers start in each process.
67
+ To run workers in their own processes, configure a distributed [PubSub](https://mastra.ai/docs/server/pubsub) backend and use the `MASTRA_WORKERS` environment variable to control which workers start in each process.
68
68
 
69
69
  **Redis Streams + PostgreSQL**:
70
70
 
@@ -100,38 +100,38 @@ export const mastra = new Mastra({
100
100
  })
101
101
  ```
102
102
 
103
- Any [supported storage backend](https://mastra.ai/reference/workers/overview) works swap the storage adapter for your preferred database.
103
+ Any [supported storage backend](https://mastra.ai/reference/workers/overview) works. Swap the storage adapter for your preferred database.
104
104
 
105
105
  Run the same build artifact in multiple containers, each with a different [`MASTRA_WORKERS`](https://mastra.ai/reference/workers/overview) value to control which worker starts in each process.
106
106
 
107
107
  Split deployments require a distributed PubSub backend ([`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams) or [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub)), a shared [storage backend](https://mastra.ai/reference/workers/overview), and network connectivity between the orchestration worker and the API.
108
108
 
109
- The [worker deployment guide](https://mastra.ai/guides/deployment/mastra-workers) walks through this setup with a Docker Compose example.
109
+ The [worker deployment guide](https://mastra.ai/guides/deployment/mastra-workers) walks through this setup with Docker Compose and Kubernetes examples.
110
110
 
111
111
  ## Network architecture
112
112
 
113
- Workers are internal infrastructure. They are not exposed to end users and do not need their own subdomain, public URL, or inbound HTTP route.
113
+ Workers are internal infrastructure. They're not exposed to end users and don't need their own subdomain, public URL, or inbound HTTP route.
114
114
 
115
115
  In a split deployment:
116
116
 
117
- - **The API server is the only public-facing process.** It serves all client HTTP requests REST endpoints, agent interactions, workflow triggers, and any custom routes.
118
- - **Workers connect outbound only.** They pull events from the distributed PubSub backend and read/write to the shared storage database. They do not accept inbound traffic from clients.
119
- - **The orchestration worker calls the API internally.** It sends step execution requests to the API over the container network using `MASTRA_STEP_EXECUTION_URL`. This is internal service-to-service communication, not a public endpoint.
117
+ - **The API server is the only public-facing process**: It serves all client HTTP requests, including REST endpoints, agent interactions, workflow triggers, and any custom routes.
118
+ - **Workers connect outbound only**: They pull events from the distributed PubSub backend and read/write to the shared storage database. They don't accept inbound traffic from clients.
119
+ - **The orchestration worker calls the API internally**: It sends step execution requests to the API over the container network using `MASTRA_STEP_EXECUTION_URL`. This is internal service-to-service communication, not a public endpoint.
120
120
 
121
121
  All three worker types (orchestration, scheduler, background task) sit behind the API on a private network. They share access to the PubSub backend and storage database but never receive traffic directly from clients. If a worker-related feature needs an HTTP route (for example, token minting for a voice integration), that route runs on the API server, not on the worker process.
122
122
 
123
123
  ## Known limitations
124
124
 
125
- - **No dead-letter queue**: Failed events are nacked and retried, but there is no DLQ for events that repeatedly fail.
125
+ - **No dead-letter queue**: Failed events are nacked and retried, but there's no DLQ for events that fail after all retries.
126
126
  - **No built-in health endpoint**: Workers don't expose an HTTP health check. Use container-level liveness probes or process monitoring.
127
127
  - **Scheduler is single-instance**: Running multiple scheduler processes causes duplicate schedule fires.
128
128
  - **Runs stuck in "running" after API crash**: If the API process crashes while executing a workflow step, the run remains in `running` status with no automatic retry. For [durable agents](https://mastra.ai/docs/long-running-agents/durable-agents), set `recovery.durableAgents` to `'auto'` in the Mastra config to automatically re-drive orphaned runs on server restart. See [Crash recovery](https://mastra.ai/docs/long-running-agents/durable-agents) for details.
129
129
 
130
130
  ## Related
131
131
 
132
- - [Worker deployment guide](https://mastra.ai/guides/deployment/mastra-workers): Docker Compose example and topology options
132
+ - [Worker deployment guide](https://mastra.ai/guides/deployment/mastra-workers): Docker Compose and Kubernetes examples
133
133
  - [Worker authentication](https://mastra.ai/docs/server/auth/workers): Secure worker-to-API communication
134
- - [Workers reference](https://mastra.ai/reference/workers/overview): Environment variables, worker types, and storage backends
134
+ - [Workers reference](https://mastra.ai/reference/workers/overview): Details about worker environment variables and types, with a list of supported storage backends
135
135
  - [CLI reference](https://mastra.ai/reference/cli/mastra): `mastra worker build` and `mastra worker start`
136
136
  - [PubSub](https://mastra.ai/docs/server/pubsub): Event delivery backends
137
137
  - [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows): Declare cron schedules on workflows
@@ -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)
@@ -172,6 +172,20 @@ export const memoryAgent = new Agent({
172
172
 
173
173
  See [Observational Memory](https://mastra.ai/docs/memory/observational-memory) for details on how observations and reflections work, and [the reference](https://mastra.ai/reference/memory/observational-memory) for all configuration options.
174
174
 
175
+ ## What the model sees
176
+
177
+ Each memory feature is added to either the system messages or the conversation messages in the request sent to the model. The layers depend on the features you've enabled. Working memory and semantic recall only appear when configured. The same applies to Observational Memory, while message history is on by default. The diagram shows where each enabled layer is placed in the request. The list below describes what each layer contributes:
178
+
179
+ ![Diagram showing how Mastra assembles the model context: system messages containing agent instructions, call-time system messages, working memory, cross-thread semantic recall, and Observational Memory, followed by conversation messages where message history and same-thread semantic recall interleave by timestamp, then call-time context messages, and finally the new user message](/img/memory/memory-context-window-light.svg)
180
+
181
+ - [Working memory](https://mastra.ai/docs/memory/working-memory) is injected as a system message containing the template and the stored data. With `useStateSignals`, it's delivered as a state signal instead.
182
+ - [Semantic recall](https://mastra.ai/docs/memory/semantic-recall) matches from the current thread are inserted as regular messages and interleave with message history by timestamp. Matches from other threads are formatted into a system message instead.
183
+ - [Message history](https://mastra.ai/docs/memory/message-history) adds the last N messages in chronological order. Your new message always comes last.
184
+ - [Observational Memory](https://mastra.ai/docs/memory/observational-memory) replaces old raw history: reflections and observations live in a system message, and only messages that haven't been observed yet remain in the conversation. A short continuation reminder is placed at the start of the conversation messages.
185
+ - Context messages are the optional `context` array passed on a call, for example `agent.generate(msg, { context: [...] })`. Use them for one-off background such as app state or your own RAG results. They appear as regular conversation messages for that request only and are never saved to memory.
186
+
187
+ Conversation messages are ordered by timestamp and deduplicated by message ID, so recalled older messages appear before recent history. Context messages passed at call time are stamped with the current time, which places them after history and recall but before your new message. To inspect the exact context for a real request, use [Tracing](https://mastra.ai/docs/observability/tracing/overview) and open the LLM call spans, see [Observability](#observability) below.
188
+
175
189
  ## Memory in multi-agent systems
176
190
 
177
191
  When a [supervisor agent](https://mastra.ai/docs/agents/supervisor-agents) delegates to a subagent, Mastra isolates subagent memory automatically. No flag enables this as it happens on every delegation. Understanding how this scoping works lets you decide what stays private and what to share intentionally.
@@ -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
 
@@ -135,7 +135,7 @@ Visit the [Configuration reference](https://mastra.ai/reference/configuration) f
135
135
 
136
136
  Re-drives every orphaned `running` durable-agent run across all registered durable agents. Called automatically on boot when `recovery.durableAgents` is `'auto'`. You can also call it directly for manual recovery or from a scheduled task.
137
137
 
138
- Requires persistent storage with an in-memory store there is nothing to recover after a process restart.
138
+ Requires persistent storage. With an in-memory store, there's nothing to recover after a process restart.
139
139
 
140
140
  ```typescript
141
141
  const result = await mastra.recoverAllDurableAgents()
@@ -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.