@mastra/mcp-docs-server 1.2.16-alpha.3 → 1.2.16-alpha.6

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.
Files changed (138) hide show
  1. package/.docs/docs/agents/a2a.md +1 -1
  2. package/.docs/docs/agents/guardrails.md +11 -10
  3. package/.docs/docs/agents/overview.md +2 -0
  4. package/.docs/docs/agents/processors.md +8 -8
  5. package/.docs/docs/agents/structured-output.md +1 -1
  6. package/.docs/docs/agents/using-tools.md +51 -12
  7. package/.docs/docs/browser/overview.md +22 -3
  8. package/.docs/docs/capabilities/subagents.md +2 -2
  9. package/.docs/docs/datasets/running-experiments.md +2 -2
  10. package/.docs/docs/deployment/overview.md +3 -3
  11. package/.docs/docs/deployment/sandbox.md +1 -1
  12. package/.docs/docs/deployment/workers.md +5 -5
  13. package/.docs/docs/deployment/workflow-runners.md +1 -1
  14. package/.docs/docs/editor/overview.md +3 -1
  15. package/.docs/docs/evals/custom-scorers.md +1 -1
  16. package/.docs/docs/evals/multi-turn.md +1 -1
  17. package/.docs/docs/evals/overview.md +3 -3
  18. package/.docs/docs/getting-started/develop.md +1 -1
  19. package/.docs/docs/harness/agent-controller.md +2 -2
  20. package/.docs/docs/harness/overview.md +1 -1
  21. package/.docs/docs/long-running-agents/background-tasks.md +2 -2
  22. package/.docs/docs/long-running-agents/goals.md +3 -2
  23. package/.docs/docs/long-running-agents/signals.md +2 -2
  24. package/.docs/docs/mastra-platform/deploy.md +1 -1
  25. package/.docs/docs/mastra-platform/github.md +1 -1
  26. package/.docs/docs/mastra-platform/observability.md +1 -1
  27. package/.docs/docs/mastra-platform/overview.md +3 -3
  28. package/.docs/docs/mastra-platform/server.md +2 -2
  29. package/.docs/docs/mastra-platform/trace-intelligence.md +3 -3
  30. package/.docs/docs/memory/memory-processors.md +1 -1
  31. package/.docs/docs/memory/message-history.md +2 -2
  32. package/.docs/docs/memory/observational-memory.md +13 -13
  33. package/.docs/docs/memory/semantic-recall.md +1 -1
  34. package/.docs/docs/memory/working-memory.md +1 -1
  35. package/.docs/docs/observability/logging.md +1 -1
  36. package/.docs/docs/observability/metrics/querying.md +1 -1
  37. package/.docs/docs/observability/tracing/overview.md +3 -3
  38. package/.docs/docs/server/custom-adapters.md +2 -2
  39. package/.docs/docs/server/custom-api-routes.md +1 -1
  40. package/.docs/docs/server/mastra-client.md +1 -1
  41. package/.docs/docs/server/server-adapters.md +1 -1
  42. package/.docs/docs/studio/deployment.md +2 -2
  43. package/.docs/docs/studio/observability.md +1 -1
  44. package/.docs/docs/studio/overview.md +2 -0
  45. package/.docs/docs/workflows/dynamic-workflows.md +1 -1
  46. package/.docs/docs/workflows/scheduled-workflows.md +1 -1
  47. package/.docs/docs/workflows/suspend-and-resume.md +1 -1
  48. package/.docs/docs/workspace/overview.md +2 -1
  49. package/.docs/docs/workspace/search.md +1 -1
  50. package/.docs/docs/workspace/skills.md +1 -1
  51. package/.docs/integrations/browsers/agent-browser.md +2 -3
  52. package/.docs/integrations/browsers/firecrawl.md +0 -1
  53. package/.docs/integrations/browsers/stagehand.md +2 -3
  54. package/.docs/models/gateways/openrouter.md +1 -2
  55. package/.docs/models/index.md +1 -1
  56. package/.docs/models/providers/kilo.md +6 -7
  57. package/.docs/models/providers/nano-gpt.md +2 -1
  58. package/.docs/reference/acp/acp-agent.md +1 -1
  59. package/.docs/reference/agent-controller/session.md +1 -1
  60. package/.docs/reference/agents/channels.md +1 -1
  61. package/.docs/reference/agents/inngest-agent.md +1 -1
  62. package/.docs/reference/ai-sdk/overview.md +1 -1
  63. package/.docs/reference/auth/auth0.md +1 -1
  64. package/.docs/reference/auth/google.md +1 -1
  65. package/.docs/reference/browser/agent-browser.md +2 -2
  66. package/.docs/reference/browser/browser-viewer.md +1 -1
  67. package/.docs/reference/browser/stagehand-browser.md +2 -2
  68. package/.docs/reference/channels/channel-provider.md +1 -1
  69. package/.docs/reference/channels/slack-provider.md +1 -1
  70. package/.docs/reference/cli/mastra.md +5 -5
  71. package/.docs/reference/code-sdk/mount-agent-controller.md +1 -1
  72. package/.docs/reference/coding-agent/build-base-prompt.md +2 -1
  73. package/.docs/reference/configuration.md +3 -3
  74. package/.docs/reference/core/getAgentById.md +1 -1
  75. package/.docs/reference/core/getWorkflow.md +2 -2
  76. package/.docs/reference/core/mastra-class.md +1 -1
  77. package/.docs/reference/deployer/netlify.md +1 -1
  78. package/.docs/reference/deployer.md +1 -1
  79. package/.docs/reference/editor/prompt-blocks.md +1 -1
  80. package/.docs/reference/editor/tools.md +1 -1
  81. package/.docs/reference/evals/completeness.md +1 -1
  82. package/.docs/reference/evals/noise-sensitivity.md +1 -1
  83. package/.docs/reference/evals/summarization.md +1 -1
  84. package/.docs/reference/file-based-agents/config.md +1 -1
  85. package/.docs/reference/file-based-agents/skills.md +5 -5
  86. package/.docs/reference/file-based-agents/workspace.md +1 -1
  87. package/.docs/reference/index.md +1 -1
  88. package/.docs/reference/logging/pino-logger.md +1 -1
  89. package/.docs/reference/memory/observational-memory.md +12 -4
  90. package/.docs/reference/migrations/upgrade-to-v1/agent.md +3 -3
  91. package/.docs/reference/migrations/upgrade-to-v1/client.md +1 -1
  92. package/.docs/reference/migrations/upgrade-to-v1/evals.md +1 -1
  93. package/.docs/reference/migrations/upgrade-to-v1/mastra.md +1 -1
  94. package/.docs/reference/migrations/upgrade-to-v1/mcp.md +1 -1
  95. package/.docs/reference/migrations/upgrade-to-v1/overview.md +1 -1
  96. package/.docs/reference/migrations/upgrade-to-v1/processors.md +1 -1
  97. package/.docs/reference/migrations/upgrade-to-v1/storage.md +5 -5
  98. package/.docs/reference/migrations/upgrade-to-v1/tools.md +1 -1
  99. package/.docs/reference/observability/tracing/bridges/datadog.md +1 -1
  100. package/.docs/reference/observability/tracing/bridges/otel.md +1 -1
  101. package/.docs/reference/observability/tracing/exporters/arize.md +1 -1
  102. package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +2 -2
  103. package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +1 -1
  104. package/.docs/reference/observability/tracing/exporters/otel.md +1 -1
  105. package/.docs/reference/observability/tracing/exporters/sentry.md +1 -1
  106. package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +27 -3
  107. package/.docs/reference/processors/batch-parts-processor.md +1 -1
  108. package/.docs/reference/processors/language-detector.md +1 -2
  109. package/.docs/reference/processors/processor-interface.md +16 -16
  110. package/.docs/reference/processors/stream-error-retry-processor.md +2 -2
  111. package/.docs/reference/processors/token-cost-control.md +154 -0
  112. package/.docs/reference/rag/chunking-and-embedding.md +1 -1
  113. package/.docs/reference/rag/metadata-filters.md +1 -1
  114. package/.docs/reference/server/koa-adapter.md +1 -1
  115. package/.docs/reference/signals/webhook-signal-provider.md +1 -1
  116. package/.docs/reference/storage/retention.md +1 -1
  117. package/.docs/reference/tools/bedrock-kb-tool.md +1 -1
  118. package/.docs/reference/tools/mcp-client.md +3 -3
  119. package/.docs/reference/tools/mcp-server.md +5 -5
  120. package/.docs/reference/tools/task-tools.md +1 -1
  121. package/.docs/reference/tools/vector-query-tool.md +1 -1
  122. package/.docs/reference/vectors/chroma.md +1 -1
  123. package/.docs/reference/vectors/convex.md +1 -1
  124. package/.docs/reference/vectors/couchbase.md +1 -1
  125. package/.docs/reference/vectors/mongodb.md +2 -2
  126. package/.docs/reference/vectors/pg.md +1 -1
  127. package/.docs/reference/vectors/qdrant.md +2 -2
  128. package/.docs/reference/voice/overview.md +1 -1
  129. package/.docs/reference/voice/speech-to-speech.md +1 -1
  130. package/.docs/reference/voice/speech-to-text.md +1 -1
  131. package/.docs/reference/voice/voice.on.md +1 -1
  132. package/.docs/reference/voice/voice.updateConfig.md +1 -1
  133. package/.docs/reference/workspace/local-sandbox.md +1 -1
  134. package/.docs/reference/workspace/workspace-class.md +1 -1
  135. package/CHANGELOG.md +14 -0
  136. package/package.json +5 -5
  137. package/.docs/docs/browser/recording.md +0 -120
  138. package/.docs/reference/processors/cost-guard-processor.md +0 -115
