@mastra/core 1.0.0-beta.13 → 1.0.0-beta.14
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 +170 -0
- package/dist/agent/agent.d.ts +2 -2
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +6 -7
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +17 -9
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +3 -3
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/trip-wire.d.ts +2 -2
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/utils.d.ts +4 -1
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/bundler/types.d.ts +1 -0
- package/dist/bundler/types.d.ts.map +1 -1
- package/dist/chunk-2AU5ZHBL.js +79 -0
- package/dist/chunk-2AU5ZHBL.js.map +1 -0
- package/dist/{chunk-BQDZIQ3G.js → chunk-3IP3DZ7G.js} +85 -18
- package/dist/chunk-3IP3DZ7G.js.map +1 -0
- package/dist/{chunk-WYWRMIQC.js → chunk-4AT6YQKZ.js} +4 -103
- package/dist/chunk-4AT6YQKZ.js.map +1 -0
- package/dist/{chunk-62Q7K656.js → chunk-4CMIJQF6.js} +114 -110
- package/dist/chunk-4CMIJQF6.js.map +1 -0
- package/dist/{chunk-MXBVP7HX.cjs → chunk-53SZJCBX.cjs} +220 -174
- package/dist/chunk-53SZJCBX.cjs.map +1 -0
- package/dist/{chunk-2IU4RGU5.js → chunk-5UQ5TB6J.js} +5 -5
- package/dist/{chunk-2IU4RGU5.js.map → chunk-5UQ5TB6J.js.map} +1 -1
- package/dist/{chunk-WYGUWVTF.js → chunk-67LM2UCT.js} +8 -8
- package/dist/chunk-67LM2UCT.js.map +1 -0
- package/dist/{chunk-U4CSOY6T.cjs → chunk-6CG7IY57.cjs} +110 -43
- package/dist/chunk-6CG7IY57.cjs.map +1 -0
- package/dist/{chunk-X6IBA7FP.cjs → chunk-72E3YF6A.cjs} +9 -110
- package/dist/chunk-72E3YF6A.cjs.map +1 -0
- package/dist/{chunk-GIWC35YQ.js → chunk-AYBJ5GAD.js} +180 -4
- package/dist/chunk-AYBJ5GAD.js.map +1 -0
- package/dist/{chunk-VEPP75C4.cjs → chunk-DBW6S25C.cjs} +10 -10
- package/dist/{chunk-VEPP75C4.cjs.map → chunk-DBW6S25C.cjs.map} +1 -1
- package/dist/{chunk-Y7MZ5LJT.cjs → chunk-EGHGFLL3.cjs} +101 -102
- package/dist/chunk-EGHGFLL3.cjs.map +1 -0
- package/dist/{chunk-LGB4VNZI.cjs → chunk-ETWAR2YE.cjs} +5 -5
- package/dist/{chunk-LGB4VNZI.cjs.map → chunk-ETWAR2YE.cjs.map} +1 -1
- package/dist/{chunk-OWIEOL55.cjs → chunk-F75EQ574.cjs} +695 -254
- package/dist/chunk-F75EQ574.cjs.map +1 -0
- package/dist/{chunk-AGHLXC4I.cjs → chunk-FPDJ4XN6.cjs} +181 -5
- package/dist/chunk-FPDJ4XN6.cjs.map +1 -0
- package/dist/{chunk-VETAQUW3.js → chunk-GBQXIVL6.js} +3 -3
- package/dist/{chunk-VETAQUW3.js.map → chunk-GBQXIVL6.js.map} +1 -1
- package/dist/{chunk-4BC5FUAO.js → chunk-GELVUDUY.js} +5 -4
- package/dist/chunk-GELVUDUY.js.map +1 -0
- package/dist/chunk-GVAPYQRO.cjs +252 -0
- package/dist/chunk-GVAPYQRO.cjs.map +1 -0
- package/dist/{chunk-R5AJGM55.cjs → chunk-JAGQZZ43.cjs} +410 -265
- package/dist/chunk-JAGQZZ43.cjs.map +1 -0
- package/dist/{chunk-ARAQIW6E.js → chunk-K66U47VL.js} +617 -188
- package/dist/chunk-K66U47VL.js.map +1 -0
- package/dist/{chunk-RCJLMMTO.js → chunk-LDXKZYOV.js} +4 -4
- package/dist/{chunk-RCJLMMTO.js.map → chunk-LDXKZYOV.js.map} +1 -1
- package/dist/{chunk-MLKE7HRS.cjs → chunk-O3ULBGV6.cjs} +4 -4
- package/dist/{chunk-MLKE7HRS.cjs.map → chunk-O3ULBGV6.cjs.map} +1 -1
- package/dist/{chunk-PJAK4U6R.cjs → chunk-O5BQBZEF.cjs} +15 -15
- package/dist/chunk-O5BQBZEF.cjs.map +1 -0
- package/dist/{chunk-H4VUIOWU.cjs → chunk-OOUFPYSX.cjs} +5 -4
- package/dist/chunk-OOUFPYSX.cjs.map +1 -0
- package/dist/{chunk-5VZGJTPR.js → chunk-QDVYP2T7.js} +56 -10
- package/dist/chunk-QDVYP2T7.js.map +1 -0
- package/dist/{chunk-E5BQRAJK.js → chunk-QF4MHFSU.js} +364 -221
- package/dist/chunk-QF4MHFSU.js.map +1 -0
- package/dist/{chunk-WPTTKULS.js → chunk-SLBWA2F3.js} +3 -3
- package/dist/{chunk-WPTTKULS.js.map → chunk-SLBWA2F3.js.map} +1 -1
- package/dist/chunk-ST7NBF4H.cjs +84 -0
- package/dist/chunk-ST7NBF4H.cjs.map +1 -0
- package/dist/{chunk-7HEAVZRS.cjs → chunk-TDM43G4I.cjs} +8 -8
- package/dist/{chunk-7HEAVZRS.cjs.map → chunk-TDM43G4I.cjs.map} +1 -1
- package/dist/{chunk-SZYSDJTN.cjs → chunk-TRUNX3AX.cjs} +117 -112
- package/dist/chunk-TRUNX3AX.cjs.map +1 -0
- package/dist/chunk-VE6HQ7H6.js +250 -0
- package/dist/chunk-VE6HQ7H6.js.map +1 -0
- package/dist/{chunk-MRRFTNF4.js → chunk-VZJOEGQA.js} +3 -4
- package/dist/chunk-VZJOEGQA.js.map +1 -0
- package/dist/evals/index.cjs +4 -4
- package/dist/evals/index.js +1 -1
- package/dist/evals/run/index.d.ts.map +1 -1
- package/dist/evals/scoreTraces/index.cjs +3 -3
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +15 -15
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/aisdk/generate-to-stream.d.ts +20 -0
- package/dist/llm/model/aisdk/generate-to-stream.d.ts.map +1 -0
- package/dist/llm/model/aisdk/v5/model.d.ts +4 -0
- package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
- package/dist/llm/model/aisdk/v6/model.d.ts +51 -0
- package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -0
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +84 -0
- package/dist/llm/model/resolve-model.d.ts +2 -2
- package/dist/llm/model/resolve-model.d.ts.map +1 -1
- package/dist/llm/model/shared.types.d.ts +18 -7
- 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/network/index.d.ts +2 -2
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts +37 -0
- package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts.map +1 -0
- package/dist/loop/test-utils/fullStream.d.ts +2 -1
- package/dist/loop/test-utils/fullStream.d.ts.map +1 -1
- package/dist/loop/test-utils/resultObject.d.ts +2 -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/utils-v3.d.ts +55 -0
- package/dist/loop/test-utils/utils-v3.d.ts.map +1 -0
- package/dist/loop/types.d.ts +5 -6
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +36 -36
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +25 -25
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +12 -12
- package/dist/loop/workflows/agentic-loop/index.d.ts +36 -36
- package/dist/loop/workflows/run-state.d.ts +2 -2
- package/dist/loop/workflows/run-state.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +12 -12
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +6 -6
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-E3WWI7VA.js +3 -0
- package/dist/{models-dev-EO22XOXQ.js.map → models-dev-E3WWI7VA.js.map} +1 -1
- package/dist/models-dev-PPS7X4JM.cjs +12 -0
- package/dist/{models-dev-D3EKFGAO.cjs.map → models-dev-PPS7X4JM.cjs.map} +1 -1
- package/dist/netlify-TY656UYF.js +3 -0
- package/dist/{netlify-AE4LNCAI.js.map → netlify-TY656UYF.js.map} +1 -1
- package/dist/netlify-VZFM5UH3.cjs +12 -0
- package/dist/{netlify-WE42TZIT.cjs.map → netlify-VZFM5UH3.cjs.map} +1 -1
- package/dist/processors/index.cjs +37 -37
- package/dist/processors/index.d.ts +7 -7
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +26 -26
- package/dist/processors/step-schema.d.ts.map +1 -1
- package/dist/provider-registry-NXVD764B.js +3 -0
- package/dist/{provider-registry-6LF3NGC5.js.map → provider-registry-NXVD764B.js.map} +1 -1
- package/dist/provider-registry-ZIWSEUQE.cjs +40 -0
- package/dist/{provider-registry-73FKMXJV.cjs.map → provider-registry-ZIWSEUQE.cjs.map} +1 -1
- package/dist/provider-registry.json +176 -0
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.cjs.map +1 -1
- package/dist/relevance/index.js +2 -2
- package/dist/relevance/index.js.map +1 -1
- package/dist/storage/index.cjs +38 -38
- package/dist/storage/index.js +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +4 -4
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts +2 -2
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +7 -5
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +12 -12
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +29 -21
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.cjs.map +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/test-utils/llm-mock.js.map +1 -1
- package/dist/token-6GSAFR2W-LTZ7QQUP.js +61 -0
- package/dist/token-6GSAFR2W-LTZ7QQUP.js.map +1 -0
- package/dist/token-6GSAFR2W-UEEINYAN.cjs +63 -0
- package/dist/token-6GSAFR2W-UEEINYAN.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-QTFZ26EN.js +8 -0
- package/dist/token-util-NEHG7TUY-QTFZ26EN.js.map +1 -0
- package/dist/token-util-NEHG7TUY-WZL2DNCG.cjs +10 -0
- package/dist/token-util-NEHG7TUY-WZL2DNCG.cjs.map +1 -0
- package/dist/utils.cjs +22 -22
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/embed.d.ts +1 -0
- package/dist/vector/embed.d.ts.map +1 -1
- package/dist/vector/index.cjs +5300 -0
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.js +5279 -1
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/vector.d.ts +14 -1
- package/dist/vector/vector.d.ts.map +1 -1
- package/dist/voice/composite-voice.d.ts.map +1 -1
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts +4 -0
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts +15 -0
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +5 -0
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/workflow.d.ts +4 -1
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +10 -12
- package/src/llm/model/provider-types.generated.d.ts +84 -0
- package/dist/chunk-4BC5FUAO.js.map +0 -1
- package/dist/chunk-5VZGJTPR.js.map +0 -1
- package/dist/chunk-62Q7K656.js.map +0 -1
- package/dist/chunk-AGHLXC4I.cjs.map +0 -1
- package/dist/chunk-ARAQIW6E.js.map +0 -1
- package/dist/chunk-BQDZIQ3G.js.map +0 -1
- package/dist/chunk-E5BQRAJK.js.map +0 -1
- package/dist/chunk-GIWC35YQ.js.map +0 -1
- package/dist/chunk-H4VUIOWU.cjs.map +0 -1
- package/dist/chunk-IXZ2T2QX.cjs +0 -448
- package/dist/chunk-IXZ2T2QX.cjs.map +0 -1
- package/dist/chunk-MRRFTNF4.js.map +0 -1
- package/dist/chunk-MXBVP7HX.cjs.map +0 -1
- package/dist/chunk-OWIEOL55.cjs.map +0 -1
- package/dist/chunk-PJAK4U6R.cjs.map +0 -1
- package/dist/chunk-R5AJGM55.cjs.map +0 -1
- package/dist/chunk-SZYSDJTN.cjs.map +0 -1
- package/dist/chunk-U4CSOY6T.cjs.map +0 -1
- package/dist/chunk-UBSPZTQX.js +0 -434
- package/dist/chunk-UBSPZTQX.js.map +0 -1
- package/dist/chunk-WYGUWVTF.js.map +0 -1
- package/dist/chunk-WYWRMIQC.js.map +0 -1
- package/dist/chunk-X6IBA7FP.cjs.map +0 -1
- package/dist/chunk-Y7MZ5LJT.cjs.map +0 -1
- package/dist/llm/model/is-v2-model.d.ts +0 -3
- package/dist/llm/model/is-v2-model.d.ts.map +0 -1
- package/dist/models-dev-D3EKFGAO.cjs +0 -12
- package/dist/models-dev-EO22XOXQ.js +0 -3
- package/dist/netlify-AE4LNCAI.js +0 -3
- package/dist/netlify-WE42TZIT.cjs +0 -12
- package/dist/provider-registry-6LF3NGC5.js +0 -3
- package/dist/provider-registry-73FKMXJV.cjs +0 -40
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOOUFPYSX_cjs = require('./chunk-OOUFPYSX.cjs');
|
|
4
4
|
var chunkL3NKIMF5_cjs = require('./chunk-L3NKIMF5.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var chunkETWAR2YE_cjs = require('./chunk-ETWAR2YE.cjs');
|
|
6
|
+
var chunk72E3YF6A_cjs = require('./chunk-72E3YF6A.cjs');
|
|
7
7
|
var chunkNESKUIRE_cjs = require('./chunk-NESKUIRE.cjs');
|
|
8
8
|
var chunkFVQTJUBD_cjs = require('./chunk-FVQTJUBD.cjs');
|
|
9
|
+
var chunk53SZJCBX_cjs = require('./chunk-53SZJCBX.cjs');
|
|
10
|
+
var chunkTRUNX3AX_cjs = require('./chunk-TRUNX3AX.cjs');
|
|
9
11
|
var chunk4D4KB75Y_cjs = require('./chunk-4D4KB75Y.cjs');
|
|
10
12
|
var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
13
|
+
var chunkO3ULBGV6_cjs = require('./chunk-O3ULBGV6.cjs');
|
|
14
|
+
var chunk72YCRTEX_cjs = require('./chunk-72YCRTEX.cjs');
|
|
15
|
+
var chunkHWMMIRIF_cjs = require('./chunk-HWMMIRIF.cjs');
|
|
14
16
|
var chunkKJBMTK5B_cjs = require('./chunk-KJBMTK5B.cjs');
|
|
15
17
|
var chunkZ55SJVEC_cjs = require('./chunk-Z55SJVEC.cjs');
|
|
16
|
-
var chunk72YCRTEX_cjs = require('./chunk-72YCRTEX.cjs');
|
|
17
18
|
var chunkUVHSM2GU_cjs = require('./chunk-UVHSM2GU.cjs');
|
|
18
|
-
var chunkHWMMIRIF_cjs = require('./chunk-HWMMIRIF.cjs');
|
|
19
19
|
var chunk4WQYXT2I_cjs = require('./chunk-4WQYXT2I.cjs');
|
|
20
20
|
var chunkDGV2FWB4_cjs = require('./chunk-DGV2FWB4.cjs');
|
|
21
21
|
var chunkAF74UXR5_cjs = require('./chunk-AF74UXR5.cjs');
|
|
@@ -28,6 +28,7 @@ var providerV5 = require('@ai-sdk/provider-v5');
|
|
|
28
28
|
var z4 = require('zod/v4');
|
|
29
29
|
var schemaCompat = require('@mastra/schema-compat');
|
|
30
30
|
var radash = require('radash');
|
|
31
|
+
var providerUtilsV5 = require('@ai-sdk/provider-utils-v5');
|
|
31
32
|
var lite = require('js-tiktoken/lite');
|
|
32
33
|
var o200k_base = require('js-tiktoken/ranks/o200k_base');
|
|
33
34
|
var lruCache = require('lru-cache');
|
|
@@ -756,6 +757,69 @@ The input text may be in any format (sentences, bullet points, paragraphs, etc.)
|
|
|
756
757
|
}
|
|
757
758
|
};
|
|
758
759
|
|
|
760
|
+
// src/agent/utils.ts
|
|
761
|
+
var supportedLanguageModelSpecifications = ["v2", "v3"];
|
|
762
|
+
var isSupportedLanguageModel = (model) => {
|
|
763
|
+
return supportedLanguageModelSpecifications.includes(model.specificationVersion);
|
|
764
|
+
};
|
|
765
|
+
async function tryGenerateWithJsonFallback(agent, prompt, options) {
|
|
766
|
+
if (!options.structuredOutput?.schema) {
|
|
767
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
768
|
+
id: "STRUCTURED_OUTPUT_OPTIONS_REQUIRED",
|
|
769
|
+
domain: "AGENT" /* AGENT */,
|
|
770
|
+
category: "USER" /* USER */,
|
|
771
|
+
text: "structuredOutput is required to use tryGenerateWithJsonFallback"
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
try {
|
|
775
|
+
return await agent.generate(prompt, options);
|
|
776
|
+
} catch (error) {
|
|
777
|
+
console.warn("Error in tryGenerateWithJsonFallback. Attempting fallback.", error);
|
|
778
|
+
return await agent.generate(prompt, {
|
|
779
|
+
...options,
|
|
780
|
+
structuredOutput: { ...options.structuredOutput, jsonPromptInjection: true }
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
async function tryStreamWithJsonFallback(agent, prompt, options) {
|
|
785
|
+
if (!options.structuredOutput?.schema) {
|
|
786
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
787
|
+
id: "STRUCTURED_OUTPUT_OPTIONS_REQUIRED",
|
|
788
|
+
domain: "AGENT" /* AGENT */,
|
|
789
|
+
category: "USER" /* USER */,
|
|
790
|
+
text: "structuredOutput is required to use tryStreamWithJsonFallback"
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
try {
|
|
794
|
+
const result = await agent.stream(prompt, options);
|
|
795
|
+
const object = await result.object;
|
|
796
|
+
if (!object) {
|
|
797
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
798
|
+
id: "STRUCTURED_OUTPUT_OBJECT_UNDEFINED",
|
|
799
|
+
domain: "AGENT" /* AGENT */,
|
|
800
|
+
category: "USER" /* USER */,
|
|
801
|
+
text: "structuredOutput object is undefined"
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
return result;
|
|
805
|
+
} catch (error) {
|
|
806
|
+
console.warn("Error in tryStreamWithJsonFallback. Attempting fallback.", error);
|
|
807
|
+
return await agent.stream(prompt, {
|
|
808
|
+
...options,
|
|
809
|
+
structuredOutput: { ...options.structuredOutput, jsonPromptInjection: true }
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
function resolveThreadIdFromArgs(args) {
|
|
814
|
+
if (args?.memory?.thread) {
|
|
815
|
+
if (typeof args.memory.thread === "string") return { id: args.memory.thread };
|
|
816
|
+
if (typeof args.memory.thread === "object" && args.memory.thread.id)
|
|
817
|
+
return args.memory.thread;
|
|
818
|
+
}
|
|
819
|
+
if (args?.threadId) return { id: args.threadId };
|
|
820
|
+
return void 0;
|
|
821
|
+
}
|
|
822
|
+
|
|
759
823
|
// src/processors/runner.ts
|
|
760
824
|
var ProcessorState = class {
|
|
761
825
|
accumulatedText = "";
|
|
@@ -928,7 +992,7 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
928
992
|
retryCount
|
|
929
993
|
});
|
|
930
994
|
const mutations = messageList.stopRecording();
|
|
931
|
-
if (result instanceof
|
|
995
|
+
if (result instanceof chunk72E3YF6A_cjs.MessageList) {
|
|
932
996
|
if (result !== messageList) {
|
|
933
997
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
934
998
|
category: "USER",
|
|
@@ -1210,7 +1274,7 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1210
1274
|
retryCount
|
|
1211
1275
|
});
|
|
1212
1276
|
let mutations;
|
|
1213
|
-
if (result instanceof
|
|
1277
|
+
if (result instanceof chunk72E3YF6A_cjs.MessageList) {
|
|
1214
1278
|
if (result !== messageList) {
|
|
1215
1279
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
1216
1280
|
category: "USER",
|
|
@@ -1560,7 +1624,7 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1560
1624
|
retryCount
|
|
1561
1625
|
});
|
|
1562
1626
|
const mutations = messageList.stopRecording();
|
|
1563
|
-
if (result instanceof
|
|
1627
|
+
if (result instanceof chunk72E3YF6A_cjs.MessageList) {
|
|
1564
1628
|
if (result !== messageList) {
|
|
1565
1629
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
1566
1630
|
category: "USER",
|
|
@@ -1630,7 +1694,7 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1630
1694
|
processor,
|
|
1631
1695
|
stepNumber
|
|
1632
1696
|
}) {
|
|
1633
|
-
if (result instanceof
|
|
1697
|
+
if (result instanceof chunk72E3YF6A_cjs.MessageList) {
|
|
1634
1698
|
if (result !== messageList) {
|
|
1635
1699
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
1636
1700
|
category: "USER",
|
|
@@ -1665,13 +1729,14 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1665
1729
|
}
|
|
1666
1730
|
const { model: _model, ...rest } = result;
|
|
1667
1731
|
if (result.model) {
|
|
1668
|
-
const resolvedModel = await
|
|
1669
|
-
|
|
1732
|
+
const resolvedModel = await chunk53SZJCBX_cjs.resolveModelConfig(result.model);
|
|
1733
|
+
const isSupported = isSupportedLanguageModel(resolvedModel);
|
|
1734
|
+
if (!isSupported) {
|
|
1670
1735
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
1671
1736
|
category: "USER",
|
|
1672
1737
|
domain: "AGENT",
|
|
1673
|
-
id: "
|
|
1674
|
-
text: `Processor ${processor.id} returned
|
|
1738
|
+
id: "PROCESSOR_RETURNED_UNSUPPORTED_MODEL",
|
|
1739
|
+
text: `Processor ${processor.id} returned an unsupported model version ${resolvedModel.specificationVersion} in step ${stepNumber}. Only ${supportedLanguageModelSpecifications.join(", ")} models are supported in processInputStep.`
|
|
1675
1740
|
});
|
|
1676
1741
|
}
|
|
1677
1742
|
return {
|
|
@@ -1870,10 +1935,8 @@ function convertFullStreamChunkToMastra(value, ctx) {
|
|
|
1870
1935
|
reason: value.finishReason
|
|
1871
1936
|
},
|
|
1872
1937
|
output: {
|
|
1873
|
-
usage
|
|
1874
|
-
|
|
1875
|
-
totalTokens: value?.usage?.totalTokens ?? (value.usage?.inputTokens ?? 0) + (value.usage?.outputTokens ?? 0)
|
|
1876
|
-
}
|
|
1938
|
+
// Normalize usage to handle both V2 (flat) and V3 (nested) formats
|
|
1939
|
+
usage: normalizeUsage(value.usage)
|
|
1877
1940
|
},
|
|
1878
1941
|
metadata: {
|
|
1879
1942
|
providerMetadata: value.providerMetadata
|
|
@@ -1925,6 +1988,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
1925
1988
|
type: "finish",
|
|
1926
1989
|
// Cast needed: Mastra extends reason with 'tripwire' | 'retry' for processor scenarios
|
|
1927
1990
|
finishReason: chunk.payload.stepResult.reason,
|
|
1991
|
+
// Cast needed: Mastra's LanguageModelUsage has optional properties, V2 has required-but-nullable
|
|
1928
1992
|
totalUsage: chunk.payload.output.usage
|
|
1929
1993
|
};
|
|
1930
1994
|
}
|
|
@@ -1943,18 +2007,8 @@ function convertMastraChunkToAISDKv5({
|
|
|
1943
2007
|
};
|
|
1944
2008
|
case "reasoning-signature":
|
|
1945
2009
|
throw new Error('AISDKv5 chunk type "reasoning-signature" not supported');
|
|
1946
|
-
// return {
|
|
1947
|
-
// type: 'reasoning-signature' as const,
|
|
1948
|
-
// id: chunk.payload.id,
|
|
1949
|
-
// signature: chunk.payload.signature,
|
|
1950
|
-
// };
|
|
1951
2010
|
case "redacted-reasoning":
|
|
1952
2011
|
throw new Error('AISDKv5 chunk type "redacted-reasoning" not supported');
|
|
1953
|
-
// return {
|
|
1954
|
-
// type: 'redacted-reasoning',
|
|
1955
|
-
// id: chunk.payload.id,
|
|
1956
|
-
// data: chunk.payload.data,
|
|
1957
|
-
// };
|
|
1958
2012
|
case "reasoning-end":
|
|
1959
2013
|
return {
|
|
1960
2014
|
type: "reasoning-end",
|
|
@@ -1986,7 +2040,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
1986
2040
|
if (mode === "generate") {
|
|
1987
2041
|
return {
|
|
1988
2042
|
type: "file",
|
|
1989
|
-
file: new
|
|
2043
|
+
file: new chunk72E3YF6A_cjs.DefaultGeneratedFile({
|
|
1990
2044
|
data: chunk.payload.data,
|
|
1991
2045
|
mediaType: chunk.payload.mimeType
|
|
1992
2046
|
})
|
|
@@ -1994,7 +2048,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
1994
2048
|
}
|
|
1995
2049
|
return {
|
|
1996
2050
|
type: "file",
|
|
1997
|
-
file: new
|
|
2051
|
+
file: new chunk72E3YF6A_cjs.DefaultGeneratedFileWithType({
|
|
1998
2052
|
data: chunk.payload.data,
|
|
1999
2053
|
mediaType: chunk.payload.mimeType
|
|
2000
2054
|
})
|
|
@@ -2108,6 +2162,44 @@ function convertMastraChunkToAISDKv5({
|
|
|
2108
2162
|
return;
|
|
2109
2163
|
}
|
|
2110
2164
|
}
|
|
2165
|
+
function isV3Usage(usage) {
|
|
2166
|
+
if (!usage || typeof usage !== "object") return false;
|
|
2167
|
+
const u = usage;
|
|
2168
|
+
return typeof u.inputTokens === "object" && u.inputTokens !== null && "total" in u.inputTokens && typeof u.outputTokens === "object" && u.outputTokens !== null && "total" in u.outputTokens;
|
|
2169
|
+
}
|
|
2170
|
+
function normalizeUsage(usage) {
|
|
2171
|
+
if (!usage) {
|
|
2172
|
+
return {
|
|
2173
|
+
inputTokens: void 0,
|
|
2174
|
+
outputTokens: void 0,
|
|
2175
|
+
totalTokens: void 0,
|
|
2176
|
+
reasoningTokens: void 0,
|
|
2177
|
+
cachedInputTokens: void 0,
|
|
2178
|
+
raw: void 0
|
|
2179
|
+
};
|
|
2180
|
+
}
|
|
2181
|
+
if (isV3Usage(usage)) {
|
|
2182
|
+
const inputTokens = usage.inputTokens.total;
|
|
2183
|
+
const outputTokens = usage.outputTokens.total;
|
|
2184
|
+
return {
|
|
2185
|
+
inputTokens,
|
|
2186
|
+
outputTokens,
|
|
2187
|
+
totalTokens: (inputTokens ?? 0) + (outputTokens ?? 0),
|
|
2188
|
+
reasoningTokens: usage.outputTokens.reasoning,
|
|
2189
|
+
cachedInputTokens: usage.inputTokens.cacheRead,
|
|
2190
|
+
raw: usage
|
|
2191
|
+
};
|
|
2192
|
+
}
|
|
2193
|
+
const v2Usage = usage;
|
|
2194
|
+
return {
|
|
2195
|
+
inputTokens: v2Usage.inputTokens,
|
|
2196
|
+
outputTokens: v2Usage.outputTokens,
|
|
2197
|
+
totalTokens: v2Usage.totalTokens ?? (v2Usage.inputTokens ?? 0) + (v2Usage.outputTokens ?? 0),
|
|
2198
|
+
reasoningTokens: v2Usage.reasoningTokens,
|
|
2199
|
+
cachedInputTokens: v2Usage.cachedInputTokens,
|
|
2200
|
+
raw: usage
|
|
2201
|
+
};
|
|
2202
|
+
}
|
|
2111
2203
|
|
|
2112
2204
|
// src/stream/aisdk/v5/output.ts
|
|
2113
2205
|
var AISDKV5OutputStream = class {
|
|
@@ -3003,7 +3095,11 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3003
3095
|
#warnings = [];
|
|
3004
3096
|
#finishReason = void 0;
|
|
3005
3097
|
#request = {};
|
|
3006
|
-
#usageCount = {
|
|
3098
|
+
#usageCount = {
|
|
3099
|
+
inputTokens: void 0,
|
|
3100
|
+
outputTokens: void 0,
|
|
3101
|
+
totalTokens: void 0
|
|
3102
|
+
};
|
|
3007
3103
|
#tripwire = void 0;
|
|
3008
3104
|
#delayedPromises = {
|
|
3009
3105
|
suspendPayload: new DelayedPromise(),
|
|
@@ -3350,23 +3446,25 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3350
3446
|
};
|
|
3351
3447
|
self.#finishReason = "other";
|
|
3352
3448
|
self.#streamFinished = true;
|
|
3353
|
-
self
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3449
|
+
self.resolvePromises({
|
|
3450
|
+
text: self.#bufferedText.join(""),
|
|
3451
|
+
finishReason: "other",
|
|
3452
|
+
object: void 0,
|
|
3453
|
+
usage: self.#usageCount,
|
|
3454
|
+
warnings: self.#warnings,
|
|
3455
|
+
providerMetadata: void 0,
|
|
3456
|
+
response: {},
|
|
3457
|
+
request: {},
|
|
3458
|
+
reasoning: [],
|
|
3459
|
+
reasoningText: void 0,
|
|
3460
|
+
sources: [],
|
|
3461
|
+
files: [],
|
|
3462
|
+
toolCalls: [],
|
|
3463
|
+
toolResults: [],
|
|
3464
|
+
steps: self.#bufferedSteps,
|
|
3465
|
+
totalUsage: self.#usageCount,
|
|
3466
|
+
content: []
|
|
3467
|
+
});
|
|
3370
3468
|
self.#emitChunk(chunk);
|
|
3371
3469
|
controller.enqueue(chunk);
|
|
3372
3470
|
self.#emitter.emit("finish");
|
|
@@ -3430,12 +3528,14 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3430
3528
|
);
|
|
3431
3529
|
const responseMessages = self.messageList.get.response.aiV4.core();
|
|
3432
3530
|
const lastResponseMessage = responseMessages[responseMessages.length - 1];
|
|
3433
|
-
const outputText = lastResponseMessage ?
|
|
3531
|
+
const outputText = lastResponseMessage ? chunk72E3YF6A_cjs.MessageList.coreContentToString(lastResponseMessage.content) : "";
|
|
3434
3532
|
if (lastStep && outputText && outputText !== originalText) {
|
|
3435
3533
|
lastStep.text = outputText;
|
|
3436
3534
|
}
|
|
3437
|
-
|
|
3438
|
-
|
|
3535
|
+
this.resolvePromises({
|
|
3536
|
+
text: outputText || originalText,
|
|
3537
|
+
finishReason: self.#finishReason
|
|
3538
|
+
});
|
|
3439
3539
|
if (chunk.payload.metadata) {
|
|
3440
3540
|
const { providerMetadata, request, ...otherMetadata } = chunk.payload.metadata;
|
|
3441
3541
|
response = {
|
|
@@ -3445,9 +3545,10 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3445
3545
|
};
|
|
3446
3546
|
}
|
|
3447
3547
|
} else if (!self.#options.isLLMExecutionStep) {
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3548
|
+
this.resolvePromises({
|
|
3549
|
+
text: self.#bufferedText.join(""),
|
|
3550
|
+
finishReason: self.#finishReason
|
|
3551
|
+
});
|
|
3451
3552
|
}
|
|
3452
3553
|
} catch (error2) {
|
|
3453
3554
|
if (error2 instanceof TripWire) {
|
|
@@ -3457,35 +3558,41 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3457
3558
|
metadata: error2.options?.metadata,
|
|
3458
3559
|
processorId: error2.processorId
|
|
3459
3560
|
};
|
|
3460
|
-
self
|
|
3461
|
-
|
|
3561
|
+
self.resolvePromises({
|
|
3562
|
+
finishReason: "other",
|
|
3563
|
+
text: ""
|
|
3564
|
+
});
|
|
3462
3565
|
} else {
|
|
3463
3566
|
self.#error = chunkHWMMIRIF_cjs.getErrorFromUnknown(error2, {
|
|
3464
3567
|
fallbackMessage: "Unknown error in stream"
|
|
3465
3568
|
});
|
|
3466
|
-
self
|
|
3467
|
-
|
|
3569
|
+
self.resolvePromises({
|
|
3570
|
+
finishReason: "error",
|
|
3571
|
+
text: ""
|
|
3572
|
+
});
|
|
3468
3573
|
}
|
|
3469
3574
|
if (self.#delayedPromises.object.status.type !== "resolved") {
|
|
3470
3575
|
self.#delayedPromises.object.resolve(void 0);
|
|
3471
3576
|
}
|
|
3472
3577
|
}
|
|
3473
|
-
self.#delayedPromises.usage.resolve(self.#usageCount);
|
|
3474
|
-
self.#delayedPromises.warnings.resolve(self.#warnings);
|
|
3475
|
-
self.#delayedPromises.providerMetadata.resolve(chunk.payload.metadata?.providerMetadata);
|
|
3476
|
-
self.#delayedPromises.response.resolve(response);
|
|
3477
|
-
self.#delayedPromises.request.resolve(self.#request || {});
|
|
3478
3578
|
const reasoningText = self.#bufferedReasoning.length > 0 ? self.#bufferedReasoning.map((reasoningPart) => reasoningPart.payload.text).join("") : void 0;
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3579
|
+
this.resolvePromises({
|
|
3580
|
+
usage: self.#usageCount,
|
|
3581
|
+
warnings: self.#warnings,
|
|
3582
|
+
providerMetadata: chunk.payload.metadata?.providerMetadata,
|
|
3583
|
+
response,
|
|
3584
|
+
request: self.#request || {},
|
|
3585
|
+
reasoningText,
|
|
3586
|
+
reasoning: Object.values(self.#bufferedReasoningDetails || {}),
|
|
3587
|
+
sources: self.#bufferedSources,
|
|
3588
|
+
files: self.#bufferedFiles,
|
|
3589
|
+
toolCalls: self.#toolCalls,
|
|
3590
|
+
toolResults: self.#toolResults,
|
|
3591
|
+
steps: self.#bufferedSteps,
|
|
3592
|
+
totalUsage: self.#getTotalUsage(),
|
|
3593
|
+
content: messageList.get.response.aiV5.stepContent(),
|
|
3594
|
+
suspendPayload: void 0
|
|
3595
|
+
});
|
|
3489
3596
|
const baseFinishStep = self.#bufferedSteps[self.#bufferedSteps.length - 1];
|
|
3490
3597
|
if (baseFinishStep) {
|
|
3491
3598
|
const onFinishPayload = {
|
|
@@ -3553,6 +3660,28 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3553
3660
|
if (self.#delayedPromises.object.status.type === "pending") {
|
|
3554
3661
|
self.#delayedPromises.object.resolve(void 0);
|
|
3555
3662
|
}
|
|
3663
|
+
if (self.#status === "suspended") {
|
|
3664
|
+
const reasoningText = self.#bufferedReasoning.length > 0 ? self.#bufferedReasoning.map((reasoningPart) => reasoningPart.payload.text).join("") : void 0;
|
|
3665
|
+
self.resolvePromises({
|
|
3666
|
+
toolResults: self.#toolResults,
|
|
3667
|
+
toolCalls: self.#toolCalls,
|
|
3668
|
+
text: self.#bufferedText.join(""),
|
|
3669
|
+
reasoning: Object.values(self.#bufferedReasoningDetails || {}),
|
|
3670
|
+
reasoningText,
|
|
3671
|
+
sources: self.#bufferedSources,
|
|
3672
|
+
files: self.#bufferedFiles,
|
|
3673
|
+
steps: self.#bufferedSteps,
|
|
3674
|
+
usage: self.#usageCount,
|
|
3675
|
+
totalUsage: self.#getTotalUsage(),
|
|
3676
|
+
warnings: self.#warnings,
|
|
3677
|
+
finishReason: "other",
|
|
3678
|
+
content: self.messageList.get.response.aiV5.stepContent(),
|
|
3679
|
+
object: void 0,
|
|
3680
|
+
request: self.#request,
|
|
3681
|
+
response: {},
|
|
3682
|
+
providerMetadata: void 0
|
|
3683
|
+
});
|
|
3684
|
+
}
|
|
3556
3685
|
Object.entries(self.#delayedPromises).forEach(([key, promise]) => {
|
|
3557
3686
|
if (promise.status.type === "pending") {
|
|
3558
3687
|
promise.reject(new Error(`promise '${key}' was not resolved or rejected when stream finished`));
|
|
@@ -3576,6 +3705,23 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
3576
3705
|
this.deserializeState(initialState);
|
|
3577
3706
|
}
|
|
3578
3707
|
}
|
|
3708
|
+
resolvePromise(key, value) {
|
|
3709
|
+
if (!(key in this.#delayedPromises)) {
|
|
3710
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
3711
|
+
id: "MASTRA_MODEL_OUTPUT_INVALID_PROMISE_KEY",
|
|
3712
|
+
domain: "LLM" /* LLM */,
|
|
3713
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
3714
|
+
text: `Attempted to resolve invalid promise key '${key}' with value '${typeof value === "object" ? JSON.stringify(value, null, 2) : value}'`
|
|
3715
|
+
});
|
|
3716
|
+
}
|
|
3717
|
+
this.#delayedPromises[key].resolve(value);
|
|
3718
|
+
}
|
|
3719
|
+
resolvePromises(data) {
|
|
3720
|
+
for (const keyString in data) {
|
|
3721
|
+
const key = keyString;
|
|
3722
|
+
this.resolvePromise(key, data[key]);
|
|
3723
|
+
}
|
|
3724
|
+
}
|
|
3579
3725
|
#getDelayedPromise(promise) {
|
|
3580
3726
|
if (!this.#consumptionStarted) {
|
|
3581
3727
|
void this.consumeStream();
|
|
@@ -4548,7 +4694,7 @@ var getModelOutputForTripwire = async ({
|
|
|
4548
4694
|
model: {
|
|
4549
4695
|
modelId: model.modelId,
|
|
4550
4696
|
provider: model.provider,
|
|
4551
|
-
version: model.specificationVersion
|
|
4697
|
+
version: model.specificationVersion
|
|
4552
4698
|
},
|
|
4553
4699
|
stream: tripwireStream,
|
|
4554
4700
|
messageList,
|
|
@@ -4619,11 +4765,6 @@ function runScorer({
|
|
|
4619
4765
|
};
|
|
4620
4766
|
chunkMR7ZWBL6_cjs.executeHook("onScorerRun" /* ON_SCORER_RUN */, payload);
|
|
4621
4767
|
}
|
|
4622
|
-
|
|
4623
|
-
// src/llm/model/is-v2-model.ts
|
|
4624
|
-
function isV2Model(model) {
|
|
4625
|
-
return model.specificationVersion === "v2";
|
|
4626
|
-
}
|
|
4627
4768
|
var EventEmitterPubSub = class extends chunk4D4KB75Y_cjs.PubSub {
|
|
4628
4769
|
emitter;
|
|
4629
4770
|
constructor(existingEmitter) {
|
|
@@ -5161,7 +5302,7 @@ var createTimeTravelExecutionParams = (params) => {
|
|
|
5161
5302
|
result = void 0;
|
|
5162
5303
|
}
|
|
5163
5304
|
if (result) {
|
|
5164
|
-
const formattedResult =
|
|
5305
|
+
const formattedResult = chunkO3ULBGV6_cjs.removeUndefinedValues(result);
|
|
5165
5306
|
stepResults[stepId] = formattedResult;
|
|
5166
5307
|
}
|
|
5167
5308
|
});
|
|
@@ -5612,7 +5753,7 @@ async function executeLoop(engine, params) {
|
|
|
5612
5753
|
const evalSpan = loopSpan?.createChildSpan({
|
|
5613
5754
|
type: "workflow_conditional_eval" /* WORKFLOW_CONDITIONAL_EVAL */,
|
|
5614
5755
|
name: `condition: '${entry.loopType}'`,
|
|
5615
|
-
input:
|
|
5756
|
+
input: chunkO3ULBGV6_cjs.selectFields(result.output, ["stepResult", "output.text", "output.object", "messages"]),
|
|
5616
5757
|
attributes: {
|
|
5617
5758
|
conditionIndex: iteration
|
|
5618
5759
|
},
|
|
@@ -7647,7 +7788,7 @@ function createStep(params, agentOptions) {
|
|
|
7647
7788
|
phase,
|
|
7648
7789
|
// Auto-create MessageList from messages if not provided
|
|
7649
7790
|
// This enables running processor workflows from the UI where messageList can't be serialized
|
|
7650
|
-
messageList: messageList ?? (Array.isArray(messages) ? new
|
|
7791
|
+
messageList: messageList ?? (Array.isArray(messages) ? new chunk72E3YF6A_cjs.MessageList().add(messages, "input").addSystem(systemMessages ?? []) : void 0),
|
|
7651
7792
|
stepNumber,
|
|
7652
7793
|
systemMessages,
|
|
7653
7794
|
streamParts,
|
|
@@ -7700,7 +7841,7 @@ function createStep(params, agentOptions) {
|
|
|
7700
7841
|
}
|
|
7701
7842
|
}
|
|
7702
7843
|
};
|
|
7703
|
-
if (result instanceof
|
|
7844
|
+
if (result instanceof chunk72E3YF6A_cjs.MessageList) {
|
|
7704
7845
|
if (result !== passThrough.messageList) {
|
|
7705
7846
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
7706
7847
|
category: "USER" /* USER */,
|
|
@@ -7825,7 +7966,7 @@ function createStep(params, agentOptions) {
|
|
|
7825
7966
|
}
|
|
7826
7967
|
}
|
|
7827
7968
|
};
|
|
7828
|
-
if (result instanceof
|
|
7969
|
+
if (result instanceof chunk72E3YF6A_cjs.MessageList) {
|
|
7829
7970
|
if (result !== passThrough.messageList) {
|
|
7830
7971
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
7831
7972
|
category: "USER" /* USER */,
|
|
@@ -7893,7 +8034,7 @@ function createStep(params, agentOptions) {
|
|
|
7893
8034
|
}
|
|
7894
8035
|
}
|
|
7895
8036
|
};
|
|
7896
|
-
if (result instanceof
|
|
8037
|
+
if (result instanceof chunk72E3YF6A_cjs.MessageList) {
|
|
7897
8038
|
if (result !== passThrough.messageList) {
|
|
7898
8039
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
7899
8040
|
category: "USER" /* USER */,
|
|
@@ -8410,7 +8551,9 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8410
8551
|
workflowStatus: run.workflowRunStatus,
|
|
8411
8552
|
stepResults: {}
|
|
8412
8553
|
});
|
|
8413
|
-
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse,
|
|
8554
|
+
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse, {
|
|
8555
|
+
withNestedWorkflows: false
|
|
8556
|
+
});
|
|
8414
8557
|
if (workflowSnapshotInStorage && workflowSnapshotInStorage.status) {
|
|
8415
8558
|
run.workflowRunStatus = workflowSnapshotInStorage.status;
|
|
8416
8559
|
}
|
|
@@ -8675,7 +8818,8 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8675
8818
|
}
|
|
8676
8819
|
return finalSteps;
|
|
8677
8820
|
}
|
|
8678
|
-
async getWorkflowRunExecutionResult(runId,
|
|
8821
|
+
async getWorkflowRunExecutionResult(runId, options = {}) {
|
|
8822
|
+
const { withNestedWorkflows = true, fields } = options;
|
|
8679
8823
|
const storage = this.#mastra?.getStorage();
|
|
8680
8824
|
if (!storage) {
|
|
8681
8825
|
this.logger.debug("Cannot get workflow run execution result. Mastra storage is not initialized");
|
|
@@ -8694,15 +8838,51 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8694
8838
|
return null;
|
|
8695
8839
|
}
|
|
8696
8840
|
}
|
|
8697
|
-
const
|
|
8841
|
+
const snapshotState = snapshot;
|
|
8842
|
+
const defaultResult = {
|
|
8843
|
+
status: snapshotState.status,
|
|
8844
|
+
result: snapshotState.result,
|
|
8845
|
+
error: snapshotState.error,
|
|
8846
|
+
payload: snapshotState.context?.input,
|
|
8847
|
+
steps: null,
|
|
8848
|
+
// Will be populated below
|
|
8849
|
+
activeStepsPath: snapshotState.activeStepsPath,
|
|
8850
|
+
serializedStepGraph: snapshotState.serializedStepGraph
|
|
8851
|
+
};
|
|
8852
|
+
const allowedFields = new Set(Object.keys(defaultResult));
|
|
8853
|
+
if (fields && fields.length > 0) {
|
|
8854
|
+
const result = {};
|
|
8855
|
+
for (const field of fields) {
|
|
8856
|
+
if (!allowedFields.has(field)) {
|
|
8857
|
+
continue;
|
|
8858
|
+
}
|
|
8859
|
+
if (field === "steps") {
|
|
8860
|
+
let fullSteps2;
|
|
8861
|
+
if (withNestedWorkflows) {
|
|
8862
|
+
fullSteps2 = await this.getWorkflowRunSteps({ runId, workflowId: this.id });
|
|
8863
|
+
} else {
|
|
8864
|
+
const { input, ...stepsOnly } = snapshotState.context || {};
|
|
8865
|
+
fullSteps2 = stepsOnly;
|
|
8866
|
+
}
|
|
8867
|
+
result.steps = fullSteps2;
|
|
8868
|
+
} else if (field === "payload") {
|
|
8869
|
+
result.payload = snapshotState.context?.input;
|
|
8870
|
+
} else {
|
|
8871
|
+
result[field] = snapshotState[field];
|
|
8872
|
+
}
|
|
8873
|
+
}
|
|
8874
|
+
return result;
|
|
8875
|
+
}
|
|
8876
|
+
let fullSteps;
|
|
8877
|
+
if (withNestedWorkflows) {
|
|
8878
|
+
fullSteps = await this.getWorkflowRunSteps({ runId, workflowId: this.id });
|
|
8879
|
+
} else {
|
|
8880
|
+
const { input, ...stepsOnly } = snapshotState.context || {};
|
|
8881
|
+
fullSteps = stepsOnly;
|
|
8882
|
+
}
|
|
8698
8883
|
return {
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
error: snapshot.error,
|
|
8702
|
-
payload: snapshot.context?.input,
|
|
8703
|
-
steps: fullSteps,
|
|
8704
|
-
activeStepsPath: snapshot.activeStepsPath,
|
|
8705
|
-
serializedStepGraph: snapshot.serializedStepGraph
|
|
8884
|
+
...defaultResult,
|
|
8885
|
+
steps: fullSteps
|
|
8706
8886
|
};
|
|
8707
8887
|
}
|
|
8708
8888
|
};
|
|
@@ -9943,13 +10123,13 @@ function execute({
|
|
|
9943
10123
|
const responseFormat = structuredOutput?.schema ? getResponseFormat(structuredOutput?.schema) : void 0;
|
|
9944
10124
|
let prompt = inputMessages;
|
|
9945
10125
|
if (structuredOutputMode === "direct" && responseFormat?.type === "json" && structuredOutput?.jsonPromptInjection) {
|
|
9946
|
-
prompt =
|
|
10126
|
+
prompt = providerUtilsV5.injectJsonInstructionIntoMessages({
|
|
9947
10127
|
messages: inputMessages,
|
|
9948
10128
|
schema: responseFormat.schema
|
|
9949
10129
|
});
|
|
9950
10130
|
}
|
|
9951
10131
|
if (structuredOutputMode === "processor" && responseFormat?.type === "json" && responseFormat?.schema) {
|
|
9952
|
-
prompt =
|
|
10132
|
+
prompt = providerUtilsV5.injectJsonInstructionIntoMessages({
|
|
9953
10133
|
messages: inputMessages,
|
|
9954
10134
|
schema: responseFormat.schema,
|
|
9955
10135
|
schemaPrefix: `Your response will be processed by another agent to extract structured data. Please ensure your response contains comprehensive information for all the following fields that will be extracted:
|
|
@@ -10390,7 +10570,7 @@ async function processOutputStream({
|
|
|
10390
10570
|
});
|
|
10391
10571
|
break;
|
|
10392
10572
|
case "error":
|
|
10393
|
-
if (
|
|
10573
|
+
if (providerUtilsV5.isAbortError(chunk.payload.error) && options?.abortSignal?.aborted) {
|
|
10394
10574
|
break;
|
|
10395
10575
|
}
|
|
10396
10576
|
runState.setState({
|
|
@@ -10447,7 +10627,7 @@ function executeStreamWithFallbackModels(models) {
|
|
|
10447
10627
|
while (attempt <= maxRetries) {
|
|
10448
10628
|
try {
|
|
10449
10629
|
const isLastModel = attempt === maxRetries && index === models.length;
|
|
10450
|
-
const result = await callback(modelConfig
|
|
10630
|
+
const result = await callback(modelConfig, isLastModel);
|
|
10451
10631
|
finalResult = result;
|
|
10452
10632
|
done = true;
|
|
10453
10633
|
break;
|
|
@@ -10489,7 +10669,6 @@ function createLLMExecutionStep({
|
|
|
10489
10669
|
inputProcessors,
|
|
10490
10670
|
logger,
|
|
10491
10671
|
agentId,
|
|
10492
|
-
headers,
|
|
10493
10672
|
downloadRetries,
|
|
10494
10673
|
downloadConcurrency,
|
|
10495
10674
|
processorStates,
|
|
@@ -10509,7 +10688,9 @@ function createLLMExecutionStep({
|
|
|
10509
10688
|
let warnings;
|
|
10510
10689
|
let request;
|
|
10511
10690
|
let rawResponse;
|
|
10512
|
-
const { outputStream, callBail, runState, stepTools } = await executeStreamWithFallbackModels(models)(async (
|
|
10691
|
+
const { outputStream, callBail, runState, stepTools } = await executeStreamWithFallbackModels(models)(async (modelConfig, isLastModel) => {
|
|
10692
|
+
const model = modelConfig.model;
|
|
10693
|
+
const modelHeaders = modelConfig.headers;
|
|
10513
10694
|
if (initialSystemMessages) {
|
|
10514
10695
|
messageList.replaceAllSystemMessages(initialSystemMessages);
|
|
10515
10696
|
}
|
|
@@ -10594,55 +10775,55 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
|
|
|
10594
10775
|
}
|
|
10595
10776
|
}
|
|
10596
10777
|
}
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10778
|
+
if (isSupportedLanguageModel(currentStep.model)) {
|
|
10779
|
+
modelResult = chunk72YCRTEX_cjs.executeWithContextSync({
|
|
10780
|
+
span: modelSpanTracker?.getTracingContext()?.currentSpan,
|
|
10781
|
+
fn: () => execute({
|
|
10782
|
+
runId,
|
|
10783
|
+
model: currentStep.model,
|
|
10784
|
+
providerOptions: currentStep.providerOptions,
|
|
10785
|
+
inputMessages,
|
|
10786
|
+
tools: currentStep.tools,
|
|
10787
|
+
toolChoice: currentStep.toolChoice,
|
|
10788
|
+
activeTools: currentStep.activeTools,
|
|
10789
|
+
options,
|
|
10790
|
+
modelSettings: currentStep.modelSettings,
|
|
10791
|
+
includeRawChunks,
|
|
10792
|
+
structuredOutput: currentStep.structuredOutput,
|
|
10793
|
+
// Merge headers: modelConfig headers first, then modelSettings overrides them
|
|
10794
|
+
// Only create object if there are actual headers to avoid passing empty {}
|
|
10795
|
+
headers: modelHeaders || currentStep.modelSettings?.headers ? { ...modelHeaders, ...currentStep.modelSettings?.headers } : void 0,
|
|
10796
|
+
methodType,
|
|
10797
|
+
generateId: _internal?.generateId,
|
|
10798
|
+
onResult: ({
|
|
10799
|
+
warnings: warningsFromStream,
|
|
10800
|
+
request: requestFromStream,
|
|
10801
|
+
rawResponse: rawResponseFromStream
|
|
10802
|
+
}) => {
|
|
10803
|
+
warnings = warningsFromStream;
|
|
10804
|
+
request = requestFromStream || {};
|
|
10805
|
+
rawResponse = rawResponseFromStream;
|
|
10806
|
+
if (!isControllerOpen(controller)) {
|
|
10807
|
+
return;
|
|
10808
|
+
}
|
|
10809
|
+
controller.enqueue({
|
|
10810
|
+
runId,
|
|
10811
|
+
from: "AGENT" /* AGENT */,
|
|
10812
|
+
type: "step-start",
|
|
10813
|
+
payload: {
|
|
10814
|
+
request: request || {},
|
|
10815
|
+
warnings: warnings || [],
|
|
10816
|
+
messageId
|
|
10626
10817
|
}
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
});
|
|
10637
|
-
},
|
|
10638
|
-
shouldThrowError: !isLastModel
|
|
10639
|
-
})
|
|
10640
|
-
});
|
|
10641
|
-
break;
|
|
10642
|
-
}
|
|
10643
|
-
default: {
|
|
10644
|
-
throw new Error(`Unsupported model version: ${model.specificationVersion}`);
|
|
10645
|
-
}
|
|
10818
|
+
});
|
|
10819
|
+
},
|
|
10820
|
+
shouldThrowError: !isLastModel
|
|
10821
|
+
})
|
|
10822
|
+
});
|
|
10823
|
+
} else {
|
|
10824
|
+
throw new Error(
|
|
10825
|
+
`Unsupported model version: ${currentStep.model.specificationVersion}. Supported versions: ${supportedLanguageModelSpecifications.join(", ")}`
|
|
10826
|
+
);
|
|
10646
10827
|
}
|
|
10647
10828
|
const outputStream2 = new MastraModelOutput({
|
|
10648
10829
|
model: {
|
|
@@ -10683,7 +10864,7 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
|
|
|
10683
10864
|
});
|
|
10684
10865
|
} catch (error) {
|
|
10685
10866
|
console.error("Error in LLM Execution Step", error);
|
|
10686
|
-
if (
|
|
10867
|
+
if (providerUtilsV5.isAbortError(error) && options?.abortSignal?.aborted) {
|
|
10687
10868
|
await options?.onAbort?.({
|
|
10688
10869
|
steps: inputData?.output?.steps ?? []
|
|
10689
10870
|
});
|
|
@@ -12006,7 +12187,7 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
12006
12187
|
const remainingTokens = parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"] ?? "", 10);
|
|
12007
12188
|
if (!isNaN(remainingTokens) && remainingTokens > 0 && remainingTokens < 2e3) {
|
|
12008
12189
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
12009
|
-
await
|
|
12190
|
+
await chunkO3ULBGV6_cjs.delay(10 * 1e3);
|
|
12010
12191
|
}
|
|
12011
12192
|
},
|
|
12012
12193
|
onFinish: async (props) => {
|
|
@@ -12216,7 +12397,7 @@ async function prepareMemoryStep({
|
|
|
12216
12397
|
);
|
|
12217
12398
|
}
|
|
12218
12399
|
} else {
|
|
12219
|
-
const messageList = new
|
|
12400
|
+
const messageList = new chunk72E3YF6A_cjs.MessageList({
|
|
12220
12401
|
threadId: thread?.id,
|
|
12221
12402
|
resourceId: thread?.resourceId
|
|
12222
12403
|
});
|
|
@@ -13186,67 +13367,6 @@ async function networkLoop({
|
|
|
13186
13367
|
|
|
13187
13368
|
// src/agent/agent-legacy.ts
|
|
13188
13369
|
var import_fast_deep_equal = chunk6SZKM6EC_cjs.__toESM(require_fast_deep_equal(), 1);
|
|
13189
|
-
|
|
13190
|
-
// src/agent/utils.ts
|
|
13191
|
-
async function tryGenerateWithJsonFallback(agent, prompt, options) {
|
|
13192
|
-
if (!options.structuredOutput?.schema) {
|
|
13193
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
13194
|
-
id: "STRUCTURED_OUTPUT_OPTIONS_REQUIRED",
|
|
13195
|
-
domain: "AGENT" /* AGENT */,
|
|
13196
|
-
category: "USER" /* USER */,
|
|
13197
|
-
text: "structuredOutput is required to use tryGenerateWithJsonFallback"
|
|
13198
|
-
});
|
|
13199
|
-
}
|
|
13200
|
-
try {
|
|
13201
|
-
return await agent.generate(prompt, options);
|
|
13202
|
-
} catch (error) {
|
|
13203
|
-
console.warn("Error in tryGenerateWithJsonFallback. Attempting fallback.", error);
|
|
13204
|
-
return await agent.generate(prompt, {
|
|
13205
|
-
...options,
|
|
13206
|
-
structuredOutput: { ...options.structuredOutput, jsonPromptInjection: true }
|
|
13207
|
-
});
|
|
13208
|
-
}
|
|
13209
|
-
}
|
|
13210
|
-
async function tryStreamWithJsonFallback(agent, prompt, options) {
|
|
13211
|
-
if (!options.structuredOutput?.schema) {
|
|
13212
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
13213
|
-
id: "STRUCTURED_OUTPUT_OPTIONS_REQUIRED",
|
|
13214
|
-
domain: "AGENT" /* AGENT */,
|
|
13215
|
-
category: "USER" /* USER */,
|
|
13216
|
-
text: "structuredOutput is required to use tryStreamWithJsonFallback"
|
|
13217
|
-
});
|
|
13218
|
-
}
|
|
13219
|
-
try {
|
|
13220
|
-
const result = await agent.stream(prompt, options);
|
|
13221
|
-
const object = await result.object;
|
|
13222
|
-
if (!object) {
|
|
13223
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
13224
|
-
id: "STRUCTURED_OUTPUT_OBJECT_UNDEFINED",
|
|
13225
|
-
domain: "AGENT" /* AGENT */,
|
|
13226
|
-
category: "USER" /* USER */,
|
|
13227
|
-
text: "structuredOutput object is undefined"
|
|
13228
|
-
});
|
|
13229
|
-
}
|
|
13230
|
-
return result;
|
|
13231
|
-
} catch (error) {
|
|
13232
|
-
console.warn("Error in tryStreamWithJsonFallback. Attempting fallback.", error);
|
|
13233
|
-
return await agent.stream(prompt, {
|
|
13234
|
-
...options,
|
|
13235
|
-
structuredOutput: { ...options.structuredOutput, jsonPromptInjection: true }
|
|
13236
|
-
});
|
|
13237
|
-
}
|
|
13238
|
-
}
|
|
13239
|
-
function resolveThreadIdFromArgs(args) {
|
|
13240
|
-
if (args?.memory?.thread) {
|
|
13241
|
-
if (typeof args.memory.thread === "string") return { id: args.memory.thread };
|
|
13242
|
-
if (typeof args.memory.thread === "object" && args.memory.thread.id)
|
|
13243
|
-
return args.memory.thread;
|
|
13244
|
-
}
|
|
13245
|
-
if (args?.threadId) return { id: args.threadId };
|
|
13246
|
-
return void 0;
|
|
13247
|
-
}
|
|
13248
|
-
|
|
13249
|
-
// src/agent/agent-legacy.ts
|
|
13250
13370
|
var AgentLegacyHandler = class {
|
|
13251
13371
|
constructor(capabilities) {
|
|
13252
13372
|
this.capabilities = capabilities;
|
|
@@ -13331,7 +13451,7 @@ var AgentLegacyHandler = class {
|
|
|
13331
13451
|
methodType: methodType === "generate" ? "generateLegacy" : "streamLegacy",
|
|
13332
13452
|
memoryConfig
|
|
13333
13453
|
});
|
|
13334
|
-
let messageList = new
|
|
13454
|
+
let messageList = new chunk72E3YF6A_cjs.MessageList({
|
|
13335
13455
|
threadId,
|
|
13336
13456
|
resourceId,
|
|
13337
13457
|
generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
|
|
@@ -13462,7 +13582,7 @@ var AgentLegacyHandler = class {
|
|
|
13462
13582
|
result: resToLog,
|
|
13463
13583
|
threadId
|
|
13464
13584
|
});
|
|
13465
|
-
const messageListResponses = new
|
|
13585
|
+
const messageListResponses = new chunk72E3YF6A_cjs.MessageList({
|
|
13466
13586
|
threadId,
|
|
13467
13587
|
resourceId,
|
|
13468
13588
|
generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
|
|
@@ -14326,6 +14446,14 @@ function createMapResultsStep({
|
|
|
14326
14446
|
};
|
|
14327
14447
|
if (result.tripwire) {
|
|
14328
14448
|
const agentModel = await capabilities.getModel({ requestContext: result.requestContext });
|
|
14449
|
+
if (!isSupportedLanguageModel(agentModel)) {
|
|
14450
|
+
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
14451
|
+
id: "MAP_RESULTS_STEP_UNSUPPORTED_MODEL",
|
|
14452
|
+
domain: "AGENT" /* AGENT */,
|
|
14453
|
+
category: "USER" /* USER */,
|
|
14454
|
+
text: "Tripwire handling requires a v2/v3 model"
|
|
14455
|
+
});
|
|
14456
|
+
}
|
|
14329
14457
|
const modelOutput = await getModelOutputForTripwire({
|
|
14330
14458
|
tripwire: memoryData.tripwire,
|
|
14331
14459
|
runId,
|
|
@@ -14455,7 +14583,7 @@ var prepareToolsStepOutputSchema = z8.z.object({
|
|
|
14455
14583
|
var prepareMemoryStepOutputSchema = z8.z.object({
|
|
14456
14584
|
threadExists: z8.z.boolean(),
|
|
14457
14585
|
thread: storageThreadSchema.optional(),
|
|
14458
|
-
messageList: z8.z.instanceof(
|
|
14586
|
+
messageList: z8.z.instanceof(chunk72E3YF6A_cjs.MessageList),
|
|
14459
14587
|
/** Tripwire data when input processor triggered abort */
|
|
14460
14588
|
tripwire: z8.z.object({
|
|
14461
14589
|
reason: z8.z.string(),
|
|
@@ -14493,7 +14621,7 @@ function createPrepareMemoryStep({
|
|
|
14493
14621
|
outputSchema: prepareMemoryStepOutputSchema,
|
|
14494
14622
|
execute: async ({ tracingContext }) => {
|
|
14495
14623
|
const thread = threadFromArgs;
|
|
14496
|
-
const messageList = new
|
|
14624
|
+
const messageList = new chunk72E3YF6A_cjs.MessageList({
|
|
14497
14625
|
threadId: thread?.id,
|
|
14498
14626
|
resourceId,
|
|
14499
14627
|
generateMessageId: capabilities.generateMessageId,
|
|
@@ -14910,7 +15038,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
14910
15038
|
this.#voice?.addInstructions(config.instructions);
|
|
14911
15039
|
}
|
|
14912
15040
|
} else {
|
|
14913
|
-
this.#voice = new
|
|
15041
|
+
this.#voice = new chunkOOUFPYSX_cjs.DefaultVoice();
|
|
14914
15042
|
}
|
|
14915
15043
|
if (config.inputProcessors) {
|
|
14916
15044
|
this.#inputProcessors = config.inputProcessors;
|
|
@@ -14967,7 +15095,6 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
14967
15095
|
}) {
|
|
14968
15096
|
const inputProcessors = inputProcessorOverrides ?? await this.listResolvedInputProcessors(requestContext);
|
|
14969
15097
|
const outputProcessors = outputProcessorOverrides ?? await this.listResolvedOutputProcessors(requestContext);
|
|
14970
|
-
this.logger.debug("outputProcessors", outputProcessors);
|
|
14971
15098
|
return new ProcessorRunner({
|
|
14972
15099
|
inputProcessors,
|
|
14973
15100
|
outputProcessors,
|
|
@@ -15226,7 +15353,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15226
15353
|
voice?.addInstructions(this.#convertInstructionsToString(instructions));
|
|
15227
15354
|
return voice;
|
|
15228
15355
|
} else {
|
|
15229
|
-
return new
|
|
15356
|
+
return new chunkOOUFPYSX_cjs.DefaultVoice();
|
|
15230
15357
|
}
|
|
15231
15358
|
}
|
|
15232
15359
|
/**
|
|
@@ -15447,7 +15574,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15447
15574
|
*/
|
|
15448
15575
|
listTools({ requestContext = new chunkUVHSM2GU_cjs.RequestContext() } = {}) {
|
|
15449
15576
|
if (typeof this.#tools !== "function") {
|
|
15450
|
-
return
|
|
15577
|
+
return chunkO3ULBGV6_cjs.ensureToolProperties(this.#tools);
|
|
15451
15578
|
}
|
|
15452
15579
|
const result = this.#tools({ requestContext, mastra: this.#mastra });
|
|
15453
15580
|
return resolveMaybePromise(result, (tools) => {
|
|
@@ -15465,7 +15592,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15465
15592
|
this.logger.error(mastraError.toString());
|
|
15466
15593
|
throw mastraError;
|
|
15467
15594
|
}
|
|
15468
|
-
return
|
|
15595
|
+
return chunkO3ULBGV6_cjs.ensureToolProperties(tools);
|
|
15469
15596
|
});
|
|
15470
15597
|
}
|
|
15471
15598
|
/**
|
|
@@ -15486,7 +15613,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15486
15613
|
const modelToUse = this.getModel({ modelConfig: model, requestContext });
|
|
15487
15614
|
return resolveMaybePromise(modelToUse, (resolvedModel) => {
|
|
15488
15615
|
let llm;
|
|
15489
|
-
if (resolvedModel
|
|
15616
|
+
if (isSupportedLanguageModel(resolvedModel)) {
|
|
15490
15617
|
const modelsPromise = Array.isArray(this.model) && !model ? this.prepareModels(requestContext) : this.prepareModels(requestContext, resolvedModel);
|
|
15491
15618
|
llm = modelsPromise.then((models) => {
|
|
15492
15619
|
const enabledModels = models.filter((model2) => model2.enabled);
|
|
@@ -15497,7 +15624,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15497
15624
|
});
|
|
15498
15625
|
});
|
|
15499
15626
|
} else {
|
|
15500
|
-
llm = new
|
|
15627
|
+
llm = new chunkTRUNX3AX_cjs.MastraLLMV1({
|
|
15501
15628
|
model: resolvedModel,
|
|
15502
15629
|
mastra: this.#mastra,
|
|
15503
15630
|
options: { tracingPolicy: this.#options?.tracingPolicy }
|
|
@@ -15522,7 +15649,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15522
15649
|
*/
|
|
15523
15650
|
async resolveModelConfig(modelConfig, requestContext) {
|
|
15524
15651
|
try {
|
|
15525
|
-
return await
|
|
15652
|
+
return await chunk53SZJCBX_cjs.resolveModelConfig(modelConfig, requestContext, this.#mastra);
|
|
15526
15653
|
} catch (error) {
|
|
15527
15654
|
const mastraError = new chunkHWMMIRIF_cjs.MastraError({
|
|
15528
15655
|
id: "AGENT_GET_MODEL_MISSING_MODEL_INSTANCE",
|
|
@@ -15728,7 +15855,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15728
15855
|
instructions
|
|
15729
15856
|
}) {
|
|
15730
15857
|
const llm = await this.getLLM({ requestContext, model });
|
|
15731
|
-
const normMessage = new
|
|
15858
|
+
const normMessage = new chunk72E3YF6A_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
|
|
15732
15859
|
if (!normMessage) {
|
|
15733
15860
|
throw new Error(`Could not generate title from input ${JSON.stringify(message)}`);
|
|
15734
15861
|
}
|
|
@@ -15750,8 +15877,8 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15750
15877
|
}
|
|
15751
15878
|
const systemInstructions = await this.resolveTitleInstructions(requestContext, instructions);
|
|
15752
15879
|
let text = "";
|
|
15753
|
-
if (llm.getModel()
|
|
15754
|
-
const messageList = new
|
|
15880
|
+
if (isSupportedLanguageModel(llm.getModel())) {
|
|
15881
|
+
const messageList = new chunk72E3YF6A_cjs.MessageList().add(
|
|
15755
15882
|
[
|
|
15756
15883
|
{
|
|
15757
15884
|
role: "system",
|
|
@@ -15804,7 +15931,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15804
15931
|
async genTitle(userMessage, requestContext, tracingContext, model, instructions) {
|
|
15805
15932
|
try {
|
|
15806
15933
|
if (userMessage) {
|
|
15807
|
-
const normMessage = new
|
|
15934
|
+
const normMessage = new chunk72E3YF6A_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
|
|
15808
15935
|
if (normMessage) {
|
|
15809
15936
|
return await this.generateTitleFromUserMessage({
|
|
15810
15937
|
message: normMessage,
|
|
@@ -15869,7 +15996,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15869
15996
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
15870
15997
|
requireApproval: toolObj.requireApproval
|
|
15871
15998
|
};
|
|
15872
|
-
const convertedToCoreTool =
|
|
15999
|
+
const convertedToCoreTool = chunkO3ULBGV6_cjs.makeCoreTool(toolObj, options, void 0, autoResumeSuspendedTools);
|
|
15873
16000
|
convertedMemoryTools[toolName] = convertedToCoreTool;
|
|
15874
16001
|
}
|
|
15875
16002
|
}
|
|
@@ -16024,7 +16151,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16024
16151
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
16025
16152
|
requireApproval: tool2.requireApproval
|
|
16026
16153
|
};
|
|
16027
|
-
return [k,
|
|
16154
|
+
return [k, chunkO3ULBGV6_cjs.makeCoreTool(tool2, options, void 0, autoResumeSuspendedTools)];
|
|
16028
16155
|
})
|
|
16029
16156
|
);
|
|
16030
16157
|
const assignedToolEntriesConverted = Object.fromEntries(
|
|
@@ -16074,7 +16201,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16074
16201
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
16075
16202
|
requireApproval: toolObj.requireApproval
|
|
16076
16203
|
};
|
|
16077
|
-
const convertedToCoreTool =
|
|
16204
|
+
const convertedToCoreTool = chunkO3ULBGV6_cjs.makeCoreTool(toolObj, options, "toolset", autoResumeSuspendedTools);
|
|
16078
16205
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
16079
16206
|
}
|
|
16080
16207
|
}
|
|
@@ -16119,7 +16246,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16119
16246
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
16120
16247
|
requireApproval: tool2.requireApproval
|
|
16121
16248
|
};
|
|
16122
|
-
const convertedToCoreTool =
|
|
16249
|
+
const convertedToCoreTool = chunkO3ULBGV6_cjs.makeCoreTool(rest, options, "client-tool", autoResumeSuspendedTools);
|
|
16123
16250
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
16124
16251
|
}
|
|
16125
16252
|
}
|
|
@@ -16289,7 +16416,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16289
16416
|
tracingContext,
|
|
16290
16417
|
tracingPolicy: this.#options?.tracingPolicy
|
|
16291
16418
|
};
|
|
16292
|
-
convertedAgentTools[`agent-${agentName}`] =
|
|
16419
|
+
convertedAgentTools[`agent-${agentName}`] = chunkO3ULBGV6_cjs.makeCoreTool(
|
|
16293
16420
|
toolObj,
|
|
16294
16421
|
options,
|
|
16295
16422
|
void 0,
|
|
@@ -16468,7 +16595,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16468
16595
|
tracingContext,
|
|
16469
16596
|
tracingPolicy: this.#options?.tracingPolicy
|
|
16470
16597
|
};
|
|
16471
|
-
convertedWorkflowTools[`workflow-${workflowName}`] =
|
|
16598
|
+
convertedWorkflowTools[`workflow-${workflowName}`] = chunkO3ULBGV6_cjs.makeCoreTool(
|
|
16472
16599
|
toolObj,
|
|
16473
16600
|
options,
|
|
16474
16601
|
void 0,
|
|
@@ -16498,7 +16625,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16498
16625
|
let mastraProxy = void 0;
|
|
16499
16626
|
const logger = this.logger;
|
|
16500
16627
|
if (this.#mastra) {
|
|
16501
|
-
mastraProxy =
|
|
16628
|
+
mastraProxy = chunkO3ULBGV6_cjs.createMastraProxy({ mastra: this.#mastra, logger });
|
|
16502
16629
|
}
|
|
16503
16630
|
const assignedTools = await this.listAssignedTools({
|
|
16504
16631
|
runId,
|
|
@@ -16702,7 +16829,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16702
16829
|
result[id] = scorerObject;
|
|
16703
16830
|
}
|
|
16704
16831
|
}
|
|
16705
|
-
if (Object.keys(result).length === 0) {
|
|
16832
|
+
if (Object.keys(result).length === 0 && Object.keys(overrideScorers).length > 0) {
|
|
16706
16833
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
16707
16834
|
id: "AGENT_GENEREATE_SCORER_NOT_FOUND",
|
|
16708
16835
|
domain: "AGENT" /* AGENT */,
|
|
@@ -16719,8 +16846,11 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16719
16846
|
async prepareModels(requestContext, model) {
|
|
16720
16847
|
if (model || !Array.isArray(this.model)) {
|
|
16721
16848
|
const modelToUse = model ?? this.model;
|
|
16722
|
-
const resolvedModel =
|
|
16723
|
-
|
|
16849
|
+
const resolvedModel = await this.resolveModelConfig(
|
|
16850
|
+
modelToUse,
|
|
16851
|
+
requestContext
|
|
16852
|
+
);
|
|
16853
|
+
if (!isSupportedLanguageModel(resolvedModel)) {
|
|
16724
16854
|
const mastraError = new chunkHWMMIRIF_cjs.MastraError({
|
|
16725
16855
|
id: "AGENT_PREPARE_MODELS_INCOMPATIBLE_WITH_MODEL_ARRAY_V1",
|
|
16726
16856
|
domain: "AGENT" /* AGENT */,
|
|
@@ -16728,26 +16858,30 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16728
16858
|
details: {
|
|
16729
16859
|
agentName: this.name
|
|
16730
16860
|
},
|
|
16731
|
-
text: `[Agent:${this.name}] - Only v2 models are allowed when an array of models is provided`
|
|
16861
|
+
text: `[Agent:${this.name}] - Only v2/v3 models are allowed when an array of models is provided`
|
|
16732
16862
|
});
|
|
16733
16863
|
this.logger.trackException(mastraError);
|
|
16734
16864
|
this.logger.error(mastraError.toString());
|
|
16735
16865
|
throw mastraError;
|
|
16736
16866
|
}
|
|
16867
|
+
let headers;
|
|
16868
|
+
if (resolvedModel instanceof chunk53SZJCBX_cjs.ModelRouterLanguageModel) {
|
|
16869
|
+
headers = resolvedModel.config?.headers;
|
|
16870
|
+
}
|
|
16737
16871
|
return [
|
|
16738
16872
|
{
|
|
16739
16873
|
id: "main",
|
|
16740
|
-
// TODO fix type check
|
|
16741
16874
|
model: resolvedModel,
|
|
16742
16875
|
maxRetries: this.maxRetries ?? 0,
|
|
16743
|
-
enabled: true
|
|
16876
|
+
enabled: true,
|
|
16877
|
+
headers
|
|
16744
16878
|
}
|
|
16745
16879
|
];
|
|
16746
16880
|
}
|
|
16747
16881
|
const models = await Promise.all(
|
|
16748
16882
|
this.model.map(async (modelConfig) => {
|
|
16749
16883
|
const model2 = await this.resolveModelConfig(modelConfig.model, requestContext);
|
|
16750
|
-
if (!
|
|
16884
|
+
if (!isSupportedLanguageModel(model2)) {
|
|
16751
16885
|
const mastraError = new chunkHWMMIRIF_cjs.MastraError({
|
|
16752
16886
|
id: "AGENT_PREPARE_MODELS_INCOMPATIBLE_WITH_MODEL_ARRAY_V1",
|
|
16753
16887
|
domain: "AGENT" /* AGENT */,
|
|
@@ -16755,7 +16889,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16755
16889
|
details: {
|
|
16756
16890
|
agentName: this.name
|
|
16757
16891
|
},
|
|
16758
|
-
text: `[Agent:${this.name}] - Only v2 models are allowed when an array of models is provided`
|
|
16892
|
+
text: `[Agent:${this.name}] - Only v2/v3 models are allowed when an array of models is provided`
|
|
16759
16893
|
});
|
|
16760
16894
|
this.logger.trackException(mastraError);
|
|
16761
16895
|
this.logger.error(mastraError.toString());
|
|
@@ -16776,11 +16910,16 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16776
16910
|
this.logger.error(mastraError.toString());
|
|
16777
16911
|
throw mastraError;
|
|
16778
16912
|
}
|
|
16913
|
+
let headers;
|
|
16914
|
+
if (model2 instanceof chunk53SZJCBX_cjs.ModelRouterLanguageModel) {
|
|
16915
|
+
headers = model2.config?.headers;
|
|
16916
|
+
}
|
|
16779
16917
|
return {
|
|
16780
16918
|
id: modelId,
|
|
16781
16919
|
model: model2,
|
|
16782
16920
|
maxRetries: modelConfig.maxRetries ?? 0,
|
|
16783
|
-
enabled: modelConfig.enabled ?? true
|
|
16921
|
+
enabled: modelConfig.enabled ?? true,
|
|
16922
|
+
headers
|
|
16784
16923
|
};
|
|
16785
16924
|
})
|
|
16786
16925
|
);
|
|
@@ -16790,7 +16929,11 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16790
16929
|
* Executes the agent call, handling tools, memory, and streaming.
|
|
16791
16930
|
* @internal
|
|
16792
16931
|
*/
|
|
16793
|
-
async #execute({
|
|
16932
|
+
async #execute({
|
|
16933
|
+
methodType,
|
|
16934
|
+
resumeContext,
|
|
16935
|
+
...options
|
|
16936
|
+
}) {
|
|
16794
16937
|
const existingSnapshot = resumeContext?.snapshot;
|
|
16795
16938
|
let snapshotMemoryInfo;
|
|
16796
16939
|
if (existingSnapshot) {
|
|
@@ -16828,7 +16971,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16828
16971
|
const targetProvider = structuredOutputModel.provider;
|
|
16829
16972
|
const targetModelId = structuredOutputModel.modelId;
|
|
16830
16973
|
if (targetProvider.includes("openai") || targetModelId.includes("openai")) {
|
|
16831
|
-
if (
|
|
16974
|
+
if (chunkO3ULBGV6_cjs.isZodType(options.structuredOutput.schema) && targetModelId) {
|
|
16832
16975
|
const modelInfo = {
|
|
16833
16976
|
provider: targetProvider,
|
|
16834
16977
|
modelId: targetModelId,
|
|
@@ -17137,14 +17280,14 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17137
17280
|
requestContext: mergedOptions.requestContext
|
|
17138
17281
|
});
|
|
17139
17282
|
const modelInfo = llm.getModel();
|
|
17140
|
-
if (modelInfo
|
|
17283
|
+
if (!isSupportedLanguageModel(modelInfo)) {
|
|
17141
17284
|
const modelId = modelInfo.modelId || "unknown";
|
|
17142
17285
|
const provider = modelInfo.provider || "unknown";
|
|
17143
17286
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
17144
17287
|
id: "AGENT_GENERATE_V1_MODEL_NOT_SUPPORTED",
|
|
17145
17288
|
domain: "AGENT" /* AGENT */,
|
|
17146
17289
|
category: "USER" /* USER */,
|
|
17147
|
-
text: `Agent "${this.name}" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with generate(). Please use AI SDK v5 models or call the generateLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.`,
|
|
17290
|
+
text: `Agent "${this.name}" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with generate(). Please use AI SDK v5+ models or call the generateLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.`,
|
|
17148
17291
|
details: {
|
|
17149
17292
|
agentName: this.name,
|
|
17150
17293
|
modelId,
|
|
@@ -17199,14 +17342,14 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17199
17342
|
requestContext: mergedOptions.requestContext
|
|
17200
17343
|
});
|
|
17201
17344
|
const modelInfo = llm.getModel();
|
|
17202
|
-
if (modelInfo
|
|
17345
|
+
if (!isSupportedLanguageModel(modelInfo)) {
|
|
17203
17346
|
const modelId = modelInfo.modelId || "unknown";
|
|
17204
17347
|
const provider = modelInfo.provider || "unknown";
|
|
17205
17348
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
17206
17349
|
id: "AGENT_STREAM_V1_MODEL_NOT_SUPPORTED",
|
|
17207
17350
|
domain: "AGENT" /* AGENT */,
|
|
17208
17351
|
category: "USER" /* USER */,
|
|
17209
|
-
text: `Agent "${this.name}" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with stream(). Please use AI SDK v5 models or call the streamLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.`,
|
|
17352
|
+
text: `Agent "${this.name}" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with stream(). Please use AI SDK v5+ models or call the streamLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.`,
|
|
17210
17353
|
details: {
|
|
17211
17354
|
agentName: this.name,
|
|
17212
17355
|
modelId,
|
|
@@ -17268,7 +17411,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
17268
17411
|
const llm = await this.getLLM({
|
|
17269
17412
|
requestContext: mergedStreamOptions.requestContext
|
|
17270
17413
|
});
|
|
17271
|
-
if (llm.getModel()
|
|
17414
|
+
if (!isSupportedLanguageModel(llm.getModel())) {
|
|
17272
17415
|
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
17273
17416
|
id: "AGENT_STREAM_V1_MODEL_NOT_SUPPORTED",
|
|
17274
17417
|
domain: "AGENT" /* AGENT */,
|
|
@@ -17508,7 +17651,7 @@ var ModerationProcessor = class _ModerationProcessor {
|
|
|
17508
17651
|
reason: z8__default.default.string().describe("Brief explanation of why content was flagged").nullable()
|
|
17509
17652
|
});
|
|
17510
17653
|
let response;
|
|
17511
|
-
if (model
|
|
17654
|
+
if (isSupportedLanguageModel(model)) {
|
|
17512
17655
|
response = await this.moderationAgent.generate(prompt, {
|
|
17513
17656
|
structuredOutput: {
|
|
17514
17657
|
schema,
|
|
@@ -17728,7 +17871,7 @@ var PromptInjectionDetector = class _PromptInjectionDetector {
|
|
|
17728
17871
|
rewritten_content: z8__default.default.string().describe("The rewritten content that neutralizes the attack while preserving any legitimate user intent").nullable()
|
|
17729
17872
|
});
|
|
17730
17873
|
}
|
|
17731
|
-
if (model
|
|
17874
|
+
if (isSupportedLanguageModel(model)) {
|
|
17732
17875
|
response = await this.detectionAgent.generate(prompt, {
|
|
17733
17876
|
structuredOutput: {
|
|
17734
17877
|
schema,
|
|
@@ -17976,7 +18119,7 @@ var PIIDetector = class _PIIDetector {
|
|
|
17976
18119
|
redacted_content: z8__default.default.string().describe("The content with all PII redacted according to the redaction method").nullable()
|
|
17977
18120
|
}) : baseSchema;
|
|
17978
18121
|
let response;
|
|
17979
|
-
if (model
|
|
18122
|
+
if (isSupportedLanguageModel(model)) {
|
|
17980
18123
|
response = await this.detectionAgent.generate(prompt, {
|
|
17981
18124
|
structuredOutput: {
|
|
17982
18125
|
schema,
|
|
@@ -18438,7 +18581,7 @@ var LanguageDetector = class _LanguageDetector {
|
|
|
18438
18581
|
const schema = this.strategy === "translate" ? baseSchema.extend({
|
|
18439
18582
|
translated_text: z8__default.default.string().describe("Translated text").nullable()
|
|
18440
18583
|
}) : baseSchema;
|
|
18441
|
-
if (model
|
|
18584
|
+
if (isSupportedLanguageModel(model)) {
|
|
18442
18585
|
response = await this.detectionAgent.generate(prompt, {
|
|
18443
18586
|
structuredOutput: {
|
|
18444
18587
|
schema
|
|
@@ -19116,7 +19259,7 @@ var SystemPromptScrubber = class {
|
|
|
19116
19259
|
const schema = this.strategy === "redact" ? baseSchema.extend({
|
|
19117
19260
|
redacted_content: z8.z.string().describe("Redacted content").nullable()
|
|
19118
19261
|
}) : baseSchema;
|
|
19119
|
-
if (model
|
|
19262
|
+
if (isSupportedLanguageModel(model)) {
|
|
19120
19263
|
result = await this.detectionAgent.generate(text, {
|
|
19121
19264
|
structuredOutput: {
|
|
19122
19265
|
schema,
|
|
@@ -19685,7 +19828,7 @@ var SemanticRecall = class {
|
|
|
19685
19828
|
*/
|
|
19686
19829
|
formatCrossThreadMessages(messages, currentThreadId) {
|
|
19687
19830
|
let result = ``;
|
|
19688
|
-
const v1Messages = new
|
|
19831
|
+
const v1Messages = new chunk72E3YF6A_cjs.MessageList().add(messages, "memory").get.all.v1();
|
|
19689
19832
|
let lastYmd = null;
|
|
19690
19833
|
for (const msg of v1Messages) {
|
|
19691
19834
|
const date = msg.createdAt;
|
|
@@ -20090,7 +20233,7 @@ https://mastra.ai/en/docs/memory/semantic-recall`
|
|
|
20090
20233
|
);
|
|
20091
20234
|
}
|
|
20092
20235
|
if (typeof config.embedder === "string") {
|
|
20093
|
-
this.embedder = new
|
|
20236
|
+
this.embedder = new chunk53SZJCBX_cjs.ModelRouterEmbeddingModel(config.embedder);
|
|
20094
20237
|
} else {
|
|
20095
20238
|
this.embedder = config.embedder;
|
|
20096
20239
|
}
|
|
@@ -20186,7 +20329,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
20186
20329
|
"The threads.generateTitle option has been moved. Use the top-level generateTitle option instead."
|
|
20187
20330
|
);
|
|
20188
20331
|
}
|
|
20189
|
-
const mergedConfig =
|
|
20332
|
+
const mergedConfig = chunkO3ULBGV6_cjs.deepMerge(this.threadConfig, config || {});
|
|
20190
20333
|
if (typeof config?.workingMemory === "object" && config.workingMemory?.schema && typeof mergedConfig.workingMemory === "object") {
|
|
20191
20334
|
mergedConfig.workingMemory.schema = config.workingMemory.schema;
|
|
20192
20335
|
}
|
|
@@ -20422,7 +20565,7 @@ var MockMemory = class extends MastraMemory {
|
|
|
20422
20565
|
} = {}) {
|
|
20423
20566
|
super({
|
|
20424
20567
|
name: "mock",
|
|
20425
|
-
storage: storage || new
|
|
20568
|
+
storage: storage || new chunkETWAR2YE_cjs.InMemoryStore(),
|
|
20426
20569
|
options: {
|
|
20427
20570
|
workingMemory: enableWorkingMemory ? { enabled: true, template: workingMemoryTemplate } : void 0,
|
|
20428
20571
|
lastMessages: enableMessageHistory ? 10 : void 0
|
|
@@ -20661,17 +20804,19 @@ exports.getZodErrors = getZodErrors;
|
|
|
20661
20804
|
exports.hydrateSerializedStepErrors = hydrateSerializedStepErrors;
|
|
20662
20805
|
exports.isProcessor = isProcessor;
|
|
20663
20806
|
exports.isProcessorWorkflow = isProcessorWorkflow;
|
|
20807
|
+
exports.isSupportedLanguageModel = isSupportedLanguageModel;
|
|
20664
20808
|
exports.loop = loop;
|
|
20665
20809
|
exports.mapVariable = mapVariable;
|
|
20666
20810
|
exports.memoryDefaultOptions = memoryDefaultOptions;
|
|
20667
20811
|
exports.parseMemoryRequestContext = parseMemoryRequestContext;
|
|
20668
20812
|
exports.resolveThreadIdFromArgs = resolveThreadIdFromArgs;
|
|
20669
20813
|
exports.runCountDeprecationMessage = runCountDeprecationMessage;
|
|
20814
|
+
exports.supportedLanguageModelSpecifications = supportedLanguageModelSpecifications;
|
|
20670
20815
|
exports.tryGenerateWithJsonFallback = tryGenerateWithJsonFallback;
|
|
20671
20816
|
exports.tryStreamWithJsonFallback = tryStreamWithJsonFallback;
|
|
20672
20817
|
exports.validateStepInput = validateStepInput;
|
|
20673
20818
|
exports.validateStepResumeData = validateStepResumeData;
|
|
20674
20819
|
exports.validateStepStateData = validateStepStateData;
|
|
20675
20820
|
exports.validateStepSuspendData = validateStepSuspendData;
|
|
20676
|
-
//# sourceMappingURL=chunk-
|
|
20677
|
-
//# sourceMappingURL=chunk-
|
|
20821
|
+
//# sourceMappingURL=chunk-JAGQZZ43.cjs.map
|
|
20822
|
+
//# sourceMappingURL=chunk-JAGQZZ43.cjs.map
|