@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as MastraStorage, g as TABLE_NAMES, h as StorageColumn, i as StorageThreadType, j as MessageType, k as StorageGetMessagesArg, E as EvalRow } from '../../base-CIPKleAU.cjs';
|
|
2
2
|
import 'ai';
|
|
3
3
|
import '../../base-DboIg_Cd.cjs';
|
|
4
4
|
import '@opentelemetry/api';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as MastraStorage, g as TABLE_NAMES, h as StorageColumn, i as StorageThreadType, j as MessageType, k as StorageGetMessagesArg, E as EvalRow } from '../../base-C_Oq53qk.js';
|
|
2
2
|
import 'ai';
|
|
3
3
|
import '../../base-BZViaFTt.js';
|
|
4
4
|
import '@opentelemetry/api';
|
package/dist/telemetry/index.cjs
CHANGED
|
@@ -1,413 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var core = require('@opentelemetry/core');
|
|
5
|
-
var otlpTransformer = require('@opentelemetry/otlp-transformer');
|
|
3
|
+
var chunkXB2TJ7LX_cjs = require('../chunk-XB2TJ7LX.cjs');
|
|
6
4
|
|
|
7
|
-
// src/telemetry/telemetry.decorators.ts
|
|
8
|
-
function hasActiveTelemetry(tracerName = "default-tracer") {
|
|
9
|
-
try {
|
|
10
|
-
return !!api.trace.getTracer(tracerName);
|
|
11
|
-
} catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
5
|
|
|
16
|
-
// src/telemetry/telemetry.decorators.ts
|
|
17
|
-
function withSpan(options) {
|
|
18
|
-
return function(_target, propertyKey, descriptor) {
|
|
19
|
-
if (!descriptor || typeof descriptor === "number") return;
|
|
20
|
-
const originalMethod = descriptor.value;
|
|
21
|
-
const methodName = String(propertyKey);
|
|
22
|
-
descriptor.value = function(...args) {
|
|
23
|
-
if (options?.skipIfNoTelemetry && !hasActiveTelemetry(options?.tracerName)) {
|
|
24
|
-
return originalMethod.apply(this, args);
|
|
25
|
-
}
|
|
26
|
-
const tracer = api.trace.getTracer(options?.tracerName ?? "default-tracer");
|
|
27
|
-
let spanName;
|
|
28
|
-
let spanKind;
|
|
29
|
-
if (typeof options === "string") {
|
|
30
|
-
spanName = options;
|
|
31
|
-
} else if (options) {
|
|
32
|
-
spanName = options.spanName || methodName;
|
|
33
|
-
spanKind = options.spanKind;
|
|
34
|
-
} else {
|
|
35
|
-
spanName = methodName;
|
|
36
|
-
}
|
|
37
|
-
const span = tracer.startSpan(spanName, { kind: spanKind });
|
|
38
|
-
let ctx = api.trace.setSpan(api.context.active(), span);
|
|
39
|
-
args.forEach((arg, index) => {
|
|
40
|
-
try {
|
|
41
|
-
span.setAttribute(`${spanName}.argument.${index}`, JSON.stringify(arg));
|
|
42
|
-
} catch {
|
|
43
|
-
span.setAttribute(`${spanName}.argument.${index}`, "[Not Serializable]");
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const currentBaggage = api.propagation.getBaggage(ctx);
|
|
47
|
-
if (currentBaggage?.componentName) {
|
|
48
|
-
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
49
|
-
span.setAttribute("runId", currentBaggage?.runId);
|
|
50
|
-
} else if (this && this.name) {
|
|
51
|
-
span.setAttribute("componentName", this.name);
|
|
52
|
-
span.setAttribute("runId", this.runId);
|
|
53
|
-
ctx = api.propagation.setBaggage(ctx, { componentName: this.name, runId: this.runId });
|
|
54
|
-
}
|
|
55
|
-
let result;
|
|
56
|
-
try {
|
|
57
|
-
result = api.context.with(ctx, () => originalMethod.apply(this, args));
|
|
58
|
-
if (result instanceof Promise) {
|
|
59
|
-
return result.then((resolvedValue) => {
|
|
60
|
-
try {
|
|
61
|
-
span.setAttribute(`${spanName}.result`, JSON.stringify(resolvedValue));
|
|
62
|
-
} catch {
|
|
63
|
-
span.setAttribute(`${spanName}.result`, "[Not Serializable]");
|
|
64
|
-
}
|
|
65
|
-
return resolvedValue;
|
|
66
|
-
}).finally(() => span.end());
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
span.setAttribute(`${spanName}.result`, JSON.stringify(result));
|
|
70
|
-
} catch {
|
|
71
|
-
span.setAttribute(`${spanName}.result`, "[Not Serializable]");
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
74
|
-
} catch (error) {
|
|
75
|
-
span.setStatus({
|
|
76
|
-
code: api.SpanStatusCode.ERROR,
|
|
77
|
-
message: error instanceof Error ? error.message : "Unknown error"
|
|
78
|
-
});
|
|
79
|
-
if (error instanceof Error) {
|
|
80
|
-
span.recordException(error);
|
|
81
|
-
}
|
|
82
|
-
throw error;
|
|
83
|
-
} finally {
|
|
84
|
-
if (!(result instanceof Promise)) {
|
|
85
|
-
span.end();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
return descriptor;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
function InstrumentClass(options) {
|
|
93
|
-
return function(target) {
|
|
94
|
-
const methods = Object.getOwnPropertyNames(target.prototype);
|
|
95
|
-
methods.forEach((method) => {
|
|
96
|
-
if (options?.excludeMethods?.includes(method) || method === "constructor") return;
|
|
97
|
-
if (options?.methodFilter && !options.methodFilter(method)) return;
|
|
98
|
-
const descriptor = Object.getOwnPropertyDescriptor(target.prototype, method);
|
|
99
|
-
if (descriptor && typeof descriptor.value === "function") {
|
|
100
|
-
Object.defineProperty(
|
|
101
|
-
target.prototype,
|
|
102
|
-
method,
|
|
103
|
-
withSpan({
|
|
104
|
-
spanName: options?.prefix ? `${options.prefix}.${method}` : method,
|
|
105
|
-
skipIfNoTelemetry: true,
|
|
106
|
-
spanKind: options?.spanKind || api.SpanKind.INTERNAL,
|
|
107
|
-
tracerName: options?.tracerName
|
|
108
|
-
})(target, method, descriptor)
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
return target;
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
6
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.queue.push({ data: items, resultCallback });
|
|
137
|
-
if (!this.activeFlush) {
|
|
138
|
-
this.activeFlush = this.flush();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
shutdown() {
|
|
142
|
-
return this.forceFlush();
|
|
143
|
-
}
|
|
144
|
-
flush() {
|
|
145
|
-
const now = /* @__PURE__ */ new Date();
|
|
146
|
-
const items = this.queue.shift();
|
|
147
|
-
if (!items) return Promise.resolve();
|
|
148
|
-
const allSpans = items.data.reduce((acc, scopedSpans) => {
|
|
149
|
-
const { scope, spans } = scopedSpans;
|
|
150
|
-
for (const span of spans) {
|
|
151
|
-
const {
|
|
152
|
-
spanId,
|
|
153
|
-
parentSpanId,
|
|
154
|
-
traceId,
|
|
155
|
-
name,
|
|
156
|
-
kind,
|
|
157
|
-
attributes,
|
|
158
|
-
status,
|
|
159
|
-
events,
|
|
160
|
-
links,
|
|
161
|
-
startTimeUnixNano,
|
|
162
|
-
endTimeUnixNano,
|
|
163
|
-
...rest
|
|
164
|
-
} = span;
|
|
165
|
-
const startTime = Number(BigInt(startTimeUnixNano) / 1000n);
|
|
166
|
-
const endTime = Number(BigInt(endTimeUnixNano) / 1000n);
|
|
167
|
-
acc.push({
|
|
168
|
-
id: spanId,
|
|
169
|
-
parentSpanId,
|
|
170
|
-
traceId,
|
|
171
|
-
name,
|
|
172
|
-
scope: scope.name,
|
|
173
|
-
kind,
|
|
174
|
-
status: JSON.stringify(status),
|
|
175
|
-
events: JSON.stringify(events),
|
|
176
|
-
links: JSON.stringify(links),
|
|
177
|
-
attributes: JSON.stringify(
|
|
178
|
-
attributes.reduce((acc2, attr) => {
|
|
179
|
-
const valueKey = Object.keys(attr.value)[0];
|
|
180
|
-
if (valueKey) {
|
|
181
|
-
acc2[attr.key] = attr.value[valueKey];
|
|
182
|
-
}
|
|
183
|
-
return acc2;
|
|
184
|
-
}, {})
|
|
185
|
-
),
|
|
186
|
-
startTime,
|
|
187
|
-
endTime,
|
|
188
|
-
other: JSON.stringify(rest),
|
|
189
|
-
createdAt: now
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
return acc;
|
|
193
|
-
}, []);
|
|
194
|
-
return this.storage.__batchInsert({
|
|
195
|
-
tableName: TABLE_TRACES,
|
|
196
|
-
records: allSpans
|
|
197
|
-
}).then(() => {
|
|
198
|
-
items.resultCallback({
|
|
199
|
-
code: core.ExportResultCode.SUCCESS
|
|
200
|
-
});
|
|
201
|
-
}).catch((e) => {
|
|
202
|
-
this.logger.error("span err:" + e?.message);
|
|
203
|
-
items.resultCallback({
|
|
204
|
-
code: core.ExportResultCode.FAILED,
|
|
205
|
-
error: e
|
|
206
|
-
});
|
|
207
|
-
}).finally(() => {
|
|
208
|
-
this.activeFlush = void 0;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
async forceFlush() {
|
|
212
|
-
if (!this.queue.length) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
await this.activeFlush;
|
|
216
|
-
while (this.queue.length) {
|
|
217
|
-
await this.flush();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
__setLogger(logger) {
|
|
221
|
-
this.logger = logger;
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
var Telemetry = class _Telemetry {
|
|
225
|
-
tracer = api.trace.getTracer("default");
|
|
226
|
-
name = "default-service";
|
|
227
|
-
constructor(config) {
|
|
228
|
-
this.name = config.serviceName ?? "default-service";
|
|
229
|
-
this.tracer = api.trace.getTracer(this.name);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* @deprecated This method does not do anything
|
|
233
|
-
*/
|
|
234
|
-
async shutdown() {
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Initialize telemetry with the given configuration
|
|
238
|
-
* @param config - Optional telemetry configuration object
|
|
239
|
-
* @returns Telemetry instance that can be used for tracing
|
|
240
|
-
*/
|
|
241
|
-
static init(config = {}) {
|
|
242
|
-
try {
|
|
243
|
-
if (!global.__TELEMETRY__) {
|
|
244
|
-
global.__TELEMETRY__ = new _Telemetry(config);
|
|
245
|
-
}
|
|
246
|
-
return global.__TELEMETRY__;
|
|
247
|
-
} catch (error) {
|
|
248
|
-
console.error("Failed to initialize telemetry:", error);
|
|
249
|
-
throw error;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Get the global telemetry instance
|
|
254
|
-
* @throws {Error} If telemetry has not been initialized
|
|
255
|
-
* @returns {Telemetry} The global telemetry instance
|
|
256
|
-
*/
|
|
257
|
-
static get() {
|
|
258
|
-
if (!global.__TELEMETRY__) {
|
|
259
|
-
throw new Error("Telemetry not initialized");
|
|
260
|
-
}
|
|
261
|
-
return global.__TELEMETRY__;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Wraps a class instance with telemetry tracing
|
|
265
|
-
* @param instance The class instance to wrap
|
|
266
|
-
* @param options Optional configuration for tracing
|
|
267
|
-
* @returns Wrapped instance with all methods traced
|
|
268
|
-
*/
|
|
269
|
-
traceClass(instance, options = {}) {
|
|
270
|
-
const { skipIfNoTelemetry = true } = options;
|
|
271
|
-
if (skipIfNoTelemetry && !hasActiveTelemetry()) {
|
|
272
|
-
return instance;
|
|
273
|
-
}
|
|
274
|
-
const { spanNamePrefix = instance.constructor.name.toLowerCase(), attributes = {}, excludeMethods = [] } = options;
|
|
275
|
-
return new Proxy(instance, {
|
|
276
|
-
get: (target, prop) => {
|
|
277
|
-
const value = target[prop];
|
|
278
|
-
if (typeof value === "function" && prop !== "constructor" && !prop.toString().startsWith("_") && !excludeMethods.includes(prop.toString())) {
|
|
279
|
-
return this.traceMethod(value.bind(target), {
|
|
280
|
-
spanName: `${spanNamePrefix}.${prop.toString()}`,
|
|
281
|
-
attributes: {
|
|
282
|
-
...attributes,
|
|
283
|
-
[`${spanNamePrefix}.name`]: target.constructor.name,
|
|
284
|
-
[`${spanNamePrefix}.method.name`]: prop.toString()
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
return value;
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* method to trace individual methods with proper context
|
|
294
|
-
* @param method The method to trace
|
|
295
|
-
* @param context Additional context for the trace
|
|
296
|
-
* @returns Wrapped method with tracing
|
|
297
|
-
*/
|
|
298
|
-
traceMethod(method, context3) {
|
|
299
|
-
let ctx = api.context.active();
|
|
300
|
-
const { skipIfNoTelemetry = true } = context3;
|
|
301
|
-
if (skipIfNoTelemetry && !hasActiveTelemetry()) {
|
|
302
|
-
return method;
|
|
303
|
-
}
|
|
304
|
-
return (...args) => {
|
|
305
|
-
const span = this.tracer.startSpan(context3.spanName);
|
|
306
|
-
function handleError(error) {
|
|
307
|
-
span.recordException(error);
|
|
308
|
-
span.setStatus({
|
|
309
|
-
code: api.SpanStatusCode.ERROR,
|
|
310
|
-
message: error.message
|
|
311
|
-
});
|
|
312
|
-
span.end();
|
|
313
|
-
throw error;
|
|
314
|
-
}
|
|
315
|
-
try {
|
|
316
|
-
let recordResult2 = function(res) {
|
|
317
|
-
try {
|
|
318
|
-
span.setAttribute(`${context3.spanName}.result`, JSON.stringify(res));
|
|
319
|
-
} catch {
|
|
320
|
-
span.setAttribute(`${context3.spanName}.result`, "[Not Serializable]");
|
|
321
|
-
}
|
|
322
|
-
span.end();
|
|
323
|
-
return res;
|
|
324
|
-
};
|
|
325
|
-
if (context3.attributes) {
|
|
326
|
-
span.setAttributes(context3.attributes);
|
|
327
|
-
}
|
|
328
|
-
if (context3.attributes?.componentName) {
|
|
329
|
-
ctx = api.propagation.setBaggage(ctx, {
|
|
330
|
-
// @ts-ignore
|
|
331
|
-
componentName: context3.attributes.componentName,
|
|
332
|
-
runId: context3.attributes.runId
|
|
333
|
-
});
|
|
334
|
-
} else {
|
|
335
|
-
const currentBaggage = api.propagation.getBaggage(ctx);
|
|
336
|
-
if (currentBaggage?.componentName) {
|
|
337
|
-
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
338
|
-
span.setAttribute("runId", currentBaggage?.runId);
|
|
339
|
-
} else if (this && this.name) {
|
|
340
|
-
span.setAttribute("componentName", this.name);
|
|
341
|
-
span.setAttribute("runId", this.runId);
|
|
342
|
-
ctx = api.propagation.setBaggage(ctx, { componentName: this.name, runId: this.runId });
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
args.forEach((arg, index) => {
|
|
346
|
-
try {
|
|
347
|
-
span.setAttribute(`${context3.spanName}.argument.${index}`, JSON.stringify(arg));
|
|
348
|
-
} catch {
|
|
349
|
-
span.setAttribute(`${context3.spanName}.argument.${index}`, "[Not Serializable]");
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
let result;
|
|
353
|
-
api.context.with(api.trace.setSpan(ctx, span), () => {
|
|
354
|
-
result = method(...args);
|
|
355
|
-
});
|
|
356
|
-
if (result instanceof Promise) {
|
|
357
|
-
return result.then(recordResult2).catch(handleError);
|
|
358
|
-
} else {
|
|
359
|
-
return recordResult2(result);
|
|
360
|
-
}
|
|
361
|
-
} catch (error) {
|
|
362
|
-
handleError(error);
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
getBaggageTracer() {
|
|
367
|
-
return new BaggageTracer(this.tracer);
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
var BaggageTracer = class {
|
|
371
|
-
_tracer;
|
|
372
|
-
constructor(tracer) {
|
|
373
|
-
this._tracer = tracer;
|
|
374
|
-
}
|
|
375
|
-
startSpan(name, options = {}, ctx) {
|
|
376
|
-
ctx = ctx ?? api.context.active();
|
|
377
|
-
const span = this._tracer.startSpan(name, options, ctx);
|
|
378
|
-
const currentBaggage = api.propagation.getBaggage(ctx);
|
|
379
|
-
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
380
|
-
span.setAttribute("runId", currentBaggage?.runId);
|
|
381
|
-
return span;
|
|
382
|
-
}
|
|
383
|
-
startActiveSpan(name, optionsOrFn, ctxOrFn, fn) {
|
|
384
|
-
if (typeof optionsOrFn === "function") {
|
|
385
|
-
const wrappedFn2 = (span) => {
|
|
386
|
-
const currentBaggage = api.propagation.getBaggage(api.context.active());
|
|
387
|
-
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
388
|
-
return optionsOrFn(span);
|
|
389
|
-
};
|
|
390
|
-
return this._tracer.startActiveSpan(name, {}, api.context.active(), wrappedFn2);
|
|
391
|
-
}
|
|
392
|
-
if (typeof ctxOrFn === "function") {
|
|
393
|
-
const wrappedFn2 = (span) => {
|
|
394
|
-
const currentBaggage = api.propagation.getBaggage(api.context.active());
|
|
395
|
-
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
396
|
-
return ctxOrFn(span);
|
|
397
|
-
};
|
|
398
|
-
return this._tracer.startActiveSpan(name, optionsOrFn, api.context.active(), wrappedFn2);
|
|
399
|
-
}
|
|
400
|
-
const wrappedFn = (span) => {
|
|
401
|
-
const currentBaggage = api.propagation.getBaggage(ctxOrFn ?? api.context.active());
|
|
402
|
-
span.setAttribute("componentName", currentBaggage?.componentName);
|
|
403
|
-
return fn(span);
|
|
404
|
-
};
|
|
405
|
-
return this._tracer.startActiveSpan(name, optionsOrFn, ctxOrFn, wrappedFn);
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
exports.InstrumentClass = InstrumentClass;
|
|
410
|
-
exports.OTLPStorageExporter = OTLPTraceExporter;
|
|
411
|
-
exports.Telemetry = Telemetry;
|
|
412
|
-
exports.hasActiveTelemetry = hasActiveTelemetry;
|
|
413
|
-
exports.withSpan = withSpan;
|
|
7
|
+
Object.defineProperty(exports, "InstrumentClass", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkXB2TJ7LX_cjs.InstrumentClass; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "OTLPStorageExporter", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkXB2TJ7LX_cjs.OTLPTraceExporter; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "Telemetry", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkXB2TJ7LX_cjs.Telemetry; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "hasActiveTelemetry", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkXB2TJ7LX_cjs.hasActiveTelemetry; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "withSpan", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkXB2TJ7LX_cjs.withSpan; }
|
|
26
|
+
});
|
|
@@ -3,7 +3,7 @@ import { SpanKind } from '@opentelemetry/api';
|
|
|
3
3
|
import { ExportResult } from '@opentelemetry/core';
|
|
4
4
|
import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
5
5
|
import { L as Logger } from '../index-mKY1XrpK.cjs';
|
|
6
|
-
import {
|
|
6
|
+
import { f as MastraStorage } from '../base-CIPKleAU.cjs';
|
|
7
7
|
import 'stream';
|
|
8
8
|
import 'pino';
|
|
9
9
|
import 'ai';
|
|
@@ -3,7 +3,7 @@ import { SpanKind } from '@opentelemetry/api';
|
|
|
3
3
|
import { ExportResult } from '@opentelemetry/core';
|
|
4
4
|
import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
5
5
|
import { L as Logger } from '../index-mKY1XrpK.js';
|
|
6
|
-
import {
|
|
6
|
+
import { f as MastraStorage } from '../base-C_Oq53qk.js';
|
|
7
7
|
import 'stream';
|
|
8
8
|
import 'pino';
|
|
9
9
|
import 'ai';
|
package/dist/tools/index.cjs
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var Tool = class {
|
|
5
|
-
id;
|
|
6
|
-
description;
|
|
7
|
-
inputSchema;
|
|
8
|
-
outputSchema;
|
|
9
|
-
execute;
|
|
10
|
-
mastra;
|
|
11
|
-
constructor(opts) {
|
|
12
|
-
this.id = opts.id;
|
|
13
|
-
this.description = opts.description;
|
|
14
|
-
this.inputSchema = opts.inputSchema;
|
|
15
|
-
this.outputSchema = opts.outputSchema;
|
|
16
|
-
this.execute = opts.execute;
|
|
17
|
-
this.mastra = opts.mastra;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
function createTool(opts) {
|
|
21
|
-
return new Tool(opts);
|
|
22
|
-
}
|
|
3
|
+
var chunk2W2GYEYQ_cjs = require('../chunk-2W2GYEYQ.cjs');
|
|
23
4
|
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "Tool", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunk2W2GYEYQ_cjs.Tool; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "createTool", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunk2W2GYEYQ_cjs.createTool; }
|
|
14
|
+
});
|
package/dist/tools/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
export { C as CoreTool, V as VercelTool } from '../base-
|
|
2
|
+
import { m as ToolExecutionContext, T as ToolAction, M as Mastra } from '../base-CIPKleAU.cjs';
|
|
3
|
+
export { C as CoreTool, V as VercelTool } from '../base-CIPKleAU.cjs';
|
|
4
4
|
import 'ai';
|
|
5
5
|
import '../base-DboIg_Cd.cjs';
|
|
6
6
|
import '@opentelemetry/api';
|
|
@@ -23,7 +23,7 @@ declare class Tool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchem
|
|
|
23
23
|
description: string;
|
|
24
24
|
inputSchema?: TSchemaIn;
|
|
25
25
|
outputSchema?: TSchemaOut;
|
|
26
|
-
execute
|
|
26
|
+
execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
|
|
27
27
|
mastra?: Mastra;
|
|
28
28
|
constructor(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>);
|
|
29
29
|
}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
export { C as CoreTool, V as VercelTool } from '../base-
|
|
2
|
+
import { m as ToolExecutionContext, T as ToolAction, M as Mastra } from '../base-C_Oq53qk.js';
|
|
3
|
+
export { C as CoreTool, V as VercelTool } from '../base-C_Oq53qk.js';
|
|
4
4
|
import 'ai';
|
|
5
5
|
import '../base-BZViaFTt.js';
|
|
6
6
|
import '@opentelemetry/api';
|
|
@@ -23,7 +23,7 @@ declare class Tool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchem
|
|
|
23
23
|
description: string;
|
|
24
24
|
inputSchema?: TSchemaIn;
|
|
25
25
|
outputSchema?: TSchemaOut;
|
|
26
|
-
execute
|
|
26
|
+
execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
|
|
27
27
|
mastra?: Mastra;
|
|
28
28
|
constructor(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>);
|
|
29
29
|
}
|