@mastra/core 1.1.0-alpha.0 → 1.1.0-alpha.1

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.
Files changed (129) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/agent/index.cjs +8 -8
  3. package/dist/agent/index.js +1 -1
  4. package/dist/{chunk-Z3XVFOTH.js → chunk-64LMKFD3.js} +4 -4
  5. package/dist/{chunk-Z3XVFOTH.js.map → chunk-64LMKFD3.js.map} +1 -1
  6. package/dist/{chunk-WBJMSOYD.cjs → chunk-66462UTX.cjs} +192 -140
  7. package/dist/chunk-66462UTX.cjs.map +1 -0
  8. package/dist/{chunk-N2FELMHU.cjs → chunk-BKUNHQZ4.cjs} +57 -24
  9. package/dist/chunk-BKUNHQZ4.cjs.map +1 -0
  10. package/dist/{chunk-DXTYXWYM.cjs → chunk-C6YO523J.cjs} +7 -7
  11. package/dist/{chunk-DXTYXWYM.cjs.map → chunk-C6YO523J.cjs.map} +1 -1
  12. package/dist/{chunk-OZFBUMI3.cjs → chunk-EZWVMAC6.cjs} +7 -7
  13. package/dist/{chunk-OZFBUMI3.cjs.map → chunk-EZWVMAC6.cjs.map} +1 -1
  14. package/dist/{chunk-ACEGVEZF.js → chunk-H4C5NORS.js} +66 -46
  15. package/dist/chunk-H4C5NORS.js.map +1 -0
  16. package/dist/{chunk-5VWOGZLE.js → chunk-HKD4NSHR.js} +49 -16
  17. package/dist/chunk-HKD4NSHR.js.map +1 -0
  18. package/dist/{chunk-3CXWVB55.cjs → chunk-IKS5Z56O.cjs} +39 -36
  19. package/dist/{chunk-3CXWVB55.cjs.map → chunk-IKS5Z56O.cjs.map} +1 -1
  20. package/dist/{chunk-YETWOFQL.js → chunk-KPIJA2R5.js} +21 -31
  21. package/dist/chunk-KPIJA2R5.js.map +1 -0
  22. package/dist/{chunk-XSRROONT.cjs → chunk-LMNHODU4.cjs} +5 -5
  23. package/dist/{chunk-XSRROONT.cjs.map → chunk-LMNHODU4.cjs.map} +1 -1
  24. package/dist/{chunk-ZZCLGEMJ.js → chunk-NVRAVZZM.js} +192 -139
  25. package/dist/chunk-NVRAVZZM.js.map +1 -0
  26. package/dist/{chunk-6FHHT22W.cjs → chunk-O7II2PSR.cjs} +44 -44
  27. package/dist/{chunk-6FHHT22W.cjs.map → chunk-O7II2PSR.cjs.map} +1 -1
  28. package/dist/{chunk-ARMHYWF5.js → chunk-QT56V3PE.js} +4 -4
  29. package/dist/{chunk-ARMHYWF5.js.map → chunk-QT56V3PE.js.map} +1 -1
  30. package/dist/{chunk-TV4DA7RI.cjs → chunk-RIPKI7ON.cjs} +21 -31
  31. package/dist/chunk-RIPKI7ON.cjs.map +1 -0
  32. package/dist/{chunk-5BEYS33K.js → chunk-RQGER4J4.js} +3 -3
  33. package/dist/{chunk-5BEYS33K.js.map → chunk-RQGER4J4.js.map} +1 -1
  34. package/dist/{chunk-REH5FX2O.js → chunk-SFICZTYL.js} +28 -25
  35. package/dist/chunk-SFICZTYL.js.map +1 -0
  36. package/dist/{chunk-CEYA6FNF.js → chunk-SJUNV5AS.js} +3 -3
  37. package/dist/{chunk-CEYA6FNF.js.map → chunk-SJUNV5AS.js.map} +1 -1
  38. package/dist/{chunk-ETSBNSRY.cjs → chunk-TO7IB5JE.cjs} +17 -9
  39. package/dist/chunk-TO7IB5JE.cjs.map +1 -0
  40. package/dist/{chunk-QGVPEZ5T.js → chunk-UJRSZGKO.js} +16 -8
  41. package/dist/chunk-UJRSZGKO.js.map +1 -0
  42. package/dist/{chunk-RFTFSXJY.cjs → chunk-YSFYUEEG.cjs} +72 -52
  43. package/dist/chunk-YSFYUEEG.cjs.map +1 -0
  44. package/dist/docs/README.md +1 -1
  45. package/dist/docs/SKILL.md +1 -1
  46. package/dist/docs/SOURCE_MAP.json +271 -271
  47. package/dist/docs/agents/01-overview.md +2 -2
  48. package/dist/docs/evals/01-overview.md +5 -5
  49. package/dist/docs/mcp/01-overview.md +2 -2
  50. package/dist/docs/observability/01-overview.md +1 -1
  51. package/dist/docs/observability/03-overview.md +3 -3
  52. package/dist/docs/rag/01-overview.md +1 -1
  53. package/dist/docs/tools-mcp/01-mcp-overview.md +2 -2
  54. package/dist/docs/voice/01-overview.md +1 -1
  55. package/dist/docs/workflows/01-overview.md +5 -5
  56. package/dist/docs/workspace/01-overview.md +32 -29
  57. package/dist/docs/workspace/02-filesystem.md +13 -0
  58. package/dist/docs/workspace/03-sandbox.md +11 -4
  59. package/dist/docs/workspace/05-search.md +1 -1
  60. package/dist/docs/workspace/06-reference.md +304 -12
  61. package/dist/evals/index.cjs +20 -20
  62. package/dist/evals/index.js +3 -3
  63. package/dist/evals/scoreTraces/index.cjs +5 -5
  64. package/dist/evals/scoreTraces/index.js +2 -2
  65. package/dist/index.cjs +2 -2
  66. package/dist/index.js +1 -1
  67. package/dist/llm/index.cjs +9 -9
  68. package/dist/llm/index.js +2 -2
  69. package/dist/llm/model/provider-types.generated.d.ts +6 -2
  70. package/dist/loop/index.cjs +12 -12
  71. package/dist/loop/index.js +1 -1
  72. package/dist/loop/network/index.d.ts.map +1 -1
  73. package/dist/mastra/index.cjs +2 -2
  74. package/dist/mastra/index.d.ts +3 -3
  75. package/dist/mastra/index.d.ts.map +1 -1
  76. package/dist/mastra/index.js +1 -1
  77. package/dist/memory/index.cjs +11 -11
  78. package/dist/memory/index.js +1 -1
  79. package/dist/processors/index.cjs +40 -40
  80. package/dist/processors/index.js +1 -1
  81. package/dist/provider-registry-JZ6QRIVL.cjs +40 -0
  82. package/dist/{provider-registry-63ZEAPKK.cjs.map → provider-registry-JZ6QRIVL.cjs.map} +1 -1
  83. package/dist/provider-registry-SQTJTKSM.js +3 -0
  84. package/dist/{provider-registry-4RA5NQGH.js.map → provider-registry-SQTJTKSM.js.map} +1 -1
  85. package/dist/provider-registry.json +14 -6
  86. package/dist/relevance/index.cjs +3 -3
  87. package/dist/relevance/index.js +1 -1
  88. package/dist/storage/constants.cjs +16 -16
  89. package/dist/storage/constants.d.ts.map +1 -1
  90. package/dist/storage/constants.js +1 -1
  91. package/dist/storage/domains/agents/base.d.ts +17 -23
  92. package/dist/storage/domains/agents/base.d.ts.map +1 -1
  93. package/dist/storage/domains/agents/inmemory.d.ts +1 -1
  94. package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
  95. package/dist/storage/index.cjs +101 -101
  96. package/dist/storage/index.js +2 -2
  97. package/dist/storage/types.d.ts +53 -37
  98. package/dist/storage/types.d.ts.map +1 -1
  99. package/dist/stream/index.cjs +8 -8
  100. package/dist/stream/index.js +1 -1
  101. package/dist/tool-loop-agent/index.cjs +4 -4
  102. package/dist/tool-loop-agent/index.js +1 -1
  103. package/dist/vector/index.cjs +7 -7
  104. package/dist/vector/index.js +1 -1
  105. package/dist/workflows/evented/index.cjs +10 -10
  106. package/dist/workflows/evented/index.js +1 -1
  107. package/dist/workflows/index.cjs +24 -24
  108. package/dist/workflows/index.js +1 -1
  109. package/dist/workspace/index.cjs +32 -32
  110. package/dist/workspace/index.js +1 -1
  111. package/dist/workspace/skills/schemas.d.ts +17 -47
  112. package/dist/workspace/skills/schemas.d.ts.map +1 -1
  113. package/dist/workspace/skills/types.d.ts +4 -4
  114. package/dist/workspace/skills/types.d.ts.map +1 -1
  115. package/package.json +4 -4
  116. package/src/llm/model/provider-types.generated.d.ts +6 -2
  117. package/dist/chunk-5VWOGZLE.js.map +0 -1
  118. package/dist/chunk-ACEGVEZF.js.map +0 -1
  119. package/dist/chunk-ETSBNSRY.cjs.map +0 -1
  120. package/dist/chunk-N2FELMHU.cjs.map +0 -1
  121. package/dist/chunk-QGVPEZ5T.js.map +0 -1
  122. package/dist/chunk-REH5FX2O.js.map +0 -1
  123. package/dist/chunk-RFTFSXJY.cjs.map +0 -1
  124. package/dist/chunk-TV4DA7RI.cjs.map +0 -1
  125. package/dist/chunk-WBJMSOYD.cjs.map +0 -1
  126. package/dist/chunk-YETWOFQL.js.map +0 -1
  127. package/dist/chunk-ZZCLGEMJ.js.map +0 -1
  128. package/dist/provider-registry-4RA5NQGH.js +0 -3
  129. package/dist/provider-registry-63ZEAPKK.cjs +0 -40