@@ -25,7 +25,7 @@ const agent = new Agent({
25
25
  })
26
26
  ```
27
27
 
28
- Or import the tools directly:
28
+ Or import the tools directly. `taskWriteTool`, `taskUpdateTool`, `taskCompleteTool`, and `taskCheckTool` are the export names; `task_write`, `task_update`, `task_complete`, and `task_check` are the tool IDs the model sees in tool calls and traces:
29
29
 
30
30
  ```typescript
31
31
  import { taskWriteTool, taskUpdateTool, taskCompleteTool, taskCheckTool } from '@mastra/core/tools'
@@ -353,7 +353,7 @@ const response = await agent.generate('Find information about deployment', {
353
353
  })
354
354
  ```
355
355
 
356
- This approach allows you to:
356
+ Runtime configuration supports these use cases:
357
357
 
358
358
  - Switch between environments (dev/staging/prod)
359
359
  - Adjust performance parameters based on load
@@ -56,7 +56,7 @@ Otherwise, you have several options for setting up your single-node Chroma serve
56
56
 
57
57
  Note: Forking is only supported on Chroma Cloud, or if you deploy your own OSS **distributed** Chroma.
58
58
 
59
- `forkIndex` lets you fork an existing Chroma index instantly. Operations on the forked index don't affect the original one. Learn more on the [Chroma docs](https://docs.trychroma.com/cloud/collection-forking).
59
+ `forkIndex` instantly forks an existing Chroma index without affecting the original index. Learn more on the [Chroma docs](https://docs.trychroma.com/cloud/collection-forking).
60
60
 
61
61
  **indexName** (`string`): Name of the index to fork
62
62
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  The `ConvexVector` class provides vector storage and similarity search using [Convex](https://convex.dev). It stores embeddings inside Convex and performs cosine similarity search in the Mastra adapter.
6
6
 
7
- > **Development-scale search:** `ConvexVector` reads matching vectors through the Mastra storage handler, filters in JavaScript, computes cosine similarity, sorts results, and returns the top matches. Use it for local development, tests, and small datasets.
7
+ > **Development-scale search:** `ConvexVector` reads matching vectors through the Mastra storage handler and filters them in JavaScript. It then computes cosine similarity and sorts the results before returning the top matches. Use it for local development, tests, and small datasets.
8
8
  >
9
9
  > For production vector search on Convex, use `ConvexNativeVector`. It uses the Convex native `vectorSearch` API, which requires a deployed Convex vector index and a Convex action.
10
10
 
@@ -101,7 +101,7 @@ Adds or updates vectors and their metadata in the collection.
101
101
 
102
102
  Searches for similar vectors.
103
103
 
104
- > **Warning:** The `filter` and `includeVector` parameters aren't currently supported. Filtering must be performed client-side after retrieving results, or by using the Couchbase SDK's Search capabilities directly. To retrieve the vector embedding, fetch the full document by ID using the Couchbase SDK.
104
+ > **Warning:** The `filter` and `includeVector` parameters aren't currently supported. Filtering must be performed client-side after retrieving results or through the Couchbase SDK's Search capabilities. Retrieve the vector embedding by fetching the full document by ID with the Couchbase SDK.
105
105
 
106
106
  **indexName** (`string`): Name of the index to search in
107
107
 
@@ -220,7 +220,7 @@ const results = await store.textQuery({
220
220
 
221
221
  ### `hybridQuery()`
222
222
 
223
- Runs a hybrid search that fuses vector similarity and full-text results using MongoDB's server-side `$rankFusion`. It requires MongoDB >= 8.0 and is generally available from 8.1. On 8.0.x, it may need a MongoDB support case to enable, and it runs where enabled, such as Atlas 8.0.x. A full-text search index must exist: it's auto-created for managed indexes, but for a bring-your-own collection you must call `createSearchIndex()` first (opt-in).
223
+ Runs a hybrid search that fuses vector similarity and full-text results using MongoDB's server-side `$rankFusion`. It requires MongoDB >= 8.0 and is generally available from 8.1. On 8.0.x, it may require a MongoDB support case for enablement. It runs where enabled, including Atlas 8.0.x. A full-text search index must exist: it's auto-created for managed indexes, but for a bring-your-own collection you must call `createSearchIndex()` first (opt-in).
224
224
 
225
225
  **indexName** (`string`): Name of the Mastra index to search
226
226
 
@@ -276,7 +276,7 @@ interface IndexStats {
276
276
  Deletes a vector index. Behavior depends on how the index was created:
277
277
 
278
278
  - **Managed index** (created without `collectionName`): drops the entire collection and all its data.
279
- - **Bring-your-own index** (created with `collectionName`): drops the Atlas vectorSearch index and, if one was provisioned via `createSearchIndex()`, the companion full-text search index. The caller's operational collection and its documents are preserved. This store never drops a collection it didn't create.
279
+ - **Bring-your-own index** (created with `collectionName`): drops the Atlas vectorSearch index. If `createSearchIndex()` provisioned a companion full-text search index, it drops that index too. The caller's operational collection and its documents are preserved. This store never drops a collection it didn't create.
280
280
 
281
281
  The BYO classification is recorded durably when the index is created, so it's applied correctly even by a different process (e.g. an index created by a setup job and later deleted by a long-lived service). Always pass the **logical index name** (the `indexName` used at `createIndex`), not the physical collection name.
282
282
 
@@ -350,7 +350,7 @@ The `PgVector` class exposes its underlying PostgreSQL connection pool as a publ
350
350
  pgVector.pool // instance of pg.Pool
351
351
  ```
