@mastra/mcp-docs-server 1.2.0 → 1.2.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/goals.md +2 -2
- package/.docs/docs/harness/modes.md +2 -2
- package/.docs/docs/harness/overview.md +23 -25
- package/.docs/docs/harness/session.md +2 -2
- package/.docs/docs/harness/subagents.md +3 -3
- package/.docs/docs/harness/tool-approvals.md +2 -2
- package/.docs/guides/build-your-ui/openui.md +297 -0
- package/.docs/models/gateways/custom-gateways.md +12 -0
- package/.docs/models/gateways/netlify.md +4 -7
- package/.docs/models/gateways/openrouter.md +20 -40
- package/.docs/models/gateways/vercel.md +281 -246
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +5 -2
- package/.docs/models/providers/alibaba-coding-plan-cn.md +5 -2
- package/.docs/models/providers/alibaba-coding-plan.md +5 -2
- package/.docs/models/providers/alibaba-token-plan-cn.md +88 -0
- package/.docs/models/providers/alibaba-token-plan.md +88 -0
- package/.docs/models/providers/alibaba.md +3 -1
- package/.docs/models/providers/ambient.md +6 -5
- package/.docs/models/providers/anthropic.md +8 -11
- package/.docs/models/providers/anyapi.md +99 -0
- package/.docs/models/providers/baseten.md +19 -19
- package/.docs/models/providers/cerebras.md +5 -7
- package/.docs/models/providers/claudinio.md +3 -2
- package/.docs/models/providers/cloudflare-workers-ai.md +4 -9
- package/.docs/models/providers/cortecs.md +9 -2
- package/.docs/models/providers/crof.md +12 -10
- package/.docs/models/providers/deepinfra.md +18 -31
- package/.docs/models/providers/deepseek.md +1 -1
- package/.docs/models/providers/digitalocean.md +5 -1
- package/.docs/models/providers/fastrouter.md +34 -2
- package/.docs/models/providers/fireworks-ai.md +22 -27
- package/.docs/models/providers/freemodel.md +108 -0
- package/.docs/models/providers/google.md +7 -9
- package/.docs/models/providers/groq.md +7 -9
- package/.docs/models/providers/helicone.md +1 -1
- package/.docs/models/providers/hpc-ai.md +3 -3
- package/.docs/models/providers/huggingface.md +1 -1
- package/.docs/models/providers/kilo.md +9 -8
- package/.docs/models/providers/kimi-for-coding.md +4 -3
- package/.docs/models/providers/llmgateway.md +38 -29
- package/.docs/models/providers/llmtr.md +76 -0
- package/.docs/models/providers/lucidquery.md +11 -9
- package/.docs/models/providers/minimax-cn-coding-plan.md +3 -2
- package/.docs/models/providers/minimax-cn.md +3 -2
- package/.docs/models/providers/minimax-coding-plan.md +3 -2
- package/.docs/models/providers/minimax.md +3 -2
- package/.docs/models/providers/mistral.md +25 -31
- package/.docs/models/providers/moonshotai-cn.md +13 -11
- package/.docs/models/providers/moonshotai.md +13 -11
- package/.docs/models/providers/nano-gpt.md +621 -529
- package/.docs/models/providers/nearai.md +5 -1
- package/.docs/models/providers/nebius.md +2 -15
- package/.docs/models/providers/neon.md +96 -0
- package/.docs/models/providers/neuralwatt.md +19 -20
- package/.docs/models/providers/novita-ai.md +7 -2
- package/.docs/models/providers/nvidia.md +5 -14
- package/.docs/models/providers/ollama-cloud.md +8 -12
- package/.docs/models/providers/openai.md +2 -3
- package/.docs/models/providers/opencode-go.md +10 -9
- package/.docs/models/providers/opencode.md +7 -2
- package/.docs/models/providers/ovhcloud.md +7 -3
- package/.docs/models/providers/poe.md +2 -1
- package/.docs/models/providers/poolside.md +72 -0
- package/.docs/models/providers/routing-run.md +5 -3
- package/.docs/models/providers/scaleway.md +3 -5
- package/.docs/models/providers/siliconflow-cn.md +4 -11
- package/.docs/models/providers/siliconflow.md +7 -13
- package/.docs/models/providers/snowflake-cortex.md +89 -0
- package/.docs/models/providers/stepfun-ai.md +5 -5
- package/.docs/models/providers/stepfun.md +1 -1
- package/.docs/models/providers/synthetic.md +2 -1
- package/.docs/models/providers/togetherai.md +30 -24
- package/.docs/models/providers/umans-ai-coding-plan.md +3 -2
- package/.docs/models/providers/umans-ai.md +75 -0
- package/.docs/models/providers/vivgrid.md +1 -1
- package/.docs/models/providers/vultr.md +14 -12
- package/.docs/models/providers/wafer.ai.md +9 -4
- package/.docs/models/providers/xai.md +3 -3
- package/.docs/models/providers/xiaomi-token-plan-ams.md +15 -13
- package/.docs/models/providers/xiaomi-token-plan-cn.md +15 -13
- package/.docs/models/providers/xiaomi-token-plan-sgp.md +15 -13
- package/.docs/models/providers/xiaomi.md +10 -9
- package/.docs/models/providers/xpersona.md +4 -3
- package/.docs/models/providers/zai-coding-plan.md +2 -1
- package/.docs/models/providers/zai.md +2 -1
- package/.docs/models/providers/zeldoc.md +71 -0
- package/.docs/models/providers/zenmux.md +19 -3
- package/.docs/models/providers/zhipuai-coding-plan.md +3 -1
- package/.docs/models/providers/zhipuai.md +2 -1
- package/.docs/models/providers.md +12 -3
- package/.docs/reference/agents/agent.md +18 -5
- package/.docs/reference/harness/harness-class.md +3 -137
- package/.docs/reference/harness/session.md +128 -2
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/tools/mcp-client.md +11 -0
- package/.docs/reference/voice/google-gemini-live.md +22 -0
- package/.docs/reference/workspace/archil-filesystem.md +203 -0
- package/.docs/reference/workspace/gcs-filesystem.md +1 -0
- package/.docs/reference/workspace/s3-filesystem.md +1 -0
- package/CHANGELOG.md +15 -0
- package/package.json +5 -5
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
**Added in:** `@mastra/core@1.42.0`
|
|
4
4
|
|
|
5
|
+
> **Alpha:** The Goals feature is in alpha stage and subject to breaking changes in minor versions until it graduates from its alpha status.
|
|
6
|
+
|
|
5
7
|
A goal is a durable, thread-scoped objective: a standing instruction the agent keeps working toward across loop iterations until a judge model decides it is satisfied or a run budget is exhausted. The objective is persisted in thread state, so it survives reloads and is evaluated in-loop — even when a new message arrives in the middle of an already-running turn.
|
|
6
8
|
|
|
7
9
|
Goals build on the same machinery as [`isTaskComplete`](https://mastra.ai/docs/agents/supervisor-agents): an LLM-as-judge scores the agent's output each iteration and gates the loop. The difference is that a goal is **durable** (stored in thread state, not passed per call) and is set and updated through `Agent` methods rather than per-`stream()` options.
|
|
8
10
|
|
|
9
|
-
> **Note:** Goals are experimental and may change in a future release.
|
|
10
|
-
|
|
11
11
|
## When to use goals
|
|
12
12
|
|
|
13
13
|
Use a goal when you want an agent to keep working toward a single objective across many iterations and messages, without re-supplying the success criteria on every call:
|
|
@@ -96,10 +96,10 @@ On plan approval, the Harness automatically switches to `build` mode. On rejecti
|
|
|
96
96
|
|
|
97
97
|
## Switching modes
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
The active mode lives on the Session, so call `harness.session.mode.switch()` to change it. The switch aborts any in-progress generation, saves the current model to the outgoing mode, and emits a `mode_changed` event. It then resolves the incoming mode's model and, when one resolves, applies it and emits a `model_changed` event:
|
|
100
100
|
|
|
101
101
|
```typescript
|
|
102
|
-
await harness.
|
|
102
|
+
await harness.session.mode.switch({ modeId: 'build' })
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
## Querying modes
|
|
@@ -92,33 +92,31 @@ await harness.sendMessage({ content: 'Hello!' })
|
|
|
92
92
|
The Harness sits between your application layer and the underlying agent loop:
|
|
93
93
|
|
|
94
94
|
```text
|
|
95
|
-
|
|
96
|
-
│
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
│
|
|
102
|
-
│
|
|
103
|
-
│
|
|
104
|
-
│
|
|
105
|
-
│
|
|
106
|
-
│
|
|
107
|
-
│
|
|
108
|
-
│ │
|
|
109
|
-
│ │
|
|
110
|
-
│ │
|
|
111
|
-
|
|
112
|
-
│
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
│ Agent + Memory + Tools │
|
|
118
|
-
└───────────────────────────┘
|
|
95
|
+
┌───────────────────────────────────────┐
|
|
96
|
+
│ Your App (TUI/Web/API) │
|
|
97
|
+
└───────────────────────────────────────┘
|
|
98
|
+
│ commands ▲ events
|
|
99
|
+
▼ │
|
|
100
|
+
┌───────────────────────────────────────┐
|
|
101
|
+
│ Harness │
|
|
102
|
+
│ Config · storage · threads │
|
|
103
|
+
│ permissions · subagents · events │
|
|
104
|
+
│ │
|
|
105
|
+
│ ┌─────────────────────────────────┐ │
|
|
106
|
+
│ │ harness.session │ │
|
|
107
|
+
│ │ identity · thread · mode │ │
|
|
108
|
+
│ │ model · run · grants │ │
|
|
109
|
+
│ │ display state │ │
|
|
110
|
+
│ └─────────────────────────────────┘ │
|
|
111
|
+
└───────────────────────────────────────┘
|
|
112
|
+
│
|
|
113
|
+
▼
|
|
114
|
+
┌───────────────────────────────────────┐
|
|
115
|
+
│ Agent + Memory + Tools │
|
|
116
|
+
└───────────────────────────────────────┘
|
|
119
117
|
```
|
|
120
118
|
|
|
121
|
-
Your app sends commands
|
|
119
|
+
Your app sends commands — send a message, switch mode, approve a tool call — and receives typed events such as `message_update` and `tool_approval_required`. The Harness manages the lifecycle internally: persisting threads, routing to the correct mode agent, enforcing permissions, and emitting events as state changes.
|
|
122
120
|
|
|
123
121
|
## Next steps
|
|
124
122
|
|
|
@@ -48,8 +48,8 @@ See [Threads and state](https://mastra.ai/docs/harness/threads-and-state) for th
|
|
|
48
48
|
The Harness defines the available modes in `config.modes`. The Session tracks which mode and model are _currently_ selected:
|
|
49
49
|
|
|
50
50
|
```typescript
|
|
51
|
-
// Switch mode (
|
|
52
|
-
await harness.
|
|
51
|
+
// Switch mode (aborts the run, emits events)
|
|
52
|
+
await harness.session.mode.switch({ modeId: 'build' })
|
|
53
53
|
|
|
54
54
|
// Read the current selection (Session state)
|
|
55
55
|
const modeId = harness.session.mode.get()
|
|
@@ -85,16 +85,16 @@ Set a global or per-type subagent model at runtime:
|
|
|
85
85
|
|
|
86
86
|
```typescript
|
|
87
87
|
// Global subagent model
|
|
88
|
-
await harness.
|
|
88
|
+
await harness.session.subagents.model.set({ modelId: 'anthropic/claude-sonnet-4-6' })
|
|
89
89
|
|
|
90
90
|
// Per-type override
|
|
91
|
-
await harness.
|
|
91
|
+
await harness.session.subagents.model.set({
|
|
92
92
|
modelId: 'anthropic/claude-haiku-4-5',
|
|
93
93
|
agentType: 'explore',
|
|
94
94
|
})
|
|
95
95
|
|
|
96
96
|
// Read current model
|
|
97
|
-
const modelId = harness.
|
|
97
|
+
const modelId = harness.session.subagents.model.get({ agentType: 'explore' })
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
## Related
|
|
@@ -16,10 +16,10 @@ Set policies per-category or per-tool. Per-tool policies take precedence over ca
|
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
// Category-level: all execute tools require approval
|
|
19
|
-
harness.
|
|
19
|
+
await harness.session.permissions.setForCategory({ category: 'execute', policy: 'ask' })
|
|
20
20
|
|
|
21
21
|
// Tool-level: this specific tool is always blocked
|
|
22
|
-
harness.
|
|
22
|
+
await harness.session.permissions.setForTool({ toolName: 'dangerous_tool', policy: 'deny' })
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
### Tool categories
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# Using OpenUI
|
|
2
|
+
|
|
3
|
+
[OpenUI](https://openui.com) is an open standard for generative UI. It pairs a compact streaming-first language (OpenUI Lang) with a React runtime and built-in component libraries, so model output can render as structured UI as it streams.
|
|
4
|
+
|
|
5
|
+
OpenUI connects to Mastra through the [AG-UI protocol](https://docs.ag-ui.com). The `@ag-ui/mastra` adapter wraps a Mastra `Agent` and emits AG-UI events, which OpenUI's `agUIAdapter()` parses on the client.
|
|
6
|
+
|
|
7
|
+
> **Tip:** For a complete working example, see the [`mastra-chat`](https://github.com/thesysdev/openui/tree/main/examples/mastra-chat) example in the OpenUI repository.
|
|
8
|
+
|
|
9
|
+
## Integration guide
|
|
10
|
+
|
|
11
|
+
Embed Mastra in your Next.js API route and connect an OpenUI `<FullScreen />` chat surface to it through the AG-UI protocol.
|
|
12
|
+
|
|
13
|
+
1. Scaffold a new OpenUI app:
|
|
14
|
+
|
|
15
|
+
**npm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx @openuidev/cli@latest create --name openui-mastra-chat
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**pnpm**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm dlx @openuidev/cli@latest create --name openui-mastra-chat
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Yarn**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn dlx @openuidev/cli@latest create --name openui-mastra-chat
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Bun**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bun x @openuidev/cli@latest create --name openui-mastra-chat
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Navigate to your newly created project directory:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
cd openui-mastra-chat
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The scaffolded app is a Next.js project with the following structure:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
openui-mastra-chat
|
|
49
|
+
└── src
|
|
50
|
+
├── app
|
|
51
|
+
│ ├── api
|
|
52
|
+
│ │ └── chat
|
|
53
|
+
│ │ └── route.ts
|
|
54
|
+
│ ├── globals.css
|
|
55
|
+
│ ├── layout.tsx
|
|
56
|
+
│ └── page.tsx
|
|
57
|
+
├── generated
|
|
58
|
+
│ └── system-prompt.txt
|
|
59
|
+
└── library.ts
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The chat route lives in `src/app/api/chat/route.ts`, the chat surface in `src/app/page.tsx`, and the component library in `src/library.ts`. The OpenUI CLI writes `src/generated/system-prompt.txt` from your library; regenerate it whenever the library changes.
|
|
63
|
+
|
|
64
|
+
Add your OpenAI key to `.env.local`:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
OPENAI_API_KEY=sk-...
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
> **Note:** OpenUI requires a model provider key. Use any provider supported by Mastra and adjust the agent configuration in the next step.
|
|
71
|
+
|
|
72
|
+
2. Install the Mastra packages and the AG-UI adapter for Mastra:
|
|
73
|
+
|
|
74
|
+
**npm**:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install @mastra/core @ag-ui/mastra @ag-ui/core zod
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**pnpm**:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pnpm add @mastra/core @ag-ui/mastra @ag-ui/core zod
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Yarn**:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
yarn add @mastra/core @ag-ui/mastra @ag-ui/core zod
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Bun**:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
bun add @mastra/core @ag-ui/mastra @ag-ui/core zod
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`@ag-ui/mastra` wraps a Mastra `Agent` in a `MastraAgent` that emits [AG-UI protocol](https://docs.ag-ui.com) events. OpenUI's `agUIAdapter()` consumes those events on the client.
|
|
99
|
+
|
|
100
|
+
3. Open `src/app/api/chat/route.ts`. Define any tools your agent needs with `createTool` from `@mastra/core/tools`:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { createTool } from '@mastra/core/tools'
|
|
104
|
+
import { z } from 'zod'
|
|
105
|
+
|
|
106
|
+
const getWeather = createTool({
|
|
107
|
+
id: 'get_weather',
|
|
108
|
+
description: 'Get current weather for a city.',
|
|
109
|
+
inputSchema: z.object({ location: z.string().describe('City name') }),
|
|
110
|
+
execute: async ({ location }) => {
|
|
111
|
+
return { location, temperature_celsius: 22, condition: 'Clear' }
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Wrap a Mastra `Agent` in `MastraAgent`. Inject the generated system prompt so the agent knows how to use the OpenUI component library:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { MastraAgent } from '@ag-ui/mastra'
|
|
120
|
+
import { Agent } from '@mastra/core/agent'
|
|
121
|
+
import { readFileSync } from 'fs'
|
|
122
|
+
import { join } from 'path'
|
|
123
|
+
|
|
124
|
+
const systemPrompt = readFileSync(join(process.cwd(), 'src/generated/system-prompt.txt'), 'utf-8')
|
|
125
|
+
|
|
126
|
+
const agent = new MastraAgent({
|
|
127
|
+
agent: new Agent({
|
|
128
|
+
id: 'openui-agent',
|
|
129
|
+
name: 'OpenUI Agent',
|
|
130
|
+
instructions: `You are a helpful assistant. Use tools when relevant.\n\n${systemPrompt}`,
|
|
131
|
+
model: {
|
|
132
|
+
id: 'openai/gpt-5.5',
|
|
133
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
134
|
+
},
|
|
135
|
+
tools: { getWeather },
|
|
136
|
+
}),
|
|
137
|
+
resourceId: 'chat-user',
|
|
138
|
+
})
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Export a `POST` handler that streams the agent's AG-UI events as Server-Sent Events (SSE):
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import type { Message } from '@ag-ui/core'
|
|
145
|
+
import { NextRequest } from 'next/server'
|
|
146
|
+
|
|
147
|
+
export async function POST(req: NextRequest) {
|
|
148
|
+
const { messages, threadId }: { messages: Message[]; threadId: string } = await req.json()
|
|
149
|
+
const encoder = new TextEncoder()
|
|
150
|
+
|
|
151
|
+
const stream = new ReadableStream({
|
|
152
|
+
start(controller) {
|
|
153
|
+
const subscription = agent
|
|
154
|
+
.run({ messages, threadId, runId: crypto.randomUUID(), tools: [], context: [] })
|
|
155
|
+
.subscribe({
|
|
156
|
+
next: event => {
|
|
157
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify(event)}\n\n`))
|
|
158
|
+
},
|
|
159
|
+
complete: () => {
|
|
160
|
+
controller.enqueue(encoder.encode('data: [DONE]\n\n'))
|
|
161
|
+
controller.close()
|
|
162
|
+
},
|
|
163
|
+
error: error => {
|
|
164
|
+
controller.enqueue(
|
|
165
|
+
encoder.encode(`data: ${JSON.stringify({ error: error.message })}\n\n`),
|
|
166
|
+
)
|
|
167
|
+
controller.close()
|
|
168
|
+
},
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
req.signal.addEventListener('abort', () => subscription.unsubscribe())
|
|
172
|
+
},
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
return new Response(stream, {
|
|
176
|
+
headers: {
|
|
177
|
+
'Content-Type': 'text/event-stream',
|
|
178
|
+
'Cache-Control': 'no-cache, no-transform',
|
|
179
|
+
Connection: 'keep-alive',
|
|
180
|
+
},
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
4. Wire the OpenUI `<FullScreen />` chat surface to the route. Set `streamProtocol` to `agUIAdapter()` so OpenUI knows to parse AG-UI events.
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
'use client'
|
|
189
|
+
|
|
190
|
+
import '@openuidev/react-ui/components.css'
|
|
191
|
+
|
|
192
|
+
import { agUIAdapter } from '@openuidev/react-headless'
|
|
193
|
+
import { FullScreen } from '@openuidev/react-ui'
|
|
194
|
+
import { openuiChatLibrary } from '@openuidev/react-ui/genui-lib'
|
|
195
|
+
|
|
196
|
+
export default function Page() {
|
|
197
|
+
return (
|
|
198
|
+
<div className="relative h-screen w-screen overflow-hidden">
|
|
199
|
+
<FullScreen
|
|
200
|
+
processMessage={async ({ messages, threadId, abortController }) => {
|
|
201
|
+
return fetch('/api/chat', {
|
|
202
|
+
method: 'POST',
|
|
203
|
+
headers: { 'Content-Type': 'application/json' },
|
|
204
|
+
body: JSON.stringify({ messages, threadId }),
|
|
205
|
+
signal: abortController.signal,
|
|
206
|
+
})
|
|
207
|
+
}}
|
|
208
|
+
streamProtocol={agUIAdapter()}
|
|
209
|
+
componentLibrary={openuiChatLibrary}
|
|
210
|
+
agentName="OpenUI + Mastra Chat"
|
|
211
|
+
/>
|
|
212
|
+
</div>
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The `componentLibrary` prop controls which components the model can generate. Replace `openuiChatLibrary` with your own library to restrict or extend the output.
|
|
218
|
+
|
|
219
|
+
5. Start the development server:
|
|
220
|
+
|
|
221
|
+
**npm**:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
npm run dev
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**pnpm**:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
pnpm run dev
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Yarn**:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
yarn dev
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Bun**:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
bun run dev
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Open <http://localhost:3000>. You can now chat with your Mastra agent through the OpenUI chat surface, with structured UI rendered progressively as the model streams.
|
|
246
|
+
|
|
247
|
+
## Streaming with AG-UI
|
|
248
|
+
|
|
249
|
+
OpenUI consumes the [AG-UI protocol](https://docs.ag-ui.com), a transport-agnostic stream of typed events for AI agents. `@ag-ui/mastra` translates a Mastra `Agent` into this protocol:
|
|
250
|
+
|
|
251
|
+
- The server calls `agent.run({ messages, threadId, runId, ... })` and serializes each emitted event as an SSE message.
|
|
252
|
+
- The client passes `streamProtocol={agUIAdapter()}` to `<FullScreen />`, which parses the SSE stream into the internal events that drive OpenUI Lang rendering.
|
|
253
|
+
|
|
254
|
+
`threadId` ties a conversation together across requests, and `runId` identifies a single execution. Generate a fresh `runId` per request and persist `threadId` on the client.
|
|
255
|
+
|
|
256
|
+
## Component libraries
|
|
257
|
+
|
|
258
|
+
OpenUI generates UI from a component library. The library defines which components are available, their props, and how the model is instructed to use them.
|
|
259
|
+
|
|
260
|
+
### Built-in libraries
|
|
261
|
+
|
|
262
|
+
`@openuidev/react-ui` ships two libraries you can use as-is:
|
|
263
|
+
|
|
264
|
+
- `openuiChatLibrary`: components for chat interfaces (cards, forms, tables, charts).
|
|
265
|
+
- `openuiDashboardLibrary`: components for dashboards and data-heavy surfaces.
|
|
266
|
+
|
|
267
|
+
Pass the library to `<FullScreen componentLibrary={...} />` to make its components available to the model.
|
|
268
|
+
|
|
269
|
+
### Customizing the library
|
|
270
|
+
|
|
271
|
+
To restrict or extend the output, define your own library in `src/library.ts` and export a subset of components. Pass that library to `<FullScreen />` and regenerate the system prompt whenever the library changes:
|
|
272
|
+
|
|
273
|
+
**npm**:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
npx @openuidev/cli generate src/library.ts --out src/generated/system-prompt.txt
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**pnpm**:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
pnpm dlx @openuidev/cli generate src/library.ts --out src/generated/system-prompt.txt
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Yarn**:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
yarn dlx @openuidev/cli generate src/library.ts --out src/generated/system-prompt.txt
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Bun**:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
bun x @openuidev/cli generate src/library.ts --out src/generated/system-prompt.txt
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
The generated prompt is read by the API route and merged into the agent's `instructions`, so the agent knows exactly which components it can emit.
|
|
@@ -585,6 +585,18 @@ describe('MyPrivateGateway', () => {
|
|
|
585
585
|
|
|
586
586
|
8. **Test thoroughly**: Write unit tests for all gateway methods
|
|
587
587
|
|
|
588
|
+
## Showing only custom gateways in Studio
|
|
589
|
+
|
|
590
|
+
By default, **Studio** lists every external model provider (such as OpenAI, Anthropic, and Gemini) alongside any custom gateways you register. To hide the external providers, set the `AUTO_BLOCK_EXTERNAL_PROVIDERS` environment variable:
|
|
591
|
+
|
|
592
|
+
```bash
|
|
593
|
+
AUTO_BLOCK_EXTERNAL_PROVIDERS=true
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
When this variable is set to `true` or `1`, Mastra returns only the providers from gateways you register yourself. The static provider registry and the built-in gateways (`models.dev`, `netlify`, and `mastra`) are hidden from the model picker. This is useful when you route all model traffic through a single private gateway and don't want the other providers to appear.
|
|
597
|
+
|
|
598
|
+
With this variable set and no custom gateway registered, the model picker is empty. Register at least one custom gateway to expose its models.
|
|
599
|
+
|
|
588
600
|
## Built-in Gateways
|
|
589
601
|
|
|
590
602
|
Mastra includes built-in gateways as reference implementations:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Netlify
|
|
2
2
|
|
|
3
|
-
Netlify AI Gateway provides unified access to multiple providers with built-in caching and observability. Access
|
|
3
|
+
Netlify AI Gateway provides unified access to multiple providers with built-in caching and observability. Access 66 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Netlify documentation](https://docs.netlify.com/build/ai-gateway/overview/).
|
|
6
6
|
|
|
@@ -38,27 +38,24 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
38
38
|
| `anthropic/claude-haiku-4-5` |
|
|
39
39
|
| `anthropic/claude-haiku-4-5-20251001` |
|
|
40
40
|
| `anthropic/claude-opus-4-1-20250805` |
|
|
41
|
-
| `anthropic/claude-opus-4-20250514` |
|
|
42
41
|
| `anthropic/claude-opus-4-5` |
|
|
43
42
|
| `anthropic/claude-opus-4-5-20251101` |
|
|
44
43
|
| `anthropic/claude-opus-4-6` |
|
|
45
44
|
| `anthropic/claude-opus-4-7` |
|
|
46
|
-
| `anthropic/claude-
|
|
47
|
-
| `anthropic/claude-sonnet-4-20250514` |
|
|
45
|
+
| `anthropic/claude-opus-4-8` |
|
|
48
46
|
| `anthropic/claude-sonnet-4-5` |
|
|
49
47
|
| `anthropic/claude-sonnet-4-5-20250929` |
|
|
50
48
|
| `anthropic/claude-sonnet-4-6` |
|
|
51
|
-
| `gemini/gemini-2.0-flash` |
|
|
52
|
-
| `gemini/gemini-2.0-flash-lite` |
|
|
53
49
|
| `gemini/gemini-2.5-flash` |
|
|
54
50
|
| `gemini/gemini-2.5-flash-image` |
|
|
55
51
|
| `gemini/gemini-2.5-flash-lite` |
|
|
56
52
|
| `gemini/gemini-2.5-pro` |
|
|
57
53
|
| `gemini/gemini-3-flash-preview` |
|
|
54
|
+
| `gemini/gemini-3-pro-image` |
|
|
58
55
|
| `gemini/gemini-3-pro-image-preview` |
|
|
56
|
+
| `gemini/gemini-3.1-flash-image` |
|
|
59
57
|
| `gemini/gemini-3.1-flash-image-preview` |
|
|
60
58
|
| `gemini/gemini-3.1-flash-lite` |
|
|
61
|
-
| `gemini/gemini-3.1-flash-lite-preview` |
|
|
62
59
|
| `gemini/gemini-3.1-pro-preview` |
|
|
63
60
|
| `gemini/gemini-3.1-pro-preview-customtools` |
|
|
64
61
|
| `gemini/gemini-3.5-flash` |
|