@@ -1,8 +1,8 @@
1
1
  > Overview of agents in Mastra, detailing their capabilities and how they interact with tools, workflows, and external systems.
2
2
 
3
3
  > **Code References:**
4
- - `Agent`: dist/agent/agent.d.ts → dist/chunk-REH5FX2O.js:17501
5
- - `Mastra`: dist/mastra/index.d.ts → dist/chunk-5VWOGZLE.js:24
4
+ - `Agent`: dist/agent/agent.d.ts → dist/chunk-SFICZTYL.js:17504
5
+ - `Mastra`: dist/mastra/index.d.ts → dist/chunk-HKD4NSHR.js:24
6
6
 
7
7
  # Using Agents
8
8
 
@@ -1,11 +1,11 @@
1
1
  > Overview of scorers in Mastra, detailing their capabilities for evaluating AI outputs and measuring performance.
2
2
 
3
3
  > **Code References:**
4
- - `Agent`: dist/agent/agent.d.ts → dist/chunk-REH5FX2O.js:17501
5
- - `createWorkflow`: dist/workflows/index.d.ts → dist/chunk-REH5FX2O.js:8275
6
- - `createStep`: dist/workflows/index.d.ts → dist/chunk-REH5FX2O.js:7615
7
- - `Workflow`: dist/workflows/workflow.d.ts → dist/chunk-REH5FX2O.js:8291
8
- - `Mastra`: dist/mastra/index.d.ts → dist/chunk-5VWOGZLE.js:24
4
+ - `Agent`: dist/agent/agent.d.ts → dist/chunk-SFICZTYL.js:17504
5
+ - `createWorkflow`: dist/workflows/index.d.ts → dist/chunk-SFICZTYL.js:8275
6
+ - `createStep`: dist/workflows/index.d.ts → dist/chunk-SFICZTYL.js:7615
7
+ - `Workflow`: dist/workflows/workflow.d.ts → dist/chunk-SFICZTYL.js:8291
8
+ - `Mastra`: dist/mastra/index.d.ts → dist/chunk-HKD4NSHR.js:24
9
9
 
