@mastra/mcp-docs-server 1.2.17-alpha.9 → 1.2.17
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/course/02-agent-tools-mcp/32-conclusion.md +1 -1
- package/.docs/docs/agents/code-mode.md +3 -3
- package/.docs/docs/agents/guardrails.md +1 -1
- package/.docs/docs/agents/{agent-approval.md → human-in-the-loop.md} +5 -5
- package/.docs/docs/agents/networks.md +3 -3
- package/.docs/docs/agents/overview.md +7 -7
- package/.docs/docs/agents/processors.md +3 -3
- package/.docs/docs/agents/{using-tools.md → tools.md} +7 -7
- package/.docs/docs/{server/auth → auth}/custom-auth-provider.md +1 -1
- package/.docs/docs/{server/auth → auth}/fga.md +27 -1
- package/.docs/docs/{server/auth.md → auth/overview.md} +4 -4
- package/.docs/docs/{server/auth → auth}/simple-auth.md +1 -1
- package/.docs/docs/{server/auth → auth}/workers.md +2 -2
- package/.docs/docs/{capabilities/channels.md → channels.md} +2 -2
- package/.docs/docs/{agents → connections}/a2a.md +2 -2
- package/.docs/docs/{agents → connections}/acp.md +18 -6
- package/.docs/docs/{mcp/overview.md → connections/mcp.md} +1 -1
- package/.docs/docs/connections/overview.md +5 -5
- package/.docs/docs/{agents → connections}/sdk-agents.md +3 -1
- package/.docs/docs/deployment/cloud-providers.md +1 -0
- package/.docs/docs/deployment/mastra-server.md +2 -2
- package/.docs/docs/deployment/overview.md +2 -1
- package/.docs/docs/deployment/sandbox.md +3 -3
- package/.docs/docs/deployment/workers.md +4 -4
- package/.docs/docs/guides/multi-agent-systems.md +7 -7
- package/.docs/docs/guides/streaming.md +1 -1
- package/.docs/docs/harness/agent-controller.md +5 -3
- package/.docs/docs/{long-running-agents → harness}/background-tasks.md +5 -5
- package/.docs/docs/{long-running-agents → harness}/durable-agents.md +18 -2
- package/.docs/docs/{long-running-agents → harness}/goals.md +6 -6
- package/.docs/docs/harness/overview.md +11 -10
- package/.docs/docs/{long-running-agents → harness}/schedules.md +5 -5
- package/.docs/docs/{long-running-agents → harness}/signal-providers.md +4 -4
- package/.docs/docs/mastra-platform/deploy.md +1 -1
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/mastra-platform/server.md +1 -1
- package/.docs/docs/memory/message-history.md +1 -1
- package/.docs/docs/memory/overview.md +4 -4
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +1 -1
- package/.docs/docs/{workspace → sandbox}/filesystem.md +2 -2
- package/.docs/docs/{workspace → sandbox}/lsp.md +3 -3
- package/.docs/docs/{workspace/sandbox.md → sandbox/overview.md} +4 -3
- package/.docs/docs/{workspace → sandbox}/search.md +2 -2
- package/.docs/docs/{workspace → sandbox}/skills.md +5 -5
- package/.docs/docs/server/custom-api-routes.md +2 -2
- package/.docs/docs/server/mastra-client.md +2 -2
- package/.docs/docs/server/{mastra-server.md → overview.md} +3 -3
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/server/server-adapters.md +4 -4
- package/.docs/docs/{agents/skills.md → skills.md} +4 -4
- package/.docs/docs/{storage/overview.md → storage.md} +2 -1
- package/.docs/docs/studio/auth.md +4 -4
- package/.docs/docs/studio/overview.md +2 -2
- package/.docs/docs/{capabilities/subagents.md → subagents.md} +35 -5
- package/.docs/docs/workflows/agents-and-tools.md +1 -1
- package/.docs/docs/workflows/control-flow.md +0 -4
- package/.docs/docs/workflows/human-in-the-loop.md +0 -4
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/scheduled-workflows.md +2 -2
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workflows/suspend-and-resume.md +0 -4
- package/.docs/integrations/agentic-ui/ai-sdk-ui.md +1 -1
- package/.docs/integrations/agentic-ui/copilotkit.md +1 -1
- package/.docs/integrations/auth/google.md +2 -2
- package/.docs/integrations/auth/workos.md +1 -1
- package/.docs/integrations/browsers/agent-browser.md +2 -2
- package/.docs/integrations/browsers/browser-viewer.md +6 -6
- package/.docs/integrations/browsers/firecrawl.md +1 -1
- package/.docs/integrations/browsers/stagehand.md +2 -2
- package/.docs/integrations/channels/discord.md +2 -2
- package/.docs/integrations/channels/github.md +1 -1
- package/.docs/integrations/channels/imessage.md +4 -4
- package/.docs/integrations/channels/slack.md +5 -5
- package/.docs/integrations/channels/teams.md +2 -2
- package/.docs/integrations/channels/telegram.md +2 -2
- package/.docs/integrations/channels/whatsapp.md +2 -2
- package/.docs/integrations/databases/postgresql.md +1 -0
- package/.docs/integrations/deploy/amazon-ec2.md +2 -2
- package/.docs/integrations/deploy/aws-lambda.md +3 -3
- package/.docs/integrations/deploy/azure-app-services.md +2 -2
- package/.docs/integrations/deploy/cloudflare.md +2 -2
- package/.docs/integrations/deploy/digital-ocean.md +3 -3
- package/.docs/integrations/deploy/kubernetes.md +11 -11
- package/.docs/integrations/deploy/netlify.md +3 -3
- package/.docs/integrations/deploy/render.md +389 -0
- package/.docs/integrations/deploy/vercel.md +2 -2
- package/.docs/integrations/file-storage/amazon-s3.md +1 -1
- package/.docs/integrations/file-storage/azure-blob.md +1 -1
- package/.docs/integrations/file-storage/google-cloud-storage.md +1 -1
- package/.docs/integrations/file-storage/mesa.md +2 -2
- package/.docs/integrations/file-storage/vercel-files.md +1 -1
- package/.docs/integrations/frameworks/astro.md +6 -2
- package/.docs/integrations/frameworks/electron.md +1 -1
- package/.docs/integrations/frameworks/express.md +1 -1
- package/.docs/integrations/frameworks/hono.md +1 -1
- package/.docs/integrations/frameworks/nestjs.md +1 -1
- package/.docs/integrations/frameworks/next-js.md +6 -2
- package/.docs/integrations/frameworks/nuxt.md +1 -1
- package/.docs/integrations/frameworks/sveltekit.md +1 -1
- package/.docs/integrations/frameworks/vite-react.md +6 -2
- package/.docs/integrations/sandboxes/agentcore.md +1 -1
- package/.docs/integrations/sandboxes/apple-container.md +1 -1
- package/.docs/integrations/sandboxes/cloudflare-sandbox.md +118 -0
- package/.docs/integrations/sandboxes/daytona.md +1 -1
- package/.docs/integrations/sandboxes/docker.md +4 -3
- package/.docs/integrations/sandboxes/e2b.md +1 -1
- package/.docs/integrations/sandboxes/modal.md +1 -1
- package/.docs/integrations/sandboxes/railway.md +11 -0
- package/.docs/integrations.md +4 -0
- package/.docs/models/environment-variables.md +8 -2
- package/.docs/models/gateways/merge-gateway.md +212 -0
- package/.docs/models/gateways/openrouter.md +3 -1
- package/.docs/models/gateways/vercel.md +22 -1
- package/.docs/models/gateways.md +1 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-token-plan-cn.md +2 -1
- package/.docs/models/providers/alibaba-token-plan.md +2 -1
- package/.docs/models/providers/ambient.md +2 -2
- package/.docs/models/providers/amd.md +73 -0
- package/.docs/models/providers/arcee.md +79 -0
- package/.docs/models/providers/baseten.md +1 -1
- package/.docs/models/providers/cerebras.md +2 -3
- package/.docs/models/providers/chutes.md +2 -1
- package/.docs/models/providers/cloudflare-workers-ai.md +3 -2
- package/.docs/models/providers/cortecs.md +2 -1
- package/.docs/models/providers/crof.md +1 -1
- package/.docs/models/providers/crossmodel.md +3 -2
- package/.docs/models/providers/deepinfra.md +5 -1
- package/.docs/models/providers/digitalocean.md +3 -2
- package/.docs/models/providers/edenai.md +19 -5
- package/.docs/models/providers/empiriolabs.md +10 -1
- package/.docs/models/providers/hetzner.md +6 -8
- package/.docs/models/providers/huggingface.md +4 -1
- package/.docs/models/providers/hyper.md +9 -8
- package/.docs/models/providers/inferx.md +19 -13
- package/.docs/models/providers/jalapeno.md +89 -0
- package/.docs/models/providers/kilo.md +13 -12
- package/.docs/models/providers/kosmik.md +73 -0
- package/.docs/models/providers/llmgateway.md +3 -3
- package/.docs/models/providers/llmtr.md +35 -10
- package/.docs/models/providers/nano-gpt.md +15 -17
- package/.docs/models/providers/ofox.md +3 -3
- package/.docs/models/providers/opencode-go.md +2 -2
- package/.docs/models/providers/requesty.md +3 -3
- package/.docs/models/providers/runinfra.md +76 -0
- package/.docs/models/providers/sakana.md +3 -2
- package/.docs/models/providers/scnet-token-plan.md +85 -0
- package/.docs/models/providers/scx-ai.md +76 -0
- package/.docs/models/providers/togetherai.md +2 -1
- package/.docs/models/providers/umans-ai-coding-plan.md +2 -1
- package/.docs/models/providers/umans-ai.md +2 -1
- package/.docs/models/providers/vivgrid.md +2 -1
- package/.docs/models/providers/wandb.md +2 -1
- package/.docs/models/providers/xai.md +2 -1
- package/.docs/models/providers.md +7 -2
- package/.docs/reference/acp/acp-agent.md +2 -2
- package/.docs/reference/acp/create-acp-tool.md +1 -1
- package/.docs/reference/agent-controller/agent-controller-class.md +2 -2
- package/.docs/reference/agents/agent.md +2 -2
- package/.docs/reference/agents/channels.md +2 -2
- package/.docs/reference/agents/createSkill.md +2 -2
- package/.docs/reference/agents/durable-agent.md +1 -1
- package/.docs/reference/agents/generate.md +3 -1
- package/.docs/reference/agents/getSkill.md +1 -1
- package/.docs/reference/agents/listSkills.md +1 -1
- package/.docs/reference/agents/listSuspendedRuns.md +6 -6
- package/.docs/reference/agents/listTools.md +2 -2
- package/.docs/reference/agents/network.md +3 -1
- package/.docs/reference/ai-sdk/chat-route.md +1 -1
- package/.docs/reference/ai-sdk/handle-chat-stream.md +1 -1
- package/.docs/reference/ai-sdk/handle-network-stream.md +2 -2
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +2 -2
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +1 -1
- package/.docs/reference/ai-sdk/workflow-route.md +1 -1
- package/.docs/reference/auth/fga.md +7 -5
- package/.docs/reference/auth/jwt.md +1 -1
- package/.docs/reference/browser/agent-browser.md +2 -2
- package/.docs/reference/browser/browser-viewer.md +2 -2
- package/.docs/reference/browser/firecrawl-browser.md +1 -1
- package/.docs/reference/browser/mastra-browser.md +1 -1
- package/.docs/reference/browser/stagehand-browser.md +2 -2
- package/.docs/reference/build-with-ai.md +2 -2
- package/.docs/reference/channels/channel-provider.md +1 -1
- package/.docs/reference/channels/slack-provider.md +1 -1
- package/.docs/reference/cli/mastra.md +2 -0
- package/.docs/reference/client-js/agents.md +24 -4
- package/.docs/reference/coding-agent/create-coding-agent.md +142 -13
- package/.docs/reference/configuration.md +6 -6
- package/.docs/reference/core/getEditor.md +1 -1
- package/.docs/reference/core/getMCPServer.md +1 -1
- package/.docs/reference/core/getMCPServerById.md +1 -1
- package/.docs/reference/core/getTool.md +1 -1
- package/.docs/reference/core/getToolById.md +1 -1
- package/.docs/reference/core/listMCPServers.md +1 -1
- package/.docs/reference/core/listTools.md +1 -1
- package/.docs/reference/core/removeWorkspace.md +1 -1
- package/.docs/reference/editor/mastra-editor.md +2 -2
- package/.docs/reference/editor/prompt-blocks.md +2 -2
- package/.docs/reference/editor/tool-provider.md +108 -1
- package/.docs/reference/editor/tools.md +1 -1
- package/.docs/reference/editor/versioning.md +3 -3
- package/.docs/reference/evals/prompt-alignment.md +18 -0
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/file-based-agents/memory.md +2 -2
- package/.docs/reference/file-based-agents/server.md +3 -3
- package/.docs/reference/file-based-agents/skills.md +1 -1
- package/.docs/reference/file-based-agents/storage.md +3 -3
- package/.docs/reference/file-based-agents/subagents.md +1 -1
- package/.docs/reference/file-based-agents/workspace.md +3 -3
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/manual-install.md +3 -3
- package/.docs/reference/memory/memory-class.md +1 -0
- package/.docs/reference/memory/settled.md +57 -0
- package/.docs/reference/migrations/network-to-supervisor.md +2 -2
- package/.docs/reference/processors/provider-history-compat.md +6 -5
- package/.docs/reference/processors/skill-search-processor.md +3 -1
- package/.docs/reference/processors/token-limiter-processor.md +4 -0
- package/.docs/reference/processors/tool-call-filter.md +7 -7
- package/.docs/reference/processors/tool-search-processor.md +1 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +3 -3
- package/.docs/reference/pubsub/redis-streams.md +1 -1
- package/.docs/reference/rag/graph-rag.md +71 -8
- package/.docs/reference/rag/retrieval.md +26 -18
- package/.docs/reference/schedules/overview.md +1 -1
- package/.docs/reference/streaming/ChunkType.md +2 -2
- package/.docs/reference/streaming/agents/stream.md +29 -4
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/tools/ask-user-tool.md +1 -1
- package/.docs/reference/tools/create-code-mode.md +1 -1
- package/.docs/reference/tools/create-tool.md +4 -4
- package/.docs/reference/tools/mcp-client.md +2 -0
- package/.docs/reference/tools/mcp-server.md +97 -4
- package/.docs/reference/tools/submit-plan-tool.md +1 -1
- package/.docs/reference/tools/task-tools.md +2 -2
- package/.docs/reference/vectors/vectorize.md +12 -2
- package/.docs/reference/workers/overview.md +2 -2
- package/.docs/reference/workspace/local-filesystem.md +1 -1
- package/.docs/reference/workspace/local-sandbox.md +4 -3
- package/.docs/reference/workspace/platform-sandbox.md +11 -0
- package/.docs/reference/workspace/process-manager.md +20 -4
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +5 -5
- package/CHANGELOG.md +73 -0
- package/package.json +6 -6
- package/.docs/models/providers/merge-gateway.md +0 -265
- /package/.docs/docs/{server/auth → auth}/composite-auth.md +0 -0
- /package/.docs/docs/{server/auth → auth}/jwt.md +0 -0
- /package/.docs/docs/{browser/overview.md → browser.md} +0 -0
- /package/.docs/docs/{getting-started/develop.md → develop.md} +0 -0
- /package/.docs/docs/{long-running-agents → harness}/signals.md +0 -0
- /package/.docs/docs/{editor/overview.md → studio/editor.md} +0 -0
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
# createCodingAgent()
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Added in:** `@mastra/core@1.48.0`
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`createCodingAgent()` builds a coding [`Agent`](https://mastra.ai/reference/agents/agent) with the essential defaults a coding agent always needs: a local workspace, the task-list signal provider when `memory` is configured, network-retry error processors, and the goal judge prompt. Supply only `model` and `instructions` to get a working agent, or override any default.
|
|
8
|
+
|
|
9
|
+
The returned value is a standard `Agent`, so it works anywhere an `Agent` does: including as the agent passed to an [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class). The function lives in `@mastra/core` with no hosted service behind it, and every default it fills in is a primitive you can also configure on [`new Agent()`](https://mastra.ai/reference/agents/agent) yourself.
|
|
10
|
+
|
|
11
|
+
The defaults match the ones [Mastra Code](https://code.mastra.ai) runs on. The prompt, modes, and tools that make up that product aren't included: `createCodingAgent()` sets up only the runtime pieces listed under [Defaults](#defaults).
|
|
8
12
|
|
|
9
13
|
## Usage example
|
|
10
14
|
|
|
11
|
-
Pass a model
|
|
15
|
+
Pass a model and instructions. `createCodingAgent()` fills in the workspace and the error processors. The task signal provider is added when `memory` is configured, and the goal prompt when a `goal` is configured:
|
|
12
16
|
|
|
13
17
|
```typescript
|
|
14
18
|
import { createCodingAgent } from '@mastra/core/coding-agent'
|
|
@@ -18,13 +22,20 @@ const agent = createCodingAgent({
|
|
|
18
22
|
name: 'My Coding Agent',
|
|
19
23
|
model: 'openai/gpt-5',
|
|
20
24
|
instructions: 'You are a helpful coding assistant.',
|
|
21
|
-
tools: {},
|
|
22
25
|
})
|
|
26
|
+
|
|
27
|
+
const result = await agent.generate('Which test files mention the /health endpoint?')
|
|
23
28
|
```
|
|
24
29
|
|
|
30
|
+
The agent receives the [workspace tools](https://mastra.ai/reference/workspace/workspace-class) for its resolved workspace, so `tools` is only needed for capabilities beyond the workspace, such as opening a pull request. Mastra also adds a description of the workspace to the system prompt.
|
|
31
|
+
|
|
32
|
+
> **Warning:** The default workspace runs commands on the host machine with the permissions of your application process. See [Workspace](#workspace) for how to swap in an isolated sandbox.
|
|
33
|
+
|
|
34
|
+
For the behavioral prompt Mastra Code uses, covering repository exploration, edits, commands, and commits, build `instructions` with [`buildBasePrompt()`](https://mastra.ai/reference/coding-agent/build-base-prompt).
|
|
35
|
+
|
|
25
36
|
## Parameters
|
|
26
37
|
|
|
27
|
-
`createCodingAgent()` accepts every field of [`AgentConfig`](https://mastra.ai/reference/agents/agent) plus the fields below. Fields you provide
|
|
38
|
+
`createCodingAgent()` accepts every field of [`AgentConfig`](https://mastra.ai/reference/agents/agent) plus the fields below. Fields you provide replace the corresponding default, except for `signals`: the default task signal provider is merged into the providers you pass. See [Signals](#signals).
|
|
28
39
|
|
|
29
40
|
**model** (`MastraLanguageModel | DynamicArgument<MastraLanguageModel>`): The language model the agent uses. Passed straight through to Agent.
|
|
30
41
|
|
|
@@ -32,11 +43,11 @@ const agent = createCodingAgent({
|
|
|
32
43
|
|
|
33
44
|
**tools** (`ToolsInput | DynamicArgument<ToolsInput>`): Tools available to the agent. Passed straight through to Agent.
|
|
34
45
|
|
|
35
|
-
**workspace** (`AnyWorkspace | undefined`): The workspace backing the agent. When the key is omitted, a default local workspace is built. When set explicitly to undefined,
|
|
46
|
+
**workspace** (`AnyWorkspace | undefined`): The workspace backing the agent. When the key is omitted, a default local workspace is built. When set explicitly to undefined, no default is built. Opt out this way when the workspace is wired elsewhere, for example at the AgentController level.
|
|
36
47
|
|
|
37
48
|
**basePath** (`string`): Base path for the default workspace built when workspace is omitted. (Default: `process.cwd()`)
|
|
38
49
|
|
|
39
|
-
**signals** (`SignalProvider[]`): Signal providers for the agent.
|
|
50
|
+
**signals** (`SignalProvider[]`): Signal providers for the agent. A TaskSignalProvider is added only when memory is configured, and it is merged into the providers you pass rather than replacing them. Without memory, the agent gets exactly the providers you pass, or none.
|
|
40
51
|
|
|
41
52
|
**errorProcessors** (`Processor[]`): Error processors for the agent. When omitted, defaults to unknown stream-error retries with specialized ECONNRESET and bad-request policies, plus PrefillErrorHandler and ProviderHistoryCompat.
|
|
42
53
|
|
|
@@ -48,18 +59,29 @@ const agent = createCodingAgent({
|
|
|
48
59
|
|
|
49
60
|
## Defaults
|
|
50
61
|
|
|
51
|
-
|
|
62
|
+
A default is only filled in when you don't provide the corresponding field. `signals` is the exception: the task signal provider is appended to the providers you pass.
|
|
52
63
|
|
|
53
64
|
| Field | Default when omitted |
|
|
54
65
|
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
66
|
| `workspace` | A [`Workspace`](https://mastra.ai/reference/workspace/workspace-class) backed by `LocalFilesystem` and `LocalSandbox` rooted at the base path. |
|
|
56
|
-
| `signals` | A
|
|
67
|
+
| `signals` | A [`TaskSignalProvider`](https://mastra.ai/reference/signals/task-signal-provider), added only when `memory` is configured. |
|
|
57
68
|
| `errorProcessors` | Unknown stream-error retries with specialized ECONNRESET and bad-request policies, plus `PrefillErrorHandler` and `ProviderHistoryCompat`. |
|
|
58
69
|
| `goal.prompt` | `DEFAULT_GOAL_JUDGE_PROMPT` (only when a `goal` is configured). |
|
|
59
70
|
|
|
71
|
+
Nothing else is filled in. There's no default `model`, `instructions`, `tools`, `memory`, storage, or input and output processors.
|
|
72
|
+
|
|
73
|
+
Each default has an explicit opt-out:
|
|
74
|
+
|
|
75
|
+
| Default | How to opt out |
|
|
76
|
+
| ----------------- | ------------------------------------------- |
|
|
77
|
+
| Workspace | `workspace: undefined` |
|
|
78
|
+
| Task tracking | Don't configure `memory` on the agent |
|
|
79
|
+
| Error processors | `errorProcessors: []` |
|
|
80
|
+
| Goal judge prompt | Omit `goal`, or pass your own `goal.prompt` |
|
|
81
|
+
|
|
60
82
|
### Workspace
|
|
61
83
|
|
|
62
|
-
When the `workspace` key is omitted,
|
|
84
|
+
When the `workspace` key is omitted, a local workspace rooted at `basePath` (default `process.cwd()`) is built:
|
|
63
85
|
|
|
64
86
|
```typescript
|
|
65
87
|
import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace'
|
|
@@ -70,19 +92,94 @@ new Workspace({
|
|
|
70
92
|
})
|
|
71
93
|
```
|
|
72
94
|
|
|
73
|
-
To
|
|
95
|
+
To keep that shape but work in a different directory, pass `basePath`:
|
|
74
96
|
|
|
75
97
|
```typescript
|
|
98
|
+
import { createCodingAgent } from '@mastra/core/coding-agent'
|
|
99
|
+
|
|
100
|
+
const agent = createCodingAgent({
|
|
101
|
+
id: 'my-coding-agent',
|
|
102
|
+
name: 'My Coding Agent',
|
|
103
|
+
model: 'openai/gpt-5',
|
|
104
|
+
instructions: 'You are a helpful coding assistant.',
|
|
105
|
+
basePath: '/srv/checkouts/my-app',
|
|
106
|
+
})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Pass a `workspace` to build the backends yourself. Here the agent reads the whole repository while commands run inside one package. A remote sandbox takes the place of `LocalSandbox` in the same slot, see [Sandbox](https://mastra.ai/docs/sandbox/overview) for the available backends and isolation options:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { createCodingAgent } from '@mastra/core/coding-agent'
|
|
113
|
+
import { LocalFilesystem, LocalSandbox, Workspace } from '@mastra/core/workspace'
|
|
114
|
+
|
|
115
|
+
const agent = createCodingAgent({
|
|
116
|
+
id: 'my-coding-agent',
|
|
117
|
+
name: 'My Coding Agent',
|
|
118
|
+
model: 'openai/gpt-5',
|
|
119
|
+
instructions: 'You are a helpful coding assistant.',
|
|
120
|
+
workspace: new Workspace({
|
|
121
|
+
filesystem: new LocalFilesystem({ basePath: '/srv/checkouts/my-app' }),
|
|
122
|
+
sandbox: new LocalSandbox({ workingDirectory: '/srv/checkouts/my-app/packages/api' }),
|
|
123
|
+
}),
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
To opt out (for example, when the workspace is injected at the [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class) level), pass `workspace: undefined` explicitly. An omitted key builds the default, an explicit `undefined` builds nothing:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { createCodingAgent } from '@mastra/core/coding-agent'
|
|
131
|
+
|
|
76
132
|
const agent = createCodingAgent({
|
|
77
133
|
id: 'my-coding-agent',
|
|
78
134
|
name: 'My Coding Agent',
|
|
79
135
|
model: 'openai/gpt-5',
|
|
80
136
|
instructions: 'You are a helpful coding assistant.',
|
|
81
|
-
tools: {},
|
|
82
137
|
workspace: undefined, // opt out of the default workspace
|
|
83
138
|
})
|
|
84
139
|
```
|
|
85
140
|
|
|
141
|
+
### Signals
|
|
142
|
+
|
|
143
|
+
[`TaskSignalProvider`](https://mastra.ai/reference/signals/task-signal-provider) adds the `task_write`, `task_update`, `task_complete`, and `task_check` [task tools](https://mastra.ai/reference/tools/task-tools) and persists the list in thread state, which gives the agent a durable plan across a multi-step request:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { createCodingAgent } from '@mastra/core/coding-agent'
|
|
147
|
+
import { Memory } from '@mastra/memory'
|
|
148
|
+
|
|
149
|
+
const agent = createCodingAgent({
|
|
150
|
+
id: 'my-coding-agent',
|
|
151
|
+
name: 'My Coding Agent',
|
|
152
|
+
model: 'openai/gpt-5',
|
|
153
|
+
instructions: 'Plan multi-step work with the task tools, then carry it out.',
|
|
154
|
+
memory: new Memory(),
|
|
155
|
+
})
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The provider needs a memory-backed thread, so it's only added when `memory` is configured. With memory configured, the provider is merged into any `signals` you pass, which keeps task tracking from being dropped by custom providers. Passing `signals: []` alongside `memory` still yields the task provider. To run a memory-backed agent with no task tracking, configure the agent with [`new Agent()`](https://mastra.ai/reference/agents/agent) instead. Before `@mastra/core@1.49.0`, the provider was always added, which failed in memoryless contexts.
|
|
159
|
+
|
|
160
|
+
`TaskSignalProvider` takes no constructor arguments, so customizing this default means choosing which other providers the agent gets:
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import { createCodingAgent } from '@mastra/core/coding-agent'
|
|
164
|
+
import { WebhookSignalProvider } from '@mastra/core/signals'
|
|
165
|
+
import { Memory } from '@mastra/memory'
|
|
166
|
+
|
|
167
|
+
const agent = createCodingAgent({
|
|
168
|
+
id: 'my-coding-agent',
|
|
169
|
+
name: 'My Coding Agent',
|
|
170
|
+
model: 'openai/gpt-5',
|
|
171
|
+
instructions: 'You are a helpful coding assistant.',
|
|
172
|
+
memory: new Memory(),
|
|
173
|
+
signals: [
|
|
174
|
+
new WebhookSignalProvider({
|
|
175
|
+
extractResourceId: payload => (payload as { repository: string }).repository,
|
|
176
|
+
}),
|
|
177
|
+
],
|
|
178
|
+
})
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
That agent gets the webhook provider and the task provider.
|
|
182
|
+
|
|
86
183
|
### Error processors
|
|
87
184
|
|
|
88
185
|
The default [`StreamErrorRetryProcessor`](https://mastra.ai/reference/processors/stream-error-retry-processor) applies these retry policies:
|
|
@@ -91,10 +188,42 @@ The default [`StreamErrorRetryProcessor`](https://mastra.ai/reference/processors
|
|
|
91
188
|
- Network resets (`ECONNRESET` / `socket hang up`) retry up to twice with exponential backoff (`1000ms * 2^retryCount`, capped at `30000ms`).
|
|
92
189
|
- Bad-request errors retry once after `2000ms`.
|
|
93
190
|
|
|
94
|
-
Specific network-reset and bad-request policies take precedence over the unknown-error policy. Passing `errorProcessors` replaces the default processor stack. `PrefillErrorHandler` and `ProviderHistoryCompat` are also included for provider compatibility.
|
|
191
|
+
Specific network-reset and bad-request policies take precedence over the unknown-error policy. Passing `errorProcessors` replaces the default processor stack. `PrefillErrorHandler` and `ProviderHistoryCompat` are also included for provider compatibility: both repair errors caused by the shape of the message history, such as a provider rejecting a conversation that ends with an assistant message.
|
|
192
|
+
|
|
193
|
+
Retries happen inside the `generate()` or `stream()` call that hit the error, so a recovered failure is invisible to your code. When the retries run out, the error surfaces the way any model error does: `generate()` rejects and `stream()` emits an `error` chunk. `generate()` and `stream()` also accept `errorProcessors` per call, which replaces the agent's stack for that request. See [Processors](https://mastra.ai/docs/agents/processors) for `maxProcessorRetries`, the retry budget these processors share.
|
|
194
|
+
|
|
195
|
+
### Goal
|
|
196
|
+
|
|
197
|
+
No goal is configured by default. When you pass a `goal` without a `prompt`, `DEFAULT_GOAL_JUDGE_PROMPT` is used. The `goal` config carries the judge and the run budget, while the objective itself is per thread and set with [`setObjective()`](https://mastra.ai/docs/harness/goals):
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import { createCodingAgent } from '@mastra/core/coding-agent'
|
|
201
|
+
import { Memory } from '@mastra/memory'
|
|
202
|
+
|
|
203
|
+
const agent = createCodingAgent({
|
|
204
|
+
id: 'my-coding-agent',
|
|
205
|
+
name: 'My Coding Agent',
|
|
206
|
+
model: 'openai/gpt-5',
|
|
207
|
+
instructions: 'You are a helpful coding assistant.',
|
|
208
|
+
memory: new Memory(),
|
|
209
|
+
goal: {
|
|
210
|
+
judge: 'openai/gpt-5-mini',
|
|
211
|
+
maxRuns: 50,
|
|
212
|
+
},
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
const threadId = 'thread-1'
|
|
216
|
+
const resourceId = 'user-1'
|
|
217
|
+
|
|
218
|
+
await agent.setObjective('Get the test suite passing', { threadId, resourceId })
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
[Goals](https://mastra.ai/docs/harness/goals) require a [storage](https://mastra.ai/docs/storage) backend and a memory-backed thread. Without a resolved `judge`, the goal step is a no-op.
|
|
95
222
|
|
|
96
223
|
## Related
|
|
97
224
|
|
|
98
225
|
- [`buildBasePrompt()`](https://mastra.ai/reference/coding-agent/build-base-prompt)
|
|
226
|
+
- [Goals](https://mastra.ai/docs/harness/goals)
|
|
227
|
+
- [Sandbox](https://mastra.ai/docs/sandbox/overview)
|
|
99
228
|
- [`Agent`](https://mastra.ai/reference/agents/agent)
|
|
100
229
|
- [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class)
|
|
@@ -44,7 +44,7 @@ export const mastra = new Mastra({
|
|
|
44
44
|
|
|
45
45
|
Enables and configures the background task manager. When enabled, agents can dispatch long-running tool calls (including subagent invocations) to run asynchronously while the agentic loop continues. Tasks are persisted, so a configured `storage` backend is required.
|
|
46
46
|
|
|
47
|
-
Visit the [Background tasks documentation](https://mastra.ai/docs/
|
|
47
|
+
Visit the [Background tasks documentation](https://mastra.ai/docs/harness/background-tasks) to learn more.
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
50
|
import { Mastra } from '@mastra/core'
|
|
@@ -219,7 +219,7 @@ export const mastra = new Mastra({
|
|
|
219
219
|
|
|
220
220
|
MCP (Model Context Protocol) servers that expose Mastra tools, agents, workflows, and resources to MCP-compatible clients. Use this to author your own MCP servers that can be consumed by any system that supports the protocol.
|
|
221
221
|
|
|
222
|
-
Visit the [MCP Overview](https://mastra.ai/docs/mcp
|
|
222
|
+
Visit the [MCP Overview](https://mastra.ai/docs/connections/mcp) to learn more.
|
|
223
223
|
|
|
224
224
|
```typescript
|
|
225
225
|
import { Mastra } from '@mastra/core'
|
|
@@ -366,7 +366,7 @@ export const mastra = new Mastra({
|
|
|
366
366
|
|
|
367
367
|
Storage provider for persisting application data. Used by memory, workflows, traces, and other components that require persistence. Mastra supports multiple database backends including PostgreSQL, MongoDB, libSQL, and more.
|
|
368
368
|
|
|
369
|
-
Visit the [Storage documentation](https://mastra.ai/docs/storage
|
|
369
|
+
Visit the [Storage documentation](https://mastra.ai/docs/storage) to learn more.
|
|
370
370
|
|
|
371
371
|
```typescript
|
|
372
372
|
import { Mastra } from '@mastra/core'
|
|
@@ -386,7 +386,7 @@ export const mastra = new Mastra({
|
|
|
386
386
|
|
|
387
387
|
Tools are reusable functions that agents can use to interact with external systems. Each tool defines inputs, outputs, and execution logic.
|
|
388
388
|
|
|
389
|
-
Visit the [Tools documentation](https://mastra.ai/docs/agents/
|
|
389
|
+
Visit the [Tools documentation](https://mastra.ai/docs/agents/tools) to learn more.
|
|
390
390
|
|
|
391
391
|
> **Note:** Most users configure tools directly on agents. This top-level configuration is for defining reusable tools that can be shared across multiple agents.
|
|
392
392
|
|
|
@@ -483,7 +483,7 @@ export const mastra = new Mastra({
|
|
|
483
483
|
|
|
484
484
|
A Mastra workspace gives agents a persistent environment for storing files and executing commands. Agents inherit the global workspace on the `Mastra` class unless they have their own workspace configured.
|
|
485
485
|
|
|
486
|
-
See the [Workspace documentation](https://mastra.ai/docs/
|
|
486
|
+
See the [Workspace documentation](https://mastra.ai/docs/sandbox/overview) for implementation details.
|
|
487
487
|
|
|
488
488
|
```typescript
|
|
489
489
|
import { Mastra } from '@mastra/core'
|
|
@@ -618,7 +618,7 @@ export const mastra = new Mastra({
|
|
|
618
618
|
|
|
619
619
|
Authentication configuration for the server. Mastra supports multiple authentication providers including JWT, Clerk, Supabase, Firebase, WorkOS, and Auth0.
|
|
620
620
|
|
|
621
|
-
Visit the [Authentication documentation](https://mastra.ai/docs/
|
|
621
|
+
Visit the [Authentication documentation](https://mastra.ai/docs/auth/overview) to learn more.
|
|
622
622
|
|
|
623
623
|
```typescript
|
|
624
624
|
import { Mastra } from '@mastra/core'
|
|
@@ -43,5 +43,5 @@ const serverById = mastra.getMCPServerById('my-mcp-server')
|
|
|
43
43
|
|
|
44
44
|
## See also
|
|
45
45
|
|
|
46
|
-
- [MCP overview](https://mastra.ai/docs/mcp
|
|
46
|
+
- [MCP overview](https://mastra.ai/docs/connections/mcp)
|
|
47
47
|
- [MCP server reference](https://mastra.ai/reference/tools/mcp-server)
|
|
@@ -27,7 +27,7 @@ const tool = mastra.getTool('weather')
|
|
|
27
27
|
|
|
28
28
|
## Related
|
|
29
29
|
|
|
30
|
-
- [Share tools across agents](https://mastra.ai/docs/agents/
|
|
30
|
+
- [Share tools across agents](https://mastra.ai/docs/agents/tools)
|
|
31
31
|
- [Mastra class](https://mastra.ai/reference/core/mastra-class)
|
|
32
32
|
- [Mastra.getToolById()](https://mastra.ai/reference/core/getToolById)
|
|
33
33
|
- [Mastra.listTools()](https://mastra.ai/reference/core/listTools)
|
|
@@ -42,7 +42,7 @@ const toolById = mastra.getToolById('weather-tool')
|
|
|
42
42
|
|
|
43
43
|
## Related
|
|
44
44
|
|
|
45
|
-
- [Share tools across agents](https://mastra.ai/docs/agents/
|
|
45
|
+
- [Share tools across agents](https://mastra.ai/docs/agents/tools)
|
|
46
46
|
- [Mastra class](https://mastra.ai/reference/core/mastra-class)
|
|
47
47
|
- [Mastra.getTool()](https://mastra.ai/reference/core/getTool)
|
|
48
48
|
- [Mastra.listTools()](https://mastra.ai/reference/core/listTools)
|
|
@@ -32,7 +32,7 @@ This method lists the Mastra-level registry. It doesn't include tools that exist
|
|
|
32
32
|
|
|
33
33
|
## Related
|
|
34
34
|
|
|
35
|
-
- [Share tools across agents](https://mastra.ai/docs/agents/
|
|
35
|
+
- [Share tools across agents](https://mastra.ai/docs/agents/tools)
|
|
36
36
|
- [Mastra class](https://mastra.ai/reference/core/mastra-class)
|
|
37
37
|
- [Mastra.getTool()](https://mastra.ai/reference/core/getTool)
|
|
38
38
|
- [Mastra.getToolById()](https://mastra.ai/reference/core/getToolById)
|
|
@@ -24,5 +24,5 @@ When `destroy` is `true` and `workspace.destroy()` throws, the call rejects with
|
|
|
24
24
|
|
|
25
25
|
## Related
|
|
26
26
|
|
|
27
|
-
- [Sandbox](https://mastra.ai/docs/
|
|
27
|
+
- [Sandbox](https://mastra.ai/docs/sandbox/overview)
|
|
28
28
|
- [Workspace class](https://mastra.ai/reference/workspace/workspace-class)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
The `MastraEditor` class sets up the editor system. Pass it to the `Mastra` constructor to turn on editor features like prompt blocks, agent code override, versioning, and tool providers.
|
|
6
6
|
|
|
7
|
-
See [Editor](https://mastra.ai/docs/editor
|
|
7
|
+
See [Editor](https://mastra.ai/docs/studio/editor) for an introduction to what the editor does.
|
|
8
8
|
|
|
9
9
|
## Usage example
|
|
10
10
|
|
|
@@ -238,4 +238,4 @@ const source = mastra.getEditor()?.getSource()
|
|
|
238
238
|
|
|
239
239
|
Returns: `'code' | 'db' | undefined`
|
|
240
240
|
|
|
241
|
-
When `source` is omitted, Editor uses the configured database storage even though `getSource()` returns `undefined`. See [Editor storage options](https://mastra.ai/docs/editor
|
|
241
|
+
When `source` is omitted, Editor uses the configured database storage even though `getSource()` returns `undefined`. See [Editor storage options](https://mastra.ai/docs/studio/editor) for the storage workflows and [code-source versioning](https://mastra.ai/reference/editor/versioning) for activation and Git history behavior.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Prompt blocks are reusable instruction templates managed by Editor. An agent's instructions can combine inline text with embedded prompt blocks and references to independently versioned prompt blocks.
|
|
6
6
|
|
|
7
|
-
See [Prompt blocks](https://mastra.ai/docs/editor
|
|
7
|
+
See [Prompt blocks](https://mastra.ai/docs/studio/editor) for the Studio workflow and common uses.
|
|
8
8
|
|
|
9
9
|
## Block types
|
|
10
10
|
|
|
@@ -134,4 +134,4 @@ The default Mastra server prefix is `/api`. A custom server prefix changes the p
|
|
|
134
134
|
|
|
135
135
|
## Version resolution
|
|
136
136
|
|
|
137
|
-
Runtime references resolve the active published block. Editor previews resolve the latest draft. See [Editor versioning](https://mastra.ai/docs/editor
|
|
137
|
+
Runtime references resolve the active published block. Editor previews resolve the latest draft. See [Editor versioning](https://mastra.ai/docs/studio/editor) for the shared draft, publish, and restore lifecycle.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
The `ToolProvider` interface defines how the editor discovers and resolves integration tools from external platforms. Mastra includes two built-in implementations: `ComposioToolProvider` and `ArcadeToolProvider`.
|
|
6
6
|
|
|
7
|
-
See [Editor tools](https://mastra.ai/docs/editor
|
|
7
|
+
See [Editor tools](https://mastra.ai/docs/studio/editor) for provider setup and the Studio workflow. See [tool configuration](https://mastra.ai/reference/editor/tools) for stored selections and resolution behavior.
|
|
8
8
|
|
|
9
9
|
## ToolProvider interface
|
|
10
10
|
|
|
@@ -77,6 +77,8 @@ const editor = new MastraEditor({
|
|
|
77
77
|
|
|
78
78
|
**defaultScope** (`'per-author' | 'caller-supplied'`): Connection identity scope. Defaults to per-author. (Default: `'per-author'`)
|
|
79
79
|
|
|
80
|
+
**userIdResolver** (`ComposioUserIdResolver`): Server-side resolver that derives the effective Composio userId from authenticated context fields. Used for invoker and caller-supplied execution. The exact connected account always comes from the stored connection pin.
|
|
81
|
+
|
|
80
82
|
### Tool slugs
|
|
81
83
|
|
|
82
84
|
Composio tools use uppercase slug format: `GITHUB_CREATE_ISSUE`, `SLACK_SEND_MESSAGE`.
|
|
@@ -85,6 +87,111 @@ Composio tools use uppercase slug format: `GITHUB_CREATE_ISSUE`, `SLACK_SEND_MES
|
|
|
85
87
|
|
|
86
88
|
Connections use per-author scope by default. Set `defaultScope: 'caller-supplied'` to bucket authorization by the caller identity resolved from `MASTRA_RESOURCE_ID_KEY` in request context. Ensure each authenticated request provides a stable, unique resource ID. When using `MastraAuthWorkos`, configure `mapUserToResourceId` to set this value from the authenticated user.
|
|
87
89
|
|
|
90
|
+
How the provider resolves the Composio user for a tool call depends on the connection:
|
|
91
|
+
|
|
92
|
+
- **Author-bound connections** (`kind: 'author'`) execute as the agent author's user against the pinned connected account.
|
|
93
|
+
- **Invoker-bound connections** (`kind: 'invoker'`) execute as the authenticated invoker against the exact pinned account, which may be an account another user shared with the invoker through Composio's access control list (ACL). The user ID comes from `userIdResolver` when configured, then the authenticated user, and never from the Memory `resourceId`. Invoker resolution fails when no authenticated user or resolver result exists.
|
|
94
|
+
- **Caller-supplied scope** (`scope: 'caller-supplied'`) uses `userIdResolver` when configured. Otherwise, it falls back to the legacy `resourceId` from request context for backward compatibility. When a specific connected account is pinned, execution routes to that exact account. Otherwise, Composio auto-resolves within the user's bucket.
|
|
95
|
+
|
|
96
|
+
### Execute with a shared account
|
|
97
|
+
|
|
98
|
+
Bob needs to run a Salesforce tool with an account that Alice shared through Composio. Keep each identity separate:
|
|
99
|
+
|
|
100
|
+
| Identity | Value |
|
|
101
|
+
| ----------------- | --------------------- |
|
|
102
|
+
| Memory resource | `project_123` |
|
|
103
|
+
| Composio user ID | `bob` |
|
|
104
|
+
| Connected account | `ca_alice_salesforce` |
|
|
105
|
+
|
|
106
|
+
Register the provider normally. Mastra server authentication writes the authenticated user to request context, so most applications don't need a `userIdResolver`:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { Mastra } from '@mastra/core/mastra'
|
|
110
|
+
import { MastraEditor } from '@mastra/editor'
|
|
111
|
+
import { ComposioToolProvider } from '@mastra/editor/composio'
|
|
112
|
+
|
|
113
|
+
const editor = new MastraEditor({
|
|
114
|
+
toolProviders: {
|
|
115
|
+
composio: new ComposioToolProvider({
|
|
116
|
+
apiKey: process.env.COMPOSIO_API_KEY!,
|
|
117
|
+
}),
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
export const mastra = new Mastra({ editor })
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Configure the agent with an invoker connection pinned to `ca_alice_salesforce`. When Bob invokes the agent, Mastra sends `bob` as the Composio user and the pinned account ID as the exact connected account. The Memory resource stays `project_123`. Composio then checks whether the account's ACL permits Bob to execute it.
|
|
125
|
+
|
|
126
|
+
### Map application users to Composio users
|
|
127
|
+
|
|
128
|
+
Use `userIdResolver` when your Composio user IDs differ from the IDs returned by Mastra authentication, or when your application must authorize the stored account pin before execution.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
type ComposioUserIdResolver = (
|
|
132
|
+
input: ComposioUserIdResolverInput,
|
|
133
|
+
) => Promise<string | undefined> | string | undefined
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**requestContext** (`RequestContext`): Live per-request context. Client-provided non-reserved entries are untrusted. Derive identity and authorize connectedAccountId only from validated, server-populated fields such as MASTRA\_USER\_KEY, read with getRaw().
|
|
137
|
+
|
|
138
|
+
**toolkit** (`string`): Toolkit slug the identity is being resolved for, when known.
|
|
139
|
+
|
|
140
|
+
**connectedAccountId** (`string`): Stored connection pin being resolved, when one exists. Use it to validate that the invoker may use this exact account.
|
|
141
|
+
|
|
142
|
+
The resolver returns the Composio user ID, or `undefined` to use the provider's default resolution. Returning an empty string throws instead of silently falling back. The resolver can't replace the connected account.
|
|
143
|
+
|
|
144
|
+
This example namespaces the Composio user by organization and asks the application's authorization layer to approve the exact account pin:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { MASTRA_USER_KEY } from '@mastra/server/auth'
|
|
148
|
+
import { ComposioToolProvider } from '@mastra/editor/composio'
|
|
149
|
+
import { canUseConnectedAccount } from './integration-authorization'
|
|
150
|
+
|
|
151
|
+
type AuthenticatedUser = {
|
|
152
|
+
id: string
|
|
153
|
+
organizationId: string
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function isAuthenticatedUser(value: unknown): value is AuthenticatedUser {
|
|
157
|
+
return (
|
|
158
|
+
typeof value === 'object' &&
|
|
159
|
+
value !== null &&
|
|
160
|
+
'id' in value &&
|
|
161
|
+
typeof value.id === 'string' &&
|
|
162
|
+
'organizationId' in value &&
|
|
163
|
+
typeof value.organizationId === 'string'
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const composio = new ComposioToolProvider({
|
|
168
|
+
apiKey: process.env.COMPOSIO_API_KEY!,
|
|
169
|
+
userIdResolver: async ({ requestContext, toolkit, connectedAccountId }) => {
|
|
170
|
+
const user = requestContext?.getRaw(MASTRA_USER_KEY)
|
|
171
|
+
if (!isAuthenticatedUser(user)) return undefined
|
|
172
|
+
|
|
173
|
+
if (connectedAccountId) {
|
|
174
|
+
const allowed = await canUseConnectedAccount({
|
|
175
|
+
actorId: user.id,
|
|
176
|
+
organizationId: user.organizationId,
|
|
177
|
+
provider: 'composio',
|
|
178
|
+
toolkit,
|
|
179
|
+
connectedAccountId,
|
|
180
|
+
})
|
|
181
|
+
if (!allowed) {
|
|
182
|
+
throw new Error('User cannot access this connected account')
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return `${user.organizationId}:${user.id}`
|
|
187
|
+
},
|
|
188
|
+
})
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Use the same namespaced ID when creating Composio connections and shared-account ACL entries. For example, Bob's Composio user ID in this setup is `acme:bob`.
|
|
192
|
+
|
|
193
|
+
Throw from `userIdResolver` to deny the request. During stored-agent resolution, Mastra logs the failure and omits tools associated with that connection, so no tool call reaches Composio. Other connections continue to resolve. When calling `resolveToolsVNext()` directly, the error is returned to the caller instead.
|
|
194
|
+
|
|
88
195
|
### Connection management tools
|
|
89
196
|
|
|
90
197
|
Composio provides tools for starting and monitoring authorization from an agent chat. When `allowedToolkits` is set, include `composio` to make these tools available:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Editor stores tool selections as part of an agent version. A stored configuration can add registered tools and tools from integration providers, as well as tools from Model Context Protocol (MCP) clients.
|
|
6
6
|
|
|
7
|
-
See [Editor tools](https://mastra.ai/docs/editor
|
|
7
|
+
See [Editor tools](https://mastra.ai/docs/studio/editor) for the Studio workflow and common uses.
|
|
8
8
|
|
|
9
9
|
## Tool sources
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Editor versions stored agents and prompt blocks. Database-backed resources use draft and publish operations. Code-backed agent overrides use deterministic files and Git history.
|
|
6
6
|
|
|
7
|
-
See [Editor versioning](https://mastra.ai/docs/editor
|
|
7
|
+
See [Editor versioning](https://mastra.ai/docs/studio/editor) for release and experimentation patterns.
|
|
8
8
|
|
|
9
9
|
## Database lifecycle
|
|
10
10
|
|
|
@@ -35,7 +35,7 @@ See [`MastraEditor`](https://mastra.ai/reference/editor/mastra-editor) for sourc
|
|
|
35
35
|
|
|
36
36
|
## Select an agent version
|
|
37
37
|
|
|
38
|
-
Calling [`mastra.getAgentById()`](https://mastra.ai/reference/core/getAgentById) without a selector returns the registered code-defined agent. Pass `status` or `versionId` to apply a stored override. See [Select a version](https://mastra.ai/docs/editor
|
|
38
|
+
Calling [`mastra.getAgentById()`](https://mastra.ai/reference/core/getAgentById) without a selector returns the registered code-defined agent. Pass `status` or `versionId` to apply a stored override. See [Select a version](https://mastra.ai/docs/studio/editor) for a TypeScript example.
|
|
39
39
|
|
|
40
40
|
With the default server prefix, pass selectors as query parameters under `/api`:
|
|
41
41
|
|
|
@@ -54,7 +54,7 @@ See the [Client SDK agents reference](https://mastra.ai/reference/client-js/agen
|
|
|
54
54
|
|
|
55
55
|
## Sub-agent versioning
|
|
56
56
|
|
|
57
|
-
Version overrides propagate through [supervisor-agent delegation](https://mastra.ai/docs/
|
|
57
|
+
Version overrides propagate through [supervisor-agent delegation](https://mastra.ai/docs/subagents) in request context. Define selectors at three levels:
|
|
58
58
|
|
|
59
59
|
1. `Mastra` instance `versions`: Defaults for every invocation
|
|
60
60
|
2. Server request-body `versions`: Per-request values added to request context
|
|
@@ -70,6 +70,24 @@ const scorer = createPromptAlignmentScorerLLM({
|
|
|
70
70
|
})
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
### Multi-turn conversations
|
|
74
|
+
|
|
75
|
+
By default the scorer only sees the current turn. In a conversation, a reply like `"A"` is meaningless on its own, so the judge can't tell what the user asked for and scores the response as misaligned.
|
|
76
|
+
|
|
77
|
+
Set `includeConversationHistory` to give the judge the prior turns from the agent's memory. The judge uses them to interpret the current prompt, but still scores only the current response.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const scorer = createPromptAlignmentScorerLLM({
|
|
81
|
+
model: 'openai/gpt-5.6-sol',
|
|
82
|
+
options: {
|
|
83
|
+
evaluationMode: 'user',
|
|
84
|
+
includeConversationHistory: { maxMessages: 6 }, // or `true` for the last 10 messages
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
This only affects agent runs, where the scorer receives the remembered messages. Runs scored from a plain prompt string are unchanged.
|
|
90
|
+
|
|
73
91
|
### Multi-Dimensional Analysis
|
|
74
92
|
|
|
75
93
|
Prompt Alignment evaluates responses across four key dimensions with weighted scoring that adapts based on the evaluation mode:
|
|
@@ -111,5 +111,5 @@ The `reason` summarizes the result and lists each criterion with its verdict, so
|
|
|
111
111
|
## Related
|
|
112
112
|
|
|
113
113
|
- [isTaskComplete on stream()](https://mastra.ai/reference/streaming/agents/stream)
|
|
114
|
-
- [Supervisor agents](https://mastra.ai/docs/
|
|
114
|
+
- [Supervisor agents](https://mastra.ai/docs/subagents)
|
|
115
115
|
- [createScorer](https://mastra.ai/reference/evals/create-scorer)
|
|
@@ -18,7 +18,7 @@ import { Memory } from '@mastra/memory'
|
|
|
18
18
|
export default new Memory()
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
The exported instance becomes the agent's `memory`. If your app configures a storage provider on the main Mastra instance, memory data is stored there. See [storage](https://mastra.ai/docs/storage
|
|
21
|
+
The exported instance becomes the agent's `memory`. If your app configures a storage provider on the main Mastra instance, memory data is stored there. See [storage](https://mastra.ai/docs/storage) for more information.
|
|
22
22
|
|
|
23
23
|
Use the same `resource` and `thread` values when calling the agent to continue a conversation:
|
|
24
24
|
|
|
@@ -51,7 +51,7 @@ export default new Memory({
|
|
|
51
51
|
|
|
52
52
|
Visit the [`Memory` reference](https://mastra.ai/reference/memory/memory-class) for constructor options. Use these pages for related memory features:
|
|
53
53
|
|
|
54
|
-
- [Storage](https://mastra.ai/docs/storage
|
|
54
|
+
- [Storage](https://mastra.ai/docs/storage): configure persistence for memory data.
|
|
55
55
|
- [Semantic recall](https://mastra.ai/docs/memory/semantic-recall): retrieve relevant past messages by semantic meaning.
|
|
56
56
|
- [Memory processors](https://mastra.ai/docs/memory/memory-processors): filter, trim, or transform messages before memory adds them to model context.
|
|
57
57
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
6
|
|
|
7
|
-
Mastra configures its HTTP [server](https://mastra.ai/docs/server/
|
|
7
|
+
Mastra configures its HTTP [server](https://mastra.ai/docs/server/overview) from a `server.ts` file directly under `src/mastra/`. The server exposes agents, workflows, and other registered primitives as REST endpoints, and the file default-exports the same `ServerConfig` shape you'd pass to [`new Mastra()`](https://mastra.ai/reference/core/mastra-class).
|
|
8
8
|
|
|
9
|
-
Use this page for the file-based convention. For server features, middleware, custom routes, generated API docs, and deployment behavior, see [Server overview](https://mastra.ai/docs/server/
|
|
9
|
+
Use this page for the file-based convention. For server features, middleware, custom routes, generated API docs, and deployment behavior, see [Server overview](https://mastra.ai/docs/server/overview).
|
|
10
10
|
|
|
11
11
|
## Quickstart
|
|
12
12
|
|
|
@@ -32,7 +32,7 @@ export default {
|
|
|
32
32
|
| Add webhooks or health checks | `apiRoutes` |
|
|
33
33
|
| Enable generated API docs | `build.openAPIDocs` and `build.swaggerUI` |
|
|
34
34
|
|
|
35
|
-
See [Mastra server](https://mastra.ai/docs/server/
|
|
35
|
+
See [Mastra server](https://mastra.ai/docs/server/overview), [middleware](https://mastra.ai/docs/server/middleware), and [custom API routes](https://mastra.ai/docs/server/custom-api-routes) for examples.
|
|
36
36
|
|
|
37
37
|
## Precedence with code
|
|
38
38
|
|