@mastra/core 0.2.0-alpha.99 → 0.2.1-alpha.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.
Files changed (84) hide show
  1. package/dist/agent/index.d.ts +6 -8
  2. package/dist/agent/index.js +1 -7
  3. package/dist/{telemetry-oCUM52DG.d.ts → base-BbtPAA6f.d.ts} +50 -8
  4. package/dist/{index-Cwb-5AzX.d.ts → base-C7R9FwZ6.d.ts} +450 -403
  5. package/dist/base.d.ts +3 -43
  6. package/dist/base.js +1 -3
  7. package/dist/bundler/index.d.ts +3 -4
  8. package/dist/bundler/index.js +1 -4
  9. package/dist/{chunk-MCB4M5W4.js → chunk-22LC46YN.js} +3 -9
  10. package/dist/chunk-4ZRHVG25.js +402 -0
  11. package/dist/{chunk-KNPBNSJ7.js → chunk-55GTEVHJ.js} +13 -14
  12. package/dist/chunk-5HXXWLRX.js +626 -0
  13. package/dist/chunk-6TCTOQ3G.js +1204 -0
  14. package/dist/{chunk-ZJOMHCWE.js → chunk-AN562ICT.js} +98 -151
  15. package/dist/chunk-AWEACB2T.js +66 -0
  16. package/dist/chunk-BB4KXGBU.js +83 -0
  17. package/dist/chunk-C6A6W6XS.js +77 -0
  18. package/dist/{chunk-EO3TIPGQ.js → chunk-CUIUUULJ.js} +375 -254
  19. package/dist/chunk-HT63PEVD.js +37 -0
  20. package/dist/chunk-K36NSQWH.js +10 -0
  21. package/dist/chunk-NUDAZEOG.js +35 -0
  22. package/dist/{chunk-ICMEXHKD.js → chunk-O2VP5JBC.js} +48 -55
  23. package/dist/{chunk-42DYOLDV.js → chunk-PNZK456O.js} +13 -21
  24. package/dist/chunk-RG66XEJT.js +8 -0
  25. package/dist/chunk-SIFBBGY6.js +190 -0
  26. package/dist/{chunk-A7SNFYQB.js → chunk-V4WSAQOP.js} +7 -15
  27. package/dist/chunk-V5UMPUKC.js +218 -0
  28. package/dist/{chunk-DHCULRJM.js → chunk-VE4JJJSW.js} +126 -78
  29. package/dist/chunk-ZINPRHAN.js +22 -0
  30. package/dist/{chunk-C55JWGDU.js → chunk-ZJOXJFJI.js} +42 -15
  31. package/dist/deployer/index.d.ts +3 -5
  32. package/dist/deployer/index.js +1 -5
  33. package/dist/eval/index.d.ts +8 -13
  34. package/dist/eval/index.js +1 -3
  35. package/dist/filter/index.js +1 -2
  36. package/dist/hooks/index.d.ts +13 -18
  37. package/dist/hooks/index.js +1 -2
  38. package/dist/{index-CBZ2mk2H.d.ts → index-B2JCcAQt.d.ts} +1 -1
  39. package/dist/index.d.ts +16 -16
  40. package/dist/index.js +37 -67
  41. package/dist/integration/index.d.ts +8 -10
  42. package/dist/integration/index.js +1 -3
  43. package/dist/llm/index.d.ts +6 -8
  44. package/dist/llm/index.js +1 -1
  45. package/dist/logger/index.d.ts +1 -1
  46. package/dist/logger/index.js +1 -2
  47. package/dist/mastra/index.d.ts +23 -25
  48. package/dist/mastra/index.js +1 -9
  49. package/dist/memory/index.d.ts +8 -10
  50. package/dist/memory/index.js +1 -9
  51. package/dist/relevance/index.js +1 -8
  52. package/dist/storage/index.d.ts +21 -10
  53. package/dist/storage/index.js +3 -7
  54. package/dist/telemetry/index.d.ts +35 -5
  55. package/dist/telemetry/index.js +1 -2
  56. package/dist/telemetry/otel-vendor.d.ts +7 -0
  57. package/dist/telemetry/otel-vendor.js +7 -0
  58. package/dist/tools/index.d.ts +6 -8
  59. package/dist/tools/index.js +1 -2
  60. package/dist/tts/index.d.ts +2 -4
  61. package/dist/tts/index.js +1 -5
  62. package/dist/{metric-BWeQNZt6.d.ts → types-m9RryK9a.d.ts} +6 -1
  63. package/dist/utils.js +1 -2
  64. package/dist/vector/index.d.ts +4 -6
  65. package/dist/vector/index.js +1 -4
  66. package/dist/vector/libsql/index.d.ts +2 -4
  67. package/dist/vector/libsql/index.js +1 -6
  68. package/dist/{workflow-DTtv7_Eq.d.ts → workflow-7xHmmFH5.d.ts} +3 -6
  69. package/dist/workflows/index.d.ts +7 -9
  70. package/dist/workflows/index.js +1 -4
  71. package/package.json +22 -18
  72. package/dist/chunk-4LJFWC2Q.js +0 -216
  73. package/dist/chunk-4ZUSEHLH.js +0 -285
  74. package/dist/chunk-AJJZUHB4.js +0 -14
  75. package/dist/chunk-G4MCO7XF.js +0 -70
  76. package/dist/chunk-HBTQNIAX.js +0 -90
  77. package/dist/chunk-HPXWJBQK.js +0 -222
  78. package/dist/chunk-JJ57BXQR.js +0 -16
  79. package/dist/chunk-JP37ODNX.js +0 -36
  80. package/dist/chunk-K3N7KJHH.js +0 -52
  81. package/dist/chunk-MDM2JS2U.js +0 -1288
  82. package/dist/chunk-VOUPGVRD.js +0 -27
  83. package/dist/chunk-Z7JFMQZZ.js +0 -551
  84. /package/dist/{chunk-AE3H2QEY.js → chunk-ZDWFBE5L.js} +0 -0
