@mastra/core 0.5.0-alpha.8 → 0.5.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 +3 -2100
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/{base-CTdONy0_.d.cts → base-CIPKleAU.d.cts} +103 -70
- package/dist/{base-DIn_km7X.d.ts → base-C_Oq53qk.d.ts} +103 -70
- package/dist/base.cjs +5 -140
- package/dist/bundler/index.cjs +5 -160
- package/dist/chunk-2W2GYEYQ.cjs +25 -0
- package/dist/chunk-3ASEZT7U.cjs +1586 -0
- package/dist/chunk-43Y7WG5W.cjs +335 -0
- package/dist/{chunk-HBHPTMAC.js → chunk-4Y74D74B.js} +46 -6
- package/dist/chunk-ENT7U27Y.cjs +37 -0
- package/dist/chunk-F5UYWPV4.cjs +14 -0
- package/dist/chunk-FL3GQXQ2.cjs +218 -0
- package/dist/chunk-FRQFWZDN.cjs +2 -0
- package/dist/chunk-GXQRMKSN.cjs +367 -0
- package/dist/chunk-HJPMYDWO.cjs +37 -0
- package/dist/chunk-IIWRJFLQ.cjs +51 -0
- package/dist/chunk-KFQ7Z3PO.cjs +347 -0
- package/dist/{chunk-SWDQYPJS.js → chunk-KP5UAFLN.js} +3 -2
- package/dist/chunk-KPKFLQFR.cjs +12 -0
- package/dist/{chunk-RRJB4TCC.js → chunk-MLFXOST6.js} +1 -1
- package/dist/{chunk-KBSR2LLT.js → chunk-OD7ZMKHY.js} +176 -63
- package/dist/chunk-OTFLHXHZ.cjs +65 -0
- package/dist/chunk-RWTSGWWL.cjs +81 -0
- package/dist/chunk-ST5RMVLG.cjs +87 -0
- package/dist/chunk-SYQ7NK2E.cjs +24 -0
- package/dist/chunk-UZNQG7QO.cjs +1868 -0
- package/dist/chunk-V5ORZPFW.cjs +38 -0
- package/dist/chunk-VA4P7QJT.cjs +443 -0
- package/dist/chunk-WB2HREXE.cjs +166 -0
- package/dist/chunk-WOMOGDGR.cjs +691 -0
- package/dist/chunk-XB2TJ7LX.cjs +408 -0
- package/dist/{chunk-QABMKXI3.js → chunk-XF2FMJYK.js} +1 -1
- package/dist/chunk-XLSROQ26.cjs +91 -0
- package/dist/chunk-YK3XJ52U.cjs +192 -0
- package/dist/{chunk-SF5GHHOQ.js → chunk-YPD6BQIM.js} +121 -93
- package/dist/deployer/index.cjs +5 -167
- package/dist/eval/index.cjs +9 -105
- package/dist/eval/index.d.cts +1 -1
- package/dist/eval/index.d.ts +1 -1
- package/dist/hooks/index.cjs +14 -83
- package/dist/index.cjs +253 -7470
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/dist/integration/index.cjs +9 -108
- package/dist/integration/index.d.cts +1 -1
- package/dist/integration/index.d.ts +1 -1
- package/dist/llm/index.d.cts +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/logger/index.cjs +33 -161
- package/dist/mastra/index.cjs +3 -1755
- package/dist/mastra/index.d.cts +1 -1
- package/dist/mastra/index.d.ts +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -2050
- package/dist/memory/index.d.cts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/relevance/index.cjs +10 -2161
- package/dist/relevance/index.d.cts +19 -2
- package/dist/relevance/index.d.ts +19 -2
- package/dist/relevance/index.js +1 -1
- package/dist/storage/index.cjs +29 -367
- package/dist/storage/index.d.cts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/libsql/index.cjs +9 -798
- package/dist/storage/libsql/index.d.cts +1 -1
- package/dist/storage/libsql/index.d.ts +1 -1
- package/dist/telemetry/index.cjs +21 -408
- package/dist/telemetry/index.d.cts +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/index.cjs +11 -22
- package/dist/tools/index.d.cts +3 -3
- package/dist/tools/index.d.ts +3 -3
- package/dist/tts/index.cjs +3 -328
- package/dist/utils.cjs +41 -309
- package/dist/utils.d.cts +10 -4
- package/dist/utils.d.ts +10 -4
- package/dist/utils.js +1 -1
- package/dist/vector/filter/index.cjs +7 -189
- package/dist/vector/index.cjs +5 -172
- package/dist/vector/libsql/index.cjs +9 -1047
- package/dist/voice/index.cjs +8 -306
- package/dist/workflows/index.cjs +65 -1925
- package/dist/workflows/index.d.cts +4 -3
- package/dist/workflows/index.d.ts +4 -3
- package/dist/workflows/index.js +1 -1
- package/package.json +27 -27
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVA4P7QJT_cjs = require('./chunk-VA4P7QJT.cjs');
|
|
4
|
+
var chunkXB2TJ7LX_cjs = require('./chunk-XB2TJ7LX.cjs');
|
|
5
|
+
var chunkWB2HREXE_cjs = require('./chunk-WB2HREXE.cjs');
|
|
6
|
+
var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
|
|
7
|
+
|
|
8
|
+
// src/mastra/index.ts
|
|
9
|
+
var _Mastra_decorators, _init;
|
|
10
|
+
_Mastra_decorators = [chunkXB2TJ7LX_cjs.InstrumentClass({
|
|
11
|
+
prefix: "mastra",
|
|
12
|
+
excludeMethods: ["getLogger", "getTelemetry"]
|
|
13
|
+
})];
|
|
14
|
+
exports.Mastra = class Mastra {
|
|
15
|
+
#vectors;
|
|
16
|
+
#agents;
|
|
17
|
+
#logger;
|
|
18
|
+
#workflows;
|
|
19
|
+
#tts;
|
|
20
|
+
#deployer;
|
|
21
|
+
#serverMiddleware = [];
|
|
22
|
+
#telemetry;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated use getStorage() instead
|
|
25
|
+
*/
|
|
26
|
+
storage;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated use getMemory() instead
|
|
29
|
+
*/
|
|
30
|
+
memory;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated use getTelemetry() instead
|
|
33
|
+
*/
|
|
34
|
+
get telemetry() {
|
|
35
|
+
return this.#telemetry;
|
|
36
|
+
}
|
|
37
|
+
constructor(config) {
|
|
38
|
+
if (config?.serverMiddleware) {
|
|
39
|
+
this.#serverMiddleware = config.serverMiddleware.map(m => ({
|
|
40
|
+
handler: m.handler,
|
|
41
|
+
path: m.path || "/api/*"
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
let logger;
|
|
45
|
+
if (config?.logger === false) {
|
|
46
|
+
logger = chunkWB2HREXE_cjs.noopLogger;
|
|
47
|
+
} else {
|
|
48
|
+
if (config?.logger) {
|
|
49
|
+
logger = config.logger;
|
|
50
|
+
} else {
|
|
51
|
+
const levleOnEnv = process.env.NODE_ENV === "production" ? chunkWB2HREXE_cjs.LogLevel.WARN : chunkWB2HREXE_cjs.LogLevel.INFO;
|
|
52
|
+
logger = chunkWB2HREXE_cjs.createLogger({
|
|
53
|
+
name: "Mastra",
|
|
54
|
+
level: levleOnEnv
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
this.#logger = logger;
|
|
59
|
+
let storage = config?.storage;
|
|
60
|
+
if (!storage) {
|
|
61
|
+
storage = new chunkVA4P7QJT_cjs.LibSQLStore({
|
|
62
|
+
config: {
|
|
63
|
+
url: process.env.MASTRA_DEFAULT_STORAGE_URL || `:memory:`
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (storage instanceof chunkVA4P7QJT_cjs.LibSQLStore && config?.telemetry?.export?.type !== "custom") {
|
|
68
|
+
const newTelemetry = {
|
|
69
|
+
...(config?.telemetry || {}),
|
|
70
|
+
export: {
|
|
71
|
+
type: "custom",
|
|
72
|
+
exporter: new chunkXB2TJ7LX_cjs.OTLPTraceExporter({
|
|
73
|
+
logger: this.getLogger(),
|
|
74
|
+
storage
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
this.#telemetry = chunkXB2TJ7LX_cjs.Telemetry.init(newTelemetry);
|
|
79
|
+
} else if (config?.telemetry) {
|
|
80
|
+
this.#telemetry = chunkXB2TJ7LX_cjs.Telemetry.init(config?.telemetry);
|
|
81
|
+
}
|
|
82
|
+
if (config?.deployer) {
|
|
83
|
+
this.#deployer = config.deployer;
|
|
84
|
+
if (this.#telemetry) {
|
|
85
|
+
this.#deployer = this.#telemetry.traceClass(config.deployer, {
|
|
86
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
87
|
+
});
|
|
88
|
+
this.#deployer.__setTelemetry(this.#telemetry);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (this.#telemetry) {
|
|
92
|
+
this.storage = this.#telemetry.traceClass(storage, {
|
|
93
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
94
|
+
});
|
|
95
|
+
this.storage.__setTelemetry(this.#telemetry);
|
|
96
|
+
} else {
|
|
97
|
+
this.storage = storage;
|
|
98
|
+
}
|
|
99
|
+
if (config?.vectors) {
|
|
100
|
+
let vectors = {};
|
|
101
|
+
Object.entries(config.vectors).forEach(([key, vector]) => {
|
|
102
|
+
if (this.#telemetry) {
|
|
103
|
+
vectors[key] = this.#telemetry.traceClass(vector, {
|
|
104
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
105
|
+
});
|
|
106
|
+
vectors[key].__setTelemetry(this.#telemetry);
|
|
107
|
+
} else {
|
|
108
|
+
vectors[key] = vector;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
this.#vectors = vectors;
|
|
112
|
+
}
|
|
113
|
+
if (config?.vectors) {
|
|
114
|
+
this.#vectors = config.vectors;
|
|
115
|
+
}
|
|
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
|
+
if (config && `memory` in config) {
|
|
126
|
+
this.#logger.warn(`
|
|
127
|
+
Memory should be added to Agents, not to Mastra.
|
|
128
|
+
|
|
129
|
+
Instead of:
|
|
130
|
+
new Mastra({ memory: new Memory() })
|
|
131
|
+
|
|
132
|
+
do:
|
|
133
|
+
new Agent({ memory: new Memory() })
|
|
134
|
+
|
|
135
|
+
This is a warning for now, but will throw an error in the future
|
|
136
|
+
`);
|
|
137
|
+
}
|
|
138
|
+
if (config?.tts) {
|
|
139
|
+
this.#tts = config.tts;
|
|
140
|
+
Object.entries(this.#tts).forEach(([key, ttsCl]) => {
|
|
141
|
+
if (this.#tts?.[key]) {
|
|
142
|
+
if (this.#telemetry) {
|
|
143
|
+
this.#tts[key] = this.#telemetry.traceClass(ttsCl, {
|
|
144
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
145
|
+
});
|
|
146
|
+
this.#tts[key].__setTelemetry(this.#telemetry);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const agents = {};
|
|
152
|
+
if (config?.agents) {
|
|
153
|
+
Object.entries(config.agents).forEach(([key, agent]) => {
|
|
154
|
+
if (agents[key]) {
|
|
155
|
+
throw new Error(`Agent with name ID:${key} already exists`);
|
|
156
|
+
}
|
|
157
|
+
agent.__registerPrimitives({
|
|
158
|
+
logger: this.getLogger(),
|
|
159
|
+
telemetry: this.#telemetry,
|
|
160
|
+
storage: this.storage,
|
|
161
|
+
memory: this.memory,
|
|
162
|
+
agents,
|
|
163
|
+
tts: this.#tts,
|
|
164
|
+
vectors: this.#vectors
|
|
165
|
+
});
|
|
166
|
+
agent.__registerMastra(this);
|
|
167
|
+
agents[key] = agent;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
this.#agents = agents;
|
|
171
|
+
this.#workflows = {};
|
|
172
|
+
if (config?.workflows) {
|
|
173
|
+
Object.entries(config.workflows).forEach(([key, workflow]) => {
|
|
174
|
+
workflow.__registerMastra(this);
|
|
175
|
+
workflow.__registerPrimitives({
|
|
176
|
+
logger: this.getLogger(),
|
|
177
|
+
telemetry: this.#telemetry,
|
|
178
|
+
storage: this.storage,
|
|
179
|
+
memory: this.memory,
|
|
180
|
+
agents,
|
|
181
|
+
tts: this.#tts,
|
|
182
|
+
vectors: this.#vectors
|
|
183
|
+
});
|
|
184
|
+
this.#workflows[key] = workflow;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
this.setLogger({
|
|
188
|
+
logger
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
getAgent(name) {
|
|
192
|
+
const agent = this.#agents?.[name];
|
|
193
|
+
if (!agent) {
|
|
194
|
+
throw new Error(`Agent with name ${String(name)} not found`);
|
|
195
|
+
}
|
|
196
|
+
return this.#agents[name];
|
|
197
|
+
}
|
|
198
|
+
getAgents() {
|
|
199
|
+
return this.#agents;
|
|
200
|
+
}
|
|
201
|
+
getVector(name) {
|
|
202
|
+
const vector = this.#vectors?.[name];
|
|
203
|
+
if (!vector) {
|
|
204
|
+
throw new Error(`Vector with name ${String(name)} not found`);
|
|
205
|
+
}
|
|
206
|
+
return vector;
|
|
207
|
+
}
|
|
208
|
+
getVectors() {
|
|
209
|
+
return this.#vectors;
|
|
210
|
+
}
|
|
211
|
+
getDeployer() {
|
|
212
|
+
return this.#deployer;
|
|
213
|
+
}
|
|
214
|
+
getWorkflow(id, {
|
|
215
|
+
serialized
|
|
216
|
+
} = {}) {
|
|
217
|
+
const workflow = this.#workflows?.[id];
|
|
218
|
+
if (!workflow) {
|
|
219
|
+
throw new Error(`Workflow with ID ${String(id)} not found`);
|
|
220
|
+
}
|
|
221
|
+
if (serialized) {
|
|
222
|
+
return {
|
|
223
|
+
name: workflow.name
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return workflow;
|
|
227
|
+
}
|
|
228
|
+
getWorkflows(props = {}) {
|
|
229
|
+
if (props.serialized) {
|
|
230
|
+
return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
|
|
231
|
+
return {
|
|
232
|
+
...acc,
|
|
233
|
+
[k]: {
|
|
234
|
+
name: v.name
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}, {});
|
|
238
|
+
}
|
|
239
|
+
return this.#workflows;
|
|
240
|
+
}
|
|
241
|
+
setStorage(storage) {
|
|
242
|
+
this.storage = storage;
|
|
243
|
+
}
|
|
244
|
+
setLogger({
|
|
245
|
+
logger
|
|
246
|
+
}) {
|
|
247
|
+
this.#logger = logger;
|
|
248
|
+
if (this.#agents) {
|
|
249
|
+
Object.keys(this.#agents).forEach(key => {
|
|
250
|
+
this.#agents?.[key]?.__setLogger(this.#logger);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
if (this.memory) {
|
|
254
|
+
this.memory.__setLogger(this.#logger);
|
|
255
|
+
}
|
|
256
|
+
if (this.#deployer) {
|
|
257
|
+
this.#deployer.__setLogger(this.#logger);
|
|
258
|
+
}
|
|
259
|
+
if (this.#tts) {
|
|
260
|
+
Object.keys(this.#tts).forEach(key => {
|
|
261
|
+
this.#tts?.[key]?.__setLogger(this.#logger);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
if (this.storage) {
|
|
265
|
+
this.storage.__setLogger(this.#logger);
|
|
266
|
+
}
|
|
267
|
+
if (this.#vectors) {
|
|
268
|
+
Object.keys(this.#vectors).forEach(key => {
|
|
269
|
+
this.#vectors?.[key]?.__setLogger(this.#logger);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
setTelemetry(telemetry) {
|
|
274
|
+
this.#telemetry = chunkXB2TJ7LX_cjs.Telemetry.init(telemetry);
|
|
275
|
+
if (this.#agents) {
|
|
276
|
+
Object.keys(this.#agents).forEach(key => {
|
|
277
|
+
if (this.#telemetry) {
|
|
278
|
+
this.#agents?.[key]?.__setTelemetry(this.#telemetry);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
if (this.memory) {
|
|
283
|
+
this.memory = this.#telemetry.traceClass(this.memory, {
|
|
284
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
285
|
+
});
|
|
286
|
+
this.memory.__setTelemetry(this.#telemetry);
|
|
287
|
+
}
|
|
288
|
+
if (this.#deployer) {
|
|
289
|
+
this.#deployer = this.#telemetry.traceClass(this.#deployer, {
|
|
290
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
291
|
+
});
|
|
292
|
+
this.#deployer.__setTelemetry(this.#telemetry);
|
|
293
|
+
}
|
|
294
|
+
if (this.#tts) {
|
|
295
|
+
let tts = {};
|
|
296
|
+
Object.entries(this.#tts).forEach(([key, ttsCl]) => {
|
|
297
|
+
if (this.#telemetry) {
|
|
298
|
+
tts[key] = this.#telemetry.traceClass(ttsCl, {
|
|
299
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
300
|
+
});
|
|
301
|
+
tts[key].__setTelemetry(this.#telemetry);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
this.#tts = tts;
|
|
305
|
+
}
|
|
306
|
+
if (this.storage) {
|
|
307
|
+
this.storage = this.#telemetry.traceClass(this.storage, {
|
|
308
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
309
|
+
});
|
|
310
|
+
this.storage.__setTelemetry(this.#telemetry);
|
|
311
|
+
}
|
|
312
|
+
if (this.#vectors) {
|
|
313
|
+
let vectors = {};
|
|
314
|
+
Object.entries(this.#vectors).forEach(([key, vector]) => {
|
|
315
|
+
if (this.#telemetry) {
|
|
316
|
+
vectors[key] = this.#telemetry.traceClass(vector, {
|
|
317
|
+
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
318
|
+
});
|
|
319
|
+
vectors[key].__setTelemetry(this.#telemetry);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
this.#vectors = vectors;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
getTTS() {
|
|
326
|
+
return this.#tts;
|
|
327
|
+
}
|
|
328
|
+
getLogger() {
|
|
329
|
+
return this.#logger;
|
|
330
|
+
}
|
|
331
|
+
getTelemetry() {
|
|
332
|
+
return this.#telemetry;
|
|
333
|
+
}
|
|
334
|
+
getMemory() {
|
|
335
|
+
return this.memory;
|
|
336
|
+
}
|
|
337
|
+
getStorage() {
|
|
338
|
+
return this.storage;
|
|
339
|
+
}
|
|
340
|
+
getServerMiddleware() {
|
|
341
|
+
return this.#serverMiddleware;
|
|
342
|
+
}
|
|
343
|
+
async getLogsByRunId({
|
|
344
|
+
runId,
|
|
345
|
+
transportId
|
|
346
|
+
}) {
|
|
347
|
+
if (!transportId) {
|
|
348
|
+
throw new Error("Transport ID is required");
|
|
349
|
+
}
|
|
350
|
+
return await this.#logger.getLogsByRunId({
|
|
351
|
+
runId,
|
|
352
|
+
transportId
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
async getLogs(transportId) {
|
|
356
|
+
if (!transportId) {
|
|
357
|
+
throw new Error("Transport ID is required");
|
|
358
|
+
}
|
|
359
|
+
return await this.#logger.getLogs(transportId);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
exports.Mastra = /*@__PURE__*/(_ => {
|
|
363
|
+
_init = chunkRWTSGWWL_cjs.__decoratorStart(null);
|
|
364
|
+
exports.Mastra = chunkRWTSGWWL_cjs.__decorateElement(_init, 0, "Mastra", _Mastra_decorators, exports.Mastra);
|
|
365
|
+
chunkRWTSGWWL_cjs.__runInitializers(_init, 1, exports.Mastra);
|
|
366
|
+
return exports.Mastra;
|
|
367
|
+
})();
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkXB2TJ7LX_cjs = require('./chunk-XB2TJ7LX.cjs');
|
|
4
|
+
var chunkIIWRJFLQ_cjs = require('./chunk-IIWRJFLQ.cjs');
|
|
5
|
+
var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
|
|
6
|
+
|
|
7
|
+
// src/tts/index.ts
|
|
8
|
+
var _MastraTTS_decorators, _init, _a;
|
|
9
|
+
_MastraTTS_decorators = [chunkXB2TJ7LX_cjs.InstrumentClass({
|
|
10
|
+
prefix: "tts",
|
|
11
|
+
excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
|
|
12
|
+
})];
|
|
13
|
+
exports.MastraTTS = class MastraTTS extends (_a = chunkIIWRJFLQ_cjs.MastraBase) {
|
|
14
|
+
model;
|
|
15
|
+
constructor({
|
|
16
|
+
model
|
|
17
|
+
}) {
|
|
18
|
+
super({
|
|
19
|
+
component: "TTS"
|
|
20
|
+
});
|
|
21
|
+
this.model = model;
|
|
22
|
+
}
|
|
23
|
+
traced(method, methodName) {
|
|
24
|
+
return this.telemetry?.traceMethod(method, {
|
|
25
|
+
spanName: `${this.model.name}-tts.${methodName}`,
|
|
26
|
+
attributes: {
|
|
27
|
+
"tts.type": `${this.model.name}`
|
|
28
|
+
}
|
|
29
|
+
}) ?? method;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.MastraTTS = /*@__PURE__*/(_ => {
|
|
33
|
+
_init = chunkRWTSGWWL_cjs.__decoratorStart(_a);
|
|
34
|
+
exports.MastraTTS = chunkRWTSGWWL_cjs.__decorateElement(_init, 0, "MastraTTS", _MastraTTS_decorators, exports.MastraTTS);
|
|
35
|
+
chunkRWTSGWWL_cjs.__runInitializers(_init, 1, exports.MastraTTS);
|
|
36
|
+
return exports.MastraTTS;
|
|
37
|
+
})();
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkWB2HREXE_cjs = require('./chunk-WB2HREXE.cjs');
|
|
4
|
+
|
|
5
|
+
// src/base.ts
|
|
6
|
+
var MastraBase = class {
|
|
7
|
+
component = chunkWB2HREXE_cjs.RegisteredLogger.LLM;
|
|
8
|
+
logger;
|
|
9
|
+
name;
|
|
10
|
+
telemetry;
|
|
11
|
+
constructor({ component, name }) {
|
|
12
|
+
this.component = component || chunkWB2HREXE_cjs.RegisteredLogger.LLM;
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.logger = chunkWB2HREXE_cjs.createLogger({ name: `${this.component} - ${this.name}` });
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Set the logger for the agent
|
|
18
|
+
* @param logger
|
|
19
|
+
*/
|
|
20
|
+
__setLogger(logger) {
|
|
21
|
+
this.logger = logger;
|
|
22
|
+
this.logger.debug(`Logger updated [component=${this.component}] [name=${this.name}]`);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Set the telemetry for the
|
|
26
|
+
* @param telemetry
|
|
27
|
+
*/
|
|
28
|
+
__setTelemetry(telemetry) {
|
|
29
|
+
this.telemetry = telemetry;
|
|
30
|
+
this.logger.debug(`Telemetry updated [component=${this.component}] [tracer=${this.telemetry.tracer}]`);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the telemetry on the vector
|
|
34
|
+
* @returns telemetry
|
|
35
|
+
*/
|
|
36
|
+
__getTelemetry() {
|
|
37
|
+
return this.telemetry;
|
|
38
|
+
}
|
|
39
|
+
/*
|
|
40
|
+
get experimental_telemetry config
|
|
41
|
+
*/
|
|
42
|
+
get experimental_telemetry() {
|
|
43
|
+
return this.telemetry ? {
|
|
44
|
+
// tracer: this.telemetry.tracer,
|
|
45
|
+
tracer: this.telemetry.getBaggageTracer(),
|
|
46
|
+
isEnabled: !!this.telemetry.tracer
|
|
47
|
+
} : void 0;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.MastraBase = MastraBase;
|