352
352
 
353
- This enables advanced usage such as running direct SQL queries, managing transactions, or monitoring pool state. When using the pool directly:
353
+ Direct pool access supports advanced operations such as direct SQL queries, transactions, or pool-state monitoring. When using the pool directly:
354
354
 
355
355
  - You are responsible for releasing clients (`client.release()`) after use.
356
356
  - The pool remains accessible after calling `disconnect()`, but new queries will fail.
@@ -24,7 +24,7 @@ The QdrantVector class provides vector search using [Qdrant](https://qdrant.tech
24
24
 
25
25
  **namedVectors** (`Record<string, { size: number; distance: 'cosine' | 'euclidean' | 'dotproduct' }>`): Configuration for named vector spaces. When provided, creates a collection with multiple named vector fields.
26
26
 
27
- #### Creating a Named Vectors Collection
27
+ #### Creating a `named vectors` Collection
28
28
 
29
29
  ```typescript
30
30
  // Create a collection with multiple named vector spaces
@@ -84,7 +84,7 @@ await store.upsert({
84
84
 
85
85
  **using** (`string`): Name of the vector field to query when using named vectors. Use this when your collection has multiple named vector fields.
86
86
 
87
- #### Named Vectors
87
+ #### `named vectors`
88
88
 
89
89
  Qdrant supports [multiple vectors per collection](https://qdrant.tech/documentation/concepts/vectors/#named-vectors), with a name assigned to each vector field. Use the `using` parameter to select the vector field to query:
90
90
 
@@ -748,7 +748,7 @@ Visit the [xAI Realtime Voice Reference](https://mastra.ai/integrations/voice/xa
748
748
 
749
749
  ### Realtime voice
750
750
 
751
- Run live calls a user can talk over, in the browser or over the phone. Mastra hands the audio loop to LiveKit, which covers voice activity detection, semantic turn detection, and barge-in, while your agent generates each reply with its own model, tools, and memory. For setup and configuration options, check out [Realtime voice](https://mastra.ai/integrations/voice/livekit).
751
+ Run live calls that a user can talk over in a browser or by phone. Mastra hands the audio loop to LiveKit for voice activity and semantic turn detection, plus barge-in. Your agent generates each reply with its own model, tools, and memory. For setup and configuration options, check out [Realtime voice](https://mastra.ai/integrations/voice/livekit).
752
752
 
753
753
  ## Voice configuration
754
754
 
@@ -80,7 +80,7 @@ export const agent = new Agent({
80
80
 
81
81
  ## Listen for realtime events
82
82
 
83
- Realtime voice providers emit events you can use to update your UI, play assistant audio, log transcriptions, and handle errors:
83
+ Realtime voice providers emit events you can use to update your UI and play assistant audio, while logging transcriptions and handling errors:
84
84
 
85
85
  ```typescript
86
86
  agent.voice.on('speaking', ({ audio }) => {
@@ -35,7 +35,7 @@ Mastra supports several Speech-to-Text providers, each with their own capabiliti
35
35
  - [**ElevenLabs**](https://mastra.ai/integrations/voice/elevenlabs): Advanced speech recognition with support for multiple languages
36
36
  - [**Google**](https://mastra.ai/integrations/voice/google): Google's speech recognition with extensive language support
37
37
  - [**Cloudflare**](https://mastra.ai/integrations/voice/cloudflare): Edge-optimized speech recognition for low-latency applications
38
- - [**Deepgram**](https://mastra.ai/integrations/voice/deepgram): AI-powered speech recognition with high accuracy for various accents
38
+ - [**Deepgram**](https://mastra.ai/integrations/voice/deepgram): AI-powered speech recognition with high accuracy for multiple accents
39
39
  - [**Sarvam**](https://mastra.ai/integrations/voice/sarvam): Specialized in Indic languages and accents
40
40
 
41
41
  Each provider is implemented as a separate package that you can install as needed:
@@ -2,7 +2,7 @@
2
2
 
3
3
  # voice.on()
4
4
 
5
- The `on()` method registers event listeners for voice events. This is particularly important for real-time voice providers, where events are used to communicate transcribed text, audio responses, and other state changes.
5
+ The `on()` method registers event listeners for voice events. This is particularly important for real-time voice providers, where events are used to communicate transcribed text and audio responses, as well as other state changes.
6
6
 
7
7
  ## Usage example
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # voice.updateConfig()
4
4
 
5
- The `updateConfig()` method allows you to update the configuration of a voice provider at runtime. This is useful for changing voice settings, API keys, or other provider-specific options without creating a new instance.
5
+ The `updateConfig()` method allows you to update the configuration of a voice provider at runtime. This is useful for changing voice settings and API keys, along with other provider-specific options without creating a new instance.
6
6
 
7
7
  ## Usage example
8
8
 
@@ -146,7 +146,7 @@ const detection = LocalSandbox.detectIsolation()
146
146
 
147
147
  ## Environment isolation
148
148
 
149
- By default, `LocalSandbox` only includes `PATH` in the environment. This allows commands to run while preventing accidental exposure of API keys and secrets.
149
+ By default, `LocalSandbox` only includes `PATH` in the environment. Commands can run without accidental exposure of API keys and secrets.
150
150
 
151
151
  ```typescript
152
152
  // Default: only PATH is available (commands work, secrets protected)
@@ -278,7 +278,7 @@ const instructions = workspace.getInstructions({ requestContext })
278
278
 
279
279
  #### `getInstructionsAsync(opts?)`
280
280
 
281
- Returns combined workspace instructions. Use this when the workspace uses resolver-backed providers. A runtime-defined filesystem is resolved per request; a runtime-defined sandbox contributes stable placeholder text unless `instructions.dynamicSandbox` is set to `'resolve'`.
281
+ Returns combined workspace instructions. Use this when the workspace uses resolver-backed providers. A runtime-defined filesystem is resolved per request. A runtime-defined sandbox contributes stable placeholder text unless `instructions.dynamicSandbox` is set to `'resolve'`.
282
282
 
283
283
  ```typescript
284
284
  const instructions = await workspace.getInstructionsAsync({ requestContext })
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @mastra/mcp-docs-server
2
2
 
3
+ ## 1.2.16-alpha.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`d118873`](https://github.com/mastra-ai/mastra/commit/d118873cfd5074b1f814a1c169a97ca7a3a29174), [`161258b`](https://github.com/mastra-ai/mastra/commit/161258b3473a6d0fce00a43cab59d119a49a232f), [`8ea8038`](https://github.com/mastra-ai/mastra/commit/8ea80386fde53d26e2c0b2060c53bc9bd9be10f3)]:
8
+ - @mastra/core@1.59.0-alpha.3
9
+
10
+ ## 1.2.16-alpha.4
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [[`898bba4`](https://github.com/mastra-ai/mastra/commit/898bba46d4806dd255a44e5dc3a3d5827eaefdfe), [`f9aab1c`](https://github.com/mastra-ai/mastra/commit/f9aab1cfc3fda03238a7fd7bd8b794e07497878c), [`e31421b`](https://github.com/mastra-ai/mastra/commit/e31421bc9c11c03c6e74f447ecb5820000e2b9d7), [`aece0e7`](https://github.com/mastra-ai/mastra/commit/aece0e7cb124ae1eb1230689b887f5554b9a0bf0)]:
15
+ - @mastra/core@1.59.0-alpha.2
16
+
3
17
  ## 1.2.16-alpha.2
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "1.2.16-alpha.3",
3
+ "version": "1.2.16-alpha.6",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "jsdom": "^26.1.0",
29
29
  "local-pkg": "^1.1.2",
30
30
  "zod": "^4.4.3",
31
- "@mastra/core": "1.59.0-alpha.1",
32
- "@mastra/mcp": "^1.16.0"
31
+ "@mastra/mcp": "^1.16.0",
32
+ "@mastra/core": "1.59.0-alpha.3"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@hono/node-server": "^2.0.0",
@@ -45,9 +45,9 @@
45
45
  "tsx": "^4.23.1",
46
46
  "typescript": "^6.0.3",
47
47
  "vitest": "4.1.10",
48
- "@internal/lint": "0.0.122",
49
48
  "@internal/types-builder": "0.0.97",
50
- "@mastra/core": "1.59.0-alpha.1"
49
+ "@mastra/core": "1.59.0-alpha.3",
50
+ "@internal/lint": "0.0.122"
51
51
  },
52
52
  "homepage": "https://mastra.ai",
53
53
  "repository": {
@@ -1,120 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Browser recording
4
-
5
- **Added in:** `@mastra/core@1.43.0`
6
-
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
-
9
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
10
-
11
- ## When to use browser recording
12
-
13
- Use browser recording when you need to:
14
-
15
- - Review what an agent did in a browser
16
- - Share a short browser automation run with a teammate
17
- - Debug missed actions, slow page loads, or unexpected navigation
18
- - Add short captions that explain each major step
19
-
20
- Recording tools are disabled by default. Enable them only for agents that need to write video files.
21
-
22
- ## Enable recording
23
-
24
- Pass a `recording` object to `AgentBrowser` or `StagehandBrowser`. The only required field is `outputDir`. You can also set `maxDurationMs`, `maxWidth`, and `maxHeight` as defaults for every recording started by this browser.
25
-
26
- The following example enables recording for `AgentBrowser`:
27
-
28
- ```typescript
29
- import { join } from 'node:path'
30
- import { AgentBrowser } from '@mastra/agent-browser'
31
-
32
- export const browser = new AgentBrowser({
33
- headless: false,
34
- recording: {
35
- outputDir: join(process.cwd(), 'browser-recordings'),
36
- maxDurationMs: 60_000,
37
- maxWidth: 1280,
38
- maxHeight: 720,
39
- },
40
- })
41
- ```
42
-
43
- The same option works with `StagehandBrowser`:
44
-
45
- ```typescript
46
- import { join } from 'node:path'
47
- import { StagehandBrowser } from '@mastra/stagehand'
48
-
49
- export const browser = new StagehandBrowser({
50
- headless: false,
51
- recording: {
52
- outputDir: join(process.cwd(), 'browser-recordings'),
53
- maxDurationMs: 60_000,
54
- maxWidth: 1280,
55
- maxHeight: 720,
56
- },
57
- })
58
- ```
59
-
60
- The agent can still override these defaults per-recording by passing `maxDurationMs`, `maxWidth`, or `maxHeight` to the `browser_record` tool at start time.
61
-
62
- ## Recording tools
63
-
64
- Enabling recording adds these tools:
65
-
66
- | Tool | Description |
67
- | ------------------------ | ------------------------------------------------------------ |
68
- | `browser_record` | Starts, stops, or checks the status of a recording. |
69
- | `browser_record_caption` | Adds a short caption at the current moment in the recording. |
70
-
71
- `browser_record` accepts an `action` field:
72
-
73
- - `start`: Start recording the current browser session.
74
- - `status`: Check whether a recording is active.
75
- - `stop`: Stop recording and write the `.avi` file.
76
-
77
- The `outputPath` option for `browser_record` must be an absolute path inside the configured `recording.outputDir`. If you omit it, Mastra creates a file in `outputDir`.
78
-
79
- ## Example agent instructions
80
-
81
- Tell the agent when to record and when to add captions:
82
-
83
- ```typescript
84
- import { Agent } from '@mastra/core/agent'
85
- import { browser } from '../browsers'
86
-
87
- export const browserAgent = new Agent({
88
- id: 'browser-agent',
89
- name: 'Browser Agent',
90
- model: 'openai/gpt-5.6-sol',
91
- browser,
92
- instructions: `Use browser tools to complete the requested task.
93
-
94
- When the user asks for a recording:
95
- 1. Call browser_record with action="start" before browser work begins.
96
- 2. After each major action, call browser_record_caption with a caption of about six words.
97
- 3. Call browser_record with action="stop" as soon as the task is complete.
98
- 4. Return the saved video path to the user.`,
99
- })
100
- ```
101
-
102
- ## Output format and limits
103
-
104
- Recordings are saved as Motion-JPEG AVI files. This format is encoded in JavaScript and doesn't require `ffmpeg` or native dependencies.
105
-
106
- Default limits:
107
-
108
- - Maximum duration: 30 seconds
109
- - Hard duration cap: 120 seconds
110
- - Maximum frame size: 1024 × 720
111
- - Captions: 80 characters each
112
- - One active recording per process
113
-
114
- Use shorter recordings when possible. Long browser sessions produce larger files and are harder to review.
115
-
116
- ## Next steps
117
-
118
- - [AgentBrowser](https://mastra.ai/integrations/browsers/agent-browser)
119
- - [Stagehand](https://mastra.ai/integrations/browsers/stagehand)
120
- - [Browser overview](https://mastra.ai/docs/browser/overview)
@@ -1,115 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # CostGuardProcessor
4
-
5
- The `CostGuardProcessor` enforces monetary cost limits across the agentic loop, blocking or warning when a configurable cost threshold is exceeded.
6
-
7
- It uses `processInputStep` to check the cost limit before each LLM call. Cost data is queried from the observability storage APIs (`getMetricAggregate`) for all scopes. For `resource` and `thread` scopes, it aggregates cost across runs within a configurable time window (defaults to 7 days). For `run` scope, it queries cost for the current trace.
8
-
9
- For token-based limits, use `TokenLimiterProcessor` instead.
10
-
11
- Supports three scoping modes:
12
-
13
- - **Run scope**: Tracks cost within a single agent run via trace ID
14
- - **Resource scope** (default): Tracks cumulative cost per `resourceId` across runs
15
- - **Thread scope**: Tracks cumulative cost per `threadId` across runs
16
-
17
- > **Approximate cost guard.** Cost data is persisted asynchronously via buffered exporters in the observability pipeline. Fast-running agents may exceed the configured limit before metrics are available for query. Treat `maxCost` as an approximate threshold that fast-running agents may exceed.
18
-
19
- ## Usage example
20
-
21
- Track cumulative cost per resource (default scope):
22
-
23
- ```typescript
24
- import { CostGuardProcessor } from '@mastra/core/processors'
25
-
26
- const costGuard = new CostGuardProcessor({
27
- maxCost: 1.0,
28
- })
29
- ```
30
-
31
- Track cumulative cost per thread with a 24-hour window:
32
-
33
- ```typescript
34
- import { CostGuardProcessor } from '@mastra/core/processors'
35
-
36
- const costGuard = new CostGuardProcessor({
37
- maxCost: 5.0,
38
- scope: 'thread',
39
- window: '24h',
40
- })
41
- ```
42
-
43
- Attach to an agent with an `onViolation` callback:
44
-
45
- ```typescript
46
- import { Agent } from '@mastra/core/agent'
47
- import { CostGuardProcessor } from '@mastra/core/processors'
48
-
49
- const costGuard = new CostGuardProcessor({
50
- maxCost: 5.0,
51
- scope: 'resource',
52
- window: '30d',
53
- })
54
-
55
- costGuard.onViolation = ({ detail }) => {
56
- console.log(`Cost exceeded for ${detail.scopeKey}: $${detail.usage}/$${detail.limit}`)
57
- }
58
-
59
- const agent = new Agent({
60
- id: 'my-agent',
61
- name: 'my-agent',
62
- model: 'openai/gpt-5-nano',
63
- processors: {
64
- input: [costGuard],
65
- },
66
- })
67
- ```
68
-
69
- ## Constructor parameters
70
-
71
- **maxCost** (`number`): Maximum estimated cost allowed (e.g. 0.50 for $0.50 USD). Must be a positive number. Uses cost data from observability metrics. This is an approximate limit due to metric persistence delays.
72
-
73
- **scope** (`'run' | 'resource' | 'thread'`): Scope for cost tracking. 'run' tracks cost within the current agent run via trace ID. 'resource' tracks cumulative cost per resourceId across runs (default). 'thread' tracks cumulative cost per threadId across runs. All scopes require observability storage with getMetricAggregate support. (Default: `'resource'`)
74
-
75
- **window** (`'1h' | '6h' | '24h' | '7d' | '30d' | '365d'`): Time window for cost aggregation when using 'resource' or 'thread' scope. Only applicable to non-run scopes. (Default: `'7d'`)
76
-
77
- **strategy** (`'block' | 'warn'`): Strategy when the cost limit is exceeded. 'block' aborts with a TripWire error. 'warn' logs a warning but allows the step to proceed. (Default: `'block'`)
78
-
79
- **message** (`string`): Custom message template for the abort reason. Supports {usage} and {limit} placeholders. (Default: `'Cost guard: cost limit exceeded ({usage}/{limit})'`)
80
-
81
- ## Instance properties
82
-
83
- **id** (`'cost-guard'`): Processor identifier.
84
-
85
- **name** (`'Cost Guard'`): Processor display name.
86
-
87
- **onViolation** (`(violation: ProcessorViolation) => void | Promise<void>`): Callback invoked when a cost violation is detected, regardless of strategy. Part of the generalized Processor interface. Use for side effects like alerting, logging to external systems, or emailing users. Errors thrown by this callback are silently caught.
88
-
89
- **processInputStep** (`(args: ProcessInputStepArgs) => Promise<void>`): Checks cumulative estimated cost against maxCost before each LLM call. Queries observability storage for cost data: run scope filters by trace ID, resource/thread scopes filter by their respective IDs with a time window. Calls abort() when the limit is exceeded (block strategy) or logs a warning (warn strategy). Cost checks are approximate due to metric persistence delays.
90
-
91
- ## Error behavior
92
-
93
- When the `block` strategy is active (default), `CostGuardProcessor` calls `abort()` with `retry: false` when the cost limit is exceeded. The TripWire metadata includes:
94
-
95
- - `processorId`: `'cost-guard'`
96
- - `usage`: Current cumulative usage (`estimatedCost`, `costUnit`)
97
- - `maxCost`: The configured cost limit
98
- - `scope`: The active scope (`'run'`, `'resource'`, or `'thread'`)
99
- - `scopeKey`: The scope identifier for resource/thread scopes (if applicable)
100
-
101
- ## Scoping behavior
102
-
103
- | Scope | Tracks across runs | Filter | Requires context |
104
- | ---------- | ------------------ | --------------------------- | -------------------------------- |
105
- | `run` | No | `traceId` from current span | Tracing context (automatic) |
106
- | `resource` | Yes | `resourceId` + time window | `resourceId` in `RequestContext` |
107
- | `thread` | Yes | `threadId` + time window | `threadId` in `RequestContext` |
108
-
109
- All scopes require observability storage with `getMetricAggregate` support. If the Mastra instance doesn't have observability storage configured, an error is thrown at registration time.
110
-
111
- For `run` scope, the processor reads the trace ID from the current span's tracing context. If no tracing context is available, the check is skipped (fail-open).
112
-
113
- For `resource` and `thread` scopes, if the required context ID is missing at runtime, the check is skipped. Observability query failures are handled with a fail-open strategy: if a query fails, cost is treated as zero.
114
-
115
- > **Note on metric persistence delay.** The observability pipeline uses buffered exporters that flush metrics asynchronously. A short delay exists between when an LLM call completes and when its cost metrics are available for query. During high-frequency agent execution, the cost guard may not detect a limit breach until one or more steps after the actual cost exceeded the threshold.