@mastra/mcp-docs-server 1.1.22-alpha.9 → 1.1.23-alpha.0
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/browser/agent-browser.md +75 -0
- package/.docs/docs/browser/overview.md +136 -0
- package/.docs/docs/browser/stagehand.md +128 -0
- package/.docs/docs/observability/tracing/exporters/arthur.md +163 -0
- package/.docs/docs/observability/tracing/exporters/langfuse.md +19 -33
- package/.docs/models/gateways/openrouter.md +4 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/deepseek.md +1 -1
- package/.docs/models/providers/google.md +3 -3
- package/.docs/models/providers/vultr.md +7 -6
- package/.docs/models/providers/zenmux.md +3 -5
- package/.docs/reference/browser/agent-browser.md +374 -0
- package/.docs/reference/browser/mastra-browser.md +284 -0
- package/.docs/reference/browser/stagehand-browser.md +290 -0
- package/.docs/reference/index.md +3 -0
- package/.docs/reference/observability/tracing/exporters/arthur.md +122 -0
- package/.docs/reference/observability/tracing/exporters/langfuse.md +23 -32
- package/CHANGELOG.md +28 -0
- package/package.json +5 -5
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# AgentBrowser
|
|
2
|
+
|
|
3
|
+
The `@mastra/agent-browser` package provides browser automation using Playwright with accessibility-first element targeting. Elements are identified by refs from the page's accessibility tree, making interactions reliable across different page layouts.
|
|
4
|
+
|
|
5
|
+
## When to use AgentBrowser
|
|
6
|
+
|
|
7
|
+
Use AgentBrowser when you need:
|
|
8
|
+
|
|
9
|
+
- Reliable element targeting through accessibility refs
|
|
10
|
+
- Fine-grained control over browser actions
|
|
11
|
+
- Playwright's robust automation capabilities
|
|
12
|
+
- Support for keyboard shortcuts and complex interactions
|
|
13
|
+
|
|
14
|
+
## Quickstart
|
|
15
|
+
|
|
16
|
+
Install the package:
|
|
17
|
+
|
|
18
|
+
**npm**:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @mastra/agent-browser
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**pnpm**:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pnpm add @mastra/agent-browser
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Yarn**:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
yarn add @mastra/agent-browser
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Bun**:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
bun add @mastra/agent-browser
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Create a browser instance and assign it to an agent:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { Agent } from '@mastra/core/agent'
|
|
46
|
+
import { AgentBrowser } from '@mastra/agent-browser'
|
|
47
|
+
|
|
48
|
+
const browser = new AgentBrowser({
|
|
49
|
+
headless: false,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
export const browserAgent = new Agent({
|
|
53
|
+
id: 'browser-agent',
|
|
54
|
+
model: 'openai/gpt-5.4',
|
|
55
|
+
browser,
|
|
56
|
+
instructions: `You are a web automation assistant.
|
|
57
|
+
|
|
58
|
+
When interacting with pages:
|
|
59
|
+
1. Use browser_snapshot to get the current page state and element refs
|
|
60
|
+
2. Use the refs (like @e1, @e2) to target elements for clicks and typing
|
|
61
|
+
3. After actions, take another snapshot to verify the result`,
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Element refs
|
|
66
|
+
|
|
67
|
+
AgentBrowser uses accessibility tree refs to identify elements. When an agent calls `browser_snapshot`, it receives a text representation of the page with refs like `@e1`, `@e2`, etc. The agent then uses these refs with other tools to interact with elements.
|
|
68
|
+
|
|
69
|
+
> **Note:** See [AgentBrowser reference](https://mastra.ai/reference/browser/agent-browser) for all configuration options and tool details.
|
|
70
|
+
|
|
71
|
+
## Related
|
|
72
|
+
|
|
73
|
+
- [Browser overview](https://mastra.ai/docs/browser/overview)
|
|
74
|
+
- [Stagehand](https://mastra.ai/docs/browser/stagehand)
|
|
75
|
+
- [AgentBrowser reference](https://mastra.ai/reference/browser/agent-browser)
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Browser overview
|
|
2
|
+
|
|
3
|
+
Browser support enables agents to navigate websites, interact with page elements, fill forms, and extract data. Mastra provides browser capabilities through SDK providers that wrap popular browser automation libraries.
|
|
4
|
+
|
|
5
|
+
Mastra supports two browser SDK providers:
|
|
6
|
+
|
|
7
|
+
- [**AgentBrowser**](https://mastra.ai/docs/browser/agent-browser): A Playwright-based provider with accessibility-first element targeting. Best for general web automation and scraping.
|
|
8
|
+
- [**Stagehand**](https://mastra.ai/docs/browser/stagehand): A Browserbase provider with AI-powered element detection. Best for complex interactions that benefit from natural language selectors.
|
|
9
|
+
|
|
10
|
+
## When to use browser
|
|
11
|
+
|
|
12
|
+
Use browser when your agent needs to:
|
|
13
|
+
|
|
14
|
+
- Navigate websites and interact with page elements
|
|
15
|
+
- Fill out forms and submit data
|
|
16
|
+
- Extract structured data from web pages
|
|
17
|
+
- Automate multi-step web workflows
|
|
18
|
+
- Take actions that require a real browser (JavaScript rendering, authentication flows)
|
|
19
|
+
|
|
20
|
+
## How it works
|
|
21
|
+
|
|
22
|
+
When you assign a browser to an agent, Mastra includes the provider's tools in the agent's toolset. The agent uses these tools to control the browser: navigating to URLs, selecting elements, typing text, and reading page content.
|
|
23
|
+
|
|
24
|
+
Each provider offers a different set of tools optimized for its approach.
|
|
25
|
+
|
|
26
|
+
## Quickstart
|
|
27
|
+
|
|
28
|
+
Install your provider of choice, for this example you'll use the AgentBrowser provider.
|
|
29
|
+
|
|
30
|
+
**npm**:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @mastra/agent-browser
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**pnpm**:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pnpm add @mastra/agent-browser
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Yarn**:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
yarn add @mastra/agent-browser
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Bun**:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
bun add @mastra/agent-browser
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Create a new browser instance:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { AgentBrowser } from '@mastra/agent-browser'
|
|
58
|
+
|
|
59
|
+
export const browser = new AgentBrowser({
|
|
60
|
+
headless: false,
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Assign the browser to an agent:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { Agent } from '@mastra/core/agent'
|
|
68
|
+
import { browser } from '../browsers'
|
|
69
|
+
|
|
70
|
+
export const webAgent = new Agent({
|
|
71
|
+
id: 'web-agent',
|
|
72
|
+
model: 'openai/gpt-5.4',
|
|
73
|
+
browser,
|
|
74
|
+
instructions:
|
|
75
|
+
'You are a web automation assistant. Use browser tools to navigate websites and complete tasks.',
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The agent automatically receives all browser tools from the provider.
|
|
80
|
+
|
|
81
|
+
## Cloud providers
|
|
82
|
+
|
|
83
|
+
Both SDK providers support connecting to cloud browser services instead of launching a local browser.
|
|
84
|
+
|
|
85
|
+
### Browserbase (Stagehand native)
|
|
86
|
+
|
|
87
|
+
Stagehand has native Browserbase integration:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { StagehandBrowser } from '@mastra/stagehand'
|
|
91
|
+
|
|
92
|
+
const browser = new StagehandBrowser({
|
|
93
|
+
env: 'BROWSERBASE',
|
|
94
|
+
apiKey: process.env.BROWSERBASE_API_KEY,
|
|
95
|
+
projectId: process.env.BROWSERBASE_PROJECT_ID,
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### CDP URL (any provider)
|
|
100
|
+
|
|
101
|
+
Connect to any browser exposing a Chrome DevTools Protocol (CDP) endpoint:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { AgentBrowser } from '@mastra/agent-browser'
|
|
105
|
+
|
|
106
|
+
const browser = new AgentBrowser({
|
|
107
|
+
cdpUrl: process.env.BROWSER_CDP_URL,
|
|
108
|
+
headless: true,
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This works with any [CDP-compatible](https://chromedevtools.github.io/devtools-protocol/) browser service.
|
|
113
|
+
|
|
114
|
+
## Screencast
|
|
115
|
+
|
|
116
|
+
Browser providers stream a live video feed of the browser to the Mastra Studio UI. This lets you watch the agent interact with pages in real-time.
|
|
117
|
+
|
|
118
|
+
Screencast is enabled by default and can be configured:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const browser = new AgentBrowser({
|
|
122
|
+
screencast: {
|
|
123
|
+
enabled: true,
|
|
124
|
+
format: 'jpeg',
|
|
125
|
+
quality: 80,
|
|
126
|
+
maxWidth: 1280,
|
|
127
|
+
maxHeight: 720,
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Next steps
|
|
133
|
+
|
|
134
|
+
- [AgentBrowser](https://mastra.ai/docs/browser/agent-browser)
|
|
135
|
+
- [Stagehand](https://mastra.ai/docs/browser/stagehand)
|
|
136
|
+
- [MastraBrowser reference](https://mastra.ai/reference/browser/mastra-browser)
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Stagehand
|
|
2
|
+
|
|
3
|
+
The `@mastra/stagehand` package provides browser automation using the [Stagehand SDK](https://docs.browserbase.com/stagehand/introduction) from Browserbase. Stagehand uses AI to understand page context and locate elements, enabling natural language descriptions instead of explicit selectors.
|
|
4
|
+
|
|
5
|
+
## When to use Stagehand
|
|
6
|
+
|
|
7
|
+
Use Stagehand when you need:
|
|
8
|
+
|
|
9
|
+
- Natural language element targeting ("select the login button")
|
|
10
|
+
- AI-powered data extraction from pages
|
|
11
|
+
- Native Browserbase cloud integration
|
|
12
|
+
- Simpler tool interface for common actions
|
|
13
|
+
|
|
14
|
+
## Quickstart
|
|
15
|
+
|
|
16
|
+
Install the package:
|
|
17
|
+
|
|
18
|
+
**npm**:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @mastra/stagehand
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**pnpm**:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pnpm add @mastra/stagehand
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Yarn**:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
yarn add @mastra/stagehand
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Bun**:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
bun add @mastra/stagehand
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Create a browser instance and assign it to an agent:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { Agent } from '@mastra/core/agent'
|
|
46
|
+
import { StagehandBrowser } from '@mastra/stagehand'
|
|
47
|
+
|
|
48
|
+
const browser = new StagehandBrowser({
|
|
49
|
+
headless: false,
|
|
50
|
+
model: 'openai/gpt-5.4',
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
export const stagehandAgent = new Agent({
|
|
54
|
+
id: 'stagehand-agent',
|
|
55
|
+
model: 'openai/gpt-5.4',
|
|
56
|
+
browser,
|
|
57
|
+
instructions: `You are a web automation assistant.
|
|
58
|
+
|
|
59
|
+
Use stagehand tools to interact with pages:
|
|
60
|
+
- stagehand_navigate to go to URLs
|
|
61
|
+
- stagehand_act to perform actions described in natural language
|
|
62
|
+
- stagehand_extract to get structured data from the page
|
|
63
|
+
- stagehand_observe to find available actions on the page`,
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Natural language actions
|
|
68
|
+
|
|
69
|
+
When the agent uses the `stagehand_act` tool, it accepts natural language descriptions of actions:
|
|
70
|
+
|
|
71
|
+
- "Press the Sign In button"
|
|
72
|
+
- "Type `'[user@example.com](mailto:user@example.com)'` in the email field"
|
|
73
|
+
- "Select 'United States' from the country dropdown"
|
|
74
|
+
|
|
75
|
+
Stagehand's AI interprets the action and finds the appropriate element on the page.
|
|
76
|
+
|
|
77
|
+
## Data extraction
|
|
78
|
+
|
|
79
|
+
When the agent uses the `stagehand_extract` tool, it can pull structured data from pages.
|
|
80
|
+
|
|
81
|
+
Example instruction: "Extract the product name, price, and availability"
|
|
82
|
+
|
|
83
|
+
The tool returns structured data based on page content:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"name": "Widget Pro",
|
|
88
|
+
"price": "$29.99",
|
|
89
|
+
"availability": "In Stock"
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Observing actions
|
|
94
|
+
|
|
95
|
+
When the agent uses the `stagehand_observe` tool, it analyzes the current page and returns possible actions.
|
|
96
|
+
|
|
97
|
+
Example instruction: "What actions can I take on this login form?"
|
|
98
|
+
|
|
99
|
+
Returns a list of available actions:
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
[
|
|
103
|
+
{ "action": "Press 'Sign In' button", "element": "button" },
|
|
104
|
+
{ "action": "Type in 'Email' field", "element": "input" },
|
|
105
|
+
{ "action": "Open 'Forgot Password' link", "element": "a" }
|
|
106
|
+
]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Browserbase
|
|
110
|
+
|
|
111
|
+
Stagehand has native Browserbase integration for cloud browser infrastructure:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
const browser = new StagehandBrowser({
|
|
115
|
+
env: 'BROWSERBASE',
|
|
116
|
+
apiKey: process.env.BROWSERBASE_API_KEY,
|
|
117
|
+
projectId: process.env.BROWSERBASE_PROJECT_ID,
|
|
118
|
+
model: 'openai/gpt-5.4',
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
> **Note:** See [StagehandBrowser reference](https://mastra.ai/reference/browser/stagehand-browser) for all configuration options.
|
|
123
|
+
|
|
124
|
+
## Related
|
|
125
|
+
|
|
126
|
+
- [Browser overview](https://mastra.ai/docs/browser/overview)
|
|
127
|
+
- [AgentBrowser](https://mastra.ai/docs/browser/agent-browser)
|
|
128
|
+
- [StagehandBrowser reference](https://mastra.ai/reference/browser/stagehand-browser)
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Arthur exporter
|
|
2
|
+
|
|
3
|
+
[Arthur](https://arthur.ai/) provides an observability and evaluation platform for AI applications through [Arthur Engine](https://github.com/arthur-ai/arthur-engine) (open-source). The Arthur exporter sends traces using OpenTelemetry and [OpenInference](https://github.com/Arize-ai/openinference/tree/main/spec) semantic conventions.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
**npm**:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @mastra/arthur@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**pnpm**:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @mastra/arthur@latest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Yarn**:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
yarn add @mastra/arthur@latest
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Bun**:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
bun add @mastra/arthur@latest
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
### Prerequisites
|
|
34
|
+
|
|
35
|
+
1. **Arthur Engine instance**: Follow the [Docker Compose deployment guide](https://docs.arthur.ai/docs/arthur-genai-engine-docker-compose-deployment-guide) to start an Arthur Engine
|
|
36
|
+
2. **API key**: [Generate an API key](https://docs.arthur.ai/docs/api-keys-management) from the Arthur Engine UI at `http://localhost:3030`
|
|
37
|
+
3. **Task ID** (optional): [Create a task](https://docs.arthur.ai/docs/create-a-task) to route traces to a specific task
|
|
38
|
+
|
|
39
|
+
### Task routing
|
|
40
|
+
|
|
41
|
+
Arthur Engine associates traces with tasks in two ways:
|
|
42
|
+
|
|
43
|
+
- **By service name**: Set `serviceName` in the observability config. Arthur Engine automatically routes traces to the task matching that name, creating it if needed.
|
|
44
|
+
- **By task ID**: Pass a pre-existing `taskId` to the exporter to send traces to a specific task directly.
|
|
45
|
+
|
|
46
|
+
If both are provided, `taskId` takes precedence.
|
|
47
|
+
|
|
48
|
+
### Environment variables
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Required
|
|
52
|
+
ARTHUR_API_KEY=your-api-key
|
|
53
|
+
ARTHUR_BASE_URL=http://localhost:3030
|
|
54
|
+
|
|
55
|
+
# Optional - route traces to a pre-existing task by ID
|
|
56
|
+
ARTHUR_TASK_ID=your-task-id
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Zero-Config Setup
|
|
60
|
+
|
|
61
|
+
With environment variables set, use the exporter with no configuration:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { Mastra } from '@mastra/core'
|
|
65
|
+
import { Observability } from '@mastra/observability'
|
|
66
|
+
import { ArthurExporter } from '@mastra/arthur'
|
|
67
|
+
|
|
68
|
+
export const mastra = new Mastra({
|
|
69
|
+
observability: new Observability({
|
|
70
|
+
configs: {
|
|
71
|
+
arthur: {
|
|
72
|
+
serviceName: 'my-service',
|
|
73
|
+
exporters: [new ArthurExporter()],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Explicit Configuration
|
|
81
|
+
|
|
82
|
+
You can also pass credentials directly (takes precedence over environment variables):
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { Mastra } from '@mastra/core'
|
|
86
|
+
import { Observability } from '@mastra/observability'
|
|
87
|
+
import { ArthurExporter } from '@mastra/arthur'
|
|
88
|
+
|
|
89
|
+
export const mastra = new Mastra({
|
|
90
|
+
observability: new Observability({
|
|
91
|
+
configs: {
|
|
92
|
+
arthur: {
|
|
93
|
+
serviceName: 'my-service',
|
|
94
|
+
exporters: [
|
|
95
|
+
new ArthurExporter({
|
|
96
|
+
apiKey: process.env.ARTHUR_API_KEY!,
|
|
97
|
+
endpoint: process.env.ARTHUR_BASE_URL!,
|
|
98
|
+
taskId: process.env.ARTHUR_TASK_ID,
|
|
99
|
+
}),
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
}),
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Configuration options
|
|
108
|
+
|
|
109
|
+
### Complete Configuration
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
new ArthurExporter({
|
|
113
|
+
// Arthur Configuration
|
|
114
|
+
apiKey: 'your-api-key', // Required
|
|
115
|
+
endpoint: 'http://localhost:3030', // Required
|
|
116
|
+
taskId: 'your-task-id', // Optional
|
|
117
|
+
|
|
118
|
+
// Optional OTLP settings
|
|
119
|
+
headers: {
|
|
120
|
+
'x-custom-header': 'value', // Additional headers for OTLP requests
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
// Debug and performance tuning
|
|
124
|
+
logLevel: 'debug', // Logging: debug | info | warn | error
|
|
125
|
+
batchSize: 512, // Batch size before exporting spans
|
|
126
|
+
timeout: 30000, // Timeout in ms before exporting spans
|
|
127
|
+
|
|
128
|
+
// Custom resource attributes
|
|
129
|
+
resourceAttributes: {
|
|
130
|
+
'deployment.environment': process.env.NODE_ENV,
|
|
131
|
+
'service.version': process.env.APP_VERSION,
|
|
132
|
+
},
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Custom metadata
|
|
137
|
+
|
|
138
|
+
Non-reserved span attributes are serialized into the OpenInference `metadata` payload and surface in Arthur. You can add them via `tracingOptions.metadata`:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
await agent.generate(input, {
|
|
142
|
+
tracingOptions: {
|
|
143
|
+
metadata: {
|
|
144
|
+
companyId: 'acme-co',
|
|
145
|
+
tier: 'enterprise',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Reserved fields such as `input`, `output`, `sessionId`, thread/user IDs, and OpenInference IDs are excluded automatically.
|
|
152
|
+
|
|
153
|
+
## OpenInference semantic conventions
|
|
154
|
+
|
|
155
|
+
This exporter implements the [OpenInference Semantic Conventions](https://github.com/Arize-ai/openinference/tree/main/spec) for generative AI applications, providing standardized trace structure across different observability platforms.
|
|
156
|
+
|
|
157
|
+
## Related
|
|
158
|
+
|
|
159
|
+
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
160
|
+
- [ArthurExporter reference](https://mastra.ai/reference/observability/tracing/exporters/arthur)
|
|
161
|
+
- [Arthur Engine documentation](https://docs.arthur.ai/)
|
|
162
|
+
- [Arthur Engine repository](https://github.com/arthur-ai/arthur-engine)
|
|
163
|
+
- [OpenInference Specification](https://github.com/Arize-ai/openinference/tree/main/spec)
|
|
@@ -82,9 +82,8 @@ export const mastra = new Mastra({
|
|
|
82
82
|
publicKey: process.env.LANGFUSE_PUBLIC_KEY!,
|
|
83
83
|
secretKey: process.env.LANGFUSE_SECRET_KEY!,
|
|
84
84
|
baseUrl: process.env.LANGFUSE_BASE_URL,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
},
|
|
85
|
+
environment: process.env.NODE_ENV,
|
|
86
|
+
release: process.env.GIT_COMMIT,
|
|
88
87
|
}),
|
|
89
88
|
],
|
|
90
89
|
},
|
|
@@ -136,12 +135,9 @@ new LangfuseExporter({
|
|
|
136
135
|
realtime: process.env.NODE_ENV === 'development', // Dynamic mode selection
|
|
137
136
|
logLevel: 'info', // Diagnostic logging: debug | info | warn | error
|
|
138
137
|
|
|
139
|
-
// Langfuse-specific
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
version: process.env.APP_VERSION, // Track different versions
|
|
143
|
-
release: process.env.GIT_COMMIT, // Git commit hash
|
|
144
|
-
},
|
|
138
|
+
// Langfuse-specific settings
|
|
139
|
+
environment: process.env.NODE_ENV, // Shows in Langfuse UI for filtering
|
|
140
|
+
release: process.env.GIT_COMMIT, // Git commit hash for version tracking
|
|
145
141
|
})
|
|
146
142
|
```
|
|
147
143
|
|
|
@@ -156,26 +152,26 @@ Use `withLangfusePrompt` with `buildTracingOptions` for the cleanest API:
|
|
|
156
152
|
```typescript
|
|
157
153
|
import { Agent } from '@mastra/core/agent'
|
|
158
154
|
import { buildTracingOptions } from '@mastra/observability'
|
|
159
|
-
import { withLangfusePrompt } from '@mastra/langfuse'
|
|
160
|
-
import { Langfuse } from 'langfuse'
|
|
155
|
+
import { LangfuseExporter, withLangfusePrompt } from '@mastra/langfuse'
|
|
161
156
|
|
|
162
|
-
|
|
163
|
-
const langfuse = new Langfuse()
|
|
157
|
+
const exporter = new LangfuseExporter()
|
|
164
158
|
|
|
165
|
-
// Fetch the prompt from Langfuse Prompt Management
|
|
166
|
-
const prompt = await
|
|
159
|
+
// Fetch the prompt from Langfuse Prompt Management via the client
|
|
160
|
+
const prompt = await exporter.client.prompt.get('customer-support', { type: 'text' })
|
|
167
161
|
|
|
168
162
|
export const supportAgent = new Agent({
|
|
169
163
|
name: 'support-agent',
|
|
170
|
-
instructions: prompt.
|
|
164
|
+
instructions: prompt.compile(), // Use the prompt text from Langfuse
|
|
171
165
|
model: 'openai/gpt-5.4',
|
|
172
166
|
defaultGenerateOptions: {
|
|
173
|
-
tracingOptions: buildTracingOptions(
|
|
167
|
+
tracingOptions: buildTracingOptions(
|
|
168
|
+
withLangfusePrompt({ name: prompt.name, version: prompt.version }),
|
|
169
|
+
),
|
|
174
170
|
},
|
|
175
171
|
})
|
|
176
172
|
```
|
|
177
173
|
|
|
178
|
-
The `withLangfusePrompt` helper
|
|
174
|
+
The `withLangfusePrompt` helper accepts `name` and `version` fields for prompt linking. Langfuse v5 requires both fields.
|
|
179
175
|
|
|
180
176
|
### Manual Fields
|
|
181
177
|
|
|
@@ -183,26 +179,16 @@ You can also pass manual fields if you're not using the Langfuse SDK:
|
|
|
183
179
|
|
|
184
180
|
```typescript
|
|
185
181
|
const tracingOptions = buildTracingOptions(withLangfusePrompt({ name: 'my-prompt', version: 1 }))
|
|
186
|
-
|
|
187
|
-
// Or with just an ID
|
|
188
|
-
const tracingOptions = buildTracingOptions(withLangfusePrompt({ id: 'prompt-uuid-12345' }))
|
|
189
182
|
```
|
|
190
183
|
|
|
191
184
|
### Prompt Object Fields
|
|
192
185
|
|
|
193
|
-
The prompt object
|
|
194
|
-
|
|
195
|
-
| Field | Type | Description |
|
|
196
|
-
| --------- | ------ | ---------------------------------- |
|
|
197
|
-
| `name` | string | The prompt name in Langfuse |
|
|
198
|
-
| `version` | number | The prompt version number |
|
|
199
|
-
| `id` | string | The prompt UUID for direct linking |
|
|
200
|
-
|
|
201
|
-
You can link prompts using either:
|
|
186
|
+
The prompt object requires both `name` and `version`:
|
|
202
187
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
188
|
+
| Field | Type | Description |
|
|
189
|
+
| --------- | ------ | --------------------------- |
|
|
190
|
+
| `name` | string | The prompt name in Langfuse |
|
|
191
|
+
| `version` | number | The prompt version number |
|
|
206
192
|
|
|
207
193
|
When set on a `MODEL_GENERATION` span, the Langfuse exporter automatically links the generation to the corresponding prompt.
|
|
208
194
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenRouter
|
|
2
2
|
|
|
3
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
3
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 170 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
6
6
|
|
|
@@ -45,6 +45,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
45
45
|
| `anthropic/claude-sonnet-4.5` |
|
|
46
46
|
| `anthropic/claude-sonnet-4.6` |
|
|
47
47
|
| `arcee-ai/trinity-large-preview:free` |
|
|
48
|
+
| `arcee-ai/trinity-large-thinking` |
|
|
48
49
|
| `arcee-ai/trinity-mini:free` |
|
|
49
50
|
| `black-forest-labs/flux.2-flex` |
|
|
50
51
|
| `black-forest-labs/flux.2-klein-4b` |
|
|
@@ -82,6 +83,8 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
82
83
|
| `google/gemma-3n-e2b-it:free` |
|
|
83
84
|
| `google/gemma-3n-e4b-it` |
|
|
84
85
|
| `google/gemma-3n-e4b-it:free` |
|
|
86
|
+
| `google/gemma-4-26b-a4b-it` |
|
|
87
|
+
| `google/gemma-4-31b-it` |
|
|
85
88
|
| `inception/mercury` |
|
|
86
89
|
| `inception/mercury-2` |
|
|
87
90
|
| `inception/mercury-coder` |
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 3605 models from 98 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -32,7 +32,7 @@ for await (const chunk of stream) {
|
|
|
32
32
|
|
|
33
33
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
34
34
|
| ---------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
35
|
-
| `deepseek/deepseek-chat` |
|
|
35
|
+
| `deepseek/deepseek-chat` | 131K | | | | | | $0.28 | $0.42 |
|
|
36
36
|
| `deepseek/deepseek-reasoner` | 128K | | | | | | $0.28 | $0.42 |
|
|
37
37
|
|
|
38
38
|
## Advanced configuration
|
|
@@ -67,8 +67,8 @@ for await (const chunk of stream) {
|
|
|
67
67
|
| `google/gemma-3-4b-it` | 33K | | | | | | — | — |
|
|
68
68
|
| `google/gemma-3n-e2b-it` | 8K | | | | | | — | — |
|
|
69
69
|
| `google/gemma-3n-e4b-it` | 8K | | | | | | — | — |
|
|
70
|
-
| `google/gemma-4-26b`
|
|
71
|
-
| `google/gemma-4-31b`
|
|
70
|
+
| `google/gemma-4-26b-it` | 256K | | | | | | — | — |
|
|
71
|
+
| `google/gemma-4-31b-it` | 256K | | | | | | — | — |
|
|
72
72
|
|
|
73
73
|
## Advanced configuration
|
|
74
74
|
|
|
@@ -97,7 +97,7 @@ const agent = new Agent({
|
|
|
97
97
|
model: ({ requestContext }) => {
|
|
98
98
|
const useAdvanced = requestContext.task === "complex";
|
|
99
99
|
return useAdvanced
|
|
100
|
-
? "google/gemma-4-31b"
|
|
100
|
+
? "google/gemma-4-31b-it"
|
|
101
101
|
: "google/gemini-1.5-flash";
|
|
102
102
|
}
|
|
103
103
|
});
|