package/dist/base.d.ts CHANGED
@@ -1,46 +1,6 @@
1
- import * as _opentelemetry_api from '@opentelemetry/api';
2
- import { R as RegisteredLogger, L as Logger, a as LogLevel } from './index-CBZ2mk2H.js';
3
- import { T as Telemetry } from './telemetry-oCUM52DG.js';
1
+ import '@opentelemetry/api';
2
+ import './index-B2JCcAQt.js';
3
+ export { M as MastraBase } from './base-BbtPAA6f.js';
4
4
  import 'pino';
5
5
  import 'stream';
6
- import '@opentelemetry/sdk-node';
7
6
  import '@opentelemetry/sdk-trace-base';
8
-
9
- declare class MastraBase {
10
- component: RegisteredLogger;
11
- protected logger: Logger;
12
- name?: string;
13
- telemetry?: Telemetry;
14
- constructor({ component, name }: {
15
- component?: RegisteredLogger;
16
- name?: string;
17
- });
18
- /**
19
- * Set the logger for the agent
20
- * @param logger
21
- */
22
- __setLogger(logger: Logger): void;
23
- /**
24
- * Internal logging helper that formats and sends logs to the configured logger
25
- * @param level - Severity level of the log
26
- * @param message - Main log message
27
- * @param opts - Optional object for the log
28
- */
29
- log(level: LogLevel, message: string, opts?: Record<string, any>): void;
30
- /**
31
- * Set the telemetry for the
32
- * @param telemetry
33
- */
34
- __setTelemetry(telemetry: Telemetry): void;
35
- /**
36
- * Get the telemetry on the vector
37
- * @returns telemetry
38
- */
39
- __getTelemetry(): Telemetry | undefined;
40
- get experimental_telemetry(): {
41
- tracer: _opentelemetry_api.Tracer;
42
- isEnabled: boolean;
43
- } | undefined;
44
- }
45
-
46
- export { MastraBase };
package/dist/base.js CHANGED
@@ -1,3 +1 @@
1
- export { MastraBase } from './chunk-G4MCO7XF.js';
2
- import './chunk-ICMEXHKD.js';
3
- import './chunk-AJJZUHB4.js';
1
+ export { MastraBase } from './chunk-AWEACB2T.js';
@@ -1,10 +1,8 @@
1
- import { MastraBase } from '../base.js';
1
+ import { M as MastraBase } from '../base-BbtPAA6f.js';
2
2
  import '@opentelemetry/api';
