@mastra/core 0.9.4 → 0.10.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +13 -14
- package/dist/agent/index.d.ts +13 -14
- package/dist/agent/index.js +1 -1
- package/dist/{base-BCfssGt6.d.ts → base-DttB7sJD.d.ts} +1187 -886
- package/dist/{base-CAEcd6q2.d.cts → base-aJ3etsh5.d.cts} +1187 -886
- package/dist/{base-H7siSAfu.d.cts → base-aPYtPBT2.d.cts} +3 -3
- package/dist/{base-4Z34GQL8.d.ts → base-tc5kgDTD.d.ts} +3 -3
- package/dist/base.cjs +2 -2
- package/dist/base.d.cts +2 -3
- package/dist/base.d.ts +2 -3
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.cts +2 -3
- package/dist/bundler/index.d.ts +2 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-W4BSLENO.js → chunk-2NTUAUGH.js} +1 -1
- package/dist/{chunk-S34QVMKE.js → chunk-2PW6UJMW.js} +77 -10
- package/dist/{chunk-WE36CRQV.cjs → chunk-2U7ZZUFO.cjs} +2 -2
- package/dist/{workflows/vNext/index.js → chunk-3SQ3G2EJ.js} +19 -16
- package/dist/chunk-5HULBQ2W.cjs +38 -0
- package/dist/{chunk-XRGDVLM4.cjs → chunk-5JRD3NDP.cjs} +15 -15
- package/dist/{chunk-GXKODTLA.cjs → chunk-5W2G7S44.cjs} +83 -68
- package/dist/chunk-75Z4BZEE.js +36 -0
- package/dist/{chunk-66GQROSI.cjs → chunk-AOGUTJUO.cjs} +58 -51
- package/dist/{chunk-WIKOYZ63.js → chunk-BPTSLJHA.js} +9 -9
- package/dist/{chunk-JBJ7KXN5.js → chunk-C3ICEF6E.js} +1 -1
- package/dist/{chunk-E4FAXBUV.cjs → chunk-CWSFP2HS.cjs} +2 -2
- package/dist/{chunk-FW5RS6WV.js → chunk-E7CLY6SK.js} +42 -35
- package/dist/{chunk-235X76GC.js → chunk-FI7R232B.js} +2 -2
- package/dist/chunk-GQ2XQ4UN.js +321 -0
- package/dist/{chunk-H4CEZSRM.js → chunk-J7GDGV6F.js} +1 -1
- package/dist/{chunk-NLBJOFNG.js → chunk-JW5TMK2L.js} +1 -1
- package/dist/{chunk-NOPY74PV.js → chunk-KJQFFEEQ.js} +1 -1
- package/dist/{chunk-V2Q2FEVO.cjs → chunk-KSPHQSZX.cjs} +2 -2
- package/dist/{chunk-NZV4OA6P.js → chunk-LHRZV5VG.js} +2 -23
- package/dist/chunk-NMDM4IZN.cjs +78 -0
- package/dist/chunk-OBEALYTK.js +74 -0
- package/dist/{chunk-PEK4TY3P.js → chunk-OCT2762Q.js} +1 -1
- package/dist/{chunk-5DUFC7TV.cjs → chunk-P7BGXOQV.cjs} +2 -2
- package/dist/{chunk-WQKOM7XM.cjs → chunk-PIZM25KI.cjs} +3 -24
- package/dist/{chunk-S7J63JOG.cjs → chunk-RVS6OUJN.cjs} +2 -2
- package/dist/{chunk-5JUWUTPJ.cjs → chunk-SKG2NIZW.cjs} +2 -2
- package/dist/chunk-SWW4EBUZ.cjs +96 -0
- package/dist/{chunk-RGE4UF6A.cjs → chunk-TMPFLJLG.cjs} +2 -2
- package/dist/{workflows/vNext/index.cjs → chunk-TTKQ37ZZ.cjs} +24 -21
- package/dist/{chunk-EJITEVAB.cjs → chunk-U3L3NEOM.cjs} +81 -10
- package/dist/chunk-VHLL4AZK.js +90 -0
- package/dist/{chunk-EG74VBSP.cjs → chunk-YEULQPUY.cjs} +6 -6
- package/dist/{chunk-SOLXHDNQ.js → chunk-ZB3LEHL2.js} +81 -66
- package/dist/{chunk-TAFOICHR.js → chunk-ZKN6HYYQ.js} +1 -1
- package/dist/chunk-ZZDAC5KD.cjs +325 -0
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.d.cts +2 -3
- package/dist/deployer/index.d.ts +2 -3
- package/dist/deployer/index.js +1 -1
- package/dist/eval/index.d.cts +13 -14
- package/dist/eval/index.d.ts +13 -14
- package/dist/hooks/index.d.cts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.cjs +88 -159
- package/dist/index.d.cts +17 -25
- package/dist/index.d.ts +17 -25
- package/dist/index.js +18 -25
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.d.cts +12 -13
- package/dist/integration/index.d.ts +12 -13
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.d.cts +13 -14
- package/dist/llm/index.d.ts +13 -14
- package/dist/logger/index.cjs +18 -17
- package/dist/logger/index.d.cts +42 -2
- package/dist/logger/index.d.ts +42 -2
- package/dist/logger/index.js +2 -1
- package/dist/{index-QV27jkxQ.d.ts → logger-EhZkzZOr.d.cts} +38 -52
- package/dist/{index-QV27jkxQ.d.cts → logger-EhZkzZOr.d.ts} +38 -52
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +11 -12
- package/dist/mastra/index.d.ts +11 -12
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +75 -17
- package/dist/mcp/index.d.cts +14 -15
- package/dist/mcp/index.d.ts +14 -15
- package/dist/mcp/index.js +69 -15
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.d.cts +12 -13
- package/dist/memory/index.d.ts +12 -13
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +8 -8
- package/dist/network/index.d.cts +12 -13
- package/dist/network/index.d.ts +12 -13
- package/dist/network/index.js +5 -5
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +15 -16
- package/dist/relevance/index.d.ts +15 -16
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +4 -0
- package/dist/server/index.d.cts +13 -12
- package/dist/server/index.d.ts +13 -12
- package/dist/server/index.js +4 -1
- package/dist/storage/index.cjs +184 -3
- package/dist/storage/index.d.cts +83 -13
- package/dist/storage/index.d.ts +83 -13
- package/dist/storage/index.js +186 -1
- package/dist/telemetry/index.d.cts +14 -15
- package/dist/telemetry/index.d.ts +14 -15
- package/dist/telemetry/otel-vendor.cjs +2 -2
- package/dist/telemetry/otel-vendor.d.cts +1 -1
- package/dist/telemetry/otel-vendor.d.ts +1 -1
- package/dist/telemetry/otel-vendor.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.cts +12 -13
- package/dist/tools/index.d.ts +12 -13
- package/dist/tools/index.js +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.d.cts +2 -3
- package/dist/tts/index.d.ts +2 -3
- package/dist/tts/index.js +1 -1
- package/dist/{types-BtMyV38I.d.ts → types-Bo1uigWx.d.cts} +1 -1
- package/dist/{types-BtMyV38I.d.cts → types-Bo1uigWx.d.ts} +1 -1
- package/dist/utils.cjs +28 -12
- package/dist/utils.d.cts +59 -16
- package/dist/utils.d.ts +59 -16
- package/dist/utils.js +1 -1
- package/dist/vector/filter/index.cjs +189 -7
- package/dist/vector/filter/index.js +190 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.d.cts +28 -20
- package/dist/vector/index.d.ts +28 -20
- package/dist/vector/index.js +1 -1
- package/dist/voice/index.cjs +4 -4
- package/dist/voice/index.d.cts +12 -13
- package/dist/voice/index.d.ts +12 -13
- package/dist/voice/index.js +1 -1
- package/dist/workflows/index.cjs +17 -69
- package/dist/workflows/index.d.cts +197 -77
- package/dist/workflows/index.d.ts +197 -77
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +90 -0
- package/dist/workflows/legacy/index.d.cts +87 -0
- package/dist/workflows/legacy/index.d.ts +87 -0
- package/dist/workflows/legacy/index.js +1 -0
- package/package.json +19 -40
- package/workflows/legacy.d.ts +1 -0
- package/dist/chunk-4WABQORE.js +0 -781
- package/dist/chunk-CIEPFV6B.js +0 -658
- package/dist/chunk-CMPPXW4U.js +0 -154
- package/dist/chunk-CTKNWYK2.js +0 -131
- package/dist/chunk-LGERQTJM.js +0 -190
- package/dist/chunk-O44MSFMZ.cjs +0 -168
- package/dist/chunk-QDAMIZY3.cjs +0 -783
- package/dist/chunk-QHDPLMHB.cjs +0 -667
- package/dist/chunk-RAQBTCIR.cjs +0 -134
- package/dist/chunk-YK3XJ52U.cjs +0 -192
- package/dist/storage/libsql/index.cjs +0 -581
- package/dist/storage/libsql/index.d.cts +0 -104
- package/dist/storage/libsql/index.d.ts +0 -104
- package/dist/storage/libsql/index.js +0 -578
- package/dist/vector/libsql/index.cjs +0 -14
- package/dist/vector/libsql/index.d.cts +0 -82
- package/dist/vector/libsql/index.d.ts +0 -82
- package/dist/vector/libsql/index.js +0 -1
- package/dist/workflows/vNext/index.d.cts +0 -209
- package/dist/workflows/vNext/index.d.ts +0 -209
- package/storage/libsql.d.ts +0 -1
- package/vector/libsql.d.ts +0 -1
- package/workflows/vNext.d.ts +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk5HULBQ2W_cjs = require('./chunk-5HULBQ2W.cjs');
|
|
4
4
|
var chunkUVRGQEMD_cjs = require('./chunk-UVRGQEMD.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkNMDM4IZN_cjs = require('./chunk-NMDM4IZN.cjs');
|
|
6
|
+
var chunkSWW4EBUZ_cjs = require('./chunk-SWW4EBUZ.cjs');
|
|
6
7
|
var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
|
|
7
8
|
|
|
8
9
|
// src/mastra/index.ts
|
|
@@ -15,8 +16,8 @@ exports.Mastra = class Mastra {
|
|
|
15
16
|
#vectors;
|
|
16
17
|
#agents;
|
|
17
18
|
#logger;
|
|
19
|
+
#legacy_workflows;
|
|
18
20
|
#workflows;
|
|
19
|
-
#vnext_workflows;
|
|
20
21
|
#tts;
|
|
21
22
|
#deployer;
|
|
22
23
|
#serverMiddleware = [];
|
|
@@ -53,32 +54,27 @@ exports.Mastra = class Mastra {
|
|
|
53
54
|
}
|
|
54
55
|
let logger;
|
|
55
56
|
if (config?.logger === false) {
|
|
56
|
-
logger =
|
|
57
|
+
logger = chunkNMDM4IZN_cjs.noopLogger;
|
|
57
58
|
} else {
|
|
58
59
|
if (config?.logger) {
|
|
59
60
|
logger = config.logger;
|
|
60
61
|
} else {
|
|
61
|
-
const
|
|
62
|
-
logger =
|
|
62
|
+
const levelOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ? chunkSWW4EBUZ_cjs.LogLevel.WARN : chunkSWW4EBUZ_cjs.LogLevel.INFO;
|
|
63
|
+
logger = new chunkSWW4EBUZ_cjs.ConsoleLogger({
|
|
63
64
|
name: "Mastra",
|
|
64
|
-
level:
|
|
65
|
+
level: levelOnEnv
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
this.#logger = logger;
|
|
69
70
|
let storage = config?.storage;
|
|
70
|
-
if (
|
|
71
|
-
storage =
|
|
72
|
-
config: {
|
|
73
|
-
url: process.env.MASTRA_DEFAULT_STORAGE_URL || `:memory:`
|
|
74
|
-
}
|
|
75
|
-
});
|
|
71
|
+
if (storage) {
|
|
72
|
+
storage = chunk5HULBQ2W_cjs.augmentWithInit(storage);
|
|
76
73
|
}
|
|
77
|
-
storage = chunkRAQBTCIR_cjs.augmentWithInit(storage);
|
|
78
74
|
this.#telemetry = chunkUVRGQEMD_cjs.Telemetry.init(config?.telemetry);
|
|
79
|
-
if (this.#telemetry) {
|
|
75
|
+
if (this.#telemetry && storage) {
|
|
80
76
|
this.#storage = this.#telemetry.traceClass(storage, {
|
|
81
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry", "batchTraceInsert"]
|
|
77
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry", "batchTraceInsert", "getTraces", "getEvalsByAgentName"]
|
|
82
78
|
});
|
|
83
79
|
this.#storage.__setTelemetry(this.#telemetry);
|
|
84
80
|
} else {
|
|
@@ -106,24 +102,16 @@ exports.Mastra = class Mastra {
|
|
|
106
102
|
}
|
|
107
103
|
if (config?.mcpServers) {
|
|
108
104
|
this.#mcpServers = config.mcpServers;
|
|
109
|
-
Object.
|
|
105
|
+
Object.entries(this.#mcpServers).forEach(([key, server]) => {
|
|
106
|
+
server.setId(key);
|
|
110
107
|
if (this.#telemetry) {
|
|
111
108
|
server.__setTelemetry(this.#telemetry);
|
|
112
109
|
}
|
|
113
110
|
server.__registerMastra(this);
|
|
114
111
|
});
|
|
115
112
|
}
|
|
116
|
-
if (config?.memory) {
|
|
117
|
-
this.#memory = config.memory;
|
|
118
|
-
if (this.#telemetry) {
|
|
119
|
-
this.#memory = this.#telemetry.traceClass(config.memory, {
|
|
120
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
121
|
-
});
|
|
122
|
-
this.#memory.__setTelemetry(this.#telemetry);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
113
|
if (config && `memory` in config) {
|
|
126
|
-
|
|
114
|
+
throw new Error(`
|
|
127
115
|
Memory should be added to Agents, not to Mastra.
|
|
128
116
|
|
|
129
117
|
Instead of:
|
|
@@ -131,8 +119,6 @@ Instead of:
|
|
|
131
119
|
|
|
132
120
|
do:
|
|
133
121
|
new Agent({ memory: new Memory() })
|
|
134
|
-
|
|
135
|
-
This is a warning for now, but will throw an error in the future
|
|
136
122
|
`);
|
|
137
123
|
}
|
|
138
124
|
if (config?.tts) {
|
|
@@ -175,9 +161,9 @@ This is a warning for now, but will throw an error in the future
|
|
|
175
161
|
this.#networks[key] = network;
|
|
176
162
|
});
|
|
177
163
|
}
|
|
178
|
-
this.#
|
|
179
|
-
if (config?.
|
|
180
|
-
Object.entries(config.
|
|
164
|
+
this.#legacy_workflows = {};
|
|
165
|
+
if (config?.legacy_workflows) {
|
|
166
|
+
Object.entries(config.legacy_workflows).forEach(([key, workflow]) => {
|
|
181
167
|
workflow.__registerMastra(this);
|
|
182
168
|
workflow.__registerPrimitives({
|
|
183
169
|
logger: this.getLogger(),
|
|
@@ -188,18 +174,18 @@ This is a warning for now, but will throw an error in the future
|
|
|
188
174
|
tts: this.#tts,
|
|
189
175
|
vectors: this.#vectors
|
|
190
176
|
});
|
|
191
|
-
this.#
|
|
177
|
+
this.#legacy_workflows[key] = workflow;
|
|
192
178
|
const workflowSteps = Object.values(workflow.steps).filter(step => !!step.workflowId && !!step.workflow);
|
|
193
179
|
if (workflowSteps.length > 0) {
|
|
194
180
|
workflowSteps.forEach(step => {
|
|
195
|
-
this.#
|
|
181
|
+
this.#legacy_workflows[step.workflowId] = step.workflow;
|
|
196
182
|
});
|
|
197
183
|
}
|
|
198
184
|
});
|
|
199
185
|
}
|
|
200
|
-
this.#
|
|
201
|
-
if (config?.
|
|
202
|
-
Object.entries(config.
|
|
186
|
+
this.#workflows = {};
|
|
187
|
+
if (config?.workflows) {
|
|
188
|
+
Object.entries(config.workflows).forEach(([key, workflow]) => {
|
|
203
189
|
workflow.__registerMastra(this);
|
|
204
190
|
workflow.__registerPrimitives({
|
|
205
191
|
logger: this.getLogger(),
|
|
@@ -210,7 +196,7 @@ This is a warning for now, but will throw an error in the future
|
|
|
210
196
|
tts: this.#tts,
|
|
211
197
|
vectors: this.#vectors
|
|
212
198
|
});
|
|
213
|
-
this.#
|
|
199
|
+
this.#workflows[key] = workflow;
|
|
214
200
|
});
|
|
215
201
|
}
|
|
216
202
|
if (config?.server) {
|
|
@@ -243,10 +229,10 @@ This is a warning for now, but will throw an error in the future
|
|
|
243
229
|
getDeployer() {
|
|
244
230
|
return this.#deployer;
|
|
245
231
|
}
|
|
246
|
-
|
|
232
|
+
legacy_getWorkflow(id, {
|
|
247
233
|
serialized
|
|
248
234
|
} = {}) {
|
|
249
|
-
const workflow = this.#
|
|
235
|
+
const workflow = this.#legacy_workflows?.[id];
|
|
250
236
|
if (!workflow) {
|
|
251
237
|
throw new Error(`Workflow with ID ${String(id)} not found`);
|
|
252
238
|
}
|
|
@@ -257,10 +243,10 @@ This is a warning for now, but will throw an error in the future
|
|
|
257
243
|
}
|
|
258
244
|
return workflow;
|
|
259
245
|
}
|
|
260
|
-
|
|
246
|
+
getWorkflow(id, {
|
|
261
247
|
serialized
|
|
262
248
|
} = {}) {
|
|
263
|
-
const workflow = this.#
|
|
249
|
+
const workflow = this.#workflows?.[id];
|
|
264
250
|
if (!workflow) {
|
|
265
251
|
throw new Error(`Workflow with ID ${String(id)} not found`);
|
|
266
252
|
}
|
|
@@ -271,9 +257,9 @@ This is a warning for now, but will throw an error in the future
|
|
|
271
257
|
}
|
|
272
258
|
return workflow;
|
|
273
259
|
}
|
|
274
|
-
|
|
260
|
+
legacy_getWorkflows(props = {}) {
|
|
275
261
|
if (props.serialized) {
|
|
276
|
-
return Object.entries(this.#
|
|
262
|
+
return Object.entries(this.#legacy_workflows).reduce((acc, [k, v]) => {
|
|
277
263
|
return {
|
|
278
264
|
...acc,
|
|
279
265
|
[k]: {
|
|
@@ -282,11 +268,11 @@ This is a warning for now, but will throw an error in the future
|
|
|
282
268
|
};
|
|
283
269
|
}, {});
|
|
284
270
|
}
|
|
285
|
-
return this.#
|
|
271
|
+
return this.#legacy_workflows;
|
|
286
272
|
}
|
|
287
|
-
|
|
273
|
+
getWorkflows(props = {}) {
|
|
288
274
|
if (props.serialized) {
|
|
289
|
-
return Object.entries(this.#
|
|
275
|
+
return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
|
|
290
276
|
return {
|
|
291
277
|
...acc,
|
|
292
278
|
[k]: {
|
|
@@ -295,20 +281,10 @@ This is a warning for now, but will throw an error in the future
|
|
|
295
281
|
};
|
|
296
282
|
}, {});
|
|
297
283
|
}
|
|
298
|
-
return this.#
|
|
284
|
+
return this.#workflows;
|
|
299
285
|
}
|
|
300
286
|
setStorage(storage) {
|
|
301
|
-
|
|
302
|
-
this.#logger.warn(`Importing "DefaultStorage" from '@mastra/core/storage/libsql' is deprecated.
|
|
303
|
-
|
|
304
|
-
Instead of:
|
|
305
|
-
import { DefaultStorage } from '@mastra/core/storage/libsql';
|
|
306
|
-
|
|
307
|
-
Do:
|
|
308
|
-
import { LibSQLStore } from '@mastra/libsql';
|
|
309
|
-
`);
|
|
310
|
-
}
|
|
311
|
-
this.#storage = chunkRAQBTCIR_cjs.augmentWithInit(storage);
|
|
287
|
+
this.#storage = chunk5HULBQ2W_cjs.augmentWithInit(storage);
|
|
312
288
|
}
|
|
313
289
|
setLogger({
|
|
314
290
|
logger
|
|
@@ -458,19 +434,58 @@ Do:
|
|
|
458
434
|
return await this.#logger.getLogs(transportId);
|
|
459
435
|
}
|
|
460
436
|
/**
|
|
461
|
-
* Get
|
|
462
|
-
* @
|
|
463
|
-
* @returns The MCP server with the specified ID, or undefined if not found
|
|
437
|
+
* Get all registered MCP server instances.
|
|
438
|
+
* @returns A record of MCP server ID to MCPServerBase instance, or undefined if none are registered.
|
|
464
439
|
*/
|
|
465
|
-
|
|
466
|
-
return this.#mcpServers
|
|
440
|
+
getMCPServers() {
|
|
441
|
+
return this.#mcpServers;
|
|
467
442
|
}
|
|
468
443
|
/**
|
|
469
|
-
* Get
|
|
470
|
-
*
|
|
444
|
+
* Get a specific MCP server instance.
|
|
445
|
+
* If a version is provided, it attempts to find the server with that exact logical ID and version.
|
|
446
|
+
* If no version is provided, it returns the server with the specified logical ID that has the most recent releaseDate.
|
|
447
|
+
* The logical ID should match the `id` property of the MCPServer instance (typically set via MCPServerConfig.id).
|
|
448
|
+
* @param serverId - The logical ID of the MCP server to retrieve.
|
|
449
|
+
* @param version - Optional specific version of the MCP server to retrieve.
|
|
450
|
+
* @returns The MCP server instance, or undefined if not found or if the specific version is not found.
|
|
471
451
|
*/
|
|
472
|
-
|
|
473
|
-
|
|
452
|
+
getMCPServer(serverId, version) {
|
|
453
|
+
if (!this.#mcpServers) {
|
|
454
|
+
return void 0;
|
|
455
|
+
}
|
|
456
|
+
const allRegisteredServers = Object.values(this.#mcpServers || {});
|
|
457
|
+
const matchingLogicalIdServers = allRegisteredServers.filter(server => server.id === serverId);
|
|
458
|
+
if (matchingLogicalIdServers.length === 0) {
|
|
459
|
+
this.#logger?.debug(`No MCP servers found with logical ID: ${serverId}`);
|
|
460
|
+
return void 0;
|
|
461
|
+
}
|
|
462
|
+
if (version) {
|
|
463
|
+
const specificVersionServer = matchingLogicalIdServers.find(server => server.version === version);
|
|
464
|
+
if (!specificVersionServer) {
|
|
465
|
+
this.#logger?.debug(`MCP server with logical ID '${serverId}' found, but not version '${version}'.`);
|
|
466
|
+
}
|
|
467
|
+
return specificVersionServer;
|
|
468
|
+
} else {
|
|
469
|
+
if (matchingLogicalIdServers.length === 1) {
|
|
470
|
+
return matchingLogicalIdServers[0];
|
|
471
|
+
}
|
|
472
|
+
matchingLogicalIdServers.sort((a, b) => {
|
|
473
|
+
const dateAVal = a.releaseDate && typeof a.releaseDate === "string" ? new Date(a.releaseDate).getTime() : NaN;
|
|
474
|
+
const dateBVal = b.releaseDate && typeof b.releaseDate === "string" ? new Date(b.releaseDate).getTime() : NaN;
|
|
475
|
+
if (isNaN(dateAVal) && isNaN(dateBVal)) return 0;
|
|
476
|
+
if (isNaN(dateAVal)) return 1;
|
|
477
|
+
if (isNaN(dateBVal)) return -1;
|
|
478
|
+
return dateBVal - dateAVal;
|
|
479
|
+
});
|
|
480
|
+
if (matchingLogicalIdServers.length > 0) {
|
|
481
|
+
const latestServer = matchingLogicalIdServers[0];
|
|
482
|
+
if (latestServer && latestServer.releaseDate && typeof latestServer.releaseDate === "string" && !isNaN(new Date(latestServer.releaseDate).getTime())) {
|
|
483
|
+
return latestServer;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
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.`);
|
|
487
|
+
return void 0;
|
|
488
|
+
}
|
|
474
489
|
}
|
|
475
490
|
};
|
|
476
491
|
exports.Mastra = /*@__PURE__*/(_ => {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/storage/storageWithInit.ts
|
|
2
|
+
var isAugmentedSymbol = Symbol("isAugmented");
|
|
3
|
+
function augmentWithInit(storage) {
|
|
4
|
+
let hasInitialized = null;
|
|
5
|
+
const ensureInit = async () => {
|
|
6
|
+
if (!hasInitialized) {
|
|
7
|
+
hasInitialized = storage.init();
|
|
8
|
+
}
|
|
9
|
+
await hasInitialized;
|
|
10
|
+
};
|
|
11
|
+
if (storage[isAugmentedSymbol]) {
|
|
12
|
+
return storage;
|
|
13
|
+
}
|
|
14
|
+
const proxy = new Proxy(storage, {
|
|
15
|
+
get(target, prop) {
|
|
16
|
+
const value = target[prop];
|
|
17
|
+
if (typeof value === "function" && prop !== "init") {
|
|
18
|
+
return async (...args) => {
|
|
19
|
+
await ensureInit();
|
|
20
|
+
return Reflect.apply(value, target, args);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return Reflect.get(target, prop);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(proxy, isAugmentedSymbol, {
|
|
27
|
+
value: true,
|
|
28
|
+
enumerable: false,
|
|
29
|
+
// Won't show up in Object.keys() or for...in loops
|
|
30
|
+
configurable: true
|
|
31
|
+
// Allows the property to be deleted or modified later if needed
|
|
32
|
+
});
|
|
33
|
+
return proxy;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { augmentWithInit };
|