@mastra/core 0.7.0 → 0.8.0-alpha.2
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 +76 -74
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +5 -3
- package/dist/agent/index.d.ts +5 -3
- package/dist/agent/index.js +1 -1
- package/dist/{base-Cmunaaxb.d.ts → base-BA_in99t.d.ts} +4 -1
- package/dist/{base-Cyl73WbV.d.ts → base-CQuRWXAH.d.ts} +985 -913
- package/dist/{base-ObPJ-w8K.d.cts → base-CvQbEqGB.d.cts} +4 -1
- package/dist/{base-C0wILuA9.d.cts → base-Dpt4tO56.d.cts} +985 -913
- package/dist/base.cjs +2 -2
- package/dist/base.d.cts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.cts +1 -1
- package/dist/bundler/index.d.ts +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-L7CR75HA.js → chunk-2BVZNKLX.js} +1 -1
- package/dist/{chunk-V5ORZPFW.cjs → chunk-3C6V2FEP.cjs} +1 -1
- package/dist/chunk-3HE5CJBG.cjs +4604 -0
- package/dist/{chunk-PNZK456O.js → chunk-4RMSGSQN.js} +4 -4
- package/dist/{chunk-WESJ2ZY7.cjs → chunk-57LXIDIK.cjs} +2 -2
- package/dist/chunk-5RRJEWMA.cjs +107 -0
- package/dist/{chunk-3CNO7YB5.js → chunk-5TFGORLG.js} +1 -1
- package/dist/{chunk-5FAJ6HUC.cjs → chunk-64VPB7ZD.cjs} +23 -2
- package/dist/chunk-6XLV4KSD.js +100 -0
- package/dist/{chunk-XLSROQ26.cjs → chunk-7I7AKQH3.cjs} +5 -5
- package/dist/{chunk-RUA6BSB6.cjs → chunk-7JBINHJX.cjs} +2 -2
- package/dist/chunk-A6MBM56X.js +268 -0
- package/dist/{chunk-2YF5JYTJ.js → chunk-BC5B4EGI.js} +21 -2
- package/dist/chunk-BF7ZLRGO.cjs +271 -0
- package/dist/{chunk-SMBKF6K5.js → chunk-BRBHQ6KS.js} +10 -1
- package/dist/{chunk-VN4M67DA.js → chunk-CLJQYXNM.js} +1 -1
- package/dist/{chunk-PL7PVTGF.cjs → chunk-D63P5O4Q.cjs} +4 -4
- package/dist/chunk-DCGLGWHI.cjs +141 -0
- package/dist/{chunk-YXJQFZOW.cjs → chunk-DL4QPJKI.cjs} +24 -10
- package/dist/{chunk-ZABXT2MN.js → chunk-FY57LEMC.js} +1 -1
- package/dist/{chunk-XLXJUYKH.js → chunk-GHK3HBWN.js} +1 -1
- package/dist/{chunk-ONDCHP6G.cjs → chunk-GO2D7FEK.cjs} +2 -2
- package/dist/{chunk-7VTZI3YN.js → chunk-H6ZU5N2C.js} +1 -1
- package/dist/{chunk-WBE5RTFI.js → chunk-HAWAUEWK.js} +2 -2
- package/dist/chunk-HCDXBSMK.js +4577 -0
- package/dist/{chunk-RU7CSPAV.js → chunk-JGJMVCJ4.js} +7 -84
- package/dist/{chunk-W5HVJX45.js → chunk-N5ZYOQBL.js} +46 -5
- package/dist/{chunk-NPOKIPWC.cjs → chunk-O7IW545H.cjs} +1 -1
- package/dist/{chunk-XB2TJ7LX.cjs → chunk-PHWEC4VD.cjs} +47 -6
- package/dist/{chunk-NUDAZEOG.js → chunk-PK5QRKSG.js} +1 -1
- package/dist/{chunk-43SD5CUE.js → chunk-QDHRRKQ5.js} +63 -9
- package/dist/{chunk-ZBKJDQPM.js → chunk-RBWBJC6D.js} +17 -3
- package/dist/{chunk-4PYORXWM.cjs → chunk-RXDLSCBA.cjs} +4 -4
- package/dist/{chunk-IQLRSKED.cjs → chunk-RZCYBC7D.cjs} +2 -2
- package/dist/{chunk-ASFUEC75.cjs → chunk-TNNHN4ZY.cjs} +67 -12
- package/dist/{chunk-QM6WIIPM.js → chunk-UF4LZV3D.js} +1 -1
- package/dist/{chunk-JJ4YQTFT.cjs → chunk-WAW7QBY4.cjs} +2 -2
- package/dist/{chunk-U7ONOIBO.cjs → chunk-YZDUZFVZ.cjs} +11 -2
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.d.cts +1 -1
- package/dist/deployer/index.d.ts +1 -1
- package/dist/deployer/index.js +1 -1
- package/dist/eval/index.cjs +3 -3
- package/dist/eval/index.d.cts +8 -5
- package/dist/eval/index.d.ts +8 -5
- package/dist/eval/index.js +1 -1
- package/dist/hooks/index.d.cts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.cjs +102 -92
- package/dist/index.d.cts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +18 -19
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.d.cts +5 -3
- package/dist/integration/index.d.ts +5 -3
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.d.cts +5 -3
- package/dist/llm/index.d.ts +5 -3
- package/dist/logger/index.cjs +9 -9
- package/dist/logger/index.js +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +5 -3
- package/dist/mastra/index.d.ts +5 -3
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +6 -2
- package/dist/memory/index.d.cts +5 -3
- package/dist/memory/index.d.ts +5 -3
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +8 -8
- package/dist/network/index.d.cts +5 -3
- package/dist/network/index.d.ts +5 -3
- package/dist/network/index.js +4 -4
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +10 -8
- package/dist/relevance/index.d.ts +10 -8
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +17 -0
- package/dist/server/index.d.cts +37 -0
- package/dist/server/index.d.ts +37 -0
- package/dist/server/index.js +15 -0
- package/dist/storage/index.cjs +12 -8
- package/dist/storage/index.d.cts +5 -3
- package/dist/storage/index.d.ts +5 -3
- package/dist/storage/index.js +2 -2
- package/dist/storage/libsql/index.cjs +24 -24
- package/dist/storage/libsql/index.d.cts +5 -3
- package/dist/storage/libsql/index.d.ts +5 -3
- package/dist/storage/libsql/index.js +12 -12
- package/dist/telemetry/index.cjs +6 -6
- package/dist/telemetry/index.d.cts +5 -3
- package/dist/telemetry/index.d.ts +5 -3
- package/dist/telemetry/index.js +1 -1
- package/dist/tools/index.cjs +7 -3
- package/dist/tools/index.d.cts +6 -3
- package/dist/tools/index.d.ts +6 -3
- package/dist/tools/index.js +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.d.cts +1 -1
- package/dist/tts/index.d.ts +1 -1
- package/dist/tts/index.js +1 -1
- package/dist/{types-CwTG2XyQ.d.cts → types-BtMyV38I.d.cts} +4 -1
- package/dist/{types-CwTG2XyQ.d.ts → types-BtMyV38I.d.ts} +4 -1
- package/dist/utils.cjs +13 -13
- package/dist/utils.d.cts +7 -5
- package/dist/utils.d.ts +7 -5
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.d.cts +1 -1
- package/dist/vector/index.d.ts +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/vector/libsql/index.cjs +3 -3
- package/dist/vector/libsql/index.d.cts +1 -1
- package/dist/vector/libsql/index.d.ts +1 -1
- package/dist/vector/libsql/index.js +1 -1
- package/dist/voice/index.cjs +13 -249
- package/dist/voice/index.d.cts +22 -8
- package/dist/voice/index.d.ts +22 -8
- package/dist/voice/index.js +1 -252
- package/dist/workflows/index.cjs +28 -20
- package/dist/workflows/index.d.cts +18 -7
- package/dist/workflows/index.d.ts +18 -7
- package/dist/workflows/index.js +1 -1
- package/package.json +5 -3
- package/dist/chunk-2W2GYEYQ.cjs +0 -25
- package/dist/chunk-C6BBAS4I.cjs +0 -1715
- package/dist/chunk-F5UYWPV4.cjs +0 -14
- package/dist/chunk-GG6TEAMJ.cjs +0 -2289
- package/dist/chunk-R2M5CZ5U.js +0 -2264
- package/dist/chunk-RG66XEJT.js +0 -8
- package/dist/chunk-VNQRLYIA.js +0 -1715
- package/dist/chunk-WVVKLIUW.cjs +0 -218
- package/dist/chunk-ZINPRHAN.js +0 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES } from './chunk-
|
|
2
|
-
import { MastraBase } from './chunk-
|
|
1
|
+
import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES, TABLE_SCHEMAS } from './chunk-6XLV4KSD.js';
|
|
2
|
+
import { MastraBase } from './chunk-CLJQYXNM.js';
|
|
3
3
|
|
|
4
4
|
// src/storage/base.ts
|
|
5
5
|
var MastraStorage = class extends MastraBase {
|
|
@@ -76,100 +76,23 @@ var MastraStorage = class extends MastraBase {
|
|
|
76
76
|
this.hasInitialized = Promise.all([
|
|
77
77
|
this.createTable({
|
|
78
78
|
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
79
|
-
schema:
|
|
80
|
-
workflow_name: {
|
|
81
|
-
type: "text"
|
|
82
|
-
},
|
|
83
|
-
run_id: {
|
|
84
|
-
type: "text"
|
|
85
|
-
},
|
|
86
|
-
snapshot: {
|
|
87
|
-
type: "text"
|
|
88
|
-
},
|
|
89
|
-
createdAt: {
|
|
90
|
-
type: "timestamp"
|
|
91
|
-
},
|
|
92
|
-
updatedAt: {
|
|
93
|
-
type: "timestamp"
|
|
94
|
-
}
|
|
95
|
-
}
|
|
79
|
+
schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT]
|
|
96
80
|
}),
|
|
97
81
|
this.createTable({
|
|
98
82
|
tableName: TABLE_EVALS,
|
|
99
|
-
schema:
|
|
100
|
-
input: {
|
|
101
|
-
type: "text"
|
|
102
|
-
},
|
|
103
|
-
output: {
|
|
104
|
-
type: "text"
|
|
105
|
-
},
|
|
106
|
-
result: {
|
|
107
|
-
type: "jsonb"
|
|
108
|
-
},
|
|
109
|
-
agent_name: {
|
|
110
|
-
type: "text"
|
|
111
|
-
},
|
|
112
|
-
metric_name: {
|
|
113
|
-
type: "text"
|
|
114
|
-
},
|
|
115
|
-
instructions: {
|
|
116
|
-
type: "text"
|
|
117
|
-
},
|
|
118
|
-
test_info: {
|
|
119
|
-
type: "jsonb",
|
|
120
|
-
nullable: true
|
|
121
|
-
},
|
|
122
|
-
global_run_id: {
|
|
123
|
-
type: "text"
|
|
124
|
-
},
|
|
125
|
-
run_id: {
|
|
126
|
-
type: "text"
|
|
127
|
-
},
|
|
128
|
-
created_at: {
|
|
129
|
-
type: "timestamp"
|
|
130
|
-
}
|
|
131
|
-
}
|
|
83
|
+
schema: TABLE_SCHEMAS[TABLE_EVALS]
|
|
132
84
|
}),
|
|
133
85
|
this.createTable({
|
|
134
86
|
tableName: TABLE_THREADS,
|
|
135
|
-
schema:
|
|
136
|
-
id: { type: "text", nullable: false, primaryKey: true },
|
|
137
|
-
resourceId: { type: "text", nullable: false },
|
|
138
|
-
title: { type: "text", nullable: false },
|
|
139
|
-
metadata: { type: "text", nullable: true },
|
|
140
|
-
createdAt: { type: "timestamp", nullable: false },
|
|
141
|
-
updatedAt: { type: "timestamp", nullable: false }
|
|
142
|
-
}
|
|
87
|
+
schema: TABLE_SCHEMAS[TABLE_THREADS]
|
|
143
88
|
}),
|
|
144
89
|
this.createTable({
|
|
145
90
|
tableName: TABLE_MESSAGES,
|
|
146
|
-
schema:
|
|
147
|
-
id: { type: "text", nullable: false, primaryKey: true },
|
|
148
|
-
thread_id: { type: "text", nullable: false },
|
|
149
|
-
content: { type: "text", nullable: false },
|
|
150
|
-
role: { type: "text", nullable: false },
|
|
151
|
-
type: { type: "text", nullable: false },
|
|
152
|
-
createdAt: { type: "timestamp", nullable: false }
|
|
153
|
-
}
|
|
91
|
+
schema: TABLE_SCHEMAS[TABLE_MESSAGES]
|
|
154
92
|
}),
|
|
155
93
|
this.createTable({
|
|
156
94
|
tableName: TABLE_TRACES,
|
|
157
|
-
schema:
|
|
158
|
-
id: { type: "text", nullable: false, primaryKey: true },
|
|
159
|
-
parentSpanId: { type: "text", nullable: true },
|
|
160
|
-
name: { type: "text", nullable: false },
|
|
161
|
-
traceId: { type: "text", nullable: false },
|
|
162
|
-
scope: { type: "text", nullable: false },
|
|
163
|
-
kind: { type: "integer", nullable: false },
|
|
164
|
-
attributes: { type: "jsonb", nullable: true },
|
|
165
|
-
status: { type: "jsonb", nullable: true },
|
|
166
|
-
events: { type: "jsonb", nullable: true },
|
|
167
|
-
links: { type: "jsonb", nullable: true },
|
|
168
|
-
other: { type: "text", nullable: true },
|
|
169
|
-
startTime: { type: "bigint", nullable: false },
|
|
170
|
-
endTime: { type: "bigint", nullable: false },
|
|
171
|
-
createdAt: { type: "timestamp", nullable: false }
|
|
172
|
-
}
|
|
95
|
+
schema: TABLE_SCHEMAS[TABLE_TRACES]
|
|
173
96
|
})
|
|
174
97
|
]).then(() => true);
|
|
175
98
|
await this.hasInitialized;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TABLE_TRACES } from './chunk-
|
|
1
|
+
import { TABLE_TRACES } from './chunk-6XLV4KSD.js';
|
|
2
2
|
import { trace, context, propagation, SpanStatusCode, SpanKind } from '@opentelemetry/api';
|
|
3
3
|
import { ExportResultCode } from '@opentelemetry/core';
|
|
4
4
|
import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';
|
|
@@ -42,13 +42,23 @@ function withSpan(options) {
|
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
const currentBaggage = propagation.getBaggage(ctx);
|
|
45
|
+
if (currentBaggage?.["http.request_id"]) {
|
|
46
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
47
|
+
}
|
|
45
48
|
if (currentBaggage?.componentName) {
|
|
46
49
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
47
50
|
span.setAttribute("runId", currentBaggage?.runId);
|
|
48
51
|
} else if (this && this.name) {
|
|
49
52
|
span.setAttribute("componentName", this.name);
|
|
50
53
|
span.setAttribute("runId", this.runId);
|
|
51
|
-
ctx = propagation.setBaggage(ctx, {
|
|
54
|
+
ctx = propagation.setBaggage(ctx, {
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
componentName: this.name,
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
runId: this.runId,
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
"http.request_id": currentBaggage?.["http.request_id"]
|
|
61
|
+
});
|
|
52
62
|
}
|
|
53
63
|
let result;
|
|
54
64
|
try {
|
|
@@ -242,6 +252,10 @@ var Telemetry = class _Telemetry {
|
|
|
242
252
|
throw error;
|
|
243
253
|
}
|
|
244
254
|
}
|
|
255
|
+
static getActiveSpan() {
|
|
256
|
+
const span = trace.getActiveSpan();
|
|
257
|
+
return span;
|
|
258
|
+
}
|
|
245
259
|
/**
|
|
246
260
|
* Get the global telemetry instance
|
|
247
261
|
* @throws {Error} If telemetry has not been initialized
|
|
@@ -282,6 +296,14 @@ var Telemetry = class _Telemetry {
|
|
|
282
296
|
}
|
|
283
297
|
});
|
|
284
298
|
}
|
|
299
|
+
static setBaggage(baggage, ctx = context.active()) {
|
|
300
|
+
const currentBaggage = propagation.getBaggage(ctx);
|
|
301
|
+
const newCtx = propagation.setBaggage(ctx, { ...currentBaggage, ...baggage });
|
|
302
|
+
return newCtx;
|
|
303
|
+
}
|
|
304
|
+
static withContext(ctx, fn) {
|
|
305
|
+
return context.with(ctx, fn);
|
|
306
|
+
}
|
|
285
307
|
/**
|
|
286
308
|
* method to trace individual methods with proper context
|
|
287
309
|
* @param method The method to trace
|
|
@@ -315,24 +337,36 @@ var Telemetry = class _Telemetry {
|
|
|
315
337
|
span.end();
|
|
316
338
|
return res;
|
|
317
339
|
};
|
|
340
|
+
const currentBaggage = propagation.getBaggage(ctx);
|
|
318
341
|
if (context3.attributes) {
|
|
319
342
|
span.setAttributes(context3.attributes);
|
|
320
343
|
}
|
|
344
|
+
if (currentBaggage?.["http.request_id"]) {
|
|
345
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
346
|
+
}
|
|
321
347
|
if (context3.attributes?.componentName) {
|
|
322
348
|
ctx = propagation.setBaggage(ctx, {
|
|
323
349
|
// @ts-ignore
|
|
324
350
|
componentName: context3.attributes.componentName,
|
|
325
|
-
runId: context3.attributes.runId
|
|
351
|
+
runId: context3.attributes.runId,
|
|
352
|
+
// @ts-ignore
|
|
353
|
+
"http.request_id": currentBaggage?.["http.request_id"]
|
|
326
354
|
});
|
|
327
355
|
} else {
|
|
328
|
-
const currentBaggage = propagation.getBaggage(ctx);
|
|
329
356
|
if (currentBaggage?.componentName) {
|
|
330
357
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
331
358
|
span.setAttribute("runId", currentBaggage?.runId);
|
|
332
359
|
} else if (this && this.name) {
|
|
333
360
|
span.setAttribute("componentName", this.name);
|
|
334
361
|
span.setAttribute("runId", this.runId);
|
|
335
|
-
ctx = propagation.setBaggage(ctx, {
|
|
362
|
+
ctx = propagation.setBaggage(ctx, {
|
|
363
|
+
// @ts-ignore
|
|
364
|
+
componentName: this.name,
|
|
365
|
+
// @ts-ignore
|
|
366
|
+
runId: this.runId,
|
|
367
|
+
// @ts-ignore
|
|
368
|
+
"http.request_id": currentBaggage?.["http.request_id"]
|
|
369
|
+
});
|
|
336
370
|
}
|
|
337
371
|
}
|
|
338
372
|
args.forEach((arg, index) => {
|
|
@@ -371,6 +405,7 @@ var BaggageTracer = class {
|
|
|
371
405
|
const currentBaggage = propagation.getBaggage(ctx);
|
|
372
406
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
373
407
|
span.setAttribute("runId", currentBaggage?.runId);
|
|
408
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
374
409
|
return span;
|
|
375
410
|
}
|
|
376
411
|
startActiveSpan(name, optionsOrFn, ctxOrFn, fn) {
|
|
@@ -378,6 +413,8 @@ var BaggageTracer = class {
|
|
|
378
413
|
const wrappedFn2 = (span) => {
|
|
379
414
|
const currentBaggage = propagation.getBaggage(context.active());
|
|
380
415
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
416
|
+
span.setAttribute("runId", currentBaggage?.runId);
|
|
417
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
381
418
|
return optionsOrFn(span);
|
|
382
419
|
};
|
|
383
420
|
return this._tracer.startActiveSpan(name, {}, context.active(), wrappedFn2);
|
|
@@ -386,6 +423,8 @@ var BaggageTracer = class {
|
|
|
386
423
|
const wrappedFn2 = (span) => {
|
|
387
424
|
const currentBaggage = propagation.getBaggage(context.active());
|
|
388
425
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
426
|
+
span.setAttribute("runId", currentBaggage?.runId);
|
|
427
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
389
428
|
return ctxOrFn(span);
|
|
390
429
|
};
|
|
391
430
|
return this._tracer.startActiveSpan(name, optionsOrFn, context.active(), wrappedFn2);
|
|
@@ -393,6 +432,8 @@ var BaggageTracer = class {
|
|
|
393
432
|
const wrappedFn = (span) => {
|
|
394
433
|
const currentBaggage = propagation.getBaggage(ctxOrFn ?? context.active());
|
|
395
434
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
435
|
+
span.setAttribute("runId", currentBaggage?.runId);
|
|
436
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
396
437
|
return fn(span);
|
|
397
438
|
};
|
|
398
439
|
return this._tracer.startActiveSpan(name, optionsOrFn, ctxOrFn, wrappedFn);
|
|
@@ -68,7 +68,7 @@ var Logger = class {
|
|
|
68
68
|
translateTime: "SYS:standard",
|
|
69
69
|
singleLine: false
|
|
70
70
|
}) : pino__default.default.multistream([
|
|
71
|
-
...transportsAry.map(([
|
|
71
|
+
...transportsAry.map(([, transport]) => ({
|
|
72
72
|
stream: transport,
|
|
73
73
|
level: options.level || LogLevel.INFO
|
|
74
74
|
})),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk5RRJEWMA_cjs = require('./chunk-5RRJEWMA.cjs');
|
|
4
4
|
var api = require('@opentelemetry/api');
|
|
5
5
|
var core = require('@opentelemetry/core');
|
|
6
6
|
var otlpTransformer = require('@opentelemetry/otlp-transformer');
|
|
@@ -44,13 +44,23 @@ function withSpan(options) {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
const currentBaggage = api.propagation.getBaggage(ctx);
|
|
47
|
+
if (currentBaggage?.["http.request_id"]) {
|
|
48
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
49
|
+
}
|
|
47
50
|
if (currentBaggage?.componentName) {
|
|
48
51
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
49
52
|
span.setAttribute("runId", currentBaggage?.runId);
|
|
50
53
|
} else if (this && this.name) {
|
|
51
54
|
span.setAttribute("componentName", this.name);
|
|
52
55
|
span.setAttribute("runId", this.runId);
|
|
53
|
-
ctx = api.propagation.setBaggage(ctx, {
|
|
56
|
+
ctx = api.propagation.setBaggage(ctx, {
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
componentName: this.name,
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
runId: this.runId,
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
"http.request_id": currentBaggage?.["http.request_id"]
|
|
63
|
+
});
|
|
54
64
|
}
|
|
55
65
|
let result;
|
|
56
66
|
try {
|
|
@@ -187,7 +197,7 @@ var OTLPTraceExporter = class {
|
|
|
187
197
|
return acc;
|
|
188
198
|
}, []);
|
|
189
199
|
return this.storage.__batchInsert({
|
|
190
|
-
tableName:
|
|
200
|
+
tableName: chunk5RRJEWMA_cjs.TABLE_TRACES,
|
|
191
201
|
records: allSpans
|
|
192
202
|
}).then(() => {
|
|
193
203
|
items.resultCallback({
|
|
@@ -244,6 +254,10 @@ var Telemetry = class _Telemetry {
|
|
|
244
254
|
throw error;
|
|
245
255
|
}
|
|
246
256
|
}
|
|
257
|
+
static getActiveSpan() {
|
|
258
|
+
const span = api.trace.getActiveSpan();
|
|
259
|
+
return span;
|
|
260
|
+
}
|
|
247
261
|
/**
|
|
248
262
|
* Get the global telemetry instance
|
|
249
263
|
* @throws {Error} If telemetry has not been initialized
|
|
@@ -284,6 +298,14 @@ var Telemetry = class _Telemetry {
|
|
|
284
298
|
}
|
|
285
299
|
});
|
|
286
300
|
}
|
|
301
|
+
static setBaggage(baggage, ctx = api.context.active()) {
|
|
302
|
+
const currentBaggage = api.propagation.getBaggage(ctx);
|
|
303
|
+
const newCtx = api.propagation.setBaggage(ctx, { ...currentBaggage, ...baggage });
|
|
304
|
+
return newCtx;
|
|
305
|
+
}
|
|
306
|
+
static withContext(ctx, fn) {
|
|
307
|
+
return api.context.with(ctx, fn);
|
|
308
|
+
}
|
|
287
309
|
/**
|
|
288
310
|
* method to trace individual methods with proper context
|
|
289
311
|
* @param method The method to trace
|
|
@@ -317,24 +339,36 @@ var Telemetry = class _Telemetry {
|
|
|
317
339
|
span.end();
|
|
318
340
|
return res;
|
|
319
341
|
};
|
|
342
|
+
const currentBaggage = api.propagation.getBaggage(ctx);
|
|
320
343
|
if (context3.attributes) {
|
|
321
344
|
span.setAttributes(context3.attributes);
|
|
322
345
|
}
|
|
346
|
+
if (currentBaggage?.["http.request_id"]) {
|
|
347
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
348
|
+
}
|
|
323
349
|
if (context3.attributes?.componentName) {
|
|
324
350
|
ctx = api.propagation.setBaggage(ctx, {
|
|
325
351
|
// @ts-ignore
|
|
326
352
|
componentName: context3.attributes.componentName,
|
|
327
|
-
runId: context3.attributes.runId
|
|
353
|
+
runId: context3.attributes.runId,
|
|
354
|
+
// @ts-ignore
|
|
355
|
+
"http.request_id": currentBaggage?.["http.request_id"]
|
|
328
356
|
});
|
|
329
357
|
} else {
|
|
330
|
-
const currentBaggage = api.propagation.getBaggage(ctx);
|
|
331
358
|
if (currentBaggage?.componentName) {
|
|
332
359
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
333
360
|
span.setAttribute("runId", currentBaggage?.runId);
|
|
334
361
|
} else if (this && this.name) {
|
|
335
362
|
span.setAttribute("componentName", this.name);
|
|
336
363
|
span.setAttribute("runId", this.runId);
|
|
337
|
-
ctx = api.propagation.setBaggage(ctx, {
|
|
364
|
+
ctx = api.propagation.setBaggage(ctx, {
|
|
365
|
+
// @ts-ignore
|
|
366
|
+
componentName: this.name,
|
|
367
|
+
// @ts-ignore
|
|
368
|
+
runId: this.runId,
|
|
369
|
+
// @ts-ignore
|
|
370
|
+
"http.request_id": currentBaggage?.["http.request_id"]
|
|
371
|
+
});
|
|
338
372
|
}
|
|
339
373
|
}
|
|
340
374
|
args.forEach((arg, index) => {
|
|
@@ -373,6 +407,7 @@ var BaggageTracer = class {
|
|
|
373
407
|
const currentBaggage = api.propagation.getBaggage(ctx);
|
|
374
408
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
375
409
|
span.setAttribute("runId", currentBaggage?.runId);
|
|
410
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
376
411
|
return span;
|
|
377
412
|
}
|
|
378
413
|
startActiveSpan(name, optionsOrFn, ctxOrFn, fn) {
|
|
@@ -380,6 +415,8 @@ var BaggageTracer = class {
|
|
|
380
415
|
const wrappedFn2 = (span) => {
|
|
381
416
|
const currentBaggage = api.propagation.getBaggage(api.context.active());
|
|
382
417
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
418
|
+
span.setAttribute("runId", currentBaggage?.runId);
|
|
419
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
383
420
|
return optionsOrFn(span);
|
|
384
421
|
};
|
|
385
422
|
return this._tracer.startActiveSpan(name, {}, api.context.active(), wrappedFn2);
|
|
@@ -388,6 +425,8 @@ var BaggageTracer = class {
|
|
|
388
425
|
const wrappedFn2 = (span) => {
|
|
389
426
|
const currentBaggage = api.propagation.getBaggage(api.context.active());
|
|
390
427
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
428
|
+
span.setAttribute("runId", currentBaggage?.runId);
|
|
429
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
391
430
|
return ctxOrFn(span);
|
|
392
431
|
};
|
|
393
432
|
return this._tracer.startActiveSpan(name, optionsOrFn, api.context.active(), wrappedFn2);
|
|
@@ -395,6 +434,8 @@ var BaggageTracer = class {
|
|
|
395
434
|
const wrappedFn = (span) => {
|
|
396
435
|
const currentBaggage = api.propagation.getBaggage(ctxOrFn ?? api.context.active());
|
|
397
436
|
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
437
|
+
span.setAttribute("runId", currentBaggage?.runId);
|
|
438
|
+
span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
|
|
398
439
|
return fn(span);
|
|
399
440
|
};
|
|
400
441
|
return this._tracer.startActiveSpan(name, optionsOrFn, ctxOrFn, wrappedFn);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LibSQLVector } from './chunk-
|
|
2
|
-
import { DefaultProxyStorage } from './chunk-
|
|
3
|
-
import { deepMerge } from './chunk-
|
|
4
|
-
import { MastraBase } from './chunk-
|
|
1
|
+
import { LibSQLVector } from './chunk-BRBHQ6KS.js';
|
|
2
|
+
import { DefaultProxyStorage } from './chunk-H6ZU5N2C.js';
|
|
3
|
+
import { deepMerge } from './chunk-BC5B4EGI.js';
|
|
4
|
+
import { MastraBase } from './chunk-CLJQYXNM.js';
|
|
5
5
|
import { existsSync } from 'fs';
|
|
6
6
|
import { join } from 'path';
|
|
7
7
|
import fsp from 'node:fs/promises';
|
|
@@ -106,11 +106,22 @@ var fastEmbedProvider = experimental_customProvider({
|
|
|
106
106
|
var defaultEmbedder = fastEmbedProvider.textEmbeddingModel;
|
|
107
107
|
|
|
108
108
|
// src/memory/memory.ts
|
|
109
|
+
var MemoryProcessor = class extends MastraBase {
|
|
110
|
+
/**
|
|
111
|
+
* Process a list of messages and return a filtered or transformed list.
|
|
112
|
+
* @param messages The messages to process
|
|
113
|
+
* @returns The processed messages
|
|
114
|
+
*/
|
|
115
|
+
process(messages, _opts) {
|
|
116
|
+
return messages;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
109
119
|
var MastraMemory = class extends MastraBase {
|
|
110
120
|
MAX_CONTEXT_TOKENS;
|
|
111
121
|
storage;
|
|
112
122
|
vector;
|
|
113
123
|
embedder;
|
|
124
|
+
processors = [];
|
|
114
125
|
threadConfig = {
|
|
115
126
|
lastMessages: 40,
|
|
116
127
|
semanticRecall: true,
|
|
@@ -149,6 +160,9 @@ var MastraMemory = class extends MastraBase {
|
|
|
149
160
|
if (config.options) {
|
|
150
161
|
this.threadConfig = this.getMergedThreadConfig(config.options);
|
|
151
162
|
}
|
|
163
|
+
if (config.processors) {
|
|
164
|
+
this.processors = config.processors;
|
|
165
|
+
}
|
|
152
166
|
}
|
|
153
167
|
setStorage(storage) {
|
|
154
168
|
this.storage = storage;
|
|
@@ -191,14 +205,52 @@ var MastraMemory = class extends MastraBase {
|
|
|
191
205
|
getMergedThreadConfig(config) {
|
|
192
206
|
return deepMerge(this.threadConfig, config || {});
|
|
193
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Apply all configured message processors to a list of messages.
|
|
210
|
+
* @param messages The messages to process
|
|
211
|
+
* @returns The processed messages
|
|
212
|
+
*/
|
|
213
|
+
applyProcessors(messages, opts) {
|
|
214
|
+
const processors = opts.processors || this.processors;
|
|
215
|
+
if (!processors || processors.length === 0) {
|
|
216
|
+
return messages;
|
|
217
|
+
}
|
|
218
|
+
let processedMessages = [...messages];
|
|
219
|
+
for (const processor of processors) {
|
|
220
|
+
processedMessages = processor.process(processedMessages, {
|
|
221
|
+
systemMessage: opts.systemMessage,
|
|
222
|
+
newMessages: opts.newMessages,
|
|
223
|
+
memorySystemMessage: opts.memorySystemMessage
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
return processedMessages;
|
|
227
|
+
}
|
|
228
|
+
processMessages({
|
|
229
|
+
messages,
|
|
230
|
+
processors,
|
|
231
|
+
...opts
|
|
232
|
+
}) {
|
|
233
|
+
return this.applyProcessors(messages, { processors: processors || this.processors, ...opts });
|
|
234
|
+
}
|
|
194
235
|
estimateTokens(text) {
|
|
195
236
|
return Math.ceil(text.split(" ").length * 1.3);
|
|
196
237
|
}
|
|
197
238
|
parseMessages(messages) {
|
|
198
|
-
return messages.map((msg) =>
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
239
|
+
return messages.map((msg) => {
|
|
240
|
+
let content = msg.content;
|
|
241
|
+
if (typeof content === "string" && (content.startsWith("[") || content.startsWith("{"))) {
|
|
242
|
+
try {
|
|
243
|
+
content = JSON.parse(content);
|
|
244
|
+
} catch {
|
|
245
|
+
}
|
|
246
|
+
} else if (typeof content === "number") {
|
|
247
|
+
content = String(content);
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
...msg,
|
|
251
|
+
content
|
|
252
|
+
};
|
|
253
|
+
});
|
|
202
254
|
}
|
|
203
255
|
convertToUIMessages(messages) {
|
|
204
256
|
function addToolMessageToChat({
|
|
@@ -307,6 +359,7 @@ var MastraMemory = class extends MastraBase {
|
|
|
307
359
|
*/
|
|
308
360
|
async addMessage({
|
|
309
361
|
threadId,
|
|
362
|
+
resourceId,
|
|
310
363
|
config,
|
|
311
364
|
content,
|
|
312
365
|
role,
|
|
@@ -321,6 +374,7 @@ var MastraMemory = class extends MastraBase {
|
|
|
321
374
|
role,
|
|
322
375
|
createdAt: /* @__PURE__ */ new Date(),
|
|
323
376
|
threadId,
|
|
377
|
+
resourceId,
|
|
324
378
|
type,
|
|
325
379
|
toolNames,
|
|
326
380
|
toolCallArgs,
|
|
@@ -338,4 +392,4 @@ var MastraMemory = class extends MastraBase {
|
|
|
338
392
|
}
|
|
339
393
|
};
|
|
340
394
|
|
|
341
|
-
export { MastraMemory };
|
|
395
|
+
export { MastraMemory, MemoryProcessor };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DefaultProxyStorage } from './chunk-
|
|
2
|
-
import { InstrumentClass, Telemetry } from './chunk-
|
|
3
|
-
import { createLogger, LogLevel, noopLogger } from './chunk-
|
|
1
|
+
import { DefaultProxyStorage } from './chunk-H6ZU5N2C.js';
|
|
2
|
+
import { InstrumentClass, Telemetry } from './chunk-N5ZYOQBL.js';
|
|
3
|
+
import { createLogger, LogLevel, noopLogger } from './chunk-2BVZNKLX.js';
|
|
4
4
|
import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
|
|
5
5
|
|
|
6
6
|
// src/mastra/index.ts
|
|
@@ -21,6 +21,7 @@ var Mastra = class {
|
|
|
21
21
|
#storage;
|
|
22
22
|
#memory;
|
|
23
23
|
#networks;
|
|
24
|
+
#server;
|
|
24
25
|
/**
|
|
25
26
|
* @deprecated use getTelemetry() instead
|
|
26
27
|
*/
|
|
@@ -173,6 +174,9 @@ This is a warning for now, but will throw an error in the future
|
|
|
173
174
|
this.#workflows[key] = workflow;
|
|
174
175
|
});
|
|
175
176
|
}
|
|
177
|
+
if (config?.server) {
|
|
178
|
+
this.#server = config.server;
|
|
179
|
+
}
|
|
176
180
|
this.setLogger({
|
|
177
181
|
logger
|
|
178
182
|
});
|
|
@@ -332,6 +336,9 @@ This is a warning for now, but will throw an error in the future
|
|
|
332
336
|
getNetworks() {
|
|
333
337
|
return Object.values(this.#networks || {});
|
|
334
338
|
}
|
|
339
|
+
getServer() {
|
|
340
|
+
return this.#server;
|
|
341
|
+
}
|
|
335
342
|
/**
|
|
336
343
|
* Get a specific network by ID
|
|
337
344
|
* @param networkId - The ID of the network to retrieve
|
|
@@ -351,6 +358,9 @@ This is a warning for now, but will throw an error in the future
|
|
|
351
358
|
if (!transportId) {
|
|
352
359
|
throw new Error("Transport ID is required");
|
|
353
360
|
}
|
|
361
|
+
if (!this.#logger?.getLogsByRunId) {
|
|
362
|
+
throw new Error("Logger is not set");
|
|
363
|
+
}
|
|
354
364
|
return await this.#logger.getLogsByRunId({
|
|
355
365
|
runId,
|
|
356
366
|
transportId
|
|
@@ -360,6 +370,10 @@ This is a warning for now, but will throw an error in the future
|
|
|
360
370
|
if (!transportId) {
|
|
361
371
|
throw new Error("Transport ID is required");
|
|
362
372
|
}
|
|
373
|
+
if (!this.#logger?.getLogs) {
|
|
374
|
+
throw new Error("Logger is not set");
|
|
375
|
+
}
|
|
376
|
+
console.log(this.#logger);
|
|
363
377
|
return await this.#logger.getLogs(transportId);
|
|
364
378
|
}
|
|
365
379
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkPHWEC4VD_cjs = require('./chunk-PHWEC4VD.cjs');
|
|
4
|
+
var chunkD63P5O4Q_cjs = require('./chunk-D63P5O4Q.cjs');
|
|
5
5
|
var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
|
|
6
6
|
|
|
7
7
|
// src/tts/index.ts
|
|
8
8
|
var _MastraTTS_decorators, _init, _a;
|
|
9
|
-
_MastraTTS_decorators = [
|
|
9
|
+
_MastraTTS_decorators = [chunkPHWEC4VD_cjs.InstrumentClass({
|
|
10
10
|
prefix: "tts",
|
|
11
11
|
excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
|
|
12
12
|
})];
|
|
13
|
-
exports.MastraTTS = class MastraTTS extends (_a =
|
|
13
|
+
exports.MastraTTS = class MastraTTS extends (_a = chunkD63P5O4Q_cjs.MastraBase) {
|
|
14
14
|
model;
|
|
15
15
|
constructor({
|
|
16
16
|
model
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkWAW7QBY4_cjs = require('./chunk-WAW7QBY4.cjs');
|
|
4
4
|
|
|
5
5
|
// src/deployer/index.ts
|
|
6
|
-
var MastraDeployer = class extends
|
|
6
|
+
var MastraDeployer = class extends chunkWAW7QBY4_cjs.MastraBundler {
|
|
7
7
|
constructor({ name }) {
|
|
8
8
|
super({ component: "DEPLOYER", name });
|
|
9
9
|
}
|