@mastra/mcp-docs-server 1.2.15-alpha.13 → 1.2.15-alpha.19
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/agent-approval.md +14 -0
- package/.docs/docs/agents/code-mode.md +16 -1
- package/.docs/docs/agents/processors.md +3 -3
- package/.docs/docs/browser/recording.md +2 -2
- package/.docs/docs/capabilities/subagents.md +4 -1
- package/.docs/docs/datasets/running-experiments.md +49 -0
- package/.docs/docs/deployment/workers.md +1 -1
- package/.docs/docs/getting-started/develop.md +1 -1
- package/.docs/docs/harness/agent-controller.md +43 -2
- package/.docs/docs/harness/overview.md +2 -4
- package/.docs/docs/long-running-agents/durable-agents.md +1 -1
- package/.docs/docs/long-running-agents/goals.md +1 -1
- package/.docs/docs/long-running-agents/schedules.md +1 -1
- package/.docs/docs/long-running-agents/signal-providers.md +1 -1
- package/.docs/docs/long-running-agents/signals.md +1 -1
- package/.docs/docs/memory/message-history.md +2 -2
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +1 -1
- package/.docs/docs/observability/integrations/exporters/otel.md +2 -2
- package/.docs/docs/server/auth/auth0.md +1 -1
- package/.docs/docs/server/auth/clerk.md +2 -2
- package/.docs/docs/server/auth/firebase.md +1 -1
- package/.docs/docs/server/auth/okta.md +24 -4
- package/.docs/docs/server/auth/supabase.md +2 -2
- package/.docs/docs/server/auth/workers.md +2 -0
- package/.docs/docs/server/auth/workos.md +1 -1
- package/.docs/docs/server/custom-adapters.md +1 -1
- package/.docs/docs/server/mastra-client.md +2 -2
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/workflows/dynamic-workflows.md +1 -1
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +3 -3
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/channels.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
- package/.docs/guides/deployment/amazon-ec2.md +1 -1
- package/.docs/guides/deployment/aws-bedrock-agentcore.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/digital-ocean.md +2 -2
- package/.docs/guides/deployment/kubernetes.md +2 -2
- package/.docs/guides/deployment/mastra-workers.md +3 -1
- package/.docs/guides/deployment/netlify.md +2 -2
- package/.docs/guides/deployment/vercel.md +1 -1
- package/.docs/guides/getting-started/electron.md +2 -2
- package/.docs/guides/getting-started/manual-install.md +2 -2
- package/.docs/guides/guide/signal-provider.md +1 -1
- package/.docs/guides/migrations/mastra-cloud.md +1 -1
- package/.docs/models/embeddings.md +1 -1
- package/.docs/models/gateways/neon.md +1 -1
- package/.docs/models/gateways/netlify.md +1 -1
- package/.docs/models/gateways/openrouter.md +1 -1
- package/.docs/models/gateways/vercel.md +3 -4
- package/.docs/models/index.md +3 -3
- package/.docs/models/providers/302ai.md +1 -1
- package/.docs/models/providers/abacus.md +1 -1
- package/.docs/models/providers/abliteration-ai.md +1 -1
- package/.docs/models/providers/agentrouter.md +1 -1
- package/.docs/models/providers/ai-router.md +1 -1
- package/.docs/models/providers/aiand.md +1 -1
- package/.docs/models/providers/aki-io.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +1 -1
- package/.docs/models/providers/alibaba-coding-plan-cn.md +1 -1
- package/.docs/models/providers/alibaba-coding-plan.md +1 -1
- package/.docs/models/providers/alibaba-token-plan-cn.md +1 -1
- package/.docs/models/providers/alibaba-token-plan.md +1 -1
- package/.docs/models/providers/alibaba.md +7 -5
- package/.docs/models/providers/ambient.md +1 -1
- package/.docs/models/providers/anyapi.md +1 -1
- package/.docs/models/providers/atomic-chat.md +1 -1
- package/.docs/models/providers/auriko.md +1 -1
- package/.docs/models/providers/bailing.md +1 -1
- package/.docs/models/providers/baseten.md +1 -1
- package/.docs/models/providers/berget.md +1 -1
- package/.docs/models/providers/blueclaw.md +1 -1
- package/.docs/models/providers/chutes.md +1 -1
- package/.docs/models/providers/clarifai.md +1 -1
- package/.docs/models/providers/claudinio.md +1 -1
- package/.docs/models/providers/cline-pass.md +1 -1
- package/.docs/models/providers/cloudferro-sherlock.md +1 -1
- package/.docs/models/providers/cloudflare-workers-ai.md +1 -1
- package/.docs/models/providers/cortecs.md +2 -3
- package/.docs/models/providers/crof.md +1 -1
- package/.docs/models/providers/crossmodel.md +2 -3
- package/.docs/models/providers/daoxe.md +1 -1
- package/.docs/models/providers/databricks.md +1 -1
- package/.docs/models/providers/deepinfra.md +1 -1
- package/.docs/models/providers/digitalocean.md +3 -3
- package/.docs/models/providers/dinference.md +1 -1
- package/.docs/models/providers/drun.md +1 -1
- package/.docs/models/providers/ebcloud.md +1 -1
- package/.docs/models/providers/empiriolabs.md +1 -1
- package/.docs/models/providers/evroc.md +1 -1
- package/.docs/models/providers/fastrouter.md +1 -1
- package/.docs/models/providers/firepass.md +1 -1
- package/.docs/models/providers/fireworks-ai.md +1 -1
- package/.docs/models/providers/firmware.md +1 -1
- package/.docs/models/providers/freemodel.md +1 -1
- package/.docs/models/providers/friendli.md +1 -1
- package/.docs/models/providers/frogbot.md +1 -1
- package/.docs/models/providers/github-models.md +1 -1
- package/.docs/models/providers/gmicloud.md +1 -1
- package/.docs/models/providers/google.md +1 -1
- package/.docs/models/providers/greenpt.md +1 -1
- package/.docs/models/providers/helicone.md +1 -1
- package/.docs/models/providers/hetzner.md +1 -1
- package/.docs/models/providers/hpc-ai.md +1 -1
- package/.docs/models/providers/huggingface.md +1 -1
- package/.docs/models/providers/hyper.md +1 -1
- package/.docs/models/providers/iflowcn.md +1 -1
- package/.docs/models/providers/impossibl.md +1 -1
- package/.docs/models/providers/inception.md +1 -1
- package/.docs/models/providers/inceptron.md +1 -1
- package/.docs/models/providers/inference.md +1 -1
- package/.docs/models/providers/inferx.md +1 -1
- package/.docs/models/providers/infomaniak.md +1 -1
- package/.docs/models/providers/io-intelligence.md +1 -1
- package/.docs/models/providers/io-net.md +1 -1
- package/.docs/models/providers/jiekou.md +1 -1
- package/.docs/models/providers/kenari.md +1 -1
- package/.docs/models/providers/kilo.md +6 -6
- package/.docs/models/providers/kimi-for-coding.md +1 -1
- package/.docs/models/providers/kiro.md +1 -1
- package/.docs/models/providers/kuae-cloud-coding-plan.md +1 -1
- package/.docs/models/providers/lilac.md +1 -1
- package/.docs/models/providers/llama.md +1 -1
- package/.docs/models/providers/llmgateway.md +2 -4
- package/.docs/models/providers/llmtr.md +1 -1
- package/.docs/models/providers/lmstudio.md +1 -1
- package/.docs/models/providers/longcat.md +1 -1
- package/.docs/models/providers/lucidquery.md +1 -1
- package/.docs/models/providers/lynkr.md +1 -1
- package/.docs/models/providers/meganova.md +1 -1
- package/.docs/models/providers/meta.md +1 -1
- package/.docs/models/providers/minimax-cn-coding-plan.md +1 -1
- package/.docs/models/providers/minimax-cn.md +1 -1
- package/.docs/models/providers/minimax-coding-plan.md +1 -1
- package/.docs/models/providers/minimax.md +1 -1
- package/.docs/models/providers/mixlayer.md +1 -1
- package/.docs/models/providers/moark.md +1 -1
- package/.docs/models/providers/modal.md +1 -1
- package/.docs/models/providers/model-oracle-ai.md +1 -1
- package/.docs/models/providers/modelis.md +1 -1
- package/.docs/models/providers/modelscope.md +1 -1
- package/.docs/models/providers/moonshotai-cn.md +1 -1
- package/.docs/models/providers/moonshotai.md +1 -1
- package/.docs/models/providers/morph.md +1 -1
- package/.docs/models/providers/nano-gpt.md +4 -2
- package/.docs/models/providers/nearai.md +1 -1
- package/.docs/models/providers/nebius.md +3 -2
- package/.docs/models/providers/neuralwatt.md +1 -1
- package/.docs/models/providers/nova.md +1 -1
- package/.docs/models/providers/novita-ai.md +1 -1
- package/.docs/models/providers/nvidia.md +1 -1
- package/.docs/models/providers/ofox.md +4 -3
- package/.docs/models/providers/ollama-cloud.md +1 -1
- package/.docs/models/providers/opencode-go.md +1 -1
- package/.docs/models/providers/opencode.md +1 -1
- package/.docs/models/providers/orcarouter.md +1 -1
- package/.docs/models/providers/ovhcloud.md +1 -1
- package/.docs/models/providers/perplexity-agent.md +1 -1
- package/.docs/models/providers/pioneer.md +1 -1
- package/.docs/models/providers/poe.md +1 -1
- package/.docs/models/providers/poolside.md +1 -1
- package/.docs/models/providers/privatemode-ai.md +1 -1
- package/.docs/models/providers/qihang-ai.md +1 -1
- package/.docs/models/providers/qiniu-ai.md +1 -1
- package/.docs/models/providers/regolo-ai.md +1 -1
- package/.docs/models/providers/requesty.md +3 -3
- package/.docs/models/providers/routing-run.md +1 -1
- package/.docs/models/providers/sakana.md +1 -1
- package/.docs/models/providers/sarvam.md +1 -1
- package/.docs/models/providers/scaleway.md +1 -1
- package/.docs/models/providers/scx.md +1 -1
- package/.docs/models/providers/siliconflow-cn.md +1 -1
- package/.docs/models/providers/siliconflow.md +1 -1
- package/.docs/models/providers/snowflake-cortex.md +1 -1
- package/.docs/models/providers/stackit.md +1 -1
- package/.docs/models/providers/stepfun-ai-step-plan.md +1 -1
- package/.docs/models/providers/stepfun-ai.md +1 -1
- package/.docs/models/providers/stepfun-step-plan.md +1 -1
- package/.docs/models/providers/stepfun.md +1 -1
- package/.docs/models/providers/subconscious.md +1 -1
- package/.docs/models/providers/submodel.md +1 -1
- package/.docs/models/providers/synthetic.md +1 -1
- package/.docs/models/providers/tencent-coding-plan.md +1 -1
- package/.docs/models/providers/tencent-token-plan.md +1 -1
- package/.docs/models/providers/tencent-tokenhub.md +1 -1
- package/.docs/models/providers/tensorx.md +1 -1
- package/.docs/models/providers/the-grid-ai.md +1 -1
- package/.docs/models/providers/thinkingmachines.md +1 -1
- package/.docs/models/providers/tinfoil.md +2 -2
- package/.docs/models/providers/togetherai.md +1 -1
- package/.docs/models/providers/trustedrouter.md +1 -1
- package/.docs/models/providers/umans-ai-coding-plan.md +1 -1
- package/.docs/models/providers/umans-ai.md +1 -1
- package/.docs/models/providers/unorouter.md +1 -1
- package/.docs/models/providers/upstage.md +1 -1
- package/.docs/models/providers/venice.md +1 -1
- package/.docs/models/providers/vivgrid.md +1 -1
- package/.docs/models/providers/vultr.md +1 -1
- package/.docs/models/providers/wafer.ai.md +1 -1
- package/.docs/models/providers/wandb.md +1 -1
- package/.docs/models/providers/xiaomi-token-plan-ams.md +1 -1
- package/.docs/models/providers/xiaomi-token-plan-cn.md +1 -1
- package/.docs/models/providers/xiaomi-token-plan-sgp.md +1 -1
- package/.docs/models/providers/xiaomi.md +1 -1
- package/.docs/models/providers/xpersona.md +1 -1
- package/.docs/models/providers/zai-coding-plan.md +1 -1
- package/.docs/models/providers/zai.md +1 -1
- package/.docs/models/providers/zeldoc.md +8 -8
- package/.docs/models/providers/zenifra.md +1 -1
- package/.docs/models/providers/zenmux.md +1 -1
- package/.docs/models/providers/zhipuai-coding-plan.md +1 -1
- package/.docs/models/providers/zhipuai.md +1 -1
- package/.docs/reference/agent-controller/agent-controller-class.md +3 -3
- package/.docs/reference/agent-controller/session.md +5 -3
- package/.docs/reference/agents/durable-agent.md +2 -0
- package/.docs/reference/agents/generateLegacy.md +1 -1
- package/.docs/reference/agents/inngest-agent.md +2 -0
- package/.docs/reference/auth/okta.md +5 -1
- package/.docs/reference/cli/mastra.md +4 -4
- package/.docs/reference/client-js/agents.md +2 -1
- package/.docs/reference/client-js/workflows.md +3 -3
- package/.docs/reference/code-sdk/mount-agent-controller.md +1 -1
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/core/addDynamicWorkflow.md +1 -1
- package/.docs/reference/core/addDynamicWorkflows.md +1 -1
- package/.docs/reference/datasets/startExperiment.md +8 -0
- package/.docs/reference/file-based-agents/config.md +2 -0
- package/.docs/reference/file-based-agents/instructions.md +2 -0
- package/.docs/reference/file-based-agents/logger.md +2 -0
- package/.docs/reference/file-based-agents/memory.md +2 -0
- package/.docs/reference/file-based-agents/observability.md +2 -0
- package/.docs/reference/file-based-agents/processors.md +2 -0
- package/.docs/reference/file-based-agents/schedules.md +2 -0
- package/.docs/reference/file-based-agents/scorers.md +2 -0
- package/.docs/reference/file-based-agents/server.md +2 -0
- package/.docs/reference/file-based-agents/skills.md +2 -0
- package/.docs/reference/file-based-agents/storage.md +2 -0
- package/.docs/reference/file-based-agents/studio.md +2 -0
- package/.docs/reference/file-based-agents/subagents.md +2 -0
- package/.docs/reference/file-based-agents/tools.md +2 -0
- package/.docs/reference/file-based-agents/workflows.md +2 -0
- package/.docs/reference/file-based-agents/workspace.md +2 -0
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/observability/tracing/exporters/datadog.md +1 -1
- package/.docs/reference/processors/pii-detector.md +2 -0
- package/.docs/reference/processors/prompt-injection-detector.md +2 -0
- package/.docs/reference/processors/response-cache.md +2 -0
- package/.docs/reference/schedules/overview.md +2 -0
- package/.docs/reference/signals/create-notification-inbox-tool.md +2 -0
- package/.docs/reference/signals/signal-provider.md +2 -0
- package/.docs/reference/signals/task-signal-provider.md +2 -0
- package/.docs/reference/signals/webhook-signal-provider.md +2 -0
- package/.docs/reference/storage/composite.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/streaming/agents/streamLegacy.md +1 -1
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/tools/create-code-mode.md +3 -1
- package/.docs/reference/tools/isolated-vm-transport.md +1 -1
- package/.docs/reference/tools/mcp-client.md +51 -0
- package/.docs/reference/tools/quickjs-transport.md +92 -0
- package/.docs/reference/vectors/chroma.md +1 -1
- package/.docs/reference/workers/overview.md +2 -0
- package/.docs/reference/workflows/dynamic-workflow-definition.md +1 -1
- package/.docs/reference/workspace/mesa-filesystem.md +1 -1
- package/.docs/reference/workspace/platform-filesystem.md +1 -1
- package/.docs/reference/workspace/platform-sandbox.md +1 -1
- package/CHANGELOG.md +29 -0
- package/package.json +6 -6
|
@@ -90,6 +90,20 @@ for await (const chunk of stream.fullStream) {
|
|
|
90
90
|
}
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
#### Explaining a decline
|
|
94
|
+
|
|
95
|
+
`declineToolCall()`, `declineToolCallGenerate()`, and `declineNetworkToolCall()` accept an optional `reason`. The reason is returned to the model in place of the tool result, so the model can adjust instead of retrying blindly. It's also stored on the tool call's `approval` metadata, so it's still there when the conversation is recalled.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const declined = await agent.declineToolCall({
|
|
99
|
+
runId: stream.runId,
|
|
100
|
+
toolCallId,
|
|
101
|
+
reason: 'Reading other users PII is not allowed, ask the user for their own email instead',
|
|
102
|
+
})
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Without a `reason`, the model receives the default message `Tool call was not approved by the user`.
|
|
106
|
+
|
|
93
107
|
#### Conditional approval with a function
|
|
94
108
|
|
|
95
109
|
Instead of a boolean, `requireToolApproval` accepts a function that decides per tool call. It receives the `toolName`, the `args` the model passed, the `requestContext`, and the `workspace`. Return `true` to require approval for that call, or `false` to allow it. This lets you gate approval at runtime, for example, only for tools whose name matches a pattern:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.38.0`
|
|
6
6
|
|
|
7
|
-
> **Beta:**
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
8
|
|
|
9
9
|
Code mode lets an agent run multi-tool computations in an isolated sandbox and return the result as a single, more accurate response.
|
|
10
10
|
|
|
@@ -164,9 +164,24 @@ const { tool, instructions } = createCodeMode(
|
|
|
164
164
|
|
|
165
165
|
`isolated-vm` is a native addon, and on Node.js 20 and later the host process must be started with the `--no-node-snapshot` flag. See the [IsolatedVmCodeModeTransport reference](https://mastra.ai/reference/tools/isolated-vm-transport) for setup details.
|
|
166
166
|
|
|
167
|
+
When the host can't install native addons or set Node.js flags, which is common on serverless platforms, use [`QuickJsCodeModeTransport`](https://mastra.ai/reference/tools/quickjs-transport) from `@mastra/quickjs` instead. It gives the same in-process boundary using a QuickJS runtime compiled to WebAssembly, at the cost of slower execution:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { createCodeMode } from '@mastra/core/tools'
|
|
171
|
+
import { QuickJsCodeModeTransport } from '@mastra/quickjs'
|
|
172
|
+
|
|
173
|
+
const { tool, instructions } = createCodeMode(
|
|
174
|
+
{ tools }, // no sandbox needed
|
|
175
|
+
new QuickJsCodeModeTransport({ memoryLimitMb: 128 }),
|
|
176
|
+
)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
See [Choosing a transport](https://mastra.ai/reference/tools/quickjs-transport) for a side-by-side comparison.
|
|
180
|
+
|
|
167
181
|
## Related
|
|
168
182
|
|
|
169
183
|
- [createCodeMode() reference](https://mastra.ai/reference/tools/create-code-mode)
|
|
170
184
|
- [IsolatedVmCodeModeTransport reference](https://mastra.ai/reference/tools/isolated-vm-transport)
|
|
185
|
+
- [QuickJsCodeModeTransport reference](https://mastra.ai/reference/tools/quickjs-transport)
|
|
171
186
|
- [Tools](https://mastra.ai/docs/agents/using-tools)
|
|
172
187
|
- [Workspace overview](https://mastra.ai/docs/workspace/overview)
|
|
@@ -432,7 +432,7 @@ See the [`ProviderHistoryCompat` reference](https://mastra.ai/reference/processo
|
|
|
432
432
|
|
|
433
433
|
## Response caching
|
|
434
434
|
|
|
435
|
-
> **Beta:**
|
|
435
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
436
436
|
|
|
437
437
|
Response caching skips the LLM call and replays a previously cached response when an agent receives an identical request. Use it to reduce latency and avoid paying for repeated calls.
|
|
438
438
|
|
|
@@ -544,7 +544,7 @@ This means the cache key is derived from the resolved `LanguageModelV2Prompt` Ma
|
|
|
544
544
|
|
|
545
545
|
When you don't supply `key`, the processor derives one deterministically from the inputs that change the LLM's response at this step: `agentId`, `stepNumber` (so each step in a tool loop has its own cache entry), `scope`, model identity (`provider`, `modelId`, spec version), and the resolved `prompt` (post-memory + post-processors). Any change to these inputs automatically invalidates the cache.
|
|
546
546
|
|
|
547
|
-
Multimodal prompts are included too. Image and file parts reach the key by value: a URL
|
|
547
|
+
Multimodal prompts are included too. Image and file parts reach the key by value: the key includes a URL's full href, and a digest of the bytes for inline binary data (`Uint8Array`, `ArrayBuffer`). Requests that differ only in which image they reference therefore get different cache entries.
|
|
548
548
|
|
|
549
549
|
#### Customize the cache key
|
|
550
550
|
|
|
@@ -664,7 +664,7 @@ export class SteeringReminderProcessor implements Processor {
|
|
|
664
664
|
}
|
|
665
665
|
```
|
|
666
666
|
|
|
667
|
-
A transient signal still
|
|
667
|
+
A transient signal is still in the prompt for the current call, so the model sees it near the latest turn. It's not retained, so re-sending it each turn keeps a single fresh copy in context instead of an accumulating history, and stored thread history never includes it. Because nothing is written, it also keeps a stable prompt cache prefix across turns.
|
|
668
668
|
|
|
669
669
|
### Emit custom stream events
|
|
670
670
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
2
|
|
|
3
|
-
# Browser recording
|
|
3
|
+
# Browser recording
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.43.0`
|
|
6
6
|
|
|
7
7
|
Browser recording adds two opt-in tools that let an agent save a browser session as a Motion-JPEG AVI video. The agent can also add short captions while it works.
|
|
8
8
|
|
|
9
|
-
> **Beta:**
|
|
9
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
10
10
|
|
|
11
11
|
## When to use browser recording
|
|
12
12
|
|
|
@@ -113,7 +113,7 @@ The `context` object includes:
|
|
|
113
113
|
|
|
114
114
|
### Request context at the delegation boundary
|
|
115
115
|
|
|
116
|
-
Each delegation receives a request context whose entries are shallowly copied from the parent run, excluding run-scoped identity keys. Setting or deleting entries during the subagent run
|
|
116
|
+
Each delegation receives a request context whose entries are shallowly copied from the parent run, excluding run-scoped identity keys. Setting or deleting entries during the subagent run doesn't affect the parent's context. Set entries on `context.requestContext` in `onDelegationStart` to pass values to the delegated run:
|
|
117
117
|
|
|
118
118
|
```typescript
|
|
119
119
|
const stream = await parentAgent.stream('Research AI trends', {
|
|
@@ -134,6 +134,9 @@ Called after a delegation finishes. Use it to inspect results or provide feedbac
|
|
|
134
134
|
|
|
135
135
|
- `context.bail()`: Stop the parent agent's loop immediately
|
|
136
136
|
- Return `{ feedback: '...' }`: Add feedback that gets saved to the parent agent's memory and is visible to subsequent iterations
|
|
137
|
+
- Return `{ resultText: '...' }`: Replace the tool result text the parent model sees for this delegation, within the current run
|
|
138
|
+
|
|
139
|
+
Use `resultText` when the subagent's own result would mislead the parent immediately. For example, a subagent that stops on a tool-calls step returns empty text, which the parent model reads as a successful but empty delegation. Unlike `feedback`, which only reaches the model on the next turn, `resultText` changes what the parent reasons on right away.
|
|
137
140
|
|
|
138
141
|
```typescript
|
|
139
142
|
const stream = await parentAgent.stream('Research AI trends', {
|
|
@@ -206,6 +206,55 @@ The `experiment.run.finished` event is awaited before Mastra persists the final
|
|
|
206
206
|
|
|
207
207
|
The exported event types are `ExperimentEvent`, `ExperimentRunStartedEvent`, `ExperimentItemCompletedEvent`, and `ExperimentRunFinishedEvent`. Use the discriminated `type` field to narrow an event before reading event-specific properties.
|
|
208
208
|
|
|
209
|
+
## Lifecycle hooks
|
|
210
|
+
|
|
211
|
+
Use lifecycle hooks to prepare state before a target runs and clean it up afterwards. This is useful when an item can't be evaluated against an empty environment. A run might need a fixture file copied into the agent's workspace, or a sandbox provisioned before the agent can touch it.
|
|
212
|
+
|
|
213
|
+
Hooks run at two levels. `beforeAll` and `afterAll` run once per experiment, and `beforeEach` and `afterEach` run once per item:
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
const summary = await dataset.startExperiment({
|
|
217
|
+
targetType: 'agent',
|
|
218
|
+
targetId: 'document-agent',
|
|
219
|
+
scorers: ['accuracy'],
|
|
220
|
+
beforeAll: async ({ experimentId }) => {
|
|
221
|
+
await createWorkspace(experimentId)
|
|
222
|
+
},
|
|
223
|
+
beforeEach: async ({ item }) => {
|
|
224
|
+
await copyFixture(item.metadata?.fixture)
|
|
225
|
+
},
|
|
226
|
+
afterEach: async ({ item, result }) => {
|
|
227
|
+
await clearWorkspaceFiles(item.id)
|
|
228
|
+
},
|
|
229
|
+
afterAll: async ({ summary }) => {
|
|
230
|
+
await deleteWorkspace(summary.experimentId)
|
|
231
|
+
},
|
|
232
|
+
})
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Every hook can be async. Each one receives the `experimentId`, the `mastra` instance, and the run-level `signal`, so long-running setup can be cancelled along with the experiment. The per-item hooks also receive `item`. The teardown hooks receive the result they follow: `afterEach` receives the item's `result` including scores, and `afterAll` receives the `summary` that's about to be returned.
|
|
236
|
+
|
|
237
|
+
The item passed to hooks exposes `id`, `input`, `groundTruth`, and `metadata`. Fields that control execution, such as tool mocks and scorer selection, aren't exposed, so a hook can't change how the item runs.
|
|
238
|
+
|
|
239
|
+
### Hook failures
|
|
240
|
+
|
|
241
|
+
Each hook has a different consequence when it throws, based on how much of the run depends on it:
|
|
242
|
+
|
|
243
|
+
| Hook | On failure |
|
|
244
|
+
| ------------ | -------------------------------------------------------------------------------- |
|
|
245
|
+
| `beforeAll` | Fails the experiment. No items run. |
|
|
246
|
+
| `beforeEach` | Fails that item with `EXPERIMENT_ITEM_BEFORE_EACH_FAILED`. Other items continue. |
|
|
247
|
+
| `afterEach` | Logged. The item's recorded outcome doesn't change. |
|
|
248
|
+
| `afterAll` | Logged. The returned summary doesn't change. |
|
|
249
|
+
|
|
250
|
+
When `beforeAll` fails, the experiment is marked failed and the `experiment.run.finished` event is still emitted before the error propagates.
|
|
251
|
+
|
|
252
|
+
When `beforeEach` fails, the target and its scorers are skipped for that item, since the item's preconditions were never met. `afterEach` is also skipped for that item, on the basis that setup which didn't finish owns its own cleanup.
|
|
253
|
+
|
|
254
|
+
Teardown failures are logged rather than propagated. By the time `afterEach` runs, the target has already produced a real result, and discarding it because cleanup was untidy would lose the data the experiment was run to collect.
|
|
255
|
+
|
|
256
|
+
`afterAll` runs on every exit path, including when the experiment fails, when `beforeAll` fails, and when an [event observer](#observe-experiment-events) fails, so teardown isn't skipped when something goes wrong. It runs at most once per experiment.
|
|
257
|
+
|
|
209
258
|
## Tool mocks
|
|
210
259
|
|
|
211
260
|
When an experiment runs an agent that calls side-effecting tools, attach static tool mocks to individual dataset items to make the run deterministic. During the experiment, a mocked tool returns its declared output instead of executing. Tools without a mock on the item run live by default.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Workers
|
|
4
4
|
|
|
5
|
-
> **Beta:**
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable. See [known limitations](#known-limitations) for current gaps.
|
|
6
6
|
|
|
7
7
|
Workers handle background processing outside the request-response cycle. Workflow step execution, cron-based scheduling, and long-running tool calls all run in workers, keeping the API responsive.
|
|
8
8
|
|
|
@@ -138,7 +138,7 @@ See the [project structure reference](https://mastra.ai/reference/project-struct
|
|
|
138
138
|
|
|
139
139
|
## File-based agents
|
|
140
140
|
|
|
141
|
-
> **Beta:**
|
|
141
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
142
142
|
>
|
|
143
143
|
> File-based discovery only runs through `mastra dev` or `mastra build`. If your app imports `mastra` directly, including through a web framework or server adapter, file-based agents aren't discovered. Register those agents in code or run Mastra as a separate server.
|
|
144
144
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# AgentController
|
|
4
4
|
|
|
5
|
-
> **Beta:**
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
6
|
|
|
7
7
|
`AgentController` is a shared runtime host for interactive agent applications. It coordinates modes, models, storage, workspaces, tool approvals, subagents, and channels. Each user or active task works through an isolated [`Session`](https://mastra.ai/reference/agent-controller/session).
|
|
8
8
|
|
|
@@ -343,7 +343,48 @@ Point each platform webhook at the controller-specific route:
|
|
|
343
343
|
|
|
344
344
|
Each external chat thread maps to one controller Session and Mastra thread. By default, new sessions use a resource ID derived from the adapter's chat-thread ID, prefixed with `channel:`. Use `resolveResourceId` to map direct messages to an existing application user or choose another memory owner. The callback only affects new threads; an existing thread keeps its stored resource ID.
|
|
345
345
|
|
|
346
|
-
Channel sessions are created by the controller rather than by your code, so `onSessionStart` is where you configure them. It runs once per session, after the session is bound to its mapped thread and before the first message is handled.
|
|
346
|
+
Channel sessions are created by the controller rather than by your code, so `onSessionStart` is where you configure them. It runs once per session, after the session is bound to its mapped thread and before the first message is handled. A channel session starts with controller defaults, so this is where you set its model and memory settings. Later messages in the same thread reuse the session and don't call it again. Errors are logged and swallowed so a session that can't be configured still answers the message.
|
|
347
|
+
|
|
348
|
+
### Authorize and route channel sessions
|
|
349
|
+
|
|
350
|
+
`onSessionStart` runs after the session exists and swallows errors, so it can't refuse a request. Use `resolveSession` when your host decides whether a session may exist. It replaces the built-in session creation and runs before any session exists. Throwing refuses the request before the controller creates a session or calls the model. Mastra logs the refusal and leaves the chat thread silent, so your authorization message never reaches the channel.
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
channels: {
|
|
354
|
+
adapters: { slack: createSlackAdapter() },
|
|
355
|
+
resolveSession: async ({ controller, thread, requestContext }) => {
|
|
356
|
+
const install = await installs.authorize(requestContext.get('teamId'))
|
|
357
|
+
|
|
358
|
+
return controller.createSession({
|
|
359
|
+
resourceId: thread.resourceId,
|
|
360
|
+
scope: install.id,
|
|
361
|
+
ownerId: controller.id,
|
|
362
|
+
requestContext,
|
|
363
|
+
})
|
|
364
|
+
},
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Create the session under `thread.resourceId`. A session can only bind threads it owns, so use `resolveResourceId` if you want a different owner for the mapped thread. Sessions are get-or-create per `resourceId` and `scope`, so pass `scope` when one thread needs separate sessions per install or principal.
|
|
369
|
+
|
|
370
|
+
Failures that aren't refusals (a storage outage, a bug in your resolver's dependencies) still post an error to the thread, so a broken bot doesn't look like a silent one. If you need to tell them apart in your own code, a refusal is a `ChannelSessionRejectedError` with the original error as its `cause`.
|
|
371
|
+
|
|
372
|
+
`resolveSession` also runs when a user answers an approval card, with that action's request context, so a shared install revalidates the person approving rather than trusting the person who sent the original message.
|
|
373
|
+
|
|
374
|
+
### Handle stale approvals
|
|
375
|
+
|
|
376
|
+
An approval gate lives in memory, so every approval answered after a restart is stale. Mastra never runs the tool for a stale action. Use `onStaleToolApproval` to settle the attempt the user answered, instead of dropping it:
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
channels: {
|
|
380
|
+
adapters: { slack: createSlackAdapter() },
|
|
381
|
+
onStaleToolApproval: async ({ decision, toolCallId, runId, memory }) => {
|
|
382
|
+
await runs.markInterrupted({ runId, toolCallId, decision, threadId: memory.thread })
|
|
383
|
+
},
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
`runId` is the run the approval card was rendered for, which is the attempt the user answered and the one you settle against after a restart. The session's own run is passed separately as `currentRunId`, and is usually `null` or a different run by then.
|
|
347
388
|
|
|
348
389
|
Controller channel sessions and auto-approval state are held in memory, so use a long-lived server. Pending approvals and live Session state don't survive process restarts. Adapters that can't render approval controls automatically run tools without an approval prompt so the run doesn't remain suspended.
|
|
349
390
|
|
|
@@ -4,12 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
A harness lets an agent pursue long-running, complex goals while keeping its work durable, visible, and steerable. It preserves progress across retries and interruptions, while giving people and other systems a way to inspect progress, add context, approve actions, redirect the agent, or stop it.
|
|
6
6
|
|
|
7
|
-
In Mastra, harness refers to a set of capabilities for managing an agent beyond a single uninterrupted run. You can adopt these capabilities individually or combine them as needed.
|
|
8
|
-
|
|
9
|
-
[`AgentController`](https://mastra.ai/docs/harness/agent-controller) is a harness designed for interactive agent applications. It extends the base [`Agent`](https://mastra.ai/docs/agents/overview) loop with isolated sessions for each user or task, persistent threads and state, switchable modes and models, tool permissions and approvals, subagent orchestration, and streams for events and display state.
|
|
10
|
-
|
|
11
7
|
Agent harnesses are useful wherever work continues over time. Common examples include coding agents that carry changes through CI and review, software factories that coordinate many tasks in parallel, SRE agents that adapt as incidents evolve, and go-to-market agents that respond as accounts, signals, and conversations change.
|
|
12
8
|
|
|
9
|
+
In Mastra, harness refers to a set of capabilities for managing an agent beyond a single uninterrupted run. You can adopt these capabilities individually or combine them as needed.
|
|
10
|
+
|
|
13
11
|
## When to use a harness
|
|
14
12
|
|
|
15
13
|
Choose a starting point based on what the agent needs. You may use one capability or several.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.45.0`
|
|
6
6
|
|
|
7
|
-
> **
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
8
|
|
|
9
9
|
A durable agent wraps a regular [`Agent`](https://mastra.ai/docs/agents/overview) so the agentic loop runs inside a workflow. Events flow through [PubSub](https://mastra.ai/docs/server/pubsub), which means a client can disconnect and reconnect without missing chunks. The run state is persisted, so it survives process restarts.
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.42.0`
|
|
6
6
|
|
|
7
|
-
> **Beta:**
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
8
|
|
|
9
9
|
A goal is a durable, thread-scoped objective: a standing instruction the agent keeps working toward across loop iterations until a judge model decides it's satisfied or a run budget is exhausted.
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.50.0`
|
|
6
6
|
|
|
7
|
-
> **Beta:**
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
8
|
|
|
9
9
|
A schedule runs an agent on a cron cadence. On each fire, Mastra sends a prompt to the agent, either as a [signal](https://mastra.ai/docs/long-running-agents/signals) into a thread or as a threadless [`agent.generate()`](https://mastra.ai/reference/agents/generate) run. Use schedules for recurring agent work such as daily summaries, periodic checks, or scheduled nudges into a conversation.
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.39.0`
|
|
6
6
|
|
|
7
|
-
> **Beta:**
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
8
|
|
|
9
9
|
A signal provider monitors an external source, such as GitHub, Slack, continuous integration (CI), or your own API, and pushes [notification signals](https://mastra.ai/docs/long-running-agents/signals) into subscribed agent threads.
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.39.0`
|
|
6
6
|
|
|
7
|
-
> **Beta:**
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
8
|
|
|
9
9
|
Signals are a way to interact with an agent through a thread. Instead of starting every interaction with `agent.stream()`, subscribe to a thread and send messages or signals. Mastra either wakes the agent when the thread is idle or drops input into the running agent loop, or alternatively queues input for the next turn.
|
|
10
10
|
|
|
@@ -6,7 +6,7 @@ Message history is the most basic and important form of memory. It gives the LLM
|
|
|
6
6
|
|
|
7
7
|
You can also retrieve message history to display past conversations in your UI.
|
|
8
8
|
|
|
9
|
-
> **
|
|
9
|
+
> **Note:** Each message belongs to a thread (the conversation) and a resource (the user or entity it's associated with). See [Threads and resources](#threads-and-resources) for more detail.
|
|
10
10
|
|
|
11
11
|
> **Warning:** When you use memory with a client application, send **only the new message** from the client instead of the full conversation history.
|
|
12
12
|
>
|
|
@@ -113,7 +113,7 @@ await agent.stream('Hello', {
|
|
|
113
113
|
})
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
> **
|
|
116
|
+
> **Note:** Threads and messages are created automatically when you call `agent.generate()` or `agent.stream()`, but you can also create them manually with [`createThread()`](https://mastra.ai/reference/memory/createThread) and [`saveMessages()`](https://mastra.ai/reference/memory/memory-class).
|
|
117
117
|
|
|
118
118
|
You can use this history in two ways:
|
|
119
119
|
|
|
@@ -186,7 +186,7 @@ When you deploy with Mastra Studio, set **Deployment → Service Name** to a sta
|
|
|
186
186
|
|
|
187
187
|
## Performance
|
|
188
188
|
|
|
189
|
-
> **
|
|
189
|
+
> **Note:** MastraPlatformExporter uses batching to optimize network usage. Events are buffered and sent in batches, reducing overhead while maintaining near real-time visibility.
|
|
190
190
|
|
|
191
191
|
### Batching behavior
|
|
192
192
|
|
|
@@ -230,7 +230,7 @@ export const mastra = new Mastra({
|
|
|
230
230
|
})
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
> **
|
|
233
|
+
> **Note:** Get your Dash0 endpoint from your dashboard. It should be in the format `ingress.{region}.aws.dash0.com:4317`.
|
|
234
234
|
|
|
235
235
|
### `SigNoz`
|
|
236
236
|
|
|
@@ -400,7 +400,7 @@ export const mastra = new Mastra({
|
|
|
400
400
|
})
|
|
401
401
|
```
|
|
402
402
|
|
|
403
|
-
> **
|
|
403
|
+
> **Note:** The Datadog Agent must be configured with OTLP ingestion enabled. Add the following to your `datadog.yaml`:
|
|
404
404
|
>
|
|
405
405
|
> ```yaml
|
|
406
406
|
> otlp_config:
|
|
@@ -200,7 +200,7 @@ export const createMastraClient = (accessToken: string) => {
|
|
|
200
200
|
}
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
-
> **
|
|
203
|
+
> **Note:** The access token must be prefixed with `Bearer` in the Authorization header.
|
|
204
204
|
>
|
|
205
205
|
> Visit [Mastra Client SDK](https://mastra.ai/docs/server/mastra-client) for more configuration options.
|
|
206
206
|
|
|
@@ -61,7 +61,7 @@ export const mastra = new Mastra({
|
|
|
61
61
|
})
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
> **
|
|
64
|
+
> **Note:** The default `authorizeUser` method allows all authenticated users. To customize user authorization, provide a custom `authorizeUser` function when constructing the provider.
|
|
65
65
|
>
|
|
66
66
|
> Visit [MastraAuthClerk](https://mastra.ai/reference/auth/clerk) for all available configuration options.
|
|
67
67
|
|
|
@@ -105,7 +105,7 @@ export const mastraClient = new MastraClient({
|
|
|
105
105
|
})
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
> **
|
|
108
|
+
> **Note:** The access token must be prefixed with `Bearer` in the Authorization header.
|
|
109
109
|
>
|
|
110
110
|
> Visit [Mastra Client SDK](https://mastra.ai/docs/server/mastra-client) for more configuration options.
|
|
111
111
|
|
|
@@ -200,7 +200,7 @@ export const createMastraClient = (idToken: string) => {
|
|
|
200
200
|
}
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
-
> **
|
|
203
|
+
> **Note:** The ID token must be prefixed with `Bearer` in the Authorization header.
|
|
204
204
|
>
|
|
205
205
|
> Visit [Mastra Client SDK](https://mastra.ai/docs/server/mastra-client) for more configuration options.
|
|
206
206
|
|
|
@@ -179,16 +179,35 @@ export const mastraClient = new MastraClient({
|
|
|
179
179
|
|
|
180
180
|
### Bearer token
|
|
181
181
|
|
|
182
|
-
You can also pass an Okta
|
|
182
|
+
You can also pass an Okta token as a Bearer token. The token is verified against Okta's JWKS endpoint, and its `aud` claim must match the configured audience. The audience defaults to your client ID, and you can override it with the `audience` option or `OKTA_AUDIENCE`.
|
|
183
|
+
|
|
184
|
+
Okta puts the client ID in the `aud` claim of **ID tokens**, so ID tokens work with the default. **Access tokens** carry the audience of the authorization server that issued them, so set the audience to match:
|
|
185
|
+
|
|
186
|
+
- **Org authorization server** (the default, issuer `https://{domain}`): set the audience to `https://{domain}`.
|
|
187
|
+
- **Custom authorization server** (issuer `https://{domain}/oauth2/{name}`): set the audience to the server's audience value from the Okta Admin Console, for example `api://default`.
|
|
188
|
+
|
|
189
|
+
```env
|
|
190
|
+
OKTA_AUDIENCE=https://dev-123456.okta.com
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Pass an array to accept more than one audience, for example ID tokens from browsers and access tokens from service callers against the same provider:
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
new MastraAuthOkta({
|
|
197
|
+
audience: ['your-client-id', 'https://dev-123456.okta.com'],
|
|
198
|
+
})
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
> **Note:** `audience` applies only to Bearer tokens. The ID token exchanged during the SSO login flow is always verified against your client ID.
|
|
183
202
|
|
|
184
203
|
```typescript
|
|
185
204
|
import { MastraClient } from '@mastra/client-js'
|
|
186
205
|
|
|
187
|
-
export const createMastraClient = (
|
|
206
|
+
export const createMastraClient = (token: string) => {
|
|
188
207
|
return new MastraClient({
|
|
189
208
|
baseUrl: 'http://localhost:4111',
|
|
190
209
|
headers: {
|
|
191
|
-
Authorization: `Bearer ${
|
|
210
|
+
Authorization: `Bearer ${token}`,
|
|
192
211
|
},
|
|
193
212
|
})
|
|
194
213
|
}
|
|
@@ -213,7 +232,7 @@ console.log(response)
|
|
|
213
232
|
```bash
|
|
214
233
|
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
215
234
|
-H "Content-Type: application/json" \
|
|
216
|
-
-H "Authorization: Bearer <your-okta-
|
|
235
|
+
-H "Authorization: Bearer <your-okta-token>" \
|
|
217
236
|
-d '{
|
|
218
237
|
"messages": "Weather in London"
|
|
219
238
|
}'
|
|
@@ -222,6 +241,7 @@ curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
|
222
241
|
## Troubleshooting
|
|
223
242
|
|
|
224
243
|
- **401 on every request**: Verify your Okta domain, client ID, and client secret are correct. Check that the redirect URI in your Okta application matches `OKTA_REDIRECT_URI`.
|
|
244
|
+
- **401 with `unexpected "aud" claim value` in the server logs**: The Bearer token's audience doesn't match the configured audience. This usually means you sent an access token while the audience is still the default client ID. Set `OKTA_AUDIENCE` to the audience of the authorization server that issued the token. See [Bearer token](#bearer-token).
|
|
225
245
|
- **Cookies not sent cross-origin**: Set `credentials: "include"` in `MastraClient` and configure `server.cors` with your frontend origin and `credentials: true`.
|
|
226
246
|
- **Session lost on restart**: Set `OKTA_COOKIE_PASSWORD` to a stable value (at least 32 characters). Without it, an auto-generated key is used that changes on each restart.
|
|
227
247
|
- **RBAC returns empty permissions**: Verify `OKTA_API_TOKEN` is set and the token has permission to list user groups. Check that group names in `roleMapping` match your Okta group names exactly.
|
|
@@ -59,7 +59,7 @@ export const mastra = new Mastra({
|
|
|
59
59
|
})
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
> **
|
|
62
|
+
> **Note:** The default `authorizeUser` method checks the `isAdmin` column in the `users` table in the `public` schema. To customize user authorization, provide a custom `authorizeUser` function when constructing the provider.
|
|
63
63
|
>
|
|
64
64
|
> Visit [MastraAuthSupabase](https://mastra.ai/reference/auth/supabase) for all available configuration options.
|
|
65
65
|
|
|
@@ -101,7 +101,7 @@ export const mastraClient = new MastraClient({
|
|
|
101
101
|
})
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
> **
|
|
104
|
+
> **Note:** The access token must be prefixed with `Bearer` in the Authorization header.
|
|
105
105
|
>
|
|
106
106
|
> Visit [Mastra Client SDK](https://mastra.ai/docs/server/mastra-client) for more configuration options.
|
|
107
107
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Workers
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
When workers run in separate processes from the API, they communicate over HTTP. The orchestration worker calls the API's step execution endpoint to run workflow steps on the API server. Push-mode PubSub brokers (like Google Cloud Pub/Sub in push mode) can also deliver events directly to the API's event endpoint. This is a distinct integration path from pull-mode workers, which pull events from the broker themselves. Both HTTP endpoints require authentication when an auth provider is configured.
|
|
6
8
|
|
|
7
9
|
## How it works
|
|
@@ -221,7 +221,7 @@ export const createMastraClient = (accessToken: string) => {
|
|
|
221
221
|
}
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
-
> **
|
|
224
|
+
> **Note:** The access token must be prefixed with `Bearer` in the Authorization header.
|
|
225
225
|
>
|
|
226
226
|
> Visit [Mastra Client SDK](https://mastra.ai/docs/server/mastra-client) for more configuration options.
|
|
227
227
|
|
|
@@ -6,7 +6,7 @@ Create a custom adapter when the prebuilt server adapters (Hono, Express, Fastif
|
|
|
6
6
|
|
|
7
7
|
A custom adapter translates between Mastra's route definitions and your framework's routing system. You'll implement methods that register middleware, handle requests, and send responses using your framework's APIs.
|
|
8
8
|
|
|
9
|
-
> **
|
|
9
|
+
> **Note:** Use any of these prebuilt server adapters:
|
|
10
10
|
>
|
|
11
11
|
> - [@mastra/hono](https://mastra.ai/reference/server/hono-adapter)
|
|
12
12
|
> - [@mastra/express](https://mastra.ai/reference/server/express-adapter)
|
|
@@ -149,7 +149,7 @@ const testAgent = async () => {
|
|
|
149
149
|
}
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
> **
|
|
152
|
+
> **Note:** You can also call `.generate()` with an array of message objects that include `role` and `content`. Visit the [.generate() reference](https://mastra.ai/reference/client-js/agents) for more information.
|
|
153
153
|
|
|
154
154
|
## Streaming responses
|
|
155
155
|
|
|
@@ -175,7 +175,7 @@ const testAgent = async () => {
|
|
|
175
175
|
}
|
|
176
176
|
```
|
|
177
177
|
|
|
178
|
-
> **
|
|
178
|
+
> **Note:** You can also call `.stream()` with an array of message objects that include `role` and `content`. Visit the [.stream() reference](https://mastra.ai/reference/client-js/agents) for more information.
|
|
179
179
|
|
|
180
180
|
## Configuration options
|
|
181
181
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Mastra runs as an HTTP server that exposes your agents, workflows, and other functionality as API endpoints. The server handles request routing, middleware execution, authentication, and streaming responses.
|
|
6
6
|
|
|
7
|
-
> **
|
|
7
|
+
> **Note:** This page covers the [`server`](https://mastra.ai/reference/configuration) configuration options passed to the `Mastra` constructor. For running Mastra with your own HTTP server (Hono, Express, etc.), visit [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
8
8
|
|
|
9
9
|
## Server features
|
|
10
10
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Dynamic workflows
|
|
4
4
|
|
|
5
|
-
> **Beta:**
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
6
|
|
|
7
7
|
Dynamic workflows are workflow definitions expressed as data instead of code. A definition is a JSON document that describes the workflow's schemas and step graph. Mastra validates the definition and registers it as a runnable workflow, then persists it in storage so it survives process restarts.
|
|
8
8
|
|
|
@@ -287,7 +287,7 @@ You can run workflows from agents, tools, the Mastra Client, or the command line
|
|
|
287
287
|
const testWorkflow = mastra.getWorkflow('testWorkflow')
|
|
288
288
|
```
|
|
289
289
|
|
|
290
|
-
> **
|
|
290
|
+
> **Note:** `mastra.getWorkflow()` is preferred over a direct import for two reasons:
|
|
291
291
|
>
|
|
292
292
|
> 1. It provides access to the Mastra instance configuration (logger, telemetry, storage, registered agents, and vector stores)
|
|
293
293
|
> 2. It provides full TypeScript type inference for workflow input and output schemas
|
|
@@ -55,7 +55,7 @@ Once you have your API routes set up, you can use them in the [`useChat()`](#use
|
|
|
55
55
|
|
|
56
56
|
Run Mastra as a standalone server and connect your frontend (e.g. using Vite + React) to its API endpoints. You'll be using Mastra's [custom API routes](https://mastra.ai/docs/server/custom-api-routes) feature for this.
|
|
57
57
|
|
|
58
|
-
> **
|
|
58
|
+
> **Note:** Mastra's [**UI Dojo**](https://ui-dojo.mastra.ai/) is an example of this setup.
|
|
59
59
|
|
|
60
60
|
You can use [`chatRoute()`](https://mastra.ai/reference/ai-sdk/chat-route), [`workflowRoute()`](https://mastra.ai/reference/ai-sdk/workflow-route), and [`networkRoute()`](https://mastra.ai/reference/ai-sdk/network-route) to create API routes that stream Mastra content in AI SDK-compatible format. Once implemented, you can use these API routes in [`useChat()`](#usechat).
|
|
61
61
|
|
|
@@ -1023,7 +1023,7 @@ export const mastra = new Mastra({
|
|
|
1023
1023
|
})
|
|
1024
1024
|
```
|
|
1025
1025
|
|
|
1026
|
-
> **
|
|
1026
|
+
> **Note:** You can access this data in your tools via the `requestContext` parameter. See the [Request Context documentation](https://mastra.ai/docs/server/request-context) for more details.
|
|
1027
1027
|
|
|
1028
1028
|
**Next.js**:
|
|
1029
1029
|
|
|
@@ -1383,7 +1383,7 @@ export function NestedAgentChat() {
|
|
|
1383
1383
|
Key points:
|
|
1384
1384
|
|
|
1385
1385
|
- Piping `fullStream` to `context.writer` creates `data-tool-agent` parts
|
|
1386
|
-
- Read `data-tool-agent-step` when you need the full payload for the nested step that
|
|
1386
|
+
- Read `data-tool-agent-step` when you need the full payload for the nested step that finished
|
|
1387
1387
|
- The `AgentDataPart` has `id` (on the part) and `data.text` (the current nested-agent text snapshot)
|
|
1388
1388
|
- The tool still returns its own output after the stream completes
|
|
1389
1389
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[Assistant UI](https://assistant-ui.com) is the TypeScript/React library for AI Chat. Built on shadcn/ui and Tailwind CSS, it enables developers to create beautiful, enterprise-grade chat experiences in minutes.
|
|
6
6
|
|
|
7
|
-
> **
|
|
7
|
+
> **Note:** For a full-stack integration approach where Mastra runs directly in your Next.js API routes, see the [Full-Stack Integration Guide](https://www.assistant-ui.com/docs/integrations/frameworks/mastra/full-stack) on Assistant UI's documentation site.
|
|
8
8
|
|
|
9
9
|
Visit Mastra's [**"UI Dojo"**](https://ui-dojo.mastra.ai/) to see real-world examples of Assistant UI integrated with Mastra.
|
|
10
10
|
|