@mastra/core 0.2.0-alpha.83 → 0.2.0-alpha.86
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 +1 -1
- package/dist/action/index.d.ts +3 -3
- package/dist/agent/index.d.ts +6 -6
- package/dist/agent/index.js +6 -6
- package/dist/base.d.ts +3 -3
- package/dist/base.js +2 -2
- package/dist/bundler/index.d.ts +21 -0
- package/dist/bundler/index.js +4 -0
- package/dist/chunk-2ISN3AA7.js +392 -0
- package/dist/chunk-2J5OHBUG.js +24 -0
- package/dist/{chunk-Y7TKCKRI.js → chunk-5NQ3MEZM.js} +8 -8
- package/dist/{chunk-K7KUCZT2.js → chunk-6WJREZ5F.js} +2 -2
- package/dist/{chunk-RPBNMIV7.js → chunk-73XDWPXJ.js} +84 -52
- package/dist/chunk-CQYUMNLZ.js +28 -0
- package/dist/{chunk-AO76Z4K3.js → chunk-D66E7L7R.js} +1 -1
- package/dist/{chunk-FCRDS4YS.js → chunk-EH2PG7Q6.js} +10 -4
- package/dist/{chunk-BWEOV64I.js → chunk-EVYBUFXB.js} +13 -9
- package/dist/{chunk-OJJ6QGX4.js → chunk-I3MJB67Z.js} +12 -12
- package/dist/{chunk-27EL4TRB.js → chunk-JCRGAEY6.js} +1 -1
- package/dist/{chunk-BQMCLBCR.js → chunk-OOZGW5CY.js} +1 -1
- package/dist/{chunk-LYNJHHQX.js → chunk-RCS7AVH6.js} +2 -2
- package/dist/chunk-RLPH6TDJ.js +30 -0
- package/dist/{chunk-FROFMREE.js → chunk-RZYBOMIG.js} +7 -0
- package/dist/{chunk-Q5JF3TKZ.js → chunk-SLWM3SEH.js} +1 -1
- package/dist/{chunk-NLQVQJOD.js → chunk-TJK6TGSR.js} +1 -0
- package/dist/{chunk-S45F6AHA.js → chunk-U25DBVJZ.js} +1 -1
- package/dist/chunk-XD5IQZRB.js +16 -0
- package/dist/deployer/index.d.ts +8 -25
- package/dist/deployer/index.js +4 -3
- package/dist/embeddings/index.d.ts +2 -2
- package/dist/embeddings/index.js +1 -1
- package/dist/engine/index.d.ts +2 -2
- package/dist/engine/index.js +3 -3
- package/dist/eval/index.d.ts +3 -3
- package/dist/filter/index.d.ts +7 -6
- package/dist/filter/index.js +1 -1
- package/dist/{index-B9i6dmc0.d.ts → index-B0-NXUYv.d.ts} +1 -0
- package/dist/{index-CA9EWqaj.d.ts → index-Duqv1Yom.d.ts} +50 -27
- package/dist/index.d.ts +15 -13
- package/dist/index.js +26 -25
- package/dist/integration/index.d.ts +4 -4
- package/dist/llm/index.d.ts +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/providers/anthropic-vertex.d.ts +31 -0
- package/dist/llm/model/providers/anthropic-vertex.js +23 -0
- package/dist/llm/model/providers/anthropic.d.ts +29 -0
- package/dist/llm/model/providers/anthropic.js +21 -0
- package/dist/llm/model/providers/azure.d.ts +48 -0
- package/dist/llm/model/providers/azure.js +50 -0
- package/dist/llm/model/providers/baseten.d.ts +33 -0
- package/dist/llm/model/providers/baseten.js +29 -0
- package/dist/llm/model/providers/bedrock.d.ts +32 -0
- package/dist/llm/model/providers/bedrock.js +24 -0
- package/dist/llm/model/providers/cerebras.d.ts +30 -0
- package/dist/llm/model/providers/cerebras.js +22 -0
- package/dist/llm/model/providers/cohere.d.ts +30 -0
- package/dist/llm/model/providers/cohere.js +22 -0
- package/dist/llm/model/providers/deepinfra.d.ts +30 -0
- package/dist/llm/model/providers/deepinfra.js +22 -0
- package/dist/llm/model/providers/deepseek.d.ts +30 -0
- package/dist/llm/model/providers/deepseek.js +22 -0
- package/dist/llm/model/providers/fireworks.d.ts +35 -0
- package/dist/llm/model/providers/fireworks.js +40 -0
- package/dist/llm/model/providers/google-vertex.d.ts +48 -0
- package/dist/llm/model/providers/google-vertex.js +22 -0
- package/dist/llm/model/providers/google.d.ts +54 -0
- package/dist/llm/model/providers/google.js +23 -0
- package/dist/llm/model/providers/grok.d.ts +32 -0
- package/dist/llm/model/providers/grok.js +22 -0
- package/dist/llm/model/providers/groq.d.ts +37 -0
- package/dist/llm/model/providers/groq.js +42 -0
- package/dist/llm/model/providers/lmstudio.d.ts +29 -0
- package/dist/llm/model/providers/lmstudio.js +22 -0
- package/dist/llm/model/providers/mistral.d.ts +30 -0
- package/dist/llm/model/providers/mistral.js +22 -0
- package/dist/llm/model/providers/mock.d.ts +30 -0
- package/dist/llm/model/providers/mock.js +83 -0
- package/dist/llm/model/providers/ollama.d.ts +31 -0
- package/dist/llm/model/providers/ollama.js +23 -0
- package/dist/llm/model/providers/openai-compat.d.ts +39 -0
- package/dist/llm/model/providers/openai-compat.js +6 -0
- package/dist/llm/model/providers/openai.d.ts +34 -0
- package/dist/llm/model/providers/openai.js +6 -0
- package/dist/llm/model/providers/openai.test.d.ts +2 -0
- package/dist/llm/model/providers/openai.test.js +220 -0
- package/dist/llm/model/providers/perplexity.d.ts +30 -0
- package/dist/llm/model/providers/perplexity.js +22 -0
- package/dist/llm/model/providers/portkey.d.ts +34 -0
- package/dist/llm/model/providers/portkey.js +22 -0
- package/dist/llm/model/providers/togetherai.d.ts +30 -0
- package/dist/llm/model/providers/togetherai.js +22 -0
- package/dist/logger/index.d.ts +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/mastra/index.d.ts +5 -4
- package/dist/mastra/index.js +5 -5
- package/dist/memory/index.d.ts +3 -3
- package/dist/memory/index.js +3 -3
- package/dist/model-QGWIMOSx.d.ts +31 -0
- package/dist/relevance/index.d.ts +3 -3
- package/dist/relevance/index.js +7 -7
- package/dist/storage/index.d.ts +4 -4
- package/dist/storage/index.js +3 -3
- package/dist/telemetry/index.d.ts +5 -103
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry-oCUM52DG.d.ts +104 -0
- package/dist/tools/index.d.ts +4 -4
- package/dist/tts/index.d.ts +2 -2
- package/dist/tts/index.js +4 -4
- package/dist/vector/index.d.ts +2 -2
- package/dist/vector/index.js +4 -4
- package/dist/{workflow-Dam5GtdA.d.ts → workflow-DQ8CtzzU.d.ts} +1 -1
- package/dist/workflows/index.d.ts +5 -5
- package/dist/workflows/index.js +3 -3
- package/package.json +30 -15
- package/dist/chunk-5R6DBXQM.js +0 -57
- /package/dist/{chunk-OZZS5Y3C.js → chunk-SDKEPBBH.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LLM } from './chunk-K7KUCZT2.js';
|
|
2
|
-
import { InstrumentClass } from './chunk-6ZVFVYLE.js';
|
|
3
|
-
import { MastraBase } from './chunk-27EL4TRB.js';
|
|
4
|
-
import { RegisteredLogger, LogLevel } from './chunk-NLQVQJOD.js';
|
|
5
1
|
import { executeHook, AvailableHooks } from './chunk-HBTQNIAX.js';
|
|
2
|
+
import { LLM } from './chunk-6WJREZ5F.js';
|
|
3
|
+
import { InstrumentClass } from './chunk-6ZVFVYLE.js';
|
|
4
|
+
import { MastraBase } from './chunk-JCRGAEY6.js';
|
|
5
|
+
import { RegisteredLogger, LogLevel } from './chunk-TJK6TGSR.js';
|
|
6
6
|
import { __name, __publicField, __privateAdd, __privateSet, __privateGet } from './chunk-AJJZUHB4.js';
|
|
7
7
|
import { randomUUID } from 'crypto';
|
|
8
8
|
import { z } from 'zod';
|
|
@@ -19,25 +19,34 @@ function _ts_metadata(k, v) {
|
|
|
19
19
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
20
20
|
}
|
|
21
21
|
__name(_ts_metadata, "_ts_metadata");
|
|
22
|
-
var _mastra;
|
|
22
|
+
var _mastra, _memory;
|
|
23
23
|
var _Agent = class _Agent extends MastraBase {
|
|
24
24
|
constructor(config) {
|
|
25
25
|
super({
|
|
26
26
|
component: RegisteredLogger.AGENT
|
|
27
27
|
});
|
|
28
28
|
__publicField(this, "name");
|
|
29
|
+
// @ts-ignore
|
|
29
30
|
__publicField(this, "llm");
|
|
30
31
|
__publicField(this, "instructions");
|
|
31
32
|
__publicField(this, "model");
|
|
32
33
|
__privateAdd(this, _mastra);
|
|
34
|
+
__privateAdd(this, _memory);
|
|
33
35
|
__publicField(this, "tools");
|
|
34
36
|
__publicField(this, "metrics");
|
|
35
37
|
this.name = config.name;
|
|
36
38
|
this.instructions = config.instructions;
|
|
37
|
-
|
|
38
|
-
model
|
|
39
|
-
}
|
|
40
|
-
|
|
39
|
+
if (!config.model && !config.llm) {
|
|
40
|
+
throw new Error("Either model or llm is required");
|
|
41
|
+
}
|
|
42
|
+
if (config.llm) {
|
|
43
|
+
this.llm = config.llm;
|
|
44
|
+
} else if (config.model) {
|
|
45
|
+
this.model = config.model;
|
|
46
|
+
this.llm = new LLM({
|
|
47
|
+
model: config.model
|
|
48
|
+
});
|
|
49
|
+
}
|
|
41
50
|
this.tools = {};
|
|
42
51
|
this.metrics = {};
|
|
43
52
|
if (config.tools) {
|
|
@@ -49,6 +58,15 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
49
58
|
if (config.metrics) {
|
|
50
59
|
this.metrics = config.metrics;
|
|
51
60
|
}
|
|
61
|
+
if (config.memory) {
|
|
62
|
+
__privateSet(this, _memory, config.memory);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
hasOwnMemory() {
|
|
66
|
+
return Boolean(__privateGet(this, _memory));
|
|
67
|
+
}
|
|
68
|
+
getMemory() {
|
|
69
|
+
return __privateGet(this, _memory) ?? __privateGet(this, _mastra)?.memory;
|
|
52
70
|
}
|
|
53
71
|
__registerPrimitives(p) {
|
|
54
72
|
if (p.telemetry) {
|
|
@@ -117,20 +135,21 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
117
135
|
}
|
|
118
136
|
async saveMemory({ threadId, memoryConfig, resourceId, userMessages, runId }) {
|
|
119
137
|
const userMessage = this.getMostRecentUserMessage(userMessages);
|
|
120
|
-
|
|
138
|
+
const memory = this.getMemory();
|
|
139
|
+
if (memory) {
|
|
121
140
|
let thread;
|
|
122
141
|
if (!threadId) {
|
|
123
142
|
this.logger.debug(`No threadId, creating new thread for agent ${this.name}`, {
|
|
124
143
|
runId: runId || this.name
|
|
125
144
|
});
|
|
126
145
|
const title = await this.genTitle(userMessage);
|
|
127
|
-
thread = await
|
|
146
|
+
thread = await memory.createThread({
|
|
128
147
|
threadId,
|
|
129
148
|
resourceId,
|
|
130
149
|
title
|
|
131
150
|
});
|
|
132
151
|
} else {
|
|
133
|
-
thread = await
|
|
152
|
+
thread = await memory.getThreadById({
|
|
134
153
|
threadId
|
|
135
154
|
});
|
|
136
155
|
if (!thread) {
|
|
@@ -138,7 +157,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
138
157
|
runId: runId || this.name
|
|
139
158
|
});
|
|
140
159
|
const title = await this.genTitle(userMessage);
|
|
141
|
-
thread = await
|
|
160
|
+
thread = await memory.createThread({
|
|
142
161
|
threadId,
|
|
143
162
|
resourceId,
|
|
144
163
|
title
|
|
@@ -151,7 +170,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
151
170
|
if (thread) {
|
|
152
171
|
const messages = newMessages.map((u) => {
|
|
153
172
|
return {
|
|
154
|
-
id:
|
|
173
|
+
id: this.getMemory()?.generateId(),
|
|
155
174
|
createdAt: /* @__PURE__ */ new Date(),
|
|
156
175
|
threadId: thread.id,
|
|
157
176
|
...u,
|
|
@@ -194,7 +213,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
194
213
|
this.log(LogLevel.DEBUG, `No context found: ${e.message}`);
|
|
195
214
|
}
|
|
196
215
|
}
|
|
197
|
-
const memoryMessages = threadId &&
|
|
216
|
+
const memoryMessages = threadId && memory ? (await memory.rememberMessages({
|
|
198
217
|
threadId,
|
|
199
218
|
config: memoryConfig,
|
|
200
219
|
vectorMessageSearch: messages.slice(-1).map((m) => {
|
|
@@ -205,10 +224,12 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
205
224
|
}).join(`
|
|
206
225
|
`)
|
|
207
226
|
})).messages : [];
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
227
|
+
if (memory) {
|
|
228
|
+
await memory.saveMessages({
|
|
229
|
+
messages,
|
|
230
|
+
memoryConfig
|
|
231
|
+
});
|
|
232
|
+
}
|
|
212
233
|
this.log(LogLevel.DEBUG, "Saved messages to memory", {
|
|
213
234
|
threadId: thread.id,
|
|
214
235
|
runId
|
|
@@ -231,7 +252,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
231
252
|
messages: userMessages
|
|
232
253
|
};
|
|
233
254
|
}
|
|
234
|
-
async saveResponse({ result, threadId, runId, memoryConfig }) {
|
|
255
|
+
async saveResponse({ result, threadId, resourceId, runId, memoryConfig }) {
|
|
235
256
|
const { response } = result;
|
|
236
257
|
try {
|
|
237
258
|
if (response.messages) {
|
|
@@ -239,12 +260,15 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
239
260
|
response.messages
|
|
240
261
|
];
|
|
241
262
|
const responseMessagesWithoutIncompleteToolCalls = this.sanitizeResponseMessages(ms);
|
|
242
|
-
|
|
243
|
-
|
|
263
|
+
const memory = this.getMemory();
|
|
264
|
+
if (memory) {
|
|
265
|
+
this.logger.debug(`[Agent:${this.name}] - Memory persistence: store=${__privateGet(this, _mastra)?.memory?.constructor.name} threadId=${threadId}`, {
|
|
266
|
+
runId,
|
|
267
|
+
resourceId,
|
|
244
268
|
threadId,
|
|
245
|
-
|
|
269
|
+
memoryStore: __privateGet(this, _mastra)?.memory?.constructor.name
|
|
246
270
|
});
|
|
247
|
-
await
|
|
271
|
+
await memory.saveMessages({
|
|
248
272
|
memoryConfig,
|
|
249
273
|
messages: responseMessagesWithoutIncompleteToolCalls.map((message) => {
|
|
250
274
|
const messageId = randomUUID();
|
|
@@ -400,7 +424,13 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
400
424
|
};
|
|
401
425
|
let coreMessages = messages;
|
|
402
426
|
let threadIdToUse = threadId;
|
|
403
|
-
if (
|
|
427
|
+
if (this.getMemory() && resourceId) {
|
|
428
|
+
this.logger.debug(`[Agent:${this.name}] - Memory persistence enabled: store=${__privateGet(this, _mastra)?.memory?.constructor.name}, resourceId=${resourceId}`, {
|
|
429
|
+
runId,
|
|
430
|
+
resourceId,
|
|
431
|
+
threadId: threadIdToUse,
|
|
432
|
+
memoryStore: __privateGet(this, _mastra)?.memory?.constructor.name
|
|
433
|
+
});
|
|
404
434
|
const preExecuteResult = await this.preExecute({
|
|
405
435
|
resourceId,
|
|
406
436
|
runId,
|
|
@@ -410,22 +440,31 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
410
440
|
});
|
|
411
441
|
coreMessages = preExecuteResult.coreMessages;
|
|
412
442
|
threadIdToUse = preExecuteResult.threadIdToUse;
|
|
413
|
-
} else {
|
|
414
|
-
this.logger.debug(`[Agents:${this.name}] - No memory store or resourceid identifier found. Skipping memory persistence.`, {
|
|
415
|
-
runId
|
|
416
|
-
});
|
|
417
443
|
}
|
|
418
444
|
let convertedTools;
|
|
419
|
-
if (toolsets && Object.keys(toolsets || {}).length > 0 ||
|
|
445
|
+
if (toolsets && Object.keys(toolsets || {}).length > 0 || this.getMemory() && resourceId || __privateGet(this, _mastra)?.engine) {
|
|
446
|
+
const reasons = [];
|
|
447
|
+
if (toolsets && Object.keys(toolsets || {}).length > 0) {
|
|
448
|
+
reasons.push(`toolsets present (${Object.keys(toolsets || {}).length} tools)`);
|
|
449
|
+
}
|
|
450
|
+
if (this.getMemory() && resourceId) {
|
|
451
|
+
reasons.push("memory and resourceId available");
|
|
452
|
+
}
|
|
453
|
+
if (__privateGet(this, _mastra)?.engine) {
|
|
454
|
+
reasons.push("mastra engine enabled");
|
|
455
|
+
}
|
|
456
|
+
this.logger.debug(`[Agent:${this.name}] - Enhancing tools: ${reasons.join(", ")}`, {
|
|
457
|
+
runId,
|
|
458
|
+
toolsets: toolsets ? Object.keys(toolsets) : undefined,
|
|
459
|
+
hasMemory: !!this.getMemory(),
|
|
460
|
+
hasResourceId: !!resourceId,
|
|
461
|
+
hasEngine: !!__privateGet(this, _mastra)?.engine
|
|
462
|
+
});
|
|
420
463
|
convertedTools = this.convertTools({
|
|
421
464
|
toolsets,
|
|
422
465
|
threadId: threadIdToUse,
|
|
423
466
|
runId
|
|
424
467
|
});
|
|
425
|
-
} else {
|
|
426
|
-
this.logger.debug(`Skipping tool conversion for agent ${this.name}`, {
|
|
427
|
-
runId
|
|
428
|
-
});
|
|
429
468
|
}
|
|
430
469
|
const messageObjects = [
|
|
431
470
|
systemMessage,
|
|
@@ -461,15 +500,12 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
461
500
|
result: resToLog,
|
|
462
501
|
threadId: threadId2
|
|
463
502
|
});
|
|
464
|
-
if (
|
|
503
|
+
if (this.getMemory() && resourceId) {
|
|
465
504
|
try {
|
|
466
|
-
this.logger.debug(`Saving assistant message in memory for agent ${this.name}`, {
|
|
467
|
-
runId: runId2,
|
|
468
|
-
threadId: threadId2
|
|
469
|
-
});
|
|
470
505
|
await this.saveResponse({
|
|
471
506
|
result,
|
|
472
507
|
threadId: threadId2,
|
|
508
|
+
resourceId,
|
|
473
509
|
memoryConfig: memoryConfig2,
|
|
474
510
|
runId: runId2
|
|
475
511
|
});
|
|
@@ -481,11 +517,6 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
481
517
|
threadId: threadId2
|
|
482
518
|
});
|
|
483
519
|
}
|
|
484
|
-
} else {
|
|
485
|
-
this.logger.debug(`[Agents:${this.name}] - No memory store or resourceid identifier found. Skipping memory persistence.`, {
|
|
486
|
-
runId: runId2,
|
|
487
|
-
threadId: threadId2
|
|
488
|
-
});
|
|
489
520
|
}
|
|
490
521
|
if (Object.keys(this.metrics || {}).length > 0) {
|
|
491
522
|
const input = messages.map((message) => message.content).join("\n");
|
|
@@ -503,7 +534,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
503
534
|
}, "after")
|
|
504
535
|
};
|
|
505
536
|
}
|
|
506
|
-
async generate(messages, { context, threadId: threadIdInFn,
|
|
537
|
+
async generate(messages, { context, threadId: threadIdInFn, memoryOptions, resourceId, maxSteps = 5, onStepFinish, runId, toolsets, output = "text", temperature } = {}) {
|
|
507
538
|
let messagesToUse = [];
|
|
508
539
|
if (typeof messages === `string`) {
|
|
509
540
|
messagesToUse = [
|
|
@@ -528,7 +559,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
528
559
|
messages: messagesToUse,
|
|
529
560
|
context,
|
|
530
561
|
threadId: threadIdInFn,
|
|
531
|
-
memoryConfig,
|
|
562
|
+
memoryConfig: memoryOptions,
|
|
532
563
|
resourceId,
|
|
533
564
|
runId: runIdToUse,
|
|
534
565
|
toolsets
|
|
@@ -548,7 +579,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
548
579
|
await after({
|
|
549
580
|
result: result2,
|
|
550
581
|
threadId,
|
|
551
|
-
memoryConfig,
|
|
582
|
+
memoryConfig: memoryOptions,
|
|
552
583
|
outputText: outputText2,
|
|
553
584
|
runId: runIdToUse
|
|
554
585
|
});
|
|
@@ -568,13 +599,13 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
568
599
|
await after({
|
|
569
600
|
result,
|
|
570
601
|
threadId,
|
|
571
|
-
memoryConfig,
|
|
602
|
+
memoryConfig: memoryOptions,
|
|
572
603
|
outputText,
|
|
573
604
|
runId: runIdToUse
|
|
574
605
|
});
|
|
575
606
|
return result;
|
|
576
607
|
}
|
|
577
|
-
async stream(messages, { context, threadId: threadIdInFn,
|
|
608
|
+
async stream(messages, { context, threadId: threadIdInFn, memoryOptions, resourceId, maxSteps = 5, onFinish, onStepFinish, runId, toolsets, output = "text", temperature } = {}) {
|
|
578
609
|
const runIdToUse = runId || randomUUID();
|
|
579
610
|
let messagesToUse = [];
|
|
580
611
|
if (typeof messages === `string`) {
|
|
@@ -599,7 +630,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
599
630
|
messages: messagesToUse,
|
|
600
631
|
context,
|
|
601
632
|
threadId: threadIdInFn,
|
|
602
|
-
memoryConfig,
|
|
633
|
+
memoryConfig: memoryOptions,
|
|
603
634
|
resourceId,
|
|
604
635
|
runId: runIdToUse,
|
|
605
636
|
toolsets
|
|
@@ -622,7 +653,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
622
653
|
await after({
|
|
623
654
|
result: res,
|
|
624
655
|
threadId,
|
|
625
|
-
memoryConfig,
|
|
656
|
+
memoryConfig: memoryOptions,
|
|
626
657
|
outputText,
|
|
627
658
|
runId: runIdToUse
|
|
628
659
|
});
|
|
@@ -655,7 +686,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
655
686
|
await after({
|
|
656
687
|
result: res,
|
|
657
688
|
threadId,
|
|
658
|
-
memoryConfig,
|
|
689
|
+
memoryConfig: memoryOptions,
|
|
659
690
|
outputText,
|
|
660
691
|
runId: runIdToUse
|
|
661
692
|
});
|
|
@@ -673,6 +704,7 @@ var _Agent = class _Agent extends MastraBase {
|
|
|
673
704
|
}
|
|
674
705
|
};
|
|
675
706
|
_mastra = new WeakMap();
|
|
707
|
+
_memory = new WeakMap();
|
|
676
708
|
__name(_Agent, "Agent");
|
|
677
709
|
var Agent = _Agent;
|
|
678
710
|
Agent = _ts_decorate([
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MastraBase } from './chunk-JCRGAEY6.js';
|
|
2
|
+
import { __name } from './chunk-AJJZUHB4.js';
|
|
3
|
+
import dotenv from 'dotenv';
|
|
4
|
+
import { readFile } from 'fs/promises';
|
|
5
|
+
|
|
6
|
+
var _MastraBundler = class _MastraBundler extends MastraBase {
|
|
7
|
+
constructor({ name, component = "BUNDLER" }) {
|
|
8
|
+
super({
|
|
9
|
+
component,
|
|
10
|
+
name
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async loadEnvVars() {
|
|
14
|
+
const envVars = /* @__PURE__ */ new Map();
|
|
15
|
+
for (const file of await this.getEnvFiles()) {
|
|
16
|
+
const content = await readFile(file, "utf-8");
|
|
17
|
+
const config = dotenv.parse(content);
|
|
18
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
19
|
+
envVars.set(key, value);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return envVars;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
__name(_MastraBundler, "MastraBundler");
|
|
26
|
+
var MastraBundler = _MastraBundler;
|
|
27
|
+
|
|
28
|
+
export { MastraBundler };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Telemetry } from './chunk-
|
|
2
|
-
import { LLM } from './chunk-
|
|
1
|
+
import { Telemetry } from './chunk-SDKEPBBH.js';
|
|
2
|
+
import { LLM } from './chunk-6WJREZ5F.js';
|
|
3
3
|
import { InstrumentClass } from './chunk-6ZVFVYLE.js';
|
|
4
|
-
import { LogLevel, createLogger, noopLogger } from './chunk-
|
|
4
|
+
import { LogLevel, createLogger, noopLogger } from './chunk-TJK6TGSR.js';
|
|
5
5
|
import { __name, __publicField } from './chunk-AJJZUHB4.js';
|
|
6
6
|
import 'dotenv/config';
|
|
7
7
|
|
|
@@ -243,7 +243,13 @@ var _Mastra = class _Mastra {
|
|
|
243
243
|
this.logger = logger;
|
|
244
244
|
if (this.agents) {
|
|
245
245
|
Object.keys(this.agents).forEach((key) => {
|
|
246
|
-
this.agents?.[key]
|
|
246
|
+
const agent = this.agents?.[key];
|
|
247
|
+
if (agent) {
|
|
248
|
+
agent.__setLogger(this.logger);
|
|
249
|
+
if (agent.hasOwnMemory()) {
|
|
250
|
+
agent.getMemory()?.__setLogger(this.logger);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
247
253
|
});
|
|
248
254
|
}
|
|
249
255
|
if (this.workflows) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MastraBase } from './chunk-
|
|
1
|
+
import { MastraBase } from './chunk-JCRGAEY6.js';
|
|
2
2
|
import { __name, __publicField } from './chunk-AJJZUHB4.js';
|
|
3
3
|
import { createClient } from '@libsql/client';
|
|
4
4
|
|
|
@@ -201,10 +201,10 @@ var _MastraStorage = class _MastraStorage extends MastraBase {
|
|
|
201
201
|
}
|
|
202
202
|
};
|
|
203
203
|
__name(_MastraStorage, "MastraStorage");
|
|
204
|
-
__publicField(_MastraStorage, "TABLE_WORKFLOW_SNAPSHOT", "
|
|
205
|
-
__publicField(_MastraStorage, "TABLE_EVALS", "
|
|
206
|
-
__publicField(_MastraStorage, "TABLE_MESSAGES", "
|
|
207
|
-
__publicField(_MastraStorage, "TABLE_THREADS", "
|
|
204
|
+
__publicField(_MastraStorage, "TABLE_WORKFLOW_SNAPSHOT", "mastra_workflow_snapshot");
|
|
205
|
+
__publicField(_MastraStorage, "TABLE_EVALS", "mastra_evals");
|
|
206
|
+
__publicField(_MastraStorage, "TABLE_MESSAGES", "mastra_messages");
|
|
207
|
+
__publicField(_MastraStorage, "TABLE_THREADS", "mastra_threads");
|
|
208
208
|
var MastraStorage = _MastraStorage;
|
|
209
209
|
var _MastraStorageLibSql = class _MastraStorageLibSql extends MastraStorage {
|
|
210
210
|
constructor({ config }) {
|
|
@@ -378,10 +378,14 @@ var _MastraStorageLibSql = class _MastraStorageLibSql extends MastraStorage {
|
|
|
378
378
|
});
|
|
379
379
|
}
|
|
380
380
|
parseRow(row) {
|
|
381
|
-
|
|
381
|
+
let content = row.content;
|
|
382
|
+
try {
|
|
383
|
+
content = JSON.parse(row.content);
|
|
384
|
+
} catch (e) {
|
|
385
|
+
}
|
|
382
386
|
return {
|
|
383
387
|
id: row.id,
|
|
384
|
-
content
|
|
388
|
+
content,
|
|
385
389
|
role: row.role,
|
|
386
390
|
type: row.type,
|
|
387
391
|
createdAt: new Date(row.createdAt),
|
|
@@ -391,7 +395,7 @@ var _MastraStorageLibSql = class _MastraStorageLibSql extends MastraStorage {
|
|
|
391
395
|
async getMessages({ threadId, selectBy }) {
|
|
392
396
|
try {
|
|
393
397
|
const messages = [];
|
|
394
|
-
const limit = selectBy?.last
|
|
398
|
+
const limit = typeof selectBy?.last === `number` ? selectBy.last : 40;
|
|
395
399
|
if (selectBy?.include?.length) {
|
|
396
400
|
const includeIds = selectBy.include.map((i) => i.id);
|
|
397
401
|
const maxPrev = Math.max(...selectBy.include.map((i) => i.withPreviousMessages || 0));
|
|
@@ -482,7 +486,7 @@ var _MastraStorageLibSql = class _MastraStorageLibSql extends MastraStorage {
|
|
|
482
486
|
args: [
|
|
483
487
|
message.id,
|
|
484
488
|
threadId,
|
|
485
|
-
JSON.stringify(message.content),
|
|
489
|
+
typeof message.content === "object" ? JSON.stringify(message.content) : message.content,
|
|
486
490
|
message.role,
|
|
487
491
|
message.type,
|
|
488
492
|
time instanceof Date ? time.toISOString() : time
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MastraBase } from './chunk-
|
|
1
|
+
import { MastraBase } from './chunk-JCRGAEY6.js';
|
|
2
2
|
import { __name, __publicField } from './chunk-AJJZUHB4.js';
|
|
3
3
|
|
|
4
4
|
// src/memory/index.ts
|
|
@@ -11,28 +11,28 @@ var _MastraMemory = class _MastraMemory extends MastraBase {
|
|
|
11
11
|
__publicField(this, "MAX_CONTEXT_TOKENS");
|
|
12
12
|
__publicField(this, "storage");
|
|
13
13
|
__publicField(this, "vector");
|
|
14
|
-
__publicField(this, "
|
|
14
|
+
__publicField(this, "embedding");
|
|
15
15
|
__publicField(this, "threadConfig", {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
lastMessages: 40,
|
|
17
|
+
semanticRecall: false
|
|
18
18
|
});
|
|
19
19
|
this.storage = config.storage;
|
|
20
20
|
if (config.vector) {
|
|
21
21
|
this.vector = config.vector;
|
|
22
|
-
this.threadConfig.
|
|
22
|
+
this.threadConfig.semanticRecall = true;
|
|
23
23
|
}
|
|
24
|
-
if (`
|
|
25
|
-
this.
|
|
24
|
+
if (`embedding` in config) {
|
|
25
|
+
this.embedding = config.embedding;
|
|
26
26
|
}
|
|
27
|
-
if (config.
|
|
28
|
-
this.threadConfig = this.getMergedThreadConfig(config.
|
|
27
|
+
if (config.options) {
|
|
28
|
+
this.threadConfig = this.getMergedThreadConfig(config.options);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
parseEmbeddingOptions() {
|
|
32
|
-
if (!this.
|
|
33
|
-
throw new Error(`Cannot use vector features without setting new Memory({
|
|
32
|
+
if (!this.embedding) {
|
|
33
|
+
throw new Error(`Cannot use vector features without setting new Memory({ embedding: { ... } })`);
|
|
34
34
|
}
|
|
35
|
-
return this.
|
|
35
|
+
return this.embedding;
|
|
36
36
|
}
|
|
37
37
|
getMergedThreadConfig(config) {
|
|
38
38
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MastraBase } from './chunk-
|
|
1
|
+
import { MastraBase } from './chunk-JCRGAEY6.js';
|
|
2
2
|
import { __name, __publicField, __privateAdd, __privateSet, __privateGet, __privateMethod } from './chunk-AJJZUHB4.js';
|
|
3
3
|
import { get } from 'radash';
|
|
4
4
|
import sift from 'sift';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MastraBase } from './chunk-
|
|
2
|
-
import { embed, embedMany } from './chunk-
|
|
1
|
+
import { MastraBase } from './chunk-JCRGAEY6.js';
|
|
2
|
+
import { embed, embedMany } from './chunk-5NQ3MEZM.js';
|
|
3
3
|
import { __name } from './chunk-AJJZUHB4.js';
|
|
4
4
|
|
|
5
5
|
// src/vector/index.ts
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MastraLLM } from './chunk-2ISN3AA7.js';
|
|
2
|
+
import { __name } from './chunk-AJJZUHB4.js';
|
|
3
|
+
import { createOpenAI } from '@ai-sdk/openai';
|
|
4
|
+
|
|
5
|
+
function openaiCompat({ baseURL, apiKey, modelName, fetch, settings }) {
|
|
6
|
+
const client = createOpenAI({
|
|
7
|
+
baseURL,
|
|
8
|
+
apiKey,
|
|
9
|
+
fetch
|
|
10
|
+
});
|
|
11
|
+
return client(modelName, settings);
|
|
12
|
+
}
|
|
13
|
+
__name(openaiCompat, "openaiCompat");
|
|
14
|
+
var _OpenaiCompat = class _OpenaiCompat extends MastraLLM {
|
|
15
|
+
constructor({ name, apiKey, baseURL, fetch, settings }) {
|
|
16
|
+
super({
|
|
17
|
+
model: openaiCompat({
|
|
18
|
+
modelName: name,
|
|
19
|
+
apiKey,
|
|
20
|
+
baseURL,
|
|
21
|
+
fetch,
|
|
22
|
+
settings
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
__name(_OpenaiCompat, "OpenaiCompat");
|
|
28
|
+
var OpenaiCompat = _OpenaiCompat;
|
|
29
|
+
|
|
30
|
+
export { OpenaiCompat, openaiCompat };
|
|
@@ -30,6 +30,10 @@ var BaseFilterTranslator = (_a = class {
|
|
|
30
30
|
isFieldOperator(key) {
|
|
31
31
|
return this.isOperator(key) && !this.isLogicalOperator(key);
|
|
32
32
|
}
|
|
33
|
+
isCustomOperator(key) {
|
|
34
|
+
const support = this.getSupportedOperators();
|
|
35
|
+
return support.custom?.includes(key) ?? false;
|
|
36
|
+
}
|
|
33
37
|
getSupportedOperators() {
|
|
34
38
|
return _a.DEFAULT_OPERATORS;
|
|
35
39
|
}
|
|
@@ -45,6 +49,9 @@ var BaseFilterTranslator = (_a = class {
|
|
|
45
49
|
if (value instanceof Date) {
|
|
46
50
|
return value.toISOString();
|
|
47
51
|
}
|
|
52
|
+
if (typeof value === "number" && Object.is(value, -0)) {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
48
55
|
return value;
|
|
49
56
|
}
|
|
50
57
|
/**
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MastraBundler } from './chunk-CQYUMNLZ.js';
|
|
2
|
+
import { __name } from './chunk-AJJZUHB4.js';
|
|
3
|
+
|
|
4
|
+
// src/deployer/index.ts
|
|
5
|
+
var _MastraDeployer = class _MastraDeployer extends MastraBundler {
|
|
6
|
+
constructor({ name }) {
|
|
7
|
+
super({
|
|
8
|
+
component: "DEPLOYER",
|
|
9
|
+
name
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
__name(_MastraDeployer, "MastraDeployer");
|
|
14
|
+
var MastraDeployer = _MastraDeployer;
|
|
15
|
+
|
|
16
|
+
export { MastraDeployer };
|
package/dist/deployer/index.d.ts
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MastraBundler } from '../bundler/index.js';
|
|
2
|
+
import '../base.js';
|
|
2
3
|
import '@opentelemetry/api';
|
|
3
|
-
import '../index-
|
|
4
|
+
import '../index-B0-NXUYv.js';
|
|
4
5
|
import 'pino';
|
|
5
6
|
import 'stream';
|
|
6
|
-
import '../telemetry
|
|
7
|
+
import '../telemetry-oCUM52DG.js';
|
|
7
8
|
import '@opentelemetry/sdk-node';
|
|
8
9
|
import '@opentelemetry/sdk-trace-base';
|
|
9
10
|
|
|
10
|
-
declare abstract class MastraDeployer extends
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
env?: Record<string, any>;
|
|
14
|
-
constructor({ scope, env, projectName }: {
|
|
15
|
-
projectName: string;
|
|
16
|
-
scope: string;
|
|
17
|
-
env?: Record<string, any>;
|
|
11
|
+
declare abstract class MastraDeployer extends MastraBundler {
|
|
12
|
+
constructor({ name }: {
|
|
13
|
+
name: string;
|
|
18
14
|
});
|
|
19
|
-
|
|
20
|
-
protected getEnvFiles(): string[];
|
|
21
|
-
protected parseEnvFile(filePath: string): string[];
|
|
22
|
-
writeFiles({ dir }: {
|
|
23
|
-
dir: string;
|
|
24
|
-
}): void;
|
|
25
|
-
writeIndex({ dir }: {
|
|
26
|
-
dir: string;
|
|
27
|
-
}): void;
|
|
28
|
-
deploy({ dir, siteId }: {
|
|
29
|
-
token: string;
|
|
30
|
-
dir: string;
|
|
31
|
-
siteId?: string;
|
|
32
|
-
}): Promise<void>;
|
|
15
|
+
abstract deploy(outputDirectory: string): Promise<void>;
|
|
33
16
|
}
|
|
34
17
|
|
|
35
18
|
export { MastraDeployer };
|
package/dist/deployer/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { MastraDeployer } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { MastraDeployer } from '../chunk-XD5IQZRB.js';
|
|
2
|
+
import '../chunk-CQYUMNLZ.js';
|
|
3
|
+
import '../chunk-JCRGAEY6.js';
|
|
4
|
+
import '../chunk-TJK6TGSR.js';
|
|
4
5
|
import '../chunk-AJJZUHB4.js';
|
|
@@ -2,7 +2,7 @@ import * as ai from 'ai';
|
|
|
2
2
|
import { E as EmbeddingOptions } from '../types-M16hSruO.js';
|
|
3
3
|
export { A as AmazonBedrockEmbeddingModelNames, C as CohereEmbeddingConfig, V as VoyageEmbeddingModelNames } from '../types-M16hSruO.js';
|
|
4
4
|
|
|
5
|
-
declare function embed(value: string,
|
|
6
|
-
declare function embedMany(value: string[],
|
|
5
|
+
declare function embed(value: string, embedding: EmbeddingOptions): Promise<ai.EmbedResult<string>>;
|
|
6
|
+
declare function embedMany(value: string[], embedding: EmbeddingOptions): Promise<ai.EmbedManyResult<string>>;
|
|
7
7
|
|
|
8
8
|
export { EmbeddingOptions, embed, embedMany };
|