@mastra/mcp-docs-server 1.2.7-alpha.6 → 1.2.7

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 (169) hide show
  1. package/.docs/docs/agent-builder/integrations.md +44 -2
  2. package/.docs/docs/agent-builder/skill-registries.md +1 -3
  3. package/.docs/docs/agent-controller/overview.md +1 -1
  4. package/.docs/docs/agent-controller/session.md +1 -3
  5. package/.docs/docs/agents/code-mode.md +17 -1
  6. package/.docs/docs/agents/guardrails.md +8 -8
  7. package/.docs/docs/agents/overview.md +2 -2
  8. package/.docs/docs/agents/processors.md +9 -3
  9. package/.docs/docs/agents/skills.md +2 -4
  10. package/.docs/docs/agents/structured-output.md +1 -1
  11. package/.docs/docs/agents/supervisor-agents.md +1 -3
  12. package/.docs/docs/agents/using-tools.md +4 -4
  13. package/.docs/docs/browser/agent-browser.md +1 -3
  14. package/.docs/docs/browser/browser-viewer.md +1 -3
  15. package/.docs/docs/browser/stagehand.md +1 -1
  16. package/.docs/docs/capabilities/channels/overview.md +1 -3
  17. package/.docs/docs/deployment/mastra-server.md +2 -4
  18. package/.docs/docs/editor/overview.md +2 -6
  19. package/.docs/docs/editor/prompts.md +1 -1
  20. package/.docs/docs/editor/tools.md +3 -5
  21. package/.docs/docs/evals/custom-scorers.md +1 -3
  22. package/.docs/docs/evals/datasets/overview.md +4 -4
  23. package/.docs/docs/evals/datasets/running-experiments.md +4 -2
  24. package/.docs/docs/evals/evals-with-memory.md +1 -3
  25. package/.docs/docs/evals/gates-and-verdicts.md +17 -2
  26. package/.docs/docs/evals/quick-checks.md +1 -3
  27. package/.docs/docs/getting-started/file-based-agents.md +9 -4
  28. package/.docs/docs/long-running-agents/background-tasks.md +1 -1
  29. package/.docs/docs/long-running-agents/durable-agents.md +3 -5
  30. package/.docs/docs/long-running-agents/goals.md +1 -3
  31. package/.docs/docs/long-running-agents/signal-providers.md +1 -3
  32. package/.docs/docs/long-running-agents/signals.md +7 -21
  33. package/.docs/docs/mastra-platform/configuration.md +15 -22
  34. package/.docs/docs/mastra-platform/database.md +50 -6
  35. package/.docs/docs/mastra-platform/deploy.md +142 -0
  36. package/.docs/docs/mastra-platform/environments.md +103 -0
  37. package/.docs/docs/mastra-platform/github.md +2 -2
  38. package/.docs/docs/mastra-platform/overview.md +5 -5
  39. package/.docs/docs/mastra-platform/server.md +2 -0
  40. package/.docs/docs/mastra-platform/studio.md +5 -3
  41. package/.docs/docs/mcp/mcp-apps.md +3 -3
  42. package/.docs/docs/mcp/overview.md +6 -10
  43. package/.docs/docs/memory/overview.md +4 -4
  44. package/.docs/docs/observability/integrations/exporters/mastra-platform.md +1 -3
  45. package/.docs/docs/observability/logging.md +3 -1
  46. package/.docs/docs/observability/metrics/querying.md +2 -0
  47. package/.docs/docs/observability/tracing/overview.md +3 -1
  48. package/.docs/docs/server/auth/auth0.md +1 -1
  49. package/.docs/docs/server/auth/better-auth.md +2 -2
  50. package/.docs/docs/server/auth/clerk.md +1 -1
  51. package/.docs/docs/server/auth/firebase.md +1 -1
  52. package/.docs/docs/server/auth/google.md +2 -2
  53. package/.docs/docs/server/auth/jwt.md +2 -2
  54. package/.docs/docs/server/auth/okta.md +2 -2
  55. package/.docs/docs/server/auth/workos.md +1 -1
  56. package/.docs/docs/server/mastra-client.md +1 -1
  57. package/.docs/docs/server/mastra-server.md +1 -1
  58. package/.docs/docs/server/pubsub.md +1 -1
  59. package/.docs/docs/server/request-context.md +4 -4
  60. package/.docs/docs/server/server-adapters.md +8 -8
  61. package/.docs/docs/studio/auth.md +1 -3
  62. package/.docs/docs/workflows/agents-and-tools.md +3 -5
  63. package/.docs/docs/workflows/control-flow.md +1 -1
  64. package/.docs/docs/workflows/overview.md +5 -5
  65. package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
  66. package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
  67. package/.docs/guides/concepts/streaming.md +3 -3
  68. package/.docs/guides/guide/chef-michel.md +1 -1
  69. package/.docs/guides/guide/coding-agent.md +392 -0
  70. package/.docs/guides/migrations/mastra-cloud.md +5 -12
  71. package/.docs/models/environment-variables.md +16 -2
  72. package/.docs/models/gateways/azure-openai.md +15 -15
  73. package/.docs/models/gateways/mastra.md +2 -2
  74. package/.docs/models/gateways/netlify.md +4 -1
  75. package/.docs/models/gateways/openrouter.md +10 -11
  76. package/.docs/models/gateways/vercel.md +9 -10
  77. package/.docs/models/index.md +1 -1
  78. package/.docs/models/providers/abacus.md +44 -14
  79. package/.docs/models/providers/ai-router.md +77 -0
  80. package/.docs/models/providers/ambient.md +10 -6
  81. package/.docs/models/providers/baseten.md +1 -1
  82. package/.docs/models/providers/blueclaw.md +74 -0
  83. package/.docs/models/providers/crossmodel.md +115 -0
  84. package/.docs/models/providers/daoxe.md +81 -0
  85. package/.docs/models/providers/databricks.md +7 -2
  86. package/.docs/models/providers/deepinfra.md +2 -2
  87. package/.docs/models/providers/deepseek.md +2 -2
  88. package/.docs/models/providers/ebcloud.md +76 -0
  89. package/.docs/models/providers/empiriolabs.md +108 -0
  90. package/.docs/models/providers/google.md +4 -0
  91. package/.docs/models/providers/hpc-ai.md +16 -10
  92. package/.docs/models/providers/inferx.md +78 -0
  93. package/.docs/models/providers/llmgateway.md +6 -7
  94. package/.docs/models/providers/lynkr.md +73 -0
  95. package/.docs/models/providers/meta.md +101 -0
  96. package/.docs/models/providers/model-oracle-ai.md +87 -0
  97. package/.docs/models/providers/nano-gpt.md +2 -2
  98. package/.docs/models/providers/neon.md +1 -1
  99. package/.docs/models/providers/nvidia.md +1 -3
  100. package/.docs/models/providers/openai.md +16 -3
  101. package/.docs/models/providers/opencode.md +5 -2
  102. package/.docs/models/providers/pioneer.md +148 -0
  103. package/.docs/models/providers/poolside.md +6 -5
  104. package/.docs/models/providers/routing-run.md +23 -34
  105. package/.docs/models/providers/snowflake-cortex.md +4 -1
  106. package/.docs/models/providers/stepfun-ai-step-plan.md +75 -0
  107. package/.docs/models/providers/stepfun-ai.md +6 -6
  108. package/.docs/models/providers/stepfun-step-plan.md +76 -0
  109. package/.docs/models/providers/stepfun.md +5 -5
  110. package/.docs/models/providers/the-grid-ai.md +3 -3
  111. package/.docs/models/providers/unorouter.md +95 -0
  112. package/.docs/models/providers/vivgrid.md +5 -2
  113. package/.docs/models/providers/wafer.ai.md +9 -12
  114. package/.docs/models/providers/xai.md +1 -1
  115. package/.docs/models/providers/zenmux.md +5 -1
  116. package/.docs/models/providers.md +16 -2
  117. package/.docs/reference/agents/generateLegacy.md +8 -2
  118. package/.docs/reference/cli/mastra.md +131 -10
  119. package/.docs/reference/code-sdk/mount-agent-controller.md +2 -0
  120. package/.docs/reference/coding-agent/create-coding-agent.md +5 -4
  121. package/.docs/reference/evals/create-scorer.md +63 -0
  122. package/.docs/reference/evals/run-evals.md +2 -2
  123. package/.docs/reference/file-based-agents/logger.md +26 -0
  124. package/.docs/reference/file-based-agents/scorers.md +54 -0
  125. package/.docs/reference/index.md +2 -0
  126. package/.docs/reference/mastra-platform/api.md +1 -1
  127. package/.docs/reference/observability/metrics/automatic-metrics.md +8 -8
  128. package/.docs/reference/observability/tracing/exporters/braintrust.md +1 -0
  129. package/.docs/reference/observability/tracing/exporters/datadog.md +10 -9
  130. package/.docs/reference/observability/tracing/exporters/langsmith.md +8 -7
  131. package/.docs/reference/observability/tracing/exporters/posthog.md +13 -12
  132. package/.docs/reference/observability/tracing/exporters/sentry.md +1 -0
  133. package/.docs/reference/observability/tracing/interfaces.md +9 -0
  134. package/.docs/reference/processors/stream-error-retry-processor.md +39 -2
  135. package/.docs/reference/pubsub/base.md +10 -0
  136. package/.docs/reference/pubsub/caching-pubsub.md +8 -0
  137. package/.docs/reference/pubsub/redis-streams.md +12 -0
  138. package/.docs/reference/server/express-adapter.md +1 -3
  139. package/.docs/reference/server/fastify-adapter.md +1 -3
  140. package/.docs/reference/server/hono-adapter.md +1 -3
  141. package/.docs/reference/server/koa-adapter.md +1 -3
  142. package/.docs/reference/server/nestjs-adapter.md +1 -3
  143. package/.docs/reference/server/register-api-route.md +5 -4
  144. package/.docs/reference/templates/overview.md +1 -1
  145. package/.docs/reference/tools/mcp-client.md +22 -0
  146. package/.docs/reference/tools/mcp-server.md +161 -4
  147. package/.docs/reference/voice/google.md +48 -8
  148. package/.docs/reference/voice/speechify.md +10 -6
  149. package/.docs/reference/workspace/agentcore-runtime-sandbox.md +1 -3
  150. package/.docs/reference/workspace/agentfs-filesystem.md +1 -3
  151. package/.docs/reference/workspace/apple-container-sandbox.md +1 -3
  152. package/.docs/reference/workspace/archil-filesystem.md +1 -3
  153. package/.docs/reference/workspace/azure-blob-filesystem.md +1 -3
  154. package/.docs/reference/workspace/blaxel-sandbox.md +1 -3
  155. package/.docs/reference/workspace/daytona-sandbox.md +1 -3
  156. package/.docs/reference/workspace/docker-sandbox.md +1 -3
  157. package/.docs/reference/workspace/e2b-sandbox.md +20 -3
  158. package/.docs/reference/workspace/files-sdk-filesystem.md +1 -3
  159. package/.docs/reference/workspace/gcs-filesystem.md +1 -3
  160. package/.docs/reference/workspace/google-drive-filesystem.md +1 -3
  161. package/.docs/reference/workspace/local-filesystem.md +1 -3
  162. package/.docs/reference/workspace/local-sandbox.md +1 -3
  163. package/.docs/reference/workspace/modal-sandbox.md +1 -3
  164. package/.docs/reference/workspace/railway-sandbox.md +1 -3
  165. package/.docs/reference/workspace/s3-filesystem.md +1 -3
  166. package/.docs/reference/workspace/vercel-sandbox.md +5 -7
  167. package/.docs/reference/workspace/vercel-serverless.md +1 -3
  168. package/CHANGELOG.md +86 -0
  169. package/package.json +10 -10