3
- import '../index-CBZ2mk2H.js';
3
+ import '../index-B2JCcAQt.js';
4
4
  import 'pino';
5
5
  import 'stream';
6
- import '../telemetry-oCUM52DG.js';
7
- import '@opentelemetry/sdk-node';
8
6
  import '@opentelemetry/sdk-trace-base';
9
7
 
10
8
  interface IBundler {
@@ -22,6 +20,7 @@ declare abstract class MastraBundler extends MastraBase implements IBundler {
22
20
  loadEnvVars(): Promise<Map<string, string>>;
23
21
  abstract prepare(outputDirectory: string): Promise<void>;
24
22
  abstract writePackageJson(outputDirectory: string, dependencies: Map<string, string>): Promise<void>;
23
+ abstract writeInstrumentationFile(outputDirectory: string): Promise<void>;
25
24
  abstract getEnvFiles(): Promise<string[]>;
26
25
  abstract bundle(entryFile: string, outputDirectory: string): Promise<void>;
27
26
  }
@@ -1,4 +1 @@
1
- export { MastraBundler } from '../chunk-MCB4M5W4.js';
2
- import '../chunk-G4MCO7XF.js';
3
- import '../chunk-ICMEXHKD.js';
4
- import '../chunk-AJJZUHB4.js';
1
+ export { MastraBundler } from '../chunk-22LC46YN.js';
@@ -1,14 +1,10 @@
1
- import { MastraBase } from './chunk-G4MCO7XF.js';
2
- import { __name } from './chunk-AJJZUHB4.js';
1
+ import { MastraBase } from './chunk-AWEACB2T.js';
3
2
  import { parse } from 'dotenv';
4
3
  import { readFile } from 'fs/promises';
5
4
 
6
- var _MastraBundler = class _MastraBundler extends MastraBase {
5
+ var MastraBundler = class extends MastraBase {
7
6
  constructor({ name, component = "BUNDLER" }) {
8
- super({
9
- component,
10
- name
11
- });
7
+ super({ component, name });
12
8
  }
13
9
  async loadEnvVars() {
14
10
  const envVars = /* @__PURE__ */ new Map();
@@ -22,7 +18,5 @@ var _MastraBundler = class _MastraBundler extends MastraBase {
22
18
  return envVars;
23
19
  }
24
20
  };
25
- __name(_MastraBundler, "MastraBundler");
26
- var MastraBundler = _MastraBundler;
27
21
 
28
22
  export { MastraBundler };
@@ -0,0 +1,402 @@
1
+ import { TABLE_TRACES } from './chunk-RG66XEJT.js';
2
+ import { trace, context, propagation, SpanStatusCode, SpanKind } from '@opentelemetry/api';
3
+ import { ExportResultCode } from '@opentelemetry/core';
4
+ import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';
5
+
6
+ function hasActiveTelemetry(tracerName = "default-tracer") {
7
+ try {
8
+ return !!trace.getTracer(tracerName);
9
+ } catch {
10
+ return false;
11
+ }
12
+ }
13
+
14
+ // src/telemetry/telemetry.decorators.ts
15
+ function withSpan(options) {
16
+ return function(_target, propertyKey, descriptor) {
17
+ if (!descriptor || typeof descriptor === "number") return;
18
+ const originalMethod = descriptor.value;
19
+ const methodName = String(propertyKey);
20
+ descriptor.value = function(...args) {
21
+ if (options?.skipIfNoTelemetry && !hasActiveTelemetry(options?.tracerName)) {
22
+ return originalMethod.apply(this, args);
23
+ }
24
+ const tracer = trace.getTracer(options?.tracerName ?? "default-tracer");
25
+ let spanName;
26
+ let spanKind;
27
+ if (typeof options === "string") {
28
+ spanName = options;
29
+ } else if (options) {
30
+ spanName = options.spanName || methodName;
31
+ spanKind = options.spanKind;
32
+ } else {
33
+ spanName = methodName;
34
+ }
35
+ const span = tracer.startSpan(spanName, { kind: spanKind });
36
+ let ctx = trace.setSpan(context.active(), span);
37
+ args.forEach((arg, index) => {
38
+ try {
39
+ span.setAttribute(`${spanName}.argument.${index}`, JSON.stringify(arg));
40
+ } catch (e) {
41
+ span.setAttribute(`${spanName}.argument.${index}`, "[Not Serializable]");
42
+ }
43
+ });
44
+ const currentBaggage = propagation.getBaggage(ctx);
45
+ if (currentBaggage?.componentName) {
46
+ span.setAttribute("componentName", currentBaggage?.componentName);
47
+ span.setAttribute("runId", currentBaggage?.runId);
48
+ } else if (this && this.name) {
49
+ span.setAttribute("componentName", this.name);
50
+ span.setAttribute("runId", this.runId);
51
+ ctx = propagation.setBaggage(ctx, { componentName: this.name, runId: this.runId });
52
+ }
53
+ let result;
54
+ try {
55
+ result = context.with(ctx, () => originalMethod.apply(this, args));
56
+ if (result instanceof Promise) {
57
+ return result.then((resolvedValue) => {
58
+ try {
59
+ span.setAttribute(`${spanName}.result`, JSON.stringify(resolvedValue));
60
+ } catch (e) {
61
+ span.setAttribute(`${spanName}.result`, "[Not Serializable]");
62
+ }
63
+ return resolvedValue;
64
+ }).finally(() => span.end());
65
+ }
66
+ try {
67
+ span.setAttribute(`${spanName}.result`, JSON.stringify(result));
68
+ } catch (e) {
69
+ span.setAttribute(`${spanName}.result`, "[Not Serializable]");
70
+ }
71
+ return result;
72
+ } catch (error) {
73
+ span.setStatus({
74
+ code: SpanStatusCode.ERROR,
75
+ message: error instanceof Error ? error.message : "Unknown error"
76
+ });
77
+ if (error instanceof Error) {
78
+ span.recordException(error);
79
+ }
80
+ throw error;
81
+ } finally {
82
+ if (!(result instanceof Promise)) {
83
+ span.end();
84
+ }
85
+ }
86
+ };
87
+ return descriptor;
88
+ };
89
+ }
90
+ function InstrumentClass(options) {
91
+ return function(target) {
92
+ const methods = Object.getOwnPropertyNames(target.prototype);
93
+ methods.forEach((method) => {
94
+ if (options?.excludeMethods?.includes(method) || method === "constructor") return;
95
+ if (options?.methodFilter && !options.methodFilter(method)) return;
96
+ const descriptor = Object.getOwnPropertyDescriptor(target.prototype, method);
97
+ if (descriptor && typeof descriptor.value === "function") {
98
+ Object.defineProperty(
99
+ target.prototype,
100
+ method,
101
+ withSpan({
102
+ spanName: options?.prefix ? `${options.prefix}.${method}` : method,
103
+ skipIfNoTelemetry: true,
104
+ spanKind: options?.spanKind || SpanKind.INTERNAL,
105
+ tracerName: options?.tracerName
106
+ })(target, method, descriptor)
107
+ );
108
+ }
109
+ });
110
+ return target;
111
+ };
112
+ }
113
+ var OTLPTraceExporter = class {
114
+ storage;
115
+ queue = [];
116
+ serializer;
117
+ logger;
118
+ activeFlush = void 0;
119
+ constructor({ logger, storage }) {
120
+ this.storage = storage;
121
+ this.serializer = JsonTraceSerializer;
122
+ this.logger = logger;
123
+ }
124
+ export(internalRepresentation, resultCallback) {
125
+ const serializedRequest = this.serializer.serializeRequest(internalRepresentation);
126
+ const payload = JSON.parse(Buffer.from(serializedRequest.buffer, "utf8"));
127
+ const items = payload?.resourceSpans?.[0]?.scopeSpans;
128
+ this.logger.debug(`Exporting telemetry: ${items.length} scope spans to be processed [trace batch]`);
129
+ this.queue.push({ data: items, resultCallback });
130
+ if (!this.activeFlush) {
131
+ this.activeFlush = this.flush();
132
+ }
133
+ }
134
+ shutdown() {
135
+ return this.forceFlush();
136
+ }
137
+ flush() {
138
+ const now = /* @__PURE__ */ new Date();
139
+ const items = this.queue.shift();
140
+ if (!items) return Promise.resolve();
141
+ const allSpans = items.data.reduce((acc, scopedSpans) => {
142
+ const { scope, spans } = scopedSpans;
143
+ for (const span of spans) {
144
+ const {
145
+ spanId,
146
+ parentSpanId,
147
+ traceId,
148
+ name,
149
+ kind,
150
+ attributes,
151
+ status,
152
+ events,
153
+ links,
154
+ startTimeUnixNano,
155
+ endTimeUnixNano,
156
+ ...rest
157
+ } = span;
158
+ const startTime = Number(BigInt(startTimeUnixNano) / 1000n);
159
+ const endTime = Number(BigInt(endTimeUnixNano) / 1000n);
160
+ acc.push({
161
+ id: spanId,
162
+ parentSpanId,
163
+ traceId,
164
+ name,
165
+ scope: scope.name,
166
+ kind,
167
+ status: JSON.stringify(status),
168
+ events: JSON.stringify(events),
169
+ links: JSON.stringify(links),
170
+ attributes: JSON.stringify(
171
+ attributes.reduce((acc2, attr) => {
172
+ const valueKey = Object.keys(attr.value)[0];
173
+ if (valueKey) {
174
+ acc2[attr.key] = attr.value[valueKey];
175
+ }
176
+ return acc2;
177
+ }, {})
178
+ ),
179
+ startTime,
180
+ endTime,
181
+ other: JSON.stringify(rest),
182
+ createdAt: now
183
+ });
184
+ }
185
+ return acc;
186
+ }, []);
187
+ return this.storage.__batchInsert({
188
+ tableName: TABLE_TRACES,
189
+ records: allSpans
190
+ }).then(() => {
191
+ items.resultCallback({
192
+ code: ExportResultCode.SUCCESS
193
+ });
194
+ }).catch((e) => {
195
+ this.logger.error("span err:" + e?.message);
196
+ items.resultCallback({
197
+ code: ExportResultCode.FAILED,
198
+ error: e
199
+ });
200
+ }).finally(() => {
201
+ this.activeFlush = void 0;
202
+ });
203
+ }
204
+ async forceFlush() {
205
+ if (!this.queue.length) {
206
+ return;
207
+ }
208
+ await this.activeFlush;
209
+ while (this.queue.length) {
210
+ await this.flush();
211
+ }
212
+ }
213
+ __setLogger(logger) {
214
+ this.logger = logger;
215
+ }
216
+ };
217
+ var Telemetry = class _Telemetry {
218
+ tracer = trace.getTracer("default");
219
+ name = "default-service";
220
+ constructor(config) {
221
+ this.name = config.serviceName ?? "default-service";
222
+ this.tracer = trace.getTracer(this.name);
223
+ }
224
+ /**
225
+ * @deprecated This method does not do anything
226
+ */
227
+ async shutdown() {
228
+ }
229
+ /**
230
+ * Initialize telemetry with the given configuration
231
+ * @param config - Optional telemetry configuration object
232
+ * @returns Telemetry instance that can be used for tracing
233
+ */
234
+ static init(config = {}) {
235
+ try {
236
+ if (!global.__TELEMETRY__) {
237
+ global.__TELEMETRY__ = new _Telemetry(config);
238
+ }
239
+ return global.__TELEMETRY__;
240
+ } catch (error) {
241
+ console.error("Failed to initialize telemetry:", error);
242
+ throw error;
243
+ }
244
+ }
245
+ /**
246
+ * Get the global telemetry instance
247
+ * @throws {Error} If telemetry has not been initialized
248
+ * @returns {Telemetry} The global telemetry instance
249
+ */
250
+ static get() {
251
+ if (!global.__TELEMETRY__) {
252
+ throw new Error("Telemetry not initialized");
253
+ }
254
+ return global.__TELEMETRY__;
255
+ }
256
+ /**
257
+ * Wraps a class instance with telemetry tracing
258
+ * @param instance The class instance to wrap
259
+ * @param options Optional configuration for tracing
260
+ * @returns Wrapped instance with all methods traced
261
+ */
262
+ traceClass(instance, options = {}) {
263
+ const { skipIfNoTelemetry = true } = options;
264
+ if (skipIfNoTelemetry && !hasActiveTelemetry()) {
265
+ return instance;
266
+ }
267
+ const { spanNamePrefix = instance.constructor.name.toLowerCase(), attributes = {}, excludeMethods = [] } = options;
268
+ return new Proxy(instance, {
269
+ get: (target, prop) => {
270
+ const value = target[prop];
271
+ if (typeof value === "function" && prop !== "constructor" && !prop.toString().startsWith("_") && !excludeMethods.includes(prop.toString())) {
272
+ return this.traceMethod(value.bind(target), {
273
+ spanName: `${spanNamePrefix}.${prop.toString()}`,
274
+ attributes: {
275
+ ...attributes,
276
+ [`${spanNamePrefix}.name`]: target.constructor.name,
277
+ [`${spanNamePrefix}.method.name`]: prop.toString()
278
+ }
279
+ });
280
+ }
281
+ return value;
282
+ }
283
+ });
284
+ }
285
+ /**
286
+ * method to trace individual methods with proper context
287
+ * @param method The method to trace
288
+ * @param context Additional context for the trace
289
+ * @returns Wrapped method with tracing
290
+ */
291
+ traceMethod(method, context3) {
292
+ let ctx = context.active();
293
+ const { skipIfNoTelemetry = true } = context3;
294
+ if (skipIfNoTelemetry && !hasActiveTelemetry()) {
295
+ return method;
296
+ }
297
+ return (...args) => {
298
+ const span = this.tracer.startSpan(context3.spanName);
299
+ function handleError(error) {
300
+ span.recordException(error);
301
+ span.setStatus({
302
+ code: SpanStatusCode.ERROR,
303
+ message: error.message
304
+ });
305
+ span.end();
306
+ throw error;
307
+ }
308
+ try {
309
+ let recordResult2 = function(res) {
310
+ try {
311
+ span.setAttribute(`${context3.spanName}.result`, JSON.stringify(res));
312
+ } catch (e) {
313
+ span.setAttribute(`${context3.spanName}.result`, "[Not Serializable]");
314
+ }
315
+ span.end();
316
+ return res;
317
+ };
318
+ if (context3.attributes) {
319
+ span.setAttributes(context3.attributes);
320
+ }
321
+ if (context3.attributes?.componentName) {
322
+ ctx = propagation.setBaggage(ctx, {
323
+ // @ts-ignore
324
+ componentName: context3.attributes.componentName,
325
+ runId: context3.attributes.runId
326
+ });
327
+ } else {
328
+ const currentBaggage = propagation.getBaggage(ctx);
329
+ if (currentBaggage?.componentName) {
330
+ span.setAttribute("componentName", currentBaggage?.componentName);
331
+ span.setAttribute("runId", currentBaggage?.runId);
332
+ } else if (this && this.name) {
333
+ span.setAttribute("componentName", this.name);
334
+ span.setAttribute("runId", this.runId);
335
+ ctx = propagation.setBaggage(ctx, { componentName: this.name, runId: this.runId });
336
+ }
337
+ }
338
+ args.forEach((arg, index) => {
339
+ try {
340
+ span.setAttribute(`${context3.spanName}.argument.${index}`, JSON.stringify(arg));
341
+ } catch (e) {
342
+ span.setAttribute(`${context3.spanName}.argument.${index}`, "[Not Serializable]");
343
+ }
344
+ });
345
+ let result;
346
+ context.with(trace.setSpan(ctx, span), () => {
347
+ result = method(...args);
348
+ });
349
+ if (result instanceof Promise) {
350
+ return result.then(recordResult2).catch(handleError);
351
+ } else {
352
+ return recordResult2(result);
353
+ }
354
+ } catch (error) {
355
+ handleError(error);
356
+ }
357
+ };
358
+ }
359
+ getBaggageTracer() {
360
+ return new BaggageTracer(this.tracer);
361
+ }
362
+ };
363
+ var BaggageTracer = class {
364
+ _tracer;
365
+ constructor(tracer) {
366
+ this._tracer = tracer;
367
+ }
368
+ startSpan(name, options = {}, ctx) {
369
+ ctx = ctx ?? context.active();
370
+ const span = this._tracer.startSpan(name, options, ctx);
371
+ const currentBaggage = propagation.getBaggage(ctx);
372
+ span.setAttribute("componentName", currentBaggage?.componentName);
373
+ span.setAttribute("runId", currentBaggage?.runId);
374
+ return span;
375
+ }
376
+ startActiveSpan(name, optionsOrFn, ctxOrFn, fn) {
377
+ if (typeof optionsOrFn === "function") {
378
+ const wrappedFn2 = (span) => {
379
+ const currentBaggage = propagation.getBaggage(context.active());
380
+ span.setAttribute("componentName", currentBaggage?.componentName);
381
+ return optionsOrFn(span);
382
+ };
383
+ return this._tracer.startActiveSpan(name, {}, context.active(), wrappedFn2);
384
+ }
385
+ if (typeof ctxOrFn === "function") {
386
+ const wrappedFn2 = (span) => {
387
+ const currentBaggage = propagation.getBaggage(context.active());
388
+ span.setAttribute("componentName", currentBaggage?.componentName);
389
+ return ctxOrFn(span);
390
+ };
391
+ return this._tracer.startActiveSpan(name, optionsOrFn, context.active(), wrappedFn2);
392
+ }
393
+ const wrappedFn = (span) => {
394
+ const currentBaggage = propagation.getBaggage(ctxOrFn ?? context.active());
395
+ span.setAttribute("componentName", currentBaggage?.componentName);
396
+ return fn(span);
397
+ };
398
+ return this._tracer.startActiveSpan(name, optionsOrFn, ctxOrFn, wrappedFn);
399
+ }
400
+ };
401
+
402
+ export { InstrumentClass, OTLPTraceExporter, Telemetry, hasActiveTelemetry, withSpan };
@@ -1,7 +1,7 @@
1
- import { __name } from './chunk-AJJZUHB4.js';
2
1
  import { z } from 'zod';
3
2
 
4
- var delay = /* @__PURE__ */ __name((ms) => new Promise((resolve) => setTimeout(resolve, ms)), "delay");
3
+ // src/utils.ts
4
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
5
5
  function jsonSchemaPropertiesToTSTypes(value) {
6
6
  if (!value.type) {
7
7
  return z.object({});
@@ -29,8 +29,10 @@ Examples: ${value.examples.join(", ")}` : ""));
29
29
  Examples: ${value.examples.join(", ")}` : ""));
30
30
  break;
31
31
  case "object":
32
- zodType = jsonSchemaToModel(value).describe((value.description || "") + (value.examples ? `
33
- Examples: ${value.examples.join(", ")}` : ""));
32
+ zodType = jsonSchemaToModel(value).describe(
33
+ (value.description || "") + (value.examples ? `
34
+ Examples: ${value.examples.join(", ")}` : "")
35
+ );
34
36
  break;
35
37
  case "null":
36
38
  zodType = z.null().describe(value.description || "");
@@ -40,7 +42,6 @@ Examples: ${value.examples.join(", ")}` : ""));
40
42
  }
41
43
  return zodType;
42
44
  }
43
- __name(jsonSchemaPropertiesToTSTypes, "jsonSchemaPropertiesToTSTypes");
44
45
  function jsonSchemaToModel(jsonSchema) {
45
46
  const properties = jsonSchema.properties;
46
47
  const requiredFields = jsonSchema.required || [];
@@ -57,7 +58,10 @@ function jsonSchemaToModel(jsonSchema) {
57
58
  Examples: ${value.examples.join(", ")}` : ""));
58
59
  } else if (value.allOf) {
59
60
  const allOfTypes = value.allOf.map((schema) => jsonSchemaPropertiesToTSTypes(schema));
60
- zodType = z.intersection(allOfTypes[0], allOfTypes.slice(1).reduce((acc, schema) => acc.and(schema), allOfTypes[0])).describe((value.description || "") + (value.examples ? `
61
+ zodType = z.intersection(
62
+ allOfTypes[0],
63
+ allOfTypes.slice(1).reduce((acc, schema) => acc.and(schema), allOfTypes[0])
64
+ ).describe((value.description || "") + (value.examples ? `
61
65
  Examples: ${value.examples.join(", ")}` : ""));
62
66
  } else {
63
67
  if (!value.type) {
@@ -76,11 +80,8 @@ Examples: ${value.examples.join(", ")}` : ""));
76
80
  }
