@mastra/mcp-docs-server 1.2.5-alpha.1 → 1.2.5-alpha.5
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/deploying.md +1 -1
- package/.docs/docs/agent-controller/overview.md +1 -1
- package/.docs/docs/agent-controller/session.md +1 -1
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/processors.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +3 -3
- package/.docs/docs/agents/using-tools.md +1 -1
- package/.docs/docs/{agents → long-running-agents}/background-tasks.md +2 -2
- package/.docs/docs/{agents → long-running-agents}/durable-agents.md +2 -2
- package/.docs/docs/{agents → long-running-agents}/goals.md +1 -1
- package/.docs/docs/{agents → long-running-agents}/heartbeats.md +5 -5
- package/.docs/docs/{agents → long-running-agents}/signal-providers.md +4 -4
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/config.md +1 -2
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/voice/overview.md +3 -3
- package/.docs/docs/voice/speech-to-speech.md +81 -1
- package/.docs/docs/voice/speech-to-text.md +19 -1
- package/.docs/docs/voice/text-to-speech.md +21 -1
- package/.docs/docs/workflows/control-flow.md +1 -1
- package/.docs/docs/workflows/error-handling.md +1 -1
- package/.docs/docs/workflows/human-in-the-loop.md +1 -1
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workflows/suspend-and-resume.md +1 -1
- package/.docs/docs/workflows/time-travel.md +1 -1
- package/.docs/docs/workflows/workflow-state.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/channels.md +76 -0
- package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +174 -0
- package/.docs/guides/build-your-ui/copilotkit/overview.md +411 -0
- package/.docs/guides/concepts/streaming.md +1 -1
- package/.docs/guides/deployment/vercel.md +1 -2
- package/.docs/guides/guide/signal-provider.md +5 -5
- package/.docs/models/environment-variables.md +1 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +2 -1
- package/.docs/models/providers/friendli.md +1 -2
- package/.docs/models/providers/nvidia.md +3 -2
- package/.docs/models/providers/tencent-token-plan.md +7 -7
- package/.docs/models/providers/tencent-tokenhub.md +5 -4
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/acp/acp-agent.md +5 -5
- package/.docs/reference/acp/create-acp-tool.md +5 -5
- package/.docs/reference/agent-controller/agent-controller-class.md +27 -27
- package/.docs/reference/agents/agent.md +34 -34
- package/.docs/reference/agents/channels.md +19 -19
- package/.docs/reference/agents/createSkill.md +2 -2
- package/.docs/reference/agents/durable-agent.md +22 -22
- package/.docs/reference/agents/generate.md +10 -10
- package/.docs/reference/agents/generateLegacy.md +12 -12
- package/.docs/reference/agents/getMetadata.md +1 -1
- package/.docs/reference/agents/getVoice.md +1 -1
- package/.docs/reference/agents/inngest-agent.md +9 -9
- package/.docs/reference/agents/network.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +4 -4
- package/.docs/reference/ai-sdk/handle-chat-stream.md +6 -6
- package/.docs/reference/ai-sdk/handle-network-stream.md +3 -3
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +4 -4
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +1 -1
- package/.docs/reference/ai-sdk/with-mastra.md +2 -2
- package/.docs/reference/ai-sdk/workflow-route.md +2 -2
- package/.docs/reference/ai-sdk/workflow-snapshot-to-stream.md +1 -1
- package/.docs/reference/auth/google.md +10 -10
- package/.docs/reference/auth/okta.md +11 -11
- package/.docs/reference/auth/workos.md +3 -3
- package/.docs/reference/channels/slack-provider.md +15 -15
- package/.docs/reference/cli/mastra.md +145 -0
- package/.docs/reference/client-js/agents.md +9 -9
- package/.docs/reference/client-js/mastra-client.md +5 -5
- package/.docs/reference/client-js/responses.md +3 -3
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/core/getAgentById.md +3 -3
- package/.docs/reference/core/getWorkflow.md +1 -1
- package/.docs/reference/core/listWorkflows.md +1 -1
- package/.docs/reference/core/mastra-class.md +3 -3
- package/.docs/reference/core/removeWorkspace.md +2 -2
- package/.docs/reference/datasets/compareExperiments.md +1 -1
- package/.docs/reference/datasets/getItemHistory.md +1 -1
- package/.docs/reference/datasets/list.md +5 -5
- package/.docs/reference/datasets/listExperimentResults.md +4 -4
- package/.docs/reference/datasets/listExperiments.md +4 -4
- package/.docs/reference/datasets/listItems.md +5 -5
- package/.docs/reference/datasets/listVersions.md +3 -3
- package/.docs/reference/datasets/startExperiment.md +8 -8
- package/.docs/reference/datasets/startExperimentAsync.md +1 -1
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +4 -4
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +7 -7
- package/.docs/reference/editor/agent-builder/builder-models.md +4 -4
- package/.docs/reference/editor/blob-store-provider.md +2 -2
- package/.docs/reference/editor/browser-provider.md +2 -2
- package/.docs/reference/editor/filesystem-provider.md +2 -2
- package/.docs/reference/editor/mastra-editor.md +2 -2
- package/.docs/reference/editor/processor-provider.md +4 -4
- package/.docs/reference/editor/sandbox-provider.md +2 -2
- package/.docs/reference/editor/storage-browser-ref.md +2 -2
- package/.docs/reference/editor/storage-workspace-ref.md +7 -7
- package/.docs/reference/evals/create-scorer.md +8 -8
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/evals/run-evals.md +7 -7
- package/.docs/reference/evals/trajectory-accuracy.md +1 -1
- package/.docs/reference/index.md +2 -2
- package/.docs/reference/logging/pino-logger.md +4 -4
- package/.docs/reference/memory/cloneThread.md +35 -4
- package/.docs/reference/memory/memory-class.md +5 -5
- package/.docs/reference/memory/observational-memory.md +43 -43
- package/.docs/reference/memory/recall.md +4 -4
- package/.docs/reference/memory/serialized-memory-config.md +6 -6
- package/.docs/reference/observability/tracing/configuration.md +4 -4
- package/.docs/reference/processors/language-detector.md +1 -1
- package/.docs/reference/processors/moderation-processor.md +1 -1
- package/.docs/reference/processors/pii-detector.md +1 -1
- package/.docs/reference/processors/processor-interface.md +20 -20
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/response-cache.md +6 -6
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/pubsub/base.md +7 -7
- package/.docs/reference/pubsub/caching-pubsub.md +1 -1
- package/.docs/reference/pubsub/event-emitter.md +2 -2
- package/.docs/reference/pubsub/google-cloud-pubsub.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +3 -3
- package/.docs/reference/pubsub/redis-streams.md +6 -6
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/rag/chunk.md +2 -2
- package/.docs/reference/server/create-route.md +3 -3
- package/.docs/reference/server/express-adapter.md +4 -4
- package/.docs/reference/server/fastify-adapter.md +4 -4
- package/.docs/reference/server/hono-adapter.md +4 -4
- package/.docs/reference/server/koa-adapter.md +4 -4
- package/.docs/reference/server/mastra-server.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +3 -3
- package/.docs/reference/server/register-api-route.md +3 -3
- package/.docs/reference/signals/create-notification-inbox-tool.md +3 -3
- package/.docs/reference/signals/signal-provider.md +7 -7
- package/.docs/reference/signals/webhook-signal-provider.md +2 -2
- package/.docs/reference/storage/clickhouse.md +7 -7
- package/.docs/reference/storage/composite.md +2 -2
- package/.docs/reference/storage/duckdb.md +1 -1
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/libsql.md +1 -1
- package/.docs/reference/storage/postgresql.md +2 -2
- package/.docs/reference/storage/redis.md +2 -2
- package/.docs/reference/storage/retention.md +5 -5
- package/.docs/reference/storage/spanner.md +6 -6
- package/.docs/reference/streaming/ChunkType.md +3 -3
- package/.docs/reference/streaming/agents/stream.md +14 -14
- package/.docs/reference/streaming/agents/streamLegacy.md +10 -10
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/templates/overview.md +1 -140
- package/.docs/reference/tools/brightdata.md +4 -4
- package/.docs/reference/tools/create-code-mode.md +5 -5
- package/.docs/reference/tools/create-tool.md +15 -15
- package/.docs/reference/tools/graph-rag-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +2 -2
- package/.docs/reference/tools/mcp-server.md +12 -12
- package/.docs/reference/tools/perplexity.md +3 -3
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +1 -1
- package/.docs/reference/vectors/chroma.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +1 -1
- package/.docs/reference/vectors/s3vectors.md +4 -4
- package/.docs/reference/voice/google-gemini-live.md +3 -3
- package/.docs/reference/voice/inworld-realtime.md +12 -12
- package/.docs/reference/voice/inworld.md +2 -2
- package/.docs/reference/voice/voice.on.md +1 -1
- package/.docs/reference/workflows/run-methods/resume.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +4 -4
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -1
- package/.docs/reference/workspace/apple-container-sandbox.md +5 -5
- package/.docs/reference/workspace/archil-filesystem.md +5 -5
- package/.docs/reference/workspace/blaxel-sandbox.md +1 -1
- package/.docs/reference/workspace/daytona-sandbox.md +1 -1
- package/.docs/reference/workspace/docker-sandbox.md +2 -2
- package/.docs/reference/workspace/e2b-sandbox.md +2 -2
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -1
- package/.docs/reference/workspace/filesystem.md +1 -1
- package/.docs/reference/workspace/local-filesystem.md +3 -3
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/mesa-filesystem.md +3 -3
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/railway-sandbox.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +4 -4
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/{vercel-microvm-sandbox.md → vercel-sandbox.md} +21 -15
- package/.docs/reference/workspace/{vercel.md → vercel-serverless.md} +21 -14
- package/.docs/reference/workspace/workspace-class.md +15 -15
- package/CHANGELOG.md +15 -0
- package/package.json +4 -4
- package/.docs/docs/agents/adding-voice.md +0 -383
- package/.docs/docs/community/contributing-templates.md +0 -5
- package/.docs/docs/community/discord.md +0 -11
- package/.docs/guides/build-your-ui/copilotkit.md +0 -291
- package/LICENSE.md +0 -30
- /package/.docs/docs/{community/licensing.md → license.md} +0 -0
- /package/.docs/docs/{agents → long-running-agents}/signals.md +0 -0
|
@@ -139,143 +139,4 @@ your-template/
|
|
|
139
139
|
├── package.json
|
|
140
140
|
├── tsconfig.json
|
|
141
141
|
└── README.md
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## Creating templates
|
|
145
|
-
|
|
146
|
-
### Requirements
|
|
147
|
-
|
|
148
|
-
Templates must meet these technical requirements:
|
|
149
|
-
|
|
150
|
-
#### Project Structure
|
|
151
|
-
|
|
152
|
-
- **Mastra code location**: All Mastra code must be in `src/mastra/` directory
|
|
153
|
-
|
|
154
|
-
- **Component organization**:
|
|
155
|
-
|
|
156
|
-
- Agents: `src/mastra/agents/`
|
|
157
|
-
- Tools: `src/mastra/tools/`
|
|
158
|
-
- Workflows: `src/mastra/workflows/`
|
|
159
|
-
- Main config: `src/mastra/index.ts`
|
|
160
|
-
|
|
161
|
-
#### TypeScript Configuration
|
|
162
|
-
|
|
163
|
-
Use the standard Mastra TypeScript configuration:
|
|
164
|
-
|
|
165
|
-
```json
|
|
166
|
-
{
|
|
167
|
-
"compilerOptions": {
|
|
168
|
-
"target": "ES2022",
|
|
169
|
-
"module": "ES2022",
|
|
170
|
-
"moduleResolution": "bundler",
|
|
171
|
-
"esModuleInterop": true,
|
|
172
|
-
"forceConsistentCasingInFileNames": true,
|
|
173
|
-
"strict": true,
|
|
174
|
-
"skipLibCheck": true,
|
|
175
|
-
"noEmit": true,
|
|
176
|
-
"outDir": "dist"
|
|
177
|
-
},
|
|
178
|
-
"include": ["src/**/*"]
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
#### Environment Configuration
|
|
183
|
-
|
|
184
|
-
Include a `.env.example` file with all required environment variables:
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
# LLM provider API keys (choose one or more)
|
|
188
|
-
OPENAI_API_KEY=your_openai_api_key_here
|
|
189
|
-
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|
190
|
-
GOOGLE_API_KEY=your_google_api_key_here
|
|
191
|
-
|
|
192
|
-
# Other service API keys as needed
|
|
193
|
-
OTHER_SERVICE_API_KEY=your_api_key_here
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
### Code Standards
|
|
197
|
-
|
|
198
|
-
#### LLM Provider
|
|
199
|
-
|
|
200
|
-
We recommend using OpenAI, Anthropic, or Google model providers for templates. Choose the provider that best fits your use case:
|
|
201
|
-
|
|
202
|
-
```typescript
|
|
203
|
-
import { Agent } from '@mastra/core/agent'
|
|
204
|
-
|
|
205
|
-
const agent = new Agent({
|
|
206
|
-
id: 'example-agent',
|
|
207
|
-
name: 'example-agent',
|
|
208
|
-
model: 'openai/gpt-5.5', // or other provider strings
|
|
209
|
-
instructions: 'Your agent instructions here',
|
|
210
|
-
})
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
#### Compatibility Requirements
|
|
214
|
-
|
|
215
|
-
Templates must be:
|
|
216
|
-
|
|
217
|
-
- **Single projects**: Not monorepos with multiple applications
|
|
218
|
-
- **Framework-free**: No Next.js, Express, or other web framework boilerplate
|
|
219
|
-
- **Mastra-focused**: Demonstrate Mastra functionality without additional layers
|
|
220
|
-
- **Mergeable**: Structure code for seamless integration into existing projects
|
|
221
|
-
- **Node.js compatible**: Support Node.js v22.13.0 and later
|
|
222
|
-
- **ESM modules**: Use ES modules (`"type": "module"` in package.json)
|
|
223
|
-
|
|
224
|
-
### Documentation Requirements
|
|
225
|
-
|
|
226
|
-
#### README Structure
|
|
227
|
-
|
|
228
|
-
Every template must include a comprehensive README:
|
|
229
|
-
|
|
230
|
-
```markdown
|
|
231
|
-
# Template Name
|
|
232
|
-
|
|
233
|
-
Brief description of what the template demonstrates.
|
|
234
|
-
|
|
235
|
-
## Overview
|
|
236
|
-
|
|
237
|
-
Detailed explanation of the template's functionality and use case.
|
|
238
|
-
|
|
239
|
-
## Setup
|
|
240
|
-
|
|
241
|
-
1. Copy `.env.example` to `.env` and fill in your API keys
|
|
242
|
-
2. Install dependencies: `npm install`
|
|
243
|
-
3. Run the project: `npm run dev`
|
|
244
|
-
|
|
245
|
-
## Environment variables
|
|
246
|
-
|
|
247
|
-
- `OPENAI_API_KEY`: Your OpenAI API key. Get one at [OpenAI Platform](https://platform.openai.com/api-keys)
|
|
248
|
-
- `ANTHROPIC_API_KEY`: Your Anthropic API key. Get one at [Anthropic Console](https://console.anthropic.com/settings/keys)
|
|
249
|
-
- `GOOGLE_API_KEY`: Your Google AI API key. Get one at [Google AI Studio](https://makersuite.google.com/app/apikey)
|
|
250
|
-
- `OTHER_API_KEY`: Description of what this key is for
|
|
251
|
-
|
|
252
|
-
## Usage
|
|
253
|
-
|
|
254
|
-
Instructions on how to use the template and examples of expected behavior.
|
|
255
|
-
|
|
256
|
-
## Customization
|
|
257
|
-
|
|
258
|
-
Guidelines for modifying the template for different use cases.
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
#### Code Comments
|
|
262
|
-
|
|
263
|
-
Include clear comments explaining:
|
|
264
|
-
|
|
265
|
-
- Complex logic or algorithms
|
|
266
|
-
- API integrations and their purpose
|
|
267
|
-
- Configuration options and their effects
|
|
268
|
-
- Example usage patterns
|
|
269
|
-
|
|
270
|
-
### Quality Standards
|
|
271
|
-
|
|
272
|
-
Templates must demonstrate:
|
|
273
|
-
|
|
274
|
-
- **Code quality** - Clean, well-commented, maintainable code
|
|
275
|
-
- **Error handling** - Proper handling for external APIs and user inputs
|
|
276
|
-
- **Type safety** - Full TypeScript typing with Zod validation
|
|
277
|
-
- **Testing** - Verified functionality with fresh installations
|
|
278
|
-
|
|
279
|
-
For information on contributing your own templates to the Mastra ecosystem, see the [Contributing Templates](https://mastra.ai/docs/community/contributing-templates) guide in the community section.
|
|
280
|
-
|
|
281
|
-
> **Info:** Templates provide an excellent way to learn Mastra patterns and accelerate development. Contributing templates helps the entire community build better AI applications.
|
|
142
|
+
```
|
|
@@ -59,7 +59,7 @@ By default, all tools read `BRIGHTDATA_API_TOKEN` from the environment. You can
|
|
|
59
59
|
|
|
60
60
|
All factory functions accept `BrightDataClientOptions` from `@brightdata/sdk`:
|
|
61
61
|
|
|
62
|
-
**apiKey** (`string`): Bright Data API token. Falls back to the
|
|
62
|
+
**apiKey** (`string`): Bright Data API token. Falls back to the BRIGHTDATA\_API\_TOKEN environment variable.
|
|
63
63
|
|
|
64
64
|
Additional fields supported by the `bdclient` constructor (such as `timeout`, `webUnlockerZone`, `serpZone`, and `rateLimit`) can be passed through the same options object.
|
|
65
65
|
|
|
@@ -92,9 +92,9 @@ const searchTool = createBrightDataSearchTool()
|
|
|
92
92
|
|
|
93
93
|
**query** (`string`): The search query.
|
|
94
94
|
|
|
95
|
-
**country** (`string`): Two-letter country code for geo-targeted results (for example,
|
|
95
|
+
**country** (`string`): Two-letter country code for geo-targeted results (for example, us or gb).
|
|
96
96
|
|
|
97
|
-
**start** (`number`): Result offset for pagination. For example,
|
|
97
|
+
**start** (`number`): Result offset for pagination. For example, 10 returns the second page of 10 results.
|
|
98
98
|
|
|
99
99
|
### Output
|
|
100
100
|
|
|
@@ -108,7 +108,7 @@ const searchTool = createBrightDataSearchTool()
|
|
|
108
108
|
|
|
109
109
|
**results.description** (`string`): Result snippet.
|
|
110
110
|
|
|
111
|
-
**currentPage** (`number`): Page number returned by the SERP API. Defaults to
|
|
111
|
+
**currentPage** (`number`): Page number returned by the SERP API. Defaults to 1 when the upstream response omits or returns a non-positive value.
|
|
112
112
|
|
|
113
113
|
## `createBrightDataFetchTool()`
|
|
114
114
|
|
|
@@ -54,9 +54,9 @@ export const shopAgent = new Agent({
|
|
|
54
54
|
|
|
55
55
|
**config** (`CodeModeConfig`): Configuration for the code mode tool and generated instructions.
|
|
56
56
|
|
|
57
|
-
**config.tools** (`ToolsInput`): Tools exposed to the generated code as
|
|
57
|
+
**config.tools** (`ToolsInput`): Tools exposed to the generated code as external\_\<id> functions. Only these tools can be called.
|
|
58
58
|
|
|
59
|
-
**config.sandbox** (`WorkspaceSandbox`): Sandbox used to execute the generated code. Required unless the agent runs in a workspace that provides a sandbox. Pass
|
|
59
|
+
**config.sandbox** (`WorkspaceSandbox`): Sandbox used to execute the generated code. Required unless the agent runs in a workspace that provides a sandbox. Pass new LocalSandbox() to run on the host explicitly.
|
|
60
60
|
|
|
61
61
|
**config.timeout** (`number`): Execution timeout in milliseconds.
|
|
62
62
|
|
|
@@ -68,9 +68,9 @@ export const shopAgent = new Agent({
|
|
|
68
68
|
|
|
69
69
|
Returns a `CodeModeResult` object.
|
|
70
70
|
|
|
71
|
-
**tool** (`Tool<any, any>`): The generated code mode tool. By default, its id is
|
|
71
|
+
**tool** (`Tool<any, any>`): The generated code mode tool. By default, its id is execute\_typescript.
|
|
72
72
|
|
|
73
|
-
**instructions** (`string`): Generated model instructions with typed
|
|
73
|
+
**instructions** (`string`): Generated model instructions with typed external\_\* declarations for the configured tools.
|
|
74
74
|
|
|
75
75
|
## CodeModeToolResult
|
|
76
76
|
|
|
@@ -80,7 +80,7 @@ The generated tool returns a `CodeModeToolResult`.
|
|
|
80
80
|
|
|
81
81
|
**result** (`unknown`): The value returned by the generated code.
|
|
82
82
|
|
|
83
|
-
**logs** (`string[]`): Captured console output from
|
|
83
|
+
**logs** (`string[]`): Captured console output from console.log, console.info, console.warn, and console.error, in order.
|
|
84
84
|
|
|
85
85
|
**error** (`{ message: string; name?: string; line?: number }`): Error details when the generated code throws or fails to execute.
|
|
86
86
|
|
|
@@ -35,33 +35,33 @@ export const tool = createTool({
|
|
|
35
35
|
|
|
36
36
|
**description** (`string`): A description of what the tool does. This is used by the agent to decide when to use the tool.
|
|
37
37
|
|
|
38
|
-
**inputSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected input parameters for the tool's
|
|
38
|
+
**inputSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected input parameters for the tool's execute function.
|
|
39
39
|
|
|
40
|
-
**outputSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected output structure of the tool's
|
|
40
|
+
**outputSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected output structure of the tool's execute function.
|
|
41
41
|
|
|
42
42
|
**strict** (`boolean`): When true, Mastra enables strict tool input generation on model adapters that support it. This helps supported providers return arguments that match the tool schema more closely.
|
|
43
43
|
|
|
44
|
-
**toModelOutput** (`(output: TSchemaOut) => unknown`): Optional function that transforms the tool's
|
|
44
|
+
**toModelOutput** (`(output: TSchemaOut) => unknown`): Optional function that transforms the tool's execute output before it is sent back to the model. Use this to return text, json, or content-shaped outputs (including multimodal parts like images/files) to the model while still keeping the full raw output in your application code.
|
|
45
45
|
|
|
46
|
-
**transform** (`ToolPayloadTransform`): Optional target-aware transform for tool payloads before they leave runtime for display streams or user-visible transcript messages. Configure
|
|
46
|
+
**transform** (`ToolPayloadTransform`): Optional target-aware transform for tool payloads before they leave runtime for display streams or user-visible transcript messages. Configure display and transcript transforms for phases such as input, inputDelta, output, error, approval, suspend, and resume.
|
|
47
47
|
|
|
48
|
-
**suspendSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the structure of the payload passed to
|
|
48
|
+
**suspendSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the structure of the payload passed to suspend(). This payload is returned to the client when the tool suspends execution.
|
|
49
49
|
|
|
50
|
-
**resumeSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected structure of
|
|
50
|
+
**resumeSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected structure of resumeData when the tool is resumed. Used by the agent to extract data from user messages when autoResumeSuspendedTools is enabled.
|
|
51
51
|
|
|
52
|
-
**requireApproval** (`boolean`): When true, the tool requires explicit approval before execution. The agent will emit a
|
|
52
|
+
**requireApproval** (`boolean`): When true, the tool requires explicit approval before execution. The agent will emit a tool-call-approval chunk and pause until approved or declined.
|
|
53
53
|
|
|
54
|
-
**mcp** (`MCPToolProperties`): MCP-specific properties for tools exposed via Model Context Protocol. Includes
|
|
54
|
+
**mcp** (`MCPToolProperties`): MCP-specific properties for tools exposed via Model Context Protocol. Includes annotations (tool behavior hints like title, readOnlyHint, destructiveHint, idempotentHint, openWorldHint) and \_meta (arbitrary metadata passed through to MCP clients).
|
|
55
55
|
|
|
56
56
|
**requestContextSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema for validating request context values. When provided, the context is validated before execute() runs, returning an error object if validation fails.
|
|
57
57
|
|
|
58
|
-
**providerOptions** (`Record<string, Record<string, unknown>>`): Provider-specific options passed to the model when this tool is used. Keys are provider names, such as
|
|
58
|
+
**providerOptions** (`Record<string, Record<string, unknown>>`): Provider-specific options passed to the model when this tool is used. Keys are provider names, such as anthropic or openai, and values are provider-specific configuration objects.
|
|
59
59
|
|
|
60
60
|
**inputExamples** (`Array<{ input: Record<string, unknown> }>`): Examples of valid tool inputs that supported model providers can use as input examples.
|
|
61
61
|
|
|
62
62
|
**background** (`ToolBackgroundConfig`): Background task configuration for this tool. When enabled, the tool can execute in the background while the agent conversation continues.
|
|
63
63
|
|
|
64
|
-
**execute** (`function`): The function that contains the tool's logic. Ordinary custom tools usually provide
|
|
64
|
+
**execute** (`function`): The function that contains the tool's logic. Ordinary custom tools usually provide execute, but the type allows omission for tool definitions that are executed or adapted elsewhere. It receives two parameters: the validated input data based on inputSchema (first parameter) and an execution context object (second parameter) containing requestContext, abortSignal, and other execution metadata.
|
|
65
65
|
|
|
66
66
|
**execute.input** (`z.infer<TInput>`): The validated input data based on inputSchema
|
|
67
67
|
|
|
@@ -77,15 +77,15 @@ export const tool = createTool({
|
|
|
77
77
|
|
|
78
78
|
**execute.context.mcp** (`MCPToolExecutionContext`): MCP-specific context (elicitation, etc.)
|
|
79
79
|
|
|
80
|
-
**execute.context.observe** (`ToolObserve`): Observability helpers for recording child spans and structured logs from inside a tool's execute function. Always provided — when no tracing context is active,
|
|
80
|
+
**execute.context.observe** (`ToolObserve`): Observability helpers for recording child spans and structured logs from inside a tool's execute function. Always provided — when no tracing context is active, span runs the function directly and log is a no-op.
|
|
81
81
|
|
|
82
|
-
**onInputStart** (`function`): Optional callback invoked when the tool call input streaming begins. Signature:
|
|
82
|
+
**onInputStart** (`function`): Optional callback invoked when the tool call input streaming begins. Signature: (options: ToolCallOptions) => void | PromiseLike\<void>.
|
|
83
83
|
|
|
84
|
-
**onInputDelta** (`function`): Optional callback invoked for each incremental chunk of input text as it streams in. Signature:
|
|
84
|
+
**onInputDelta** (`function`): Optional callback invoked for each incremental chunk of input text as it streams in. Signature: ({ inputTextDelta, ...options }: { inputTextDelta: string } & ToolCallOptions) => void | PromiseLike\<void>.
|
|
85
85
|
|
|
86
|
-
**onInputAvailable** (`function`): Optional callback invoked when the complete tool input is available and parsed. Signature:
|
|
86
|
+
**onInputAvailable** (`function`): Optional callback invoked when the complete tool input is available and parsed. Signature: ({ input, ...options }: { input: TSchemaIn } & ToolCallOptions) => void | PromiseLike\<void>.
|
|
87
87
|
|
|
88
|
-
**onOutput** (`function`): Optional callback invoked after the tool has successfully executed and returned output. Signature:
|
|
88
|
+
**onOutput** (`function`): Optional callback invoked after the tool has successfully executed and returned output. Signature: ({ output, toolName, ...options }: { output: TSchemaOut; toolName: string } & Omit\<ToolCallOptions, 'messages'>) => void | PromiseLike\<void>.
|
|
89
89
|
|
|
90
90
|
Runtime-populated fields such as `mastra` and `mcpMetadata` appear in source types but are set by Mastra or MCP adapters. You do not need to configure them for ordinary `createTool()` usage.
|
|
91
91
|
|
|
@@ -53,7 +53,7 @@ const graphTool = createGraphRAGTool({
|
|
|
53
53
|
|
|
54
54
|
**providerOptions** (`Record<string, Record<string, any>>`): Provider-specific options for the embedding model (e.g., outputDimensionality). \*\*Important\*\*: Only works with AI SDK EmbeddingModelV2 models. For V1 models, configure options when creating the model itself.
|
|
55
55
|
|
|
56
|
-
**vectorStore** (`MastraVector | VectorStoreResolver`): Direct vector store instance or a resolver function for dynamic selection. Use a function for multi-tenant applications where the vector store is selected based on request context. When provided,
|
|
56
|
+
**vectorStore** (`MastraVector | VectorStoreResolver`): Direct vector store instance or a resolver function for dynamic selection. Use a function for multi-tenant applications where the vector store is selected based on request context. When provided, vectorStoreName becomes optional.
|
|
57
57
|
|
|
58
58
|
## Returns
|
|
59
59
|
|
|
@@ -43,7 +43,7 @@ Each server in the `servers` map is configured using the `MastraMCPServerDefinit
|
|
|
43
43
|
|
|
44
44
|
**eventSourceInit** (`EventSourceInit`): For SSE fallback: Custom fetch configuration for SSE connections. Required when using custom headers with SSE.
|
|
45
45
|
|
|
46
|
-
**fetch** (`MastraFetchLike`): For HTTP servers: Custom fetch implementation used for all network requests. Receives an optional third
|
|
46
|
+
**fetch** (`MastraFetchLike`): For HTTP servers: Custom fetch implementation used for all network requests. Receives an optional third requestContext parameter containing request-scoped data (e.g., authentication cookies, bearer tokens) from the incoming request. When provided, this function will be used for all HTTP requests, allowing you to add dynamic authentication headers, forward request-scoped credentials to the MCP server, customize request behavior per-request, or intercept and modify requests/responses. When fetch is provided, requestInit, eventSourceInit, and authProvider become optional, as you can handle these concerns within your custom fetch function.
|
|
47
47
|
|
|
48
48
|
**logger** (`LogHandler`): Optional additional handler for logging.
|
|
49
49
|
|
|
@@ -59,7 +59,7 @@ Each server in the `servers` map is configured using the `MastraMCPServerDefinit
|
|
|
59
59
|
|
|
60
60
|
**instructionsMaxLength** (`number`): Maximum number of server instruction characters to append to an agent's system prompt. (Default: `512`)
|
|
61
61
|
|
|
62
|
-
**requireToolApproval** (`boolean | (params: RequireToolApprovalContext) => boolean | Promise<boolean>`): Require human approval before executing tools from this server. When set to
|
|
62
|
+
**requireToolApproval** (`boolean | (params: RequireToolApprovalContext) => boolean | Promise<boolean>`): Require human approval before executing tools from this server. When set to true, all tools require approval. When set to a function, the function is called with the tool name, arguments, request context, and any tool annotations advertised by the server to dynamically decide whether approval is needed.
|
|
63
63
|
|
|
64
64
|
## Tool approval
|
|
65
65
|
|
|
@@ -59,19 +59,19 @@ The constructor accepts an `MCPServerConfig` object with the following propertie
|
|
|
59
59
|
|
|
60
60
|
**version** (`string`): The semantic version of your server (e.g., '1.0.0').
|
|
61
61
|
|
|
62
|
-
**tools** (`ToolsInput`): An object where keys are tool names and values are Mastra tool definitions (created with
|
|
62
|
+
**tools** (`ToolsInput`): An object where keys are tool names and values are Mastra tool definitions (created with createTool or Vercel AI SDK). These tools will be directly exposed.
|
|
63
63
|
|
|
64
|
-
**agents** (`Record<string, Agent>`): An object where keys are agent identifiers and values are Mastra Agent instances. Each agent will be automatically converted into a tool named
|
|
64
|
+
**agents** (`Record<string, Agent>`): An object where keys are agent identifiers and values are Mastra Agent instances. Each agent will be automatically converted into a tool named ask\_\<agentIdentifier>. The agent \*\*must\*\* have a non-empty description string property defined in its constructor configuration. This description will be used in the tool's description. If an agent's description is missing or empty, an error will be thrown during MCPServer initialization.
|
|
65
65
|
|
|
66
|
-
**workflows** (`Record<string, Workflow>`): An object where keys are workflow identifiers and values are Mastra Workflow instances. Each workflow is converted into a tool named
|
|
66
|
+
**workflows** (`Record<string, Workflow>`): An object where keys are workflow identifiers and values are Mastra Workflow instances. Each workflow is converted into a tool named run\_\<workflowKey>. The workflow's inputSchema becomes the tool's input schema. The workflow \*\*must\*\* have a non-empty description string property, which is used for the tool's description. If a workflow's description is missing or empty, an error will be thrown. The tool executes the workflow by calling workflow\.createRun() followed by run.start({ inputData: \<tool\_input> }). If a tool name derived from an agent or workflow (e.g., ask\_myAgent or run\_myWorkflow) collides with an explicitly defined tool name or another derived name, the explicitly defined tool takes precedence, and a warning is logged. Agents/workflows leading to subsequent collisions are skipped.
|
|
67
67
|
|
|
68
68
|
**description** (`string`): Optional description of what the MCP server does.
|
|
69
69
|
|
|
70
70
|
**instructions** (`string`): Optional instructions describing how to use the server and its features.
|
|
71
71
|
|
|
72
|
-
**mapAuthInfoToUser** (`({ authInfo, extra, requestContext }) => unknown | null | undefined | Promise<unknown | null | undefined>`): Maps MCP transport auth data from
|
|
72
|
+
**mapAuthInfoToUser** (`({ authInfo, extra, requestContext }) => unknown | null | undefined | Promise<unknown | null | undefined>`): Maps MCP transport auth data from extra.authInfo into the user value used by Mastra FGA checks. Use this when an OAuth-protected MCP server is registered on a Mastra instance with an FGA provider.
|
|
73
73
|
|
|
74
|
-
**fga** (`{ resourceMapping?: Partial<Record<'tool' | 'tools', { fgaResourceType: string; deriveId?: ({ user, resourceId, requestContext }) => string | undefined }>>; permissionMapping?: Record<string, string> }`): Overrides resource and permission mappings for this MCP server's
|
|
74
|
+
**fga** (`{ resourceMapping?: Partial<Record<'tool' | 'tools', { fgaResourceType: string; deriveId?: ({ user, resourceId, requestContext }) => string | undefined }>>; permissionMapping?: Record<string, string> }`): Overrides resource and permission mappings for this MCP server's tools/list and tools/call FGA checks. Use this when MCP authorization should be scoped differently from internal agent or workflow tool execution.
|
|
75
75
|
|
|
76
76
|
**repository** (`Repository`): Optional repository information for the server's source code.
|
|
77
77
|
|
|
@@ -89,7 +89,7 @@ The constructor accepts an `MCPServerConfig` object with the following propertie
|
|
|
89
89
|
|
|
90
90
|
**prompts** (`MCPServerPrompts`): An object defining how the server should handle MCP prompts. See Prompt Handling section for details.
|
|
91
91
|
|
|
92
|
-
**appResources** (`AppResources`): A map of
|
|
92
|
+
**appResources** (`AppResources`): A map of ui:// URIs to app resource configurations. Each entry defines an interactive HTML UI served via the MCP Apps extension (SEP-1865). See the MCP Apps section for details.
|
|
93
93
|
|
|
94
94
|
## Exposing agents as tools
|
|
95
95
|
|
|
@@ -422,13 +422,13 @@ Here are the details for the values needed by the `startHTTP` method:
|
|
|
422
422
|
|
|
423
423
|
The `StreamableHTTPServerTransportOptions` object allows you to customize the behavior of the HTTP transport. Here are the available options:
|
|
424
424
|
|
|
425
|
-
**serverless** (`boolean`): If
|
|
425
|
+
**serverless** (`boolean`): If true, runs in stateless mode without session management. Each request is handled independently with a fresh server instance. Essential for serverless environments (Cloudflare Workers, Supabase Edge Functions, Vercel Edge, etc.) where sessions cannot persist between invocations. Defaults to false.
|
|
426
426
|
|
|
427
|
-
**sessionIdGenerator** (`(() => string) | undefined`): A function that generates a unique session ID. This should be a cryptographically secure, globally unique string. Return
|
|
427
|
+
**sessionIdGenerator** (`(() => string) | undefined`): A function that generates a unique session ID. This should be a cryptographically secure, globally unique string. Return undefined to disable session management.
|
|
428
428
|
|
|
429
429
|
**onsessioninitialized** (`(sessionId: string) => void`): A callback that is invoked when a new session is initialized. This is useful for tracking active MCP sessions.
|
|
430
430
|
|
|
431
|
-
**enableJsonResponse** (`boolean`): If
|
|
431
|
+
**enableJsonResponse** (`boolean`): If true, the server will return plain JSON responses instead of using Server-Sent Events (SSE) for streaming. Defaults to false.
|
|
432
432
|
|
|
433
433
|
**eventStore** (`EventStore`): An event store for message resumability. Providing this enables clients to reconnect and resume message streams.
|
|
434
434
|
|
|
@@ -1350,7 +1350,7 @@ The `appResources` option lets you serve interactive HTML UIs from your MCP serv
|
|
|
1350
1350
|
|
|
1351
1351
|
### `AppResources` type
|
|
1352
1352
|
|
|
1353
|
-
**Key (URI)** (`string`): A
|
|
1353
|
+
**Key (URI)** (`string`): A ui:// URI that identifies the app resource (e.g., ui://calculator/main).
|
|
1354
1354
|
|
|
1355
1355
|
Each value is an `AppResource` object:
|
|
1356
1356
|
|
|
@@ -1358,9 +1358,9 @@ Each value is an `AppResource` object:
|
|
|
1358
1358
|
|
|
1359
1359
|
**description** (`string`): Optional description of the UI resource.
|
|
1360
1360
|
|
|
1361
|
-
**html** (`string`): Inline HTML content for the UI. Provide either
|
|
1361
|
+
**html** (`string`): Inline HTML content for the UI. Provide either html or htmlPath.
|
|
1362
1362
|
|
|
1363
|
-
**htmlPath** (`string`): Path to an HTML file. Resolved at server startup. Provide either
|
|
1363
|
+
**htmlPath** (`string`): Path to an HTML file. Resolved at server startup. Provide either html or htmlPath.
|
|
1364
1364
|
|
|
1365
1365
|
**meta** (`McpUiResourceMeta`): UI resource metadata (CSP, permissions, rendering preferences) from the official ext-apps SDK.
|
|
1366
1366
|
|
|
@@ -56,11 +56,11 @@ const searchTool = createPerplexitySearchTool({ apiKey: 'pplx-...' })
|
|
|
56
56
|
|
|
57
57
|
All factory functions accept a `PerplexityClientOptions` object:
|
|
58
58
|
|
|
59
|
-
**apiKey** (`string`): Perplexity API key. Falls back to the
|
|
59
|
+
**apiKey** (`string`): Perplexity API key. Falls back to the PERPLEXITY\_API\_KEY then PPLX\_API\_KEY environment variables.
|
|
60
60
|
|
|
61
61
|
**baseUrl** (`string`): Override the API base URL. (Default: `'https://api.perplexity.ai'`)
|
|
62
62
|
|
|
63
|
-
**fetch** (`typeof fetch`): Custom
|
|
63
|
+
**fetch** (`typeof fetch`): Custom fetch implementation. Useful for tests, retries, or instrumentation.
|
|
64
64
|
|
|
65
65
|
## Methods
|
|
66
66
|
|
|
@@ -97,7 +97,7 @@ const searchTool = createPerplexitySearchTool()
|
|
|
97
97
|
|
|
98
98
|
**maxResults** (`number`): Maximum number of results to return (1-20).
|
|
99
99
|
|
|
100
|
-
**searchDomainFilter** (`string[]`): Restrict (or exclude) results by domain. Prefix a domain with
|
|
100
|
+
**searchDomainFilter** (`string[]`): Restrict (or exclude) results by domain. Prefix a domain with - to exclude it (for example, -pinterest.com). Do not mix allow- and deny-list entries in the same call.
|
|
101
101
|
|
|
102
102
|
**searchRecencyFilter** (`'hour' | 'day' | 'week' | 'month' | 'year'`): Only return results from within the given recency window.
|
|
103
103
|
|
|
@@ -57,7 +57,7 @@ By default, all tools read `TAVILY_API_KEY` from the environment. You can pass `
|
|
|
57
57
|
|
|
58
58
|
All factory functions accept `TavilyClientOptions` from `@tavily/core`:
|
|
59
59
|
|
|
60
|
-
**apiKey** (`string`): Tavily API key. Falls back to the
|
|
60
|
+
**apiKey** (`string`): Tavily API key. Falls back to the TAVILY\_API\_KEY environment variable.
|
|
61
61
|
|
|
62
62
|
**clientSource** (`string`): Attribution string sent with each request. (Default: `'mastra'`)
|
|
63
63
|
|
|
@@ -71,7 +71,7 @@ const queryTool = createVectorQueryTool({
|
|
|
71
71
|
|
|
72
72
|
**providerOptions** (`Record<string, Record<string, any>>`): Provider-specific options for the embedding model (e.g., outputDimensionality). \*\*Important\*\*: Only works with AI SDK EmbeddingModelV2 models. For V1 models, configure options when creating the model itself.
|
|
73
73
|
|
|
74
|
-
**vectorStore** (`MastraVector | VectorStoreResolver`): Direct vector store instance or a resolver function for dynamic selection. Use a function for multi-tenant applications where the vector store is selected based on request context. When provided,
|
|
74
|
+
**vectorStore** (`MastraVector | VectorStoreResolver`): Direct vector store instance or a resolver function for dynamic selection. Use a function for multi-tenant applications where the vector store is selected based on request context. When provided, vectorStoreName becomes optional.
|
|
75
75
|
|
|
76
76
|
## Returns
|
|
77
77
|
|
|
@@ -129,7 +129,7 @@ You can also provide the shape of your metadata to a `get` call for type inferen
|
|
|
129
129
|
|
|
130
130
|
**limit** (`number`): The maximum number of records to return (Default: `100`)
|
|
131
131
|
|
|
132
|
-
**offset** (`number`): Offset for returning records. Use with
|
|
132
|
+
**offset** (`number`): Offset for returning records. Use with limit to paginate results.
|
|
133
133
|
|
|
134
134
|
### `listIndexes()`
|
|
135
135
|
|
|
@@ -103,7 +103,7 @@ Searches for similar vectors with optional metadata filtering.
|
|
|
103
103
|
|
|
104
104
|
**topK** (`number`): Number of results to return (Default: `10`)
|
|
105
105
|
|
|
106
|
-
**filter** (`Record<string, any>`): Metadata filters (applies to the
|
|
106
|
+
**filter** (`Record<string, any>`): Metadata filters (applies to the metadata field)
|
|
107
107
|
|
|
108
108
|
**documentFilter** (`Record<string, any>`): Filters on original document fields (not just metadata)
|
|
109
109
|
|
|
@@ -28,7 +28,7 @@ The PgVector class provides vector search using [PostgreSQL](https://www.postgre
|
|
|
28
28
|
|
|
29
29
|
**pgPoolOptions** (`PoolConfig`): Additional pg pool configuration options
|
|
30
30
|
|
|
31
|
-
**disableInit** (`boolean`): When true, automatic DDL (schema, extension, table, and index creation) inside
|
|
31
|
+
**disableInit** (`boolean`): When true, automatic DDL (schema, extension, table, and index creation) inside createIndex is skipped. Useful for CI/CD pipelines where schema and indexes are managed separately and the runtime database role lacks DDL privileges. Can also be enabled with the MASTRA\_DISABLE\_STORAGE\_INIT environment variable. (Default: `false`)
|
|
32
32
|
|
|
33
33
|
## Constructor examples
|
|
34
34
|
|
|
@@ -88,9 +88,9 @@ await store.disconnect()
|
|
|
88
88
|
|
|
89
89
|
**vectorBucketName** (`string`): Target S3 Vectors vector bucket name.
|
|
90
90
|
|
|
91
|
-
**clientConfig** (`S3VectorsClientConfig`): AWS SDK v3 client options (e.g.,
|
|
91
|
+
**clientConfig** (`S3VectorsClientConfig`): AWS SDK v3 client options (e.g., region, credentials).
|
|
92
92
|
|
|
93
|
-
**nonFilterableMetadataKeys** (`string[]`): Metadata keys that should NOT be filterable (applied to the index at creation time). Use this for large text fields like
|
|
93
|
+
**nonFilterableMetadataKeys** (`string[]`): Metadata keys that should NOT be filterable (applied to the index at creation time). Use this for large text fields like content.
|
|
94
94
|
|
|
95
95
|
## Methods
|
|
96
96
|
|
|
@@ -102,7 +102,7 @@ Creates a new vector index in the configured vector bucket. If the index already
|
|
|
102
102
|
|
|
103
103
|
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
104
104
|
|
|
105
|
-
**metric** (`'cosine' | 'euclidean'`): Distance metric for similarity search.
|
|
105
|
+
**metric** (`'cosine' | 'euclidean'`): Distance metric for similarity search. dotproduct is not supported by S3 Vectors. (Default: `cosine`)
|
|
106
106
|
|
|
107
107
|
### `upsert()`
|
|
108
108
|
|
|
@@ -126,7 +126,7 @@ Searches for nearest neighbors with optional metadata filtering.
|
|
|
126
126
|
|
|
127
127
|
**topK** (`number`): Number of results to return (Default: `10`)
|
|
128
128
|
|
|
129
|
-
**filter** (`S3VectorsFilter`): JSON-based metadata filter supporting
|
|
129
|
+
**filter** (`S3VectorsFilter`): JSON-based metadata filter supporting $and, $or, $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $exists.
|
|
130
130
|
|
|
131
131
|
**includeVector** (`boolean`): Whether to include vectors in the results (Default: `false`)
|
|
132
132
|
|
|
@@ -162,7 +162,7 @@ await voice.sendContext([
|
|
|
162
162
|
await voice.send(micStream)
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
-
**turns** (`IncrementalTurn[]`): Prior conversation turns to seed into the session. Each turn has a
|
|
165
|
+
**turns** (`IncrementalTurn[]`): Prior conversation turns to seed into the session. Each turn has a role ("user" or "assistant") and content string. Both roles are supported on newer models (e.g. gemini-2.5-flash-native-audio-preview-12-2025). Some older models only accept user-role turns.
|
|
166
166
|
|
|
167
167
|
**options** (`object`): Optional configuration.
|
|
168
168
|
|
|
@@ -266,9 +266,9 @@ The GeminiLiveVoice class emits the following events:
|
|
|
266
266
|
|
|
267
267
|
**speaking** (`event`): Emitted with audio metadata. Callback receives { audioData?: Int16Array, sampleRate?: number }.
|
|
268
268
|
|
|
269
|
-
**writing** (`event`): Emitted when transcribed text is available. Callback receives { text: string, role: 'assistant' | 'user' }. On native-audio models the assistant transcript is driven by the server's
|
|
269
|
+
**writing** (`event`): Emitted when transcribed text is available. Callback receives { text: string, role: 'assistant' | 'user' }. On native-audio models the assistant transcript is driven by the server's output\_audio\_transcription channel rather than modelTurn.parts.text.
|
|
270
270
|
|
|
271
|
-
**thinking** (`event`): Emitted on native-audio models with the model's chain-of-thought / reasoning text from
|
|
271
|
+
**thinking** (`event`): Emitted on native-audio models with the model's chain-of-thought / reasoning text from modelTurn.parts.text. Callback receives { text: string }. Does not fire on non-native-audio models, where modelTurn.parts.text is the spoken response and is emitted as writing instead.
|
|
272
272
|
|
|
273
273
|
**session** (`event`): Emitted on session state changes. Callback receives { state: 'connecting' | 'connected' | 'disconnected' | 'disconnecting' | 'updated', config?: object }.
|
|
274
274
|
|
|
@@ -68,7 +68,7 @@ voice.close()
|
|
|
68
68
|
|
|
69
69
|
**speaker** (`string`): Default voice ID for speech synthesis. Any voice from Inworld's catalog is accepted. (Default: `'Sarah'`)
|
|
70
70
|
|
|
71
|
-
**sessionId** (`string`): Client-generated session key surfaced as the URL
|
|
71
|
+
**sessionId** (`string`): Client-generated session key surfaced as the URL key parameter. A timestamp-based key is generated automatically when omitted. (Default: `'voice-{Date.now()}'`)
|
|
72
72
|
|
|
73
73
|
**instructions** (`string`): System prompt sent with the initial session.update.
|
|
74
74
|
|
|
@@ -76,9 +76,9 @@ voice.close()
|
|
|
76
76
|
|
|
77
77
|
**debug** (`boolean`): Log raw server events. (Default: `false`)
|
|
78
78
|
|
|
79
|
-
**providerData** (`InworldProviderData`): Typed Inworld extension config (stt, tts, memory, backchannel, responsiveness, plus user\_id and metadata). Sent under session.providerData on every session.update. Composes with any session.providerData set via the
|
|
79
|
+
**providerData** (`InworldProviderData`): Typed Inworld extension config (stt, tts, memory, backchannel, responsiveness, plus user\_id and metadata). Sent under session.providerData on every session.update. Composes with any session.providerData set via the session field; the constructor option wins on key collisions.
|
|
80
80
|
|
|
81
|
-
**connectTimeoutMs** (`number`): Max time
|
|
81
|
+
**connectTimeoutMs** (`number`): Max time connect() will wait for both the WebSocket handshake and the initial session.updated round-trip. A pre-open error or close on the WebSocket — or this timeout expiring — surfaces as a rejected promise instead of an uncaught socket error. (Default: `15000`)
|
|
82
82
|
|
|
83
83
|
### `session` (typed knobs)
|
|
84
84
|
|
|
@@ -86,21 +86,21 @@ Use the typed `session` field for documented Inworld realtime options. Fields co
|
|
|
86
86
|
|
|
87
87
|
**output\_modalities** (`Array<"text" | "audio">`): Modalities the model should produce.
|
|
88
88
|
|
|
89
|
-
**audio.output.voice** (`string`): Voice catalog ID. When omitted, the constructor
|
|
89
|
+
**audio.output.voice** (`string`): Voice catalog ID. When omitted, the constructor speaker is used.
|
|
90
90
|
|
|
91
91
|
**audio.output.speed** (`number`): Playback speed multiplier for synthesized audio (0.25 to 1.5).
|
|
92
92
|
|
|
93
93
|
**audio.output.model** (`string`): Inworld TTS model (e.g. "inworld-tts-2").
|
|
94
94
|
|
|
95
|
-
**audio.output.format** (`InworldAudioFormat`): Output audio encoding. A codec string (e.g. "audio/pcm", "audio/pcmu", "audio/pcma", "audio/float32") or an object
|
|
95
|
+
**audio.output.format** (`InworldAudioFormat`): Output audio encoding. A codec string (e.g. "audio/pcm", "audio/pcmu", "audio/pcma", "audio/float32") or an object { type, rate? }. rate (Hz) applies to audio/pcm and audio/float32 (default 24000); audio/pcmu and audio/pcma are fixed at 8 kHz.
|
|
96
96
|
|
|
97
|
-
**audio.input.format** (`InworldAudioFormat`): Input audio encoding sent to the server. Same shape as
|
|
97
|
+
**audio.input.format** (`InworldAudioFormat`): Input audio encoding sent to the server. Same shape as audio.output.format — a codec string or { type, rate? } object.
|
|
98
98
|
|
|
99
99
|
**audio.input.noise\_reduction** (`{ type: "near_field" | "far_field" }`): Input noise-reduction mode applied before transcription and VAD.
|
|
100
100
|
|
|
101
|
-
**audio.input.transcription** (`{ model?: string; language?: string; prompt?: string }`): Server-side transcription for incoming user audio. Defaults to
|
|
101
|
+
**audio.input.transcription** (`{ model?: string; language?: string; prompt?: string }`): Server-side transcription for incoming user audio. Defaults to { model: "inworld/inworld-stt-1" }. prompt biases transcription with vocabulary, spelling, or style hints. Supply your own object to override; set to null to disable user-side transcription.
|
|
102
102
|
|
|
103
|
-
**audio.input.turn\_detection** (`InworldTurnDetection | null`): Voice activity / turn detection. Defaults to
|
|
103
|
+
**audio.input.turn\_detection** (`InworldTurnDetection | null`): Voice activity / turn detection. Defaults to { type: "semantic\_vad", eagerness: "medium", create\_response: true, interrupt\_response: true }. Supply your own object to override; set to null to disable turn detection entirely. The eagerness field controls how quickly semantic VAD ends a user turn — low waits for clearer pauses (more interruption-resistant), high ends turns sooner (snappier, more prone to cutting users off). Default medium balances both. idle\_timeout\_ms (server\_vad only) sets the idle window before the server commits a turn.
|
|
104
104
|
|
|
105
105
|
**tool\_choice** (`string | { type: "function"; name: string } | { type: "mcp"; server_label: string }`): Tool selection strategy. Use the mcp variant to route tool calls through a configured Inworld MCP server.
|
|
106
106
|
|
|
@@ -279,11 +279,11 @@ The `InworldRealtimeVoice` class emits the following events:
|
|
|
279
279
|
|
|
280
280
|
**writing** (`event`): Emitted as transcribed text becomes available. Callback receives { text: string, response\_id: string, role: "assistant" | "user", voiceProfile? }. Deduplicated across audio-transcript and text deltas in the same response so a single response only emits one stream. On user events, voiceProfile is present when providerData.stt.voice\_profile is enabled.
|
|
281
281
|
|
|
282
|
-
**speech-started** (`event`): Raw
|
|
282
|
+
**speech-started** (`event`): Raw input\_audio\_buffer.speech\_started VAD edge from the server.
|
|
283
283
|
|
|
284
|
-
**speech-stopped** (`event`): Raw
|
|
284
|
+
**speech-stopped** (`event`): Raw input\_audio\_buffer.speech\_stopped VAD edge from the server.
|
|
285
285
|
|
|
286
|
-
**interrupted** (`event`): Synthetic client-side signal: emitted once per in-flight
|
|
286
|
+
**interrupted** (`event`): Synthetic client-side signal: emitted once per in-flight response\_id when the user starts speaking. Use this to stop main response playback on barge-in. Callback receives { response\_id: string }. Only carries main-response ids — never back-channel ids — so stopping the matching speaker stream leaves backchannel streams playing (back-channels are meant to overlap user speech and are never cancelled by barge-in).
|
|
287
287
|
|
|
288
288
|
**turn-suggestion** (`event`): Smart-turn endpointing hint for a buffered user utterance. Callback receives { item\_id, utterance\_index, probability, trailing\_silence\_ms?, audio\_duration\_ms?, inference\_ms? }.
|
|
289
289
|
|
|
@@ -303,7 +303,7 @@ The `InworldRealtimeVoice` class emits the following events:
|
|
|
303
303
|
|
|
304
304
|
**memory** (`event`): Emitted with Inworld's rolling summary and facts state, deduplicated by version. Requires providerData.memory.enabled. Callback receives InworldMemoryState.
|
|
305
305
|
|
|
306
|
-
**backchannel** (`event`): Emitted with a PassThrough stream of back-channel PCM audio (short acknowledgements while the user speaks). Each stream's
|
|
306
|
+
**backchannel** (`event`): Emitted with a PassThrough stream of back-channel PCM audio (short acknowledgements while the user speaks). Each stream's .id is a backchannel\_id that never appears in interrupted, so play these on a separate track that barge-in does not stop. Requires providerData.backchannel.enabled.
|
|
307
307
|
|
|
308
308
|
**backchannel.done** (`event`): Emitted when a back-channel finishes. Callback receives { backchannel\_id: string, phrase? }.
|
|
309
309
|
|
|
@@ -84,9 +84,9 @@ const audioStream = await voice.speak('Hello, world!', {
|
|
|
84
84
|
|
|
85
85
|
**options.speakingRate** (`number`): Adjust the speaking rate.
|
|
86
86
|
|
|
87
|
-
**options.temperature** (`number`): Controls voice variability. Honored on
|
|
87
|
+
**options.temperature** (`number`): Controls voice variability. Honored on inworld-tts-1.5-\* models; ignored by inworld-tts-2.
|
|
88
88
|
|
|
89
|
-
**options.deliveryMode** (`'STABLE' | 'BALANCED' | 'CREATIVE'`): Steering control for delivery style. Only honored by
|
|
89
|
+
**options.deliveryMode** (`'STABLE' | 'BALANCED' | 'CREATIVE'`): Steering control for delivery style. Only honored by inworld-tts-2.
|
|
90
90
|
|
|
91
91
|
**options.language** (`string`): BCP-47 language code for this request. Auto-detected when omitted.
|
|
92
92
|
|