@@ -10,7 +10,7 @@ Visit the [CopilotKit documentation](https://docs.copilotkit.ai/) to learn more
10
10
 
11
11
  > **Info:** For a full-stack integration approach where Mastra runs directly in your Next.js API routes, see the [CopilotKit Quickstart](https://docs.copilotkit.ai/mastra/quickstart) guide.
12
12
 
13
- > **Tip:** Visit Mastra's ["UI Dojo"](https://ui-dojo.mastra.ai/) to see real-world examples of CopilotKit integrated with Mastra.
13
+ Visit Mastra's ["UI Dojo"](https://ui-dojo.mastra.ai/) to see real-world examples of CopilotKit integrated with Mastra.
14
14
 
15
15
  ## Integration guide
16
16
 
@@ -29,7 +29,7 @@ for await (const chunk of stream.textStream) {
29
29
  }
30
30
  ```
31
31
 
32
- > **Info:** Visit [Agent.stream()](https://mastra.ai/reference/streaming/agents/stream) for more information.
32
+ Visit [Agent.stream()](https://mastra.ai/reference/streaming/agents/stream) for more information.
33
33
 
34
34
  > **Tip:** For agents that dispatch [background tasks](https://mastra.ai/docs/long-running-agents/background-tasks), use [`Agent.streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle) to keep the stream open until those tasks complete and the agent has had a chance to respond to their results.
35
35
 
@@ -101,7 +101,7 @@ for await (const chunk of stream) {
101
101
  }
102
102
  ```
103
103
 
104
- > **Info:** Visit [Run.stream()](https://mastra.ai/reference/streaming/workflows/stream) for more information.
104
+ Visit [Run.stream()](https://mastra.ai/reference/streaming/workflows/stream) for more information.
105
105
 
106
106
  ### Output from `Run.stream()`
107
107
 
@@ -160,7 +160,7 @@ for await (const chunk of stream) {
160
160
  }
161
161
  ```
162
162
 
163
- > **Info:** Visit [Agent.stream()](https://mastra.ai/reference/streaming/agents/stream) for more information.
163
+ Visit [Agent.stream()](https://mastra.ai/reference/streaming/agents/stream) for more information.
164
164
 
165
165
  ### Example agent output
166
166
 
@@ -1,6 +1,6 @@
1
1
  > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
2
 
3
- # How to build an AI chef assistant
3
+ # Building an AI chef assistant
4
4
 
5
5
  In this guide, you'll create a "Chef Assistant" agent that helps users cook meals with available ingredients.
6
6
 
@@ -0,0 +1,392 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Building a coding agent
4
+
5
+ In this guide, you'll build a small coding-agent application in the same category as Mastra Code, Claude Code, or Codex. You'll create the coding agent with `buildBasePrompt()` and `createCodingAgent()`, wrap it in an `AgentController` for interactive sessions and tool approvals, and run the controller in a terminal UI built with pi-tui.
6
+
7
+ The video below shows the coding agent you'll build in action.
8
+
9
+ ## Prerequisites
10
+
11
+ - Node.js `v22.19.0` or later installed
12
+ - An API key from a supported [Model Provider](https://mastra.ai/models)
13
+ - An existing Mastra project. Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) if needed.
14
+
15
+ ## Install the terminal dependencies
16
+
17
+ Install [pi-tui](https://github.com/earendil-works/pi/tree/main/packages/tui) and `tsx`:
18
+
19
+ **npm**:
20
+
21
+ ```bash
22
+ npm install @earendil-works/pi-tui
23
+ npm install --save-dev tsx
24
+ ```
25
+
26
+ **pnpm**:
27
+
28
+ ```bash
29
+ pnpm add @earendil-works/pi-tui
30
+ pnpm add --save-dev tsx
31
+ ```
32
+
33
+ **Yarn**:
34
+
35
+ ```bash
36
+ yarn add @earendil-works/pi-tui
37
+ yarn add --dev tsx
38
+ ```
39
+
40
+ **Bun**:
41
+
42
+ ```bash
43
+ bun add @earendil-works/pi-tui
44
+ bun add --dev tsx
45
+ ```
46
+
47
+ pi-tui provides the terminal renderer and input editor. `tsx` runs the TypeScript entry point directly.
48
+
49
+ ## Create the coding agent
50
+
51
+ Create `src/mastra/agents/coding-agent.ts`. The prompt describes the current project and maps the prompt's generic tool names to the tools supplied by the default workspace.
52
+
53
+ ```typescript
54
+ import { basename } from 'node:path'
55
+ import { buildBasePrompt, createCodingAgent } from '@mastra/core/coding-agent'
56
+
57
+ export const projectPath = process.cwd()
58
+ const model = 'openai/gpt-5.5'
59
+
60
+ const instructions = buildBasePrompt({
61
+ projectPath,
62
+ projectName: basename(projectPath),
63
+ platform: process.platform,
64
+ date: new Date().toISOString().slice(0, 10),
65
+ mode: 'build',
66
+ modelId: model,
67
+ productName: 'My Coding Agent',
68
+ coAuthorName: 'My Coding Agent',
69
+ coAuthorEmail: 'coding-agent@example.com',
70
+ toolGuidance: `# Workspace tools
71
+ - Use mastra_workspace_read_file for view.
72
+ - Use mastra_workspace_list_files for find_files.
73
+ - Use mastra_workspace_grep for search_content.
74
+ - Use mastra_workspace_execute_command for execute_command.
75
+ - Use mastra_workspace_write_file, mastra_workspace_edit_file, and mastra_workspace_file_stat for writing, editing, and inspecting file metadata.
76
+ - Use only the workspace tools provided to you. Do not attempt unavailable capabilities.`,
77
+ })
78
+
79
+ export const codingAgent = createCodingAgent({
80
+ id: 'coding-agent',
81
+ name: 'Coding Agent',
82
+ model,
83
+ instructions,
84
+ basePath: projectPath,
85
+ })
86
+ ```
87
+
88
+ Replace the branding values with the name and co-author details for your agent. `createCodingAgent()` supplies a local filesystem and sandbox workspace, along with defaults for recovering from transient provider errors. The `basePath` scopes the filesystem tools and sets the initial working directory for commands. Any configuration you pass to the factory takes precedence over its defaults.
89
+
90
+ The default local sandbox runs commands directly on the host without isolation, so `basePath` isn't an operating-system security boundary. This example adds per-tool-call approval in the terminal, but you should still run it only against a trusted local project.
91
+
92
+ ## Register the coding agent
93
+
94
+ Register the returned agent like any other Mastra agent in `src/mastra/index.ts`. Registration also makes the underlying agent available in Studio and through the Mastra server.
95
+
96
+ ```typescript
97
+ import { Mastra } from '@mastra/core/mastra'
98
+ import { codingAgent } from './agents/coding-agent'
99
+
100
+ export const mastra = new Mastra({
101
+ agents: { codingAgent },
102
+ })
103
+ ```
104
+
105
+ ## Test the coding agent
106
+
107
+ Before adding the terminal interface, verify the underlying agent in Studio. When the development server starts, its working directory is `src/mastra/public`, so add a non-sensitive file there for the agent to inspect:
108
+
109
+ ```md
110
+ # Project notes
111
+
112
+ Name: Acme support portal
113
+ Status: In development
114
+ Owner: Platform team
115
+ ```
116
+
117
+ Start the development server:
118
+
119
+ **npm**:
120
+
121
+ ```bash
122
+ npm run dev
123
+ ```
124
+
125
+ **pnpm**:
126
+
127
+ ```bash
128
+ pnpm run dev
129
+ ```
130
+
131
+ **Yarn**:
132
+
133
+ ```bash
134
+ yarn dev
135
+ ```
136
+
137
+ **Bun**:
138
+
139
+ ```bash
140
+ bun run dev
141
+ ```
142
+
143
+ Open [Studio](https://mastra.ai/docs/studio/overview), select **Coding Agent**, and enter:
144
+
145
+ ```text
146
+ Inspect project-notes.md and report the project name, status, and owner. Do not modify files.
147
+ ```
148
+
149
+ The response should identify the Acme support portal, its development status, and the Platform team without changing the file. Model wording may vary.
150
+
151
+ ## Create the agent controller
152
+
153
+ Create `src/mastra/coding-agent-controller.ts`. The controller owns the interactive session, exposes UI events, and pauses workspace tools for approval.
154
+
155
+ ```typescript
156
+ import { AgentController } from '@mastra/core/agent-controller'
157
+ import { codingAgent, projectPath } from './agents/coding-agent'
158
+
159
+ export async function createCodingAgentSession() {
160
+ const workspace = await codingAgent.getWorkspace()
161
+
162
+ if (!workspace) {
163
+ throw new Error('The coding agent requires a workspace.')
164
+ }
165
+
166
+ const controller = new AgentController({
167
+ id: 'coding-agent-controller',
168
+ agent: codingAgent,
169
+ workspace,
170
+ modes: [{ id: 'build', name: 'Build', metadata: { default: true } }],
171
+ disableBuiltinTools: [
172
+ 'ask_user',
173
+ 'submit_plan',
174
+ 'task_write',
175
+ 'task_update',
176
+ 'task_complete',
177
+ 'task_check',
178
+ 'subagent',
179
+ ],
180
+ })
181
+
182
+ await controller.init()
183
+
184
+ const session = await controller.createSession({
185
+ id: 'local-session',
186
+ ownerId: 'local-user',
187
+ resourceId: projectPath,
188
+ })
189
+
190
+ return { controller, session }
191
+ }
192
+ ```
193
+
194
+ This example uses one mode and disables the controller's additional built-in tools so the introductory UI can focus on workspace execution. This is a tutorial simplification, not a production recommendation. In a production application, enable the built-in tools your product needs and implement their UI flows: interactive tools such as `ask_user` and `submit_plan` suspend until your interface resumes them, while task and subagent tools have their own lifecycle events. See [tool approvals and suspensions](https://mastra.ai/docs/agent-controller/tool-approvals).
195
+
196
+ The example also omits storage, so the conversation lasts only for the current process. You can add storage later when you want to resume sessions.
197
+
198
+ ## Build the terminal UI
199
+
200
+ Create `src/coding-agent-tui.ts`. The UI renders assistant message updates, shows tool activity, and asks the user to approve or decline each workspace tool call.
201
+
202
+ ```typescript
203
+ import { pathToFileURL } from 'node:url'
204
+ import {
205
+ Editor,
206
+ matchesKey,
207
+ ProcessTerminal,
208
+ Text,
209
+ TUI,
210
+ type EditorTheme,
211
+ type Terminal,
212
+ } from '@earendil-works/pi-tui'
213
+ import { createCodingAgentSession } from './mastra/coding-agent-controller'
214
+
215
+ const plain = (text: string) => text
216
+ const editorTheme: EditorTheme = {
217
+ borderColor: plain,
218
+ selectList: {
219
+ selectedPrefix: plain,
220
+ selectedText: plain,
221
+ description: plain,
222
+ scrollInfo: plain,
223
+ noMatch: plain,
224
+ },
225
+ }
226
+
227
+ function getText(message: { content: Array<{ type: string; text?: string }> }) {
228
+ return message.content
229
+ .filter(part => part.type === 'text')
230
+ .map(part => part.text ?? '')
231
+ .join('')
232
+ }
233
+
234
+ export async function startCodingAgentTui(terminal: Terminal = new ProcessTerminal()) {
235
+ const { controller, session } = await createCodingAgentSession()
236
+ const tui = new TUI(terminal)
237
+ const output = new Text('Ask me to inspect or change this project.', 1, 0)
238
+ const editor = new Editor(tui, editorTheme)
239
+
240
+ let busy = false
241
+ let pendingApproval: { toolCallId: string; toolName: string } | undefined
242
+
243
+ const showError = (error: unknown) => {
244
+ output.setText(`Error: ${error instanceof Error ? error.message : String(error)}`)
245
+ busy = false
246
+ pendingApproval = undefined
247
+ tui.requestRender()
248
+ }
249
+
250
+ const unsubscribe = session.subscribe(event => {
251
+ if (event.type === 'message_update' && event.message.role === 'assistant') {
252
+ output.setText(getText(event.message))
253
+ } else if (event.type === 'tool_start') {
254
+ output.setText(`Running ${event.toolName}...`)
255
+ } else if (event.type === 'tool_approval_required') {
256
+ pendingApproval = { toolCallId: event.toolCallId, toolName: event.toolName }
257
+ output.setText(`Allow ${event.toolName}? Enter y or n.`)
258
+ } else if (event.type === 'agent_end') {
259
+ busy = false
260
+ } else if (event.type === 'error') {
261
+ showError(event.error)
262
+ return
263
+ }
264
+
265
+ tui.requestRender()
266
+ })
267
+
268
+ editor.onSubmit = value => {
269
+ if (pendingApproval) {
270
+ const answer = value.trim().toLowerCase()
271
+ if (answer !== 'y' && answer !== 'n') {
272
+ output.setText(`Allow ${pendingApproval.toolName}? Enter y or n.`)
273
+ tui.requestRender()
274
+ return
275
+ }
276
+
277
+ const approval = pendingApproval
278
+ pendingApproval = undefined
279
+ session.respondToToolApproval({
280
+ toolCallId: approval.toolCallId,
281
+ decision: answer === 'y' ? 'approve' : 'decline',
282
+ })
283
+ return
284
+ }
285
+
286
+ if (busy || !value.trim()) return
287
+
288
+ busy = true
289
+ output.setText('Thinking...')
290
+ tui.requestRender()
291
+ void session.sendMessage({ content: value.trim() }).catch(showError)
292
+ }
293
+
294
+ tui.addChild(new Text('My Coding Agent', 1, 0))
295
+ tui.addChild(output)
296
+ tui.addChild(editor)
297
+ tui.setFocus(editor)
298
+
299
+ let stopPromise: Promise<void> | undefined
300
+ let removeInputListener = () => {}
301
+
302
+ const stop = () => {
303
+ stopPromise ??= (async () => {
304
+ process.off('SIGINT', handleExit)
305
+ removeInputListener()
306
+ session.abort()
307
+ unsubscribe()
308
+ tui.stop()
309
+ await controller.destroy()
310
+ })()
311
+ return stopPromise
312
+ }
313
+
314
+ const handleExit = () => {
315
+ void stop().catch(error => {
316
+ console.error(error)
317
+ process.exitCode = 1
318
+ })
319
+ }
320
+
321
+ removeInputListener = tui.addInputListener(data => {
322
+ if (!matchesKey(data, 'ctrl+c')) return
323
+ handleExit()
324
+ return { consume: true }
325
+ })
326
+ process.once('SIGINT', handleExit)
327
+ tui.start()
328
+
329
+ return { stop }
330
+ }
331
+
332
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
333
+ await startCodingAgentTui()
334
+ }
335
+ ```
336
+
337
+ The optional `Terminal` parameter supports automated tests while using `ProcessTerminal` during normal execution. The UI intentionally renders only the latest response; the `Session` still maintains the conversation context for follow-up prompts.
338
+
339
+ ## Run the coding agent
340
+
341
+ Start the terminal application from the project root so `process.cwd()` points to the project you want the agent to use:
342
+
343
+ **npm**:
344
+
345
+ ```bash
346
+ npx tsx src/coding-agent-tui.ts
347
+ ```
348
+
349
+ **pnpm**:
350
+
351
+ ```bash
352
+ pnpm dlx tsx src/coding-agent-tui.ts
353
+ ```
354
+
355
+ **Yarn**:
356
+
357
+ ```bash
358
+ yarn dlx tsx src/coding-agent-tui.ts
359
+ ```
360
+
361
+ **Bun**:
362
+
363
+ ```bash
364
+ bun x tsx src/coding-agent-tui.ts
365
+ ```
366
+
367
+ Enter this prompt:
368
+
369
+ ```text
370
+ Inspect package.json and report the package name and available scripts. Do not modify files.
371
+ ```
372
+
373
+ When the controller asks whether to allow `mastra_workspace_read_file`, enter `y`. The agent reads `package.json` and reports what it finds. Model wording varies, but the response should include the package name and its scripts without changing the file.
374
+
375
+ Press **Ctrl+C** to close the application and destroy the controller.
376
+
377
+ ## Next steps
378
+
379
+ You can extend this foundation to:
380
+
381
+ - Add storage to persist and resume controller sessions
382
+ - Add more modes with different instructions and workspace-tool allowlists
383
+ - Replace the latest-response component with a transcript that renders tool calls and results
384
+ - Add sandbox isolation before accepting untrusted prompts or distributing the application
385
+
386
+ Learn more:
387
+
388
+ - [`createCodingAgent()` reference](https://mastra.ai/reference/coding-agent/create-coding-agent)
389
+ - [`buildBasePrompt()` reference](https://mastra.ai/reference/coding-agent/build-base-prompt)
390
+ - [AgentController overview](https://mastra.ai/docs/agent-controller/overview)
391
+ - [`AgentController` reference](https://mastra.ai/reference/agent-controller/agent-controller-class)
392
+ - [Workspace overview](https://mastra.ai/docs/workspace/overview)
@@ -271,7 +271,7 @@ mastra studio deploy
271
271
 
272
272
  The CLI builds your project, uploads the artifact, and deploys it. On first deploy, a `.mastra-project.json` file is created to link your local project to the platform. Commit this file to your repository.
273
273
 
274
- The deploy requires a `.env` or `.env.*` file in the project directory. If none exists the CLI errors with `No env file found for deploy.` after the build completes — add at least an empty `.env` before running the command.
274
+ A local env file is optional. When a `.env` or `.env.*` file is present in the project directory, the deploy bundles its environment variables.
275
275
 
276
276
  To create a new platform project in one non-interactive step (instead of running `mastra studio projects create` separately), pass a name with `--project` and accept defaults with `--yes`:
277
277
 
@@ -283,21 +283,14 @@ See [Studio deployment](https://mastra.ai/docs/studio/deployment) for details.
283
283
 
284
284
  ### Multiple environments
285
285
 
286
- Mastra platform projects don't have a built-in concept of named environments (for example `staging` vs `production`). To deploy the same codebase to multiple environments, create one project per environment and pair each deploy with the matching env file using `--env-file`.
287
-
288
- The pattern below uses one `.env.<env>` file per environment, deploys to a project named `my-app-<env>`, and overrides `.mastra-project.json` per deploy with `MASTRA_ORG_ID` and `MASTRA_PROJECT_ID`:
286
+ A single Mastra platform project runs the same codebase across multiple named [environments](https://mastra.ai/docs/mastra-platform/environments), such as `production` and `staging`. Deploy to each with the unified [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy) command:
289
287
 
290
288
  ```bash
291
- # First deploy of each environment — creates the project
292
- mastra studio deploy --project "my-app-staging" --env-file .env.staging --yes
293
- mastra studio deploy --project "my-app-production" --env-file .env.production --yes
294
-
295
- # Subsequent deploys (CI/CD) — target the existing project
296
- MASTRA_PROJECT_ID="<staging-id>" mastra studio deploy --env-file .env.staging --yes
297
- MASTRA_PROJECT_ID="<production-id>" mastra studio deploy --env-file .env.production --yes
289
+ mastra deploy --env production --yes
290
+ mastra deploy --env staging --env-file .env.staging --yes
298
291
  ```
299
292
 
300
- Each environment ends up with its own Studio URL and its own observability data. Send `MASTRA_PLATFORM_ACCESS_TOKEN` and `MASTRA_PROJECT_ID` per environment so `MastraPlatformExporter` routes traces to the correct project.
293
+ Each environment gets its own URL, its own environment variables, and its own deploy history.
301
294
 
302
295
  ## Deploy Server (optional)
303
296
 
@@ -9,6 +9,7 @@ List of required environment variables for each model provider and gateway suppo
9
9
  | [302.AI](https://mastra.ai/models/providers/302ai) | `302ai/*` | `302AI_API_KEY` |
10
10
  | [Abacus](https://mastra.ai/models/providers/abacus) | `abacus/*` | `ABACUS_API_KEY` |
11
11
  | [abliteration.ai](https://mastra.ai/models/providers/abliteration-ai) | `abliteration-ai/*` | `ABLIT_KEY` |
12
+ | [AI-ROUTER](https://mastra.ai/models/providers/ai-router) | `ai-router/*` | `AI_ROUTER_API_KEY` |
12
13
  | [Alibaba](https://mastra.ai/models/providers/alibaba) | `alibaba/*` | `DASHSCOPE_API_KEY` |
13
14
  | [Alibaba (China)](https://mastra.ai/models/providers/alibaba-cn) | `alibaba-cn/*` | `DASHSCOPE_API_KEY` |
14
15
  | [Alibaba Coding Plan](https://mastra.ai/models/providers/alibaba-coding-plan) | `alibaba-coding-plan/*` | `ALIBABA_CODING_PLAN_API_KEY` |
@@ -23,6 +24,7 @@ List of required environment variables for each model provider and gateway suppo
23
24
  | [Bailing](https://mastra.ai/models/providers/bailing) | `bailing/*` | `BAILING_API_TOKEN` |
24
25
  | [Baseten](https://mastra.ai/models/providers/baseten) | `baseten/*` | `BASETEN_API_KEY` |
25
26
  | [Berget.AI](https://mastra.ai/models/providers/berget) | `berget/*` | `BERGET_API_KEY` |
27
+ | [Blue Claw](https://mastra.ai/models/providers/blueclaw) | `blueclaw/*` | `BLUECLAW_API_KEY` |
26
28
  | [Cerebras](https://mastra.ai/models/providers/cerebras) | `cerebras/*` | `CEREBRAS_API_KEY` |
27
29
  | [Chutes](https://mastra.ai/models/providers/chutes) | `chutes/*` | `CHUTES_API_KEY` |
28
30
  | [Clarifai](https://mastra.ai/models/providers/clarifai) | `clarifai/*` | `CLARIFAI_PAT` |
@@ -31,12 +33,16 @@ List of required environment variables for each model provider and gateway suppo
31
33
  | [Cloudflare Workers AI](https://mastra.ai/models/providers/cloudflare-workers-ai) | `cloudflare-workers-ai/*` | `CLOUDFLARE_ACCOUNT_ID`, `CLOUDFLARE_API_KEY` |
32
34
  | [Cortecs](https://mastra.ai/models/providers/cortecs) | `cortecs/*` | `CORTECS_API_KEY` |
33
35
  | [CrofAI](https://mastra.ai/models/providers/crof) | `crof/*` | `CROF_API_KEY` |
36
+ | [CrossModel](https://mastra.ai/models/providers/crossmodel) | `crossmodel/*` | `CROSSMODEL_API_KEY` |
34
37
  | [D.Run (China)](https://mastra.ai/models/providers/drun) | `drun/*` | `DRUN_API_KEY` |
38
+ | [DaoXE](https://mastra.ai/models/providers/daoxe) | `daoxe/*` | `DAOXE_API_KEY` |
35
39
  | [Databricks](https://mastra.ai/models/providers/databricks) | `databricks/*` | `DATABRICKS_HOST`, `DATABRICKS_TOKEN` |
36
40
  | [Deep Infra](https://mastra.ai/models/providers/deepinfra) | `deepinfra/*` | `DEEPINFRA_API_KEY` |
37
41
  | [DeepSeek](https://mastra.ai/models/providers/deepseek) | `deepseek/*` | `DEEPSEEK_API_KEY` |
38
42
  | [DigitalOcean](https://mastra.ai/models/providers/digitalocean) | `digitalocean/*` | `DIGITALOCEAN_ACCESS_TOKEN` |
39
43
  | [DInference](https://mastra.ai/models/providers/dinference) | `dinference/*` | `DINFERENCE_API_KEY` |
44
+ | [EBCloud](https://mastra.ai/models/providers/ebcloud) | `ebcloud/*` | `EBCLOUD_API_KEY` |
45
+ | [EmpirioLabs AI](https://mastra.ai/models/providers/empiriolabs) | `empiriolabs/*` | `EMPIRIOLABS_API_KEY` |
40
46
  | [evroc](https://mastra.ai/models/providers/evroc) | `evroc/*` | `EVROC_API_KEY` |
41
47
  | [FastRouter](https://mastra.ai/models/providers/fastrouter) | `fastrouter/*` | `FASTROUTER_API_KEY` |
42
48
  | [Fireworks AI](https://mastra.ai/models/providers/fireworks-ai) | `fireworks-ai/*` | `FIREWORKS_API_KEY` |
@@ -54,6 +60,7 @@ List of required environment variables for each model provider and gateway suppo
54
60
  | [Inception](https://mastra.ai/models/providers/inception) | `inception/*` | `INCEPTION_API_KEY` |
55
61
  | [Inceptron](https://mastra.ai/models/providers/inceptron) | `inceptron/*` | `INCEPTRON_API_KEY` |
56
62
  | [Inference](https://mastra.ai/models/providers/inference) | `inference/*` | `INFERENCE_API_KEY` |
63
+ | [InferX](https://mastra.ai/models/providers/inferx) | `inferx/*` | `INFERX_API_KEY` |
57
64
  | [IO.NET](https://mastra.ai/models/providers/io-net) | `io-net/*` | `IOINTELLIGENCE_API_KEY` |
58
65
  | [Jiekou.AI](https://mastra.ai/models/providers/jiekou) | `jiekou/*` | `JIEKOU_API_KEY` |
59
66
  | [Kenari](https://mastra.ai/models/providers/kenari) | `kenari/*` | `KENARI_API_KEY` |
@@ -67,7 +74,9 @@ List of required environment variables for each model provider and gateway suppo
67
74
  | [LMStudio](https://mastra.ai/models/providers/lmstudio) | `lmstudio/*` | `LMSTUDIO_API_KEY` |
68
75
  | [LongCat](https://mastra.ai/models/providers/longcat) | `longcat/*` | `LONGCAT_API_KEY` |
69
76
  | [LucidQuery](https://mastra.ai/models/providers/lucidquery) | `lucidquery/*` | `LUCIDQUERY_API_KEY` |
77
+ | [Lynkr](https://mastra.ai/models/providers/lynkr) | `lynkr/*` | `LYNKR_API_KEY` |
70
78
  | [Meganova](https://mastra.ai/models/providers/meganova) | `meganova/*` | `MEGANOVA_API_KEY` |
79
+ | [Meta](https://mastra.ai/models/providers/meta) | `meta/*` | `META_MODEL_API_KEY` |
71
80
  | [MiniMax (minimax.io)](https://mastra.ai/models/providers/minimax) | `minimax/*` | `MINIMAX_API_KEY` |
72
81
  | [MiniMax (minimaxi.com)](https://mastra.ai/models/providers/minimax-cn) | `minimax-cn/*` | `MINIMAX_API_KEY` |
73
82
  | [MiniMax Token Plan (minimax.io)](https://mastra.ai/models/providers/minimax-coding-plan) | `minimax-coding-plan/*` | `MINIMAX_API_KEY` |
@@ -75,6 +84,7 @@ List of required environment variables for each model provider and gateway suppo
75
84
  | [Mistral](https://mastra.ai/models/providers/mistral) | `mistral/*` | `MISTRAL_API_KEY` |
76
85
  | [Mixlayer](https://mastra.ai/models/providers/mixlayer) | `mixlayer/*` | `MIXLAYER_API_KEY` |
77
86
  | [Moark](https://mastra.ai/models/providers/moark) | `moark/*` | `MOARK_API_KEY` |
87
+ | [Model Oracle AI](https://mastra.ai/models/providers/model-oracle-ai) | `model-oracle-ai/*` | `MODEL_ORACLE_API_KEY` |
78
88
  | [ModelScope](https://mastra.ai/models/providers/modelscope) | `modelscope/*` | `MODELSCOPE_API_KEY` |
79
89
  | [Moonshot AI](https://mastra.ai/models/providers/moonshotai) | `moonshotai/*` | `MOONSHOT_API_KEY` |
80
90
  | [Moonshot AI (China)](https://mastra.ai/models/providers/moonshotai-cn) | `moonshotai-cn/*` | `MOONSHOT_API_KEY` |
@@ -95,6 +105,7 @@ List of required environment variables for each model provider and gateway suppo
95
105
  | [OVHcloud AI Endpoints](https://mastra.ai/models/providers/ovhcloud) | `ovhcloud/*` | `OVHCLOUD_API_KEY` |
96
106
  | [Perplexity](https://mastra.ai/models/providers/perplexity) | `perplexity/*` | `PERPLEXITY_API_KEY` |
97
107
  | [Perplexity Agent](https://mastra.ai/models/providers/perplexity-agent) | `perplexity-agent/*` | `PERPLEXITY_API_KEY` |
108
+ | [Pioneer](https://mastra.ai/models/providers/pioneer) | `pioneer/*` | `PIONEER_API_KEY` |
98
109
  | [Poe](https://mastra.ai/models/providers/poe) | `poe/*` | `POE_API_KEY` |
99
110
  | [Poolside](https://mastra.ai/models/providers/poolside) | `poolside/*` | `POOLSIDE_API_KEY` |
100
111
  | [Privatemode AI](https://mastra.ai/models/providers/privatemode-ai) | `privatemode-ai/*` | `PRIVATEMODE_API_KEY` |
@@ -110,8 +121,10 @@ List of required environment variables for each model provider and gateway suppo
110
121
  | [SiliconFlow (China)](https://mastra.ai/models/providers/siliconflow-cn) | `siliconflow-cn/*` | `SILICONFLOW_CN_API_KEY` |
111
122
  | [Snowflake Cortex](https://mastra.ai/models/providers/snowflake-cortex) | `snowflake-cortex/*` | `SNOWFLAKE_ACCOUNT`, `SNOWFLAKE_CORTEX_PAT` |
112
123
  | [STACKIT](https://mastra.ai/models/providers/stackit) | `stackit/*` | `STACKIT_API_KEY` |
113
- | [StepFun](https://mastra.ai/models/providers/stepfun) | `stepfun/*` | `STEPFUN_API_KEY` |
114
- | [StepFun AI](https://mastra.ai/models/providers/stepfun-ai) | `stepfun-ai/*` | `STEPFUN_API_KEY` |
124
+ | [StepFun (China)](https://mastra.ai/models/providers/stepfun) | `stepfun/*` | `STEPFUN_API_KEY` |
125
+ | [StepFun (Global)](https://mastra.ai/models/providers/stepfun-ai) | `stepfun-ai/*` | `STEPFUN_API_KEY` |
126
+ | [StepFun Step Plan (China)](https://mastra.ai/models/providers/stepfun-step-plan) | `stepfun-step-plan/*` | `STEPFUN_API_KEY` |
127
+ | [StepFun Step Plan (Global)](https://mastra.ai/models/providers/stepfun-ai-step-plan) | `stepfun-ai-step-plan/*` | `STEPFUN_API_KEY` |
115
128
  | [Subconscious](https://mastra.ai/models/providers/subconscious) | `subconscious/*` | `SUBCONSCIOUS_API_KEY` |
116
129
  | [submodel](https://mastra.ai/models/providers/submodel) | `submodel/*` | `SUBMODEL_INSTAGEN_ACCESS_KEY` |
117
130
  | [Synthetic](https://mastra.ai/models/providers/synthetic) | `synthetic/*` | `SYNTHETIC_API_KEY` |
@@ -124,6 +137,7 @@ List of required environment variables for each model provider and gateway suppo
124
137
  | [TrustedRouter](https://mastra.ai/models/providers/trustedrouter) | `trustedrouter/*` | `TRUSTEDROUTER_API_KEY` |
125
138
  | [Umans AI](https://mastra.ai/models/providers/umans-ai) | `umans-ai/*` | `UMANS_AI_API_KEY` |
126
139
  | [Umans AI Coding Plan](https://mastra.ai/models/providers/umans-ai-coding-plan) | `umans-ai-coding-plan/*` | `UMANS_AI_CODING_PLAN_API_KEY` |
140
+ | [UnoRouter](https://mastra.ai/models/providers/unorouter) | `unorouter/*` | `UNOROUTER_API_KEY` |
127
141
  | [Upstage](https://mastra.ai/models/providers/upstage) | `upstage/*` | `UPSTAGE_API_KEY` |
128
142
  | [Vivgrid](https://mastra.ai/models/providers/vivgrid) | `vivgrid/*` | `VIVGRID_API_KEY` |
129
143
  | [Vultr](https://mastra.ai/models/providers/vultr) | `vultr/*` | `VULTR_API_KEY` |