@mastra/mcp-docs-server 1.2.15-alpha.1 → 1.2.15-alpha.10
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/a2a.md +75 -2
- package/.docs/docs/agents/processors.md +2 -0
- package/.docs/docs/agents/skills.md +15 -1
- package/.docs/docs/capabilities/channels/overview.md +19 -0
- package/.docs/docs/capabilities/subagents.md +23 -5
- package/.docs/docs/connections/overview.md +94 -0
- package/.docs/docs/datasets/running-experiments.md +18 -0
- package/.docs/docs/evals/overview.md +16 -4
- package/.docs/docs/harness/agent-controller.md +6 -0
- package/.docs/docs/harness/overview.md +26 -0
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/mcp/overview.md +10 -0
- package/.docs/docs/memory/multi-user-threads.md +1 -1
- package/.docs/docs/memory/observational-memory.md +1 -1
- package/.docs/docs/memory/semantic-recall.md +2 -1
- package/.docs/docs/memory/working-memory.md +1 -0
- package/.docs/docs/observability/feedback.md +16 -0
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +1 -0
- package/.docs/docs/server/auth.md +2 -0
- package/.docs/docs/server/mastra-client.md +11 -11
- package/.docs/docs/storage/overview.md +1 -0
- package/.docs/docs/workflows/agents-and-tools.md +2 -2
- package/.docs/docs/workflows/{stored-workflows.md → dynamic-workflows.md} +23 -23
- package/.docs/docs/workflows/snapshots.md +3 -1
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +25 -14
- package/.docs/guides/getting-started/quickstart.md +1 -1
- package/.docs/guides/rag/overview.md +1 -1
- package/.docs/guides/rag/retrieval.md +17 -0
- package/.docs/guides/rag/vector-databases.md +41 -0
- package/.docs/guides/voice/realtime-voice.md +28 -2
- package/.docs/models/gateways/neon.md +15 -9
- package/.docs/models/gateways/netlify.md +1 -2
- package/.docs/models/gateways/openrouter.md +3 -2
- package/.docs/models/gateways/vercel.md +10 -3
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/cortecs.md +2 -1
- package/.docs/models/providers/deepinfra.md +6 -3
- package/.docs/models/providers/digitalocean.md +6 -5
- package/.docs/models/providers/empiriolabs.md +6 -4
- package/.docs/models/providers/friendli.md +8 -9
- package/.docs/models/providers/huggingface.md +4 -1
- package/.docs/models/providers/hyper.md +5 -6
- package/.docs/models/providers/kilo.md +11 -9
- package/.docs/models/providers/llmgateway.md +3 -3
- package/.docs/models/providers/meta.md +7 -5
- package/.docs/models/providers/nano-gpt.md +7 -4
- package/.docs/models/providers/neuralwatt.md +2 -1
- package/.docs/models/providers/ofox.md +74 -16
- package/.docs/models/providers/opencode-go.md +1 -1
- package/.docs/models/providers/opencode.md +2 -3
- package/.docs/models/providers/regolo-ai.md +25 -20
- package/.docs/models/providers/upstage.md +3 -2
- package/.docs/models/providers/vivgrid.md +4 -2
- package/.docs/models/providers/wandb.md +1 -1
- package/.docs/reference/agents/channels.md +22 -1
- package/.docs/reference/agents/generate.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +2 -0
- package/.docs/reference/browser/agent-browser.md +1 -1
- package/.docs/reference/browser/mastra-browser.md +1 -1
- package/.docs/reference/browser/stagehand-browser.md +1 -1
- package/.docs/reference/channels/slack-provider.md +2 -0
- package/.docs/reference/client-js/observability.md +22 -0
- package/.docs/reference/client-js/workflows.md +32 -19
- package/.docs/reference/configuration.md +26 -1
- package/.docs/reference/core/{addStoredWorkflow.md → addDynamicWorkflow.md} +10 -10
- package/.docs/reference/core/{addStoredWorkflows.md → addDynamicWorkflows.md} +9 -9
- package/.docs/reference/editor/tool-provider.md +26 -1
- package/.docs/reference/file-based-agents/config.md +22 -21
- package/.docs/reference/file-based-agents/instructions.md +42 -17
- package/.docs/reference/index.md +6 -3
- package/.docs/reference/observability/metrics/automatic-metrics.md +10 -8
- package/.docs/reference/rag/metadata-filters.md +13 -4
- package/.docs/reference/server/register-api-route.md +2 -0
- package/.docs/reference/server/routes.md +38 -24
- package/.docs/reference/storage/composite.md +58 -0
- package/.docs/reference/storage/oracledb.md +239 -0
- package/.docs/reference/storage/overview.md +9 -9
- package/.docs/reference/storage/retention.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/tools/bedrock-kb-tool.md +117 -0
- package/.docs/reference/tools/mcp-client.md +54 -0
- package/.docs/reference/vectors/oracledb.md +347 -0
- package/.docs/reference/voice/google.md +19 -3
- package/.docs/reference/workflows/{stored-workflow-definition.md → dynamic-workflow-definition.md} +7 -7
- package/.docs/reference/workflows/step.md +40 -0
- package/.docs/reference/workflows/workflow-methods/agent.md +3 -3
- package/.docs/reference/workflows/workflow-methods/tool.md +3 -3
- package/.docs/reference/workspace/daytona-sandbox.md +21 -0
- package/.docs/reference/workspace/workspace-class.md +2 -0
- package/CHANGELOG.md +44 -0
- package/package.json +6 -6
|
@@ -92,7 +92,7 @@ Each domain declares which of its tables can be age-pruned and which timestamp c
|
|
|
92
92
|
> - Experiments prune as whole units: an aged experiment's result rows are deleted together with it (results cascade with their parent), so a run is never left partially deleted. Retention doesn't have a separate `results` key.
|
|
93
93
|
> - For `schedules`, the growth table is the fire history (`schedule_triggers`, one row per fire): schedule definitions are config and aren't pruned.
|
|
94
94
|
> - On PostgreSQL, timestamp anchors use the timezone-aware mirror columns (for example `createdAtZ`, `completedAtZ`).
|
|
95
|
-
> - LibSQL
|
|
95
|
+
> - LibSQL and PostgreSQL support all domains above except `harness`, which PostgreSQL doesn't implement. MongoDB supports all except `threadState` and `harness`.
|
|
96
96
|
> - The v-next PostgreSQL observability domain stores signal events in day-partitioned tables (`spans`, `metrics`, `logs`, `scores`, `feedback`). For it, `prune()` drops whole day partitions (or TimescaleDB chunks) that are entirely older than the cutoff instead of deleting rows: effective level of detail is one day, and a partition is only dropped once its entire day is past `maxAge`. `PruneResult.deleted` reports the number of rows in the dropped partitions.
|
|
97
97
|
|
|
98
98
|
## Methods
|
|
@@ -66,7 +66,7 @@ const stream = await agent.stream('message for agent')
|
|
|
66
66
|
|
|
67
67
|
**options.delegation** (`DelegationConfig`): Configuration for subagent delegation. Use this to control and monitor when the agent delegates tasks to other agents, including the ability to modify, reject delegations, and provide feedback to guide the supervisor.
|
|
68
68
|
|
|
69
|
-
**options.delegation.onDelegationStart** (`(context: DelegationStartContext) => DelegationStartResult | void | Promise<DelegationStartResult | void>`): Called before delegating to a subagent. Use this to modify the delegation parameters
|
|
69
|
+
**options.delegation.onDelegationStart** (`(context: DelegationStartContext) => DelegationStartResult | void | Promise<DelegationStartResult | void>`): Called before delegating to a subagent. Use this to modify the delegation parameters, reject the delegation entirely, or mutate context.requestContext to add entries to the subagent run's request context.
|
|
70
70
|
|
|
71
71
|
**options.delegation.onDelegationComplete** (`(context: DelegationCompleteContext) => { feedback?: string } | void | Promise<{ feedback?: string } | void>`): Called after a subagent delegation completes. The context includes a bail() method to stop further execution, and you can return { feedback } to guide the supervisor's next action. Feedback is saved to supervisor memory as an assistant message.
|
|
72
72
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# createBedrockKBTool()
|
|
4
|
+
|
|
5
|
+
The `createBedrockKBTool()` function creates a tool that retrieves relevant documents from an Amazon Bedrock Knowledge Base. It supports both managed search configuration and agentic retrieval (query decomposition and managed reranking) with automatic fallback to standard retrieval.
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { createBedrockKBTool } from '@mastra/rag'
|
|
11
|
+
|
|
12
|
+
const kbTool = createBedrockKBTool({
|
|
13
|
+
knowledgeBaseId: 'YOUR_KB_ID',
|
|
14
|
+
region: 'us-west-2',
|
|
15
|
+
numberOfResults: 5,
|
|
16
|
+
useAgenticRetrieval: true,
|
|
17
|
+
})
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### With an Agent
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { Agent } from '@mastra/core/agent'
|
|
24
|
+
import { createBedrockKBTool } from '@mastra/rag'
|
|
25
|
+
|
|
26
|
+
const kbTool = createBedrockKBTool({
|
|
27
|
+
knowledgeBaseId: 'YOUR_KB_ID',
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const agent = new Agent({
|
|
31
|
+
name: 'KnowledgeAssistant',
|
|
32
|
+
instructions: 'Use the knowledge base tool to answer questions.',
|
|
33
|
+
model: myModel,
|
|
34
|
+
tools: { kb: kbTool },
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Parameters
|
|
39
|
+
|
|
40
|
+
**knowledgeBaseId** (`string`): The ID of the Amazon Bedrock Knowledge Base to query.
|
|
41
|
+
|
|
42
|
+
**region** (`string`): AWS region where the Knowledge Base is deployed. Defaults to AWS\_REGION environment variable or us-east-1.
|
|
43
|
+
|
|
44
|
+
**numberOfResults** (`number`): Maximum number of results to return. Defaults to 5.
|
|
45
|
+
|
|
46
|
+
**useAgenticRetrieval** (`boolean`): Use AgenticRetrieveStream for complex queries with query decomposition and managed reranking. Falls back to standard Retrieve on failure. Defaults to true (disable with USE\_AGENTIC\_RETRIEVAL=false env var).
|
|
47
|
+
|
|
48
|
+
**userId** (`string`): Default AWS user ID for document-level access control. A userId in the Mastra request context takes precedence.
|
|
49
|
+
|
|
50
|
+
## Input Schema
|
|
51
|
+
|
|
52
|
+
The tool accepts the following input when called by an agent:
|
|
53
|
+
|
|
54
|
+
**queryText** (`string`): The search query to find relevant documents in the knowledge base.
|
|
55
|
+
|
|
56
|
+
## Output Schema
|
|
57
|
+
|
|
58
|
+
The tool returns an object with:
|
|
59
|
+
|
|
60
|
+
**results** (`BedrockKBResult[]`): Array of retrieval results. Standard retrieval includes source and score when Bedrock provides them; agentic retrieval may omit those fields.
|
|
61
|
+
|
|
62
|
+
### BedrockKBResult
|
|
63
|
+
|
|
64
|
+
| Field | Type | Description |
|
|
65
|
+
| ---------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `content` | `string` | The text content of the retrieved passage. |
|
|
67
|
+
| `source` | `string \| undefined` | The source URI when Bedrock provides one. Agentic retrieval only includes this field when the result metadata contains `_source_uri`. |
|
|
68
|
+
| `score` | `number \| undefined` | The relevance score returned by standard retrieval. The agentic API doesn't return a score for result items. |
|
|
69
|
+
| `metadata` | `Record<string, unknown>` | Additional metadata from the retrieval result. |
|
|
70
|
+
|
|
71
|
+
## Retrieval Modes
|
|
72
|
+
|
|
73
|
+
### Agentic Retrieval (default)
|
|
74
|
+
|
|
75
|
+
When `useAgenticRetrieval` is `true` (default), the tool uses `AgenticRetrieveStreamCommand` which:
|
|
76
|
+
|
|
77
|
+
- Decomposes complex queries into sub-queries
|
|
78
|
+
- Retrieves across multiple passes
|
|
79
|
+
- Applies managed reranking for better results
|
|
80
|
+
|
|
81
|
+
If agentic retrieval fails (e.g., older SDK, permissions), it automatically falls back to standard managed retrieval.
|
|
82
|
+
|
|
83
|
+
### Standard Managed Retrieval
|
|
84
|
+
|
|
85
|
+
When `useAgenticRetrieval` is `false`, the tool uses `RetrieveCommand` with `managedSearchConfiguration` for direct single-pass retrieval.
|
|
86
|
+
|
|
87
|
+
## User-based access control
|
|
88
|
+
|
|
89
|
+
Set `userId` in the Mastra request context to forward it as the Bedrock `userContext.userId`. This supports knowledge bases that enforce document-level access control. The request context value overrides the default `userId` configured on the tool.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { RequestContext } from '@mastra/core/request-context'
|
|
93
|
+
|
|
94
|
+
const requestContext = new RequestContext()
|
|
95
|
+
requestContext.set('userId', 'user-123')
|
|
96
|
+
|
|
97
|
+
await agent.generate('Find my private documents', { requestContext })
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Required IAM Permissions
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"Version": "2012-10-17",
|
|
105
|
+
"Statement": [
|
|
106
|
+
{
|
|
107
|
+
"Effect": "Allow",
|
|
108
|
+
"Action": ["bedrock:Retrieve", "bedrock:AgenticRetrieveStream"],
|
|
109
|
+
"Resource": "arn:aws:bedrock:*:*:knowledge-base/*"
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## SDK Requirements
|
|
116
|
+
|
|
117
|
+
- `@aws-sdk/client-bedrock-agent-runtime` >= 3.1000 (AgenticRetrieveStreamCommand requires \~3.1000+)
|
|
@@ -37,6 +37,8 @@ Each server in the `servers` map is configured using the `MastraMCPServerDefinit
|
|
|
37
37
|
|
|
38
38
|
**env** (`Record<string, string>`): For Stdio servers: Environment variables to set for the command.
|
|
39
39
|
|
|
40
|
+
**inheritDefaultEnv** (`boolean`): For Stdio servers: Whether the subprocess environment starts from the MCP SDK's default inherited environment. The default is a curated whitelist, not the full process environment: on POSIX it inherits HOME, LOGNAME, PATH, SHELL, TERM, and USER; on Windows it inherits APPDATA, HOMEDRIVE, HOMEPATH, LOCALAPPDATA, PATH, PROCESSOR\_ARCHITECTURE, SYSTEMDRIVE, SYSTEMROOT, TEMP, USERNAME, and USERPROFILE. When set to false, only the variables explicitly listed in env are passed to the subprocess. Note that a subprocess without PATH may fail to spawn commands that are not absolute paths. (Default: `true`)
|
|
41
|
+
|
|
40
42
|
**url** (`URL`): For HTTP servers (Streamable HTTP or SSE): The URL of the server.
|
|
41
43
|
|
|
42
44
|
**requestInit** (`RequestInit`): For HTTP servers: Request configuration for the fetch API.
|
|
@@ -45,6 +47,8 @@ Each server in the `servers` map is configured using the `MastraMCPServerDefinit
|
|
|
45
47
|
|
|
46
48
|
**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
49
|
|
|
50
|
+
**allowedHosts** (`string[]`): For HTTP servers: Opt-in allowlist of hosts the client may contact on behalf of this server. Each entry is matched against the URL host (hostname plus port when the URL carries a non-default port), for example "api.example.com" or "localhost:8080". Matching is exact and case-insensitive on the hostname; wildcards are not supported and the URL scheme is not checked. An empty array denies all requests. When unset, no restriction is applied. See the Security section below for enforcement details.
|
|
51
|
+
|
|
48
52
|
**logger** (`LogHandler`): Optional additional handler for logging.
|
|
49
53
|
|
|
50
54
|
**timeout** (`number`): Server-specific timeout in milliseconds.
|
|
@@ -159,6 +163,56 @@ When `forwardInstructions` is omitted (the default), instructions are still cach
|
|
|
159
163
|
|
|
160
164
|
> **Security note:** server instructions are forwarded verbatim (subject only to length truncation) into the agent's system prompt. A malicious or compromised MCP server can use them to inject instructions the agent will treat as trusted system guidance. Only enable `forwardInstructions` for servers you trust, and prefer reviewing instructions with `getServerInstructions()` before forwarding instructions from third-party servers.
|
|
161
165
|
|
|
166
|
+
## Security
|
|
167
|
+
|
|
168
|
+
### Subprocess environment for Stdio servers
|
|
169
|
+
|
|
170
|
+
Stdio subprocesses don't inherit the full parent process environment. By default the subprocess environment starts from the MCP SDK's curated whitelist (POSIX: `HOME`, `LOGNAME`, `PATH`, `SHELL`, `TERM`, `USER`; Windows: `APPDATA`, `HOMEDRIVE`, `HOMEPATH`, `LOCALAPPDATA`, `PATH`, `PROCESSOR_ARCHITECTURE`, `SYSTEMDRIVE`, `SYSTEMROOT`, `TEMP`, `USERNAME`, `USERPROFILE`), merged with any variables you set in `env`. Sensitive variables such as API keys aren't inherited unless you pass them explicitly.
|
|
171
|
+
|
|
172
|
+
For stricter isolation, set `inheritDefaultEnv: false` so only your configured `env` entries reach the subprocess:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
const mcp = new MCPClient({
|
|
176
|
+
servers: {
|
|
177
|
+
myTool: {
|
|
178
|
+
command: '/usr/local/bin/my-mcp-server',
|
|
179
|
+
inheritDefaultEnv: false,
|
|
180
|
+
env: { MY_TOOL_API_KEY: process.env.MY_TOOL_API_KEY! },
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Variables you place in `env` are forwarded verbatim, so treat server configurations that come from untrusted sources (for example, user-supplied config files) as untrusted input.
|
|
187
|
+
|
|
188
|
+
### Restricting outbound hosts with `allowedHosts`
|
|
189
|
+
|
|
190
|
+
When HTTP server URLs come from untrusted configuration, an attacker-controlled URL can point the client at internal services (server-side request forgery). Set `allowedHosts` on such servers to restrict which hosts the client will contact:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
const mcp = new MCPClient({
|
|
194
|
+
servers: {
|
|
195
|
+
remote: {
|
|
196
|
+
url: new URL(untrustedConfig.serverUrl),
|
|
197
|
+
allowedHosts: ['api.example.com'],
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
})
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Enforcement details:
|
|
204
|
+
|
|
205
|
+
- On the default fetch path, requests to disallowed hosts, including every redirect hop, are blocked **before** they're sent. Redirects are followed manually (up to 5 hops) so each hop is validated, and the `Authorization` header isn't carried across hops to a different origin (any scheme, host, or port change drops it, matching standard fetch behavior).
|
|
206
|
+
- When you supply a custom `fetch` (or a custom `eventSourceInit.fetch`), the initial URL is still checked before the request, but redirect hops are validated **after the fact** using `response.url`: the outbound hop may occur, and the response is discarded when its final URL points at a disallowed host. A hand-built `Response` with an empty `response.url` skips this post-hoc check.
|
|
207
|
+
- OAuth requests made through `authProvider` (authorization server metadata discovery, token exchange, refresh) are also validated. If your authorization server runs on a different host than the MCP server, add that host to `allowedHosts` too.
|
|
208
|
+
- A blocked host fails the connection with a clear error and is never retried by the reconnect logic.
|
|
209
|
+
|
|
210
|
+
`allowedHosts` is intentionally minimal: it matches exact hosts and doesn't support wildcards or scheme checks. If you need richer policy (scheme checks, IP-range rules), supply a custom `fetch` implementation, which is invoked for every request the client makes.
|
|
211
|
+
|
|
212
|
+
### Treat tool responses as untrusted input
|
|
213
|
+
|
|
214
|
+
Tool results returned by MCP servers flow into your agent's context as model input. A malicious or compromised server can use tool output for prompt injection. The transport client doesn't sanitize tool responses: sanitization policy belongs at the agent layer, where Mastra's [input and output processors](https://mastra.ai/docs/agents/processors) let you inspect, transform, or block content before and after it reaches the model. Combine this with `requireToolApproval` and the `forwardInstructions` security note above when working with third-party servers.
|
|
215
|
+
|
|
162
216
|
## Methods
|
|
163
217
|
|
|
164
218
|
### `listTools()`
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# OracleDB vector store
|
|
4
|
+
|
|
5
|
+
`OracleVector` stores embeddings in Oracle Database `VECTOR` columns and exposes them through Mastra's vector interface. Each logical Mastra vector index is mapped to an Oracle vector table through a registry table, while metadata is stored as Oracle JSON for structured filtering.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
**npm**:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @mastra/oracledb@latest
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**pnpm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mastra/oracledb@latest
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Yarn**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @mastra/oracledb@latest
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Bun**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @mastra/oracledb@latest
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { OracleVector } from '@mastra/oracledb'
|
|
37
|
+
|
|
38
|
+
const vector = new OracleVector({
|
|
39
|
+
id: 'oracle-vector',
|
|
40
|
+
user: process.env.ORACLE_DATABASE_USER,
|
|
41
|
+
password: process.env.ORACLE_DATABASE_PASSWORD,
|
|
42
|
+
connectString: process.env.ORACLE_DATABASE_CONNECT_STRING,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
await vector.createIndex({
|
|
46
|
+
indexName: 'memory_messages',
|
|
47
|
+
dimension: 1536,
|
|
48
|
+
metric: 'cosine',
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
await vector.upsert({
|
|
52
|
+
indexName: 'memory_messages',
|
|
53
|
+
vectors: [embedding],
|
|
54
|
+
metadata: [{ resource_id: 'user-1', thread_id: 'thread-1' }],
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const results = await vector.query({
|
|
58
|
+
indexName: 'memory_messages',
|
|
59
|
+
queryVector,
|
|
60
|
+
topK: 5,
|
|
61
|
+
filter: { resource_id: 'user-1' },
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
By default, `OracleVector` uses exact search with no approximate vector index. Configure IVF or HNSW when your dataset and latency requirements need approximate search.
|
|
66
|
+
|
|
67
|
+
## Constructor options
|
|
68
|
+
|
|
69
|
+
Pass Oracle connection options (`user`, `password`, `connectString`, `pool`, wallet options, or `externalAuth`) directly, or pass `poolManager` to share the pool used by `OracleStore`. The vector-specific options are:
|
|
70
|
+
|
|
71
|
+
**id** (`string`): Unique identifier for this vector store instance.
|
|
72
|
+
|
|
73
|
+
**poolManager** (`OraclePoolManager`): Shared Oracle pool manager. Use this to share one Oracle pool with OracleStore.
|
|
74
|
+
|
|
75
|
+
**schemaName** (`string`): Oracle schema name used to qualify the vector registry and vector tables.
|
|
76
|
+
|
|
77
|
+
**tablePrefix** (`string`): Prefix used for physical Oracle vector tables. (Default: `'MASTRA_VEC'`)
|
|
78
|
+
|
|
79
|
+
**registryTableName** (`string`): Oracle table used to map Mastra logical index names to physical vector tables. (Default: `'MASTRA_VECTOR_INDEXES'`)
|
|
80
|
+
|
|
81
|
+
**defaultIndexConfig** (`OracleVectorIndexConfig`): Default Oracle vector index configuration. (Default: `{ type: 'none', accuracy: 95 }`)
|
|
82
|
+
|
|
83
|
+
**defaultMetadataIndexes** (`string[]`): Metadata fields to index automatically when vector tables are created. (Default: `['thread_id', 'resource_id', 'message_id', 'source_id']`)
|
|
84
|
+
|
|
85
|
+
**defaultVectorFormat** (`'vector' | 'bit' | 'int8'`): Default Oracle vector format for dense, binary, and int8 embeddings. (Default: `'vector'`)
|
|
86
|
+
|
|
87
|
+
**upsertBatchSize** (`number`): Number of vectors sent per Oracle executeMany call. The full upsert commits once after all batches succeed. (Default: `200`)
|
|
88
|
+
|
|
89
|
+
## Constructor examples
|
|
90
|
+
|
|
91
|
+
### Shared pool with OracleStore
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { OracleStore, OracleVector } from '@mastra/oracledb'
|
|
95
|
+
|
|
96
|
+
const storage = new OracleStore({ id: 'oracle-storage', user, password, connectString })
|
|
97
|
+
|
|
98
|
+
const vector = new OracleVector({
|
|
99
|
+
id: 'oracle-vector',
|
|
100
|
+
poolManager: storage.getPoolManager(),
|
|
101
|
+
})
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
For Autonomous Database and mTLS connections, pass `walletLocation`, `walletPassword`, and `configDir` in the same constructor.
|
|
105
|
+
|
|
106
|
+
## Methods
|
|
107
|
+
|
|
108
|
+
### `createIndex()`
|
|
109
|
+
|
|
110
|
+
Creates the registry row, physical Oracle vector table, metadata indexes, and optionally an Oracle vector index.
|
|
111
|
+
|
|
112
|
+
**indexName** (`string`): Logical Mastra index name. The provider maps this to a valid Oracle table name internally.
|
|
113
|
+
|
|
114
|
+
**dimension** (`number`): Vector dimension. This must match the embedding model output size.
|
|
115
|
+
|
|
116
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct' | 'hamming' | 'jaccard'`): Distance metric for similarity search. Binary vectors support hamming and jaccard. (Default: `cosine`)
|
|
117
|
+
|
|
118
|
+
**vectorFormat** (`'vector' | 'bit' | 'int8'`): Oracle vector storage format. (Default: `vector`)
|
|
119
|
+
|
|
120
|
+
**indexConfig** (`OracleVectorIndexConfig`): Oracle vector index configuration. none means exact search with no approximate vector index. (Default: `{ type: 'none', accuracy: 95 }`)
|
|
121
|
+
|
|
122
|
+
**buildIndex** (`boolean`): Whether to build the Oracle vector index when indexConfig.type is ivf or hnsw. (Default: `true`)
|
|
123
|
+
|
|
124
|
+
**metadataIndexes** (`string[]`): Metadata field names to index for faster JSON metadata filtering.
|
|
125
|
+
|
|
126
|
+
#### `OracleVectorIndexConfig`
|
|
127
|
+
|
|
128
|
+
**type** (`'none' | 'ivf' | 'hnsw'`): Oracle vector index type. (Default: `'none'`)
|
|
129
|
+
|
|
130
|
+
**accuracy** (`number`): Target accuracy for approximate vector search. (Default: `95`)
|
|
131
|
+
|
|
132
|
+
**ivf.neighborPartitions** (`number`): Oracle IVF neighbor partitions setting.
|
|
133
|
+
|
|
134
|
+
**hnsw\.neighbors** (`number`): Oracle HNSW neighbor setting.
|
|
135
|
+
|
|
136
|
+
**hnsw\.efConstruction** (`number`): Oracle HNSW build-time construction setting.
|
|
137
|
+
|
|
138
|
+
#### Index configuration
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
await vector.createIndex({
|
|
142
|
+
indexName: 'support_articles',
|
|
143
|
+
dimension: 1536,
|
|
144
|
+
metric: 'cosine',
|
|
145
|
+
indexConfig: {
|
|
146
|
+
type: 'ivf',
|
|
147
|
+
accuracy: 95,
|
|
148
|
+
ivf: {
|
|
149
|
+
neighborPartitions: 32,
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The default is `indexConfig: { type: 'none' }`, which uses exact search and requires no approximate index tuning. Use IVF or HNSW only when your data volume and latency requirements justify approximate search. HNSW is configured with `indexConfig: { type: 'hnsw', hnsw: { neighbors, efConstruction } }` and requires Oracle Vector Pool memory, which `configureVectorMemory()` can allocate for local or self-managed databases.
|
|
156
|
+
|
|
157
|
+
### `upsert()`
|
|
158
|
+
|
|
159
|
+
**indexName** (`string`): Name of the index to upsert vectors into.
|
|
160
|
+
|
|
161
|
+
**vectors** (`number[][]`): Array of embedding vectors.
|
|
162
|
+
|
|
163
|
+
**metadata** (`Record<string, any>[]`): Metadata stored as Oracle JSON. Must align by position with vectors.
|
|
164
|
+
|
|
165
|
+
**ids** (`string[]`): Optional vector IDs. IDs are generated when omitted.
|
|
166
|
+
|
|
167
|
+
### `query()`
|
|
168
|
+
|
|
169
|
+
**indexName** (`string`): Name of the index to query.
|
|
170
|
+
|
|
171
|
+
**queryVector** (`number[]`): Query vector.
|
|
172
|
+
|
|
173
|
+
**topK** (`number`): Number of results to return. (Default: `10`)
|
|
174
|
+
|
|
175
|
+
**filter** (`Record<string, any>`): Mastra metadata filter translated to Oracle JSON predicates.
|
|
176
|
+
|
|
177
|
+
**includeVector** (`boolean`): Whether to include the vector in each result. (Default: `false`)
|
|
178
|
+
|
|
179
|
+
**minScore** (`number`): Minimum similarity score threshold. (Default: `-1`)
|
|
180
|
+
|
|
181
|
+
**queryMode** (`'exact' | 'approx'`): Oracle query mode. Exact search is used by default when no approximate vector index is configured.
|
|
182
|
+
|
|
183
|
+
**targetAccuracy** (`number`): Target accuracy for approximate Oracle vector queries.
|
|
184
|
+
|
|
185
|
+
### `listIndexes()`
|
|
186
|
+
|
|
187
|
+
Returns the logical Mastra index names recorded in the Oracle vector registry table.
|
|
188
|
+
|
|
189
|
+
### `describeIndex()`
|
|
190
|
+
|
|
191
|
+
Returns Oracle index metadata, including the physical table name, dimension, vector count, metric, index type, vector format, and configured accuracy.
|
|
192
|
+
|
|
193
|
+
### `deleteIndex()`
|
|
194
|
+
|
|
195
|
+
Deletes the Oracle vector table and removes the registry entry for the logical index.
|
|
196
|
+
|
|
197
|
+
### `updateVector()`
|
|
198
|
+
|
|
199
|
+
Update vectors by ID or metadata filter. Either `id` or `filter` must be provided, but not both. The `update` object may include `vector`, `metadata`, or both.
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
await vector.updateVector({
|
|
203
|
+
indexName: 'support_articles',
|
|
204
|
+
id: 'doc-1',
|
|
205
|
+
update: { metadata: { status: 'reviewed' } },
|
|
206
|
+
})
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### `deleteVector()`
|
|
210
|
+
|
|
211
|
+
Deletes a single vector by ID.
|
|
212
|
+
|
|
213
|
+
### `deleteVectors()`
|
|
214
|
+
|
|
215
|
+
Deletes multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
|
|
216
|
+
|
|
217
|
+
### `buildIndex()`
|
|
218
|
+
|
|
219
|
+
Builds an Oracle vector index for an existing logical index. If the resolved index type is `none`, this method is a no-op.
|
|
220
|
+
|
|
221
|
+
### `rebuildIndex()`
|
|
222
|
+
|
|
223
|
+
Drops and recreates the Oracle vector index for an existing logical index, typically after changing approximate-index tuning.
|
|
224
|
+
|
|
225
|
+
### Index diagnostics
|
|
226
|
+
|
|
227
|
+
Use `getIndexStatus({ indexName })` to inspect Oracle catalog status, and `indexAccuracyQuery({ indexName, queryVector, topK, targetAccuracy })` to run `DBMS_VECTOR.INDEX_ACCURACY_QUERY` for approximate indexes.
|
|
228
|
+
|
|
229
|
+
### `configureVectorMemory()`
|
|
230
|
+
|
|
231
|
+
Allocates Oracle Vector Pool memory, which HNSW indexes require. This calls `ALTER SYSTEM SET VECTOR_MEMORY_SIZE`, so it requires a privileged connection such as `SYSDBA` or `SYSTEM`.
|
|
232
|
+
|
|
233
|
+
**size** (`string`): Vector pool size, as an integer optionally followed by K, M, or G (for example "512M").
|
|
234
|
+
|
|
235
|
+
**scope** (`'MEMORY' | 'SPFILE' | 'BOTH'`): Oracle ALTER SYSTEM scope. Use 'SPFILE' or 'BOTH' so the setting survives a database restart. (Default: `'MEMORY'`)
|
|
236
|
+
|
|
237
|
+
### `disconnect()`
|
|
238
|
+
|
|
239
|
+
Closes the Oracle pool when `OracleVector` created the pool manager. If you provide `pool` or `poolManager`, you own that lifecycle.
|
|
240
|
+
|
|
241
|
+
## Metadata filters
|
|
242
|
+
|
|
243
|
+
`OracleVector` accepts Mastra's standard metadata filter syntax. Filters are translated into Oracle JSON predicates with bound values:
|
|
244
|
+
|
|
245
|
+
- scalar comparisons use `JSON_VALUE`
|
|
246
|
+
- array, existence, and element-match checks use `JSON_EXISTS`
|
|
247
|
+
- regex filters use `REGEXP_LIKE`
|
|
248
|
+
- string contains filters use case-insensitive `LIKE`
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
const results = await vector.query({
|
|
252
|
+
indexName: 'memory_messages',
|
|
253
|
+
queryVector,
|
|
254
|
+
topK: 5,
|
|
255
|
+
filter: {
|
|
256
|
+
resource_id: 'user-1',
|
|
257
|
+
tags: { $contains: 'support' },
|
|
258
|
+
score: { $gte: 0.8 },
|
|
259
|
+
$or: [{ source: 'docs' }, { source: 'tickets' }],
|
|
260
|
+
},
|
|
261
|
+
})
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Metadata is stored as native Oracle JSON, so the rows are also readable directly with standard Oracle JDBC tools such as DBeaver and SQL Developer.
|
|
265
|
+
|
|
266
|
+
Use `ORACLEDB_PROMPT` when an agent should generate Oracle-compatible metadata filters for `createVectorQueryTool()`:
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
import { Agent } from '@mastra/core/agent'
|
|
270
|
+
import { createVectorQueryTool } from '@mastra/rag'
|
|
271
|
+
import { fastembed } from '@mastra/fastembed'
|
|
272
|
+
import { ORACLEDB_PROMPT } from '@mastra/oracledb'
|
|
273
|
+
|
|
274
|
+
const vectorQueryTool = createVectorQueryTool({
|
|
275
|
+
vectorStoreName: 'oracle',
|
|
276
|
+
indexName: 'support_articles',
|
|
277
|
+
model: fastembed,
|
|
278
|
+
enableFilter: true,
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
export const ragAgent = new Agent({
|
|
282
|
+
id: 'oracle-rag-agent',
|
|
283
|
+
name: 'Oracle RAG Agent',
|
|
284
|
+
model: 'openai/gpt-5.6-sol',
|
|
285
|
+
instructions: `
|
|
286
|
+
Use the retrieval tool when you need source context.
|
|
287
|
+
Available metadata fields: resource_id, thread_id, source, category, tags.
|
|
288
|
+
${ORACLEDB_PROMPT}
|
|
289
|
+
`,
|
|
290
|
+
tools: { vectorQueryTool },
|
|
291
|
+
})
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Response types
|
|
295
|
+
|
|
296
|
+
Query results are returned in this format:
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
interface QueryResult {
|
|
300
|
+
id: string
|
|
301
|
+
score: number
|
|
302
|
+
metadata: Record<string, any>
|
|
303
|
+
vector?: number[]
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Usage example
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
import { Agent } from '@mastra/core/agent'
|
|
311
|
+
import { Memory } from '@mastra/memory'
|
|
312
|
+
import { fastembed } from '@mastra/fastembed'
|
|
313
|
+
import { OracleStore, OracleVector } from '@mastra/oracledb'
|
|
314
|
+
|
|
315
|
+
const storage = new OracleStore({
|
|
316
|
+
id: 'oracle-storage',
|
|
317
|
+
user: process.env.ORACLE_DATABASE_USER,
|
|
318
|
+
password: process.env.ORACLE_DATABASE_PASSWORD,
|
|
319
|
+
connectString: process.env.ORACLE_DATABASE_CONNECT_STRING,
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
const vector = new OracleVector({
|
|
323
|
+
id: 'oracle-vector',
|
|
324
|
+
poolManager: storage.getPoolManager(),
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
export const oracleAgent = new Agent({
|
|
328
|
+
id: 'oracle-agent',
|
|
329
|
+
name: 'Oracle Agent',
|
|
330
|
+
instructions: 'You are an assistant with OracleDB-backed memory and semantic recall.',
|
|
331
|
+
model: 'openai/gpt-5.6-sol',
|
|
332
|
+
memory: new Memory({
|
|
333
|
+
storage,
|
|
334
|
+
vector,
|
|
335
|
+
embedder: fastembed,
|
|
336
|
+
options: {
|
|
337
|
+
semanticRecall: { topK: 3, messageRange: 2 },
|
|
338
|
+
},
|
|
339
|
+
}),
|
|
340
|
+
})
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Related
|
|
344
|
+
|
|
345
|
+
- [OracleDB storage](https://mastra.ai/reference/storage/oracledb)
|
|
346
|
+
- [Metadata Filters](https://mastra.ai/reference/rag/metadata-filters)
|
|
347
|
+
- [Vector databases](https://mastra.ai/guides/rag/vector-databases)
|
|
@@ -109,7 +109,17 @@ Converts speech to text using Google Cloud Speech-to-Text service. Supports both
|
|
|
109
109
|
|
|
110
110
|
Pass `v2: true` to use the Cloud Speech-to-Text v2 API, which supports additional audio formats like AAC-in-MP4 (iOS Safari).
|
|
111
111
|
|
|
112
|
+
The v2 `recognize` call is IAM-authorized and does not accept API-key-only authentication. Configure service account credentials on the `listeningModel` (or set `GOOGLE_APPLICATION_CREDENTIALS`) and set `GOOGLE_CLOUD_PROJECT` so the recognizer path can be resolved, even when `vertexAI` is not enabled.
|
|
113
|
+
|
|
112
114
|
```typescript
|
|
115
|
+
import { GoogleVoice } from '@mastra/voice-google'
|
|
116
|
+
|
|
117
|
+
// v2 listen() requires service account credentials, not just GOOGLE_API_KEY.
|
|
118
|
+
// Set GOOGLE_CLOUD_PROJECT so the recognizer path can be resolved.
|
|
119
|
+
const voice = new GoogleVoice({
|
|
120
|
+
listeningModel: { keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS },
|
|
121
|
+
})
|
|
122
|
+
|
|
113
123
|
const transcript = await voice.listen(iosSafariAacStream, {
|
|
114
124
|
v2: true,
|
|
115
125
|
config: {
|
|
@@ -118,6 +128,8 @@ const transcript = await voice.listen(iosSafariAacStream, {
|
|
|
118
128
|
})
|
|
119
129
|
```
|
|
120
130
|
|
|
131
|
+
> **Note:** `listen({ v2: true })` fails with `PERMISSION_DENIED` on `speech.recognizers.recognize` when only `GOOGLE_API_KEY` is set. An API-key request carries no OAuth identity, so granting `roles/speech.client` to a user account does not help — the role must be granted to the service account presented in the request. This applies regardless of the `vertexAI` setting; `speak()` and v1 `listen()` still work with an API key alone.
|
|
132
|
+
|
|
121
133
|
**audioStream** (`NodeJS.ReadableStream`): Audio stream to transcribe
|
|
122
134
|
|
|
123
135
|
**options** (`GoogleListenOptionsV2`): v2 recognition options
|
|
@@ -162,7 +174,7 @@ The Google Voice provider supports two authentication methods:
|
|
|
162
174
|
|
|
163
175
|
### Standard Mode (API Key)
|
|
164
176
|
|
|
165
|
-
Uses a Google Cloud API key for authentication.
|
|
177
|
+
Uses a Google Cloud API key for authentication. Covers `speak()` and v1 `listen()`. It does not cover `listen({ v2: true })`, which is IAM-authorized and requires service account credentials (see [v2](#v2)).
|
|
166
178
|
|
|
167
179
|
```typescript
|
|
168
180
|
// Using environment variable (GOOGLE_API_KEY)
|
|
@@ -238,6 +250,8 @@ For Speech-to-Text:
|
|
|
238
250
|
|
|
239
251
|
- `roles/speech.client` - Speech-to-Text Client
|
|
240
252
|
|
|
253
|
+
Grant `roles/speech.client` to the service account whose credentials the request presents (via `keyFilename`, `credentials`, or `GOOGLE_APPLICATION_CREDENTIALS`). This role is required for `listen({ v2: true })` specifically, not only for Vertex AI mode. Granting it to a user account has no effect on API-key-only requests, which carry no identity to authorize.
|
|
254
|
+
|
|
241
255
|
#### OAuth Scopes
|
|
242
256
|
|
|
243
257
|
For synchronous Text-to-Speech synthesis:
|
|
@@ -269,6 +283,8 @@ For long-audio Text-to-Speech operations:
|
|
|
269
283
|
|
|
270
284
|
6. The `listen()` method supports various recognition configurations through the Google Cloud Speech-to-Text API.
|
|
271
285
|
|
|
272
|
-
7.
|
|
286
|
+
7. `listen({ v2: true })` requires service account credentials and `GOOGLE_CLOUD_PROJECT`; it fails with `PERMISSION_DENIED` when only `GOOGLE_API_KEY` is set. `speak()` and v1 `listen()` work with an API key alone.
|
|
287
|
+
|
|
288
|
+
8. Available voices can be filtered by language code using the `getSpeakers()` method.
|
|
273
289
|
|
|
274
|
-
|
|
290
|
+
9. Vertex AI mode provides enterprise features including IAM control, audit logs, and project-level billing.
|
package/.docs/reference/workflows/{stored-workflow-definition.md → dynamic-workflow-definition.md}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# Dynamic workflow definition
|
|
4
4
|
|
|
5
|
-
> **Beta:**
|
|
5
|
+
> **Beta:** Dynamic workflows are in beta. Breaking changes may occur without a major version bump until the API is stable.
|
|
6
6
|
|
|
7
|
-
A
|
|
7
|
+
A dynamic workflow definition is a JSON-compatible `DynamicWorkflowGraph` accepted by [`Mastra.addDynamicWorkflow()`](https://mastra.ai/reference/core/addDynamicWorkflow), the stored-workflow server routes, and the Client SDK workflows API.
|
|
8
8
|
|
|
9
|
-
See [
|
|
9
|
+
See [Dynamic workflows](https://mastra.ai/docs/workflows/dynamic-workflows) for a complete setup and usage example.
|
|
10
10
|
|
|
11
11
|
## Definition fields
|
|
12
12
|
|
|
@@ -286,7 +286,7 @@ Validation errors include a dotted path, such as `graph.2.steps.0`, that identif
|
|
|
286
286
|
|
|
287
287
|
## Related
|
|
288
288
|
|
|
289
|
-
- [Use
|
|
290
|
-
- [`Mastra.
|
|
291
|
-
- [`Mastra.
|
|
289
|
+
- [Use dynamic workflows](https://mastra.ai/docs/workflows/dynamic-workflows)
|
|
290
|
+
- [`Mastra.addDynamicWorkflow()`](https://mastra.ai/reference/core/addDynamicWorkflow)
|
|
291
|
+
- [`Mastra.addDynamicWorkflows()`](https://mastra.ai/reference/core/addDynamicWorkflows)
|
|
292
292
|
- [Client SDK workflows API](https://mastra.ai/reference/client-js/workflows)
|