@mastra/mcp-docs-server 1.1.46-alpha.2 → 1.1.46-alpha.4
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/agent-builder/browser.md +1 -1
- package/.docs/docs/agent-builder/channels.md +1 -1
- package/.docs/docs/agent-builder/integrations.md +73 -0
- package/.docs/docs/agent-builder/overview.md +1 -0
- package/.docs/docs/agents/adding-voice.md +1 -1
- package/.docs/docs/agents/agent-approval.md +2 -2
- package/.docs/docs/agents/background-tasks.md +1 -1
- package/.docs/docs/agents/channels.md +2 -2
- package/.docs/docs/agents/code-mode.md +20 -56
- package/.docs/docs/agents/overview.md +1 -0
- package/.docs/docs/agents/sdk-agents.md +165 -1
- package/.docs/docs/agents/supervisor-agents.md +40 -2
- package/.docs/docs/agents/using-tools.md +59 -1
- package/.docs/docs/browser/agent-browser.md +1 -1
- package/.docs/docs/browser/browser-viewer.md +22 -15
- package/.docs/docs/browser/overview.md +1 -1
- package/.docs/docs/browser/stagehand.md +1 -1
- package/.docs/docs/editor/overview.md +6 -6
- package/.docs/docs/editor/prompts.md +3 -3
- package/.docs/docs/editor/tools.md +2 -2
- package/.docs/docs/evals/evals-with-memory.md +8 -8
- package/.docs/docs/mastra-platform/observability.md +1 -1
- package/.docs/docs/mastra-platform/server.md +1 -1
- package/.docs/docs/mcp/mcp-apps.md +4 -4
- package/.docs/docs/memory/observational-memory.md +1 -1
- package/.docs/docs/memory/working-memory.md +2 -2
- package/.docs/docs/observability/integrations/bridges/datadog.md +1 -1
- package/.docs/docs/observability/integrations/bridges/otel.md +1 -1
- package/.docs/docs/observability/integrations/exporters/laminar.md +1 -1
- package/.docs/docs/observability/integrations/exporters/langfuse.md +26 -1
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +1 -1
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +4 -4
- package/.docs/docs/observability/integrations/exporters/otel.md +1 -1
- package/.docs/docs/observability/integrations/overview.md +1 -1
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/metrics/overview.md +3 -3
- package/.docs/docs/observability/metrics/querying.md +2 -2
- package/.docs/docs/observability/storage.md +2 -2
- package/.docs/docs/observability/tracing/overview.md +1 -1
- package/.docs/docs/server/auth/fga.md +15 -15
- package/.docs/docs/server/auth/okta.md +2 -2
- package/.docs/docs/server/auth/workos.md +1 -1
- package/.docs/docs/server/custom-api-routes.md +1 -1
- package/.docs/docs/server/pubsub.md +4 -4
- package/.docs/docs/studio/auth.md +1 -1
- package/.docs/docs/studio/observability.md +3 -1
- package/.docs/docs/workflows/scheduled-workflows.md +13 -13
- package/.docs/docs/workspace/filesystem.md +1 -1
- package/.docs/docs/workspace/lsp.md +1 -1
- package/.docs/docs/workspace/overview.md +35 -1
- package/.docs/docs/workspace/sandbox.md +4 -3
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +2 -2
- package/.docs/guides/deployment/aws-bedrock-agentcore.md +3 -3
- package/.docs/guides/deployment/inngest.md +5 -5
- package/.docs/guides/deployment/temporal.md +3 -3
- package/.docs/guides/getting-started/nestjs.md +1 -1
- package/.docs/guides/migrations/mastra-cloud.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/overview.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +1 -1
- package/.docs/models/gateways/custom-gateways.md +57 -7
- package/.docs/reference/acp/acp-agent.md +2 -2
- package/.docs/reference/agents/agent.md +44 -0
- package/.docs/reference/agents/channels.md +1 -1
- package/.docs/reference/agents/durable-agent.md +2 -2
- package/.docs/reference/agents/generate.md +2 -0
- package/.docs/reference/agents/generateLegacy.md +2 -0
- package/.docs/reference/ai-sdk/handle-chat-stream.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +1 -1
- package/.docs/reference/auth/okta.md +1 -1
- package/.docs/reference/auth/workos.md +1 -1
- package/.docs/reference/browser/agent-browser.md +1 -1
- package/.docs/reference/browser/browser-viewer.md +11 -9
- package/.docs/reference/browser/stagehand-browser.md +1 -1
- package/.docs/reference/cli/mastra.md +3 -1
- package/.docs/reference/client-js/responses.md +2 -2
- package/.docs/reference/client-js/workflows.md +1 -1
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/core/mastra-model-gateway.md +15 -1
- package/.docs/reference/core/removeWorkspace.md +26 -0
- package/.docs/reference/editor/browser-provider.md +1 -1
- package/.docs/reference/editor/storage-browser-ref.md +3 -3
- package/.docs/reference/editor/storage-workspace-ref.md +1 -1
- package/.docs/reference/evals/rubric.md +113 -0
- package/.docs/reference/evals/trajectory-accuracy.md +3 -3
- package/.docs/reference/harness/harness-class.md +81 -62
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/memory/serialized-memory-config.md +1 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
- package/.docs/reference/observability/tracing/bridges/datadog.md +1 -1
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +3 -3
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +1 -1
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +5 -5
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +1 -1
- package/.docs/reference/observability/tracing/exporters/otel.md +1 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +2 -2
- package/.docs/reference/processors/cost-guard-processor.md +2 -2
- package/.docs/reference/processors/processor-interface.md +4 -4
- package/.docs/reference/processors/response-cache.md +2 -2
- package/.docs/reference/processors/skill-search-processor.md +3 -3
- package/.docs/reference/processors/tool-search-processor.md +108 -4
- package/.docs/reference/pubsub/base.md +1 -1
- package/.docs/reference/pubsub/caching-pubsub.md +2 -2
- package/.docs/reference/pubsub/event-emitter.md +3 -3
- package/.docs/reference/pubsub/google-cloud-pubsub.md +1 -1
- package/.docs/reference/pubsub/redis-streams.md +1 -1
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +2 -2
- package/.docs/reference/signals/task-signal-provider.md +62 -0
- package/.docs/reference/storage/clickhouse.md +49 -4
- package/.docs/reference/storage/composite.md +33 -1
- package/.docs/reference/storage/convex.md +2 -2
- package/.docs/reference/storage/dsql.md +7 -7
- package/.docs/reference/storage/duckdb.md +3 -3
- package/.docs/reference/storage/redis.md +3 -3
- package/.docs/reference/storage/spanner.md +7 -7
- package/.docs/reference/streaming/agents/stream.md +2 -0
- package/.docs/reference/streaming/agents/streamLegacy.md +2 -0
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/tools/brightdata.md +3 -3
- package/.docs/reference/tools/create-code-mode.md +124 -0
- package/.docs/reference/tools/create-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +5 -5
- package/.docs/reference/tools/mcp-server.md +45 -0
- package/.docs/reference/tools/perplexity.md +4 -4
- package/.docs/reference/tools/tavily.md +3 -3
- package/.docs/reference/voice/aws-nova-sonic.md +1 -1
- package/.docs/reference/voice/google-gemini-live.md +1 -1
- package/.docs/reference/voice/inworld-realtime.md +5 -5
- package/.docs/reference/voice/inworld.md +1 -1
- package/.docs/reference/voice/sarvam.md +1 -1
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +7 -7
- package/.docs/reference/workspace/azure-blob-filesystem.md +2 -2
- package/.docs/reference/workspace/files-sdk-filesystem.md +3 -3
- package/.docs/reference/workspace/google-drive-filesystem.md +7 -7
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/railway-sandbox.md +230 -0
- package/.docs/reference/workspace/vercel-microvm-sandbox.md +1 -1
- package/.docs/reference/workspace/vercel.md +2 -2
- package/.docs/reference/workspace/workspace-class.md +39 -3
- package/CHANGELOG.md +17 -0
- package/dist/chunk-GLPCVXXO.js +2075 -0
- package/dist/chunk-GLPCVXXO.js.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/stdio.js +1 -2070
- package/dist/stdio.js.map +1 -1
- package/package.json +4 -4
|
@@ -426,6 +426,12 @@ Returns an `AgentThreadSubscription` object with these members:
|
|
|
426
426
|
|
|
427
427
|
**tools** (`ToolsInput | ({ requestContext: RequestContext }) => ToolsInput | Promise<ToolsInput>`): Tools that the agent can access. Can be provided statically or resolved dynamically.
|
|
428
428
|
|
|
429
|
+
**hooks** (`ToolHooks`): Hooks that run before and after every tool call made by this agent. Per-execution hooks passed to \`generate()\` or \`stream()\` override matching hooks set here. See Tool hooks below.
|
|
430
|
+
|
|
431
|
+
**hooks.beforeToolCall** (`(context: ToolHookContext) => void | ToolBeforeHookResult | Promise<void | ToolBeforeHookResult>`): Runs before a tool executes. Receives \`{ toolName, input, context, metadata }\`. Return \`{ proceed: false, output }\` to skip the tool call and use \`output\` as its result.
|
|
432
|
+
|
|
433
|
+
**hooks.afterToolCall** (`(context: ToolAfterHookContext) => void | Promise<void>`): Runs after a tool executes. Receives \`{ toolName, input, context, metadata, output, error }\`. \`output\` is undefined when the tool throws, and \`error\` is set instead.
|
|
434
|
+
|
|
429
435
|
**transform** (`ToolPayloadTransformPolicy`): Shared policy for transforming tool payloads before display streams or user-visible transcript messages receive them. Use per-tool \`transform\` on \`createTool()\` for tool-local rules.
|
|
430
436
|
|
|
431
437
|
**workflows** (`Record<string, Workflow> | ({ requestContext: RequestContext }) => Record<string, Workflow> | Promise<Record<string, Workflow>>`): Workflows that the agent can execute. Can be static or dynamically resolved.
|
|
@@ -458,6 +464,44 @@ Returns an `AgentThreadSubscription` object with these members:
|
|
|
458
464
|
|
|
459
465
|
**editor** (`false | { instructions?: boolean; tools?: boolean | { description?: boolean } }`): Controls which fields the editor can override for this code-defined agent. Omit to allow editing instructions and tools. See Editor overrides below.
|
|
460
466
|
|
|
467
|
+
## Tool hooks
|
|
468
|
+
|
|
469
|
+
Use `hooks` to run logic around every tool call the agent makes, including assigned tools, memory tools, toolsets, client tools, and workspace tools.
|
|
470
|
+
|
|
471
|
+
```typescript
|
|
472
|
+
import { Agent } from '@mastra/core/agent'
|
|
473
|
+
|
|
474
|
+
export const agent = new Agent({
|
|
475
|
+
name: 'support-agent',
|
|
476
|
+
instructions: 'Help users with their questions.',
|
|
477
|
+
model: 'openai/gpt-5.5',
|
|
478
|
+
hooks: {
|
|
479
|
+
beforeToolCall: ({ toolName, input }) => {
|
|
480
|
+
console.log(`Running ${toolName}`, input)
|
|
481
|
+
},
|
|
482
|
+
afterToolCall: ({ toolName, output, error }) => {
|
|
483
|
+
console.log(`Finished ${toolName}`, { output, error })
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
})
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
`beforeToolCall` can short-circuit the tool call by returning `{ proceed: false, output }`. The agent skips execution and uses `output` as the tool result:
|
|
490
|
+
|
|
491
|
+
```typescript
|
|
492
|
+
const result = await agent.generate('Clean up old records', {
|
|
493
|
+
hooks: {
|
|
494
|
+
beforeToolCall: ({ toolName }) => {
|
|
495
|
+
if (toolName === 'deleteRecord') {
|
|
496
|
+
return { proceed: false, output: { blocked: true } }
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
})
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
The hook context `metadata` includes `agentId` and `agentName`. Per-execution hooks passed to `generate()` or `stream()` override matching agent-level hooks. When a [workspace](https://mastra.ai/reference/workspace/workspace-class) also defines `tools.hooks`, workspace hooks run inside the agent hook wrapper.
|
|
504
|
+
|
|
461
505
|
## Editor overrides
|
|
462
506
|
|
|
463
507
|
When you register the [`MastraEditor`](https://mastra.ai/reference/editor/mastra-editor), the `editor` field controls which parts of a code-defined agent can be changed through the editor. Fields owned by code are read-only in Studio and are stripped from saved overrides.
|
|
@@ -247,7 +247,7 @@ The `ResolveResourceIdContext` passed to the function:
|
|
|
247
247
|
|
|
248
248
|
## Inline media
|
|
249
249
|
|
|
250
|
-
Controls which attachment types (images, video, PDFs, etc.) are sent as file parts to the model. Types that
|
|
250
|
+
Controls which attachment types (images, video, PDFs, etc.) are sent as file parts to the model. Types that don't match are described as text summaries so the agent knows about the file without crashing models that reject unsupported types.
|
|
251
251
|
|
|
252
252
|
The default (`['image/png', 'image/jpeg', 'image/webp', 'application/pdf']`) matches the formats supported by major vision models. Override `inlineMedia` to expand the list (e.g. `['image/*', 'audio/*']`) or replace it entirely with a predicate function.
|
|
253
253
|
|
|
@@ -63,7 +63,7 @@ Returns: `DurableAgent`
|
|
|
63
63
|
|
|
64
64
|
## `createEventedAgent(options)`
|
|
65
65
|
|
|
66
|
-
Wraps an `Agent` with fire-and-forget durable execution on the built-in workflow engine. Like `createDurableAgent`, it returns a result you stream from, but the underlying workflow runs non-blocking (via `startAsync`) instead of running to completion before the stream is wired up. Use it when you want the run to progress independently of the caller. It
|
|
66
|
+
Wraps an `Agent` with fire-and-forget durable execution on the built-in workflow engine. Like `createDurableAgent`, it returns a result you stream from, but the underlying workflow runs non-blocking (via `startAsync`) instead of running to completion before the stream is wired up. Use it when you want the run to progress independently of the caller. It doesn't accept `id` or `name` overrides.
|
|
67
67
|
|
|
68
68
|
```typescript
|
|
69
69
|
import { createEventedAgent } from '@mastra/core/agent/durable'
|
|
@@ -151,7 +151,7 @@ await output.text
|
|
|
151
151
|
|
|
152
152
|
Returns: `Promise<DurableAgentStreamResult>`
|
|
153
153
|
|
|
154
|
-
> **Warning:** The `cleanup()` returned by `observe()` destroys the run's registry entries and cached events. Only call it when you are done with the run. If the run is suspended and you intend to resume later,
|
|
154
|
+
> **Warning:** The `cleanup()` returned by `observe()` destroys the run's registry entries and cached events. Only call it when you are done with the run. If the run is suspended and you intend to resume later, don't call `cleanup()` — let the auto-cleanup timer handle it after the run finishes or errors. Auto-cleanup doesn't fire on suspended events.
|
|
155
155
|
|
|
156
156
|
## Stream options
|
|
157
157
|
|
|
@@ -266,6 +266,8 @@ const response = await agent.generate('Help me organize my day', {
|
|
|
266
266
|
|
|
267
267
|
**options.clientTools** (`ToolsInput`): Client-side tools available during execution.
|
|
268
268
|
|
|
269
|
+
**options.hooks** (`ToolHooks`): Per-execution hooks that run before and after tool calls. Overrides matching agent-level hooks for this execution. \`beforeToolCall\` can return \`{ proceed: false, output }\` to skip the tool call.
|
|
270
|
+
|
|
269
271
|
**options.savePerStep** (`boolean`): Save messages incrementally after each generation step completes (default: false). Disabled internally when observational memory is enabled.
|
|
270
272
|
|
|
271
273
|
**options.providerOptions** (`Record<string, Record<string, JSONValue>>`): Provider-specific options passed to the language model.
|
|
@@ -84,6 +84,8 @@ await agent.generateLegacy('message for agent')
|
|
|
84
84
|
|
|
85
85
|
**options.clientTools** (`ToolsInput`): Tools that are executed on the 'client' side of the request. These tools do not have execute functions in the definition.
|
|
86
86
|
|
|
87
|
+
**options.hooks** (`ToolHooks`): Per-execution hooks that run before and after tool calls. Overrides matching agent-level hooks for this execution. \`beforeToolCall\` can return \`{ proceed: false, output }\` to skip the tool call.
|
|
88
|
+
|
|
87
89
|
**options.savePerStep** (`boolean`): Save messages incrementally after each generation step completes (default: false). Disabled internally when observational memory is enabled.
|
|
88
90
|
|
|
89
91
|
**options.providerOptions** (`Record<string, Record<string, JSONValue>>`): Additional provider-specific options that are passed through to the underlying LLM provider. The structure is \`{ providerName: { optionKey: value } }\`. Since Mastra extends AI SDK, see the \[AI SDK documentation]\(https\://sdk.vercel.ai/docs/providers/ai-sdk-providers) for complete provider options.
|
|
@@ -21,7 +21,7 @@ When you pass `structuredOutput` to the underlying agent execution, the final st
|
|
|
21
21
|
}
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
The `object` field contains your full structured output value. Mastra emits this event for the final structured output object only. Partial structured output chunks
|
|
24
|
+
The `object` field contains your full structured output value. Mastra emits this event for the final structured output object only. Partial structured output chunks aren't exposed in the UI stream.
|
|
25
25
|
|
|
26
26
|
Read this event with AI SDK UI's custom data handling, such as `onData`, or render it from message data parts.
|
|
27
27
|
|
|
@@ -19,7 +19,7 @@ When the source agent stream includes a final structured output object, `toAISdk
|
|
|
19
19
|
}
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
The `object` field contains your full structured output value. This maps Mastra's final structured output chunk into the AI SDK UI stream. Partial structured output chunks
|
|
22
|
+
The `object` field contains your full structured output value. This maps Mastra's final structured output chunk into the AI SDK UI stream. Partial structured output chunks aren't emitted.
|
|
23
23
|
|
|
24
24
|
## Usage example
|
|
25
25
|
|
|
@@ -54,7 +54,7 @@ export const mastra = new Mastra({
|
|
|
54
54
|
|
|
55
55
|
### Environment variables
|
|
56
56
|
|
|
57
|
-
The following environment variables are automatically used when constructor options
|
|
57
|
+
The following environment variables are automatically used when constructor options aren't provided:
|
|
58
58
|
|
|
59
59
|
**OKTA\_DOMAIN** (`string`): Your Okta domain (e.g., \`dev-123456.okta.com\`). Found in your Okta admin console.
|
|
60
60
|
|
|
@@ -81,7 +81,7 @@ const auth = new MastraAuthWorkos({
|
|
|
81
81
|
})
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
When `trustJwtClaims` is enabled, Mastra can authenticate verified bearer tokens for service principals even if `getUser()`
|
|
84
|
+
When `trustJwtClaims` is enabled, Mastra can authenticate verified bearer tokens for service principals even if `getUser()` isn't the right lookup path. This is the preferred way to pass pre-resolved `organizationMembershipId` values into FGA checks for machine-to-machine flows.
|
|
85
85
|
|
|
86
86
|
## Custom authorization
|
|
87
87
|
|
|
@@ -363,7 +363,7 @@ Capture a screenshot of the current page as PNG (viewport by default; set `fullP
|
|
|
363
363
|
|
|
364
364
|
| Parameter | Type | Description |
|
|
365
365
|
| ---------- | --------- | ---------------------------------------------------------------------------------------- |
|
|
366
|
-
| `fullPage` | `boolean` | Capture the full scrollable page instead of
|
|
366
|
+
| `fullPage` | `boolean` | Capture the full scrollable page instead of only the viewport (optional, default: false) |
|
|
367
367
|
|
|
368
368
|
### `browser_close`
|
|
369
369
|
|
|
@@ -8,6 +8,7 @@ Use `BrowserViewer` when your agent drives a browser through a CLI tool like `br
|
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
10
|
import { Workspace, LocalSandbox } from '@mastra/core/workspace'
|
|
11
|
+
import { Memory } from '@mastra/memory'
|
|
11
12
|
import { BrowserViewer } from '@mastra/browser-viewer'
|
|
12
13
|
import { Agent } from '@mastra/core/agent'
|
|
13
14
|
|
|
@@ -26,6 +27,7 @@ const browserAgent = new Agent({
|
|
|
26
27
|
model: 'openai/gpt-5.5',
|
|
27
28
|
workspace,
|
|
28
29
|
instructions: 'You are a web automation assistant.',
|
|
30
|
+
memory: new Memory(),
|
|
29
31
|
})
|
|
30
32
|
```
|
|
31
33
|
|
|
@@ -42,7 +44,7 @@ When `cdpUrl` is provided, `BrowserViewer` connects to the existing browser inst
|
|
|
42
44
|
|
|
43
45
|
## Constructor parameters
|
|
44
46
|
|
|
45
|
-
**cli** (`'agent-browser' | 'browser-use' | 'browse-cli'`): Which CLI the agent uses for browser automation. The CLI connects to Chrome via the CDP URL.
|
|
47
|
+
**cli** (`'agent-browser' | 'browser-use' | 'browse' | 'browse-cli'`): Which CLI the agent uses for browser automation. The CLI connects to Chrome via the CDP URL.
|
|
46
48
|
|
|
47
49
|
**headless** (`boolean`): Whether to run Chrome in headless mode. (Default: `true`)
|
|
48
50
|
|
|
@@ -72,7 +74,7 @@ When `cdpUrl` is provided, `BrowserViewer` connects to the existing browser inst
|
|
|
72
74
|
|
|
73
75
|
**providerType** (`'cli'`): Always 'cli'. Distinguishes BrowserViewer from SDK-based providers like AgentBrowser.
|
|
74
76
|
|
|
75
|
-
**cli** (`'agent-browser' | 'browser-use' | 'browse-cli'`): The CLI provider this instance is configured for.
|
|
77
|
+
**cli** (`'agent-browser' | 'browser-use' | 'browse' | 'browse-cli'`): The CLI provider this instance is configured for.
|
|
76
78
|
|
|
77
79
|
**status** (`BrowserStatus`): Current browser status: 'pending', 'launching', 'ready', 'error', 'closing', or 'closed'.
|
|
78
80
|
|
|
@@ -192,9 +194,9 @@ await viewer.injectKeyboardEvent({
|
|
|
192
194
|
|
|
193
195
|
Each CLI must be installed separately. Each also publishes a [skill](https://mastra.ai/docs/workspace/skills) that teaches the agent its commands and workflows. When a CLI command runs through `workspace_execute_command`, Mastra detects it and injects the CDP URL automatically using the correct flag.
|
|
194
196
|
|
|
195
|
-
Unlike SDK providers, `BrowserViewer`
|
|
197
|
+
Unlike SDK providers, `BrowserViewer` doesn't provide agent tools. The agent uses CLI commands through `workspace_execute_command` instead.
|
|
196
198
|
|
|
197
|
-
### [agent-browser](https://www.npmjs.com/package/agent-browser)
|
|
199
|
+
### [`agent-browser`](https://www.npmjs.com/package/agent-browser)
|
|
198
200
|
|
|
199
201
|
Config value: `'agent-browser'` · CDP flag: `--cdp`
|
|
200
202
|
|
|
@@ -203,7 +205,7 @@ npm install -g agent-browser
|
|
|
203
205
|
npx skills add vercel-labs/agent-browser
|
|
204
206
|
```
|
|
205
207
|
|
|
206
|
-
### [browser-use](https://pypi.org/project/browser-use/)
|
|
208
|
+
### [`browser-use`](https://pypi.org/project/browser-use/)
|
|
207
209
|
|
|
208
210
|
Config value: `'browser-use'` · CDP flag: `--cdp-url`
|
|
209
211
|
|
|
@@ -212,13 +214,13 @@ pip install browser-use
|
|
|
212
214
|
npx skills add browser-use/browser-use --skill browser-use
|
|
213
215
|
```
|
|
214
216
|
|
|
215
|
-
### [browse
|
|
217
|
+
### [`browse`](https://www.npmjs.com/package/browse) (command: `browse`)
|
|
216
218
|
|
|
217
|
-
Config value: `'browse
|
|
219
|
+
Config value: `'browse'` · CDP flag: `--ws`
|
|
218
220
|
|
|
219
221
|
```bash
|
|
220
|
-
npm install -g
|
|
221
|
-
|
|
222
|
+
npm install -g browse
|
|
223
|
+
browse skills install
|
|
222
224
|
```
|
|
223
225
|
|
|
224
226
|
## Related
|
|
@@ -248,7 +248,7 @@ Capture a screenshot of the current page as PNG (viewport by default; set `fullP
|
|
|
248
248
|
|
|
249
249
|
| Parameter | Type | Description |
|
|
250
250
|
| ---------- | --------- | ---------------------------------------------------------------------------------------- |
|
|
251
|
-
| `fullPage` | `boolean` | Capture the full scrollable page instead of
|
|
251
|
+
| `fullPage` | `boolean` | Capture the full scrollable page instead of only the viewport (optional, default: false) |
|
|
252
252
|
|
|
253
253
|
### `stagehand_close`
|
|
254
254
|
|
|
@@ -1222,7 +1222,9 @@ Prints help message and exits.
|
|
|
1222
1222
|
|
|
1223
1223
|
By default, Mastra collects anonymous information about your project like your OS, Mastra version or Node.js version. You can read the [source code](https://github.com/mastra-ai/mastra/blob/main/packages/cli/src/analytics/index.ts) to check what's collected.
|
|
1224
1224
|
|
|
1225
|
-
|
|
1225
|
+
When a server started with `mastra dev` or `mastra start` has observability metrics enabled, Mastra also sends anonymous, aggregated model usage at startup: input and output token counts per provider and model, plus the command (`dev` or `start`) and `NODE_ENV`. No prompts, responses, or other message content is ever sent. You can read the [source code](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/telemetry/usage-telemetry.ts) to check what's collected.
|
|
1226
|
+
|
|
1227
|
+
You can opt out of all CLI and usage analytics by setting an environment variable:
|
|
1226
1228
|
|
|
1227
1229
|
```bash
|
|
1228
1230
|
MASTRA_TELEMETRY_DISABLED=1
|
|
@@ -130,7 +130,7 @@ Use [`client.conversations`](https://mastra.ai/reference/client-js/conversations
|
|
|
130
130
|
|
|
131
131
|
`response.tools` contains the configured function definitions available for the request.
|
|
132
132
|
|
|
133
|
-
If the model calls a function, that activity
|
|
133
|
+
If the model calls a function, that activity is included in `response.output` as `function_call` and `function_call_output` items alongside the final assistant `message`.
|
|
134
134
|
|
|
135
135
|
When `stream: true`, function calls are also emitted as Responses stream events. Read `response.function_call_arguments.delta` events for partial argument chunks and prefer `response.function_call_arguments.done` for the finalized arguments payload and tool name. Read `response.output_item.done` events for completed `function_call` and `function_call_output` items. Tool output items use `<toolCallId>:output` IDs.
|
|
136
136
|
|
|
@@ -167,7 +167,7 @@ const response = await client.responses.create({
|
|
|
167
167
|
|
|
168
168
|
## Provider-backed requests
|
|
169
169
|
|
|
170
|
-
Use `providerOptions` when you need provider-specific options that Mastra
|
|
170
|
+
Use `providerOptions` when you need provider-specific options that Mastra doesn't normalize at the Responses layer.
|
|
171
171
|
|
|
172
172
|
```typescript
|
|
173
173
|
const response = await client.responses.create({
|
|
@@ -243,7 +243,7 @@ await mastraClient.pauseSchedule('daily-report')
|
|
|
243
243
|
|
|
244
244
|
### `resumeSchedule()`
|
|
245
245
|
|
|
246
|
-
Resume a paused schedule. The next fire time is recomputed from now, so a long-paused schedule
|
|
246
|
+
Resume a paused schedule. The next fire time is recomputed from now, so a long-paused schedule doesn't fire a backlog. Returns the updated schedule. Idempotent.
|
|
247
247
|
|
|
248
248
|
```typescript
|
|
249
249
|
await mastraClient.resumeSchedule('daily-report')
|
|
@@ -637,7 +637,7 @@ export const mastra = new Mastra({
|
|
|
637
637
|
**Type:** `object`\
|
|
638
638
|
**Default:** `undefined`
|
|
639
639
|
|
|
640
|
-
MCP transport options applied to all MCP HTTP and SSE routes. Use this to enable stateless mode for serverless environments (Cloudflare Workers, Vercel Edge, AWS Lambda, etc.) where persistent connections and in-memory session state
|
|
640
|
+
MCP transport options applied to all MCP HTTP and SSE routes. Use this to enable stateless mode for serverless environments (Cloudflare Workers, Vercel Edge, AWS Lambda, etc.) where persistent connections and in-memory session state aren't available.
|
|
641
641
|
|
|
642
642
|
| Property | Type | Default | Description |
|
|
643
643
|
| -------------------- | -------------- | ----------- | ---------------------------------------------------- |
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Abstract base class for implementing custom model gateways. Gateways handle provider-specific logic for accessing language models, including provider configuration, authentication, URL construction, and model instantiation.
|
|
4
4
|
|
|
5
|
+
Use `MastraModelGatewayInterface` when you want to provide a plain object gateway instead of extending the base class.
|
|
6
|
+
|
|
5
7
|
## Class overview
|
|
6
8
|
|
|
7
9
|
```typescript
|
|
@@ -17,7 +19,7 @@ class MyCustomGateway extends MastraModelGateway {
|
|
|
17
19
|
return {
|
|
18
20
|
'my-provider': {
|
|
19
21
|
name: 'My Provider',
|
|
20
|
-
models: ['
|
|
22
|
+
models: ['openai/gpt-5.5', 'anthropic/claude-sonnet-4-6'],
|
|
21
23
|
apiKeyEnvVar: 'MY_API_KEY',
|
|
22
24
|
gateway: this.id,
|
|
23
25
|
},
|
|
@@ -107,6 +109,18 @@ Retrieves the API key for authentication.
|
|
|
107
109
|
|
|
108
110
|
**Returns:** `Promise<string>`
|
|
109
111
|
|
|
112
|
+
### `resolveAuth()`
|
|
113
|
+
|
|
114
|
+
Resolves credentials before Mastra creates the language model. Implement this optional hook when a gateway owns authentication. If omitted, Mastra falls back to `getApiKey()`.
|
|
115
|
+
|
|
116
|
+
**Parameters:**
|
|
117
|
+
|
|
118
|
+
**request** (`GatewayAuthRequest`): Incoming request context containing gatewayId, providerId, modelId, and routerId for the gateway to inspect and validate.
|
|
119
|
+
|
|
120
|
+
**Returns:** `GatewayAuthResult | undefined | Promise<GatewayAuthResult | undefined>`
|
|
121
|
+
|
|
122
|
+
A `GatewayAuthResult` may include `apiKey`, `bearerToken`, `headers`, and an optional `source` field to trace where auth came from.
|
|
123
|
+
|
|
110
124
|
### `resolveLanguageModel()`
|
|
111
125
|
|
|
112
126
|
Creates a language model instance.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Mastra.removeWorkspace()
|
|
2
|
+
|
|
3
|
+
The `.removeWorkspace()` method removes a workspace from the Mastra runtime registry. Pass `{ destroy: true }` to destroy the workspace before it's removed.
|
|
4
|
+
|
|
5
|
+
## Usage example
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
await mastra.removeWorkspace('workspace-123', { destroy: true })
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
**id** (`string`): The ID of the workspace to remove.
|
|
14
|
+
|
|
15
|
+
**options** (`{ destroy?: boolean }`): Optional cleanup behavior. Set \`destroy\` to \`true\` to call \`workspace.destroy()\` before removing the workspace.
|
|
16
|
+
|
|
17
|
+
## Returns
|
|
18
|
+
|
|
19
|
+
**removed** (`Promise<boolean>`): \`true\` when a workspace was removed. \`false\` when no workspace exists for the ID.
|
|
20
|
+
|
|
21
|
+
When `destroy` is `true` and `workspace.destroy()` throws, the call rejects with that error and the workspace remains registered so the caller can retry cleanup.
|
|
22
|
+
|
|
23
|
+
## Related
|
|
24
|
+
|
|
25
|
+
- [Workspace overview](https://mastra.ai/docs/workspace/overview)
|
|
26
|
+
- [Workspace class](https://mastra.ai/reference/workspace/workspace-class)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`BrowserProvider` is the interface a package implements to register a browser with [`MastraEditor`](https://mastra.ai/reference/editor/mastra-editor). The editor calls `createBrowser(config)` at agent hydration time, using the `provider` id from the stored [`StorageBrowserRef`](https://mastra.ai/reference/editor/storage-browser-ref) as the lookup key.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
No built-in browser providers are available. To use the `browser` feature in the Agent Builder, register a provider package (for example, `@mastra/stagehand`).
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`StorageBrowserRef` is the inline browser configuration attached to a stored agent. The `provider` id is resolved at hydration time against the [`BrowserProvider`](https://mastra.ai/reference/editor/browser-provider) registered on [`MastraEditor.browsers`](https://mastra.ai/reference/editor/mastra-editor).
|
|
4
4
|
|
|
5
|
-
It
|
|
5
|
+
It's the type used by [`BuilderAgentDefaults.browser`](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults) and by stored agent records.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -36,7 +36,7 @@ new MastraEditor({
|
|
|
36
36
|
type StorageBrowserRef = { type: 'inline'; config: StorageBrowserConfig }
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
A `{ type: 'id' }` variant for browsers isn't available — they're always inlined.
|
|
40
40
|
|
|
41
41
|
## Properties
|
|
42
42
|
|
|
@@ -70,7 +70,7 @@ The shape embedded under `config`. Defined in `@mastra/core/storage`.
|
|
|
70
70
|
|
|
71
71
|
## Hydration
|
|
72
72
|
|
|
73
|
-
`StorageBrowserRef` is resolved lazily on `mastra.editor.agent.getById()`. The editor looks up `config.provider` on `MastraEditor.browsers` and calls `provider.createBrowser(config)`. If the provider
|
|
73
|
+
`StorageBrowserRef` is resolved lazily on `mastra.editor.agent.getById()`. The editor looks up `config.provider` on `MastraEditor.browsers` and calls `provider.createBrowser(config)`. If the provider isn't registered, the editor logs a warning and returns `undefined` — the agent still loads, but without a browser.
|
|
74
74
|
|
|
75
75
|
## Related
|
|
76
76
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`StorageWorkspaceRef` is the discriminated union used to attach a workspace to a stored agent. It either points at a workspace registered on the Mastra runtime by ID, or embeds a workspace snapshot inline.
|
|
4
4
|
|
|
5
|
-
It
|
|
5
|
+
It's the type used by [`BuilderAgentDefaults.workspace`](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults) and by stored agent records.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Rubric scorer
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/evals@1.3.0`
|
|
4
|
+
|
|
5
|
+
The `createRubricScorer()` function creates an LLM-as-judge scorer that grades an agent's output against a rubric (a checklist of criteria). It returns a **binary** score: `1` only when every required criterion is satisfied, otherwise `0`. The `reason` lists each criterion's verdict so the agent knows exactly what to fix.
|
|
6
|
+
|
|
7
|
+
This scorer is designed to drop into [`isTaskComplete`](https://mastra.ai/reference/streaming/agents/stream). Because `isTaskComplete` treats `score === 1` as "task complete" and injects the `reason` back into the conversation as feedback, the agent keeps iterating until the rubric is satisfied (or `maxSteps` is reached).
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
**model** (`MastraModelConfig`): The language model used to grade the output against the rubric. A smaller, cheaper model is usually sufficient for grading.
|
|
12
|
+
|
|
13
|
+
**criteria** (`RubricCriterion[] | string`): The rubric to grade against. A string is treated as a newline-delimited checklist (each line becomes a required criterion). If omitted, the rubric is read at run time from a \`rubric\` value on request/additional context; if none resolves, the scorer is a no-op and returns 1.
|
|
14
|
+
|
|
15
|
+
**options** (`RubricScorerOptions`): Configuration options for the scorer
|
|
16
|
+
|
|
17
|
+
## `.run()` returns
|
|
18
|
+
|
|
19
|
+
**score** (`number`): 1 when every required criterion is satisfied, otherwise 0 (multiplied by scale).
|
|
20
|
+
|
|
21
|
+
**reason** (`string`): A per-criterion explanation listing which criteria are met or unmet and why. This is the text that isTaskComplete injects back into the conversation as feedback.
|
|
22
|
+
|
|
23
|
+
## Usage with isTaskComplete
|
|
24
|
+
|
|
25
|
+
Define the rubric once, attach the scorer to `isTaskComplete`, and the agent self-corrects until the rubric is satisfied:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Agent } from '@mastra/core/agent'
|
|
29
|
+
import { createRubricScorer } from '@mastra/evals/scorers/prebuilt'
|
|
30
|
+
|
|
31
|
+
const supervisor = new Agent({
|
|
32
|
+
id: 'supervisor',
|
|
33
|
+
instructions: `You coordinate research and writing using specialized agents. Delegate to research-agent for facts, then writing-agent for content.`,
|
|
34
|
+
model: 'openai/gpt-5.5',
|
|
35
|
+
agents: { researchAgent, writingAgent },
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const rubricScorer = createRubricScorer({
|
|
39
|
+
model: 'openai/gpt-5-mini',
|
|
40
|
+
criteria: [
|
|
41
|
+
{ description: 'The response includes an analysis section' },
|
|
42
|
+
{ description: 'The response includes concrete recommendations' },
|
|
43
|
+
],
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const stream = await supervisor.stream('Research AI in education', {
|
|
47
|
+
maxSteps: 10,
|
|
48
|
+
isTaskComplete: {
|
|
49
|
+
scorers: [rubricScorer],
|
|
50
|
+
strategy: 'all',
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## String rubric
|
|
56
|
+
|
|
57
|
+
A newline-delimited string is parsed into criteria, with common list markers (`-`, `*`, `1.`) stripped. Every line becomes a required criterion:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const rubricScorer = createRubricScorer({
|
|
61
|
+
model: 'openai/gpt-5-mini',
|
|
62
|
+
criteria: `- All tests pass in the test suite
|
|
63
|
+
- The function is named find_duplicates and accepts a single list argument`,
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Optional criteria
|
|
68
|
+
|
|
69
|
+
Mark a criterion as optional to have it graded and reported without gating completion:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const rubricScorer = createRubricScorer({
|
|
73
|
+
model: 'openai/gpt-5-mini',
|
|
74
|
+
criteria: [
|
|
75
|
+
{ description: 'Includes an analysis section', required: true },
|
|
76
|
+
{ description: 'Includes citations', required: false },
|
|
77
|
+
],
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Dynamic rubric per run
|
|
82
|
+
|
|
83
|
+
When no `criteria` is passed to the factory, the scorer resolves a `rubric` value from the run's request context, additional context, or input. This lets a single scorer instance grade different rubrics per run without rebuilding it:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const rubricScorer = createRubricScorer({
|
|
87
|
+
model: 'openai/gpt-5-mini',
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
await supervisor.stream('Write find_duplicates', {
|
|
91
|
+
isTaskComplete: { scorers: [rubricScorer] },
|
|
92
|
+
requestContext: {
|
|
93
|
+
rubric: '- All tests pass\n- The function is named find_duplicates',
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
If no rubric resolves, the scorer returns `1` and doesn't gate the loop.
|
|
99
|
+
|
|
100
|
+
## Scoring details
|
|
101
|
+
|
|
102
|
+
The scorer runs in two phases:
|
|
103
|
+
|
|
104
|
+
1. **Grade**: The judge model evaluates each criterion independently and returns a per-criterion verdict (`satisfied` / not) with reasoning.
|
|
105
|
+
2. **Score**: The result is `1` only when every required criterion is `satisfied`, otherwise `0`. If no criteria are marked required, all criteria are treated as required.
|
|
106
|
+
|
|
107
|
+
The `reason` summarizes the overall result and lists each criterion with its verdict, so a failing grade gives the agent targeted, actionable feedback rather than a generic "try again".
|
|
108
|
+
|
|
109
|
+
## Related
|
|
110
|
+
|
|
111
|
+
- [isTaskComplete on stream()](https://mastra.ai/reference/streaming/agents/stream)
|
|
112
|
+
- [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents)
|
|
113
|
+
- [createScorer](https://mastra.ai/reference/evals/create-scorer)
|
|
@@ -31,7 +31,7 @@ workflow_run
|
|
|
31
31
|
|
|
32
32
|
### Fallback extraction
|
|
33
33
|
|
|
34
|
-
When storage
|
|
34
|
+
When storage isn't available, the pipeline falls back to:
|
|
35
35
|
|
|
36
36
|
- **Agents:** `extractTrajectory()` — Extracts `ToolCallStep` entries from `toolInvocations` in the agent's message output. Produces a flat list of tool calls.
|
|
37
37
|
- **Workflows:** `extractWorkflowTrajectory()` — Extracts `WorkflowStepStep` entries from `stepResults`. Produces a flat list of workflow steps.
|
|
@@ -176,7 +176,7 @@ In this example, the parent workflow requires strict ordering of its steps, but
|
|
|
176
176
|
### Use the LLM-based scorer when:
|
|
177
177
|
|
|
178
178
|
- You need **semantic understanding** of whether steps were appropriate
|
|
179
|
-
- The optimal trajectory
|
|
179
|
+
- The optimal trajectory **isn't predetermined** (evaluate based on task requirements)
|
|
180
180
|
- You want to detect **unnecessary, redundant, or missing** steps
|
|
181
181
|
- You need **explanations** for scoring decisions
|
|
182
182
|
- You are evaluating **production agent behavior**
|
|
@@ -360,7 +360,7 @@ console.log(result.scores.trajectory['trajectory-accuracy'])
|
|
|
360
360
|
|
|
361
361
|
### Comparing step data
|
|
362
362
|
|
|
363
|
-
Validates
|
|
363
|
+
Validates the step names and step-specific data. For tool calls, this compares `toolArgs` and `toolResult`. For workflow steps, this compares `output`.
|
|
364
364
|
|
|
365
365
|
```typescript
|
|
366
366
|
const scorer = createTrajectoryAccuracyScorerCode({
|