10
10
  # Scorers overview
11
11
 
@@ -1,8 +1,8 @@
1
1
  > Learn about the Model Context Protocol (MCP), how to use third-party tools via MCPClient, connect to registries, and share your own tools using MCPServer.
2
2
 
3
3
  > **Code References:**
4
- - `Agent`: dist/agent/agent.d.ts → dist/chunk-REH5FX2O.js:17501
5
- - `Mastra`: dist/mastra/index.d.ts → dist/chunk-5VWOGZLE.js:24
4
+ - `Agent`: dist/agent/agent.d.ts → dist/chunk-SFICZTYL.js:17504
5
+ - `Mastra`: dist/mastra/index.d.ts → dist/chunk-HKD4NSHR.js:24
6
6
 
7
7
  # MCP Overview
8
8
 
@@ -1,7 +1,7 @@
1
1
  > Monitor and debug applications with Mastra
2
2
 
3
3
  > **Code References:**
4
- - `Mastra`: dist/mastra/index.d.ts → dist/chunk-5VWOGZLE.js:24
4
+ - `Mastra`: dist/mastra/index.d.ts → dist/chunk-HKD4NSHR.js:24
5
5
 
6
6
  # Observability Overview
7
7
 
@@ -1,9 +1,9 @@
1
1
  > Set up Tracing for Mastra applications
2
2
 
3
3
  > **Code References:**
4
- - `Mastra`: dist/mastra/index.d.ts → dist/chunk-5VWOGZLE.js:24
5
- - `Workflow`: dist/workflows/workflow.d.ts → dist/chunk-REH5FX2O.js:8291
6
- - `Run`: dist/workflows/index.d.ts → dist/chunk-REH5FX2O.js:9121
4
+ - `Mastra`: dist/mastra/index.d.ts → dist/chunk-HKD4NSHR.js:24
5
+ - `Workflow`: dist/workflows/workflow.d.ts → dist/chunk-SFICZTYL.js:8291
6
+ - `Run`: dist/workflows/index.d.ts → dist/chunk-SFICZTYL.js:9121
7
7
 
