@mastra/core 0.10.12 → 0.10.13
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/package.json +1 -1
- package/a2a.d.ts +0 -1
- package/agent.d.ts +0 -1
- package/base.d.ts +0 -1
- package/bundler.d.ts +0 -1
- package/deployer.d.ts +0 -1
- package/di.d.ts +0 -1
- package/dist/a2a/index.cjs +0 -79
- package/dist/a2a/index.d.cts +0 -780
- package/dist/a2a/index.d.ts +0 -780
- package/dist/a2a/index.js +0 -68
- package/dist/agent/index.cjs +0 -15
- package/dist/agent/index.d.cts +0 -29
- package/dist/agent/index.d.ts +0 -29
- package/dist/agent/index.js +0 -2
- package/dist/base-B_y9sMg0.d.cts +0 -162
- package/dist/base-CS5eSXbL.d.cts +0 -4117
- package/dist/base-ClrXcCRx.d.ts +0 -162
- package/dist/base-DBhKcre4.d.ts +0 -4117
- package/dist/base.cjs +0 -10
- package/dist/base.d.cts +0 -6
- package/dist/base.d.ts +0 -6
- package/dist/base.js +0 -1
- package/dist/bundler/index.cjs +0 -10
- package/dist/bundler/index.d.cts +0 -30
- package/dist/bundler/index.d.ts +0 -30
- package/dist/bundler/index.js +0 -1
- package/dist/chunk-2GRYVZ2O.cjs +0 -244
- package/dist/chunk-2HDFKWFU.js +0 -2249
- package/dist/chunk-32C7JDIZ.js +0 -1
- package/dist/chunk-4UBOJFSL.js +0 -989
- package/dist/chunk-4UWPFBC6.js +0 -88
- package/dist/chunk-4Z3OU5RY.cjs +0 -31
- package/dist/chunk-5HTMDAXP.js +0 -359
- package/dist/chunk-5IEKR756.js +0 -53
- package/dist/chunk-5YDTZN2X.js +0 -114
- package/dist/chunk-6UNGH46J.js +0 -75
- package/dist/chunk-6Y4UL5Z6.cjs +0 -94
- package/dist/chunk-7F6BQXE2.cjs +0 -425
- package/dist/chunk-7H2GET5Z.cjs +0 -668
- package/dist/chunk-7HZ6NIAF.cjs +0 -2
- package/dist/chunk-7MZNOW6W.cjs +0 -2263
- package/dist/chunk-7XQIPES3.js +0 -668
- package/dist/chunk-AKYTYALY.js +0 -70
- package/dist/chunk-ATXBSEFT.js +0 -22
- package/dist/chunk-B6TOBUS6.cjs +0 -80
- package/dist/chunk-B7SQOKEC.cjs +0 -91
- package/dist/chunk-BB4KXGBU.js +0 -83
- package/dist/chunk-BB6DPGIV.cjs +0 -6
- package/dist/chunk-C4LMN2IR.js +0 -27
- package/dist/chunk-DFFVEKIG.js +0 -407
- package/dist/chunk-E7AX3U6M.cjs +0 -659
- package/dist/chunk-EWCOOO3H.js +0 -5007
- package/dist/chunk-F2WMR75C.cjs +0 -183
- package/dist/chunk-FBKJ3652.cjs +0 -5034
- package/dist/chunk-FEYYOBBG.cjs +0 -24
- package/dist/chunk-FL5SZ2XU.js +0 -181
- package/dist/chunk-GH2KM66J.js +0 -37
- package/dist/chunk-GWFS5DAR.cjs +0 -37
- package/dist/chunk-HNEE7IF4.js +0 -60
- package/dist/chunk-HSVOEWAM.cjs +0 -2
- package/dist/chunk-J52TXHZV.cjs +0 -73
- package/dist/chunk-JNMQKJH4.js +0 -10
- package/dist/chunk-JQOMTERC.js +0 -89
- package/dist/chunk-LABUWBKX.cjs +0 -71
- package/dist/chunk-LXFZUKP3.cjs +0 -34
- package/dist/chunk-MP2QBLUJ.cjs +0 -70
- package/dist/chunk-MUNFCOMB.cjs +0 -62
- package/dist/chunk-NH5WJNNS.js +0 -1
- package/dist/chunk-P3Q73CAW.cjs +0 -55
- package/dist/chunk-PA2YIVIT.js +0 -61
- package/dist/chunk-QFTBW7ZZ.cjs +0 -2
- package/dist/chunk-QQ5K5TZE.cjs +0 -619
- package/dist/chunk-QUSEDVYI.cjs +0 -991
- package/dist/chunk-R4V75T7J.js +0 -1
- package/dist/chunk-SGGPJWRQ.js +0 -69
- package/dist/chunk-ST5RMVLG.cjs +0 -87
- package/dist/chunk-TC2SCOTE.js +0 -605
- package/dist/chunk-U64IJDC5.cjs +0 -109
- package/dist/chunk-UX3B6S2I.cjs +0 -65
- package/dist/chunk-V5D2LIF5.js +0 -68
- package/dist/chunk-VG4OPO2R.js +0 -240
- package/dist/chunk-WQNOATKB.js +0 -103
- package/dist/chunk-Y7D2JLKS.js +0 -4
- package/dist/chunk-YJEHXYK5.js +0 -657
- package/dist/chunk-YOQP5T77.js +0 -32
- package/dist/chunk-ZIZ3CVHN.cjs +0 -120
- package/dist/chunk-ZPOUMTTH.cjs +0 -362
- package/dist/chunk-ZZLBNB3U.cjs +0 -12
- package/dist/deployer/index.cjs +0 -10
- package/dist/deployer/index.d.cts +0 -19
- package/dist/deployer/index.d.ts +0 -19
- package/dist/deployer/index.js +0 -1
- package/dist/di/index.cjs +0 -10
- package/dist/di/index.d.cts +0 -1
- package/dist/di/index.d.ts +0 -1
- package/dist/di/index.js +0 -1
- package/dist/error/index.cjs +0 -22
- package/dist/error/index.d.cts +0 -86
- package/dist/error/index.d.ts +0 -86
- package/dist/error/index.js +0 -1
- package/dist/eval/index.cjs +0 -14
- package/dist/eval/index.d.cts +0 -43
- package/dist/eval/index.d.ts +0 -43
- package/dist/eval/index.js +0 -1
- package/dist/hooks/index.cjs +0 -18
- package/dist/hooks/index.d.cts +0 -33
- package/dist/hooks/index.d.ts +0 -33
- package/dist/hooks/index.js +0 -1
- package/dist/index.cjs +0 -281
- package/dist/index.d.cts +0 -92
- package/dist/index.d.ts +0 -92
- package/dist/index.js +0 -112
- package/dist/integration/index.cjs +0 -14
- package/dist/integration/index.d.cts +0 -65
- package/dist/integration/index.d.ts +0 -65
- package/dist/integration/index.js +0 -1
- package/dist/llm/index.cjs +0 -10
- package/dist/llm/index.d.cts +0 -29
- package/dist/llm/index.d.ts +0 -29
- package/dist/llm/index.js +0 -1
- package/dist/logger/index.cjs +0 -43
- package/dist/logger/index.d.cts +0 -96
- package/dist/logger/index.d.ts +0 -96
- package/dist/logger/index.js +0 -2
- package/dist/logger-B8XXh6ya.d.cts +0 -159
- package/dist/logger-Bpa2oLL4.d.ts +0 -159
- package/dist/mastra/index.cjs +0 -10
- package/dist/mastra/index.d.cts +0 -29
- package/dist/mastra/index.d.ts +0 -29
- package/dist/mastra/index.js +0 -1
- package/dist/mcp/index.cjs +0 -106
- package/dist/mcp/index.d.cts +0 -29
- package/dist/mcp/index.d.ts +0 -29
- package/dist/mcp/index.js +0 -100
- package/dist/memory/index.cjs +0 -18
- package/dist/memory/index.d.cts +0 -29
- package/dist/memory/index.d.ts +0 -29
- package/dist/memory/index.js +0 -1
- package/dist/network/index.cjs +0 -311
- package/dist/network/index.d.cts +0 -29
- package/dist/network/index.d.ts +0 -29
- package/dist/network/index.js +0 -309
- package/dist/network/vNext/index.cjs +0 -873
- package/dist/network/vNext/index.d.cts +0 -29
- package/dist/network/vNext/index.d.ts +0 -29
- package/dist/network/vNext/index.js +0 -871
- package/dist/relevance/index.cjs +0 -18
- package/dist/relevance/index.d.cts +0 -49
- package/dist/relevance/index.d.ts +0 -49
- package/dist/relevance/index.js +0 -1
- package/dist/runtime-context/index.cjs +0 -10
- package/dist/runtime-context/index.d.cts +0 -52
- package/dist/runtime-context/index.d.ts +0 -52
- package/dist/runtime-context/index.js +0 -1
- package/dist/server/index.cjs +0 -62
- package/dist/server/index.d.cts +0 -52
- package/dist/server/index.d.ts +0 -52
- package/dist/server/index.js +0 -59
- package/dist/storage/index.cjs +0 -336
- package/dist/storage/index.d.cts +0 -149
- package/dist/storage/index.d.ts +0 -149
- package/dist/storage/index.js +0 -303
- package/dist/telemetry/index.cjs +0 -30
- package/dist/telemetry/index.d.cts +0 -75
- package/dist/telemetry/index.d.ts +0 -75
- package/dist/telemetry/index.js +0 -1
- package/dist/telemetry/otel-vendor.cjs +0 -103
- package/dist/telemetry/otel-vendor.d.cts +0 -20
- package/dist/telemetry/otel-vendor.d.ts +0 -20
- package/dist/telemetry/otel-vendor.js +0 -57
- package/dist/tools/index.cjs +0 -18
- package/dist/tools/index.d.cts +0 -41
- package/dist/tools/index.d.ts +0 -41
- package/dist/tools/index.js +0 -1
- package/dist/tts/index.cjs +0 -10
- package/dist/tts/index.d.cts +0 -28
- package/dist/tts/index.d.ts +0 -28
- package/dist/tts/index.js +0 -1
- package/dist/types-Bo1uigWx.d.cts +0 -17
- package/dist/types-Bo1uigWx.d.ts +0 -17
- package/dist/utils.cjs +0 -58
- package/dist/utils.d.cts +0 -149
- package/dist/utils.d.ts +0 -149
- package/dist/utils.js +0 -1
- package/dist/vector/filter/index.cjs +0 -192
- package/dist/vector/filter/index.d.cts +0 -128
- package/dist/vector/filter/index.d.ts +0 -128
- package/dist/vector/filter/index.js +0 -190
- package/dist/vector/index.cjs +0 -10
- package/dist/vector/index.d.cts +0 -77
- package/dist/vector/index.d.ts +0 -77
- package/dist/vector/index.js +0 -1
- package/dist/voice/index.cjs +0 -18
- package/dist/voice/index.d.cts +0 -29
- package/dist/voice/index.d.ts +0 -29
- package/dist/voice/index.js +0 -1
- package/dist/workflows/constants.cjs +0 -10
- package/dist/workflows/constants.d.cts +0 -3
- package/dist/workflows/constants.d.ts +0 -3
- package/dist/workflows/constants.js +0 -1
- package/dist/workflows/index.cjs +0 -42
- package/dist/workflows/index.d.cts +0 -282
- package/dist/workflows/index.d.ts +0 -282
- package/dist/workflows/index.js +0 -1
- package/dist/workflows/legacy/index.cjs +0 -90
- package/dist/workflows/legacy/index.d.cts +0 -91
- package/dist/workflows/legacy/index.d.ts +0 -91
- package/dist/workflows/legacy/index.js +0 -1
- package/error.d.ts +0 -1
- package/eval.d.ts +0 -1
- package/hooks.d.ts +0 -1
- package/integration.d.ts +0 -1
- package/llm.d.ts +0 -1
- package/logger.d.ts +0 -1
- package/mastra.d.ts +0 -1
- package/mcp.d.ts +0 -1
- package/memory.d.ts +0 -1
- package/network/vNext.d.ts +0 -1
- package/network.d.ts +0 -1
- package/relevance.d.ts +0 -1
- package/runtime-context.d.ts +0 -1
- package/server.d.ts +0 -1
- package/storage.d.ts +0 -1
- package/telemetry/otel-vendor.d.ts +0 -1
- package/telemetry.d.ts +0 -1
- package/tools.d.ts +0 -1
- package/tts.d.ts +0 -1
- package/utils.d.ts +0 -1
- package/vector/filter.d.ts +0 -1
- package/vector.d.ts +0 -1
- package/voice.d.ts +0 -1
- package/workflows/_constants.d.ts +0 -1
- package/workflows/legacy.d.ts +0 -1
- package/workflows.d.ts +0 -1
package/dist/chunk-7XQIPES3.js
DELETED
|
@@ -1,668 +0,0 @@
|
|
|
1
|
-
import { augmentWithInit } from './chunk-YOQP5T77.js';
|
|
2
|
-
import { InstrumentClass, Telemetry } from './chunk-TC2SCOTE.js';
|
|
3
|
-
import { noopLogger } from './chunk-JQOMTERC.js';
|
|
4
|
-
import { MastraError } from './chunk-6UNGH46J.js';
|
|
5
|
-
import { ConsoleLogger, LogLevel } from './chunk-5YDTZN2X.js';
|
|
6
|
-
import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-WQNOATKB.js';
|
|
7
|
-
|
|
8
|
-
// src/mastra/index.ts
|
|
9
|
-
var _Mastra_decorators, _init;
|
|
10
|
-
_Mastra_decorators = [InstrumentClass({
|
|
11
|
-
prefix: "mastra",
|
|
12
|
-
excludeMethods: ["getLogger", "getTelemetry"]
|
|
13
|
-
})];
|
|
14
|
-
var Mastra = class {
|
|
15
|
-
#vectors;
|
|
16
|
-
#agents;
|
|
17
|
-
#logger;
|
|
18
|
-
#legacy_workflows;
|
|
19
|
-
#workflows;
|
|
20
|
-
#tts;
|
|
21
|
-
#deployer;
|
|
22
|
-
#serverMiddleware = [];
|
|
23
|
-
#telemetry;
|
|
24
|
-
#storage;
|
|
25
|
-
#memory;
|
|
26
|
-
#networks;
|
|
27
|
-
#vnext_networks;
|
|
28
|
-
#server;
|
|
29
|
-
#mcpServers;
|
|
30
|
-
#bundler;
|
|
31
|
-
/**
|
|
32
|
-
* @deprecated use getTelemetry() instead
|
|
33
|
-
*/
|
|
34
|
-
get telemetry() {
|
|
35
|
-
return this.#telemetry;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @deprecated use getStorage() instead
|
|
39
|
-
*/
|
|
40
|
-
get storage() {
|
|
41
|
-
return this.#storage;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated use getMemory() instead
|
|
45
|
-
*/
|
|
46
|
-
get memory() {
|
|
47
|
-
return this.#memory;
|
|
48
|
-
}
|
|
49
|
-
constructor(config) {
|
|
50
|
-
if (config?.serverMiddleware) {
|
|
51
|
-
this.#serverMiddleware = config.serverMiddleware.map(m => ({
|
|
52
|
-
handler: m.handler,
|
|
53
|
-
path: m.path || "/api/*"
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
let logger;
|
|
57
|
-
if (config?.logger === false) {
|
|
58
|
-
logger = noopLogger;
|
|
59
|
-
} else {
|
|
60
|
-
if (config?.logger) {
|
|
61
|
-
logger = config.logger;
|
|
62
|
-
} else {
|
|
63
|
-
const levelOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ? LogLevel.WARN : LogLevel.INFO;
|
|
64
|
-
logger = new ConsoleLogger({
|
|
65
|
-
name: "Mastra",
|
|
66
|
-
level: levelOnEnv
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
this.#logger = logger;
|
|
71
|
-
let storage = config?.storage;
|
|
72
|
-
if (storage) {
|
|
73
|
-
storage = augmentWithInit(storage);
|
|
74
|
-
}
|
|
75
|
-
this.#telemetry = Telemetry.init(config?.telemetry);
|
|
76
|
-
if (this.#telemetry && storage) {
|
|
77
|
-
this.#storage = this.#telemetry.traceClass(storage, {
|
|
78
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry", "batchTraceInsert", "getTraces", "getEvalsByAgentName"]
|
|
79
|
-
});
|
|
80
|
-
this.#storage.__setTelemetry(this.#telemetry);
|
|
81
|
-
} else {
|
|
82
|
-
this.#storage = storage;
|
|
83
|
-
}
|
|
84
|
-
if (config?.vectors) {
|
|
85
|
-
let vectors = {};
|
|
86
|
-
Object.entries(config.vectors).forEach(([key, vector]) => {
|
|
87
|
-
if (this.#telemetry) {
|
|
88
|
-
vectors[key] = this.#telemetry.traceClass(vector, {
|
|
89
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
90
|
-
});
|
|
91
|
-
vectors[key].__setTelemetry(this.#telemetry);
|
|
92
|
-
} else {
|
|
93
|
-
vectors[key] = vector;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
this.#vectors = vectors;
|
|
97
|
-
}
|
|
98
|
-
if (config?.vectors) {
|
|
99
|
-
this.#vectors = config.vectors;
|
|
100
|
-
}
|
|
101
|
-
if (config?.networks) {
|
|
102
|
-
this.#networks = config.networks;
|
|
103
|
-
}
|
|
104
|
-
if (config?.vnext_networks) {
|
|
105
|
-
this.#vnext_networks = config.vnext_networks;
|
|
106
|
-
}
|
|
107
|
-
if (config?.mcpServers) {
|
|
108
|
-
this.#mcpServers = config.mcpServers;
|
|
109
|
-
Object.entries(this.#mcpServers).forEach(([key, server]) => {
|
|
110
|
-
server.setId(key);
|
|
111
|
-
if (this.#telemetry) {
|
|
112
|
-
server.__setTelemetry(this.#telemetry);
|
|
113
|
-
}
|
|
114
|
-
server.__registerMastra(this);
|
|
115
|
-
server.__setLogger(this.getLogger());
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
if (config && `memory` in config) {
|
|
119
|
-
const error = new MastraError({
|
|
120
|
-
id: "MASTRA_CONSTRUCTOR_INVALID_MEMORY_CONFIG",
|
|
121
|
-
domain: "MASTRA" /* MASTRA */,
|
|
122
|
-
category: "USER" /* USER */,
|
|
123
|
-
text: `
|
|
124
|
-
Memory should be added to Agents, not to Mastra.
|
|
125
|
-
|
|
126
|
-
Instead of:
|
|
127
|
-
new Mastra({ memory: new Memory() })
|
|
128
|
-
|
|
129
|
-
do:
|
|
130
|
-
new Agent({ memory: new Memory() })
|
|
131
|
-
`
|
|
132
|
-
});
|
|
133
|
-
this.#logger?.trackException(error);
|
|
134
|
-
throw error;
|
|
135
|
-
}
|
|
136
|
-
if (config?.tts) {
|
|
137
|
-
this.#tts = config.tts;
|
|
138
|
-
Object.entries(this.#tts).forEach(([key, ttsCl]) => {
|
|
139
|
-
if (this.#tts?.[key]) {
|
|
140
|
-
if (this.#telemetry) {
|
|
141
|
-
this.#tts[key] = this.#telemetry.traceClass(ttsCl, {
|
|
142
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
143
|
-
});
|
|
144
|
-
this.#tts[key].__setTelemetry(this.#telemetry);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
const agents = {};
|
|
150
|
-
if (config?.agents) {
|
|
151
|
-
Object.entries(config.agents).forEach(([key, agent]) => {
|
|
152
|
-
if (agents[key]) {
|
|
153
|
-
const error = new MastraError({
|
|
154
|
-
id: "MASTRA_AGENT_REGISTRATION_DUPLICATE_ID",
|
|
155
|
-
domain: "MASTRA" /* MASTRA */,
|
|
156
|
-
category: "USER" /* USER */,
|
|
157
|
-
text: `Agent with name ID:${key} already exists`,
|
|
158
|
-
details: {
|
|
159
|
-
agentId: key
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
this.#logger?.trackException(error);
|
|
163
|
-
throw error;
|
|
164
|
-
}
|
|
165
|
-
agent.__registerMastra(this);
|
|
166
|
-
agent.__registerPrimitives({
|
|
167
|
-
logger: this.getLogger(),
|
|
168
|
-
telemetry: this.#telemetry,
|
|
169
|
-
storage: this.storage,
|
|
170
|
-
memory: this.memory,
|
|
171
|
-
agents,
|
|
172
|
-
tts: this.#tts,
|
|
173
|
-
vectors: this.#vectors
|
|
174
|
-
});
|
|
175
|
-
agents[key] = agent;
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
this.#agents = agents;
|
|
179
|
-
this.#networks = {};
|
|
180
|
-
this.#vnext_networks = {};
|
|
181
|
-
if (config?.networks) {
|
|
182
|
-
Object.entries(config.networks).forEach(([key, network]) => {
|
|
183
|
-
network.__registerMastra(this);
|
|
184
|
-
this.#networks[key] = network;
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
if (config?.vnext_networks) {
|
|
188
|
-
Object.entries(config.vnext_networks).forEach(([key, network]) => {
|
|
189
|
-
network.__registerMastra(this);
|
|
190
|
-
this.#vnext_networks[key] = network;
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
this.#legacy_workflows = {};
|
|
194
|
-
if (config?.legacy_workflows) {
|
|
195
|
-
Object.entries(config.legacy_workflows).forEach(([key, workflow]) => {
|
|
196
|
-
workflow.__registerMastra(this);
|
|
197
|
-
workflow.__registerPrimitives({
|
|
198
|
-
logger: this.getLogger(),
|
|
199
|
-
telemetry: this.#telemetry,
|
|
200
|
-
storage: this.storage,
|
|
201
|
-
memory: this.memory,
|
|
202
|
-
agents,
|
|
203
|
-
tts: this.#tts,
|
|
204
|
-
vectors: this.#vectors
|
|
205
|
-
});
|
|
206
|
-
this.#legacy_workflows[key] = workflow;
|
|
207
|
-
const workflowSteps = Object.values(workflow.steps).filter(step => !!step.workflowId && !!step.workflow);
|
|
208
|
-
if (workflowSteps.length > 0) {
|
|
209
|
-
workflowSteps.forEach(step => {
|
|
210
|
-
this.#legacy_workflows[step.workflowId] = step.workflow;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
this.#workflows = {};
|
|
216
|
-
if (config?.workflows) {
|
|
217
|
-
Object.entries(config.workflows).forEach(([key, workflow]) => {
|
|
218
|
-
workflow.__registerMastra(this);
|
|
219
|
-
workflow.__registerPrimitives({
|
|
220
|
-
logger: this.getLogger(),
|
|
221
|
-
telemetry: this.#telemetry,
|
|
222
|
-
storage: this.storage,
|
|
223
|
-
memory: this.memory,
|
|
224
|
-
agents,
|
|
225
|
-
tts: this.#tts,
|
|
226
|
-
vectors: this.#vectors
|
|
227
|
-
});
|
|
228
|
-
this.#workflows[key] = workflow;
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
if (config?.server) {
|
|
232
|
-
this.#server = config.server;
|
|
233
|
-
}
|
|
234
|
-
this.setLogger({
|
|
235
|
-
logger
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
getAgent(name) {
|
|
239
|
-
const agent = this.#agents?.[name];
|
|
240
|
-
if (!agent) {
|
|
241
|
-
const error = new MastraError({
|
|
242
|
-
id: "MASTRA_GET_AGENT_BY_NAME_NOT_FOUND",
|
|
243
|
-
domain: "MASTRA" /* MASTRA */,
|
|
244
|
-
category: "USER" /* USER */,
|
|
245
|
-
text: `Agent with name ${String(name)} not found`,
|
|
246
|
-
details: {
|
|
247
|
-
status: 404,
|
|
248
|
-
agentName: String(name),
|
|
249
|
-
agents: Object.keys(this.#agents ?? {}).join(", ")
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
this.#logger?.trackException(error);
|
|
253
|
-
throw error;
|
|
254
|
-
}
|
|
255
|
-
return this.#agents[name];
|
|
256
|
-
}
|
|
257
|
-
getAgents() {
|
|
258
|
-
return this.#agents;
|
|
259
|
-
}
|
|
260
|
-
getVector(name) {
|
|
261
|
-
const vector = this.#vectors?.[name];
|
|
262
|
-
if (!vector) {
|
|
263
|
-
const error = new MastraError({
|
|
264
|
-
id: "MASTRA_GET_VECTOR_BY_NAME_NOT_FOUND",
|
|
265
|
-
domain: "MASTRA" /* MASTRA */,
|
|
266
|
-
category: "USER" /* USER */,
|
|
267
|
-
text: `Vector with name ${String(name)} not found`,
|
|
268
|
-
details: {
|
|
269
|
-
status: 404,
|
|
270
|
-
vectorName: String(name),
|
|
271
|
-
vectors: Object.keys(this.#vectors ?? {}).join(", ")
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
this.#logger?.trackException(error);
|
|
275
|
-
throw error;
|
|
276
|
-
}
|
|
277
|
-
return vector;
|
|
278
|
-
}
|
|
279
|
-
getVectors() {
|
|
280
|
-
return this.#vectors;
|
|
281
|
-
}
|
|
282
|
-
getDeployer() {
|
|
283
|
-
return this.#deployer;
|
|
284
|
-
}
|
|
285
|
-
legacy_getWorkflow(id, {
|
|
286
|
-
serialized
|
|
287
|
-
} = {}) {
|
|
288
|
-
const workflow = this.#legacy_workflows?.[id];
|
|
289
|
-
if (!workflow) {
|
|
290
|
-
const error = new MastraError({
|
|
291
|
-
id: "MASTRA_GET_LEGACY_WORKFLOW_BY_ID_NOT_FOUND",
|
|
292
|
-
domain: "MASTRA" /* MASTRA */,
|
|
293
|
-
category: "USER" /* USER */,
|
|
294
|
-
text: `Workflow with ID ${String(id)} not found`,
|
|
295
|
-
details: {
|
|
296
|
-
status: 404,
|
|
297
|
-
workflowId: String(id),
|
|
298
|
-
workflows: Object.keys(this.#legacy_workflows ?? {}).join(", ")
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
this.#logger?.trackException(error);
|
|
302
|
-
throw error;
|
|
303
|
-
}
|
|
304
|
-
if (serialized) {
|
|
305
|
-
return {
|
|
306
|
-
name: workflow.name
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
return workflow;
|
|
310
|
-
}
|
|
311
|
-
getWorkflow(id, {
|
|
312
|
-
serialized
|
|
313
|
-
} = {}) {
|
|
314
|
-
const workflow = this.#workflows?.[id];
|
|
315
|
-
if (!workflow) {
|
|
316
|
-
const error = new MastraError({
|
|
317
|
-
id: "MASTRA_GET_WORKFLOW_BY_ID_NOT_FOUND",
|
|
318
|
-
domain: "MASTRA" /* MASTRA */,
|
|
319
|
-
category: "USER" /* USER */,
|
|
320
|
-
text: `Workflow with ID ${String(id)} not found`,
|
|
321
|
-
details: {
|
|
322
|
-
status: 404,
|
|
323
|
-
workflowId: String(id),
|
|
324
|
-
workflows: Object.keys(this.#workflows ?? {}).join(", ")
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
this.#logger?.trackException(error);
|
|
328
|
-
throw error;
|
|
329
|
-
}
|
|
330
|
-
if (serialized) {
|
|
331
|
-
return {
|
|
332
|
-
name: workflow.name
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
return workflow;
|
|
336
|
-
}
|
|
337
|
-
legacy_getWorkflows(props = {}) {
|
|
338
|
-
if (props.serialized) {
|
|
339
|
-
return Object.entries(this.#legacy_workflows).reduce((acc, [k, v]) => {
|
|
340
|
-
return {
|
|
341
|
-
...acc,
|
|
342
|
-
[k]: {
|
|
343
|
-
name: v.name
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
}, {});
|
|
347
|
-
}
|
|
348
|
-
return this.#legacy_workflows;
|
|
349
|
-
}
|
|
350
|
-
getWorkflows(props = {}) {
|
|
351
|
-
if (props.serialized) {
|
|
352
|
-
return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
|
|
353
|
-
return {
|
|
354
|
-
...acc,
|
|
355
|
-
[k]: {
|
|
356
|
-
name: v.name
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
}, {});
|
|
360
|
-
}
|
|
361
|
-
return this.#workflows;
|
|
362
|
-
}
|
|
363
|
-
setStorage(storage) {
|
|
364
|
-
this.#storage = augmentWithInit(storage);
|
|
365
|
-
}
|
|
366
|
-
setLogger({
|
|
367
|
-
logger
|
|
368
|
-
}) {
|
|
369
|
-
this.#logger = logger;
|
|
370
|
-
if (this.#agents) {
|
|
371
|
-
Object.keys(this.#agents).forEach(key => {
|
|
372
|
-
this.#agents?.[key]?.__setLogger(this.#logger);
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
if (this.#memory) {
|
|
376
|
-
this.#memory.__setLogger(this.#logger);
|
|
377
|
-
}
|
|
378
|
-
if (this.#deployer) {
|
|
379
|
-
this.#deployer.__setLogger(this.#logger);
|
|
380
|
-
}
|
|
381
|
-
if (this.#tts) {
|
|
382
|
-
Object.keys(this.#tts).forEach(key => {
|
|
383
|
-
this.#tts?.[key]?.__setLogger(this.#logger);
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
if (this.#storage) {
|
|
387
|
-
this.#storage.__setLogger(this.#logger);
|
|
388
|
-
}
|
|
389
|
-
if (this.#vectors) {
|
|
390
|
-
Object.keys(this.#vectors).forEach(key => {
|
|
391
|
-
this.#vectors?.[key]?.__setLogger(this.#logger);
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
if (this.#mcpServers) {
|
|
395
|
-
Object.keys(this.#mcpServers).forEach(key => {
|
|
396
|
-
this.#mcpServers?.[key]?.__setLogger(this.#logger);
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
setTelemetry(telemetry) {
|
|
401
|
-
this.#telemetry = Telemetry.init(telemetry);
|
|
402
|
-
if (this.#agents) {
|
|
403
|
-
Object.keys(this.#agents).forEach(key => {
|
|
404
|
-
if (this.#telemetry) {
|
|
405
|
-
this.#agents?.[key]?.__setTelemetry(this.#telemetry);
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
if (this.#memory) {
|
|
410
|
-
this.#memory = this.#telemetry.traceClass(this.#memory, {
|
|
411
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
412
|
-
});
|
|
413
|
-
this.#memory.__setTelemetry(this.#telemetry);
|
|
414
|
-
}
|
|
415
|
-
if (this.#deployer) {
|
|
416
|
-
this.#deployer = this.#telemetry.traceClass(this.#deployer, {
|
|
417
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
418
|
-
});
|
|
419
|
-
this.#deployer.__setTelemetry(this.#telemetry);
|
|
420
|
-
}
|
|
421
|
-
if (this.#tts) {
|
|
422
|
-
let tts = {};
|
|
423
|
-
Object.entries(this.#tts).forEach(([key, ttsCl]) => {
|
|
424
|
-
if (this.#telemetry) {
|
|
425
|
-
tts[key] = this.#telemetry.traceClass(ttsCl, {
|
|
426
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
427
|
-
});
|
|
428
|
-
tts[key].__setTelemetry(this.#telemetry);
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
this.#tts = tts;
|
|
432
|
-
}
|
|
433
|
-
if (this.#storage) {
|
|
434
|
-
this.#storage = this.#telemetry.traceClass(this.#storage, {
|
|
435
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
436
|
-
});
|
|
437
|
-
this.#storage.__setTelemetry(this.#telemetry);
|
|
438
|
-
}
|
|
439
|
-
if (this.#vectors) {
|
|
440
|
-
let vectors = {};
|
|
441
|
-
Object.entries(this.#vectors).forEach(([key, vector]) => {
|
|
442
|
-
if (this.#telemetry) {
|
|
443
|
-
vectors[key] = this.#telemetry.traceClass(vector, {
|
|
444
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
445
|
-
});
|
|
446
|
-
vectors[key].__setTelemetry(this.#telemetry);
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
this.#vectors = vectors;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
getTTS() {
|
|
453
|
-
return this.#tts;
|
|
454
|
-
}
|
|
455
|
-
getLogger() {
|
|
456
|
-
return this.#logger;
|
|
457
|
-
}
|
|
458
|
-
getTelemetry() {
|
|
459
|
-
return this.#telemetry;
|
|
460
|
-
}
|
|
461
|
-
getMemory() {
|
|
462
|
-
return this.#memory;
|
|
463
|
-
}
|
|
464
|
-
getStorage() {
|
|
465
|
-
return this.#storage;
|
|
466
|
-
}
|
|
467
|
-
getServerMiddleware() {
|
|
468
|
-
return this.#serverMiddleware;
|
|
469
|
-
}
|
|
470
|
-
setServerMiddleware(serverMiddleware) {
|
|
471
|
-
if (typeof serverMiddleware === "function") {
|
|
472
|
-
this.#serverMiddleware = [{
|
|
473
|
-
handler: serverMiddleware,
|
|
474
|
-
path: "/api/*"
|
|
475
|
-
}];
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
if (!Array.isArray(serverMiddleware)) {
|
|
479
|
-
const error = new MastraError({
|
|
480
|
-
id: "MASTRA_SET_SERVER_MIDDLEWARE_INVALID_TYPE",
|
|
481
|
-
domain: "MASTRA" /* MASTRA */,
|
|
482
|
-
category: "USER" /* USER */,
|
|
483
|
-
text: `Invalid middleware: expected a function or array, received ${typeof serverMiddleware}`
|
|
484
|
-
});
|
|
485
|
-
this.#logger?.trackException(error);
|
|
486
|
-
throw error;
|
|
487
|
-
}
|
|
488
|
-
this.#serverMiddleware = serverMiddleware.map(m => {
|
|
489
|
-
if (typeof m === "function") {
|
|
490
|
-
return {
|
|
491
|
-
handler: m,
|
|
492
|
-
path: "/api/*"
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
return {
|
|
496
|
-
handler: m.handler,
|
|
497
|
-
path: m.path || "/api/*"
|
|
498
|
-
};
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
getNetworks() {
|
|
502
|
-
return Object.values(this.#networks || {});
|
|
503
|
-
}
|
|
504
|
-
vnext_getNetworks() {
|
|
505
|
-
return Object.values(this.#vnext_networks || {});
|
|
506
|
-
}
|
|
507
|
-
getServer() {
|
|
508
|
-
return this.#server;
|
|
509
|
-
}
|
|
510
|
-
getBundlerConfig() {
|
|
511
|
-
return this.#bundler;
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Get a specific network by ID
|
|
515
|
-
* @param networkId - The ID of the network to retrieve
|
|
516
|
-
* @returns The network with the specified ID, or undefined if not found
|
|
517
|
-
*/
|
|
518
|
-
getNetwork(networkId) {
|
|
519
|
-
const networks = this.getNetworks();
|
|
520
|
-
return networks.find(network => {
|
|
521
|
-
const routingAgent = network.getRoutingAgent();
|
|
522
|
-
return network.formatAgentId(routingAgent.name) === networkId;
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
vnext_getNetwork(networkId) {
|
|
526
|
-
const networks = this.vnext_getNetworks();
|
|
527
|
-
return networks.find(network => network.id === networkId);
|
|
528
|
-
}
|
|
529
|
-
async getLogsByRunId({
|
|
530
|
-
runId,
|
|
531
|
-
transportId,
|
|
532
|
-
fromDate,
|
|
533
|
-
toDate,
|
|
534
|
-
logLevel,
|
|
535
|
-
filters,
|
|
536
|
-
page,
|
|
537
|
-
perPage
|
|
538
|
-
}) {
|
|
539
|
-
if (!transportId) {
|
|
540
|
-
const error = new MastraError({
|
|
541
|
-
id: "MASTRA_GET_LOGS_BY_RUN_ID_MISSING_TRANSPORT",
|
|
542
|
-
domain: "MASTRA" /* MASTRA */,
|
|
543
|
-
category: "USER" /* USER */,
|
|
544
|
-
text: "Transport ID is required",
|
|
545
|
-
details: {
|
|
546
|
-
runId,
|
|
547
|
-
transportId
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
this.#logger?.trackException(error);
|
|
551
|
-
throw error;
|
|
552
|
-
}
|
|
553
|
-
if (!this.#logger?.getLogsByRunId) {
|
|
554
|
-
const error = new MastraError({
|
|
555
|
-
id: "MASTRA_GET_LOGS_BY_RUN_ID_LOGGER_NOT_CONFIGURED",
|
|
556
|
-
domain: "MASTRA" /* MASTRA */,
|
|
557
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
558
|
-
text: "Logger is not configured or does not support getLogsByRunId operation",
|
|
559
|
-
details: {
|
|
560
|
-
runId,
|
|
561
|
-
transportId
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
this.#logger?.trackException(error);
|
|
565
|
-
throw error;
|
|
566
|
-
}
|
|
567
|
-
return await this.#logger.getLogsByRunId({
|
|
568
|
-
runId,
|
|
569
|
-
transportId,
|
|
570
|
-
fromDate,
|
|
571
|
-
toDate,
|
|
572
|
-
logLevel,
|
|
573
|
-
filters,
|
|
574
|
-
page,
|
|
575
|
-
perPage
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
async getLogs(transportId, params) {
|
|
579
|
-
if (!transportId) {
|
|
580
|
-
const error = new MastraError({
|
|
581
|
-
id: "MASTRA_GET_LOGS_MISSING_TRANSPORT",
|
|
582
|
-
domain: "MASTRA" /* MASTRA */,
|
|
583
|
-
category: "USER" /* USER */,
|
|
584
|
-
text: "Transport ID is required",
|
|
585
|
-
details: {
|
|
586
|
-
transportId
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
this.#logger?.trackException(error);
|
|
590
|
-
throw error;
|
|
591
|
-
}
|
|
592
|
-
if (!this.#logger) {
|
|
593
|
-
const error = new MastraError({
|
|
594
|
-
id: "MASTRA_GET_LOGS_LOGGER_NOT_CONFIGURED",
|
|
595
|
-
domain: "MASTRA" /* MASTRA */,
|
|
596
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
597
|
-
text: "Logger is not set",
|
|
598
|
-
details: {
|
|
599
|
-
transportId
|
|
600
|
-
}
|
|
601
|
-
});
|
|
602
|
-
throw error;
|
|
603
|
-
}
|
|
604
|
-
return await this.#logger.getLogs(transportId, params);
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* Get all registered MCP server instances.
|
|
608
|
-
* @returns A record of MCP server ID to MCPServerBase instance, or undefined if none are registered.
|
|
609
|
-
*/
|
|
610
|
-
getMCPServers() {
|
|
611
|
-
return this.#mcpServers;
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Get a specific MCP server instance.
|
|
615
|
-
* If a version is provided, it attempts to find the server with that exact logical ID and version.
|
|
616
|
-
* If no version is provided, it returns the server with the specified logical ID that has the most recent releaseDate.
|
|
617
|
-
* The logical ID should match the `id` property of the MCPServer instance (typically set via MCPServerConfig.id).
|
|
618
|
-
* @param serverId - The logical ID of the MCP server to retrieve.
|
|
619
|
-
* @param version - Optional specific version of the MCP server to retrieve.
|
|
620
|
-
* @returns The MCP server instance, or undefined if not found or if the specific version is not found.
|
|
621
|
-
*/
|
|
622
|
-
getMCPServer(serverId, version) {
|
|
623
|
-
if (!this.#mcpServers) {
|
|
624
|
-
return void 0;
|
|
625
|
-
}
|
|
626
|
-
const allRegisteredServers = Object.values(this.#mcpServers || {});
|
|
627
|
-
const matchingLogicalIdServers = allRegisteredServers.filter(server => server.id === serverId);
|
|
628
|
-
if (matchingLogicalIdServers.length === 0) {
|
|
629
|
-
this.#logger?.debug(`No MCP servers found with logical ID: ${serverId}`);
|
|
630
|
-
return void 0;
|
|
631
|
-
}
|
|
632
|
-
if (version) {
|
|
633
|
-
const specificVersionServer = matchingLogicalIdServers.find(server => server.version === version);
|
|
634
|
-
if (!specificVersionServer) {
|
|
635
|
-
this.#logger?.debug(`MCP server with logical ID '${serverId}' found, but not version '${version}'.`);
|
|
636
|
-
}
|
|
637
|
-
return specificVersionServer;
|
|
638
|
-
} else {
|
|
639
|
-
if (matchingLogicalIdServers.length === 1) {
|
|
640
|
-
return matchingLogicalIdServers[0];
|
|
641
|
-
}
|
|
642
|
-
matchingLogicalIdServers.sort((a, b) => {
|
|
643
|
-
const dateAVal = a.releaseDate && typeof a.releaseDate === "string" ? new Date(a.releaseDate).getTime() : NaN;
|
|
644
|
-
const dateBVal = b.releaseDate && typeof b.releaseDate === "string" ? new Date(b.releaseDate).getTime() : NaN;
|
|
645
|
-
if (isNaN(dateAVal) && isNaN(dateBVal)) return 0;
|
|
646
|
-
if (isNaN(dateAVal)) return 1;
|
|
647
|
-
if (isNaN(dateBVal)) return -1;
|
|
648
|
-
return dateBVal - dateAVal;
|
|
649
|
-
});
|
|
650
|
-
if (matchingLogicalIdServers.length > 0) {
|
|
651
|
-
const latestServer = matchingLogicalIdServers[0];
|
|
652
|
-
if (latestServer && latestServer.releaseDate && typeof latestServer.releaseDate === "string" && !isNaN(new Date(latestServer.releaseDate).getTime())) {
|
|
653
|
-
return latestServer;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
this.#logger?.warn(`Could not determine the latest server for logical ID '${serverId}' due to invalid or missing release dates, or no servers left after filtering.`);
|
|
657
|
-
return void 0;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
};
|
|
661
|
-
Mastra = /*@__PURE__*/(_ => {
|
|
662
|
-
_init = __decoratorStart(null);
|
|
663
|
-
Mastra = __decorateElement(_init, 0, "Mastra", _Mastra_decorators, Mastra);
|
|
664
|
-
__runInitializers(_init, 1, Mastra);
|
|
665
|
-
return Mastra;
|
|
666
|
-
})();
|
|
667
|
-
|
|
668
|
-
export { Mastra };
|