@mastra/mcp-docs-server 1.2.5-alpha.1 → 1.2.5-alpha.3
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/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 +8 -0
- package/package.json +5 -5
- 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
|
@@ -19,7 +19,7 @@ interface ObservabilityRegistryConfig {
|
|
|
19
19
|
|
|
20
20
|
**configSelector** (`ConfigSelector`): Runtime configuration selector function
|
|
21
21
|
|
|
22
|
-
**sensitiveDataFilter** (`boolean | SensitiveDataFilterOptions`): Controls whether a
|
|
22
|
+
**sensitiveDataFilter** (`boolean | SensitiveDataFilterOptions`): Controls whether a SensitiveDataFilter is auto-applied to every configured instance. Defaults to true. Pass false to opt out, or pass a SensitiveDataFilterOptions object to customize fields, redaction token, or redaction style. If a config already includes a SensitiveDataFilter in spanOutputProcessors, it is not duplicated. Pre-instantiated instances are not modified.
|
|
23
23
|
|
|
24
24
|
## `ObservabilityInstanceConfig`
|
|
25
25
|
|
|
@@ -51,9 +51,9 @@ interface ObservabilityInstanceConfig {
|
|
|
51
51
|
|
|
52
52
|
**includeInternalSpans** (`boolean`): Include spans internal to Mastra operations
|
|
53
53
|
|
|
54
|
-
**excludeSpanTypes** (`SpanType[]`): Span types to exclude from export. Useful for reducing noise and costs in per-span billing platforms. See the
|
|
54
|
+
**excludeSpanTypes** (`SpanType[]`): Span types to exclude from export. Useful for reducing noise and costs in per-span billing platforms. See the Span filtering reference for details.
|
|
55
55
|
|
|
56
|
-
**spanFilter** (`(span: AnyExportedSpan) => boolean`): Filter function to control which spans are exported. Return true to keep, false to drop. Runs after excludeSpanTypes and spanOutputProcessors. See the
|
|
56
|
+
**spanFilter** (`(span: AnyExportedSpan) => boolean`): Filter function to control which spans are exported. Return true to keep, false to drop. Runs after excludeSpanTypes and spanOutputProcessors. See the Span filtering reference for details.
|
|
57
57
|
|
|
58
58
|
**requestContextKeys** (`string[]`): RequestContext keys to extract as metadata (supports dot notation)
|
|
59
59
|
|
|
@@ -67,7 +67,7 @@ interface ObservabilityInstanceConfig {
|
|
|
67
67
|
|
|
68
68
|
**serializationOptions.maxObjectKeys** (`number`): Maximum number of keys in objects (default: 50)
|
|
69
69
|
|
|
70
|
-
**logging** (`{ enabled?: boolean; level?: LogLevel }`): Controls log forwarding to observability storage. See
|
|
70
|
+
**logging** (`{ enabled?: boolean; level?: LogLevel }`): Controls log forwarding to observability storage. See Logging to observability storage for details.
|
|
71
71
|
|
|
72
72
|
**logging.enabled** (`boolean`): Set to false to disable log forwarding to observability storage (default: true)
|
|
73
73
|
|
|
@@ -42,7 +42,7 @@ const processor = new LanguageDetector({
|
|
|
42
42
|
|
|
43
43
|
**options.translationQuality** (`'speed' | 'quality' | 'balanced'`): Translation quality preference: 'speed' prioritizes fast translation, 'quality' prioritizes accuracy, 'balanced' balances between speed and quality
|
|
44
44
|
|
|
45
|
-
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal detection agent. Use this to control model behavior like reasoning effort for thinking models (e.g.,
|
|
45
|
+
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal detection agent. Use this to control model behavior like reasoning effort for thinking models (e.g., { openai: { reasoningEffort: 'low' } })
|
|
46
46
|
|
|
47
47
|
## Returns
|
|
48
48
|
|
|
@@ -38,7 +38,7 @@ const processor = new ModerationProcessor({
|
|
|
38
38
|
|
|
39
39
|
**options.chunkWindow** (`number`): Number of previous chunks to include for context when moderating stream chunks. If set to 1, includes the previous part, etc.
|
|
40
40
|
|
|
41
|
-
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal moderation agent. Use this to control model behavior like reasoning effort for thinking models (e.g.,
|
|
41
|
+
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal moderation agent. Use this to control model behavior like reasoning effort for thinking models (e.g., { openai: { reasoningEffort: 'low' } })
|
|
42
42
|
|
|
43
43
|
## Returns
|
|
44
44
|
|
|
@@ -40,7 +40,7 @@ const processor = new PIIDetector({
|
|
|
40
40
|
|
|
41
41
|
**options.preserveFormat** (`boolean`): Whether to preserve PII format during redaction. When true, maintains structure like \*\*\*-\*\*-1234 for phone numbers
|
|
42
42
|
|
|
43
|
-
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal detection agent. Use this to control model behavior like reasoning effort for thinking models (e.g.,
|
|
43
|
+
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal detection agent. Use this to control model behavior like reasoning effort for thinking models (e.g., { openai: { reasoningEffort: 'low' } })
|
|
44
44
|
|
|
45
45
|
## Returns
|
|
46
46
|
|
|
@@ -145,7 +145,7 @@ interface Processor<TId extends string = string, TTripwireMetadata = unknown> {
|
|
|
145
145
|
|
|
146
146
|
**processorIndex** (`number`): Position of the processor in the combined processor list. Set at runtime by Mastra when processors are merged with memory, workspace, and per-call overrides. You do not set this yourself.
|
|
147
147
|
|
|
148
|
-
**processDataParts** (`boolean`): When true, the processOutputStream method also receives
|
|
148
|
+
**processDataParts** (`boolean`): When true, the processOutputStream method also receives data-\* chunks emitted by tools via writer.custom(). Defaults to false.
|
|
149
149
|
|
|
150
150
|
**onViolation** (`(violation: ProcessorViolation) => void | Promise<void>`): Optional callback invoked when the processor detects a policy violation, regardless of strategy (block or warn). Use for side effects like alerting, logging to external systems, or emailing users. Errors thrown by this callback are silently caught to prevent interfering with processor logic. The violation object contains processorId, message, and a processor-specific detail field.
|
|
151
151
|
|
|
@@ -226,7 +226,7 @@ processInput?(args: ProcessInputArgs): Promise<ProcessInputResult> | ProcessInpu
|
|
|
226
226
|
|
|
227
227
|
**messageList** (`MessageList`): Full MessageList instance for advanced message management.
|
|
228
228
|
|
|
229
|
-
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution. Pass
|
|
229
|
+
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution. Pass retry: true to request the LLM retry the step with feedback.
|
|
230
230
|
|
|
231
231
|
**retryCount** (`number`): Number of times processors have triggered retry for this generation. Use this to limit retry attempts. Always passed by Mastra; starts at 0.
|
|
232
232
|
|
|
@@ -301,9 +301,9 @@ processInputStep?<TTripwireMetadata = unknown>(
|
|
|
301
301
|
|
|
302
302
|
**structuredOutput** (`StructuredOutputOptions`): Structured output configuration (schema, output mode). Return in result to modify.
|
|
303
303
|
|
|
304
|
-
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution. Pass
|
|
304
|
+
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution. Pass retry: true to request the LLM retry the step with feedback.
|
|
305
305
|
|
|
306
|
-
**retryCount** (`number`): Current retry attempt count from
|
|
306
|
+
**retryCount** (`number`): Current retry attempt count from ProcessorContext. Starts at 0; use to cap processor-triggered retries.
|
|
307
307
|
|
|
308
308
|
**tracingContext** (`TracingContext`): Tracing context for observability.
|
|
309
309
|
|
|
@@ -391,15 +391,15 @@ processLLMRequest?(
|
|
|
391
391
|
|
|
392
392
|
**state** (`Record<string, unknown>`): Per-processor state that persists across all method calls within this request.
|
|
393
393
|
|
|
394
|
-
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution and emits a
|
|
394
|
+
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution and emits a tripwire chunk.
|
|
395
395
|
|
|
396
|
-
**retryCount** (`number`): Current retry attempt count from
|
|
396
|
+
**retryCount** (`number`): Current retry attempt count from ProcessorContext. Starts at 0; use to cap processor-triggered retries.
|
|
397
397
|
|
|
398
398
|
**requestContext** (`RequestContext`): Request-scoped context with execution metadata.
|
|
399
399
|
|
|
400
400
|
**tracingContext** (`TracingContext`): Tracing context for observability.
|
|
401
401
|
|
|
402
|
-
**writer** (`ProcessorStreamWriter`): Stream writer for emitting custom data chunks during streaming. Use
|
|
402
|
+
**writer** (`ProcessorStreamWriter`): Stream writer for emitting custom data chunks during streaming. Use writer.custom() to send transient UI signals.
|
|
403
403
|
|
|
404
404
|
**abortSignal** (`AbortSignal`): Signal for cancelling the operation.
|
|
405
405
|
|
|
@@ -432,7 +432,7 @@ processLLMResponse?(
|
|
|
432
432
|
|
|
433
433
|
#### `ProcessLLMResponseArgs`
|
|
434
434
|
|
|
435
|
-
**chunks** (`CachedLLMStepChunk[]`): Chunks produced by the LLM call (or replayed from cache) for this step, in stripped form (
|
|
435
|
+
**chunks** (`CachedLLMStepChunk[]`): Chunks produced by the LLM call (or replayed from cache) for this step, in stripped form ({ type, payload }).
|
|
436
436
|
|
|
437
437
|
**model** (`MastraLanguageModel`): The model that produced (or would have produced) the response.
|
|
438
438
|
|
|
@@ -440,9 +440,9 @@ processLLMResponse?(
|
|
|
440
440
|
|
|
441
441
|
**steps** (`StepResult[]`): All completed steps so far, including this step.
|
|
442
442
|
|
|
443
|
-
**state** (`Record<string, unknown>`): Per-processor state shared with
|
|
443
|
+
**state** (`Record<string, unknown>`): Per-processor state shared with processLLMRequest for the same step. Use this to pass data between the two hooks (e.g. a cache key).
|
|
444
444
|
|
|
445
|
-
**fromCache** (`boolean`): When
|
|
445
|
+
**fromCache** (`boolean`): When true, the response was replayed from a cache via processLLMRequest returning { response }. Processors that write to a cache should skip writes when this is true.
|
|
446
446
|
|
|
447
447
|
**warnings** (`LanguageModelV2CallWarning[]`): Warnings reported by the language model call (e.g. unsupported settings).
|
|
448
448
|
|
|
@@ -452,7 +452,7 @@ processLLMResponse?(
|
|
|
452
452
|
|
|
453
453
|
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution.
|
|
454
454
|
|
|
455
|
-
**retryCount** (`number`): Current retry attempt count. Starts at
|
|
455
|
+
**retryCount** (`number`): Current retry attempt count. Starts at 0; use to cap processor-triggered retries.
|
|
456
456
|
|
|
457
457
|
**requestContext** (`RequestContext`): Request-scoped context with execution metadata.
|
|
458
458
|
|
|
@@ -504,7 +504,7 @@ processAPIError?(args: ProcessAPIErrorArgs): Promise<ProcessAPIErrorResult | voi
|
|
|
504
504
|
|
|
505
505
|
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing.
|
|
506
506
|
|
|
507
|
-
**writer** (`ProcessorStreamWriter`): Stream writer for emitting custom data chunks during streaming. Use
|
|
507
|
+
**writer** (`ProcessorStreamWriter`): Stream writer for emitting custom data chunks during streaming. Use writer.custom() to send transient UI signals.
|
|
508
508
|
|
|
509
509
|
**requestContext** (`RequestContext`): Request context passed through from the agent call.
|
|
510
510
|
|
|
@@ -568,9 +568,9 @@ processOutputStream?(args: ProcessOutputStreamArgs): Promise<ChunkType | null |
|
|
|
568
568
|
|
|
569
569
|
**state** (`Record<string, unknown>`): Mutable per-processor state that persists across every chunk and every method call within a single request. A fresh state object is created for each new generate or stream call.
|
|
570
570
|
|
|
571
|
-
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort the stream. Throws a TripWire error that ends the stream and emits a
|
|
571
|
+
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort the stream. Throws a TripWire error that ends the stream and emits a tripwire chunk. Pass retry: true to request another LLM attempt instead of ending.
|
|
572
572
|
|
|
573
|
-
**retryCount** (`number`): Current retry attempt count from
|
|
573
|
+
**retryCount** (`number`): Current retry attempt count from ProcessorContext. Starts at 0; use to cap processor-triggered retries.
|
|
574
574
|
|
|
575
575
|
**messageList** (`MessageList`): MessageList instance for accessing conversation history.
|
|
576
576
|
|
|
@@ -608,11 +608,11 @@ processOutputResult?(args: ProcessOutputResultArgs): ProcessorMessageResult;
|
|
|
608
608
|
|
|
609
609
|
**state** (`Record<string, unknown>`): Per-processor state that persists across all method calls within this request. Shared with processOutputStream and other methods.
|
|
610
610
|
|
|
611
|
-
**result** (`OutputResult`): Resolved generation result containing
|
|
611
|
+
**result** (`OutputResult`): Resolved generation result containing text (accumulated text), usage (token usage with inputTokens, outputTokens, totalTokens), finishReason (why generation ended), and steps (all LLM step results, each with toolCalls, toolResults, reasoning, sources, files, etc.).
|
|
612
612
|
|
|
613
|
-
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution and emits a
|
|
613
|
+
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution and emits a tripwire chunk.
|
|
614
614
|
|
|
615
|
-
**retryCount** (`number`): Current retry attempt count from
|
|
615
|
+
**retryCount** (`number`): Current retry attempt count from ProcessorContext. Starts at 0; use to cap processor-triggered retries.
|
|
616
616
|
|
|
617
617
|
**tracingContext** (`TracingContext`): Tracing context for observability.
|
|
618
618
|
|
|
@@ -640,13 +640,13 @@ processOutputStep?(args: ProcessOutputStepArgs): ProcessorMessageResult;
|
|
|
640
640
|
|
|
641
641
|
**finishReason** (`string`): The finish reason from the LLM (stop, tool-use, length, etc.).
|
|
642
642
|
|
|
643
|
-
**providerMetadata** (`ProviderMetadata`): Provider-specific metadata for the finishing step (e.g. AWS Bedrock guardrail trace). Present when the model step produced provider metadata, including on content-filter blocks where
|
|
643
|
+
**providerMetadata** (`ProviderMetadata`): Provider-specific metadata for the finishing step (e.g. AWS Bedrock guardrail trace). Present when the model step produced provider metadata, including on content-filter blocks where steps is empty.
|
|
644
644
|
|
|
645
645
|
**toolCalls** (`ToolCallInfo[]`): Tool calls made in this step (if any).
|
|
646
646
|
|
|
647
647
|
**text** (`string`): Generated text from this step.
|
|
648
648
|
|
|
649
|
-
**usage** (`LanguageModelUsage`): Token usage for the current step (
|
|
649
|
+
**usage** (`LanguageModelUsage`): Token usage for the current step (inputTokens, outputTokens, totalTokens).
|
|
650
650
|
|
|
651
651
|
**systemMessages** (`CoreMessage[]`): All system messages for read/modify access.
|
|
652
652
|
|
|
@@ -654,7 +654,7 @@ processOutputStep?(args: ProcessOutputStepArgs): ProcessorMessageResult;
|
|
|
654
654
|
|
|
655
655
|
**state** (`Record<string, unknown>`): Per-processor state that persists across all method calls within this request. Shared with processOutputStream and processOutputResult.
|
|
656
656
|
|
|
657
|
-
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Pass
|
|
657
|
+
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Pass retry: true to request the LLM retry the step.
|
|
658
658
|
|
|
659
659
|
**retryCount** (`number`): Number of times processors have triggered retry. Use this to limit retry attempts. Always passed by Mastra; starts at 0.
|
|
660
660
|
|
|
@@ -36,7 +36,7 @@ const processor = new PromptInjectionDetector({
|
|
|
36
36
|
|
|
37
37
|
**options.lastMessageOnly** (`boolean`): Whether to inspect only the most recent message in the batch instead of checking every message. Use this to avoid extra LLM calls for earlier conversation history.
|
|
38
38
|
|
|
39
|
-
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal detection agent. Use this to control model behavior like reasoning effort for thinking models (e.g.,
|
|
39
|
+
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal detection agent. Use this to control model behavior like reasoning effort for thinking models (e.g., { openai: { reasoningEffort: 'low' } })
|
|
40
40
|
|
|
41
41
|
## Returns
|
|
42
42
|
|
|
@@ -41,17 +41,17 @@ See [Response caching](https://mastra.ai/docs/agents/processors) for the concept
|
|
|
41
41
|
|
|
42
42
|
## Constructor parameters
|
|
43
43
|
|
|
44
|
-
**cache** (`MastraServerCache`): The cache backend. Required. Pass any
|
|
44
|
+
**cache** (`MastraServerCache`): The cache backend. Required. Pass any MastraServerCache implementation — InMemoryServerCache for local development, RedisCache from @mastra/redis for production, or your own subclass for a custom backend.
|
|
45
45
|
|
|
46
46
|
**ttl** (`number`): Time-to-live (seconds) for entries written by this processor. Defaults to 300 seconds (5 minutes), matching OpenRouter's reference implementation. (Default: `300`)
|
|
47
47
|
|
|
48
|
-
**scope** (`string | null`): Tenant scope appended to the cache key.
|
|
48
|
+
**scope** (`string | null`): Tenant scope appended to the cache key. null opts out of scoping. When omitted, the processor falls back to the resource id resolved from the request context (MASTRA\_RESOURCE\_ID\_KEY) for automatic per-user isolation.
|
|
49
49
|
|
|
50
|
-
**key** (`string | (inputs: ResponseCacheKeyInputs) => string | Promise<string>`): Override the auto-derived cache key. Pass a string to pin a key, or a function that receives
|
|
50
|
+
**key** (`string | (inputs: ResponseCacheKeyInputs) => string | Promise<string>`): Override the auto-derived cache key. Pass a string to pin a key, or a function that receives { agentId, scope, model, prompt, stepNumber } and returns a key. If the function throws, the processor falls back to the deterministic hash so the call still benefits from caching.
|
|
51
51
|
|
|
52
52
|
**bust** (`boolean`): Force a cache miss on every call: skip the read but still write on completion. Useful for explicit refresh paths. (Default: `false`)
|
|
53
53
|
|
|
54
|
-
**agentId** (`string`): Logical id used in the cache key namespace. Defaults to
|
|
54
|
+
**agentId** (`string`): Logical id used in the cache key namespace. Defaults to 'mastra-response-cache'. Set this to the owning agent's id when you want cache entries scoped per-agent. (Default: `'mastra-response-cache'`)
|
|
55
55
|
|
|
56
56
|
## Static helpers
|
|
57
57
|
|
|
@@ -84,7 +84,7 @@ The shape passed to `ResponseCache.context()` / `ResponseCache.applyContext()`.
|
|
|
84
84
|
|
|
85
85
|
**key** (`string | (inputs: ResponseCacheKeyInputs) => string | Promise<string>`): Overrides the auto-derived cache key for this request only.
|
|
86
86
|
|
|
87
|
-
**scope** (`string | null`): Overrides the tenant scope for this request only.
|
|
87
|
+
**scope** (`string | null`): Overrides the tenant scope for this request only. null opts out of scoping.
|
|
88
88
|
|
|
89
89
|
**bust** (`boolean`): Skip the cache read but still write on completion.
|
|
90
90
|
|
|
@@ -96,7 +96,7 @@ The argument passed to a `key` function (constructor or per-call). All fields co
|
|
|
96
96
|
|
|
97
97
|
**agentId** (`string`): Logical processor id used to namespace the cache key.
|
|
98
98
|
|
|
99
|
-
**scope** (`string | null | undefined`): Resolved scope for this request, or
|
|
99
|
+
**scope** (`string | null | undefined`): Resolved scope for this request, or null when scoping is disabled.
|
|
100
100
|
|
|
101
101
|
**model** (`{ provider?: string; modelId?: string; specVersion?: string }`): Provider/model identity. Different models produce different responses.
|
|
102
102
|
|
|
@@ -19,7 +19,7 @@ const processor = new UnicodeNormalizer({
|
|
|
19
19
|
|
|
20
20
|
**options** (`Options`): Configuration options for Unicode text normalization
|
|
21
21
|
|
|
22
|
-
**options.stripControlChars** (`boolean`): Whether to strip control characters. When enabled, removes control characters except
|
|
22
|
+
**options.stripControlChars** (`boolean`): Whether to strip control characters. When enabled, removes control characters except , ,
|
|
23
23
|
|
|
24
24
|
**options.preserveEmojis** (`boolean`): Whether to preserve emojis. When disabled, emojis may be removed if they contain control characters
|
|
25
25
|
|
|
@@ -137,9 +137,9 @@ await pubsub.subscribeFromOffset('my-topic', 42, event => {
|
|
|
137
137
|
|
|
138
138
|
## Properties
|
|
139
139
|
|
|
140
|
-
**supportedModes** (`ReadonlyArray<"pull" | "push">`): Delivery modes the implementation supports. Defaults to
|
|
140
|
+
**supportedModes** (`ReadonlyArray<"pull" | "push">`): Delivery modes the implementation supports. Defaults to \["pull"].
|
|
141
141
|
|
|
142
|
-
**supportsNativeBatching** (`boolean`): Whether the implementation honors
|
|
142
|
+
**supportsNativeBatching** (`boolean`): Whether the implementation honors options.batch on subscribe(). Defaults to false. Backends that integrate batching internally override this and return true.
|
|
143
143
|
|
|
144
144
|
## Types
|
|
145
145
|
|
|
@@ -163,7 +163,7 @@ await pubsub.subscribeFromOffset('my-topic', 42, event => {
|
|
|
163
163
|
|
|
164
164
|
**group** (`string`): When set, subscribers with the same group compete for messages and each event is delivered to one member. When omitted, every subscriber receives every event.
|
|
165
165
|
|
|
166
|
-
**batch** (`SubscribeBatchOptions`): Opt in to batched delivery for this subscription. When omitted, events are delivered one at a time. Honored only by backends where
|
|
166
|
+
**batch** (`SubscribeBatchOptions`): Opt in to batched delivery for this subscription. When omitted, events are delivered one at a time. Honored only by backends where supportsNativeBatching is true.
|
|
167
167
|
|
|
168
168
|
### `SubscribeBatchOptions`
|
|
169
169
|
|
|
@@ -173,15 +173,15 @@ Per-subscription batching policy. The callback signature doesn't change; a batch
|
|
|
173
173
|
|
|
174
174
|
**maxWaitMs** (`number`): Maximum time in milliseconds the oldest event may sit in the buffer. The timer starts when the buffer transitions from empty to non-empty.
|
|
175
175
|
|
|
176
|
-
**minIntervalMs** (`number`): Minimum time in milliseconds between consecutive batch deliveries. Even when
|
|
176
|
+
**minIntervalMs** (`number`): Minimum time in milliseconds between consecutive batch deliveries. Even when maxSize or maxWaitMs would fire, the buffer holds until this interval has elapsed since the last delivery.
|
|
177
177
|
|
|
178
|
-
**isImmediate** (`(event: Event) => boolean`): When it returns
|
|
178
|
+
**isImmediate** (`(event: Event) => boolean`): When it returns true for an event, the buffer flushes immediately on publish, subject to minIntervalMs. A per-event escape hatch.
|
|
179
179
|
|
|
180
|
-
**coalesce** (`(events: Event[]) => Event[]`): Applied to the queued batch before delivery to drop superseded events. Must return a subset of its input by reference identity; returning freshly constructed
|
|
180
|
+
**coalesce** (`(events: Event[]) => Event[]`): Applied to the queued batch before delivery to drop superseded events. Must return a subset of its input by reference identity; returning freshly constructed Event objects is a contract violation and discards the whole batch. Ordering of kept events is preserved.
|
|
181
181
|
|
|
182
182
|
**maxBufferSize** (`number`): Maximum events the buffer may hold before overflow handling kicks in. Events flagged immediate are never dropped on overflow. (Default: `256`)
|
|
183
183
|
|
|
184
|
-
**overflow** (`"drop-oldest" | "drop-newest" | "coalesce-or-drop-oldest"`): Overflow strategy when the buffer exceeds
|
|
184
|
+
**overflow** (`"drop-oldest" | "drop-newest" | "coalesce-or-drop-oldest"`): Overflow strategy when the buffer exceeds maxBufferSize. coalesce-or-drop-oldest runs coalesce first, then drops oldest if still over budget. (Default: `coalesce-or-drop-oldest`)
|
|
185
185
|
|
|
186
186
|
### `EventCallback`
|
|
187
187
|
|
|
@@ -44,7 +44,7 @@ const pubsub = withCaching(new EventEmitterPubSub(), new InMemoryServerCache())
|
|
|
44
44
|
|
|
45
45
|
## Properties
|
|
46
46
|
|
|
47
|
-
**supportsNativeBatching** (`boolean`): Mirrors the inner pub/sub. Returns
|
|
47
|
+
**supportsNativeBatching** (`boolean`): Mirrors the inner pub/sub. Returns true only when the wrapped implementation supports batching.
|
|
48
48
|
|
|
49
49
|
## Methods
|
|
50
50
|
|
|
@@ -47,9 +47,9 @@ const pubsub = new EventEmitterPubSub(undefined, { logger })
|
|
|
47
47
|
|
|
48
48
|
## Properties
|
|
49
49
|
|
|
50
|
-
**supportedModes** (`ReadonlyArray<"pull" | "push">`): Returns
|
|
50
|
+
**supportedModes** (`ReadonlyArray<"pull" | "push">`): Returns \["pull", "push"]. The emitter can serve a pull-style worker or push events directly to listeners.
|
|
51
51
|
|
|
52
|
-
**supportsNativeBatching** (`boolean`): Returns
|
|
52
|
+
**supportsNativeBatching** (`boolean`): Returns true. Subscribers can opt in to batched delivery with options.batch.
|
|
53
53
|
|
|
54
54
|
## Methods
|
|
55
55
|
|
|
@@ -51,7 +51,7 @@ export const mastra = new Mastra({
|
|
|
51
51
|
|
|
52
52
|
## Constructor parameters
|
|
53
53
|
|
|
54
|
-
**config** (`ClientConfig`): Configuration for the Google Cloud Pub/Sub client, including credentials and project ID. See the
|
|
54
|
+
**config** (`ClientConfig`): Configuration for the Google Cloud Pub/Sub client, including credentials and project ID. See the @google-cloud/pubsub client documentation for all fields.
|
|
55
55
|
|
|
56
56
|
## Methods
|
|
57
57
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# LeaseProvider
|
|
4
4
|
|
|
5
|
-
`LeaseProvider` is the distributed leasing contract, separate from event delivery ([`PubSub`](https://mastra.ai/reference/pubsub/base)). Mastra's [signals layer](https://mastra.ai/docs/agents/signals) uses it to elect a single owner across multiple processes (for example, serverless invocations) for a given resource, most commonly a thread key. The owner is the process that wakes and runs the agent stream, so other processes route follow-up work to it instead of starting a competing run.
|
|
5
|
+
`LeaseProvider` is the distributed leasing contract, separate from event delivery ([`PubSub`](https://mastra.ai/reference/pubsub/base)). Mastra's [signals layer](https://mastra.ai/docs/long-running-agents/signals) uses it to elect a single owner across multiple processes (for example, serverless invocations) for a given resource, most commonly a thread key. The owner is the process that wakes and runs the agent stream, so other processes route follow-up work to it instead of starting a competing run.
|
|
6
6
|
|
|
7
7
|
Leasing is a distinct concern from pub/sub. A backend implements `LeaseProvider` only when it can genuinely coordinate a lock, such as Redis via atomic `SET`/Lua, or an in-memory map for single-process. Backends that cannot lease omit it; the signals runtime feature-detects the capability and falls back to a no-op provider, preserving single-process behavior.
|
|
8
8
|
|
|
@@ -62,7 +62,7 @@ Returns: `Promise<{ acquired: boolean; owner?: string }>`
|
|
|
62
62
|
|
|
63
63
|
**key** (`string`): The lease key, such as a thread key.
|
|
64
64
|
|
|
65
|
-
**owner** (`string`): Identifier for the owner, such as a
|
|
65
|
+
**owner** (`string`): Identifier for the owner, such as a runId. The same owner can call acquireLease idempotently to renew or release.
|
|
66
66
|
|
|
67
67
|
**ttlMs** (`number`): Time-to-live in milliseconds for the lease.
|
|
68
68
|
|
|
@@ -129,5 +129,5 @@ When the configured pub/sub backend does not implement `LeaseProvider`, the runt
|
|
|
129
129
|
|
|
130
130
|
- [PubSub](https://mastra.ai/reference/pubsub/base): The event delivery contract, separate from leasing
|
|
131
131
|
- [RedisStreamsPubSub](https://mastra.ai/reference/pubsub/redis-streams): The built-in backend that implements `LeaseProvider`
|
|
132
|
-
- [Signals](https://mastra.ai/docs/agents/signals): The runtime that uses leasing to coordinate thread runs across processes
|
|
132
|
+
- [Signals](https://mastra.ai/docs/long-running-agents/signals): The runtime that uses leasing to coordinate thread runs across processes
|
|
133
133
|
- [Channels](https://mastra.ai/docs/agents/channels): Uses leasing to coordinate agent runs in serverless and multi-instance deployments
|
|
@@ -53,13 +53,13 @@ export const mastra = new Mastra({
|
|
|
53
53
|
|
|
54
54
|
## Constructor parameters
|
|
55
55
|
|
|
56
|
-
**url** (`string`): Redis connection URL. Falls back to
|
|
56
|
+
**url** (`string`): Redis connection URL. Falls back to redisOptions.url. (Default: `redis://localhost:6379`)
|
|
57
57
|
|
|
58
|
-
**keyPrefix** (`string`): Prefix for stream keys. Each topic maps to
|
|
58
|
+
**keyPrefix** (`string`): Prefix for stream keys. Each topic maps to \<keyPrefix>:\<topic>. (Default: `mastra:topic`)
|
|
59
59
|
|
|
60
60
|
**blockMs** (`number`): How long, in milliseconds, each read blocks while waiting for new events. (Default: `1000`)
|
|
61
61
|
|
|
62
|
-
**redisOptions** (`RedisClientOptions`): Options passed to the underlying
|
|
62
|
+
**redisOptions** (`RedisClientOptions`): Options passed to the underlying redis client for advanced configuration.
|
|
63
63
|
|
|
64
64
|
**maxStreamLength** (`number`): Approximate maximum number of entries kept per stream. Set to 0 to disable trimming. (Default: `10000`)
|
|
65
65
|
|
|
@@ -67,13 +67,13 @@ export const mastra = new Mastra({
|
|
|
67
67
|
|
|
68
68
|
**reclaimIdleMs** (`number`): Minimum idle time, in milliseconds, before a pending event is eligible for reclaim. Keep this well above typical processing time to avoid double delivery. (Default: `60000`)
|
|
69
69
|
|
|
70
|
-
**maxDeliveryAttempts** (`number`): Maximum times an event is redelivered through
|
|
70
|
+
**maxDeliveryAttempts** (`number`): Maximum times an event is redelivered through nack before it is dropped. Pass Infinity to disable the cap. (Default: `5`)
|
|
71
71
|
|
|
72
72
|
**logger** (`{ debug?: Function; warn?: Function }`): Optional logger for diagnostics. When omitted, suppressed errors are silent.
|
|
73
73
|
|
|
74
74
|
## Properties
|
|
75
75
|
|
|
76
|
-
**supportedModes** (`ReadonlyArray<"pull" | "push">`): Returns
|
|
76
|
+
**supportedModes** (`ReadonlyArray<"pull" | "push">`): Returns \["pull"].
|
|
77
77
|
|
|
78
78
|
## Methods
|
|
79
79
|
|
|
@@ -111,7 +111,7 @@ When a subscriber calls `nack`, the event is republished with an incremented `de
|
|
|
111
111
|
|
|
112
112
|
## Distributed leasing
|
|
113
113
|
|
|
114
|
-
`RedisStreamsPubSub` implements the [`LeaseProvider`](https://mastra.ai/reference/pubsub/lease-provider) contract on top of the same Redis connection. The [signals runtime](https://mastra.ai/docs/agents/signals) uses it to elect a single owner (usually per thread key) so that across instances only one process wakes and runs the agent, and others route follow-up work to the holder. This is what makes signals work on serverless and multi-instance deployments; without a shared lease, each instance would start its own competing run.
|
|
114
|
+
`RedisStreamsPubSub` implements the [`LeaseProvider`](https://mastra.ai/reference/pubsub/lease-provider) contract on top of the same Redis connection. The [signals runtime](https://mastra.ai/docs/long-running-agents/signals) uses it to elect a single owner (usually per thread key) so that across instances only one process wakes and runs the agent, and others route follow-up work to the holder. This is what makes signals work on serverless and multi-instance deployments; without a shared lease, each instance would start its own competing run.
|
|
115
115
|
|
|
116
116
|
Lease keys are namespaced under the same `keyPrefix` as topics, as `<keyPrefix>:lease:<key>`. All operations are atomic: `acquireLease` uses `SET NX PX` and refreshes its own TTL idempotently, while `releaseLease`, `renewLease`, and `transferLease` use Lua scripts that check ownership before mutating, so a concurrent renewal from another owner is never clobbered.
|
|
117
117
|
|
|
@@ -31,7 +31,7 @@ export const mastra = new Mastra({
|
|
|
31
31
|
|
|
32
32
|
**socketPath** (`string`): The socket path passed to the constructor.
|
|
33
33
|
|
|
34
|
-
**supportedModes** (`ReadonlyArray<"pull" | "push">`): Returns
|
|
34
|
+
**supportedModes** (`ReadonlyArray<"pull" | "push">`): Returns \["push"].
|
|
35
35
|
|
|
36
36
|
**isBroker** (`boolean`): Whether this instance currently acts as the broker.
|
|
37
37
|
|
|
@@ -178,9 +178,9 @@ The options documented below are passed directly at the top level of the configu
|
|
|
178
178
|
|
|
179
179
|
**joinThreshold** (`number`): Maximum token count for merging related sections. Sections exceeding this limit individually are left intact, but smaller sections are merged with siblings or parents if the combined size stays under this threshold. (Default: `500`)
|
|
180
180
|
|
|
181
|
-
**modelName** (`string`): Name of the model for tokenization. If provided, the model's underlying tokenization
|
|
181
|
+
**modelName** (`string`): Name of the model for tokenization. If provided, the model's underlying tokenization encodingName will be used.
|
|
182
182
|
|
|
183
|
-
**encodingName** (`string`): Name of the token encoding to use. Derived from
|
|
183
|
+
**encodingName** (`string`): Name of the token encoding to use. Derived from modelName if available. (Default: `cl100k_base`)
|
|
184
184
|
|
|
185
185
|
**allowedSpecial** (`Set<string> | 'all'`): Set of special tokens allowed during tokenization, or 'all' to allow all special tokens
|
|
186
186
|
|
|
@@ -22,9 +22,9 @@ function createRoute<TPath, TQuery, TBody, TResponse, TResponseType>(
|
|
|
22
22
|
|
|
23
23
|
**method** (`'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'ALL'`): HTTP method
|
|
24
24
|
|
|
25
|
-
**path** (`string`): Route path with optional params (e.g.,
|
|
25
|
+
**path** (`string`): Route path with optional params (e.g., /api/items/:id)
|
|
26
26
|
|
|
27
|
-
**responseType** (`'json' | 'stream'`): Response format. Internal routes may use additional types (
|
|
27
|
+
**responseType** (`'json' | 'stream'`): Response format. Internal routes may use additional types (datastream-response, mcp-http, mcp-sse).
|
|
28
28
|
|
|
29
29
|
**handler** (`ServerRouteHandler`): Route handler function
|
|
30
30
|
|
|
@@ -48,7 +48,7 @@ function createRoute<TPath, TQuery, TBody, TResponse, TResponseType>(
|
|
|
48
48
|
|
|
49
49
|
**deprecated** (`boolean`): Mark route as deprecated
|
|
50
50
|
|
|
51
|
-
**onValidationError** (`(error: ZodError, context: 'query' | 'body' | 'path') => { status: number; body: unknown } | undefined`): Custom validation error handler for this route. Overrides the server-level
|
|
51
|
+
**onValidationError** (`(error: ZodError, context: 'query' | 'body' | 'path') => { status: number; body: unknown } | undefined`): Custom validation error handler for this route. Overrides the server-level onValidationError hook. Return { status, body } to customize the response, or undefined to use the default.
|
|
52
52
|
|
|
53
53
|
## Handler parameters
|
|
54
54
|
|
|
@@ -60,21 +60,21 @@ app.listen(4111, () => {
|
|
|
60
60
|
|
|
61
61
|
**mastra** (`Mastra`): Mastra instance
|
|
62
62
|
|
|
63
|
-
**prefix** (`string`): Route path prefix (e.g.,
|
|
63
|
+
**prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `''`)
|
|
64
64
|
|
|
65
|
-
**openapiPath** (`string`): Path to serve OpenAPI spec (e.g.,
|
|
65
|
+
**openapiPath** (`string`): Path to serve OpenAPI spec (e.g., /openapi.json) (Default: `''`)
|
|
66
66
|
|
|
67
67
|
**bodyLimitOptions** (`{ maxSize: number, onError: (err) => unknown }`): Request body size limits
|
|
68
68
|
|
|
69
69
|
**streamOptions** (`{ redact?: boolean }`): Stream redaction config. When true, redacts sensitive data from streams. (Default: `{ redact: true }`)
|
|
70
70
|
|
|
71
|
-
**customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are
|
|
71
|
+
**customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are METHOD:PATH (e.g., GET:/api/health). Value false makes route public, true requires auth.
|
|
72
72
|
|
|
73
73
|
**tools** (`Record<string, Tool>`): Available tools for the server
|
|
74
74
|
|
|
75
75
|
**taskStore** (`InMemoryTaskStore`): Task store for A2A (Agent-to-Agent) operations
|
|
76
76
|
|
|
77
|
-
**mcpOptions** (`MCPOptions`): MCP transport options. Set
|
|
77
|
+
**mcpOptions** (`MCPOptions`): MCP transport options. Set serverless: true for stateless environments like Cloudflare Workers or Vercel Edge.
|
|
78
78
|
|
|
79
79
|
## Differences from Hono
|
|
80
80
|
|
|
@@ -61,21 +61,21 @@ app.listen({ port: 3000 }, (err, address) => {
|
|
|
61
61
|
|
|
62
62
|
**mastra** (`Mastra`): Mastra instance
|
|
63
63
|
|
|
64
|
-
**prefix** (`string`): Route path prefix (e.g.,
|
|
64
|
+
**prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `''`)
|
|
65
65
|
|
|
66
|
-
**openapiPath** (`string`): Path to serve OpenAPI spec (e.g.,
|
|
66
|
+
**openapiPath** (`string`): Path to serve OpenAPI spec (e.g., /openapi.json) (Default: `''`)
|
|
67
67
|
|
|
68
68
|
**bodyLimitOptions** (`BodyLimitOptions`): Request body size limits
|
|
69
69
|
|
|
70
70
|
**streamOptions** (`StreamOptions`): Stream redaction config. When true (default), redacts sensitive data (system prompts, tool definitions, API keys) from stream chunks before sending to clients. (Default: `{ redact: true }`)
|
|
71
71
|
|
|
72
|
-
**customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are
|
|
72
|
+
**customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are METHOD:PATH (e.g., GET:/api/health). Value false makes route public, true requires auth.
|
|
73
73
|
|
|
74
74
|
**tools** (`ToolsInput`): Available tools for the server
|
|
75
75
|
|
|
76
76
|
**taskStore** (`InMemoryTaskStore`): Task store for A2A (Agent-to-Agent) operations
|
|
77
77
|
|
|
78
|
-
**mcpOptions** (`MCPOptions`): MCP transport options. Set
|
|
78
|
+
**mcpOptions** (`MCPOptions`): MCP transport options. Set serverless: true for stateless environments like Cloudflare Workers or Vercel Edge.
|
|
79
79
|
|
|
80
80
|
## Protecting raw routes
|
|
81
81
|
|
|
@@ -55,21 +55,21 @@ export default app
|
|
|
55
55
|
|
|
56
56
|
**mastra** (`Mastra`): Mastra instance
|
|
57
57
|
|
|
58
|
-
**prefix** (`string`): Route path prefix (e.g.,
|
|
58
|
+
**prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `''`)
|
|
59
59
|
|
|
60
|
-
**openapiPath** (`string`): Path to serve OpenAPI spec (e.g.,
|
|
60
|
+
**openapiPath** (`string`): Path to serve OpenAPI spec (e.g., /openapi.json) (Default: `''`)
|
|
61
61
|
|
|
62
62
|
**bodyLimitOptions** (`{ maxSize: number, onError: (err) => unknown }`): Request body size limits
|
|
63
63
|
|
|
64
64
|
**streamOptions** (`{ redact?: boolean }`): Stream redaction config. When true, redacts sensitive data from streams. (Default: `{ redact: true }`)
|
|
65
65
|
|
|
66
|
-
**customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are
|
|
66
|
+
**customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are METHOD:PATH (e.g., GET:/api/health). Value false makes route public, true requires auth.
|
|
67
67
|
|
|
68
68
|
**tools** (`Record<string, Tool>`): Available tools for the server
|
|
69
69
|
|
|
70
70
|
**taskStore** (`InMemoryTaskStore`): Task store for A2A (Agent-to-Agent) operations
|
|
71
71
|
|
|
72
|
-
**mcpOptions** (`MCPOptions`): MCP transport options. Set
|
|
72
|
+
**mcpOptions** (`MCPOptions`): MCP transport options. Set serverless: true for stateless environments like Cloudflare Workers or Vercel Edge.
|
|
73
73
|
|
|
74
74
|
## Adding custom routes
|
|
75
75
|
|
|
@@ -60,21 +60,21 @@ app.listen(3000, () => {
|
|
|
60
60
|
|
|
61
61
|
**mastra** (`Mastra`): Mastra instance
|
|
62
62
|
|
|
63
|
-
**prefix** (`string`): Route path prefix (e.g.,
|
|
63
|
+
**prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `''`)
|
|
64
64
|
|
|
65
|
-
**openapiPath** (`string`): Path to serve OpenAPI spec (e.g.,
|
|
65
|
+
**openapiPath** (`string`): Path to serve OpenAPI spec (e.g., /openapi.json) (Default: `''`)
|
|
66
66
|
|
|
67
67
|
**bodyLimitOptions** (`BodyLimitOptions`): Request body size limits
|
|
68
68
|
|
|
69
69
|
**streamOptions** (`StreamOptions`): Stream redaction config. When true (default), redacts sensitive data (system prompts, tool definitions, API keys) from stream chunks before sending to clients. (Default: `{ redact: true }`)
|
|
70
70
|
|
|
71
|
-
**customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are
|
|
71
|
+
**customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are METHOD:PATH (e.g., GET:/api/health). Value false makes route public, true requires auth.
|
|
72
72
|
|
|
73
73
|
**tools** (`ToolsInput`): Available tools for the server
|
|
74
74
|
|
|
75
75
|
**taskStore** (`InMemoryTaskStore`): Task store for A2A (Agent-to-Agent) operations
|
|
76
76
|
|
|
77
|
-
**mcpOptions** (`MCPOptions`): MCP transport options. Set
|
|
77
|
+
**mcpOptions** (`MCPOptions`): MCP transport options. Set serverless: true for stateless environments like Cloudflare Workers or Vercel Edge.
|
|
78
78
|
|
|
79
79
|
## Error handling
|
|
80
80
|
|
|
@@ -34,7 +34,7 @@ constructor(options: MastraServerOptions<TApp>)
|
|
|
34
34
|
|
|
35
35
|
**mastra** (`Mastra`): Mastra instance
|
|
36
36
|
|
|
37
|
-
**prefix** (`string`): Route path prefix (e.g.,
|
|
37
|
+
**prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `''`)
|
|
38
38
|
|
|
39
39
|
**openapiPath** (`string`): Path to serve OpenAPI spec (Default: `''`)
|
|
40
40
|
|
|
@@ -73,7 +73,7 @@ By default, Mastra routes mount under `/api`. Use `prefix` to change it.
|
|
|
73
73
|
|
|
74
74
|
**mastra** (`Mastra`): Mastra instance
|
|
75
75
|
|
|
76
|
-
**prefix** (`string`): Route path prefix (e.g.,
|
|
76
|
+
**prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `` `/api` ``)
|
|
77
77
|
|
|
78
78
|
**rateLimitOptions** (`{ enabled?: boolean; defaultLimit?: number; windowMs?: number; generateLimit?: number }`): Rate limiting config (enabled by default)
|
|
79
79
|
|
|
@@ -87,7 +87,7 @@ By default, Mastra routes mount under `/api`. Use `prefix` to change it.
|
|
|
87
87
|
|
|
88
88
|
**contextOptions** (`{ strict?: boolean; logWarnings?: boolean }`): Request context parsing config
|
|
89
89
|
|
|
90
|
-
**customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are
|
|
90
|
+
**customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are METHOD:PATH.
|
|
91
91
|
|
|
92
92
|
**tools** (`Record<string, Tool>`): Registered tools for the server
|
|
93
93
|
|
|
@@ -95,7 +95,7 @@ By default, Mastra routes mount under `/api`. Use `prefix` to change it.
|
|
|
95
95
|
|
|
96
96
|
**mcpOptions** (`{ serverless?: boolean; sessionIdGenerator?: () => string }`): MCP transport options
|
|
97
97
|
|
|
98
|
-
**auth** (`{ enabled?: boolean; allowQueryApiKey?: boolean }`): Enable Mastra token auth. Disabled by default — most NestJS apps use their own auth guards. Query-string
|
|
98
|
+
**auth** (`{ enabled?: boolean; allowQueryApiKey?: boolean }`): Enable Mastra token auth. Disabled by default — most NestJS apps use their own auth guards. Query-string apiKey auth is opt-in for backward compatibility. (Default: `` `{ enabled: false }` ``)
|
|
99
99
|
|
|
100
100
|
## Async registration
|
|
101
101
|
|