8
8
  # Tracing
9
9
 
@@ -1,7 +1,7 @@
1
1
  > Overview of Retrieval-Augmented Generation (RAG) in Mastra, detailing its capabilities for enhancing LLM outputs with relevant context.
2
2
 
3
3
  > **Code References:**
4
- - `ModelRouterEmbeddingModel`: dist/llm/index.d.ts → dist/chunk-5BEYS33K.js:4851
4
+ - `ModelRouterEmbeddingModel`: dist/llm/index.d.ts → dist/chunk-RQGER4J4.js:4851
5
5
 
6
6
  # RAG (Retrieval-Augmented Generation) in Mastra
7
7
 
@@ -1,8 +1,8 @@
1
1
  > Learn about the Model Context Protocol (MCP), how to use third-party tools via MCPClient, connect to registries, and share your own tools using MCPServer.
2
2
 
3
3
  > **Code References:**
4
- - `Agent`: dist/agent/agent.d.ts → dist/chunk-REH5FX2O.js:17501
5
- - `Mastra`: dist/mastra/index.d.ts → dist/chunk-5VWOGZLE.js:24
4
+ - `Agent`: dist/agent/agent.d.ts → dist/chunk-SFICZTYL.js:17504
5
+ - `Mastra`: dist/mastra/index.d.ts → dist/chunk-HKD4NSHR.js:24
6
6
 
7
7
  # MCP Overview
8
8
 
@@ -1,7 +1,7 @@
1
1
  > Overview of voice capabilities in Mastra, including text-to-speech, speech-to-text, and real-time speech-to-speech interactions.
2
2
 
3
3
  > **Code References:**
4
- - `Agent`: dist/agent/agent.d.ts → dist/chunk-REH5FX2O.js:17501
4
+ - `Agent`: dist/agent/agent.d.ts → dist/chunk-SFICZTYL.js:17504
5
5
  - `CompositeVoice`: dist/voice/index.d.ts → dist/chunk-MQB7XFXP.js:192
6
6
 
7
7
  # Voice in Mastra
@@ -1,11 +1,11 @@
1
1
  > Workflows in Mastra help you orchestrate complex sequences of tasks with features like branching, parallel execution, resource suspension, and more.
2
2
 
3
3
  > **Code References:**
4
- - `createStep`: dist/workflows/index.d.ts → dist/chunk-REH5FX2O.js:7615
5
- - `createWorkflow`: dist/workflows/index.d.ts → dist/chunk-REH5FX2O.js:8275
6
- - `cloneWorkflow`: dist/workflows/index.d.ts → dist/chunk-REH5FX2O.js:8278
7
- - `Mastra`: dist/mastra/index.d.ts → dist/chunk-5VWOGZLE.js:24
8
- - `Workflow`: dist/workflows/workflow.d.ts → dist/chunk-REH5FX2O.js:8291
4
+ - `createStep`: dist/workflows/index.d.ts → dist/chunk-SFICZTYL.js:7615
5
+ - `createWorkflow`: dist/workflows/index.d.ts → dist/chunk-SFICZTYL.js:8275
6
+ - `cloneWorkflow`: dist/workflows/index.d.ts → dist/chunk-SFICZTYL.js:8278
7
+ - `Mastra`: dist/mastra/index.d.ts → dist/chunk-HKD4NSHR.js:24
8
+ - `Workflow`: dist/workflows/workflow.d.ts → dist/chunk-SFICZTYL.js:8291
9
9
 
10
10
  # Workflows overview
11
11
 
@@ -1,8 +1,8 @@
1
1
  > Give agents filesystem access and code execution through workspaces.
2
2
 
3
3
  > **Code References:**
4
- - `Mastra`: dist/mastra/index.d.ts → dist/chunk-5VWOGZLE.js:24
5
- - `Agent`: dist/agent/agent.d.ts → dist/chunk-REH5FX2O.js:17501
4
+ - `Mastra`: dist/mastra/index.d.ts → dist/chunk-HKD4NSHR.js:24
5
+ - `Agent`: dist/agent/agent.d.ts → dist/chunk-SFICZTYL.js:17504
6
6
 
7
7
  # Workspace
8
8
 
@@ -10,15 +10,16 @@ A workspace gives agents a persistent environment for storing files and executin
10
10
 
11
11
  ## How Workspaces Work
12
12
 
13
- A workspace combines up to three components:
13
+ A workspace supports the following features:
14
14
 
