@mastra/core 0.9.0-alpha.7 → 0.9.0
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/dist/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/{base-BlGpZfLc.d.ts → base-Bk5V1doj.d.ts} +50 -30
- package/dist/{base-xpk2ifTz.d.cts → base-oP3DoUrm.d.cts} +50 -30
- package/dist/{chunk-KR6AYHNH.cjs → chunk-53P5ZBJE.cjs} +4 -3
- package/dist/{chunk-3XWBNOSO.cjs → chunk-7CSNWYGJ.cjs} +2 -2
- package/dist/{chunk-BBDXZGCM.cjs → chunk-ATXF6TIO.cjs} +72 -72
- package/dist/{chunk-YVPTMEI4.js → chunk-DGL5RCEO.js} +157 -122
- package/dist/{chunk-F4WOCJZQ.cjs → chunk-DIZZQ3E5.cjs} +2 -2
- package/dist/{chunk-M6MZXBG5.js → chunk-GEIPVIW4.js} +1 -1
- package/dist/{chunk-HHDP5KHS.js → chunk-GJWCFDFN.js} +1 -1
- package/dist/{chunk-BUNPX6LU.js → chunk-HARYMLZH.js} +58 -58
- package/dist/{chunk-63YK3N3V.cjs → chunk-KZWBYRXW.cjs} +4 -4
- package/dist/{chunk-3PBEAM6M.js → chunk-M472GIT6.js} +2 -2
- package/dist/{chunk-5OPUKM43.js → chunk-N2ONCUUS.js} +2 -2
- package/dist/{chunk-KAJSLFMA.js → chunk-NTHHPNOW.js} +4 -4
- package/dist/{chunk-LZQIMLJV.cjs → chunk-NZDXKMDP.cjs} +2 -2
- package/dist/{chunk-WXENXL7L.js → chunk-RASVJ3TR.js} +3 -3
- package/dist/{chunk-AAMFAGE5.cjs → chunk-TEEAQX2B.cjs} +157 -122
- package/dist/{chunk-D6OBOFCM.cjs → chunk-W5IA5OGL.cjs} +3 -3
- package/dist/di/index.cjs +3 -3
- package/dist/di/index.d.cts +2 -2
- package/dist/di/index.d.ts +2 -2
- package/dist/di/index.js +1 -1
- package/dist/eval/index.d.cts +1 -1
- package/dist/eval/index.d.ts +1 -1
- package/dist/index.cjs +55 -51
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.d.cts +1 -1
- package/dist/integration/index.d.ts +1 -1
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.d.cts +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +1 -1
- package/dist/mastra/index.d.ts +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +3 -3
- package/dist/memory/index.d.cts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +8 -8
- package/dist/network/index.d.cts +1 -1
- package/dist/network/index.d.ts +1 -1
- package/dist/network/index.js +6 -6
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +1 -1
- package/dist/relevance/index.d.ts +1 -1
- package/dist/relevance/index.js +1 -1
- package/dist/runtime-context/index.cjs +71 -0
- package/dist/runtime-context/index.d.cts +52 -0
- package/dist/runtime-context/index.d.ts +52 -0
- package/dist/runtime-context/index.js +69 -0
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/storage/index.d.cts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/libsql/index.d.cts +1 -1
- package/dist/storage/libsql/index.d.ts +1 -1
- package/dist/telemetry/index.d.cts +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.cts +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/utils.cjs +17 -13
- package/dist/utils.d.cts +10 -4
- package/dist/utils.d.ts +10 -4
- package/dist/utils.js +1 -1
- package/dist/vector/libsql/index.cjs +3 -3
- package/dist/vector/libsql/index.js +1 -1
- package/dist/voice/index.d.cts +2 -2
- package/dist/voice/index.d.ts +2 -2
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.d.cts +2 -2
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +1 -1
- package/package.json +1 -1
- package/runtime-context.d.ts +1 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DefaultVoice } from './chunk-MWLZJBPF.js';
|
|
2
2
|
import { InstrumentClass } from './chunk-HFOT2NFM.js';
|
|
3
|
-
import { ensureToolProperties, ensureAllMessagesAreCoreMessages, createMastraProxy, makeCoreTool, delay } from './chunk-
|
|
3
|
+
import { ensureToolProperties, ensureAllMessagesAreCoreMessages, createMastraProxy, makeCoreTool, delay } from './chunk-NTHHPNOW.js';
|
|
4
4
|
import { MastraBase } from './chunk-CLJQYXNM.js';
|
|
5
5
|
import { RegisteredLogger } from './chunk-2BVZNKLX.js';
|
|
6
|
-
import {
|
|
6
|
+
import { RuntimeContext } from './chunk-M472GIT6.js';
|
|
7
7
|
import { executeHook } from './chunk-BB4KXGBU.js';
|
|
8
8
|
import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
|
|
9
9
|
import { context, trace } from '@opentelemetry/api';
|
|
@@ -192,7 +192,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
192
192
|
threadId,
|
|
193
193
|
resourceId,
|
|
194
194
|
memory,
|
|
195
|
-
|
|
195
|
+
runtimeContext
|
|
196
196
|
}) {
|
|
197
197
|
this.logger.debug("Starting tool conversion for LLM");
|
|
198
198
|
let mastraProxy = void 0;
|
|
@@ -215,7 +215,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
215
215
|
logger: this.logger,
|
|
216
216
|
memory,
|
|
217
217
|
mastra: mastraProxy,
|
|
218
|
-
|
|
218
|
+
runtimeContext
|
|
219
219
|
};
|
|
220
220
|
memo[k] = makeCoreTool(tool, options);
|
|
221
221
|
}
|
|
@@ -238,7 +238,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
238
238
|
threadId,
|
|
239
239
|
resourceId,
|
|
240
240
|
memory,
|
|
241
|
-
|
|
241
|
+
runtimeContext,
|
|
242
242
|
...rest
|
|
243
243
|
}) {
|
|
244
244
|
const model = this.#model;
|
|
@@ -256,7 +256,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
256
256
|
threadId,
|
|
257
257
|
resourceId,
|
|
258
258
|
memory,
|
|
259
|
-
|
|
259
|
+
runtimeContext
|
|
260
260
|
});
|
|
261
261
|
const argsForExecute = {
|
|
262
262
|
model,
|
|
@@ -325,7 +325,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
325
325
|
threadId,
|
|
326
326
|
resourceId,
|
|
327
327
|
memory,
|
|
328
|
-
|
|
328
|
+
runtimeContext,
|
|
329
329
|
...rest
|
|
330
330
|
}) {
|
|
331
331
|
const model = this.#model;
|
|
@@ -338,7 +338,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
338
338
|
threadId,
|
|
339
339
|
resourceId,
|
|
340
340
|
memory,
|
|
341
|
-
|
|
341
|
+
runtimeContext
|
|
342
342
|
});
|
|
343
343
|
const argsForExecute = {
|
|
344
344
|
model,
|
|
@@ -404,7 +404,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
404
404
|
threadId,
|
|
405
405
|
resourceId,
|
|
406
406
|
memory,
|
|
407
|
-
|
|
407
|
+
runtimeContext,
|
|
408
408
|
...rest
|
|
409
409
|
}) {
|
|
410
410
|
const model = this.#model;
|
|
@@ -422,7 +422,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
422
422
|
threadId,
|
|
423
423
|
resourceId,
|
|
424
424
|
memory,
|
|
425
|
-
|
|
425
|
+
runtimeContext
|
|
426
426
|
});
|
|
427
427
|
const argsForExecute = {
|
|
428
428
|
model,
|
|
@@ -497,7 +497,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
497
497
|
convertedTools,
|
|
498
498
|
maxSteps = 5,
|
|
499
499
|
toolChoice = "auto",
|
|
500
|
-
|
|
500
|
+
runtimeContext,
|
|
501
501
|
threadId,
|
|
502
502
|
resourceId,
|
|
503
503
|
memory,
|
|
@@ -521,7 +521,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
521
521
|
threadId,
|
|
522
522
|
resourceId,
|
|
523
523
|
memory,
|
|
524
|
-
|
|
524
|
+
runtimeContext
|
|
525
525
|
});
|
|
526
526
|
const argsForExecute = {
|
|
527
527
|
model,
|
|
@@ -819,7 +819,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
819
819
|
const {
|
|
820
820
|
text
|
|
821
821
|
} = await this.llm.__text({
|
|
822
|
-
|
|
822
|
+
runtimeContext: new RuntimeContext(),
|
|
823
823
|
messages: [{
|
|
824
824
|
role: "system",
|
|
825
825
|
content: `
|
|
@@ -918,7 +918,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
918
918
|
messages: [memorySystemMessage ? {
|
|
919
919
|
role: "system",
|
|
920
920
|
content: memorySystemMessage
|
|
921
|
-
} : null, ...processedMessages].filter(message => Boolean(message))
|
|
921
|
+
} : null, ...processedMessages, ...newMessages].filter(message => Boolean(message))
|
|
922
922
|
};
|
|
923
923
|
}
|
|
924
924
|
return {
|
|
@@ -1040,7 +1040,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1040
1040
|
threadId,
|
|
1041
1041
|
resourceId,
|
|
1042
1042
|
runId,
|
|
1043
|
-
|
|
1043
|
+
runtimeContext
|
|
1044
1044
|
}) {
|
|
1045
1045
|
this.logger.debug(`[Agents:${this.name}] - Assigning tools`, {
|
|
1046
1046
|
runId,
|
|
@@ -1070,7 +1070,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1070
1070
|
mastra: mastraProxy,
|
|
1071
1071
|
memory,
|
|
1072
1072
|
agentName: this.name,
|
|
1073
|
-
|
|
1073
|
+
runtimeContext
|
|
1074
1074
|
};
|
|
1075
1075
|
memo[k] = makeCoreTool(tool, options);
|
|
1076
1076
|
}
|
|
@@ -1099,7 +1099,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1099
1099
|
resourceId,
|
|
1100
1100
|
logger: this.logger,
|
|
1101
1101
|
agentName: this.name,
|
|
1102
|
-
|
|
1102
|
+
runtimeContext
|
|
1103
1103
|
}, options) ?? void 0;
|
|
1104
1104
|
} catch (err) {
|
|
1105
1105
|
this.logger.error(`[Agent:${this.name}] - Failed memory tool execution`, {
|
|
@@ -1135,7 +1135,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1135
1135
|
mastra: mastraProxy,
|
|
1136
1136
|
memory,
|
|
1137
1137
|
agentName: this.name,
|
|
1138
|
-
|
|
1138
|
+
runtimeContext
|
|
1139
1139
|
};
|
|
1140
1140
|
const convertedToCoreTool = makeCoreTool(toolObj, options, "toolset");
|
|
1141
1141
|
toolsFromToolsetsConverted[toolName] = convertedToCoreTool;
|
|
@@ -1161,7 +1161,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1161
1161
|
mastra: mastraProxy,
|
|
1162
1162
|
memory,
|
|
1163
1163
|
agentName: this.name,
|
|
1164
|
-
|
|
1164
|
+
runtimeContext
|
|
1165
1165
|
};
|
|
1166
1166
|
const convertedToCoreTool = makeCoreTool(rest, options, "client-tool");
|
|
1167
1167
|
toolsFromToolsetsConverted[toolName] = convertedToCoreTool;
|
|
@@ -1208,7 +1208,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1208
1208
|
runId,
|
|
1209
1209
|
toolsets,
|
|
1210
1210
|
clientTools,
|
|
1211
|
-
|
|
1211
|
+
runtimeContext
|
|
1212
1212
|
}) {
|
|
1213
1213
|
return {
|
|
1214
1214
|
before: async () => {
|
|
@@ -1280,7 +1280,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1280
1280
|
threadId: threadIdToUse,
|
|
1281
1281
|
resourceId,
|
|
1282
1282
|
runId,
|
|
1283
|
-
|
|
1283
|
+
runtimeContext
|
|
1284
1284
|
});
|
|
1285
1285
|
}
|
|
1286
1286
|
const messageObjects = [systemMessage, ...(context || []), ...coreMessages];
|
|
@@ -1411,7 +1411,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1411
1411
|
toolChoice = "auto",
|
|
1412
1412
|
experimental_output,
|
|
1413
1413
|
telemetry,
|
|
1414
|
-
|
|
1414
|
+
runtimeContext,
|
|
1415
1415
|
...rest
|
|
1416
1416
|
} = Object.assign({}, this.#defaultGenerateOptions, generateOptions);
|
|
1417
1417
|
let messagesToUse = [];
|
|
@@ -1434,7 +1434,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1434
1434
|
messagesToUse = [messages];
|
|
1435
1435
|
}
|
|
1436
1436
|
const runIdToUse = runId || randomUUID();
|
|
1437
|
-
const
|
|
1437
|
+
const normalizedRuntimeContext = runtimeContext ?? new RuntimeContext();
|
|
1438
1438
|
const {
|
|
1439
1439
|
before,
|
|
1440
1440
|
after
|
|
@@ -1448,7 +1448,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1448
1448
|
runId: runIdToUse,
|
|
1449
1449
|
toolsets,
|
|
1450
1450
|
clientTools,
|
|
1451
|
-
|
|
1451
|
+
runtimeContext: normalizedRuntimeContext
|
|
1452
1452
|
});
|
|
1453
1453
|
const {
|
|
1454
1454
|
threadId,
|
|
@@ -1472,7 +1472,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1472
1472
|
threadId,
|
|
1473
1473
|
resourceId,
|
|
1474
1474
|
memory: this.getMemory(),
|
|
1475
|
-
|
|
1475
|
+
runtimeContext: normalizedRuntimeContext,
|
|
1476
1476
|
...rest
|
|
1477
1477
|
});
|
|
1478
1478
|
const outputText2 = result2.text;
|
|
@@ -1504,7 +1504,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1504
1504
|
threadId,
|
|
1505
1505
|
resourceId,
|
|
1506
1506
|
memory: this.getMemory(),
|
|
1507
|
-
|
|
1507
|
+
runtimeContext: normalizedRuntimeContext,
|
|
1508
1508
|
...rest
|
|
1509
1509
|
});
|
|
1510
1510
|
const outputText2 = result2.text;
|
|
@@ -1532,7 +1532,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1532
1532
|
toolChoice,
|
|
1533
1533
|
telemetry,
|
|
1534
1534
|
memory: this.getMemory(),
|
|
1535
|
-
|
|
1535
|
+
runtimeContext: normalizedRuntimeContext,
|
|
1536
1536
|
...rest
|
|
1537
1537
|
});
|
|
1538
1538
|
const outputText = JSON.stringify(result.object);
|
|
@@ -1564,10 +1564,10 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1564
1564
|
toolChoice = "auto",
|
|
1565
1565
|
experimental_output,
|
|
1566
1566
|
telemetry,
|
|
1567
|
-
|
|
1567
|
+
runtimeContext,
|
|
1568
1568
|
...rest
|
|
1569
1569
|
} = Object.assign({}, this.#defaultStreamOptions, streamOptions);
|
|
1570
|
-
const
|
|
1570
|
+
const normalizedRuntimeContext = runtimeContext ?? new RuntimeContext();
|
|
1571
1571
|
const runIdToUse = runId || randomUUID();
|
|
1572
1572
|
let messagesToUse = [];
|
|
1573
1573
|
if (typeof messages === `string`) {
|
|
@@ -1599,7 +1599,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1599
1599
|
runId: runIdToUse,
|
|
1600
1600
|
toolsets,
|
|
1601
1601
|
clientTools,
|
|
1602
|
-
|
|
1602
|
+
runtimeContext: normalizedRuntimeContext
|
|
1603
1603
|
});
|
|
1604
1604
|
const {
|
|
1605
1605
|
threadId,
|
|
@@ -1643,7 +1643,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1643
1643
|
toolChoice,
|
|
1644
1644
|
experimental_output,
|
|
1645
1645
|
memory: this.getMemory(),
|
|
1646
|
-
|
|
1646
|
+
runtimeContext: normalizedRuntimeContext,
|
|
1647
1647
|
...rest
|
|
1648
1648
|
});
|
|
1649
1649
|
const newStreamResult = streamResult;
|
|
@@ -1685,7 +1685,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1685
1685
|
toolChoice,
|
|
1686
1686
|
telemetry,
|
|
1687
1687
|
memory: this.getMemory(),
|
|
1688
|
-
|
|
1688
|
+
runtimeContext: normalizedRuntimeContext,
|
|
1689
1689
|
...rest
|
|
1690
1690
|
});
|
|
1691
1691
|
}
|
|
@@ -1724,7 +1724,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1724
1724
|
toolChoice,
|
|
1725
1725
|
telemetry,
|
|
1726
1726
|
memory: this.getMemory(),
|
|
1727
|
-
|
|
1727
|
+
runtimeContext: normalizedRuntimeContext,
|
|
1728
1728
|
...rest
|
|
1729
1729
|
});
|
|
1730
1730
|
}
|
|
@@ -2005,7 +2005,7 @@ function workflowToStep(workflow, {
|
|
|
2005
2005
|
suspend,
|
|
2006
2006
|
emit,
|
|
2007
2007
|
mastra: mastraFromExecute,
|
|
2008
|
-
|
|
2008
|
+
runtimeContext
|
|
2009
2009
|
}) => {
|
|
2010
2010
|
const realMastra = mastraFromExecute ?? mastra;
|
|
2011
2011
|
if (realMastra) {
|
|
@@ -2029,10 +2029,10 @@ function workflowToStep(workflow, {
|
|
|
2029
2029
|
const awaitedResult = context.isResume && context.isResume.stepId.includes(".") ? await run.resume({
|
|
2030
2030
|
stepId: context.isResume.stepId.split(".").slice(1).join("."),
|
|
2031
2031
|
context: context.inputData,
|
|
2032
|
-
|
|
2032
|
+
runtimeContext
|
|
2033
2033
|
}) : await run.start({
|
|
2034
2034
|
triggerData: context.inputData,
|
|
2035
|
-
|
|
2035
|
+
runtimeContext
|
|
2036
2036
|
});
|
|
2037
2037
|
unwatch();
|
|
2038
2038
|
if (!awaitedResult) {
|
|
@@ -2087,7 +2087,7 @@ function isConditionalKey(key) {
|
|
|
2087
2087
|
var Machine = class extends EventEmitter {
|
|
2088
2088
|
logger;
|
|
2089
2089
|
#mastra;
|
|
2090
|
-
#
|
|
2090
|
+
#runtimeContext;
|
|
2091
2091
|
#workflowInstance;
|
|
2092
2092
|
#executionSpan;
|
|
2093
2093
|
#stepGraph;
|
|
@@ -2101,7 +2101,7 @@ var Machine = class extends EventEmitter {
|
|
|
2101
2101
|
constructor({
|
|
2102
2102
|
logger,
|
|
2103
2103
|
mastra,
|
|
2104
|
-
|
|
2104
|
+
runtimeContext,
|
|
2105
2105
|
workflowInstance,
|
|
2106
2106
|
executionSpan,
|
|
2107
2107
|
name,
|
|
@@ -2114,7 +2114,7 @@ var Machine = class extends EventEmitter {
|
|
|
2114
2114
|
super();
|
|
2115
2115
|
this.#mastra = mastra;
|
|
2116
2116
|
this.#workflowInstance = workflowInstance;
|
|
2117
|
-
this.#
|
|
2117
|
+
this.#runtimeContext = runtimeContext;
|
|
2118
2118
|
this.#executionSpan = executionSpan;
|
|
2119
2119
|
this.logger = logger;
|
|
2120
2120
|
this.#runId = runId;
|
|
@@ -2441,7 +2441,7 @@ var Machine = class extends EventEmitter {
|
|
|
2441
2441
|
},
|
|
2442
2442
|
runId: this.#runId,
|
|
2443
2443
|
mastra: mastraProxy,
|
|
2444
|
-
|
|
2444
|
+
runtimeContext: this.#runtimeContext
|
|
2445
2445
|
});
|
|
2446
2446
|
} catch (error) {
|
|
2447
2447
|
this.logger.debug(`Step ${stepNode.id} failed`, {
|
|
@@ -2566,7 +2566,7 @@ var Machine = class extends EventEmitter {
|
|
|
2566
2566
|
parentStepId,
|
|
2567
2567
|
context
|
|
2568
2568
|
} = input;
|
|
2569
|
-
const result = await this.#workflowInstance.runMachine(parentStepId, context, this.#
|
|
2569
|
+
const result = await this.#workflowInstance.runMachine(parentStepId, context, this.#runtimeContext);
|
|
2570
2570
|
return Promise.resolve({
|
|
2571
2571
|
steps: result.reduce((acc, r) => {
|
|
2572
2572
|
return {
|
|
@@ -3254,11 +3254,11 @@ var WorkflowInstance = class {
|
|
|
3254
3254
|
}
|
|
3255
3255
|
async start({
|
|
3256
3256
|
triggerData,
|
|
3257
|
-
|
|
3257
|
+
runtimeContext
|
|
3258
3258
|
} = {}) {
|
|
3259
3259
|
const results = await this.execute({
|
|
3260
3260
|
triggerData,
|
|
3261
|
-
|
|
3261
|
+
runtimeContext: runtimeContext ?? new RuntimeContext()
|
|
3262
3262
|
});
|
|
3263
3263
|
if (this.#onFinish) {
|
|
3264
3264
|
this.#onFinish();
|
|
@@ -3278,9 +3278,9 @@ var WorkflowInstance = class {
|
|
|
3278
3278
|
snapshot,
|
|
3279
3279
|
stepId,
|
|
3280
3280
|
resumeData,
|
|
3281
|
-
|
|
3281
|
+
runtimeContext
|
|
3282
3282
|
} = {
|
|
3283
|
-
|
|
3283
|
+
runtimeContext: new RuntimeContext()
|
|
3284
3284
|
}) {
|
|
3285
3285
|
this.#executionSpan = this.#mastra?.getTelemetry()?.tracer.startSpan(`workflow.${this.name}.execute`, {
|
|
3286
3286
|
attributes: {
|
|
@@ -3310,7 +3310,7 @@ var WorkflowInstance = class {
|
|
|
3310
3310
|
const defaultMachine = new Machine({
|
|
3311
3311
|
logger: this.logger,
|
|
3312
3312
|
mastra: this.#mastra,
|
|
3313
|
-
|
|
3313
|
+
runtimeContext,
|
|
3314
3314
|
workflowInstance: this,
|
|
3315
3315
|
name: this.name,
|
|
3316
3316
|
runId: this.runId,
|
|
@@ -3380,7 +3380,7 @@ var WorkflowInstance = class {
|
|
|
3380
3380
|
hasSubscribers(stepId) {
|
|
3381
3381
|
return Object.keys(this.#stepSubscriberGraph).some(key => key.split("&&").includes(stepId));
|
|
3382
3382
|
}
|
|
3383
|
-
async runMachine(parentStepId, input,
|
|
3383
|
+
async runMachine(parentStepId, input, runtimeContext = new RuntimeContext()) {
|
|
3384
3384
|
const stepStatus = input.steps[parentStepId]?.status;
|
|
3385
3385
|
const subscriberKeys = Object.keys(this.#stepSubscriberGraph).filter(key => key.split("&&").includes(parentStepId));
|
|
3386
3386
|
subscriberKeys.forEach(key => {
|
|
@@ -3424,7 +3424,7 @@ var WorkflowInstance = class {
|
|
|
3424
3424
|
const machine = new Machine({
|
|
3425
3425
|
logger: this.logger,
|
|
3426
3426
|
mastra: this.#mastra,
|
|
3427
|
-
|
|
3427
|
+
runtimeContext,
|
|
3428
3428
|
workflowInstance: this,
|
|
3429
3429
|
name: parentStepId === "trigger" ? this.name : `${this.name}-${parentStepId}`,
|
|
3430
3430
|
runId: this.runId,
|
|
@@ -3568,7 +3568,7 @@ var WorkflowInstance = class {
|
|
|
3568
3568
|
timestamp: Date.now()
|
|
3569
3569
|
};
|
|
3570
3570
|
}
|
|
3571
|
-
async resumeWithEvent(eventName, data,
|
|
3571
|
+
async resumeWithEvent(eventName, data, runtimeContext = new RuntimeContext()) {
|
|
3572
3572
|
const event = this.events?.[eventName];
|
|
3573
3573
|
if (!event) {
|
|
3574
3574
|
throw new Error(`Event ${eventName} not found`);
|
|
@@ -3578,20 +3578,20 @@ var WorkflowInstance = class {
|
|
|
3578
3578
|
context: {
|
|
3579
3579
|
resumedEvent: data
|
|
3580
3580
|
},
|
|
3581
|
-
|
|
3581
|
+
runtimeContext
|
|
3582
3582
|
});
|
|
3583
3583
|
return results;
|
|
3584
3584
|
}
|
|
3585
3585
|
async resume({
|
|
3586
3586
|
stepId,
|
|
3587
3587
|
context: resumeContext,
|
|
3588
|
-
|
|
3588
|
+
runtimeContext = new RuntimeContext()
|
|
3589
3589
|
}) {
|
|
3590
3590
|
await new Promise(resolve => setTimeout(resolve, 0));
|
|
3591
3591
|
return this._resume({
|
|
3592
3592
|
stepId,
|
|
3593
3593
|
context: resumeContext,
|
|
3594
|
-
|
|
3594
|
+
runtimeContext
|
|
3595
3595
|
});
|
|
3596
3596
|
}
|
|
3597
3597
|
async #loadWorkflowSnapshot(runId) {
|
|
@@ -3611,7 +3611,7 @@ var WorkflowInstance = class {
|
|
|
3611
3611
|
async _resume({
|
|
3612
3612
|
stepId,
|
|
3613
3613
|
context: resumeContext,
|
|
3614
|
-
|
|
3614
|
+
runtimeContext
|
|
3615
3615
|
}) {
|
|
3616
3616
|
const snapshot = await this.#loadWorkflowSnapshot(this.runId);
|
|
3617
3617
|
if (!snapshot) {
|
|
@@ -3679,7 +3679,7 @@ var WorkflowInstance = class {
|
|
|
3679
3679
|
snapshot: parsedSnapshot,
|
|
3680
3680
|
stepId: stepPath,
|
|
3681
3681
|
resumeData: resumeContext,
|
|
3682
|
-
|
|
3682
|
+
runtimeContext
|
|
3683
3683
|
});
|
|
3684
3684
|
}
|
|
3685
3685
|
#initializeCompoundDependencies() {
|
|
@@ -4644,7 +4644,7 @@ var Workflow = class extends MastraBase {
|
|
|
4644
4644
|
runId,
|
|
4645
4645
|
stepId,
|
|
4646
4646
|
context: resumeContext,
|
|
4647
|
-
|
|
4647
|
+
runtimeContext = new RuntimeContext()
|
|
4648
4648
|
}) {
|
|
4649
4649
|
this.logger.warn(`Please use 'resume' on the 'createRun' call instead, resume is deprecated`);
|
|
4650
4650
|
const activeRun = this.#runs.get(runId);
|
|
@@ -4652,7 +4652,7 @@ var Workflow = class extends MastraBase {
|
|
|
4652
4652
|
return activeRun.resume({
|
|
4653
4653
|
stepId,
|
|
4654
4654
|
context: resumeContext,
|
|
4655
|
-
|
|
4655
|
+
runtimeContext
|
|
4656
4656
|
});
|
|
4657
4657
|
}
|
|
4658
4658
|
const run = this.createRun({
|
|
@@ -4661,7 +4661,7 @@ var Workflow = class extends MastraBase {
|
|
|
4661
4661
|
return run.resume({
|
|
4662
4662
|
stepId,
|
|
4663
4663
|
context: resumeContext,
|
|
4664
|
-
|
|
4664
|
+
runtimeContext
|
|
4665
4665
|
});
|
|
4666
4666
|
}
|
|
4667
4667
|
watch(onTransition) {
|
|
@@ -4683,7 +4683,7 @@ var Workflow = class extends MastraBase {
|
|
|
4683
4683
|
context: {
|
|
4684
4684
|
resumedEvent: data
|
|
4685
4685
|
},
|
|
4686
|
-
|
|
4686
|
+
runtimeContext: new RuntimeContext()
|
|
4687
4687
|
});
|
|
4688
4688
|
return results;
|
|
4689
4689
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkTEEAQX2B_cjs = require('./chunk-TEEAQX2B.cjs');
|
|
4
4
|
var chunkWEYWYKLG_cjs = require('./chunk-WEYWYKLG.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunk53P5ZBJE_cjs = require('./chunk-53P5ZBJE.cjs');
|
|
6
6
|
var chunkD63P5O4Q_cjs = require('./chunk-D63P5O4Q.cjs');
|
|
7
7
|
var fs = require('fs');
|
|
8
8
|
var path = require('path');
|
|
@@ -169,7 +169,7 @@ var MastraMemory = class extends chunkD63P5O4Q_cjs.MastraBase {
|
|
|
169
169
|
`Found deprecated Memory vector db file ${oldDb} this db is now merged with the default ${newDb} file. Delete the old one to use the new one. You will need to migrate any data if that's important to you. For now the deprecated path will be used but in a future breaking change we will only use the new db file path.`
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
|
-
this.vector = new
|
|
172
|
+
this.vector = new chunkTEEAQX2B_cjs.LibSQLVector({
|
|
173
173
|
connectionUrl: hasOldDb ? `file:${oldDb}` : `file:${newDb}`
|
|
174
174
|
});
|
|
175
175
|
}
|
|
@@ -227,7 +227,7 @@ var MastraMemory = class extends chunkD63P5O4Q_cjs.MastraBase {
|
|
|
227
227
|
return { indexName };
|
|
228
228
|
}
|
|
229
229
|
getMergedThreadConfig(config) {
|
|
230
|
-
return
|
|
230
|
+
return chunk53P5ZBJE_cjs.deepMerge(this.threadConfig, config || {});
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
233
233
|
* Apply all configured message processors to a list of messages.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/di/index.ts
|
|
2
|
-
var
|
|
2
|
+
var RuntimeContext = class {
|
|
3
3
|
registry = /* @__PURE__ */ new Map();
|
|
4
4
|
constructor(iterable) {
|
|
5
5
|
this.registry = new Map(iterable);
|
|
@@ -66,4 +66,4 @@ var Container = class {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
export {
|
|
69
|
+
export { RuntimeContext };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LibSQLVector } from './chunk-
|
|
1
|
+
import { LibSQLVector } from './chunk-DGL5RCEO.js';
|
|
2
2
|
import { DefaultProxyStorage, augmentWithInit } from './chunk-LANFNMEE.js';
|
|
3
|
-
import { deepMerge } from './chunk-
|
|
3
|
+
import { deepMerge } from './chunk-NTHHPNOW.js';
|
|
4
4
|
import { MastraBase } from './chunk-CLJQYXNM.js';
|
|
5
5
|
import { existsSync } from 'fs';
|
|
6
6
|
import { join } from 'path';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RuntimeContext } from './chunk-M472GIT6.js';
|
|
2
2
|
import { createHash } from 'crypto';
|
|
3
3
|
import { convertToCoreMessages } from 'ai';
|
|
4
4
|
import jsonSchemaToZod from 'json-schema-to-zod';
|
|
@@ -221,7 +221,7 @@ function createLogMessageOptions({ agentName, toolName, type }) {
|
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
function createExecute(tool, options, logType) {
|
|
224
|
-
const { logger, mastra: _mastra, memory: _memory,
|
|
224
|
+
const { logger, mastra: _mastra, memory: _memory, runtimeContext, ...rest } = options;
|
|
225
225
|
const { start, error } = createLogMessageOptions({
|
|
226
226
|
agentName: options.agentName,
|
|
227
227
|
toolName: options.name,
|
|
@@ -239,7 +239,7 @@ function createExecute(tool, options, logType) {
|
|
|
239
239
|
mastra: options.mastra,
|
|
240
240
|
memory: options.memory,
|
|
241
241
|
runId: options.runId,
|
|
242
|
-
|
|
242
|
+
runtimeContext: runtimeContext ?? new RuntimeContext()
|
|
243
243
|
},
|
|
244
244
|
execOptions
|
|
245
245
|
) ?? void 0;
|
|
@@ -427,4 +427,4 @@ ${JSON.stringify(message, null, 2)}
|
|
|
427
427
|
}).flat();
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
export { Tool, checkEvalStorageFields, createMastraProxy, createTool, deepMerge, delay, ensureAllMessagesAreCoreMessages, ensureToolProperties, isVercelTool, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, makeCoreTool, maskStreamTags, resolveSerializedZodOutput };
|
|
430
|
+
export { Tool, checkEvalStorageFields, createMastraProxy, createTool, deepMerge, delay, ensureAllMessagesAreCoreMessages, ensureToolProperties, isVercelTool, isZodType, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, makeCoreTool, maskStreamTags, resolveSerializedZodOutput };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/di/index.ts
|
|
4
|
-
var
|
|
4
|
+
var RuntimeContext = class {
|
|
5
5
|
registry = /* @__PURE__ */ new Map();
|
|
6
6
|
constructor(iterable) {
|
|
7
7
|
this.registry = new Map(iterable);
|
|
@@ -68,4 +68,4 @@ var Container = class {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
exports.
|
|
71
|
+
exports.RuntimeContext = RuntimeContext;
|
|
@@ -54,7 +54,7 @@ var Mastra = class {
|
|
|
54
54
|
if (config?.logger) {
|
|
55
55
|
logger = config.logger;
|
|
56
56
|
} else {
|
|
57
|
-
const levleOnEnv = process.env.NODE_ENV === "production" ? LogLevel.WARN : LogLevel.INFO;
|
|
57
|
+
const levleOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ? LogLevel.WARN : LogLevel.INFO;
|
|
58
58
|
logger = createLogger({
|
|
59
59
|
name: "Mastra",
|
|
60
60
|
level: levleOnEnv
|
|
@@ -74,7 +74,7 @@ var Mastra = class {
|
|
|
74
74
|
this.#telemetry = Telemetry.init(config?.telemetry);
|
|
75
75
|
if (this.#telemetry) {
|
|
76
76
|
this.#storage = this.#telemetry.traceClass(storage, {
|
|
77
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry", "
|
|
77
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry", "batchTraceInsert"]
|
|
78
78
|
});
|
|
79
79
|
this.#storage.__setTelemetry(this.#telemetry);
|
|
80
80
|
} else {
|
|
@@ -305,7 +305,7 @@ This is a warning for now, but will throw an error in the future
|
|
|
305
305
|
}
|
|
306
306
|
if (this.#storage) {
|
|
307
307
|
this.#storage = this.#telemetry.traceClass(this.#storage, {
|
|
308
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"
|
|
308
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
309
309
|
});
|
|
310
310
|
this.#storage.__setTelemetry(this.#telemetry);
|
|
311
311
|
}
|