@mastra/core 1.0.0-beta.7 → 1.0.0-beta.9
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 +77 -0
- package/dist/agent/agent.d.ts +1 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +9 -9
- 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/workflows/prepare-stream/index.d.ts +2 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +2 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/{chunk-PJ7AYWAX.cjs → chunk-3DRGAKUH.cjs} +382 -13
- package/dist/chunk-3DRGAKUH.cjs.map +1 -0
- package/dist/{chunk-EE5NIGJ4.js → chunk-4GLDYGNN.js} +3 -3
- package/dist/{chunk-EE5NIGJ4.js.map → chunk-4GLDYGNN.js.map} +1 -1
- package/dist/{chunk-4GTU7MB2.js → chunk-7IMDJAYQ.js} +5 -5
- package/dist/{chunk-4GTU7MB2.js.map → chunk-7IMDJAYQ.js.map} +1 -1
- package/dist/{chunk-M7CQULF7.cjs → chunk-7S7TLMTS.cjs} +287 -10
- package/dist/chunk-7S7TLMTS.cjs.map +1 -0
- package/dist/{chunk-NAKPEQEQ.js → chunk-A4C3AGVS.js} +5 -5
- package/dist/{chunk-NAKPEQEQ.js.map → chunk-A4C3AGVS.js.map} +1 -1
- package/dist/{chunk-DMPHPHMU.js → chunk-APMPOYPI.js} +3 -3
- package/dist/{chunk-DMPHPHMU.js.map → chunk-APMPOYPI.js.map} +1 -1
- package/dist/{chunk-POM7FCH5.js → chunk-ARSSSQQP.js} +141 -48
- package/dist/chunk-ARSSSQQP.js.map +1 -0
- package/dist/{chunk-HJNEZRI4.cjs → chunk-CKRWR5DS.cjs} +15 -15
- package/dist/{chunk-HJNEZRI4.cjs.map → chunk-CKRWR5DS.cjs.map} +1 -1
- package/dist/{chunk-26YAGTXK.cjs → chunk-DWB7SBVC.cjs} +28 -32
- package/dist/chunk-DWB7SBVC.cjs.map +1 -0
- package/dist/{chunk-URMN7TTH.cjs → chunk-EGXQVF75.cjs} +380 -6
- package/dist/chunk-EGXQVF75.cjs.map +1 -0
- package/dist/{chunk-4AP234N6.cjs → chunk-F77YTHXI.cjs} +4 -4
- package/dist/{chunk-4AP234N6.cjs.map → chunk-F77YTHXI.cjs.map} +1 -1
- package/dist/{chunk-6C2PU6J4.cjs → chunk-HSRQXO6F.cjs} +6 -6
- package/dist/{chunk-6C2PU6J4.cjs.map → chunk-HSRQXO6F.cjs.map} +1 -1
- package/dist/{chunk-YUXTDKYN.cjs → chunk-IISGCZJ4.cjs} +15 -15
- package/dist/{chunk-YUXTDKYN.cjs.map → chunk-IISGCZJ4.cjs.map} +1 -1
- package/dist/{chunk-EPMSC67U.js → chunk-LB7UOP2X.js} +376 -7
- package/dist/chunk-LB7UOP2X.js.map +1 -0
- package/dist/{chunk-URBPEE67.js → chunk-MCRIVYUB.js} +3 -3
- package/dist/{chunk-URBPEE67.js.map → chunk-MCRIVYUB.js.map} +1 -1
- package/dist/{chunk-AZQMPE7G.cjs → chunk-MRFUISXC.cjs} +3 -3
- package/dist/{chunk-AZQMPE7G.cjs.map → chunk-MRFUISXC.cjs.map} +1 -1
- package/dist/{chunk-TLLXRG2Z.js → chunk-OEIVMCWX.js} +3 -3
- package/dist/{chunk-TLLXRG2Z.js.map → chunk-OEIVMCWX.js.map} +1 -1
- package/dist/{chunk-FNSFXWDN.js → chunk-PIHOAJTA.js} +2 -2
- package/dist/chunk-PIHOAJTA.js.map +1 -0
- package/dist/{chunk-ZUWJCGLM.js → chunk-QM5SRDJX.js} +4 -5
- package/dist/chunk-QM5SRDJX.js.map +1 -0
- package/dist/{chunk-Z4Y554NX.js → chunk-QTEIZ2XG.js} +8 -12
- package/dist/chunk-QTEIZ2XG.js.map +1 -0
- package/dist/{chunk-VBKMNIWK.cjs → chunk-RIG4JP3V.cjs} +11 -11
- package/dist/{chunk-VBKMNIWK.cjs.map → chunk-RIG4JP3V.cjs.map} +1 -1
- package/dist/{chunk-5T53HHNP.js → chunk-SLX3NVAC.js} +4 -4
- package/dist/{chunk-5T53HHNP.js.map → chunk-SLX3NVAC.js.map} +1 -1
- package/dist/{chunk-TQB2HMEC.cjs → chunk-SVLMF4UZ.cjs} +44 -45
- package/dist/chunk-SVLMF4UZ.cjs.map +1 -0
- package/dist/{chunk-3EYBRHB2.cjs → chunk-UVM27J4A.cjs} +2 -2
- package/dist/chunk-UVM27J4A.cjs.map +1 -0
- package/dist/{chunk-GZ6MCDK2.js → chunk-VQ3FTSRC.js} +379 -5
- package/dist/chunk-VQ3FTSRC.js.map +1 -0
- package/dist/{chunk-YBEW5YWC.cjs → chunk-VRFSEZBA.cjs} +6 -6
- package/dist/{chunk-YBEW5YWC.cjs.map → chunk-VRFSEZBA.cjs.map} +1 -1
- package/dist/{chunk-RBBEMTMA.cjs → chunk-XMT5T4F2.cjs} +184 -89
- package/dist/chunk-XMT5T4F2.cjs.map +1 -0
- package/dist/{chunk-G32WDDGV.js → chunk-ZINZHEXZ.js} +282 -9
- package/dist/chunk-ZINZHEXZ.js.map +1 -0
- package/dist/evals/index.cjs +9 -9
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/evals/types.d.ts +21 -20
- package/dist/evals/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +11 -11
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +180 -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/types.d.ts +1 -0
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +191 -5
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +6 -6
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +6 -0
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/models-dev-23RN2WHG.js +3 -0
- package/dist/{models-dev-6GD3644V.js.map → models-dev-23RN2WHG.js.map} +1 -1
- package/dist/models-dev-EO3SUIY2.cjs +12 -0
- package/dist/{models-dev-IUQBXJSS.cjs.map → models-dev-EO3SUIY2.cjs.map} +1 -1
- package/dist/observability/index.cjs +10 -10
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +4 -0
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/processors/index.cjs +17 -17
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-FM3IVY6C.js +3 -0
- package/dist/{provider-registry-ZTMZMTVV.js.map → provider-registry-FM3IVY6C.js.map} +1 -1
- package/dist/provider-registry-Q6T32VC5.cjs +40 -0
- package/dist/{provider-registry-7IFOXWPR.cjs.map → provider-registry-Q6T32VC5.cjs.map} +1 -1
- package/dist/provider-registry.json +376 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +1 -1
- package/dist/storage/base.d.ts +50 -2
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.d.ts +3 -1
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/domains/agents/base.d.ts +49 -0
- package/dist/storage/domains/agents/base.d.ts.map +1 -0
- package/dist/storage/domains/agents/index.d.ts +3 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -0
- package/dist/storage/domains/agents/inmemory.d.ts +22 -0
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/index.d.ts +1 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/scores/base.d.ts +2 -2
- package/dist/storage/domains/scores/base.d.ts.map +1 -1
- package/dist/storage/domains/scores/inmemory.d.ts +2 -2
- package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +50 -34
- package/dist/storage/index.js +1 -1
- package/dist/storage/mock.d.ts +3 -2
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +82 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/base/output-format-handlers.d.ts +13 -0
- package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
- package/dist/stream/index.cjs +15 -11
- package/dist/stream/index.d.ts +1 -1
- package/dist/stream/index.d.ts.map +1 -1
- package/dist/stream/index.js +2 -2
- package/dist/test-utils/llm-mock.cjs +10 -10
- package/dist/test-utils/llm-mock.js +3 -3
- package/dist/utils.cjs +22 -22
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +1 -1
- package/dist/workflows/default.d.ts +2 -2
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts.map +1 -1
- package/dist/workflows/index.cjs +24 -20
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +4 -3
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +10 -1
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +3 -3
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/llm/model/provider-types.generated.d.ts +180 -1
- package/dist/chunk-26YAGTXK.cjs.map +0 -1
- package/dist/chunk-3EYBRHB2.cjs.map +0 -1
- package/dist/chunk-EPMSC67U.js.map +0 -1
- package/dist/chunk-FNSFXWDN.js.map +0 -1
- package/dist/chunk-G32WDDGV.js.map +0 -1
- package/dist/chunk-GZ6MCDK2.js.map +0 -1
- package/dist/chunk-M7CQULF7.cjs.map +0 -1
- package/dist/chunk-PJ7AYWAX.cjs.map +0 -1
- package/dist/chunk-POM7FCH5.js.map +0 -1
- package/dist/chunk-RBBEMTMA.cjs.map +0 -1
- package/dist/chunk-TQB2HMEC.cjs.map +0 -1
- package/dist/chunk-URMN7TTH.cjs.map +0 -1
- package/dist/chunk-Z4Y554NX.js.map +0 -1
- package/dist/chunk-ZUWJCGLM.js.map +0 -1
- package/dist/models-dev-6GD3644V.js +0 -3
- package/dist/models-dev-IUQBXJSS.cjs +0 -12
- package/dist/provider-registry-7IFOXWPR.cjs +0 -40
- package/dist/provider-registry-ZTMZMTVV.js +0 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DefaultVoice } from './chunk-F2GAJSBI.js';
|
|
2
2
|
import { EMITTER_SYMBOL, STREAM_FORMAT_SYMBOL } from './chunk-NLNKQD2T.js';
|
|
3
|
-
import { InMemoryStore } from './chunk-
|
|
4
|
-
import { MessageList, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-
|
|
5
|
-
import { ModelRouterEmbeddingModel, resolveModelConfig } from './chunk-
|
|
6
|
-
import { MastraLLMV1 } from './chunk-
|
|
3
|
+
import { InMemoryStore } from './chunk-ZINZHEXZ.js';
|
|
4
|
+
import { MessageList, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-APMPOYPI.js';
|
|
5
|
+
import { ModelRouterEmbeddingModel, resolveModelConfig } from './chunk-A4C3AGVS.js';
|
|
6
|
+
import { MastraLLMV1 } from './chunk-7IMDJAYQ.js';
|
|
7
7
|
import { executeHook } from './chunk-L54GIUCB.js';
|
|
8
|
-
import { removeUndefinedValues, deepMerge, ensureToolProperties, makeCoreTool, createMastraProxy, isZodType, selectFields, delay } from './chunk-
|
|
9
|
-
import { getOrCreateSpan, wrapMastra, executeWithContextSync } from './chunk-
|
|
8
|
+
import { removeUndefinedValues, deepMerge, ensureToolProperties, makeCoreTool, createMastraProxy, isZodType, selectFields, delay } from './chunk-MCRIVYUB.js';
|
|
9
|
+
import { getOrCreateSpan, wrapMastra, executeWithContextSync } from './chunk-PIHOAJTA.js';
|
|
10
10
|
import { MastraError, getErrorFromUnknown } from './chunk-JJ5O45LH.js';
|
|
11
11
|
import { ToolStream } from './chunk-F54IK3GJ.js';
|
|
12
12
|
import { Tool, createTool } from './chunk-4F6RAJFU.js';
|
|
@@ -977,14 +977,15 @@ async function validateStepResumeData({ resumeData, step }) {
|
|
|
977
977
|
}
|
|
978
978
|
async function validateStepSuspendData({
|
|
979
979
|
suspendData,
|
|
980
|
-
step
|
|
980
|
+
step,
|
|
981
|
+
validateInputs
|
|
981
982
|
}) {
|
|
982
983
|
if (!suspendData) {
|
|
983
984
|
return { suspendData: void 0, validationError: void 0 };
|
|
984
985
|
}
|
|
985
986
|
let validationError;
|
|
986
987
|
const suspendSchema = step.suspendSchema;
|
|
987
|
-
if (suspendSchema) {
|
|
988
|
+
if (suspendSchema && validateInputs) {
|
|
988
989
|
const validatedSuspendData = await suspendSchema.safeParseAsync(suspendData);
|
|
989
990
|
if (!validatedSuspendData.success) {
|
|
990
991
|
const errors = getZodErrors(validatedSuspendData.error);
|
|
@@ -996,6 +997,28 @@ async function validateStepSuspendData({
|
|
|
996
997
|
}
|
|
997
998
|
return { suspendData, validationError };
|
|
998
999
|
}
|
|
1000
|
+
async function validateStepStateData({
|
|
1001
|
+
stateData,
|
|
1002
|
+
step,
|
|
1003
|
+
validateInputs
|
|
1004
|
+
}) {
|
|
1005
|
+
if (!stateData) {
|
|
1006
|
+
return { stateData: void 0, validationError: void 0 };
|
|
1007
|
+
}
|
|
1008
|
+
let validationError;
|
|
1009
|
+
const stateSchema = step.stateSchema;
|
|
1010
|
+
if (stateSchema && validateInputs) {
|
|
1011
|
+
const validatedStateData = await stateSchema.safeParseAsync(stateData);
|
|
1012
|
+
if (!validatedStateData.success) {
|
|
1013
|
+
const errors = getZodErrors(validatedStateData.error);
|
|
1014
|
+
const errorMessages = errors.map((e) => `- ${e.path?.join(".")}: ${e.message}`).join("\n");
|
|
1015
|
+
validationError = new Error("Step state data validation failed: \n" + errorMessages);
|
|
1016
|
+
} else {
|
|
1017
|
+
stateData = validatedStateData.data;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
return { stateData, validationError };
|
|
1021
|
+
}
|
|
999
1022
|
function getResumeLabelsByStepId(resumeLabels, stepId) {
|
|
1000
1023
|
return Object.entries(resumeLabels).filter(([_, value]) => value.stepId === stepId).reduce(
|
|
1001
1024
|
(acc, [key, value]) => {
|
|
@@ -1315,18 +1338,12 @@ async function executeConditional(engine, params) {
|
|
|
1315
1338
|
requestContext,
|
|
1316
1339
|
inputData: prevOutput,
|
|
1317
1340
|
state: executionContext.state,
|
|
1318
|
-
setState: (state) => {
|
|
1319
|
-
executionContext.state = state;
|
|
1320
|
-
},
|
|
1321
1341
|
retryCount: -1,
|
|
1322
1342
|
tracingContext: {
|
|
1323
1343
|
currentSpan: evalSpan
|
|
1324
1344
|
},
|
|
1325
1345
|
getInitData: () => stepResults?.input,
|
|
1326
1346
|
getStepResult: getStepResult.bind(null, stepResults),
|
|
1327
|
-
// TODO: this function shouldn't have suspend probably?
|
|
1328
|
-
suspend: async (_suspendPayload) => {
|
|
1329
|
-
},
|
|
1330
1347
|
bail: () => {
|
|
1331
1348
|
},
|
|
1332
1349
|
abort: () => {
|
|
@@ -1566,9 +1583,6 @@ async function executeLoop(engine, params) {
|
|
|
1566
1583
|
requestContext,
|
|
1567
1584
|
inputData: result.output,
|
|
1568
1585
|
state: executionContext.state,
|
|
1569
|
-
setState: (state) => {
|
|
1570
|
-
executionContext.state = state;
|
|
1571
|
-
},
|
|
1572
1586
|
retryCount: -1,
|
|
1573
1587
|
tracingContext: {
|
|
1574
1588
|
currentSpan: evalSpan
|
|
@@ -1576,8 +1590,6 @@ async function executeLoop(engine, params) {
|
|
|
1576
1590
|
iterationCount: iteration + 1,
|
|
1577
1591
|
getInitData: () => stepResults?.input,
|
|
1578
1592
|
getStepResult: getStepResult.bind(null, stepResults),
|
|
1579
|
-
suspend: async (_suspendPayload) => {
|
|
1580
|
-
},
|
|
1581
1593
|
bail: () => {
|
|
1582
1594
|
},
|
|
1583
1595
|
abort: () => {
|
|
@@ -2291,7 +2303,7 @@ async function executeSleep(engine, params) {
|
|
|
2291
2303
|
requestContext,
|
|
2292
2304
|
inputData: prevOutput,
|
|
2293
2305
|
state: executionContext.state,
|
|
2294
|
-
setState: (state) => {
|
|
2306
|
+
setState: async (state) => {
|
|
2295
2307
|
executionContext.state = state;
|
|
2296
2308
|
},
|
|
2297
2309
|
retryCount: -1,
|
|
@@ -2372,7 +2384,7 @@ async function executeSleepUntil(engine, params) {
|
|
|
2372
2384
|
requestContext,
|
|
2373
2385
|
inputData: prevOutput,
|
|
2374
2386
|
state: executionContext.state,
|
|
2375
|
-
setState: (state) => {
|
|
2387
|
+
setState: async (state) => {
|
|
2376
2388
|
executionContext.state = state;
|
|
2377
2389
|
},
|
|
2378
2390
|
retryCount: -1,
|
|
@@ -2581,9 +2593,16 @@ async function executeStep(engine, params) {
|
|
|
2581
2593
|
requestContext,
|
|
2582
2594
|
inputData,
|
|
2583
2595
|
state: executionContext.state,
|
|
2584
|
-
setState: (state) => {
|
|
2585
|
-
|
|
2586
|
-
|
|
2596
|
+
setState: async (state) => {
|
|
2597
|
+
const { stateData, validationError: stateValidationError } = await validateStepStateData({
|
|
2598
|
+
stateData: state,
|
|
2599
|
+
step,
|
|
2600
|
+
validateInputs: engine.options?.validateInputs ?? true
|
|
2601
|
+
});
|
|
2602
|
+
if (stateValidationError) {
|
|
2603
|
+
throw stateValidationError;
|
|
2604
|
+
}
|
|
2605
|
+
contextMutations.stateUpdate = stateData;
|
|
2587
2606
|
},
|
|
2588
2607
|
retryCount,
|
|
2589
2608
|
resumeData: resumeDataToUse,
|
|
@@ -2594,7 +2613,8 @@ async function executeStep(engine, params) {
|
|
|
2594
2613
|
suspend: async (suspendPayload, suspendOptions) => {
|
|
2595
2614
|
const { suspendData, validationError: suspendValidationError } = await validateStepSuspendData({
|
|
2596
2615
|
suspendData: suspendPayload,
|
|
2597
|
-
step
|
|
2616
|
+
step,
|
|
2617
|
+
validateInputs: engine.options?.validateInputs ?? true
|
|
2598
2618
|
});
|
|
2599
2619
|
if (suspendValidationError) {
|
|
2600
2620
|
throw suspendValidationError;
|
|
@@ -2669,9 +2689,6 @@ async function executeStep(engine, params) {
|
|
|
2669
2689
|
const { result: durableResult } = stepRetryResult;
|
|
2670
2690
|
Object.assign(executionContext.suspendedPaths, durableResult.contextMutations.suspendedPaths);
|
|
2671
2691
|
Object.assign(executionContext.resumeLabels, durableResult.contextMutations.resumeLabels);
|
|
2672
|
-
if (durableResult.contextMutations.stateUpdate !== null) {
|
|
2673
|
-
executionContext.state = durableResult.contextMutations.stateUpdate;
|
|
2674
|
-
}
|
|
2675
2692
|
if (engine.requiresDurableContextSerialization() && durableResult.contextMutations.requestContextUpdate) {
|
|
2676
2693
|
requestContext.clear();
|
|
2677
2694
|
for (const [key, value] of Object.entries(durableResult.contextMutations.requestContextUpdate)) {
|
|
@@ -2729,7 +2746,10 @@ async function executeStep(engine, params) {
|
|
|
2729
2746
|
return {
|
|
2730
2747
|
result: stepResult,
|
|
2731
2748
|
stepResults: { [step.id]: stepResult },
|
|
2732
|
-
mutableContext: engine.buildMutableContext(
|
|
2749
|
+
mutableContext: engine.buildMutableContext({
|
|
2750
|
+
...executionContext,
|
|
2751
|
+
state: stepRetryResult.ok ? stepRetryResult.result.contextMutations.stateUpdate ?? executionContext.state : executionContext.state
|
|
2752
|
+
}),
|
|
2733
2753
|
requestContext: engine.serializeRequestContext(requestContext)
|
|
2734
2754
|
};
|
|
2735
2755
|
}
|
|
@@ -3077,7 +3097,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
3077
3097
|
* Apply mutable context changes back to the execution context.
|
|
3078
3098
|
*/
|
|
3079
3099
|
applyMutableContext(executionContext, mutableContext) {
|
|
3080
|
-
executionContext.state
|
|
3100
|
+
Object.assign(executionContext.state, mutableContext.state);
|
|
3081
3101
|
Object.assign(executionContext.suspendedPaths, mutableContext.suspendedPaths);
|
|
3082
3102
|
Object.assign(executionContext.resumeLabels, mutableContext.resumeLabels);
|
|
3083
3103
|
}
|
|
@@ -4041,7 +4061,7 @@ var Workflow = class extends MastraBase {
|
|
|
4041
4061
|
return stepRes?.status === "suspended";
|
|
4042
4062
|
});
|
|
4043
4063
|
if (res.state) {
|
|
4044
|
-
setState(res.state);
|
|
4064
|
+
await setState(res.state);
|
|
4045
4065
|
}
|
|
4046
4066
|
if (suspendedSteps?.length) {
|
|
4047
4067
|
for (const [stepName, stepResult] of suspendedSteps) {
|
|
@@ -8074,6 +8094,7 @@ var MastraLLMVNext = class extends MastraBase {
|
|
|
8074
8094
|
requireToolApproval,
|
|
8075
8095
|
_internal,
|
|
8076
8096
|
agentId,
|
|
8097
|
+
agentName,
|
|
8077
8098
|
toolCallId,
|
|
8078
8099
|
requestContext,
|
|
8079
8100
|
methodType,
|
|
@@ -8101,6 +8122,8 @@ var MastraLLMVNext = class extends MastraBase {
|
|
|
8101
8122
|
messages: [...messageList.getSystemMessages(), ...messages]
|
|
8102
8123
|
},
|
|
8103
8124
|
attributes: {
|
|
8125
|
+
agentId,
|
|
8126
|
+
agentName,
|
|
8104
8127
|
model: firstModel.modelId,
|
|
8105
8128
|
provider: firstModel.provider,
|
|
8106
8129
|
streaming: true,
|
|
@@ -8135,6 +8158,7 @@ var MastraLLMVNext = class extends MastraBase {
|
|
|
8135
8158
|
modelSpanTracker,
|
|
8136
8159
|
requireToolApproval,
|
|
8137
8160
|
agentId,
|
|
8161
|
+
agentName,
|
|
8138
8162
|
requestContext,
|
|
8139
8163
|
methodType,
|
|
8140
8164
|
includeRawChunks,
|
|
@@ -9167,6 +9191,7 @@ ${completionResult?.object?.finalResult}` : ""}
|
|
|
9167
9191
|
mastra: agent.getMastraInstance(),
|
|
9168
9192
|
agent: {
|
|
9169
9193
|
resourceId: initData.threadResourceId || networkName,
|
|
9194
|
+
toolCallId,
|
|
9170
9195
|
threadId: initData.threadId
|
|
9171
9196
|
},
|
|
9172
9197
|
runId,
|
|
@@ -12876,6 +12901,11 @@ var memoryDefaultOptions = {
|
|
|
12876
12901
|
}
|
|
12877
12902
|
};
|
|
12878
12903
|
var MastraMemory = class extends MastraBase {
|
|
12904
|
+
/**
|
|
12905
|
+
* Unique identifier for the memory instance.
|
|
12906
|
+
* If not provided, defaults to a static name 'default-memory'.
|
|
12907
|
+
*/
|
|
12908
|
+
id;
|
|
12879
12909
|
MAX_CONTEXT_TOKENS;
|
|
12880
12910
|
_storage;
|
|
12881
12911
|
vector;
|
|
@@ -12884,6 +12914,7 @@ var MastraMemory = class extends MastraBase {
|
|
|
12884
12914
|
#mastra;
|
|
12885
12915
|
constructor(config) {
|
|
12886
12916
|
super({ component: "MEMORY", name: config.name });
|
|
12917
|
+
this.id = config.id ?? config.name ?? "default-memory";
|
|
12887
12918
|
if (config.options) this.threadConfig = this.getMergedThreadConfig(config.options);
|
|
12888
12919
|
if (config.processors) {
|
|
12889
12920
|
throw new Error(
|
|
@@ -14417,6 +14448,7 @@ function createStreamStep({
|
|
|
14417
14448
|
requireToolApproval,
|
|
14418
14449
|
resumeContext,
|
|
14419
14450
|
agentId,
|
|
14451
|
+
agentName,
|
|
14420
14452
|
toolCallId,
|
|
14421
14453
|
methodType,
|
|
14422
14454
|
saveQueueManager,
|
|
@@ -14457,6 +14489,7 @@ function createStreamStep({
|
|
|
14457
14489
|
memory
|
|
14458
14490
|
},
|
|
14459
14491
|
agentId,
|
|
14492
|
+
agentName,
|
|
14460
14493
|
toolCallId,
|
|
14461
14494
|
methodType: modelMethodType
|
|
14462
14495
|
});
|
|
@@ -14483,6 +14516,7 @@ function createPrepareStreamWorkflow({
|
|
|
14483
14516
|
requireToolApproval,
|
|
14484
14517
|
resumeContext,
|
|
14485
14518
|
agentId,
|
|
14519
|
+
agentName,
|
|
14486
14520
|
toolCallId
|
|
14487
14521
|
}) {
|
|
14488
14522
|
const prepareToolsStep = createPrepareToolsStep({
|
|
@@ -14514,6 +14548,7 @@ function createPrepareStreamWorkflow({
|
|
|
14514
14548
|
requireToolApproval,
|
|
14515
14549
|
resumeContext,
|
|
14516
14550
|
agentId,
|
|
14551
|
+
agentName,
|
|
14517
14552
|
toolCallId,
|
|
14518
14553
|
methodType,
|
|
14519
14554
|
saveQueueManager,
|
|
@@ -15463,7 +15498,8 @@ var Agent = class extends MastraBase {
|
|
|
15463
15498
|
requestContext,
|
|
15464
15499
|
tracingContext,
|
|
15465
15500
|
messageList,
|
|
15466
|
-
agentId: this.id
|
|
15501
|
+
agentId: this.id,
|
|
15502
|
+
agentName: this.name
|
|
15467
15503
|
});
|
|
15468
15504
|
text = await result.text;
|
|
15469
15505
|
} else {
|
|
@@ -16021,16 +16057,25 @@ var Agent = class extends MastraBase {
|
|
|
16021
16057
|
threadId,
|
|
16022
16058
|
resourceId
|
|
16023
16059
|
});
|
|
16024
|
-
const run = await workflow.createRun();
|
|
16060
|
+
const run = await workflow.createRun({ runId });
|
|
16025
16061
|
const { initialState, inputData: workflowInputData } = inputData;
|
|
16062
|
+
const { resumeData, suspend } = context?.agent ?? {};
|
|
16026
16063
|
let result = void 0;
|
|
16027
16064
|
if (methodType === "generate" || methodType === "generateLegacy") {
|
|
16028
|
-
|
|
16029
|
-
|
|
16030
|
-
|
|
16031
|
-
|
|
16032
|
-
|
|
16033
|
-
|
|
16065
|
+
if (resumeData) {
|
|
16066
|
+
result = await run.resume({
|
|
16067
|
+
resumeData,
|
|
16068
|
+
requestContext,
|
|
16069
|
+
tracingContext: context?.tracingContext
|
|
16070
|
+
});
|
|
16071
|
+
} else {
|
|
16072
|
+
result = await run.start({
|
|
16073
|
+
inputData: workflowInputData,
|
|
16074
|
+
requestContext,
|
|
16075
|
+
tracingContext: context?.tracingContext,
|
|
16076
|
+
...initialState && { initialState }
|
|
16077
|
+
});
|
|
16078
|
+
}
|
|
16034
16079
|
} else if (methodType === "streamLegacy") {
|
|
16035
16080
|
const streamResult = run.streamLegacy({
|
|
16036
16081
|
inputData: workflowInputData,
|
|
@@ -16045,7 +16090,11 @@ var Agent = class extends MastraBase {
|
|
|
16045
16090
|
}
|
|
16046
16091
|
result = await streamResult.getWorkflowState();
|
|
16047
16092
|
} else if (methodType === "stream") {
|
|
16048
|
-
const streamResult = run.
|
|
16093
|
+
const streamResult = resumeData ? run.resumeStream({
|
|
16094
|
+
resumeData,
|
|
16095
|
+
requestContext,
|
|
16096
|
+
tracingContext: context?.tracingContext
|
|
16097
|
+
}) : run.stream({
|
|
16049
16098
|
inputData: workflowInputData,
|
|
16050
16099
|
requestContext,
|
|
16051
16100
|
tracingContext: context?.tracingContext,
|
|
@@ -16066,10 +16115,12 @@ var Agent = class extends MastraBase {
|
|
|
16066
16115
|
runId: run.runId
|
|
16067
16116
|
};
|
|
16068
16117
|
} else if (result?.status === "suspended") {
|
|
16069
|
-
|
|
16070
|
-
|
|
16071
|
-
|
|
16072
|
-
|
|
16118
|
+
const suspendedStep = result?.suspended?.[0]?.[0];
|
|
16119
|
+
const suspendPayload = result?.steps?.[suspendedStep]?.suspendPayload;
|
|
16120
|
+
if (suspendPayload?.__workflow_meta) {
|
|
16121
|
+
delete suspendPayload.__workflow_meta;
|
|
16122
|
+
}
|
|
16123
|
+
return suspend?.(suspendPayload);
|
|
16073
16124
|
} else {
|
|
16074
16125
|
return {
|
|
16075
16126
|
error: `Workflow should never reach this path, workflow returned no status`,
|
|
@@ -16541,6 +16592,7 @@ var Agent = class extends MastraBase {
|
|
|
16541
16592
|
requireToolApproval: options.requireToolApproval,
|
|
16542
16593
|
resumeContext,
|
|
16543
16594
|
agentId: this.id,
|
|
16595
|
+
agentName: this.name,
|
|
16544
16596
|
toolCallId: options.toolCallId
|
|
16545
16597
|
});
|
|
16546
16598
|
const run = await executionWorkflow.createRun();
|
|
@@ -17306,6 +17358,45 @@ var AISDKV5OutputStream = class {
|
|
|
17306
17358
|
return this.#modelOutput.object;
|
|
17307
17359
|
}
|
|
17308
17360
|
};
|
|
17361
|
+
function escapeUnescapedControlCharsInJsonStrings(text) {
|
|
17362
|
+
let result = "";
|
|
17363
|
+
let inString = false;
|
|
17364
|
+
let i = 0;
|
|
17365
|
+
while (i < text.length) {
|
|
17366
|
+
const char = text[i];
|
|
17367
|
+
if (char === "\\" && i + 1 < text.length) {
|
|
17368
|
+
result += char + text[i + 1];
|
|
17369
|
+
i += 2;
|
|
17370
|
+
continue;
|
|
17371
|
+
}
|
|
17372
|
+
if (char === '"') {
|
|
17373
|
+
inString = !inString;
|
|
17374
|
+
result += char;
|
|
17375
|
+
i++;
|
|
17376
|
+
continue;
|
|
17377
|
+
}
|
|
17378
|
+
if (inString) {
|
|
17379
|
+
if (char === "\n") {
|
|
17380
|
+
result += "\\n";
|
|
17381
|
+
i++;
|
|
17382
|
+
continue;
|
|
17383
|
+
}
|
|
17384
|
+
if (char === "\r") {
|
|
17385
|
+
result += "\\r";
|
|
17386
|
+
i++;
|
|
17387
|
+
continue;
|
|
17388
|
+
}
|
|
17389
|
+
if (char === " ") {
|
|
17390
|
+
result += "\\t";
|
|
17391
|
+
i++;
|
|
17392
|
+
continue;
|
|
17393
|
+
}
|
|
17394
|
+
}
|
|
17395
|
+
result += char;
|
|
17396
|
+
i++;
|
|
17397
|
+
}
|
|
17398
|
+
return result;
|
|
17399
|
+
}
|
|
17309
17400
|
var BaseFormatHandler = class {
|
|
17310
17401
|
/**
|
|
17311
17402
|
* The original user-provided schema (Zod, JSON Schema, or AI SDK Schema).
|
|
@@ -17397,7 +17488,8 @@ ${z42.prettifyError(result.error)}
|
|
|
17397
17488
|
}
|
|
17398
17489
|
}
|
|
17399
17490
|
/**
|
|
17400
|
-
* Preprocesses accumulated text to handle LLMs that wrap JSON in code blocks
|
|
17491
|
+
* Preprocesses accumulated text to handle LLMs that wrap JSON in code blocks
|
|
17492
|
+
* and fix common JSON formatting issues like unescaped newlines in strings.
|
|
17401
17493
|
* Extracts content from the first complete valid ```json...``` code block or removes opening ```json prefix if no complete code block is found (streaming chunks).
|
|
17402
17494
|
* @param accumulatedText - Raw accumulated text from streaming
|
|
17403
17495
|
* @returns Processed text ready for JSON parsing
|
|
@@ -17418,6 +17510,7 @@ ${z42.prettifyError(result.error)}
|
|
|
17418
17510
|
processedText = processedText.replace(/^```json\s*\n?/, "");
|
|
17419
17511
|
}
|
|
17420
17512
|
}
|
|
17513
|
+
processedText = escapeUnescapedControlCharsInJsonStrings(processedText);
|
|
17421
17514
|
return processedText;
|
|
17422
17515
|
}
|
|
17423
17516
|
};
|
|
@@ -18795,6 +18888,6 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
18795
18888
|
}
|
|
18796
18889
|
};
|
|
18797
18890
|
|
|
18798
|
-
export { AISDKV5OutputStream, Agent, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, ExecutionEngine, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MemoryProcessor, MessageHistory, MockMemory, ModerationProcessor, PIIDetector, ProcessorRunner, ProcessorState, PromptInjectionDetector, Run, SemanticRecall, StructuredOutputProcessor, SystemPromptScrubber, TokenLimiterProcessor, ToolCallFilter, TripWire, UnicodeNormalizer, Workflow, WorkflowRunOutput, WorkingMemory, augmentWithInit, cloneStep, cloneWorkflow, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createStep, createTimeTravelExecutionParams, createWorkflow, getResumeLabelsByStepId, getStepIds, getStepResult, getZodErrors, loop, mapVariable, memoryDefaultOptions, parseMemoryRuntimeContext, resolveThreadIdFromArgs, runCountDeprecationMessage, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepResumeData, validateStepSuspendData };
|
|
18799
|
-
//# sourceMappingURL=chunk-
|
|
18800
|
-
//# sourceMappingURL=chunk-
|
|
18891
|
+
export { AISDKV5OutputStream, Agent, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, ExecutionEngine, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MemoryProcessor, MessageHistory, MockMemory, ModerationProcessor, PIIDetector, ProcessorRunner, ProcessorState, PromptInjectionDetector, Run, SemanticRecall, StructuredOutputProcessor, SystemPromptScrubber, TokenLimiterProcessor, ToolCallFilter, TripWire, UnicodeNormalizer, Workflow, WorkflowRunOutput, WorkingMemory, augmentWithInit, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createStep, createTimeTravelExecutionParams, createWorkflow, getResumeLabelsByStepId, getStepIds, getStepResult, getZodErrors, loop, mapVariable, memoryDefaultOptions, parseMemoryRuntimeContext, resolveThreadIdFromArgs, runCountDeprecationMessage, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepResumeData, validateStepStateData, validateStepSuspendData };
|
|
18892
|
+
//# sourceMappingURL=chunk-ARSSSQQP.js.map
|
|
18893
|
+
//# sourceMappingURL=chunk-ARSSSQQP.js.map
|