@mastra/mcp-docs-server 1.2.8-alpha.9 → 1.2.8
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/integrations.md +1 -3
- package/.docs/docs/agent-builder/overview.md +2 -0
- package/.docs/docs/agents/overview.md +17 -13
- package/.docs/docs/agents/skills.md +1 -3
- package/.docs/docs/agents/structured-output.md +2 -0
- package/.docs/docs/agents/using-tools.md +66 -49
- package/.docs/docs/browser/agent-browser.md +1 -0
- package/.docs/docs/browser/firecrawl.md +129 -0
- package/.docs/docs/browser/overview.md +16 -2
- package/.docs/docs/capabilities/channels/slack.md +111 -1
- package/.docs/docs/deployment/mastra-server.md +35 -0
- package/.docs/docs/deployment/monorepo.md +2 -0
- package/.docs/docs/deployment/overview.md +6 -0
- package/.docs/docs/deployment/sandbox.md +277 -0
- package/.docs/docs/editor/overview.md +2 -6
- package/.docs/docs/editor/tools.md +2 -6
- package/.docs/docs/evals/running-in-ci.md +3 -9
- package/.docs/docs/getting-started/build-with-ai.md +2 -6
- package/.docs/docs/getting-started/manual-install.md +1 -1
- package/.docs/docs/index.md +17 -13
- package/.docs/docs/long-running-agents/background-tasks.md +2 -2
- package/.docs/docs/long-running-agents/goals.md +3 -1
- package/.docs/docs/mastra-platform/database.md +12 -6
- package/.docs/docs/mastra-platform/deploy.md +14 -7
- package/.docs/docs/mastra-platform/environments.md +5 -4
- package/.docs/docs/mastra-platform/observability.md +4 -12
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/mastra-platform/regions.md +73 -0
- package/.docs/docs/mastra-platform/workspace.md +111 -0
- package/.docs/docs/memory/observational-memory.md +77 -2
- package/.docs/docs/memory/overview.md +4 -0
- package/.docs/docs/observability/feedback.md +4 -0
- package/.docs/docs/observability/integrations/bridges/otel.md +1 -3
- package/.docs/docs/observability/integrations/exporters/otel.md +1 -3
- package/.docs/docs/server/auth/fga.md +40 -0
- package/.docs/docs/server/auth/simple-auth.md +1 -3
- package/.docs/docs/studio/overview.md +2 -0
- package/.docs/docs/workflows/control-flow.md +1 -3
- package/.docs/docs/workspace/filesystem.md +1 -0
- package/.docs/docs/workspace/sandbox.md +1 -0
- package/.docs/guides/getting-started/quickstart.md +40 -25
- package/.docs/guides/index.md +1 -1
- package/.docs/guides/migrations/vnext-to-standard-apis.md +1 -3
- package/.docs/models/environment-variables.md +2 -0
- package/.docs/models/gateways/netlify.md +3 -6
- package/.docs/models/gateways/openrouter.md +343 -346
- package/.docs/models/gateways/vercel.md +6 -5
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/aki-io.md +78 -0
- package/.docs/models/providers/alibaba-token-plan-cn.md +22 -21
- package/.docs/models/providers/alibaba-token-plan.md +22 -21
- package/.docs/models/providers/ambient.md +12 -10
- package/.docs/models/providers/baseten.md +2 -1
- package/.docs/models/providers/cline-pass.md +82 -0
- package/.docs/models/providers/cortecs.md +2 -1
- package/.docs/models/providers/crossmodel.md +2 -1
- package/.docs/models/providers/deepinfra.md +4 -7
- package/.docs/models/providers/deepseek.md +3 -1
- package/.docs/models/providers/empiriolabs.md +2 -1
- package/.docs/models/providers/google.md +4 -2
- package/.docs/models/providers/huggingface.md +2 -1
- package/.docs/models/providers/inferx.md +3 -3
- package/.docs/models/providers/kenari.md +44 -29
- package/.docs/models/providers/kimi-for-coding.md +6 -9
- package/.docs/models/providers/llmgateway.md +4 -1
- package/.docs/models/providers/moonshotai-cn.md +1 -1
- package/.docs/models/providers/moonshotai.md +1 -1
- package/.docs/models/providers/nebius.md +3 -1
- package/.docs/models/providers/novita-ai.md +3 -1
- package/.docs/models/providers/opencode-go.md +4 -3
- package/.docs/models/providers/opencode.md +4 -2
- package/.docs/models/providers/poolside.md +2 -2
- package/.docs/models/providers/togetherai.md +2 -6
- package/.docs/models/providers/wandb.md +2 -1
- package/.docs/models/providers/zenmux.md +3 -1
- package/.docs/models/providers.md +2 -0
- package/.docs/reference/agent-controller/session.md +13 -0
- package/.docs/reference/agents/agent.md +13 -1
- package/.docs/reference/agents/generate.md +18 -0
- package/.docs/reference/browser/firecrawl-browser.md +71 -0
- package/.docs/reference/cli/create-mastra.md +118 -43
- package/.docs/reference/cli/mastra.md +59 -5
- package/.docs/reference/code-sdk/mount-agent-controller.md +4 -4
- package/.docs/reference/core/getMCPServer.md +1 -3
- package/.docs/reference/core/getMCPServerById.md +1 -3
- package/.docs/reference/core/getWorkflow.md +1 -3
- package/.docs/reference/core/listMCPServers.md +2 -6
- package/.docs/reference/datasets/addItem.md +1 -3
- package/.docs/reference/datasets/addItems.md +1 -3
- package/.docs/reference/datasets/compareExperiments.md +1 -3
- package/.docs/reference/datasets/create.md +1 -3
- package/.docs/reference/datasets/dataset.md +2 -6
- package/.docs/reference/datasets/datasets-manager.md +5 -15
- package/.docs/reference/datasets/delete.md +1 -3
- package/.docs/reference/datasets/deleteExperiment.md +1 -3
- package/.docs/reference/datasets/deleteItem.md +1 -3
- package/.docs/reference/datasets/deleteItems.md +1 -3
- package/.docs/reference/datasets/get.md +1 -3
- package/.docs/reference/datasets/getDetails.md +1 -3
- package/.docs/reference/datasets/getExperiment.md +1 -3
- package/.docs/reference/datasets/getItem.md +1 -3
- package/.docs/reference/datasets/getItemHistory.md +1 -3
- package/.docs/reference/datasets/list.md +1 -3
- package/.docs/reference/datasets/listExperimentResults.md +1 -3
- package/.docs/reference/datasets/listExperiments.md +1 -3
- package/.docs/reference/datasets/listItems.md +1 -3
- package/.docs/reference/datasets/listVersions.md +1 -3
- package/.docs/reference/datasets/startExperiment.md +1 -3
- package/.docs/reference/datasets/startExperimentAsync.md +1 -3
- package/.docs/reference/datasets/update.md +1 -3
- package/.docs/reference/datasets/updateItem.md +1 -3
- package/.docs/reference/editor/mastra-editor.md +1 -3
- package/.docs/reference/evals/context-recall.md +205 -0
- package/.docs/reference/evals/create-scorer.md +3 -9
- package/.docs/reference/evals/mastra-scorer.md +1 -3
- package/.docs/reference/file-based-agents/tools.md +7 -6
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/memory/observational-memory.md +21 -0
- package/.docs/reference/observability/tracing/exporters/posthog.md +39 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -3
- package/.docs/reference/processors/token-limiter-processor.md +1 -3
- package/.docs/reference/rag/database-config.md +12 -0
- package/.docs/reference/streaming/agents/stream.md +2 -0
- package/.docs/reference/templates/overview.md +6 -32
- package/.docs/reference/tools/create-tool.md +78 -52
- package/.docs/reference/tools/mcp-client.md +8 -24
- package/.docs/reference/tools/mcp-server.md +143 -44
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +22 -0
- package/.docs/reference/vectors/mongodb.md +2 -0
- package/.docs/reference/vectors/turbopuffer.md +4 -0
- package/.docs/reference/voice/mistral.md +127 -0
- package/.docs/reference/workspace/daytona-sandbox.md +2 -6
- package/.docs/reference/workspace/platform-filesystem.md +182 -0
- package/.docs/reference/workspace/platform-sandbox.md +200 -0
- package/.docs/reference/workspace/railway-sandbox.md +37 -1
- package/CHANGELOG.md +71 -0
- package/dist/{chunk-GLPCVXXO.js → chunk-HGADBLKG.js} +2 -2
- package/dist/{chunk-GLPCVXXO.js.map → chunk-HGADBLKG.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/stdio.js +1 -1
- package/dist/tools/docs.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
Observability on Mastra platform is a standalone hosted product for searchable traces, logs, and metrics across Mastra projects and deploys. Use it when you want observability without deploying Studio first or setting up local storage.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Use `mastra init` to configure platform observability while adding Mastra to an existing application, or configure it manually in a newly created Mastra project.
|
|
8
8
|
|
|
9
9
|
## Quickstart
|
|
10
10
|
|
|
11
|
-
Choose the setup path that matches your project.
|
|
11
|
+
Choose the setup path that matches your project.
|
|
12
12
|
|
|
13
13
|
### New project
|
|
14
14
|
|
|
15
|
-
Create a
|
|
15
|
+
Create a managed Mastra project. When prompted, opt into Mastra Platform Observability to configure it automatically:
|
|
16
16
|
|
|
17
17
|
**npm**:
|
|
18
18
|
|
|
@@ -38,15 +38,7 @@ yarn create mastra
|
|
|
38
38
|
bunx create-mastra
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
When
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
Enable Mastra Observability? (will open auth flow)
|
|
45
|
-
|
|
46
|
-
> Yes
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
The CLI authenticates with Mastra platform, creates a platform project, writes the required environment variables, and configures the observability exporters.
|
|
41
|
+
When you select observability, the create command authenticates with Mastra Platform, provisions a platform project, and writes the credentials to your project. If you skip platform setup or use a prompt-free creation flow, follow the [manual setup](#manual-setup) steps instead.
|
|
50
42
|
|
|
51
43
|
### Existing non-Mastra projects
|
|
52
44
|
|
|
@@ -10,7 +10,7 @@ The [Mastra platform](https://projects.mastra.ai) provides three products for de
|
|
|
10
10
|
|
|
11
11
|
Deploy with a single command, [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy), or connect a GitHub repository for push-to-deploy. See the [GitHub integration](https://mastra.ai/docs/mastra-platform/github) for the repository-linked flow.
|
|
12
12
|
|
|
13
|
-
Each project can run multiple [**Environments**](https://mastra.ai/docs/mastra-platform/environments) (for example `production` and `staging`)
|
|
13
|
+
Each project can run multiple [**Environments**](https://mastra.ai/docs/mastra-platform/environments) (for example `production` and `staging`), provision [**Hosted databases**](https://mastra.ai/docs/mastra-platform/database) from the CLI or project settings to persist application data, and get a managed [**Workspace**](https://mastra.ai/docs/mastra-platform/workspace) per environment that gives agents a filesystem and a sandbox with no manual configuration.
|
|
14
14
|
|
|
15
15
|
## Get started
|
|
16
16
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Regions
|
|
4
|
+
|
|
5
|
+
A region controls where a platform environment runs, where its [hosted database](https://mastra.ai/docs/mastra-platform/database) is placed, and where its observability data is stored. The region is fixed when the environment is created and can't be changed later.
|
|
6
|
+
|
|
7
|
+
Mastra platform offers two residency zones today, `us` and `eu`, backed by specific compute regions on Railway. Databases and observability follow the environment's region automatically.
|
|
8
|
+
|
|
9
|
+
## Choose a region
|
|
10
|
+
|
|
11
|
+
Pass `--region` when creating or first deploying to an environment:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
mastra deploy --env production --region eu
|
|
15
|
+
mastra env create staging --region us
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Both `mastra deploy --region` and `mastra env create --region` accept either the `us` / `eu` shorthand or a canonical Railway region code from the table below. Shorthand is the recommended form.
|
|
19
|
+
|
|
20
|
+
The default when no region is passed is `us`, which resolves to `pdx` (Portland, Oregon).
|
|
21
|
+
|
|
22
|
+
## Available regions
|
|
23
|
+
|
|
24
|
+
The residency selector offers four Railway regions across two zones. `us` and `eu` shorthand resolve to the underlined default in each zone.
|
|
25
|
+
|
|
26
|
+
| Zone | Railway code | Location |
|
|
27
|
+
| ---- | --------------- | ------------------------- |
|
|
28
|
+
| `us` | `pdx` (default) | Portland, Oregon |
|
|
29
|
+
| `us` | `iad` | Ashburn, Virginia |
|
|
30
|
+
| `us` | `sfo` | San Francisco, California |
|
|
31
|
+
| `eu` | `ams` (default) | Amsterdam, Netherlands |
|
|
32
|
+
|
|
33
|
+
Pass a Railway code directly when you need to pin an environment to a specific data center. Passing `us` selects `pdx`, and passing `eu` selects `ams`.
|
|
34
|
+
|
|
35
|
+
> **Note:** Additional Railway regions exist in the deploy pipeline (for example Singapore, `sin`) but aren't offered in the residency selector yet, because hosted databases and observability don't have local placement outside the US and EU. Passing an unrecognized region falls back to the US default rather than pinning to it.
|
|
36
|
+
|
|
37
|
+
## Hosted database placement
|
|
38
|
+
|
|
39
|
+
When you attach an [environment-scoped database](https://mastra.ai/docs/mastra-platform/database), the platform picks the provider region closest to the environment. This is server-authoritative, so an explicit `--region` on `mastra env db create <env>` is ignored. The environment's region is the source of truth.
|
|
40
|
+
|
|
41
|
+
| Environment region | Turso region | Postgres (Neon) region |
|
|
42
|
+
| ------------------ | ----------------- | ------------------------------ |
|
|
43
|
+
| `pdx` | `sjc` (San Jose) | `aws-us-west-2` (Oregon) |
|
|
44
|
+
| `iad` | `iad` (Ashburn) | `aws-us-east-1` (N. Virginia) |
|
|
45
|
+
| `sfo` | `sjc` (San Jose) | `aws-us-west-2` (Oregon) |
|
|
46
|
+
| `ams` | `ams` (Amsterdam) | `aws-eu-central-1` (Frankfurt) |
|
|
47
|
+
|
|
48
|
+
Project-scoped databases (shared across environments) accept an explicit `--region` because they aren't bound to a single environment. Use a provider region ID for the flag, not the `us` / `eu` shorthand:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
mastra env db create --kind turso --region fra
|
|
52
|
+
mastra env db create --kind neon --region aws-us-east-1
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Turso offers 20+ regions and Postgres (Neon) is available across AWS and Azure regions in the US, EU, and APAC. See the [Turso regions list](https://docs.turso.tech/features/data-edge#locations) and [Neon regions list](https://neon.com/docs/introduction/regions) for the full set. Passing a code not offered by the provider fails at attach time with the provider's error.
|
|
56
|
+
|
|
57
|
+
## Observability co-location
|
|
58
|
+
|
|
59
|
+
Observability ingest runs in two regions today: **US** (Iowa, `us-central1`) and **EU** (Amsterdam). Every environment's traces, logs, and metrics are routed to the ingest region that matches its residency zone:
|
|
60
|
+
|
|
61
|
+
| Environment region | Observability region |
|
|
62
|
+
| ----------------------------------- | -------------------- |
|
|
63
|
+
| `pdx`, `iad`, `sfo`, `us` shorthand | US (Iowa) |
|
|
64
|
+
| `ams`, `eu` shorthand | EU (Amsterdam) |
|
|
65
|
+
|
|
66
|
+
Compute and databases can be placed in more Railway and provider regions than observability supports, so co-location isn't perfect for every combination. A `us`-zone environment always sends telemetry to US ingest, and an `eu`-zone environment always sends telemetry to EU ingest, even if the underlying Railway region is a specific city not directly served by an ingest endpoint. Data residency is preserved at the zone level. Telemetry from an `eu` environment never crosses into the US.
|
|
67
|
+
|
|
68
|
+
## Related
|
|
69
|
+
|
|
70
|
+
- [Deploy](https://mastra.ai/docs/mastra-platform/deploy)
|
|
71
|
+
- [Environments](https://mastra.ai/docs/mastra-platform/environments)
|
|
72
|
+
- [Hosted databases](https://mastra.ai/docs/mastra-platform/database)
|
|
73
|
+
- [Observability](https://mastra.ai/docs/mastra-platform/observability)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Workspace
|
|
4
|
+
|
|
5
|
+
A workspace gives an environment two things your agents can use at runtime:
|
|
6
|
+
|
|
7
|
+
- A **bucket** for filesystem storage, exposed to your code as [`PlatformFilesystem`](https://mastra.ai/reference/workspace/platform-filesystem).
|
|
8
|
+
- A **sandbox** for executing commands, exposed as [`PlatformSandbox`](https://mastra.ai/reference/workspace/platform-sandbox).
|
|
9
|
+
|
|
10
|
+
Workspaces are provisioned per [environment](https://mastra.ai/docs/mastra-platform/environments), so `production` and `staging` each get their own bucket and sandbox. The platform manages provisioning, credentials, and lifecycle; your deploy code only needs to construct the providers.
|
|
11
|
+
|
|
12
|
+
## When workspaces are provisioned
|
|
13
|
+
|
|
14
|
+
New projects have workspaces enabled by default. When you create an environment, the platform provisions a bucket for it automatically. The sandbox base image is warmed in the background so the first `PlatformSandbox` call starts quickly.
|
|
15
|
+
|
|
16
|
+
Existing projects that haven't opted in show an **Enable workspaces** action in the Workspaces tab. Enabling provisions a bucket for every environment on the project.
|
|
17
|
+
|
|
18
|
+
If provisioning fails for an environment — for example while Railway is under load — the Workspaces tab shows the failure and offers a retry. The environment itself is still created; only the workspace is unavailable until you retry.
|
|
19
|
+
|
|
20
|
+
## Use the workspace from your code
|
|
21
|
+
|
|
22
|
+
Install the provider package:
|
|
23
|
+
|
|
24
|
+
**npm**:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @mastra/platform-workspace
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**pnpm**:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm add @mastra/platform-workspace
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Yarn**:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
yarn add @mastra/platform-workspace
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Bun**:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
bun add @mastra/platform-workspace
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Compose the providers into a workspace and register it with Mastra:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { Workspace } from '@mastra/core/workspace'
|
|
52
|
+
import { PlatformFilesystem, PlatformSandbox } from '@mastra/platform-workspace'
|
|
53
|
+
|
|
54
|
+
export const workspace = new Workspace({
|
|
55
|
+
filesystem: new PlatformFilesystem(),
|
|
56
|
+
sandbox: new PlatformSandbox(),
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { Mastra } from '@mastra/core'
|
|
62
|
+
import { workspace } from './workspace'
|
|
63
|
+
|
|
64
|
+
export const mastra = new Mastra({
|
|
65
|
+
workspace,
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`PlatformFilesystem` and `PlatformSandbox` read their credentials from environment variables the platform injects at deploy time, so you don't pass any options on the platform.
|
|
70
|
+
|
|
71
|
+
## Injected environment variables
|
|
72
|
+
|
|
73
|
+
Every deploy that runs on a platform environment with a workspace receives these variables:
|
|
74
|
+
|
|
75
|
+
| Variable | Contents |
|
|
76
|
+
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| `MASTRA_PLATFORM_SECRET_KEY` | Secret key scoped to the deploy. Used by the workspace providers to authenticate. `MASTRA_PLATFORM_ACCESS_TOKEN` is also injected as a deprecated alias. |
|
|
78
|
+
| `MASTRA_PROJECT_ID` | Project the deploy belongs to. |
|
|
79
|
+
| `MASTRA_ENVIRONMENT_ID` | Environment the deploy belongs to. Selects which sandbox pool the platform uses. |
|
|
80
|
+
| `MASTRA_PLATFORM_BUCKET_NAME` | Bucket name attached to the environment. Selects which bucket `PlatformFilesystem` reads and writes. |
|
|
81
|
+
|
|
82
|
+
These names are reserved. If your project sets any of them explicitly, the platform-managed values take precedence.
|
|
83
|
+
|
|
84
|
+
## Local development
|
|
85
|
+
|
|
86
|
+
Reuse the same providers locally by putting the four variables in your `.env` file. Get the values from your project's Workspaces tab:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
MASTRA_PLATFORM_SECRET_KEY=your-secret-key
|
|
90
|
+
MASTRA_PROJECT_ID=your-project-id
|
|
91
|
+
MASTRA_ENVIRONMENT_ID=your-environment-id
|
|
92
|
+
MASTRA_PLATFORM_BUCKET_NAME=your-bucket-name
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`PlatformFilesystem` and `PlatformSandbox` behave the same locally as on the platform — they connect to the same bucket and sandbox pool for that environment. Use a `staging` or `preview` environment's variables for local runs if you want to keep production data isolated.
|
|
96
|
+
|
|
97
|
+
For a purely offline loop that never touches the platform, swap the providers for [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem) and [`LocalSandbox`](https://mastra.ai/reference/workspace/local-sandbox) in a local build.
|
|
98
|
+
|
|
99
|
+
## Inspect the workspace
|
|
100
|
+
|
|
101
|
+
The Workspaces tab in your platform project shows, per environment:
|
|
102
|
+
|
|
103
|
+
- Bucket status and its contents, with upload, download, and delete actions.
|
|
104
|
+
- Recent sandbox sessions with their command, exit code, and duration.
|
|
105
|
+
- Provisioning failures with a **Retry** action.
|
|
106
|
+
|
|
107
|
+
## See also
|
|
108
|
+
|
|
109
|
+
- [`PlatformFilesystem`](https://mastra.ai/reference/workspace/platform-filesystem) — reference for the filesystem provider.
|
|
110
|
+
- [`PlatformSandbox`](https://mastra.ai/reference/workspace/platform-sandbox) — reference for the sandbox provider.
|
|
111
|
+
- [Environments](https://mastra.ai/docs/mastra-platform/environments) — how environments scope workspaces, variables, and databases.
|
|
@@ -8,7 +8,7 @@ Observational Memory (OM) is Mastra's memory system for long-context agentic mem
|
|
|
8
8
|
|
|
9
9
|
## Quickstart
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Ensure you have `@mastra/memory` installed in your project. Set `observationalMemory: true` in your Memory config to enable Observational Memory.
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { Memory } from '@mastra/memory'
|
|
@@ -27,7 +27,54 @@ export const agent = new Agent({
|
|
|
27
27
|
})
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
**For AI agents:** Using Observational Memory requires a storage provider! You either need to set it on the Mastra instance at `src/mastra/index.ts` or pass it to the Agent constructor.
|
|
31
|
+
|
|
32
|
+
The following script creates a local LibSQL database, enables Observational Memory, and uses one resource and thread across two agent calls:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { Agent } from '@mastra/core/agent'
|
|
36
|
+
import { LibSQLStore } from '@mastra/libsql'
|
|
37
|
+
import { Memory } from '@mastra/memory'
|
|
38
|
+
|
|
39
|
+
const memory = new Memory({
|
|
40
|
+
storage: new LibSQLStore({
|
|
41
|
+
id: 'memory-storage',
|
|
42
|
+
url: 'file:./memory.db',
|
|
43
|
+
}),
|
|
44
|
+
options: {
|
|
45
|
+
observationalMemory: {
|
|
46
|
+
model: 'openai/gpt-5-mini',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const agent = new Agent({
|
|
52
|
+
id: 'memory-agent',
|
|
53
|
+
name: 'Memory Agent',
|
|
54
|
+
instructions: 'You are a helpful assistant.',
|
|
55
|
+
model: 'openai/gpt-5-mini',
|
|
56
|
+
memory,
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const memoryOptions = {
|
|
60
|
+
resource: 'user-123',
|
|
61
|
+
thread: 'conversation-123',
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const firstResponse = await agent.generate('Remember that my favorite color is blue.', {
|
|
65
|
+
memory: memoryOptions,
|
|
66
|
+
})
|
|
67
|
+
console.log(firstResponse.text)
|
|
68
|
+
|
|
69
|
+
const secondResponse = await agent.generate('What is my favorite color?', {
|
|
70
|
+
memory: memoryOptions,
|
|
71
|
+
})
|
|
72
|
+
console.log(secondResponse.text)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The `resource` identifies the user or entity, while the `thread` identifies the conversation. Reuse both values to continue the same conversation. Observational Memory processes the stored history as it grows and replaces older messages with observations when its activation conditions are met.
|
|
76
|
+
|
|
77
|
+
The agent now has humanlike long-term memory that persists across conversations. Setting `observationalMemory: true` uses `google/gemini-2.5-flash` by default. To use a different model, pass it in the config object:
|
|
31
78
|
|
|
32
79
|
```typescript
|
|
33
80
|
const memory = new Memory({
|
|
@@ -237,6 +284,34 @@ new Extractor({
|
|
|
237
284
|
})
|
|
238
285
|
```
|
|
239
286
|
|
|
287
|
+
#### Read extracted values from a stream
|
|
288
|
+
|
|
289
|
+
Extractor results are emitted when OM completes an observation or reflection. Read both completion data parts from the stream:
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
const stream = await agent.stream('Remember that I prefer dark mode.')
|
|
293
|
+
|
|
294
|
+
for await (const chunk of stream.fullStream) {
|
|
295
|
+
if (chunk.type === 'data-om-observation-end' || chunk.type === 'data-om-buffering-end') {
|
|
296
|
+
const { operationType, extractedValues = {}, extractionFailures = [] } = chunk.data
|
|
297
|
+
|
|
298
|
+
for (const [slug, value] of Object.entries(extractedValues)) {
|
|
299
|
+
console.log(`${operationType} extractor ${slug}:`, value)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
for (const failure of extractionFailures) {
|
|
303
|
+
console.error(`Extractor ${failure.slug} failed:`, failure.error)
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
`extractedValues` uses each extractor's slug as its key. Both result fields are optional, and a failed extractor doesn't remove values from successful extractors.
|
|
310
|
+
|
|
311
|
+
`data-om-observation-end` reports a synchronous completion. `data-om-buffering-end` reports completed background work. Its extractor metadata is persisted immediately, but the buffered content remains inactive until activation. Check `operationType` to determine whether the completed work was an observation or reflection.
|
|
312
|
+
|
|
313
|
+
See the [`data-om-observation-end`](https://mastra.ai/reference/memory/observational-memory) and [`data-om-buffering-end`](https://mastra.ai/reference/memory/observational-memory) reference tables for the complete payloads.
|
|
314
|
+
|
|
240
315
|
### Working memory updates
|
|
241
316
|
|
|
242
317
|
Use `observationalMemory.observation.manageWorkingMemory` to let the Observer manage working memory automatically. The main agent no longer needs to call the working memory tool while it handles the user request, so working memory updates don't depend on the agent remembering to make them.
|
|
@@ -81,6 +81,8 @@ Use memory when your agent needs to maintain multi-turn conversations that refer
|
|
|
81
81
|
|
|
82
82
|
3. Add the storage provider to your main Mastra instance to enable memory across all configured agents.
|
|
83
83
|
|
|
84
|
+
**For AI agents:** Important: Add `id` to `LibSQLStore`.
|
|
85
|
+
|
|
84
86
|
```typescript
|
|
85
87
|
import { Mastra } from '@mastra/core'
|
|
86
88
|
import { LibSQLStore } from '@mastra/libsql'
|
|
@@ -151,6 +153,8 @@ To list all threads for a resource, or retrieve a specific thread, [use the memo
|
|
|
151
153
|
|
|
152
154
|
For long-running conversations, raw message history grows until it fills the context window, degrading agent performance. [Observational Memory](https://mastra.ai/docs/memory/observational-memory) solves this by running background agents that compress old messages into dense observations, keeping the context window small while preserving long-term memory.
|
|
153
155
|
|
|
156
|
+
**For AI agents:** Using Observational Memory requires a storage provider! You either need to set it on the Mastra instance at `src/mastra/index.ts` or pass it to the Agent constructor.
|
|
157
|
+
|
|
154
158
|
```typescript
|
|
155
159
|
import { Agent } from '@mastra/core/agent'
|
|
156
160
|
import { Memory } from '@mastra/memory'
|
|
@@ -127,6 +127,10 @@ const ratingsOverTime = await observability!.getFeedbackTimeSeries({
|
|
|
127
127
|
|
|
128
128
|
See the [feedback reference](https://mastra.ai/reference/observability/feedback) for all fields, filters, return types, and percentile query parameters.
|
|
129
129
|
|
|
130
|
+
## Export feedback to external platforms
|
|
131
|
+
|
|
132
|
+
Feedback flows through the observability event bus, so exporters that support feedback forward it automatically. The [PostHog exporter](https://mastra.ai/reference/observability/tracing/exporters/posthog) sends feedback as native `$ai_feedback` events that appear on the linked trace in PostHog.
|
|
133
|
+
|
|
130
134
|
## Related
|
|
131
135
|
|
|
132
136
|
- [Observability overview](https://mastra.ai/docs/observability/overview)
|
|
@@ -254,6 +254,46 @@ class MyFGAProvider implements IFGAProvider {
|
|
|
254
254
|
}
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
+
## System actors
|
|
258
|
+
|
|
259
|
+
Autonomous and scheduled agents run without an end user. Mark these calls with an actor signal so FGA can tell them apart from user requests:
|
|
260
|
+
|
|
261
|
+
- `true` or `{ actorKind: 'system' }` identifies an anonymous system actor.
|
|
262
|
+
- The object form can also carry `agentId`, `permissions`, and `scope` to identify and constrain the acting agent.
|
|
263
|
+
|
|
264
|
+
By default, a trusted actor skips the user-centric `require()` check after a tenant-scope check. To enforce per-agent least privilege, implement the optional `requireActor` method on your provider. It receives the actor and the same `FGACheckParams` as `require`, and throws `FGADeniedError` to deny. When your provider doesn't implement `requireActor`, the trusted-actor bypass is preserved, so adding it is backward compatible.
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
import { FGADeniedError } from '@mastra/core/auth/ee'
|
|
268
|
+
import type { ActorSignal, FGACheckParams, IFGAProvider } from '@mastra/core/auth/ee'
|
|
269
|
+
|
|
270
|
+
class MyFGAProvider implements IFGAProvider {
|
|
271
|
+
// ...check, require, filterAccessible...
|
|
272
|
+
|
|
273
|
+
async requireActor(actor: ActorSignal, params: FGACheckParams): Promise<void> {
|
|
274
|
+
const agentId = actor === true ? undefined : actor.agentId
|
|
275
|
+
// Resolve the agent's real grants from a trusted source keyed by agentId.
|
|
276
|
+
const granted = await this.grantsForAgent(agentId)
|
|
277
|
+
const required = Array.isArray(params.permission) ? params.permission : [params.permission]
|
|
278
|
+
if (!required.some(permission => granted.includes(permission))) {
|
|
279
|
+
throw new FGADeniedError(null, params.resource, params.permission)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Trust requirements
|
|
286
|
+
|
|
287
|
+
The actor signal is trusted input, so construct it server-side:
|
|
288
|
+
|
|
289
|
+
- Treat `actor` as a per-call signal. Durable workflows forward it when a run starts, but don't restore the initial actor on resume. Pass it explicitly on every trusted resume, or resolve a fresh actor through agent `defaultOptions`. Without a current actor, user authorization applies and a missing user fails closed.
|
|
290
|
+
- Mastra strips `actor` from execution options handled by its built-in agent HTTP routes. Set it in server-side code, for example a scheduled job or a workflow, never from client input.
|
|
291
|
+
- Establish tenant scope server-side. Built-in agent HTTP routes ignore a client-supplied `organizationId` in the request context, and the trusted-actor path requires an `organizationId` to be set.
|
|
292
|
+
- Durable resume keeps its existing request-context recovery and merge behavior. This doesn't make a persisted actor trusted for a later workflow segment.
|
|
293
|
+
- The tenant-scope check confirms that a trusted `organizationId` exists. It doesn't verify that `actor.agentId` belongs to that organization. When that relationship matters, verify it in `requireActor` using authoritative provider data.
|
|
294
|
+
- Treat `actor.permissions` as a claim, not a grant. A provider that enforces least privilege resolves the agent's authoritative permissions from a trusted source, for example a manifest or your FGA backend keyed by `agentId`, rather than trusting the inline values.
|
|
295
|
+
- Once a provider implements `requireActor`, errors from that method stop execution. Mastra doesn't fall back to organization-only authorization.
|
|
296
|
+
|
|
257
297
|
## Related
|
|
258
298
|
|
|
259
299
|
- [Authentication overview](https://mastra.ai/docs/server/auth)
|
|
@@ -91,6 +91,8 @@ See [request context](https://mastra.ai/docs/server/request-context) for configu
|
|
|
91
91
|
|
|
92
92
|
## Evaluation
|
|
93
93
|
|
|
94
|
+
Use the date filter to limit score metrics to a preset or custom time range.
|
|
95
|
+
|
|
94
96
|
### Scorers
|
|
95
97
|
|
|
96
98
|
The Scorers tab displays the results of your agent's scorers as they run. When messages pass through your agent, the defined scorers evaluate each output asynchronously and render their results here. This allows you to understand how your scorers respond to different interactions, compare performance across test cases, and identify areas for improvement.
|
|
@@ -591,9 +591,7 @@ const embedStep = createStep({
|
|
|
591
591
|
inputSchema: z.object({ chunk: z.string() }),
|
|
592
592
|
outputSchema: z.object({ embedding: z.array(z.number()) }),
|
|
593
593
|
execute: async ({ inputData }) => ({
|
|
594
|
-
embedding: [
|
|
595
|
-
/* vector embedding */
|
|
596
|
-
],
|
|
594
|
+
embedding: [/* vector embedding */],
|
|
597
595
|
}),
|
|
598
596
|
})
|
|
599
597
|
|
|
@@ -23,6 +23,7 @@ Available providers:
|
|
|
23
23
|
- [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem): Stores files in a directory on disk
|
|
24
24
|
- [`S3Filesystem`](https://mastra.ai/reference/workspace/s3-filesystem): Stores files in Amazon S3 or S3-compatible storage (R2, MinIO, Tigris)
|
|
25
25
|
- [`GCSFilesystem`](https://mastra.ai/reference/workspace/gcs-filesystem): Stores files in Google Cloud Storage
|
|
26
|
+
- [`PlatformFilesystem`](https://mastra.ai/reference/workspace/platform-filesystem): Stores files in a Mastra Platform workspace bucket
|
|
26
27
|
- [`GoogleDriveFilesystem`](https://mastra.ai/reference/workspace/google-drive-filesystem): Stores files inside a Google Drive folder
|
|
27
28
|
- [`AzureBlobFilesystem`](https://mastra.ai/reference/workspace/azure-blob-filesystem): Stores files in Azure Blob Storage
|
|
28
29
|
- [`FilesSDKFilesystem`](https://mastra.ai/reference/workspace/files-sdk-filesystem): Stores files in any [FilesSDK](https://files-sdk.dev) adapter (S3, R2, GCS, Azure Blob, Vercel Blob, local filesystem, and more) — useful when you want one provider that can target multiple backends
|
|
@@ -26,6 +26,7 @@ A sandbox provider executes commands in a controlled environment:
|
|
|
26
26
|
- [`DaytonaSandbox`](https://mastra.ai/reference/workspace/daytona-sandbox): Executes commands in isolated Daytona cloud sandboxes
|
|
27
27
|
- [`E2BSandbox`](https://mastra.ai/reference/workspace/e2b-sandbox): Executes commands in isolated E2B cloud sandboxes
|
|
28
28
|
- [`ModalSandbox`](https://mastra.ai/reference/workspace/modal-sandbox): Executes commands in isolated Modal cloud sandboxes
|
|
29
|
+
- [`PlatformSandbox`](https://mastra.ai/reference/workspace/platform-sandbox): Executes commands in a sandbox tied to a Mastra Platform environment
|
|
29
30
|
- [`RailwaySandbox`](https://mastra.ai/reference/workspace/railway-sandbox): Executes commands in ephemeral, isolated Railway cloud sandboxes
|
|
30
31
|
|
|
31
32
|
## Basic usage
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
# Mastra Quickstart
|
|
4
4
|
|
|
5
|
-
**For AI agents:**
|
|
5
|
+
**For AI agents:** Create a new Mastra project non-interactively with `npm create mastra@latest <project-name> -- --llm <provider>`, replacing `<provider>` with `openai`, `anthropic`, `google`, or `xai`. For a minimal project without an agent or model provider, use `npm create mastra@latest <project-name> -- --empty`. To build a Mastra project from scratch, see the [manual installation guide](https://mastra.ai/docs/getting-started/manual-install).
|
|
6
6
|
|
|
7
|
-
The `create
|
|
7
|
+
The `create-mastra` CLI is the quickest way to start a Mastra project. It creates an agent harness with workspace tools, memory, task tracking, web access, schedules, storage, and observability.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
For more control, see the [manual installation guide](https://mastra.ai/docs/getting-started/manual-install). To add Mastra to an existing project, use [`mastra init`](https://mastra.ai/reference/cli/mastra).
|
|
10
10
|
|
|
11
|
-
> **📹 Watch:** Watch [Mastra AI agent course](https://www.youtube.com/watch?v=lCmf_qrGfGA) for a guided introduction to building agents with Mastra.
|
|
11
|
+
> **📹 Watch:** Watch the [Mastra AI agent course](https://www.youtube.com/watch?v=lCmf_qrGfGA) for a guided introduction to building agents with Mastra.
|
|
12
12
|
|
|
13
13
|
## Before you begin
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
You'll need an API key from OpenAI, Anthropic, Google Gemini, or xAI. You can skip entering it during setup and add it to `.env` later.
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Create the project
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Run the interactive setup:
|
|
20
20
|
|
|
21
21
|
**npm**:
|
|
22
22
|
|
|
@@ -42,32 +42,47 @@ yarn create mastra
|
|
|
42
42
|
bunx create-mastra
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
The command asks for a project name, model provider, and optional API key. It then installs dependencies, installs Mastra skills for your coding assistants, and creates an initial Git commit when you aren't already inside a repository.
|
|
46
46
|
|
|
47
|
-
The
|
|
47
|
+
The generated `src/mastra` directory contains the Mastra entry point, agent, workspace tools, and supporting code. See the [project structure reference](https://mastra.ai/reference/project-structure) for the standard Mastra layout.
|
|
48
48
|
|
|
49
|
-
-
|
|
50
|
-
- `agents/weather-agent.ts`: A weather agent with a prompt that uses the tool
|
|
51
|
-
- `tools/weather-tool.ts`: A tool to fetch weather for a given location
|
|
52
|
-
- `workflows/weather-workflow.ts`: A workflow that runs the weather agent
|
|
53
|
-
- `scorers/weather-scorer.ts`: A scorer to evaluate the weather agent's responses
|
|
49
|
+
> **Tip:** Use `--template <template>` to start from a template, or `--empty` to create a minimal provider-free project. Use `--no-skills` or `--no-git` to skip automatic setup. See the [`create-mastra` reference](https://mastra.ai/reference/cli/create-mastra) for all flags.
|
|
54
50
|
|
|
55
|
-
|
|
51
|
+
## Test your agent
|
|
56
52
|
|
|
57
|
-
|
|
53
|
+
Follow the terminal instructions to enter the project directory and start the development server:
|
|
58
54
|
|
|
59
|
-
|
|
55
|
+
**npm**:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run dev
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**pnpm**:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pnpm run dev
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Yarn**:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
yarn dev
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Bun**:
|
|
60
74
|
|
|
61
|
-
|
|
75
|
+
```bash
|
|
76
|
+
bun run dev
|
|
77
|
+
```
|
|
62
78
|
|
|
63
|
-
|
|
79
|
+
Open [Studio at localhost:4111](http://localhost:4111), select the agent, and send a message. Add the provider API key named in `.env.example` to an `.env` file if you skipped it during setup.
|
|
64
80
|
|
|
65
|
-
[Studio](https://mastra.ai/docs/studio/overview) lets you
|
|
81
|
+
[Studio](https://mastra.ai/docs/studio/overview) lets you build and test agents without creating a separate UI.
|
|
66
82
|
|
|
67
83
|
## Next steps
|
|
68
84
|
|
|
69
|
-
- Integrate Mastra with
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
- Watch conceptual guides on our [YouTube channel](https://www.youtube.com/@mastra-ai) and [subscribe](https://www.youtube.com/@mastra-ai?sub_confirmation=1)
|
|
85
|
+
- Integrate Mastra with [Next.js](https://mastra.ai/guides/getting-started/next-js), [React](https://mastra.ai/guides/getting-started/vite-react), or [Astro](https://mastra.ai/guides/getting-started/astro)
|
|
86
|
+
- Learn how to [build Mastra with AI](https://mastra.ai/docs/getting-started/build-with-ai)
|
|
87
|
+
- Build an agent from scratch with a [guide](https://mastra.ai/guides)
|
|
88
|
+
- Watch the [Mastra YouTube channel](https://www.youtube.com/@mastra-ai)
|
package/.docs/guides/index.md
CHANGED
|
@@ -6,7 +6,7 @@ Mastra offers a variety of guides to help you build and work with Mastra, from b
|
|
|
6
6
|
|
|
7
7
|
## New project
|
|
8
8
|
|
|
9
|
-
The `create mastra` command is the fastest way to build your first agent. It
|
|
9
|
+
The `npm create mastra@latest` command is the fastest way to build your first agent. It creates a ready-to-run agent harness that you can explore and adapt in [Studio](https://mastra.ai/docs/studio/overview) right away. You can always integrate Mastra with your framework or UI when you’re ready.
|
|
10
10
|
|
|
11
11
|
- [Quickstart](https://mastra.ai/guides/getting-started/quickstart)
|
|
12
12
|
|
|
@@ -245,9 +245,7 @@ The following options are available in the standard `.stream()` and `generate()`
|
|
|
245
245
|
const result = await agent.stream(messages, {
|
|
246
246
|
prepareStep: ({ step, state }) => {
|
|
247
247
|
console.log('About to execute step:', step)
|
|
248
|
-
return {
|
|
249
|
-
/* modified state */
|
|
250
|
-
}
|
|
248
|
+
return {/* modified state */}
|
|
251
249
|
},
|
|
252
250
|
})
|
|
253
251
|
```
|