@mastra/mcp-docs-server 1.2.4 → 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 +2 -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/kenari.md +95 -0
- package/.docs/models/providers/nvidia.md +2 -3
- package/.docs/models/providers/tencent-token-plan.md +7 -7
- package/.docs/models/providers/tencent-tokenhub.md +5 -4
- package/.docs/models/providers.md +2 -0
- package/.docs/reference/acp/acp-agent.md +5 -5
- package/.docs/reference/acp/create-acp-tool.md +5 -5
- package/.docs/reference/agent-controller/agent-controller-class.md +27 -27
- package/.docs/reference/agents/agent.md +34 -34
- package/.docs/reference/agents/channels.md +19 -19
- package/.docs/reference/agents/createSkill.md +2 -2
- package/.docs/reference/agents/durable-agent.md +22 -22
- package/.docs/reference/agents/generate.md +10 -10
- package/.docs/reference/agents/generateLegacy.md +12 -12
- package/.docs/reference/agents/getMetadata.md +1 -1
- package/.docs/reference/agents/getVoice.md +1 -1
- package/.docs/reference/agents/inngest-agent.md +9 -9
- package/.docs/reference/agents/network.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +4 -4
- package/.docs/reference/ai-sdk/handle-chat-stream.md +6 -6
- package/.docs/reference/ai-sdk/handle-network-stream.md +3 -3
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +4 -4
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +1 -1
- package/.docs/reference/ai-sdk/with-mastra.md +2 -2
- package/.docs/reference/ai-sdk/workflow-route.md +2 -2
- package/.docs/reference/ai-sdk/workflow-snapshot-to-stream.md +1 -1
- package/.docs/reference/auth/google.md +10 -10
- package/.docs/reference/auth/okta.md +11 -11
- package/.docs/reference/auth/workos.md +3 -3
- package/.docs/reference/channels/slack-provider.md +15 -15
- package/.docs/reference/cli/mastra.md +145 -0
- package/.docs/reference/client-js/agents.md +9 -9
- package/.docs/reference/client-js/mastra-client.md +5 -5
- package/.docs/reference/client-js/responses.md +3 -3
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/core/getAgentById.md +3 -3
- package/.docs/reference/core/getWorkflow.md +1 -1
- package/.docs/reference/core/listWorkflows.md +1 -1
- package/.docs/reference/core/mastra-class.md +3 -3
- package/.docs/reference/core/removeWorkspace.md +2 -2
- package/.docs/reference/datasets/compareExperiments.md +1 -1
- package/.docs/reference/datasets/getItemHistory.md +1 -1
- package/.docs/reference/datasets/list.md +5 -5
- package/.docs/reference/datasets/listExperimentResults.md +4 -4
- package/.docs/reference/datasets/listExperiments.md +4 -4
- package/.docs/reference/datasets/listItems.md +5 -5
- package/.docs/reference/datasets/listVersions.md +3 -3
- package/.docs/reference/datasets/startExperiment.md +8 -8
- package/.docs/reference/datasets/startExperimentAsync.md +1 -1
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +4 -4
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +7 -7
- package/.docs/reference/editor/agent-builder/builder-models.md +4 -4
- package/.docs/reference/editor/blob-store-provider.md +2 -2
- package/.docs/reference/editor/browser-provider.md +2 -2
- package/.docs/reference/editor/filesystem-provider.md +2 -2
- package/.docs/reference/editor/mastra-editor.md +2 -2
- package/.docs/reference/editor/processor-provider.md +4 -4
- package/.docs/reference/editor/sandbox-provider.md +2 -2
- package/.docs/reference/editor/storage-browser-ref.md +2 -2
- package/.docs/reference/editor/storage-workspace-ref.md +7 -7
- package/.docs/reference/evals/create-scorer.md +8 -8
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/evals/run-evals.md +7 -7
- package/.docs/reference/evals/trajectory-accuracy.md +1 -1
- package/.docs/reference/index.md +2 -2
- package/.docs/reference/logging/pino-logger.md +4 -4
- package/.docs/reference/memory/cloneThread.md +35 -4
- package/.docs/reference/memory/memory-class.md +5 -5
- package/.docs/reference/memory/observational-memory.md +43 -43
- package/.docs/reference/memory/recall.md +4 -4
- package/.docs/reference/memory/serialized-memory-config.md +6 -6
- package/.docs/reference/observability/tracing/configuration.md +4 -4
- package/.docs/reference/processors/language-detector.md +1 -1
- package/.docs/reference/processors/moderation-processor.md +1 -1
- package/.docs/reference/processors/pii-detector.md +1 -1
- package/.docs/reference/processors/processor-interface.md +20 -20
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/response-cache.md +6 -6
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/pubsub/base.md +7 -7
- package/.docs/reference/pubsub/caching-pubsub.md +1 -1
- package/.docs/reference/pubsub/event-emitter.md +2 -2
- package/.docs/reference/pubsub/google-cloud-pubsub.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +3 -3
- package/.docs/reference/pubsub/redis-streams.md +6 -6
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/rag/chunk.md +2 -2
- package/.docs/reference/server/create-route.md +3 -3
- package/.docs/reference/server/express-adapter.md +4 -4
- package/.docs/reference/server/fastify-adapter.md +4 -4
- package/.docs/reference/server/hono-adapter.md +4 -4
- package/.docs/reference/server/koa-adapter.md +4 -4
- package/.docs/reference/server/mastra-server.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +3 -3
- package/.docs/reference/server/register-api-route.md +3 -3
- package/.docs/reference/signals/create-notification-inbox-tool.md +3 -3
- package/.docs/reference/signals/signal-provider.md +7 -7
- package/.docs/reference/signals/webhook-signal-provider.md +2 -2
- package/.docs/reference/storage/clickhouse.md +7 -7
- package/.docs/reference/storage/composite.md +2 -2
- package/.docs/reference/storage/duckdb.md +1 -1
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/libsql.md +1 -1
- package/.docs/reference/storage/postgresql.md +2 -2
- package/.docs/reference/storage/redis.md +2 -2
- package/.docs/reference/storage/retention.md +5 -5
- package/.docs/reference/storage/spanner.md +6 -6
- package/.docs/reference/streaming/ChunkType.md +3 -3
- package/.docs/reference/streaming/agents/stream.md +14 -14
- package/.docs/reference/streaming/agents/streamLegacy.md +10 -10
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/templates/overview.md +1 -140
- package/.docs/reference/tools/brightdata.md +4 -4
- package/.docs/reference/tools/create-code-mode.md +5 -5
- package/.docs/reference/tools/create-tool.md +15 -15
- package/.docs/reference/tools/graph-rag-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +2 -2
- package/.docs/reference/tools/mcp-server.md +12 -12
- package/.docs/reference/tools/perplexity.md +3 -3
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +1 -1
- package/.docs/reference/vectors/chroma.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +1 -1
- package/.docs/reference/vectors/s3vectors.md +4 -4
- package/.docs/reference/voice/google-gemini-live.md +3 -3
- package/.docs/reference/voice/inworld-realtime.md +12 -12
- package/.docs/reference/voice/inworld.md +2 -2
- package/.docs/reference/voice/voice.on.md +1 -1
- package/.docs/reference/workflows/run-methods/resume.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +4 -4
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -1
- package/.docs/reference/workspace/apple-container-sandbox.md +5 -5
- package/.docs/reference/workspace/archil-filesystem.md +5 -5
- package/.docs/reference/workspace/blaxel-sandbox.md +1 -1
- package/.docs/reference/workspace/daytona-sandbox.md +1 -1
- package/.docs/reference/workspace/docker-sandbox.md +2 -2
- package/.docs/reference/workspace/e2b-sandbox.md +2 -2
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -1
- package/.docs/reference/workspace/filesystem.md +1 -1
- package/.docs/reference/workspace/local-filesystem.md +3 -3
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/mesa-filesystem.md +3 -3
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/railway-sandbox.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +4 -4
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/{vercel-microvm-sandbox.md → vercel-sandbox.md} +21 -15
- package/.docs/reference/workspace/{vercel.md → vercel-serverless.md} +21 -14
- package/.docs/reference/workspace/workspace-class.md +15 -15
- package/CHANGELOG.md +15 -0
- package/package.json +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
|
@@ -33,35 +33,35 @@ Observer input is multimodal-aware. OM keeps text placeholders like `[Image #1:
|
|
|
33
33
|
|
|
34
34
|
OM performs thresholding with fast local token estimation. Text uses `tokenx`, and image-like inputs use provider-aware heuristics plus deterministic fallbacks when metadata is incomplete.
|
|
35
35
|
|
|
36
|
-
**enabled** (`boolean`): Enable or disable Observational Memory. When omitted from a config object, defaults to
|
|
36
|
+
**enabled** (`boolean`): Enable or disable Observational Memory. When omitted from a config object, defaults to true. Only enabled: false explicitly disables it. (Default: `true`)
|
|
37
37
|
|
|
38
|
-
**model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Sets the model for both at once. Cannot be used together with
|
|
38
|
+
**model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Sets the model for both at once. Cannot be used together with observation.model or reflection.model — an error will be thrown if both are set. When using observationalMemory: true, defaults to google/gemini-2.5-flash. When passing a config object, this or observation.model/reflection.model must be set. Use "default" to explicitly use the default model (google/gemini-2.5-flash). (Default: `'google/gemini-2.5-flash' (when using observationalMemory: true)`)
|
|
39
39
|
|
|
40
|
-
**scope** (`'resource' | 'thread'`): Memory scope for observations.
|
|
40
|
+
**scope** (`'resource' | 'thread'`): Memory scope for observations. 'thread' keeps observations per-thread. 'resource' (experimental) shares observations across all threads for a resource, enabling cross-conversation memory. (Default: `'thread'`)
|
|
41
41
|
|
|
42
|
-
**activateAfterIdle** (`number | string | false | "auto"`): Time before buffered observations are forced to activate after inactivity, even before
|
|
42
|
+
**activateAfterIdle** (`number | string | false | "auto"`): Time before buffered observations are forced to activate after inactivity, even before observation.messageTokens is reached. Accepts a numeric millisecond value such as 300\_000, duration strings like "5m" or "1hr", "auto" for a provider-aware prompt cache TTL, or false to disable inherited observation idle activation. Reflections do not inherit this setting. Use reflection.activateAfterIdle to opt reflections into idle activation.
|
|
43
43
|
|
|
44
|
-
**activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. Reflections do not inherit this setting. Use
|
|
44
|
+
**activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. Reflections do not inherit this setting. Use reflection.activateOnProviderChange to opt reflections into provider-change activation. (Default: `false`)
|
|
45
45
|
|
|
46
|
-
**shareTokenBudget** (`boolean`): Share the token budget between messages and observations. When enabled, the total budget is
|
|
46
|
+
**shareTokenBudget** (`boolean`): Share the token budget between messages and observations. When enabled, the total budget is observation.messageTokens + reflection.observationTokens. Messages can use more space when observations are small, and vice versa. This maximizes context usage through flexible allocation. shareTokenBudget is not yet compatible with async buffering. You must set observation: { bufferTokens: false } when using this option (this is a temporary limitation). (Default: `false`)
|
|
47
47
|
|
|
48
48
|
**temporalMarkers** (`boolean`): Insert temporal-gap reminder markers before new user messages when the previous message in the thread is at least 10 minutes older. The marker is persisted in memory, emitted as an inline reminder event so clients can render it specially, and shown to the observer so it can anchor observations to when events occurred. (Default: `false`)
|
|
49
49
|
|
|
50
|
-
**retrieval** (`boolean | { vector?: boolean; scope?: 'thread' | 'resource' }`): Enable retrieval-mode observation groups as durable pointers to raw message history.
|
|
50
|
+
**retrieval** (`boolean | { vector?: boolean; scope?: 'thread' | 'resource' }`): Enable retrieval-mode observation groups as durable pointers to raw message history. true enables cross-thread browsing by default. { vector: true } also enables semantic search using Memory's vector store and embedder. { scope: 'thread' } restricts the recall tool to the current thread only. Default scope is 'resource'. (Default: `false`)
|
|
51
51
|
|
|
52
52
|
**observation** (`ObservationalMemoryObservationConfig`): Configuration for the observation step. Controls when the Observer agent runs and how it behaves.
|
|
53
53
|
|
|
54
|
-
**observation.model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for the Observer agent. Cannot be set if a top-level
|
|
54
|
+
**observation.model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for the Observer agent. Cannot be set if a top-level model is also provided. If neither this nor the top-level model is set, falls back to reflection.model.
|
|
55
55
|
|
|
56
56
|
**observation.instruction** (`string`): Custom instruction appended to the Observer's system prompt. Use this to customize what the Observer focuses on, such as domain-specific preferences or priorities.
|
|
57
57
|
|
|
58
|
-
**observation.threadTitle** (`boolean`): When
|
|
58
|
+
**observation.threadTitle** (`boolean`): When true, the Observer suggests short thread titles and updates the thread title when the conversation topic meaningfully changes. This is opt-in and defaults to disabled.
|
|
59
59
|
|
|
60
60
|
**observation.extract** (`Extractor[]`): Custom values to extract after observation. Schema-less extractors are requested inline in the Observer output. Schema-backed extractors run as a follow-up structured output call and are stored in thread OM metadata.
|
|
61
61
|
|
|
62
|
-
**observation.observeAttachments** (`boolean | string[]`): Controls which image/file attachments are forwarded to the Observer model alongside their placeholder text lines.
|
|
62
|
+
**observation.observeAttachments** (`boolean | string[]`): Controls which image/file attachments are forwarded to the Observer model alongside their placeholder text lines. true (default) forwards all attachments. false drops all attachments while keeping placeholders visible. An array is a case-insensitive mimeType allowlist supporting exact matches ('application/pdf'), wildcard subtypes ('image/\*'), and bare '\*' for everything. Useful when the Observer model is text-only (e.g. some DeepSeek endpoints) while the main agent uses a multimodal model. Tool-result attachments are filtered using the same rule.
|
|
63
63
|
|
|
64
|
-
**observation.messageTokens** (`number`): Token count of unobserved messages that triggers observation. When unobserved message tokens exceed this threshold, the Observer agent is called. Text is estimated locally with
|
|
64
|
+
**observation.messageTokens** (`number`): Token count of unobserved messages that triggers observation. When unobserved message tokens exceed this threshold, the Observer agent is called. Text is estimated locally with tokenx. Image parts are included with model-aware heuristics when possible, with deterministic fallbacks when image metadata is incomplete. Image-like file parts are counted the same way when uploads are normalized as files.
|
|
65
65
|
|
|
66
66
|
**observation.maxTokensPerBatch** (`number`): Maximum tokens per batch when observing multiple threads in resource scope. Threads are chunked into batches of this size and processed in parallel. Lower values mean more parallelism but more API calls.
|
|
67
67
|
|
|
@@ -71,23 +71,23 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
71
71
|
|
|
72
72
|
**observation.modelSettings.maxOutputTokens** (`number`): Maximum output tokens. Set high to prevent truncation of observations.
|
|
73
73
|
|
|
74
|
-
**observation.bufferTokens** (`number | false`): Token interval for async background observation buffering. Can be an absolute token count (e.g.
|
|
74
|
+
**observation.bufferTokens** (`number | false`): Token interval for async background observation buffering. Can be an absolute token count (e.g. 5000) or a fraction of messageTokens (e.g. 0.25 = buffer every 25% of threshold). When set, observations run in the background at this interval, storing results in a buffer. When the main messageTokens threshold is reached, buffered observations activate instantly without a blocking LLM call. Must resolve to less than messageTokens. Set to false to explicitly disable all async buffering (both observation and reflection).
|
|
75
75
|
|
|
76
|
-
**observation.bufferOnIdle** (`boolean`): Run background observation buffering when an agent turn ends and the agent becomes idle. This is separate from
|
|
76
|
+
**observation.bufferOnIdle** (`boolean`): Run background observation buffering when an agent turn ends and the agent becomes idle. This is separate from bufferTokens, which controls step-time async buffering. Set this to true to buffer short idle turns without waiting for the next turn or the messageTokens threshold.
|
|
77
77
|
|
|
78
|
-
**observation.bufferActivation** (`number`): Controls how much of the message window to retain after activation. Accepts a ratio (0-1) or an absolute token count (≥ 1000). For example,
|
|
78
|
+
**observation.bufferActivation** (`number`): Controls how much of the message window to retain after activation. Accepts a ratio (0-1) or an absolute token count (≥ 1000). For example, 0.8 means: activate enough buffers to remove 80% of messageTokens and leave 20% as active message history. An absolute token count like 4000 targets a goal of keeping \~4k message tokens remaining after activation. Higher values remove more message history per activation when using a ratio. Higher values keep more message history when using a token count.
|
|
79
79
|
|
|
80
|
-
**observation.activateAfterIdle** (`number | string | false | "auto"`): Time before buffered observations are forced to activate after inactivity. Accepts milliseconds, a duration string,
|
|
80
|
+
**observation.activateAfterIdle** (`number | string | false | "auto"`): Time before buffered observations are forced to activate after inactivity. Accepts milliseconds, a duration string, "auto" for a provider-aware prompt cache TTL, or false. If unset, the top-level activateAfterIdle value is used for observations. Set false to disable the top-level idle setting for observations.
|
|
81
81
|
|
|
82
|
-
**observation.activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. If unset, the top-level
|
|
82
|
+
**observation.activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. If unset, the top-level activateOnProviderChange value is used for observations.
|
|
83
83
|
|
|
84
|
-
**observation.blockAfter** (`number`): Token threshold above which synchronous (blocking) observation is forced. Between
|
|
84
|
+
**observation.blockAfter** (`number`): Token threshold above which synchronous (blocking) observation is forced. Between messageTokens and blockAfter, only async buffering/activation is used. Above blockAfter, a synchronous observation runs as a last resort, while buffered activation still preserves a minimum remaining context (min(1000, retention floor)). Accepts a multiplier (1 < value < 2, multiplied by messageTokens) or an absolute token count (≥ 2, must be greater than messageTokens). Only relevant when bufferTokens is set. Defaults to 1.2 when async buffering is enabled.
|
|
85
85
|
|
|
86
|
-
**observation.previousObserverTokens** (`number | false`): Optional token budget for the observer's previous-observations context. When set to a number, the observations passed to the Observer agent are tail-truncated to fit within this budget while keeping the newest observations and preserving highlighted 🔴 items when possible. When a buffered reflection is pending, the already-reflected observation lines are automatically replaced with the reflection summary before truncation. Set to
|
|
86
|
+
**observation.previousObserverTokens** (`number | false`): Optional token budget for the observer's previous-observations context. When set to a number, the observations passed to the Observer agent are tail-truncated to fit within this budget while keeping the newest observations and preserving highlighted 🔴 items when possible. When a buffered reflection is pending, the already-reflected observation lines are automatically replaced with the reflection summary before truncation. Set to 0 to omit previous observations entirely, or false to disable truncation explicitly.
|
|
87
87
|
|
|
88
88
|
**reflection** (`ObservationalMemoryReflectionConfig`): Configuration for the reflection step. Controls when the Reflector agent runs and how it behaves.
|
|
89
89
|
|
|
90
|
-
**reflection.model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for the Reflector agent. Cannot be set if a top-level
|
|
90
|
+
**reflection.model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for the Reflector agent. Cannot be set if a top-level model is also provided. If neither this nor the top-level model is set, falls back to observation.model.
|
|
91
91
|
|
|
92
92
|
**reflection.instruction** (`string`): Custom instruction appended to the Reflector's system prompt. Use this to customize how the Reflector consolidates observations, such as prioritizing certain types of information.
|
|
93
93
|
|
|
@@ -101,13 +101,13 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
101
101
|
|
|
102
102
|
**reflection.modelSettings.maxOutputTokens** (`number`): Maximum output tokens. Set high to prevent truncation of observations.
|
|
103
103
|
|
|
104
|
-
**reflection.bufferActivation** (`number`): Ratio (0-1) controlling when async reflection buffering starts. When observation tokens reach
|
|
104
|
+
**reflection.bufferActivation** (`number`): Ratio (0-1) controlling when async reflection buffering starts. When observation tokens reach observationTokens \* bufferActivation, reflection runs in the background. On activation at the full threshold, the buffered reflection replaces the observations it covers, preserving any new observations appended after that range.
|
|
105
105
|
|
|
106
|
-
**reflection.activateAfterIdle** (`number | string | false | "auto"`): Time before buffered reflections are forced to activate after inactivity. Accepts milliseconds, a duration string,
|
|
106
|
+
**reflection.activateAfterIdle** (`number | string | false | "auto"`): Time before buffered reflections are forced to activate after inactivity. Accepts milliseconds, a duration string, "auto" for a provider-aware prompt cache TTL, or false. Reflections do not inherit top-level activateAfterIdle; set this explicitly to opt reflections into idle activation.
|
|
107
107
|
|
|
108
|
-
**reflection.activateOnProviderChange** (`boolean`): Force buffered reflections to activate when the actor provider or model changes. Reflections do not inherit top-level
|
|
108
|
+
**reflection.activateOnProviderChange** (`boolean`): Force buffered reflections to activate when the actor provider or model changes. Reflections do not inherit top-level activateOnProviderChange; set this explicitly to opt reflections into provider-change activation.
|
|
109
109
|
|
|
110
|
-
**reflection.blockAfter** (`number`): Token threshold above which synchronous (blocking) reflection is forced. Between
|
|
110
|
+
**reflection.blockAfter** (`number`): Token threshold above which synchronous (blocking) reflection is forced. Between observationTokens and blockAfter, only async buffering/activation is used. Above blockAfter, a synchronous reflection runs as a last resort. Accepts a multiplier (1 < value < 2, multiplied by observationTokens) or an absolute token count (≥ 2, must be greater than observationTokens). Only relevant when bufferActivation is set. Defaults to 1.2 when async reflection is enabled.
|
|
111
111
|
|
|
112
112
|
### Token estimate metadata cache
|
|
113
113
|
|
|
@@ -156,7 +156,7 @@ const memory = new Memory({
|
|
|
156
156
|
|
|
157
157
|
**schema** (`ZodType<T> | (context) => ZodType<T> | undefined`): Optional Zod schema for structured extraction. When provided, OM runs a follow-up structured output call after the main OM operation. When omitted, the extractor is an inline string extractor emitted in the Observer or Reflector response. Use a function to derive the schema from runtime context.
|
|
158
158
|
|
|
159
|
-
**includePreviousExtraction** (`boolean`): Controls whether the previous extraction is shown to the extractor on future OM runs. Set to
|
|
159
|
+
**includePreviousExtraction** (`boolean`): Controls whether the previous extraction is shown to the extractor on future OM runs. Set to false for values that should only come from the current OM run. (Default: `true`)
|
|
160
160
|
|
|
161
161
|
**onExtracted** (`(context) => T | void | Promise<T | void>`): Optional hook called after a custom extractor returns a value and before metadata is persisted. Returning a value replaces the extracted value. Throwing records an extraction failure.
|
|
162
162
|
|
|
@@ -498,13 +498,13 @@ Emitted when the Observer or Reflector agent begins processing.
|
|
|
498
498
|
|
|
499
499
|
**threadIds** (`string[]`): All thread IDs in this batch (for resource-scoped).
|
|
500
500
|
|
|
501
|
-
**config** (`ObservationMarkerConfig`): Snapshot of
|
|
501
|
+
**config** (`ObservationMarkerConfig`): Snapshot of messageTokens, observationTokens, and scope at observation time.
|
|
502
502
|
|
|
503
503
|
### `data-om-observation-end`
|
|
504
504
|
|
|
505
505
|
Emitted when observation or reflection completes successfully.
|
|
506
506
|
|
|
507
|
-
**cycleId** (`string`): Matches the corresponding
|
|
507
|
+
**cycleId** (`string`): Matches the corresponding start marker.
|
|
508
508
|
|
|
509
509
|
**operationType** (`'observation' | 'reflection'`): Type of operation that completed.
|
|
510
510
|
|
|
@@ -534,7 +534,7 @@ Emitted when observation or reflection completes successfully.
|
|
|
534
534
|
|
|
535
535
|
Emitted when observation or reflection fails. The system falls back to synchronous processing.
|
|
536
536
|
|
|
537
|
-
**cycleId** (`string`): Matches the corresponding
|
|
537
|
+
**cycleId** (`string`): Matches the corresponding start marker.
|
|
538
538
|
|
|
539
539
|
**operationType** (`'observation' | 'reflection'`): Type of operation that failed.
|
|
540
540
|
|
|
@@ -576,7 +576,7 @@ Emitted when async buffering begins in the background. Buffering pre-computes ob
|
|
|
576
576
|
|
|
577
577
|
Emitted when async buffering completes. The content is stored but not yet activated in the main context.
|
|
578
578
|
|
|
579
|
-
**cycleId** (`string`): Matches the corresponding
|
|
579
|
+
**cycleId** (`string`): Matches the corresponding buffering-start marker.
|
|
580
580
|
|
|
581
581
|
**operationType** (`'observation' | 'reflection'`): Type of operation that was buffered.
|
|
582
582
|
|
|
@@ -602,7 +602,7 @@ Emitted when async buffering completes. The content is stored but not yet activa
|
|
|
602
602
|
|
|
603
603
|
Emitted when async buffering fails. The system falls back to synchronous processing when the threshold is reached.
|
|
604
604
|
|
|
605
|
-
**cycleId** (`string`): Matches the corresponding
|
|
605
|
+
**cycleId** (`string`): Matches the corresponding buffering-start marker.
|
|
606
606
|
|
|
607
607
|
**operationType** (`'observation' | 'reflection'`): Type of operation that failed.
|
|
608
608
|
|
|
@@ -688,7 +688,7 @@ export const agent = new Agent({
|
|
|
688
688
|
|
|
689
689
|
The standalone `ObservationalMemory` class accepts all the same options as the `observationalMemory` config object above, plus the following:
|
|
690
690
|
|
|
691
|
-
**storage** (`MemoryStorage`): Storage adapter for persisting observations. Must be a MemoryStorage instance (from
|
|
691
|
+
**storage** (`MemoryStorage`): Storage adapter for persisting observations. Must be a MemoryStorage instance (from MastraStorage.stores.memory).
|
|
692
692
|
|
|
693
693
|
**onDebugEvent** (`(event: ObservationDebugEvent) => void`): Debug callback for observation events. Called whenever observation-related events occur. Useful for debugging and understanding the observation flow.
|
|
694
694
|
|
|
@@ -700,29 +700,29 @@ When `retrieval` is set (any truthy value), a `recall` tool is registered so the
|
|
|
700
700
|
|
|
701
701
|
### Parameters
|
|
702
702
|
|
|
703
|
-
**mode** (`'messages' | 'threads' | 'search'`): What to retrieve.
|
|
703
|
+
**mode** (`'messages' | 'threads' | 'search'`): What to retrieve. "messages" (default) pages through message history. "threads" lists all threads for the current user. "search" finds messages by semantic similarity across all threads (requires vector store and embedder). (Default: `'messages'`)
|
|
704
704
|
|
|
705
|
-
**query** (`string`): Search query for
|
|
705
|
+
**query** (`string`): Search query for mode: "search". Finds messages semantically similar to this text across all threads for the current user.
|
|
706
706
|
|
|
707
|
-
**cursor** (`string`): A message ID to anchor the recall query. Required for
|
|
707
|
+
**cursor** (`string`): A message ID to anchor the recall query. Required for mode: "messages" when browsing the current thread. Extract the start or end ID from an observation group range (e.g. from \_range: \startId:endId\\\_, use either startId or endId). If a range string is passed directly, the tool returns a hint explaining how to extract the correct ID. Can be omitted when threadId is provided to start reading from the beginning of that thread.
|
|
708
708
|
|
|
709
|
-
**threadId** (`string`): Browse a different thread by its ID. Use
|
|
709
|
+
**threadId** (`string`): Browse a different thread by its ID. Use mode: "threads" first to discover thread IDs. When provided without a cursor, reading starts from the beginning of the thread.
|
|
710
710
|
|
|
711
|
-
**page** (`number`): Pagination offset. For messages: positive values page forward from cursor, negative values page backward. For threads: page number (0-indexed).
|
|
711
|
+
**page** (`number`): Pagination offset. For messages: positive values page forward from cursor, negative values page backward. For threads: page number (0-indexed). 0 is treated as 1 for messages. (Default: `1`)
|
|
712
712
|
|
|
713
713
|
**limit** (`number`): Maximum number of items to return per page. (Default: `20`)
|
|
714
714
|
|
|
715
|
-
**detail** (`'low' | 'high'`): Controls how much content is shown per message part.
|
|
715
|
+
**detail** (`'low' | 'high'`): Controls how much content is shown per message part. 'low' shows truncated text and tool names with positional indices (\[p0], \[p1]). 'high' shows full content including tool arguments and results, clamped to one part per call with continuation hints. (Default: `'low'`)
|
|
716
716
|
|
|
717
|
-
**partIndex** (`number`): Fetch a single message part at full detail by its positional index. Use this when a low-detail recall shows an interesting part at
|
|
717
|
+
**partIndex** (`number`): Fetch a single message part at full detail by its positional index. Use this when a low-detail recall shows an interesting part at \[p1] — call again with partIndex: 1 to see the full content without loading every part.
|
|
718
718
|
|
|
719
|
-
**before** (`string`): For
|
|
719
|
+
**before** (`string`): For mode: "threads" only. Filter to threads created before this date. Accepts ISO 8601 format (e.g. "2026-03-15", "2026-03-10T00:00:00Z").
|
|
720
720
|
|
|
721
|
-
**after** (`string`): For
|
|
721
|
+
**after** (`string`): For mode: "threads" only. Filter to threads created after this date. Accepts ISO 8601 format (e.g. "2026-03-01", "2026-03-10T00:00:00Z").
|
|
722
722
|
|
|
723
723
|
### Returns (messages mode)
|
|
724
724
|
|
|
725
|
-
**messages** (`string`): Formatted message content. Format depends on the
|
|
725
|
+
**messages** (`string`): Formatted message content. Format depends on the detail level.
|
|
726
726
|
|
|
727
727
|
**count** (`number`): Number of messages in this page.
|
|
728
728
|
|
|
@@ -736,13 +736,13 @@ When `retrieval` is set (any truthy value), a `recall` tool is registered so the
|
|
|
736
736
|
|
|
737
737
|
**hasPrevPage** (`boolean`): Whether more messages exist before this page.
|
|
738
738
|
|
|
739
|
-
**truncated** (`boolean`): Present and
|
|
739
|
+
**truncated** (`boolean`): Present and true when the output was capped by the token budget. The agent can paginate or use partIndex to access remaining content.
|
|
740
740
|
|
|
741
|
-
**tokenOffset** (`number`): Approximate number of tokens that were trimmed when
|
|
741
|
+
**tokenOffset** (`number`): Approximate number of tokens that were trimmed when truncated is true.
|
|
742
742
|
|
|
743
743
|
### Returns (threads mode)
|
|
744
744
|
|
|
745
|
-
**threads** (`string`): Formatted thread listing. Each thread shows its title, ID, and dates. The current thread is marked with
|
|
745
|
+
**threads** (`string`): Formatted thread listing. Each thread shows its title, ID, and dates. The current thread is marked with ← current.
|
|
746
746
|
|
|
747
747
|
**count** (`number`): Number of threads returned.
|
|
748
748
|
|
|
@@ -22,9 +22,9 @@ await memory?.recall({ threadId: 'user-123' })
|
|
|
22
22
|
|
|
23
23
|
**page** (`number`): Zero-based page number for pagination. Used with perPage to retrieve messages in batches.
|
|
24
24
|
|
|
25
|
-
**include** (`{ id: string; threadId?: string; withPreviousMessages?: number; withNextMessages?: number }[]`): Array of specific message IDs to include with optional context messages. Each item has an
|
|
25
|
+
**include** (`{ id: string; threadId?: string; withPreviousMessages?: number; withNextMessages?: number }[]`): Array of specific message IDs to include with optional context messages. Each item has an id (required), optional threadId (defaults to main threadId), withPreviousMessages (number of messages before, defaults to 2 for vector search, 0 otherwise), and withNextMessages (number of messages after, defaults to 2 for vector search, 0 otherwise).
|
|
26
26
|
|
|
27
|
-
**filter** (`{ dateRange?: { start?: Date; end?: Date; startExclusive?: boolean; endExclusive?: boolean } }`): Filter options for message retrieval. Currently supports
|
|
27
|
+
**filter** (`{ dateRange?: { start?: Date; end?: Date; startExclusive?: boolean; endExclusive?: boolean } }`): Filter options for message retrieval. Currently supports dateRange to filter messages by creation date. Use startExclusive or endExclusive to exclude boundary dates (useful for cursor-based pagination).
|
|
28
28
|
|
|
29
29
|
**orderBy** (`{ field: 'createdAt'; direction: 'ASC' | 'DESC' }`): Sort order for retrieved messages. Defaults to descending by creation date.
|
|
30
30
|
|
|
@@ -34,9 +34,9 @@ await memory?.recall({ threadId: 'user-123' })
|
|
|
34
34
|
|
|
35
35
|
**threadConfig.semanticRecall** (`boolean | { topK: number; messageRange: number | { before: number; after: number }; scope?: 'thread' | 'resource' }`): Enable semantic search in message history. Can be a boolean or an object with configuration options. When enabled, requires both vector store and embedder to be configured.
|
|
36
36
|
|
|
37
|
-
**threadConfig.workingMemory** (`WorkingMemory`): Configuration for working memory feature. Can be
|
|
37
|
+
**threadConfig.workingMemory** (`WorkingMemory`): Configuration for working memory feature. Can be { enabled: boolean; template?: string; schema?: ZodObject\<any> | JSONSchema7; scope?: 'thread' | 'resource' } or { enabled: boolean } to disable.
|
|
38
38
|
|
|
39
|
-
**threadConfig.threads** (`{ generateTitle?: boolean | { model: DynamicArgument<MastraLanguageModel>; instructions?: DynamicArgument<string> } }`): Settings related to memory thread creation.
|
|
39
|
+
**threadConfig.threads** (`{ generateTitle?: boolean | { model: DynamicArgument<MastraLanguageModel>; instructions?: DynamicArgument<string> } }`): Settings related to memory thread creation. generateTitle controls automatic thread title generation from the user's first message. Can be a boolean or an object with custom model and instructions.
|
|
40
40
|
|
|
41
41
|
## Returns
|
|
42
42
|
|
|
@@ -28,9 +28,9 @@ new MastraEditor({
|
|
|
28
28
|
|
|
29
29
|
## Properties
|
|
30
30
|
|
|
31
|
-
**vector** (`string | false`): Vector store identifier. The vector instance must be registered with the Mastra instance to resolve from this ID. Set to
|
|
31
|
+
**vector** (`string | false`): Vector store identifier. The vector instance must be registered with the Mastra instance to resolve from this ID. Set to false to disable vector search.
|
|
32
32
|
|
|
33
|
-
**embedder** (`string`): Embedding model ID in the format
|
|
33
|
+
**embedder** (`string`): Embedding model ID in the format "provider/model" (for example, "openai/text-embedding-3-small").
|
|
34
34
|
|
|
35
35
|
**embedderOptions** (`Omit<MastraEmbeddingOptions, 'telemetry'>`): Options passed to the embedder. Telemetry options are stripped.
|
|
36
36
|
|
|
@@ -38,17 +38,17 @@ new MastraEditor({
|
|
|
38
38
|
|
|
39
39
|
**options.readOnly** (`boolean`): Treat memory as read-only — no new messages are stored.
|
|
40
40
|
|
|
41
|
-
**options.lastMessages** (`number | false`): Number of recent messages to include in context, or
|
|
41
|
+
**options.lastMessages** (`number | false`): Number of recent messages to include in context, or false to disable.
|
|
42
42
|
|
|
43
43
|
**options.semanticRecall** (`boolean | SemanticRecall`): Semantic recall configuration. See the Memory class reference for the full shape.
|
|
44
44
|
|
|
45
|
-
**options.generateTitle** (`boolean | { model: ModelRouterModelId; instructions?: string }`): Title generation configuration. Pass an object with
|
|
45
|
+
**options.generateTitle** (`boolean | { model: ModelRouterModelId; instructions?: string }`): Title generation configuration. Pass an object with model (in "provider/model" form) and optional instructions.
|
|
46
46
|
|
|
47
|
-
**observationalMemory** (`boolean | SerializedObservationalMemoryConfig`): Long-lived fact extraction. Pass
|
|
47
|
+
**observationalMemory** (`boolean | SerializedObservationalMemoryConfig`): Long-lived fact extraction. Pass true to enable with defaults, or an object to override observer/reflector models, scope, and activation behavior.
|
|
48
48
|
|
|
49
49
|
## `SerializedObservationalMemoryConfig`
|
|
50
50
|
|
|
51
|
-
**model** (`string`): Model ID used by both the Observer and Reflector (for example,
|
|
51
|
+
**model** (`string`): Model ID used by both the Observer and Reflector (for example, "google/gemini-2.5-flash").
|
|
52
52
|
|
|
53
53
|
**scope** (`'resource' | 'thread'`): Whether observations are scoped to a resource or a single thread.
|
|
54
54
|
|
|
@@ -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
|
|