@mastra/core 1.18.0-alpha.2 → 1.18.0-alpha.3

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 (173) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/dist/agent/agent-legacy.d.ts +3 -3
  3. package/dist/agent/agent-legacy.d.ts.map +1 -1
  4. package/dist/agent/agent.d.ts +12 -12
  5. package/dist/agent/agent.d.ts.map +1 -1
  6. package/dist/agent/index.cjs +8 -8
  7. package/dist/agent/index.js +1 -1
  8. package/dist/agent/types.d.ts +12 -12
  9. package/dist/agent/types.d.ts.map +1 -1
  10. package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
  11. package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +2 -1
  12. package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
  13. package/dist/{chunk-VF3CL3JV.js → chunk-32NEFSTI.js} +153 -44
  14. package/dist/chunk-32NEFSTI.js.map +1 -0
  15. package/dist/{chunk-XRZNAZRP.cjs → chunk-3UM5VCQ5.cjs} +3 -3
  16. package/dist/{chunk-XRZNAZRP.cjs.map → chunk-3UM5VCQ5.cjs.map} +1 -1
  17. package/dist/{chunk-VAVK4KJI.cjs → chunk-4K2NKQGN.cjs} +316 -207
  18. package/dist/chunk-4K2NKQGN.cjs.map +1 -0
  19. package/dist/{chunk-WPDB2VAM.cjs → chunk-5IZ346TV.cjs} +7 -7
  20. package/dist/{chunk-WPDB2VAM.cjs.map → chunk-5IZ346TV.cjs.map} +1 -1
  21. package/dist/{chunk-R2V6BCYX.cjs → chunk-64565EZF.cjs} +9 -9
  22. package/dist/{chunk-R2V6BCYX.cjs.map → chunk-64565EZF.cjs.map} +1 -1
  23. package/dist/{chunk-6WVZQBYQ.cjs → chunk-6LHF5UDX.cjs} +9 -9
  24. package/dist/{chunk-6WVZQBYQ.cjs.map → chunk-6LHF5UDX.cjs.map} +1 -1
  25. package/dist/{chunk-L53NRDFU.js → chunk-7USX5P3I.js} +3 -3
  26. package/dist/{chunk-L53NRDFU.js.map → chunk-7USX5P3I.js.map} +1 -1
  27. package/dist/{chunk-FWDG2WUV.js → chunk-AHFHYQS6.js} +3 -3
  28. package/dist/{chunk-FWDG2WUV.js.map → chunk-AHFHYQS6.js.map} +1 -1
  29. package/dist/{chunk-G5HKDGNT.cjs → chunk-B6D4D2CY.cjs} +2 -2
  30. package/dist/{chunk-G5HKDGNT.cjs.map → chunk-B6D4D2CY.cjs.map} +1 -1
  31. package/dist/{chunk-URN2SKVG.js → chunk-BFRUEBG3.js} +4 -4
  32. package/dist/{chunk-URN2SKVG.js.map → chunk-BFRUEBG3.js.map} +1 -1
  33. package/dist/{chunk-CT4YYQI3.js → chunk-CX5I6VS4.js} +2 -2
  34. package/dist/{chunk-CT4YYQI3.js.map → chunk-CX5I6VS4.js.map} +1 -1
  35. package/dist/{chunk-JEWTRDRI.js → chunk-D5VCCQ4L.js} +5 -5
  36. package/dist/{chunk-JEWTRDRI.js.map → chunk-D5VCCQ4L.js.map} +1 -1
  37. package/dist/{chunk-WVTVBWOQ.js → chunk-FB6O7FNK.js} +42 -61
  38. package/dist/chunk-FB6O7FNK.js.map +1 -0
  39. package/dist/{chunk-LUONHWL6.cjs → chunk-GVHBM6VU.cjs} +6 -6
  40. package/dist/{chunk-LUONHWL6.cjs.map → chunk-GVHBM6VU.cjs.map} +1 -1
  41. package/dist/{chunk-ZOJZL62I.js → chunk-HDPQ3LEE.js} +4 -4
  42. package/dist/{chunk-ZOJZL62I.js.map → chunk-HDPQ3LEE.js.map} +1 -1
  43. package/dist/{chunk-IOCCTQYZ.js → chunk-IR4WRS3N.js} +38 -14
  44. package/dist/chunk-IR4WRS3N.js.map +1 -0
  45. package/dist/{chunk-E6XNM5ES.js → chunk-MP2VGF73.js} +3 -3
  46. package/dist/{chunk-E6XNM5ES.js.map → chunk-MP2VGF73.js.map} +1 -1
  47. package/dist/{chunk-DQYOFNZ7.cjs → chunk-OKKJRRSS.cjs} +39 -15
  48. package/dist/chunk-OKKJRRSS.cjs.map +1 -0
  49. package/dist/{chunk-H5O522FY.cjs → chunk-OVWOD5GI.cjs} +53 -72
  50. package/dist/chunk-OVWOD5GI.cjs.map +1 -0
  51. package/dist/{chunk-MBJ6IAKF.cjs → chunk-OXS5X7PW.cjs} +13 -13
  52. package/dist/{chunk-MBJ6IAKF.cjs.map → chunk-OXS5X7PW.cjs.map} +1 -1
  53. package/dist/{chunk-M5CZCWWW.js → chunk-OYAHOEQP.js} +4 -4
  54. package/dist/{chunk-M5CZCWWW.js.map → chunk-OYAHOEQP.js.map} +1 -1
  55. package/dist/{chunk-5AVTFQEP.cjs → chunk-PYNUWPGW.cjs} +19 -19
  56. package/dist/{chunk-5AVTFQEP.cjs.map → chunk-PYNUWPGW.cjs.map} +1 -1
  57. package/dist/{chunk-7IDACSBM.cjs → chunk-QXPUTX3W.cjs} +32 -32
  58. package/dist/chunk-QXPUTX3W.cjs.map +1 -0
  59. package/dist/{chunk-VMKNS3YO.js → chunk-SLHDZJ4B.js} +3 -3
  60. package/dist/chunk-SLHDZJ4B.js.map +1 -0
  61. package/dist/{chunk-YEKQKMCU.cjs → chunk-T5XU5TAV.cjs} +82 -82
  62. package/dist/{chunk-YEKQKMCU.cjs.map → chunk-T5XU5TAV.cjs.map} +1 -1
  63. package/dist/{chunk-YN3FI4AD.js → chunk-UORUVXKY.js} +5 -5
  64. package/dist/{chunk-YN3FI4AD.js.map → chunk-UORUVXKY.js.map} +1 -1
  65. package/dist/{chunk-T2CILERS.cjs → chunk-VVR3SFKH.cjs} +68 -68
  66. package/dist/{chunk-T2CILERS.cjs.map → chunk-VVR3SFKH.cjs.map} +1 -1
  67. package/dist/{chunk-EYM6DWKD.js → chunk-W2QYKEBN.js} +5 -5
  68. package/dist/{chunk-EYM6DWKD.js.map → chunk-W2QYKEBN.js.map} +1 -1
  69. package/dist/{chunk-PK3X5KIF.cjs → chunk-X36INADV.cjs} +23 -23
  70. package/dist/{chunk-PK3X5KIF.cjs.map → chunk-X36INADV.cjs.map} +1 -1
  71. package/dist/{chunk-45M6KUQZ.js → chunk-YBVRBNRY.js} +7 -7
  72. package/dist/{chunk-45M6KUQZ.js.map → chunk-YBVRBNRY.js.map} +1 -1
  73. package/dist/{chunk-QR2Z4WQ7.js → chunk-ZFH5KWHO.js} +3 -3
  74. package/dist/{chunk-QR2Z4WQ7.js.map → chunk-ZFH5KWHO.js.map} +1 -1
  75. package/dist/{chunk-4KGTZPYF.cjs → chunk-ZFZ6HQFT.cjs} +185 -185
  76. package/dist/{chunk-4KGTZPYF.cjs.map → chunk-ZFZ6HQFT.cjs.map} +1 -1
  77. package/dist/datasets/index.cjs +17 -17
  78. package/dist/datasets/index.js +2 -2
  79. package/dist/docs/SKILL.md +1 -1
  80. package/dist/docs/assets/SOURCE_MAP.json +469 -469
  81. package/dist/docs/references/docs-memory-observational-memory.md +49 -4
  82. package/dist/docs/references/docs-server-mastra-client.md +17 -0
  83. package/dist/docs/references/reference-client-js-agents.md +11 -6
  84. package/dist/docs/references/reference-evals-scorer-utils.md +9 -5
  85. package/dist/docs/references/reference-evals-trajectory-accuracy.md +29 -15
  86. package/dist/docs/references/reference-memory-observational-memory.md +32 -6
  87. package/dist/evals/index.cjs +23 -23
  88. package/dist/evals/index.js +3 -3
  89. package/dist/evals/scoreTraces/index.cjs +7 -7
  90. package/dist/evals/scoreTraces/index.js +3 -3
  91. package/dist/evals/types.d.ts +58 -28
  92. package/dist/evals/types.d.ts.map +1 -1
  93. package/dist/harness/harness.d.ts.map +1 -1
  94. package/dist/harness/index.cjs +28 -8
  95. package/dist/harness/index.cjs.map +1 -1
  96. package/dist/harness/index.js +26 -6
  97. package/dist/harness/index.js.map +1 -1
  98. package/dist/index.cjs +2 -2
  99. package/dist/index.js +1 -1
  100. package/dist/llm/index.cjs +16 -16
  101. package/dist/llm/index.js +5 -5
  102. package/dist/llm/model/provider-types.generated.d.ts +14 -2
  103. package/dist/loop/index.cjs +14 -14
  104. package/dist/loop/index.js +1 -1
  105. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  106. package/dist/mastra/index.cjs +2 -2
  107. package/dist/mastra/index.d.ts +11 -0
  108. package/dist/mastra/index.d.ts.map +1 -1
  109. package/dist/mastra/index.js +1 -1
  110. package/dist/memory/index.cjs +14 -14
  111. package/dist/memory/index.js +1 -1
  112. package/dist/memory/memory.d.ts.map +1 -1
  113. package/dist/memory/types.d.ts +16 -2
  114. package/dist/memory/types.d.ts.map +1 -1
  115. package/dist/models-dev-MIC2CW43.cjs +12 -0
  116. package/dist/{models-dev-GLFQVCT4.cjs.map → models-dev-MIC2CW43.cjs.map} +1 -1
  117. package/dist/models-dev-VDZIOMAC.js +3 -0
  118. package/dist/{models-dev-WSLKK6FO.js.map → models-dev-VDZIOMAC.js.map} +1 -1
  119. package/dist/netlify-2CGMKEKT.js +3 -0
  120. package/dist/{netlify-SNTN56QS.js.map → netlify-2CGMKEKT.js.map} +1 -1
  121. package/dist/netlify-KZ4HQR5N.cjs +12 -0
  122. package/dist/{netlify-VFRYJYBK.cjs.map → netlify-KZ4HQR5N.cjs.map} +1 -1
  123. package/dist/observability/index.cjs +18 -18
  124. package/dist/observability/index.js +1 -1
  125. package/dist/observability/types/tracing.d.ts +3 -0
  126. package/dist/observability/types/tracing.d.ts.map +1 -1
  127. package/dist/processor-provider/index.cjs +10 -10
  128. package/dist/processor-provider/index.js +1 -1
  129. package/dist/processors/index.cjs +44 -44
  130. package/dist/processors/index.js +1 -1
  131. package/dist/processors/tool-result-reminder.d.ts +2 -0
  132. package/dist/processors/tool-result-reminder.d.ts.map +1 -1
  133. package/dist/provider-registry-HGWTTWCL.cjs +40 -0
  134. package/dist/{provider-registry-L6KDLMFM.cjs.map → provider-registry-HGWTTWCL.cjs.map} +1 -1
  135. package/dist/provider-registry-QRWUBN5N.js +3 -0
  136. package/dist/{provider-registry-LEXW2E53.js.map → provider-registry-QRWUBN5N.js.map} +1 -1
  137. package/dist/provider-registry.json +34 -10
  138. package/dist/relevance/index.cjs +3 -3
  139. package/dist/relevance/index.js +1 -1
  140. package/dist/storage/constants.cjs +56 -56
  141. package/dist/storage/constants.js +1 -1
  142. package/dist/storage/index.cjs +268 -268
  143. package/dist/storage/index.js +3 -3
  144. package/dist/stream/index.cjs +8 -8
  145. package/dist/stream/index.js +1 -1
  146. package/dist/test-utils/llm-mock.cjs +4 -4
  147. package/dist/test-utils/llm-mock.js +1 -1
  148. package/dist/tool-loop-agent/index.cjs +4 -4
  149. package/dist/tool-loop-agent/index.js +1 -1
  150. package/dist/utils.cjs +23 -23
  151. package/dist/utils.js +1 -1
  152. package/dist/vector/index.cjs +7 -7
  153. package/dist/vector/index.js +1 -1
  154. package/dist/workflows/evented/index.cjs +10 -10
  155. package/dist/workflows/evented/index.js +1 -1
  156. package/dist/workflows/index.cjs +24 -24
  157. package/dist/workflows/index.js +1 -1
  158. package/package.json +4 -3
  159. package/src/llm/model/provider-types.generated.d.ts +14 -2
  160. package/dist/chunk-7IDACSBM.cjs.map +0 -1
  161. package/dist/chunk-DQYOFNZ7.cjs.map +0 -1
  162. package/dist/chunk-H5O522FY.cjs.map +0 -1
  163. package/dist/chunk-IOCCTQYZ.js.map +0 -1
  164. package/dist/chunk-VAVK4KJI.cjs.map +0 -1
  165. package/dist/chunk-VF3CL3JV.js.map +0 -1
  166. package/dist/chunk-VMKNS3YO.js.map +0 -1
  167. package/dist/chunk-WVTVBWOQ.js.map +0 -1
  168. package/dist/models-dev-GLFQVCT4.cjs +0 -12
  169. package/dist/models-dev-WSLKK6FO.js +0 -3
  170. package/dist/netlify-SNTN56QS.js +0 -3
  171. package/dist/netlify-VFRYJYBK.cjs +0 -12
  172. package/dist/provider-registry-L6KDLMFM.cjs +0 -40
  173. package/dist/provider-registry-LEXW2E53.js +0 -3
