@mastra/mcp-docs-server 1.2.11 → 1.2.12-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/using-tools.md +25 -0
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +5 -5
- package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +8 -8
- package/.docs/guides/build-your-ui/copilotkit/overview.md +2 -2
- package/.docs/guides/build-your-ui/openui.md +1 -1
- package/.docs/guides/concepts/multi-agent-systems.md +5 -5
- package/.docs/guides/concepts/streaming.md +9 -9
- package/.docs/guides/deployment/amazon-ec2.md +1 -1
- package/.docs/guides/deployment/aws-lambda.md +1 -1
- package/.docs/guides/deployment/azure-app-services.md +1 -1
- package/.docs/guides/deployment/cloudflare.md +1 -1
- package/.docs/guides/deployment/inngest.md +6 -6
- package/.docs/guides/deployment/temporal.md +1 -1
- package/.docs/guides/deployment/vercel.md +1 -1
- package/.docs/guides/getting-started/astro.md +1 -1
- package/.docs/guides/getting-started/electron.md +1 -1
- package/.docs/guides/getting-started/nestjs.md +5 -5
- package/.docs/guides/getting-started/vite-react.md +1 -1
- package/.docs/guides/guide/chef-michel.md +1 -1
- package/.docs/guides/guide/code-review-bot.md +1 -1
- package/.docs/guides/guide/coding-agent.md +4 -4
- package/.docs/guides/guide/dev-assistant.md +1 -1
- package/.docs/guides/guide/docs-manager.md +3 -3
- package/.docs/guides/guide/github-actions-pr-description.md +4 -4
- package/.docs/guides/guide/research-assistant.md +3 -3
- package/.docs/guides/guide/research-coordinator.md +3 -3
- package/.docs/guides/guide/slack-assistant.md +1 -1
- package/.docs/guides/guide/stock-agent.md +1 -1
- package/.docs/guides/index.md +1 -1
- package/.docs/guides/migrations/ai-sdk-v4-to-v5.md +1 -1
- package/.docs/guides/migrations/mastra-cloud.md +6 -6
- package/.docs/guides/migrations/network-to-supervisor.md +9 -9
- package/.docs/guides/migrations/upgrade-to-v1/agent.md +5 -5
- package/.docs/guides/migrations/upgrade-to-v1/cli.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/client.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/evals.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/memory.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/overview.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/processors.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/storage.md +11 -11
- package/.docs/guides/migrations/upgrade-to-v1/tools.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/voice.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/workflows.md +1 -1
- package/.docs/models/environment-variables.md +1 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/modal.md +73 -0
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/acp/acp-agent.md +3 -3
- package/.docs/reference/acp/create-acp-tool.md +2 -2
- package/.docs/reference/agent-controller/agent-controller-class.md +36 -36
- package/.docs/reference/agent-controller/session.md +6 -6
- package/.docs/reference/agents/agent.md +7 -7
- package/.docs/reference/agents/channels.md +3 -3
- package/.docs/reference/agents/durable-agent.md +3 -3
- package/.docs/reference/agents/generate.md +3 -3
- package/.docs/reference/agents/getDefaultOptions.md +1 -1
- package/.docs/reference/agents/getDefaultStreamOptions.md +1 -1
- package/.docs/reference/agents/listScorers.md +1 -1
- package/.docs/reference/agents/listSkills.md +1 -1
- package/.docs/reference/agents/listSuspendedRuns.md +2 -2
- package/.docs/reference/ai-sdk/chat-route.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-v5-messages.md +1 -1
- package/.docs/reference/ai-sdk/workflow-route.md +1 -1
- package/.docs/reference/ai-sdk/workflow-snapshot-to-stream.md +2 -2
- package/.docs/reference/auth/auth0.md +1 -1
- package/.docs/reference/auth/fga.md +2 -2
- package/.docs/reference/auth/google.md +2 -2
- package/.docs/reference/auth/okta.md +1 -1
- package/.docs/reference/auth/workos.md +2 -2
- package/.docs/reference/browser/agent-browser.md +2 -2
- package/.docs/reference/browser/browser-viewer.md +3 -3
- package/.docs/reference/browser/mastra-browser.md +3 -3
- package/.docs/reference/browser/stagehand-browser.md +4 -4
- package/.docs/reference/channels/slack-provider.md +2 -2
- package/.docs/reference/cli/create-mastra.md +1 -1
- package/.docs/reference/cli/mastra.md +23 -23
- package/.docs/reference/client-js/agents.md +9 -9
- package/.docs/reference/client-js/memory.md +2 -2
- package/.docs/reference/client-js/workflows.md +1 -1
- package/.docs/reference/coding-agent/build-base-prompt.md +2 -2
- package/.docs/reference/coding-agent/create-coding-agent.md +2 -2
- package/.docs/reference/configuration.md +6 -6
- package/.docs/reference/core/getMCPServer.md +1 -1
- package/.docs/reference/core/getScorer.md +1 -1
- package/.docs/reference/datasets/addItem.md +1 -1
- package/.docs/reference/datasets/listItems.md +1 -1
- package/.docs/reference/deployer/netlify.md +4 -4
- package/.docs/reference/deployer/vercel.md +7 -7
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +4 -4
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +6 -6
- package/.docs/reference/editor/agent-builder/builder-models.md +3 -3
- package/.docs/reference/editor/blob-store-provider.md +1 -1
- package/.docs/reference/editor/browser-provider.md +3 -3
- package/.docs/reference/editor/filesystem-provider.md +4 -4
- package/.docs/reference/editor/mastra-editor.md +5 -5
- package/.docs/reference/editor/processor-provider.md +3 -3
- package/.docs/reference/editor/sandbox-provider.md +4 -4
- package/.docs/reference/editor/storage-browser-ref.md +6 -6
- package/.docs/reference/editor/storage-workspace-ref.md +4 -4
- package/.docs/reference/editor/tool-provider.md +1 -1
- package/.docs/reference/evals/answer-relevancy.md +4 -4
- package/.docs/reference/evals/bias.md +3 -3
- package/.docs/reference/evals/checks.md +3 -3
- package/.docs/reference/evals/completeness.md +5 -5
- package/.docs/reference/evals/content-similarity.md +5 -5
- package/.docs/reference/evals/context-precision.md +2 -2
- package/.docs/reference/evals/context-recall.md +8 -8
- package/.docs/reference/evals/context-relevance.md +4 -4
- package/.docs/reference/evals/create-scorer.md +1 -1
- package/.docs/reference/evals/faithfulness.md +3 -3
- package/.docs/reference/evals/filter-run.md +2 -2
- package/.docs/reference/evals/hallucination.md +6 -6
- package/.docs/reference/evals/keyword-coverage.md +6 -6
- package/.docs/reference/evals/mastra-scorer.md +2 -2
- package/.docs/reference/evals/noise-sensitivity.md +5 -5
- package/.docs/reference/evals/prompt-alignment.md +5 -5
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/evals/run-evals.md +3 -3
- package/.docs/reference/evals/scorer-utils.md +4 -4
- package/.docs/reference/evals/textual-difference.md +4 -4
- package/.docs/reference/evals/tool-call-accuracy.md +1 -1
- package/.docs/reference/evals/toxicity.md +4 -4
- package/.docs/reference/evals/trajectory-accuracy.md +10 -10
- package/.docs/reference/file-based-agents/instructions.md +2 -2
- package/.docs/reference/file-based-agents/logger.md +1 -1
- package/.docs/reference/file-based-agents/observability.md +1 -1
- package/.docs/reference/file-based-agents/processors.md +1 -1
- package/.docs/reference/file-based-agents/skills.md +1 -1
- package/.docs/reference/file-based-agents/storage.md +1 -1
- package/.docs/reference/file-based-agents/studio.md +1 -1
- package/.docs/reference/file-based-agents/subagents.md +1 -1
- package/.docs/reference/file-based-agents/tools.md +1 -1
- package/.docs/reference/file-based-agents/workspace.md +1 -1
- package/.docs/reference/logging/pino-logger.md +3 -3
- package/.docs/reference/memory/clone-utilities.md +1 -1
- package/.docs/reference/memory/cloneThread.md +3 -3
- package/.docs/reference/memory/listThreads.md +1 -1
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/observational-memory.md +11 -11
- package/.docs/reference/memory/recall.md +2 -2
- package/.docs/reference/memory/serialized-memory-config.md +4 -4
- package/.docs/reference/memory/summarizeConversation.md +3 -3
- package/.docs/reference/memory/summarizeThread.md +3 -3
- package/.docs/reference/observability/feedback.md +1 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +7 -7
- package/.docs/reference/observability/tracing/bridges/datadog.md +2 -2
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +3 -3
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +1 -1
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +4 -4
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +1 -1
- package/.docs/reference/observability/tracing/interfaces.md +1 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -1
- package/.docs/reference/observability/tracing/span-filtering.md +1 -1
- package/.docs/reference/processors/cost-guard-processor.md +1 -1
- package/.docs/reference/processors/pii-detector.md +1 -1
- package/.docs/reference/processors/processor-interface.md +12 -12
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/provider-history-compat.md +1 -1
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/response-cache.md +8 -8
- package/.docs/reference/processors/system-prompt-scrubber.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +1 -1
- package/.docs/reference/processors/tool-search-processor.md +7 -7
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/pubsub/base.md +4 -4
- package/.docs/reference/pubsub/google-cloud-pubsub.md +2 -2
- package/.docs/reference/pubsub/lease-provider.md +4 -4
- package/.docs/reference/pubsub/redis-streams.md +1 -1
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/rag/chunk.md +5 -5
- package/.docs/reference/rag/database-config.md +2 -2
- package/.docs/reference/rag/metadata-filters.md +2 -2
- package/.docs/reference/schedules/overview.md +1 -1
- package/.docs/reference/server/register-api-route.md +1 -1
- package/.docs/reference/server/routes.md +1 -1
- package/.docs/reference/signals/signal-provider.md +8 -8
- package/.docs/reference/storage/clickhouse.md +4 -4
- package/.docs/reference/storage/cloudflare-d1.md +4 -4
- package/.docs/reference/storage/convex.md +4 -4
- package/.docs/reference/storage/dsql.md +2 -2
- package/.docs/reference/storage/dynamodb.md +7 -7
- package/.docs/reference/storage/lance.md +1 -1
- package/.docs/reference/storage/mongodb.md +1 -1
- package/.docs/reference/storage/mssql.md +1 -1
- package/.docs/reference/storage/postgresql.md +1 -1
- package/.docs/reference/storage/retention.md +33 -33
- package/.docs/reference/storage/spanner.md +8 -8
- package/.docs/reference/streaming/ChunkType.md +2 -2
- package/.docs/reference/streaming/agents/MastraModelOutput.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/streaming/agents/streamUntilIdle.md +2 -2
- package/.docs/reference/streaming/workflows/observeStream.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/streaming/workflows/stream.md +1 -1
- package/.docs/reference/streaming/workflows/timeTravelStream.md +2 -2
- package/.docs/reference/templates/overview.md +1 -1
- package/.docs/reference/tools/brightdata.md +1 -1
- package/.docs/reference/tools/create-tool.md +1 -1
- package/.docs/reference/tools/graph-rag-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +13 -13
- package/.docs/reference/tools/mcp-server.md +20 -20
- package/.docs/reference/tools/submit-plan-tool.md +1 -1
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +4 -4
- package/.docs/reference/vectors/astra.md +1 -1
- package/.docs/reference/vectors/chroma.md +2 -2
- package/.docs/reference/vectors/convex.md +2 -2
- package/.docs/reference/vectors/couchbase.md +4 -4
- package/.docs/reference/vectors/libsql.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +4 -4
- package/.docs/reference/vectors/qdrant.md +2 -2
- package/.docs/reference/vectors/s3vectors.md +4 -4
- package/.docs/reference/vectors/turbopuffer.md +1 -1
- package/.docs/reference/voice/aws-nova-sonic.md +1 -1
- package/.docs/reference/voice/azure.md +1 -1
- package/.docs/reference/voice/google-gemini-live.md +4 -4
- package/.docs/reference/voice/inworld-realtime.md +7 -7
- package/.docs/reference/voice/livekit.md +13 -13
- package/.docs/reference/voice/mistral.md +1 -1
- package/.docs/reference/voice/openai-realtime.md +1 -1
- package/.docs/reference/voice/sarvam.md +1 -1
- package/.docs/reference/voice/voice.addTools.md +1 -1
- package/.docs/reference/voice/voice.events.md +1 -1
- package/.docs/reference/voice/voice.getSpeakers.md +2 -2
- package/.docs/reference/voice/voice.on.md +2 -2
- package/.docs/reference/voice/xai-realtime.md +2 -2
- package/.docs/reference/workflows/run-methods/cancel.md +1 -1
- package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workflows/workflow-methods/foreach.md +1 -1
- package/.docs/reference/workflows/workflow-methods/sleep.md +1 -1
- package/.docs/reference/workflows/workflow-state-reader.md +2 -2
- package/.docs/reference/workspace/apple-container-sandbox.md +2 -2
- package/.docs/reference/workspace/daytona-sandbox.md +3 -3
- package/.docs/reference/workspace/docker-sandbox.md +2 -2
- package/.docs/reference/workspace/e2b-sandbox.md +2 -2
- package/.docs/reference/workspace/files-sdk-filesystem.md +3 -3
- package/.docs/reference/workspace/google-drive-filesystem.md +4 -4
- package/.docs/reference/workspace/local-filesystem.md +2 -2
- package/.docs/reference/workspace/local-sandbox.md +2 -2
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/platform-filesystem.md +3 -3
- package/.docs/reference/workspace/platform-sandbox.md +2 -2
- package/.docs/reference/workspace/process-manager.md +1 -1
- package/.docs/reference/workspace/railway-sandbox.md +4 -4
- package/.docs/reference/workspace/s3-filesystem.md +1 -1
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/vercel-sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +10 -10
- package/CHANGELOG.md +7 -0
- package/package.json +5 -5
|
@@ -65,6 +65,31 @@ export const weatherAgent = new Agent({
|
|
|
65
65
|
})
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
## Use provider web search
|
|
69
|
+
|
|
70
|
+
Import `webSearchTool` from `@mastra/core/tools` when you want the model provider to run its native web search tool. The tool has no local `execute` function. Mastra resolves it at run time from the active model, then passes the provider-managed tool to the model.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { Agent } from '@mastra/core/agent'
|
|
74
|
+
import { webSearchTool } from '@mastra/core/tools'
|
|
75
|
+
|
|
76
|
+
export const researchAgent = new Agent({
|
|
77
|
+
id: 'research-agent',
|
|
78
|
+
name: 'Research Agent',
|
|
79
|
+
instructions: `
|
|
80
|
+
You are a helpful research assistant.
|
|
81
|
+
Use web search when you need current information.`,
|
|
82
|
+
model: 'openai/gpt-5.5',
|
|
83
|
+
tools: {
|
|
84
|
+
webSearch: webSearchTool,
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`webSearchTool` supports OpenAI, Anthropic, Google Gemini, and xAI models. If Mastra can't infer one of those providers from the active model, the agent run fails with a `MastraError`.
|
|
90
|
+
|
|
91
|
+
Only the `webSearchTool` value triggers provider web search. A custom tool named `webSearch` or `web_search` stays unchanged.
|
|
92
|
+
|
|
68
93
|
## Define schemas
|
|
69
94
|
|
|
70
95
|
You can define the tool's `inputSchema` and `outputSchema` with any library that supports [Standard JSON Schema](https://standardschema.dev/json-schema). This includes libraries like [Zod](https://zod.dev/), [Valibot](https://valibot.dev/), and [ArkType](https://arktype.io/).
|
|
@@ -44,7 +44,7 @@ You're now ready to follow the integration guides and recipes below!
|
|
|
44
44
|
|
|
45
45
|
## Integration guides
|
|
46
46
|
|
|
47
|
-
Typically, you'll set up API routes that stream Mastra content in AI SDK-compatible format, and then use those routes in AI SDK UI hooks like `useChat()`.
|
|
47
|
+
Typically, you'll set up API routes that stream Mastra content in AI SDK-compatible format, and then use those routes in AI SDK UI hooks like `useChat()`. Choose one of these approaches:
|
|
48
48
|
|
|
49
49
|
- [Mastra's server](#mastras-server)
|
|
50
50
|
- [Framework-agnostic](#framework-agnostic)
|
|
@@ -298,7 +298,7 @@ export default function Page() {
|
|
|
298
298
|
}
|
|
299
299
|
```
|
|
300
300
|
|
|
301
|
-
|
|
301
|
+
Choose a backend implementation:
|
|
302
302
|
|
|
303
303
|
**Mastra Server**:
|
|
304
304
|
|
|
@@ -380,7 +380,7 @@ export async function POST(req: Request) {
|
|
|
380
380
|
|
|
381
381
|
## Custom UI
|
|
382
382
|
|
|
383
|
-
Custom UI (also known as Generative UI) allows you to render custom React components based on data streamed from Mastra. Instead of displaying raw text or JSON, you can create visual components for tool outputs
|
|
383
|
+
Custom UI (also known as Generative UI) allows you to render custom React components based on data streamed from Mastra. Instead of displaying raw text or JSON, you can create visual components for tool outputs and workflow progress, including agent network execution and custom events.
|
|
384
384
|
|
|
385
385
|
Use Custom UI when you want to:
|
|
386
386
|
|
|
@@ -990,7 +990,7 @@ export function ChatAdditional() {
|
|
|
990
990
|
}
|
|
991
991
|
```
|
|
992
992
|
|
|
993
|
-
|
|
993
|
+
Implement the backend with either of these examples.
|
|
994
994
|
|
|
995
995
|
**Mastra Server**:
|
|
996
996
|
|
|
@@ -1545,7 +1545,7 @@ For a complete implementation, see the [workflow-agent-text-stream example](http
|
|
|
1545
1545
|
|
|
1546
1546
|
### Multi-stage progress with branching workflows
|
|
1547
1547
|
|
|
1548
|
-
For workflows with conditional branching (e.g., express vs standard
|
|
1548
|
+
For workflows with conditional branching (e.g., express vs standard delivery), you can track progress across different branches by including an identifier in your custom events.
|
|
1549
1549
|
|
|
1550
1550
|
The UI Dojo example uses a `stage` field in the event data to identify which branch is executing (e.g., `"validation"`, `"standard-processing"`, `"express-processing"`). The frontend groups events by this field to show a pipeline-style progress UI.
|
|
1551
1551
|
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
# CopilotKit generative UI
|
|
4
4
|
|
|
5
|
-
Generative UI
|
|
5
|
+
Generative UI describes interfaces that agents help create and that users can interact with. CopilotKit organizes these interfaces along a single axis, the **generative UI spectrum**, which runs from author-controlled (you decide every pixel) to agent-invented (the agent owns the rendered surface). Your position on the axis is a trade-off between predictability and breadth.
|
|
6
6
|
|
|
7
7
|
The spectrum has three tiers:
|
|
8
8
|
|
|
9
9
|
| Tier | Who controls the surface | Primitives |
|
|
10
10
|
| --------------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- |
|
|
11
|
-
| **Controlled** | You wrote the component
|
|
12
|
-
| **Declarative** | The agent emits a structured spec
|
|
11
|
+
| **Controlled** | You wrote the component. The agent picks which one to use and what data to pass. | Tool call rendering, state rendering, reasoning, components as tools |
|
|
12
|
+
| **Declarative** | The agent emits a structured spec. The frontend composes it from a catalog you registered. | A2UI (fixed-schema and flexible variants) |
|
|
13
13
|
| **Open-ended** | The UI is invented elsewhere (an MCP server) and you sandbox it. | MCP Apps |
|
|
14
14
|
|
|
15
15
|
Each tier is a Mastra agent exposed through `registerCopilotKit()` (see [CopilotKit overview](https://mastra.ai/guides/build-your-ui/copilotkit/overview)) plus the matching CopilotKit hook on the frontend. For the full concept, see CopilotKit's [generative UI spectrum](https://www.copilotkit.ai/generative-ui-spectrum) and [generative UI overview](https://docs.copilotkit.ai/concepts/generative-ui-overview).
|
|
16
16
|
|
|
17
|
-
> **Tip:** Mastra's [UI Dojo](https://ui-dojo.mastra.ai/) has working CopilotKit examples
|
|
17
|
+
> **Tip:** Mastra's [UI Dojo](https://ui-dojo.mastra.ai/) has working CopilotKit examples. Browse the source under `src/pages/copilot-kit`.
|
|
18
18
|
|
|
19
19
|
## Controlled
|
|
20
20
|
|
|
21
|
-
You
|
|
21
|
+
You provide a fixed set of components. The agent chooses which component to render and supplies its data. This predictable, brand-safe approach works well for high-traffic surfaces. The Controlled primitives use CopilotKit's v2 API, imported from `@copilotkit/react-core/v2`.
|
|
22
22
|
|
|
23
23
|
### Tool call rendering
|
|
24
24
|
|
|
@@ -125,7 +125,7 @@ Reasoning is zero-config: when your Mastra agent runs a reasoning-capable model,
|
|
|
125
125
|
|
|
126
126
|
## Declarative
|
|
127
127
|
|
|
128
|
-
Instead of a fixed component per tool, you register a catalog of typed building blocks and the agent assembles them into a UI tree per request. CopilotKit calls this **A2UI** (Agent-to-UI),
|
|
128
|
+
Instead of a fixed component per tool, you register a catalog of typed building blocks and the agent assembles them into a UI tree per request. CopilotKit calls this **A2UI** (Agent-to-UI), which has fixed-schema and flexible variants. It suits the long tail of secondary interactions where breadth matters more than pixel-perfection.
|
|
129
129
|
|
|
130
130
|
The path of least resistance is to pass your catalog to the `<CopilotKit>` provider. That single prop enables A2UI rendering and injects the A2UI tool into your agent, so no backend change is needed:
|
|
131
131
|
|
|
@@ -146,11 +146,11 @@ export default function Page() {
|
|
|
146
146
|
}
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
The catalog defines the primitives (their schemas) and the renderers (how each primitive displays). In the fixed-schema variant the components are pre-authored and the agent's tool only supplies data
|
|
149
|
+
The catalog defines the primitives (their schemas) and the renderers (how each primitive displays). In the fixed-schema variant, the components are pre-authored and the agent's tool only supplies data. The flexible variant lets the agent compose the tree more freely. See CopilotKit's [A2UI documentation](https://docs.copilotkit.ai/a2a/generative-ui/a2ui).
|
|
150
150
|
|
|
151
151
|
## Open-ended
|
|
152
152
|
|
|
153
|
-
At the far end of the spectrum, the agent owns the entire surface: the UI is invented elsewhere and sandboxed in your app. CopilotKit supports this through **MCP Apps**, where an MCP server
|
|
153
|
+
At the far end of the spectrum, the agent owns the entire surface: the UI is invented elsewhere and sandboxed in your app. CopilotKit supports this through **MCP Apps**, where an MCP server provides UI that renders inside your application. This tier trades determinism for novelty and is the most experimental point on the spectrum.
|
|
154
154
|
|
|
155
155
|
The path of least resistance keeps the frontend untouched: your existing `<CopilotKit>` provider is enough. On the backend, point `registerCopilotKit()` at one or more MCP servers with the `mcpApps` option (it's forwarded to the CopilotKit runtime):
|
|
156
156
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Using CopilotKit
|
|
4
4
|
|
|
5
|
-
[CopilotKit](https://www.copilotkit.ai/) provides React components to quickly integrate customizable AI copilots into your application. Combined with Mastra, you can build
|
|
5
|
+
[CopilotKit](https://www.copilotkit.ai/) provides React components to quickly integrate customizable AI copilots into your application. Combined with Mastra, you can build AI apps with bidirectional state synchronization and interactive UIs.
|
|
6
6
|
|
|
7
7
|
CopilotKit talks to Mastra through the [AG-UI protocol](https://docs.ag-ui.com/). The `@ag-ui/mastra` package exposes your Mastra agents as an AG-UI endpoint, and CopilotKit's React hooks and components consume it. This unlocks a spectrum of experiences on top of ordinary chat: [generative UI, human-in-the-loop, and frontend tools](https://mastra.ai/guides/build-your-ui/copilotkit/generative-ui), plus deploying the same agent to [messaging channels like Slack](https://mastra.ai/guides/build-your-ui/copilotkit/channels).
|
|
8
8
|
|
|
@@ -266,7 +266,7 @@ Your CopilotKit frontend now communicates with a standalone Mastra agent server.
|
|
|
266
266
|
|
|
267
267
|
## Chat UI options
|
|
268
268
|
|
|
269
|
-
`CopilotChat` renders an inline, full-height chat. CopilotKit
|
|
269
|
+
`CopilotChat` renders an inline, full-height chat. CopilotKit provides two other drop-in surfaces that share the same props:
|
|
270
270
|
|
|
271
271
|
- `CopilotSidebar`: a collapsible panel docked to the side of your app.
|
|
272
272
|
- `CopilotPopup`: a floating button that opens a chat window.
|
|
@@ -253,7 +253,7 @@ OpenUI generates UI from a component library. The library defines which componen
|
|
|
253
253
|
|
|
254
254
|
### Built-in libraries
|
|
255
255
|
|
|
256
|
-
`@openuidev/react-ui`
|
|
256
|
+
`@openuidev/react-ui` provides two libraries you can use as-is:
|
|
257
257
|
|
|
258
258
|
- `openuiChatLibrary`: components for chat interfaces (cards, forms, tables, charts).
|
|
259
259
|
- `openuiDashboardLibrary`: components for dashboards and data-heavy surfaces.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
A multi-agent system distributes a task across multiple agents instead of asking one agent to do everything. In Mastra, this usually means combining agents, workflows, or both so each part of the system has a clear role.
|
|
6
6
|
|
|
7
|
-
The goal is to assign the right context, tools, and responsibilities to the right component. When that split is clear, a multi-agent system can be easier to reason about than one agent with a long prompt
|
|
7
|
+
The goal is to assign the right context, tools, and responsibilities to the right component. When that split is clear, a multi-agent system can be easier to reason about than one agent burdened with a long prompt and too many tools or responsibilities.
|
|
8
8
|
|
|
9
9
|
## When to use multi-agent systems
|
|
10
10
|
|
|
@@ -34,9 +34,9 @@ In Mastra, implement this pattern by combining [agents](https://mastra.ai/docs/a
|
|
|
34
34
|
|
|
35
35
|
A workflow pattern defines the execution path in code. Instead of asking an agent to decide what happens next, you define the sequence through steps, branches, loops, and parallel blocks.
|
|
36
36
|
|
|
37
|
-
Use workflows when the task is well understood and the execution path is known in advance. The main advantage is predictability: The system
|
|
37
|
+
Use workflows when the task is well understood and the execution path is known in advance. The main advantage is predictability: The explicit structure makes the system easier to debug and audit. The tradeoff is flexibility, since workflows are less adaptive when the task changes as it unfolds.
|
|
38
38
|
|
|
39
|
-
In Mastra, [workflows](https://mastra.ai/docs/workflows/overview) can implement
|
|
39
|
+
In Mastra, [workflows](https://mastra.ai/docs/workflows/overview) can implement coordination patterns such as handoffs and councils. A workflow is distinct because its control logic lives in the workflow itself, regardless of which agents it calls.
|
|
40
40
|
|
|
41
41
|
## Supervisors
|
|
42
42
|
|
|
@@ -54,7 +54,7 @@ A council pattern asks multiple agents to work on the same problem independently
|
|
|
54
54
|
|
|
55
55
|
Use this pattern when the question is ambiguous, evaluative, or high-stakes and answer quality matters more than speed. The tradeoff is cost, since councils intentionally duplicate effort and usually take longer and use more tokens than other patterns.
|
|
56
56
|
|
|
57
|
-
Mastra doesn't provide a dedicated council primitive. In Mastra, implement this pattern with [agents](https://mastra.ai/docs/agents/overview) and [workflows](https://mastra.ai/docs/workflows/overview): Run multiple agents in parallel
|
|
57
|
+
Mastra doesn't provide a dedicated council primitive. In Mastra, implement this pattern with [agents](https://mastra.ai/docs/agents/overview) and [workflows](https://mastra.ai/docs/workflows/overview): Run multiple agents in parallel and collect their outputs. Then add a final synthesis or review step. Workflow control flow methods such as `.parallel()` provide the structure for this pattern.
|
|
58
58
|
|
|
59
59
|
## Choosing a pattern
|
|
60
60
|
|
|
@@ -64,7 +64,7 @@ These patterns differ mainly in how they distribute control:
|
|
|
64
64
|
| ----------------- | -------------------- | ------------------------------------------------ | -------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
65
65
|
| Handoffs | Current specialist | Ownership should move between specialists | Context transfer becomes more important | Agents with workflows and memory |
|
|
66
66
|
| Workflows | Execution graph | The path is known in advance | Less adaptive when the task changes | [Workflows](https://mastra.ai/docs/workflows/overview) |
|
|
67
|
-
| Supervisor agents | One lead agent |
|
|
67
|
+
| Supervisor agents | One lead agent | Delegation must adapt during execution | Results depend on good coordination and clear boundaries | [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents) |
|
|
68
68
|
| Council | Final synthesis step | The task needs multiple independent perspectives | Higher cost and latency | Agents with workflow parallelism |
|
|
69
69
|
|
|
70
70
|
In practice, these patterns are often combined:
|
|
@@ -46,7 +46,7 @@ Here are some questions to consider:
|
|
|
46
46
|
|
|
47
47
|
### Agent stream properties
|
|
48
48
|
|
|
49
|
-
An agent stream provides access to
|
|
49
|
+
An agent stream provides access to these response properties:
|
|
50
50
|
|
|
51
51
|
- **`stream.textStream`**: A readable stream that emits text chunks.
|
|
52
52
|
- **`stream.text`**: Promise that resolves to the full text response.
|
|
@@ -124,13 +124,13 @@ The event structure includes `runId` and `from` at the top level, making it easi
|
|
|
124
124
|
|
|
125
125
|
### Workflow stream properties
|
|
126
126
|
|
|
127
|
-
A workflow stream provides access to
|
|
127
|
+
A workflow stream provides access to these response properties:
|
|
128
128
|
|
|
129
129
|
- **`stream.status`**: The status of the workflow run.
|
|
130
130
|
- **`stream.result`**: The result of the workflow run.
|
|
131
131
|
- **`stream.usage`**: The total token usage of the workflow run.
|
|
132
132
|
|
|
133
|
-
Streaming from agents or workflows provides real-time visibility into either the LLM’s output or the status of a workflow run.
|
|
133
|
+
Streaming from agents or workflows provides real-time visibility into either the LLM’s output or the status of a workflow run. Pass this feedback directly to the user, or use it in an application to display workflow status as it changes.
|
|
134
134
|
|
|
135
135
|
Events emitted from agents or workflows represent different stages of generation and execution, such as when a run starts, when text is produced, or when a tool is invoked.
|
|
136
136
|
|
|
@@ -193,11 +193,11 @@ Below is an example of events that may be emitted. Each event always includes a
|
|
|
193
193
|
|
|
194
194
|
## Writer API
|
|
195
195
|
|
|
196
|
-
The `writer` API is shared by tools and workflow steps
|
|
196
|
+
The `writer` API is shared by tools and workflow steps. See the Tools and Workflows docs for feature-specific examples.
|
|
197
197
|
|
|
198
198
|
## Agent using tool
|
|
199
199
|
|
|
200
|
-
Agent streaming can be combined with tool calls, allowing tool outputs to be written directly into the agent’s streaming response. This
|
|
200
|
+
Agent streaming can be combined with tool calls, allowing tool outputs to be written directly into the agent’s streaming response. This surfaces tool activity as part of the interaction.
|
|
201
201
|
|
|
202
202
|
```typescript
|
|
203
203
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -214,7 +214,7 @@ export const testAgent = new Agent({
|
|
|
214
214
|
|
|
215
215
|
### Using `context.writer`
|
|
216
216
|
|
|
217
|
-
The `context.writer` object is available in a tool's `execute()` function and can
|
|
217
|
+
The `context.writer` object is available in a tool's `execute()` function and can emit custom events, data, or values into the active stream. Tools use these events to provide intermediate results or status updates during execution.
|
|
218
218
|
|
|
219
219
|
> **Warning:** You must `await` the call to `writer.write()` or else you will lock the stream and get a `WritableStream is locked` error.
|
|
220
220
|
|
|
@@ -274,7 +274,7 @@ export const testTool = createTool({
|
|
|
274
274
|
|
|
275
275
|
### Transient data chunks
|
|
276
276
|
|
|
277
|
-
By default, `data-*` chunks emitted with `writer.custom()` are persisted to storage as part of the message history. For chunks that are only needed during live streaming
|
|
277
|
+
By default, `data-*` chunks emitted with `writer.custom()` are persisted to storage as part of the message history. For chunks that are only needed during live streaming, such as progress updates or verbose log output, set `transient: true` to skip storage persistence. Transient chunks are still streamed to the client in real time but aren't saved to the database.
|
|
278
278
|
|
|
279
279
|
```typescript
|
|
280
280
|
await context?.writer?.custom({
|
|
@@ -284,11 +284,11 @@ await context?.writer?.custom({
|
|
|
284
284
|
})
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
Use transient chunks when the data is large or high-frequency and only relevant during the live session. After a page refresh, transient chunks are no longer available
|
|
287
|
+
Use transient chunks when the data is large or high-frequency and only relevant during the live session. After a page refresh, transient chunks are no longer available. Only the tool's return value and any non-transient chunks are loaded from storage.
|
|
288
288
|
|
|
289
289
|
## Using the `writer` argument
|
|
290
290
|
|
|
291
|
-
The `writer` argument is passed to a workflow step's `execute` function and can
|
|
291
|
+
The `writer` argument is passed to a workflow step's `execute` function and can emit custom events, data, or values into the active stream. Workflow steps use these events to provide intermediate results or status updates during execution.
|
|
292
292
|
|
|
293
293
|
> **Warning:** You must `await` the call to `writer.write(...)` or else you will lock the stream and get a `WritableStream is locked` error.
|
|
294
294
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Deploy Mastra to Amazon EC2
|
|
4
4
|
|
|
5
|
-
Deploy your Mastra server to Amazon EC2.
|
|
5
|
+
Deploy your Mastra server to Amazon EC2. The server runs on infrastructure you manage and can support long-running agents and workflows.
|
|
6
6
|
|
|
7
7
|
> **Info:** This guide covers deploying the [Mastra server](https://mastra.ai/docs/server/mastra-server). If you're using a [server adapter](https://mastra.ai/docs/server/server-adapters) or [web framework](https://mastra.ai/docs/deployment/web-framework), deploy the way you normally would for that framework.
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ You'll need:
|
|
|
12
12
|
|
|
13
13
|
- A [Mastra application](https://mastra.ai/guides/getting-started/quickstart)
|
|
14
14
|
- An [AWS account](https://aws.amazon.com/) with permissions for Lambda, ECR, and IAM
|
|
15
|
-
- **[AWS CLI](https://aws.amazon.com/cli/)** installed
|
|
15
|
+
- **[AWS CLI](https://aws.amazon.com/cli/)** installed: Run `aws configure` to authenticate
|
|
16
16
|
- **[Docker](https://www.docker.com/)** installed and running
|
|
17
17
|
|
|
18
18
|
> **Warning:** On AWS Lambda, the filesystem is ephemeral, so any local database file will be lost between invocations. If you're using [LibSQLStore](https://mastra.ai/reference/storage/libsql) with a local file, configure it to use a remote LibSQL-compatible database (for example, [Turso](https://turso.tech/)) instead.
|
|
@@ -71,7 +71,7 @@ In these steps, you'll connect your Azure App Service to your GitHub repository
|
|
|
71
71
|
run: (cd .mastra/output && zip ../../release.zip -r .)
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
The deployment package then contains only the build outputs from `.mastra/output`.
|
|
75
75
|
|
|
76
76
|
5. Commit and push your workflow modifications. The build will be automatically triggered in the **Deployment Center** in your Azure dashboard. Monitor the deployment progress until it completes successfully.
|
|
77
77
|
|
|
@@ -56,7 +56,7 @@ export const mastra = new Mastra({
|
|
|
56
56
|
})
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
To test your Cloudflare Worker locally, also install the [`wrangler` CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/):
|
|
60
60
|
|
|
61
61
|
**npm**:
|
|
62
62
|
|
|
@@ -8,11 +8,11 @@ For a complete example with advanced flow control features, see the [Inngest wor
|
|
|
8
8
|
|
|
9
9
|
## How Inngest works with Mastra
|
|
10
10
|
|
|
11
|
-
Inngest and Mastra integrate by aligning their workflow models: Inngest organizes logic into functions composed of steps, and Mastra workflows defined using `createWorkflow()` and `createStep()` map directly onto this
|
|
11
|
+
Inngest and Mastra integrate by aligning their workflow models: Inngest organizes logic into functions composed of steps, and Mastra workflows defined using `createWorkflow()` and `createStep()` map directly onto this structure. Each Mastra workflow becomes an Inngest function with a unique identifier, and each step within the workflow maps to an Inngest step.
|
|
12
12
|
|
|
13
13
|
The `serve()` function bridges the two systems by registering Mastra workflows as Inngest functions and setting up the necessary event handlers for execution and monitoring.
|
|
14
14
|
|
|
15
|
-
When an event triggers a workflow, Inngest executes it step by step
|
|
15
|
+
When an event triggers a workflow, Inngest executes it step by step and memoizes each result. On retry or resume, Inngest skips completed steps based on those saved results. Mastra control flow primitives, such as loops, conditionals, and nested workflows, map to the same Inngest function and step model while preserving composition, branching, and suspension.
|
|
16
16
|
|
|
17
17
|
Real-time monitoring, suspend/resume, and step-level observability are enabled via Inngest's publish-subscribe system and dashboard. As each step executes, its state and output are tracked using Mastra storage and can be resumed as needed.
|
|
18
18
|
|
|
@@ -194,7 +194,7 @@ export const mastra = new Mastra({
|
|
|
194
194
|
|
|
195
195
|
3. Open the Inngest Dashboard at <http://localhost:8288> and go to the **Apps** section in the sidebar to verify your Mastra workflow is registered
|
|
196
196
|
|
|
197
|
-
4.
|
|
197
|
+
4. In **Functions**, open your workflow. Select **Invoke** and provide the following input:
|
|
198
198
|
|
|
199
199
|
```json
|
|
200
200
|
{
|
|
@@ -256,7 +256,7 @@ Before you begin, make sure you have:
|
|
|
256
256
|
|
|
257
257
|
> **Warning:** Inngest's auto-discover convention assumes `/api/inngest`. Because this guide uses `/inngest/api`, set the **URL** field on the Inngest app to your deployed origin plus `/inngest/api` (for example `https://your-app.vercel.app/inngest/api`). If you leave it on the default, the Inngest dashboard won't find your app's functions.
|
|
258
258
|
|
|
259
|
-
6.
|
|
259
|
+
6. In **Functions**, open `workflow.increment-workflow`. Select **All actions** > **Invoke** and provide the following input:
|
|
260
260
|
|
|
261
261
|
```json
|
|
262
262
|
{
|
|
@@ -496,7 +496,7 @@ When migrating an existing production app from `serve()` to `connect()`, test th
|
|
|
496
496
|
- `functions`: Optional array of additional Inngest functions to register alongside Mastra workflows.
|
|
497
497
|
- `instanceId`: Stable identifier for the worker, shown in the Inngest dashboard. Defaults to the machine hostname.
|
|
498
498
|
- `maxWorkerConcurrency`: Maximum number of steps the worker runs at a time. Defaults to unlimited.
|
|
499
|
-
- `registerOptions`: Forwarded to Inngest during app registration (for example `signingKey`). When a field is set both here and at the top level, `registerOptions` wins
|
|
499
|
+
- `registerOptions`: Forwarded to Inngest during app registration (for example `signingKey`). When a field is set both here and at the top level, `registerOptions` wins. This matches the behavior of `serve()`.
|
|
500
500
|
|
|
501
501
|
`connect()` returns Inngest's `WorkerConnection`. The Inngest SDK handles `SIGINT` and `SIGTERM` by default. Store the returned connection and call `.close()` only when your worker needs custom shutdown control.
|
|
502
502
|
|
|
@@ -663,7 +663,7 @@ All flow control options are optional. If not specified, workflows run with Inng
|
|
|
663
663
|
|
|
664
664
|
## Cron scheduling
|
|
665
665
|
|
|
666
|
-
|
|
666
|
+
Use cron expressions to trigger Inngest workflows on a schedule. Common uses include daily reports and hourly data syncs, as well as maintenance tasks.
|
|
667
667
|
|
|
668
668
|
### Basic cron scheduling
|
|
669
669
|
|
|
@@ -171,7 +171,7 @@ await worker.run()
|
|
|
171
171
|
|
|
172
172
|
2. Open the Temporal UI at <http://localhost:8080> to inspect namespaces, workflows, and activities.
|
|
173
173
|
|
|
174
|
-
3.
|
|
174
|
+
3. In a new terminal, start the worker by running:
|
|
175
175
|
|
|
176
176
|
```bash
|
|
177
177
|
npx tsx src/mastra/worker.ts
|
|
@@ -84,7 +84,7 @@ export const mastra = new Mastra({
|
|
|
84
84
|
})
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
After deploying, Studio is available at the root URL (`https://<your-project>.vercel.app/`) and the API remains at `/api/*`. Studio automatically connects to the API on the same origin
|
|
87
|
+
After deploying, Studio is available at the root URL (`https://<your-project>.vercel.app/`) and the API remains at `/api/*`. Studio automatically connects to the API on the same origin, so you don't need additional environment variables.
|
|
88
88
|
|
|
89
89
|
> **Warning:** Once Studio is connected to your Mastra server, it has full access to your agents, workflows, and tools. Be sure to secure it properly in production (e.g. behind authentication, VPN, etc.) to prevent unauthorized access.
|
|
90
90
|
|
|
@@ -432,7 +432,7 @@ This connects [`useChat()`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat
|
|
|
432
432
|
|
|
433
433
|
## Test your agent
|
|
434
434
|
|
|
435
|
-
|
|
435
|
+
To test your agent with the chat interface, run both the Mastra server and the Electron app.
|
|
436
436
|
|
|
437
437
|
1. Start the mastra development server:
|
|
438
438
|
|
|
@@ -199,11 +199,11 @@ export class AgentService {
|
|
|
199
199
|
|
|
200
200
|
`MastraService` exposes:
|
|
201
201
|
|
|
202
|
-
- `getMastra()
|
|
203
|
-
- `getAgent(id)
|
|
204
|
-
- `getWorkflow(id)
|
|
205
|
-
- `getOptions()
|
|
206
|
-
- `isShuttingDown
|
|
202
|
+
- `getMastra()`: Returns the underlying `Mastra` instance
|
|
203
|
+
- `getAgent(id)`: Shorthand for `mastra.getAgent(id)`
|
|
204
|
+
- `getWorkflow(id)`: Shorthand for `mastra.getWorkflow(id)`
|
|
205
|
+
- `getOptions()`: Returns the module configuration
|
|
206
|
+
- `isShuttingDown`: `true` after graceful shutdown begins
|
|
207
207
|
|
|
208
208
|
### MASTRA token
|
|
209
209
|
|
|
@@ -353,7 +353,7 @@ It renders the response text using the [`<MessageResponse>`](https://ai-sdk.dev/
|
|
|
353
353
|
|
|
354
354
|
## Test your agent
|
|
355
355
|
|
|
356
|
-
|
|
356
|
+
To test your agent with the chat interface, run both the Mastra server and the Vite development server.
|
|
357
357
|
|
|
358
358
|
1. Start the Mastra development server:
|
|
359
359
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
In this guide, you'll create a "Chef Assistant" agent that helps users cook meals with available ingredients.
|
|
6
6
|
|
|
7
|
-
You'll learn how to create the agent and register it with Mastra. Next, you'll interact with the agent through your terminal and get to know different response formats.
|
|
7
|
+
You'll learn how to create the agent and register it with Mastra. Next, you'll interact with the agent through your terminal and get to know different response formats. You'll then access the agent through Mastra's local API endpoints.
|
|
8
8
|
|
|
9
9
|
## Prerequisites
|
|
10
10
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Building a code review bot
|
|
4
4
|
|
|
5
|
-
In this guide, you'll build a code review bot that automatically reviews pull requests using workspace skills. The bot loads coding standards from skill files and provides structured feedback. You'll
|
|
5
|
+
In this guide, you'll build a code review bot that automatically reviews pull requests using workspace skills. The bot loads coding standards from skill files and provides structured feedback. You'll create a workspace with a skills directory and define an [Agent Skill](https://agentskills.io) with review instructions and reference files. Then you'll connect the skill to an agent that performs automated reviews.
|
|
6
6
|
|
|
7
7
|
## Prerequisites
|
|
8
8
|
|
|
@@ -146,7 +146,7 @@ Open [Studio](https://mastra.ai/docs/studio/overview), select **Coding Agent**,
|
|
|
146
146
|
Inspect project-notes.md and report the project name, status, and owner. Do not modify files.
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
The response should identify the Acme support portal
|
|
149
|
+
The response should identify the Acme support portal and describe its development status. It should report that the Platform team owns the project and leave the file unchanged. Model wording may vary.
|
|
150
150
|
|
|
151
151
|
## Create the agent controller
|
|
152
152
|
|
|
@@ -191,13 +191,13 @@ export async function createCodingAgentSession() {
|
|
|
191
191
|
}
|
|
192
192
|
```
|
|
193
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.
|
|
194
|
+
This example uses one mode and disables the controller's additional built-in tools so the introductory UI can focus on workspace execution. The simplified setup is intended for this tutorial. 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
195
|
|
|
196
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
197
|
|
|
198
198
|
## Build the terminal UI
|
|
199
199
|
|
|
200
|
-
Create `src/coding-agent-tui.ts`. The UI renders assistant message updates
|
|
200
|
+
Create `src/coding-agent-tui.ts`. The UI renders assistant message updates and shows tool activity. It also asks the user to approve or decline each workspace tool call.
|
|
201
201
|
|
|
202
202
|
```typescript
|
|
203
203
|
import { pathToFileURL } from 'node:url'
|
|
@@ -334,7 +334,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
|
334
334
|
}
|
|
335
335
|
```
|
|
336
336
|
|
|
337
|
-
The optional `Terminal` parameter supports automated tests while using `ProcessTerminal` during normal execution. The UI intentionally renders only the latest response
|
|
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
338
|
|
|
339
339
|
## Run the coding agent
|
|
340
340
|
|
|
@@ -9,7 +9,7 @@ In this guide, you'll build a complete development assistant that combines all w
|
|
|
9
9
|
- [Skills](https://mastra.ai/docs/workspace/skills) for coding standards
|
|
10
10
|
- [Search](https://mastra.ai/docs/workspace/search) for finding examples
|
|
11
11
|
|
|
12
|
-
You'll set up a workspace with a sample project
|
|
12
|
+
You'll set up a workspace with a sample project and add coding standards as a skill. Then you'll create an agent that writes code following TDD practices. By the end, the agent can read existing code and write new implementations, then run tests in a sandbox and iterate based on the results.
|
|
13
13
|
|
|
14
14
|
## Prerequisites
|
|
15
15
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Building a docs manager
|
|
4
4
|
|
|
5
|
-
In this guide, you'll build a documentation manager that maintains your project's docs. It creates well-structured markdown files
|
|
5
|
+
In this guide, you'll build a documentation manager that maintains your project's docs. It creates well-structured markdown files and keeps documentation organized while preventing accidental overwrites. You'll set up a workspace filesystem and create an agent with document management instructions. Then you'll use conversational prompts to generate and update documentation.
|
|
6
6
|
|
|
7
7
|
## Prerequisites
|
|
8
8
|
|
|
@@ -40,7 +40,7 @@ Inside the `workspace` directory, create the following folders:
|
|
|
40
40
|
- `docs/api/`: For API reference documentation
|
|
41
41
|
- `docs/tutorials/`: For step-by-step tutorials
|
|
42
42
|
|
|
43
|
-
Create
|
|
43
|
+
Create `workspace/docs/README.md` as the documentation index:
|
|
44
44
|
|
|
45
45
|
```markdown
|
|
46
46
|
# Project Documentation
|
|
@@ -217,7 +217,7 @@ Try updating an existing document:
|
|
|
217
217
|
Update the getting started guide to include a section on configuration after the Quick Example
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
The agent should read the existing `getting-started.md` file
|
|
220
|
+
The agent should read the existing `getting-started.md` file and find the right insertion point. It should add the new section without disrupting existing content.
|
|
221
221
|
|
|
222
222
|
### Organize documentation
|
|
223
223
|
|
|
@@ -121,11 +121,11 @@ The agent will return a formatted description with sections in English, Spanish,
|
|
|
121
121
|
|
|
122
122
|
## GitHub actions
|
|
123
123
|
|
|
124
|
-
GitHub Actions run your workflows in short-lived environments on GitHub's infrastructure. Each run starts with a clean virtual machine
|
|
124
|
+
GitHub Actions run your workflows in short-lived environments on GitHub's infrastructure. Each run starts with a clean virtual machine and checks out your code. It installs dependencies before running your workflow steps. The environment shuts down when the run completes. Nothing persists between runs unless you explicitly save it as an artifact or cache.
|
|
125
125
|
|
|
126
126
|
### Create the workflow
|
|
127
127
|
|
|
128
|
-
GitHub Actions workflows live in the `.github/workflows` directory. Create a `.github` directory at the root of your project, then create a `workflows` directory inside it. Add
|
|
128
|
+
GitHub Actions workflows live in the `.github/workflows` directory. Create a `.github` directory at the root of your project, then create a `workflows` directory inside it. Add `pr-description.yml`.
|
|
129
129
|
|
|
130
130
|
This workflow runs whenever a pull request is opened or updated. It generates a diff for the PR, calls the Mastra agent to describe the changes, and writes the description directly into the PR in the GitHub UI.
|
|
131
131
|
|
|
@@ -187,7 +187,7 @@ jobs:
|
|
|
187
187
|
|
|
188
188
|
### Create the workflow script
|
|
189
189
|
|
|
190
|
-
Create a `scripts` directory inside `.github` and add
|
|
190
|
+
Create a `scripts` directory inside `.github` and add `generate-description.ts`.
|
|
191
191
|
|
|
192
192
|
This script reads the PR diff from `PR_DIFF_FILE`, generates a description using the Mastra agent, and writes the result to `PR_DESCRIPTION_FILE` for the workflow to publish to the pull request.
|
|
193
193
|
|
|
@@ -229,7 +229,7 @@ ${readFileSync(process.env.PR_DIFF_FILE!, 'utf-8')}
|
|
|
229
229
|
|
|
230
230
|
You now have a GitHub Action that generates multi-language PR descriptions using a Mastra agent. Once the workflow and supporting files are merged into your main branch, the agent will run automatically the next time a pull request is created or updated. You can monitor the run in the **Actions** tab of your repository.
|
|
231
231
|
|
|
232
|
-
From here,
|
|
232
|
+
From here, customize the agent instructions or change the output languages. You can also extend the workflow to handle other events.
|
|
233
233
|
|
|
234
234
|
To learn more:
|
|
235
235
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
In this guide, you'll create an AI research assistant that can analyze academic papers and answer specific questions about their content using Retrieval Augmented Generation (RAG).
|
|
6
6
|
|
|
7
|
-
You'll use the
|
|
7
|
+
You'll use the original Transformer paper ["Attention Is All You Need"](https://arxiv.org/html/1706.03762) as your example. As a database you'll use a local libSQL database.
|
|
8
8
|
|
|
9
9
|
## Prerequisites
|
|
10
10
|
|
|
@@ -155,7 +155,7 @@ Let's define the agent's behavior, connect it to your Mastra project, and create
|
|
|
155
155
|
|
|
156
156
|
## Processing documents
|
|
157
157
|
|
|
158
|
-
In the following steps you'll fetch the research paper
|
|
158
|
+
In the following steps, you'll fetch the research paper and split it into smaller chunks. You'll then generate embeddings and store the chunks in the vector database.
|
|
159
159
|
|
|
160
160
|
1. In this step the research paper is retrieved by providing an URL, then converted to a document object, and split into smaller, manageable chunks. By splitting into chunks the processing is faster and more efficient.
|
|
161
161
|
|
|
@@ -201,7 +201,7 @@ In the following steps you'll fetch the research paper, split it into smaller ch
|
|
|
201
201
|
|
|
202
202
|
> **Note:** This metadata is crucial as it allows for returning the actual content when the vector store finds relevant matches.
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
The agent uses the vector index to search for and retrieve relevant information.
|
|
205
205
|
|
|
206
206
|
Open the `src/store.ts` file and add the following:
|
|
207
207
|
|