@mastra/fastembed 1.3.5-alpha.3 → 1.3.6-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.
package/dist/index.js CHANGED
@@ -10889,7 +10889,7 @@ function logProxy$2(funcName, namespace, args) {
10889
10889
  * of the levels are defined to match the original values from the initial LogLevel to avoid
10890
10890
  * compatibility/migration issues for any implementation that assume the numeric ordering.
10891
10891
  */
10892
- var DiagLogLevel$2;
10892
+ var DiagLogLevel$1;
10893
10893
  (function(DiagLogLevel) {
10894
10894
  /** Diagnostic Logging level setting to disable all logging (except and forced logs) */
10895
10895
  DiagLogLevel[DiagLogLevel["NONE"] = 0] = "NONE";
@@ -10908,10 +10908,10 @@ var DiagLogLevel$2;
10908
10908
  DiagLogLevel[DiagLogLevel["VERBOSE"] = 80] = "VERBOSE";
10909
10909
  /** Used to set the logging level to include all logging */
10910
10910
  DiagLogLevel[DiagLogLevel["ALL"] = 9999] = "ALL";
10911
- })(DiagLogLevel$2 || (DiagLogLevel$2 = {}));
10911
+ })(DiagLogLevel$1 || (DiagLogLevel$1 = {}));
10912
10912
  function createLogLevelDiagLogger$2(maxLevel, logger) {
10913
- if (maxLevel < DiagLogLevel$2.NONE) maxLevel = DiagLogLevel$2.NONE;
10914
- else if (maxLevel > DiagLogLevel$2.ALL) maxLevel = DiagLogLevel$2.ALL;
10913
+ if (maxLevel < DiagLogLevel$1.NONE) maxLevel = DiagLogLevel$1.NONE;
10914
+ else if (maxLevel > DiagLogLevel$1.ALL) maxLevel = DiagLogLevel$1.ALL;
10915
10915
  logger = logger || {};
10916
10916
  function _filterFunc(funcName, theLevel) {
10917
10917
  var theFunc = logger[funcName];
@@ -10919,11 +10919,11 @@ function createLogLevelDiagLogger$2(maxLevel, logger) {
10919
10919
  return function() {};
10920
10920
  }
10921
10921
  return {
10922
- error: _filterFunc("error", DiagLogLevel$2.ERROR),
10923
- warn: _filterFunc("warn", DiagLogLevel$2.WARN),
10924
- info: _filterFunc("info", DiagLogLevel$2.INFO),
10925
- debug: _filterFunc("debug", DiagLogLevel$2.DEBUG),
10926
- verbose: _filterFunc("verbose", DiagLogLevel$2.VERBOSE)
10922
+ error: _filterFunc("error", DiagLogLevel$1.ERROR),
10923
+ warn: _filterFunc("warn", DiagLogLevel$1.WARN),
10924
+ info: _filterFunc("info", DiagLogLevel$1.INFO),
10925
+ debug: _filterFunc("debug", DiagLogLevel$1.DEBUG),
10926
+ verbose: _filterFunc("verbose", DiagLogLevel$1.VERBOSE)
10927
10927
  };
10928
10928
  }
10929
10929
  var __read$2$1 = function(o, n) {
@@ -10975,7 +10975,7 @@ var DiagAPI$2 = function() {
10975
10975
  var self = this;
10976
10976
  var setLogger = function(logger, optionsOrLogLevel) {
10977
10977
  var _a, _b, _c;
10978
- if (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel$2.INFO };
10978
+ if (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel$1.INFO };
10979
10979
  if (logger === self) {
10980
10980
  var err = /* @__PURE__ */ new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
10981
10981
  self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
@@ -10983,7 +10983,7 @@ var DiagAPI$2 = function() {
10983
10983
  }
10984
10984
  if (typeof optionsOrLogLevel === "number") optionsOrLogLevel = { logLevel: optionsOrLogLevel };
10985
10985
  var oldLogger = getGlobal$2("diag");
10986
- var newLogger = createLogLevelDiagLogger$2((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel$2.INFO, logger);
10986
+ var newLogger = createLogLevelDiagLogger$2((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel$1.INFO, logger);
10987
10987
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
10988
10988
  var stack = (_c = (/* @__PURE__ */ new Error()).stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
10989
10989
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -11178,17 +11178,17 @@ var ContextAPI$2 = function() {
11178
11178
  };
11179
11179
  return ContextAPI;
11180
11180
  }();
11181
- var TraceFlags$2;
11181
+ var TraceFlags$1;
11182
11182
  (function(TraceFlags) {
11183
11183
  /** Represents no flag set. */
11184
11184
  TraceFlags[TraceFlags["NONE"] = 0] = "NONE";
11185
11185
  /** Bit to represent whether trace is sampled in trace flags. */
11186
11186
  TraceFlags[TraceFlags["SAMPLED"] = 1] = "SAMPLED";
11187
- })(TraceFlags$2 || (TraceFlags$2 = {}));
11187
+ })(TraceFlags$1 || (TraceFlags$1 = {}));
11188
11188
  var INVALID_SPAN_CONTEXT$2 = {
11189
11189
  traceId: "00000000000000000000000000000000",
11190
11190
  spanId: "0000000000000000",
11191
- traceFlags: TraceFlags$2.NONE
11191
+ traceFlags: TraceFlags$1.NONE
11192
11192
  };
11193
11193
  /**
11194
11194
  * The NonRecordingSpan is the default {@link Span} that is used when no Span
@@ -11420,7 +11420,7 @@ var ProxyTracerProvider$2 = function() {
11420
11420
  /**
11421
11421
  * An enumeration of status codes.
11422
11422
  */
11423
- var SpanStatusCode$2;
11423
+ var SpanStatusCode$1;
11424
11424
  (function(SpanStatusCode) {
11425
11425
  /**
11426
11426
  * The default status.
@@ -11435,7 +11435,7 @@ var SpanStatusCode$2;
11435
11435
  * The operation contains an error.
11436
11436
  */
11437
11437
  SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
11438
- })(SpanStatusCode$2 || (SpanStatusCode$2 = {}));
11438
+ })(SpanStatusCode$1 || (SpanStatusCode$1 = {}));
11439
11439
  var API_NAME$5 = "trace";
11440
11440
  (function() {
11441
11441
  /** Empty private constructor prevents end users from constructing a new instance of the API */
@@ -14117,7 +14117,7 @@ function logProxy$1(funcName, namespace, args) {
14117
14117
  * of the levels are defined to match the original values from the initial LogLevel to avoid
14118
14118
  * compatibility/migration issues for any implementation that assume the numeric ordering.
14119
14119
  */
14120
- var DiagLogLevel$1;
14120
+ var DiagLogLevel;
14121
14121
  (function(DiagLogLevel) {
14122
14122
  /** Diagnostic Logging level setting to disable all logging (except and forced logs) */
14123
14123
  DiagLogLevel[DiagLogLevel["NONE"] = 0] = "NONE";
@@ -14136,10 +14136,10 @@ var DiagLogLevel$1;
14136
14136
  DiagLogLevel[DiagLogLevel["VERBOSE"] = 80] = "VERBOSE";
14137
14137
  /** Used to set the logging level to include all logging */
14138
14138
  DiagLogLevel[DiagLogLevel["ALL"] = 9999] = "ALL";
14139
- })(DiagLogLevel$1 || (DiagLogLevel$1 = {}));
14139
+ })(DiagLogLevel || (DiagLogLevel = {}));
14140
14140
  function createLogLevelDiagLogger$1(maxLevel, logger) {
14141
- if (maxLevel < DiagLogLevel$1.NONE) maxLevel = DiagLogLevel$1.NONE;
14142
- else if (maxLevel > DiagLogLevel$1.ALL) maxLevel = DiagLogLevel$1.ALL;
14141
+ if (maxLevel < DiagLogLevel.NONE) maxLevel = DiagLogLevel.NONE;
14142
+ else if (maxLevel > DiagLogLevel.ALL) maxLevel = DiagLogLevel.ALL;
14143
14143
  logger = logger || {};
14144
14144
  function _filterFunc(funcName, theLevel) {
14145
14145
  var theFunc = logger[funcName];
@@ -14147,11 +14147,11 @@ function createLogLevelDiagLogger$1(maxLevel, logger) {
14147
14147
  return function() {};
14148
14148
  }
14149
14149
  return {
14150
- error: _filterFunc("error", DiagLogLevel$1.ERROR),
14151
- warn: _filterFunc("warn", DiagLogLevel$1.WARN),
14152
- info: _filterFunc("info", DiagLogLevel$1.INFO),
14153
- debug: _filterFunc("debug", DiagLogLevel$1.DEBUG),
14154
- verbose: _filterFunc("verbose", DiagLogLevel$1.VERBOSE)
14150
+ error: _filterFunc("error", DiagLogLevel.ERROR),
14151
+ warn: _filterFunc("warn", DiagLogLevel.WARN),
14152
+ info: _filterFunc("info", DiagLogLevel.INFO),
14153
+ debug: _filterFunc("debug", DiagLogLevel.DEBUG),
14154
+ verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
14155
14155
  };
14156
14156
  }
14157
14157
  var __read$2 = function(o, n) {
@@ -14203,7 +14203,7 @@ var DiagAPI$1 = function() {
14203
14203
  var self = this;
14204
14204
  var setLogger = function(logger, optionsOrLogLevel) {
14205
14205
  var _a, _b, _c;
14206
- if (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel$1.INFO };
14206
+ if (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
14207
14207
  if (logger === self) {
14208
14208
  var err = /* @__PURE__ */ new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
14209
14209
  self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
@@ -14211,7 +14211,7 @@ var DiagAPI$1 = function() {
14211
14211
  }
14212
14212
  if (typeof optionsOrLogLevel === "number") optionsOrLogLevel = { logLevel: optionsOrLogLevel };
14213
14213
  var oldLogger = getGlobal$1("diag");
14214
- var newLogger = createLogLevelDiagLogger$1((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel$1.INFO, logger);
14214
+ var newLogger = createLogLevelDiagLogger$1((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
14215
14215
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
14216
14216
  var stack = (_c = (/* @__PURE__ */ new Error()).stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
14217
14217
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -14406,17 +14406,17 @@ var ContextAPI$1 = function() {
14406
14406
  };
14407
14407
  return ContextAPI;
14408
14408
  }();
14409
- var TraceFlags$1;
14409
+ var TraceFlags;
14410
14410
  (function(TraceFlags) {
14411
14411
  /** Represents no flag set. */
14412
14412
  TraceFlags[TraceFlags["NONE"] = 0] = "NONE";
14413
14413
  /** Bit to represent whether trace is sampled in trace flags. */
14414
14414
  TraceFlags[TraceFlags["SAMPLED"] = 1] = "SAMPLED";
14415
- })(TraceFlags$1 || (TraceFlags$1 = {}));
14415
+ })(TraceFlags || (TraceFlags = {}));
14416
14416
  var INVALID_SPAN_CONTEXT$1 = {
14417
14417
  traceId: "00000000000000000000000000000000",
14418
14418
  spanId: "0000000000000000",
14419
- traceFlags: TraceFlags$1.NONE
14419
+ traceFlags: TraceFlags.NONE
14420
14420
  };
14421
14421
  /**
14422
14422
  * The NonRecordingSpan is the default {@link Span} that is used when no Span
@@ -14648,7 +14648,7 @@ var ProxyTracerProvider$1 = function() {
14648
14648
  /**
14649
14649
  * An enumeration of status codes.
14650
14650
  */
14651
- var SpanStatusCode$1;
14651
+ var SpanStatusCode;
14652
14652
  (function(SpanStatusCode) {
14653
14653
  /**
14654
14654
  * The default status.
@@ -14663,7 +14663,7 @@ var SpanStatusCode$1;
14663
14663
  * The operation contains an error.
14664
14664
  */
14665
14665
  SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
14666
- })(SpanStatusCode$1 || (SpanStatusCode$1 = {}));
14666
+ })(SpanStatusCode || (SpanStatusCode = {}));
14667
14667
  var API_NAME$3 = "trace";
14668
14668
  (function() {
14669
14669
  /** Empty private constructor prevents end users from constructing a new instance of the API */
@@ -16513,7 +16513,7 @@ async function resolve(value) {
16513
16513
  }
16514
16514
  new TextDecoder();
16515
16515
  // ../_vendored/ai_v6/dist/index.js
16516
- const VERSION$1 = "1.9.1";
16516
+ const VERSION$1 = "1.10.0";
16517
16517
  const re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
16518
16518
  /**
16519
16519
  * Create a function to test an API version to see if it is compatible with the provided ownVersion.
@@ -16593,15 +16593,23 @@ const isCompatible = _makeCompatibilityCheck(VERSION$1);
16593
16593
  const major = VERSION$1.split(".")[0];
16594
16594
  const GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
16595
16595
  const _global = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
16596
+ function _makeGlobalApi() {
16597
+ return Object.defineProperty({}, "version", {
16598
+ value: VERSION$1,
16599
+ enumerable: true,
16600
+ writable: false,
16601
+ configurable: false
16602
+ });
16603
+ }
16596
16604
  function registerGlobal(type, instance, diag, allowOverride = false) {
16597
- var _a;
16598
- const api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : { version: VERSION$1 };
16605
+ var _global$GLOBAL_OPENTE;
16606
+ const api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_global$GLOBAL_OPENTE = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _global$GLOBAL_OPENTE !== void 0 ? _global$GLOBAL_OPENTE : _makeGlobalApi();
16599
16607
  if (!allowOverride && api[type]) {
16600
16608
  const err = /* @__PURE__ */ new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${type}`);
16601
16609
  diag.error(err.stack || err.message);
16602
16610
  return false;
16603
16611
  }
16604
- if (api.version !== "1.9.1") {
16612
+ if (api.version !== "1.10.0") {
16605
16613
  const err = /* @__PURE__ */ new Error(`@opentelemetry/api: Registration of version v${api.version} for ${type} does not match previously registered API v${VERSION$1}`);
16606
16614
  diag.error(err.stack || err.message);
16607
16615
  return false;
@@ -16610,11 +16618,15 @@ function registerGlobal(type, instance, diag, allowOverride = false) {
16610
16618
  diag.debug(`@opentelemetry/api: Registered a global for ${type} v${VERSION$1}.`);
16611
16619
  return true;
16612
16620
  }
16621
+ let _compatibleGlobalApi;
16613
16622
  function getGlobal(type) {
16614
- var _a, _b;
16615
- const globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
16616
- if (!globalVersion || !isCompatible(globalVersion)) return;
16617
- return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
16623
+ const api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
16624
+ if (api == null) return;
16625
+ if (api !== _compatibleGlobalApi) {
16626
+ if (!api.version || !isCompatible(api.version)) return;
16627
+ _compatibleGlobalApi = api;
16628
+ }
16629
+ return api[type];
16618
16630
  }
16619
16631
  function unregisterGlobal(type, diag) {
16620
16632
  diag.debug(`@opentelemetry/api: Unregistering a global for ${type} v${VERSION$1}.`);
@@ -16655,34 +16667,9 @@ function logProxy(funcName, namespace, args) {
16655
16667
  if (!logger) return;
16656
16668
  return logger[funcName](namespace, ...args);
16657
16669
  }
16658
- /**
16659
- * Defines the available internal logging levels for the diagnostic logger, the numeric values
16660
- * of the levels are defined to match the original values from the initial LogLevel to avoid
16661
- * compatibility/migration issues for any implementation that assume the numeric ordering.
16662
- */
16663
- var DiagLogLevel;
16664
- (function(DiagLogLevel) {
16665
- /** Diagnostic Logging level setting to disable all logging (except and forced logs) */
16666
- DiagLogLevel[DiagLogLevel["NONE"] = 0] = "NONE";
16667
- /** Identifies an error scenario */
16668
- DiagLogLevel[DiagLogLevel["ERROR"] = 30] = "ERROR";
16669
- /** Identifies a warning scenario */
16670
- DiagLogLevel[DiagLogLevel["WARN"] = 50] = "WARN";
16671
- /** General informational log message */
16672
- DiagLogLevel[DiagLogLevel["INFO"] = 60] = "INFO";
16673
- /** General debug log message */
16674
- DiagLogLevel[DiagLogLevel["DEBUG"] = 70] = "DEBUG";
16675
- /**
16676
- * Detailed trace level logging should only be used for development, should only be set
16677
- * in a development environment.
16678
- */
16679
- DiagLogLevel[DiagLogLevel["VERBOSE"] = 80] = "VERBOSE";
16680
- /** Used to set the logging level to include all logging */
16681
- DiagLogLevel[DiagLogLevel["ALL"] = 9999] = "ALL";
16682
- })(DiagLogLevel || (DiagLogLevel = {}));
16683
16670
  function createLogLevelDiagLogger(maxLevel, logger) {
16684
- if (maxLevel < DiagLogLevel.NONE) maxLevel = DiagLogLevel.NONE;
16685
- else if (maxLevel > DiagLogLevel.ALL) maxLevel = DiagLogLevel.ALL;
16671
+ if (maxLevel < 0) maxLevel = 0;
16672
+ else if (maxLevel > 9999) maxLevel = 9999;
16686
16673
  logger = logger || {};
16687
16674
  function _filterFunc(funcName, theLevel) {
16688
16675
  const theFunc = logger[funcName];
@@ -16690,11 +16677,11 @@ function createLogLevelDiagLogger(maxLevel, logger) {
16690
16677
  return function() {};
16691
16678
  }
16692
16679
  return {
16693
- error: _filterFunc("error", DiagLogLevel.ERROR),
16694
- warn: _filterFunc("warn", DiagLogLevel.WARN),
16695
- info: _filterFunc("info", DiagLogLevel.INFO),
16696
- debug: _filterFunc("debug", DiagLogLevel.DEBUG),
16697
- verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
16680
+ error: _filterFunc("error", 30),
16681
+ warn: _filterFunc("warn", 50),
16682
+ info: _filterFunc("info", 60),
16683
+ debug: _filterFunc("debug", 70),
16684
+ verbose: _filterFunc("verbose", 80)
16698
16685
  };
16699
16686
  }
16700
16687
  const API_NAME$2 = "diag";
@@ -16723,18 +16710,20 @@ var DiagAPI = class DiagAPI {
16723
16710
  };
16724
16711
  }
16725
16712
  const self = this;
16726
- const setLogger = (logger, optionsOrLogLevel = { logLevel: DiagLogLevel.INFO }) => {
16727
- var _a, _b, _c;
16713
+ const setLogger = (logger, optionsOrLogLevel = { logLevel: 60 }) => {
16714
+ var _optionsOrLogLevel$lo;
16728
16715
  if (logger === self) {
16716
+ var _err$stack;
16729
16717
  const err = /* @__PURE__ */ new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
16730
- self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
16718
+ self.error((_err$stack = err.stack) !== null && _err$stack !== void 0 ? _err$stack : err.message);
16731
16719
  return false;
16732
16720
  }
16733
16721
  if (typeof optionsOrLogLevel === "number") optionsOrLogLevel = { logLevel: optionsOrLogLevel };
16734
16722
  const oldLogger = getGlobal("diag");
16735
- const newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
16723
+ const newLogger = createLogLevelDiagLogger((_optionsOrLogLevel$lo = optionsOrLogLevel.logLevel) !== null && _optionsOrLogLevel$lo !== void 0 ? _optionsOrLogLevel$lo : 60, logger);
16736
16724
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
16737
- const stack = (_c = (/* @__PURE__ */ new Error()).stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
16725
+ var _Error$stack;
16726
+ const stack = (_Error$stack = (/* @__PURE__ */ new Error()).stack) !== null && _Error$stack !== void 0 ? _Error$stack : "<failed to generate stacktrace>";
16738
16727
  oldLogger.warn(`Current logger will be overwritten from ${stack}`);
16739
16728
  newLogger.warn(`Current logger will overwrite one already registered from ${stack}`);
16740
16729
  }
@@ -16789,98 +16778,13 @@ const ROOT_CONTEXT = new class BaseContext {
16789
16778
  };
16790
16779
  }
16791
16780
  }();
16792
- var NoopContextManager = class {
16793
- active() {
16794
- return ROOT_CONTEXT;
16795
- }
16796
- with(_context, fn, thisArg, ...args) {
16797
- return fn.call(thisArg, ...args);
16798
- }
16799
- bind(_context, target) {
16800
- return target;
16801
- }
16802
- enable() {
16803
- return this;
16804
- }
16805
- disable() {
16806
- return this;
16807
- }
16808
- };
16809
- const API_NAME$1 = "context";
16810
- const NOOP_CONTEXT_MANAGER = new NoopContextManager();
16811
- /**
16812
- * Singleton object which represents the entry point to the OpenTelemetry Context API
16813
- *
16814
- * @since 1.0.0
16815
- */
16816
- var ContextAPI = class ContextAPI {
16817
- /** Empty private constructor prevents end users from constructing a new instance of the API */
16818
- constructor() {}
16819
- /** Get the singleton instance of the Context API */
16820
- static getInstance() {
16821
- if (!this._instance) this._instance = new ContextAPI();
16822
- return this._instance;
16823
- }
16824
- /**
16825
- * Set the current context manager.
16826
- *
16827
- * @returns true if the context manager was successfully registered, else false
16828
- */
16829
- setGlobalContextManager(contextManager) {
16830
- return registerGlobal(API_NAME$1, contextManager, DiagAPI.instance());
16831
- }
16832
- /**
16833
- * Get the currently active context
16834
- */
16835
- active() {
16836
- return this._getContextManager().active();
16837
- }
16838
- /**
16839
- * Execute a function with an active context
16840
- *
16841
- * @param context context to be active during function execution
16842
- * @param fn function to execute in a context
16843
- * @param thisArg optional receiver to be used for calling fn
16844
- * @param args optional arguments forwarded to fn
16845
- */
16846
- with(context, fn, thisArg, ...args) {
16847
- return this._getContextManager().with(context, fn, thisArg, ...args);
16848
- }
16849
- /**
16850
- * Bind a context to a target function or event emitter
16851
- *
16852
- * @param context context to bind to the event emitter or function. Defaults to the currently active context
16853
- * @param target function or event emitter to bind
16854
- */
16855
- bind(context, target) {
16856
- return this._getContextManager().bind(context, target);
16857
- }
16858
- _getContextManager() {
16859
- return getGlobal(API_NAME$1) || NOOP_CONTEXT_MANAGER;
16860
- }
16861
- /** Disable and remove the global context manager */
16862
- disable() {
16863
- this._getContextManager().disable();
16864
- unregisterGlobal(API_NAME$1, DiagAPI.instance());
16865
- }
16866
- };
16867
- /**
16868
- * @since 1.0.0
16869
- */
16870
- var TraceFlags;
16871
- (function(TraceFlags) {
16872
- /** Represents no flag set. */
16873
- TraceFlags[TraceFlags["NONE"] = 0] = "NONE";
16874
- /** Bit to represent whether trace is sampled in trace flags. */
16875
- TraceFlags[TraceFlags["SAMPLED"] = 1] = "SAMPLED";
16876
- })(TraceFlags || (TraceFlags = {}));
16877
16781
  /**
16878
16782
  * @since 1.0.0
16879
16783
  */
16880
16784
  const INVALID_SPAN_CONTEXT = {
16881
16785
  traceId: "00000000000000000000000000000000",
16882
16786
  spanId: "0000000000000000",
16883
- traceFlags: TraceFlags.NONE
16787
+ traceFlags: 0
16884
16788
  };
16885
16789
  /**
16886
16790
  * The NonRecordingSpan is the default {@link Span} that is used when no Span
@@ -16921,60 +16825,6 @@ var NonRecordingSpan = class {
16921
16825
  }
16922
16826
  recordException(_exception, _time) {}
16923
16827
  };
16924
- /**
16925
- * span key
16926
- */
16927
- const SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
16928
- /**
16929
- * Return the span if one exists
16930
- *
16931
- * @param context context to get span from
16932
- */
16933
- function getSpan(context) {
16934
- return context.getValue(SPAN_KEY) || void 0;
16935
- }
16936
- /**
16937
- * Gets the span from the current context, if one exists.
16938
- */
16939
- function getActiveSpan() {
16940
- return getSpan(ContextAPI.getInstance().active());
16941
- }
16942
- /**
16943
- * Set the span on a context
16944
- *
16945
- * @param context context to use as parent
16946
- * @param span span to set active
16947
- */
16948
- function setSpan(context, span) {
16949
- return context.setValue(SPAN_KEY, span);
16950
- }
16951
- /**
16952
- * Remove current span stored in the context
16953
- *
16954
- * @param context context to delete span from
16955
- */
16956
- function deleteSpan(context) {
16957
- return context.deleteValue(SPAN_KEY);
16958
- }
16959
- /**
16960
- * Wrap span context in a NoopSpan and set as span in a new
16961
- * context
16962
- *
16963
- * @param context context to set active span on
16964
- * @param spanContext span context to be wrapped
16965
- */
16966
- function setSpanContext(context, spanContext) {
16967
- return setSpan(context, new NonRecordingSpan(spanContext));
16968
- }
16969
- /**
16970
- * Get the span context of the span if it exists.
16971
- *
16972
- * @param context context to get values from
16973
- */
16974
- function getSpanContext(context) {
16975
- var _a;
16976
- return (_a = getSpan(context)) === null || _a === void 0 ? void 0 : _a.spanContext();
16977
- }
16978
16828
  const isHex = new Uint8Array([
16979
16829
  0,
16980
16830
  0,
@@ -17116,6 +16966,173 @@ function isSpanContextValid(spanContext) {
17116
16966
  function wrapSpanContext(spanContext) {
17117
16967
  return new NonRecordingSpan(spanContext);
17118
16968
  }
16969
+ var NoopContextManager = class {
16970
+ active() {
16971
+ return ROOT_CONTEXT;
16972
+ }
16973
+ with(_context, fn, thisArg, ...args) {
16974
+ return fn.call(thisArg, ...args);
16975
+ }
16976
+ bind(_context, target) {
16977
+ return target;
16978
+ }
16979
+ enable() {
16980
+ return this;
16981
+ }
16982
+ disable() {
16983
+ return this;
16984
+ }
16985
+ /** @experimental This API is experimental and may change in minor releases without prior notice. */
16986
+ attach(_context) {
16987
+ return { dispose() {} };
16988
+ }
16989
+ };
16990
+ const API_NAME$1 = "context";
16991
+ const NOOP_CONTEXT_MANAGER = new NoopContextManager();
16992
+ const NOOP_TOKEN = Object.freeze({ dispose: () => {} });
16993
+ /**
16994
+ * Singleton object which represents the entry point to the OpenTelemetry Context API
16995
+ *
16996
+ * @since 1.0.0
16997
+ */
16998
+ var ContextAPI = class ContextAPI {
16999
+ /** Empty private constructor prevents end users from constructing a new instance of the API */
17000
+ constructor() {
17001
+ this._attachUnsupportedWarned = false;
17002
+ }
17003
+ /** Get the singleton instance of the Context API */
17004
+ static getInstance() {
17005
+ if (!this._instance) this._instance = new ContextAPI();
17006
+ return this._instance;
17007
+ }
17008
+ /**
17009
+ * Set the current context manager.
17010
+ *
17011
+ * @returns true if the context manager was successfully registered, else false
17012
+ */
17013
+ setGlobalContextManager(contextManager) {
17014
+ return registerGlobal(API_NAME$1, contextManager, DiagAPI.instance());
17015
+ }
17016
+ /**
17017
+ * Get the currently active context
17018
+ */
17019
+ active() {
17020
+ return this._getContextManager().active();
17021
+ }
17022
+ /**
17023
+ * Execute a function with an active context
17024
+ *
17025
+ * @param context context to be active during function execution
17026
+ * @param fn function to execute in a context
17027
+ * @param thisArg optional receiver to be used for calling fn
17028
+ * @param args optional arguments forwarded to fn
17029
+ */
17030
+ with(context, fn, thisArg, ...args) {
17031
+ return this._getContextManager().with(context, fn, thisArg, ...args);
17032
+ }
17033
+ /**
17034
+ * Bind a context to a target function or event emitter
17035
+ *
17036
+ * @param context context to bind to the event emitter or function. Defaults to the currently active context
17037
+ * @param target function or event emitter to bind
17038
+ */
17039
+ bind(context, target) {
17040
+ return this._getContextManager().bind(context, target);
17041
+ }
17042
+ /**
17043
+ * Imperatively sets `context` as active, returning a {@link ContextManagementToken} whose
17044
+ * {@link ContextManagementToken.dispose} restores the previous context.
17045
+ *
17046
+ * This is a delicate, low-level API - prefer {@link with}/{@link bind}, which
17047
+ * restore context automatically. Use `attach` only to bridge callback
17048
+ * boundaries that `with` cannot wrap. Call `token.dispose()` when the
17049
+ * operation is done.
17050
+ *
17051
+ * **Caveat for async functions:** If called inside an async function before
17052
+ * the first `await`, the context change may leak into the caller's context
17053
+ * and remain active there. Prefer {@link with} for async code.
17054
+ *
17055
+ * Support is best-effort and varies by the active ContextManager (see
17056
+ * {@link ContextManager.attach}); if it does not implement `attach`, this logs
17057
+ * a warning and returns a no-op token.
17058
+ *
17059
+ * @param context The Context to attach
17060
+ * @returns A {@link ContextManagementToken} whose dispose() restores the previous Context
17061
+ * @since 1.10.0
17062
+ * @experimental This API is experimental and may change in minor releases without prior notice.
17063
+ */
17064
+ attach(context) {
17065
+ const contextManager = this._getContextManager();
17066
+ if (contextManager.attach) return contextManager.attach(context);
17067
+ if (!this._attachUnsupportedWarned) {
17068
+ this._attachUnsupportedWarned = true;
17069
+ DiagAPI.instance().warn("The current ContextManager does not implement attach(). The context will not be attached. Use a ContextManager that supports attach() (e.g. AsyncLocalStorageContextManager) or use with()/bind() instead.");
17070
+ }
17071
+ return NOOP_TOKEN;
17072
+ }
17073
+ _getContextManager() {
17074
+ return getGlobal(API_NAME$1) || NOOP_CONTEXT_MANAGER;
17075
+ }
17076
+ /** Disable and remove the global context manager */
17077
+ disable() {
17078
+ this._getContextManager().disable();
17079
+ unregisterGlobal(API_NAME$1, DiagAPI.instance());
17080
+ }
17081
+ };
17082
+ /**
17083
+ * span key
17084
+ */
17085
+ const SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
17086
+ /**
17087
+ * Return the span if one exists
17088
+ *
17089
+ * @param context context to get span from
17090
+ */
17091
+ function getSpan(context) {
17092
+ return context.getValue(SPAN_KEY) || void 0;
17093
+ }
17094
+ /**
17095
+ * Gets the span from the current context, if one exists.
17096
+ */
17097
+ function getActiveSpan() {
17098
+ return getSpan(ContextAPI.getInstance().active());
17099
+ }
17100
+ /**
17101
+ * Set the span on a context
17102
+ *
17103
+ * @param context context to use as parent
17104
+ * @param span span to set active
17105
+ */
17106
+ function setSpan(context, span) {
17107
+ return context.setValue(SPAN_KEY, span);
17108
+ }
17109
+ /**
17110
+ * Remove current span stored in the context
17111
+ *
17112
+ * @param context context to delete span from
17113
+ */
17114
+ function deleteSpan(context) {
17115
+ return context.deleteValue(SPAN_KEY);
17116
+ }
17117
+ /**
17118
+ * Wrap span context in a NoopSpan and set as span in a new
17119
+ * context
17120
+ *
17121
+ * @param context context to set active span on
17122
+ * @param spanContext span context to be wrapped
17123
+ */
17124
+ function setSpanContext(context, spanContext) {
17125
+ return setSpan(context, new NonRecordingSpan(spanContext));
17126
+ }
17127
+ /**
17128
+ * Get the span context of the span if it exists.
17129
+ *
17130
+ * @param context context to get values from
17131
+ */
17132
+ function getSpanContext(context) {
17133
+ var _getSpan;
17134
+ return (_getSpan = getSpan(context)) === null || _getSpan === void 0 ? void 0 : _getSpan.spanContext();
17135
+ }
17119
17136
  const contextApi = ContextAPI.getInstance();
17120
17137
  /**
17121
17138
  * No-op implementations of {@link Tracer}.
@@ -17128,6 +17145,7 @@ var NoopTracer = class {
17128
17145
  else return new NonRecordingSpan();
17129
17146
  }
17130
17147
  startActiveSpan(name, arg2, arg3, arg4) {
17148
+ var _ctx;
17131
17149
  let opts;
17132
17150
  let ctx;
17133
17151
  let fn;
@@ -17141,7 +17159,7 @@ var NoopTracer = class {
17141
17159
  ctx = arg3;
17142
17160
  fn = arg4;
17143
17161
  }
17144
- const parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
17162
+ const parentContext = (_ctx = ctx) !== null && _ctx !== void 0 ? _ctx : contextApi.active();
17145
17163
  const span = this.startSpan(name, opts, parentContext);
17146
17164
  const contextWithSpanSet = setSpan(parentContext, span);
17147
17165
  return contextApi.with(contextWithSpanSet, fn, void 0, span);
@@ -17210,12 +17228,12 @@ var ProxyTracerProvider = class {
17210
17228
  * Get a {@link ProxyTracer}
17211
17229
  */
17212
17230
  getTracer(name, version, options) {
17213
- var _a;
17214
- return (_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name, version, options);
17231
+ var _this$getDelegateTrac;
17232
+ return (_this$getDelegateTrac = this.getDelegateTracer(name, version, options)) !== null && _this$getDelegateTrac !== void 0 ? _this$getDelegateTrac : new ProxyTracer(this, name, version, options);
17215
17233
  }
17216
17234
  getDelegate() {
17217
- var _a;
17218
- return (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;
17235
+ var _this$_delegate;
17236
+ return (_this$_delegate = this._delegate) !== null && _this$_delegate !== void 0 ? _this$_delegate : NOOP_TRACER_PROVIDER;
17219
17237
  }
17220
17238
  /**
17221
17239
  * Set the delegate tracer provider
@@ -17224,31 +17242,10 @@ var ProxyTracerProvider = class {
17224
17242
  this._delegate = delegate;
17225
17243
  }
17226
17244
  getDelegateTracer(name, version, options) {
17227
- var _a;
17228
- return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options);
17245
+ var _this$_delegate2;
17246
+ return (_this$_delegate2 = this._delegate) === null || _this$_delegate2 === void 0 ? void 0 : _this$_delegate2.getTracer(name, version, options);
17229
17247
  }
17230
17248
  };
17231
- /**
17232
- * An enumeration of status codes.
17233
- *
17234
- * @since 1.0.0
17235
- */
17236
- var SpanStatusCode;
17237
- (function(SpanStatusCode) {
17238
- /**
17239
- * The default status.
17240
- */
17241
- SpanStatusCode[SpanStatusCode["UNSET"] = 0] = "UNSET";
17242
- /**
17243
- * The operation has been validated by an Application developer or
17244
- * Operator to have completed successfully.
17245
- */
17246
- SpanStatusCode[SpanStatusCode["OK"] = 1] = "OK";
17247
- /**
17248
- * The operation contains an error.
17249
- */
17250
- SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
17251
- })(SpanStatusCode || (SpanStatusCode = {}));
17252
17249
  ContextAPI.getInstance();
17253
17250
  const API_NAME = "trace";
17254
17251
  (class TraceAPI {