@mastra/fastembed 1.3.5 → 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.cjs CHANGED
@@ -10916,7 +10916,7 @@ function logProxy$2(funcName, namespace, args) {
10916
10916
  * of the levels are defined to match the original values from the initial LogLevel to avoid
10917
10917
  * compatibility/migration issues for any implementation that assume the numeric ordering.
10918
10918
  */
10919
- var DiagLogLevel$2;
10919
+ var DiagLogLevel$1;
10920
10920
  (function(DiagLogLevel) {
10921
10921
  /** Diagnostic Logging level setting to disable all logging (except and forced logs) */
10922
10922
  DiagLogLevel[DiagLogLevel["NONE"] = 0] = "NONE";
@@ -10935,10 +10935,10 @@ var DiagLogLevel$2;
10935
10935
  DiagLogLevel[DiagLogLevel["VERBOSE"] = 80] = "VERBOSE";
10936
10936
  /** Used to set the logging level to include all logging */
10937
10937
  DiagLogLevel[DiagLogLevel["ALL"] = 9999] = "ALL";
10938
- })(DiagLogLevel$2 || (DiagLogLevel$2 = {}));
10938
+ })(DiagLogLevel$1 || (DiagLogLevel$1 = {}));
10939
10939
  function createLogLevelDiagLogger$2(maxLevel, logger) {
10940
- if (maxLevel < DiagLogLevel$2.NONE) maxLevel = DiagLogLevel$2.NONE;
10941
- else if (maxLevel > DiagLogLevel$2.ALL) maxLevel = DiagLogLevel$2.ALL;
10940
+ if (maxLevel < DiagLogLevel$1.NONE) maxLevel = DiagLogLevel$1.NONE;
10941
+ else if (maxLevel > DiagLogLevel$1.ALL) maxLevel = DiagLogLevel$1.ALL;
10942
10942
  logger = logger || {};
10943
10943
  function _filterFunc(funcName, theLevel) {
10944
10944
  var theFunc = logger[funcName];
@@ -10946,11 +10946,11 @@ function createLogLevelDiagLogger$2(maxLevel, logger) {
10946
10946
  return function() {};
10947
10947
  }
10948
10948
  return {
10949
- error: _filterFunc("error", DiagLogLevel$2.ERROR),
10950
- warn: _filterFunc("warn", DiagLogLevel$2.WARN),
10951
- info: _filterFunc("info", DiagLogLevel$2.INFO),
10952
- debug: _filterFunc("debug", DiagLogLevel$2.DEBUG),
10953
- verbose: _filterFunc("verbose", DiagLogLevel$2.VERBOSE)
10949
+ error: _filterFunc("error", DiagLogLevel$1.ERROR),
10950
+ warn: _filterFunc("warn", DiagLogLevel$1.WARN),
10951
+ info: _filterFunc("info", DiagLogLevel$1.INFO),
10952
+ debug: _filterFunc("debug", DiagLogLevel$1.DEBUG),
10953
+ verbose: _filterFunc("verbose", DiagLogLevel$1.VERBOSE)
10954
10954
  };
10955
10955
  }
10956
10956
  var __read$2$1 = function(o, n) {
@@ -11002,7 +11002,7 @@ var DiagAPI$2 = function() {
11002
11002
  var self = this;
11003
11003
  var setLogger = function(logger, optionsOrLogLevel) {
11004
11004
  var _a, _b, _c;
11005
- if (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel$2.INFO };
11005
+ if (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel$1.INFO };
11006
11006
  if (logger === self) {
11007
11007
  var err = /* @__PURE__ */ new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
11008
11008
  self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
@@ -11010,7 +11010,7 @@ var DiagAPI$2 = function() {
11010
11010
  }
11011
11011
  if (typeof optionsOrLogLevel === "number") optionsOrLogLevel = { logLevel: optionsOrLogLevel };
11012
11012
  var oldLogger = getGlobal$2("diag");
11013
- var newLogger = createLogLevelDiagLogger$2((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel$2.INFO, logger);
11013
+ var newLogger = createLogLevelDiagLogger$2((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel$1.INFO, logger);
11014
11014
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
11015
11015
  var stack = (_c = (/* @__PURE__ */ new Error()).stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
11016
11016
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -11205,17 +11205,17 @@ var ContextAPI$2 = function() {
11205
11205
  };
11206
11206
  return ContextAPI;
11207
11207
  }();
11208
- var TraceFlags$2;
11208
+ var TraceFlags$1;
11209
11209
  (function(TraceFlags) {
11210
11210
  /** Represents no flag set. */
11211
11211
  TraceFlags[TraceFlags["NONE"] = 0] = "NONE";
11212
11212
  /** Bit to represent whether trace is sampled in trace flags. */
11213
11213
  TraceFlags[TraceFlags["SAMPLED"] = 1] = "SAMPLED";
11214
- })(TraceFlags$2 || (TraceFlags$2 = {}));
11214
+ })(TraceFlags$1 || (TraceFlags$1 = {}));
11215
11215
  var INVALID_SPAN_CONTEXT$2 = {
11216
11216
  traceId: "00000000000000000000000000000000",
11217
11217
  spanId: "0000000000000000",
11218
- traceFlags: TraceFlags$2.NONE
11218
+ traceFlags: TraceFlags$1.NONE
11219
11219
  };
11220
11220
  /**
11221
11221
  * The NonRecordingSpan is the default {@link Span} that is used when no Span
@@ -11447,7 +11447,7 @@ var ProxyTracerProvider$2 = function() {
11447
11447
  /**
11448
11448
  * An enumeration of status codes.
11449
11449
  */
11450
- var SpanStatusCode$2;
11450
+ var SpanStatusCode$1;
11451
11451
  (function(SpanStatusCode) {
11452
11452
  /**
11453
11453
  * The default status.
@@ -11462,7 +11462,7 @@ var SpanStatusCode$2;
11462
11462
  * The operation contains an error.
11463
11463
  */
11464
11464
  SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
11465
- })(SpanStatusCode$2 || (SpanStatusCode$2 = {}));
11465
+ })(SpanStatusCode$1 || (SpanStatusCode$1 = {}));
11466
11466
  var API_NAME$5 = "trace";
11467
11467
  (function() {
11468
11468
  /** Empty private constructor prevents end users from constructing a new instance of the API */
@@ -14144,7 +14144,7 @@ function logProxy$1(funcName, namespace, args) {
14144
14144
  * of the levels are defined to match the original values from the initial LogLevel to avoid
14145
14145
  * compatibility/migration issues for any implementation that assume the numeric ordering.
14146
14146
  */
14147
- var DiagLogLevel$1;
14147
+ var DiagLogLevel;
14148
14148
  (function(DiagLogLevel) {
14149
14149
  /** Diagnostic Logging level setting to disable all logging (except and forced logs) */
14150
14150
  DiagLogLevel[DiagLogLevel["NONE"] = 0] = "NONE";
@@ -14163,10 +14163,10 @@ var DiagLogLevel$1;
14163
14163
  DiagLogLevel[DiagLogLevel["VERBOSE"] = 80] = "VERBOSE";
14164
14164
  /** Used to set the logging level to include all logging */
14165
14165
  DiagLogLevel[DiagLogLevel["ALL"] = 9999] = "ALL";
14166
- })(DiagLogLevel$1 || (DiagLogLevel$1 = {}));
14166
+ })(DiagLogLevel || (DiagLogLevel = {}));
14167
14167
  function createLogLevelDiagLogger$1(maxLevel, logger) {
14168
- if (maxLevel < DiagLogLevel$1.NONE) maxLevel = DiagLogLevel$1.NONE;
14169
- else if (maxLevel > DiagLogLevel$1.ALL) maxLevel = DiagLogLevel$1.ALL;
14168
+ if (maxLevel < DiagLogLevel.NONE) maxLevel = DiagLogLevel.NONE;
14169
+ else if (maxLevel > DiagLogLevel.ALL) maxLevel = DiagLogLevel.ALL;
14170
14170
  logger = logger || {};
14171
14171
  function _filterFunc(funcName, theLevel) {
14172
14172
  var theFunc = logger[funcName];
@@ -14174,11 +14174,11 @@ function createLogLevelDiagLogger$1(maxLevel, logger) {
14174
14174
  return function() {};
14175
14175
  }
14176
14176
  return {
14177
- error: _filterFunc("error", DiagLogLevel$1.ERROR),
14178
- warn: _filterFunc("warn", DiagLogLevel$1.WARN),
14179
- info: _filterFunc("info", DiagLogLevel$1.INFO),
14180
- debug: _filterFunc("debug", DiagLogLevel$1.DEBUG),
14181
- verbose: _filterFunc("verbose", DiagLogLevel$1.VERBOSE)
14177
+ error: _filterFunc("error", DiagLogLevel.ERROR),
14178
+ warn: _filterFunc("warn", DiagLogLevel.WARN),
14179
+ info: _filterFunc("info", DiagLogLevel.INFO),
14180
+ debug: _filterFunc("debug", DiagLogLevel.DEBUG),
14181
+ verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
14182
14182
  };
14183
14183
  }
14184
14184
  var __read$2 = function(o, n) {
@@ -14230,7 +14230,7 @@ var DiagAPI$1 = function() {
14230
14230
  var self = this;
14231
14231
  var setLogger = function(logger, optionsOrLogLevel) {
14232
14232
  var _a, _b, _c;
14233
- if (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel$1.INFO };
14233
+ if (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
14234
14234
  if (logger === self) {
14235
14235
  var err = /* @__PURE__ */ new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
14236
14236
  self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
@@ -14238,7 +14238,7 @@ var DiagAPI$1 = function() {
14238
14238
  }
14239
14239
  if (typeof optionsOrLogLevel === "number") optionsOrLogLevel = { logLevel: optionsOrLogLevel };
14240
14240
  var oldLogger = getGlobal$1("diag");
14241
- var newLogger = createLogLevelDiagLogger$1((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel$1.INFO, logger);
14241
+ var newLogger = createLogLevelDiagLogger$1((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
14242
14242
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
14243
14243
  var stack = (_c = (/* @__PURE__ */ new Error()).stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
14244
14244
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -14433,17 +14433,17 @@ var ContextAPI$1 = function() {
14433
14433
  };
14434
14434
  return ContextAPI;
14435
14435
  }();
14436
- var TraceFlags$1;
14436
+ var TraceFlags;
14437
14437
  (function(TraceFlags) {
14438
14438
  /** Represents no flag set. */
14439
14439
  TraceFlags[TraceFlags["NONE"] = 0] = "NONE";
14440
14440
  /** Bit to represent whether trace is sampled in trace flags. */
14441
14441
  TraceFlags[TraceFlags["SAMPLED"] = 1] = "SAMPLED";
14442
- })(TraceFlags$1 || (TraceFlags$1 = {}));
14442
+ })(TraceFlags || (TraceFlags = {}));
14443
14443
  var INVALID_SPAN_CONTEXT$1 = {
14444
14444
  traceId: "00000000000000000000000000000000",
14445
14445
  spanId: "0000000000000000",
14446
- traceFlags: TraceFlags$1.NONE
14446
+ traceFlags: TraceFlags.NONE
14447
14447
  };
14448
14448
  /**
14449
14449
  * The NonRecordingSpan is the default {@link Span} that is used when no Span
@@ -14675,7 +14675,7 @@ var ProxyTracerProvider$1 = function() {
14675
14675
  /**
14676
14676
  * An enumeration of status codes.
14677
14677
  */
14678
- var SpanStatusCode$1;
14678
+ var SpanStatusCode;
14679
14679
  (function(SpanStatusCode) {
14680
14680
  /**
14681
14681
  * The default status.
@@ -14690,7 +14690,7 @@ var SpanStatusCode$1;
14690
14690
  * The operation contains an error.
14691
14691
  */
14692
14692
  SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
14693
- })(SpanStatusCode$1 || (SpanStatusCode$1 = {}));
14693
+ })(SpanStatusCode || (SpanStatusCode = {}));
14694
14694
  var API_NAME$3 = "trace";
14695
14695
  (function() {
14696
14696
  /** Empty private constructor prevents end users from constructing a new instance of the API */
@@ -16540,7 +16540,7 @@ async function resolve(value) {
16540
16540
  }
16541
16541
  new TextDecoder();
16542
16542
  // ../_vendored/ai_v6/dist/index.js
16543
- const VERSION$1 = "1.9.1";
16543
+ const VERSION$1 = "1.10.0";
16544
16544
  const re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
16545
16545
  /**
16546
16546
  * Create a function to test an API version to see if it is compatible with the provided ownVersion.
@@ -16620,15 +16620,23 @@ const isCompatible = _makeCompatibilityCheck(VERSION$1);
16620
16620
  const major = VERSION$1.split(".")[0];
16621
16621
  const GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
16622
16622
  const _global = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
16623
+ function _makeGlobalApi() {
16624
+ return Object.defineProperty({}, "version", {
16625
+ value: VERSION$1,
16626
+ enumerable: true,
16627
+ writable: false,
16628
+ configurable: false
16629
+ });
16630
+ }
16623
16631
  function registerGlobal(type, instance, diag, allowOverride = false) {
16624
- var _a;
16625
- const api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : { version: VERSION$1 };
16632
+ var _global$GLOBAL_OPENTE;
16633
+ 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();
16626
16634
  if (!allowOverride && api[type]) {
16627
16635
  const err = /* @__PURE__ */ new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${type}`);
16628
16636
  diag.error(err.stack || err.message);
16629
16637
  return false;
16630
16638
  }
16631
- if (api.version !== "1.9.1") {
16639
+ if (api.version !== "1.10.0") {
16632
16640
  const err = /* @__PURE__ */ new Error(`@opentelemetry/api: Registration of version v${api.version} for ${type} does not match previously registered API v${VERSION$1}`);
16633
16641
  diag.error(err.stack || err.message);
16634
16642
  return false;
@@ -16637,11 +16645,15 @@ function registerGlobal(type, instance, diag, allowOverride = false) {
16637
16645
  diag.debug(`@opentelemetry/api: Registered a global for ${type} v${VERSION$1}.`);
16638
16646
  return true;
16639
16647
  }
16648
+ let _compatibleGlobalApi;
16640
16649
  function getGlobal(type) {
16641
- var _a, _b;
16642
- const globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
16643
- if (!globalVersion || !isCompatible(globalVersion)) return;
16644
- return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
16650
+ const api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
16651
+ if (api == null) return;
16652
+ if (api !== _compatibleGlobalApi) {
16653
+ if (!api.version || !isCompatible(api.version)) return;
16654
+ _compatibleGlobalApi = api;
16655
+ }
16656
+ return api[type];
16645
16657
  }
16646
16658
  function unregisterGlobal(type, diag) {
16647
16659
  diag.debug(`@opentelemetry/api: Unregistering a global for ${type} v${VERSION$1}.`);
@@ -16682,34 +16694,9 @@ function logProxy(funcName, namespace, args) {
16682
16694
  if (!logger) return;
16683
16695
  return logger[funcName](namespace, ...args);
16684
16696
  }
16685
- /**
16686
- * Defines the available internal logging levels for the diagnostic logger, the numeric values
16687
- * of the levels are defined to match the original values from the initial LogLevel to avoid
16688
- * compatibility/migration issues for any implementation that assume the numeric ordering.
16689
- */
16690
- var DiagLogLevel;
16691
- (function(DiagLogLevel) {
16692
- /** Diagnostic Logging level setting to disable all logging (except and forced logs) */
16693
- DiagLogLevel[DiagLogLevel["NONE"] = 0] = "NONE";
16694
- /** Identifies an error scenario */
16695
- DiagLogLevel[DiagLogLevel["ERROR"] = 30] = "ERROR";
16696
- /** Identifies a warning scenario */
16697
- DiagLogLevel[DiagLogLevel["WARN"] = 50] = "WARN";
16698
- /** General informational log message */
16699
- DiagLogLevel[DiagLogLevel["INFO"] = 60] = "INFO";
16700
- /** General debug log message */
16701
- DiagLogLevel[DiagLogLevel["DEBUG"] = 70] = "DEBUG";
16702
- /**
16703
- * Detailed trace level logging should only be used for development, should only be set
16704
- * in a development environment.
16705
- */
16706
- DiagLogLevel[DiagLogLevel["VERBOSE"] = 80] = "VERBOSE";
16707
- /** Used to set the logging level to include all logging */
16708
- DiagLogLevel[DiagLogLevel["ALL"] = 9999] = "ALL";
16709
- })(DiagLogLevel || (DiagLogLevel = {}));
16710
16697
  function createLogLevelDiagLogger(maxLevel, logger) {
16711
- if (maxLevel < DiagLogLevel.NONE) maxLevel = DiagLogLevel.NONE;
16712
- else if (maxLevel > DiagLogLevel.ALL) maxLevel = DiagLogLevel.ALL;
16698
+ if (maxLevel < 0) maxLevel = 0;
16699
+ else if (maxLevel > 9999) maxLevel = 9999;
16713
16700
  logger = logger || {};
16714
16701
  function _filterFunc(funcName, theLevel) {
16715
16702
  const theFunc = logger[funcName];
@@ -16717,11 +16704,11 @@ function createLogLevelDiagLogger(maxLevel, logger) {
16717
16704
  return function() {};
16718
16705
  }
16719
16706
  return {
16720
- error: _filterFunc("error", DiagLogLevel.ERROR),
16721
- warn: _filterFunc("warn", DiagLogLevel.WARN),
16722
- info: _filterFunc("info", DiagLogLevel.INFO),
16723
- debug: _filterFunc("debug", DiagLogLevel.DEBUG),
16724
- verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
16707
+ error: _filterFunc("error", 30),
16708
+ warn: _filterFunc("warn", 50),
16709
+ info: _filterFunc("info", 60),
16710
+ debug: _filterFunc("debug", 70),
16711
+ verbose: _filterFunc("verbose", 80)
16725
16712
  };
16726
16713
  }
16727
16714
  const API_NAME$2 = "diag";
@@ -16750,18 +16737,20 @@ var DiagAPI = class DiagAPI {
16750
16737
  };
16751
16738
  }
16752
16739
  const self = this;
16753
- const setLogger = (logger, optionsOrLogLevel = { logLevel: DiagLogLevel.INFO }) => {
16754
- var _a, _b, _c;
16740
+ const setLogger = (logger, optionsOrLogLevel = { logLevel: 60 }) => {
16741
+ var _optionsOrLogLevel$lo;
16755
16742
  if (logger === self) {
16743
+ var _err$stack;
16756
16744
  const err = /* @__PURE__ */ new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
16757
- self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
16745
+ self.error((_err$stack = err.stack) !== null && _err$stack !== void 0 ? _err$stack : err.message);
16758
16746
  return false;
16759
16747
  }
16760
16748
  if (typeof optionsOrLogLevel === "number") optionsOrLogLevel = { logLevel: optionsOrLogLevel };
16761
16749
  const oldLogger = getGlobal("diag");
16762
- const newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
16750
+ const newLogger = createLogLevelDiagLogger((_optionsOrLogLevel$lo = optionsOrLogLevel.logLevel) !== null && _optionsOrLogLevel$lo !== void 0 ? _optionsOrLogLevel$lo : 60, logger);
16763
16751
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
16764
- const stack = (_c = (/* @__PURE__ */ new Error()).stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
16752
+ var _Error$stack;
16753
+ const stack = (_Error$stack = (/* @__PURE__ */ new Error()).stack) !== null && _Error$stack !== void 0 ? _Error$stack : "<failed to generate stacktrace>";
16765
16754
  oldLogger.warn(`Current logger will be overwritten from ${stack}`);
16766
16755
  newLogger.warn(`Current logger will overwrite one already registered from ${stack}`);
16767
16756
  }
@@ -16816,98 +16805,13 @@ const ROOT_CONTEXT = new class BaseContext {
16816
16805
  };
16817
16806
  }
16818
16807
  }();
16819
- var NoopContextManager = class {
16820
- active() {
16821
- return ROOT_CONTEXT;
16822
- }
16823
- with(_context, fn, thisArg, ...args) {
16824
- return fn.call(thisArg, ...args);
16825
- }
16826
- bind(_context, target) {
16827
- return target;
16828
- }
16829
- enable() {
16830
- return this;
16831
- }
16832
- disable() {
16833
- return this;
16834
- }
16835
- };
16836
- const API_NAME$1 = "context";
16837
- const NOOP_CONTEXT_MANAGER = new NoopContextManager();
16838
- /**
16839
- * Singleton object which represents the entry point to the OpenTelemetry Context API
16840
- *
16841
- * @since 1.0.0
16842
- */
16843
- var ContextAPI = class ContextAPI {
16844
- /** Empty private constructor prevents end users from constructing a new instance of the API */
16845
- constructor() {}
16846
- /** Get the singleton instance of the Context API */
16847
- static getInstance() {
16848
- if (!this._instance) this._instance = new ContextAPI();
16849
- return this._instance;
16850
- }
16851
- /**
16852
- * Set the current context manager.
16853
- *
16854
- * @returns true if the context manager was successfully registered, else false
16855
- */
16856
- setGlobalContextManager(contextManager) {
16857
- return registerGlobal(API_NAME$1, contextManager, DiagAPI.instance());
16858
- }
16859
- /**
16860
- * Get the currently active context
16861
- */
16862
- active() {
16863
- return this._getContextManager().active();
16864
- }
16865
- /**
16866
- * Execute a function with an active context
16867
- *
16868
- * @param context context to be active during function execution
16869
- * @param fn function to execute in a context
16870
- * @param thisArg optional receiver to be used for calling fn
16871
- * @param args optional arguments forwarded to fn
16872
- */
16873
- with(context, fn, thisArg, ...args) {
16874
- return this._getContextManager().with(context, fn, thisArg, ...args);
16875
- }
16876
- /**
16877
- * Bind a context to a target function or event emitter
16878
- *
16879
- * @param context context to bind to the event emitter or function. Defaults to the currently active context
16880
- * @param target function or event emitter to bind
16881
- */
16882
- bind(context, target) {
16883
- return this._getContextManager().bind(context, target);
16884
- }
16885
- _getContextManager() {
16886
- return getGlobal(API_NAME$1) || NOOP_CONTEXT_MANAGER;
16887
- }
16888
- /** Disable and remove the global context manager */
16889
- disable() {
16890
- this._getContextManager().disable();
16891
- unregisterGlobal(API_NAME$1, DiagAPI.instance());
16892
- }
16893
- };
16894
- /**
16895
- * @since 1.0.0
16896
- */
16897
- var TraceFlags;
16898
- (function(TraceFlags) {
16899
- /** Represents no flag set. */
16900
- TraceFlags[TraceFlags["NONE"] = 0] = "NONE";
16901
- /** Bit to represent whether trace is sampled in trace flags. */
16902
- TraceFlags[TraceFlags["SAMPLED"] = 1] = "SAMPLED";
16903
- })(TraceFlags || (TraceFlags = {}));
16904
16808
  /**
16905
16809
  * @since 1.0.0
16906
16810
  */
16907
16811
  const INVALID_SPAN_CONTEXT = {
16908
16812
  traceId: "00000000000000000000000000000000",
16909
16813
  spanId: "0000000000000000",
16910
- traceFlags: TraceFlags.NONE
16814
+ traceFlags: 0
16911
16815
  };
16912
16816
  /**
16913
16817
  * The NonRecordingSpan is the default {@link Span} that is used when no Span
@@ -16948,60 +16852,6 @@ var NonRecordingSpan = class {
16948
16852
  }
16949
16853
  recordException(_exception, _time) {}
16950
16854
  };
16951
- /**
16952
- * span key
16953
- */
16954
- const SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
16955
- /**
16956
- * Return the span if one exists
16957
- *
16958
- * @param context context to get span from
16959
- */
16960
- function getSpan(context) {
16961
- return context.getValue(SPAN_KEY) || void 0;
16962
- }
16963
- /**
16964
- * Gets the span from the current context, if one exists.
16965
- */
16966
- function getActiveSpan() {
16967
- return getSpan(ContextAPI.getInstance().active());
16968
- }
16969
- /**
16970
- * Set the span on a context
16971
- *
16972
- * @param context context to use as parent
16973
- * @param span span to set active
16974
- */
16975
- function setSpan(context, span) {
16976
- return context.setValue(SPAN_KEY, span);
16977
- }
16978
- /**
16979
- * Remove current span stored in the context
16980
- *
16981
- * @param context context to delete span from
16982
- */
16983
- function deleteSpan(context) {
16984
- return context.deleteValue(SPAN_KEY);
16985
- }
16986
- /**
16987
- * Wrap span context in a NoopSpan and set as span in a new
16988
- * context
16989
- *
16990
- * @param context context to set active span on
16991
- * @param spanContext span context to be wrapped
16992
- */
16993
- function setSpanContext(context, spanContext) {
16994
- return setSpan(context, new NonRecordingSpan(spanContext));
16995
- }
16996
- /**
16997
- * Get the span context of the span if it exists.
16998
- *
16999
- * @param context context to get values from
17000
- */
17001
- function getSpanContext(context) {
17002
- var _a;
17003
- return (_a = getSpan(context)) === null || _a === void 0 ? void 0 : _a.spanContext();
17004
- }
17005
16855
  const isHex = new Uint8Array([
17006
16856
  0,
17007
16857
  0,
@@ -17143,6 +16993,173 @@ function isSpanContextValid(spanContext) {
17143
16993
  function wrapSpanContext(spanContext) {
17144
16994
  return new NonRecordingSpan(spanContext);
17145
16995
  }
16996
+ var NoopContextManager = class {
16997
+ active() {
16998
+ return ROOT_CONTEXT;
16999
+ }
17000
+ with(_context, fn, thisArg, ...args) {
17001
+ return fn.call(thisArg, ...args);
17002
+ }
17003
+ bind(_context, target) {
17004
+ return target;
17005
+ }
17006
+ enable() {
17007
+ return this;
17008
+ }
17009
+ disable() {
17010
+ return this;
17011
+ }
17012
+ /** @experimental This API is experimental and may change in minor releases without prior notice. */
17013
+ attach(_context) {
17014
+ return { dispose() {} };
17015
+ }
17016
+ };
17017
+ const API_NAME$1 = "context";
17018
+ const NOOP_CONTEXT_MANAGER = new NoopContextManager();
17019
+ const NOOP_TOKEN = Object.freeze({ dispose: () => {} });
17020
+ /**
17021
+ * Singleton object which represents the entry point to the OpenTelemetry Context API
17022
+ *
17023
+ * @since 1.0.0
17024
+ */
17025
+ var ContextAPI = class ContextAPI {
17026
+ /** Empty private constructor prevents end users from constructing a new instance of the API */
17027
+ constructor() {
17028
+ this._attachUnsupportedWarned = false;
17029
+ }
17030
+ /** Get the singleton instance of the Context API */
17031
+ static getInstance() {
17032
+ if (!this._instance) this._instance = new ContextAPI();
17033
+ return this._instance;
17034
+ }
17035
+ /**
17036
+ * Set the current context manager.
17037
+ *
17038
+ * @returns true if the context manager was successfully registered, else false
17039
+ */
17040
+ setGlobalContextManager(contextManager) {
17041
+ return registerGlobal(API_NAME$1, contextManager, DiagAPI.instance());
17042
+ }
17043
+ /**
17044
+ * Get the currently active context
17045
+ */
17046
+ active() {
17047
+ return this._getContextManager().active();
17048
+ }
17049
+ /**
17050
+ * Execute a function with an active context
17051
+ *
17052
+ * @param context context to be active during function execution
17053
+ * @param fn function to execute in a context
17054
+ * @param thisArg optional receiver to be used for calling fn
17055
+ * @param args optional arguments forwarded to fn
17056
+ */
17057
+ with(context, fn, thisArg, ...args) {
17058
+ return this._getContextManager().with(context, fn, thisArg, ...args);
17059
+ }
17060
+ /**
17061
+ * Bind a context to a target function or event emitter
17062
+ *
17063
+ * @param context context to bind to the event emitter or function. Defaults to the currently active context
17064
+ * @param target function or event emitter to bind
17065
+ */
17066
+ bind(context, target) {
17067
+ return this._getContextManager().bind(context, target);
17068
+ }
17069
+ /**
17070
+ * Imperatively sets `context` as active, returning a {@link ContextManagementToken} whose
17071
+ * {@link ContextManagementToken.dispose} restores the previous context.
17072
+ *
17073
+ * This is a delicate, low-level API - prefer {@link with}/{@link bind}, which
17074
+ * restore context automatically. Use `attach` only to bridge callback
17075
+ * boundaries that `with` cannot wrap. Call `token.dispose()` when the
17076
+ * operation is done.
17077
+ *
17078
+ * **Caveat for async functions:** If called inside an async function before
17079
+ * the first `await`, the context change may leak into the caller's context
17080
+ * and remain active there. Prefer {@link with} for async code.
17081
+ *
17082
+ * Support is best-effort and varies by the active ContextManager (see
17083
+ * {@link ContextManager.attach}); if it does not implement `attach`, this logs
17084
+ * a warning and returns a no-op token.
17085
+ *
17086
+ * @param context The Context to attach
17087
+ * @returns A {@link ContextManagementToken} whose dispose() restores the previous Context
17088
+ * @since 1.10.0
17089
+ * @experimental This API is experimental and may change in minor releases without prior notice.
17090
+ */
17091
+ attach(context) {
17092
+ const contextManager = this._getContextManager();
17093
+ if (contextManager.attach) return contextManager.attach(context);
17094
+ if (!this._attachUnsupportedWarned) {
17095
+ this._attachUnsupportedWarned = true;
17096
+ 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.");
17097
+ }
17098
+ return NOOP_TOKEN;
17099
+ }
17100
+ _getContextManager() {
17101
+ return getGlobal(API_NAME$1) || NOOP_CONTEXT_MANAGER;
17102
+ }
17103
+ /** Disable and remove the global context manager */
17104
+ disable() {
17105
+ this._getContextManager().disable();
17106
+ unregisterGlobal(API_NAME$1, DiagAPI.instance());
17107
+ }
17108
+ };
17109
+ /**
17110
+ * span key
17111
+ */
17112
+ const SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
17113
+ /**
17114
+ * Return the span if one exists
17115
+ *
17116
+ * @param context context to get span from
17117
+ */
17118
+ function getSpan(context) {
17119
+ return context.getValue(SPAN_KEY) || void 0;
17120
+ }
17121
+ /**
17122
+ * Gets the span from the current context, if one exists.
17123
+ */
17124
+ function getActiveSpan() {
17125
+ return getSpan(ContextAPI.getInstance().active());
17126
+ }
17127
+ /**
17128
+ * Set the span on a context
17129
+ *
17130
+ * @param context context to use as parent
17131
+ * @param span span to set active
17132
+ */
17133
+ function setSpan(context, span) {
17134
+ return context.setValue(SPAN_KEY, span);
17135
+ }
17136
+ /**
17137
+ * Remove current span stored in the context
17138
+ *
17139
+ * @param context context to delete span from
17140
+ */
17141
+ function deleteSpan(context) {
17142
+ return context.deleteValue(SPAN_KEY);
17143
+ }
17144
+ /**
17145
+ * Wrap span context in a NoopSpan and set as span in a new
17146
+ * context
17147
+ *
17148
+ * @param context context to set active span on
17149
+ * @param spanContext span context to be wrapped
17150
+ */
17151
+ function setSpanContext(context, spanContext) {
17152
+ return setSpan(context, new NonRecordingSpan(spanContext));
17153
+ }
17154
+ /**
17155
+ * Get the span context of the span if it exists.
17156
+ *
17157
+ * @param context context to get values from
17158
+ */
17159
+ function getSpanContext(context) {
17160
+ var _getSpan;
17161
+ return (_getSpan = getSpan(context)) === null || _getSpan === void 0 ? void 0 : _getSpan.spanContext();
17162
+ }
17146
17163
  const contextApi = ContextAPI.getInstance();
17147
17164
  /**
17148
17165
  * No-op implementations of {@link Tracer}.
@@ -17155,6 +17172,7 @@ var NoopTracer = class {
17155
17172
  else return new NonRecordingSpan();
17156
17173
  }
17157
17174
  startActiveSpan(name, arg2, arg3, arg4) {
17175
+ var _ctx;
17158
17176
  let opts;
17159
17177
  let ctx;
17160
17178
  let fn;
@@ -17168,7 +17186,7 @@ var NoopTracer = class {
17168
17186
  ctx = arg3;
17169
17187
  fn = arg4;
17170
17188
  }
17171
- const parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
17189
+ const parentContext = (_ctx = ctx) !== null && _ctx !== void 0 ? _ctx : contextApi.active();
17172
17190
  const span = this.startSpan(name, opts, parentContext);
17173
17191
  const contextWithSpanSet = setSpan(parentContext, span);
17174
17192
  return contextApi.with(contextWithSpanSet, fn, void 0, span);
@@ -17237,12 +17255,12 @@ var ProxyTracerProvider = class {
17237
17255
  * Get a {@link ProxyTracer}
17238
17256
  */
17239
17257
  getTracer(name, version, options) {
17240
- var _a;
17241
- return (_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name, version, options);
17258
+ var _this$getDelegateTrac;
17259
+ return (_this$getDelegateTrac = this.getDelegateTracer(name, version, options)) !== null && _this$getDelegateTrac !== void 0 ? _this$getDelegateTrac : new ProxyTracer(this, name, version, options);
17242
17260
  }
17243
17261
  getDelegate() {
17244
- var _a;
17245
- return (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;
17262
+ var _this$_delegate;
17263
+ return (_this$_delegate = this._delegate) !== null && _this$_delegate !== void 0 ? _this$_delegate : NOOP_TRACER_PROVIDER;
17246
17264
  }
17247
17265
  /**
17248
17266
  * Set the delegate tracer provider
@@ -17251,31 +17269,10 @@ var ProxyTracerProvider = class {
17251
17269
  this._delegate = delegate;
17252
17270
  }
17253
17271
  getDelegateTracer(name, version, options) {
17254
- var _a;
17255
- return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options);
17272
+ var _this$_delegate2;
17273
+ return (_this$_delegate2 = this._delegate) === null || _this$_delegate2 === void 0 ? void 0 : _this$_delegate2.getTracer(name, version, options);
17256
17274
  }
17257
17275
  };
17258
- /**
17259
- * An enumeration of status codes.
17260
- *
17261
- * @since 1.0.0
17262
- */
17263
- var SpanStatusCode;
17264
- (function(SpanStatusCode) {
17265
- /**
17266
- * The default status.
17267
- */
17268
- SpanStatusCode[SpanStatusCode["UNSET"] = 0] = "UNSET";
17269
- /**
17270
- * The operation has been validated by an Application developer or
17271
- * Operator to have completed successfully.
17272
- */
17273
- SpanStatusCode[SpanStatusCode["OK"] = 1] = "OK";
17274
- /**
17275
- * The operation contains an error.
17276
- */
17277
- SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
17278
- })(SpanStatusCode || (SpanStatusCode = {}));
17279
17276
  ContextAPI.getInstance();
17280
17277
  const API_NAME = "trace";
17281
17278
  (class TraceAPI {