@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,19 +1,19 @@
|
|
|
1
|
-
import { DefaultVoice } from './chunk-
|
|
1
|
+
import { DefaultVoice } from './chunk-GELVUDUY.js';
|
|
2
2
|
import { PUBSUB_SYMBOL, STREAM_FORMAT_SYMBOL } from './chunk-6PMMP3FR.js';
|
|
3
|
-
import { InMemoryStore } from './chunk-
|
|
4
|
-
import { MessageList, DefaultGeneratedFile, DefaultGeneratedFileWithType
|
|
3
|
+
import { InMemoryStore } from './chunk-GBQXIVL6.js';
|
|
4
|
+
import { MessageList, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-4AT6YQKZ.js';
|
|
5
5
|
import { createTextStreamResponse, createUIMessageStreamResponse, createUIMessageStream, parsePartialJson, isDeepEqualData, stepCountIs } from './chunk-2SQB3WBT.js';
|
|
6
6
|
import { generateId, asSchema, jsonSchema, APICallError, tool } from './chunk-G6E6V2Z4.js';
|
|
7
|
+
import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-QDVYP2T7.js';
|
|
8
|
+
import { MastraLLMV1 } from './chunk-4CMIJQF6.js';
|
|
7
9
|
import { PubSub } from './chunk-BVUMKER5.js';
|
|
8
10
|
import { executeHook } from './chunk-L54GIUCB.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
11
|
+
import { removeUndefinedValues, ensureToolProperties, makeCoreTool, createMastraProxy, isZodType, deepMerge, selectFields, delay } from './chunk-LDXKZYOV.js';
|
|
12
|
+
import { getOrCreateSpan, wrapMastra, executeWithContextSync } from './chunk-Y36Y5MTD.js';
|
|
13
|
+
import { MastraError, getErrorFromUnknown } from './chunk-YPLZDWG7.js';
|
|
12
14
|
import { ToolStream } from './chunk-DD2VNRQM.js';
|
|
13
15
|
import { Tool, createTool } from './chunk-373OC54J.js';
|
|
14
|
-
import { getOrCreateSpan, wrapMastra, executeWithContextSync } from './chunk-Y36Y5MTD.js';
|
|
15
16
|
import { RequestContext, MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY } from './chunk-6TBWJV35.js';
|
|
16
|
-
import { MastraError, getErrorFromUnknown } from './chunk-YPLZDWG7.js';
|
|
17
17
|
import { zodToJsonSchema as zodToJsonSchema$1 } from './chunk-PJKCPRYF.js';
|
|
18
18
|
import { MastraBase } from './chunk-LSHPJWM5.js';
|
|
19
19
|
import { RegisteredLogger, ConsoleLogger } from './chunk-NRUZYMHE.js';
|
|
@@ -27,6 +27,7 @@ import { getErrorMessage, TypeValidationError } from '@ai-sdk/provider-v5';
|
|
|
27
27
|
import z4 from 'zod/v4';
|
|
28
28
|
import { OpenAIReasoningSchemaCompatLayer, OpenAISchemaCompatLayer, GoogleSchemaCompatLayer, AnthropicSchemaCompatLayer, DeepSeekSchemaCompatLayer, MetaSchemaCompatLayer, applyCompatLayer } from '@mastra/schema-compat';
|
|
29
29
|
import { isEmpty } from 'radash';
|
|
30
|
+
import { isAbortError, injectJsonInstructionIntoMessages } from '@ai-sdk/provider-utils-v5';
|
|
30
31
|
import { Tiktoken } from 'js-tiktoken/lite';
|
|
31
32
|
import o200k_base from 'js-tiktoken/ranks/o200k_base';
|
|
32
33
|
import { LRUCache } from 'lru-cache';
|
|
@@ -728,6 +729,69 @@ The input text may be in any format (sentences, bullet points, paragraphs, etc.)
|
|
|
728
729
|
}
|
|
729
730
|
};
|
|
730
731
|
|
|
732
|
+
// src/agent/utils.ts
|
|
733
|
+
var supportedLanguageModelSpecifications = ["v2", "v3"];
|
|
734
|
+
var isSupportedLanguageModel = (model) => {
|
|
735
|
+
return supportedLanguageModelSpecifications.includes(model.specificationVersion);
|
|
736
|
+
};
|
|
737
|
+
async function tryGenerateWithJsonFallback(agent, prompt, options) {
|
|
738
|
+
if (!options.structuredOutput?.schema) {
|
|
739
|
+
throw new MastraError({
|
|
740
|
+
id: "STRUCTURED_OUTPUT_OPTIONS_REQUIRED",
|
|
741
|
+
domain: "AGENT" /* AGENT */,
|
|
742
|
+
category: "USER" /* USER */,
|
|
743
|
+
text: "structuredOutput is required to use tryGenerateWithJsonFallback"
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
try {
|
|
747
|
+
return await agent.generate(prompt, options);
|
|
748
|
+
} catch (error) {
|
|
749
|
+
console.warn("Error in tryGenerateWithJsonFallback. Attempting fallback.", error);
|
|
750
|
+
return await agent.generate(prompt, {
|
|
751
|
+
...options,
|
|
752
|
+
structuredOutput: { ...options.structuredOutput, jsonPromptInjection: true }
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
async function tryStreamWithJsonFallback(agent, prompt, options) {
|
|
757
|
+
if (!options.structuredOutput?.schema) {
|
|
758
|
+
throw new MastraError({
|
|
759
|
+
id: "STRUCTURED_OUTPUT_OPTIONS_REQUIRED",
|
|
760
|
+
domain: "AGENT" /* AGENT */,
|
|
761
|
+
category: "USER" /* USER */,
|
|
762
|
+
text: "structuredOutput is required to use tryStreamWithJsonFallback"
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
try {
|
|
766
|
+
const result = await agent.stream(prompt, options);
|
|
767
|
+
const object = await result.object;
|
|
768
|
+
if (!object) {
|
|
769
|
+
throw new MastraError({
|
|
770
|
+
id: "STRUCTURED_OUTPUT_OBJECT_UNDEFINED",
|
|
771
|
+
domain: "AGENT" /* AGENT */,
|
|
772
|
+
category: "USER" /* USER */,
|
|
773
|
+
text: "structuredOutput object is undefined"
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
return result;
|
|
777
|
+
} catch (error) {
|
|
778
|
+
console.warn("Error in tryStreamWithJsonFallback. Attempting fallback.", error);
|
|
779
|
+
return await agent.stream(prompt, {
|
|
780
|
+
...options,
|
|
781
|
+
structuredOutput: { ...options.structuredOutput, jsonPromptInjection: true }
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function resolveThreadIdFromArgs(args) {
|
|
786
|
+
if (args?.memory?.thread) {
|
|
787
|
+
if (typeof args.memory.thread === "string") return { id: args.memory.thread };
|
|
788
|
+
if (typeof args.memory.thread === "object" && args.memory.thread.id)
|
|
789
|
+
return args.memory.thread;
|
|
790
|
+
}
|
|
791
|
+
if (args?.threadId) return { id: args.threadId };
|
|
792
|
+
return void 0;
|
|
793
|
+
}
|
|
794
|
+
|
|
731
795
|
// src/processors/runner.ts
|
|
732
796
|
var ProcessorState = class {
|
|
733
797
|
accumulatedText = "";
|
|
@@ -1638,12 +1702,13 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1638
1702
|
const { model: _model, ...rest } = result;
|
|
1639
1703
|
if (result.model) {
|
|
1640
1704
|
const resolvedModel = await resolveModelConfig(result.model);
|
|
1641
|
-
|
|
1705
|
+
const isSupported = isSupportedLanguageModel(resolvedModel);
|
|
1706
|
+
if (!isSupported) {
|
|
1642
1707
|
throw new MastraError({
|
|
1643
1708
|
category: "USER",
|
|
1644
1709
|
domain: "AGENT",
|
|
1645
|
-
id: "
|
|
1646
|
-
text: `Processor ${processor.id} returned
|
|
1710
|
+
id: "PROCESSOR_RETURNED_UNSUPPORTED_MODEL",
|
|
1711
|
+
text: `Processor ${processor.id} returned an unsupported model version ${resolvedModel.specificationVersion} in step ${stepNumber}. Only ${supportedLanguageModelSpecifications.join(", ")} models are supported in processInputStep.`
|
|
1647
1712
|
});
|
|
1648
1713
|
}
|
|
1649
1714
|
return {
|
|
@@ -1842,10 +1907,8 @@ function convertFullStreamChunkToMastra(value, ctx) {
|
|
|
1842
1907
|
reason: value.finishReason
|
|
1843
1908
|
},
|
|
1844
1909
|
output: {
|
|
1845
|
-
usage
|
|
1846
|
-
|
|
1847
|
-
totalTokens: value?.usage?.totalTokens ?? (value.usage?.inputTokens ?? 0) + (value.usage?.outputTokens ?? 0)
|
|
1848
|
-
}
|
|
1910
|
+
// Normalize usage to handle both V2 (flat) and V3 (nested) formats
|
|
1911
|
+
usage: normalizeUsage(value.usage)
|
|
1849
1912
|
},
|
|
1850
1913
|
metadata: {
|
|
1851
1914
|
providerMetadata: value.providerMetadata
|
|
@@ -1897,6 +1960,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
1897
1960
|
type: "finish",
|
|
1898
1961
|
// Cast needed: Mastra extends reason with 'tripwire' | 'retry' for processor scenarios
|
|
1899
1962
|
finishReason: chunk.payload.stepResult.reason,
|
|
1963
|
+
// Cast needed: Mastra's LanguageModelUsage has optional properties, V2 has required-but-nullable
|
|
1900
1964
|
totalUsage: chunk.payload.output.usage
|
|
1901
1965
|
};
|
|
1902
1966
|
}
|
|
@@ -1915,18 +1979,8 @@ function convertMastraChunkToAISDKv5({
|
|
|
1915
1979
|
};
|
|
1916
1980
|
case "reasoning-signature":
|
|
1917
1981
|
throw new Error('AISDKv5 chunk type "reasoning-signature" not supported');
|
|
1918
|
-
// return {
|
|
1919
|
-
// type: 'reasoning-signature' as const,
|
|
1920
|
-
// id: chunk.payload.id,
|
|
1921
|
-
// signature: chunk.payload.signature,
|
|
1922
|
-
// };
|
|
1923
1982
|
case "redacted-reasoning":
|
|
1924
1983
|
throw new Error('AISDKv5 chunk type "redacted-reasoning" not supported');
|
|
1925
|
-
// return {
|
|
1926
|
-
// type: 'redacted-reasoning',
|
|
1927
|
-
// id: chunk.payload.id,
|
|
1928
|
-
// data: chunk.payload.data,
|
|
1929
|
-
// };
|
|
1930
1984
|
case "reasoning-end":
|
|
1931
1985
|
return {
|
|
1932
1986
|
type: "reasoning-end",
|
|
@@ -2080,6 +2134,44 @@ function convertMastraChunkToAISDKv5({
|
|
|
2080
2134
|
return;
|
|
2081
2135
|
}
|
|
2082
2136
|
}
|
|
2137
|
+
function isV3Usage(usage) {
|
|
2138
|
+
if (!usage || typeof usage !== "object") return false;
|
|
2139
|
+
const u = usage;
|
|
2140
|
+
return typeof u.inputTokens === "object" && u.inputTokens !== null && "total" in u.inputTokens && typeof u.outputTokens === "object" && u.outputTokens !== null && "total" in u.outputTokens;
|
|
2141
|
+
}
|
|
2142
|
+
function normalizeUsage(usage) {
|
|
2143
|
+
if (!usage) {
|
|
2144
|
+
return {
|
|
2145
|
+
inputTokens: void 0,
|
|
2146
|
+
outputTokens: void 0,
|
|
2147
|
+
totalTokens: void 0,
|
|
2148
|
+
reasoningTokens: void 0,
|
|
2149
|
+
cachedInputTokens: void 0,
|
|
2150
|
+
raw: void 0
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
if (isV3Usage(usage)) {
|
|
2154
|
+
const inputTokens = usage.inputTokens.total;
|
|
2155
|
+
const outputTokens = usage.outputTokens.total;
|
|
2156
|
+
return {
|
|
2157
|
+
inputTokens,
|
|
2158
|
+
outputTokens,
|
|
2159
|
+
totalTokens: (inputTokens ?? 0) + (outputTokens ?? 0),
|
|
2160
|
+
reasoningTokens: usage.outputTokens.reasoning,
|
|
2161
|
+
cachedInputTokens: usage.inputTokens.cacheRead,
|
|
2162
|
+
raw: usage
|
|
2163
|
+
};
|
|
2164
|
+
}
|
|
2165
|
+
const v2Usage = usage;
|
|
2166
|
+
return {
|
|
2167
|
+
inputTokens: v2Usage.inputTokens,
|
|
2168
|
+
outputTokens: v2Usage.outputTokens,
|
|
2169
|
+
totalTokens: v2Usage.totalTokens ?? (v2Usage.inputTokens ?? 0) + (v2Usage.outputTokens ?? 0),
|
|
2170
|
+
reasoningTokens: v2Usage.reasoningTokens,
|
|
2171
|
+
cachedInputTokens: v2Usage.cachedInputTokens,
|
|
2172
|
+
raw: usage
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
2083
2175
|
|
|
2084
2176
|
// src/stream/aisdk/v5/output.ts
|
|
2085
2177
|
var AISDKV5OutputStream = class {
|
|
@@ -2975,7 +3067,11 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
2975
3067
|
#warnings = [];
|
|
2976
3068
|
#finishReason = void 0;
|
|
2977
3069
|
#request = {};
|
|
2978
|
-
#usageCount = {
|
|
3070
|
+
#usageCount = {
|
|
3071
|
+
inputTokens: void 0,
|
|
3072
|
+
outputTokens: void 0,
|
|
3073
|
+
totalTokens: void 0
|
|
3074
|
+
};
|
|
2979
3075
|
#tripwire = void 0;
|
|
2980
3076
|
#delayedPromises = {
|
|
2981
3077
|
suspendPayload: new DelayedPromise(),
|
|
@@ -3322,23 +3418,25 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
3322
3418
|
};
|
|
3323
3419
|
self.#finishReason = "other";
|
|
3324
3420
|
self.#streamFinished = true;
|
|
3325
|
-
self
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3421
|
+
self.resolvePromises({
|
|
3422
|
+
text: self.#bufferedText.join(""),
|
|
3423
|
+
finishReason: "other",
|
|
3424
|
+
object: void 0,
|
|
3425
|
+
usage: self.#usageCount,
|
|
3426
|
+
warnings: self.#warnings,
|
|
3427
|
+
providerMetadata: void 0,
|
|
3428
|
+
response: {},
|
|
3429
|
+
request: {},
|
|
3430
|
+
reasoning: [],
|
|
3431
|
+
reasoningText: void 0,
|
|
3432
|
+
sources: [],
|
|
3433
|
+
files: [],
|
|
3434
|
+
toolCalls: [],
|
|
3435
|
+
toolResults: [],
|
|
3436
|
+
steps: self.#bufferedSteps,
|
|
3437
|
+
totalUsage: self.#usageCount,
|
|
3438
|
+
content: []
|
|
3439
|
+
});
|
|
3342
3440
|
self.#emitChunk(chunk);
|
|
3343
3441
|
controller.enqueue(chunk);
|
|
3344
3442
|
self.#emitter.emit("finish");
|
|
@@ -3406,8 +3504,10 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
3406
3504
|
if (lastStep && outputText && outputText !== originalText) {
|
|
3407
3505
|
lastStep.text = outputText;
|
|
3408
3506
|
}
|
|
3409
|
-
|
|
3410
|
-
|
|
3507
|
+
this.resolvePromises({
|
|
3508
|
+
text: outputText || originalText,
|
|
3509
|
+
finishReason: self.#finishReason
|
|
3510
|
+
});
|
|
3411
3511
|
if (chunk.payload.metadata) {
|
|
3412
3512
|
const { providerMetadata, request, ...otherMetadata } = chunk.payload.metadata;
|
|
3413
3513
|
response = {
|
|
@@ -3417,9 +3517,10 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
3417
3517
|
};
|
|
3418
3518
|
}
|
|
3419
3519
|
} else if (!self.#options.isLLMExecutionStep) {
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3520
|
+
this.resolvePromises({
|
|
3521
|
+
text: self.#bufferedText.join(""),
|
|
3522
|
+
finishReason: self.#finishReason
|
|
3523
|
+
});
|
|
3423
3524
|
}
|
|
3424
3525
|
} catch (error2) {
|
|
3425
3526
|
if (error2 instanceof TripWire) {
|
|
@@ -3429,35 +3530,41 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
3429
3530
|
metadata: error2.options?.metadata,
|
|
3430
3531
|
processorId: error2.processorId
|
|
3431
3532
|
};
|
|
3432
|
-
self
|
|
3433
|
-
|
|
3533
|
+
self.resolvePromises({
|
|
3534
|
+
finishReason: "other",
|
|
3535
|
+
text: ""
|
|
3536
|
+
});
|
|
3434
3537
|
} else {
|
|
3435
3538
|
self.#error = getErrorFromUnknown(error2, {
|
|
3436
3539
|
fallbackMessage: "Unknown error in stream"
|
|
3437
3540
|
});
|
|
3438
|
-
self
|
|
3439
|
-
|
|
3541
|
+
self.resolvePromises({
|
|
3542
|
+
finishReason: "error",
|
|
3543
|
+
text: ""
|
|
3544
|
+
});
|
|
3440
3545
|
}
|
|
3441
3546
|
if (self.#delayedPromises.object.status.type !== "resolved") {
|
|
3442
3547
|
self.#delayedPromises.object.resolve(void 0);
|
|
3443
3548
|
}
|
|
3444
3549
|
}
|
|
3445
|
-
self.#delayedPromises.usage.resolve(self.#usageCount);
|
|
3446
|
-
self.#delayedPromises.warnings.resolve(self.#warnings);
|
|
3447
|
-
self.#delayedPromises.providerMetadata.resolve(chunk.payload.metadata?.providerMetadata);
|
|
3448
|
-
self.#delayedPromises.response.resolve(response);
|
|
3449
|
-
self.#delayedPromises.request.resolve(self.#request || {});
|
|
3450
3550
|
const reasoningText = self.#bufferedReasoning.length > 0 ? self.#bufferedReasoning.map((reasoningPart) => reasoningPart.payload.text).join("") : void 0;
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3551
|
+
this.resolvePromises({
|
|
3552
|
+
usage: self.#usageCount,
|
|
3553
|
+
warnings: self.#warnings,
|
|
3554
|
+
providerMetadata: chunk.payload.metadata?.providerMetadata,
|
|
3555
|
+
response,
|
|
3556
|
+
request: self.#request || {},
|
|
3557
|
+
reasoningText,
|
|
3558
|
+
reasoning: Object.values(self.#bufferedReasoningDetails || {}),
|
|
3559
|
+
sources: self.#bufferedSources,
|
|
3560
|
+
files: self.#bufferedFiles,
|
|
3561
|
+
toolCalls: self.#toolCalls,
|
|
3562
|
+
toolResults: self.#toolResults,
|
|
3563
|
+
steps: self.#bufferedSteps,
|
|
3564
|
+
totalUsage: self.#getTotalUsage(),
|
|
3565
|
+
content: messageList.get.response.aiV5.stepContent(),
|
|
3566
|
+
suspendPayload: void 0
|
|
3567
|
+
});
|
|
3461
3568
|
const baseFinishStep = self.#bufferedSteps[self.#bufferedSteps.length - 1];
|
|
3462
3569
|
if (baseFinishStep) {
|
|
3463
3570
|
const onFinishPayload = {
|
|
@@ -3525,6 +3632,28 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
3525
3632
|
if (self.#delayedPromises.object.status.type === "pending") {
|
|
3526
3633
|
self.#delayedPromises.object.resolve(void 0);
|
|
3527
3634
|
}
|
|
3635
|
+
if (self.#status === "suspended") {
|
|
3636
|
+
const reasoningText = self.#bufferedReasoning.length > 0 ? self.#bufferedReasoning.map((reasoningPart) => reasoningPart.payload.text).join("") : void 0;
|
|
3637
|
+
self.resolvePromises({
|
|
3638
|
+
toolResults: self.#toolResults,
|
|
3639
|
+
toolCalls: self.#toolCalls,
|
|
3640
|
+
text: self.#bufferedText.join(""),
|
|
3641
|
+
reasoning: Object.values(self.#bufferedReasoningDetails || {}),
|
|
3642
|
+
reasoningText,
|
|
3643
|
+
sources: self.#bufferedSources,
|
|
3644
|
+
files: self.#bufferedFiles,
|
|
3645
|
+
steps: self.#bufferedSteps,
|
|
3646
|
+
usage: self.#usageCount,
|
|
3647
|
+
totalUsage: self.#getTotalUsage(),
|
|
3648
|
+
warnings: self.#warnings,
|
|
3649
|
+
finishReason: "other",
|
|
3650
|
+
content: self.messageList.get.response.aiV5.stepContent(),
|
|
3651
|
+
object: void 0,
|
|
3652
|
+
request: self.#request,
|
|
3653
|
+
response: {},
|
|
3654
|
+
providerMetadata: void 0
|
|
3655
|
+
});
|
|
3656
|
+
}
|
|
3528
3657
|
Object.entries(self.#delayedPromises).forEach(([key, promise]) => {
|
|
3529
3658
|
if (promise.status.type === "pending") {
|
|
3530
3659
|
promise.reject(new Error(`promise '${key}' was not resolved or rejected when stream finished`));
|
|
@@ -3548,6 +3677,23 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
3548
3677
|
this.deserializeState(initialState);
|
|
3549
3678
|
}
|
|
3550
3679
|
}
|
|
3680
|
+
resolvePromise(key, value) {
|
|
3681
|
+
if (!(key in this.#delayedPromises)) {
|
|
3682
|
+
throw new MastraError({
|
|
3683
|
+
id: "MASTRA_MODEL_OUTPUT_INVALID_PROMISE_KEY",
|
|
3684
|
+
domain: "LLM" /* LLM */,
|
|
3685
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
3686
|
+
text: `Attempted to resolve invalid promise key '${key}' with value '${typeof value === "object" ? JSON.stringify(value, null, 2) : value}'`
|
|
3687
|
+
});
|
|
3688
|
+
}
|
|
3689
|
+
this.#delayedPromises[key].resolve(value);
|
|
3690
|
+
}
|
|
3691
|
+
resolvePromises(data) {
|
|
3692
|
+
for (const keyString in data) {
|
|
3693
|
+
const key = keyString;
|
|
3694
|
+
this.resolvePromise(key, data[key]);
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3551
3697
|
#getDelayedPromise(promise) {
|
|
3552
3698
|
if (!this.#consumptionStarted) {
|
|
3553
3699
|
void this.consumeStream();
|
|
@@ -4520,7 +4666,7 @@ var getModelOutputForTripwire = async ({
|
|
|
4520
4666
|
model: {
|
|
4521
4667
|
modelId: model.modelId,
|
|
4522
4668
|
provider: model.provider,
|
|
4523
|
-
version: model.specificationVersion
|
|
4669
|
+
version: model.specificationVersion
|
|
4524
4670
|
},
|
|
4525
4671
|
stream: tripwireStream,
|
|
4526
4672
|
messageList,
|
|
@@ -4591,11 +4737,6 @@ function runScorer({
|
|
|
4591
4737
|
};
|
|
4592
4738
|
executeHook("onScorerRun" /* ON_SCORER_RUN */, payload);
|
|
4593
4739
|
}
|
|
4594
|
-
|
|
4595
|
-
// src/llm/model/is-v2-model.ts
|
|
4596
|
-
function isV2Model(model) {
|
|
4597
|
-
return model.specificationVersion === "v2";
|
|
4598
|
-
}
|
|
4599
4740
|
var EventEmitterPubSub = class extends PubSub {
|
|
4600
4741
|
emitter;
|
|
4601
4742
|
constructor(existingEmitter) {
|
|
@@ -8382,7 +8523,9 @@ var Workflow = class extends MastraBase {
|
|
|
8382
8523
|
workflowStatus: run.workflowRunStatus,
|
|
8383
8524
|
stepResults: {}
|
|
8384
8525
|
});
|
|
8385
|
-
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse,
|
|
8526
|
+
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse, {
|
|
8527
|
+
withNestedWorkflows: false
|
|
8528
|
+
});
|
|
8386
8529
|
if (workflowSnapshotInStorage && workflowSnapshotInStorage.status) {
|
|
8387
8530
|
run.workflowRunStatus = workflowSnapshotInStorage.status;
|
|
8388
8531
|
}
|
|
@@ -8647,7 +8790,8 @@ var Workflow = class extends MastraBase {
|
|
|
8647
8790
|
}
|
|
8648
8791
|
return finalSteps;
|
|
8649
8792
|
}
|
|
8650
|
-
async getWorkflowRunExecutionResult(runId,
|
|
8793
|
+
async getWorkflowRunExecutionResult(runId, options = {}) {
|
|
8794
|
+
const { withNestedWorkflows = true, fields } = options;
|
|
8651
8795
|
const storage = this.#mastra?.getStorage();
|
|
8652
8796
|
if (!storage) {
|
|
8653
8797
|
this.logger.debug("Cannot get workflow run execution result. Mastra storage is not initialized");
|
|
@@ -8666,15 +8810,51 @@ var Workflow = class extends MastraBase {
|
|
|
8666
8810
|
return null;
|
|
8667
8811
|
}
|
|
8668
8812
|
}
|
|
8669
|
-
const
|
|
8813
|
+
const snapshotState = snapshot;
|
|
8814
|
+
const defaultResult = {
|
|
8815
|
+
status: snapshotState.status,
|
|
8816
|
+
result: snapshotState.result,
|
|
8817
|
+
error: snapshotState.error,
|
|
8818
|
+
payload: snapshotState.context?.input,
|
|
8819
|
+
steps: null,
|
|
8820
|
+
// Will be populated below
|
|
8821
|
+
activeStepsPath: snapshotState.activeStepsPath,
|
|
8822
|
+
serializedStepGraph: snapshotState.serializedStepGraph
|
|
8823
|
+
};
|
|
8824
|
+
const allowedFields = new Set(Object.keys(defaultResult));
|
|
8825
|
+
if (fields && fields.length > 0) {
|
|
8826
|
+
const result = {};
|
|
8827
|
+
for (const field of fields) {
|
|
8828
|
+
if (!allowedFields.has(field)) {
|
|
8829
|
+
continue;
|
|
8830
|
+
}
|
|
8831
|
+
if (field === "steps") {
|
|
8832
|
+
let fullSteps2;
|
|
8833
|
+
if (withNestedWorkflows) {
|
|
8834
|
+
fullSteps2 = await this.getWorkflowRunSteps({ runId, workflowId: this.id });
|
|
8835
|
+
} else {
|
|
8836
|
+
const { input, ...stepsOnly } = snapshotState.context || {};
|
|
8837
|
+
fullSteps2 = stepsOnly;
|
|
8838
|
+
}
|
|
8839
|
+
result.steps = fullSteps2;
|
|
8840
|
+
} else if (field === "payload") {
|
|
8841
|
+
result.payload = snapshotState.context?.input;
|
|
8842
|
+
} else {
|
|
8843
|
+
result[field] = snapshotState[field];
|
|
8844
|
+
}
|
|
8845
|
+
}
|
|
8846
|
+
return result;
|
|
8847
|
+
}
|
|
8848
|
+
let fullSteps;
|
|
8849
|
+
if (withNestedWorkflows) {
|
|
8850
|
+
fullSteps = await this.getWorkflowRunSteps({ runId, workflowId: this.id });
|
|
8851
|
+
} else {
|
|
8852
|
+
const { input, ...stepsOnly } = snapshotState.context || {};
|
|
8853
|
+
fullSteps = stepsOnly;
|
|
8854
|
+
}
|
|
8670
8855
|
return {
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
error: snapshot.error,
|
|
8674
|
-
payload: snapshot.context?.input,
|
|
8675
|
-
steps: fullSteps,
|
|
8676
|
-
activeStepsPath: snapshot.activeStepsPath,
|
|
8677
|
-
serializedStepGraph: snapshot.serializedStepGraph
|
|
8856
|
+
...defaultResult,
|
|
8857
|
+
steps: fullSteps
|
|
8678
8858
|
};
|
|
8679
8859
|
}
|
|
8680
8860
|
};
|
|
@@ -10419,7 +10599,7 @@ function executeStreamWithFallbackModels(models) {
|
|
|
10419
10599
|
while (attempt <= maxRetries) {
|
|
10420
10600
|
try {
|
|
10421
10601
|
const isLastModel = attempt === maxRetries && index === models.length;
|
|
10422
|
-
const result = await callback(modelConfig
|
|
10602
|
+
const result = await callback(modelConfig, isLastModel);
|
|
10423
10603
|
finalResult = result;
|
|
10424
10604
|
done = true;
|
|
10425
10605
|
break;
|
|
@@ -10461,7 +10641,6 @@ function createLLMExecutionStep({
|
|
|
10461
10641
|
inputProcessors,
|
|
10462
10642
|
logger,
|
|
10463
10643
|
agentId,
|
|
10464
|
-
headers,
|
|
10465
10644
|
downloadRetries,
|
|
10466
10645
|
downloadConcurrency,
|
|
10467
10646
|
processorStates,
|
|
@@ -10481,7 +10660,9 @@ function createLLMExecutionStep({
|
|
|
10481
10660
|
let warnings;
|
|
10482
10661
|
let request;
|
|
10483
10662
|
let rawResponse;
|
|
10484
|
-
const { outputStream, callBail, runState, stepTools } = await executeStreamWithFallbackModels(models)(async (
|
|
10663
|
+
const { outputStream, callBail, runState, stepTools } = await executeStreamWithFallbackModels(models)(async (modelConfig, isLastModel) => {
|
|
10664
|
+
const model = modelConfig.model;
|
|
10665
|
+
const modelHeaders = modelConfig.headers;
|
|
10485
10666
|
if (initialSystemMessages) {
|
|
10486
10667
|
messageList.replaceAllSystemMessages(initialSystemMessages);
|
|
10487
10668
|
}
|
|
@@ -10566,55 +10747,55 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
|
|
|
10566
10747
|
}
|
|
10567
10748
|
}
|
|
10568
10749
|
}
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10750
|
+
if (isSupportedLanguageModel(currentStep.model)) {
|
|
10751
|
+
modelResult = executeWithContextSync({
|
|
10752
|
+
span: modelSpanTracker?.getTracingContext()?.currentSpan,
|
|
10753
|
+
fn: () => execute({
|
|
10754
|
+
runId,
|
|
10755
|
+
model: currentStep.model,
|
|
10756
|
+
providerOptions: currentStep.providerOptions,
|
|
10757
|
+
inputMessages,
|
|
10758
|
+
tools: currentStep.tools,
|
|
10759
|
+
toolChoice: currentStep.toolChoice,
|
|
10760
|
+
activeTools: currentStep.activeTools,
|
|
10761
|
+
options,
|
|
10762
|
+
modelSettings: currentStep.modelSettings,
|
|
10763
|
+
includeRawChunks,
|
|
10764
|
+
structuredOutput: currentStep.structuredOutput,
|
|
10765
|
+
// Merge headers: modelConfig headers first, then modelSettings overrides them
|
|
10766
|
+
// Only create object if there are actual headers to avoid passing empty {}
|
|
10767
|
+
headers: modelHeaders || currentStep.modelSettings?.headers ? { ...modelHeaders, ...currentStep.modelSettings?.headers } : void 0,
|
|
10768
|
+
methodType,
|
|
10769
|
+
generateId: _internal?.generateId,
|
|
10770
|
+
onResult: ({
|
|
10771
|
+
warnings: warningsFromStream,
|
|
10772
|
+
request: requestFromStream,
|
|
10773
|
+
rawResponse: rawResponseFromStream
|
|
10774
|
+
}) => {
|
|
10775
|
+
warnings = warningsFromStream;
|
|
10776
|
+
request = requestFromStream || {};
|
|
10777
|
+
rawResponse = rawResponseFromStream;
|
|
10778
|
+
if (!isControllerOpen(controller)) {
|
|
10779
|
+
return;
|
|
10780
|
+
}
|
|
10781
|
+
controller.enqueue({
|
|
10782
|
+
runId,
|
|
10783
|
+
from: "AGENT" /* AGENT */,
|
|
10784
|
+
type: "step-start",
|
|
10785
|
+
payload: {
|
|
10786
|
+
request: request || {},
|
|
10787
|
+
warnings: warnings || [],
|
|
10788
|
+
messageId
|
|
10598
10789
|
}
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
});
|
|
10609
|
-
},
|
|
10610
|
-
shouldThrowError: !isLastModel
|
|
10611
|
-
})
|
|
10612
|
-
});
|
|
10613
|
-
break;
|
|
10614
|
-
}
|
|
10615
|
-
default: {
|
|
10616
|
-
throw new Error(`Unsupported model version: ${model.specificationVersion}`);
|
|
10617
|
-
}
|
|
10790
|
+
});
|
|
10791
|
+
},
|
|
10792
|
+
shouldThrowError: !isLastModel
|
|
10793
|
+
})
|
|
10794
|
+
});
|
|
10795
|
+
} else {
|
|
10796
|
+
throw new Error(
|
|
10797
|
+
`Unsupported model version: ${currentStep.model.specificationVersion}. Supported versions: ${supportedLanguageModelSpecifications.join(", ")}`
|
|
10798
|
+
);
|
|
10618
10799
|
}
|
|
10619
10800
|
const outputStream2 = new MastraModelOutput({
|
|
10620
10801
|
model: {
|
|
@@ -13158,67 +13339,6 @@ async function networkLoop({
|
|
|
13158
13339
|
|
|
13159
13340
|
// src/agent/agent-legacy.ts
|
|
13160
13341
|
var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
|
|
13161
|
-
|
|
13162
|
-
// src/agent/utils.ts
|
|
13163
|
-
async function tryGenerateWithJsonFallback(agent, prompt, options) {
|
|
13164
|
-
if (!options.structuredOutput?.schema) {
|
|
13165
|
-
throw new MastraError({
|
|
13166
|
-
id: "STRUCTURED_OUTPUT_OPTIONS_REQUIRED",
|
|
13167
|
-
domain: "AGENT" /* AGENT */,
|
|
13168
|
-
category: "USER" /* USER */,
|
|
13169
|
-
text: "structuredOutput is required to use tryGenerateWithJsonFallback"
|
|
13170
|
-
});
|
|
13171
|
-
}
|
|
13172
|
-
try {
|
|
13173
|
-
return await agent.generate(prompt, options);
|
|
13174
|
-
} catch (error) {
|
|
13175
|
-
console.warn("Error in tryGenerateWithJsonFallback. Attempting fallback.", error);
|
|
13176
|
-
return await agent.generate(prompt, {
|
|
13177
|
-
...options,
|
|
13178
|
-
structuredOutput: { ...options.structuredOutput, jsonPromptInjection: true }
|
|
13179
|
-
});
|
|
13180
|
-
}
|
|
13181
|
-
}
|
|
13182
|
-
async function tryStreamWithJsonFallback(agent, prompt, options) {
|
|
13183
|
-
if (!options.structuredOutput?.schema) {
|
|
13184
|
-
throw new MastraError({
|
|
13185
|
-
id: "STRUCTURED_OUTPUT_OPTIONS_REQUIRED",
|
|
13186
|
-
domain: "AGENT" /* AGENT */,
|
|
13187
|
-
category: "USER" /* USER */,
|
|
13188
|
-
text: "structuredOutput is required to use tryStreamWithJsonFallback"
|
|
13189
|
-
});
|
|
13190
|
-
}
|
|
13191
|
-
try {
|
|
13192
|
-
const result = await agent.stream(prompt, options);
|
|
13193
|
-
const object = await result.object;
|
|
13194
|
-
if (!object) {
|
|
13195
|
-
throw new MastraError({
|
|
13196
|
-
id: "STRUCTURED_OUTPUT_OBJECT_UNDEFINED",
|
|
13197
|
-
domain: "AGENT" /* AGENT */,
|
|
13198
|
-
category: "USER" /* USER */,
|
|
13199
|
-
text: "structuredOutput object is undefined"
|
|
13200
|
-
});
|
|
13201
|
-
}
|
|
13202
|
-
return result;
|
|
13203
|
-
} catch (error) {
|
|
13204
|
-
console.warn("Error in tryStreamWithJsonFallback. Attempting fallback.", error);
|
|
13205
|
-
return await agent.stream(prompt, {
|
|
13206
|
-
...options,
|
|
13207
|
-
structuredOutput: { ...options.structuredOutput, jsonPromptInjection: true }
|
|
13208
|
-
});
|
|
13209
|
-
}
|
|
13210
|
-
}
|
|
13211
|
-
function resolveThreadIdFromArgs(args) {
|
|
13212
|
-
if (args?.memory?.thread) {
|
|
13213
|
-
if (typeof args.memory.thread === "string") return { id: args.memory.thread };
|
|
13214
|
-
if (typeof args.memory.thread === "object" && args.memory.thread.id)
|
|
13215
|
-
return args.memory.thread;
|
|
13216
|
-
}
|
|
13217
|
-
if (args?.threadId) return { id: args.threadId };
|
|
13218
|
-
return void 0;
|
|
13219
|
-
}
|
|
13220
|
-
|
|
13221
|
-
// src/agent/agent-legacy.ts
|
|
13222
13342
|
var AgentLegacyHandler = class {
|
|
13223
13343
|
constructor(capabilities) {
|
|
13224
13344
|
this.capabilities = capabilities;
|
|
@@ -14298,6 +14418,14 @@ function createMapResultsStep({
|
|
|
14298
14418
|
};
|
|
14299
14419
|
if (result.tripwire) {
|
|
14300
14420
|
const agentModel = await capabilities.getModel({ requestContext: result.requestContext });
|
|
14421
|
+
if (!isSupportedLanguageModel(agentModel)) {
|
|
14422
|
+
throw new MastraError({
|
|
14423
|
+
id: "MAP_RESULTS_STEP_UNSUPPORTED_MODEL",
|
|
14424
|
+
domain: "AGENT" /* AGENT */,
|
|
14425
|
+
category: "USER" /* USER */,
|
|
14426
|
+
text: "Tripwire handling requires a v2/v3 model"
|
|
14427
|
+
});
|
|
14428
|
+
}
|
|
14301
14429
|
const modelOutput = await getModelOutputForTripwire({
|
|
14302
14430
|
tripwire: memoryData.tripwire,
|
|
14303
14431
|
runId,
|
|
@@ -14939,7 +15067,6 @@ var Agent = class extends MastraBase {
|
|
|
14939
15067
|
}) {
|
|
14940
15068
|
const inputProcessors = inputProcessorOverrides ?? await this.listResolvedInputProcessors(requestContext);
|
|
14941
15069
|
const outputProcessors = outputProcessorOverrides ?? await this.listResolvedOutputProcessors(requestContext);
|
|
14942
|
-
this.logger.debug("outputProcessors", outputProcessors);
|
|
14943
15070
|
return new ProcessorRunner({
|
|
14944
15071
|
inputProcessors,
|
|
14945
15072
|
outputProcessors,
|
|
@@ -15458,7 +15585,7 @@ var Agent = class extends MastraBase {
|
|
|
15458
15585
|
const modelToUse = this.getModel({ modelConfig: model, requestContext });
|
|
15459
15586
|
return resolveMaybePromise(modelToUse, (resolvedModel) => {
|
|
15460
15587
|
let llm;
|
|
15461
|
-
if (resolvedModel
|
|
15588
|
+
if (isSupportedLanguageModel(resolvedModel)) {
|
|
15462
15589
|
const modelsPromise = Array.isArray(this.model) && !model ? this.prepareModels(requestContext) : this.prepareModels(requestContext, resolvedModel);
|
|
15463
15590
|
llm = modelsPromise.then((models) => {
|
|
15464
15591
|
const enabledModels = models.filter((model2) => model2.enabled);
|
|
@@ -15722,7 +15849,7 @@ var Agent = class extends MastraBase {
|
|
|
15722
15849
|
}
|
|
15723
15850
|
const systemInstructions = await this.resolveTitleInstructions(requestContext, instructions);
|
|
15724
15851
|
let text = "";
|
|
15725
|
-
if (llm.getModel()
|
|
15852
|
+
if (isSupportedLanguageModel(llm.getModel())) {
|
|
15726
15853
|
const messageList = new MessageList().add(
|
|
15727
15854
|
[
|
|
15728
15855
|
{
|
|
@@ -16674,7 +16801,7 @@ var Agent = class extends MastraBase {
|
|
|
16674
16801
|
result[id] = scorerObject;
|
|
16675
16802
|
}
|
|
16676
16803
|
}
|
|
16677
|
-
if (Object.keys(result).length === 0) {
|
|
16804
|
+
if (Object.keys(result).length === 0 && Object.keys(overrideScorers).length > 0) {
|
|
16678
16805
|
throw new MastraError({
|
|
16679
16806
|
id: "AGENT_GENEREATE_SCORER_NOT_FOUND",
|
|
16680
16807
|
domain: "AGENT" /* AGENT */,
|
|
@@ -16691,8 +16818,11 @@ var Agent = class extends MastraBase {
|
|
|
16691
16818
|
async prepareModels(requestContext, model) {
|
|
16692
16819
|
if (model || !Array.isArray(this.model)) {
|
|
16693
16820
|
const modelToUse = model ?? this.model;
|
|
16694
|
-
const resolvedModel =
|
|
16695
|
-
|
|
16821
|
+
const resolvedModel = await this.resolveModelConfig(
|
|
16822
|
+
modelToUse,
|
|
16823
|
+
requestContext
|
|
16824
|
+
);
|
|
16825
|
+
if (!isSupportedLanguageModel(resolvedModel)) {
|
|
16696
16826
|
const mastraError = new MastraError({
|
|
16697
16827
|
id: "AGENT_PREPARE_MODELS_INCOMPATIBLE_WITH_MODEL_ARRAY_V1",
|
|
16698
16828
|
domain: "AGENT" /* AGENT */,
|
|
@@ -16700,26 +16830,30 @@ var Agent = class extends MastraBase {
|
|
|
16700
16830
|
details: {
|
|
16701
16831
|
agentName: this.name
|
|
16702
16832
|
},
|
|
16703
|
-
text: `[Agent:${this.name}] - Only v2 models are allowed when an array of models is provided`
|
|
16833
|
+
text: `[Agent:${this.name}] - Only v2/v3 models are allowed when an array of models is provided`
|
|
16704
16834
|
});
|
|
16705
16835
|
this.logger.trackException(mastraError);
|
|
16706
16836
|
this.logger.error(mastraError.toString());
|
|
16707
16837
|
throw mastraError;
|
|
16708
16838
|
}
|
|
16839
|
+
let headers;
|
|
16840
|
+
if (resolvedModel instanceof ModelRouterLanguageModel) {
|
|
16841
|
+
headers = resolvedModel.config?.headers;
|
|
16842
|
+
}
|
|
16709
16843
|
return [
|
|
16710
16844
|
{
|
|
16711
16845
|
id: "main",
|
|
16712
|
-
// TODO fix type check
|
|
16713
16846
|
model: resolvedModel,
|
|
16714
16847
|
maxRetries: this.maxRetries ?? 0,
|
|
16715
|
-
enabled: true
|
|
16848
|
+
enabled: true,
|
|
16849
|
+
headers
|
|
16716
16850
|
}
|
|
16717
16851
|
];
|
|
16718
16852
|
}
|
|
16719
16853
|
const models = await Promise.all(
|
|
16720
16854
|
this.model.map(async (modelConfig) => {
|
|
16721
16855
|
const model2 = await this.resolveModelConfig(modelConfig.model, requestContext);
|
|
16722
|
-
if (!
|
|
16856
|
+
if (!isSupportedLanguageModel(model2)) {
|
|
16723
16857
|
const mastraError = new MastraError({
|
|
16724
16858
|
id: "AGENT_PREPARE_MODELS_INCOMPATIBLE_WITH_MODEL_ARRAY_V1",
|
|
16725
16859
|
domain: "AGENT" /* AGENT */,
|
|
@@ -16727,7 +16861,7 @@ var Agent = class extends MastraBase {
|
|
|
16727
16861
|
details: {
|
|
16728
16862
|
agentName: this.name
|
|
16729
16863
|
},
|
|
16730
|
-
text: `[Agent:${this.name}] - Only v2 models are allowed when an array of models is provided`
|
|
16864
|
+
text: `[Agent:${this.name}] - Only v2/v3 models are allowed when an array of models is provided`
|
|
16731
16865
|
});
|
|
16732
16866
|
this.logger.trackException(mastraError);
|
|
16733
16867
|
this.logger.error(mastraError.toString());
|
|
@@ -16748,11 +16882,16 @@ var Agent = class extends MastraBase {
|
|
|
16748
16882
|
this.logger.error(mastraError.toString());
|
|
16749
16883
|
throw mastraError;
|
|
16750
16884
|
}
|
|
16885
|
+
let headers;
|
|
16886
|
+
if (model2 instanceof ModelRouterLanguageModel) {
|
|
16887
|
+
headers = model2.config?.headers;
|
|
16888
|
+
}
|
|
16751
16889
|
return {
|
|
16752
16890
|
id: modelId,
|
|
16753
16891
|
model: model2,
|
|
16754
16892
|
maxRetries: modelConfig.maxRetries ?? 0,
|
|
16755
|
-
enabled: modelConfig.enabled ?? true
|
|
16893
|
+
enabled: modelConfig.enabled ?? true,
|
|
16894
|
+
headers
|
|
16756
16895
|
};
|
|
16757
16896
|
})
|
|
16758
16897
|
);
|
|
@@ -16762,7 +16901,11 @@ var Agent = class extends MastraBase {
|
|
|
16762
16901
|
* Executes the agent call, handling tools, memory, and streaming.
|
|
16763
16902
|
* @internal
|
|
16764
16903
|
*/
|
|
16765
|
-
async #execute({
|
|
16904
|
+
async #execute({
|
|
16905
|
+
methodType,
|
|
16906
|
+
resumeContext,
|
|
16907
|
+
...options
|
|
16908
|
+
}) {
|
|
16766
16909
|
const existingSnapshot = resumeContext?.snapshot;
|
|
16767
16910
|
let snapshotMemoryInfo;
|
|
16768
16911
|
if (existingSnapshot) {
|
|
@@ -17109,14 +17252,14 @@ var Agent = class extends MastraBase {
|
|
|
17109
17252
|
requestContext: mergedOptions.requestContext
|
|
17110
17253
|
});
|
|
17111
17254
|
const modelInfo = llm.getModel();
|
|
17112
|
-
if (modelInfo
|
|
17255
|
+
if (!isSupportedLanguageModel(modelInfo)) {
|
|
17113
17256
|
const modelId = modelInfo.modelId || "unknown";
|
|
17114
17257
|
const provider = modelInfo.provider || "unknown";
|
|
17115
17258
|
throw new MastraError({
|
|
17116
17259
|
id: "AGENT_GENERATE_V1_MODEL_NOT_SUPPORTED",
|
|
17117
17260
|
domain: "AGENT" /* AGENT */,
|
|
17118
17261
|
category: "USER" /* USER */,
|
|
17119
|
-
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.`,
|
|
17262
|
+
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.`,
|
|
17120
17263
|
details: {
|
|
17121
17264
|
agentName: this.name,
|
|
17122
17265
|
modelId,
|
|
@@ -17171,14 +17314,14 @@ var Agent = class extends MastraBase {
|
|
|
17171
17314
|
requestContext: mergedOptions.requestContext
|
|
17172
17315
|
});
|
|
17173
17316
|
const modelInfo = llm.getModel();
|
|
17174
|
-
if (modelInfo
|
|
17317
|
+
if (!isSupportedLanguageModel(modelInfo)) {
|
|
17175
17318
|
const modelId = modelInfo.modelId || "unknown";
|
|
17176
17319
|
const provider = modelInfo.provider || "unknown";
|
|
17177
17320
|
throw new MastraError({
|
|
17178
17321
|
id: "AGENT_STREAM_V1_MODEL_NOT_SUPPORTED",
|
|
17179
17322
|
domain: "AGENT" /* AGENT */,
|
|
17180
17323
|
category: "USER" /* USER */,
|
|
17181
|
-
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.`,
|
|
17324
|
+
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.`,
|
|
17182
17325
|
details: {
|
|
17183
17326
|
agentName: this.name,
|
|
17184
17327
|
modelId,
|
|
@@ -17240,7 +17383,7 @@ var Agent = class extends MastraBase {
|
|
|
17240
17383
|
const llm = await this.getLLM({
|
|
17241
17384
|
requestContext: mergedStreamOptions.requestContext
|
|
17242
17385
|
});
|
|
17243
|
-
if (llm.getModel()
|
|
17386
|
+
if (!isSupportedLanguageModel(llm.getModel())) {
|
|
17244
17387
|
throw new MastraError({
|
|
17245
17388
|
id: "AGENT_STREAM_V1_MODEL_NOT_SUPPORTED",
|
|
17246
17389
|
domain: "AGENT" /* AGENT */,
|
|
@@ -17480,7 +17623,7 @@ var ModerationProcessor = class _ModerationProcessor {
|
|
|
17480
17623
|
reason: z8.string().describe("Brief explanation of why content was flagged").nullable()
|
|
17481
17624
|
});
|
|
17482
17625
|
let response;
|
|
17483
|
-
if (model
|
|
17626
|
+
if (isSupportedLanguageModel(model)) {
|
|
17484
17627
|
response = await this.moderationAgent.generate(prompt, {
|
|
17485
17628
|
structuredOutput: {
|
|
17486
17629
|
schema,
|
|
@@ -17700,7 +17843,7 @@ var PromptInjectionDetector = class _PromptInjectionDetector {
|
|
|
17700
17843
|
rewritten_content: z8.string().describe("The rewritten content that neutralizes the attack while preserving any legitimate user intent").nullable()
|
|
17701
17844
|
});
|
|
17702
17845
|
}
|
|
17703
|
-
if (model
|
|
17846
|
+
if (isSupportedLanguageModel(model)) {
|
|
17704
17847
|
response = await this.detectionAgent.generate(prompt, {
|
|
17705
17848
|
structuredOutput: {
|
|
17706
17849
|
schema,
|
|
@@ -17948,7 +18091,7 @@ var PIIDetector = class _PIIDetector {
|
|
|
17948
18091
|
redacted_content: z8.string().describe("The content with all PII redacted according to the redaction method").nullable()
|
|
17949
18092
|
}) : baseSchema;
|
|
17950
18093
|
let response;
|
|
17951
|
-
if (model
|
|
18094
|
+
if (isSupportedLanguageModel(model)) {
|
|
17952
18095
|
response = await this.detectionAgent.generate(prompt, {
|
|
17953
18096
|
structuredOutput: {
|
|
17954
18097
|
schema,
|
|
@@ -18410,7 +18553,7 @@ var LanguageDetector = class _LanguageDetector {
|
|
|
18410
18553
|
const schema = this.strategy === "translate" ? baseSchema.extend({
|
|
18411
18554
|
translated_text: z8.string().describe("Translated text").nullable()
|
|
18412
18555
|
}) : baseSchema;
|
|
18413
|
-
if (model
|
|
18556
|
+
if (isSupportedLanguageModel(model)) {
|
|
18414
18557
|
response = await this.detectionAgent.generate(prompt, {
|
|
18415
18558
|
structuredOutput: {
|
|
18416
18559
|
schema
|
|
@@ -19088,7 +19231,7 @@ var SystemPromptScrubber = class {
|
|
|
19088
19231
|
const schema = this.strategy === "redact" ? baseSchema.extend({
|
|
19089
19232
|
redacted_content: z.string().describe("Redacted content").nullable()
|
|
19090
19233
|
}) : baseSchema;
|
|
19091
|
-
if (model
|
|
19234
|
+
if (isSupportedLanguageModel(model)) {
|
|
19092
19235
|
result = await this.detectionAgent.generate(text, {
|
|
19093
19236
|
structuredOutput: {
|
|
19094
19237
|
schema,
|
|
@@ -20567,6 +20710,6 @@ var MockMemory = class extends MastraMemory {
|
|
|
20567
20710
|
}
|
|
20568
20711
|
};
|
|
20569
20712
|
|
|
20570
|
-
export { AISDKV5OutputStream, Agent, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, EventEmitterPubSub, ExecutionEngine, FilePartSchema, ImagePartSchema, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MemoryProcessor, MessageContentSchema, MessageHistory, MessagePartSchema, MockMemory, ModerationProcessor, PIIDetector, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ReasoningPartSchema, Run, SemanticRecall, SourcePartSchema, StepStartPartSchema, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, TripWire, UnicodeNormalizer, Workflow, WorkflowRunOutput, WorkingMemory, augmentWithInit, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createStep, createTimeTravelExecutionParams, createWorkflow, getResumeLabelsByStepId, getStepIds, getStepResult, getZodErrors, hydrateSerializedStepErrors, isProcessor, isProcessorWorkflow, loop, mapVariable, memoryDefaultOptions, parseMemoryRequestContext, resolveThreadIdFromArgs, runCountDeprecationMessage, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepResumeData, validateStepStateData, validateStepSuspendData };
|
|
20571
|
-
//# sourceMappingURL=chunk-
|
|
20572
|
-
//# sourceMappingURL=chunk-
|
|
20713
|
+
export { AISDKV5OutputStream, Agent, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, EventEmitterPubSub, ExecutionEngine, FilePartSchema, ImagePartSchema, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MemoryProcessor, MessageContentSchema, MessageHistory, MessagePartSchema, MockMemory, ModerationProcessor, PIIDetector, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ReasoningPartSchema, Run, SemanticRecall, SourcePartSchema, StepStartPartSchema, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, TripWire, UnicodeNormalizer, Workflow, WorkflowRunOutput, WorkingMemory, augmentWithInit, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createStep, createTimeTravelExecutionParams, createWorkflow, getResumeLabelsByStepId, getStepIds, getStepResult, getZodErrors, hydrateSerializedStepErrors, isProcessor, isProcessorWorkflow, isSupportedLanguageModel, loop, mapVariable, memoryDefaultOptions, parseMemoryRequestContext, resolveThreadIdFromArgs, runCountDeprecationMessage, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepResumeData, validateStepStateData, validateStepSuspendData };
|
|
20714
|
+
//# sourceMappingURL=chunk-QF4MHFSU.js.map
|
|
20715
|
+
//# sourceMappingURL=chunk-QF4MHFSU.js.map
|