@mastra/core 0.9.4 → 0.10.0-alpha.1
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/README.md +3 -2
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +13 -14
- package/dist/agent/index.d.ts +13 -14
- package/dist/agent/index.js +1 -1
- package/dist/{base-BCfssGt6.d.ts → base-DttB7sJD.d.ts} +1187 -886
- package/dist/{base-CAEcd6q2.d.cts → base-aJ3etsh5.d.cts} +1187 -886
- package/dist/{base-H7siSAfu.d.cts → base-aPYtPBT2.d.cts} +3 -3
- package/dist/{base-4Z34GQL8.d.ts → base-tc5kgDTD.d.ts} +3 -3
- package/dist/base.cjs +2 -2
- package/dist/base.d.cts +2 -3
- package/dist/base.d.ts +2 -3
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.cts +2 -3
- package/dist/bundler/index.d.ts +2 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-W4BSLENO.js → chunk-2NTUAUGH.js} +1 -1
- package/dist/{chunk-S34QVMKE.js → chunk-2PW6UJMW.js} +77 -10
- package/dist/{chunk-WE36CRQV.cjs → chunk-2U7ZZUFO.cjs} +2 -2
- package/dist/{workflows/vNext/index.js → chunk-3SQ3G2EJ.js} +19 -16
- package/dist/chunk-5HULBQ2W.cjs +38 -0
- package/dist/{chunk-XRGDVLM4.cjs → chunk-5JRD3NDP.cjs} +15 -15
- package/dist/{chunk-GXKODTLA.cjs → chunk-5W2G7S44.cjs} +83 -68
- package/dist/chunk-75Z4BZEE.js +36 -0
- package/dist/{chunk-66GQROSI.cjs → chunk-AOGUTJUO.cjs} +58 -51
- package/dist/{chunk-WIKOYZ63.js → chunk-BPTSLJHA.js} +9 -9
- package/dist/{chunk-JBJ7KXN5.js → chunk-C3ICEF6E.js} +1 -1
- package/dist/{chunk-E4FAXBUV.cjs → chunk-CWSFP2HS.cjs} +2 -2
- package/dist/{chunk-FW5RS6WV.js → chunk-E7CLY6SK.js} +42 -35
- package/dist/{chunk-235X76GC.js → chunk-FI7R232B.js} +2 -2
- package/dist/chunk-GQ2XQ4UN.js +321 -0
- package/dist/{chunk-H4CEZSRM.js → chunk-J7GDGV6F.js} +1 -1
- package/dist/{chunk-NLBJOFNG.js → chunk-JW5TMK2L.js} +1 -1
- package/dist/{chunk-NOPY74PV.js → chunk-KJQFFEEQ.js} +1 -1
- package/dist/{chunk-V2Q2FEVO.cjs → chunk-KSPHQSZX.cjs} +2 -2
- package/dist/{chunk-NZV4OA6P.js → chunk-LHRZV5VG.js} +2 -23
- package/dist/chunk-NMDM4IZN.cjs +78 -0
- package/dist/chunk-OBEALYTK.js +74 -0
- package/dist/{chunk-PEK4TY3P.js → chunk-OCT2762Q.js} +1 -1
- package/dist/{chunk-5DUFC7TV.cjs → chunk-P7BGXOQV.cjs} +2 -2
- package/dist/{chunk-WQKOM7XM.cjs → chunk-PIZM25KI.cjs} +3 -24
- package/dist/{chunk-S7J63JOG.cjs → chunk-RVS6OUJN.cjs} +2 -2
- package/dist/{chunk-5JUWUTPJ.cjs → chunk-SKG2NIZW.cjs} +2 -2
- package/dist/chunk-SWW4EBUZ.cjs +96 -0
- package/dist/{chunk-RGE4UF6A.cjs → chunk-TMPFLJLG.cjs} +2 -2
- package/dist/{workflows/vNext/index.cjs → chunk-TTKQ37ZZ.cjs} +24 -21
- package/dist/{chunk-EJITEVAB.cjs → chunk-U3L3NEOM.cjs} +81 -10
- package/dist/chunk-VHLL4AZK.js +90 -0
- package/dist/{chunk-EG74VBSP.cjs → chunk-YEULQPUY.cjs} +6 -6
- package/dist/{chunk-SOLXHDNQ.js → chunk-ZB3LEHL2.js} +81 -66
- package/dist/{chunk-TAFOICHR.js → chunk-ZKN6HYYQ.js} +1 -1
- package/dist/chunk-ZZDAC5KD.cjs +325 -0
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.d.cts +2 -3
- package/dist/deployer/index.d.ts +2 -3
- package/dist/deployer/index.js +1 -1
- package/dist/eval/index.d.cts +13 -14
- package/dist/eval/index.d.ts +13 -14
- package/dist/hooks/index.d.cts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.cjs +88 -159
- package/dist/index.d.cts +17 -25
- package/dist/index.d.ts +17 -25
- package/dist/index.js +18 -25
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.d.cts +12 -13
- package/dist/integration/index.d.ts +12 -13
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.d.cts +13 -14
- package/dist/llm/index.d.ts +13 -14
- package/dist/logger/index.cjs +18 -17
- package/dist/logger/index.d.cts +42 -2
- package/dist/logger/index.d.ts +42 -2
- package/dist/logger/index.js +2 -1
- package/dist/{index-QV27jkxQ.d.ts → logger-EhZkzZOr.d.cts} +38 -52
- package/dist/{index-QV27jkxQ.d.cts → logger-EhZkzZOr.d.ts} +38 -52
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +11 -12
- package/dist/mastra/index.d.ts +11 -12
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +75 -17
- package/dist/mcp/index.d.cts +14 -15
- package/dist/mcp/index.d.ts +14 -15
- package/dist/mcp/index.js +69 -15
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.d.cts +12 -13
- package/dist/memory/index.d.ts +12 -13
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +8 -8
- package/dist/network/index.d.cts +12 -13
- package/dist/network/index.d.ts +12 -13
- package/dist/network/index.js +5 -5
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +15 -16
- package/dist/relevance/index.d.ts +15 -16
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +4 -0
- package/dist/server/index.d.cts +13 -12
- package/dist/server/index.d.ts +13 -12
- package/dist/server/index.js +4 -1
- package/dist/storage/index.cjs +184 -3
- package/dist/storage/index.d.cts +83 -13
- package/dist/storage/index.d.ts +83 -13
- package/dist/storage/index.js +186 -1
- package/dist/telemetry/index.d.cts +14 -15
- package/dist/telemetry/index.d.ts +14 -15
- package/dist/telemetry/otel-vendor.cjs +2 -2
- package/dist/telemetry/otel-vendor.d.cts +1 -1
- package/dist/telemetry/otel-vendor.d.ts +1 -1
- package/dist/telemetry/otel-vendor.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.cts +12 -13
- package/dist/tools/index.d.ts +12 -13
- package/dist/tools/index.js +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.d.cts +2 -3
- package/dist/tts/index.d.ts +2 -3
- package/dist/tts/index.js +1 -1
- package/dist/{types-BtMyV38I.d.ts → types-Bo1uigWx.d.cts} +1 -1
- package/dist/{types-BtMyV38I.d.cts → types-Bo1uigWx.d.ts} +1 -1
- package/dist/utils.cjs +28 -12
- package/dist/utils.d.cts +59 -16
- package/dist/utils.d.ts +59 -16
- package/dist/utils.js +1 -1
- package/dist/vector/filter/index.cjs +189 -7
- package/dist/vector/filter/index.js +190 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.d.cts +28 -20
- package/dist/vector/index.d.ts +28 -20
- package/dist/vector/index.js +1 -1
- package/dist/voice/index.cjs +4 -4
- package/dist/voice/index.d.cts +12 -13
- package/dist/voice/index.d.ts +12 -13
- package/dist/voice/index.js +1 -1
- package/dist/workflows/index.cjs +17 -69
- package/dist/workflows/index.d.cts +197 -77
- package/dist/workflows/index.d.ts +197 -77
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +90 -0
- package/dist/workflows/legacy/index.d.cts +87 -0
- package/dist/workflows/legacy/index.d.ts +87 -0
- package/dist/workflows/legacy/index.js +1 -0
- package/package.json +19 -40
- package/workflows/legacy.d.ts +1 -0
- package/dist/chunk-4WABQORE.js +0 -781
- package/dist/chunk-CIEPFV6B.js +0 -658
- package/dist/chunk-CMPPXW4U.js +0 -154
- package/dist/chunk-CTKNWYK2.js +0 -131
- package/dist/chunk-LGERQTJM.js +0 -190
- package/dist/chunk-O44MSFMZ.cjs +0 -168
- package/dist/chunk-QDAMIZY3.cjs +0 -783
- package/dist/chunk-QHDPLMHB.cjs +0 -667
- package/dist/chunk-RAQBTCIR.cjs +0 -134
- package/dist/chunk-YK3XJ52U.cjs +0 -192
- package/dist/storage/libsql/index.cjs +0 -581
- package/dist/storage/libsql/index.d.cts +0 -104
- package/dist/storage/libsql/index.d.ts +0 -104
- package/dist/storage/libsql/index.js +0 -578
- package/dist/vector/libsql/index.cjs +0 -14
- package/dist/vector/libsql/index.d.cts +0 -82
- package/dist/vector/libsql/index.d.ts +0 -82
- package/dist/vector/libsql/index.js +0 -1
- package/dist/workflows/vNext/index.d.cts +0 -209
- package/dist/workflows/vNext/index.d.ts +0 -209
- package/storage/libsql.d.ts +0 -1
- package/vector/libsql.d.ts +0 -1
- package/workflows/vNext.d.ts +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DefaultVoice } from './chunk-
|
|
2
|
-
import {
|
|
1
|
+
import { DefaultVoice } from './chunk-KJQFFEEQ.js';
|
|
2
|
+
import { executeHook } from './chunk-BB4KXGBU.js';
|
|
3
|
+
import { MastraLLM } from './chunk-BPTSLJHA.js';
|
|
3
4
|
import { InstrumentClass } from './chunk-BFNYQFG2.js';
|
|
4
|
-
import { ensureToolProperties, ensureAllMessagesAreCoreMessages, makeCoreTool, createMastraProxy } from './chunk-
|
|
5
|
+
import { ensureToolProperties, ensureAllMessagesAreCoreMessages, makeCoreTool, createMastraProxy } from './chunk-2PW6UJMW.js';
|
|
6
|
+
import { MastraBase } from './chunk-FI7R232B.js';
|
|
7
|
+
import { RegisteredLogger } from './chunk-VHLL4AZK.js';
|
|
5
8
|
import { RuntimeContext } from './chunk-SGGPJWRQ.js';
|
|
6
|
-
import { executeHook } from './chunk-BB4KXGBU.js';
|
|
7
|
-
import { MastraBase } from './chunk-235X76GC.js';
|
|
8
|
-
import { RegisteredLogger } from './chunk-CMPPXW4U.js';
|
|
9
9
|
import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
|
|
10
10
|
import { context, trace } from '@opentelemetry/api';
|
|
11
11
|
import { z } from 'zod';
|
|
@@ -15,8 +15,8 @@ import EventEmitter from 'node:events';
|
|
|
15
15
|
import sift from 'sift';
|
|
16
16
|
import { createActor, assign, fromPromise, setup } from 'xstate';
|
|
17
17
|
|
|
18
|
-
// src/workflows/step.ts
|
|
19
|
-
var
|
|
18
|
+
// src/workflows/legacy/step.ts
|
|
19
|
+
var LegacyStep = class {
|
|
20
20
|
id;
|
|
21
21
|
description;
|
|
22
22
|
inputSchema;
|
|
@@ -44,7 +44,7 @@ var Step = class {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
// src/workflows/types.ts
|
|
47
|
+
// src/workflows/legacy/types.ts
|
|
48
48
|
var WhenConditionReturnValue = /* @__PURE__ */(WhenConditionReturnValue2 => {
|
|
49
49
|
WhenConditionReturnValue2["CONTINUE"] = "continue";
|
|
50
50
|
WhenConditionReturnValue2["CONTINUE_FAILED"] = "continue_failed";
|
|
@@ -131,7 +131,14 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
131
131
|
return Boolean(this.#memory);
|
|
132
132
|
}
|
|
133
133
|
getMemory() {
|
|
134
|
-
|
|
134
|
+
const memory = this.#memory;
|
|
135
|
+
if (memory && !memory.hasOwnStorage && this.#mastra) {
|
|
136
|
+
const storage = this.#mastra.getStorage();
|
|
137
|
+
if (storage) {
|
|
138
|
+
memory.setStorage(storage);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return memory;
|
|
135
142
|
}
|
|
136
143
|
get voice() {
|
|
137
144
|
if (typeof this.#instructions === "function") {
|
|
@@ -1136,7 +1143,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1136
1143
|
messages: messageObjects,
|
|
1137
1144
|
tools: convertedTools,
|
|
1138
1145
|
onStepFinish: result3 => {
|
|
1139
|
-
|
|
1146
|
+
return onStepFinish?.(result3);
|
|
1140
1147
|
},
|
|
1141
1148
|
maxSteps,
|
|
1142
1149
|
runId: runIdToUse,
|
|
@@ -1168,7 +1175,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1168
1175
|
messages: messageObjects,
|
|
1169
1176
|
tools: convertedTools,
|
|
1170
1177
|
onStepFinish: result3 => {
|
|
1171
|
-
|
|
1178
|
+
return onStepFinish?.(result3);
|
|
1172
1179
|
},
|
|
1173
1180
|
maxSteps,
|
|
1174
1181
|
runId: runIdToUse,
|
|
@@ -1198,7 +1205,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1198
1205
|
tools: convertedTools,
|
|
1199
1206
|
structuredOutput: output,
|
|
1200
1207
|
onStepFinish: result2 => {
|
|
1201
|
-
|
|
1208
|
+
return onStepFinish?.(result2);
|
|
1202
1209
|
},
|
|
1203
1210
|
maxSteps,
|
|
1204
1211
|
runId: runIdToUse,
|
|
@@ -1296,7 +1303,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1296
1303
|
temperature,
|
|
1297
1304
|
tools: convertedTools,
|
|
1298
1305
|
onStepFinish: result => {
|
|
1299
|
-
|
|
1306
|
+
return onStepFinish?.(result);
|
|
1300
1307
|
},
|
|
1301
1308
|
onFinish: async result => {
|
|
1302
1309
|
try {
|
|
@@ -1316,7 +1323,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1316
1323
|
runId
|
|
1317
1324
|
});
|
|
1318
1325
|
}
|
|
1319
|
-
|
|
1326
|
+
await onFinish?.(result);
|
|
1320
1327
|
},
|
|
1321
1328
|
maxSteps,
|
|
1322
1329
|
runId: runIdToUse,
|
|
@@ -1338,7 +1345,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1338
1345
|
temperature,
|
|
1339
1346
|
tools: convertedTools,
|
|
1340
1347
|
onStepFinish: result => {
|
|
1341
|
-
|
|
1348
|
+
return onStepFinish?.(result);
|
|
1342
1349
|
},
|
|
1343
1350
|
onFinish: async result => {
|
|
1344
1351
|
try {
|
|
@@ -1358,7 +1365,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1358
1365
|
runId
|
|
1359
1366
|
});
|
|
1360
1367
|
}
|
|
1361
|
-
|
|
1368
|
+
await onFinish?.(result);
|
|
1362
1369
|
},
|
|
1363
1370
|
maxSteps,
|
|
1364
1371
|
runId: runIdToUse,
|
|
@@ -1378,7 +1385,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1378
1385
|
temperature,
|
|
1379
1386
|
structuredOutput: output,
|
|
1380
1387
|
onStepFinish: result => {
|
|
1381
|
-
|
|
1388
|
+
return onStepFinish?.(result);
|
|
1382
1389
|
},
|
|
1383
1390
|
onFinish: async result => {
|
|
1384
1391
|
try {
|
|
@@ -1398,7 +1405,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1398
1405
|
runId
|
|
1399
1406
|
});
|
|
1400
1407
|
}
|
|
1401
|
-
|
|
1408
|
+
await onFinish?.(result);
|
|
1402
1409
|
},
|
|
1403
1410
|
runId: runIdToUse,
|
|
1404
1411
|
toolChoice,
|
|
@@ -1472,7 +1479,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1472
1479
|
}
|
|
1473
1480
|
toStep() {
|
|
1474
1481
|
const x = agentToStep(this);
|
|
1475
|
-
return new
|
|
1482
|
+
return new LegacyStep(x);
|
|
1476
1483
|
}
|
|
1477
1484
|
};
|
|
1478
1485
|
Agent = /*@__PURE__*/(_ => {
|
|
@@ -1480,10 +1487,10 @@ Agent = /*@__PURE__*/(_ => {
|
|
|
1480
1487
|
Agent = __decorateElement(_init, 0, "Agent", _Agent_decorators, Agent);
|
|
1481
1488
|
__runInitializers(_init, 1, Agent);
|
|
1482
1489
|
|
|
1483
|
-
// src/workflows/utils.ts
|
|
1490
|
+
// src/workflows/legacy/utils.ts
|
|
1484
1491
|
return Agent;
|
|
1485
1492
|
})();
|
|
1486
|
-
// src/workflows/utils.ts
|
|
1493
|
+
// src/workflows/legacy/utils.ts
|
|
1487
1494
|
function isErrorEvent(stateEvent) {
|
|
1488
1495
|
return stateEvent.type.startsWith("xstate.error.actor.");
|
|
1489
1496
|
}
|
|
@@ -1602,7 +1609,7 @@ function getResultActivePaths(state) {
|
|
|
1602
1609
|
return activePathsAndStatus;
|
|
1603
1610
|
}
|
|
1604
1611
|
function isWorkflow(step) {
|
|
1605
|
-
return step instanceof
|
|
1612
|
+
return step instanceof LegacyWorkflow;
|
|
1606
1613
|
}
|
|
1607
1614
|
function isAgent(step) {
|
|
1608
1615
|
return step instanceof Agent;
|
|
@@ -1716,7 +1723,7 @@ function workflowToStep(workflow, {
|
|
|
1716
1723
|
});
|
|
1717
1724
|
unwatch();
|
|
1718
1725
|
if (!awaitedResult) {
|
|
1719
|
-
throw new Error("
|
|
1726
|
+
throw new Error("LegacyWorkflow run failed");
|
|
1720
1727
|
}
|
|
1721
1728
|
if (awaitedResult.activePaths?.size > 0) {
|
|
1722
1729
|
const suspendedStep = [...awaitedResult.activePaths.entries()].find(([, {
|
|
@@ -2868,7 +2875,7 @@ var Machine = class extends EventEmitter {
|
|
|
2868
2875
|
}
|
|
2869
2876
|
};
|
|
2870
2877
|
|
|
2871
|
-
// src/workflows/workflow-instance.ts
|
|
2878
|
+
// src/workflows/legacy/workflow-instance.ts
|
|
2872
2879
|
var WorkflowInstance = class {
|
|
2873
2880
|
name;
|
|
2874
2881
|
#mastra;
|
|
@@ -3452,8 +3459,8 @@ var WorkflowInstance = class {
|
|
|
3452
3459
|
}
|
|
3453
3460
|
};
|
|
3454
3461
|
|
|
3455
|
-
// src/workflows/workflow.ts
|
|
3456
|
-
var
|
|
3462
|
+
// src/workflows/legacy/workflow.ts
|
|
3463
|
+
var LegacyWorkflow = class extends MastraBase {
|
|
3457
3464
|
name;
|
|
3458
3465
|
triggerSchema;
|
|
3459
3466
|
resultSchema;
|
|
@@ -3480,7 +3487,7 @@ var Workflow = class extends MastraBase {
|
|
|
3480
3487
|
#steps = {};
|
|
3481
3488
|
#ifCount = 0;
|
|
3482
3489
|
/**
|
|
3483
|
-
* Creates a new
|
|
3490
|
+
* Creates a new LegacyWorkflow instance
|
|
3484
3491
|
* @param name - Identifier for the workflow (not necessarily unique)
|
|
3485
3492
|
* @param logger - Optional logger instance
|
|
3486
3493
|
*/
|
|
@@ -3525,7 +3532,7 @@ var Workflow = class extends MastraBase {
|
|
|
3525
3532
|
});
|
|
3526
3533
|
nextSteps.forEach(step2 => this.step(step2, config));
|
|
3527
3534
|
this.after(nextSteps);
|
|
3528
|
-
this.step(new
|
|
3535
|
+
this.step(new LegacyStep({
|
|
3529
3536
|
id: `__after_${next.map(step2 => config?.id ?? step2?.id ?? step2?.name).join("_")}`,
|
|
3530
3537
|
execute: async () => {
|
|
3531
3538
|
return {
|
|
@@ -3604,7 +3611,7 @@ var Workflow = class extends MastraBase {
|
|
|
3604
3611
|
});
|
|
3605
3612
|
nextSteps.forEach(step2 => this.#__internalStep(step2, config, internalUse));
|
|
3606
3613
|
this.after(nextSteps);
|
|
3607
|
-
this.#__internalStep(new
|
|
3614
|
+
this.#__internalStep(new LegacyStep({
|
|
3608
3615
|
id: `__after_${next.map(step2 => step2?.id ?? step2?.name).join("_")}`,
|
|
3609
3616
|
execute: async () => {
|
|
3610
3617
|
return {
|
|
@@ -3688,7 +3695,7 @@ var Workflow = class extends MastraBase {
|
|
|
3688
3695
|
return step2;
|
|
3689
3696
|
});
|
|
3690
3697
|
nextSteps.forEach(step2 => this.step(step2, config));
|
|
3691
|
-
this.step(new
|
|
3698
|
+
this.step(new LegacyStep({
|
|
3692
3699
|
// @ts-ignore
|
|
3693
3700
|
id: `__after_${next.map(step2 => step2?.id ?? step2?.name).join("_")}`,
|
|
3694
3701
|
execute: async () => {
|
|
@@ -4002,7 +4009,7 @@ var Workflow = class extends MastraBase {
|
|
|
4002
4009
|
} else {
|
|
4003
4010
|
this.after(_ifStep);
|
|
4004
4011
|
}
|
|
4005
|
-
this.step(new
|
|
4012
|
+
this.step(new LegacyStep({
|
|
4006
4013
|
id: `${lastStep.id}_if_else`,
|
|
4007
4014
|
execute: async () => {
|
|
4008
4015
|
return {
|
|
@@ -4083,7 +4090,7 @@ var Workflow = class extends MastraBase {
|
|
|
4083
4090
|
throw new Error("Condition requires a step to be executed after");
|
|
4084
4091
|
}
|
|
4085
4092
|
const eventStepKey = `__${eventName}_event`;
|
|
4086
|
-
const eventStep = new
|
|
4093
|
+
const eventStep = new LegacyStep({
|
|
4087
4094
|
id: eventStepKey,
|
|
4088
4095
|
execute: async ({
|
|
4089
4096
|
context,
|
|
@@ -4429,8 +4436,8 @@ var Workflow = class extends MastraBase {
|
|
|
4429
4436
|
const x = workflowToStep(this, {
|
|
4430
4437
|
mastra: this.#mastra
|
|
4431
4438
|
});
|
|
4432
|
-
return new
|
|
4439
|
+
return new LegacyStep(x);
|
|
4433
4440
|
}
|
|
4434
4441
|
};
|
|
4435
4442
|
|
|
4436
|
-
export { Agent,
|
|
4443
|
+
export { Agent, LegacyStep, LegacyWorkflow, WhenConditionReturnValue, agentToStep, getActivePathsAndStatus, getResultActivePaths, getStepResult, getSuspendedPaths, isAgent, isConditionalKey, isErrorEvent, isFinalState, isLimboState, isTransitionEvent, isVariableReference, isWorkflow, mergeChildValue, recursivelyCheckForFinalState, resolveVariables, updateStepInHierarchy, workflowToStep };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RegisteredLogger,
|
|
1
|
+
import { RegisteredLogger, ConsoleLogger } from './chunk-VHLL4AZK.js';
|
|
2
2
|
|
|
3
3
|
// src/base.ts
|
|
4
4
|
var MastraBase = class {
|
|
@@ -9,7 +9,7 @@ var MastraBase = class {
|
|
|
9
9
|
constructor({ component, name }) {
|
|
10
10
|
this.component = component || RegisteredLogger.LLM;
|
|
11
11
|
this.name = name;
|
|
12
|
-
this.logger =
|
|
12
|
+
this.logger = new ConsoleLogger({ name: `${this.component} - ${this.name}` });
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Set the logger for the agent
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { augmentWithInit } from './chunk-75Z4BZEE.js';
|
|
2
|
+
import { deepMerge } from './chunk-2PW6UJMW.js';
|
|
3
|
+
import { MastraBase } from './chunk-FI7R232B.js';
|
|
4
|
+
|
|
5
|
+
// src/memory/memory.ts
|
|
6
|
+
var MemoryProcessor = class extends MastraBase {
|
|
7
|
+
/**
|
|
8
|
+
* Process a list of messages and return a filtered or transformed list.
|
|
9
|
+
* @param messages The messages to process
|
|
10
|
+
* @returns The processed messages
|
|
11
|
+
*/
|
|
12
|
+
process(messages, _opts) {
|
|
13
|
+
return messages;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var memoryDefaultOptions = {
|
|
17
|
+
lastMessages: 10,
|
|
18
|
+
semanticRecall: false,
|
|
19
|
+
threads: {
|
|
20
|
+
generateTitle: false
|
|
21
|
+
},
|
|
22
|
+
workingMemory: {
|
|
23
|
+
enabled: false,
|
|
24
|
+
template: `
|
|
25
|
+
# User Information
|
|
26
|
+
- **First Name**:
|
|
27
|
+
- **Last Name**:
|
|
28
|
+
- **Location**:
|
|
29
|
+
- **Occupation**:
|
|
30
|
+
- **Interests**:
|
|
31
|
+
- **Goals**:
|
|
32
|
+
- **Events**:
|
|
33
|
+
- **Facts**:
|
|
34
|
+
- **Projects**:
|
|
35
|
+
`
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var MastraMemory = class extends MastraBase {
|
|
39
|
+
MAX_CONTEXT_TOKENS;
|
|
40
|
+
_storage;
|
|
41
|
+
vector;
|
|
42
|
+
embedder;
|
|
43
|
+
processors = [];
|
|
44
|
+
threadConfig = { ...memoryDefaultOptions };
|
|
45
|
+
constructor(config) {
|
|
46
|
+
super({ component: "MEMORY", name: config.name });
|
|
47
|
+
if (config.options) this.threadConfig = this.getMergedThreadConfig(config.options);
|
|
48
|
+
if (config.processors) this.processors = config.processors;
|
|
49
|
+
if (config.storage) {
|
|
50
|
+
this._storage = augmentWithInit(config.storage);
|
|
51
|
+
this._hasOwnStorage = true;
|
|
52
|
+
}
|
|
53
|
+
if (this.threadConfig.semanticRecall) {
|
|
54
|
+
if (!config.vector) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Semantic recall requires a vector store to be configured.
|
|
57
|
+
|
|
58
|
+
https://mastra.ai/en/docs/memory/semantic-recall`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
this.vector = config.vector;
|
|
62
|
+
if (!config.embedder) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`Semantic recall requires an embedder to be configured.
|
|
65
|
+
|
|
66
|
+
https://mastra.ai/en/docs/memory/semantic-recall`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
this.embedder = config.embedder;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
_hasOwnStorage = false;
|
|
73
|
+
get hasOwnStorage() {
|
|
74
|
+
return this._hasOwnStorage;
|
|
75
|
+
}
|
|
76
|
+
get storage() {
|
|
77
|
+
if (!this._storage) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`Memory requires a storage provider to function. Add a storage configuration to Memory or to your Mastra instance.
|
|
80
|
+
|
|
81
|
+
https://mastra.ai/en/docs/memory/overview`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return this._storage;
|
|
85
|
+
}
|
|
86
|
+
setStorage(storage) {
|
|
87
|
+
this._storage = storage;
|
|
88
|
+
}
|
|
89
|
+
setVector(vector) {
|
|
90
|
+
this.vector = vector;
|
|
91
|
+
}
|
|
92
|
+
setEmbedder(embedder) {
|
|
93
|
+
this.embedder = embedder;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get a system message to inject into the conversation.
|
|
97
|
+
* This will be called before each conversation turn.
|
|
98
|
+
* Implementations can override this to inject custom system messages.
|
|
99
|
+
*/
|
|
100
|
+
async getSystemMessage(_input) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get tools that should be available to the agent.
|
|
105
|
+
* This will be called when converting tools for the agent.
|
|
106
|
+
* Implementations can override this to provide additional tools.
|
|
107
|
+
*/
|
|
108
|
+
getTools(_config) {
|
|
109
|
+
return {};
|
|
110
|
+
}
|
|
111
|
+
async createEmbeddingIndex(dimensions) {
|
|
112
|
+
const defaultDimensions = 1536;
|
|
113
|
+
const isDefault = dimensions === defaultDimensions;
|
|
114
|
+
const usedDimensions = dimensions ?? defaultDimensions;
|
|
115
|
+
const separator = this.vector?.indexSeparator ?? "_";
|
|
116
|
+
const indexName = isDefault ? `memory${separator}messages` : `memory${separator}messages${separator}${usedDimensions}`;
|
|
117
|
+
if (typeof this.vector === `undefined`) {
|
|
118
|
+
throw new Error(`Tried to create embedding index but no vector db is attached to this Memory instance.`);
|
|
119
|
+
}
|
|
120
|
+
await this.vector.createIndex({
|
|
121
|
+
indexName,
|
|
122
|
+
dimension: usedDimensions
|
|
123
|
+
});
|
|
124
|
+
return { indexName };
|
|
125
|
+
}
|
|
126
|
+
getMergedThreadConfig(config) {
|
|
127
|
+
if (config?.workingMemory && "use" in config.workingMemory) {
|
|
128
|
+
throw new Error("The workingMemory.use option has been removed. Working memory always uses tool-call mode.");
|
|
129
|
+
}
|
|
130
|
+
return deepMerge(this.threadConfig, config || {});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Apply all configured message processors to a list of messages.
|
|
134
|
+
* @param messages The messages to process
|
|
135
|
+
* @returns The processed messages
|
|
136
|
+
*/
|
|
137
|
+
applyProcessors(messages, opts) {
|
|
138
|
+
const processors = opts.processors || this.processors;
|
|
139
|
+
if (!processors || processors.length === 0) {
|
|
140
|
+
return messages;
|
|
141
|
+
}
|
|
142
|
+
let processedMessages = [...messages];
|
|
143
|
+
for (const processor of processors) {
|
|
144
|
+
processedMessages = processor.process(processedMessages, {
|
|
145
|
+
systemMessage: opts.systemMessage,
|
|
146
|
+
newMessages: opts.newMessages,
|
|
147
|
+
memorySystemMessage: opts.memorySystemMessage
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return processedMessages;
|
|
151
|
+
}
|
|
152
|
+
processMessages({
|
|
153
|
+
messages,
|
|
154
|
+
processors,
|
|
155
|
+
...opts
|
|
156
|
+
}) {
|
|
157
|
+
return this.applyProcessors(messages, { processors: processors || this.processors, ...opts });
|
|
158
|
+
}
|
|
159
|
+
estimateTokens(text) {
|
|
160
|
+
return Math.ceil(text.split(" ").length * 1.3);
|
|
161
|
+
}
|
|
162
|
+
parseMessages(messages) {
|
|
163
|
+
return messages.map((msg) => {
|
|
164
|
+
let content = msg.content;
|
|
165
|
+
if (typeof content === "string" && (content.startsWith("[") || content.startsWith("{"))) {
|
|
166
|
+
try {
|
|
167
|
+
content = JSON.parse(content);
|
|
168
|
+
} catch {
|
|
169
|
+
}
|
|
170
|
+
} else if (typeof content === "number") {
|
|
171
|
+
content = String(content);
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
...msg,
|
|
175
|
+
content
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
convertToUIMessages(messages) {
|
|
180
|
+
function addToolMessageToChat({
|
|
181
|
+
toolMessage,
|
|
182
|
+
messages: messages2,
|
|
183
|
+
toolResultContents
|
|
184
|
+
}) {
|
|
185
|
+
const chatMessages2 = messages2.map((message) => {
|
|
186
|
+
if (message.toolInvocations) {
|
|
187
|
+
return {
|
|
188
|
+
...message,
|
|
189
|
+
toolInvocations: message.toolInvocations.map((toolInvocation) => {
|
|
190
|
+
const toolResult = toolMessage.content.find((tool) => tool.toolCallId === toolInvocation.toolCallId);
|
|
191
|
+
if (toolResult) {
|
|
192
|
+
return {
|
|
193
|
+
...toolInvocation,
|
|
194
|
+
state: "result",
|
|
195
|
+
result: toolResult.result
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return toolInvocation;
|
|
199
|
+
})
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return message;
|
|
203
|
+
});
|
|
204
|
+
const resultContents = [...toolResultContents, ...toolMessage.content];
|
|
205
|
+
return { chatMessages: chatMessages2, toolResultContents: resultContents };
|
|
206
|
+
}
|
|
207
|
+
const { chatMessages } = messages.reduce(
|
|
208
|
+
(obj, message) => {
|
|
209
|
+
if (message.role === "tool") {
|
|
210
|
+
return addToolMessageToChat({
|
|
211
|
+
toolMessage: message,
|
|
212
|
+
messages: obj.chatMessages,
|
|
213
|
+
toolResultContents: obj.toolResultContents
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
let textContent = "";
|
|
217
|
+
let toolInvocations = [];
|
|
218
|
+
if (typeof message.content === "string") {
|
|
219
|
+
textContent = message.content;
|
|
220
|
+
} else if (typeof message.content === "number") {
|
|
221
|
+
textContent = String(message.content);
|
|
222
|
+
} else if (Array.isArray(message.content)) {
|
|
223
|
+
for (const content of message.content) {
|
|
224
|
+
if (content.type === "text") {
|
|
225
|
+
textContent += content.text;
|
|
226
|
+
} else if (content.type === "tool-call") {
|
|
227
|
+
const toolResult = obj.toolResultContents.find((tool) => tool.toolCallId === content.toolCallId);
|
|
228
|
+
toolInvocations.push({
|
|
229
|
+
state: toolResult ? "result" : "call",
|
|
230
|
+
toolCallId: content.toolCallId,
|
|
231
|
+
toolName: content.toolName,
|
|
232
|
+
args: content.args,
|
|
233
|
+
result: toolResult?.result
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
obj.chatMessages.push({
|
|
239
|
+
id: message.id,
|
|
240
|
+
role: message.role,
|
|
241
|
+
content: textContent,
|
|
242
|
+
toolInvocations,
|
|
243
|
+
createdAt: message.createdAt
|
|
244
|
+
});
|
|
245
|
+
return obj;
|
|
246
|
+
},
|
|
247
|
+
{ chatMessages: [], toolResultContents: [] }
|
|
248
|
+
);
|
|
249
|
+
return chatMessages;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Helper method to create a new thread
|
|
253
|
+
* @param title - Optional title for the thread
|
|
254
|
+
* @param metadata - Optional metadata for the thread
|
|
255
|
+
* @returns Promise resolving to the created thread
|
|
256
|
+
*/
|
|
257
|
+
async createThread({
|
|
258
|
+
threadId,
|
|
259
|
+
resourceId,
|
|
260
|
+
title,
|
|
261
|
+
metadata,
|
|
262
|
+
memoryConfig
|
|
263
|
+
}) {
|
|
264
|
+
await this.storage.init();
|
|
265
|
+
const thread = {
|
|
266
|
+
id: threadId || this.generateId(),
|
|
267
|
+
title: title || `New Thread ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
268
|
+
resourceId,
|
|
269
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
270
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
271
|
+
metadata
|
|
272
|
+
};
|
|
273
|
+
return this.saveThread({ thread, memoryConfig });
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Helper method to add a single message to a thread
|
|
277
|
+
* @param threadId - The thread to add the message to
|
|
278
|
+
* @param content - The message content
|
|
279
|
+
* @param role - The role of the message sender
|
|
280
|
+
* @param type - The type of the message
|
|
281
|
+
* @param toolNames - Optional array of tool names that were called
|
|
282
|
+
* @param toolCallArgs - Optional array of tool call arguments
|
|
283
|
+
* @param toolCallIds - Optional array of tool call ids
|
|
284
|
+
* @returns Promise resolving to the saved message
|
|
285
|
+
*/
|
|
286
|
+
async addMessage({
|
|
287
|
+
threadId,
|
|
288
|
+
resourceId,
|
|
289
|
+
config,
|
|
290
|
+
content,
|
|
291
|
+
role,
|
|
292
|
+
type,
|
|
293
|
+
toolNames,
|
|
294
|
+
toolCallArgs,
|
|
295
|
+
toolCallIds
|
|
296
|
+
}) {
|
|
297
|
+
const message = {
|
|
298
|
+
id: this.generateId(),
|
|
299
|
+
content,
|
|
300
|
+
role,
|
|
301
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
302
|
+
threadId,
|
|
303
|
+
resourceId,
|
|
304
|
+
type,
|
|
305
|
+
toolNames,
|
|
306
|
+
toolCallArgs,
|
|
307
|
+
toolCallIds
|
|
308
|
+
};
|
|
309
|
+
const savedMessages = await this.saveMessages({ messages: [message], memoryConfig: config });
|
|
310
|
+
return savedMessages[0];
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Generates a unique identifier
|
|
314
|
+
* @returns A unique string ID
|
|
315
|
+
*/
|
|
316
|
+
generateId() {
|
|
317
|
+
return crypto.randomUUID();
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
export { MastraMemory, MemoryProcessor, memoryDefaultOptions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InstrumentClass } from './chunk-BFNYQFG2.js';
|
|
2
|
-
import { MastraBase } from './chunk-
|
|
2
|
+
import { MastraBase } from './chunk-FI7R232B.js';
|
|
3
3
|
import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
|
|
4
4
|
|
|
5
5
|
// src/voice/voice.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkUVRGQEMD_cjs = require('./chunk-UVRGQEMD.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkYEULQPUY_cjs = require('./chunk-YEULQPUY.cjs');
|
|
5
5
|
var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
|
|
6
6
|
|
|
7
7
|
// src/tts/index.ts
|
|
@@ -10,7 +10,7 @@ _MastraTTS_decorators = [chunkUVRGQEMD_cjs.InstrumentClass({
|
|
|
10
10
|
prefix: "tts",
|
|
11
11
|
excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
|
|
12
12
|
})];
|
|
13
|
-
exports.MastraTTS = class MastraTTS extends (_a =
|
|
13
|
+
exports.MastraTTS = class MastraTTS extends (_a = chunkYEULQPUY_cjs.MastraBase) {
|
|
14
14
|
model;
|
|
15
15
|
constructor({
|
|
16
16
|
model
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MastraBase } from './chunk-
|
|
1
|
+
import { MastraBase } from './chunk-FI7R232B.js';
|
|
2
2
|
|
|
3
3
|
// src/vector/vector.ts
|
|
4
4
|
var MastraVector = class extends MastraBase {
|
|
@@ -8,31 +8,10 @@ var MastraVector = class extends MastraBase {
|
|
|
8
8
|
get indexSeparator() {
|
|
9
9
|
return "_";
|
|
10
10
|
}
|
|
11
|
-
baseKeys = {
|
|
12
|
-
query: ["queryVector", "topK", "filter", "includeVector"],
|
|
13
|
-
upsert: ["vectors", "metadata", "ids"],
|
|
14
|
-
createIndex: ["dimension", "metric"]
|
|
15
|
-
};
|
|
16
|
-
normalizeArgs(method, [first, ...rest], extendedKeys = []) {
|
|
17
|
-
if (typeof first === "object") {
|
|
18
|
-
return first;
|
|
19
|
-
}
|
|
20
|
-
this.logger.warn(
|
|
21
|
-
`Deprecation Warning: Passing individual arguments to ${method}() is deprecated.
|
|
22
|
-
Please use an object parameter instead.
|
|
23
|
-
Individual arguments will be removed on May 20th, 2025.`
|
|
24
|
-
);
|
|
25
|
-
const baseKeys = this.baseKeys[method] || [];
|
|
26
|
-
const paramKeys = [...baseKeys, ...extendedKeys].slice(0, rest.length);
|
|
27
|
-
return {
|
|
28
|
-
indexName: first,
|
|
29
|
-
...Object.fromEntries(paramKeys.map((key, i) => [key, rest[i]]))
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
11
|
async validateExistingIndex(indexName, dimension, metric) {
|
|
33
12
|
let info;
|
|
34
13
|
try {
|
|
35
|
-
info = await this.describeIndex(indexName);
|
|
14
|
+
info = await this.describeIndex({ indexName });
|
|
36
15
|
} catch (infoError) {
|
|
37
16
|
const message = `Index "${indexName}" already exists, but failed to fetch index info for dimension check: ${infoError}`;
|
|
38
17
|
this.logger?.error(message);
|