@mastra/core 0.0.0-commonjs-20250227130920

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.
Files changed (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +180 -0
  3. package/dist/agent/index.cjs +1865 -0
  4. package/dist/agent/index.d.cts +15 -0
  5. package/dist/agent/index.d.ts +15 -0
  6. package/dist/agent/index.js +1 -0
  7. package/dist/base-D90KQ4XI.d.ts +139 -0
  8. package/dist/base-hs9NDAZ2.d.cts +139 -0
  9. package/dist/base-nKCMCNrM.d.ts +920 -0
  10. package/dist/base-nhesrHv3.d.cts +920 -0
  11. package/dist/base.cjs +138 -0
  12. package/dist/base.d.cts +6 -0
  13. package/dist/base.d.ts +6 -0
  14. package/dist/base.js +1 -0
  15. package/dist/bundler/index.cjs +158 -0
  16. package/dist/bundler/index.d.cts +28 -0
  17. package/dist/bundler/index.d.ts +28 -0
  18. package/dist/bundler/index.js +1 -0
  19. package/dist/chunk-33GSTUNK.js +620 -0
  20. package/dist/chunk-4YRYBCOZ.js +10 -0
  21. package/dist/chunk-55NFNRKO.js +10 -0
  22. package/dist/chunk-5XPCMNGW.js +215 -0
  23. package/dist/chunk-B3M27AMP.js +1479 -0
  24. package/dist/chunk-BB4KXGBU.js +83 -0
  25. package/dist/chunk-C6A6W6XS.js +77 -0
  26. package/dist/chunk-HQ55LN2U.js +318 -0
  27. package/dist/chunk-KNVTCZW7.js +416 -0
  28. package/dist/chunk-LH47WVJL.js +61 -0
  29. package/dist/chunk-NGD2HQYW.js +346 -0
  30. package/dist/chunk-NUDAZEOG.js +35 -0
  31. package/dist/chunk-OZ4XVJ6F.js +49 -0
  32. package/dist/chunk-PHMSPCTC.js +145 -0
  33. package/dist/chunk-PNZK456O.js +88 -0
  34. package/dist/chunk-QAAJAHDB.js +37 -0
  35. package/dist/chunk-RG66XEJT.js +8 -0
  36. package/dist/chunk-SIFBBGY6.js +190 -0
  37. package/dist/chunk-SVEAENO7.js +22 -0
  38. package/dist/chunk-SY5244IR.js +1499 -0
  39. package/dist/chunk-W5HVJX45.js +402 -0
  40. package/dist/chunk-WIBGG4X6.js +173 -0
  41. package/dist/chunk-ZDWFBE5L.js +1 -0
  42. package/dist/chunk-ZINPRHAN.js +22 -0
  43. package/dist/deployer/index.cjs +165 -0
  44. package/dist/deployer/index.d.cts +19 -0
  45. package/dist/deployer/index.d.ts +19 -0
  46. package/dist/deployer/index.js +1 -0
  47. package/dist/eval/index.cjs +110 -0
  48. package/dist/eval/index.d.cts +28 -0
  49. package/dist/eval/index.d.ts +28 -0
  50. package/dist/eval/index.js +1 -0
  51. package/dist/filter/index.cjs +192 -0
  52. package/dist/filter/index.d.cts +90 -0
  53. package/dist/filter/index.d.ts +90 -0
  54. package/dist/filter/index.js +1 -0
  55. package/dist/hooks/index.cjs +87 -0
  56. package/dist/hooks/index.d.cts +33 -0
  57. package/dist/hooks/index.d.ts +33 -0
  58. package/dist/hooks/index.js +1 -0
  59. package/dist/index-mKY1XrpK.d.cts +90 -0
  60. package/dist/index-mKY1XrpK.d.ts +90 -0
  61. package/dist/index.cjs +6844 -0
  62. package/dist/index.d.cts +97 -0
  63. package/dist/index.d.ts +97 -0
  64. package/dist/index.js +119 -0
  65. package/dist/integration/index.cjs +113 -0
  66. package/dist/integration/index.d.cts +52 -0
  67. package/dist/integration/index.d.ts +52 -0
  68. package/dist/integration/index.js +1 -0
  69. package/dist/llm/index.cjs +2 -0
  70. package/dist/llm/index.d.cts +15 -0
  71. package/dist/llm/index.d.ts +15 -0
  72. package/dist/llm/index.js +1 -0
  73. package/dist/logger/index.cjs +159 -0
  74. package/dist/logger/index.d.cts +3 -0
  75. package/dist/logger/index.d.ts +3 -0
  76. package/dist/logger/index.js +1 -0
  77. package/dist/mastra/index.cjs +1741 -0
  78. package/dist/mastra/index.d.cts +67 -0
  79. package/dist/mastra/index.d.ts +67 -0
  80. package/dist/mastra/index.js +1 -0
  81. package/dist/memory/index.cjs +1907 -0
  82. package/dist/memory/index.d.cts +15 -0
  83. package/dist/memory/index.d.ts +15 -0
  84. package/dist/memory/index.js +1 -0
  85. package/dist/relevance/index.cjs +1927 -0
  86. package/dist/relevance/index.d.cts +21 -0
  87. package/dist/relevance/index.d.ts +21 -0
  88. package/dist/relevance/index.js +1 -0
  89. package/dist/storage/index.cjs +361 -0
  90. package/dist/storage/index.d.cts +15 -0
  91. package/dist/storage/index.d.ts +15 -0
  92. package/dist/storage/index.js +2 -0
  93. package/dist/storage/libsql/index.cjs +770 -0
  94. package/dist/storage/libsql/index.d.cts +81 -0
  95. package/dist/storage/libsql/index.d.ts +81 -0
  96. package/dist/storage/libsql/index.js +1 -0
  97. package/dist/telemetry/index.cjs +413 -0
  98. package/dist/telemetry/index.d.cts +51 -0
  99. package/dist/telemetry/index.d.ts +51 -0
  100. package/dist/telemetry/index.js +1 -0
  101. package/dist/telemetry/otel-vendor.cjs +52 -0
  102. package/dist/telemetry/otel-vendor.d.cts +7 -0
  103. package/dist/telemetry/otel-vendor.d.ts +7 -0
  104. package/dist/telemetry/otel-vendor.js +7 -0
  105. package/dist/tools/index.cjs +25 -0
  106. package/dist/tools/index.d.cts +29 -0
  107. package/dist/tools/index.d.ts +29 -0
  108. package/dist/tools/index.js +1 -0
  109. package/dist/tts/index.cjs +328 -0
  110. package/dist/tts/index.d.cts +28 -0
  111. package/dist/tts/index.d.ts +28 -0
  112. package/dist/tts/index.js +1 -0
  113. package/dist/types-m9RryK9a.d.cts +14 -0
  114. package/dist/types-m9RryK9a.d.ts +14 -0
  115. package/dist/utils.cjs +179 -0
  116. package/dist/utils.d.cts +26 -0
  117. package/dist/utils.d.ts +26 -0
  118. package/dist/utils.js +1 -0
  119. package/dist/vector/index.cjs +145 -0
  120. package/dist/vector/index.d.cts +30 -0
  121. package/dist/vector/index.d.ts +30 -0
  122. package/dist/vector/index.js +1 -0
  123. package/dist/vector/libsql/index.cjs +951 -0
  124. package/dist/vector/libsql/index.d.cts +29 -0
  125. package/dist/vector/libsql/index.d.ts +29 -0
  126. package/dist/vector/libsql/index.js +1 -0
  127. package/dist/voice/index.cjs +369 -0
  128. package/dist/voice/index.d.cts +67 -0
  129. package/dist/voice/index.d.ts +67 -0
  130. package/dist/voice/index.js +76 -0
  131. package/dist/workflow-DqQ4pON_.d.cts +84 -0
  132. package/dist/workflow-Ng_F_Zaf.d.ts +84 -0
  133. package/dist/workflows/index.cjs +1628 -0
  134. package/dist/workflows/index.d.cts +48 -0
  135. package/dist/workflows/index.d.ts +48 -0
  136. package/dist/workflows/index.js +1 -0
  137. package/package.json +162 -0
@@ -0,0 +1,346 @@
1
+ import { LibSQLStore } from './chunk-KNVTCZW7.js';
2
+ import { InstrumentClass, OTLPTraceExporter, Telemetry } from './chunk-W5HVJX45.js';
3
+ import { createLogger, LogLevel, noopLogger } from './chunk-PHMSPCTC.js';
4
+ import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
5
+
6
+ // src/mastra/index.ts
7
+ var _Mastra_decorators, _init;
8
+ _Mastra_decorators = [InstrumentClass({
9
+ prefix: "mastra",
10
+ excludeMethods: ["getLogger", "getTelemetry"]
11
+ })];
12
+ var Mastra = class {
13
+ vectors;
14
+ agents;
15
+ logger;
16
+ workflows;
17
+ telemetry;
18
+ tts;
19
+ deployer;
20
+ storage;
21
+ memory;
22
+ constructor(config) {
23
+ let logger;
24
+ if (config?.logger === false) {
25
+ logger = noopLogger;
26
+ } else {
27
+ if (config?.logger) {
28
+ logger = config.logger;
29
+ } else {
30
+ const levleOnEnv = process.env.NODE_ENV === "production" ? LogLevel.WARN : LogLevel.INFO;
31
+ logger = createLogger({
32
+ name: "Mastra",
33
+ level: levleOnEnv
34
+ });
35
+ }
36
+ }
37
+ this.logger = logger;
38
+ let storage = config?.storage;
39
+ if (!storage) {
40
+ storage = new LibSQLStore({
41
+ config: {
42
+ url: process.env.MASTRA_DEFAULT_STORAGE_URL || `:memory:`
43
+ }
44
+ });
45
+ }
46
+ if (storage instanceof LibSQLStore && config?.telemetry?.export?.type !== "custom") {
47
+ const newTelemetry = {
48
+ ...(config?.telemetry || {}),
49
+ export: {
50
+ type: "custom",
51
+ exporter: new OTLPTraceExporter({
52
+ logger: this.getLogger(),
53
+ storage
54
+ })
55
+ }
56
+ };
57
+ this.telemetry = Telemetry.init(newTelemetry);
58
+ } else if (config?.telemetry) {
59
+ this.telemetry = Telemetry.init(config?.telemetry);
60
+ }
61
+ if (config?.deployer) {
62
+ this.deployer = config.deployer;
63
+ if (this.telemetry) {
64
+ this.deployer = this.telemetry.traceClass(config.deployer, {
65
+ excludeMethods: ["__setTelemetry", "__getTelemetry"]
66
+ });
67
+ this.deployer.__setTelemetry(this.telemetry);
68
+ }
69
+ }
70
+ if (this.telemetry) {
71
+ this.storage = this.telemetry.traceClass(storage, {
72
+ excludeMethods: ["__setTelemetry", "__getTelemetry"]
73
+ });
74
+ this.storage.__setTelemetry(this.telemetry);
75
+ } else {
76
+ this.storage = storage;
77
+ }
78
+ if (config?.vectors) {
79
+ let vectors = {};
80
+ Object.entries(config.vectors).forEach(([key, vector]) => {
81
+ if (this.telemetry) {
82
+ vectors[key] = this.telemetry.traceClass(vector, {
83
+ excludeMethods: ["__setTelemetry", "__getTelemetry"]
84
+ });
85
+ vectors[key].__setTelemetry(this.telemetry);
86
+ } else {
87
+ vectors[key] = vector;
88
+ }
89
+ });
90
+ this.vectors = vectors;
91
+ }
92
+ if (config?.vectors) {
93
+ this.vectors = config.vectors;
94
+ }
95
+ if (config?.memory) {
96
+ this.memory = config.memory;
97
+ if (this.telemetry) {
98
+ this.memory = this.telemetry.traceClass(config.memory, {
99
+ excludeMethods: ["__setTelemetry", "__getTelemetry"]
100
+ });
101
+ this.memory.__setTelemetry(this.telemetry);
102
+ }
103
+ }
104
+ if (config && `memory` in config) {
105
+ this.logger.warn(`
106
+ Memory should be added to Agents, not to Mastra.
107
+
108
+ Instead of:
109
+ new Mastra({ memory: new Memory() })
110
+
111
+ do:
112
+ new Agent({ memory: new Memory() })
113
+
114
+ This is a warning for now, but will throw an error in the future
115
+ `);
116
+ }
117
+ if (config?.tts) {
118
+ this.tts = config.tts;
119
+ Object.entries(this.tts).forEach(([key, ttsCl]) => {
120
+ if (this.tts?.[key]) {
121
+ if (this.telemetry) {
122
+ this.tts[key] = this.telemetry.traceClass(ttsCl, {
123
+ excludeMethods: ["__setTelemetry", "__getTelemetry"]
124
+ });
125
+ this.tts[key].__setTelemetry(this.telemetry);
126
+ }
127
+ }
128
+ });
129
+ }
130
+ const agents = {};
131
+ if (config?.agents) {
132
+ Object.entries(config.agents).forEach(([key, agent]) => {
133
+ if (agents[key]) {
134
+ throw new Error(`Agent with name ID:${key} already exists`);
135
+ }
136
+ agent.__registerPrimitives({
137
+ logger: this.getLogger(),
138
+ telemetry: this.telemetry,
139
+ storage: this.storage,
140
+ memory: this.memory,
141
+ agents,
142
+ tts: this.tts,
143
+ vectors: this.vectors
144
+ });
145
+ agents[key] = agent;
146
+ });
147
+ }
148
+ this.agents = agents;
149
+ this.workflows = {};
150
+ if (config?.workflows) {
151
+ Object.entries(config.workflows).forEach(([key, workflow]) => {
152
+ workflow.__registerPrimitives({
153
+ logger: this.getLogger(),
154
+ telemetry: this.telemetry,
155
+ storage: this.storage,
156
+ memory: this.memory,
157
+ agents: this.agents,
158
+ tts: this.tts,
159
+ vectors: this.vectors
160
+ });
161
+ this.workflows[key] = workflow;
162
+ });
163
+ }
164
+ this.setLogger({
165
+ logger
166
+ });
167
+ }
168
+ getAgent(name) {
169
+ const agent = this.agents?.[name];
170
+ if (!agent) {
171
+ throw new Error(`Agent with name ${String(name)} not found`);
172
+ }
173
+ return this.agents[name];
174
+ }
175
+ getAgents() {
176
+ return this.agents;
177
+ }
178
+ getVector(name) {
179
+ const vector = this.vectors?.[name];
180
+ if (!vector) {
181
+ throw new Error(`Vector with name ${String(name)} not found`);
182
+ }
183
+ return vector;
184
+ }
185
+ getVectors() {
186
+ return this.vectors;
187
+ }
188
+ getDeployer() {
189
+ return this.deployer;
190
+ }
191
+ getWorkflow(id, {
192
+ serialized
193
+ } = {}) {
194
+ const workflow = this.workflows?.[id];
195
+ if (!workflow) {
196
+ throw new Error(`Workflow with ID ${String(id)} not found`);
197
+ }
198
+ if (serialized) {
199
+ return {
200
+ name: workflow.name
201
+ };
202
+ }
203
+ return workflow;
204
+ }
205
+ getWorkflows(props = {}) {
206
+ if (props.serialized) {
207
+ return Object.entries(this.workflows).reduce((acc, [k, v]) => {
208
+ return {
209
+ ...acc,
210
+ [k]: {
211
+ name: v.name
212
+ }
213
+ };
214
+ }, {});
215
+ }
216
+ return this.workflows;
217
+ }
218
+ setStorage(storage) {
219
+ this.storage = storage;
220
+ }
221
+ setLogger({
222
+ logger
223
+ }) {
224
+ this.logger = logger;
225
+ if (this.agents) {
226
+ Object.keys(this.agents).forEach(key => {
227
+ this.agents?.[key]?.__setLogger(this.logger);
228
+ });
229
+ }
230
+ if (this.workflows) {
231
+ Object.keys(this.workflows).forEach(key => {
232
+ this.workflows?.[key]?.__setLogger(this.logger);
233
+ });
234
+ }
235
+ if (this.memory) {
236
+ this.memory.__setLogger(this.logger);
237
+ }
238
+ if (this.deployer) {
239
+ this.deployer.__setLogger(this.logger);
240
+ }
241
+ if (this.tts) {
242
+ Object.keys(this.tts).forEach(key => {
243
+ this.tts?.[key]?.__setLogger(this.logger);
244
+ });
245
+ }
246
+ if (this.storage) {
247
+ this.storage.__setLogger(this.logger);
248
+ }
249
+ if (this.vectors) {
250
+ Object.keys(this.vectors).forEach(key => {
251
+ this.vectors?.[key]?.__setLogger(this.logger);
252
+ });
253
+ }
254
+ }
255
+ setTelemetry(telemetry) {
256
+ this.telemetry = Telemetry.init(telemetry);
257
+ if (this.agents) {
258
+ Object.keys(this.agents).forEach(key => {
259
+ if (this.telemetry) {
260
+ this.agents?.[key]?.__setTelemetry(this.telemetry);
261
+ }
262
+ });
263
+ }
264
+ if (this.workflows) {
265
+ Object.keys(this.workflows).forEach(key => {
266
+ if (this.telemetry) {
267
+ this.workflows?.[key]?.__setTelemetry(this.telemetry);
268
+ }
269
+ });
270
+ }
271
+ if (this.memory) {
272
+ this.memory = this.telemetry.traceClass(this.memory, {
273
+ excludeMethods: ["__setTelemetry", "__getTelemetry"]
274
+ });
275
+ this.memory.__setTelemetry(this.telemetry);
276
+ }
277
+ if (this.deployer) {
278
+ this.deployer = this.telemetry.traceClass(this.deployer, {
279
+ excludeMethods: ["__setTelemetry", "__getTelemetry"]
280
+ });
281
+ this.deployer.__setTelemetry(this.telemetry);
282
+ }
283
+ if (this.tts) {
284
+ let tts = {};
285
+ Object.entries(this.tts).forEach(([key, ttsCl]) => {
286
+ if (this.telemetry) {
287
+ tts[key] = this.telemetry.traceClass(ttsCl, {
288
+ excludeMethods: ["__setTelemetry", "__getTelemetry"]
289
+ });
290
+ tts[key].__setTelemetry(this.telemetry);
291
+ }
292
+ });
293
+ this.tts = tts;
294
+ }
295
+ if (this.storage) {
296
+ this.storage = this.telemetry.traceClass(this.storage, {
297
+ excludeMethods: ["__setTelemetry", "__getTelemetry"]
298
+ });
299
+ this.storage.__setTelemetry(this.telemetry);
300
+ }
301
+ if (this.vectors) {
302
+ let vectors = {};
303
+ Object.entries(this.vectors).forEach(([key, vector]) => {
304
+ if (this.telemetry) {
305
+ vectors[key] = this.telemetry.traceClass(vector, {
306
+ excludeMethods: ["__setTelemetry", "__getTelemetry"]
307
+ });
308
+ vectors[key].__setTelemetry(this.telemetry);
309
+ }
310
+ });
311
+ this.vectors = vectors;
312
+ }
313
+ }
314
+ getLogger() {
315
+ return this.logger;
316
+ }
317
+ getTelemetry() {
318
+ return this.telemetry;
319
+ }
320
+ async getLogsByRunId({
321
+ runId,
322
+ transportId
323
+ }) {
324
+ if (!transportId) {
325
+ throw new Error("Transport ID is required");
326
+ }
327
+ return await this.logger.getLogsByRunId({
328
+ runId,
329
+ transportId
330
+ });
331
+ }
332
+ async getLogs(transportId) {
333
+ if (!transportId) {
334
+ throw new Error("Transport ID is required");
335
+ }
336
+ return await this.logger.getLogs(transportId);
337
+ }
338
+ };
339
+ Mastra = /*@__PURE__*/(_ => {
340
+ _init = __decoratorStart(null);
341
+ Mastra = __decorateElement(_init, 0, "Mastra", _Mastra_decorators, Mastra);
342
+ __runInitializers(_init, 1, Mastra);
343
+ return Mastra;
344
+ })();
345
+
346
+ export { Mastra };
@@ -0,0 +1,35 @@
1
+ import { executeHook } from './chunk-BB4KXGBU.js';
2
+
3
+ // src/eval/metric.ts
4
+ var Metric = class {
5
+ };
6
+
7
+ // src/eval/evaluation.ts
8
+ async function evaluate({
9
+ agentName,
10
+ input,
11
+ metric,
12
+ output,
13
+ runId,
14
+ globalRunId,
15
+ testInfo,
16
+ instructions
17
+ }) {
18
+ const runIdToUse = runId || crypto.randomUUID();
19
+ const metricResult = await metric.measure(input.toString(), output);
20
+ const traceObject = {
21
+ input: input.toString(),
22
+ output,
23
+ result: metricResult,
24
+ agentName,
25
+ metricName: metric.constructor.name,
26
+ instructions,
27
+ globalRunId,
28
+ runId: runIdToUse,
29
+ testInfo
30
+ };
31
+ executeHook("onEvaluation" /* ON_EVALUATION */, traceObject);
32
+ return metricResult;
33
+ }
34
+
35
+ export { Metric, evaluate };
@@ -0,0 +1,49 @@
1
+ import { RegisteredLogger, createLogger } from './chunk-PHMSPCTC.js';
2
+
3
+ // src/base.ts
4
+ var MastraBase = class {
5
+ component = RegisteredLogger.LLM;
6
+ logger;
7
+ name;
8
+ telemetry;
9
+ constructor({ component, name }) {
10
+ this.component = component || RegisteredLogger.LLM;
11
+ this.name = name;
12
+ this.logger = createLogger({ name: `${this.component} - ${this.name}` });
13
+ }
14
+ /**
15
+ * Set the logger for the agent
16
+ * @param logger
17
+ */
18
+ __setLogger(logger) {
19
+ this.logger = logger;
20
+ this.logger.debug(`Logger updated [component=${this.component}] [name=${this.name}]`);
21
+ }
22
+ /**
23
+ * Set the telemetry for the
24
+ * @param telemetry
25
+ */
26
+ __setTelemetry(telemetry) {
27
+ this.telemetry = telemetry;
28
+ this.logger.debug(`Telemetry updated [component=${this.component}] [tracer=${this.telemetry.tracer}]`);
29
+ }
30
+ /**
31
+ * Get the telemetry on the vector
32
+ * @returns telemetry
33
+ */
34
+ __getTelemetry() {
35
+ return this.telemetry;
36
+ }
37
+ /*
38
+ get experimental_telemetry config
39
+ */
40
+ get experimental_telemetry() {
41
+ return this.telemetry ? {
42
+ // tracer: this.telemetry.tracer,
43
+ tracer: this.telemetry.getBaggageTracer(),
44
+ isEnabled: !!this.telemetry.tracer
45
+ } : void 0;
46
+ }
47
+ };
48
+
49
+ export { MastraBase };
@@ -0,0 +1,145 @@
1
+ import { Transform } from 'stream';
2
+ import pino from 'pino';
3
+ import pretty from 'pino-pretty';
4
+
5
+ // src/logger/index.ts
6
+ var RegisteredLogger = {
7
+ AGENT: "AGENT",
8
+ WORKFLOW: "WORKFLOW",
9
+ LLM: "LLM",
10
+ TTS: "TTS",
11
+ VOICE: "VOICE",
12
+ VECTOR: "VECTOR",
13
+ BUNDLER: "BUNDLER",
14
+ DEPLOYER: "DEPLOYER",
15
+ MEMORY: "MEMORY",
16
+ STORAGE: "STORAGE",
17
+ EMBEDDINGS: "EMBEDDINGS"
18
+ };
19
+ var LogLevel = {
20
+ DEBUG: "debug",
21
+ INFO: "info",
22
+ WARN: "warn",
23
+ ERROR: "error",
24
+ NONE: "silent"
25
+ };
26
+ var LoggerTransport = class extends Transform {
27
+ constructor(opts = {}) {
28
+ super({ ...opts, objectMode: true });
29
+ }
30
+ async getLogsByRunId(_args) {
31
+ return [];
32
+ }
33
+ async getLogs() {
34
+ return [];
35
+ }
36
+ };
37
+ var Logger = class {
38
+ logger;
39
+ transports;
40
+ constructor(options = {}) {
41
+ this.transports = options.transports || {};
42
+ const transportsAry = Object.entries(this.transports);
43
+ this.logger = pino(
44
+ {
45
+ name: options.name || "app",
46
+ level: options.level || LogLevel.INFO
47
+ },
48
+ options.overrideDefaultTransports ? options?.transports?.default : transportsAry.length === 0 ? pretty({
49
+ colorize: true,
50
+ levelFirst: true,
51
+ ignore: "pid,hostname",
52
+ colorizeObjects: true,
53
+ translateTime: "SYS:standard",
54
+ singleLine: false
55
+ }) : pino.multistream([
56
+ ...transportsAry.map(([_, transport]) => ({
57
+ stream: transport,
58
+ level: options.level || LogLevel.INFO
59
+ })),
60
+ {
61
+ stream: pretty({
62
+ colorize: true,
63
+ levelFirst: true,
64
+ ignore: "pid,hostname",
65
+ colorizeObjects: true,
66
+ translateTime: "SYS:standard",
67
+ singleLine: false
68
+ }),
69
+ level: options.level || LogLevel.INFO
70
+ }
71
+ ])
72
+ );
73
+ }
74
+ debug(message, args = {}) {
75
+ this.logger.debug(args, message);
76
+ }
77
+ info(message, args = {}) {
78
+ this.logger.info(args, message);
79
+ }
80
+ warn(message, args = {}) {
81
+ this.logger.warn(args, message);
82
+ }
83
+ error(message, args = {}) {
84
+ this.logger.error(args, message);
85
+ }
86
+ // Stream creation for process output handling
87
+ createStream() {
88
+ return new Transform({
89
+ transform: (chunk, _encoding, callback) => {
90
+ const line = chunk.toString().trim();
91
+ if (line) {
92
+ this.info(line);
93
+ }
94
+ callback(null, chunk);
95
+ }
96
+ });
97
+ }
98
+ async getLogs(transportId) {
99
+ if (!transportId || !this.transports[transportId]) {
100
+ return [];
101
+ }
102
+ return this.transports[transportId].getLogs();
103
+ }
104
+ async getLogsByRunId({ runId, transportId }) {
105
+ return this.transports[transportId]?.getLogsByRunId({ runId });
106
+ }
107
+ };
108
+ function createLogger(options) {
109
+ return new Logger(options);
110
+ }
111
+ var MultiLogger = class {
112
+ loggers;
113
+ constructor(loggers) {
114
+ this.loggers = loggers;
115
+ }
116
+ debug(message, ...args) {
117
+ this.loggers.forEach((logger) => logger.debug(message, ...args));
118
+ }
119
+ info(message, ...args) {
120
+ this.loggers.forEach((logger) => logger.info(message, ...args));
121
+ }
122
+ warn(message, ...args) {
123
+ this.loggers.forEach((logger) => logger.warn(message, ...args));
124
+ }
125
+ error(message, ...args) {
126
+ this.loggers.forEach((logger) => logger.error(message, ...args));
127
+ }
128
+ };
129
+ function combineLoggers(loggers) {
130
+ return new MultiLogger(loggers);
131
+ }
132
+ var noopLogger = {
133
+ debug: () => {
134
+ },
135
+ info: () => {
136
+ },
137
+ warn: () => {
138
+ },
139
+ error: () => {
140
+ },
141
+ cleanup: async () => {
142
+ }
143
+ };
144
+
145
+ export { LogLevel, Logger, LoggerTransport, MultiLogger, RegisteredLogger, combineLoggers, createLogger, noopLogger };
@@ -0,0 +1,88 @@
1
+ import { createTool } from './chunk-ZINPRHAN.js';
2
+ import { z } from 'zod';
3
+
4
+ // src/integration/integration.ts
5
+ var Integration = class {
6
+ name = "Integration";
7
+ workflows;
8
+ constructor() {
9
+ this.workflows = {};
10
+ }
11
+ /**
12
+ * Workflows
13
+ */
14
+ registerWorkflow(name, fn) {
15
+ if (this.workflows[name]) {
16
+ throw new Error(`Sync function "${name}" already registered`);
17
+ }
18
+ this.workflows[name] = fn;
19
+ }
20
+ getWorkflows({ serialized }) {
21
+ if (serialized) {
22
+ return Object.entries(this.workflows).reduce((acc, [k, v]) => {
23
+ return {
24
+ ...acc,
25
+ [k]: {
26
+ name: v.name
27
+ }
28
+ };
29
+ }, {});
30
+ }
31
+ return this.workflows;
32
+ }
33
+ /**
34
+ * TOOLS
35
+ */
36
+ getStaticTools(_params) {
37
+ throw new Error("Method not implemented.");
38
+ }
39
+ async getTools(_params) {
40
+ throw new Error("Method not implemented.");
41
+ }
42
+ async getApiClient() {
43
+ throw new Error("Method not implemented");
44
+ }
45
+ };
46
+ var OpenAPIToolset = class {
47
+ authType = "API_KEY";
48
+ constructor() {
49
+ }
50
+ get toolSchemas() {
51
+ return {};
52
+ }
53
+ get toolDocumentations() {
54
+ return {};
55
+ }
56
+ get baseClient() {
57
+ return {};
58
+ }
59
+ async getApiClient() {
60
+ throw new Error("API not implemented");
61
+ }
62
+ _generateIntegrationTools() {
63
+ const { client, ...clientMethods } = this.baseClient;
64
+ const schemas = this.toolSchemas;
65
+ const documentations = this.toolDocumentations;
66
+ const tools = Object.keys(clientMethods).reduce((acc, key) => {
67
+ const comment = documentations[key]?.comment;
68
+ const fallbackComment = `Execute ${key}`;
69
+ const tool = createTool({
70
+ id: key,
71
+ inputSchema: schemas[key] || z.object({}),
72
+ description: comment || fallbackComment,
73
+ // documentation: doc || fallbackComment,
74
+ execute: async ({ context }) => {
75
+ const client2 = await this.getApiClient();
76
+ const value = client2[key];
77
+ return value({
78
+ ...context
79
+ });
80
+ }
81
+ });
82
+ return { ...acc, [key]: tool };
83
+ }, {});
84
+ return tools;
85
+ }
86
+ };
87
+
88
+ export { Integration, OpenAPIToolset };
@@ -0,0 +1,37 @@
1
+ import { InstrumentClass } from './chunk-W5HVJX45.js';
2
+ import { MastraBase } from './chunk-OZ4XVJ6F.js';
3
+ import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
4
+
5
+ // src/tts/index.ts
6
+ var _MastraTTS_decorators, _init, _a;
7
+ _MastraTTS_decorators = [InstrumentClass({
8
+ prefix: "tts",
9
+ excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
10
+ })];
11
+ var MastraTTS = class extends (_a = MastraBase) {
12
+ model;
13
+ constructor({
14
+ model
15
+ }) {
16
+ super({
17
+ component: "TTS"
18
+ });
19
+ this.model = model;
20
+ }
21
+ traced(method, methodName) {
22
+ return this.telemetry?.traceMethod(method, {
23
+ spanName: `${this.model.name}-tts.${methodName}`,
24
+ attributes: {
25
+ "tts.type": `${this.model.name}`
26
+ }
27
+ }) ?? method;
28
+ }
29
+ };
30
+ MastraTTS = /*@__PURE__*/(_ => {
31
+ _init = __decoratorStart(_a);
32
+ MastraTTS = __decorateElement(_init, 0, "MastraTTS", _MastraTTS_decorators, MastraTTS);
33
+ __runInitializers(_init, 1, MastraTTS);
34
+ return MastraTTS;
35
+ })();
36
+
37
+ export { MastraTTS };
@@ -0,0 +1,8 @@
1
+ // src/storage/constants.ts
2
+ var TABLE_WORKFLOW_SNAPSHOT = "mastra_workflow_snapshot";
3
+ var TABLE_EVALS = "mastra_evals";
4
+ var TABLE_MESSAGES = "mastra_messages";
5
+ var TABLE_THREADS = "mastra_threads";
6
+ var TABLE_TRACES = "mastra_traces";
7
+
8
+ export { TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES, TABLE_WORKFLOW_SNAPSHOT };