15
- - **[Filesystem provider](https://mastra.ai/docs/workspace/filesystem)** - Handles file storage (read, write, list, delete)
16
- - **[Sandbox provider](https://mastra.ai/docs/workspace/sandbox)** - Handles command execution (shell commands)
15
+ - **[Filesystem](https://mastra.ai/docs/workspace/filesystem)** - File storage (read, write, list, delete)
16
+ - **[Sandbox](https://mastra.ai/docs/workspace/sandbox)** - Command execution (shell commands)
17
+ - **[Search](https://mastra.ai/docs/workspace/search)** - BM25, vector, or hybrid search over indexed content
17
18
  - **[Skills](https://mastra.ai/docs/workspace/skills)** - Reusable instructions for agents
18
19
 
19
20
  When you assign a workspace to an agent, Mastra includes the corresponding tools in the agent's toolset. The agent can then use these tools to interact with files and execute commands as part of its task.
20
21
 
21
- You can create a workspace with any combination of these components. The agent receives only the tools relevant to what's configured.
22
+ You can create a workspace with any combination of these features. The agent receives only the tools relevant to what's configured.
22
23
 
23
24
  ## Creating a Workspace
24
25
 
@@ -36,29 +37,6 @@ const workspace = new Workspace({
36
37
  });
37
38
  ```
38
39
 
39
- ## Initialization
40
-
41
- You can optionally call `init()` to initialize the workspace before use:
42
-
43
- ```typescript
44
- const workspace = new Workspace({
45
- filesystem: new LocalFilesystem({ basePath: './workspace' }),
46
- sandbox: new LocalSandbox({ workingDirectory: './workspace' }),
47
- });
48
-
49
- await workspace.init();
50
- ```
51
-
52
- ### What init() does
53
-
54
- Initialization runs setup logic for each configured provider:
55
-
56
- - **LocalFilesystem**: Creates the base directory if it doesn't exist
57
- - **LocalSandbox**: Creates working directory
58
- - **Search**: Indexes files from `autoIndexPaths` (if configured)
59
-
60
- External providers may perform additional setup like establishing connections or authenticating.
61
-
62
40
  ## Global Workspace
63
41
 
64
42
  Set a workspace on the Mastra instance. All agents inherit this workspace unless they define their own:
@@ -96,6 +74,31 @@ export const myAgent = new Agent({
96
74
  });
97
75
  ```
98
76
 
77
+ ## Initialization
78
+
79
+ You can optionally call `init()` to initialize the workspace before use:
80
+
81
+ ```typescript
82
+ import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace';
83
+
84
+ const workspace = new Workspace({
85
+ filesystem: new LocalFilesystem({ basePath: './workspace' }),
86
+ sandbox: new LocalSandbox({ workingDirectory: './workspace' }),
87
+ });
88
+
89
+ await workspace.init();
90
+ ```
91
+
92
+ ### What init() does
93
+
94
+ Initialization runs setup logic for each configured provider:
95
+
96
+ - **LocalFilesystem**: Creates the base directory if it doesn't exist
97
+ - **LocalSandbox**: Creates working directory
98
+ - **Search** (if configured): Indexes files from `autoIndexPaths` — see [Search and Indexing](https://mastra.ai/docs/workspace/search)
99
+
100
+ External providers may perform additional setup like establishing connections or authenticating.
101
+
99
102
  ## Tool Configuration
100
103
 
101
104
  Configure tool behavior through the `tools` option on the Workspace. This controls which tools are enabled and their safety settings.
@@ -27,7 +27,10 @@ LocalFilesystem is the simplest way to get started - it requires no external ser
27
27
 
28
28
  ## Basic usage
29
29
 
30
+ Create a workspace with a filesystem and assign it to an agent. The agent can then read, write, and manage files as part of its tasks:
31
+
30
32
  ```typescript
33
+ import { Agent } from '@mastra/core/agent';
31
34
  import { Workspace, LocalFilesystem } from '@mastra/core/workspace';
32
35
 
33
36
  const workspace = new Workspace({
@@ -35,6 +38,16 @@ const workspace = new Workspace({
35
38
  basePath: './workspace',
36
39
  }),
37
40
  });
41
+
42
+ const agent = new Agent({
43
+ id: 'file-agent',
44
+ model: 'openai/gpt-4o',
45
+ instructions: 'You are a helpful file management assistant.',
46
+ workspace,
47
+ });
48
+
49
+ // The agent now has filesystem tools available
50
+ const response = await agent.generate('List all files in the workspace');
38
51
  ```
39
52
 
40
53
  ## Read-only mode
@@ -24,9 +24,10 @@ Each provider page includes configuration options and usage examples:
24
24
 
25
25
  ## Basic usage
26
26
 
27
- Create a workspace with a sandbox and execute commands:
27
+ Create a workspace with a sandbox and assign it to an agent. The agent can then execute shell commands as part of its tasks:
28
28
 
29
29
  ```typescript
30
+ import { Agent } from '@mastra/core/agent';
30
31
  import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace';
31
32
 
32
33
  const workspace = new Workspace({
@@ -38,9 +39,15 @@ const workspace = new Workspace({
38
39
  }),
39
40
  });
40
41
 
41
- // Execute a command
42
- const result = await workspace.sandbox.executeCommand('ls', ['-la']);
43
- console.log(result.stdout);
42
+ const agent = new Agent({
43
+ id: 'dev-agent',
44
+ model: 'openai/gpt-4o',
45
+ instructions: 'You are a helpful development assistant.',
46
+ workspace,
47
+ });
48
+
49
+ // The agent now has the execute_command tool available
50
+ const response = await agent.generate('Run `ls -la` in the workspace directory');
44
51
  ```
45
52
 
46
53
  See [LocalSandbox Reference](https://mastra.ai/reference/workspace/local-sandbox) for configuration options including environment isolation and native OS sandboxing.
@@ -50,7 +50,7 @@ For custom BM25 parameters:
50
50
  const workspace = new Workspace({
51
51
  filesystem: new LocalFilesystem({ basePath: './workspace' }),
52
52
  bm25: {
53
- k1: 1.2, // Term frequency saturation (default: 1.2)
53
+ k1: 1.5, // Term frequency saturation (default: 1.5)
54
54
  b: 0.75, // Document length normalization (default: 0.75)
55
55
  },
56
56
  });
@@ -304,12 +304,26 @@ npm install @mastra/core@latest
304
304
 
305
305
  ## Usage
306
306
 
307
+ Add a `LocalFilesystem` to a workspace and assign it to an agent. The agent can then read, write, and manage files as part of its tasks:
308
+
307
309
  ```typescript
308
- import { LocalFilesystem } from '@mastra/core/workspace';
310
+ import { Agent } from '@mastra/core/agent';
311
+ import { Workspace, LocalFilesystem } from '@mastra/core/workspace';
309
312
 
310
- const filesystem = new LocalFilesystem({
311
- basePath: './workspace',
313
+ const workspace = new Workspace({
314
+ filesystem: new LocalFilesystem({
315
+ basePath: './workspace',
316
+ }),
312
317
  });
318
+
319
+ const agent = new Agent({
320
+ id: 'file-agent',
321
+ model: 'openai/gpt-4o',
322
+ workspace,
323
+ });
324
+
325
+ // The agent now has filesystem tools available
326
+ const response = await agent.generate('List all files in the workspace');
313
327
  ```
314
328
 
315
329
  ## Constructor Parameters
@@ -318,6 +332,166 @@ const filesystem = new LocalFilesystem({
318
332
 
319
333
  ## Methods
320
334
 
335
+ ### `init()`
336
+
337
+ Initialize the filesystem. Creates the base directory if it doesn't exist.
338
+
339
+ ```typescript
340
+ await filesystem.init();
341
+ ```
342
+
343
+ Called by `workspace.init()`.
344
+
345
+ ### `destroy()`
346
+
347
+ Clean up filesystem resources.
348
+
349
+ ```typescript
350
+ await filesystem.destroy();
351
+ ```
352
+
353
+ Called by `workspace.destroy()`.
354
+
355
+ ### `readFile(path, options?)`
356
+
357
+ Read file contents.
358
+
359
+ ```typescript
360
+ const content = await filesystem.readFile('/docs/guide.md');
361
+ const buffer = await filesystem.readFile('/image.png', { encoding: 'binary' });
362
+ ```
363
+
364
+ **Parameters:**
365
+
366
+ **Returns:** `Promise<string | Buffer>`
367
+
368
+ ### `writeFile(path, content, options?)`
369
+
370
+ Write content to a file.
371
+
372
+ ```typescript
373
+ await filesystem.writeFile('/docs/new.md', '# New Document');
374
+ await filesystem.writeFile('/nested/path/file.md', content, { recursive: true });
375
+ ```
376
+
377
+ **Parameters:**
378
+
379
+ ### `appendFile(path, content)`
380
+
381
+ Append content to an existing file.
382
+
383
+ ```typescript
384
+ await filesystem.appendFile('/logs/app.log', 'New log entry\n');
385
+ ```
386
+
387
+ **Parameters:**
388
+
389
+ ### `deleteFile(path, options?)`
390
+
391
+ Delete a file.
392
+
393
+ ```typescript
394
+ await filesystem.deleteFile('/docs/old.md');
395
+ await filesystem.deleteFile('/docs/maybe.md', { force: true }); // Don't throw if missing
396
+ ```
397
+
398
+ **Parameters:**
399
+
400
+ ### `copyFile(src, dest, options?)`
401
+
402
+ Copy a file to a new location.
403
+
404
+ ```typescript
405
+ await filesystem.copyFile('/docs/template.md', '/docs/new-doc.md');
406
+ await filesystem.copyFile('/src/config.json', '/backup/config.json', { overwrite: false });
407
+ ```
408
+
409
+ **Parameters:**
410
+
411
+ ### `moveFile(src, dest, options?)`
412
+
413
+ Move or rename a file.
414
+
415
+ ```typescript
416
+ await filesystem.moveFile('/docs/draft.md', '/docs/final.md');
417
+ await filesystem.moveFile('/temp/upload.txt', '/files/document.txt');
418
+ ```
419
+
420
+ **Parameters:**
421
+
422
+ ### `mkdir(path, options?)`
423
+
424
+ Create a directory.
425
+
426
+ ```typescript
427
+ await filesystem.mkdir('/docs/api');
428
+ await filesystem.mkdir('/deeply/nested/path', { recursive: true });
429
+ ```
430
+
431
+ **Parameters:**
432
+
433
+ ### `rmdir(path, options?)`
434
+
435
+ Remove a directory.
436
+
437
+ ```typescript
438
+ await filesystem.rmdir('/docs/old');
439
+ await filesystem.rmdir('/docs/nested', { recursive: true });
440
+ ```
441
+
442
+ **Parameters:**
443
+
444
+ ### `readdir(path, options?)`
445
+
446
+ List directory contents.
447
+
448
+ ```typescript
449
+ const entries = await filesystem.readdir('/docs');
450
+ // [{ name: 'guide.md', type: 'file' }, { name: 'api', type: 'directory' }]
451
+ ```
452
+
453
+ **Returns:** `Promise<FileEntry[]>`
454
+
455
+ ```typescript
456
+ interface FileEntry {
457
+ name: string;
458
+ type: 'file' | 'directory';
459
+ size?: number;
460
+ modifiedAt?: Date;
461
+ }
462
+ ```
463
+
464
+ ### `exists(path)`
465
+
466
+ Check if a path exists.
467
+
468
+ ```typescript
469
+ const exists = await filesystem.exists('/docs/guide.md');
470
+ ```
471
+
472
+ **Returns:** `Promise<boolean>`
473
+
474
+ ### `stat(path)`
475
+
476
+ Get file or directory metadata.
477
+
478
+ ```typescript
479
+ const stat = await filesystem.stat('/docs/guide.md');
480
+ // { type: 'file', size: 1234, modifiedAt: Date, createdAt: Date, path: '/docs/guide.md' }
481
+ ```
482
+
483
+ **Returns:** `Promise<FileStat>`
484
+
485
+ ```typescript
486
+ interface FileStat {
487
+ type: 'file' | 'directory';
488
+ size: number;
489
+ modifiedAt: Date;
490
+ createdAt: Date;
491
+ path: string;
492
+ }
493
+ ```
494
+
321
495
  ### `getInfo()`
322
496
 
323
497
  Returns metadata about this filesystem instance.
@@ -327,6 +501,18 @@ const info = filesystem.getInfo();
327
501
  // { id: '...', name: 'LocalFilesystem', provider: 'local', basePath: '/workspace', readOnly: false }
328
502
  ```
329
503
 
504
+ **Returns:** `FilesystemInfo`
505
+
506
+ ```typescript
507
+ interface FilesystemInfo {
508
+ id: string;
509
+ name: string;
510
+ provider: string;
511
+ basePath?: string;
512
+ readOnly?: boolean;
513
+ }
514
+ ```
515
+
330
516
  ### `getInstructions()`
331
517
 
332
518
  Returns a description of how paths work in this filesystem. Used in tool descriptions.
@@ -336,6 +522,8 @@ const instructions = filesystem.getInstructions();
336
522
  // 'Local filesystem at "/workspace". Files at workspace path "/foo" are stored at "/workspace/foo" on disk.'
337
523
  ```
338
524
 
525
+ **Returns:** `string`
526
+
339
527
  ## Path Resolution
340
528
 
341
529
  ### How basePath works
@@ -410,23 +598,35 @@ npm install @mastra/core@latest
410
598
 
411
599
  ## Usage
412
600
 
601
+ Add a `LocalSandbox` to a workspace and assign it to an agent. The agent can then execute shell commands as part of its tasks:
602
+
413
603
  ```typescript
414
- import { LocalSandbox } from '@mastra/core/workspace';
604
+ import { Agent } from '@mastra/core/agent';
605
+ import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace';
415
606
 
416
- const sandbox = new LocalSandbox({
417
- workingDirectory: './workspace',
418
- env: {
419
- NODE_ENV: 'development',
420
- },
607
+ const workspace = new Workspace({
608
+ filesystem: new LocalFilesystem({ basePath: './workspace' }),
609
+ sandbox: new LocalSandbox({
610
+ workingDirectory: './workspace',
611
+ env: {
612
+ NODE_ENV: 'development',
613
+ },
614
+ }),
615
+ });
616
+
617
+ const agent = new Agent({
618
+ id: 'dev-agent',
619
+ model: 'openai/gpt-4o',
620
+ workspace,
421
621
  });
422
622
 
423
- // Execute a command (auto-starts if not already running)
424
- const result = await sandbox.executeCommand('echo', ['hello']);
623
+ // The agent now has the execute_command tool available
624
+ const response = await agent.generate('Run npm install');
425
625
  ```
426
626
 
427
627
  ### Auto-start behavior
428
628
 
429
- `LocalSandbox` automatically starts on the first `executeCommand()` call if not already running. You can also explicitly start the sandbox by calling `workspace.init()` at application startup to avoid first-command latency.
629
+ `LocalSandbox` automatically starts on the first command execution if not already running. You can also explicitly start the sandbox by calling `workspace.init()` at application startup to avoid first-command latency.
430
630
 
431
631
  ## Constructor Parameters
432
632
 
@@ -438,6 +638,96 @@ Configuration options for native OS sandboxing (used with `isolation: 'seatbelt'
438
638
 
439
639
  ## Methods
440
640
 
641
+ ### `start()`
642
+
643
+ Initialize and start the sandbox. Creates the working directory and sets up seatbelt profiles if using native isolation.
644
+
645
+ ```typescript
646
+ await sandbox.start();
647
+ ```
648
+
649
+ Called automatically by `workspace.init()` or on first `executeCommand()` call.
650
+
651
+ ### `stop()`
652
+
653
+ Stop the sandbox.
654
+
655
+ ```typescript
656
+ await sandbox.stop();
657
+ ```
658
+
659
+ ### `destroy()`
660
+
661
+ Clean up sandbox resources. Removes seatbelt profiles if they were auto-generated.
662
+
663
+ ```typescript
664
+ await sandbox.destroy();
665
+ ```
666
+
667
+ Called by `workspace.destroy()`.
668
+
669
+ ### `isReady()`
670
+
671
+ Check if the sandbox is ready for operations.
672
+
673
+ ```typescript
674
+ const ready = await sandbox.isReady();
675
+ // true if status is 'running'
676
+ ```
677
+
678
+ **Returns:** `Promise<boolean>`
679
+
680
+ ### `executeCommand(command, args?, options?)`
681
+
682
+ Execute a shell command in the sandbox.
683
+
684
+ ```typescript
685
+ const listResult = await sandbox.executeCommand('ls', ['-la']);
686
+ const installResult = await sandbox.executeCommand('npm', ['install', 'lodash'], {
687
+ timeout: 60000,
688
+ env: { NODE_ENV: 'development' },
689
+ });
690
+ ```
691
+
692
+ **Parameters:**
693
+
694
+ **Returns:** `Promise<CommandResult>`
695
+
696
+ ```typescript
697
+ interface CommandResult {
698
+ success: boolean;
699
+ stdout: string;
700
+ stderr: string;
701
+ exitCode: number;
702
+ executionTimeMs: number;
703
+ }
704
+ ```
705
+
706
+ ### `getInfo()`
707
+
708
+ Get sandbox status and resource information.
709
+
710
+ ```typescript
711
+ const info = await sandbox.getInfo();
712
+ // { status: 'running', resources: { ... } }
713
+ ```
714
+
715
+ **Returns:** `Promise<SandboxInfo>`
716
+
717
+ ```typescript
718
+ interface SandboxInfo {
719
+ status: 'starting' | 'running' | 'stopped' | 'error';
720
+ resources?: {
721
+ memoryMB?: number;
722
+ memoryUsedMB?: number;
723
+ cpuCores?: number;
724
+ cpuPercent?: number;
725
+ diskMB?: number;
726
+ diskUsedMB?: number;
727
+ };
728
+ }
729
+ ```
730
+
441
731
  ### `getInstructions()`
442
732
 
443
733
  Returns a description of how this sandbox works. Used in tool descriptions.
@@ -447,6 +737,8 @@ const instructions = sandbox.getInstructions();
447
737
  // 'Local command execution. Working directory: "/workspace".'
448
738
  ```
449
739
 
740
+ **Returns:** `string`
741
+
450
742
  ## Path Resolution
451
743
 
452
744
  ### Relative paths and execution context