@mastra/core 0.23.0 → 0.23.2-alpha.0

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.
Files changed (113) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/agent/agent.d.ts.map +1 -1
  3. package/dist/agent/index.cjs +13 -13
  4. package/dist/agent/index.js +2 -2
  5. package/dist/agent/input-processor/index.cjs +6 -6
  6. package/dist/agent/input-processor/index.js +1 -1
  7. package/dist/ai-tracing/index.cjs +36 -36
  8. package/dist/ai-tracing/index.d.ts +1 -1
  9. package/dist/ai-tracing/index.js +1 -1
  10. package/dist/ai-tracing/model-tracing.d.ts +63 -0
  11. package/dist/ai-tracing/model-tracing.d.ts.map +1 -0
  12. package/dist/{chunk-NVDVFJWA.js → chunk-32ZQNYMV.js} +3 -3
  13. package/dist/{chunk-NVDVFJWA.js.map → chunk-32ZQNYMV.js.map} +1 -1
  14. package/dist/{chunk-MRJUTTCU.js → chunk-455LR5KI.js} +3 -3
  15. package/dist/{chunk-MRJUTTCU.js.map → chunk-455LR5KI.js.map} +1 -1
  16. package/dist/{chunk-HANVMC6C.cjs → chunk-4PYSODHR.cjs} +12 -12
  17. package/dist/{chunk-HANVMC6C.cjs.map → chunk-4PYSODHR.cjs.map} +1 -1
  18. package/dist/{chunk-PS4ABZY7.js → chunk-6GDXSCHL.js} +5 -5
  19. package/dist/{chunk-PS4ABZY7.js.map → chunk-6GDXSCHL.js.map} +1 -1
  20. package/dist/{chunk-34WQUECJ.cjs → chunk-CE2Y5BC2.cjs} +52 -52
  21. package/dist/chunk-CE2Y5BC2.cjs.map +1 -0
  22. package/dist/{chunk-4YHU6R7W.cjs → chunk-CL6Z33KH.cjs} +18 -18
  23. package/dist/chunk-CL6Z33KH.cjs.map +1 -0
  24. package/dist/{chunk-ONKGWHY6.js → chunk-DTTOVV72.js} +194 -146
  25. package/dist/chunk-DTTOVV72.js.map +1 -0
  26. package/dist/{chunk-ZWF7AVLU.js → chunk-E3PG7G6E.js} +3 -3
  27. package/dist/{chunk-ZWF7AVLU.js.map → chunk-E3PG7G6E.js.map} +1 -1
  28. package/dist/{chunk-JZ7I64PK.js → chunk-ICGCDCJE.js} +17 -17
  29. package/dist/chunk-ICGCDCJE.js.map +1 -0
  30. package/dist/{chunk-ITCG6QJR.js → chunk-JZGCSEW5.js} +5 -5
  31. package/dist/{chunk-ITCG6QJR.js.map → chunk-JZGCSEW5.js.map} +1 -1
  32. package/dist/{chunk-HFXV34OE.js → chunk-KAEQISOW.js} +3 -3
  33. package/dist/{chunk-HFXV34OE.js.map → chunk-KAEQISOW.js.map} +1 -1
  34. package/dist/{chunk-4XE7GVZM.cjs → chunk-MCASUJWY.cjs} +35 -35
  35. package/dist/chunk-MCASUJWY.cjs.map +1 -0
  36. package/dist/{chunk-JTI6TVDV.cjs → chunk-MJMID7LX.cjs} +4 -4
  37. package/dist/{chunk-JTI6TVDV.cjs.map → chunk-MJMID7LX.cjs.map} +1 -1
  38. package/dist/{chunk-7KYNQSR4.js → chunk-N4DKYHQH.js} +15 -15
  39. package/dist/chunk-N4DKYHQH.js.map +1 -0
  40. package/dist/{chunk-QOTPNUIA.js → chunk-NNBF7NYQ.js} +4 -4
  41. package/dist/{chunk-QOTPNUIA.js.map → chunk-NNBF7NYQ.js.map} +1 -1
  42. package/dist/{chunk-A55YFHFT.js → chunk-NR77P3TK.js} +32 -32
  43. package/dist/chunk-NR77P3TK.js.map +1 -0
  44. package/dist/{chunk-DPE27ECD.cjs → chunk-NTKOVUTG.cjs} +11 -11
  45. package/dist/{chunk-DPE27ECD.cjs.map → chunk-NTKOVUTG.cjs.map} +1 -1
  46. package/dist/{chunk-5P4S4AVU.cjs → chunk-OOMWL2VB.cjs} +4 -4
  47. package/dist/{chunk-5P4S4AVU.cjs.map → chunk-OOMWL2VB.cjs.map} +1 -1
  48. package/dist/{chunk-PDST7KX7.cjs → chunk-P35FNLTQ.cjs} +194 -146
  49. package/dist/chunk-P35FNLTQ.cjs.map +1 -0
  50. package/dist/{chunk-7XAVBWZI.cjs → chunk-SKAKD7UJ.cjs} +12 -12
  51. package/dist/{chunk-7XAVBWZI.cjs.map → chunk-SKAKD7UJ.cjs.map} +1 -1
  52. package/dist/{chunk-VTNVK7HN.cjs → chunk-UZKIGB7M.cjs} +4 -4
  53. package/dist/{chunk-VTNVK7HN.cjs.map → chunk-UZKIGB7M.cjs.map} +1 -1
  54. package/dist/{chunk-TYWQLUF6.cjs → chunk-WCTRQHTG.cjs} +8 -8
  55. package/dist/{chunk-TYWQLUF6.cjs.map → chunk-WCTRQHTG.cjs.map} +1 -1
  56. package/dist/index.cjs +48 -48
  57. package/dist/index.js +8 -8
  58. package/dist/llm/index.cjs +7 -7
  59. package/dist/llm/index.js +1 -1
  60. package/dist/llm/model/model.d.ts.map +1 -1
  61. package/dist/llm/model/model.loop.d.ts.map +1 -1
  62. package/dist/llm/model/provider-registry.d.ts.map +1 -1
  63. package/dist/loop/index.cjs +2 -2
  64. package/dist/loop/index.js +1 -1
  65. package/dist/loop/loop.d.ts +1 -1
  66. package/dist/loop/loop.d.ts.map +1 -1
  67. package/dist/loop/test-utils/options.d.ts.map +1 -1
  68. package/dist/loop/types.d.ts +1 -2
  69. package/dist/loop/types.d.ts.map +1 -1
  70. package/dist/loop/workflows/stream.d.ts +1 -1
  71. package/dist/loop/workflows/stream.d.ts.map +1 -1
  72. package/dist/mastra/index.cjs +2 -2
  73. package/dist/mastra/index.js +1 -1
  74. package/dist/memory/index.cjs +4 -4
  75. package/dist/memory/index.js +1 -1
  76. package/dist/processors/index.cjs +11 -11
  77. package/dist/processors/index.js +1 -1
  78. package/dist/relevance/index.cjs +4 -4
  79. package/dist/relevance/index.js +1 -1
  80. package/dist/scores/index.cjs +9 -9
  81. package/dist/scores/index.js +2 -2
  82. package/dist/scores/scoreTraces/index.cjs +8 -8
  83. package/dist/scores/scoreTraces/index.js +3 -3
  84. package/dist/storage/index.cjs +3 -3
  85. package/dist/storage/index.js +1 -1
  86. package/dist/stream/index.cjs +11 -11
  87. package/dist/stream/index.js +2 -2
  88. package/dist/test-utils/llm-mock.cjs +2 -2
  89. package/dist/test-utils/llm-mock.js +1 -1
  90. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  91. package/dist/utils.cjs +17 -17
  92. package/dist/utils.js +1 -1
  93. package/dist/workflows/evented/index.cjs +10 -10
  94. package/dist/workflows/evented/index.js +1 -1
  95. package/dist/workflows/execution-engine.d.ts +1 -0
  96. package/dist/workflows/execution-engine.d.ts.map +1 -1
  97. package/dist/workflows/index.cjs +13 -13
  98. package/dist/workflows/index.js +1 -1
  99. package/dist/workflows/legacy/index.cjs +22 -22
  100. package/dist/workflows/legacy/index.js +1 -1
  101. package/dist/workflows/workflow.d.ts +3 -1
  102. package/dist/workflows/workflow.d.ts.map +1 -1
  103. package/package.json +5 -5
  104. package/dist/ai-tracing/chunk-tracing.d.ts +0 -76
  105. package/dist/ai-tracing/chunk-tracing.d.ts.map +0 -1
  106. package/dist/chunk-34WQUECJ.cjs.map +0 -1
  107. package/dist/chunk-4XE7GVZM.cjs.map +0 -1
  108. package/dist/chunk-4YHU6R7W.cjs.map +0 -1
  109. package/dist/chunk-7KYNQSR4.js.map +0 -1
  110. package/dist/chunk-A55YFHFT.js.map +0 -1
  111. package/dist/chunk-JZ7I64PK.js.map +0 -1
  112. package/dist/chunk-ONKGWHY6.js.map +0 -1
  113. package/dist/chunk-PDST7KX7.cjs.map +0 -1