77
81
  return z.object(zodSchema);
78
82
  }
79
- __name(jsonSchemaToModel, "jsonSchemaToModel");
80
83
  function deepMerge(target, source) {
81
- const output = {
82
- ...target
83
- };
84
+ const output = { ...target };
84
85
  if (!source) return output;
85
86
  Object.keys(source).forEach((key) => {
86
87
  const targetValue = output[key];
@@ -89,13 +90,12 @@ function deepMerge(target, source) {
89
90
  output[key] = sourceValue;
90
91
  } else if (sourceValue instanceof Object && targetValue instanceof Object && !Array.isArray(sourceValue) && !Array.isArray(targetValue)) {
91
92
  output[key] = deepMerge(targetValue, sourceValue);
92
- } else if (sourceValue !== undefined) {
93
+ } else if (sourceValue !== void 0) {
93
94
  output[key] = sourceValue;
94
95
  }
95
96
  });
96
97
  return output;
97
98
  }
98
- __name(deepMerge, "deepMerge");
99
99
  async function* maskStreamTags(stream, tag, options = {}) {
100
100
  const { onStart, onEnd, onMask } = options;
101
101
  const openTag = `<${tag}>`;
@@ -104,7 +104,7 @@ async function* maskStreamTags(stream, tag, options = {}) {
104
104
  let fullContent = "";
105
105
  let isMasking = false;
106
106
  let isBuffering = false;
107
- const startsWith = /* @__PURE__ */ __name((text, pattern) => text.trim().startsWith(pattern.trim()), "startsWith");
107
+ const startsWith = (text, pattern) => text.trim().startsWith(pattern.trim());
108
108
  for await (const chunk of stream) {
109
109
  fullContent += chunk;
110
110
  if (isBuffering) buffer += chunk;
@@ -140,6 +140,5 @@ async function* maskStreamTags(stream, tag, options = {}) {
140
140
  yield chunk;
141
141
  }
142
142
  }
143
- __name(maskStreamTags, "maskStreamTags");
144
143
 
145
144
  export { deepMerge, delay, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, maskStreamTags };