@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
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var chunk4JKEUSCC_cjs = require('./chunk-4JKEUSCC.cjs');
|
|
4
4
|
var chunkABJOUEVA_cjs = require('./chunk-ABJOUEVA.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
5
|
+
var chunk7S7TLMTS_cjs = require('./chunk-7S7TLMTS.cjs');
|
|
6
|
+
var chunkVRFSEZBA_cjs = require('./chunk-VRFSEZBA.cjs');
|
|
7
|
+
var chunkCKRWR5DS_cjs = require('./chunk-CKRWR5DS.cjs');
|
|
8
|
+
var chunkIISGCZJ4_cjs = require('./chunk-IISGCZJ4.cjs');
|
|
9
9
|
var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var chunkHSRQXO6F_cjs = require('./chunk-HSRQXO6F.cjs');
|
|
11
|
+
var chunkUVM27J4A_cjs = require('./chunk-UVM27J4A.cjs');
|
|
12
12
|
var chunkTWH4PTDG_cjs = require('./chunk-TWH4PTDG.cjs');
|
|
13
13
|
var chunk3JA6VPNM_cjs = require('./chunk-3JA6VPNM.cjs');
|
|
14
14
|
var chunkY24HI6ND_cjs = require('./chunk-Y24HI6ND.cjs');
|
|
@@ -1005,14 +1005,15 @@ async function validateStepResumeData({ resumeData, step }) {
|
|
|
1005
1005
|
}
|
|
1006
1006
|
async function validateStepSuspendData({
|
|
1007
1007
|
suspendData,
|
|
1008
|
-
step
|
|
1008
|
+
step,
|
|
1009
|
+
validateInputs
|
|
1009
1010
|
}) {
|
|
1010
1011
|
if (!suspendData) {
|
|
1011
1012
|
return { suspendData: void 0, validationError: void 0 };
|
|
1012
1013
|
}
|
|
1013
1014
|
let validationError;
|
|
1014
1015
|
const suspendSchema = step.suspendSchema;
|
|
1015
|
-
if (suspendSchema) {
|
|
1016
|
+
if (suspendSchema && validateInputs) {
|
|
1016
1017
|
const validatedSuspendData = await suspendSchema.safeParseAsync(suspendData);
|
|
1017
1018
|
if (!validatedSuspendData.success) {
|
|
1018
1019
|
const errors = getZodErrors(validatedSuspendData.error);
|
|
@@ -1024,6 +1025,28 @@ async function validateStepSuspendData({
|
|
|
1024
1025
|
}
|
|
1025
1026
|
return { suspendData, validationError };
|
|
1026
1027
|
}
|
|
1028
|
+
async function validateStepStateData({
|
|
1029
|
+
stateData,
|
|
1030
|
+
step,
|
|
1031
|
+
validateInputs
|
|
1032
|
+
}) {
|
|
1033
|
+
if (!stateData) {
|
|
1034
|
+
return { stateData: void 0, validationError: void 0 };
|
|
1035
|
+
}
|
|
1036
|
+
let validationError;
|
|
1037
|
+
const stateSchema = step.stateSchema;
|
|
1038
|
+
if (stateSchema && validateInputs) {
|
|
1039
|
+
const validatedStateData = await stateSchema.safeParseAsync(stateData);
|
|
1040
|
+
if (!validatedStateData.success) {
|
|
1041
|
+
const errors = getZodErrors(validatedStateData.error);
|
|
1042
|
+
const errorMessages = errors.map((e) => `- ${e.path?.join(".")}: ${e.message}`).join("\n");
|
|
1043
|
+
validationError = new Error("Step state data validation failed: \n" + errorMessages);
|
|
1044
|
+
} else {
|
|
1045
|
+
stateData = validatedStateData.data;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
return { stateData, validationError };
|
|
1049
|
+
}
|
|
1027
1050
|
function getResumeLabelsByStepId(resumeLabels, stepId) {
|
|
1028
1051
|
return Object.entries(resumeLabels).filter(([_, value]) => value.stepId === stepId).reduce(
|
|
1029
1052
|
(acc, [key, value]) => {
|
|
@@ -1138,7 +1161,7 @@ var createTimeTravelExecutionParams = (params) => {
|
|
|
1138
1161
|
result = void 0;
|
|
1139
1162
|
}
|
|
1140
1163
|
if (result) {
|
|
1141
|
-
const formattedResult =
|
|
1164
|
+
const formattedResult = chunkHSRQXO6F_cjs.removeUndefinedValues(result);
|
|
1142
1165
|
stepResults[stepId] = formattedResult;
|
|
1143
1166
|
}
|
|
1144
1167
|
});
|
|
@@ -1343,18 +1366,12 @@ async function executeConditional(engine, params) {
|
|
|
1343
1366
|
requestContext,
|
|
1344
1367
|
inputData: prevOutput,
|
|
1345
1368
|
state: executionContext.state,
|
|
1346
|
-
setState: (state) => {
|
|
1347
|
-
executionContext.state = state;
|
|
1348
|
-
},
|
|
1349
1369
|
retryCount: -1,
|
|
1350
1370
|
tracingContext: {
|
|
1351
1371
|
currentSpan: evalSpan
|
|
1352
1372
|
},
|
|
1353
1373
|
getInitData: () => stepResults?.input,
|
|
1354
1374
|
getStepResult: getStepResult.bind(null, stepResults),
|
|
1355
|
-
// TODO: this function shouldn't have suspend probably?
|
|
1356
|
-
suspend: async (_suspendPayload) => {
|
|
1357
|
-
},
|
|
1358
1375
|
bail: () => {
|
|
1359
1376
|
},
|
|
1360
1377
|
abort: () => {
|
|
@@ -1579,7 +1596,7 @@ async function executeLoop(engine, params) {
|
|
|
1579
1596
|
const evalSpan = loopSpan?.createChildSpan({
|
|
1580
1597
|
type: "workflow_conditional_eval" /* WORKFLOW_CONDITIONAL_EVAL */,
|
|
1581
1598
|
name: `condition: '${entry.loopType}'`,
|
|
1582
|
-
input:
|
|
1599
|
+
input: chunkHSRQXO6F_cjs.selectFields(result.output, ["stepResult", "output.text", "output.object", "messages"]),
|
|
1583
1600
|
attributes: {
|
|
1584
1601
|
conditionIndex: iteration
|
|
1585
1602
|
},
|
|
@@ -1594,9 +1611,6 @@ async function executeLoop(engine, params) {
|
|
|
1594
1611
|
requestContext,
|
|
1595
1612
|
inputData: result.output,
|
|
1596
1613
|
state: executionContext.state,
|
|
1597
|
-
setState: (state) => {
|
|
1598
|
-
executionContext.state = state;
|
|
1599
|
-
},
|
|
1600
1614
|
retryCount: -1,
|
|
1601
1615
|
tracingContext: {
|
|
1602
1616
|
currentSpan: evalSpan
|
|
@@ -1604,8 +1618,6 @@ async function executeLoop(engine, params) {
|
|
|
1604
1618
|
iterationCount: iteration + 1,
|
|
1605
1619
|
getInitData: () => stepResults?.input,
|
|
1606
1620
|
getStepResult: getStepResult.bind(null, stepResults),
|
|
1607
|
-
suspend: async (_suspendPayload) => {
|
|
1608
|
-
},
|
|
1609
1621
|
bail: () => {
|
|
1610
1622
|
},
|
|
1611
1623
|
abort: () => {
|
|
@@ -2319,7 +2331,7 @@ async function executeSleep(engine, params) {
|
|
|
2319
2331
|
requestContext,
|
|
2320
2332
|
inputData: prevOutput,
|
|
2321
2333
|
state: executionContext.state,
|
|
2322
|
-
setState: (state) => {
|
|
2334
|
+
setState: async (state) => {
|
|
2323
2335
|
executionContext.state = state;
|
|
2324
2336
|
},
|
|
2325
2337
|
retryCount: -1,
|
|
@@ -2400,7 +2412,7 @@ async function executeSleepUntil(engine, params) {
|
|
|
2400
2412
|
requestContext,
|
|
2401
2413
|
inputData: prevOutput,
|
|
2402
2414
|
state: executionContext.state,
|
|
2403
|
-
setState: (state) => {
|
|
2415
|
+
setState: async (state) => {
|
|
2404
2416
|
executionContext.state = state;
|
|
2405
2417
|
},
|
|
2406
2418
|
retryCount: -1,
|
|
@@ -2605,13 +2617,20 @@ async function executeStep(engine, params) {
|
|
|
2605
2617
|
runId,
|
|
2606
2618
|
resourceId,
|
|
2607
2619
|
workflowId,
|
|
2608
|
-
mastra: engine.mastra ?
|
|
2620
|
+
mastra: engine.mastra ? chunkUVM27J4A_cjs.wrapMastra(engine.mastra, { currentSpan: stepSpan }) : void 0,
|
|
2609
2621
|
requestContext,
|
|
2610
2622
|
inputData,
|
|
2611
2623
|
state: executionContext.state,
|
|
2612
|
-
setState: (state) => {
|
|
2613
|
-
|
|
2614
|
-
|
|
2624
|
+
setState: async (state) => {
|
|
2625
|
+
const { stateData, validationError: stateValidationError } = await validateStepStateData({
|
|
2626
|
+
stateData: state,
|
|
2627
|
+
step,
|
|
2628
|
+
validateInputs: engine.options?.validateInputs ?? true
|
|
2629
|
+
});
|
|
2630
|
+
if (stateValidationError) {
|
|
2631
|
+
throw stateValidationError;
|
|
2632
|
+
}
|
|
2633
|
+
contextMutations.stateUpdate = stateData;
|
|
2615
2634
|
},
|
|
2616
2635
|
retryCount,
|
|
2617
2636
|
resumeData: resumeDataToUse,
|
|
@@ -2622,7 +2641,8 @@ async function executeStep(engine, params) {
|
|
|
2622
2641
|
suspend: async (suspendPayload, suspendOptions) => {
|
|
2623
2642
|
const { suspendData, validationError: suspendValidationError } = await validateStepSuspendData({
|
|
2624
2643
|
suspendData: suspendPayload,
|
|
2625
|
-
step
|
|
2644
|
+
step,
|
|
2645
|
+
validateInputs: engine.options?.validateInputs ?? true
|
|
2626
2646
|
});
|
|
2627
2647
|
if (suspendValidationError) {
|
|
2628
2648
|
throw suspendValidationError;
|
|
@@ -2697,9 +2717,6 @@ async function executeStep(engine, params) {
|
|
|
2697
2717
|
const { result: durableResult } = stepRetryResult;
|
|
2698
2718
|
Object.assign(executionContext.suspendedPaths, durableResult.contextMutations.suspendedPaths);
|
|
2699
2719
|
Object.assign(executionContext.resumeLabels, durableResult.contextMutations.resumeLabels);
|
|
2700
|
-
if (durableResult.contextMutations.stateUpdate !== null) {
|
|
2701
|
-
executionContext.state = durableResult.contextMutations.stateUpdate;
|
|
2702
|
-
}
|
|
2703
2720
|
if (engine.requiresDurableContextSerialization() && durableResult.contextMutations.requestContextUpdate) {
|
|
2704
2721
|
requestContext.clear();
|
|
2705
2722
|
for (const [key, value] of Object.entries(durableResult.contextMutations.requestContextUpdate)) {
|
|
@@ -2757,7 +2774,10 @@ async function executeStep(engine, params) {
|
|
|
2757
2774
|
return {
|
|
2758
2775
|
result: stepResult,
|
|
2759
2776
|
stepResults: { [step.id]: stepResult },
|
|
2760
|
-
mutableContext: engine.buildMutableContext(
|
|
2777
|
+
mutableContext: engine.buildMutableContext({
|
|
2778
|
+
...executionContext,
|
|
2779
|
+
state: stepRetryResult.ok ? stepRetryResult.result.contextMutations.stateUpdate ?? executionContext.state : executionContext.state
|
|
2780
|
+
}),
|
|
2761
2781
|
requestContext: engine.serializeRequestContext(requestContext)
|
|
2762
2782
|
};
|
|
2763
2783
|
}
|
|
@@ -3105,7 +3125,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
3105
3125
|
* Apply mutable context changes back to the execution context.
|
|
3106
3126
|
*/
|
|
3107
3127
|
applyMutableContext(executionContext, mutableContext) {
|
|
3108
|
-
executionContext.state
|
|
3128
|
+
Object.assign(executionContext.state, mutableContext.state);
|
|
3109
3129
|
Object.assign(executionContext.suspendedPaths, mutableContext.suspendedPaths);
|
|
3110
3130
|
Object.assign(executionContext.resumeLabels, mutableContext.resumeLabels);
|
|
3111
3131
|
}
|
|
@@ -4069,7 +4089,7 @@ var Workflow = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
4069
4089
|
return stepRes?.status === "suspended";
|
|
4070
4090
|
});
|
|
4071
4091
|
if (res.state) {
|
|
4072
|
-
setState(res.state);
|
|
4092
|
+
await setState(res.state);
|
|
4073
4093
|
}
|
|
4074
4094
|
if (suspendedSteps?.length) {
|
|
4075
4095
|
for (const [stepName, stepResult] of suspendedSteps) {
|
|
@@ -4374,7 +4394,7 @@ var Run = class {
|
|
|
4374
4394
|
format,
|
|
4375
4395
|
outputOptions
|
|
4376
4396
|
}) {
|
|
4377
|
-
const workflowSpan =
|
|
4397
|
+
const workflowSpan = chunkUVM27J4A_cjs.getOrCreateSpan({
|
|
4378
4398
|
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
4379
4399
|
name: `workflow run: '${this.workflowId}'`,
|
|
4380
4400
|
input: inputData,
|
|
@@ -4869,7 +4889,7 @@ var Run = class {
|
|
|
4869
4889
|
requestContextToUse.set(key, value);
|
|
4870
4890
|
}
|
|
4871
4891
|
});
|
|
4872
|
-
const workflowSpan =
|
|
4892
|
+
const workflowSpan = chunkUVM27J4A_cjs.getOrCreateSpan({
|
|
4873
4893
|
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
4874
4894
|
name: `workflow run: '${this.workflowId}'`,
|
|
4875
4895
|
input: resumeDataToUse,
|
|
@@ -4994,7 +5014,7 @@ var Run = class {
|
|
|
4994
5014
|
requestContextToUse.set(key, value);
|
|
4995
5015
|
}
|
|
4996
5016
|
}
|
|
4997
|
-
const workflowSpan =
|
|
5017
|
+
const workflowSpan = chunkUVM27J4A_cjs.getOrCreateSpan({
|
|
4998
5018
|
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
4999
5019
|
name: `workflow run: '${this.workflowId}'`,
|
|
5000
5020
|
attributes: {
|
|
@@ -5099,7 +5119,7 @@ var Run = class {
|
|
|
5099
5119
|
requestContextToUse.set(key, value);
|
|
5100
5120
|
}
|
|
5101
5121
|
}
|
|
5102
|
-
const workflowSpan =
|
|
5122
|
+
const workflowSpan = chunkUVM27J4A_cjs.getOrCreateSpan({
|
|
5103
5123
|
type: "workflow_run" /* WORKFLOW_RUN */,
|
|
5104
5124
|
name: `workflow run: '${this.workflowId}'`,
|
|
5105
5125
|
input: inputData,
|
|
@@ -5410,7 +5430,7 @@ var ProcessorRunner = class {
|
|
|
5410
5430
|
requestContext
|
|
5411
5431
|
});
|
|
5412
5432
|
const mutations = messageList.stopRecording();
|
|
5413
|
-
if (result instanceof
|
|
5433
|
+
if (result instanceof chunkVRFSEZBA_cjs.MessageList) {
|
|
5414
5434
|
if (result !== messageList) {
|
|
5415
5435
|
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
5416
5436
|
category: "USER",
|
|
@@ -5590,7 +5610,7 @@ var ProcessorRunner = class {
|
|
|
5590
5610
|
requestContext
|
|
5591
5611
|
});
|
|
5592
5612
|
let mutations;
|
|
5593
|
-
if (result instanceof
|
|
5613
|
+
if (result instanceof chunkVRFSEZBA_cjs.MessageList) {
|
|
5594
5614
|
if (result !== messageList) {
|
|
5595
5615
|
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
5596
5616
|
category: "USER",
|
|
@@ -5711,7 +5731,7 @@ var ProcessorRunner = class {
|
|
|
5711
5731
|
requestContext
|
|
5712
5732
|
});
|
|
5713
5733
|
const mutations = messageList.stopRecording();
|
|
5714
|
-
if (result instanceof
|
|
5734
|
+
if (result instanceof chunkVRFSEZBA_cjs.MessageList) {
|
|
5715
5735
|
if (result !== messageList) {
|
|
5716
5736
|
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
5717
5737
|
category: "USER",
|
|
@@ -6155,7 +6175,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
6155
6175
|
if (mode === "generate") {
|
|
6156
6176
|
return {
|
|
6157
6177
|
type: "file",
|
|
6158
|
-
file: new
|
|
6178
|
+
file: new chunkVRFSEZBA_cjs.DefaultGeneratedFile({
|
|
6159
6179
|
data: chunk.payload.data,
|
|
6160
6180
|
mediaType: chunk.payload.mimeType
|
|
6161
6181
|
})
|
|
@@ -6163,7 +6183,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
6163
6183
|
}
|
|
6164
6184
|
return {
|
|
6165
6185
|
type: "file",
|
|
6166
|
-
file: new
|
|
6186
|
+
file: new chunkVRFSEZBA_cjs.DefaultGeneratedFileWithType({
|
|
6167
6187
|
data: chunk.payload.data,
|
|
6168
6188
|
mediaType: chunk.payload.mimeType
|
|
6169
6189
|
})
|
|
@@ -6972,7 +6992,7 @@ function createLLMExecutionStep({
|
|
|
6972
6992
|
}
|
|
6973
6993
|
if (prepareStepResult.messages) {
|
|
6974
6994
|
const newMessages = prepareStepResult.messages;
|
|
6975
|
-
const newMessageList = new
|
|
6995
|
+
const newMessageList = new chunkVRFSEZBA_cjs.MessageList();
|
|
6976
6996
|
for (const message of newMessages) {
|
|
6977
6997
|
if (message.role === "system") {
|
|
6978
6998
|
newMessageList.addSystem(message);
|
|
@@ -6989,7 +7009,7 @@ function createLLMExecutionStep({
|
|
|
6989
7009
|
console.error("Error in prepareStep callback:", error);
|
|
6990
7010
|
}
|
|
6991
7011
|
}
|
|
6992
|
-
modelResult =
|
|
7012
|
+
modelResult = chunkUVM27J4A_cjs.executeWithContextSync({
|
|
6993
7013
|
span: modelSpanTracker?.getTracingContext()?.currentSpan,
|
|
6994
7014
|
fn: () => execute({
|
|
6995
7015
|
runId,
|
|
@@ -8102,6 +8122,7 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8102
8122
|
requireToolApproval,
|
|
8103
8123
|
_internal,
|
|
8104
8124
|
agentId,
|
|
8125
|
+
agentName,
|
|
8105
8126
|
toolCallId,
|
|
8106
8127
|
requestContext,
|
|
8107
8128
|
methodType,
|
|
@@ -8129,6 +8150,8 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8129
8150
|
messages: [...messageList.getSystemMessages(), ...messages]
|
|
8130
8151
|
},
|
|
8131
8152
|
attributes: {
|
|
8153
|
+
agentId,
|
|
8154
|
+
agentName,
|
|
8132
8155
|
model: firstModel.modelId,
|
|
8133
8156
|
provider: firstModel.provider,
|
|
8134
8157
|
streaming: true,
|
|
@@ -8163,6 +8186,7 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8163
8186
|
modelSpanTracker,
|
|
8164
8187
|
requireToolApproval,
|
|
8165
8188
|
agentId,
|
|
8189
|
+
agentName,
|
|
8166
8190
|
requestContext,
|
|
8167
8191
|
methodType,
|
|
8168
8192
|
includeRawChunks,
|
|
@@ -8206,7 +8230,7 @@ var MastraLLMVNext = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
8206
8230
|
const remainingTokens = parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"] ?? "", 10);
|
|
8207
8231
|
if (!isNaN(remainingTokens) && remainingTokens > 0 && remainingTokens < 2e3) {
|
|
8208
8232
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
8209
|
-
await
|
|
8233
|
+
await chunkHSRQXO6F_cjs.delay(10 * 1e3);
|
|
8210
8234
|
}
|
|
8211
8235
|
},
|
|
8212
8236
|
onFinish: async (props) => {
|
|
@@ -8520,7 +8544,7 @@ async function prepareMemoryStep({
|
|
|
8520
8544
|
);
|
|
8521
8545
|
}
|
|
8522
8546
|
} else {
|
|
8523
|
-
const messageList = new
|
|
8547
|
+
const messageList = new chunkVRFSEZBA_cjs.MessageList({
|
|
8524
8548
|
threadId: thread?.id,
|
|
8525
8549
|
resourceId: thread?.resourceId
|
|
8526
8550
|
});
|
|
@@ -9195,6 +9219,7 @@ ${completionResult?.object?.finalResult}` : ""}
|
|
|
9195
9219
|
mastra: agent.getMastraInstance(),
|
|
9196
9220
|
agent: {
|
|
9197
9221
|
resourceId: initData.threadResourceId || networkName,
|
|
9222
|
+
toolCallId,
|
|
9198
9223
|
threadId: initData.threadId
|
|
9199
9224
|
},
|
|
9200
9225
|
runId,
|
|
@@ -9580,7 +9605,7 @@ var AgentLegacyHandler = class {
|
|
|
9580
9605
|
if (process.env.NODE_ENV !== "test") {
|
|
9581
9606
|
this.capabilities.logger.debug(`[Agents:${this.capabilities.name}] - Starting generation`, { runId });
|
|
9582
9607
|
}
|
|
9583
|
-
const agentSpan =
|
|
9608
|
+
const agentSpan = chunkUVM27J4A_cjs.getOrCreateSpan({
|
|
9584
9609
|
type: "agent_run" /* AGENT_RUN */,
|
|
9585
9610
|
name: `agent run: '${this.capabilities.id}'`,
|
|
9586
9611
|
input: {
|
|
@@ -9634,7 +9659,7 @@ var AgentLegacyHandler = class {
|
|
|
9634
9659
|
methodType: methodType === "generate" ? "generateLegacy" : "streamLegacy",
|
|
9635
9660
|
memoryConfig
|
|
9636
9661
|
});
|
|
9637
|
-
let messageList = new
|
|
9662
|
+
let messageList = new chunkVRFSEZBA_cjs.MessageList({
|
|
9638
9663
|
threadId,
|
|
9639
9664
|
resourceId,
|
|
9640
9665
|
generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
|
|
@@ -9775,7 +9800,7 @@ var AgentLegacyHandler = class {
|
|
|
9775
9800
|
result: resToLog,
|
|
9776
9801
|
threadId
|
|
9777
9802
|
});
|
|
9778
|
-
const messageListResponses = new
|
|
9803
|
+
const messageListResponses = new chunkVRFSEZBA_cjs.MessageList({
|
|
9779
9804
|
threadId,
|
|
9780
9805
|
resourceId,
|
|
9781
9806
|
generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
|
|
@@ -12904,6 +12929,11 @@ var memoryDefaultOptions = {
|
|
|
12904
12929
|
}
|
|
12905
12930
|
};
|
|
12906
12931
|
var MastraMemory = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
12932
|
+
/**
|
|
12933
|
+
* Unique identifier for the memory instance.
|
|
12934
|
+
* If not provided, defaults to a static name 'default-memory'.
|
|
12935
|
+
*/
|
|
12936
|
+
id;
|
|
12907
12937
|
MAX_CONTEXT_TOKENS;
|
|
12908
12938
|
_storage;
|
|
12909
12939
|
vector;
|
|
@@ -12912,6 +12942,7 @@ var MastraMemory = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
12912
12942
|
#mastra;
|
|
12913
12943
|
constructor(config) {
|
|
12914
12944
|
super({ component: "MEMORY", name: config.name });
|
|
12945
|
+
this.id = config.id ?? config.name ?? "default-memory";
|
|
12915
12946
|
if (config.options) this.threadConfig = this.getMergedThreadConfig(config.options);
|
|
12916
12947
|
if (config.processors) {
|
|
12917
12948
|
throw new Error(
|
|
@@ -12962,7 +12993,7 @@ https://mastra.ai/en/docs/memory/semantic-recall`
|
|
|
12962
12993
|
);
|
|
12963
12994
|
}
|
|
12964
12995
|
if (typeof config.embedder === "string") {
|
|
12965
|
-
this.embedder = new
|
|
12996
|
+
this.embedder = new chunkCKRWR5DS_cjs.ModelRouterEmbeddingModel(config.embedder);
|
|
12966
12997
|
} else {
|
|
12967
12998
|
this.embedder = config.embedder;
|
|
12968
12999
|
}
|
|
@@ -13058,7 +13089,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
13058
13089
|
"The threads.generateTitle option has been moved. Use the top-level generateTitle option instead."
|
|
13059
13090
|
);
|
|
13060
13091
|
}
|
|
13061
|
-
const mergedConfig =
|
|
13092
|
+
const mergedConfig = chunkHSRQXO6F_cjs.deepMerge(this.threadConfig, config || {});
|
|
13062
13093
|
if (typeof config?.workingMemory === "object" && config.workingMemory?.schema && typeof mergedConfig.workingMemory === "object") {
|
|
13063
13094
|
mergedConfig.workingMemory.schema = config.workingMemory.schema;
|
|
13064
13095
|
}
|
|
@@ -13294,7 +13325,7 @@ var MockMemory = class extends MastraMemory {
|
|
|
13294
13325
|
} = {}) {
|
|
13295
13326
|
super({
|
|
13296
13327
|
name: "mock",
|
|
13297
|
-
storage: storage || new
|
|
13328
|
+
storage: storage || new chunk7S7TLMTS_cjs.InMemoryStore(),
|
|
13298
13329
|
options: {
|
|
13299
13330
|
workingMemory: enableWorkingMemory ? { enabled: true, template: workingMemoryTemplate } : void 0,
|
|
13300
13331
|
lastMessages: enableMessageHistory ? 10 : void 0
|
|
@@ -13808,7 +13839,7 @@ var SemanticRecall = class {
|
|
|
13808
13839
|
*/
|
|
13809
13840
|
formatCrossThreadMessages(messages, currentThreadId) {
|
|
13810
13841
|
let result = ``;
|
|
13811
|
-
const v1Messages = new
|
|
13842
|
+
const v1Messages = new chunkVRFSEZBA_cjs.MessageList().add(messages, "memory").get.all.v1();
|
|
13812
13843
|
let lastYmd = null;
|
|
13813
13844
|
for (const msg of v1Messages) {
|
|
13814
13845
|
const date = msg.createdAt;
|
|
@@ -14260,7 +14291,7 @@ var prepareToolsStepOutputSchema = z5.z.object({
|
|
|
14260
14291
|
var prepareMemoryStepOutputSchema = z5.z.object({
|
|
14261
14292
|
threadExists: z5.z.boolean(),
|
|
14262
14293
|
thread: storageThreadSchema.optional(),
|
|
14263
|
-
messageList: z5.z.instanceof(
|
|
14294
|
+
messageList: z5.z.instanceof(chunkVRFSEZBA_cjs.MessageList),
|
|
14264
14295
|
tripwire: z5.z.boolean().optional(),
|
|
14265
14296
|
tripwireReason: z5.z.string().optional()
|
|
14266
14297
|
});
|
|
@@ -14293,7 +14324,7 @@ function createPrepareMemoryStep({
|
|
|
14293
14324
|
outputSchema: prepareMemoryStepOutputSchema,
|
|
14294
14325
|
execute: async ({ tracingContext }) => {
|
|
14295
14326
|
const thread = threadFromArgs;
|
|
14296
|
-
const messageList = new
|
|
14327
|
+
const messageList = new chunkVRFSEZBA_cjs.MessageList({
|
|
14297
14328
|
threadId: thread?.id,
|
|
14298
14329
|
resourceId,
|
|
14299
14330
|
generateMessageId: capabilities.generateMessageId,
|
|
@@ -14445,6 +14476,7 @@ function createStreamStep({
|
|
|
14445
14476
|
requireToolApproval,
|
|
14446
14477
|
resumeContext,
|
|
14447
14478
|
agentId,
|
|
14479
|
+
agentName,
|
|
14448
14480
|
toolCallId,
|
|
14449
14481
|
methodType,
|
|
14450
14482
|
saveQueueManager,
|
|
@@ -14485,6 +14517,7 @@ function createStreamStep({
|
|
|
14485
14517
|
memory
|
|
14486
14518
|
},
|
|
14487
14519
|
agentId,
|
|
14520
|
+
agentName,
|
|
14488
14521
|
toolCallId,
|
|
14489
14522
|
methodType: modelMethodType
|
|
14490
14523
|
});
|
|
@@ -14511,6 +14544,7 @@ function createPrepareStreamWorkflow({
|
|
|
14511
14544
|
requireToolApproval,
|
|
14512
14545
|
resumeContext,
|
|
14513
14546
|
agentId,
|
|
14547
|
+
agentName,
|
|
14514
14548
|
toolCallId
|
|
14515
14549
|
}) {
|
|
14516
14550
|
const prepareToolsStep = createPrepareToolsStep({
|
|
@@ -14542,6 +14576,7 @@ function createPrepareStreamWorkflow({
|
|
|
14542
14576
|
requireToolApproval,
|
|
14543
14577
|
resumeContext,
|
|
14544
14578
|
agentId,
|
|
14579
|
+
agentName,
|
|
14545
14580
|
toolCallId,
|
|
14546
14581
|
methodType,
|
|
14547
14582
|
saveQueueManager,
|
|
@@ -15165,7 +15200,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15165
15200
|
*/
|
|
15166
15201
|
listTools({ requestContext = new chunkUVHSM2GU_cjs.RequestContext() } = {}) {
|
|
15167
15202
|
if (typeof this.#tools !== "function") {
|
|
15168
|
-
return
|
|
15203
|
+
return chunkHSRQXO6F_cjs.ensureToolProperties(this.#tools);
|
|
15169
15204
|
}
|
|
15170
15205
|
const result = this.#tools({ requestContext, mastra: this.#mastra });
|
|
15171
15206
|
return resolveMaybePromise(result, (tools) => {
|
|
@@ -15183,7 +15218,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15183
15218
|
this.logger.error(mastraError.toString());
|
|
15184
15219
|
throw mastraError;
|
|
15185
15220
|
}
|
|
15186
|
-
return
|
|
15221
|
+
return chunkHSRQXO6F_cjs.ensureToolProperties(tools);
|
|
15187
15222
|
});
|
|
15188
15223
|
}
|
|
15189
15224
|
/**
|
|
@@ -15215,7 +15250,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15215
15250
|
});
|
|
15216
15251
|
});
|
|
15217
15252
|
} else {
|
|
15218
|
-
llm = new
|
|
15253
|
+
llm = new chunkIISGCZJ4_cjs.MastraLLMV1({
|
|
15219
15254
|
model: resolvedModel,
|
|
15220
15255
|
mastra: this.#mastra,
|
|
15221
15256
|
options: { tracingPolicy: this.#options?.tracingPolicy }
|
|
@@ -15240,7 +15275,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15240
15275
|
*/
|
|
15241
15276
|
async resolveModelConfig(modelConfig, requestContext) {
|
|
15242
15277
|
try {
|
|
15243
|
-
return await
|
|
15278
|
+
return await chunkCKRWR5DS_cjs.resolveModelConfig(modelConfig, requestContext, this.#mastra);
|
|
15244
15279
|
} catch (error) {
|
|
15245
15280
|
const mastraError = new chunkTWH4PTDG_cjs.MastraError({
|
|
15246
15281
|
id: "AGENT_GET_MODEL_MISSING_MODEL_INSTANCE",
|
|
@@ -15446,7 +15481,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15446
15481
|
instructions
|
|
15447
15482
|
}) {
|
|
15448
15483
|
const llm = await this.getLLM({ requestContext, model });
|
|
15449
|
-
const normMessage = new
|
|
15484
|
+
const normMessage = new chunkVRFSEZBA_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
|
|
15450
15485
|
if (!normMessage) {
|
|
15451
15486
|
throw new Error(`Could not generate title from input ${JSON.stringify(message)}`);
|
|
15452
15487
|
}
|
|
@@ -15469,7 +15504,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15469
15504
|
const systemInstructions = await this.resolveTitleInstructions(requestContext, instructions);
|
|
15470
15505
|
let text = "";
|
|
15471
15506
|
if (llm.getModel().specificationVersion === "v2") {
|
|
15472
|
-
const messageList = new
|
|
15507
|
+
const messageList = new chunkVRFSEZBA_cjs.MessageList().add(
|
|
15473
15508
|
[
|
|
15474
15509
|
{
|
|
15475
15510
|
role: "system",
|
|
@@ -15491,7 +15526,8 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15491
15526
|
requestContext,
|
|
15492
15527
|
tracingContext,
|
|
15493
15528
|
messageList,
|
|
15494
|
-
agentId: this.id
|
|
15529
|
+
agentId: this.id,
|
|
15530
|
+
agentName: this.name
|
|
15495
15531
|
});
|
|
15496
15532
|
text = await result.text;
|
|
15497
15533
|
} else {
|
|
@@ -15521,7 +15557,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15521
15557
|
async genTitle(userMessage, requestContext, tracingContext, model, instructions) {
|
|
15522
15558
|
try {
|
|
15523
15559
|
if (userMessage) {
|
|
15524
|
-
const normMessage = new
|
|
15560
|
+
const normMessage = new chunkVRFSEZBA_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
|
|
15525
15561
|
if (normMessage) {
|
|
15526
15562
|
return await this.generateTitleFromUserMessage({
|
|
15527
15563
|
message: normMessage,
|
|
@@ -15585,7 +15621,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15585
15621
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
15586
15622
|
requireApproval: toolObj.requireApproval
|
|
15587
15623
|
};
|
|
15588
|
-
const convertedToCoreTool =
|
|
15624
|
+
const convertedToCoreTool = chunkHSRQXO6F_cjs.makeCoreTool(toolObj, options);
|
|
15589
15625
|
convertedMemoryTools[toolName] = convertedToCoreTool;
|
|
15590
15626
|
}
|
|
15591
15627
|
}
|
|
@@ -15735,7 +15771,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15735
15771
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
15736
15772
|
requireApproval: tool.requireApproval
|
|
15737
15773
|
};
|
|
15738
|
-
return [k,
|
|
15774
|
+
return [k, chunkHSRQXO6F_cjs.makeCoreTool(tool, options)];
|
|
15739
15775
|
})
|
|
15740
15776
|
);
|
|
15741
15777
|
const assignedToolEntriesConverted = Object.fromEntries(
|
|
@@ -15784,7 +15820,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15784
15820
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
15785
15821
|
requireApproval: toolObj.requireApproval
|
|
15786
15822
|
};
|
|
15787
|
-
const convertedToCoreTool =
|
|
15823
|
+
const convertedToCoreTool = chunkHSRQXO6F_cjs.makeCoreTool(toolObj, options, "toolset");
|
|
15788
15824
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
15789
15825
|
}
|
|
15790
15826
|
}
|
|
@@ -15828,7 +15864,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15828
15864
|
tracingPolicy: this.#options?.tracingPolicy,
|
|
15829
15865
|
requireApproval: tool.requireApproval
|
|
15830
15866
|
};
|
|
15831
|
-
const convertedToCoreTool =
|
|
15867
|
+
const convertedToCoreTool = chunkHSRQXO6F_cjs.makeCoreTool(rest, options, "client-tool");
|
|
15832
15868
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
15833
15869
|
}
|
|
15834
15870
|
}
|
|
@@ -15997,7 +16033,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
15997
16033
|
tracingContext,
|
|
15998
16034
|
tracingPolicy: this.#options?.tracingPolicy
|
|
15999
16035
|
};
|
|
16000
|
-
convertedAgentTools[`agent-${agentName}`] =
|
|
16036
|
+
convertedAgentTools[`agent-${agentName}`] = chunkHSRQXO6F_cjs.makeCoreTool(toolObj, options);
|
|
16001
16037
|
}
|
|
16002
16038
|
}
|
|
16003
16039
|
return convertedAgentTools;
|
|
@@ -16049,16 +16085,25 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16049
16085
|
threadId,
|
|
16050
16086
|
resourceId
|
|
16051
16087
|
});
|
|
16052
|
-
const run = await workflow.createRun();
|
|
16088
|
+
const run = await workflow.createRun({ runId });
|
|
16053
16089
|
const { initialState, inputData: workflowInputData } = inputData;
|
|
16090
|
+
const { resumeData, suspend } = context?.agent ?? {};
|
|
16054
16091
|
let result = void 0;
|
|
16055
16092
|
if (methodType === "generate" || methodType === "generateLegacy") {
|
|
16056
|
-
|
|
16057
|
-
|
|
16058
|
-
|
|
16059
|
-
|
|
16060
|
-
|
|
16061
|
-
|
|
16093
|
+
if (resumeData) {
|
|
16094
|
+
result = await run.resume({
|
|
16095
|
+
resumeData,
|
|
16096
|
+
requestContext,
|
|
16097
|
+
tracingContext: context?.tracingContext
|
|
16098
|
+
});
|
|
16099
|
+
} else {
|
|
16100
|
+
result = await run.start({
|
|
16101
|
+
inputData: workflowInputData,
|
|
16102
|
+
requestContext,
|
|
16103
|
+
tracingContext: context?.tracingContext,
|
|
16104
|
+
...initialState && { initialState }
|
|
16105
|
+
});
|
|
16106
|
+
}
|
|
16062
16107
|
} else if (methodType === "streamLegacy") {
|
|
16063
16108
|
const streamResult = run.streamLegacy({
|
|
16064
16109
|
inputData: workflowInputData,
|
|
@@ -16073,7 +16118,11 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16073
16118
|
}
|
|
16074
16119
|
result = await streamResult.getWorkflowState();
|
|
16075
16120
|
} else if (methodType === "stream") {
|
|
16076
|
-
const streamResult = run.
|
|
16121
|
+
const streamResult = resumeData ? run.resumeStream({
|
|
16122
|
+
resumeData,
|
|
16123
|
+
requestContext,
|
|
16124
|
+
tracingContext: context?.tracingContext
|
|
16125
|
+
}) : run.stream({
|
|
16077
16126
|
inputData: workflowInputData,
|
|
16078
16127
|
requestContext,
|
|
16079
16128
|
tracingContext: context?.tracingContext,
|
|
@@ -16094,10 +16143,12 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16094
16143
|
runId: run.runId
|
|
16095
16144
|
};
|
|
16096
16145
|
} else if (result?.status === "suspended") {
|
|
16097
|
-
|
|
16098
|
-
|
|
16099
|
-
|
|
16100
|
-
|
|
16146
|
+
const suspendedStep = result?.suspended?.[0]?.[0];
|
|
16147
|
+
const suspendPayload = result?.steps?.[suspendedStep]?.suspendPayload;
|
|
16148
|
+
if (suspendPayload?.__workflow_meta) {
|
|
16149
|
+
delete suspendPayload.__workflow_meta;
|
|
16150
|
+
}
|
|
16151
|
+
return suspend?.(suspendPayload);
|
|
16101
16152
|
} else {
|
|
16102
16153
|
return {
|
|
16103
16154
|
error: `Workflow should never reach this path, workflow returned no status`,
|
|
@@ -16140,7 +16191,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16140
16191
|
tracingContext,
|
|
16141
16192
|
tracingPolicy: this.#options?.tracingPolicy
|
|
16142
16193
|
};
|
|
16143
|
-
convertedWorkflowTools[`workflow-${workflowName}`] =
|
|
16194
|
+
convertedWorkflowTools[`workflow-${workflowName}`] = chunkHSRQXO6F_cjs.makeCoreTool(toolObj, options);
|
|
16144
16195
|
}
|
|
16145
16196
|
}
|
|
16146
16197
|
return convertedWorkflowTools;
|
|
@@ -16164,7 +16215,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16164
16215
|
let mastraProxy = void 0;
|
|
16165
16216
|
const logger = this.logger;
|
|
16166
16217
|
if (this.#mastra) {
|
|
16167
|
-
mastraProxy =
|
|
16218
|
+
mastraProxy = chunkHSRQXO6F_cjs.createMastraProxy({ mastra: this.#mastra, logger });
|
|
16168
16219
|
}
|
|
16169
16220
|
const assignedTools = await this.listAssignedTools({
|
|
16170
16221
|
runId,
|
|
@@ -16488,7 +16539,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16488
16539
|
const targetProvider = structuredOutputModel.provider;
|
|
16489
16540
|
const targetModelId = structuredOutputModel.modelId;
|
|
16490
16541
|
if (targetProvider.includes("openai") || targetModelId.includes("openai")) {
|
|
16491
|
-
if (
|
|
16542
|
+
if (chunkHSRQXO6F_cjs.isZodType(options.structuredOutput.schema) && targetModelId) {
|
|
16492
16543
|
const modelInfo = {
|
|
16493
16544
|
provider: targetProvider,
|
|
16494
16545
|
modelId: targetModelId,
|
|
@@ -16507,7 +16558,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16507
16558
|
}
|
|
16508
16559
|
const runId = options.runId || this.#mastra?.generateId() || crypto2.randomUUID();
|
|
16509
16560
|
const instructions = options.instructions || await this.getInstructions({ requestContext });
|
|
16510
|
-
const agentSpan =
|
|
16561
|
+
const agentSpan = chunkUVM27J4A_cjs.getOrCreateSpan({
|
|
16511
16562
|
type: "agent_run" /* AGENT_RUN */,
|
|
16512
16563
|
name: `agent run: '${this.id}'`,
|
|
16513
16564
|
input: options.messages,
|
|
@@ -16569,6 +16620,7 @@ var Agent = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
16569
16620
|
requireToolApproval: options.requireToolApproval,
|
|
16570
16621
|
resumeContext,
|
|
16571
16622
|
agentId: this.id,
|
|
16623
|
+
agentName: this.name,
|
|
16572
16624
|
toolCallId: options.toolCallId
|
|
16573
16625
|
});
|
|
16574
16626
|
const run = await executionWorkflow.createRun();
|
|
@@ -17334,6 +17386,45 @@ var AISDKV5OutputStream = class {
|
|
|
17334
17386
|
return this.#modelOutput.object;
|
|
17335
17387
|
}
|
|
17336
17388
|
};
|
|
17389
|
+
function escapeUnescapedControlCharsInJsonStrings(text) {
|
|
17390
|
+
let result = "";
|
|
17391
|
+
let inString = false;
|
|
17392
|
+
let i = 0;
|
|
17393
|
+
while (i < text.length) {
|
|
17394
|
+
const char = text[i];
|
|
17395
|
+
if (char === "\\" && i + 1 < text.length) {
|
|
17396
|
+
result += char + text[i + 1];
|
|
17397
|
+
i += 2;
|
|
17398
|
+
continue;
|
|
17399
|
+
}
|
|
17400
|
+
if (char === '"') {
|
|
17401
|
+
inString = !inString;
|
|
17402
|
+
result += char;
|
|
17403
|
+
i++;
|
|
17404
|
+
continue;
|
|
17405
|
+
}
|
|
17406
|
+
if (inString) {
|
|
17407
|
+
if (char === "\n") {
|
|
17408
|
+
result += "\\n";
|
|
17409
|
+
i++;
|
|
17410
|
+
continue;
|
|
17411
|
+
}
|
|
17412
|
+
if (char === "\r") {
|
|
17413
|
+
result += "\\r";
|
|
17414
|
+
i++;
|
|
17415
|
+
continue;
|
|
17416
|
+
}
|
|
17417
|
+
if (char === " ") {
|
|
17418
|
+
result += "\\t";
|
|
17419
|
+
i++;
|
|
17420
|
+
continue;
|
|
17421
|
+
}
|
|
17422
|
+
}
|
|
17423
|
+
result += char;
|
|
17424
|
+
i++;
|
|
17425
|
+
}
|
|
17426
|
+
return result;
|
|
17427
|
+
}
|
|
17337
17428
|
var BaseFormatHandler = class {
|
|
17338
17429
|
/**
|
|
17339
17430
|
* The original user-provided schema (Zod, JSON Schema, or AI SDK Schema).
|
|
@@ -17425,7 +17516,8 @@ ${z42__default.default.prettifyError(result.error)}
|
|
|
17425
17516
|
}
|
|
17426
17517
|
}
|
|
17427
17518
|
/**
|
|
17428
|
-
* Preprocesses accumulated text to handle LLMs that wrap JSON in code blocks
|
|
17519
|
+
* Preprocesses accumulated text to handle LLMs that wrap JSON in code blocks
|
|
17520
|
+
* and fix common JSON formatting issues like unescaped newlines in strings.
|
|
17429
17521
|
* Extracts content from the first complete valid ```json...``` code block or removes opening ```json prefix if no complete code block is found (streaming chunks).
|
|
17430
17522
|
* @param accumulatedText - Raw accumulated text from streaming
|
|
17431
17523
|
* @returns Processed text ready for JSON parsing
|
|
@@ -17446,6 +17538,7 @@ ${z42__default.default.prettifyError(result.error)}
|
|
|
17446
17538
|
processedText = processedText.replace(/^```json\s*\n?/, "");
|
|
17447
17539
|
}
|
|
17448
17540
|
}
|
|
17541
|
+
processedText = escapeUnescapedControlCharsInJsonStrings(processedText);
|
|
17449
17542
|
return processedText;
|
|
17450
17543
|
}
|
|
17451
17544
|
};
|
|
@@ -18228,7 +18321,7 @@ var MastraModelOutput = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
18228
18321
|
options.tracingContext,
|
|
18229
18322
|
self.#options.requestContext
|
|
18230
18323
|
);
|
|
18231
|
-
const outputText = self.messageList.get.response.aiV4.core().map((m) =>
|
|
18324
|
+
const outputText = self.messageList.get.response.aiV4.core().map((m) => chunkVRFSEZBA_cjs.MessageList.coreContentToString(m.content)).join("\n");
|
|
18232
18325
|
self.#delayedPromises.text.resolve(outputText);
|
|
18233
18326
|
self.#delayedPromises.finishReason.resolve(self.#finishReason);
|
|
18234
18327
|
if (chunk.payload.metadata) {
|
|
@@ -18855,6 +18948,7 @@ exports.WorkingMemory = WorkingMemory;
|
|
|
18855
18948
|
exports.augmentWithInit = augmentWithInit;
|
|
18856
18949
|
exports.cloneStep = cloneStep;
|
|
18857
18950
|
exports.cloneWorkflow = cloneWorkflow;
|
|
18951
|
+
exports.convertFullStreamChunkToMastra = convertFullStreamChunkToMastra;
|
|
18858
18952
|
exports.convertFullStreamChunkToUIMessageStream = convertFullStreamChunkToUIMessageStream;
|
|
18859
18953
|
exports.convertMastraChunkToAISDKv5 = convertMastraChunkToAISDKv5;
|
|
18860
18954
|
exports.createDeprecationProxy = createDeprecationProxy;
|
|
@@ -18875,6 +18969,7 @@ exports.tryGenerateWithJsonFallback = tryGenerateWithJsonFallback;
|
|
|
18875
18969
|
exports.tryStreamWithJsonFallback = tryStreamWithJsonFallback;
|
|
18876
18970
|
exports.validateStepInput = validateStepInput;
|
|
18877
18971
|
exports.validateStepResumeData = validateStepResumeData;
|
|
18972
|
+
exports.validateStepStateData = validateStepStateData;
|
|
18878
18973
|
exports.validateStepSuspendData = validateStepSuspendData;
|
|
18879
|
-
//# sourceMappingURL=chunk-
|
|
18880
|
-
//# sourceMappingURL=chunk-
|
|
18974
|
+
//# sourceMappingURL=chunk-XMT5T4F2.cjs.map
|
|
18975
|
+
//# sourceMappingURL=chunk-XMT5T4F2.cjs.map
|