@mastra/core 0.16.4-alpha.2 → 0.17.0-alpha.4
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 +55 -0
- package/dist/agent/agent.d.ts +17 -2
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +11 -11
- package/dist/agent/index.js +2 -2
- package/dist/agent/input-processor/index.cjs +6 -6
- package/dist/agent/input-processor/index.js +1 -1
- package/dist/agent/message-list/index.d.ts +1 -1
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/types.d.ts +15 -2
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/ai-tracing/exporters/default.d.ts +1 -0
- package/dist/ai-tracing/exporters/default.d.ts.map +1 -1
- package/dist/ai-tracing/index.cjs +35 -31
- package/dist/ai-tracing/index.js +1 -1
- package/dist/ai-tracing/span_processors/sensitive-data-filter.d.ts +7 -1
- package/dist/ai-tracing/span_processors/sensitive-data-filter.d.ts.map +1 -1
- package/dist/ai-tracing/spans/base.d.ts +2 -1
- package/dist/ai-tracing/spans/base.d.ts.map +1 -1
- package/dist/ai-tracing/types.d.ts +35 -4
- package/dist/ai-tracing/types.d.ts.map +1 -1
- package/dist/ai-tracing/utils.d.ts +3 -2
- package/dist/ai-tracing/utils.d.ts.map +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.ts +8 -2
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-AWILTHBM.js → chunk-2PQSZI63.js} +3 -3
- package/dist/{chunk-AWILTHBM.js.map → chunk-2PQSZI63.js.map} +1 -1
- package/dist/{chunk-4VP3M5T7.js → chunk-4OT7CXAS.js} +17 -4
- package/dist/chunk-4OT7CXAS.js.map +1 -0
- package/dist/{chunk-O5GOFG6A.js → chunk-4VHC2F5H.js} +10 -8
- package/dist/chunk-4VHC2F5H.js.map +1 -0
- package/dist/{chunk-VVH4BOE4.cjs → chunk-6MDSS7WL.cjs} +4 -4
- package/dist/{chunk-VVH4BOE4.cjs.map → chunk-6MDSS7WL.cjs.map} +1 -1
- package/dist/{chunk-YLR7PB3B.cjs → chunk-BGAJ72HJ.cjs} +104 -86
- package/dist/chunk-BGAJ72HJ.cjs.map +1 -0
- package/dist/{chunk-YYZT5JKX.js → chunk-BY37WSX5.js} +5 -5
- package/dist/{chunk-YYZT5JKX.js.map → chunk-BY37WSX5.js.map} +1 -1
- package/dist/{chunk-ERRIEUC2.cjs → chunk-CP4TZ4HO.cjs} +129 -48
- package/dist/chunk-CP4TZ4HO.cjs.map +1 -0
- package/dist/{chunk-W4GRW6AV.cjs → chunk-F3XF7MEZ.cjs} +12 -12
- package/dist/{chunk-W4GRW6AV.cjs.map → chunk-F3XF7MEZ.cjs.map} +1 -1
- package/dist/{chunk-PY4MHJTE.js → chunk-G366B5BY.js} +2 -2
- package/dist/chunk-G366B5BY.js.map +1 -0
- package/dist/{chunk-GJKL73EJ.cjs → chunk-HBQSSMAD.cjs} +13 -11
- package/dist/chunk-HBQSSMAD.cjs.map +1 -0
- package/dist/{chunk-UIFZI5XX.cjs → chunk-HZGYVRVN.cjs} +21 -8
- package/dist/chunk-HZGYVRVN.cjs.map +1 -0
- package/dist/{chunk-DUUXEPE5.cjs → chunk-MRZHPP3G.cjs} +103 -5
- package/dist/chunk-MRZHPP3G.cjs.map +1 -0
- package/dist/{chunk-ODLGLX2R.js → chunk-PL3B3FZM.js} +129 -49
- package/dist/chunk-PL3B3FZM.js.map +1 -0
- package/dist/{chunk-LVVAUDVQ.cjs → chunk-QHDT3QQC.cjs} +2 -2
- package/dist/chunk-QHDT3QQC.cjs.map +1 -0
- package/dist/chunk-QPOJZU26.cjs +14 -0
- package/dist/{chunk-ELKY3FEM.cjs.map → chunk-QPOJZU26.cjs.map} +1 -1
- package/dist/{chunk-VH3RNDZA.cjs → chunk-RNJ4GD7U.cjs} +6 -6
- package/dist/{chunk-VH3RNDZA.cjs.map → chunk-RNJ4GD7U.cjs.map} +1 -1
- package/dist/{chunk-ES5UWPHJ.js → chunk-TUXCO343.js} +17 -6
- package/dist/chunk-TUXCO343.js.map +1 -0
- package/dist/{chunk-CF3TI576.js → chunk-UWUM3F3X.js} +84 -66
- package/dist/chunk-UWUM3F3X.js.map +1 -0
- package/dist/{chunk-BVE3UPHV.js → chunk-VXJFKEON.js} +4 -4
- package/dist/{chunk-BVE3UPHV.js.map → chunk-VXJFKEON.js.map} +1 -1
- package/dist/{chunk-FTDM75SW.cjs → chunk-X3MOJJYH.cjs} +20 -9
- package/dist/chunk-X3MOJJYH.cjs.map +1 -0
- package/dist/{chunk-LVKX346H.js → chunk-XKVDOO2O.js} +3 -3
- package/dist/{chunk-LVKX346H.js.map → chunk-XKVDOO2O.js.map} +1 -1
- package/dist/{chunk-ZDMAOD35.js → chunk-XRJDA7BI.js} +102 -4
- package/dist/chunk-XRJDA7BI.js.map +1 -0
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.js +1 -1
- package/dist/index.cjs +40 -40
- package/dist/index.js +8 -8
- package/dist/llm/model/model.d.ts +3 -1
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +6 -4
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/model.loop.types.d.ts +1 -1
- package/dist/llm/model/model.loop.types.d.ts.map +1 -1
- package/dist/llm/model/shared.types.d.ts +5 -0
- package/dist/llm/model/shared.types.d.ts.map +1 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/loop.d.ts +1 -1
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/test-utils/fullStream.d.ts.map +1 -1
- package/dist/loop/test-utils/generateText.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -1
- package/dist/loop/test-utils/resultObject.d.ts.map +1 -1
- package/dist/loop/test-utils/streamObject.d.ts.map +1 -1
- package/dist/loop/test-utils/textStream.d.ts.map +1 -1
- package/dist/loop/test-utils/tools.d.ts.map +1 -1
- package/dist/loop/test-utils/utils.d.ts +4 -3
- package/dist/loop/test-utils/utils.d.ts.map +1 -1
- package/dist/loop/types.d.ts +2 -2
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +836 -0
- package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -0
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +559 -0
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -0
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +311 -0
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -0
- package/dist/loop/{workflow → workflows/agentic-execution}/tool-call-step.d.ts +16 -16
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -0
- package/dist/loop/workflows/agentic-loop/index.d.ts +842 -0
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -0
- package/dist/loop/workflows/run-state.d.ts.map +1 -0
- package/dist/loop/workflows/schema.d.ts +439 -0
- package/dist/loop/workflows/schema.d.ts.map +1 -0
- package/dist/loop/{workflow → workflows}/stream.d.ts +1 -1
- package/dist/loop/workflows/stream.d.ts.map +1 -0
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +2 -2
- package/dist/network/index.js +1 -1
- package/dist/network/vNext/index.cjs +34 -34
- package/dist/network/vNext/index.cjs.map +1 -1
- package/dist/network/vNext/index.js +7 -7
- package/dist/network/vNext/index.js.map +1 -1
- package/dist/processors/index.cjs +8 -8
- package/dist/processors/index.js +2 -2
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.js +1 -1
- package/dist/scores/base.d.ts.map +1 -1
- package/dist/scores/index.cjs +8 -8
- package/dist/scores/index.js +1 -1
- package/dist/server/types.d.ts +7 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/storage/index.cjs +3 -3
- package/dist/storage/index.js +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +2 -1
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output-helpers.d.ts +1 -5
- package/dist/stream/aisdk/v5/output-helpers.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts +2 -10
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +1 -5
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +3 -3
- package/dist/stream/index.js +1 -1
- package/dist/stream/types.d.ts +8 -2
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +2 -2
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/utils.cjs +17 -17
- package/dist/utils.d.ts +2 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +7 -2
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/index.cjs +10 -10
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +22 -22
- package/dist/workflows/legacy/index.js +1 -1
- package/dist/workflows/types.d.ts +6 -1
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +12 -10
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +7 -6
- package/dist/chunk-4VP3M5T7.js.map +0 -1
- package/dist/chunk-CF3TI576.js.map +0 -1
- package/dist/chunk-DUUXEPE5.cjs.map +0 -1
- package/dist/chunk-ELKY3FEM.cjs +0 -14
- package/dist/chunk-ERRIEUC2.cjs.map +0 -1
- package/dist/chunk-ES5UWPHJ.js.map +0 -1
- package/dist/chunk-FTDM75SW.cjs.map +0 -1
- package/dist/chunk-GJKL73EJ.cjs.map +0 -1
- package/dist/chunk-LVVAUDVQ.cjs.map +0 -1
- package/dist/chunk-O5GOFG6A.js.map +0 -1
- package/dist/chunk-ODLGLX2R.js.map +0 -1
- package/dist/chunk-PY4MHJTE.js.map +0 -1
- package/dist/chunk-UIFZI5XX.cjs.map +0 -1
- package/dist/chunk-YLR7PB3B.cjs.map +0 -1
- package/dist/chunk-ZDMAOD35.js.map +0 -1
- package/dist/loop/workflow/llm-execution.d.ts +0 -81
- package/dist/loop/workflow/llm-execution.d.ts.map +0 -1
- package/dist/loop/workflow/outer-llm-step.d.ts +0 -44
- package/dist/loop/workflow/outer-llm-step.d.ts.map +0 -1
- package/dist/loop/workflow/run-state.d.ts.map +0 -1
- package/dist/loop/workflow/schema.d.ts +0 -92
- package/dist/loop/workflow/schema.d.ts.map +0 -1
- package/dist/loop/workflow/stream.d.ts.map +0 -1
- package/dist/loop/workflow/tool-call-step.d.ts.map +0 -1
- /package/dist/loop/{workflow → workflows}/run-state.d.ts +0 -0
|
@@ -9,7 +9,79 @@ import jsonSchemaToZod from 'json-schema-to-zod';
|
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { convertZodSchemaToAISDKSchema, OpenAIReasoningSchemaCompatLayer, OpenAISchemaCompatLayer, GoogleSchemaCompatLayer, AnthropicSchemaCompatLayer, DeepSeekSchemaCompatLayer, MetaSchemaCompatLayer, applyCompatLayer } from '@mastra/schema-compat';
|
|
11
11
|
|
|
12
|
+
// src/ai-tracing/types.ts
|
|
13
|
+
var AISpanType = /* @__PURE__ */ ((AISpanType2) => {
|
|
14
|
+
AISpanType2["AGENT_RUN"] = "agent_run";
|
|
15
|
+
AISpanType2["GENERIC"] = "generic";
|
|
16
|
+
AISpanType2["LLM_GENERATION"] = "llm_generation";
|
|
17
|
+
AISpanType2["LLM_CHUNK"] = "llm_chunk";
|
|
18
|
+
AISpanType2["MCP_TOOL_CALL"] = "mcp_tool_call";
|
|
19
|
+
AISpanType2["TOOL_CALL"] = "tool_call";
|
|
20
|
+
AISpanType2["WORKFLOW_RUN"] = "workflow_run";
|
|
21
|
+
AISpanType2["WORKFLOW_STEP"] = "workflow_step";
|
|
22
|
+
AISpanType2["WORKFLOW_CONDITIONAL"] = "workflow_conditional";
|
|
23
|
+
AISpanType2["WORKFLOW_CONDITIONAL_EVAL"] = "workflow_conditional_eval";
|
|
24
|
+
AISpanType2["WORKFLOW_PARALLEL"] = "workflow_parallel";
|
|
25
|
+
AISpanType2["WORKFLOW_LOOP"] = "workflow_loop";
|
|
26
|
+
AISpanType2["WORKFLOW_SLEEP"] = "workflow_sleep";
|
|
27
|
+
AISpanType2["WORKFLOW_WAIT_EVENT"] = "workflow_wait_event";
|
|
28
|
+
return AISpanType2;
|
|
29
|
+
})(AISpanType || {});
|
|
30
|
+
var InternalSpans = /* @__PURE__ */ ((InternalSpans2) => {
|
|
31
|
+
InternalSpans2[InternalSpans2["NONE"] = 0] = "NONE";
|
|
32
|
+
InternalSpans2[InternalSpans2["WORKFLOW"] = 1] = "WORKFLOW";
|
|
33
|
+
InternalSpans2[InternalSpans2["AGENT"] = 2] = "AGENT";
|
|
34
|
+
InternalSpans2[InternalSpans2["TOOL"] = 4] = "TOOL";
|
|
35
|
+
InternalSpans2[InternalSpans2["LLM"] = 8] = "LLM";
|
|
36
|
+
InternalSpans2[InternalSpans2["ALL"] = 15] = "ALL";
|
|
37
|
+
return InternalSpans2;
|
|
38
|
+
})(InternalSpans || {});
|
|
39
|
+
var SamplingStrategyType = /* @__PURE__ */ ((SamplingStrategyType2) => {
|
|
40
|
+
SamplingStrategyType2["ALWAYS"] = "always";
|
|
41
|
+
SamplingStrategyType2["NEVER"] = "never";
|
|
42
|
+
SamplingStrategyType2["RATIO"] = "ratio";
|
|
43
|
+
SamplingStrategyType2["CUSTOM"] = "custom";
|
|
44
|
+
return SamplingStrategyType2;
|
|
45
|
+
})(SamplingStrategyType || {});
|
|
46
|
+
var AITracingEventType = /* @__PURE__ */ ((AITracingEventType2) => {
|
|
47
|
+
AITracingEventType2["SPAN_STARTED"] = "span_started";
|
|
48
|
+
AITracingEventType2["SPAN_UPDATED"] = "span_updated";
|
|
49
|
+
AITracingEventType2["SPAN_ENDED"] = "span_ended";
|
|
50
|
+
return AITracingEventType2;
|
|
51
|
+
})(AITracingEventType || {});
|
|
52
|
+
|
|
12
53
|
// src/ai-tracing/spans/base.ts
|
|
54
|
+
function isSpanInternal(spanType, flags) {
|
|
55
|
+
if (flags === void 0 || flags === 0 /* NONE */) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
switch (spanType) {
|
|
59
|
+
// Workflow-related spans
|
|
60
|
+
case "workflow_run" /* WORKFLOW_RUN */:
|
|
61
|
+
case "workflow_step" /* WORKFLOW_STEP */:
|
|
62
|
+
case "workflow_conditional" /* WORKFLOW_CONDITIONAL */:
|
|
63
|
+
case "workflow_conditional_eval" /* WORKFLOW_CONDITIONAL_EVAL */:
|
|
64
|
+
case "workflow_parallel" /* WORKFLOW_PARALLEL */:
|
|
65
|
+
case "workflow_loop" /* WORKFLOW_LOOP */:
|
|
66
|
+
case "workflow_sleep" /* WORKFLOW_SLEEP */:
|
|
67
|
+
case "workflow_wait_event" /* WORKFLOW_WAIT_EVENT */:
|
|
68
|
+
return (flags & 1 /* WORKFLOW */) !== 0;
|
|
69
|
+
// Agent-related spans
|
|
70
|
+
case "agent_run" /* AGENT_RUN */:
|
|
71
|
+
return (flags & 2 /* AGENT */) !== 0;
|
|
72
|
+
// Tool-related spans
|
|
73
|
+
case "tool_call" /* TOOL_CALL */:
|
|
74
|
+
case "mcp_tool_call" /* MCP_TOOL_CALL */:
|
|
75
|
+
return (flags & 4 /* TOOL */) !== 0;
|
|
76
|
+
// LLM-related spans
|
|
77
|
+
case "llm_generation" /* LLM_GENERATION */:
|
|
78
|
+
case "llm_chunk" /* LLM_CHUNK */:
|
|
79
|
+
return (flags & 8 /* LLM */) !== 0;
|
|
80
|
+
// Default: never internal
|
|
81
|
+
default:
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
13
85
|
var BaseAISpan = class {
|
|
14
86
|
name;
|
|
15
87
|
type;
|
|
@@ -33,7 +105,7 @@ var BaseAISpan = class {
|
|
|
33
105
|
this.startTime = /* @__PURE__ */ new Date();
|
|
34
106
|
this.aiTracing = aiTracing;
|
|
35
107
|
this.isEvent = options.isEvent ?? false;
|
|
36
|
-
this.isInternal = options.
|
|
108
|
+
this.isInternal = isSpanInternal(this.type, options.tracingPolicy?.internal);
|
|
37
109
|
if (this.isEvent) {
|
|
38
110
|
this.output = deepClean(options.output);
|
|
39
111
|
} else {
|
|
@@ -246,38 +318,6 @@ var NoOpAISpan = class extends BaseAISpan {
|
|
|
246
318
|
}
|
|
247
319
|
};
|
|
248
320
|
|
|
249
|
-
// src/ai-tracing/types.ts
|
|
250
|
-
var AISpanType = /* @__PURE__ */ ((AISpanType2) => {
|
|
251
|
-
AISpanType2["AGENT_RUN"] = "agent_run";
|
|
252
|
-
AISpanType2["GENERIC"] = "generic";
|
|
253
|
-
AISpanType2["LLM_GENERATION"] = "llm_generation";
|
|
254
|
-
AISpanType2["LLM_CHUNK"] = "llm_chunk";
|
|
255
|
-
AISpanType2["MCP_TOOL_CALL"] = "mcp_tool_call";
|
|
256
|
-
AISpanType2["TOOL_CALL"] = "tool_call";
|
|
257
|
-
AISpanType2["WORKFLOW_RUN"] = "workflow_run";
|
|
258
|
-
AISpanType2["WORKFLOW_STEP"] = "workflow_step";
|
|
259
|
-
AISpanType2["WORKFLOW_CONDITIONAL"] = "workflow_conditional";
|
|
260
|
-
AISpanType2["WORKFLOW_CONDITIONAL_EVAL"] = "workflow_conditional_eval";
|
|
261
|
-
AISpanType2["WORKFLOW_PARALLEL"] = "workflow_parallel";
|
|
262
|
-
AISpanType2["WORKFLOW_LOOP"] = "workflow_loop";
|
|
263
|
-
AISpanType2["WORKFLOW_SLEEP"] = "workflow_sleep";
|
|
264
|
-
AISpanType2["WORKFLOW_WAIT_EVENT"] = "workflow_wait_event";
|
|
265
|
-
return AISpanType2;
|
|
266
|
-
})(AISpanType || {});
|
|
267
|
-
var SamplingStrategyType = /* @__PURE__ */ ((SamplingStrategyType2) => {
|
|
268
|
-
SamplingStrategyType2["ALWAYS"] = "always";
|
|
269
|
-
SamplingStrategyType2["NEVER"] = "never";
|
|
270
|
-
SamplingStrategyType2["RATIO"] = "ratio";
|
|
271
|
-
SamplingStrategyType2["CUSTOM"] = "custom";
|
|
272
|
-
return SamplingStrategyType2;
|
|
273
|
-
})(SamplingStrategyType || {});
|
|
274
|
-
var AITracingEventType = /* @__PURE__ */ ((AITracingEventType2) => {
|
|
275
|
-
AITracingEventType2["SPAN_STARTED"] = "span_started";
|
|
276
|
-
AITracingEventType2["SPAN_UPDATED"] = "span_updated";
|
|
277
|
-
AITracingEventType2["SPAN_ENDED"] = "span_ended";
|
|
278
|
-
return AITracingEventType2;
|
|
279
|
-
})(AITracingEventType || {});
|
|
280
|
-
|
|
281
321
|
// src/ai-tracing/tracers/base.ts
|
|
282
322
|
var BaseAITracing = class extends MastraBase {
|
|
283
323
|
config;
|
|
@@ -594,7 +634,7 @@ var CoreToolBuilder = class extends MastraBase {
|
|
|
594
634
|
toolDescription: options.description,
|
|
595
635
|
toolType: logType || "tool"
|
|
596
636
|
},
|
|
597
|
-
|
|
637
|
+
tracingPolicy: options.tracingPolicy
|
|
598
638
|
});
|
|
599
639
|
try {
|
|
600
640
|
let result;
|
|
@@ -1345,6 +1385,8 @@ var DefaultExporter = class {
|
|
|
1345
1385
|
resolvedStrategy;
|
|
1346
1386
|
buffer;
|
|
1347
1387
|
flushTimer = null;
|
|
1388
|
+
// Track all spans that have been created, persists across flushes
|
|
1389
|
+
allCreatedSpans = /* @__PURE__ */ new Set();
|
|
1348
1390
|
constructor(config = {}, logger) {
|
|
1349
1391
|
if (logger) {
|
|
1350
1392
|
this.logger = logger;
|
|
@@ -1365,6 +1407,7 @@ var DefaultExporter = class {
|
|
|
1365
1407
|
insertOnly: [],
|
|
1366
1408
|
seenSpans: /* @__PURE__ */ new Set(),
|
|
1367
1409
|
spanSequences: /* @__PURE__ */ new Map(),
|
|
1410
|
+
completedSpans: /* @__PURE__ */ new Set(),
|
|
1368
1411
|
outOfOrderCount: 0,
|
|
1369
1412
|
totalSize: 0
|
|
1370
1413
|
};
|
|
@@ -1428,6 +1471,7 @@ var DefaultExporter = class {
|
|
|
1428
1471
|
this.logger.warn("Out-of-order span update detected - skipping event", {
|
|
1429
1472
|
spanId: event.exportedSpan.id,
|
|
1430
1473
|
traceId: event.exportedSpan.traceId,
|
|
1474
|
+
spanName: event.exportedSpan.name,
|
|
1431
1475
|
eventType: event.type
|
|
1432
1476
|
});
|
|
1433
1477
|
}
|
|
@@ -1451,11 +1495,12 @@ var DefaultExporter = class {
|
|
|
1451
1495
|
};
|
|
1452
1496
|
this.buffer.creates.push(createRecord);
|
|
1453
1497
|
this.buffer.seenSpans.add(spanKey);
|
|
1498
|
+
this.allCreatedSpans.add(spanKey);
|
|
1454
1499
|
}
|
|
1455
1500
|
break;
|
|
1456
1501
|
case "span_updated" /* SPAN_UPDATED */:
|
|
1457
1502
|
if (this.resolvedStrategy === "batch-with-updates") {
|
|
1458
|
-
if (this.
|
|
1503
|
+
if (this.allCreatedSpans.has(spanKey)) {
|
|
1459
1504
|
this.buffer.updates.push({
|
|
1460
1505
|
traceId: event.exportedSpan.traceId,
|
|
1461
1506
|
spanId: event.exportedSpan.id,
|
|
@@ -1473,7 +1518,7 @@ var DefaultExporter = class {
|
|
|
1473
1518
|
break;
|
|
1474
1519
|
case "span_ended" /* SPAN_ENDED */:
|
|
1475
1520
|
if (this.resolvedStrategy === "batch-with-updates") {
|
|
1476
|
-
if (this.
|
|
1521
|
+
if (this.allCreatedSpans.has(spanKey)) {
|
|
1477
1522
|
this.buffer.updates.push({
|
|
1478
1523
|
traceId: event.exportedSpan.traceId,
|
|
1479
1524
|
spanId: event.exportedSpan.id,
|
|
@@ -1483,6 +1528,7 @@ var DefaultExporter = class {
|
|
|
1483
1528
|
},
|
|
1484
1529
|
sequenceNumber: this.getNextSequence(spanKey)
|
|
1485
1530
|
});
|
|
1531
|
+
this.buffer.completedSpans.add(spanKey);
|
|
1486
1532
|
} else if (event.exportedSpan.isEvent) {
|
|
1487
1533
|
const createRecord = {
|
|
1488
1534
|
traceId: event.exportedSpan.traceId,
|
|
@@ -1493,6 +1539,8 @@ var DefaultExporter = class {
|
|
|
1493
1539
|
};
|
|
1494
1540
|
this.buffer.creates.push(createRecord);
|
|
1495
1541
|
this.buffer.seenSpans.add(spanKey);
|
|
1542
|
+
this.allCreatedSpans.add(spanKey);
|
|
1543
|
+
this.buffer.completedSpans.add(spanKey);
|
|
1496
1544
|
} else {
|
|
1497
1545
|
this.handleOutOfOrderUpdate(event);
|
|
1498
1546
|
this.buffer.outOfOrderCount++;
|
|
@@ -1506,6 +1554,8 @@ var DefaultExporter = class {
|
|
|
1506
1554
|
updatedAt: null
|
|
1507
1555
|
};
|
|
1508
1556
|
this.buffer.insertOnly.push(createRecord);
|
|
1557
|
+
this.buffer.completedSpans.add(spanKey);
|
|
1558
|
+
this.allCreatedSpans.add(spanKey);
|
|
1509
1559
|
}
|
|
1510
1560
|
break;
|
|
1511
1561
|
}
|
|
@@ -1532,15 +1582,19 @@ var DefaultExporter = class {
|
|
|
1532
1582
|
/**
|
|
1533
1583
|
* Resets the buffer after successful flush
|
|
1534
1584
|
*/
|
|
1535
|
-
resetBuffer() {
|
|
1585
|
+
resetBuffer(completedSpansToCleanup = /* @__PURE__ */ new Set()) {
|
|
1536
1586
|
this.buffer.creates = [];
|
|
1537
1587
|
this.buffer.updates = [];
|
|
1538
1588
|
this.buffer.insertOnly = [];
|
|
1539
1589
|
this.buffer.seenSpans.clear();
|
|
1540
1590
|
this.buffer.spanSequences.clear();
|
|
1591
|
+
this.buffer.completedSpans.clear();
|
|
1541
1592
|
this.buffer.outOfOrderCount = 0;
|
|
1542
1593
|
this.buffer.firstEventTime = void 0;
|
|
1543
1594
|
this.buffer.totalSize = 0;
|
|
1595
|
+
for (const spanKey of completedSpansToCleanup) {
|
|
1596
|
+
this.allCreatedSpans.delete(spanKey);
|
|
1597
|
+
}
|
|
1544
1598
|
}
|
|
1545
1599
|
/**
|
|
1546
1600
|
* Schedules a flush using setTimeout
|
|
@@ -1621,6 +1675,7 @@ var DefaultExporter = class {
|
|
|
1621
1675
|
*/
|
|
1622
1676
|
async handleRealtimeEvent(event, storage) {
|
|
1623
1677
|
const span = event.exportedSpan;
|
|
1678
|
+
const spanKey = this.buildSpanKey(span.traceId, span.id);
|
|
1624
1679
|
if (span.isEvent) {
|
|
1625
1680
|
if (event.type === "span_ended" /* SPAN_ENDED */) {
|
|
1626
1681
|
await storage.createAISpan({
|
|
@@ -1643,8 +1698,18 @@ var DefaultExporter = class {
|
|
|
1643
1698
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1644
1699
|
updatedAt: null
|
|
1645
1700
|
});
|
|
1701
|
+
this.allCreatedSpans.add(spanKey);
|
|
1646
1702
|
break;
|
|
1647
1703
|
case "span_updated" /* SPAN_UPDATED */:
|
|
1704
|
+
await storage.updateAISpan({
|
|
1705
|
+
traceId: span.traceId,
|
|
1706
|
+
spanId: span.id,
|
|
1707
|
+
updates: {
|
|
1708
|
+
...this.buildUpdateRecord(span),
|
|
1709
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
1710
|
+
}
|
|
1711
|
+
});
|
|
1712
|
+
break;
|
|
1648
1713
|
case "span_ended" /* SPAN_ENDED */:
|
|
1649
1714
|
await storage.updateAISpan({
|
|
1650
1715
|
traceId: span.traceId,
|
|
@@ -1654,6 +1719,7 @@ var DefaultExporter = class {
|
|
|
1654
1719
|
updatedAt: /* @__PURE__ */ new Date()
|
|
1655
1720
|
}
|
|
1656
1721
|
});
|
|
1722
|
+
this.allCreatedSpans.delete(spanKey);
|
|
1657
1723
|
break;
|
|
1658
1724
|
default:
|
|
1659
1725
|
this.logger.warn(`Tracing event type not implemented for span spans: ${event.type}`);
|
|
@@ -1726,6 +1792,7 @@ var DefaultExporter = class {
|
|
|
1726
1792
|
insertOnly: [...this.buffer.insertOnly],
|
|
1727
1793
|
seenSpans: new Set(this.buffer.seenSpans),
|
|
1728
1794
|
spanSequences: new Map(this.buffer.spanSequences),
|
|
1795
|
+
completedSpans: new Set(this.buffer.completedSpans),
|
|
1729
1796
|
outOfOrderCount: this.buffer.outOfOrderCount,
|
|
1730
1797
|
firstEventTime: this.buffer.firstEventTime,
|
|
1731
1798
|
totalSize: this.buffer.totalSize
|
|
@@ -1765,6 +1832,9 @@ var DefaultExporter = class {
|
|
|
1765
1832
|
await storage.batchCreateAISpans({ records: buffer.insertOnly });
|
|
1766
1833
|
}
|
|
1767
1834
|
}
|
|
1835
|
+
for (const spanKey of buffer.completedSpans) {
|
|
1836
|
+
this.allCreatedSpans.delete(spanKey);
|
|
1837
|
+
}
|
|
1768
1838
|
} catch (error) {
|
|
1769
1839
|
if (attempt < this.config.maxRetries) {
|
|
1770
1840
|
const retryDelay = this.calculateRetryDelay(attempt);
|
|
@@ -1783,6 +1853,9 @@ var DefaultExporter = class {
|
|
|
1783
1853
|
droppedBatchSize: buffer.totalSize,
|
|
1784
1854
|
error: error instanceof Error ? error.message : String(error)
|
|
1785
1855
|
});
|
|
1856
|
+
for (const spanKey of buffer.completedSpans) {
|
|
1857
|
+
this.allCreatedSpans.delete(spanKey);
|
|
1858
|
+
}
|
|
1786
1859
|
}
|
|
1787
1860
|
}
|
|
1788
1861
|
}
|
|
@@ -1919,10 +1992,18 @@ var SensitiveDataFilter = class {
|
|
|
1919
1992
|
return key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
1920
1993
|
}
|
|
1921
1994
|
/**
|
|
1922
|
-
* Check whether a normalized key matches any sensitive field
|
|
1995
|
+
* Check whether a normalized key exactly matches any sensitive field.
|
|
1996
|
+
* Both key and sensitive fields are normalized by removing all non-alphanumeric
|
|
1997
|
+
* characters and converting to lowercase before comparison.
|
|
1998
|
+
*
|
|
1999
|
+
* Examples:
|
|
2000
|
+
* - "api_key", "api-key", "ApiKey" all normalize to "apikey" → MATCHES "apikey"
|
|
2001
|
+
* - "promptTokens", "prompt_tokens" normalize to "prompttokens" → DOES NOT MATCH "token"
|
|
1923
2002
|
*/
|
|
1924
2003
|
isSensitive(normalizedKey) {
|
|
1925
|
-
return this.sensitiveFields.some((
|
|
2004
|
+
return this.sensitiveFields.some((sensitiveField) => {
|
|
2005
|
+
return normalizedKey === sensitiveField;
|
|
2006
|
+
});
|
|
1926
2007
|
}
|
|
1927
2008
|
/**
|
|
1928
2009
|
* Redact a sensitive value.
|
|
@@ -2132,18 +2213,17 @@ function getValidTraceId(span) {
|
|
|
2132
2213
|
return span?.isValid ? span.traceId : void 0;
|
|
2133
2214
|
}
|
|
2134
2215
|
function getOrCreateSpan(options) {
|
|
2135
|
-
const { type, attributes, tracingContext,
|
|
2216
|
+
const { type, attributes, tracingContext, runtimeContext, ...rest } = options;
|
|
2136
2217
|
const metadata = {
|
|
2137
2218
|
...rest.metadata ?? {},
|
|
2138
|
-
...tracingOptions?.metadata ?? {}
|
|
2219
|
+
...rest.tracingOptions?.metadata ?? {}
|
|
2139
2220
|
};
|
|
2140
2221
|
if (tracingContext?.currentSpan) {
|
|
2141
2222
|
return tracingContext.currentSpan.createChildSpan({
|
|
2142
2223
|
type,
|
|
2143
2224
|
attributes,
|
|
2144
2225
|
...rest,
|
|
2145
|
-
metadata
|
|
2146
|
-
isInternal: tracingContext?.isInternal
|
|
2226
|
+
metadata
|
|
2147
2227
|
});
|
|
2148
2228
|
}
|
|
2149
2229
|
const aiTracing = getSelectedAITracing({
|
|
@@ -2152,12 +2232,12 @@ function getOrCreateSpan(options) {
|
|
|
2152
2232
|
return aiTracing?.startSpan({
|
|
2153
2233
|
type,
|
|
2154
2234
|
attributes,
|
|
2235
|
+
...rest,
|
|
2236
|
+
metadata,
|
|
2155
2237
|
customSamplerOptions: {
|
|
2156
2238
|
runtimeContext,
|
|
2157
2239
|
metadata
|
|
2158
|
-
}
|
|
2159
|
-
...rest,
|
|
2160
|
-
metadata
|
|
2240
|
+
}
|
|
2161
2241
|
});
|
|
2162
2242
|
}
|
|
2163
2243
|
|
|
@@ -2308,6 +2388,6 @@ function wrapRun(run, tracingContext) {
|
|
|
2308
2388
|
}
|
|
2309
2389
|
}
|
|
2310
2390
|
|
|
2311
|
-
export { AISpanType, AITracingEventType, BaseAISpan, BaseAITracing, CloudExporter, ConsoleExporter, DefaultAISpan, DefaultAITracing, DefaultExporter, NoOpAISpan, SamplingStrategyType, SensitiveDataFilter, checkEvalStorageFields, clearAITracingRegistry, createMastraProxy, deepClean, deepMerge, delay, ensureToolProperties, fetchWithRetry, generateEmptyFromSchema, getAITracing, getAllAITracing, getDefaultAITracing, getOrCreateSpan, getSelectedAITracing, getValidTraceId, hasAITracing, isCoreMessage, isMastra, isUiMessage, isZodType, makeCoreTool, makeCoreToolV5, maskStreamTags, omitKeys, parseFieldKey, parseSqlIdentifier, registerAITracing, resolveSerializedZodOutput, selectFields, setSelector, setupAITracing, shutdownAITracingRegistry, unregisterAITracing, wrapMastra };
|
|
2312
|
-
//# sourceMappingURL=chunk-
|
|
2313
|
-
//# sourceMappingURL=chunk-
|
|
2391
|
+
export { AISpanType, AITracingEventType, BaseAISpan, BaseAITracing, CloudExporter, ConsoleExporter, DefaultAISpan, DefaultAITracing, DefaultExporter, InternalSpans, NoOpAISpan, SamplingStrategyType, SensitiveDataFilter, checkEvalStorageFields, clearAITracingRegistry, createMastraProxy, deepClean, deepMerge, delay, ensureToolProperties, fetchWithRetry, generateEmptyFromSchema, getAITracing, getAllAITracing, getDefaultAITracing, getOrCreateSpan, getSelectedAITracing, getValidTraceId, hasAITracing, isCoreMessage, isMastra, isUiMessage, isZodType, makeCoreTool, makeCoreToolV5, maskStreamTags, omitKeys, parseFieldKey, parseSqlIdentifier, registerAITracing, resolveSerializedZodOutput, selectFields, setSelector, setupAITracing, shutdownAITracingRegistry, unregisterAITracing, wrapMastra };
|
|
2392
|
+
//# sourceMappingURL=chunk-PL3B3FZM.js.map
|
|
2393
|
+
//# sourceMappingURL=chunk-PL3B3FZM.js.map
|