@@ -501,7 +501,7 @@ var CoreToolBuilder = class extends MastraBase {
501
501
  error: `${prefix} - Failed ${toolType} execution`
502
502
  };
503
503
  }
504
- createExecute(tool, options, logType) {
504
+ createExecute(tool, options, logType, processedSchema) {
505
505
  const { logger, mastra: _mastra, memory: _memory, runtimeContext, model, ...rest } = options;
506
506
  const logModelObject = {
507
507
  modelId: model?.modelId,
@@ -566,7 +566,7 @@ var CoreToolBuilder = class extends MastraBase {
566
566
  let logger2 = options.logger || this.logger;
567
567
  try {
568
568
  logger2.debug(start, { ...rest, model: logModelObject, args });
569
- const parameters = this.getParameters();
569
+ const parameters = processedSchema || this.getParameters();
570
570
  const { data, error: error2 } = validateToolInput(parameters, args, options.name);
571
571
  if (error2) {
572
572
  logger2.warn(`Tool input validation failed for '${options.name}'`, {
@@ -637,18 +637,6 @@ var CoreToolBuilder = class extends MastraBase {
637
637
  if (providerTool) {
638
638
  return providerTool;
639
639
  }
640
- const definition = {
641
- type: "function",
642
- description: this.originalTool.description,
643
- parameters: this.getParameters(),
644
- outputSchema: this.getOutputSchema(),
645
- requireApproval: this.options.requireApproval,
646
- execute: this.originalTool.execute ? this.createExecute(
647
- this.originalTool,
648
- { ...this.options, description: this.originalTool.description },
649
- this.logType
650
- ) : void 0
651
- };
652
640
  const model = this.options.model;
653
641
  const schemaCompatLayers = [];
654
642
  if (model) {
@@ -667,11 +655,25 @@ var CoreToolBuilder = class extends MastraBase {
667
655
  new MetaSchemaCompatLayer(modelInfo)
668
656
  );
669
657
  }
670
- const processedSchema = applyCompatLayer({
671
- schema: this.getParameters(),
672
- compatLayers: schemaCompatLayers,
673
- mode: "aiSdkSchema"
674
- });
658
+ let processedZodSchema;
659
+ let processedSchema;
660
+ const originalSchema = this.getParameters();
661
+ const applicableLayer = schemaCompatLayers.find((layer) => layer.shouldApply());
662
+ if (applicableLayer && originalSchema) {
663
+ processedZodSchema = applicableLayer.processZodType(originalSchema);
664
+ processedSchema = applyCompatLayer({
665
+ schema: originalSchema,
666
+ compatLayers: schemaCompatLayers,
667
+ mode: "aiSdkSchema"
668
+ });
669
+ } else {
670
+ processedZodSchema = originalSchema;
671
+ processedSchema = applyCompatLayer({
672
+ schema: originalSchema,
673
+ compatLayers: schemaCompatLayers,
674
+ mode: "aiSdkSchema"
675
+ });
676
+ }
675
677
  let processedOutputSchema;
676
678
  if (this.getOutputSchema()) {
677
679
  processedOutputSchema = applyCompatLayer({
@@ -680,6 +682,20 @@ var CoreToolBuilder = class extends MastraBase {
680
682
  mode: "aiSdkSchema"
681
683
  });
682
684
  }
685
+ const definition = {
686
+ type: "function",
687
+ description: this.originalTool.description,
688
+ parameters: this.getParameters(),
689
+ outputSchema: this.getOutputSchema(),
690
+ requireApproval: this.options.requireApproval,
691
+ execute: this.originalTool.execute ? this.createExecute(
692
+ this.originalTool,
693
+ { ...this.options, description: this.originalTool.description },
694
+ this.logType,
695
+ processedZodSchema
696
+ // Pass the processed Zod schema for validation
697
+ ) : void 0
698
+ };
683
699
  return {
684
700
  ...definition,
685
701
  id: "id" in this.originalTool ? this.originalTool.id : void 0,
@@ -2562,36 +2578,63 @@ function wrapRun(run, tracingContext) {
2562
2578
  }
2563
2579
  }
2564
2580
  var ModelSpanTracker = class {
2565
- modelSpan;
2566
- currentStepSpan;
2567
- currentChunkSpan;
2568
- accumulator = {};
2569
- stepIndex = 0;
2570
- chunkSequence = 0;
2581
+ #modelSpan;
2582
+ #currentStepSpan;
2583
+ #currentChunkSpan;
2584
+ #accumulator = {};
2585
+ #stepIndex = 0;
2586
+ #chunkSequence = 0;
2571
2587
  constructor(modelSpan) {
2572
- this.modelSpan = modelSpan;
2588
+ this.#modelSpan = modelSpan;
2589
+ }
2590
+ /**
2591
+ * Get the tracing context for creating child spans.
2592
+ * Returns the current step span if active, otherwise the model span.
2593
+ */
2594
+ getTracingContext() {
2595
+ return {
2596
+ currentSpan: this.#currentStepSpan ?? this.#modelSpan
2597
+ };
2598
+ }
2599
+ /**
2600
+ * Report an error on the generation span
2601
+ */
2602
+ reportGenerationError(options) {
2603
+ this.#modelSpan?.error(options);
2604
+ }
2605
+ /**
2606
+ * End the generation span
2607
+ */
2608
+ endGeneration(options) {
2609
+ this.#modelSpan?.end(options);
2610
+ }
2611
+ /**
2612
+ * Update the generation span
2613
+ */
2614
+ updateGeneration(options) {
2615
+ this.#modelSpan?.update(options);
2573
2616
  }
2574
2617
  /**
2575
2618
  * Start a new Model execution step
2576
2619
  */
2577
- startStepSpan(payload) {
2578
- this.currentStepSpan = this.modelSpan?.createChildSpan({
2579
- name: `step: ${this.stepIndex}`,
2620
+ #startStepSpan(payload) {
2621
+ this.#currentStepSpan = this.#modelSpan?.createChildSpan({
2622
+ name: `step: ${this.#stepIndex}`,
2580
2623
  type: "model_step" /* MODEL_STEP */,
2581
2624
  attributes: {
2582
- stepIndex: this.stepIndex,
2625
+ stepIndex: this.#stepIndex,
2583
2626
  ...payload?.messageId ? { messageId: payload.messageId } : {},
2584
2627
  ...payload?.warnings?.length ? { warnings: payload.warnings } : {}
2585
2628
  },
2586
2629
  input: payload?.request
2587
2630
  });
2588
- this.chunkSequence = 0;
2631
+ this.#chunkSequence = 0;
2589
2632
  }
2590
2633
  /**
2591
2634
  * End the current Model execution step with token usage, finish reason, output, and metadata
2592
2635
  */
2593
- endStepSpan(payload) {
2594
- if (!this.currentStepSpan) return;
2636
+ #endStepSpan(payload) {
2637
+ if (!this.#currentStepSpan) return;
2595
2638
  const output = payload.output;
2596
2639
  const { usage, ...otherOutput } = output;
2597
2640
  const stepResult = payload.stepResult;
@@ -2600,7 +2643,7 @@ var ModelSpanTracker = class {
2600
2643
  if (cleanMetadata?.request) {
2601
2644
  delete cleanMetadata.request;
2602
2645
  }
2603
- this.currentStepSpan.end({
2646
+ this.#currentStepSpan.end({
2604
2647
  output: otherOutput,
2605
2648
  attributes: {
2606
2649
  usage,
@@ -2612,86 +2655,161 @@ var ModelSpanTracker = class {
2612
2655
  ...cleanMetadata
2613
2656
  }
2614
2657
  });
2615
- this.currentStepSpan = void 0;
2616
- this.stepIndex++;
2658
+ this.#currentStepSpan = void 0;
2659
+ this.#stepIndex++;
2617
2660
  }
2618
2661
  /**
2619
2662
  * Create a new chunk span (for multi-part chunks like text-start/delta/end)
2620
2663
  */
2621
- startChunkSpan(chunkType, initialData) {
2622
- if (!this.currentStepSpan) {
2623
- this.startStepSpan();
2664
+ #startChunkSpan(chunkType, initialData) {
2665
+ if (!this.#currentStepSpan) {
2666
+ this.#startStepSpan();
2624
2667
  }
2625
- this.currentChunkSpan = this.currentStepSpan?.createChildSpan({
2668
+ this.#currentChunkSpan = this.#currentStepSpan?.createChildSpan({
2626
2669
  name: `chunk: '${chunkType}'`,
2627
2670
  type: "model_chunk" /* MODEL_CHUNK */,
2628
2671
  attributes: {
2629
2672
  chunkType,
2630
- sequenceNumber: this.chunkSequence
2673
+ sequenceNumber: this.#chunkSequence
2631
2674
  }
2632
2675
  });
2633
- this.accumulator = initialData || {};
2676
+ this.#accumulator = initialData || {};
2634
2677
  }
2635
2678
  /**
2636
2679
  * Append string content to a specific field in the accumulator
2637
2680
  */
2638
- appendToAccumulator(field, text) {
2639
- if (this.accumulator[field] === void 0) {
2640
- this.accumulator[field] = text;
2681
+ #appendToAccumulator(field, text) {
2682
+ if (this.#accumulator[field] === void 0) {
2683
+ this.#accumulator[field] = text;
2641
2684
  } else {
2642
- this.accumulator[field] += text;
2685
+ this.#accumulator[field] += text;
2643
2686
  }
2644
2687
  }
2645
2688
  /**
2646
2689
  * End the current chunk span.
2647
2690
  * Safe to call multiple times - will no-op if span already ended.
2648
2691
  */
2649
- endChunkSpan(output) {
2650
- if (!this.currentChunkSpan) return;
2651
- this.currentChunkSpan.end({
2652
- output: output !== void 0 ? output : this.accumulator
2692
+ #endChunkSpan(output) {
2693
+ if (!this.#currentChunkSpan) return;
2694
+ this.#currentChunkSpan.end({
2695
+ output: output !== void 0 ? output : this.#accumulator
2653
2696
  });
2654
- this.currentChunkSpan = void 0;
2655
- this.accumulator = {};
2656
- this.chunkSequence++;
2697
+ this.#currentChunkSpan = void 0;
2698
+ this.#accumulator = {};
2699
+ this.#chunkSequence++;
2657
2700
  }
2658
2701
  /**
2659
2702
  * Create an event span (for single chunks like tool-call)
2660
2703
  */
2661
- createEventSpan(chunkType, output) {
2662
- if (!this.currentStepSpan) {
2663
- this.startStepSpan();
2704
+ #createEventSpan(chunkType, output) {
2705
+ if (!this.#currentStepSpan) {
2706
+ this.#startStepSpan();
2664
2707
  }
2665
- const span = this.currentStepSpan?.createEventSpan({
2708
+ const span = this.#currentStepSpan?.createEventSpan({
2666
2709
  name: `chunk: '${chunkType}'`,
2667
2710
  type: "model_chunk" /* MODEL_CHUNK */,
2668
2711
  attributes: {
2669
2712
  chunkType,
2670
- sequenceNumber: this.chunkSequence
2713
+ sequenceNumber: this.#chunkSequence
2671
2714
  },
2672
2715
  output
2673
2716
  });
2674
2717
  if (span) {
2675
- this.chunkSequence++;
2718
+ this.#chunkSequence++;
2676
2719
  }
2677
2720
  }
2678
2721
  /**
2679
2722
  * Check if there is currently an active chunk span
2680
2723
  */
2681
- hasActiveChunkSpan() {
2682
- return !!this.currentChunkSpan;
2724
+ #hasActiveChunkSpan() {
2725
+ return !!this.#currentChunkSpan;
2683
2726
  }
2684
2727
  /**
2685
2728
  * Get the current accumulator value
2686
2729
  */
2687
- getAccumulator() {
2688
- return this.accumulator;
2730
+ #getAccumulator() {
2731
+ return this.#accumulator;
2689
2732
  }
2690
2733
  /**
2691
- * Get the current step span (for making tool calls children of steps)
2734
+ * Handle text chunk spans (text-start/delta/end)
2692
2735
  */
2693
- getCurrentStepSpan() {
2694
- return this.currentStepSpan;
2736
+ #handleTextChunk(chunk) {
2737
+ switch (chunk.type) {
2738
+ case "text-start":
2739
+ this.#startChunkSpan("text");
2740
+ break;
2741
+ case "text-delta":
2742
+ this.#appendToAccumulator("text", chunk.payload.text);
2743
+ break;
2744
+ case "text-end": {
2745
+ this.#endChunkSpan();
2746
+ break;
2747
+ }
2748
+ }
2749
+ }
2750
+ /**
2751
+ * Handle reasoning chunk spans (reasoning-start/delta/end)
2752
+ */
2753
+ #handleReasoningChunk(chunk) {
2754
+ switch (chunk.type) {
2755
+ case "reasoning-start":
2756
+ this.#startChunkSpan("reasoning");
2757
+ break;
2758
+ case "reasoning-delta":
2759
+ this.#appendToAccumulator("text", chunk.payload.text);
2760
+ break;
2761
+ case "reasoning-end": {
2762
+ this.#endChunkSpan();
2763
+ break;
2764
+ }
2765
+ }
2766
+ }
2767
+ /**
2768
+ * Handle tool call chunk spans (tool-call-input-streaming-start/delta/end, tool-call)
2769
+ */
2770
+ #handleToolCallChunk(chunk) {
2771
+ switch (chunk.type) {
2772
+ case "tool-call-input-streaming-start":
2773
+ this.#startChunkSpan("tool-call", {
2774
+ toolName: chunk.payload.toolName,
2775
+ toolCallId: chunk.payload.toolCallId
2776
+ });
2777
+ break;
2778
+ case "tool-call-delta":
2779
+ this.#appendToAccumulator("toolInput", chunk.payload.argsTextDelta);
2780
+ break;
2781
+ case "tool-call-input-streaming-end":
2782
+ case "tool-call": {
2783
+ const acc = this.#getAccumulator();
2784
+ let toolInput;
2785
+ try {
2786
+ toolInput = acc.toolInput ? JSON.parse(acc.toolInput) : {};
2787
+ } catch {
2788
+ toolInput = acc.toolInput;
2789
+ }
2790
+ this.#endChunkSpan({
2791
+ toolName: acc.toolName,
2792
+ toolCallId: acc.toolCallId,
2793
+ toolInput
2794
+ });
2795
+ break;
2796
+ }
2797
+ }
2798
+ }
2799
+ /**
2800
+ * Handle object chunk spans (object, object-result)
2801
+ */
2802
+ #handleObjectChunk(chunk) {
2803
+ switch (chunk.type) {
2804
+ case "object":
2805
+ if (!this.#hasActiveChunkSpan()) {
2806
+ this.#startChunkSpan("object");
2807
+ }
2808
+ break;
2809
+ case "object-result":
2810
+ this.#endChunkSpan(chunk.object);
2811
+ break;
2812
+ }
2695
2813
  }
2696
2814
  /**
2697
2815
  * Wraps a stream with model tracing transform to track MODEL_STEP and MODEL_CHUNK spans.
@@ -2700,37 +2818,36 @@ var ModelSpanTracker = class {
2700
2818
  * create MODEL_STEP and MODEL_CHUNK spans for each semantic unit in the stream.
2701
2819
  */
2702
2820
  wrapStream(stream) {
2703
- const tracker = this;
2704
2821
  return stream.pipeThrough(
2705
2822
  new TransformStream({
2706
- transform(chunk, controller) {
2823
+ transform: (chunk, controller) => {
2707
2824
  controller.enqueue(chunk);
2708
2825
  switch (chunk.type) {
2709
2826
  case "text-start":
2710
2827
  case "text-delta":
2711
2828
  case "text-end":
2712
- handleTextChunk(chunk, tracker);
2829
+ this.#handleTextChunk(chunk);
2713
2830
  break;
2714
2831
  case "tool-call-input-streaming-start":
2715
2832
  case "tool-call-delta":
2716
2833
  case "tool-call-input-streaming-end":
2717
2834
  case "tool-call":
2718
- handleToolCallChunk(chunk, tracker);
2835
+ this.#handleToolCallChunk(chunk);
2719
2836
  break;
2720
2837
  case "reasoning-start":
2721
2838
  case "reasoning-delta":
2722
2839
  case "reasoning-end":
2723
- handleReasoningChunk(chunk, tracker);
2840
+ this.#handleReasoningChunk(chunk);
2724
2841
  break;
2725
2842
  case "object":
2726
2843
  case "object-result":
2727
- handleObjectChunk(chunk, tracker);
2844
+ this.#handleObjectChunk(chunk);
2728
2845
  break;
2729
2846
  case "step-start":
2730
- tracker.startStepSpan(chunk.payload);
2847
+ this.#startStepSpan(chunk.payload);
2731
2848
  break;
2732
2849
  case "step-finish":
2733
- tracker.endStepSpan(chunk.payload);
2850
+ this.#endStepSpan(chunk.payload);
2734
2851
  break;
2735
2852
  case "raw":
2736
2853
  // Skip raw chunks as they're redundant
@@ -2748,7 +2865,7 @@ var ModelSpanTracker = class {
2748
2865
  delete outputPayload.data;
2749
2866
  }
2750
2867
  }
2751
- tracker.createEventSpan(chunk.type, outputPayload);
2868
+ this.#createEventSpan(chunk.type, outputPayload);
2752
2869
  break;
2753
2870
  }
2754
2871
  }
@@ -2757,76 +2874,7 @@ var ModelSpanTracker = class {
2757
2874
  );
2758
2875
  }
2759
2876
  };
2760
- function handleTextChunk(chunk, tracker) {
2761
- switch (chunk.type) {
2762
- case "text-start":
2763
- tracker.startChunkSpan("text");
2764
- break;
2765
- case "text-delta":
2766
- tracker.appendToAccumulator("text", chunk.payload.text);
2767
- break;
2768
- case "text-end": {
2769
- tracker.endChunkSpan();
2770
- break;
2771
- }
2772
- }
2773
- }
2774
- function handleReasoningChunk(chunk, tracker) {
2775
- switch (chunk.type) {
2776
- case "reasoning-start":
2777
- tracker.startChunkSpan("reasoning");
2778
- break;
2779
- case "reasoning-delta":
2780
- tracker.appendToAccumulator("text", chunk.payload.text);
2781
- break;
2782
- case "reasoning-end": {
2783
- tracker.endChunkSpan();
2784
- break;
2785
- }
2786
- }
2787
- }
2788
- function handleToolCallChunk(chunk, tracker) {
2789
- switch (chunk.type) {
2790
- case "tool-call-input-streaming-start":
2791
- tracker.startChunkSpan("tool-call", {
2792
- toolName: chunk.payload.toolName,
2793
- toolCallId: chunk.payload.toolCallId
2794
- });
2795
- break;
2796
- case "tool-call-delta":
2797
- tracker.appendToAccumulator("toolInput", chunk.payload.argsTextDelta);
2798
- break;
2799
- case "tool-call-input-streaming-end":
2800
- case "tool-call": {
2801
- const acc = tracker.getAccumulator();
2802
- let toolInput;
2803
- try {
2804
- toolInput = acc.toolInput ? JSON.parse(acc.toolInput) : {};
2805
- } catch {
2806
- toolInput = acc.toolInput;
2807
- }
2808
- tracker.endChunkSpan({
2809
- toolName: acc.toolName,
2810
- toolCallId: acc.toolCallId,
2811
- toolInput
2812
- });
2813
- break;
2814
- }
2815
- }
2816
- }
2817
- function handleObjectChunk(chunk, tracker) {
2818
- switch (chunk.type) {
2819
- case "object":
2820
- if (!tracker.hasActiveChunkSpan()) {
2821
- tracker.startChunkSpan("object");
2822
- }
2823
- break;
2824
- case "object-result":
2825
- tracker.endChunkSpan(chunk.object);
2826
- break;
2827
- }
2828
- }
2829
2877
 
2830
2878
  export { AISpanType, AITracingEventType, BaseAISpan, BaseAITracing, BaseExporter, CloudExporter, ConsoleExporter, DefaultAISpan, DefaultAITracing, DefaultExporter, InternalSpans, ModelSpanTracker, NoOpAISpan, SamplingStrategyType, SensitiveDataFilter, checkEvalStorageFields, clearAITracingRegistry, createMastraProxy, deepClean, deepMerge, delay, ensureToolProperties, fetchWithRetry, generateEmptyFromSchema, getAITracing, getAllAITracing, getDefaultAITracing, getNestedValue, getOrCreateSpan, getSelectedAITracing, getValidTraceId, hasAITracing, isCoreMessage, isMastra, isUiMessage, isZodType, makeCoreTool, makeCoreToolV5, maskStreamTags, omitKeys, parseFieldKey, parseSqlIdentifier, registerAITracing, resolveSerializedZodOutput, selectFields, setNestedValue, setSelector, setupAITracing, shutdownAITracingRegistry, unregisterAITracing, wrapMastra };
2831
- //# sourceMappingURL=chunk-ONKGWHY6.js.map
2832
- //# sourceMappingURL=chunk-ONKGWHY6.js.map
2879
+ //# sourceMappingURL=chunk-DTTOVV72.js.map
2880
+ //# sourceMappingURL=chunk-DTTOVV72.js.map