@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
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var v4 = require('zod/v4');
|
|
4
|
+
var async_hooks = require('async_hooks');
|
|
4
5
|
|
|
5
|
-
//
|
|
6
|
-
var SamplingStrategyType = /* @__PURE__ */ ((SamplingStrategyType2) => {
|
|
7
|
-
SamplingStrategyType2["ALWAYS"] = "always";
|
|
8
|
-
SamplingStrategyType2["NEVER"] = "never";
|
|
9
|
-
SamplingStrategyType2["RATIO"] = "ratio";
|
|
10
|
-
SamplingStrategyType2["CUSTOM"] = "custom";
|
|
11
|
-
return SamplingStrategyType2;
|
|
12
|
-
})(SamplingStrategyType || {});
|
|
6
|
+
// ../_internal-core/dist/index.js
|
|
13
7
|
var EntityType = /* @__PURE__ */ ((EntityType2) => {
|
|
14
8
|
EntityType2["AGENT"] = "agent";
|
|
15
|
-
EntityType2["
|
|
9
|
+
EntityType2["SCORER"] = "scorer";
|
|
10
|
+
EntityType2["TRAJECTORY"] = "trajectory";
|
|
16
11
|
EntityType2["INPUT_PROCESSOR"] = "input_processor";
|
|
17
12
|
EntityType2["INPUT_STEP_PROCESSOR"] = "input_step_processor";
|
|
18
13
|
EntityType2["OUTPUT_PROCESSOR"] = "output_processor";
|
|
@@ -200,8 +195,9 @@ var listLogsResponseSchema = v4.z.object({
|
|
|
200
195
|
logs: v4.z.array(logRecordSchema)
|
|
201
196
|
});
|
|
202
197
|
var scorerIdField = v4.z.string().describe("Identifier of the scorer (e.g., relevance, accuracy)");
|
|
198
|
+
var scorerNameField = v4.z.string().describe("Display name of the scorer");
|
|
203
199
|
var scorerVersionField = v4.z.string().describe("Version of the scorer");
|
|
204
|
-
var scoreSourceField = v4.z.string().describe("
|
|
200
|
+
var scoreSourceField = v4.z.string().describe("How the score was produced (e.g., manual, automated, experiment)");
|
|
205
201
|
var scoreValueField = v4.z.number().describe("Score value (range defined by scorer)");
|
|
206
202
|
var scoreReasonField = v4.z.string().describe("Explanation for the score");
|
|
207
203
|
var scoreRecordSchema = v4.z.object({
|
|
@@ -211,6 +207,7 @@ var scoreRecordSchema = v4.z.object({
|
|
|
211
207
|
spanId: spanIdField.nullish().describe("Span ID this score applies to"),
|
|
212
208
|
// Score data
|
|
213
209
|
scorerId: scorerIdField,
|
|
210
|
+
scorerName: scorerNameField.nullish(),
|
|
214
211
|
scorerVersion: scorerVersionField.nullish(),
|
|
215
212
|
scoreSource: scoreSourceField.nullish(),
|
|
216
213
|
/**
|
|
@@ -228,6 +225,7 @@ var scoreRecordSchema = v4.z.object({
|
|
|
228
225
|
}).describe("Score record as stored in the database");
|
|
229
226
|
var scoreInputSchema = v4.z.object({
|
|
230
227
|
scorerId: scorerIdField,
|
|
228
|
+
scorerName: scorerNameField.optional(),
|
|
231
229
|
scorerVersion: scorerVersionField.optional(),
|
|
232
230
|
scoreSource: scoreSourceField.optional(),
|
|
233
231
|
/**
|
|
@@ -238,7 +236,8 @@ var scoreInputSchema = v4.z.object({
|
|
|
238
236
|
reason: scoreReasonField.optional(),
|
|
239
237
|
metadata: v4.z.record(v4.z.string(), v4.z.unknown()).optional().describe("Additional scorer-specific metadata"),
|
|
240
238
|
experimentId: experimentIdField.optional(),
|
|
241
|
-
scoreTraceId: v4.z.string().optional().describe("Trace ID of the scoring run for debugging score generation")
|
|
239
|
+
scoreTraceId: v4.z.string().optional().describe("Trace ID of the scoring run for debugging score generation"),
|
|
240
|
+
targetEntityType: entityTypeField.optional().describe("Entity type the scorer evaluated when known")
|
|
242
241
|
}).describe("User-provided score input");
|
|
243
242
|
var createScoreRecordSchema = scoreRecordSchema;
|
|
244
243
|
var createScoreArgsSchema = v4.z.object({
|
|
@@ -255,11 +254,11 @@ var scoresFilterSchema = v4.z.object({
|
|
|
255
254
|
...commonFilterFields,
|
|
256
255
|
// Score-specific filters
|
|
257
256
|
scorerId: v4.z.union([v4.z.string(), v4.z.array(v4.z.string())]).optional().describe("Filter by scorer ID(s)"),
|
|
258
|
-
scoreSource: scoreSourceField.optional().describe("Filter by score
|
|
257
|
+
scoreSource: scoreSourceField.optional().describe("Filter by how the score was produced"),
|
|
259
258
|
/**
|
|
260
259
|
* @deprecated Use `scoreSource` instead.
|
|
261
260
|
*/
|
|
262
|
-
source: scoreSourceField.optional().describe("Filter by score
|
|
261
|
+
source: scoreSourceField.optional().describe("Filter by how the score was produced")
|
|
263
262
|
}).describe("Filters for querying scores");
|
|
264
263
|
var scoresOrderByFieldSchema = v4.z.enum(["timestamp", "score"]).describe("Field to order by: 'timestamp' | 'score'");
|
|
265
264
|
var scoresOrderBySchema = v4.z.object({
|
|
@@ -696,6 +695,8 @@ var getTagsResponseSchema = v4.z.object({
|
|
|
696
695
|
// src/observability/types/tracing.ts
|
|
697
696
|
var SpanType = /* @__PURE__ */ ((SpanType2) => {
|
|
698
697
|
SpanType2["AGENT_RUN"] = "agent_run";
|
|
698
|
+
SpanType2["SCORER_RUN"] = "scorer_run";
|
|
699
|
+
SpanType2["SCORER_STEP"] = "scorer_step";
|
|
699
700
|
SpanType2["GENERIC"] = "generic";
|
|
700
701
|
SpanType2["MODEL_GENERATION"] = "model_generation";
|
|
701
702
|
SpanType2["MODEL_STEP"] = "model_step";
|
|
@@ -728,290 +729,98 @@ var TracingEventType = /* @__PURE__ */ ((TracingEventType2) => {
|
|
|
728
729
|
TracingEventType2["SPAN_ENDED"] = "span_ended";
|
|
729
730
|
return TracingEventType2;
|
|
730
731
|
})(TracingEventType || {});
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
"span_id",
|
|
736
|
-
"run_id",
|
|
737
|
-
"request_id",
|
|
738
|
-
"user_id",
|
|
739
|
-
"resource_id",
|
|
740
|
-
"session_id",
|
|
741
|
-
"thread_id"
|
|
742
|
-
];
|
|
743
|
-
|
|
744
|
-
// src/observability/no-op.ts
|
|
745
|
-
var noOpCounter = {
|
|
746
|
-
add() {
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
|
-
var noOpGauge = {
|
|
750
|
-
set() {
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
var noOpHistogram = {
|
|
754
|
-
record() {
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
var noOpTracingContext = {
|
|
758
|
-
currentSpan: void 0
|
|
759
|
-
};
|
|
760
|
-
var noOpLoggerContext = {
|
|
761
|
-
debug() {
|
|
762
|
-
},
|
|
763
|
-
info() {
|
|
764
|
-
},
|
|
765
|
-
warn() {
|
|
766
|
-
},
|
|
767
|
-
error() {
|
|
768
|
-
},
|
|
769
|
-
fatal() {
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
var noOpMetricsContext = {
|
|
773
|
-
emit() {
|
|
774
|
-
},
|
|
775
|
-
counter() {
|
|
776
|
-
return noOpCounter;
|
|
777
|
-
},
|
|
778
|
-
gauge() {
|
|
779
|
-
return noOpGauge;
|
|
780
|
-
},
|
|
781
|
-
histogram() {
|
|
782
|
-
return noOpHistogram;
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
var NoOpObservability = class {
|
|
786
|
-
setMastraContext(_options) {
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
setLogger(_options) {
|
|
790
|
-
return;
|
|
791
|
-
}
|
|
792
|
-
getSelectedInstance(_options) {
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
async getRecordedTrace(_args) {
|
|
796
|
-
return null;
|
|
797
|
-
}
|
|
798
|
-
async addScore(_args) {
|
|
799
|
-
return;
|
|
800
|
-
}
|
|
801
|
-
async addFeedback(_args) {
|
|
802
|
-
return;
|
|
803
|
-
}
|
|
804
|
-
registerInstance(_name, _instance, _isDefault = false) {
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
getInstance(_name) {
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
getDefaultInstance() {
|
|
811
|
-
return;
|
|
812
|
-
}
|
|
813
|
-
listInstances() {
|
|
814
|
-
return /* @__PURE__ */ new Map();
|
|
815
|
-
}
|
|
816
|
-
unregisterInstance(_name) {
|
|
817
|
-
return false;
|
|
818
|
-
}
|
|
819
|
-
hasInstance(_name) {
|
|
820
|
-
return false;
|
|
821
|
-
}
|
|
822
|
-
setConfigSelector(_selector) {
|
|
823
|
-
return;
|
|
824
|
-
}
|
|
825
|
-
clear() {
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
async shutdown() {
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
};
|
|
832
|
-
|
|
833
|
-
// src/observability/context-factory.ts
|
|
834
|
-
function deriveLoggerContext(tracing) {
|
|
835
|
-
const span = tracing.currentSpan;
|
|
836
|
-
return span?.observabilityInstance?.getLoggerContext?.(span) ?? noOpLoggerContext;
|
|
837
|
-
}
|
|
838
|
-
function deriveMetricsContext(tracing) {
|
|
839
|
-
const span = tracing.currentSpan;
|
|
840
|
-
return span?.observabilityInstance?.getMetricsContext?.(span) ?? noOpMetricsContext;
|
|
841
|
-
}
|
|
842
|
-
function createObservabilityContext(tracingContext) {
|
|
843
|
-
const tracing = tracingContext ?? noOpTracingContext;
|
|
844
|
-
return {
|
|
845
|
-
tracing,
|
|
846
|
-
loggerVNext: deriveLoggerContext(tracing),
|
|
847
|
-
metrics: deriveMetricsContext(tracing),
|
|
848
|
-
tracingContext: tracing
|
|
849
|
-
// alias — preferred at forwarding sites
|
|
850
|
-
};
|
|
732
|
+
var entityTypeValues = new Set(Object.values(EntityType));
|
|
733
|
+
var spanContextStorage = new async_hooks.AsyncLocalStorage();
|
|
734
|
+
function getCurrentSpan() {
|
|
735
|
+
return spanContextStorage.getStore();
|
|
851
736
|
}
|
|
852
|
-
function
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
metrics: partial.metrics ?? deriveMetricsContext(tracing),
|
|
858
|
-
tracingContext: tracing
|
|
859
|
-
// alias — preferred at forwarding sites
|
|
737
|
+
function getOrCreateSpan(options) {
|
|
738
|
+
const { type, attributes, tracingContext, requestContext, tracingOptions, ...rest } = options;
|
|
739
|
+
const metadata = {
|
|
740
|
+
...rest.metadata ?? {},
|
|
741
|
+
...tracingOptions?.metadata ?? {}
|
|
860
742
|
};
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
function isNoOpSpan(span) {
|
|
869
|
-
return span.constructor.name === "NoOpSpan" || span.__isNoOp === true;
|
|
870
|
-
}
|
|
871
|
-
function isMastra(mastra) {
|
|
872
|
-
const hasAgentGetters = AGENT_GETTERS.every((method) => typeof mastra?.[method] === "function");
|
|
873
|
-
const hasWorkflowGetters = WORKFLOW_GETTERS.every((method) => typeof mastra?.[method] === "function");
|
|
874
|
-
return hasAgentGetters && hasWorkflowGetters;
|
|
875
|
-
}
|
|
876
|
-
function wrapMastra(mastra, tracingContext) {
|
|
877
|
-
if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) {
|
|
878
|
-
return mastra;
|
|
879
|
-
}
|
|
880
|
-
if (!isMastra(mastra)) {
|
|
881
|
-
return mastra;
|
|
882
|
-
}
|
|
883
|
-
try {
|
|
884
|
-
return new Proxy(mastra, {
|
|
885
|
-
get(target, prop) {
|
|
886
|
-
try {
|
|
887
|
-
if (AGENT_GETTERS.includes(prop)) {
|
|
888
|
-
return (...args) => {
|
|
889
|
-
const agent = target[prop](...args);
|
|
890
|
-
return wrapAgent(agent, tracingContext);
|
|
891
|
-
};
|
|
892
|
-
}
|
|
893
|
-
if (WORKFLOW_GETTERS.includes(prop)) {
|
|
894
|
-
return (...args) => {
|
|
895
|
-
const workflow = target[prop](...args);
|
|
896
|
-
return wrapWorkflow(workflow, tracingContext);
|
|
897
|
-
};
|
|
898
|
-
}
|
|
899
|
-
const value = target[prop];
|
|
900
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
901
|
-
} catch (error) {
|
|
902
|
-
console.warn("Tracing: Failed to wrap method, falling back to original", error);
|
|
903
|
-
const value = target[prop];
|
|
904
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
905
|
-
}
|
|
906
|
-
}
|
|
743
|
+
if (tracingContext?.currentSpan) {
|
|
744
|
+
return tracingContext.currentSpan.createChildSpan({
|
|
745
|
+
type,
|
|
746
|
+
attributes,
|
|
747
|
+
...rest,
|
|
748
|
+
metadata,
|
|
749
|
+
requestContext
|
|
907
750
|
});
|
|
908
|
-
} catch (error) {
|
|
909
|
-
console.warn("Tracing: Failed to create proxy, using original Mastra instance", error);
|
|
910
|
-
return mastra;
|
|
911
751
|
}
|
|
752
|
+
const instance = options.mastra?.observability?.getSelectedInstance({ requestContext });
|
|
753
|
+
return instance?.startSpan({
|
|
754
|
+
type,
|
|
755
|
+
attributes,
|
|
756
|
+
...rest,
|
|
757
|
+
metadata,
|
|
758
|
+
requestContext,
|
|
759
|
+
tracingOptions,
|
|
760
|
+
traceId: tracingOptions?.traceId,
|
|
761
|
+
parentSpanId: tracingOptions?.parentSpanId,
|
|
762
|
+
customSamplerOptions: {
|
|
763
|
+
requestContext,
|
|
764
|
+
metadata
|
|
765
|
+
}
|
|
766
|
+
});
|
|
912
767
|
}
|
|
913
|
-
function
|
|
914
|
-
|
|
915
|
-
|
|
768
|
+
async function executeWithContext(params) {
|
|
769
|
+
const { span, fn } = params;
|
|
770
|
+
const wrappedFn = span ? () => spanContextStorage.run(span, fn) : fn;
|
|
771
|
+
if (span?.executeInContext) {
|
|
772
|
+
return span.executeInContext(wrappedFn);
|
|
916
773
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
...options,
|
|
925
|
-
...createObservabilityContext(tracingContext)
|
|
926
|
-
});
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
|
-
const value = target[prop];
|
|
930
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
931
|
-
} catch (error) {
|
|
932
|
-
console.warn("Tracing: Failed to wrap agent method, falling back to original", error);
|
|
933
|
-
const value = target[prop];
|
|
934
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
});
|
|
938
|
-
} catch (error) {
|
|
939
|
-
console.warn("Tracing: Failed to create agent proxy, using original instance", error);
|
|
940
|
-
return agent;
|
|
774
|
+
return wrappedFn();
|
|
775
|
+
}
|
|
776
|
+
function executeWithContextSync(params) {
|
|
777
|
+
const { span, fn } = params;
|
|
778
|
+
const wrappedFn = span ? () => spanContextStorage.run(span, fn) : fn;
|
|
779
|
+
if (span?.executeInContextSync) {
|
|
780
|
+
return span.executeInContextSync(wrappedFn);
|
|
941
781
|
}
|
|
782
|
+
return wrappedFn();
|
|
942
783
|
}
|
|
943
|
-
function
|
|
944
|
-
if (!
|
|
945
|
-
return
|
|
784
|
+
function getRootExportSpan(span) {
|
|
785
|
+
if (!span?.isValid) {
|
|
786
|
+
return void 0;
|
|
946
787
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
const run = await target[prop](options);
|
|
955
|
-
return run ? wrapRun(run, tracingContext) : run;
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
return (input, options = {}) => {
|
|
959
|
-
return target[prop](input, {
|
|
960
|
-
...options,
|
|
961
|
-
...createObservabilityContext(tracingContext)
|
|
962
|
-
});
|
|
963
|
-
};
|
|
964
|
-
}
|
|
965
|
-
const value = target[prop];
|
|
966
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
967
|
-
} catch (error) {
|
|
968
|
-
console.warn("Tracing: Failed to wrap workflow method, falling back to original", error);
|
|
969
|
-
const value = target[prop];
|
|
970
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
});
|
|
974
|
-
} catch (error) {
|
|
975
|
-
console.warn("Tracing: Failed to create workflow proxy, using original instance", error);
|
|
976
|
-
return workflow;
|
|
788
|
+
let current = span;
|
|
789
|
+
let rootExportSpan = span.isInternal ? void 0 : span;
|
|
790
|
+
while (current?.parent) {
|
|
791
|
+
current = current.parent;
|
|
792
|
+
if (!current.isInternal) {
|
|
793
|
+
rootExportSpan = current;
|
|
794
|
+
}
|
|
977
795
|
}
|
|
796
|
+
return rootExportSpan;
|
|
978
797
|
}
|
|
979
|
-
function
|
|
980
|
-
if (
|
|
981
|
-
return
|
|
798
|
+
function getEntityTypeForSpan(span) {
|
|
799
|
+
if (span.entityType && entityTypeValues.has(span.entityType)) {
|
|
800
|
+
return span.entityType;
|
|
982
801
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
});
|
|
1004
|
-
} catch (error) {
|
|
1005
|
-
console.warn("Tracing: Failed to create run proxy, using original instance", error);
|
|
1006
|
-
return run;
|
|
802
|
+
switch (span.spanType) {
|
|
803
|
+
case "agent_run" /* AGENT_RUN */:
|
|
804
|
+
return EntityType.AGENT;
|
|
805
|
+
case "scorer_run" /* SCORER_RUN */:
|
|
806
|
+
case "scorer_step" /* SCORER_STEP */:
|
|
807
|
+
return EntityType.SCORER;
|
|
808
|
+
case "workflow_run" /* WORKFLOW_RUN */:
|
|
809
|
+
return EntityType.WORKFLOW_RUN;
|
|
810
|
+
case "workflow_step" /* WORKFLOW_STEP */:
|
|
811
|
+
return EntityType.WORKFLOW_STEP;
|
|
812
|
+
case "tool_call" /* TOOL_CALL */:
|
|
813
|
+
case "mcp_tool_call" /* MCP_TOOL_CALL */:
|
|
814
|
+
return EntityType.TOOL;
|
|
815
|
+
case "processor_run" /* PROCESSOR_RUN */:
|
|
816
|
+
return EntityType.OUTPUT_PROCESSOR;
|
|
817
|
+
default:
|
|
818
|
+
return void 0;
|
|
1007
819
|
}
|
|
1008
820
|
}
|
|
1009
821
|
|
|
1010
|
-
exports.DEFAULT_BLOCKED_LABELS = DEFAULT_BLOCKED_LABELS;
|
|
1011
822
|
exports.EntityType = EntityType;
|
|
1012
823
|
exports.InternalSpans = InternalSpans;
|
|
1013
|
-
exports.NoOpObservability = NoOpObservability;
|
|
1014
|
-
exports.SamplingStrategyType = SamplingStrategyType;
|
|
1015
824
|
exports.SpanType = SpanType;
|
|
1016
825
|
exports.TracingEventType = TracingEventType;
|
|
1017
826
|
exports.aggregationIntervalSchema = aggregationIntervalSchema;
|
|
@@ -1029,7 +838,6 @@ exports.createFeedbackRecordSchema = createFeedbackRecordSchema;
|
|
|
1029
838
|
exports.createFeedbackResponseSchema = createFeedbackResponseSchema;
|
|
1030
839
|
exports.createLogRecordSchema = createLogRecordSchema;
|
|
1031
840
|
exports.createMetricRecordSchema = createMetricRecordSchema;
|
|
1032
|
-
exports.createObservabilityContext = createObservabilityContext;
|
|
1033
841
|
exports.createScoreArgsSchema = createScoreArgsSchema;
|
|
1034
842
|
exports.createScoreBodySchema = createScoreBodySchema;
|
|
1035
843
|
exports.createScoreRecordSchema = createScoreRecordSchema;
|
|
@@ -1041,6 +849,8 @@ exports.entityIdField = entityIdField;
|
|
|
1041
849
|
exports.entityNameField = entityNameField;
|
|
1042
850
|
exports.entityTypeField = entityTypeField;
|
|
1043
851
|
exports.environmentField = environmentField;
|
|
852
|
+
exports.executeWithContext = executeWithContext;
|
|
853
|
+
exports.executeWithContextSync = executeWithContextSync;
|
|
1044
854
|
exports.executionSourceField = executionSourceField;
|
|
1045
855
|
exports.experimentIdField = experimentIdField;
|
|
1046
856
|
exports.feedbackFilterSchema = feedbackFilterSchema;
|
|
@@ -1048,8 +858,10 @@ exports.feedbackInputSchema = feedbackInputSchema;
|
|
|
1048
858
|
exports.feedbackOrderByFieldSchema = feedbackOrderByFieldSchema;
|
|
1049
859
|
exports.feedbackOrderBySchema = feedbackOrderBySchema;
|
|
1050
860
|
exports.feedbackRecordSchema = feedbackRecordSchema;
|
|
861
|
+
exports.getCurrentSpan = getCurrentSpan;
|
|
1051
862
|
exports.getEntityNamesArgsSchema = getEntityNamesArgsSchema;
|
|
1052
863
|
exports.getEntityNamesResponseSchema = getEntityNamesResponseSchema;
|
|
864
|
+
exports.getEntityTypeForSpan = getEntityTypeForSpan;
|
|
1053
865
|
exports.getEntityTypesArgsSchema = getEntityTypesArgsSchema;
|
|
1054
866
|
exports.getEntityTypesResponseSchema = getEntityTypesResponseSchema;
|
|
1055
867
|
exports.getEnvironmentsArgsSchema = getEnvironmentsArgsSchema;
|
|
@@ -1076,6 +888,8 @@ exports.getMetricPercentilesArgsSchema = getMetricPercentilesArgsSchema;
|
|
|
1076
888
|
exports.getMetricPercentilesResponseSchema = getMetricPercentilesResponseSchema;
|
|
1077
889
|
exports.getMetricTimeSeriesArgsSchema = getMetricTimeSeriesArgsSchema;
|
|
1078
890
|
exports.getMetricTimeSeriesResponseSchema = getMetricTimeSeriesResponseSchema;
|
|
891
|
+
exports.getOrCreateSpan = getOrCreateSpan;
|
|
892
|
+
exports.getRootExportSpan = getRootExportSpan;
|
|
1079
893
|
exports.getScoreAggregateArgsSchema = getScoreAggregateArgsSchema;
|
|
1080
894
|
exports.getScoreAggregateResponseSchema = getScoreAggregateResponseSchema;
|
|
1081
895
|
exports.getScoreBreakdownArgsSchema = getScoreBreakdownArgsSchema;
|
|
@@ -1110,9 +924,6 @@ exports.metricsAggregationSchema = metricsAggregationSchema;
|
|
|
1110
924
|
exports.metricsFilterSchema = metricsFilterSchema;
|
|
1111
925
|
exports.metricsOrderByFieldSchema = metricsOrderByFieldSchema;
|
|
1112
926
|
exports.metricsOrderBySchema = metricsOrderBySchema;
|
|
1113
|
-
exports.noOpLoggerContext = noOpLoggerContext;
|
|
1114
|
-
exports.noOpMetricsContext = noOpMetricsContext;
|
|
1115
|
-
exports.noOpTracingContext = noOpTracingContext;
|
|
1116
927
|
exports.organizationIdField = organizationIdField;
|
|
1117
928
|
exports.paginationArgsSchema = paginationArgsSchema;
|
|
1118
929
|
exports.paginationInfoSchema = paginationInfoSchema;
|
|
@@ -1120,7 +931,6 @@ exports.parentEntityIdField = parentEntityIdField;
|
|
|
1120
931
|
exports.parentEntityNameField = parentEntityNameField;
|
|
1121
932
|
exports.parentEntityTypeField = parentEntityTypeField;
|
|
1122
933
|
exports.requestIdField = requestIdField;
|
|
1123
|
-
exports.resolveObservabilityContext = resolveObservabilityContext;
|
|
1124
934
|
exports.resourceIdField = resourceIdField;
|
|
1125
935
|
exports.rootEntityIdField = rootEntityIdField;
|
|
1126
936
|
exports.rootEntityNameField = rootEntityNameField;
|
|
@@ -1143,6 +953,5 @@ exports.threadIdField = threadIdField;
|
|
|
1143
953
|
exports.traceIdField = traceIdField;
|
|
1144
954
|
exports.updatedAtField = updatedAtField;
|
|
1145
955
|
exports.userIdField = userIdField;
|
|
1146
|
-
|
|
1147
|
-
//# sourceMappingURL=chunk-
|
|
1148
|
-
//# sourceMappingURL=chunk-57OYWNNV.cjs.map
|
|
956
|
+
//# sourceMappingURL=chunk-EX2LVHTL.cjs.map
|
|
957
|
+
//# sourceMappingURL=chunk-EX2LVHTL.cjs.map
|