@@ -1,17 +1,17 @@
1
1
  import { DefaultVoice } from './chunk-YDLGEJ7W.js';
2
2
  import { PUBSUB_SYMBOL, STREAM_FORMAT_SYMBOL } from './chunk-2QXNHEDL.js';
3
3
  import { createWorkspaceTools, createSkillTools, getTiktoken, BM25Index } from './chunk-ABA3KD3X.js';
4
- import { InMemoryStore } from './chunk-EYM6DWKD.js';
4
+ import { InMemoryStore } from './chunk-W2QYKEBN.js';
5
5
  import { MessageList, coreContentToString, DefaultGeneratedFile, DefaultGeneratedFileWithType, sanitizeToolName } from './chunk-SLZ3WO42.js';
6
6
  import { parsePartialJson, isDeepEqualData, stepCountIs } from './chunk-2PHG443D.js';
7
7
  import { generateId, APICallError, tool, asSchema } from './chunk-6PALJNKG.js';
8
8
  import { executeHook } from './chunk-L54GIUCB.js';
9
- import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-45M6KUQZ.js';
10
- import { MastraLLMV1 } from './chunk-ZOJZL62I.js';
9
+ import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-YBVRBNRY.js';
10
+ import { MastraLLMV1 } from './chunk-HDPQ3LEE.js';
11
11
  import { noopLogger } from './chunk-PSCMWPLC.js';
