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