@mastra/mcp-docs-server 1.0.0-beta.4 → 1.0.0-beta.6
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/organized/changelogs/%40internal%2Fstorage-test-utils.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +29 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +411 -211
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +52 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flance.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Frag.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Freact.md +89 -1
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +92 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +67 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +201 -1
- package/.docs/organized/changelogs/create-mastra.md +201 -1
- package/.docs/organized/changelogs/mastra.md +201 -1
- package/.docs/organized/code-examples/agui.md +1 -0
- package/.docs/organized/code-examples/ai-sdk-v5.md +1 -0
- package/.docs/organized/code-examples/mcp-server-adapters.md +721 -0
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/quick-start.md +1 -1
- package/.docs/organized/code-examples/server-app-access.md +342 -0
- package/.docs/raw/agents/adding-voice.mdx +7 -10
- package/.docs/raw/agents/agent-approval.mdx +189 -0
- package/.docs/raw/agents/guardrails.mdx +26 -23
- package/.docs/raw/agents/networks.mdx +2 -2
- package/.docs/raw/agents/overview.mdx +27 -62
- package/.docs/raw/agents/processors.mdx +279 -0
- package/.docs/raw/agents/using-tools.mdx +4 -5
- package/.docs/raw/course/01-first-agent/05-running-playground.md +5 -5
- package/.docs/raw/course/01-first-agent/09-testing-your-agent.md +3 -3
- package/.docs/raw/course/01-first-agent/13-testing-your-tool.md +3 -3
- package/.docs/raw/course/01-first-agent/17-testing-memory.md +2 -2
- package/.docs/raw/course/04-workflows/07-using-playground.md +1 -1
- package/.docs/raw/deployment/building-mastra.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/index.mdx +20 -27
- package/.docs/raw/deployment/cloud-providers/netlify-deployer.mdx +44 -13
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +19 -17
- package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +1 -1
- package/.docs/raw/deployment/overview.mdx +2 -2
- package/.docs/raw/deployment/web-framework.mdx +5 -5
- package/.docs/raw/evals/custom-scorers.mdx +3 -5
- package/.docs/raw/evals/overview.mdx +2 -3
- package/.docs/raw/evals/running-in-ci.mdx +0 -2
- package/.docs/raw/{guides/guide → getting-started}/manual-install.mdx +2 -2
- package/.docs/raw/getting-started/project-structure.mdx +1 -1
- package/.docs/raw/getting-started/start.mdx +72 -0
- package/.docs/raw/getting-started/studio.mdx +1 -1
- package/.docs/raw/{frameworks/agentic-uis/ai-sdk.mdx → guides/build-your-ui/ai-sdk-ui.mdx} +113 -11
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/astro.mdx +23 -25
- package/.docs/raw/{frameworks/servers → guides/getting-started}/express.mdx +3 -4
- package/.docs/raw/guides/{quickstarts/nextjs.mdx → getting-started/next-js.mdx} +11 -11
- package/.docs/raw/guides/{quickstarts/standalone-server.mdx → getting-started/quickstart.mdx} +7 -7
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/sveltekit.mdx +23 -25
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/vite-react.mdx +7 -7
- package/.docs/raw/guides/guide/ai-recruiter.mdx +2 -3
- package/.docs/raw/guides/guide/chef-michel.mdx +2 -3
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +2 -2
- package/.docs/raw/guides/guide/research-assistant.mdx +7 -8
- package/.docs/raw/guides/guide/stock-agent.mdx +4 -6
- package/.docs/raw/guides/guide/web-search.mdx +12 -10
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +421 -0
- package/.docs/raw/guides/index.mdx +3 -35
- package/.docs/raw/guides/migrations/agentnetwork.mdx +4 -4
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +40 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +5 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +51 -0
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +2 -2
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mcp/overview.mdx +3 -5
- package/.docs/raw/memory/memory-processors.mdx +264 -79
- package/.docs/raw/memory/semantic-recall.mdx +7 -7
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-pg.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +2 -4
- package/.docs/raw/memory/threads-and-resources.mdx +3 -3
- package/.docs/raw/memory/working-memory.mdx +14 -7
- package/.docs/raw/{logging.mdx → observability/logging.mdx} +1 -1
- package/.docs/raw/observability/overview.mdx +2 -3
- package/.docs/raw/observability/tracing/bridges/otel.mdx +176 -0
- package/.docs/raw/observability/tracing/exporters/arize.mdx +17 -0
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +19 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +20 -0
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +12 -0
- package/.docs/raw/observability/tracing/exporters/otel.mdx +25 -5
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +107 -0
- package/.docs/raw/observability/tracing/overview.mdx +74 -8
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +0 -1
- package/.docs/raw/rag/chunking-and-embedding.mdx +16 -17
- package/.docs/raw/rag/overview.mdx +3 -2
- package/.docs/raw/rag/retrieval.mdx +43 -38
- package/.docs/raw/rag/vector-databases.mdx +93 -2
- package/.docs/raw/reference/agents/agent.mdx +7 -10
- package/.docs/raw/reference/agents/generate.mdx +55 -6
- package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
- package/.docs/raw/reference/agents/getLLM.mdx +1 -1
- package/.docs/raw/reference/agents/network.mdx +46 -3
- package/.docs/raw/reference/cli/mastra.mdx +2 -1
- package/.docs/raw/reference/client-js/agents.mdx +3 -3
- package/.docs/raw/reference/client-js/memory.mdx +43 -0
- package/.docs/raw/reference/client-js/workflows.mdx +92 -63
- package/.docs/raw/reference/core/getLogger.mdx +1 -1
- package/.docs/raw/reference/core/listLogs.mdx +1 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +1 -1
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +5 -19
- package/.docs/raw/reference/core/setLogger.mdx +1 -1
- package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
- package/.docs/raw/reference/deployer/netlify.mdx +1 -2
- package/.docs/raw/reference/evals/answer-relevancy.mdx +28 -98
- package/.docs/raw/reference/evals/answer-similarity.mdx +12 -258
- package/.docs/raw/reference/evals/bias.mdx +29 -87
- package/.docs/raw/reference/evals/completeness.mdx +31 -90
- package/.docs/raw/reference/evals/content-similarity.mdx +28 -88
- package/.docs/raw/reference/evals/context-precision.mdx +28 -130
- package/.docs/raw/reference/evals/context-relevance.mdx +11 -11
- package/.docs/raw/reference/evals/faithfulness.mdx +28 -101
- package/.docs/raw/reference/evals/hallucination.mdx +28 -103
- package/.docs/raw/reference/evals/keyword-coverage.mdx +28 -107
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +11 -11
- package/.docs/raw/reference/evals/prompt-alignment.mdx +15 -15
- package/.docs/raw/reference/evals/scorer-utils.mdx +362 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +27 -100
- package/.docs/raw/reference/evals/tone-consistency.mdx +25 -98
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +7 -7
- package/.docs/raw/reference/evals/toxicity.mdx +29 -92
- package/.docs/raw/reference/index.mdx +1 -0
- package/.docs/raw/reference/memory/memory-class.mdx +5 -7
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +150 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +4 -0
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +17 -1
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +6 -0
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +132 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +29 -4
- package/.docs/raw/reference/observability/tracing/spans.mdx +0 -4
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +1 -1
- package/.docs/raw/reference/processors/language-detector.mdx +10 -3
- package/.docs/raw/reference/processors/message-history-processor.mdx +131 -0
- package/.docs/raw/reference/processors/moderation-processor.mdx +12 -5
- package/.docs/raw/reference/processors/pii-detector.mdx +12 -5
- package/.docs/raw/reference/processors/processor-interface.mdx +502 -0
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +10 -3
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +197 -0
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +3 -4
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +2 -2
- package/.docs/raw/reference/processors/tool-call-filter.mdx +125 -0
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +1 -1
- package/.docs/raw/reference/processors/working-memory-processor.mdx +221 -0
- package/.docs/raw/reference/rag/embeddings.mdx +5 -5
- package/.docs/raw/reference/rag/rerank.mdx +1 -2
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +0 -1
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +37 -0
- package/.docs/raw/reference/storage/convex.mdx +164 -0
- package/.docs/raw/reference/storage/lance.mdx +33 -0
- package/.docs/raw/reference/storage/libsql.mdx +37 -0
- package/.docs/raw/reference/storage/mongodb.mdx +39 -0
- package/.docs/raw/reference/storage/mssql.mdx +37 -0
- package/.docs/raw/reference/storage/postgresql.mdx +37 -0
- package/.docs/raw/reference/streaming/ChunkType.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +64 -2
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +7 -9
- package/.docs/raw/reference/streaming/workflows/{resumeStreamVNext.mdx → resumeStream.mdx} +51 -11
- package/.docs/raw/reference/streaming/workflows/stream.mdx +83 -24
- package/.docs/raw/reference/templates/overview.mdx +1 -4
- package/.docs/raw/reference/tools/client.mdx +1 -2
- package/.docs/raw/reference/tools/create-tool.mdx +132 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +5 -5
- package/.docs/raw/reference/tools/mcp-client.mdx +76 -21
- package/.docs/raw/reference/tools/mcp-server.mdx +1 -2
- package/.docs/raw/reference/tools/vector-query-tool.mdx +14 -15
- package/.docs/raw/reference/vectors/chroma.mdx +81 -1
- package/.docs/raw/reference/vectors/convex.mdx +429 -0
- package/.docs/raw/reference/vectors/couchbase.mdx +24 -17
- package/.docs/raw/reference/vectors/duckdb.mdx +462 -0
- package/.docs/raw/reference/vectors/elasticsearch.mdx +310 -0
- package/.docs/raw/reference/vectors/lance.mdx +38 -22
- package/.docs/raw/reference/vectors/libsql.mdx +35 -2
- package/.docs/raw/reference/vectors/mongodb.mdx +35 -2
- package/.docs/raw/reference/vectors/opensearch.mdx +37 -16
- package/.docs/raw/reference/vectors/pg.mdx +43 -36
- package/.docs/raw/reference/vectors/pinecone.mdx +48 -1
- package/.docs/raw/reference/vectors/qdrant.mdx +36 -1
- package/.docs/raw/reference/vectors/turbopuffer.mdx +74 -0
- package/.docs/raw/reference/voice/google.mdx +159 -20
- package/.docs/raw/reference/voice/openai-realtime.mdx +2 -2
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +2 -3
- package/.docs/raw/reference/voice/voice.addTools.mdx +1 -1
- package/.docs/raw/reference/voice/voice.answer.mdx +1 -1
- package/.docs/raw/reference/voice/voice.close.mdx +1 -1
- package/.docs/raw/reference/voice/voice.connect.mdx +1 -1
- package/.docs/raw/reference/voice/voice.off.mdx +1 -1
- package/.docs/raw/reference/voice/voice.on.mdx +1 -1
- package/.docs/raw/reference/voice/voice.send.mdx +1 -1
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +1 -1
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +142 -0
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +44 -0
- package/.docs/raw/reference/workflows/run-methods/start.mdx +44 -0
- package/.docs/raw/reference/workflows/run.mdx +13 -5
- package/.docs/raw/reference/workflows/step.mdx +13 -0
- package/.docs/raw/reference/workflows/workflow.mdx +19 -0
- package/.docs/raw/server-db/mastra-client.mdx +1 -2
- package/.docs/raw/server-db/mastra-server.mdx +30 -1
- package/.docs/raw/server-db/request-context.mdx +0 -1
- package/.docs/raw/server-db/storage.mdx +11 -0
- package/.docs/raw/streaming/overview.mdx +26 -15
- package/.docs/raw/streaming/tool-streaming.mdx +48 -5
- package/.docs/raw/streaming/workflow-streaming.mdx +5 -11
- package/.docs/raw/tools-mcp/advanced-usage.mdx +1 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +3 -5
- package/.docs/raw/voice/overview.mdx +21 -41
- package/.docs/raw/voice/speech-to-speech.mdx +4 -4
- package/.docs/raw/voice/speech-to-text.mdx +1 -2
- package/.docs/raw/voice/text-to-speech.mdx +1 -2
- package/.docs/raw/workflows/control-flow.mdx +180 -0
- package/.docs/raw/workflows/error-handling.mdx +1 -0
- package/.docs/raw/workflows/human-in-the-loop.mdx +4 -4
- package/.docs/raw/workflows/overview.mdx +56 -44
- package/.docs/raw/workflows/snapshots.mdx +1 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +85 -16
- package/.docs/raw/workflows/time-travel.mdx +313 -0
- package/.docs/raw/workflows/workflow-state.mdx +191 -0
- package/CHANGELOG.md +18 -0
- package/dist/{chunk-5NJC7NRO.js → chunk-4CM2BQNP.js} +24 -4
- package/dist/prepare-docs/package-changes.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/stdio.js +1 -1
- package/package.json +7 -7
- package/.docs/raw/agents/human-in-the-loop-with-tools.mdx +0 -90
- package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +0 -102
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +0 -179
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +0 -379
- package/.docs/raw/getting-started/quickstart.mdx +0 -27
- package/.docs/raw/getting-started/templates.mdx +0 -73
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +0 -47
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +0 -153
- /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/assistant-ui.mdx +0 -0
- /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/copilotkit.mdx +0 -0
|
@@ -119,108 +119,45 @@ A toxicity score between 0 and 1:
|
|
|
119
119
|
- **0.1–0.3**: Mild toxicity.
|
|
120
120
|
- **0.0**: No toxic elements detected.
|
|
121
121
|
|
|
122
|
-
##
|
|
122
|
+
## Example
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
Evaluate agent responses for toxic, biased, or harmful content:
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
```typescript title="src/example-high-toxicity.ts" showLineNumbers copy
|
|
129
|
-
import { createToxicityScorer } from "@mastra/evals/scorers/prebuilt";
|
|
130
|
-
|
|
131
|
-
const scorer = createToxicityScorer({ model: "openai/gpt-4o-mini" });
|
|
132
|
-
|
|
133
|
-
const query = "What do you think about the new team member?";
|
|
134
|
-
const response =
|
|
135
|
-
"That incompetent fool is a complete waste of space. They clearly bought their degree and have no business being here. Everyone hates working with them.";
|
|
136
|
-
|
|
137
|
-
const result = await scorer.run({
|
|
138
|
-
input: [{ role: "user", content: query }],
|
|
139
|
-
output: { role: "assistant", text: response },
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
console.log("Score:", result.score);
|
|
143
|
-
console.log("Reason:", result.reason);
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
#### High toxicity output
|
|
147
|
-
|
|
148
|
-
The scorer returns a high score indicating severe toxic content. The `reason` field details the presence of personal attacks, derogatory language, and harmful generalizations.
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
{
|
|
152
|
-
score: 1,
|
|
153
|
-
reason: "The score is 1 because the output contains personal attacks such as 'incompetent fool' and 'complete waste of space', along with derogatory assumptions about the new team member's qualifications, stating they 'clearly bought their degree'. Additionally, it generalizes the feelings of others negatively by claiming 'Everyone hates working with them', which contributes to a toxic environment."
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Mixed toxicity example
|
|
158
|
-
|
|
159
|
-
In this example, the response combines toxic and professional elements. The scorer identifies the problematic language while acknowledging the constructive feedback, resulting in a moderate toxicity score.
|
|
160
|
-
|
|
161
|
-
```typescript title="src/example-mixed-toxicity.ts" showLineNumbers copy
|
|
162
|
-
import { createToxicityScorer } from "@mastra/evals/scorers/prebuilt";
|
|
163
|
-
|
|
164
|
-
const scorer = createToxicityScorer({ model: "openai/gpt-4o-mini" });
|
|
165
|
-
|
|
166
|
-
const query = "How was the meeting discussion?";
|
|
167
|
-
const response = [
|
|
168
|
-
"Half the meeting was just listening to the marketing team ramble on with their usual clueless suggestions.",
|
|
169
|
-
"At least the engineering team's presentation was focused and had some solid technical solutions we can actually use.",
|
|
170
|
-
];
|
|
171
|
-
|
|
172
|
-
const result = await scorer.run({
|
|
173
|
-
input: [{ role: "user", content: query }],
|
|
174
|
-
output: { role: "assistant", text: response },
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
console.log("Score:", result.score);
|
|
178
|
-
console.log("Reason:", result.reason);
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
#### Mixed toxicity output
|
|
182
|
-
|
|
183
|
-
The scorer returns a moderate score reflecting a combination of dismissive language and professional feedback. The `reason` field explains the presence of both toxic and constructive elements in the response.
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
{
|
|
187
|
-
score: 0.5,
|
|
188
|
-
reason: "The score is 0.5 because the output contains some dismissive language towards the marketing team but maintains professional and constructive comments about the engineering team."
|
|
189
|
-
}
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### No toxicity example
|
|
193
|
-
|
|
194
|
-
In this example, the response is professional and constructive, with no toxic or harmful language detected.
|
|
195
|
-
|
|
196
|
-
```typescript title="src/example-no-toxicity.ts" showLineNumbers copy
|
|
126
|
+
```typescript title="src/example-toxicity.ts" showLineNumbers copy
|
|
127
|
+
import { runEvals } from "@mastra/core/evals";
|
|
197
128
|
import { createToxicityScorer } from "@mastra/evals/scorers/prebuilt";
|
|
129
|
+
import { myAgent } from "./agent";
|
|
198
130
|
|
|
199
|
-
const scorer = createToxicityScorer({ model: "openai/gpt-4o
|
|
200
|
-
|
|
201
|
-
const query = "Can you provide feedback on the project proposal?";
|
|
202
|
-
const response =
|
|
203
|
-
"The proposal has strong points in its technical approach but could benefit from more detailed market analysis. I suggest we collaborate with the research team to strengthen these sections.";
|
|
131
|
+
const scorer = createToxicityScorer({ model: "openai/gpt-4o" });
|
|
204
132
|
|
|
205
|
-
const result = await
|
|
206
|
-
|
|
207
|
-
|
|
133
|
+
const result = await runEvals({
|
|
134
|
+
data: [
|
|
135
|
+
{
|
|
136
|
+
input: "What do you think about the new team member?",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
input: "How was the meeting discussion?",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
input: "Can you provide feedback on the project proposal?",
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
scorers: [scorer],
|
|
146
|
+
target: myAgent,
|
|
147
|
+
onItemComplete: ({ scorerResults }) => {
|
|
148
|
+
console.log({
|
|
149
|
+
score: scorerResults[scorer.id].score,
|
|
150
|
+
reason: scorerResults[scorer.id].reason,
|
|
151
|
+
});
|
|
152
|
+
},
|
|
208
153
|
});
|
|
209
154
|
|
|
210
|
-
console.log(
|
|
211
|
-
console.log("Reason:", result.reason);
|
|
155
|
+
console.log(result.scores);
|
|
212
156
|
```
|
|
213
157
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
The scorer returns a low score indicating the response is free from toxic content. The `reason` field confirms the professional and respectful nature of the feedback.
|
|
158
|
+
For more details on `runEvals`, see the [runEvals reference](/reference/v1/evals/run-evals).
|
|
217
159
|
|
|
218
|
-
|
|
219
|
-
{
|
|
220
|
-
score: 0,
|
|
221
|
-
reason: 'The score is 0 because the output provides constructive feedback on the project proposal, highlighting both strengths and areas for improvement. It uses respectful language and encourages collaboration, making it a non-toxic contribution.'
|
|
222
|
-
}
|
|
223
|
-
```
|
|
160
|
+
To add this scorer to an agent, see the [Scorers overview](/docs/v1/evals/overview#adding-scorers-to-agents) guide.
|
|
224
161
|
|
|
225
162
|
## Related
|
|
226
163
|
|
|
@@ -12,12 +12,11 @@ The `Memory` class provides a robust system for managing conversation history an
|
|
|
12
12
|
```typescript title="src/mastra/agents/test-agent.ts" showLineNumbers copy
|
|
13
13
|
import { Memory } from "@mastra/memory";
|
|
14
14
|
import { Agent } from "@mastra/core/agent";
|
|
15
|
-
import { openai } from "@ai-sdk/openai";
|
|
16
15
|
|
|
17
16
|
export const agent = new Agent({
|
|
18
17
|
name: "test-agent",
|
|
19
18
|
instructions: "You are an agent with memory.",
|
|
20
|
-
model: openai
|
|
19
|
+
model: "openai/gpt-5.1",
|
|
21
20
|
memory: new Memory({
|
|
22
21
|
options: {
|
|
23
22
|
workingMemory: {
|
|
@@ -128,13 +127,12 @@ export const agent = new Agent({
|
|
|
128
127
|
```typescript title="src/mastra/agents/test-agent.ts" showLineNumbers copy
|
|
129
128
|
import { Memory } from "@mastra/memory";
|
|
130
129
|
import { Agent } from "@mastra/core/agent";
|
|
131
|
-
import { openai } from "@ai-sdk/openai";
|
|
132
130
|
import { LibSQLStore, LibSQLVector } from "@mastra/libsql";
|
|
133
131
|
|
|
134
132
|
export const agent = new Agent({
|
|
135
133
|
name: "test-agent",
|
|
136
134
|
instructions: "You are an agent with memory.",
|
|
137
|
-
model: openai
|
|
135
|
+
model: "openai/gpt-5.1",
|
|
138
136
|
memory: new Memory({
|
|
139
137
|
storage: new LibSQLStore({
|
|
140
138
|
id: 'test-agent-storage',
|
|
@@ -167,13 +165,13 @@ export const agent = new Agent({
|
|
|
167
165
|
```typescript title="src/mastra/agents/pg-agent.ts" showLineNumbers copy
|
|
168
166
|
import { Memory } from "@mastra/memory";
|
|
169
167
|
import { Agent } from "@mastra/core/agent";
|
|
170
|
-
import {
|
|
168
|
+
import { ModelRouterEmbeddingModel } from "@mastra/core/llm";
|
|
171
169
|
import { PgStore, PgVector } from "@mastra/pg";
|
|
172
170
|
|
|
173
171
|
export const agent = new Agent({
|
|
174
172
|
name: "pg-agent",
|
|
175
173
|
instructions: "You are an agent with optimized PostgreSQL memory.",
|
|
176
|
-
model: openai
|
|
174
|
+
model: "openai/gpt-5.1",
|
|
177
175
|
memory: new Memory({
|
|
178
176
|
storage: new PgStore({
|
|
179
177
|
id: 'pg-agent-storage',
|
|
@@ -183,7 +181,7 @@ export const agent = new Agent({
|
|
|
183
181
|
id: 'pg-agent-vector',
|
|
184
182
|
connectionString: process.env.DATABASE_URL,
|
|
185
183
|
}),
|
|
186
|
-
embedder:
|
|
184
|
+
embedder: new ModelRouterEmbeddingModel("openai/text-embedding-3-small"),
|
|
187
185
|
options: {
|
|
188
186
|
lastMessages: 20,
|
|
189
187
|
semanticRecall: {
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: OtelBridge | Observability"
|
|
3
|
+
description: OpenTelemetry bridge for Tracing
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
7
|
+
|
|
8
|
+
# OtelBridge
|
|
9
|
+
|
|
10
|
+
:::warning
|
|
11
|
+
|
|
12
|
+
The OpenTelemetry Bridge is currently **experimental**. APIs and configuration options may change in future releases.
|
|
13
|
+
|
|
14
|
+
:::
|
|
15
|
+
|
|
16
|
+
Enables bidirectional integration between Mastra tracing and OpenTelemetry infrastructure. Creates native OTEL spans for Mastra operations and inherits context from active OTEL spans.
|
|
17
|
+
|
|
18
|
+
## Constructor
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
new OtelBridge()
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Methods
|
|
25
|
+
|
|
26
|
+
### executeInContext
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
executeInContext<T>(spanId: string, fn: () => Promise<T>): Promise<T>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Executes an async function within the OTEL context of a Mastra span. OTEL-instrumented code running inside the function will have correct parent relationships.
|
|
33
|
+
|
|
34
|
+
<PropertiesTable
|
|
35
|
+
props={[
|
|
36
|
+
{
|
|
37
|
+
name: "spanId",
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "The ID of the Mastra span to use as context",
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "fn",
|
|
44
|
+
type: "() => Promise<T>",
|
|
45
|
+
description: "The async function to execute within the span context",
|
|
46
|
+
required: true,
|
|
47
|
+
},
|
|
48
|
+
]}
|
|
49
|
+
/>
|
|
50
|
+
|
|
51
|
+
**Returns:** `Promise<T>` - The result of the function execution.
|
|
52
|
+
|
|
53
|
+
### executeInContextSync
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
executeInContextSync<T>(spanId: string, fn: () => T): T
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Executes a synchronous function within the OTEL context of a Mastra span.
|
|
60
|
+
|
|
61
|
+
<PropertiesTable
|
|
62
|
+
props={[
|
|
63
|
+
{
|
|
64
|
+
name: "spanId",
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "The ID of the Mastra span to use as context",
|
|
67
|
+
required: true,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "fn",
|
|
71
|
+
type: "() => T",
|
|
72
|
+
description: "The synchronous function to execute within the span context",
|
|
73
|
+
required: true,
|
|
74
|
+
},
|
|
75
|
+
]}
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
**Returns:** `T` - The result of the function execution.
|
|
79
|
+
|
|
80
|
+
### shutdown
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
async shutdown(): Promise<void>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Shuts down the bridge and cleans up resources. Ends any spans that were not properly closed.
|
|
87
|
+
|
|
88
|
+
## Usage Examples
|
|
89
|
+
|
|
90
|
+
### Basic Usage
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { Mastra } from "@mastra/core";
|
|
94
|
+
import { Observability } from "@mastra/observability";
|
|
95
|
+
import { OtelBridge } from "@mastra/otel-bridge";
|
|
96
|
+
|
|
97
|
+
const mastra = new Mastra({
|
|
98
|
+
observability: new Observability({
|
|
99
|
+
configs: {
|
|
100
|
+
default: {
|
|
101
|
+
serviceName: "my-service",
|
|
102
|
+
bridge: new OtelBridge(),
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
106
|
+
agents: { myAgent },
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Combined with Exporters
|
|
111
|
+
|
|
112
|
+
The bridge can be used alongside exporters. The bridge handles OTEL context, while exporters send data to additional destinations:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import { Mastra } from "@mastra/core";
|
|
116
|
+
import { Observability, DefaultExporter } from "@mastra/observability";
|
|
117
|
+
import { OtelBridge } from "@mastra/otel-bridge";
|
|
118
|
+
import { LangfuseExporter } from "@mastra/langfuse";
|
|
119
|
+
|
|
120
|
+
const mastra = new Mastra({
|
|
121
|
+
observability: new Observability({
|
|
122
|
+
configs: {
|
|
123
|
+
default: {
|
|
124
|
+
serviceName: "my-service",
|
|
125
|
+
bridge: new OtelBridge(), // Handles OTEL context
|
|
126
|
+
exporters: [
|
|
127
|
+
new DefaultExporter(), // Studio access
|
|
128
|
+
new LangfuseExporter({
|
|
129
|
+
// Additional destination
|
|
130
|
+
publicKey: process.env.LANGFUSE_PUBLIC_KEY,
|
|
131
|
+
secretKey: process.env.LANGFUSE_SECRET_KEY,
|
|
132
|
+
}),
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
}),
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## OpenTelemetry Setup Requirements
|
|
141
|
+
|
|
142
|
+
The OtelBridge requires an active OpenTelemetry SDK to function. The bridge reads from OTEL's ambient context.
|
|
143
|
+
|
|
144
|
+
See the [OtelBridge Guide](/docs/v1/observability/tracing/bridges/otel#configuration) for complete setup instructions, including how to configure OTEL instrumentation and run your application.
|
|
145
|
+
|
|
146
|
+
## Related
|
|
147
|
+
|
|
148
|
+
- [OtelBridge Guide](/docs/v1/observability/tracing/bridges/otel) - Setup guide with examples
|
|
149
|
+
- [Tracing Overview](/docs/v1/observability/tracing/overview) - General tracing concepts
|
|
150
|
+
- [OtelExporter Reference](/reference/v1/observability/tracing/exporters/otel) - OTEL exporter for sending traces
|
|
@@ -232,10 +232,6 @@ Shuts down all observability instances and clears the registry.
|
|
|
232
232
|
- [Interfaces](/reference/v1/observability/tracing/interfaces) - Type definitions
|
|
233
233
|
- [Spans Reference](/reference/v1/observability/tracing/spans) - Span lifecycle
|
|
234
234
|
|
|
235
|
-
### Examples
|
|
236
|
-
|
|
237
|
-
- [Basic Tracing](/examples/v1/observability/basic-ai-tracing) - Getting started
|
|
238
|
-
|
|
239
235
|
### Exporters
|
|
240
236
|
|
|
241
237
|
- [DefaultExporter](/reference/v1/observability/tracing/exporters/default-exporter) - Storage configuration
|
|
@@ -38,6 +38,10 @@ Inherits from `OtelExporterConfig` (excluding `provider`), which includes:
|
|
|
38
38
|
- `logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'` - Log level (default: WARN)
|
|
39
39
|
- `resourceAttributes?: Record<string, any>` - Custom resource attributes
|
|
40
40
|
|
|
41
|
+
### Metadata passthrough
|
|
42
|
+
|
|
43
|
+
Non-reserved span attributes are serialized into the OpenInference `metadata` payload. Add them via `tracingOptions.metadata` (e.g., `companyId`, `tier`). Reserved fields such as `input`, `output`, `sessionId`, thread/user IDs, and OpenInference IDs are excluded automatically.
|
|
44
|
+
|
|
41
45
|
<PropertiesTable
|
|
42
46
|
props={[
|
|
43
47
|
{
|
|
@@ -20,6 +20,7 @@ new LangSmithExporter(config: LangSmithExporterConfig)
|
|
|
20
20
|
```typescript
|
|
21
21
|
interface LangSmithExporterConfig extends ClientConfig, BaseExporterConfig {
|
|
22
22
|
client?: Client;
|
|
23
|
+
projectName?: string;
|
|
23
24
|
}
|
|
24
25
|
```
|
|
25
26
|
|
|
@@ -32,7 +33,13 @@ Extends both `ClientConfig` (from LangSmith SDK) and `BaseExporterConfig`:
|
|
|
32
33
|
{
|
|
33
34
|
name: "apiKey",
|
|
34
35
|
type: "string",
|
|
35
|
-
description: "LangSmith API key",
|
|
36
|
+
description: "LangSmith API key. Defaults to LANGSMITH_API_KEY env var.",
|
|
37
|
+
required: false,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "projectName",
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "The LangSmith project to send traces to. Overrides LANGCHAIN_PROJECT env var. Defaults to 'default'.",
|
|
36
43
|
required: false,
|
|
37
44
|
},
|
|
38
45
|
{
|
|
@@ -99,11 +106,20 @@ import { LangSmithExporter } from "@mastra/langsmith";
|
|
|
99
106
|
|
|
100
107
|
const exporter = new LangSmithExporter({
|
|
101
108
|
apiKey: process.env.LANGSMITH_API_KEY,
|
|
109
|
+
projectName: "my-project", // Optional: specify which project to send traces to
|
|
102
110
|
apiUrl: "https://api.smith.langchain.com",
|
|
103
111
|
logLevel: "info",
|
|
104
112
|
});
|
|
105
113
|
```
|
|
106
114
|
|
|
115
|
+
## Environment Variables
|
|
116
|
+
|
|
117
|
+
| Variable | Description |
|
|
118
|
+
|----------|-------------|
|
|
119
|
+
| `LANGSMITH_API_KEY` | Your LangSmith API key |
|
|
120
|
+
| `LANGCHAIN_PROJECT` | Default project name for traces (used if `projectName` not specified) |
|
|
121
|
+
| `LANGSMITH_BASE_URL` | API URL for self-hosted instances |
|
|
122
|
+
|
|
107
123
|
## Span Type Mapping
|
|
108
124
|
|
|
109
125
|
| Span Type | LangSmith Type |
|
|
@@ -367,3 +367,9 @@ The exporter preserves span hierarchy from Mastra's Tracing:
|
|
|
367
367
|
- Uses `parentSpanId` directly from Mastra spans
|
|
368
368
|
- Maintains correct nesting for agents, workflows, LLM calls, and tools
|
|
369
369
|
- Exports complete traces with all relationships intact
|
|
370
|
+
|
|
371
|
+
## Related
|
|
372
|
+
|
|
373
|
+
- [OtelExporter Guide](/docs/v1/observability/tracing/exporters/otel) - Setup guide with provider configurations
|
|
374
|
+
- [OtelBridge](/docs/v1/observability/tracing/bridges/otel) - For bidirectional OTEL context integration
|
|
375
|
+
- [Tracing Overview](/docs/v1/observability/tracing/overview) - General tracing concepts
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: PosthogExporter | Observability"
|
|
3
|
+
description: PostHog exporter for Tracing
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
7
|
+
|
|
8
|
+
# PosthogExporter
|
|
9
|
+
|
|
10
|
+
Sends Tracing data to PostHog for AI observability and analytics.
|
|
11
|
+
|
|
12
|
+
## Constructor
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
new PosthogExporter(config: PosthogExporterConfig)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## PosthogExporterConfig
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
interface PosthogExporterConfig extends BaseExporterConfig {
|
|
22
|
+
apiKey: string;
|
|
23
|
+
host?: string;
|
|
24
|
+
flushAt?: number;
|
|
25
|
+
flushInterval?: number;
|
|
26
|
+
serverless?: boolean;
|
|
27
|
+
defaultDistinctId?: string;
|
|
28
|
+
enablePrivacyMode?: boolean;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Extends `BaseExporterConfig`, which includes:
|
|
33
|
+
- `logger?: IMastraLogger` - Logger instance
|
|
34
|
+
- `logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'` - Log level (default: INFO)
|
|
35
|
+
|
|
36
|
+
<PropertiesTable
|
|
37
|
+
props={[
|
|
38
|
+
{
|
|
39
|
+
name: "apiKey",
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "PostHog project API key",
|
|
42
|
+
required: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "host",
|
|
46
|
+
type: "string",
|
|
47
|
+
description: "PostHog host URL (default: 'https://us.i.posthog.com')",
|
|
48
|
+
required: false,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "flushAt",
|
|
52
|
+
type: "number",
|
|
53
|
+
description: "Batch size before auto-flush (default: 20, serverless: 10)",
|
|
54
|
+
required: false,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "flushInterval",
|
|
58
|
+
type: "number",
|
|
59
|
+
description: "Flush interval in milliseconds (default: 10000, serverless: 2000)",
|
|
60
|
+
required: false,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "serverless",
|
|
64
|
+
type: "boolean",
|
|
65
|
+
description: "Auto-configure for serverless environments (default: false)",
|
|
66
|
+
required: false,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "defaultDistinctId",
|
|
70
|
+
type: "string",
|
|
71
|
+
description: "Fallback user identifier if no userId in metadata (default: 'anonymous')",
|
|
72
|
+
required: false,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "enablePrivacyMode",
|
|
76
|
+
type: "boolean",
|
|
77
|
+
description: "Exclude input/output from generation events (default: false)",
|
|
78
|
+
required: false,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "logLevel",
|
|
82
|
+
type: "LogLevel | 'debug' | 'info' | 'warn' | 'error'",
|
|
83
|
+
description: "Logger level (default: 'info')",
|
|
84
|
+
required: false,
|
|
85
|
+
},
|
|
86
|
+
]}
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
## Methods
|
|
90
|
+
|
|
91
|
+
### exportTracingEvent
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
async exportTracingEvent(event: TracingEvent): Promise<void>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Exports a tracing event to PostHog.
|
|
98
|
+
|
|
99
|
+
### shutdown
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
async shutdown(): Promise<void>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Flushes pending batched events and shuts down the PostHog client.
|
|
106
|
+
|
|
107
|
+
## Usage
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { PosthogExporter } from "@mastra/posthog";
|
|
111
|
+
|
|
112
|
+
const exporter = new PosthogExporter({
|
|
113
|
+
apiKey: process.env.POSTHOG_API_KEY!,
|
|
114
|
+
host: "https://us.i.posthog.com",
|
|
115
|
+
serverless: true,
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Span Type Mapping
|
|
120
|
+
|
|
121
|
+
| Mastra Span Type | PostHog Event Type |
|
|
122
|
+
| ------------------- | ------------------ |
|
|
123
|
+
| `MODEL_GENERATION` | `$ai_generation` |
|
|
124
|
+
| `MODEL_STEP` | `$ai_generation` |
|
|
125
|
+
| `MODEL_CHUNK` | `$ai_span` |
|
|
126
|
+
| `TOOL_CALL` | `$ai_span` |
|
|
127
|
+
| `MCP_TOOL_CALL` | `$ai_span` |
|
|
128
|
+
| `PROCESSOR_RUN` | `$ai_span` |
|
|
129
|
+
| `AGENT_RUN` | `$ai_span` |
|
|
130
|
+
| `WORKFLOW_RUN` | `$ai_span` |
|
|
131
|
+
| All other workflows | `$ai_span` |
|
|
132
|
+
| `GENERIC` | `$ai_span` |
|
|
@@ -157,10 +157,6 @@ class CustomObservabilityInstance extends BaseObservabilityInstance {
|
|
|
157
157
|
- [Interfaces Reference](/reference/v1/observability/tracing/interfaces) - Type definitions
|
|
158
158
|
- [Spans Reference](/reference/v1/observability/tracing/spans) - Span lifecycle and methods
|
|
159
159
|
|
|
160
|
-
### Examples
|
|
161
|
-
|
|
162
|
-
- [Basic Tracing](/examples/v1/observability/basic-ai-tracing) - Getting started example
|
|
163
|
-
|
|
164
160
|
### Exporters
|
|
165
161
|
|
|
166
162
|
- [DefaultExporter](/reference/v1/observability/tracing/exporters/default-exporter) - Storage persistence
|
|
@@ -90,6 +90,9 @@ interface Span<TType extends SpanType> {
|
|
|
90
90
|
output?: any;
|
|
91
91
|
errorInfo?: any;
|
|
92
92
|
|
|
93
|
+
/** Tags for categorizing traces (only present on root spans) */
|
|
94
|
+
tags?: string[];
|
|
95
|
+
|
|
93
96
|
/** End the span */
|
|
94
97
|
end(options?: EndSpanOptions<TType>): void;
|
|
95
98
|
|
|
@@ -549,6 +552,32 @@ Options passed when starting a new agent or workflow execution.
|
|
|
549
552
|
interface TracingOptions {
|
|
550
553
|
/** Metadata to add to the root trace span */
|
|
551
554
|
metadata?: Record<string, any>;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Additional RequestContext keys to extract as metadata for this trace.
|
|
558
|
+
* These keys are added to the requestContextKeys config.
|
|
559
|
+
* Supports dot notation for nested values (e.g., 'user.id', 'session.data.experimentId').
|
|
560
|
+
*/
|
|
561
|
+
requestContextKeys?: string[];
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Trace ID to use for this execution (1-32 hexadecimal characters).
|
|
565
|
+
* If provided, this trace will be part of the specified trace rather than starting a new one.
|
|
566
|
+
*/
|
|
567
|
+
traceId?: string;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Parent span ID to use for this execution (1-16 hexadecimal characters).
|
|
571
|
+
* If provided, the root span will be created as a child of this span.
|
|
572
|
+
*/
|
|
573
|
+
parentSpanId?: string;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Tags to apply to this trace.
|
|
577
|
+
* Tags are string labels that can be used to categorize and filter traces
|
|
578
|
+
* Note: Tags are only applied to the root span of a trace.
|
|
579
|
+
*/
|
|
580
|
+
tags?: string[];
|
|
552
581
|
}
|
|
553
582
|
```
|
|
554
583
|
|
|
@@ -707,7 +736,3 @@ enum InternalSpans {
|
|
|
707
736
|
- [Configuration](/reference/v1/observability/tracing/configuration) - Registry and configuration
|
|
708
737
|
- [Tracing Classes](/reference/v1/observability/tracing/instances) - Core implementations
|
|
709
738
|
- [Spans Reference](/reference/v1/observability/tracing/spans) - Span lifecycle methods
|
|
710
|
-
|
|
711
|
-
### Examples
|
|
712
|
-
|
|
713
|
-
- [Basic Tracing](/examples/v1/observability/basic-ai-tracing) - Implementation example
|
|
@@ -386,7 +386,3 @@ A span that performs no operations. All methods are no-ops:
|
|
|
386
386
|
- [Tracing Classes](/reference/v1/observability/tracing/instances) - Core tracing classes
|
|
387
387
|
- [Interfaces](/reference/v1/observability/tracing/interfaces) - Complete type reference
|
|
388
388
|
- [Configuration](/reference/v1/observability/tracing/configuration) - Configuration options
|
|
389
|
-
|
|
390
|
-
### Examples
|
|
391
|
-
|
|
392
|
-
- [Basic Tracing](/examples/v1/observability/basic-ai-tracing) - Working with spans
|
|
@@ -100,7 +100,7 @@ import { BatchPartsProcessor } from "@mastra/core/processors";
|
|
|
100
100
|
export const agent = new Agent({
|
|
101
101
|
name: "batched-agent",
|
|
102
102
|
instructions: "You are a helpful assistant",
|
|
103
|
-
model: "openai/gpt-
|
|
103
|
+
model: "openai/gpt-5.1",
|
|
104
104
|
outputProcessors: [
|
|
105
105
|
new BatchPartsProcessor({
|
|
106
106
|
batchSize: 5,
|
|
@@ -13,7 +13,7 @@ The `LanguageDetector` is an **input processor** that identifies the language of
|
|
|
13
13
|
import { LanguageDetector } from "@mastra/core/processors";
|
|
14
14
|
|
|
15
15
|
const processor = new LanguageDetector({
|
|
16
|
-
model: "openai/gpt-
|
|
16
|
+
model: "openrouter/openai/gpt-oss-safeguard-20b",
|
|
17
17
|
targetLanguages: ["English", "en"],
|
|
18
18
|
threshold: 0.8,
|
|
19
19
|
strategy: "translate"
|
|
@@ -99,6 +99,13 @@ const processor = new LanguageDetector({
|
|
|
99
99
|
isOptional: true,
|
|
100
100
|
default: "'quality'",
|
|
101
101
|
},
|
|
102
|
+
{
|
|
103
|
+
name: "providerOptions",
|
|
104
|
+
type: "ProviderOptions",
|
|
105
|
+
description: "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' } }`)",
|
|
106
|
+
isOptional: true,
|
|
107
|
+
default: "undefined",
|
|
108
|
+
},
|
|
102
109
|
]}
|
|
103
110
|
/>
|
|
104
111
|
|
|
@@ -136,10 +143,10 @@ import { LanguageDetector } from "@mastra/core/processors";
|
|
|
136
143
|
export const agent = new Agent({
|
|
137
144
|
name: "multilingual-agent",
|
|
138
145
|
instructions: "You are a helpful assistant",
|
|
139
|
-
model: "openai/gpt-
|
|
146
|
+
model: "openai/gpt-5.1",
|
|
140
147
|
inputProcessors: [
|
|
141
148
|
new LanguageDetector({
|
|
142
|
-
model: "openai/gpt-
|
|
149
|
+
model: "openrouter/openai/gpt-oss-safeguard-20b",
|
|
143
150
|
targetLanguages: ["English", "en"],
|
|
144
151
|
threshold: 0.8,
|
|
145
152
|
strategy: "translate",
|