12
12
  import { EventEmitterPubSub } from './chunk-X2HAI3OX.js';
13
- import { removeUndefinedValues, ensureToolProperties, makeCoreTool, createMastraProxy, deepMerge, generateEmptyFromSchema, selectFields, delay } from './chunk-FWDG2WUV.js';
14
- import { resolveObservabilityContext, EntityType, createObservabilityContext, getRootExportSpan, getOrCreateSpan, wrapMastra, executeWithContext, executeWithContextSync } from './chunk-CT4YYQI3.js';
13
+ import { removeUndefinedValues, ensureToolProperties, makeCoreTool, createMastraProxy, deepMerge, generateEmptyFromSchema, selectFields, delay } from './chunk-AHFHYQS6.js';
14
+ import { resolveObservabilityContext, EntityType, createObservabilityContext, getRootExportSpan, getOrCreateSpan, wrapMastra, executeWithContext, executeWithContextSync } from './chunk-CX5I6VS4.js';
15
15
  import { ToolStream } from './chunk-DD2VNRQM.js';
16
16
  import { Tool, createTool, isMastraTool, isProviderTool, getProviderToolName, isProviderDefinedTool } from './chunk-GRMC2OYN.js';
17
17
  import { toStandardSchema, standardSchemaToJSONSchema, isStandardSchemaWithJSON } from './chunk-6SRTDZ7S.js';
