@mastra/core 1.20.0 → 1.21.0-alpha.1
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/CHANGELOG.md +34 -0
- package/dist/_types/@internal_core/dist/index.d.ts +12 -2
- package/dist/agent/agent-legacy.d.ts +2 -1
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +32 -2
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-RB7WTRE2.js → chunk-2JJQDDEN.js} +8 -6
- package/dist/chunk-2JJQDDEN.js.map +1 -0
- package/dist/{chunk-2QO3IQWR.cjs → chunk-2STTKMFO.cjs} +82 -82
- package/dist/{chunk-2QO3IQWR.cjs.map → chunk-2STTKMFO.cjs.map} +1 -1
- package/dist/{chunk-3FW24B6P.cjs → chunk-3EPAGV3T.cjs} +4 -4
- package/dist/{chunk-3FW24B6P.cjs.map → chunk-3EPAGV3T.cjs.map} +1 -1
- package/dist/{chunk-F3OO446O.cjs → chunk-3OK3LWP4.cjs} +34 -32
- package/dist/chunk-3OK3LWP4.cjs.map +1 -0
- package/dist/{chunk-7JKIBZI7.js → chunk-5QQZSWLU.js} +4 -4
- package/dist/{chunk-7JKIBZI7.js.map → chunk-5QQZSWLU.js.map} +1 -1
- package/dist/{chunk-7URCVA7N.js → chunk-6PJQGNFV.js} +10 -10
- package/dist/chunk-6PJQGNFV.js.map +1 -0
- package/dist/{chunk-ED6CLXQI.cjs → chunk-75LYWKFT.cjs} +25 -25
- package/dist/chunk-75LYWKFT.cjs.map +1 -0
- package/dist/{chunk-53NCHPV5.cjs → chunk-AL5ACSAH.cjs} +7 -7
- package/dist/{chunk-53NCHPV5.cjs.map → chunk-AL5ACSAH.cjs.map} +1 -1
- package/dist/{chunk-S3JFAGMH.js → chunk-B4KB75RH.js} +67 -21
- package/dist/chunk-B4KB75RH.js.map +1 -0
- package/dist/{chunk-3R4YK3VD.js → chunk-CJA2FWKT.js} +3 -3
- package/dist/{chunk-3R4YK3VD.js.map → chunk-CJA2FWKT.js.map} +1 -1
- package/dist/{chunk-FQCASJGT.js → chunk-D7NEB3NV.js} +5 -5
- package/dist/{chunk-FQCASJGT.js.map → chunk-D7NEB3NV.js.map} +1 -1
- package/dist/{chunk-CRGRF7QL.cjs → chunk-E4TMODUG.cjs} +75 -29
- package/dist/chunk-E4TMODUG.cjs.map +1 -0
- package/dist/{chunk-Q4YIRO5A.js → chunk-ESQI2JRD.js} +5 -3
- package/dist/chunk-ESQI2JRD.js.map +1 -0
- package/dist/{chunk-57OYWNNV.cjs → chunk-EX2LVHTL.cjs} +97 -288
- package/dist/chunk-EX2LVHTL.cjs.map +1 -0
- package/dist/{chunk-J7AHOVB2.cjs → chunk-F6ZURDS4.cjs} +368 -218
- package/dist/chunk-F6ZURDS4.cjs.map +1 -0
- package/dist/chunk-FAULJTC5.js +290 -0
- package/dist/chunk-FAULJTC5.js.map +1 -0
- package/dist/{chunk-T72NHA2O.cjs → chunk-FJT6H2US.cjs} +3 -3
- package/dist/chunk-FJT6H2US.cjs.map +1 -0
- package/dist/{chunk-BCOOJFBB.js → chunk-GGJSRBFY.js} +13 -7
- package/dist/chunk-GGJSRBFY.js.map +1 -0
- package/dist/{chunk-CU6QKXLW.js → chunk-HU6OWHBI.js} +3 -3
- package/dist/{chunk-CU6QKXLW.js.map → chunk-HU6OWHBI.js.map} +1 -1
- package/dist/{chunk-JBOVTCTQ.cjs → chunk-I7AUCCNO.cjs} +69 -69
- package/dist/{chunk-JBOVTCTQ.cjs.map → chunk-I7AUCCNO.cjs.map} +1 -1
- package/dist/{chunk-GFRRPVRL.cjs → chunk-IG6JCDCL.cjs} +185 -185
- package/dist/{chunk-GFRRPVRL.cjs.map → chunk-IG6JCDCL.cjs.map} +1 -1
- package/dist/{chunk-UFXC6VJW.js → chunk-JB7HORUI.js} +3 -3
- package/dist/{chunk-UFXC6VJW.js.map → chunk-JB7HORUI.js.map} +1 -1
- package/dist/{chunk-2H6WEHWI.js → chunk-JBLN5IVV.js} +4 -4
- package/dist/{chunk-2H6WEHWI.js.map → chunk-JBLN5IVV.js.map} +1 -1
- package/dist/{chunk-HOAKFZ6P.js → chunk-JIA3SJK6.js} +198 -48
- package/dist/chunk-JIA3SJK6.js.map +1 -0
- package/dist/{chunk-MIWHSH7L.js → chunk-KLHD3PBK.js} +3 -3
- package/dist/chunk-KLHD3PBK.js.map +1 -0
- package/dist/{chunk-5PAHRQLU.js → chunk-ODUJYYA5.js} +32 -7
- package/dist/chunk-ODUJYYA5.js.map +1 -0
- package/dist/chunk-QRJSP5G2.cjs +300 -0
- package/dist/chunk-QRJSP5G2.cjs.map +1 -0
- package/dist/{chunk-7PYYVPF5.js → chunk-RF42EKVR.js} +6 -6
- package/dist/{chunk-7PYYVPF5.js.map → chunk-RF42EKVR.js.map} +1 -1
- package/dist/{chunk-L6AZQNL2.cjs → chunk-S6B5GIFC.cjs} +31 -25
- package/dist/chunk-S6B5GIFC.cjs.map +1 -0
- package/dist/{chunk-YEQJIM5W.cjs → chunk-TMRHUTY6.cjs} +15 -15
- package/dist/{chunk-YEQJIM5W.cjs.map → chunk-TMRHUTY6.cjs.map} +1 -1
- package/dist/{chunk-BZW4PQNA.cjs → chunk-UUNTJ256.cjs} +9 -7
- package/dist/chunk-UUNTJ256.cjs.map +1 -0
- package/dist/{chunk-RDHIVATT.cjs → chunk-VAACVUEO.cjs} +9 -9
- package/dist/{chunk-RDHIVATT.cjs.map → chunk-VAACVUEO.cjs.map} +1 -1
- package/dist/{chunk-UCCVELTP.js → chunk-VJKW6RRY.js} +7 -7
- package/dist/{chunk-UCCVELTP.js.map → chunk-VJKW6RRY.js.map} +1 -1
- package/dist/{chunk-2NISBCML.js → chunk-WG7QIVL7.js} +92 -280
- package/dist/chunk-WG7QIVL7.js.map +1 -0
- package/dist/{chunk-QG7NJ3JU.cjs → chunk-XANKVDSM.cjs} +10 -10
- package/dist/{chunk-QG7NJ3JU.cjs.map → chunk-XANKVDSM.cjs.map} +1 -1
- package/dist/{chunk-HVVHMUI4.cjs → chunk-Z745DCGY.cjs} +34 -9
- package/dist/chunk-Z745DCGY.cjs.map +1 -0
- package/dist/datasets/experiment/scorer.d.ts.map +1 -1
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +3 -3
- package/dist/docs/assets/SOURCE_MAP.json +522 -522
- package/dist/docs/references/docs-server-mastra-client.md +12 -10
- package/dist/docs/references/docs-server-mastra-server.md +13 -1
- package/dist/docs/references/docs-studio-observability.md +9 -1
- package/dist/docs/references/docs-studio-overview.md +1 -1
- package/dist/docs/references/reference-agents-getLLM.md +9 -3
- package/dist/docs/references/reference.md +2 -0
- package/dist/evals/base.d.ts +29 -6
- package/dist/evals/base.d.ts.map +1 -1
- package/dist/evals/index.cjs +23 -23
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +21 -37
- package/dist/evals/scoreTraces/index.cjs.map +1 -1
- package/dist/evals/scoreTraces/index.js +18 -34
- package/dist/evals/scoreTraces/index.js.map +1 -1
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts +2 -3
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/evals/types.d.ts.map +1 -1
- package/dist/harness/index.cjs +9 -9
- package/dist/harness/index.js +6 -6
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +16 -16
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/provider-types.generated.d.ts +1 -0
- package/dist/logger/index.cjs +6 -6
- package/dist/logger/index.js +1 -1
- package/dist/loop/index.cjs +14 -14
- package/dist/loop/index.js +1 -1
- package/dist/mastra/hooks.d.ts +3 -0
- package/dist/mastra/hooks.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +3 -3
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-4HBR4MAS.js +3 -0
- package/dist/{models-dev-WTF6UG4D.js.map → models-dev-4HBR4MAS.js.map} +1 -1
- package/dist/models-dev-W2D3QNCX.cjs +12 -0
- package/dist/{models-dev-TKKI7LVH.cjs.map → models-dev-W2D3QNCX.cjs.map} +1 -1
- package/dist/netlify-A6TIZLU7.cjs +12 -0
- package/dist/{netlify-QCPWAYI2.cjs.map → netlify-A6TIZLU7.cjs.map} +1 -1
- package/dist/netlify-YRVEP6E4.js +3 -0
- package/dist/{netlify-V6N4TT4H.js.map → netlify-YRVEP6E4.js.map} +1 -1
- package/dist/observability/index.cjs +36 -32
- package/dist/observability/index.js +2 -2
- package/dist/observability/no-op.d.ts +1 -1
- package/dist/observability/no-op.d.ts.map +1 -1
- package/dist/observability/types/core.d.ts +15 -1
- package/dist/observability/types/core.d.ts.map +1 -1
- package/dist/observability/types/feedback.d.ts +2 -2
- package/dist/observability/types/feedback.d.ts.map +1 -1
- package/dist/observability/types/scores.d.ts +16 -7
- package/dist/observability/types/scores.d.ts.map +1 -1
- package/dist/observability/types/tracing.d.ts +27 -1
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/observability/utils.d.ts +12 -1
- package/dist/observability/utils.d.ts.map +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +44 -44
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-6ONBOGD7.cjs +40 -0
- package/dist/{provider-registry-C54SHAP6.cjs.map → provider-registry-6ONBOGD7.cjs.map} +1 -1
- package/dist/provider-registry-AIPF3CGZ.js +3 -0
- package/dist/{provider-registry-34O53EL4.js.map → provider-registry-AIPF3CGZ.js.map} +1 -1
- package/dist/provider-registry.json +4 -2
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +56 -56
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/observability/base.d.ts +4 -0
- package/dist/storage/domains/observability/base.d.ts.map +1 -1
- package/dist/storage/domains/observability/record-builders.d.ts.map +1 -1
- package/dist/storage/index.cjs +286 -286
- package/dist/storage/index.js +3 -3
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/utils.cjs +25 -25
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/package.json +4 -4
- package/src/llm/model/provider-types.generated.d.ts +1 -0
- package/dist/chunk-2NISBCML.js.map +0 -1
- package/dist/chunk-57OYWNNV.cjs.map +0 -1
- package/dist/chunk-5PAHRQLU.js.map +0 -1
- package/dist/chunk-7URCVA7N.js.map +0 -1
- package/dist/chunk-AC5GUOWY.js +0 -72
- package/dist/chunk-AC5GUOWY.js.map +0 -1
- package/dist/chunk-BCOOJFBB.js.map +0 -1
- package/dist/chunk-BZW4PQNA.cjs.map +0 -1
- package/dist/chunk-CRGRF7QL.cjs.map +0 -1
- package/dist/chunk-ED6CLXQI.cjs.map +0 -1
- package/dist/chunk-EZHHTAJU.cjs +0 -78
- package/dist/chunk-EZHHTAJU.cjs.map +0 -1
- package/dist/chunk-F3OO446O.cjs.map +0 -1
- package/dist/chunk-HOAKFZ6P.js.map +0 -1
- package/dist/chunk-HVVHMUI4.cjs.map +0 -1
- package/dist/chunk-J7AHOVB2.cjs.map +0 -1
- package/dist/chunk-L6AZQNL2.cjs.map +0 -1
- package/dist/chunk-MIWHSH7L.js.map +0 -1
- package/dist/chunk-Q4YIRO5A.js.map +0 -1
- package/dist/chunk-RB7WTRE2.js.map +0 -1
- package/dist/chunk-S3JFAGMH.js.map +0 -1
- package/dist/chunk-T72NHA2O.cjs.map +0 -1
- package/dist/models-dev-TKKI7LVH.cjs +0 -12
- package/dist/models-dev-WTF6UG4D.js +0 -3
- package/dist/netlify-QCPWAYI2.cjs +0 -12
- package/dist/netlify-V6N4TT4H.js +0 -3
- package/dist/provider-registry-34O53EL4.js +0 -3
- package/dist/provider-registry-C54SHAP6.cjs +0 -40
|
@@ -4,7 +4,7 @@ The Mastra Client SDK provides a concise and type-safe interface for interacting
|
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Before you start local development, have:
|
|
8
8
|
|
|
9
9
|
- Node.js `v22.13.0` or later
|
|
10
10
|
- TypeScript `v4.7` or higher (if using TypeScript)
|
|
@@ -54,15 +54,17 @@ export const mastraClient = new MastraClient({
|
|
|
54
54
|
|
|
55
55
|
## Core APIs
|
|
56
56
|
|
|
57
|
-
The Mastra Client SDK exposes all resources served by the Mastra Server
|
|
57
|
+
The Mastra Client SDK exposes all resources served by the Mastra Server.
|
|
58
58
|
|
|
59
59
|
- **[Agents](https://mastra.ai/reference/client-js/agents)**: Generate responses and stream conversations.
|
|
60
60
|
- **[Memory](https://mastra.ai/reference/client-js/memory)**: Manage conversation threads and message history.
|
|
61
61
|
- **[Tools](https://mastra.ai/reference/client-js/tools)**: Executed and managed tools.
|
|
62
62
|
- **[Workflows](https://mastra.ai/reference/client-js/workflows)**: Trigger workflows and track their execution.
|
|
63
63
|
- **[Vectors](https://mastra.ai/reference/client-js/vectors)**: Use vector embeddings for semantic search.
|
|
64
|
+
- **[Responses](https://mastra.ai/reference/client-js/responses)**: Call the OpenAI Responses API through Mastra agents. This API is currently experimental.
|
|
65
|
+
- **[Conversations](https://mastra.ai/reference/client-js/conversations)**: Work with OpenAI Responses API conversations and their stored item history. This API is currently experimental.
|
|
64
66
|
- **[Logs](https://mastra.ai/reference/client-js/logs)**: View logs and debug system behavior.
|
|
65
|
-
- **[Telemetry](https://mastra.ai/reference/client-js/telemetry)**:
|
|
67
|
+
- **[Telemetry](https://mastra.ai/reference/client-js/telemetry)**: View app performance and trace activity.
|
|
66
68
|
|
|
67
69
|
## Generating responses
|
|
68
70
|
|
|
@@ -133,7 +135,7 @@ export const mastraClient = new MastraClient({
|
|
|
133
135
|
|
|
134
136
|
## Credentials and session cookies
|
|
135
137
|
|
|
136
|
-
**Authenticate Mastra API calls with session cookies** when your UI and Mastra API
|
|
138
|
+
**Authenticate Mastra API calls with session cookies** when your UI and Mastra API aren't on the same origin—different host, subdomain, or port (for example Mastra Studio on one port and a custom server on another). Add **`credentials: 'include'`** to `MastraClient` so each request carries the cookies the user already has after sign-in. Skip this and you will often get **`401`** responses from Mastra even though login succeeded in the browser.
|
|
137
139
|
|
|
138
140
|
```typescript
|
|
139
141
|
import { MastraClient } from '@mastra/client-js'
|
|
@@ -146,7 +148,7 @@ export const mastraClient = new MastraClient({
|
|
|
146
148
|
|
|
147
149
|
**Allow credentialed cross-origin requests on your server**—see [CORS: requests with credentials](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS#requests_with_credentials). You need a concrete `Access-Control-Allow-Origin` (not `*`) and `Access-Control-Allow-Credentials: true`, or the browser will block the call before it reaches Mastra.
|
|
148
150
|
|
|
149
|
-
**Using `@mastra/react`?** Wrap your app with `MastraReactProvider`, set `baseUrl` and `apiPrefix` to match your server, and rely on the default `credentials: 'include'`. Change `credentials` only when you
|
|
151
|
+
**Using `@mastra/react`?** Wrap your app with `MastraReactProvider`, set `baseUrl` and `apiPrefix` to match your server, and rely on the default `credentials: 'include'`. Change `credentials` only when you want `same-origin` or `omit` behavior.
|
|
150
152
|
|
|
151
153
|
## Adding request cancelling
|
|
152
154
|
|
|
@@ -219,7 +221,7 @@ const handleClientTool = async () => {
|
|
|
219
221
|
}
|
|
220
222
|
```
|
|
221
223
|
|
|
222
|
-
### Client tool
|
|
224
|
+
### Client tool agent
|
|
223
225
|
|
|
224
226
|
This is a standard Mastra [agent](https://mastra.ai/docs/agents/overview) configured to return hex color codes, intended to work with the browser-based client tool defined above.
|
|
225
227
|
|
|
@@ -236,9 +238,9 @@ export const colorAgent = new Agent({
|
|
|
236
238
|
})
|
|
237
239
|
```
|
|
238
240
|
|
|
239
|
-
##
|
|
241
|
+
## Use MastraClient on the server
|
|
240
242
|
|
|
241
|
-
You can also use `MastraClient` in server-side environments such as API routes, serverless functions or actions. The usage
|
|
243
|
+
You can also use `MastraClient` in server-side environments such as API routes, serverless functions, or actions. The usage remains the same, but you may need to recreate the response for your client:
|
|
242
244
|
|
|
243
245
|
```typescript
|
|
244
246
|
export async function action() {
|
|
@@ -252,7 +254,7 @@ export async function action() {
|
|
|
252
254
|
|
|
253
255
|
## Best practices
|
|
254
256
|
|
|
255
|
-
1. **Error Handling**:
|
|
257
|
+
1. **Error Handling**: Use [error handling](https://mastra.ai/reference/client-js/error-handling) for development scenarios.
|
|
256
258
|
2. **Environment Variables**: Use environment variables for configuration.
|
|
257
259
|
3. **Debugging**: Enable detailed [logging](https://mastra.ai/reference/client-js/logs) when needed.
|
|
258
|
-
4. **Performance**:
|
|
260
|
+
4. **Performance**: Track application performance, [telemetry](https://mastra.ai/reference/client-js/telemetry), and traces.
|
|
@@ -12,7 +12,7 @@ The server provides:
|
|
|
12
12
|
|
|
13
13
|
- API endpoints for all registered agents and workflows
|
|
14
14
|
- Custom API routes and middleware
|
|
15
|
-
- Authentication
|
|
15
|
+
- Authentication across providers
|
|
16
16
|
- Request context for dynamic configuration
|
|
17
17
|
- Stream data redaction for secure responses
|
|
18
18
|
|
|
@@ -51,6 +51,18 @@ To explore the API interactively, visit the Swagger UI at <http://localhost:4111
|
|
|
51
51
|
|
|
52
52
|
> **Note:** The OpenAPI and Swagger endpoints are disabled in production by default. To enable them, set [`server.build.openAPIDocs`](https://mastra.ai/reference/configuration) and [`server.build.swaggerUI`](https://mastra.ai/reference/configuration) to `true` respectively.
|
|
53
53
|
|
|
54
|
+
## OpenAI Responses API
|
|
55
|
+
|
|
56
|
+
Mastra exposes OpenAI-compatible Responses and Conversations routes. These routes are agent-backed adapters over Mastra agents, memory, and storage, so requests run through the selected Mastra agent instead of acting as a raw provider proxy.
|
|
57
|
+
|
|
58
|
+
These APIs are currently experimental.
|
|
59
|
+
|
|
60
|
+
Use `agent_id` to select the Mastra agent that should handle the request. Initial requests target an agent directly, and stored follow-up turns can continue with `previous_response_id`. You can also pass `model` to override the agent's configured model for a single request. If you omit `model`, Mastra uses the model already configured on the agent.
|
|
61
|
+
|
|
62
|
+
The Responses routes support streaming, function calling (tools), stored continuations with `previous_response_id`, conversation threads through `conversation_id`, provider-specific passthrough with `providerOptions`, and JSON output through `text.format`.
|
|
63
|
+
|
|
64
|
+
For the full request and response contract, see the [Responses API reference](https://mastra.ai/reference/client-js/responses) and [Conversations API reference](https://mastra.ai/reference/client-js/conversations). For the complete list of HTTP routes, see [server routes](https://mastra.ai/reference/server/routes).
|
|
65
|
+
|
|
54
66
|
## Stream data redaction
|
|
55
67
|
|
|
56
68
|
When streaming agent responses, the HTTP layer redacts system prompts, tool definitions, API keys, and similar data from each chunk before sending it to clients. This is enabled by default.
|
|
@@ -4,6 +4,7 @@ Studio includes these observability views:
|
|
|
4
4
|
|
|
5
5
|
- **Metrics** for aggregate performance data
|
|
6
6
|
- **Traces** for individual request inspection
|
|
7
|
+
- **Logs** for browsing internal and application logs
|
|
7
8
|
|
|
8
9
|
All require an [observability storage backend](#quickstart) to be configured.
|
|
9
10
|
|
|
@@ -21,6 +22,12 @@ When you run an agent or workflow, the Observability tab displays traces that hi
|
|
|
21
22
|
|
|
22
23
|
Tracing filters out low-level framework details so your traces stay focused and readable. Visit the [tracing overview](https://mastra.ai/docs/observability/tracing/overview) for more details.
|
|
23
24
|
|
|
25
|
+
## Logs
|
|
26
|
+
|
|
27
|
+
Browse internal Mastra logs forwarded to your observability storage. Logs provide full-text search (across message content, entity names, and trace IDs), date presets (last 24 hours to 30 days), and multi-select filters for level, entity type, and entity name. Selecting a log opens a detail panel showing the full message, structured data, and metadata. If the log is correlated with a trace, you can navigate directly to the trace and span timeline.
|
|
28
|
+
|
|
29
|
+
Log forwarding is enabled by default when you configure observability. See [logging](https://mastra.ai/docs/observability/logging) for level configuration, query examples, and customization details.
|
|
30
|
+
|
|
24
31
|
## Quickstart
|
|
25
32
|
|
|
26
33
|
For detailed instructions, follow the [observability instructions](https://mastra.ai/docs/observability/overview). To get up and running quickly, add the `@mastra/observability` package to your project and configure it with [LibSQL](https://mastra.ai/reference/storage/libsql) and [DuckDB](https://mastra.ai/reference/vectors/duckdb) for a local development setup that supports both traces and metrics.
|
|
@@ -95,4 +102,5 @@ export const mastra = new Mastra({
|
|
|
95
102
|
|
|
96
103
|
- [Observability overview](https://mastra.ai/docs/observability/overview)
|
|
97
104
|
- [Metrics overview](https://mastra.ai/docs/observability/metrics/overview)
|
|
98
|
-
- [Tracing overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
105
|
+
- [Tracing overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
106
|
+
- [Logging](https://mastra.ai/docs/observability/logging)
|
|
@@ -124,4 +124,4 @@ Mastra also supports HTTPS development through the [`--https`](https://mastra.ai
|
|
|
124
124
|
|
|
125
125
|
- Learn how to [deploy Studio](https://mastra.ai/docs/studio/deployment) for production use.
|
|
126
126
|
- Add [authentication](https://mastra.ai/docs/studio/auth) to control access to your deployed Studio.
|
|
127
|
-
- Explore [Studio observability](https://mastra.ai/docs/studio/observability) to monitor agent performance
|
|
127
|
+
- Explore [Studio observability](https://mastra.ai/docs/studio/observability) to monitor agent performance through metrics, traces, and logs.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agent.getLLM()
|
|
2
2
|
|
|
3
|
-
The `.getLLM()` method retrieves the language model instance configured for an agent, resolving it if it's a function.
|
|
3
|
+
The `.getLLM()` method retrieves the language model instance configured for an agent, resolving it if it's a function. You can also pass a request-scoped `model` override without mutating the agent's configured model.
|
|
4
4
|
|
|
5
5
|
## Usage example
|
|
6
6
|
|
|
@@ -8,13 +8,19 @@ The `.getLLM()` method retrieves the language model instance configured for an a
|
|
|
8
8
|
await agent.getLLM()
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
```typescript
|
|
12
|
+
await agent.getLLM({
|
|
13
|
+
model: 'openai/gpt-5.4',
|
|
14
|
+
})
|
|
15
|
+
```
|
|
16
|
+
|
|
11
17
|
## Parameters
|
|
12
18
|
|
|
13
|
-
**options** (`{ requestContext?: RequestContext; model?:
|
|
19
|
+
**options** (`{ requestContext?: RequestContext; model?: MastraModelConfig | DynamicArgument<MastraModelConfig> }`): Optional configuration object containing request context and an optional request-scoped model override. (Default: `{}`)
|
|
14
20
|
|
|
15
21
|
**options.requestContext** (`RequestContext`): Request Context for dependency injection and contextual information.
|
|
16
22
|
|
|
17
|
-
**options.model** (`
|
|
23
|
+
**options.model** (`MastraModelConfig | DynamicArgument<MastraModelConfig>`): Optional request-scoped model override. The agent's configured model is not mutated.
|
|
18
24
|
|
|
19
25
|
## Returns
|
|
20
26
|
|
|
@@ -41,11 +41,13 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
41
41
|
- [create-mastra](https://mastra.ai/reference/cli/create-mastra)
|
|
42
42
|
- [mastra](https://mastra.ai/reference/cli/mastra)
|
|
43
43
|
- [Agents API](https://mastra.ai/reference/client-js/agents)
|
|
44
|
+
- [Conversations API](https://mastra.ai/reference/client-js/conversations)
|
|
44
45
|
- [Error Handling](https://mastra.ai/reference/client-js/error-handling)
|
|
45
46
|
- [Logs API](https://mastra.ai/reference/client-js/logs)
|
|
46
47
|
- [Mastra Client SDK](https://mastra.ai/reference/client-js/mastra-client)
|
|
47
48
|
- [Memory API](https://mastra.ai/reference/client-js/memory)
|
|
48
49
|
- [Observability API](https://mastra.ai/reference/client-js/observability)
|
|
50
|
+
- [Responses API](https://mastra.ai/reference/client-js/responses)
|
|
49
51
|
- [Telemetry API](https://mastra.ai/reference/client-js/telemetry)
|
|
50
52
|
- [Tools API](https://mastra.ai/reference/client-js/tools)
|
|
51
53
|
- [Vectors API](https://mastra.ai/reference/client-js/vectors)
|
package/dist/evals/base.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
2
|
import type { MastraModelConfig } from '../llm/model/shared.types.js';
|
|
3
3
|
import type { Mastra } from '../mastra/index.js';
|
|
4
|
-
import
|
|
4
|
+
import { EntityType } from '../observability/index.js';
|
|
5
|
+
import type { DefinitionSource, ObservabilityContext, ScorerScoreSource, ScorerStepType, ScorerTargetScope } from '../observability/index.js';
|
|
6
|
+
import { RequestContext } from '../request-context/index.js';
|
|
5
7
|
import type { PublicSchema } from '../schema/index.js';
|
|
6
8
|
import type { ScoringSamplingConfig, ScorerRunInputForAgent, ScorerRunOutputForAgent, Trajectory, TrajectoryExpectation } from './types.js';
|
|
7
9
|
interface ScorerStepDefinition {
|
|
@@ -32,14 +34,33 @@ interface ScorerConfig<TID extends string, TInput = any, TRunOutput = any> {
|
|
|
32
34
|
output: z.ZodSchema<TRunOutput>;
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
interface ScorerRun<TInput = any, TOutput = any>
|
|
37
|
+
interface ScorerRun<TInput = any, TOutput = any> {
|
|
38
|
+
/** Unique ID for this scorer execution. Generated by scorer.run() when omitted. */
|
|
36
39
|
runId?: string;
|
|
40
|
+
/** Primary scorer input. This is often model input/messages, but can be any structured value. */
|
|
37
41
|
input?: TInput;
|
|
42
|
+
/** Primary scorer target output. This is the required value the scorer evaluates. */
|
|
38
43
|
output: TOutput;
|
|
44
|
+
/** Optional expected label/reference value for judged or supervised evaluations. */
|
|
39
45
|
groundTruth?: any;
|
|
40
46
|
/** Expected trajectory config for trajectory scorers. Flows from dataset items or scorer constructor. */
|
|
41
47
|
expectedTrajectory?: TrajectoryExpectation;
|
|
42
|
-
|
|
48
|
+
/** Optional request context forwarded to scorers and judge prompts. */
|
|
49
|
+
requestContext?: Record<string, any> | RequestContext;
|
|
50
|
+
/** What kind of scoring flow produced this score, such as live runs, trace scoring, or experiments. */
|
|
51
|
+
scoreSource?: ScorerScoreSource;
|
|
52
|
+
/**
|
|
53
|
+
* How the scorer interpreted the target data.
|
|
54
|
+
* `span` means a single span's input/output was scored.
|
|
55
|
+
* `trajectory` means a trajectory/path was scored.
|
|
56
|
+
*/
|
|
57
|
+
targetScope?: ScorerTargetScope;
|
|
58
|
+
/** Entity type of the scored target when known. */
|
|
59
|
+
targetEntityType?: EntityType;
|
|
60
|
+
/** Trace anchor for the target being scored. Required today for observability.addScore(). */
|
|
61
|
+
targetTraceId?: string;
|
|
62
|
+
/** Optional span anchor for the target being scored. */
|
|
63
|
+
targetSpanId?: string;
|
|
43
64
|
}
|
|
44
65
|
interface PromptObject<TOutput, TAccumulated extends Record<string, any>, TStepName extends string = string, TInput = any, TRunOutput = any> {
|
|
45
66
|
description: string;
|
|
@@ -59,7 +80,7 @@ interface PromptObject<TOutput, TAccumulated extends Record<string, any>, TStepN
|
|
|
59
80
|
}
|
|
60
81
|
type StepResultKey<T extends string> = `${T}StepResult`;
|
|
61
82
|
type Awaited<T> = T extends Promise<infer U> ? U : T;
|
|
62
|
-
type StepContext<TAccumulated extends Record<string, any>, TInput, TRunOutput> = {
|
|
83
|
+
type StepContext<TAccumulated extends Record<string, any>, TInput, TRunOutput> = Partial<ObservabilityContext> & {
|
|
63
84
|
run: ScorerRun<TInput, TRunOutput>;
|
|
64
85
|
results: TAccumulated;
|
|
65
86
|
};
|
|
@@ -68,6 +89,7 @@ type GenerateReasonContext<TAccumulated extends Record<string, any>, TInput, TRu
|
|
|
68
89
|
score: TAccumulated extends Record<'generateScoreStepResult', infer TScore> ? TScore : never;
|
|
69
90
|
};
|
|
70
91
|
type ScorerRunResult<TAccumulatedResults extends Record<string, any>, TInput, TRunOutput> = Promise<ScorerRun<TInput, TRunOutput> & {
|
|
92
|
+
scoreTraceId?: string;
|
|
71
93
|
score: TAccumulatedResults extends Record<'generateScoreStepResult', infer TScore> ? TScore : never;
|
|
72
94
|
reason?: TAccumulatedResults extends Record<'generateReasonStepResult', infer TReason> ? TReason : undefined;
|
|
73
95
|
preprocessPrompt?: string;
|
|
@@ -116,7 +138,7 @@ declare class MastraScorer<TID extends string = string, TInput = any, TRunOutput
|
|
|
116
138
|
* Tracks whether this scorer was defined in code or loaded from storage.
|
|
117
139
|
* Set by `Mastra.addScorer()` when the `source` option is provided.
|
|
118
140
|
*/
|
|
119
|
-
source?:
|
|
141
|
+
source?: DefinitionSource;
|
|
120
142
|
constructor(config: ScorerConfig<TID, TInput, TRunOutput>, steps?: Array<ScorerStepDefinition>, originalPromptObjects?: Map<string, PromptObject<any, any, any, TInput, TRunOutput> | GenerateReasonPromptObject<any, TInput, TRunOutput> | GenerateScorePromptObject<any, TInput, TRunOutput>>, mastra?: Mastra);
|
|
121
143
|
/**
|
|
122
144
|
* Registers the Mastra instance with the scorer.
|
|
@@ -150,11 +172,12 @@ declare class MastraScorer<TID extends string = string, TInput = any, TRunOutput
|
|
|
150
172
|
generateScore<TScoreOutput extends number = number>(stepDef: GenerateScoreStepDef<TAccumulatedResults, TInput, TRunOutput>): MastraScorer<TID, TInput, TRunOutput, AccumulatedResults<TAccumulatedResults, 'generateScore', Awaited<TScoreOutput>>>;
|
|
151
173
|
generateReason<TReasonOutput = string>(stepDef: GenerateReasonStepDef<TAccumulatedResults, TInput, TRunOutput>): MastraScorer<TID, TInput, TRunOutput, AccumulatedResults<TAccumulatedResults, 'generateReason', Awaited<TReasonOutput>>>;
|
|
152
174
|
private get hasGenerateScore();
|
|
175
|
+
private normalizeRunRequestContext;
|
|
153
176
|
run(input: ScorerRun<TInput, TRunOutput>): ScorerRunResult<TAccumulatedResults, TInput, TRunOutput>;
|
|
154
177
|
private isPromptObject;
|
|
155
178
|
getSteps(): Array<{
|
|
156
179
|
name: string;
|
|
157
|
-
type:
|
|
180
|
+
type: ScorerStepType;
|
|
158
181
|
description?: string;
|
|
159
182
|
}>;
|
|
160
183
|
private toMastraWorkflow;
|
package/dist/evals/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/evals/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAK3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/evals/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAK3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAEL,UAAU,EAKX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EAElB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,UAAU,EACV,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,GAAG,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;CACzB;AAGD,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE;QACL,KAAK,EAAE,sBAAsB,CAAC;QAC9B,MAAM,EAAE,uBAAuB,CAAC;KACjC,CAAC;IACF,UAAU,EAAE;QAC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AAE,aAAa,CAAA;KAAE,CAAC;CACtD,GACA,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;AAGxE,wBAAgB,YAAY,CAAC,MAAM,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EAAE,GAAG,SAAS,MAAM,GAAG,MAAM,EACtF,MAAM,EAAE,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,GAC5C,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;AAa7C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACzC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAG9D,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/evals/index.cjs
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkE4TMODUG_cjs = require('../chunk-E4TMODUG.cjs');
|
|
4
|
+
var chunkF6ZURDS4_cjs = require('../chunk-F6ZURDS4.cjs');
|
|
5
|
+
var chunk3OK3LWP4_cjs = require('../chunk-3OK3LWP4.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "runEvals", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkE4TMODUG_cjs.runEvals; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "MastraScorer", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkF6ZURDS4_cjs.MastraScorer; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "createScorer", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkF6ZURDS4_cjs.createScorer; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "extractTrajectory", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunk3OK3LWP4_cjs.extractTrajectory; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "extractTrajectoryFromTrace", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunk3OK3LWP4_cjs.extractTrajectoryFromTrace; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "extractWorkflowTrajectory", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunk3OK3LWP4_cjs.extractWorkflowTrajectory; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, "listScoresResponseSchema", {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunk3OK3LWP4_cjs.listScoresResponseSchema; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, "saveScorePayloadSchema", {
|
|
38
38
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunk3OK3LWP4_cjs.saveScorePayloadSchema; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, "scoreResultSchema", {
|
|
42
42
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
43
|
+
get: function () { return chunk3OK3LWP4_cjs.scoreResultSchema; }
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(exports, "scoreRowDataSchema", {
|
|
46
46
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunk3OK3LWP4_cjs.scoreRowDataSchema; }
|
|
48
48
|
});
|
|
49
49
|
Object.defineProperty(exports, "scoringEntityTypeSchema", {
|
|
50
50
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
51
|
+
get: function () { return chunk3OK3LWP4_cjs.scoringEntityTypeSchema; }
|
|
52
52
|
});
|
|
53
53
|
Object.defineProperty(exports, "scoringExtractStepResultSchema", {
|
|
54
54
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
55
|
+
get: function () { return chunk3OK3LWP4_cjs.scoringExtractStepResultSchema; }
|
|
56
56
|
});
|
|
57
57
|
Object.defineProperty(exports, "scoringHookInputSchema", {
|
|
58
58
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
59
|
+
get: function () { return chunk3OK3LWP4_cjs.scoringHookInputSchema; }
|
|
60
60
|
});
|
|
61
61
|
Object.defineProperty(exports, "scoringInputSchema", {
|
|
62
62
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
63
|
+
get: function () { return chunk3OK3LWP4_cjs.scoringInputSchema; }
|
|
64
64
|
});
|
|
65
65
|
Object.defineProperty(exports, "scoringInputWithExtractStepResultAndAnalyzeStepResultSchema", {
|
|
66
66
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
67
|
+
get: function () { return chunk3OK3LWP4_cjs.scoringInputWithExtractStepResultAndAnalyzeStepResultSchema; }
|
|
68
68
|
});
|
|
69
69
|
Object.defineProperty(exports, "scoringInputWithExtractStepResultAndScoreAndReasonSchema", {
|
|
70
70
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
71
|
+
get: function () { return chunk3OK3LWP4_cjs.scoringInputWithExtractStepResultAndScoreAndReasonSchema; }
|
|
72
72
|
});
|
|
73
73
|
Object.defineProperty(exports, "scoringInputWithExtractStepResultSchema", {
|
|
74
74
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
75
|
+
get: function () { return chunk3OK3LWP4_cjs.scoringInputWithExtractStepResultSchema; }
|
|
76
76
|
});
|
|
77
77
|
Object.defineProperty(exports, "scoringPromptsSchema", {
|
|
78
78
|
enumerable: true,
|
|
79
|
-
get: function () { return
|
|
79
|
+
get: function () { return chunk3OK3LWP4_cjs.scoringPromptsSchema; }
|
|
80
80
|
});
|
|
81
81
|
Object.defineProperty(exports, "scoringSourceSchema", {
|
|
82
82
|
enumerable: true,
|
|
83
|
-
get: function () { return
|
|
83
|
+
get: function () { return chunk3OK3LWP4_cjs.scoringSourceSchema; }
|
|
84
84
|
});
|
|
85
85
|
Object.defineProperty(exports, "scoringValueSchema", {
|
|
86
86
|
enumerable: true,
|
|
87
|
-
get: function () { return
|
|
87
|
+
get: function () { return chunk3OK3LWP4_cjs.scoringValueSchema; }
|
|
88
88
|
});
|
|
89
89
|
//# sourceMappingURL=index.cjs.map
|
|
90
90
|
//# sourceMappingURL=index.cjs.map
|
package/dist/evals/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { runEvals } from '../chunk-
|
|
2
|
-
export { MastraScorer, createScorer } from '../chunk-
|
|
3
|
-
export { extractTrajectory, extractTrajectoryFromTrace, extractWorkflowTrajectory, listScoresResponseSchema, saveScorePayloadSchema, scoreResultSchema, scoreRowDataSchema, scoringEntityTypeSchema, scoringExtractStepResultSchema, scoringHookInputSchema, scoringInputSchema, scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, scoringInputWithExtractStepResultAndScoreAndReasonSchema, scoringInputWithExtractStepResultSchema, scoringPromptsSchema, scoringSourceSchema, scoringValueSchema } from '../chunk-
|
|
1
|
+
export { runEvals } from '../chunk-B4KB75RH.js';
|
|
2
|
+
export { MastraScorer, createScorer } from '../chunk-JIA3SJK6.js';
|
|
3
|
+
export { extractTrajectory, extractTrajectoryFromTrace, extractWorkflowTrajectory, listScoresResponseSchema, saveScorePayloadSchema, scoreResultSchema, scoreRowDataSchema, scoringEntityTypeSchema, scoringExtractStepResultSchema, scoringHookInputSchema, scoringInputSchema, scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, scoringInputWithExtractStepResultAndScoreAndReasonSchema, scoringInputWithExtractStepResultSchema, scoringPromptsSchema, scoringSourceSchema, scoringValueSchema } from '../chunk-ESQI2JRD.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkI7AUCCNO_cjs = require('../../chunk-I7AUCCNO.cjs');
|
|
4
|
+
var chunk3OK3LWP4_cjs = require('../../chunk-3OK3LWP4.cjs');
|
|
5
|
+
var chunkEX2LVHTL_cjs = require('../../chunk-EX2LVHTL.cjs');
|
|
6
6
|
var chunk4U7ZLI36_cjs = require('../../chunk-4U7ZLI36.cjs');
|
|
7
7
|
var pMap = require('p-map');
|
|
8
8
|
var v4 = require('zod/v4');
|
|
@@ -234,7 +234,7 @@ function transformTraceToScorerInputAndOutput(trace) {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
// src/evals/scoreTraces/scoreTracesWorkflow.ts
|
|
237
|
-
var getTraceStep =
|
|
237
|
+
var getTraceStep = chunkI7AUCCNO_cjs.createStep({
|
|
238
238
|
id: "__process-trace-scoring",
|
|
239
239
|
inputSchema: v4.z.object({
|
|
240
240
|
targets: v4.z.array(
|
|
@@ -246,8 +246,7 @@ var getTraceStep = chunkJBOVTCTQ_cjs.createStep({
|
|
|
246
246
|
scorerId: v4.z.string()
|
|
247
247
|
}),
|
|
248
248
|
outputSchema: v4.z.any(),
|
|
249
|
-
execute: async ({ inputData, mastra
|
|
250
|
-
const observabilityContext = chunk57OYWNNV_cjs.resolveObservabilityContext(rest);
|
|
249
|
+
execute: async ({ inputData, mastra }) => {
|
|
251
250
|
const logger = mastra.getLogger();
|
|
252
251
|
if (!logger) {
|
|
253
252
|
console.warn(
|
|
@@ -291,7 +290,7 @@ var getTraceStep = chunkJBOVTCTQ_cjs.createStep({
|
|
|
291
290
|
inputData.targets,
|
|
292
291
|
async (target) => {
|
|
293
292
|
try {
|
|
294
|
-
await runScorerOnTarget({ storage, scorer, target
|
|
293
|
+
await runScorerOnTarget({ storage, scorer, target });
|
|
295
294
|
} catch (error) {
|
|
296
295
|
const mastraError = new chunk4U7ZLI36_cjs.MastraError(
|
|
297
296
|
{
|
|
@@ -316,8 +315,7 @@ var getTraceStep = chunkJBOVTCTQ_cjs.createStep({
|
|
|
316
315
|
async function runScorerOnTarget({
|
|
317
316
|
storage,
|
|
318
317
|
scorer,
|
|
319
|
-
target
|
|
320
|
-
...observabilityContext
|
|
318
|
+
target
|
|
321
319
|
}) {
|
|
322
320
|
const observabilityStore = await storage.getStore("observability");
|
|
323
321
|
if (!observabilityStore) {
|
|
@@ -345,11 +343,17 @@ async function runScorerOnTarget({
|
|
|
345
343
|
}
|
|
346
344
|
const scorerRun = buildScorerRun({
|
|
347
345
|
scorerType: scorer.type === "agent" ? "agent" : void 0,
|
|
348
|
-
...observabilityContext,
|
|
349
346
|
trace,
|
|
350
347
|
targetSpan: span
|
|
351
348
|
});
|
|
352
|
-
const result = await scorer.run(
|
|
349
|
+
const result = await scorer.run({
|
|
350
|
+
...scorerRun,
|
|
351
|
+
scoreSource: "trace",
|
|
352
|
+
targetScope: "span",
|
|
353
|
+
targetEntityType: chunkEX2LVHTL_cjs.getEntityTypeForSpan(span),
|
|
354
|
+
targetTraceId: target.traceId,
|
|
355
|
+
targetSpanId: span.spanId
|
|
356
|
+
});
|
|
353
357
|
const scorerResult = {
|
|
354
358
|
...result,
|
|
355
359
|
scorer: {
|
|
@@ -359,7 +363,7 @@ async function runScorerOnTarget({
|
|
|
359
363
|
hasJudge: !!scorer.judge
|
|
360
364
|
},
|
|
361
365
|
traceId: target.traceId,
|
|
362
|
-
spanId:
|
|
366
|
+
spanId: span.spanId,
|
|
363
367
|
entityId: span.entityId || span.entityName || "unknown",
|
|
364
368
|
entityType: span.spanType,
|
|
365
369
|
entity: { traceId: span.traceId, spanId: span.spanId },
|
|
@@ -379,21 +383,20 @@ async function validateAndSaveScore({ storage, scorerResult }) {
|
|
|
379
383
|
text: "Scores storage domain is not available"
|
|
380
384
|
});
|
|
381
385
|
}
|
|
382
|
-
const payloadToSave =
|
|
386
|
+
const payloadToSave = chunk3OK3LWP4_cjs.saveScorePayloadSchema.parse(scorerResult);
|
|
383
387
|
const result = await scoresStore.saveScore(payloadToSave);
|
|
384
388
|
return result.score;
|
|
385
389
|
}
|
|
386
390
|
function buildScorerRun({
|
|
387
391
|
scorerType,
|
|
388
392
|
trace,
|
|
389
|
-
targetSpan
|
|
390
|
-
...observabilityContext
|
|
393
|
+
targetSpan
|
|
391
394
|
}) {
|
|
392
395
|
if (scorerType === "agent") {
|
|
393
396
|
const { input, output } = transformTraceToScorerInputAndOutput(trace);
|
|
394
|
-
return { input, output
|
|
397
|
+
return { input, output };
|
|
395
398
|
}
|
|
396
|
-
return { input: targetSpan.input, output: targetSpan.output
|
|
399
|
+
return { input: targetSpan.input, output: targetSpan.output };
|
|
397
400
|
}
|
|
398
401
|
async function attachScoreToSpan({
|
|
399
402
|
storage,
|
|
@@ -425,24 +428,8 @@ async function attachScoreToSpan({
|
|
|
425
428
|
});
|
|
426
429
|
} catch {
|
|
427
430
|
}
|
|
428
|
-
try {
|
|
429
|
-
await observabilityStore.createScore({
|
|
430
|
-
score: {
|
|
431
|
-
timestamp: scoreRecord.createdAt ? new Date(scoreRecord.createdAt) : /* @__PURE__ */ new Date(),
|
|
432
|
-
traceId: span.traceId,
|
|
433
|
-
spanId: span.spanId,
|
|
434
|
-
scorerId: scoreRecord.scorerId ?? scoreRecord.scorer?.id,
|
|
435
|
-
score: scoreRecord.score,
|
|
436
|
-
reason: scoreRecord.reason ?? null,
|
|
437
|
-
experimentId: null,
|
|
438
|
-
scoreTraceId: null,
|
|
439
|
-
metadata: scoreRecord.metadata ?? null
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
} catch {
|
|
443
|
-
}
|
|
444
431
|
}
|
|
445
|
-
var scoreTracesWorkflow =
|
|
432
|
+
var scoreTracesWorkflow = chunkI7AUCCNO_cjs.createWorkflow({
|
|
446
433
|
id: "__batch-scoring-traces",
|
|
447
434
|
inputSchema: v4.z.object({
|
|
448
435
|
targets: v4.z.array(
|
|
@@ -456,9 +443,6 @@ var scoreTracesWorkflow = chunkJBOVTCTQ_cjs.createWorkflow({
|
|
|
456
443
|
outputSchema: v4.z.any(),
|
|
457
444
|
steps: [getTraceStep],
|
|
458
445
|
options: {
|
|
459
|
-
tracingPolicy: {
|
|
460
|
-
internal: 15 /* ALL */
|
|
461
|
-
},
|
|
462
446
|
validateInputs: false
|
|
463
447
|
}
|
|
464
448
|
});
|