@mastra/core 0.10.2 → 0.10.4-alpha.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 +4 -4
- package/dist/agent/index.d.cts +4 -3
- package/dist/agent/index.d.ts +4 -3
- package/dist/agent/index.js +2 -2
- package/dist/{base-BJBoI-g2.d.cts → base-BURd0RH-.d.cts} +48 -7
- package/dist/{base-BY9WFI65.d.cts → base-Bi9KB0TN.d.ts} +19 -3
- package/dist/{base-C0yUw8BC.d.ts → base-CO-L7hF9.d.cts} +19 -3
- package/dist/{base-BEjkhvZ_.d.ts → base-nFL4giIu.d.ts} +48 -7
- package/dist/base.cjs +2 -2
- package/dist/base.d.cts +3 -2
- package/dist/base.d.ts +3 -2
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.cts +3 -2
- package/dist/bundler/index.d.ts +3 -2
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-NMDM4IZN.cjs → chunk-2D7NOO7S.cjs} +16 -11
- package/dist/{chunk-3JGO7S6X.cjs → chunk-33LPXZPZ.cjs} +2 -2
- package/dist/{chunk-JOCKZ2US.js → chunk-5IEKR756.js} +1 -1
- package/dist/{chunk-XXVGT7SJ.js → chunk-5YDTZN2X.js} +32 -9
- package/dist/{chunk-DTJ4KVHM.js → chunk-ATXBSEFT.js} +1 -1
- package/dist/chunk-BBAQW23O.cjs +68 -0
- package/dist/{chunk-OBEALYTK.js → chunk-DO5R43AJ.js} +16 -11
- package/dist/{chunk-7AWGDSGR.js → chunk-DU32FMDF.js} +3 -3
- package/dist/{chunk-CYJF6U6B.cjs → chunk-FEYYOBBG.cjs} +2 -2
- package/dist/{chunk-HZ7ME4LD.cjs → chunk-FFYVLKQW.cjs} +2 -2
- package/dist/{chunk-5G3XWKIU.cjs → chunk-FJXOUO3F.cjs} +2 -2
- package/dist/{chunk-FGBS7VRU.js → chunk-FNQU5CHU.js} +3 -3
- package/dist/{chunk-JBTXWDNO.js → chunk-GEDW7TMB.js} +9 -9
- package/dist/{chunk-KUJQVCEL.cjs → chunk-H5IRI46R.cjs} +6 -3
- package/dist/{chunk-FLPSXJWQ.js → chunk-HJML6BS7.js} +1 -1
- package/dist/{chunk-B2RDYK2X.js → chunk-IG7FGYSW.js} +1 -1
- package/dist/{chunk-PMAVDBJY.js → chunk-IM7CLVLZ.js} +1 -1
- package/dist/{chunk-XJCP3SLA.js → chunk-JNMQKJH4.js} +1 -1
- package/dist/{chunk-WE5ABCZN.js → chunk-KIKYEFSA.js} +3 -3
- package/dist/{chunk-VBSKHNCY.cjs → chunk-KQ2KYQLN.cjs} +9 -9
- package/dist/{chunk-TAHSAZUN.cjs → chunk-LEK3J7YN.cjs} +2 -2
- package/dist/{chunk-TO5645ZP.cjs → chunk-MHN2BI4P.cjs} +25 -25
- package/dist/{chunk-VHZPWE5L.cjs → chunk-P3Q73CAW.cjs} +6 -6
- package/dist/chunk-PVGSY24V.js +63 -0
- package/dist/chunk-QVROTSA5.cjs +408 -0
- package/dist/{chunk-SH2C4VTJ.cjs → chunk-QVTGHY2K.cjs} +21 -10
- package/dist/{chunk-S4TS74VT.cjs → chunk-RORSYAKV.cjs} +7 -7
- package/dist/{chunk-7MWWPVCE.js → chunk-RSN3NZQS.js} +1 -1
- package/dist/chunk-TRJIWZKM.js +390 -0
- package/dist/{chunk-ZPOETARN.js → chunk-V6I25JEV.js} +1 -1
- package/dist/{chunk-SKYO5NFQ.cjs → chunk-VAOBU5SY.cjs} +8 -8
- package/dist/{chunk-X6VHQCYN.cjs → chunk-W5I6MEVU.cjs} +2 -2
- package/dist/{chunk-JAVP6ACT.js → chunk-YCYAVLYR.js} +4 -1
- package/dist/{chunk-TIPFGQCO.js → chunk-YKJZX7TE.js} +18 -7
- package/dist/{chunk-RFAN7FAT.cjs → chunk-ZIZ3CVHN.cjs} +32 -9
- package/dist/{chunk-PKYG5CWB.cjs → chunk-ZZLBNB3U.cjs} +2 -2
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.d.cts +3 -2
- package/dist/deployer/index.d.ts +3 -2
- package/dist/deployer/index.js +1 -1
- package/dist/error/index.cjs +19 -72
- package/dist/error/index.d.cts +25 -31
- package/dist/error/index.d.ts +25 -31
- package/dist/error/index.js +1 -70
- package/dist/eval/index.d.cts +4 -3
- package/dist/eval/index.d.ts +4 -3
- package/dist/index.cjs +45 -45
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +13 -13
- package/dist/integration/index.d.cts +4 -3
- package/dist/integration/index.d.ts +4 -3
- package/dist/llm/index.d.cts +4 -3
- package/dist/llm/index.d.ts +4 -3
- package/dist/logger/index.cjs +10 -10
- package/dist/logger/index.d.cts +60 -7
- package/dist/logger/index.d.ts +60 -7
- package/dist/logger/index.js +2 -2
- package/dist/logger-CpL0z5v_.d.cts +158 -0
- package/dist/logger-DtVDdb81.d.ts +158 -0
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +5 -4
- package/dist/mastra/index.d.ts +5 -4
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +4 -4
- package/dist/mcp/index.d.cts +5 -4
- package/dist/mcp/index.d.ts +5 -4
- package/dist/mcp/index.js +3 -3
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.d.cts +4 -3
- package/dist/memory/index.d.ts +4 -3
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +6 -6
- package/dist/network/index.d.cts +4 -3
- package/dist/network/index.d.ts +4 -3
- package/dist/network/index.js +3 -3
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +5 -4
- package/dist/relevance/index.d.ts +5 -4
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +2 -2
- package/dist/server/index.d.cts +5 -4
- package/dist/server/index.d.ts +5 -4
- package/dist/server/index.js +1 -1
- package/dist/storage/index.cjs +5 -5
- package/dist/storage/index.d.cts +6 -5
- package/dist/storage/index.d.ts +6 -5
- package/dist/storage/index.js +3 -3
- package/dist/telemetry/index.d.cts +4 -3
- package/dist/telemetry/index.d.ts +4 -3
- package/dist/tools/index.d.cts +6 -5
- package/dist/tools/index.d.ts +6 -5
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.d.cts +3 -2
- package/dist/tts/index.d.ts +3 -2
- package/dist/tts/index.js +1 -1
- package/dist/utils.cjs +14 -14
- package/dist/utils.d.cts +4 -3
- package/dist/utils.d.ts +4 -3
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.d.cts +3 -2
- package/dist/vector/index.d.ts +3 -2
- package/dist/vector/index.js +1 -1
- package/dist/voice/index.cjs +4 -4
- package/dist/voice/index.d.cts +4 -3
- package/dist/voice/index.d.ts +4 -3
- package/dist/voice/index.js +1 -1
- package/dist/workflows/index.cjs +9 -9
- package/dist/workflows/index.d.cts +5 -4
- package/dist/workflows/index.d.ts +5 -4
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +22 -22
- package/dist/workflows/legacy/index.d.cts +5 -4
- package/dist/workflows/legacy/index.d.ts +5 -4
- package/dist/workflows/legacy/index.js +1 -1
- package/package.json +9 -10
- package/dist/chunk-WWLMZIHW.cjs +0 -995
- package/dist/chunk-Y5BGCPNZ.js +0 -977
- package/dist/logger-BF2Sn7JX.d.cts +0 -79
- package/dist/logger-BF2Sn7JX.d.ts +0 -79
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/error/index.ts
|
|
4
|
+
var ErrorDomain = /* @__PURE__ */ ((ErrorDomain2) => {
|
|
5
|
+
ErrorDomain2["TOOL"] = "TOOL";
|
|
6
|
+
ErrorDomain2["AGENT"] = "AGENT";
|
|
7
|
+
ErrorDomain2["MCP"] = "MCP";
|
|
8
|
+
ErrorDomain2["UNKNOWN"] = "UNKNOWN";
|
|
9
|
+
return ErrorDomain2;
|
|
10
|
+
})(ErrorDomain || {});
|
|
11
|
+
var ErrorCategory = /* @__PURE__ */ ((ErrorCategory2) => {
|
|
12
|
+
ErrorCategory2["UNKNOWN"] = "UNKNOWN";
|
|
13
|
+
ErrorCategory2["USER"] = "USER";
|
|
14
|
+
ErrorCategory2["SYSTEM"] = "SYSTEM";
|
|
15
|
+
ErrorCategory2["THIRD_PARTY"] = "THIRD_PARTY";
|
|
16
|
+
return ErrorCategory2;
|
|
17
|
+
})(ErrorCategory || {});
|
|
18
|
+
var MastraBaseError = class extends Error {
|
|
19
|
+
id;
|
|
20
|
+
domain;
|
|
21
|
+
category;
|
|
22
|
+
details = {};
|
|
23
|
+
message;
|
|
24
|
+
constructor(errorDefinition, originalError) {
|
|
25
|
+
let error;
|
|
26
|
+
if (originalError instanceof Error) {
|
|
27
|
+
error = originalError;
|
|
28
|
+
} else if (originalError) {
|
|
29
|
+
error = new Error(String(originalError));
|
|
30
|
+
}
|
|
31
|
+
const message = errorDefinition.text ?? error?.message ?? "Unknown error";
|
|
32
|
+
super(message, { cause: error });
|
|
33
|
+
this.id = errorDefinition.id;
|
|
34
|
+
this.domain = errorDefinition.domain;
|
|
35
|
+
this.category = errorDefinition.category;
|
|
36
|
+
this.details = errorDefinition.details ?? {};
|
|
37
|
+
this.message = message;
|
|
38
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns a structured representation of the error, useful for logging or API responses.
|
|
42
|
+
*/
|
|
43
|
+
toJSONDetails() {
|
|
44
|
+
return {
|
|
45
|
+
message: this.message,
|
|
46
|
+
domain: this.domain,
|
|
47
|
+
category: this.category,
|
|
48
|
+
details: this.details
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
toJSON() {
|
|
52
|
+
return {
|
|
53
|
+
message: this.message,
|
|
54
|
+
details: this.toJSONDetails(),
|
|
55
|
+
code: this.id
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
toString() {
|
|
59
|
+
return JSON.stringify(this.toJSON());
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var MastraError = class extends MastraBaseError {
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.ErrorCategory = ErrorCategory;
|
|
66
|
+
exports.ErrorDomain = ErrorDomain;
|
|
67
|
+
exports.MastraBaseError = MastraBaseError;
|
|
68
|
+
exports.MastraError = MastraError;
|
|
@@ -18,28 +18,31 @@ var MultiLogger = class {
|
|
|
18
18
|
error(message, ...args) {
|
|
19
19
|
this.loggers.forEach((logger) => logger.error(message, ...args));
|
|
20
20
|
}
|
|
21
|
+
trackException(error) {
|
|
22
|
+
this.loggers.forEach((logger) => logger.trackException(error));
|
|
23
|
+
}
|
|
21
24
|
getTransports() {
|
|
22
25
|
const transports = [];
|
|
23
26
|
this.loggers.forEach((logger) => transports.push(...logger.getTransports().entries()));
|
|
24
27
|
return new Map(transports);
|
|
25
28
|
}
|
|
26
|
-
async getLogs(transportId) {
|
|
29
|
+
async getLogs(transportId, params) {
|
|
27
30
|
for (const logger of this.loggers) {
|
|
28
|
-
const logs = await logger.getLogs(transportId);
|
|
29
|
-
if (logs.
|
|
31
|
+
const logs = await logger.getLogs(transportId, params);
|
|
32
|
+
if (logs.total > 0) {
|
|
30
33
|
return logs;
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
|
-
return [];
|
|
36
|
+
return { logs: [], total: 0, page: params?.page ?? 1, perPage: params?.perPage ?? 100, hasMore: false };
|
|
34
37
|
}
|
|
35
38
|
async getLogsByRunId(args) {
|
|
36
39
|
for (const logger of this.loggers) {
|
|
37
40
|
const logs = await logger.getLogsByRunId(args);
|
|
38
|
-
if (logs.
|
|
41
|
+
if (logs.total > 0) {
|
|
39
42
|
return logs;
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
|
-
return [];
|
|
45
|
+
return { logs: [], total: 0, page: args.page ?? 1, perPage: args.perPage ?? 100, hasMore: false };
|
|
43
46
|
}
|
|
44
47
|
};
|
|
45
48
|
|
|
@@ -56,18 +59,20 @@ var noopLogger = {
|
|
|
56
59
|
cleanup: async () => {
|
|
57
60
|
},
|
|
58
61
|
getTransports: () => /* @__PURE__ */ new Map(),
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
trackException: () => {
|
|
63
|
+
},
|
|
64
|
+
getLogs: async () => ({ logs: [], total: 0, page: 1, perPage: 100, hasMore: false }),
|
|
65
|
+
getLogsByRunId: async () => ({ logs: [], total: 0, page: 1, perPage: 100, hasMore: false })
|
|
61
66
|
};
|
|
62
67
|
var LoggerTransport = class extends Transform {
|
|
63
68
|
constructor(opts = {}) {
|
|
64
69
|
super({ ...opts, objectMode: true });
|
|
65
70
|
}
|
|
66
71
|
async getLogsByRunId(_args) {
|
|
67
|
-
return [];
|
|
72
|
+
return { logs: [], total: 0, page: _args?.page ?? 1, perPage: _args?.perPage ?? 100, hasMore: false };
|
|
68
73
|
}
|
|
69
|
-
async getLogs() {
|
|
70
|
-
return [];
|
|
74
|
+
async getLogs(_args) {
|
|
75
|
+
return { logs: [], total: 0, page: _args?.page ?? 1, perPage: _args?.perPage ?? 100, hasMore: false };
|
|
71
76
|
}
|
|
72
77
|
};
|
|
73
78
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { augmentWithInit } from './chunk-YOQP5T77.js';
|
|
2
|
-
import { MessageList } from './chunk-
|
|
3
|
-
import { deepMerge } from './chunk-
|
|
4
|
-
import { MastraBase } from './chunk-
|
|
2
|
+
import { MessageList } from './chunk-YCYAVLYR.js';
|
|
3
|
+
import { deepMerge } from './chunk-TRJIWZKM.js';
|
|
4
|
+
import { MastraBase } from './chunk-5IEKR756.js';
|
|
5
5
|
|
|
6
6
|
// src/memory/memory.ts
|
|
7
7
|
var MemoryProcessor = class extends MastraBase {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
|
|
4
4
|
var promises = require('fs/promises');
|
|
5
5
|
var dotenv = require('dotenv');
|
|
6
6
|
|
|
7
|
-
var MastraBundler = class extends
|
|
7
|
+
var MastraBundler = class extends chunkP3Q73CAW_cjs.MastraBase {
|
|
8
8
|
constructor({ name, component = "BUNDLER" }) {
|
|
9
9
|
super({ component, name });
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkTICDQWVJ_cjs = require('./chunk-TICDQWVJ.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
|
|
5
5
|
var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
|
|
6
6
|
|
|
7
7
|
// src/tts/index.ts
|
|
@@ -10,7 +10,7 @@ _MastraTTS_decorators = [chunkTICDQWVJ_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 = chunkP3Q73CAW_cjs.MastraBase) {
|
|
14
14
|
model;
|
|
15
15
|
constructor({
|
|
16
16
|
model
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMHN2BI4P_cjs = require('./chunk-MHN2BI4P.cjs');
|
|
4
4
|
var cohereAi = require('cohere-ai');
|
|
5
5
|
|
|
6
6
|
var CohereRelevanceScorer = class {
|
|
@@ -38,7 +38,7 @@ Relevance score (0-1):`;
|
|
|
38
38
|
var MastraAgentRelevanceScorer = class {
|
|
39
39
|
agent;
|
|
40
40
|
constructor(name, model) {
|
|
41
|
-
this.agent = new
|
|
41
|
+
this.agent = new chunkMHN2BI4P_cjs.Agent({
|
|
42
42
|
name: `Relevance Scorer ${name}`,
|
|
43
43
|
instructions: `You are a specialized agent for evaluating the relevance of text to queries.
|
|
44
44
|
Your task is to rate how well a text passage answers a given query.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { delay } from './chunk-
|
|
2
|
-
import { MastraBase } from './chunk-
|
|
3
|
-
import { RegisteredLogger } from './chunk-
|
|
1
|
+
import { delay } from './chunk-TRJIWZKM.js';
|
|
2
|
+
import { MastraBase } from './chunk-5IEKR756.js';
|
|
3
|
+
import { RegisteredLogger } from './chunk-5YDTZN2X.js';
|
|
4
4
|
import { jsonSchema, generateText, Output, generateObject, streamText, streamObject } from 'ai';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { DefaultVoice } from './chunk-
|
|
2
|
-
import { MessageList } from './chunk-
|
|
1
|
+
import { DefaultVoice } from './chunk-HJML6BS7.js';
|
|
2
|
+
import { MessageList } from './chunk-YCYAVLYR.js';
|
|
3
3
|
import { executeHook } from './chunk-BB4KXGBU.js';
|
|
4
|
-
import { MastraLLM } from './chunk-
|
|
4
|
+
import { MastraLLM } from './chunk-FNQU5CHU.js';
|
|
5
5
|
import { InstrumentClass } from './chunk-EWDGXKOQ.js';
|
|
6
|
-
import { ensureToolProperties, makeCoreTool, createMastraProxy } from './chunk-
|
|
7
|
-
import { MastraBase } from './chunk-
|
|
8
|
-
import { RegisteredLogger } from './chunk-
|
|
6
|
+
import { ensureToolProperties, makeCoreTool, createMastraProxy } from './chunk-TRJIWZKM.js';
|
|
7
|
+
import { MastraBase } from './chunk-5IEKR756.js';
|
|
8
|
+
import { RegisteredLogger } from './chunk-5YDTZN2X.js';
|
|
9
9
|
import { RuntimeContext } from './chunk-SGGPJWRQ.js';
|
|
10
10
|
import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
|
|
11
11
|
import { context, trace } from '@opentelemetry/api';
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { get } from 'radash';
|
|
14
14
|
import { randomUUID } from 'crypto';
|
|
15
|
-
import EventEmitter from '
|
|
15
|
+
import EventEmitter from 'events';
|
|
16
16
|
import sift from 'sift';
|
|
17
17
|
import { createActor, assign, fromPromise, setup } from 'xstate';
|
|
18
18
|
|
|
@@ -763,7 +763,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
763
763
|
}).addSystem({
|
|
764
764
|
role: "system",
|
|
765
765
|
content: instructions || `${this.instructions}.`
|
|
766
|
-
}).add(context || [], "
|
|
766
|
+
}).add(context || [], "context");
|
|
767
767
|
if (!memory || !threadId && !resourceId) {
|
|
768
768
|
messageList.add(messages, "user");
|
|
769
769
|
return {
|
|
@@ -821,7 +821,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
821
821
|
const processedList = new MessageList({
|
|
822
822
|
threadId,
|
|
823
823
|
resourceId
|
|
824
|
-
}).addSystem(instructions || `${this.instructions}.`).addSystem(memorySystemMessage).add(context || [], "
|
|
824
|
+
}).addSystem(instructions || `${this.instructions}.`).addSystem(memorySystemMessage).add(context || [], "context").add(processedMemoryMessages, "memory").add(messageList.get.input.v2(), "user").get.all.prompt();
|
|
825
825
|
return {
|
|
826
826
|
convertedTools,
|
|
827
827
|
threadId,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQVROTSA5_cjs = require('./chunk-QVROTSA5.cjs');
|
|
4
4
|
var crypto = require('crypto');
|
|
5
5
|
var ai = require('ai');
|
|
6
6
|
var providerUtils = require('@ai-sdk/provider-utils');
|
|
@@ -356,6 +356,7 @@ var MessageList = class _MessageList {
|
|
|
356
356
|
memoryMessages = /* @__PURE__ */ new Set();
|
|
357
357
|
newUserMessages = /* @__PURE__ */ new Set();
|
|
358
358
|
newResponseMessages = /* @__PURE__ */ new Set();
|
|
359
|
+
userContextMessages = /* @__PURE__ */ new Set();
|
|
359
360
|
generateMessageId;
|
|
360
361
|
constructor({
|
|
361
362
|
threadId,
|
|
@@ -645,6 +646,8 @@ ${JSON.stringify(message, null, 2)}`
|
|
|
645
646
|
this.newResponseMessages.add(messageV2);
|
|
646
647
|
} else if (messageSource === `user`) {
|
|
647
648
|
this.newUserMessages.add(messageV2);
|
|
649
|
+
} else if (messageSource === `context`) {
|
|
650
|
+
this.userContextMessages.add(messageV2);
|
|
648
651
|
} else {
|
|
649
652
|
throw new Error(`Missing message source for message ${messageV2}`);
|
|
650
653
|
}
|
|
@@ -854,10 +857,10 @@ ${JSON.stringify(message, null, 2)}`
|
|
|
854
857
|
};
|
|
855
858
|
}
|
|
856
859
|
static isVercelUIMessage(msg) {
|
|
857
|
-
return !_MessageList.isMastraMessage(msg) &&
|
|
860
|
+
return !_MessageList.isMastraMessage(msg) && chunkQVROTSA5_cjs.isUiMessage(msg);
|
|
858
861
|
}
|
|
859
862
|
static isVercelCoreMessage(msg) {
|
|
860
|
-
return !_MessageList.isMastraMessage(msg) &&
|
|
863
|
+
return !_MessageList.isMastraMessage(msg) && chunkQVROTSA5_cjs.isCoreMessage(msg);
|
|
861
864
|
}
|
|
862
865
|
static isMastraMessage(msg) {
|
|
863
866
|
return _MessageList.isMastraMessageV2(msg) || _MessageList.isMastraMessageV1(msg);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InstrumentClass } from './chunk-EWDGXKOQ.js';
|
|
2
|
-
import { MastraBase } from './chunk-
|
|
2
|
+
import { MastraBase } from './chunk-5IEKR756.js';
|
|
3
3
|
import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
|
|
4
4
|
|
|
5
5
|
// src/voice/voice.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EMITTER_SYMBOL } from './chunk-Y7D2JLKS.js';
|
|
2
|
-
import { Agent } from './chunk-
|
|
2
|
+
import { Agent } from './chunk-GEDW7TMB.js';
|
|
3
3
|
import { Tool } from './chunk-C4LMN2IR.js';
|
|
4
|
-
import { MastraBase } from './chunk-
|
|
5
|
-
import { RegisteredLogger } from './chunk-
|
|
4
|
+
import { MastraBase } from './chunk-5IEKR756.js';
|
|
5
|
+
import { RegisteredLogger } from './chunk-5YDTZN2X.js';
|
|
6
6
|
import { RuntimeContext } from './chunk-SGGPJWRQ.js';
|
|
7
7
|
import { randomUUID } from 'crypto';
|
|
8
8
|
import EventEmitter from 'events';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkQVROTSA5_cjs = require('./chunk-QVROTSA5.cjs');
|
|
4
|
+
var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
|
|
5
|
+
var chunkZIZ3CVHN_cjs = require('./chunk-ZIZ3CVHN.cjs');
|
|
6
6
|
var ai = require('ai');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
|
|
9
9
|
// src/llm/model/base.ts
|
|
10
|
-
var MastraLLMBase = class extends
|
|
10
|
+
var MastraLLMBase = class extends chunkP3Q73CAW_cjs.MastraBase {
|
|
11
11
|
// @ts-ignore
|
|
12
12
|
#mastra;
|
|
13
13
|
#model;
|
|
14
14
|
constructor({ name, model }) {
|
|
15
15
|
super({
|
|
16
|
-
component:
|
|
16
|
+
component: chunkZIZ3CVHN_cjs.RegisteredLogger.LLM,
|
|
17
17
|
name
|
|
18
18
|
});
|
|
19
19
|
this.#model = model;
|
|
@@ -162,7 +162,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
162
162
|
});
|
|
163
163
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
164
164
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
165
|
-
await
|
|
165
|
+
await chunkQVROTSA5_cjs.delay(10 * 1e3);
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
168
|
...rest
|
|
@@ -231,7 +231,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
231
231
|
});
|
|
232
232
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
233
233
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
234
|
-
await
|
|
234
|
+
await chunkQVROTSA5_cjs.delay(10 * 1e3);
|
|
235
235
|
}
|
|
236
236
|
},
|
|
237
237
|
...rest
|
|
@@ -304,7 +304,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
304
304
|
});
|
|
305
305
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
306
306
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
307
|
-
await
|
|
307
|
+
await chunkQVROTSA5_cjs.delay(10 * 1e3);
|
|
308
308
|
}
|
|
309
309
|
},
|
|
310
310
|
onFinish: async (props) => {
|
|
@@ -395,7 +395,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
395
395
|
});
|
|
396
396
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
397
397
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
398
|
-
await
|
|
398
|
+
await chunkQVROTSA5_cjs.delay(10 * 1e3);
|
|
399
399
|
}
|
|
400
400
|
},
|
|
401
401
|
onFinish: async (props) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
|
|
4
4
|
|
|
5
5
|
// src/vector/vector.ts
|
|
6
|
-
var MastraVector = class extends
|
|
6
|
+
var MastraVector = class extends chunkP3Q73CAW_cjs.MastraBase {
|
|
7
7
|
constructor() {
|
|
8
8
|
super({ name: "MastraVector", component: "VECTOR" });
|
|
9
9
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk33LPXZPZ_cjs = require('./chunk-33LPXZPZ.cjs');
|
|
4
|
+
var chunkH5IRI46R_cjs = require('./chunk-H5IRI46R.cjs');
|
|
5
5
|
var chunkST5RMVLG_cjs = require('./chunk-ST5RMVLG.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkKQ2KYQLN_cjs = require('./chunk-KQ2KYQLN.cjs');
|
|
7
7
|
var chunkTICDQWVJ_cjs = require('./chunk-TICDQWVJ.cjs');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
8
|
+
var chunkQVROTSA5_cjs = require('./chunk-QVROTSA5.cjs');
|
|
9
|
+
var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
|
|
10
|
+
var chunkZIZ3CVHN_cjs = require('./chunk-ZIZ3CVHN.cjs');
|
|
11
11
|
var chunkLABUWBKX_cjs = require('./chunk-LABUWBKX.cjs');
|
|
12
12
|
var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
|
|
13
13
|
var api = require('@opentelemetry/api');
|
|
@@ -71,7 +71,7 @@ _Agent_decorators = [chunkTICDQWVJ_cjs.InstrumentClass({
|
|
|
71
71
|
prefix: "agent",
|
|
72
72
|
excludeMethods: ["hasOwnMemory", "getMemory", "__primitive", "__registerMastra", "__registerPrimitives", "__setTools", "__setLogger", "__setTelemetry", "log", "getModel", "getInstructions", "getTools", "getLLM", "getWorkflows", "getDefaultGenerateOptions", "getDefaultStreamOptions", "getDescription"]
|
|
73
73
|
})];
|
|
74
|
-
exports.Agent = class Agent extends (_a =
|
|
74
|
+
exports.Agent = class Agent extends (_a = chunkP3Q73CAW_cjs.MastraBase) {
|
|
75
75
|
id;
|
|
76
76
|
name;
|
|
77
77
|
#instructions;
|
|
@@ -89,7 +89,7 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
89
89
|
#voice;
|
|
90
90
|
constructor(config) {
|
|
91
91
|
super({
|
|
92
|
-
component:
|
|
92
|
+
component: chunkZIZ3CVHN_cjs.RegisteredLogger.AGENT
|
|
93
93
|
});
|
|
94
94
|
this.name = config.name;
|
|
95
95
|
this.id = config.name;
|
|
@@ -134,7 +134,7 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
134
134
|
this.#voice?.addInstructions(config.instructions);
|
|
135
135
|
}
|
|
136
136
|
} else {
|
|
137
|
-
this.#voice = new
|
|
137
|
+
this.#voice = new chunk33LPXZPZ_cjs.DefaultVoice();
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
hasOwnMemory() {
|
|
@@ -187,7 +187,7 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
187
187
|
}));
|
|
188
188
|
return voice;
|
|
189
189
|
} else {
|
|
190
|
-
return new
|
|
190
|
+
return new chunk33LPXZPZ_cjs.DefaultVoice();
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
get instructions() {
|
|
@@ -228,13 +228,13 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
228
228
|
if (typeof this.#tools === "function") {
|
|
229
229
|
throw new Error("Tools are not compatible when tools are a function. Please use getTools() instead.");
|
|
230
230
|
}
|
|
231
|
-
return
|
|
231
|
+
return chunkQVROTSA5_cjs.ensureToolProperties(this.#tools);
|
|
232
232
|
}
|
|
233
233
|
getTools({
|
|
234
234
|
runtimeContext = new chunkLABUWBKX_cjs.RuntimeContext()
|
|
235
235
|
} = {}) {
|
|
236
236
|
if (typeof this.#tools !== "function") {
|
|
237
|
-
return
|
|
237
|
+
return chunkQVROTSA5_cjs.ensureToolProperties(this.#tools);
|
|
238
238
|
}
|
|
239
239
|
const result = this.#tools({
|
|
240
240
|
runtimeContext
|
|
@@ -244,7 +244,7 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
244
244
|
this.logger.error(`[Agent:${this.name}] - Function-based tools returned empty value`);
|
|
245
245
|
throw new Error("Tools are required when using a function to provide them. The function returned an empty value.");
|
|
246
246
|
}
|
|
247
|
-
return
|
|
247
|
+
return chunkQVROTSA5_cjs.ensureToolProperties(tools);
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
get llm() {
|
|
@@ -266,7 +266,7 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
266
266
|
runtimeContext
|
|
267
267
|
});
|
|
268
268
|
return resolveMaybePromise(model, model2 => {
|
|
269
|
-
const llm = new
|
|
269
|
+
const llm = new chunkKQ2KYQLN_cjs.MastraLLM({
|
|
270
270
|
model: model2,
|
|
271
271
|
mastra: this.#mastra
|
|
272
272
|
});
|
|
@@ -393,7 +393,7 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
393
393
|
memoryConfig,
|
|
394
394
|
resourceId,
|
|
395
395
|
runId,
|
|
396
|
-
messageList = new
|
|
396
|
+
messageList = new chunkH5IRI46R_cjs.MessageList({
|
|
397
397
|
threadId,
|
|
398
398
|
resourceId
|
|
399
399
|
})
|
|
@@ -525,7 +525,7 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
525
525
|
runtimeContext
|
|
526
526
|
}) : this.model
|
|
527
527
|
};
|
|
528
|
-
return [k,
|
|
528
|
+
return [k, chunkQVROTSA5_cjs.makeCoreTool(tool, options)];
|
|
529
529
|
}));
|
|
530
530
|
const assignedToolEntriesConverted = Object.fromEntries(assignedCoreToolEntries.filter(entry => Boolean(entry)));
|
|
531
531
|
toolsForRequest = {
|
|
@@ -565,7 +565,7 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
565
565
|
runtimeContext
|
|
566
566
|
}) : this.model
|
|
567
567
|
};
|
|
568
|
-
const convertedToCoreTool =
|
|
568
|
+
const convertedToCoreTool = chunkQVROTSA5_cjs.makeCoreTool(toolObj, options, "toolset");
|
|
569
569
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
570
570
|
}
|
|
571
571
|
}
|
|
@@ -606,7 +606,7 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
606
606
|
runtimeContext
|
|
607
607
|
}) : this.model
|
|
608
608
|
};
|
|
609
|
-
const convertedToCoreTool =
|
|
609
|
+
const convertedToCoreTool = chunkQVROTSA5_cjs.makeCoreTool(rest, options, "client-tool");
|
|
610
610
|
toolsForRequest[toolName] = convertedToCoreTool;
|
|
611
611
|
}
|
|
612
612
|
}
|
|
@@ -673,7 +673,7 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
673
673
|
let mastraProxy = void 0;
|
|
674
674
|
const logger = this.logger;
|
|
675
675
|
if (this.#mastra) {
|
|
676
|
-
mastraProxy =
|
|
676
|
+
mastraProxy = chunkQVROTSA5_cjs.createMastraProxy({
|
|
677
677
|
mastra: this.#mastra,
|
|
678
678
|
logger
|
|
679
679
|
});
|
|
@@ -763,14 +763,14 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
763
763
|
runId,
|
|
764
764
|
runtimeContext
|
|
765
765
|
});
|
|
766
|
-
const messageList = new
|
|
766
|
+
const messageList = new chunkH5IRI46R_cjs.MessageList({
|
|
767
767
|
threadId,
|
|
768
768
|
resourceId,
|
|
769
769
|
generateMessageId
|
|
770
770
|
}).addSystem({
|
|
771
771
|
role: "system",
|
|
772
772
|
content: instructions || `${this.instructions}.`
|
|
773
|
-
}).add(context || [], "
|
|
773
|
+
}).add(context || [], "context");
|
|
774
774
|
if (!memory || !threadId && !resourceId) {
|
|
775
775
|
messageList.add(messages, "user");
|
|
776
776
|
return {
|
|
@@ -825,10 +825,10 @@ exports.Agent = class Agent extends (_a = chunkVHZPWE5L_cjs.MastraBase) {
|
|
|
825
825
|
systemMessage,
|
|
826
826
|
memorySystemMessage: memorySystemMessage || void 0
|
|
827
827
|
});
|
|
828
|
-
const processedList = new
|
|
828
|
+
const processedList = new chunkH5IRI46R_cjs.MessageList({
|
|
829
829
|
threadId,
|
|
830
830
|
resourceId
|
|
831
|
-
}).addSystem(instructions || `${this.instructions}.`).addSystem(memorySystemMessage).add(context || [], "
|
|
831
|
+
}).addSystem(instructions || `${this.instructions}.`).addSystem(memorySystemMessage).add(context || [], "context").add(processedMemoryMessages, "memory").add(messageList.get.input.v2(), "user").get.all.prompt();
|
|
832
832
|
return {
|
|
833
833
|
convertedTools,
|
|
834
834
|
threadId,
|
|
@@ -1912,7 +1912,7 @@ var Machine = class extends EventEmitter__default.default {
|
|
|
1912
1912
|
const logger = this.logger;
|
|
1913
1913
|
let mastraProxy = void 0;
|
|
1914
1914
|
if (this.#mastra) {
|
|
1915
|
-
mastraProxy =
|
|
1915
|
+
mastraProxy = chunkQVROTSA5_cjs.createMastraProxy({
|
|
1916
1916
|
mastra: this.#mastra,
|
|
1917
1917
|
logger
|
|
1918
1918
|
});
|
|
@@ -3294,7 +3294,7 @@ var WorkflowInstance = class {
|
|
|
3294
3294
|
};
|
|
3295
3295
|
|
|
3296
3296
|
// src/workflows/legacy/workflow.ts
|
|
3297
|
-
var LegacyWorkflow = class extends
|
|
3297
|
+
var LegacyWorkflow = class extends chunkP3Q73CAW_cjs.MastraBase {
|
|
3298
3298
|
name;
|
|
3299
3299
|
triggerSchema;
|
|
3300
3300
|
resultSchema;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkZIZ3CVHN_cjs = require('./chunk-ZIZ3CVHN.cjs');
|
|
4
4
|
|
|
5
5
|
// src/base.ts
|
|
6
6
|
var MastraBase = class {
|
|
7
|
-
component =
|
|
7
|
+
component = chunkZIZ3CVHN_cjs.RegisteredLogger.LLM;
|
|
8
8
|
logger;
|
|
9
9
|
name;
|
|
10
10
|
telemetry;
|
|
11
11
|
constructor({ component, name }) {
|
|
12
|
-
this.component = component ||
|
|
12
|
+
this.component = component || chunkZIZ3CVHN_cjs.RegisteredLogger.LLM;
|
|
13
13
|
this.name = name;
|
|
14
|
-
this.logger = new
|
|
14
|
+
this.logger = new chunkZIZ3CVHN_cjs.ConsoleLogger({ name: `${this.component} - ${this.name}` });
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Set the logger for the agent
|
|
@@ -19,7 +19,7 @@ var MastraBase = class {
|
|
|
19
19
|
*/
|
|
20
20
|
__setLogger(logger) {
|
|
21
21
|
this.logger = logger;
|
|
22
|
-
if (this.component !==
|
|
22
|
+
if (this.component !== chunkZIZ3CVHN_cjs.RegisteredLogger.LLM) {
|
|
23
23
|
this.logger.debug(`Logger updated [component=${this.component}] [name=${this.name}]`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -29,7 +29,7 @@ var MastraBase = class {
|
|
|
29
29
|
*/
|
|
30
30
|
__setTelemetry(telemetry) {
|
|
31
31
|
this.telemetry = telemetry;
|
|
32
|
-
if (this.component !==
|
|
32
|
+
if (this.component !== chunkZIZ3CVHN_cjs.RegisteredLogger.LLM) {
|
|
33
33
|
this.logger.debug(`Telemetry updated [component=${this.component}] [name=${this.telemetry.name}]`);
|
|
34
34
|
}
|
|
35
35
|
}
|