@@ -30,6 +30,7 @@ import { isEmpty } from 'radash';
30
30
  import { isAbortError, injectJsonInstructionIntoMessages } from '@ai-sdk/provider-utils-v5';
31
31
  import { existsSync, statSync, readFileSync } from 'fs';
32
32
  import { normalize, isAbsolute, resolve, basename, dirname, join } from 'path';
33
+ import { estimateTokenCount } from 'tokenx';
33
34
  import xxhash from 'xxhash-wasm';
34
35
  import { LRUCache } from 'lru-cache';
35
36
 
@@ -12780,6 +12781,35 @@ function createLLMExecutionStep({
12780
12781
  abortSignal: options?.abortSignal
12781
12782
  });
12782
12783
  Object.assign(currentStep, processInputStepResult);
12784
+ const modelChanged = processInputStepResult.model && processInputStepResult.model !== model;
12785
+ const modelSettingsChanged = processInputStepResult.modelSettings && processInputStepResult.modelSettings !== modelSettings;
12786
+ if (modelSpanTracker && (modelChanged || modelSettingsChanged)) {
12787
+ modelSpanTracker.updateGeneration({
12788
+ ...modelChanged ? { name: `llm: '${currentStep.model.modelId}'` } : {},
12789
+ attributes: {
12790
+ ...modelChanged ? {
12791
+ model: currentStep.model.modelId,
12792
+ provider: currentStep.model.provider
12793
+ } : {},
12794
+ ...modelSettingsChanged ? { parameters: currentStep.modelSettings } : {}
12795
+ }
12796
+ });
12797
+ }
12798
+ const toolsChanged = processInputStepResult.tools && processInputStepResult.tools !== tools;
12799
+ const activeToolsChanged = processInputStepResult.activeTools && processInputStepResult.activeTools !== activeTools;
12800
+ if (toolsChanged || activeToolsChanged) {
12801
+ const agentSpan = tracingContext?.currentSpan?.findParent("agent_run" /* AGENT_RUN */);
12802
+ if (agentSpan) {
12803
+ const toolNames = activeToolsChanged ? processInputStepResult.activeTools : currentStep.tools ? Object.keys(currentStep.tools) : void 0;
12804
+ if (toolNames !== void 0) {
12805
+ agentSpan.update({
12806
+ attributes: {
12807
+ availableTools: toolNames
12808
+ }
12809
+ });
12810
+ }
12811
+ }
12812
+ }
12783
12813
  if (processInputStepResult.tools && currentStep.tools) {
12784
12814
  const convertedTools = {};
12785
12815
  for (const [name, tool2] of Object.entries(currentStep.tools)) {
@@ -18516,7 +18546,8 @@ function createPrepareMemoryStep({
18516
18546
  requestContext,
18517
18547
  instructions,
18518
18548
  memoryConfig,
18519
- memory
18549
+ memory,
18550
+ isResume
18520
18551
  }) {
18521
18552
  return createStep({
18522
18553
  id: "prepare-memory-step",
@@ -18539,13 +18570,16 @@ function createPrepareMemoryStep({
18539
18570
  addSystemMessage(messageList, options.system, "user-provided");
18540
18571
  if (!memory || !thread?.id && !resourceId) {
18541
18572
  messageList.add(options.messages, "input");
18542
- const { tripwire: tripwire2 } = await capabilities.runInputProcessors({
18543
- requestContext,
18544
- ...observabilityContext,
18545
- messageList,
18546
- inputProcessorOverrides: options.inputProcessors,
18547
- processorStates
18548
- });
18573
+ let tripwire2;
18574
+ if (!isResume) {
18575
+ ({ tripwire: tripwire2 } = await capabilities.runInputProcessors({
18576
+ requestContext,
18577
+ ...observabilityContext,
18578
+ messageList,
18579
+ inputProcessorOverrides: options.inputProcessors,
18580
+ processorStates
18581
+ }));
18582
+ }
18549
18583
  return {
18550
18584
  threadExists: false,
18551
18585
  thread: void 0,
@@ -18607,13 +18641,16 @@ function createPrepareMemoryStep({
18607
18641
  memoryConfig
18608
18642
  });
18609
18643
  messageList.add(options.messages, "input");
18610
- const { tripwire } = await capabilities.runInputProcessors({
18611
- requestContext,
18612
- ...observabilityContext,
18613
- messageList,
18614
- inputProcessorOverrides: options.inputProcessors,
18615
- processorStates
18616
- });
18644
+ let tripwire;
18645
+ if (!isResume) {
18646
+ ({ tripwire } = await capabilities.runInputProcessors({
18647
+ requestContext,
18648
+ ...observabilityContext,
18649
+ messageList,
18650
+ inputProcessorOverrides: options.inputProcessors,
18651
+ processorStates
18652
+ }));
18653
+ }
18617
18654
  return {
18618
18655
  thread: threadObject,
18619
18656
  messageList,
@@ -18783,7 +18820,8 @@ function createPrepareStreamWorkflow({
18783
18820
  requestContext,
18784
18821
  instructions,
18785
18822
  memoryConfig,
18786
- memory
18823
+ memory,
18824
+ isResume: !!resumeContext
18787
18825
  });
18788
18826
  const streamStep = createStreamStep({
18789
18827
  capabilities,
@@ -19163,7 +19201,9 @@ ${errorMessages}`,
19163
19201
  * @internal
19164
19202
  */
19165
19203
  async listResolvedOutputProcessors(requestContext, configuredProcessorOverrides) {
19166
- const configuredProcessors = configuredProcessorOverrides ? configuredProcessorOverrides : this.#outputProcessors ? typeof this.#outputProcessors === "function" ? await this.#outputProcessors({ requestContext: requestContext || new RequestContext() }) : this.#outputProcessors : [];
19204
+ const configuredProcessors = configuredProcessorOverrides ? configuredProcessorOverrides : this.#outputProcessors ? typeof this.#outputProcessors === "function" ? await this.#outputProcessors({
19205
+ requestContext: requestContext || new RequestContext()
19206
+ }) : this.#outputProcessors : [];
19167
19207
  const memory = await this.getMemory({ requestContext: requestContext || new RequestContext() });
19168
19208
  const memoryProcessors = memory ? await memory.getOutputProcessors(configuredProcessors, requestContext) : [];
19169
19209
  const allProcessors = [...configuredProcessors, ...memoryProcessors];
@@ -19175,7 +19215,9 @@ ${errorMessages}`,
19175
19215
  * @internal
19176
19216
  */
19177
19217
  async listResolvedInputProcessors(requestContext, configuredProcessorOverrides) {
19178
- const configuredProcessors = configuredProcessorOverrides ? configuredProcessorOverrides : this.#inputProcessors ? typeof this.#inputProcessors === "function" ? await this.#inputProcessors({ requestContext: requestContext || new RequestContext() }) : this.#inputProcessors : [];
19218
+ const configuredProcessors = configuredProcessorOverrides ? configuredProcessorOverrides : this.#inputProcessors ? typeof this.#inputProcessors === "function" ? await this.#inputProcessors({
19219
+ requestContext: requestContext || new RequestContext()
19220
+ }) : this.#inputProcessors : [];
19179
19221
  const memory = await this.getMemory({ requestContext: requestContext || new RequestContext() });
19180
19222
  const memoryProcessors = memory ? await memory.getInputProcessors(configuredProcessors, requestContext) : [];
19181
19223
  const workspaceProcessors = await this.getWorkspaceInstructionsProcessors(configuredProcessors, requestContext);
@@ -19236,7 +19278,9 @@ ${errorMessages}`,
19236
19278
  */
19237
19279
  async listConfiguredInputProcessors(requestContext) {
19238
19280
  if (!this.#inputProcessors) return [];
19239
- const configuredProcessors = typeof this.#inputProcessors === "function" ? await this.#inputProcessors({ requestContext: requestContext || new RequestContext() }) : this.#inputProcessors;
19281
+ const configuredProcessors = typeof this.#inputProcessors === "function" ? await this.#inputProcessors({
19282
+ requestContext: requestContext || new RequestContext()
19283
+ }) : this.#inputProcessors;
19240
19284
  return configuredProcessors;
19241
19285
  }
19242
19286
  /**
@@ -19248,7 +19292,9 @@ ${errorMessages}`,
19248
19292
  */
19249
19293
  async listConfiguredOutputProcessors(requestContext) {
19250
19294
  if (!this.#outputProcessors) return [];
19251
- const configuredProcessors = typeof this.#outputProcessors === "function" ? await this.#outputProcessors({ requestContext: requestContext || new RequestContext() }) : this.#outputProcessors;
19295
+ const configuredProcessors = typeof this.#outputProcessors === "function" ? await this.#outputProcessors({
19296
+ requestContext: requestContext || new RequestContext()
19297
+ }) : this.#outputProcessors;
19252
19298
  return configuredProcessors;
19253
19299
  }
19254
19300
  /**
@@ -19330,7 +19376,10 @@ ${errorMessages}`,
19330
19376
  if (typeof this.#memory !== "function") {
19331
19377
  resolvedMemory = this.#memory;
19332
19378
  } else {
19333
- const result = this.#memory({ requestContext, mastra: this.#mastra });
19379
+ const result = this.#memory({
19380
+ requestContext,
19381
+ mastra: this.#mastra
19382
+ });
19334
19383
  resolvedMemory = await Promise.resolve(result);
19335
19384
  if (!resolvedMemory) {
19336
19385
  const mastraError = new MastraError({
@@ -19391,7 +19440,10 @@ ${errorMessages}`,
19391
19440
  if (typeof this.#workspace !== "function") {
19392
19441
  return this.#workspace;
19393
19442
  }
19394
- const result = this.#workspace({ requestContext, mastra: this.#mastra });
19443
+ const result = this.#workspace({
19444
+ requestContext,
19445
+ mastra: this.#mastra
19446
+ });
19395
19447
  const resolvedWorkspace = await Promise.resolve(result);
19396
19448
  if (!resolvedWorkspace) {
19397
19449
  return void 0;
@@ -19447,7 +19499,9 @@ ${errorMessages}`,
19447
19499
  } = {}) {
19448
19500
  let workflowRecord;
19449
19501
  if (typeof this.#workflows === "function") {
19450
- workflowRecord = await Promise.resolve(this.#workflows({ requestContext, mastra: this.#mastra }));
19502
+ workflowRecord = await Promise.resolve(
19503
+ this.#workflows({ requestContext, mastra: this.#mastra })
19504
+ );
19451
19505
  } else {
19452
19506
  workflowRecord = this.#workflows ?? {};
19453
19507
  }
@@ -19464,7 +19518,10 @@ ${errorMessages}`,
19464
19518
  if (typeof this.#scorers !== "function") {
19465
19519
  return this.#scorers;
19466
19520
  }
19467
- const result = this.#scorers({ requestContext, mastra: this.#mastra });
19521
+ const result = this.#scorers({
19522
+ requestContext,
19523
+ mastra: this.#mastra
19524
+ });
19468
19525
  return resolveMaybePromise(result, (scorers) => {
19469
19526
  if (!scorers) {
19470
19527
  const mastraError = new MastraError({
@@ -19625,7 +19682,10 @@ ${errorMessages}`,
19625
19682
  if (typeof this.#defaultGenerateOptionsLegacy !== "function") {
19626
19683
  return this.#defaultGenerateOptionsLegacy;
19627
19684
  }
19628
- const result = this.#defaultGenerateOptionsLegacy({ requestContext, mastra: this.#mastra });
19685
+ const result = this.#defaultGenerateOptionsLegacy({
19686
+ requestContext,
19687
+ mastra: this.#mastra
19688
+ });
19629
19689
  return resolveMaybePromise(result, (options) => {
19630
19690
  if (!options) {
19631
19691
  const mastraError = new MastraError({
@@ -19660,7 +19720,10 @@ ${errorMessages}`,
19660
19720
  if (typeof this.#defaultStreamOptionsLegacy !== "function") {
19661
19721
  return this.#defaultStreamOptionsLegacy;
19662
19722
  }
19663
- const result = this.#defaultStreamOptionsLegacy({ requestContext, mastra: this.#mastra });
19723
+ const result = this.#defaultStreamOptionsLegacy({
19724
+ requestContext,
19725
+ mastra: this.#mastra
19726
+ });
19664
19727
  return resolveMaybePromise(result, (options) => {
19665
19728
  if (!options) {
19666
19729
  const mastraError = new MastraError({
@@ -19693,7 +19756,10 @@ ${errorMessages}`,
19693
19756
  if (typeof this.#defaultOptions !== "function") {
19694
19757
  return this.#defaultOptions;
19695
19758
  }
19696
- const result = this.#defaultOptions({ requestContext, mastra: this.#mastra });
19759
+ const result = this.#defaultOptions({
19760
+ requestContext,
19761
+ mastra: this.#mastra
19762
+ });
19697
19763
  return resolveMaybePromise(result, (options) => {
19698
19764
  if (!options) {
19699
19765
  const mastraError = new MastraError({
@@ -19729,7 +19795,10 @@ ${errorMessages}`,
19729
19795
  if (typeof this.#defaultNetworkOptions !== "function") {
19730
19796
  return this.#defaultNetworkOptions;
19731
19797
  }
19732
- const result = this.#defaultNetworkOptions({ requestContext, mastra: this.#mastra });
19798
+ const result = this.#defaultNetworkOptions({
19799
+ requestContext,
19800
+ mastra: this.#mastra
19801
+ });
19733
19802
  return resolveMaybePromise(result, (options) => {
19734
19803
  if (!options) {
19735
19804
  const mastraError = new MastraError({
@@ -19799,7 +19868,10 @@ ${errorMessages}`,
19799
19868
  requestContext = new RequestContext(),
19800
19869
  model
19801
19870
  } = {}) {
19802
- const modelSelectionPromise = model ? this.resolveModelSelection(model, requestContext) : this.resolveModelSelection(this.model, requestContext);
19871
+ const modelSelectionPromise = model ? this.resolveModelSelection(
19872
+ model,
19873
+ requestContext
19874
+ ) : this.resolveModelSelection(this.model, requestContext);
19803
19875
  return modelSelectionPromise.then((modelSelection) => {
19804
19876
  const firstEnabledModel = Array.isArray(modelSelection) ? modelSelection.find((m) => m.enabled)?.model : modelSelection;
19805
19877
  if (!firstEnabledModel) {
@@ -19925,7 +19997,10 @@ ${errorMessages}`,
19925
19997
  */
19926
19998
  async resolveModelSelection(modelConfig, requestContext) {
19927
19999
  if (typeof modelConfig === "function") {
19928
- const resolved = await modelConfig({ requestContext, mastra: this.#mastra });
20000
+ const resolved = await modelConfig({
20001
+ requestContext,
20002
+ mastra: this.#mastra
20003
+ });
19929
20004
  if (Array.isArray(resolved)) {
19930
20005
  if (resolved.length === 0) {
19931
20006
  const mastraError = new MastraError({
@@ -21154,7 +21229,6 @@ ${effectiveInstructions}`;
21154
21229
  }
21155
21230
  } : {}
21156
21231
  });
21157
- let fullText = "";
21158
21232
  let requireToolApproval;
21159
21233
  let suspendedPayload;
21160
21234
  let resumeSchema;
@@ -21182,9 +21256,6 @@ ${effectiveInstructions}`;
21182
21256
  }
21183
21257
  }
21184
21258
  }
21185
- if (chunk.type === "text-delta") {
21186
- fullText += chunk.payload.text;
21187
- }
21188
21259
  }
21189
21260
  const subAgentToolResults = (await streamResult.toolResults)?.map((toolResult) => ({
21190
21261
  toolName: toolResult.payload.toolName,
@@ -21236,7 +21307,13 @@ ${effectiveInstructions}`;
21236
21307
  isAgentSuspend: true
21237
21308
  });
21238
21309
  }
21239
- result = { text: fullText, subAgentThreadId, subAgentResourceId, subAgentToolResults };
21310
+ const processedText = await streamResult.text;
21311
+ result = {
21312
+ text: processedText,
21313
+ subAgentThreadId,
21314
+ subAgentResourceId,
21315
+ subAgentToolResults
21316
+ };
21240
21317
  } else {
21241
21318
  const streamResult = await agent.streamLegacy(effectivePrompt, {
21242
21319
  requestContext,
@@ -22191,7 +22268,9 @@ ${effectiveInstructions}`;
22191
22268
  shouldGenerate,
22192
22269
  model: titleModel,
22193
22270
  instructions: titleInstructions
22194
- } = this.resolveTitleGenerationConfig(config.generateTitle);
22271
+ } = this.resolveTitleGenerationConfig(
22272
+ config.generateTitle
22273
+ );
22195
22274
  if (shouldGenerate && !thread.title) {
22196
22275
  const userMessage = this.getMostRecentUserMessage(messageList.get.all.ui());
22197
22276
  if (userMessage) {
@@ -24886,6 +24965,20 @@ function getMessageText(message) {
24886
24965
  function getReminderMarkup(reminderText, instructionPath) {
24887
24966
  return `<system-reminder type="${REMINDER_TYPE}" path="${escapeXmlAttribute(instructionPath)}">${escapeXml(reminderText)}</system-reminder>`;
24888
24967
  }
24968
+ function truncateToTokenLimit(content, maxTokens) {
24969
+ const estimatedTokens = estimateTokenCount(content);
24970
+ if (estimatedTokens <= maxTokens) {
24971
+ return content;
24972
+ }
24973
+ const approximateCharLimit = Math.max(maxTokens * 4, 1);
24974
+ const sliceEnd = Math.min(content.length, approximateCharLimit);
24975
+ const newlineIndex = content.lastIndexOf("\n", sliceEnd);
24976
+ const truncatedContent = content.slice(0, newlineIndex > 0 ? newlineIndex : sliceEnd).trimEnd();
24977
+ const shownTokens = estimateTokenCount(truncatedContent);
24978
+ return `${truncatedContent}
24979
+
24980
+ [truncated \u2014 showing first ~${shownTokens} of ~${estimatedTokens} estimated tokens]`;
24981
+ }
24889
24982
  function getCompletedToolCalls(messageList) {
24890
24983
  const completed = [];
24891
24984
  for (const message of messageList.get.all.db()) {
@@ -24929,12 +25022,14 @@ var AgentsMDInjector = class {
24929
25022
  description = "Injects AGENTS.md reminders when instruction file operations are detected";
24930
25023
  processorIndex = 0;
24931
25024
  reminderText;
25025
+ maxTokens;
24932
25026
  pathExists;
24933
25027
  isDirectory;
24934
25028
  readFile;
24935
25029
  getIgnoredInstructionPaths;
24936
25030
  constructor(options) {
24937
25031
  this.reminderText = options.reminderText;
25032
+ this.maxTokens = options.maxTokens ?? 1e3;
24938
25033
  this.pathExists = options.pathExists ?? existsSync;
24939
25034
  this.isDirectory = options.isDirectory ?? ((path) => {
24940
25035
  try {
@@ -24982,7 +25077,7 @@ var AgentsMDInjector = class {
24982
25077
  try {
24983
25078
  const content = this.readFile(instructionPath).trim();
24984
25079
  if (content.length > 0) {
24985
- return content;
25080
+ return truncateToTokenLimit(content, this.maxTokens);
24986
25081
  }
24987
25082
  } catch {
24988
25083
  }
@@ -26494,6 +26589,20 @@ https://mastra.ai/en/docs/memory/semantic-recall`
26494
26589
  if (config.embedderOptions) {
26495
26590
  this.embedderOptions = config.embedderOptions;
26496
26591
  }
26592
+ } else {
26593
+ if (config.vector) {
26594
+ this.vector = config.vector;
26595
+ }
26596
+ if (config.embedder) {
26597
+ if (typeof config.embedder === "string") {
26598
+ this.embedder = new ModelRouterEmbeddingModel(config.embedder);
26599
+ } else {
26600
+ this.embedder = config.embedder;
26601
+ }
26602
+ }
26603
+ if (config.embedderOptions) {
26604
+ this.embedderOptions = config.embedderOptions;
26605
+ }
26497
26606
  }
26498
26607
  }
26499
26608
  /**
@@ -27179,5 +27288,5 @@ var MockMemory = class extends MastraMemory {
27179
27288
  };
27180
27289
 
27181
27290
  export { Agent, AgentsMDInjector, BaseProcessor, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, ExecutionEngine, FilePartSchema, ImagePartSchema, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MastraScorer, MemoryProcessor, MessageContentSchema, MessageHistory, MessagePartSchema, MockMemory, ModerationProcessor, PIIDetector, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ReasoningPartSchema, Run, SemanticRecall, SkillSearchProcessor, SkillsProcessor, SourcePartSchema, StepStartPartSchema, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, ToolSearchProcessor, TripWire, UnicodeNormalizer, WORKING_MEMORY_END_TAG, WORKING_MEMORY_START_TAG, Workflow, WorkflowRunOutput, WorkingMemory, WorkspaceInstructionsProcessor, augmentWithInit, cleanStepResult, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createScorer, createStep, createTimeTravelExecutionParams, createWorkflow, extractWorkingMemoryContent, extractWorkingMemoryTags, formatCheckFeedback, formatCompletionFeedback, formatStreamCompletionFeedback, formatValidationFeedback, forwardAgentStreamChunk, generateFinalResult, generateStructuredFinalResult, getResumeLabelsByStepId, getStepIds, getStepResult, getThreadOMMetadata, globalEmbeddingCache, hydrateSerializedStepErrors, isObservationalMemoryEnabled, isProcessor, isProcessorWorkflow, isSupportedLanguageModel, loop, mapVariable, memoryDefaultOptions, parseMemoryRequestContext, removeWorkingMemoryTags, resolveThreadIdFromArgs, runChecks, runCompletionScorers, runCountDeprecationMessage, runDefaultCompletionCheck, runStreamCompletionScorers, runValidation, setThreadOMMetadata, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepRequestContext, validateStepResumeData, validateStepStateData, validateStepSuspendData };
27182
- //# sourceMappingURL=chunk-VF3CL3JV.js.map
27183
- //# sourceMappingURL=chunk-VF3CL3JV.js.map
27291
+ //# sourceMappingURL=chunk-32NEFSTI.js.map
27292
+ //# sourceMappingURL=chunk-32NEFSTI.js.map