@elizaos/server 1.6.2-alpha.2 → 1.6.2-alpha.20

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
@@ -12295,21 +12295,21 @@ var require_ParentBasedSampler = __commonJS((exports) => {
12295
12295
  this._localParentSampled = config.localParentSampled ?? new AlwaysOnSampler_1.AlwaysOnSampler;
12296
12296
  this._localParentNotSampled = config.localParentNotSampled ?? new AlwaysOffSampler_1.AlwaysOffSampler;
12297
12297
  }
12298
- shouldSample(context2, traceId, spanName, spanKind, attributes, links) {
12299
- const parentContext = api_1.trace.getSpanContext(context2);
12298
+ shouldSample(context3, traceId, spanName, spanKind, attributes, links) {
12299
+ const parentContext = api_1.trace.getSpanContext(context3);
12300
12300
  if (!parentContext || !(0, api_1.isSpanContextValid)(parentContext)) {
12301
- return this._root.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
12301
+ return this._root.shouldSample(context3, traceId, spanName, spanKind, attributes, links);
12302
12302
  }
12303
12303
  if (parentContext.isRemote) {
12304
12304
  if (parentContext.traceFlags & api_1.TraceFlags.SAMPLED) {
12305
- return this._remoteParentSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
12305
+ return this._remoteParentSampled.shouldSample(context3, traceId, spanName, spanKind, attributes, links);
12306
12306
  }
12307
- return this._remoteParentNotSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
12307
+ return this._remoteParentNotSampled.shouldSample(context3, traceId, spanName, spanKind, attributes, links);
12308
12308
  }
12309
12309
  if (parentContext.traceFlags & api_1.TraceFlags.SAMPLED) {
12310
- return this._localParentSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
12310
+ return this._localParentSampled.shouldSample(context3, traceId, spanName, spanKind, attributes, links);
12311
12311
  }
12312
- return this._localParentNotSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
12312
+ return this._localParentNotSampled.shouldSample(context3, traceId, spanName, spanKind, attributes, links);
12313
12313
  }
12314
12314
  toString() {
12315
12315
  return `ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`;
@@ -12333,7 +12333,7 @@ var require_TraceIdRatioBasedSampler = __commonJS((exports) => {
12333
12333
  this._ratio = this._normalize(_ratio);
12334
12334
  this._upperBound = Math.floor(this._ratio * 4294967295);
12335
12335
  }
12336
- shouldSample(context2, traceId) {
12336
+ shouldSample(context3, traceId) {
12337
12337
  return {
12338
12338
  decision: (0, api_1.isValidTraceId)(traceId) && this._accumulate(traceId) < this._upperBound ? Sampler_1.SamplingDecision.RECORD_AND_SAMPLED : Sampler_1.SamplingDecision.NOT_RECORD
12339
12339
  };
@@ -12729,12 +12729,12 @@ var require_Tracer = __commonJS((exports) => {
12729
12729
  this._spanProcessor = spanProcessor;
12730
12730
  this.instrumentationScope = instrumentationScope;
12731
12731
  }
12732
- startSpan(name, options = {}, context2 = api.context.active()) {
12732
+ startSpan(name, options = {}, context3 = api.context.active()) {
12733
12733
  if (options.root) {
12734
- context2 = api.trace.deleteSpan(context2);
12734
+ context3 = api.trace.deleteSpan(context3);
12735
12735
  }
12736
- const parentSpan = api.trace.getSpan(context2);
12737
- if ((0, core_1.isTracingSuppressed)(context2)) {
12736
+ const parentSpan = api.trace.getSpan(context3);
12737
+ if ((0, core_1.isTracingSuppressed)(context3)) {
12738
12738
  api.diag.debug("Instrumentation suppressed, returning Noop Span");
12739
12739
  const nonRecordingSpan = api.trace.wrapSpanContext(api.INVALID_SPAN_CONTEXT);
12740
12740
  return nonRecordingSpan;
@@ -12759,7 +12759,7 @@ var require_Tracer = __commonJS((exports) => {
12759
12759
  };
12760
12760
  });
12761
12761
  const attributes = (0, core_1.sanitizeAttributes)(options.attributes);
12762
- const samplingResult = this._sampler.shouldSample(context2, traceId, name, spanKind, attributes, links);
12762
+ const samplingResult = this._sampler.shouldSample(context3, traceId, name, spanKind, attributes, links);
12763
12763
  traceState = samplingResult.traceState ?? traceState;
12764
12764
  const traceFlags = samplingResult.decision === api.SamplingDecision.RECORD_AND_SAMPLED ? api.TraceFlags.SAMPLED : api.TraceFlags.NONE;
12765
12765
  const spanContext = { traceId, spanId, traceFlags, traceState };
@@ -12772,7 +12772,7 @@ var require_Tracer = __commonJS((exports) => {
12772
12772
  const span = new Span_1.SpanImpl({
12773
12773
  resource: this._resource,
12774
12774
  scope: this.instrumentationScope,
12775
- context: context2,
12775
+ context: context3,
12776
12776
  spanContext,
12777
12777
  name,
12778
12778
  kind: spanKind,
@@ -12841,9 +12841,9 @@ var require_MultiSpanProcessor = __commonJS((exports) => {
12841
12841
  });
12842
12842
  });
12843
12843
  }
12844
- onStart(span, context2) {
12844
+ onStart(span, context3) {
12845
12845
  for (const spanProcessor of this._spanProcessors) {
12846
- spanProcessor.onStart(span, context2);
12846
+ spanProcessor.onStart(span, context3);
12847
12847
  }
12848
12848
  }
12849
12849
  onEnd(span) {
@@ -13171,19 +13171,19 @@ var require_AbstractAsyncHooksContextManager = __commonJS((exports) => {
13171
13171
  ];
13172
13172
 
13173
13173
  class AbstractAsyncHooksContextManager {
13174
- bind(context6, target) {
13174
+ bind(context7, target) {
13175
13175
  if (target instanceof events_1.EventEmitter) {
13176
- return this._bindEventEmitter(context6, target);
13176
+ return this._bindEventEmitter(context7, target);
13177
13177
  }
13178
13178
  if (typeof target === "function") {
13179
- return this._bindFunction(context6, target);
13179
+ return this._bindFunction(context7, target);
13180
13180
  }
13181
13181
  return target;
13182
13182
  }
13183
- _bindFunction(context6, target) {
13183
+ _bindFunction(context7, target) {
13184
13184
  const manager = this;
13185
13185
  const contextWrapper = function(...args) {
13186
- return manager.with(context6, () => target.apply(this, args));
13186
+ return manager.with(context7, () => target.apply(this, args));
13187
13187
  };
13188
13188
  Object.defineProperty(contextWrapper, "length", {
13189
13189
  enumerable: false,
@@ -13193,7 +13193,7 @@ var require_AbstractAsyncHooksContextManager = __commonJS((exports) => {
13193
13193
  });
13194
13194
  return contextWrapper;
13195
13195
  }
13196
- _bindEventEmitter(context6, ee) {
13196
+ _bindEventEmitter(context7, ee) {
13197
13197
  const map = this._getPatchMap(ee);
13198
13198
  if (map !== undefined)
13199
13199
  return ee;
@@ -13201,7 +13201,7 @@ var require_AbstractAsyncHooksContextManager = __commonJS((exports) => {
13201
13201
  ADD_LISTENER_METHODS.forEach((methodName) => {
13202
13202
  if (ee[methodName] === undefined)
13203
13203
  return;
13204
- ee[methodName] = this._patchAddListener(ee, ee[methodName], context6);
13204
+ ee[methodName] = this._patchAddListener(ee, ee[methodName], context7);
13205
13205
  });
13206
13206
  if (typeof ee.removeListener === "function") {
13207
13207
  ee.removeListener = this._patchRemoveListener(ee, ee.removeListener);
@@ -13239,7 +13239,7 @@ var require_AbstractAsyncHooksContextManager = __commonJS((exports) => {
13239
13239
  return original.apply(this, arguments);
13240
13240
  };
13241
13241
  }
13242
- _patchAddListener(ee, original, context6) {
13242
+ _patchAddListener(ee, original, context7) {
13243
13243
  const contextManager = this;
13244
13244
  return function(event, listener) {
13245
13245
  if (contextManager._wrapped) {
@@ -13254,7 +13254,7 @@ var require_AbstractAsyncHooksContextManager = __commonJS((exports) => {
13254
13254
  listeners = new WeakMap;
13255
13255
  map[event] = listeners;
13256
13256
  }
13257
- const patchedListener = contextManager.bind(context6, listener);
13257
+ const patchedListener = contextManager.bind(context7, listener);
13258
13258
  listeners.set(listener, patchedListener);
13259
13259
  contextManager._wrapped = true;
13260
13260
  try {
@@ -13303,8 +13303,8 @@ var require_AsyncHooksContextManager = __commonJS((exports) => {
13303
13303
  active() {
13304
13304
  return this._stack[this._stack.length - 1] ?? api_1.ROOT_CONTEXT;
13305
13305
  }
13306
- with(context6, fn, thisArg, ...args) {
13307
- this._enterContext(context6);
13306
+ with(context7, fn, thisArg, ...args) {
13307
+ this._enterContext(context7);
13308
13308
  try {
13309
13309
  return fn.call(thisArg, ...args);
13310
13310
  } finally {
@@ -13324,25 +13324,25 @@ var require_AsyncHooksContextManager = __commonJS((exports) => {
13324
13324
  _init(uid, type) {
13325
13325
  if (type === "TIMERWRAP")
13326
13326
  return;
13327
- const context6 = this._stack[this._stack.length - 1];
13328
- if (context6 !== undefined) {
13329
- this._contexts.set(uid, context6);
13327
+ const context7 = this._stack[this._stack.length - 1];
13328
+ if (context7 !== undefined) {
13329
+ this._contexts.set(uid, context7);
13330
13330
  }
13331
13331
  }
13332
13332
  _destroy(uid) {
13333
13333
  this._contexts.delete(uid);
13334
13334
  }
13335
13335
  _before(uid) {
13336
- const context6 = this._contexts.get(uid);
13337
- if (context6 !== undefined) {
13338
- this._enterContext(context6);
13336
+ const context7 = this._contexts.get(uid);
13337
+ if (context7 !== undefined) {
13338
+ this._enterContext(context7);
13339
13339
  }
13340
13340
  }
13341
13341
  _after() {
13342
13342
  this._exitContext();
13343
13343
  }
13344
- _enterContext(context6) {
13345
- this._stack.push(context6);
13344
+ _enterContext(context7) {
13345
+ this._stack.push(context7);
13346
13346
  }
13347
13347
  _exitContext() {
13348
13348
  this._stack.pop();
@@ -13368,9 +13368,9 @@ var require_AsyncLocalStorageContextManager = __commonJS((exports) => {
13368
13368
  active() {
13369
13369
  return this._asyncLocalStorage.getStore() ?? api_1.ROOT_CONTEXT;
13370
13370
  }
13371
- with(context6, fn, thisArg, ...args) {
13371
+ with(context7, fn, thisArg, ...args) {
13372
13372
  const cb = thisArg == null ? fn : fn.bind(thisArg);
13373
- return this._asyncLocalStorage.run(context6, cb, ...args);
13373
+ return this._asyncLocalStorage.run(context7, cb, ...args);
13374
13374
  }
13375
13375
  enable() {
13376
13376
  return this;
@@ -19072,6 +19072,9 @@ var require_parse_options = __commonJS((exports, module) => {
19072
19072
  var require_identifiers = __commonJS((exports, module) => {
19073
19073
  var numeric = /^[0-9]+$/;
19074
19074
  var compareIdentifiers = (a, b) => {
19075
+ if (typeof a === "number" && typeof b === "number") {
19076
+ return a === b ? 0 : a < b ? -1 : 1;
19077
+ }
19075
19078
  const anum = numeric.test(a);
19076
19079
  const bnum = numeric.test(b);
19077
19080
  if (anum && bnum) {
@@ -19174,7 +19177,25 @@ var require_semver3 = __commonJS((exports, module) => {
19174
19177
  if (!(other instanceof SemVer)) {
19175
19178
  other = new SemVer(other, this.options);
19176
19179
  }
19177
- return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
19180
+ if (this.major < other.major) {
19181
+ return -1;
19182
+ }
19183
+ if (this.major > other.major) {
19184
+ return 1;
19185
+ }
19186
+ if (this.minor < other.minor) {
19187
+ return -1;
19188
+ }
19189
+ if (this.minor > other.minor) {
19190
+ return 1;
19191
+ }
19192
+ if (this.patch < other.patch) {
19193
+ return -1;
19194
+ }
19195
+ if (this.patch > other.patch) {
19196
+ return 1;
19197
+ }
19198
+ return 0;
19178
19199
  }
19179
19200
  comparePre(other) {
19180
19201
  if (!(other instanceof SemVer)) {
@@ -19851,6 +19872,7 @@ var require_range = __commonJS((exports, module) => {
19851
19872
  return result;
19852
19873
  };
19853
19874
  var parseComparator = (comp, options) => {
19875
+ comp = comp.replace(re[t.BUILD], "");
19854
19876
  debug2("comp", comp, options);
19855
19877
  comp = replaceCarets(comp, options);
19856
19878
  debug2("caret", comp);
@@ -21778,7 +21800,7 @@ var require_utils20 = __commonJS((exports) => {
21778
21800
  var types_1 = require_types3();
21779
21801
  var AttributeNames_1 = require_AttributeNames7();
21780
21802
  var semantic_conventions_1 = require_src2();
21781
- var getMiddlewareMetadata = (context11, layer, isRouter, layerPath) => {
21803
+ var getMiddlewareMetadata = (context12, layer, isRouter, layerPath) => {
21782
21804
  if (isRouter) {
21783
21805
  return {
21784
21806
  attributes: {
@@ -21786,7 +21808,7 @@ var require_utils20 = __commonJS((exports) => {
21786
21808
  [AttributeNames_1.AttributeNames.KOA_TYPE]: types_1.KoaLayerType.ROUTER,
21787
21809
  [semantic_conventions_1.SEMATTRS_HTTP_ROUTE]: layerPath?.toString()
21788
21810
  },
21789
- name: context11._matchedRouteName || `router - ${layerPath}`
21811
+ name: context12._matchedRouteName || `router - ${layerPath}`
21790
21812
  };
21791
21813
  } else {
21792
21814
  return {
@@ -21882,23 +21904,23 @@ var require_instrumentation17 = __commonJS((exports) => {
21882
21904
  }
21883
21905
  middlewareLayer[internal_types_1.kLayerPatched] = true;
21884
21906
  api2.diag.debug("patching Koa middleware layer");
21885
- return async (context11, next) => {
21907
+ return async (context12, next) => {
21886
21908
  const parent = api2.trace.getSpan(api2.context.active());
21887
21909
  if (parent === undefined) {
21888
- return middlewareLayer(context11, next);
21910
+ return middlewareLayer(context12, next);
21889
21911
  }
21890
- const metadata = (0, utils_1.getMiddlewareMetadata)(context11, middlewareLayer, isRouter, layerPath);
21912
+ const metadata = (0, utils_1.getMiddlewareMetadata)(context12, middlewareLayer, isRouter, layerPath);
21891
21913
  const span = this.tracer.startSpan(metadata.name, {
21892
21914
  attributes: metadata.attributes
21893
21915
  });
21894
21916
  const rpcMetadata = (0, core_1.getRPCMetadata)(api2.context.active());
21895
- if (rpcMetadata?.type === core_1.RPCType.HTTP && context11._matchedRoute) {
21896
- rpcMetadata.route = context11._matchedRoute.toString();
21917
+ if (rpcMetadata?.type === core_1.RPCType.HTTP && context12._matchedRoute) {
21918
+ rpcMetadata.route = context12._matchedRoute.toString();
21897
21919
  }
21898
21920
  const { requestHook: requestHook2 } = this.getConfig();
21899
21921
  if (requestHook2) {
21900
21922
  (0, instrumentation_1.safeExecuteInTheMiddle)(() => requestHook2(span, {
21901
- context: context11,
21923
+ context: context12,
21902
21924
  middlewareLayer,
21903
21925
  layerType
21904
21926
  }), (e) => {
@@ -21910,7 +21932,7 @@ var require_instrumentation17 = __commonJS((exports) => {
21910
21932
  const newContext = api2.trace.setSpan(api2.context.active(), span);
21911
21933
  return api2.context.with(newContext, async () => {
21912
21934
  try {
21913
- return await middlewareLayer(context11, next);
21935
+ return await middlewareLayer(context12, next);
21914
21936
  } catch (err) {
21915
21937
  span.recordException(err);
21916
21938
  throw err;
@@ -22615,16 +22637,16 @@ var require_utils23 = __commonJS((exports) => {
22615
22637
  return attributes;
22616
22638
  };
22617
22639
  exports.getConnectionAttributesFromUrl = getConnectionAttributesFromUrl;
22618
- var markConfirmChannelTracing = (context11) => {
22619
- return context11.setValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY, true);
22640
+ var markConfirmChannelTracing = (context12) => {
22641
+ return context12.setValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY, true);
22620
22642
  };
22621
22643
  exports.markConfirmChannelTracing = markConfirmChannelTracing;
22622
- var unmarkConfirmChannelTracing = (context11) => {
22623
- return context11.deleteValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY);
22644
+ var unmarkConfirmChannelTracing = (context12) => {
22645
+ return context12.deleteValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY);
22624
22646
  };
22625
22647
  exports.unmarkConfirmChannelTracing = unmarkConfirmChannelTracing;
22626
- var isConfirmChannelTracing = (context11) => {
22627
- return context11.getValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY) === true;
22648
+ var isConfirmChannelTracing = (context12) => {
22649
+ return context12.getValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY) === true;
22628
22650
  };
22629
22651
  exports.isConfirmChannelTracing = isConfirmChannelTracing;
22630
22652
  });
@@ -23045,7 +23067,7 @@ var require_src32 = __commonJS((exports) => {
23045
23067
 
23046
23068
  // src/index.ts
23047
23069
  import {
23048
- logger as logger32,
23070
+ logger as logger30,
23049
23071
  parseBooleanFromText,
23050
23072
  getDatabaseDir,
23051
23073
  getGeneratedDir as getGeneratedDir2,
@@ -23595,10 +23617,11 @@ var helmet = Object.assign(function helmet2(options = {}) {
23595
23617
  });
23596
23618
 
23597
23619
  // src/index.ts
23598
- import * as fs7 from "node:fs";
23620
+ import * as fs6 from "node:fs";
23599
23621
  import http4 from "node:http";
23600
23622
  import os3 from "node:os";
23601
- import path9, { basename as basename2, dirname as dirname3, extname, join as join5 } from "node:path";
23623
+ import net3 from "node:net";
23624
+ import path8, { basename as basename2, dirname as dirname3, extname, join as join4 } from "node:path";
23602
23625
  import { fileURLToPath as fileURLToPath2 } from "node:url";
23603
23626
 
23604
23627
  // src/api/index.ts
@@ -23764,6 +23787,8 @@ function createAgentCrudRouter(elizaOS, serverInstance) {
23764
23787
  }
23765
23788
  const updates = req.body;
23766
23789
  try {
23790
+ const currentAgent = await db.getAgent(agentId);
23791
+ const activeRuntime = elizaOS.getAgent(agentId);
23767
23792
  if (updates.settings?.secrets) {
23768
23793
  const salt = getSalt();
23769
23794
  const encryptedSecrets = {};
@@ -23782,11 +23807,46 @@ function createAgentCrudRouter(elizaOS, serverInstance) {
23782
23807
  await db.updateAgent(agentId, updates);
23783
23808
  }
23784
23809
  const updatedAgent = await db.getAgent(agentId);
23785
- const activeRuntime = elizaOS.getAgent(agentId);
23810
+ let needsRestart = false;
23811
+ if (currentAgent && activeRuntime && updatedAgent) {
23812
+ if (updatedAgent.plugins && !Array.isArray(updatedAgent.plugins)) {
23813
+ throw new Error("plugins must be an array");
23814
+ }
23815
+ const currentPlugins = (currentAgent.plugins || []).filter((p) => p != null).map((p) => typeof p === "string" ? p : p.name).filter((name) => typeof name === "string").sort();
23816
+ const updatedPlugins = (updatedAgent.plugins || []).filter((p) => p != null).map((p) => typeof p === "string" ? p : p.name).filter((name) => typeof name === "string").sort();
23817
+ const pluginsChanged = currentPlugins.length !== updatedPlugins.length || currentPlugins.some((plugin, idx) => plugin !== updatedPlugins[idx]);
23818
+ needsRestart = pluginsChanged;
23819
+ if (needsRestart) {
23820
+ logger.debug(`[AGENT UPDATE] Agent ${agentId} requires restart due to plugins changes`);
23821
+ }
23822
+ }
23786
23823
  if (activeRuntime && updatedAgent) {
23787
- const { enabled, status: status2, createdAt, updatedAt, ...characterData } = updatedAgent;
23788
- await elizaOS.updateAgent(agentId, characterData);
23789
- logger.debug(`[AGENT UPDATE] Updated active agent ${agentId} without restart`);
23824
+ if (needsRestart) {
23825
+ logger.debug(`[AGENT UPDATE] Restarting agent ${agentId} due to configuration changes`);
23826
+ try {
23827
+ await serverInstance?.unregisterAgent(agentId);
23828
+ const { enabled, status: status2, createdAt, updatedAt, ...characterData } = updatedAgent;
23829
+ const runtimes = await serverInstance?.startAgents([{ character: characterData }]);
23830
+ if (!runtimes || runtimes.length === 0) {
23831
+ throw new Error("Failed to restart agent after configuration change");
23832
+ }
23833
+ logger.success(`[AGENT UPDATE] Agent ${agentId} restarted successfully`);
23834
+ } catch (restartError) {
23835
+ logger.error({ error: restartError, agentId }, `[AGENT UPDATE] Failed to restart agent ${agentId}, attempting to restore previous state`);
23836
+ try {
23837
+ const { enabled, status: status2, createdAt, updatedAt, ...previousCharacterData } = currentAgent;
23838
+ await serverInstance?.startAgents([{ character: previousCharacterData }]);
23839
+ logger.warn(`[AGENT UPDATE] Restored agent ${agentId} to previous state`);
23840
+ } catch (restoreError) {
23841
+ logger.error({ error: restoreError, agentId }, `[AGENT UPDATE] Failed to restore agent ${agentId} - agent may be in broken state`);
23842
+ }
23843
+ throw restartError;
23844
+ }
23845
+ } else {
23846
+ const { enabled, status: status2, createdAt, updatedAt, ...characterData } = updatedAgent;
23847
+ await elizaOS.updateAgent(agentId, characterData);
23848
+ logger.debug(`[AGENT UPDATE] Updated active agent ${agentId} without restart`);
23849
+ }
23790
23850
  }
23791
23851
  const runtime = elizaOS.getAgent(agentId);
23792
23852
  const status = runtime ? "active" : "inactive";
@@ -23897,7 +23957,7 @@ import { validateUuid as validateUuid2, logger as logger2 } from "@elizaos/core"
23897
23957
  import express2 from "express";
23898
23958
  function createAgentLifecycleRouter(elizaOS, serverInstance) {
23899
23959
  const router = express2.Router();
23900
- const db = serverInstance?.database;
23960
+ const db = serverInstance.database;
23901
23961
  router.post("/:agentId/start", async (req, res) => {
23902
23962
  const agentId = validateUuid2(req.params.agentId);
23903
23963
  if (!agentId) {
@@ -23921,7 +23981,7 @@ function createAgentLifecycleRouter(elizaOS, serverInstance) {
23921
23981
  status: "active"
23922
23982
  });
23923
23983
  }
23924
- await serverInstance?.startAgents([agent]);
23984
+ await serverInstance.startAgents([{ character: agent }]);
23925
23985
  const runtime = elizaOS.getAgent(agentId);
23926
23986
  if (!runtime) {
23927
23987
  throw new Error("Failed to start agent");
@@ -28796,7 +28856,7 @@ import express30 from "express";
28796
28856
  // package.json
28797
28857
  var package_default = {
28798
28858
  name: "@elizaos/server",
28799
- version: "1.6.2-alpha.2",
28859
+ version: "1.6.2-alpha.20",
28800
28860
  description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
28801
28861
  publishConfig: {
28802
28862
  access: "public",
@@ -30343,7 +30403,7 @@ async function loadCharacters(charactersArg) {
30343
30403
  }
30344
30404
 
30345
30405
  // ../../node_modules/@sentry/node/build/esm/integrations/http.js
30346
- var import_api9 = __toESM(require_src(), 1);
30406
+ var import_api10 = __toESM(require_src(), 1);
30347
30407
  var import_instrumentation_http = __toESM(require_src7(), 1);
30348
30408
 
30349
30409
  // ../../node_modules/@sentry/core/build/esm/debug-build.js
@@ -30353,7 +30413,7 @@ var DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
30353
30413
  var GLOBAL_OBJ = globalThis;
30354
30414
 
30355
30415
  // ../../node_modules/@sentry/core/build/esm/utils/version.js
30356
- var SDK_VERSION = "10.16.0";
30416
+ var SDK_VERSION = "10.20.0";
30357
30417
 
30358
30418
  // ../../node_modules/@sentry/core/build/esm/carrier.js
30359
30419
  function getMainCarrier() {
@@ -31783,13 +31843,21 @@ function parseBaggageHeader(baggageHeader) {
31783
31843
  return baggageHeaderToObject(baggageHeader);
31784
31844
  }
31785
31845
  function baggageHeaderToObject(baggageHeader) {
31786
- return baggageHeader.split(",").map((baggageEntry) => baggageEntry.split("=").map((keyOrValue) => {
31787
- try {
31788
- return decodeURIComponent(keyOrValue.trim());
31789
- } catch {
31790
- return;
31846
+ return baggageHeader.split(",").map((baggageEntry) => {
31847
+ const eqIdx = baggageEntry.indexOf("=");
31848
+ if (eqIdx === -1) {
31849
+ return [];
31791
31850
  }
31792
- })).reduce((acc, [key, value]) => {
31851
+ const key = baggageEntry.slice(0, eqIdx);
31852
+ const value = baggageEntry.slice(eqIdx + 1);
31853
+ return [key, value].map((keyOrValue) => {
31854
+ try {
31855
+ return decodeURIComponent(keyOrValue.trim());
31856
+ } catch {
31857
+ return;
31858
+ }
31859
+ });
31860
+ }).reduce((acc, [key, value]) => {
31793
31861
  if (key && value) {
31794
31862
  acc[key] = value;
31795
31863
  }
@@ -32573,7 +32641,9 @@ var ITEM_TYPE_TO_DATA_CATEGORY_MAP = {
32573
32641
  feedback: "feedback",
32574
32642
  span: "span",
32575
32643
  raw_security: "security",
32576
- log: "log_item"
32644
+ log: "log_item",
32645
+ metric: "metric",
32646
+ trace_metric: "metric"
32577
32647
  };
32578
32648
  function envelopeItemTypeToDataCategory(type) {
32579
32649
  return ITEM_TYPE_TO_DATA_CATEGORY_MAP[type];
@@ -33524,40 +33594,55 @@ function applyFingerprintToEvent(event, fingerprint) {
33524
33594
 
33525
33595
  // ../../node_modules/@sentry/core/build/esm/utils/debug-ids.js
33526
33596
  var parsedStackResults;
33527
- var lastKeysCount;
33597
+ var lastSentryKeysCount;
33598
+ var lastNativeKeysCount;
33528
33599
  var cachedFilenameDebugIds;
33529
33600
  function getFilenameToDebugIdMap(stackParser) {
33530
- const debugIdMap = GLOBAL_OBJ._sentryDebugIds;
33531
- if (!debugIdMap) {
33601
+ const sentryDebugIdMap = GLOBAL_OBJ._sentryDebugIds;
33602
+ const nativeDebugIdMap = GLOBAL_OBJ._debugIds;
33603
+ if (!sentryDebugIdMap && !nativeDebugIdMap) {
33532
33604
  return {};
33533
33605
  }
33534
- const debugIdKeys = Object.keys(debugIdMap);
33535
- if (cachedFilenameDebugIds && debugIdKeys.length === lastKeysCount) {
33606
+ const sentryDebugIdKeys = sentryDebugIdMap ? Object.keys(sentryDebugIdMap) : [];
33607
+ const nativeDebugIdKeys = nativeDebugIdMap ? Object.keys(nativeDebugIdMap) : [];
33608
+ if (cachedFilenameDebugIds && sentryDebugIdKeys.length === lastSentryKeysCount && nativeDebugIdKeys.length === lastNativeKeysCount) {
33536
33609
  return cachedFilenameDebugIds;
33537
33610
  }
33538
- lastKeysCount = debugIdKeys.length;
33539
- cachedFilenameDebugIds = debugIdKeys.reduce((acc, stackKey) => {
33540
- if (!parsedStackResults) {
33541
- parsedStackResults = {};
33542
- }
33543
- const result = parsedStackResults[stackKey];
33544
- if (result) {
33545
- acc[result[0]] = result[1];
33546
- } else {
33547
- const parsedStack = stackParser(stackKey);
33548
- for (let i = parsedStack.length - 1;i >= 0; i--) {
33549
- const stackFrame = parsedStack[i];
33550
- const filename = stackFrame?.filename;
33551
- const debugId = debugIdMap[stackKey];
33552
- if (filename && debugId) {
33553
- acc[filename] = debugId;
33554
- parsedStackResults[stackKey] = [filename, debugId];
33555
- break;
33611
+ lastSentryKeysCount = sentryDebugIdKeys.length;
33612
+ lastNativeKeysCount = nativeDebugIdKeys.length;
33613
+ cachedFilenameDebugIds = {};
33614
+ if (!parsedStackResults) {
33615
+ parsedStackResults = {};
33616
+ }
33617
+ const processDebugIds = (debugIdKeys, debugIdMap) => {
33618
+ for (const key of debugIdKeys) {
33619
+ const debugId = debugIdMap[key];
33620
+ const result = parsedStackResults?.[key];
33621
+ if (result && cachedFilenameDebugIds && debugId) {
33622
+ cachedFilenameDebugIds[result[0]] = debugId;
33623
+ if (parsedStackResults) {
33624
+ parsedStackResults[key] = [result[0], debugId];
33625
+ }
33626
+ } else if (debugId) {
33627
+ const parsedStack = stackParser(key);
33628
+ for (let i = parsedStack.length - 1;i >= 0; i--) {
33629
+ const stackFrame = parsedStack[i];
33630
+ const filename = stackFrame?.filename;
33631
+ if (filename && cachedFilenameDebugIds && parsedStackResults) {
33632
+ cachedFilenameDebugIds[filename] = debugId;
33633
+ parsedStackResults[key] = [filename, debugId];
33634
+ break;
33635
+ }
33556
33636
  }
33557
33637
  }
33558
33638
  }
33559
- return acc;
33560
- }, {});
33639
+ };
33640
+ if (sentryDebugIdMap) {
33641
+ processDebugIds(sentryDebugIdKeys, sentryDebugIdMap);
33642
+ }
33643
+ if (nativeDebugIdMap) {
33644
+ processDebugIds(nativeDebugIdKeys, nativeDebugIdMap);
33645
+ }
33561
33646
  return cachedFilenameDebugIds;
33562
33647
  }
33563
33648
 
@@ -33902,6 +33987,111 @@ function defineIntegration(fn) {
33902
33987
  return fn;
33903
33988
  }
33904
33989
 
33990
+ // ../../node_modules/@sentry/core/build/esm/utils/trace-info.js
33991
+ function _getTraceInfoFromScope(client, scope) {
33992
+ if (!scope) {
33993
+ return [undefined, undefined];
33994
+ }
33995
+ return withScope2(scope, () => {
33996
+ const span = getActiveSpan();
33997
+ const traceContext = span ? spanToTraceContext(span) : getTraceContextFromScope(scope);
33998
+ const dynamicSamplingContext = span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromScope(client, scope);
33999
+ return [dynamicSamplingContext, traceContext];
34000
+ });
34001
+ }
34002
+
34003
+ // ../../node_modules/@sentry/core/build/esm/logs/envelope.js
34004
+ function createLogContainerEnvelopeItem(items) {
34005
+ return [
34006
+ {
34007
+ type: "log",
34008
+ item_count: items.length,
34009
+ content_type: "application/vnd.sentry.items.log+json"
34010
+ },
34011
+ {
34012
+ items
34013
+ }
34014
+ ];
34015
+ }
34016
+ function createLogEnvelope(logs, metadata, tunnel, dsn) {
34017
+ const headers = {};
34018
+ if (metadata?.sdk) {
34019
+ headers.sdk = {
34020
+ name: metadata.sdk.name,
34021
+ version: metadata.sdk.version
34022
+ };
34023
+ }
34024
+ if (!!tunnel && !!dsn) {
34025
+ headers.dsn = dsnToString(dsn);
34026
+ }
34027
+ return createEnvelope(headers, [createLogContainerEnvelopeItem(logs)]);
34028
+ }
34029
+
34030
+ // ../../node_modules/@sentry/core/build/esm/logs/internal.js
34031
+ function _INTERNAL_flushLogsBuffer(client, maybeLogBuffer) {
34032
+ const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];
34033
+ if (logBuffer.length === 0) {
34034
+ return;
34035
+ }
34036
+ const clientOptions = client.getOptions();
34037
+ const envelope = createLogEnvelope(logBuffer, clientOptions._metadata, clientOptions.tunnel, client.getDsn());
34038
+ _getBufferMap().set(client, []);
34039
+ client.emit("flushLogs");
34040
+ client.sendEnvelope(envelope);
34041
+ }
34042
+ function _INTERNAL_getLogBuffer(client) {
34043
+ return _getBufferMap().get(client);
34044
+ }
34045
+ function _getBufferMap() {
34046
+ return getGlobalSingleton("clientToLogBufferMap", () => new WeakMap);
34047
+ }
34048
+
34049
+ // ../../node_modules/@sentry/core/build/esm/metrics/envelope.js
34050
+ function createMetricContainerEnvelopeItem(items) {
34051
+ return [
34052
+ {
34053
+ type: "trace_metric",
34054
+ item_count: items.length,
34055
+ content_type: "application/vnd.sentry.items.trace-metric+json"
34056
+ },
34057
+ {
34058
+ items
34059
+ }
34060
+ ];
34061
+ }
34062
+ function createMetricEnvelope(metrics, metadata, tunnel, dsn) {
34063
+ const headers = {};
34064
+ if (metadata?.sdk) {
34065
+ headers.sdk = {
34066
+ name: metadata.sdk.name,
34067
+ version: metadata.sdk.version
34068
+ };
34069
+ }
34070
+ if (!!tunnel && !!dsn) {
34071
+ headers.dsn = dsnToString(dsn);
34072
+ }
34073
+ return createEnvelope(headers, [createMetricContainerEnvelopeItem(metrics)]);
34074
+ }
34075
+
34076
+ // ../../node_modules/@sentry/core/build/esm/metrics/internal.js
34077
+ function _INTERNAL_flushMetricsBuffer(client, maybeMetricBuffer) {
34078
+ const metricBuffer = maybeMetricBuffer ?? _INTERNAL_getMetricBuffer(client) ?? [];
34079
+ if (metricBuffer.length === 0) {
34080
+ return;
34081
+ }
34082
+ const clientOptions = client.getOptions();
34083
+ const envelope = createMetricEnvelope(metricBuffer, clientOptions._metadata, clientOptions.tunnel, client.getDsn());
34084
+ _getBufferMap2().set(client, []);
34085
+ client.emit("flushMetrics");
34086
+ client.sendEnvelope(envelope);
34087
+ }
34088
+ function _INTERNAL_getMetricBuffer(client) {
34089
+ return _getBufferMap2().get(client);
34090
+ }
34091
+ function _getBufferMap2() {
34092
+ return getGlobalSingleton("clientToMetricBufferMap", () => new WeakMap);
34093
+ }
34094
+
33905
34095
  // ../../node_modules/@sentry/core/build/esm/utils/clientreport.js
33906
34096
  function createClientReportEnvelope(discarded_events, dsn, timestamp) {
33907
34097
  const clientReportItem = [
@@ -33982,6 +34172,7 @@ var ALREADY_SEEN_ERROR = "Not capturing exception because it's already been capt
33982
34172
  var MISSING_RELEASE_FOR_SESSION_ERROR = "Discarded session because of missing or non-string release";
33983
34173
  var INTERNAL_ERROR_SYMBOL = Symbol.for("SentryInternalError");
33984
34174
  var DO_NOT_SEND_EVENT_SYMBOL = Symbol.for("SentryDoNotSendEventError");
34175
+ var DEFAULT_FLUSH_INTERVAL = 5000;
33985
34176
  function _makeInternalError(message) {
33986
34177
  return {
33987
34178
  message,
@@ -34000,6 +34191,28 @@ function _isInternalError(error2) {
34000
34191
  function _isDoNotSendEventError(error2) {
34001
34192
  return !!error2 && typeof error2 === "object" && DO_NOT_SEND_EVENT_SYMBOL in error2;
34002
34193
  }
34194
+ function setupWeightBasedFlushing(client, afterCaptureHook, flushHook, estimateSizeFn, flushFn) {
34195
+ let weight = 0;
34196
+ let flushTimeout;
34197
+ client.on(flushHook, () => {
34198
+ weight = 0;
34199
+ clearTimeout(flushTimeout);
34200
+ });
34201
+ client.on(afterCaptureHook, (item) => {
34202
+ weight += estimateSizeFn(item);
34203
+ if (weight >= 800000) {
34204
+ flushFn(client);
34205
+ } else {
34206
+ clearTimeout(flushTimeout);
34207
+ flushTimeout = setTimeout(() => {
34208
+ flushFn(client);
34209
+ }, DEFAULT_FLUSH_INTERVAL);
34210
+ }
34211
+ });
34212
+ client.on("flush", () => {
34213
+ flushFn(client);
34214
+ });
34215
+ }
34003
34216
 
34004
34217
  class Client {
34005
34218
  constructor(options) {
@@ -34023,6 +34236,12 @@ class Client {
34023
34236
  url
34024
34237
  });
34025
34238
  }
34239
+ if (this._options.enableLogs) {
34240
+ setupWeightBasedFlushing(this, "afterCaptureLog", "flushLogs", estimateLogSizeInBytes, _INTERNAL_flushLogsBuffer);
34241
+ }
34242
+ if (this._options._experiments?.enableMetrics) {
34243
+ setupWeightBasedFlushing(this, "afterCaptureMetric", "flushMetrics", estimateMetricSizeInBytes, _INTERNAL_flushMetricsBuffer);
34244
+ }
34026
34245
  }
34027
34246
  captureException(exception, hint, scope) {
34028
34247
  const eventId = uuid4();
@@ -34464,16 +34683,50 @@ function isErrorEvent2(event) {
34464
34683
  function isTransactionEvent(event) {
34465
34684
  return event.type === "transaction";
34466
34685
  }
34467
- function _getTraceInfoFromScope(client, scope) {
34468
- if (!scope) {
34469
- return [undefined, undefined];
34686
+ function estimateMetricSizeInBytes(metric) {
34687
+ let weight = 0;
34688
+ if (metric.name) {
34689
+ weight += metric.name.length * 2;
34470
34690
  }
34471
- return withScope2(scope, () => {
34472
- const span = getActiveSpan();
34473
- const traceContext = span ? spanToTraceContext(span) : getTraceContextFromScope(scope);
34474
- const dynamicSamplingContext = span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromScope(client, scope);
34475
- return [dynamicSamplingContext, traceContext];
34691
+ if (typeof metric.value === "string") {
34692
+ weight += metric.value.length * 2;
34693
+ } else {
34694
+ weight += 8;
34695
+ }
34696
+ return weight + estimateAttributesSizeInBytes(metric.attributes);
34697
+ }
34698
+ function estimateLogSizeInBytes(log2) {
34699
+ let weight = 0;
34700
+ if (log2.message) {
34701
+ weight += log2.message.length * 2;
34702
+ }
34703
+ return weight + estimateAttributesSizeInBytes(log2.attributes);
34704
+ }
34705
+ function estimateAttributesSizeInBytes(attributes) {
34706
+ if (!attributes) {
34707
+ return 0;
34708
+ }
34709
+ let weight = 0;
34710
+ Object.values(attributes).forEach((value) => {
34711
+ if (Array.isArray(value)) {
34712
+ weight += value.length * estimatePrimitiveSizeInBytes(value[0]);
34713
+ } else if (isPrimitive(value)) {
34714
+ weight += estimatePrimitiveSizeInBytes(value);
34715
+ } else {
34716
+ weight += 100;
34717
+ }
34476
34718
  });
34719
+ return weight;
34720
+ }
34721
+ function estimatePrimitiveSizeInBytes(value) {
34722
+ if (typeof value === "string") {
34723
+ return value.length * 2;
34724
+ } else if (typeof value === "number") {
34725
+ return 8;
34726
+ } else if (typeof value === "boolean") {
34727
+ return 4;
34728
+ }
34729
+ return 0;
34477
34730
  }
34478
34731
 
34479
34732
  // ../../node_modules/@sentry/core/build/esm/checkin.js
@@ -34503,52 +34756,6 @@ function createCheckInEnvelopeItem(checkIn) {
34503
34756
  return [checkInHeaders, checkIn];
34504
34757
  }
34505
34758
 
34506
- // ../../node_modules/@sentry/core/build/esm/logs/envelope.js
34507
- function createLogContainerEnvelopeItem(items) {
34508
- return [
34509
- {
34510
- type: "log",
34511
- item_count: items.length,
34512
- content_type: "application/vnd.sentry.items.log+json"
34513
- },
34514
- {
34515
- items
34516
- }
34517
- ];
34518
- }
34519
- function createLogEnvelope(logs, metadata, tunnel, dsn) {
34520
- const headers = {};
34521
- if (metadata?.sdk) {
34522
- headers.sdk = {
34523
- name: metadata.sdk.name,
34524
- version: metadata.sdk.version
34525
- };
34526
- }
34527
- if (!!tunnel && !!dsn) {
34528
- headers.dsn = dsnToString(dsn);
34529
- }
34530
- return createEnvelope(headers, [createLogContainerEnvelopeItem(logs)]);
34531
- }
34532
-
34533
- // ../../node_modules/@sentry/core/build/esm/logs/internal.js
34534
- function _INTERNAL_flushLogsBuffer(client, maybeLogBuffer) {
34535
- const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];
34536
- if (logBuffer.length === 0) {
34537
- return;
34538
- }
34539
- const clientOptions = client.getOptions();
34540
- const envelope = createLogEnvelope(logBuffer, clientOptions._metadata, clientOptions.tunnel, client.getDsn());
34541
- _getBufferMap().set(client, []);
34542
- client.emit("flushLogs");
34543
- client.sendEnvelope(envelope);
34544
- }
34545
- function _INTERNAL_getLogBuffer(client) {
34546
- return _getBufferMap().get(client);
34547
- }
34548
- function _getBufferMap() {
34549
- return getGlobalSingleton("clientToLogBufferMap", () => new WeakMap);
34550
- }
34551
-
34552
34759
  // ../../node_modules/@sentry/core/build/esm/utils/eventbuilder.js
34553
34760
  function parseStackFrames(stackParser, error2) {
34554
34761
  return stackParser(error2.stack || "", 1);
@@ -34673,33 +34880,10 @@ function eventFromMessage(stackParser, message, level = "info", hint, attachStac
34673
34880
  }
34674
34881
 
34675
34882
  // ../../node_modules/@sentry/core/build/esm/server-runtime-client.js
34676
- var DEFAULT_LOG_FLUSH_INTERVAL = 5000;
34677
-
34678
34883
  class ServerRuntimeClient extends Client {
34679
34884
  constructor(options) {
34680
34885
  registerSpanErrorInstrumentation();
34681
34886
  super(options);
34682
- this._logWeight = 0;
34683
- if (this._options.enableLogs) {
34684
- const client = this;
34685
- client.on("flushLogs", () => {
34686
- client._logWeight = 0;
34687
- clearTimeout(client._logFlushIdleTimeout);
34688
- });
34689
- client.on("afterCaptureLog", (log2) => {
34690
- client._logWeight += estimateLogSizeInBytes(log2);
34691
- if (client._logWeight >= 800000) {
34692
- _INTERNAL_flushLogsBuffer(client);
34693
- } else {
34694
- client._logFlushIdleTimeout = setTimeout(() => {
34695
- _INTERNAL_flushLogsBuffer(client);
34696
- }, DEFAULT_LOG_FLUSH_INTERVAL);
34697
- }
34698
- });
34699
- client.on("flush", () => {
34700
- _INTERNAL_flushLogsBuffer(client);
34701
- });
34702
- }
34703
34887
  }
34704
34888
  eventFromException(exception, hint) {
34705
34889
  const event = eventFromUnknownInput(this, this._options.stackParser, exception, hint);
@@ -34786,34 +34970,6 @@ function setCurrentRequestSessionErroredOrCrashed(eventHint) {
34786
34970
  }
34787
34971
  }
34788
34972
  }
34789
- function estimateLogSizeInBytes(log2) {
34790
- let weight = 0;
34791
- if (log2.message) {
34792
- weight += log2.message.length * 2;
34793
- }
34794
- if (log2.attributes) {
34795
- Object.values(log2.attributes).forEach((value) => {
34796
- if (Array.isArray(value)) {
34797
- weight += value.length * estimatePrimitiveSizeInBytes(value[0]);
34798
- } else if (isPrimitive(value)) {
34799
- weight += estimatePrimitiveSizeInBytes(value);
34800
- } else {
34801
- weight += 100;
34802
- }
34803
- });
34804
- }
34805
- return weight;
34806
- }
34807
- function estimatePrimitiveSizeInBytes(value) {
34808
- if (typeof value === "string") {
34809
- return value.length * 2;
34810
- } else if (typeof value === "number") {
34811
- return 8;
34812
- } else if (typeof value === "boolean") {
34813
- return 4;
34814
- }
34815
- return 0;
34816
- }
34817
34973
  // ../../node_modules/@sentry/core/build/esm/utils/promisebuffer.js
34818
34974
  var SENTRY_BUFFER_FULL_ERROR = Symbol.for("SentryBufferFullError");
34819
34975
  function makePromiseBuffer(limit = 100) {
@@ -35758,6 +35914,7 @@ function _INTERNAL_cleanupToolCallSpan(toolCallId) {
35758
35914
 
35759
35915
  // ../../node_modules/@sentry/core/build/esm/utils/vercel-ai/vercel-ai-attributes.js
35760
35916
  var AI_PROMPT_ATTRIBUTE = "ai.prompt";
35917
+ var AI_SCHEMA_ATTRIBUTE = "ai.schema";
35761
35918
  var AI_RESPONSE_OBJECT_ATTRIBUTE = "ai.response.object";
35762
35919
  var AI_RESPONSE_TEXT_ATTRIBUTE = "ai.response.text";
35763
35920
  var AI_RESPONSE_TOOL_CALLS_ATTRIBUTE = "ai.response.toolCalls";
@@ -35834,6 +35991,7 @@ function processEndedVercelAiSpan(span) {
35834
35991
  renameAttributeKey(attributes, AI_PROMPT_TOOLS_ATTRIBUTE, "gen_ai.request.available_tools");
35835
35992
  renameAttributeKey(attributes, AI_TOOL_CALL_ARGS_ATTRIBUTE, "gen_ai.tool.input");
35836
35993
  renameAttributeKey(attributes, AI_TOOL_CALL_RESULT_ATTRIBUTE, "gen_ai.tool.output");
35994
+ renameAttributeKey(attributes, AI_SCHEMA_ATTRIBUTE, "gen_ai.request.schema");
35837
35995
  addProviderMetadataToAttributes(attributes);
35838
35996
  for (const key of Object.keys(attributes)) {
35839
35997
  if (key.startsWith("ai.")) {
@@ -35870,7 +36028,7 @@ function processGenerateSpan(span, name, attributes) {
35870
36028
  span.setAttribute("ai.pipeline.name", nameWthoutAi);
35871
36029
  span.updateName(nameWthoutAi);
35872
36030
  const functionId = attributes[AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE];
35873
- if (functionId && typeof functionId === "string" && name.split(".").length - 1 === 1) {
36031
+ if (functionId && typeof functionId === "string") {
35874
36032
  span.updateName(`${nameWthoutAi} ${functionId}`);
35875
36033
  span.setAttribute("gen_ai.function_id", functionId);
35876
36034
  }
@@ -36898,11 +37056,112 @@ function instrumentAnthropicAiClient(anthropicAiClient, options) {
36898
37056
  }
36899
37057
  // ../../node_modules/@sentry/core/build/esm/utils/google-genai/constants.js
36900
37058
  var GOOGLE_GENAI_INTEGRATION_NAME = "Google_GenAI";
36901
- var GOOGLE_GENAI_INSTRUMENTED_METHODS = ["models.generateContent", "chats.create", "sendMessage"];
37059
+ var GOOGLE_GENAI_INSTRUMENTED_METHODS = [
37060
+ "models.generateContent",
37061
+ "models.generateContentStream",
37062
+ "chats.create",
37063
+ "sendMessage",
37064
+ "sendMessageStream"
37065
+ ];
36902
37066
  var GOOGLE_GENAI_SYSTEM_NAME = "google_genai";
36903
37067
  var CHATS_CREATE_METHOD = "chats.create";
36904
37068
  var CHAT_PATH = "chat";
36905
37069
 
37070
+ // ../../node_modules/@sentry/core/build/esm/utils/google-genai/streaming.js
37071
+ function isErrorChunk(chunk, span) {
37072
+ const feedback = chunk?.promptFeedback;
37073
+ if (feedback?.blockReason) {
37074
+ const message = feedback.blockReasonMessage ?? feedback.blockReason;
37075
+ span.setStatus({ code: SPAN_STATUS_ERROR, message: `Content blocked: ${message}` });
37076
+ captureException(`Content blocked: ${message}`, {
37077
+ mechanism: { handled: false, type: "auto.ai.google_genai" }
37078
+ });
37079
+ return true;
37080
+ }
37081
+ return false;
37082
+ }
37083
+ function handleResponseMetadata(chunk, state) {
37084
+ if (typeof chunk.responseId === "string")
37085
+ state.responseId = chunk.responseId;
37086
+ if (typeof chunk.modelVersion === "string")
37087
+ state.responseModel = chunk.modelVersion;
37088
+ const usage = chunk.usageMetadata;
37089
+ if (usage) {
37090
+ if (typeof usage.promptTokenCount === "number")
37091
+ state.promptTokens = usage.promptTokenCount;
37092
+ if (typeof usage.candidatesTokenCount === "number")
37093
+ state.completionTokens = usage.candidatesTokenCount;
37094
+ if (typeof usage.totalTokenCount === "number")
37095
+ state.totalTokens = usage.totalTokenCount;
37096
+ }
37097
+ }
37098
+ function handleCandidateContent(chunk, state, recordOutputs) {
37099
+ if (Array.isArray(chunk.functionCalls)) {
37100
+ state.toolCalls.push(...chunk.functionCalls);
37101
+ }
37102
+ for (const candidate of chunk.candidates ?? []) {
37103
+ if (candidate?.finishReason && !state.finishReasons.includes(candidate.finishReason)) {
37104
+ state.finishReasons.push(candidate.finishReason);
37105
+ }
37106
+ for (const part of candidate?.content?.parts ?? []) {
37107
+ if (recordOutputs && part.text)
37108
+ state.responseTexts.push(part.text);
37109
+ if (part.functionCall) {
37110
+ state.toolCalls.push({
37111
+ type: "function",
37112
+ id: part.functionCall.id,
37113
+ name: part.functionCall.name,
37114
+ arguments: part.functionCall.args
37115
+ });
37116
+ }
37117
+ }
37118
+ }
37119
+ }
37120
+ function processChunk(chunk, state, recordOutputs, span) {
37121
+ if (!chunk || isErrorChunk(chunk, span))
37122
+ return;
37123
+ handleResponseMetadata(chunk, state);
37124
+ handleCandidateContent(chunk, state, recordOutputs);
37125
+ }
37126
+ async function* instrumentStream2(stream, span, recordOutputs) {
37127
+ const state = {
37128
+ responseTexts: [],
37129
+ finishReasons: [],
37130
+ toolCalls: []
37131
+ };
37132
+ try {
37133
+ for await (const chunk of stream) {
37134
+ processChunk(chunk, state, recordOutputs, span);
37135
+ yield chunk;
37136
+ }
37137
+ } finally {
37138
+ const attrs = {
37139
+ [GEN_AI_RESPONSE_STREAMING_ATTRIBUTE]: true
37140
+ };
37141
+ if (state.responseId)
37142
+ attrs[GEN_AI_RESPONSE_ID_ATTRIBUTE] = state.responseId;
37143
+ if (state.responseModel)
37144
+ attrs[GEN_AI_RESPONSE_MODEL_ATTRIBUTE] = state.responseModel;
37145
+ if (state.promptTokens !== undefined)
37146
+ attrs[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] = state.promptTokens;
37147
+ if (state.completionTokens !== undefined)
37148
+ attrs[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] = state.completionTokens;
37149
+ if (state.totalTokens !== undefined)
37150
+ attrs[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE] = state.totalTokens;
37151
+ if (state.finishReasons.length) {
37152
+ attrs[GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE] = JSON.stringify(state.finishReasons);
37153
+ }
37154
+ if (recordOutputs && state.responseTexts.length) {
37155
+ attrs[GEN_AI_RESPONSE_TEXT_ATTRIBUTE] = state.responseTexts.join("");
37156
+ }
37157
+ if (recordOutputs && state.toolCalls.length) {
37158
+ attrs[GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE] = JSON.stringify(state.toolCalls);
37159
+ }
37160
+ span.setAttributes(attrs);
37161
+ span.end();
37162
+ }
37163
+ }
37164
+
36906
37165
  // ../../node_modules/@sentry/core/build/esm/utils/google-genai/utils.js
36907
37166
  function shouldInstrument3(methodPath) {
36908
37167
  if (GOOGLE_GENAI_INSTRUMENTED_METHODS.includes(methodPath)) {
@@ -36911,6 +37170,9 @@ function shouldInstrument3(methodPath) {
36911
37170
  const methodName = methodPath.split(".").pop();
36912
37171
  return GOOGLE_GENAI_INSTRUMENTED_METHODS.includes(methodName);
36913
37172
  }
37173
+ function isStreamingMethod(methodPath) {
37174
+ return methodPath.includes("Stream") || methodPath.endsWith("generateContentStream") || methodPath.endsWith("sendMessageStream");
37175
+ }
36914
37176
 
36915
37177
  // ../../node_modules/@sentry/core/build/esm/utils/google-genai/index.js
36916
37178
  function extractModel(params, context) {
@@ -36950,17 +37212,21 @@ function extractConfigAttributes(config) {
36950
37212
  }
36951
37213
  return attributes;
36952
37214
  }
36953
- function extractRequestAttributes3(args, methodPath, context) {
37215
+ function extractRequestAttributes3(methodPath, params, context) {
36954
37216
  const attributes = {
36955
37217
  [GEN_AI_SYSTEM_ATTRIBUTE]: GOOGLE_GENAI_SYSTEM_NAME,
36956
37218
  [GEN_AI_OPERATION_NAME_ATTRIBUTE]: getFinalOperationName(methodPath),
36957
37219
  [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ai.google_genai"
36958
37220
  };
36959
- if (args.length > 0 && typeof args[0] === "object" && args[0] !== null) {
36960
- const params = args[0];
37221
+ if (params) {
36961
37222
  attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = extractModel(params, context);
36962
37223
  if ("config" in params && typeof params.config === "object" && params.config) {
36963
- Object.assign(attributes, extractConfigAttributes(params.config));
37224
+ const config = params.config;
37225
+ Object.assign(attributes, extractConfigAttributes(config));
37226
+ if ("tools" in config && Array.isArray(config.tools)) {
37227
+ const functionDeclarations = config.tools.map((tool) => tool.functionDeclarations);
37228
+ attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = JSON.stringify(functionDeclarations);
37229
+ }
36964
37230
  }
36965
37231
  } else {
36966
37232
  attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = extractModel({}, context);
@@ -37012,33 +37278,69 @@ function addResponseAttributes3(span, response, recordOutputs) {
37012
37278
  });
37013
37279
  }
37014
37280
  }
37281
+ if (recordOutputs && response.functionCalls) {
37282
+ const functionCalls = response.functionCalls;
37283
+ if (Array.isArray(functionCalls) && functionCalls.length > 0) {
37284
+ span.setAttributes({
37285
+ [GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: JSON.stringify(functionCalls)
37286
+ });
37287
+ }
37288
+ }
37015
37289
  }
37016
37290
  function instrumentMethod3(originalMethod, methodPath, context, options) {
37017
37291
  const isSyncCreate = methodPath === CHATS_CREATE_METHOD;
37018
- const run = (...args) => {
37019
- const requestAttributes = extractRequestAttributes3(args, methodPath, context);
37020
- const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? "unknown";
37021
- const operationName = getFinalOperationName(methodPath);
37022
- return startSpan({
37023
- name: isSyncCreate ? `${operationName} ${model} create` : `${operationName} ${model}`,
37024
- op: getSpanOperation2(methodPath),
37025
- attributes: requestAttributes
37026
- }, (span) => {
37027
- if (options.recordInputs && args[0] && typeof args[0] === "object") {
37028
- addPrivateRequestAttributes2(span, args[0]);
37029
- }
37030
- return handleCallbackErrors(() => originalMethod.apply(context, args), (error2) => {
37031
- captureException(error2, {
37032
- mechanism: { handled: false, type: "auto.ai.google_genai", data: { function: methodPath } }
37292
+ return new Proxy(originalMethod, {
37293
+ apply(target, _, args) {
37294
+ const params = args[0];
37295
+ const requestAttributes = extractRequestAttributes3(methodPath, params, context);
37296
+ const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? "unknown";
37297
+ const operationName = getFinalOperationName(methodPath);
37298
+ if (isStreamingMethod(methodPath)) {
37299
+ return startSpanManual({
37300
+ name: `${operationName} ${model} stream-response`,
37301
+ op: getSpanOperation2(methodPath),
37302
+ attributes: requestAttributes
37303
+ }, async (span) => {
37304
+ try {
37305
+ if (options.recordInputs && params) {
37306
+ addPrivateRequestAttributes2(span, params);
37307
+ }
37308
+ const stream = await target.apply(context, args);
37309
+ return instrumentStream2(stream, span, Boolean(options.recordOutputs));
37310
+ } catch (error2) {
37311
+ span.setStatus({ code: SPAN_STATUS_ERROR, message: "internal_error" });
37312
+ captureException(error2, {
37313
+ mechanism: {
37314
+ handled: false,
37315
+ type: "auto.ai.google_genai",
37316
+ data: { function: methodPath }
37317
+ }
37318
+ });
37319
+ span.end();
37320
+ throw error2;
37321
+ }
37033
37322
  });
37034
- }, () => {}, (result) => {
37035
- if (!isSyncCreate) {
37036
- addResponseAttributes3(span, result, options.recordOutputs);
37323
+ }
37324
+ return startSpan({
37325
+ name: isSyncCreate ? `${operationName} ${model} create` : `${operationName} ${model}`,
37326
+ op: getSpanOperation2(methodPath),
37327
+ attributes: requestAttributes
37328
+ }, (span) => {
37329
+ if (options.recordInputs && params) {
37330
+ addPrivateRequestAttributes2(span, params);
37037
37331
  }
37332
+ return handleCallbackErrors(() => target.apply(context, args), (error2) => {
37333
+ captureException(error2, {
37334
+ mechanism: { handled: false, type: "auto.ai.google_genai", data: { function: methodPath } }
37335
+ });
37336
+ }, () => {}, (result) => {
37337
+ if (!isSyncCreate) {
37338
+ addResponseAttributes3(span, result, options.recordOutputs);
37339
+ }
37340
+ });
37038
37341
  });
37039
- });
37040
- };
37041
- return run;
37342
+ }
37343
+ });
37042
37344
  }
37043
37345
  function createDeepProxy3(target, currentPath = "", options) {
37044
37346
  return new Proxy(target, {
@@ -37245,9 +37547,6 @@ class LRUMap {
37245
37547
  return values;
37246
37548
  }
37247
37549
  }
37248
- // ../../node_modules/@sentry/node-core/build/esm/debug-build.js
37249
- var DEBUG_BUILD2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
37250
-
37251
37550
  // ../../node_modules/@sentry/node-core/build/esm/otel/instrument.js
37252
37551
  var import_instrumentation = __toESM(require_src6(), 1);
37253
37552
  var INSTRUMENTED = {};
@@ -37317,76 +37616,85 @@ function hasWrap(instrumentation) {
37317
37616
  return typeof instrumentation["_wrap"] === "function";
37318
37617
  }
37319
37618
 
37320
- // ../../node_modules/@sentry/node-core/build/esm/integrations/http/SentryHttpInstrumentation.js
37321
- var import_api4 = __toESM(require_src(), 1);
37322
- var import_core40 = __toESM(require_src3(), 1);
37323
- var import_instrumentation2 = __toESM(require_src6(), 1);
37324
- import { subscribe, unsubscribe } from "node:diagnostics_channel";
37619
+ // ../../node_modules/@sentry/node-core/build/esm/integrations/http/httpServerIntegration.js
37620
+ var import_api2 = __toESM(require_src(), 1);
37621
+ import { subscribe } from "node:diagnostics_channel";
37325
37622
 
37326
- // ../../node_modules/@sentry/node-core/build/esm/utils/getRequestUrl.js
37327
- function getRequestUrl(requestOptions) {
37328
- const protocol = requestOptions.protocol || "";
37329
- const hostname = requestOptions.hostname || requestOptions.host || "";
37330
- const port = !requestOptions.port || requestOptions.port === 80 || requestOptions.port === 443 || /^(.*):(\d+)$/.test(hostname) ? "" : `:${requestOptions.port}`;
37331
- const path7 = requestOptions.path ? requestOptions.path : "/";
37332
- return `${protocol}//${hostname}${port}${path7}`;
37333
- }
37623
+ // ../../node_modules/@sentry/node-core/build/esm/debug-build.js
37624
+ var DEBUG_BUILD2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
37334
37625
 
37335
37626
  // ../../node_modules/@sentry/node-core/build/esm/integrations/http/constants.js
37336
37627
  var INSTRUMENTATION_NAME = "@sentry/instrumentation-http";
37337
37628
  var MAX_BODY_BYTE_LENGTH = 1024 * 1024;
37338
37629
 
37339
- // ../../node_modules/@sentry/node-core/build/esm/integrations/http/incoming-requests.js
37340
- var import_api2 = __toESM(require_src(), 1);
37341
- var import_core34 = __toESM(require_src3(), 1);
37342
- var import_semantic_conventions = __toESM(require_src2(), 1);
37343
- import { errorMonitor } from "events";
37630
+ // ../../node_modules/@sentry/node-core/build/esm/integrations/http/httpServerIntegration.js
37344
37631
  var HTTP_SERVER_INSTRUMENTED_KEY = import_api2.createContextKey("sentry_http_server_instrumented");
37632
+ var INTEGRATION_NAME6 = "Http.Server";
37345
37633
  var clientToRequestSessionAggregatesMap = new Map;
37346
37634
  var wrappedEmitFns = new WeakSet;
37635
+ function addStartSpanCallback(request, callback) {
37636
+ addNonEnumerableProperty(request, "_startSpanCallback", new WeakRef(callback));
37637
+ }
37638
+ var _httpServerIntegration = (options = {}) => {
37639
+ const _options = {
37640
+ sessions: options.sessions ?? true,
37641
+ sessionFlushingDelayMS: options.sessionFlushingDelayMS ?? 60000,
37642
+ maxRequestBodySize: options.maxRequestBodySize ?? "medium",
37643
+ ignoreRequestBody: options.ignoreRequestBody
37644
+ };
37645
+ return {
37646
+ name: INTEGRATION_NAME6,
37647
+ setupOnce() {
37648
+ const onHttpServerRequestStart = (_data) => {
37649
+ const data = _data;
37650
+ instrumentServer(data.server, _options);
37651
+ };
37652
+ subscribe("http.server.request.start", onHttpServerRequestStart);
37653
+ },
37654
+ afterAllSetup(client) {
37655
+ if (DEBUG_BUILD2 && client.getIntegrationByName("Http")) {
37656
+ debug.warn("It seems that you have manually added `httpServerIntegration` while `httpIntegration` is also present. Make sure to remove `httpServerIntegration` when adding `httpIntegration`.");
37657
+ }
37658
+ }
37659
+ };
37660
+ };
37661
+ var httpServerIntegration = _httpServerIntegration;
37347
37662
  function instrumentServer(server, {
37348
- ignoreIncomingRequestBody,
37349
- ignoreSpansForIncomingRequests,
37350
- maxIncomingRequestBodySize = "medium",
37351
- trackIncomingRequestsAsSessions = true,
37352
- spans,
37353
- ignoreStaticAssets = true,
37354
- sessionFlushingDelayMS,
37355
- instrumentation,
37356
- incomingRequestSpanHook
37663
+ ignoreRequestBody,
37664
+ maxRequestBodySize,
37665
+ sessions: sessions2,
37666
+ sessionFlushingDelayMS
37357
37667
  }) {
37358
37668
  const originalEmit = server.emit;
37359
37669
  if (wrappedEmitFns.has(originalEmit)) {
37360
- DEBUG_BUILD2 && debug.log(INSTRUMENTATION_NAME, "Incoming requests already instrumented, not instrumenting again...");
37361
37670
  return;
37362
37671
  }
37363
- const { requestHook, responseHook, applyCustomAttributesOnSpan } = instrumentation ?? {};
37364
37672
  const newEmit = new Proxy(originalEmit, {
37365
37673
  apply(target, thisArg, args) {
37366
37674
  if (args[0] !== "request") {
37367
37675
  return target.apply(thisArg, args);
37368
37676
  }
37369
- if (import_api2.context.active().getValue(HTTP_SERVER_INSTRUMENTED_KEY)) {
37677
+ const client = getClient();
37678
+ if (import_api2.context.active().getValue(HTTP_SERVER_INSTRUMENTED_KEY) || !client) {
37370
37679
  return target.apply(thisArg, args);
37371
37680
  }
37372
- DEBUG_BUILD2 && debug.log(INSTRUMENTATION_NAME, "Handling incoming request");
37373
- const client = getClient();
37681
+ DEBUG_BUILD2 && debug.log(INTEGRATION_NAME6, "Handling incoming request");
37374
37682
  const isolationScope = getIsolationScope().clone();
37375
37683
  const request = args[1];
37376
37684
  const response = args[2];
37377
37685
  const normalizedRequest = httpRequestToRequestData(request);
37378
37686
  const ipAddress = request.ip || request.socket?.remoteAddress;
37379
37687
  const url = request.url || "/";
37380
- if (maxIncomingRequestBodySize !== "none" && !ignoreIncomingRequestBody?.(url, request)) {
37381
- patchRequestToCaptureBody(request, isolationScope, maxIncomingRequestBodySize);
37688
+ if (maxRequestBodySize !== "none" && !ignoreRequestBody?.(url, request)) {
37689
+ patchRequestToCaptureBody(request, isolationScope, maxRequestBodySize);
37382
37690
  }
37383
37691
  isolationScope.setSDKProcessingMetadata({ normalizedRequest, ipAddress });
37384
37692
  const httpMethod = (request.method || "GET").toUpperCase();
37385
37693
  const httpTargetWithoutQueryFragment = stripUrlQueryAndFragment(url);
37386
37694
  const bestEffortTransactionName = `${httpMethod} ${httpTargetWithoutQueryFragment}`;
37387
37695
  isolationScope.setTransactionName(bestEffortTransactionName);
37388
- if (trackIncomingRequestsAsSessions !== false) {
37389
- recordRequestSession({
37696
+ if (sessions2 && client) {
37697
+ recordRequestSession(client, {
37390
37698
  requestIsolationScope: isolationScope,
37391
37699
  response,
37392
37700
  sessionFlushingDelayMS: sessionFlushingDelayMS ?? 60000
@@ -37396,79 +37704,12 @@ function instrumentServer(server, {
37396
37704
  getCurrentScope().getPropagationContext().propagationSpanId = generateSpanId();
37397
37705
  const ctx = import_api2.propagation.extract(import_api2.context.active(), normalizedRequest.headers).setValue(HTTP_SERVER_INSTRUMENTED_KEY, true);
37398
37706
  return import_api2.context.with(ctx, () => {
37399
- if (typeof __SENTRY_TRACING__ !== "undefined" && !__SENTRY_TRACING__ || !spans || !client || shouldIgnoreSpansForIncomingRequest(request, {
37400
- ignoreStaticAssets,
37401
- ignoreSpansForIncomingRequests
37402
- })) {
37403
- DEBUG_BUILD2 && debug.log(INSTRUMENTATION_NAME, "Skipping span creation for incoming request");
37404
- return target.apply(thisArg, args);
37707
+ client.emit("httpServerRequest", request, response, normalizedRequest);
37708
+ const callback = request._startSpanCallback?.deref();
37709
+ if (callback) {
37710
+ return callback(() => target.apply(thisArg, args));
37405
37711
  }
37406
- const fullUrl = normalizedRequest.url || url;
37407
- const urlObj = parseStringToURLObject(fullUrl);
37408
- const headers = request.headers;
37409
- const userAgent = headers["user-agent"];
37410
- const ips = headers["x-forwarded-for"];
37411
- const httpVersion = request.httpVersion;
37412
- const host = headers.host;
37413
- const hostname = host?.replace(/^(.*)(:[0-9]{1,5})/, "$1") || "localhost";
37414
- const tracer = client.tracer;
37415
- const scheme = fullUrl.startsWith("https") ? "https" : "http";
37416
- const shouldSendDefaultPii = client?.getOptions().sendDefaultPii ?? false;
37417
- const span = tracer.startSpan(bestEffortTransactionName, {
37418
- kind: import_api2.SpanKind.SERVER,
37419
- attributes: {
37420
- [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "http.server",
37421
- [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.http.otel.http",
37422
- "sentry.http.prefetch": isKnownPrefetchRequest(request) || undefined,
37423
- "http.url": fullUrl,
37424
- "http.method": httpMethod,
37425
- "http.target": urlObj ? `${urlObj.pathname}${urlObj.search}` : httpTargetWithoutQueryFragment,
37426
- "http.host": host,
37427
- "net.host.name": hostname,
37428
- "http.client_ip": typeof ips === "string" ? ips.split(",")[0] : undefined,
37429
- "http.user_agent": userAgent,
37430
- "http.scheme": scheme,
37431
- "http.flavor": httpVersion,
37432
- "net.transport": httpVersion?.toUpperCase() === "QUIC" ? "ip_udp" : "ip_tcp",
37433
- ...getRequestContentLengthAttribute(request),
37434
- ...httpHeadersToSpanAttributes(normalizedRequest.headers || {}, shouldSendDefaultPii)
37435
- }
37436
- });
37437
- requestHook?.(span, request);
37438
- responseHook?.(span, response);
37439
- applyCustomAttributesOnSpan?.(span, request, response);
37440
- incomingRequestSpanHook?.(span, request, response);
37441
- const rpcMetadata = {
37442
- type: import_core34.RPCType.HTTP,
37443
- span
37444
- };
37445
- import_api2.context.with(import_core34.setRPCMetadata(import_api2.trace.setSpan(import_api2.context.active(), span), rpcMetadata), () => {
37446
- import_api2.context.bind(import_api2.context.active(), request);
37447
- import_api2.context.bind(import_api2.context.active(), response);
37448
- let isEnded = false;
37449
- function endSpan(status) {
37450
- if (isEnded) {
37451
- return;
37452
- }
37453
- isEnded = true;
37454
- const newAttributes = getIncomingRequestAttributesOnResponse(request, response);
37455
- span.setAttributes(newAttributes);
37456
- span.setStatus(status);
37457
- span.end();
37458
- const route = newAttributes["http.route"];
37459
- if (route) {
37460
- getIsolationScope().setTransactionName(`${request.method?.toUpperCase() || "GET"} ${route}`);
37461
- }
37462
- }
37463
- response.on("close", () => {
37464
- endSpan(getSpanStatusFromHttpCode(response.statusCode));
37465
- });
37466
- response.on(errorMonitor, () => {
37467
- const httpStatus = getSpanStatusFromHttpCode(response.statusCode);
37468
- endSpan(httpStatus.code === SPAN_STATUS_ERROR ? httpStatus : { code: SPAN_STATUS_ERROR });
37469
- });
37470
- return target.apply(thisArg, args);
37471
- });
37712
+ return target.apply(thisArg, args);
37472
37713
  });
37473
37714
  });
37474
37715
  }
@@ -37476,7 +37717,7 @@ function instrumentServer(server, {
37476
37717
  wrappedEmitFns.add(newEmit);
37477
37718
  server.emit = newEmit;
37478
37719
  }
37479
- function recordRequestSession({
37720
+ function recordRequestSession(client, {
37480
37721
  requestIsolationScope,
37481
37722
  response,
37482
37723
  sessionFlushingDelayMS
@@ -37485,7 +37726,6 @@ function recordRequestSession({
37485
37726
  requestSession: { status: "ok" }
37486
37727
  });
37487
37728
  response.once("close", () => {
37488
- const client = getClient();
37489
37729
  const requestSession = requestIsolationScope.getScopeData().sdkProcessingMetadata.requestSession;
37490
37730
  if (client && requestSession) {
37491
37731
  DEBUG_BUILD2 && debug.log(`Recorded request session with status: ${requestSession.status}`);
@@ -37528,7 +37768,7 @@ function recordRequestSession({
37528
37768
  function patchRequestToCaptureBody(req, isolationScope, maxIncomingRequestBodySize) {
37529
37769
  let bodyByteLength = 0;
37530
37770
  const chunks = [];
37531
- DEBUG_BUILD2 && debug.log(INSTRUMENTATION_NAME, "Patching request.on");
37771
+ DEBUG_BUILD2 && debug.log(INTEGRATION_NAME6, "Patching request.on");
37532
37772
  const callbackMap = new WeakMap;
37533
37773
  const maxBodySize = maxIncomingRequestBodySize === "small" ? 1000 : maxIncomingRequestBodySize === "medium" ? 1e4 : MAX_BODY_BYTE_LENGTH;
37534
37774
  try {
@@ -37536,7 +37776,7 @@ function patchRequestToCaptureBody(req, isolationScope, maxIncomingRequestBodySi
37536
37776
  apply: (target, thisArg, args) => {
37537
37777
  const [event, listener, ...restArgs] = args;
37538
37778
  if (event === "data") {
37539
- DEBUG_BUILD2 && debug.log(INSTRUMENTATION_NAME, `Handling request.on("data") with maximum body size of ${maxBodySize}b`);
37779
+ DEBUG_BUILD2 && debug.log(INTEGRATION_NAME6, `Handling request.on("data") with maximum body size of ${maxBodySize}b`);
37540
37780
  const callback = new Proxy(listener, {
37541
37781
  apply: (target2, thisArg2, args2) => {
37542
37782
  try {
@@ -37546,10 +37786,10 @@ function patchRequestToCaptureBody(req, isolationScope, maxIncomingRequestBodySi
37546
37786
  chunks.push(bufferifiedChunk);
37547
37787
  bodyByteLength += bufferifiedChunk.byteLength;
37548
37788
  } else if (DEBUG_BUILD2) {
37549
- debug.log(INSTRUMENTATION_NAME, `Dropping request body chunk because maximum body length of ${maxBodySize}b is exceeded.`);
37789
+ debug.log(INTEGRATION_NAME6, `Dropping request body chunk because maximum body length of ${maxBodySize}b is exceeded.`);
37550
37790
  }
37551
37791
  } catch (err) {
37552
- DEBUG_BUILD2 && debug.error(INSTRUMENTATION_NAME, "Encountered error while storing body chunk.");
37792
+ DEBUG_BUILD2 && debug.error(INTEGRATION_NAME6, "Encountered error while storing body chunk.");
37553
37793
  }
37554
37794
  return Reflect.apply(target2, thisArg2, args2);
37555
37795
  }
@@ -37583,16 +37823,183 @@ function patchRequestToCaptureBody(req, isolationScope, maxIncomingRequestBodySi
37583
37823
  }
37584
37824
  } catch (error2) {
37585
37825
  if (DEBUG_BUILD2) {
37586
- debug.error(INSTRUMENTATION_NAME, "Error building captured request body", error2);
37826
+ debug.error(INTEGRATION_NAME6, "Error building captured request body", error2);
37587
37827
  }
37588
37828
  }
37589
37829
  });
37590
37830
  } catch (error2) {
37591
37831
  if (DEBUG_BUILD2) {
37592
- debug.error(INSTRUMENTATION_NAME, "Error patching request to capture body", error2);
37832
+ debug.error(INTEGRATION_NAME6, "Error patching request to capture body", error2);
37593
37833
  }
37594
37834
  }
37595
37835
  }
37836
+
37837
+ // ../../node_modules/@sentry/node-core/build/esm/integrations/http/httpServerSpansIntegration.js
37838
+ var import_api3 = __toESM(require_src(), 1);
37839
+ var import_core35 = __toESM(require_src3(), 1);
37840
+ var import_semantic_conventions = __toESM(require_src2(), 1);
37841
+ import { errorMonitor } from "node:events";
37842
+ var INTEGRATION_NAME7 = "Http.ServerSpans";
37843
+ var _httpServerSpansIntegration = (options = {}) => {
37844
+ const ignoreStaticAssets = options.ignoreStaticAssets ?? true;
37845
+ const ignoreIncomingRequests = options.ignoreIncomingRequests;
37846
+ const ignoreStatusCodes = options.ignoreStatusCodes ?? [
37847
+ [401, 404],
37848
+ [301, 303],
37849
+ [305, 399]
37850
+ ];
37851
+ const { onSpanCreated } = options;
37852
+ const { requestHook, responseHook, applyCustomAttributesOnSpan } = options.instrumentation ?? {};
37853
+ return {
37854
+ name: INTEGRATION_NAME7,
37855
+ setup(client) {
37856
+ if (typeof __SENTRY_TRACING__ !== "undefined" && !__SENTRY_TRACING__) {
37857
+ return;
37858
+ }
37859
+ client.on("httpServerRequest", (_request, _response, normalizedRequest) => {
37860
+ const request = _request;
37861
+ const response = _response;
37862
+ const startSpan2 = (next) => {
37863
+ if (shouldIgnoreSpansForIncomingRequest(request, {
37864
+ ignoreStaticAssets,
37865
+ ignoreIncomingRequests
37866
+ })) {
37867
+ DEBUG_BUILD2 && debug.log(INTEGRATION_NAME7, "Skipping span creation for incoming request", request.url);
37868
+ return next();
37869
+ }
37870
+ const fullUrl = normalizedRequest.url || request.url || "/";
37871
+ const urlObj = parseStringToURLObject(fullUrl);
37872
+ const headers = request.headers;
37873
+ const userAgent = headers["user-agent"];
37874
+ const ips = headers["x-forwarded-for"];
37875
+ const httpVersion = request.httpVersion;
37876
+ const host = headers.host;
37877
+ const hostname = host?.replace(/^(.*)(:[0-9]{1,5})/, "$1") || "localhost";
37878
+ const tracer = client.tracer;
37879
+ const scheme = fullUrl.startsWith("https") ? "https" : "http";
37880
+ const method = normalizedRequest.method || request.method?.toUpperCase() || "GET";
37881
+ const httpTargetWithoutQueryFragment = urlObj ? urlObj.pathname : stripUrlQueryAndFragment(fullUrl);
37882
+ const bestEffortTransactionName = `${method} ${httpTargetWithoutQueryFragment}`;
37883
+ const shouldSendDefaultPii = client.getOptions().sendDefaultPii ?? false;
37884
+ const span = tracer.startSpan(bestEffortTransactionName, {
37885
+ kind: import_api3.SpanKind.SERVER,
37886
+ attributes: {
37887
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "http.server",
37888
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.http.otel.http",
37889
+ "sentry.http.prefetch": isKnownPrefetchRequest(request) || undefined,
37890
+ "http.url": fullUrl,
37891
+ "http.method": normalizedRequest.method,
37892
+ "http.target": urlObj ? `${urlObj.pathname}${urlObj.search}` : httpTargetWithoutQueryFragment,
37893
+ "http.host": host,
37894
+ "net.host.name": hostname,
37895
+ "http.client_ip": typeof ips === "string" ? ips.split(",")[0] : undefined,
37896
+ "http.user_agent": userAgent,
37897
+ "http.scheme": scheme,
37898
+ "http.flavor": httpVersion,
37899
+ "net.transport": httpVersion?.toUpperCase() === "QUIC" ? "ip_udp" : "ip_tcp",
37900
+ ...getRequestContentLengthAttribute(request),
37901
+ ...httpHeadersToSpanAttributes(normalizedRequest.headers || {}, shouldSendDefaultPii)
37902
+ }
37903
+ });
37904
+ requestHook?.(span, request);
37905
+ responseHook?.(span, response);
37906
+ applyCustomAttributesOnSpan?.(span, request, response);
37907
+ onSpanCreated?.(span, request, response);
37908
+ const rpcMetadata = {
37909
+ type: import_core35.RPCType.HTTP,
37910
+ span
37911
+ };
37912
+ return import_api3.context.with(import_core35.setRPCMetadata(import_api3.trace.setSpan(import_api3.context.active(), span), rpcMetadata), () => {
37913
+ import_api3.context.bind(import_api3.context.active(), request);
37914
+ import_api3.context.bind(import_api3.context.active(), response);
37915
+ let isEnded = false;
37916
+ function endSpan(status) {
37917
+ if (isEnded) {
37918
+ return;
37919
+ }
37920
+ isEnded = true;
37921
+ const newAttributes = getIncomingRequestAttributesOnResponse(request, response);
37922
+ span.setAttributes(newAttributes);
37923
+ span.setStatus(status);
37924
+ span.end();
37925
+ const route = newAttributes["http.route"];
37926
+ if (route) {
37927
+ getIsolationScope().setTransactionName(`${request.method?.toUpperCase() || "GET"} ${route}`);
37928
+ }
37929
+ }
37930
+ response.on("close", () => {
37931
+ endSpan(getSpanStatusFromHttpCode(response.statusCode));
37932
+ });
37933
+ response.on(errorMonitor, () => {
37934
+ const httpStatus = getSpanStatusFromHttpCode(response.statusCode);
37935
+ endSpan(httpStatus.code === SPAN_STATUS_ERROR ? httpStatus : { code: SPAN_STATUS_ERROR });
37936
+ });
37937
+ return next();
37938
+ });
37939
+ };
37940
+ addStartSpanCallback(request, startSpan2);
37941
+ });
37942
+ },
37943
+ processEvent(event) {
37944
+ if (event.type === "transaction") {
37945
+ const statusCode = event.contexts?.trace?.data?.["http.response.status_code"];
37946
+ if (typeof statusCode === "number") {
37947
+ const shouldDrop = shouldFilterStatusCode(statusCode, ignoreStatusCodes);
37948
+ if (shouldDrop) {
37949
+ DEBUG_BUILD2 && debug.log("Dropping transaction due to status code", statusCode);
37950
+ return null;
37951
+ }
37952
+ }
37953
+ }
37954
+ return event;
37955
+ },
37956
+ afterAllSetup(client) {
37957
+ if (!DEBUG_BUILD2) {
37958
+ return;
37959
+ }
37960
+ if (client.getIntegrationByName("Http")) {
37961
+ debug.warn("It seems that you have manually added `httpServerSpansIntergation` while `httpIntegration` is also present. Make sure to remove `httpIntegration` when adding `httpServerSpansIntegration`.");
37962
+ }
37963
+ if (!client.getIntegrationByName("Http.Server")) {
37964
+ debug.error("It seems that you have manually added `httpServerSpansIntergation` without adding `httpServerIntegration`. This is a requiement for spans to be created - please add the `httpServerIntegration` integration.");
37965
+ }
37966
+ }
37967
+ };
37968
+ };
37969
+ var httpServerSpansIntegration = _httpServerSpansIntegration;
37970
+ function isKnownPrefetchRequest(req) {
37971
+ return req.headers["next-router-prefetch"] === "1";
37972
+ }
37973
+ function isStaticAssetRequest(urlPath) {
37974
+ const path7 = stripUrlQueryAndFragment(urlPath);
37975
+ if (path7.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
37976
+ return true;
37977
+ }
37978
+ if (path7.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
37979
+ return true;
37980
+ }
37981
+ return false;
37982
+ }
37983
+ function shouldIgnoreSpansForIncomingRequest(request, {
37984
+ ignoreStaticAssets,
37985
+ ignoreIncomingRequests
37986
+ }) {
37987
+ if (import_core35.isTracingSuppressed(import_api3.context.active())) {
37988
+ return true;
37989
+ }
37990
+ const urlPath = request.url;
37991
+ const method = request.method?.toUpperCase();
37992
+ if (method === "OPTIONS" || method === "HEAD" || !urlPath) {
37993
+ return true;
37994
+ }
37995
+ if (ignoreStaticAssets && method === "GET" && isStaticAssetRequest(urlPath)) {
37996
+ return true;
37997
+ }
37998
+ if (ignoreIncomingRequests?.(urlPath, request)) {
37999
+ return true;
38000
+ }
38001
+ return false;
38002
+ }
37596
38003
  function getRequestContentLengthAttribute(request) {
37597
38004
  const length = getContentLength(request.headers);
37598
38005
  if (length == null) {
@@ -37629,7 +38036,7 @@ function getIncomingRequestAttributesOnResponse(request, response) {
37629
38036
  [import_semantic_conventions.SEMATTRS_HTTP_STATUS_CODE]: statusCode,
37630
38037
  "http.status_text": statusMessage?.toUpperCase()
37631
38038
  };
37632
- const rpcMetadata = import_core34.getRPCMetadata(import_api2.context.active());
38039
+ const rpcMetadata = import_core35.getRPCMetadata(import_api3.context.active());
37633
38040
  if (socket) {
37634
38041
  const { localAddress, localPort, remoteAddress, remotePort } = socket;
37635
38042
  newAttributes[import_semantic_conventions.SEMATTRS_NET_HOST_IP] = localAddress;
@@ -37639,51 +38046,42 @@ function getIncomingRequestAttributesOnResponse(request, response) {
37639
38046
  }
37640
38047
  newAttributes[import_semantic_conventions.SEMATTRS_HTTP_STATUS_CODE] = statusCode;
37641
38048
  newAttributes["http.status_text"] = (statusMessage || "").toUpperCase();
37642
- if (rpcMetadata?.type === import_core34.RPCType.HTTP && rpcMetadata.route !== undefined) {
38049
+ if (rpcMetadata?.type === import_core35.RPCType.HTTP && rpcMetadata.route !== undefined) {
37643
38050
  const routeName = rpcMetadata.route;
37644
38051
  newAttributes[import_semantic_conventions.ATTR_HTTP_ROUTE] = routeName;
37645
38052
  }
37646
38053
  return newAttributes;
37647
38054
  }
37648
- function isKnownPrefetchRequest(req) {
37649
- return req.headers["next-router-prefetch"] === "1";
37650
- }
37651
- function isStaticAssetRequest(urlPath) {
37652
- const path7 = stripUrlQueryAndFragment(urlPath);
37653
- if (path7.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
37654
- return true;
37655
- }
37656
- if (path7.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
37657
- return true;
37658
- }
37659
- return false;
38055
+ function shouldFilterStatusCode(statusCode, dropForStatusCodes) {
38056
+ return dropForStatusCodes.some((code) => {
38057
+ if (typeof code === "number") {
38058
+ return code === statusCode;
38059
+ }
38060
+ const [min, max] = code;
38061
+ return statusCode >= min && statusCode <= max;
38062
+ });
37660
38063
  }
37661
- function shouldIgnoreSpansForIncomingRequest(request, {
37662
- ignoreStaticAssets,
37663
- ignoreSpansForIncomingRequests
37664
- }) {
37665
- if (import_core34.isTracingSuppressed(import_api2.context.active())) {
37666
- return true;
37667
- }
37668
- const urlPath = request.url;
37669
- const method = request.method?.toUpperCase();
37670
- if (method === "OPTIONS" || method === "HEAD" || !urlPath) {
37671
- return true;
37672
- }
37673
- if (ignoreStaticAssets && method === "GET" && isStaticAssetRequest(urlPath)) {
37674
- return true;
37675
- }
37676
- if (ignoreSpansForIncomingRequests?.(urlPath, request)) {
37677
- return true;
37678
- }
37679
- return false;
38064
+
38065
+ // ../../node_modules/@sentry/node-core/build/esm/integrations/http/SentryHttpInstrumentation.js
38066
+ var import_api5 = __toESM(require_src(), 1);
38067
+ var import_core41 = __toESM(require_src3(), 1);
38068
+ var import_instrumentation2 = __toESM(require_src6(), 1);
38069
+ import { subscribe as subscribe2, unsubscribe } from "node:diagnostics_channel";
38070
+
38071
+ // ../../node_modules/@sentry/node-core/build/esm/utils/getRequestUrl.js
38072
+ function getRequestUrl(requestOptions) {
38073
+ const protocol = requestOptions.protocol || "";
38074
+ const hostname = requestOptions.hostname || requestOptions.host || "";
38075
+ const port = !requestOptions.port || requestOptions.port === 80 || requestOptions.port === 443 || /^(.*):(\d+)$/.test(hostname) ? "" : `:${requestOptions.port}`;
38076
+ const path7 = requestOptions.path ? requestOptions.path : "/";
38077
+ return `${protocol}//${hostname}${port}${path7}`;
37680
38078
  }
37681
38079
 
37682
38080
  // ../../node_modules/@sentry/opentelemetry/build/esm/index.js
37683
38081
  var import_semantic_conventions2 = __toESM(require_src2(), 1);
37684
38082
  var api = __toESM(require_src(), 1);
37685
- var import_api3 = __toESM(require_src(), 1);
37686
- var import_core37 = __toESM(require_src3(), 1);
38083
+ var import_api4 = __toESM(require_src(), 1);
38084
+ var import_core38 = __toESM(require_src3(), 1);
37687
38085
  var import_sdk_trace_base = __toESM(require_src9(), 1);
37688
38086
  var SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE = "sentry.parentIsRemote";
37689
38087
  var SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION = "sentry.graphql.operation";
@@ -37741,7 +38139,7 @@ function getSpanKind(span) {
37741
38139
  if (spanHasKind(span)) {
37742
38140
  return span.kind;
37743
38141
  }
37744
- return import_api3.SpanKind.INTERNAL;
38142
+ return import_api4.SpanKind.INTERNAL;
37745
38143
  }
37746
38144
  var SENTRY_TRACE_HEADER = "sentry-trace";
37747
38145
  var SENTRY_BAGGAGE_HEADER = "baggage";
@@ -37750,19 +38148,19 @@ var SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING = "sentry.sampled_not_recording";
37750
38148
  var SENTRY_TRACE_STATE_URL = "sentry.url";
37751
38149
  var SENTRY_TRACE_STATE_SAMPLE_RAND = "sentry.sample_rand";
37752
38150
  var SENTRY_TRACE_STATE_SAMPLE_RATE = "sentry.sample_rate";
37753
- var SENTRY_SCOPES_CONTEXT_KEY = import_api3.createContextKey("sentry_scopes");
37754
- var SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY = import_api3.createContextKey("sentry_fork_isolation_scope");
37755
- var SENTRY_FORK_SET_SCOPE_CONTEXT_KEY = import_api3.createContextKey("sentry_fork_set_scope");
37756
- var SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY = import_api3.createContextKey("sentry_fork_set_isolation_scope");
38151
+ var SENTRY_SCOPES_CONTEXT_KEY = import_api4.createContextKey("sentry_scopes");
38152
+ var SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY = import_api4.createContextKey("sentry_fork_isolation_scope");
38153
+ var SENTRY_FORK_SET_SCOPE_CONTEXT_KEY = import_api4.createContextKey("sentry_fork_set_scope");
38154
+ var SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY = import_api4.createContextKey("sentry_fork_set_isolation_scope");
37757
38155
  var SCOPE_CONTEXT_FIELD = "_scopeContext";
37758
- function getScopesFromContext(context4) {
37759
- return context4.getValue(SENTRY_SCOPES_CONTEXT_KEY);
38156
+ function getScopesFromContext(context5) {
38157
+ return context5.getValue(SENTRY_SCOPES_CONTEXT_KEY);
37760
38158
  }
37761
- function setScopesOnContext(context4, scopes) {
37762
- return context4.setValue(SENTRY_SCOPES_CONTEXT_KEY, scopes);
38159
+ function setScopesOnContext(context5, scopes) {
38160
+ return context5.setValue(SENTRY_SCOPES_CONTEXT_KEY, scopes);
37763
38161
  }
37764
- function setContextOnScope(scope, context4) {
37765
- addNonEnumerableProperty(scope, SCOPE_CONTEXT_FIELD, context4);
38162
+ function setContextOnScope(scope, context5) {
38163
+ addNonEnumerableProperty(scope, SCOPE_CONTEXT_FIELD, context5);
37766
38164
  }
37767
38165
  function getContextFromScope(scope) {
37768
38166
  return scope[SCOPE_CONTEXT_FIELD];
@@ -37770,7 +38168,7 @@ function getContextFromScope(scope) {
37770
38168
  function getSamplingDecision(spanContext) {
37771
38169
  const { traceFlags, traceState } = spanContext;
37772
38170
  const sampledNotRecording = traceState ? traceState.get(SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING) === "1" : false;
37773
- if (traceFlags === import_api3.TraceFlags.SAMPLED) {
38171
+ if (traceFlags === import_api4.TraceFlags.SAMPLED) {
37774
38172
  return true;
37775
38173
  }
37776
38174
  if (sampledNotRecording) {
@@ -37845,10 +38243,10 @@ function descriptionForDbSystem({ attributes, name }) {
37845
38243
  function descriptionForHttpMethod({ name, kind, attributes }, httpMethod) {
37846
38244
  const opParts = ["http"];
37847
38245
  switch (kind) {
37848
- case import_api3.SpanKind.CLIENT:
38246
+ case import_api4.SpanKind.CLIENT:
37849
38247
  opParts.push("client");
37850
38248
  break;
37851
- case import_api3.SpanKind.SERVER:
38249
+ case import_api4.SpanKind.SERVER:
37852
38250
  opParts.push("server");
37853
38251
  break;
37854
38252
  }
@@ -37873,7 +38271,7 @@ function descriptionForHttpMethod({ name, kind, attributes }, httpMethod) {
37873
38271
  if (fragment) {
37874
38272
  data["http.fragment"] = fragment;
37875
38273
  }
37876
- const isClientOrServerKind = kind === import_api3.SpanKind.CLIENT || kind === import_api3.SpanKind.SERVER;
38274
+ const isClientOrServerKind = kind === import_api4.SpanKind.CLIENT || kind === import_api4.SpanKind.SERVER;
37877
38275
  const origin = attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] || "manual";
37878
38276
  const isManualSpan = !`${origin}`.startsWith("auto");
37879
38277
  const alreadyHasCustomSource = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] === "custom";
@@ -37909,7 +38307,7 @@ function getSanitizedUrl(attributes, kind) {
37909
38307
  if (typeof httpRoute === "string") {
37910
38308
  return { urlPath: httpRoute, url, query, fragment, hasRoute: true };
37911
38309
  }
37912
- if (kind === import_api3.SpanKind.SERVER && typeof httpTarget === "string") {
38310
+ if (kind === import_api4.SpanKind.SERVER && typeof httpTarget === "string") {
37913
38311
  return { urlPath: stripUrlQueryAndFragment(httpTarget), url, query, fragment, hasRoute: false };
37914
38312
  }
37915
38313
  if (parsedUrl) {
@@ -37950,7 +38348,7 @@ function enhanceDscWithOpenTelemetryRootSpanName(client) {
37950
38348
  });
37951
38349
  }
37952
38350
  function getActiveSpan2() {
37953
- return import_api3.trace.getActiveSpan();
38351
+ return import_api4.trace.getActiveSpan();
37954
38352
  }
37955
38353
  var DEBUG_BUILD3 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
37956
38354
  function makeTraceState({
@@ -37958,7 +38356,7 @@ function makeTraceState({
37958
38356
  sampled
37959
38357
  }) {
37960
38358
  const dscString = dsc ? dynamicSamplingContextToSentryBaggageHeader(dsc) : undefined;
37961
- const traceStateBase = new import_core37.TraceState;
38359
+ const traceStateBase = new import_core38.TraceState;
37962
38360
  const traceStateWithDsc = dscString ? traceStateBase.set(SENTRY_TRACE_STATE_DSC, dscString) : traceStateBase;
37963
38361
  return sampled === false ? traceStateWithDsc.set(SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING, "1") : traceStateWithDsc;
37964
38362
  }
@@ -37970,18 +38368,18 @@ function setIsSetup(element) {
37970
38368
  setupElements.add(element);
37971
38369
  }
37972
38370
 
37973
- class SentryPropagator extends import_core37.W3CBaggagePropagator {
38371
+ class SentryPropagator extends import_core38.W3CBaggagePropagator {
37974
38372
  constructor() {
37975
38373
  super();
37976
38374
  setIsSetup("SentryPropagator");
37977
38375
  this._urlMatchesTargetsMap = new LRUMap(100);
37978
38376
  }
37979
- inject(context4, carrier, setter) {
37980
- if (import_core37.isTracingSuppressed(context4)) {
38377
+ inject(context5, carrier, setter) {
38378
+ if (import_core38.isTracingSuppressed(context5)) {
37981
38379
  DEBUG_BUILD3 && debug.log("[Tracing] Not injecting trace data for url because tracing is suppressed.");
37982
38380
  return;
37983
38381
  }
37984
- const activeSpan = import_api3.trace.getSpan(context4);
38382
+ const activeSpan = import_api4.trace.getSpan(context5);
37985
38383
  const url = activeSpan && getCurrentURL(activeSpan);
37986
38384
  const tracePropagationTargets = getClient()?.getOptions()?.tracePropagationTargets;
37987
38385
  if (!shouldPropagateTraceForUrl(url, tracePropagationTargets, this._urlMatchesTargetsMap)) {
@@ -37989,8 +38387,8 @@ class SentryPropagator extends import_core37.W3CBaggagePropagator {
37989
38387
  return;
37990
38388
  }
37991
38389
  const existingBaggageHeader = getExistingBaggage(carrier);
37992
- let baggage = import_api3.propagation.getBaggage(context4) || import_api3.propagation.createBaggage({});
37993
- const { dynamicSamplingContext, traceId, spanId, sampled } = getInjectionData(context4);
38390
+ let baggage = import_api4.propagation.getBaggage(context5) || import_api4.propagation.createBaggage({});
38391
+ const { dynamicSamplingContext, traceId, spanId, sampled } = getInjectionData(context5);
37994
38392
  if (existingBaggageHeader) {
37995
38393
  const baggageEntries = parseBaggageHeader(existingBaggageHeader);
37996
38394
  if (baggageEntries) {
@@ -38007,16 +38405,16 @@ class SentryPropagator extends import_core37.W3CBaggagePropagator {
38007
38405
  return b;
38008
38406
  }, baggage);
38009
38407
  }
38010
- if (traceId && traceId !== import_api3.INVALID_TRACEID) {
38408
+ if (traceId && traceId !== import_api4.INVALID_TRACEID) {
38011
38409
  setter.set(carrier, SENTRY_TRACE_HEADER, generateSentryTraceHeader(traceId, spanId, sampled));
38012
38410
  }
38013
- super.inject(import_api3.propagation.setBaggage(context4, baggage), carrier, setter);
38411
+ super.inject(import_api4.propagation.setBaggage(context5, baggage), carrier, setter);
38014
38412
  }
38015
- extract(context4, carrier, getter) {
38413
+ extract(context5, carrier, getter) {
38016
38414
  const maybeSentryTraceHeader = getter.get(carrier, SENTRY_TRACE_HEADER);
38017
38415
  const baggage = getter.get(carrier, SENTRY_BAGGAGE_HEADER);
38018
38416
  const sentryTrace = maybeSentryTraceHeader ? Array.isArray(maybeSentryTraceHeader) ? maybeSentryTraceHeader[0] : maybeSentryTraceHeader : undefined;
38019
- return ensureScopesOnContext(getContextWithRemoteActiveSpan(context4, { sentryTrace, baggage }));
38417
+ return ensureScopesOnContext(getContextWithRemoteActiveSpan(context5, { sentryTrace, baggage }));
38020
38418
  }
38021
38419
  fields() {
38022
38420
  return [SENTRY_TRACE_HEADER, SENTRY_BAGGAGE_HEADER];
@@ -38037,8 +38435,8 @@ function shouldPropagateTraceForUrl(url, tracePropagationTargets, decisionMap) {
38037
38435
  DEBUG_BUILD3 && !decision && debug.log(NOT_PROPAGATED_MESSAGE, url);
38038
38436
  return decision;
38039
38437
  }
38040
- function getInjectionData(context4, options = {}) {
38041
- const span = import_api3.trace.getSpan(context4);
38438
+ function getInjectionData(context5, options = {}) {
38439
+ const span = import_api4.trace.getSpan(context5);
38042
38440
  if (span?.spanContext().isRemote) {
38043
38441
  const spanContext = span.spanContext();
38044
38442
  const dynamicSamplingContext2 = getDynamicSamplingContextFromSpan(span);
@@ -38059,7 +38457,7 @@ function getInjectionData(context4, options = {}) {
38059
38457
  sampled: getSamplingDecision(spanContext)
38060
38458
  };
38061
38459
  }
38062
- const scope = options.scope || getScopesFromContext(context4)?.scope || getCurrentScope();
38460
+ const scope = options.scope || getScopesFromContext(context5)?.scope || getCurrentScope();
38063
38461
  const client = options.client || getClient();
38064
38462
  const propagationContext = scope.getPropagationContext();
38065
38463
  const dynamicSamplingContext = client ? getDynamicSamplingContextFromScope(client, scope) : undefined;
@@ -38084,11 +38482,11 @@ function getContextWithRemoteActiveSpan(ctx, { sentryTrace, baggage }) {
38084
38482
  sampled,
38085
38483
  dsc
38086
38484
  });
38087
- return import_api3.trace.setSpanContext(ctx, spanContext);
38485
+ return import_api4.trace.setSpanContext(ctx, spanContext);
38088
38486
  }
38089
38487
  function continueTraceAsRemoteSpan(ctx, options, callback) {
38090
38488
  const ctxWithSpanContext = ensureScopesOnContext(getContextWithRemoteActiveSpan(ctx, options));
38091
- return import_api3.context.with(ctxWithSpanContext, callback);
38489
+ return import_api4.context.with(ctxWithSpanContext, callback);
38092
38490
  }
38093
38491
  function ensureScopesOnContext(ctx) {
38094
38492
  const scopes = getScopesFromContext(ctx);
@@ -38132,7 +38530,7 @@ function generateRemoteSpanContext({
38132
38530
  traceId,
38133
38531
  spanId,
38134
38532
  isRemote: true,
38135
- traceFlags: sampled ? import_api3.TraceFlags.SAMPLED : import_api3.TraceFlags.NONE,
38533
+ traceFlags: sampled ? import_api4.TraceFlags.SAMPLED : import_api4.TraceFlags.NONE,
38136
38534
  traceState
38137
38535
  };
38138
38536
  return spanContext;
@@ -38143,13 +38541,13 @@ function startSpan2(options, callback) {
38143
38541
  const wrapper = getActiveSpanWrapper2(customParentSpan);
38144
38542
  return wrapper(() => {
38145
38543
  const activeCtx = getContext(options.scope, options.forceTransaction);
38146
- const shouldSkipSpan = options.onlyIfParent && !import_api3.trace.getSpan(activeCtx);
38147
- const ctx = shouldSkipSpan ? import_core37.suppressTracing(activeCtx) : activeCtx;
38544
+ const shouldSkipSpan = options.onlyIfParent && !import_api4.trace.getSpan(activeCtx);
38545
+ const ctx = shouldSkipSpan ? import_core38.suppressTracing(activeCtx) : activeCtx;
38148
38546
  const spanOptions = getSpanOptions(options);
38149
38547
  return tracer.startActiveSpan(name, spanOptions, ctx, (span) => {
38150
38548
  return handleCallbackErrors(() => callback(span), () => {
38151
38549
  if (spanToJSON(span).status === undefined) {
38152
- span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
38550
+ span.setStatus({ code: import_api4.SpanStatusCode.ERROR });
38153
38551
  }
38154
38552
  }, () => span.end());
38155
38553
  });
@@ -38161,13 +38559,13 @@ function startSpanManual2(options, callback) {
38161
38559
  const wrapper = getActiveSpanWrapper2(customParentSpan);
38162
38560
  return wrapper(() => {
38163
38561
  const activeCtx = getContext(options.scope, options.forceTransaction);
38164
- const shouldSkipSpan = options.onlyIfParent && !import_api3.trace.getSpan(activeCtx);
38165
- const ctx = shouldSkipSpan ? import_core37.suppressTracing(activeCtx) : activeCtx;
38562
+ const shouldSkipSpan = options.onlyIfParent && !import_api4.trace.getSpan(activeCtx);
38563
+ const ctx = shouldSkipSpan ? import_core38.suppressTracing(activeCtx) : activeCtx;
38166
38564
  const spanOptions = getSpanOptions(options);
38167
38565
  return tracer.startActiveSpan(name, spanOptions, ctx, (span) => {
38168
38566
  return handleCallbackErrors(() => callback(span, () => span.end()), () => {
38169
38567
  if (spanToJSON(span).status === undefined) {
38170
- span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
38568
+ span.setStatus({ code: import_api4.SpanStatusCode.ERROR });
38171
38569
  }
38172
38570
  });
38173
38571
  });
@@ -38179,20 +38577,20 @@ function startInactiveSpan2(options) {
38179
38577
  const wrapper = getActiveSpanWrapper2(customParentSpan);
38180
38578
  return wrapper(() => {
38181
38579
  const activeCtx = getContext(options.scope, options.forceTransaction);
38182
- const shouldSkipSpan = options.onlyIfParent && !import_api3.trace.getSpan(activeCtx);
38183
- const ctx = shouldSkipSpan ? import_core37.suppressTracing(activeCtx) : activeCtx;
38580
+ const shouldSkipSpan = options.onlyIfParent && !import_api4.trace.getSpan(activeCtx);
38581
+ const ctx = shouldSkipSpan ? import_core38.suppressTracing(activeCtx) : activeCtx;
38184
38582
  const spanOptions = getSpanOptions(options);
38185
38583
  const span = tracer.startSpan(name, spanOptions, ctx);
38186
38584
  return span;
38187
38585
  });
38188
38586
  }
38189
38587
  function withActiveSpan2(span, callback) {
38190
- const newContextWithActiveSpan = span ? import_api3.trace.setSpan(import_api3.context.active(), span) : import_api3.trace.deleteSpan(import_api3.context.active());
38191
- return import_api3.context.with(newContextWithActiveSpan, () => callback(getCurrentScope()));
38588
+ const newContextWithActiveSpan = span ? import_api4.trace.setSpan(import_api4.context.active(), span) : import_api4.trace.deleteSpan(import_api4.context.active());
38589
+ return import_api4.context.with(newContextWithActiveSpan, () => callback(getCurrentScope()));
38192
38590
  }
38193
38591
  function getTracer() {
38194
38592
  const client = getClient();
38195
- return client?.tracer || import_api3.trace.getTracer("@sentry/opentelemetry", SDK_VERSION);
38593
+ return client?.tracer || import_api4.trace.getTracer("@sentry/opentelemetry", SDK_VERSION);
38196
38594
  }
38197
38595
  function getSpanOptions(options) {
38198
38596
  const { startTime, attributes, kind, op, links } = options;
@@ -38213,14 +38611,14 @@ function ensureTimestampInMilliseconds(timestamp) {
38213
38611
  }
38214
38612
  function getContext(scope, forceTransaction) {
38215
38613
  const ctx = getContextForScope(scope);
38216
- const parentSpan = import_api3.trace.getSpan(ctx);
38614
+ const parentSpan = import_api4.trace.getSpan(ctx);
38217
38615
  if (!parentSpan) {
38218
38616
  return ctx;
38219
38617
  }
38220
38618
  if (!forceTransaction) {
38221
38619
  return ctx;
38222
38620
  }
38223
- const ctxWithoutSpan = import_api3.trace.deleteSpan(ctx);
38621
+ const ctxWithoutSpan = import_api4.trace.deleteSpan(ctx);
38224
38622
  const { spanId, traceId } = parentSpan.spanContext();
38225
38623
  const sampled = getSamplingDecision(parentSpan.spanContext());
38226
38624
  const rootSpan = getRootSpan(parentSpan);
@@ -38233,10 +38631,10 @@ function getContext(scope, forceTransaction) {
38233
38631
  traceId,
38234
38632
  spanId,
38235
38633
  isRemote: true,
38236
- traceFlags: sampled ? import_api3.TraceFlags.SAMPLED : import_api3.TraceFlags.NONE,
38634
+ traceFlags: sampled ? import_api4.TraceFlags.SAMPLED : import_api4.TraceFlags.NONE,
38237
38635
  traceState
38238
38636
  };
38239
- const ctxWithSpanContext = import_api3.trace.setSpanContext(ctxWithoutSpan, spanOptions);
38637
+ const ctxWithSpanContext = import_api4.trace.setSpanContext(ctxWithoutSpan, spanOptions);
38240
38638
  return ctxWithSpanContext;
38241
38639
  }
38242
38640
  function getContextForScope(scope) {
@@ -38246,14 +38644,14 @@ function getContextForScope(scope) {
38246
38644
  return ctx;
38247
38645
  }
38248
38646
  }
38249
- return import_api3.context.active();
38647
+ return import_api4.context.active();
38250
38648
  }
38251
38649
  function continueTrace2(options, callback) {
38252
- return continueTraceAsRemoteSpan(import_api3.context.active(), options, callback);
38650
+ return continueTraceAsRemoteSpan(import_api4.context.active(), options, callback);
38253
38651
  }
38254
38652
  function getTraceContextForScope(client, scope) {
38255
38653
  const ctx = getContextFromScope(scope);
38256
- const span = ctx && import_api3.trace.getSpan(ctx);
38654
+ const span = ctx && import_api4.trace.getSpan(ctx);
38257
38655
  const traceContext = span ? spanToTraceContext(span) : getTraceContextFromScope(scope);
38258
38656
  const dynamicSamplingContext = span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromScope(client, scope);
38259
38657
  return [dynamicSamplingContext, traceContext];
@@ -38264,8 +38662,8 @@ function getActiveSpanWrapper2(parentSpan) {
38264
38662
  } : (callback) => callback();
38265
38663
  }
38266
38664
  function suppressTracing2(callback) {
38267
- const ctx = import_core37.suppressTracing(import_api3.context.active());
38268
- return import_api3.context.with(ctx, callback);
38665
+ const ctx = import_core38.suppressTracing(import_api4.context.active());
38666
+ return import_api4.context.with(ctx, callback);
38269
38667
  }
38270
38668
  function setupEventContextTrace(client) {
38271
38669
  client.on("preprocessEvent", (event) => {
@@ -38367,17 +38765,17 @@ function wrapContextManagerClass(ContextManagerClass) {
38367
38765
  super(...args);
38368
38766
  setIsSetup("SentryContextManager");
38369
38767
  }
38370
- with(context4, fn, thisArg, ...args) {
38371
- const currentScopes = getScopesFromContext(context4);
38768
+ with(context5, fn, thisArg, ...args) {
38769
+ const currentScopes = getScopesFromContext(context5);
38372
38770
  const currentScope = currentScopes?.scope || getCurrentScope();
38373
38771
  const currentIsolationScope = currentScopes?.isolationScope || getIsolationScope();
38374
- const shouldForkIsolationScope = context4.getValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY) === true;
38375
- const scope = context4.getValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY);
38376
- const isolationScope = context4.getValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY);
38772
+ const shouldForkIsolationScope = context5.getValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY) === true;
38773
+ const scope = context5.getValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY);
38774
+ const isolationScope = context5.getValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY);
38377
38775
  const newCurrentScope = scope || currentScope.clone();
38378
38776
  const newIsolationScope = isolationScope || (shouldForkIsolationScope ? currentIsolationScope.clone() : currentIsolationScope);
38379
38777
  const scopes = { scope: newCurrentScope, isolationScope: newIsolationScope };
38380
- const ctx1 = setScopesOnContext(context4, scopes);
38778
+ const ctx1 = setScopesOnContext(context5, scopes);
38381
38779
  const ctx2 = ctx1.deleteValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY).deleteValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY).deleteValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY);
38382
38780
  setContextOnScope(newCurrentScope, ctx2);
38383
38781
  return super.with(ctx2, fn, thisArg, ...args);
@@ -38454,9 +38852,9 @@ function mapStatus(span) {
38454
38852
  const attributes = spanHasAttributes(span) ? span.attributes : {};
38455
38853
  const status = spanHasStatus(span) ? span.status : undefined;
38456
38854
  if (status) {
38457
- if (status.code === import_api3.SpanStatusCode.OK) {
38855
+ if (status.code === import_api4.SpanStatusCode.OK) {
38458
38856
  return { code: SPAN_STATUS_OK };
38459
- } else if (status.code === import_api3.SpanStatusCode.ERROR) {
38857
+ } else if (status.code === import_api4.SpanStatusCode.ERROR) {
38460
38858
  if (typeof status.message === "undefined") {
38461
38859
  const inferredStatus2 = inferStatusFromAttributes(attributes);
38462
38860
  if (inferredStatus2) {
@@ -38474,7 +38872,7 @@ function mapStatus(span) {
38474
38872
  if (inferredStatus) {
38475
38873
  return inferredStatus;
38476
38874
  }
38477
- if (status?.code === import_api3.SpanStatusCode.UNSET) {
38875
+ if (status?.code === import_api4.SpanStatusCode.UNSET) {
38478
38876
  return { code: SPAN_STATUS_OK };
38479
38877
  } else {
38480
38878
  return { code: SPAN_STATUS_ERROR, message: "unknown_error" };
@@ -38725,8 +39123,8 @@ function removeSentryAttributes(data) {
38725
39123
  function getData(span) {
38726
39124
  const attributes = span.attributes;
38727
39125
  const data = {};
38728
- if (span.kind !== import_api3.SpanKind.INTERNAL) {
38729
- data["otel.kind"] = import_api3.SpanKind[span.kind];
39126
+ if (span.kind !== import_api4.SpanKind.INTERNAL) {
39127
+ data["otel.kind"] = import_api4.SpanKind[span.kind];
38730
39128
  }
38731
39129
  const maybeHttpStatusCodeAttribute = attributes[import_semantic_conventions2.SEMATTRS_HTTP_STATUS_CODE];
38732
39130
  if (maybeHttpStatusCodeAttribute) {
@@ -38745,7 +39143,7 @@ function getData(span) {
38745
39143
  return data;
38746
39144
  }
38747
39145
  function onSpanStart(span, parentContext) {
38748
- const parentSpan = import_api3.trace.getSpan(parentContext);
39146
+ const parentSpan = import_api4.trace.getSpan(parentContext);
38749
39147
  let scopes = getScopesFromContext(parentContext);
38750
39148
  if (parentSpan && !parentSpan.spanContext().isRemote) {
38751
39149
  addChildSpanToSpan(parentSpan, span);
@@ -38753,7 +39151,7 @@ function onSpanStart(span, parentContext) {
38753
39151
  if (parentSpan?.spanContext().isRemote) {
38754
39152
  span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE, true);
38755
39153
  }
38756
- if (parentContext === import_api3.ROOT_CONTEXT) {
39154
+ if (parentContext === import_api4.ROOT_CONTEXT) {
38757
39155
  scopes = {
38758
39156
  scope: getDefaultCurrentScope(),
38759
39157
  isolationScope: getDefaultIsolationScope()
@@ -38797,23 +39195,23 @@ class SentrySampler {
38797
39195
  this._client = client;
38798
39196
  setIsSetup("SentrySampler");
38799
39197
  }
38800
- shouldSample(context4, traceId, spanName, spanKind, spanAttributes, _links) {
39198
+ shouldSample(context5, traceId, spanName, spanKind, spanAttributes, _links) {
38801
39199
  const options = this._client.getOptions();
38802
- const parentSpan = getValidSpan(context4);
39200
+ const parentSpan = getValidSpan(context5);
38803
39201
  const parentContext = parentSpan?.spanContext();
38804
39202
  if (!hasSpansEnabled(options)) {
38805
- return wrapSamplingDecision({ decision: undefined, context: context4, spanAttributes });
39203
+ return wrapSamplingDecision({ decision: undefined, context: context5, spanAttributes });
38806
39204
  }
38807
39205
  const maybeSpanHttpMethod = spanAttributes[import_semantic_conventions2.SEMATTRS_HTTP_METHOD] || spanAttributes[import_semantic_conventions2.ATTR_HTTP_REQUEST_METHOD];
38808
- if (spanKind === import_api3.SpanKind.CLIENT && maybeSpanHttpMethod && (!parentSpan || parentContext?.isRemote)) {
38809
- return wrapSamplingDecision({ decision: undefined, context: context4, spanAttributes });
39206
+ if (spanKind === import_api4.SpanKind.CLIENT && maybeSpanHttpMethod && (!parentSpan || parentContext?.isRemote)) {
39207
+ return wrapSamplingDecision({ decision: undefined, context: context5, spanAttributes });
38810
39208
  }
38811
39209
  const parentSampled = parentSpan ? getParentSampled(parentSpan, traceId, spanName) : undefined;
38812
39210
  const isRootSpan = !parentSpan || parentContext?.isRemote;
38813
39211
  if (!isRootSpan) {
38814
39212
  return wrapSamplingDecision({
38815
39213
  decision: parentSampled ? import_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED : import_sdk_trace_base.SamplingDecision.NOT_RECORD,
38816
- context: context4,
39214
+ context: context5,
38817
39215
  spanAttributes
38818
39216
  });
38819
39217
  }
@@ -38837,9 +39235,9 @@ class SentrySampler {
38837
39235
  parentContext
38838
39236
  }, mutableSamplingDecision);
38839
39237
  if (!mutableSamplingDecision.decision) {
38840
- return wrapSamplingDecision({ decision: undefined, context: context4, spanAttributes });
39238
+ return wrapSamplingDecision({ decision: undefined, context: context5, spanAttributes });
38841
39239
  }
38842
- const { isolationScope } = getScopesFromContext(context4) ?? {};
39240
+ const { isolationScope } = getScopesFromContext(context5) ?? {};
38843
39241
  const dscString = parentContext?.traceState ? parentContext.traceState.get(SENTRY_TRACE_STATE_DSC) : undefined;
38844
39242
  const dsc = dscString ? baggageHeaderToDynamicSamplingContext(dscString) : undefined;
38845
39243
  const sampleRand = parseSampleRate(dsc?.sample_rand) ?? Math.random();
@@ -38855,7 +39253,7 @@ class SentrySampler {
38855
39253
  DEBUG_BUILD3 && debug.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`);
38856
39254
  return wrapSamplingDecision({
38857
39255
  decision: import_sdk_trace_base.SamplingDecision.NOT_RECORD,
38858
- context: context4,
39256
+ context: context5,
38859
39257
  spanAttributes,
38860
39258
  sampleRand,
38861
39259
  downstreamTraceSampleRate: 0
@@ -38868,7 +39266,7 @@ class SentrySampler {
38868
39266
  return {
38869
39267
  ...wrapSamplingDecision({
38870
39268
  decision: sampled ? import_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED : import_sdk_trace_base.SamplingDecision.NOT_RECORD,
38871
- context: context4,
39269
+ context: context5,
38872
39270
  spanAttributes,
38873
39271
  sampleRand,
38874
39272
  downstreamTraceSampleRate: localSampleRateWasApplied ? sampleRate : undefined
@@ -38884,7 +39282,7 @@ class SentrySampler {
38884
39282
  }
38885
39283
  function getParentSampled(parentSpan, traceId, spanName) {
38886
39284
  const parentContext = parentSpan.spanContext();
38887
- if (import_api3.isSpanContextValid(parentContext) && parentContext.traceId === traceId) {
39285
+ if (import_api4.isSpanContextValid(parentContext) && parentContext.traceId === traceId) {
38888
39286
  if (parentContext.isRemote) {
38889
39287
  const parentSampled2 = getSamplingDecision(parentSpan.spanContext());
38890
39288
  DEBUG_BUILD3 && debug.log(`[Tracing] Inheriting remote parent's sampled decision for ${spanName}: ${parentSampled2}`);
@@ -38898,12 +39296,12 @@ function getParentSampled(parentSpan, traceId, spanName) {
38898
39296
  }
38899
39297
  function wrapSamplingDecision({
38900
39298
  decision,
38901
- context: context4,
39299
+ context: context5,
38902
39300
  spanAttributes,
38903
39301
  sampleRand,
38904
39302
  downstreamTraceSampleRate
38905
39303
  }) {
38906
- let traceState = getBaseTraceState(context4, spanAttributes);
39304
+ let traceState = getBaseTraceState(context5, spanAttributes);
38907
39305
  if (downstreamTraceSampleRate !== undefined) {
38908
39306
  traceState = traceState.set(SENTRY_TRACE_STATE_SAMPLE_RATE, `${downstreamTraceSampleRate}`);
38909
39307
  }
@@ -38918,19 +39316,19 @@ function wrapSamplingDecision({
38918
39316
  }
38919
39317
  return { decision, traceState };
38920
39318
  }
38921
- function getBaseTraceState(context4, spanAttributes) {
38922
- const parentSpan = import_api3.trace.getSpan(context4);
39319
+ function getBaseTraceState(context5, spanAttributes) {
39320
+ const parentSpan = import_api4.trace.getSpan(context5);
38923
39321
  const parentContext = parentSpan?.spanContext();
38924
- let traceState = parentContext?.traceState || new import_core37.TraceState;
39322
+ let traceState = parentContext?.traceState || new import_core38.TraceState;
38925
39323
  const url = spanAttributes[import_semantic_conventions2.SEMATTRS_HTTP_URL] || spanAttributes[import_semantic_conventions2.ATTR_URL_FULL];
38926
39324
  if (url && typeof url === "string") {
38927
39325
  traceState = traceState.set(SENTRY_TRACE_STATE_URL, url);
38928
39326
  }
38929
39327
  return traceState;
38930
39328
  }
38931
- function getValidSpan(context4) {
38932
- const span = import_api3.trace.getSpan(context4);
38933
- return span && import_api3.isSpanContextValid(span.spanContext()) ? span : undefined;
39329
+ function getValidSpan(context5) {
39330
+ const span = import_api4.trace.getSpan(context5);
39331
+ return span && import_api4.isSpanContextValid(span.spanContext()) ? span : undefined;
38934
39332
  }
38935
39333
 
38936
39334
  // ../../node_modules/@sentry/node-core/build/esm/utils/baggage.js
@@ -39045,21 +39443,6 @@ class SentryHttpInstrumentation extends import_instrumentation2.InstrumentationB
39045
39443
  }
39046
39444
  init() {
39047
39445
  let hasRegisteredHandlers = false;
39048
- const spansEnabled = this.getConfig().spans ?? true;
39049
- const onHttpServerRequestStart = (_data) => {
39050
- const data = _data;
39051
- instrumentServer(data.server, {
39052
- instrumentation: this.getConfig().instrumentation,
39053
- ignoreIncomingRequestBody: this.getConfig().ignoreIncomingRequestBody,
39054
- ignoreSpansForIncomingRequests: this.getConfig().ignoreSpansForIncomingRequests,
39055
- incomingRequestSpanHook: this.getConfig().incomingRequestSpanHook,
39056
- maxIncomingRequestBodySize: this.getConfig().maxIncomingRequestBodySize,
39057
- trackIncomingRequestsAsSessions: this.getConfig().trackIncomingRequestsAsSessions,
39058
- sessionFlushingDelayMS: this.getConfig().sessionFlushingDelayMS ?? 60000,
39059
- ignoreStaticAssets: this.getConfig().ignoreStaticAssets,
39060
- spans: spansEnabled && !this.getConfig().disableIncomingRequestSpans
39061
- });
39062
- };
39063
39446
  const onHttpClientResponseFinish = (_data) => {
39064
39447
  const data = _data;
39065
39448
  this._onOutgoingRequestFinish(data.request, data.response);
@@ -39077,16 +39460,14 @@ class SentryHttpInstrumentation extends import_instrumentation2.InstrumentationB
39077
39460
  return moduleExports;
39078
39461
  }
39079
39462
  hasRegisteredHandlers = true;
39080
- subscribe("http.server.request.start", onHttpServerRequestStart);
39081
- subscribe("http.client.response.finish", onHttpClientResponseFinish);
39082
- subscribe("http.client.request.error", onHttpClientRequestError);
39463
+ subscribe2("http.client.response.finish", onHttpClientResponseFinish);
39464
+ subscribe2("http.client.request.error", onHttpClientRequestError);
39083
39465
  if (this.getConfig().propagateTraceInOutgoingRequests) {
39084
- subscribe("http.client.request.created", onHttpClientRequestCreated);
39466
+ subscribe2("http.client.request.created", onHttpClientRequestCreated);
39085
39467
  }
39086
39468
  return moduleExports;
39087
39469
  };
39088
39470
  const unwrap = () => {
39089
- unsubscribe("http.server.request.start", onHttpServerRequestStart);
39090
39471
  unsubscribe("http.client.response.finish", onHttpClientResponseFinish);
39091
39472
  unsubscribe("http.client.request.error", onHttpClientRequestError);
39092
39473
  unsubscribe("http.client.request.created", onHttpClientRequestCreated);
@@ -39115,7 +39496,7 @@ class SentryHttpInstrumentation extends import_instrumentation2.InstrumentationB
39115
39496
  addTracePropagationHeadersToOutgoingRequest(request, this._propagationDecisionMap);
39116
39497
  }
39117
39498
  _shouldIgnoreOutgoingRequest(request) {
39118
- if (import_core40.isTracingSuppressed(import_api4.context.active())) {
39499
+ if (import_core41.isTracingSuppressed(import_api5.context.active())) {
39119
39500
  return true;
39120
39501
  }
39121
39502
  const ignoreOutgoingRequests = this.getConfig().ignoreOutgoingRequests;
@@ -39129,53 +39510,51 @@ class SentryHttpInstrumentation extends import_instrumentation2.InstrumentationB
39129
39510
  }
39130
39511
 
39131
39512
  // ../../node_modules/@sentry/node-core/build/esm/integrations/http/index.js
39132
- var INTEGRATION_NAME6 = "Http";
39133
- var instrumentSentryHttp = generateInstrumentOnce(`${INTEGRATION_NAME6}.sentry`, (options) => {
39513
+ var INTEGRATION_NAME8 = "Http";
39514
+ var instrumentSentryHttp = generateInstrumentOnce(`${INTEGRATION_NAME8}.sentry`, (options) => {
39134
39515
  return new SentryHttpInstrumentation(options);
39135
39516
  });
39136
39517
  var httpIntegration = defineIntegration((options = {}) => {
39137
- const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [
39138
- [401, 404],
39139
- [301, 303],
39140
- [305, 399]
39141
- ];
39518
+ const serverOptions = {
39519
+ sessions: options.trackIncomingRequestsAsSessions,
39520
+ sessionFlushingDelayMS: options.sessionFlushingDelayMS,
39521
+ ignoreRequestBody: options.ignoreIncomingRequestBody,
39522
+ maxRequestBodySize: options.maxIncomingRequestBodySize
39523
+ };
39524
+ const serverSpansOptions = {
39525
+ ignoreIncomingRequests: options.ignoreIncomingRequests,
39526
+ ignoreStaticAssets: options.ignoreStaticAssets,
39527
+ ignoreStatusCodes: options.dropSpansForIncomingRequestStatusCodes
39528
+ };
39529
+ const httpInstrumentationOptions = {
39530
+ breadcrumbs: options.breadcrumbs,
39531
+ propagateTraceInOutgoingRequests: true,
39532
+ ignoreOutgoingRequests: options.ignoreOutgoingRequests
39533
+ };
39534
+ const server = httpServerIntegration(serverOptions);
39535
+ const serverSpans = httpServerSpansIntegration(serverSpansOptions);
39536
+ const spans = options.spans ?? false;
39537
+ const disableIncomingRequestSpans = options.disableIncomingRequestSpans ?? false;
39538
+ const enabledServerSpans = spans && !disableIncomingRequestSpans;
39142
39539
  return {
39143
- name: INTEGRATION_NAME6,
39540
+ name: INTEGRATION_NAME8,
39541
+ setup(client) {
39542
+ if (enabledServerSpans) {
39543
+ serverSpans.setup(client);
39544
+ }
39545
+ },
39144
39546
  setupOnce() {
39145
- instrumentSentryHttp({
39146
- ...options,
39147
- ignoreSpansForIncomingRequests: options.ignoreIncomingRequests,
39148
- disableIncomingRequestSpans: true,
39149
- propagateTraceInOutgoingRequests: true
39150
- });
39547
+ server.setupOnce();
39548
+ instrumentSentryHttp(httpInstrumentationOptions);
39151
39549
  },
39152
39550
  processEvent(event) {
39153
- if (event.type === "transaction") {
39154
- const statusCode = event.contexts?.trace?.data?.["http.response.status_code"];
39155
- if (typeof statusCode === "number") {
39156
- const shouldDrop = shouldFilterStatusCode(statusCode, dropSpansForIncomingRequestStatusCodes);
39157
- if (shouldDrop) {
39158
- DEBUG_BUILD2 && debug.log("Dropping transaction due to status code", statusCode);
39159
- return null;
39160
- }
39161
- }
39162
- }
39163
- return event;
39551
+ return serverSpans.processEvent(event);
39164
39552
  }
39165
39553
  };
39166
39554
  });
39167
- function shouldFilterStatusCode(statusCode, dropForStatusCodes) {
39168
- return dropForStatusCodes.some((code) => {
39169
- if (typeof code === "number") {
39170
- return code === statusCode;
39171
- }
39172
- const [min, max] = code;
39173
- return statusCode >= min && statusCode <= max;
39174
- });
39175
- }
39176
39555
  // ../../node_modules/@sentry/node-core/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js
39177
- var import_api5 = __toESM(require_src(), 1);
39178
- var import_core44 = __toESM(require_src3(), 1);
39556
+ var import_api6 = __toESM(require_src(), 1);
39557
+ var import_core45 = __toESM(require_src3(), 1);
39179
39558
  var import_instrumentation3 = __toESM(require_src6(), 1);
39180
39559
  import * as diagch from "diagnostics_channel";
39181
39560
 
@@ -39295,7 +39674,7 @@ class SentryNodeFetchInstrumentation extends import_instrumentation3.Instrumenta
39295
39674
  });
39296
39675
  }
39297
39676
  _shouldIgnoreOutgoingRequest(request) {
39298
- if (import_core44.isTracingSuppressed(import_api5.context.active())) {
39677
+ if (import_core45.isTracingSuppressed(import_api6.context.active())) {
39299
39678
  return true;
39300
39679
  }
39301
39680
  const url = getAbsoluteUrl2(request.origin, request.path);
@@ -39360,8 +39739,8 @@ function getAbsoluteUrl2(origin, path7 = "/") {
39360
39739
  }
39361
39740
 
39362
39741
  // ../../node_modules/@sentry/node-core/build/esm/integrations/node-fetch/index.js
39363
- var INTEGRATION_NAME7 = "NodeFetch";
39364
- var instrumentSentryNodeFetch = generateInstrumentOnce(`${INTEGRATION_NAME7}.sentry`, SentryNodeFetchInstrumentation, (options) => {
39742
+ var INTEGRATION_NAME9 = "NodeFetch";
39743
+ var instrumentSentryNodeFetch = generateInstrumentOnce(`${INTEGRATION_NAME9}.sentry`, SentryNodeFetchInstrumentation, (options) => {
39365
39744
  return options;
39366
39745
  });
39367
39746
  var _nativeNodeFetchIntegration = (options = {}) => {
@@ -39381,7 +39760,7 @@ import { join as join2 } from "node:path";
39381
39760
  import { promisify } from "node:util";
39382
39761
  var readFileAsync = promisify(readFile);
39383
39762
  var readDirAsync = promisify(readdir);
39384
- var INTEGRATION_NAME8 = "Context";
39763
+ var INTEGRATION_NAME10 = "Context";
39385
39764
  var _nodeContextIntegration = (options = {}) => {
39386
39765
  let cachedContext;
39387
39766
  const _options = {
@@ -39430,7 +39809,7 @@ var _nodeContextIntegration = (options = {}) => {
39430
39809
  return contexts;
39431
39810
  }
39432
39811
  return {
39433
- name: INTEGRATION_NAME8,
39812
+ name: INTEGRATION_NAME10,
39434
39813
  processEvent(event) {
39435
39814
  return addContext(event);
39436
39815
  }
@@ -39664,7 +40043,7 @@ import { createInterface } from "node:readline";
39664
40043
  var LRU_FILE_CONTENTS_CACHE = new LRUMap(10);
39665
40044
  var LRU_FILE_CONTENTS_FS_READ_FAILED = new LRUMap(20);
39666
40045
  var DEFAULT_LINES_OF_CONTEXT = 7;
39667
- var INTEGRATION_NAME9 = "ContextLines";
40046
+ var INTEGRATION_NAME11 = "ContextLines";
39668
40047
  var MAX_CONTEXTLINES_COLNO = 1000;
39669
40048
  var MAX_CONTEXTLINES_LINENO = 1e4;
39670
40049
  function emplace(map, key, contents) {
@@ -39901,7 +40280,7 @@ function makeContextRange(line, linecontext) {
39901
40280
  var _contextLinesIntegration = (options = {}) => {
39902
40281
  const contextLines = options.frameContextLines !== undefined ? options.frameContextLines : DEFAULT_LINES_OF_CONTEXT;
39903
40282
  return {
39904
- name: INTEGRATION_NAME9,
40283
+ name: INTEGRATION_NAME11,
39905
40284
  processEvent(event) {
39906
40285
  return addSourceContext(event, contextLines);
39907
40286
  }
@@ -39962,7 +40341,7 @@ function functionNamesMatch(a, b) {
39962
40341
  }
39963
40342
 
39964
40343
  // ../../node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js
39965
- var base64WorkerScript = "LyohIEBzZW50cnkvbm9kZS1jb3JlIDEwLjE2LjAgKDc0YzUyMTMpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPWdsb2JhbFRoaXMsaT17fTtjb25zdCBvPSJfX1NFTlRSWV9FUlJPUl9MT0NBTF9WQVJJQUJMRVNfXyI7Y29uc3QgYT10O2Z1bmN0aW9uIHMoLi4uZSl7YS5kZWJ1ZyYmZnVuY3Rpb24oZSl7aWYoISgiY29uc29sZSJpbiBuKSlyZXR1cm4gZSgpO2NvbnN0IHQ9bi5jb25zb2xlLG89e30sYT1PYmplY3Qua2V5cyhpKTthLmZvckVhY2goZT0+e2NvbnN0IG49aVtlXTtvW2VdPXRbZV0sdFtlXT1ufSk7dHJ5e3JldHVybiBlKCl9ZmluYWxseXthLmZvckVhY2goZT0+e3RbZV09b1tlXX0pfX0oKCk9PmNvbnNvbGUubG9nKCJbTG9jYWxWYXJpYWJsZXMgV29ya2VyXSIsLi4uZSkpfWFzeW5jIGZ1bmN0aW9uIGMoZSx0LG4saSl7Y29uc3Qgbz1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pO2lbbl09by5yZXN1bHQuZmlsdGVyKGU9PiJsZW5ndGgiIT09ZS5uYW1lJiYhaXNOYU4ocGFyc2VJbnQoZS5uYW1lLDEwKSkpLnNvcnQoKGUsdCk9PnBhcnNlSW50KGUubmFtZSwxMCktcGFyc2VJbnQodC5uYW1lLDEwKSkubWFwKGU9PmUudmFsdWU/LnZhbHVlKX1hc3luYyBmdW5jdGlvbiByKGUsdCxuLGkpe2NvbnN0IG89YXdhaXQgZS5wb3N0KCJSdW50aW1lLmdldFByb3BlcnRpZXMiLHtvYmplY3RJZDp0LG93blByb3BlcnRpZXM6ITB9KTtpW25dPW8ucmVzdWx0Lm1hcChlPT5bZS5uYW1lLGUudmFsdWU/LnZhbHVlXSkucmVkdWNlKChlLFt0LG5dKT0+KGVbdF09bixlKSx7fSl9ZnVuY3Rpb24gdShlLHQpe2UudmFsdWUmJigidmFsdWUiaW4gZS52YWx1ZT92b2lkIDA9PT1lLnZhbHVlLnZhbHVlfHxudWxsPT09ZS52YWx1ZS52YWx1ZT90W2UubmFtZV09YDwke2UudmFsdWUudmFsdWV9PmA6dFtlLm5hbWVdPWUudmFsdWUudmFsdWU6ImRlc2NyaXB0aW9uImluIGUudmFsdWUmJiJmdW5jdGlvbiIhPT1lLnZhbHVlLnR5cGU/dFtlLm5hbWVdPWA8JHtlLnZhbHVlLmRlc2NyaXB0aW9ufT5gOiJ1bmRlZmluZWQiPT09ZS52YWx1ZS50eXBlJiYodFtlLm5hbWVdPSI8dW5kZWZpbmVkPiIpKX1hc3luYyBmdW5jdGlvbiBsKGUsdCl7Y29uc3Qgbj1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pLGk9e307Zm9yKGNvbnN0IHQgb2Ygbi5yZXN1bHQpaWYodC52YWx1ZT8ub2JqZWN0SWQmJiJBcnJheSI9PT10LnZhbHVlLmNsYXNzTmFtZSl7Y29uc3Qgbj10LnZhbHVlLm9iamVjdElkO2F3YWl0IGMoZSxuLHQubmFtZSxpKX1lbHNlIGlmKHQudmFsdWU/Lm9iamVjdElkJiYiT2JqZWN0Ij09PXQudmFsdWUuY2xhc3NOYW1lKXtjb25zdCBuPXQudmFsdWUub2JqZWN0SWQ7YXdhaXQgcihlLG4sdC5uYW1lLGkpfWVsc2UgdC52YWx1ZSYmdSh0LGkpO3JldHVybiBpfWxldCBmOyhhc3luYyBmdW5jdGlvbigpe2NvbnN0IHQ9bmV3IGU7dC5jb25uZWN0VG9NYWluVGhyZWFkKCkscygiQ29ubmVjdGVkIHRvIG1haW4gdGhyZWFkIik7bGV0IG49ITE7dC5vbigiRGVidWdnZXIucmVzdW1lZCIsKCk9PntuPSExfSksdC5vbigiRGVidWdnZXIucGF1c2VkIixlPT57bj0hMCxhc3luYyBmdW5jdGlvbihlLHtyZWFzb246dCxkYXRhOntvYmplY3RJZDpufSxjYWxsRnJhbWVzOml9KXtpZigiZXhjZXB0aW9uIiE9PXQmJiJwcm9taXNlUmVqZWN0aW9uIiE9PXQpcmV0dXJuO2lmKGY/LigpLG51bGw9PW4pcmV0dXJuO2NvbnN0IGE9W107Zm9yKGxldCB0PTA7dDxpLmxlbmd0aDt0Kyspe2NvbnN0e3Njb3BlQ2hhaW46bixmdW5jdGlvbk5hbWU6byx0aGlzOnN9PWlbdF0sYz1uLmZpbmQoZT0+ImxvY2FsIj09PWUudHlwZSkscj0iZ2xvYmFsIiE9PXMuY2xhc3NOYW1lJiZzLmNsYXNzTmFtZT9gJHtzLmNsYXNzTmFtZX0uJHtvfWA6bztpZih2b2lkIDA9PT1jPy5vYmplY3Qub2JqZWN0SWQpYVt0XT17ZnVuY3Rpb246cn07ZWxzZXtjb25zdCBuPWF3YWl0IGwoZSxjLm9iamVjdC5vYmplY3RJZCk7YVt0XT17ZnVuY3Rpb246cix2YXJzOm59fX1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuY2FsbEZ1bmN0aW9uT24iLHtmdW5jdGlvbkRlY2xhcmF0aW9uOmBmdW5jdGlvbigpIHsgdGhpcy4ke299ID0gdGhpcy4ke299IHx8ICR7SlNPTi5zdHJpbmdpZnkoYSl9OyB9YCxzaWxlbnQ6ITAsb2JqZWN0SWQ6bn0pLGF3YWl0IGUucG9zdCgiUnVudGltZS5yZWxlYXNlT2JqZWN0Iix7b2JqZWN0SWQ6bn0pfSh0LGUucGFyYW1zKS50aGVuKGFzeW5jKCk9PntuJiZhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnJlc3VtZSIpfSxhc3luYyBlPT57biYmYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5yZXN1bWUiKX0pfSksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5lbmFibGUiKTtjb25zdCBpPSExIT09YS5jYXB0dXJlQWxsRXhjZXB0aW9ucztpZihhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnNldFBhdXNlT25FeGNlcHRpb25zIix7c3RhdGU6aT8iYWxsIjoidW5jYXVnaHQifSksaSl7Y29uc3QgZT1hLm1heEV4Y2VwdGlvbnNQZXJTZWNvbmR8fDUwO2Y9ZnVuY3Rpb24oZSx0LG4pe2xldCBpPTAsbz01LGE9MDtyZXR1cm4gc2V0SW50ZXJ2YWwoKCk9PnswPT09YT9pPmUmJihvKj0yLG4obyksbz44NjQwMCYmKG89ODY0MDApLGE9byk6KGEtPTEsMD09PWEmJnQoKSksaT0wfSwxZTMpLnVucmVmKCksKCk9PntpKz0xfX0oZSxhc3luYygpPT57cygiUmF0ZS1saW1pdCBsaWZ0ZWQuIiksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJhbGwifSl9LGFzeW5jIGU9PntzKGBSYXRlLWxpbWl0IGV4Y2VlZGVkLiBEaXNhYmxpbmcgY2FwdHVyaW5nIG9mIGNhdWdodCBleGNlcHRpb25zIGZvciAke2V9IHNlY29uZHMuYCksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJ1bmNhdWdodCJ9KX0pfX0pKCkuY2F0Y2goZT0+e3MoIkZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlciIsZSl9KSxzZXRJbnRlcnZhbCgoKT0+e30sMWU0KTs=";
40344
+ var base64WorkerScript = "LyohIEBzZW50cnkvbm9kZS1jb3JlIDEwLjIwLjAgKGIzYzcxNDEpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPWdsb2JhbFRoaXMsaT17fTtjb25zdCBvPSJfX1NFTlRSWV9FUlJPUl9MT0NBTF9WQVJJQUJMRVNfXyI7Y29uc3QgYT10O2Z1bmN0aW9uIHMoLi4uZSl7YS5kZWJ1ZyYmZnVuY3Rpb24oZSl7aWYoISgiY29uc29sZSJpbiBuKSlyZXR1cm4gZSgpO2NvbnN0IHQ9bi5jb25zb2xlLG89e30sYT1PYmplY3Qua2V5cyhpKTthLmZvckVhY2goZT0+e2NvbnN0IG49aVtlXTtvW2VdPXRbZV0sdFtlXT1ufSk7dHJ5e3JldHVybiBlKCl9ZmluYWxseXthLmZvckVhY2goZT0+e3RbZV09b1tlXX0pfX0oKCk9PmNvbnNvbGUubG9nKCJbTG9jYWxWYXJpYWJsZXMgV29ya2VyXSIsLi4uZSkpfWFzeW5jIGZ1bmN0aW9uIGMoZSx0LG4saSl7Y29uc3Qgbz1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pO2lbbl09by5yZXN1bHQuZmlsdGVyKGU9PiJsZW5ndGgiIT09ZS5uYW1lJiYhaXNOYU4ocGFyc2VJbnQoZS5uYW1lLDEwKSkpLnNvcnQoKGUsdCk9PnBhcnNlSW50KGUubmFtZSwxMCktcGFyc2VJbnQodC5uYW1lLDEwKSkubWFwKGU9PmUudmFsdWU/LnZhbHVlKX1hc3luYyBmdW5jdGlvbiByKGUsdCxuLGkpe2NvbnN0IG89YXdhaXQgZS5wb3N0KCJSdW50aW1lLmdldFByb3BlcnRpZXMiLHtvYmplY3RJZDp0LG93blByb3BlcnRpZXM6ITB9KTtpW25dPW8ucmVzdWx0Lm1hcChlPT5bZS5uYW1lLGUudmFsdWU/LnZhbHVlXSkucmVkdWNlKChlLFt0LG5dKT0+KGVbdF09bixlKSx7fSl9ZnVuY3Rpb24gdShlLHQpe2UudmFsdWUmJigidmFsdWUiaW4gZS52YWx1ZT92b2lkIDA9PT1lLnZhbHVlLnZhbHVlfHxudWxsPT09ZS52YWx1ZS52YWx1ZT90W2UubmFtZV09YDwke2UudmFsdWUudmFsdWV9PmA6dFtlLm5hbWVdPWUudmFsdWUudmFsdWU6ImRlc2NyaXB0aW9uImluIGUudmFsdWUmJiJmdW5jdGlvbiIhPT1lLnZhbHVlLnR5cGU/dFtlLm5hbWVdPWA8JHtlLnZhbHVlLmRlc2NyaXB0aW9ufT5gOiJ1bmRlZmluZWQiPT09ZS52YWx1ZS50eXBlJiYodFtlLm5hbWVdPSI8dW5kZWZpbmVkPiIpKX1hc3luYyBmdW5jdGlvbiBsKGUsdCl7Y29uc3Qgbj1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pLGk9e307Zm9yKGNvbnN0IHQgb2Ygbi5yZXN1bHQpaWYodC52YWx1ZT8ub2JqZWN0SWQmJiJBcnJheSI9PT10LnZhbHVlLmNsYXNzTmFtZSl7Y29uc3Qgbj10LnZhbHVlLm9iamVjdElkO2F3YWl0IGMoZSxuLHQubmFtZSxpKX1lbHNlIGlmKHQudmFsdWU/Lm9iamVjdElkJiYiT2JqZWN0Ij09PXQudmFsdWUuY2xhc3NOYW1lKXtjb25zdCBuPXQudmFsdWUub2JqZWN0SWQ7YXdhaXQgcihlLG4sdC5uYW1lLGkpfWVsc2UgdC52YWx1ZSYmdSh0LGkpO3JldHVybiBpfWxldCBmOyhhc3luYyBmdW5jdGlvbigpe2NvbnN0IHQ9bmV3IGU7dC5jb25uZWN0VG9NYWluVGhyZWFkKCkscygiQ29ubmVjdGVkIHRvIG1haW4gdGhyZWFkIik7bGV0IG49ITE7dC5vbigiRGVidWdnZXIucmVzdW1lZCIsKCk9PntuPSExfSksdC5vbigiRGVidWdnZXIucGF1c2VkIixlPT57bj0hMCxhc3luYyBmdW5jdGlvbihlLHtyZWFzb246dCxkYXRhOntvYmplY3RJZDpufSxjYWxsRnJhbWVzOml9KXtpZigiZXhjZXB0aW9uIiE9PXQmJiJwcm9taXNlUmVqZWN0aW9uIiE9PXQpcmV0dXJuO2lmKGY/LigpLG51bGw9PW4pcmV0dXJuO2NvbnN0IGE9W107Zm9yKGxldCB0PTA7dDxpLmxlbmd0aDt0Kyspe2NvbnN0e3Njb3BlQ2hhaW46bixmdW5jdGlvbk5hbWU6byx0aGlzOnN9PWlbdF0sYz1uLmZpbmQoZT0+ImxvY2FsIj09PWUudHlwZSkscj0iZ2xvYmFsIiE9PXMuY2xhc3NOYW1lJiZzLmNsYXNzTmFtZT9gJHtzLmNsYXNzTmFtZX0uJHtvfWA6bztpZih2b2lkIDA9PT1jPy5vYmplY3Qub2JqZWN0SWQpYVt0XT17ZnVuY3Rpb246cn07ZWxzZXtjb25zdCBuPWF3YWl0IGwoZSxjLm9iamVjdC5vYmplY3RJZCk7YVt0XT17ZnVuY3Rpb246cix2YXJzOm59fX1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuY2FsbEZ1bmN0aW9uT24iLHtmdW5jdGlvbkRlY2xhcmF0aW9uOmBmdW5jdGlvbigpIHsgdGhpcy4ke299ID0gdGhpcy4ke299IHx8ICR7SlNPTi5zdHJpbmdpZnkoYSl9OyB9YCxzaWxlbnQ6ITAsb2JqZWN0SWQ6bn0pLGF3YWl0IGUucG9zdCgiUnVudGltZS5yZWxlYXNlT2JqZWN0Iix7b2JqZWN0SWQ6bn0pfSh0LGUucGFyYW1zKS50aGVuKGFzeW5jKCk9PntuJiZhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnJlc3VtZSIpfSxhc3luYyBlPT57biYmYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5yZXN1bWUiKX0pfSksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5lbmFibGUiKTtjb25zdCBpPSExIT09YS5jYXB0dXJlQWxsRXhjZXB0aW9ucztpZihhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnNldFBhdXNlT25FeGNlcHRpb25zIix7c3RhdGU6aT8iYWxsIjoidW5jYXVnaHQifSksaSl7Y29uc3QgZT1hLm1heEV4Y2VwdGlvbnNQZXJTZWNvbmR8fDUwO2Y9ZnVuY3Rpb24oZSx0LG4pe2xldCBpPTAsbz01LGE9MDtyZXR1cm4gc2V0SW50ZXJ2YWwoKCk9PnswPT09YT9pPmUmJihvKj0yLG4obyksbz44NjQwMCYmKG89ODY0MDApLGE9byk6KGEtPTEsMD09PWEmJnQoKSksaT0wfSwxZTMpLnVucmVmKCksKCk9PntpKz0xfX0oZSxhc3luYygpPT57cygiUmF0ZS1saW1pdCBsaWZ0ZWQuIiksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJhbGwifSl9LGFzeW5jIGU9PntzKGBSYXRlLWxpbWl0IGV4Y2VlZGVkLiBEaXNhYmxpbmcgY2FwdHVyaW5nIG9mIGNhdWdodCBleGNlcHRpb25zIGZvciAke2V9IHNlY29uZHMuYCksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJ1bmNhdWdodCJ9KX0pfX0pKCkuY2F0Y2goZT0+e3MoIkZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlciIsZSl9KSxzZXRJbnRlcnZhbCgoKT0+e30sMWU0KTs=";
39966
40345
  function log2(...args) {
39967
40346
  debug.log("[LocalVariables]", ...args);
39968
40347
  }
@@ -40169,7 +40548,7 @@ class AsyncSession {
40169
40548
  next(vars);
40170
40549
  }
40171
40550
  }
40172
- var INTEGRATION_NAME10 = "LocalVariables";
40551
+ var INTEGRATION_NAME12 = "LocalVariables";
40173
40552
  var _localVariablesSyncIntegration = (options = {}, sessionOverride) => {
40174
40553
  const cachedFrames = new LRUMap(20);
40175
40554
  let rateLimiter;
@@ -40204,7 +40583,7 @@ var _localVariablesSyncIntegration = (options = {}, sessionOverride) => {
40204
40583
  return event;
40205
40584
  }
40206
40585
  return {
40207
- name: INTEGRATION_NAME10,
40586
+ name: INTEGRATION_NAME12,
40208
40587
  async setupOnce() {
40209
40588
  const client = getClient();
40210
40589
  const clientOptions = client?.getOptions();
@@ -40324,11 +40703,11 @@ function supportsEsmLoaderHooks() {
40324
40703
 
40325
40704
  // ../../node_modules/@sentry/node-core/build/esm/integrations/modules.js
40326
40705
  var moduleCache;
40327
- var INTEGRATION_NAME11 = "Modules";
40706
+ var INTEGRATION_NAME13 = "Modules";
40328
40707
  var SERVER_MODULES = typeof __SENTRY_SERVER_MODULES__ === "undefined" ? {} : __SENTRY_SERVER_MODULES__;
40329
40708
  var _modulesIntegration = () => {
40330
40709
  return {
40331
- name: INTEGRATION_NAME11,
40710
+ name: INTEGRATION_NAME13,
40332
40711
  processEvent(event) {
40333
40712
  event.modules = {
40334
40713
  ...event.modules,
@@ -40432,14 +40811,14 @@ function logAndExitProcess(error2) {
40432
40811
  }
40433
40812
 
40434
40813
  // ../../node_modules/@sentry/node-core/build/esm/integrations/onuncaughtexception.js
40435
- var INTEGRATION_NAME12 = "OnUncaughtException";
40814
+ var INTEGRATION_NAME14 = "OnUncaughtException";
40436
40815
  var onUncaughtExceptionIntegration = defineIntegration((options = {}) => {
40437
40816
  const optionsWithDefaults = {
40438
40817
  exitEvenIfOtherHandlersAreRegistered: false,
40439
40818
  ...options
40440
40819
  };
40441
40820
  return {
40442
- name: INTEGRATION_NAME12,
40821
+ name: INTEGRATION_NAME14,
40443
40822
  setup(client) {
40444
40823
  global.process.on("uncaughtException", makeErrorHandler(client, optionsWithDefaults));
40445
40824
  }
@@ -40503,25 +40882,51 @@ function makeErrorHandler(client, options) {
40503
40882
  }
40504
40883
 
40505
40884
  // ../../node_modules/@sentry/node-core/build/esm/integrations/onunhandledrejection.js
40506
- var INTEGRATION_NAME13 = "OnUnhandledRejection";
40885
+ var INTEGRATION_NAME15 = "OnUnhandledRejection";
40886
+ var DEFAULT_IGNORES = [
40887
+ {
40888
+ name: "AI_NoOutputGeneratedError"
40889
+ }
40890
+ ];
40507
40891
  var _onUnhandledRejectionIntegration = (options = {}) => {
40508
40892
  const opts = {
40509
- mode: "warn",
40510
- ...options
40893
+ mode: options.mode ?? "warn",
40894
+ ignore: [...DEFAULT_IGNORES, ...options.ignore ?? []]
40511
40895
  };
40512
40896
  return {
40513
- name: INTEGRATION_NAME13,
40897
+ name: INTEGRATION_NAME15,
40514
40898
  setup(client) {
40515
40899
  global.process.on("unhandledRejection", makeUnhandledPromiseHandler(client, opts));
40516
40900
  }
40517
40901
  };
40518
40902
  };
40519
40903
  var onUnhandledRejectionIntegration = defineIntegration(_onUnhandledRejectionIntegration);
40904
+ function extractErrorInfo(reason) {
40905
+ if (typeof reason !== "object" || reason === null) {
40906
+ return { name: "", message: String(reason ?? "") };
40907
+ }
40908
+ const errorLike = reason;
40909
+ const name = typeof errorLike.name === "string" ? errorLike.name : "";
40910
+ const message = typeof errorLike.message === "string" ? errorLike.message : String(reason);
40911
+ return { name, message };
40912
+ }
40913
+ function isMatchingReason(matcher, errorInfo) {
40914
+ const nameMatches = matcher.name === undefined || isMatchingPattern(errorInfo.name, matcher.name, true);
40915
+ const messageMatches = matcher.message === undefined || isMatchingPattern(errorInfo.message, matcher.message);
40916
+ return nameMatches && messageMatches;
40917
+ }
40918
+ function matchesIgnore(list, reason) {
40919
+ const errorInfo = extractErrorInfo(reason);
40920
+ return list.some((matcher) => isMatchingReason(matcher, errorInfo));
40921
+ }
40520
40922
  function makeUnhandledPromiseHandler(client, options) {
40521
40923
  return function sendUnhandledPromise(reason, promise) {
40522
40924
  if (getClient() !== client) {
40523
40925
  return;
40524
40926
  }
40927
+ if (matchesIgnore(options.ignore ?? [], reason)) {
40928
+ return;
40929
+ }
40525
40930
  const level = options.mode === "strict" ? "fatal" : "error";
40526
40931
  const activeSpanForError = reason && typeof reason === "object" ? reason._sentry_active_span : undefined;
40527
40932
  const activeSpanWrapper = activeSpanForError ? (fn) => withActiveSpan(activeSpanForError, fn) : (fn) => fn();
@@ -40558,13 +40963,13 @@ function handleRejection(reason, mode) {
40558
40963
 
40559
40964
  // ../../node_modules/@sentry/node-core/build/esm/integrations/spotlight.js
40560
40965
  import * as http from "node:http";
40561
- var INTEGRATION_NAME14 = "Spotlight";
40966
+ var INTEGRATION_NAME16 = "Spotlight";
40562
40967
  var _spotlightIntegration = (options = {}) => {
40563
40968
  const _options = {
40564
40969
  sidecarUrl: options.sidecarUrl || "http://localhost:8969/stream"
40565
40970
  };
40566
40971
  return {
40567
- name: INTEGRATION_NAME14,
40972
+ name: INTEGRATION_NAME16,
40568
40973
  setup(client) {
40569
40974
  try {
40570
40975
  if (false) {}
@@ -40623,7 +41028,7 @@ function parseSidecarUrl(url) {
40623
41028
 
40624
41029
  // ../../node_modules/@sentry/node-core/build/esm/integrations/systemError.js
40625
41030
  import * as util from "node:util";
40626
- var INTEGRATION_NAME15 = "NodeSystemError";
41031
+ var INTEGRATION_NAME17 = "NodeSystemError";
40627
41032
  function isSystemError(error2) {
40628
41033
  if (!(error2 instanceof Error)) {
40629
41034
  return false;
@@ -40635,7 +41040,7 @@ function isSystemError(error2) {
40635
41040
  }
40636
41041
  var systemErrorIntegration = defineIntegration((options = {}) => {
40637
41042
  return {
40638
- name: INTEGRATION_NAME15,
41043
+ name: INTEGRATION_NAME17,
40639
41044
  processEvent: (event, hint, client) => {
40640
41045
  if (!isSystemError(hint.originalException)) {
40641
41046
  return event;
@@ -40669,10 +41074,10 @@ var systemErrorIntegration = defineIntegration((options = {}) => {
40669
41074
 
40670
41075
  // ../../node_modules/@sentry/node-core/build/esm/integrations/childProcess.js
40671
41076
  import * as diagnosticsChannel from "node:diagnostics_channel";
40672
- var INTEGRATION_NAME16 = "ChildProcess";
41077
+ var INTEGRATION_NAME18 = "ChildProcess";
40673
41078
  var childProcessIntegration = defineIntegration((options = {}) => {
40674
41079
  return {
40675
- name: INTEGRATION_NAME16,
41080
+ name: INTEGRATION_NAME18,
40676
41081
  setup() {
40677
41082
  diagnosticsChannel.channel("child_process").subscribe((event) => {
40678
41083
  if (event && typeof event === "object" && "process" in event) {
@@ -40747,22 +41152,22 @@ function captureWorkerThreadEvents(worker, options) {
40747
41152
  var import_context_async_hooks = __toESM(require_src10(), 1);
40748
41153
  var SentryContextManager = wrapContextManagerClass(import_context_async_hooks.AsyncLocalStorageContextManager);
40749
41154
  // ../../node_modules/@sentry/node-core/build/esm/otel/logger.js
40750
- var import_api6 = __toESM(require_src(), 1);
41155
+ var import_api7 = __toESM(require_src(), 1);
40751
41156
  function setupOpenTelemetryLogger() {
40752
- import_api6.diag.disable();
40753
- import_api6.diag.setLogger({
41157
+ import_api7.diag.disable();
41158
+ import_api7.diag.setLogger({
40754
41159
  error: debug.error,
40755
41160
  warn: debug.warn,
40756
41161
  info: debug.log,
40757
41162
  debug: debug.log,
40758
41163
  verbose: debug.log
40759
- }, import_api6.DiagLogLevel.DEBUG);
41164
+ }, import_api7.DiagLogLevel.DEBUG);
40760
41165
  }
40761
41166
  // ../../node_modules/@sentry/node-core/build/esm/integrations/processSession.js
40762
- var INTEGRATION_NAME17 = "ProcessSession";
41167
+ var INTEGRATION_NAME19 = "ProcessSession";
40763
41168
  var processSessionIntegration = defineIntegration(() => {
40764
41169
  return {
40765
- name: INTEGRATION_NAME17,
41170
+ name: INTEGRATION_NAME19,
40766
41171
  setupOnce() {
40767
41172
  startSession();
40768
41173
  process.on("beforeExit", () => {
@@ -41179,7 +41584,7 @@ function getSentryRelease(fallback) {
41179
41584
  var defaultStackParser = createStackParser(nodeStackLineParser(createGetModuleFromFilename()));
41180
41585
 
41181
41586
  // ../../node_modules/@sentry/node-core/build/esm/sdk/client.js
41182
- var import_api7 = __toESM(require_src(), 1);
41587
+ var import_api8 = __toESM(require_src(), 1);
41183
41588
  var import_instrumentation4 = __toESM(require_src6(), 1);
41184
41589
  import * as os2 from "node:os";
41185
41590
  import { threadId, isMainThread } from "worker_threads";
@@ -41223,7 +41628,7 @@ class NodeClient extends ServerRuntimeClient {
41223
41628
  }
41224
41629
  const name = "@sentry/node";
41225
41630
  const version = SDK_VERSION;
41226
- const tracer = import_api7.trace.getTracer(name, version);
41631
+ const tracer = import_api8.trace.getTracer(name, version);
41227
41632
  this._tracer = tracer;
41228
41633
  return tracer;
41229
41634
  }
@@ -41333,7 +41738,7 @@ function _init(_options = {}, getDefaultIntegrationsImpl) {
41333
41738
  setOpenTelemetryContextAsyncContextStrategy();
41334
41739
  const scope = getCurrentScope();
41335
41740
  scope.update(options.initialScope);
41336
- if (options.spotlight && !options.integrations.some(({ name }) => name === INTEGRATION_NAME14)) {
41741
+ if (options.spotlight && !options.integrations.some(({ name }) => name === INTEGRATION_NAME16)) {
41337
41742
  options.integrations.push(spotlightIntegration({
41338
41743
  sidecarUrl: typeof options.spotlight === "string" ? options.spotlight : undefined
41339
41744
  }));
@@ -41342,6 +41747,7 @@ function _init(_options = {}, getDefaultIntegrationsImpl) {
41342
41747
  const client = new NodeClient(options);
41343
41748
  getCurrentScope().setClient(client);
41344
41749
  client.init();
41750
+ GLOBAL_OBJ._sentryInjectLoaderHookRegister?.();
41345
41751
  debug.log(`SDK initialized from ${isCjs() ? "CommonJS" : "ESM"}`);
41346
41752
  client.startClientReportTracking();
41347
41753
  updateScopeFromEnvVariables();
@@ -41426,22 +41832,19 @@ function updateScopeFromEnvVariables() {
41426
41832
  function addOriginToSpan2(span, origin) {
41427
41833
  span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
41428
41834
  }
41429
- // ../../node_modules/@sentry/node/build/esm/debug-build.js
41430
- var DEBUG_BUILD4 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
41431
-
41432
41835
  // ../../node_modules/@sentry/node/build/esm/integrations/http.js
41433
- var INTEGRATION_NAME18 = "Http";
41836
+ var INTEGRATION_NAME20 = "Http";
41434
41837
  var INSTRUMENTATION_NAME2 = "@opentelemetry_sentry-patched/instrumentation-http";
41435
- var instrumentSentryHttp2 = generateInstrumentOnce(`${INTEGRATION_NAME18}.sentry`, (options) => {
41838
+ var instrumentSentryHttp2 = generateInstrumentOnce(`${INTEGRATION_NAME20}.sentry`, (options) => {
41436
41839
  return new SentryHttpInstrumentation(options);
41437
41840
  });
41438
- var instrumentOtelHttp = generateInstrumentOnce(INTEGRATION_NAME18, (config) => {
41841
+ var instrumentOtelHttp = generateInstrumentOnce(INTEGRATION_NAME20, (config) => {
41439
41842
  const instrumentation = new import_instrumentation_http.HttpInstrumentation({
41440
41843
  ...config,
41441
41844
  disableIncomingRequestInstrumentation: true
41442
41845
  });
41443
41846
  try {
41444
- instrumentation["_diag"] = import_api9.diag.createComponentLogger({
41847
+ instrumentation["_diag"] = import_api10.diag.createComponentLogger({
41445
41848
  namespace: INSTRUMENTATION_NAME2
41446
41849
  });
41447
41850
  instrumentation.instrumentationName = INSTRUMENTATION_NAME2;
@@ -41461,40 +41864,49 @@ function _shouldUseOtelHttpInstrumentation(options, clientOptions = {}) {
41461
41864
  return true;
41462
41865
  }
41463
41866
  var httpIntegration2 = defineIntegration((options = {}) => {
41464
- const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [
41465
- [401, 404],
41466
- [301, 303],
41467
- [305, 399]
41468
- ];
41867
+ const spans = options.spans ?? true;
41868
+ const disableIncomingRequestSpans = options.disableIncomingRequestSpans;
41869
+ const serverOptions = {
41870
+ sessions: options.trackIncomingRequestsAsSessions,
41871
+ sessionFlushingDelayMS: options.sessionFlushingDelayMS,
41872
+ ignoreRequestBody: options.ignoreIncomingRequestBody,
41873
+ maxRequestBodySize: options.maxIncomingRequestBodySize
41874
+ };
41875
+ const serverSpansOptions = {
41876
+ ignoreIncomingRequests: options.ignoreIncomingRequests,
41877
+ ignoreStaticAssets: options.ignoreStaticAssets,
41878
+ ignoreStatusCodes: options.dropSpansForIncomingRequestStatusCodes,
41879
+ instrumentation: options.instrumentation,
41880
+ onSpanCreated: options.incomingRequestSpanHook
41881
+ };
41882
+ const server = httpServerIntegration(serverOptions);
41883
+ const serverSpans = httpServerSpansIntegration(serverSpansOptions);
41884
+ const enableServerSpans = spans && !disableIncomingRequestSpans;
41469
41885
  return {
41470
- name: INTEGRATION_NAME18,
41886
+ name: INTEGRATION_NAME20,
41887
+ setup(client) {
41888
+ const clientOptions = client.getOptions();
41889
+ if (enableServerSpans && hasSpansEnabled(clientOptions)) {
41890
+ serverSpans.setup(client);
41891
+ }
41892
+ },
41471
41893
  setupOnce() {
41472
41894
  const clientOptions = getClient()?.getOptions() || {};
41473
41895
  const useOtelHttpInstrumentation = _shouldUseOtelHttpInstrumentation(options, clientOptions);
41474
- const disableIncomingRequestSpans = options.disableIncomingRequestSpans ?? !hasSpansEnabled(clientOptions);
41475
- instrumentSentryHttp2({
41476
- ...options,
41477
- disableIncomingRequestSpans,
41478
- ignoreSpansForIncomingRequests: options.ignoreIncomingRequests,
41479
- propagateTraceInOutgoingRequests: !useOtelHttpInstrumentation
41480
- });
41896
+ server.setupOnce();
41897
+ const sentryHttpInstrumentationOptions = {
41898
+ breadcrumbs: options.breadcrumbs,
41899
+ propagateTraceInOutgoingRequests: !useOtelHttpInstrumentation,
41900
+ ignoreOutgoingRequests: options.ignoreOutgoingRequests
41901
+ };
41902
+ instrumentSentryHttp2(sentryHttpInstrumentationOptions);
41481
41903
  if (useOtelHttpInstrumentation) {
41482
41904
  const instrumentationConfig = getConfigWithDefaults(options);
41483
41905
  instrumentOtelHttp(instrumentationConfig);
41484
41906
  }
41485
41907
  },
41486
41908
  processEvent(event) {
41487
- if (event.type === "transaction") {
41488
- const statusCode = event.contexts?.trace?.data?.["http.response.status_code"];
41489
- if (typeof statusCode === "number") {
41490
- const shouldDrop = shouldFilterStatusCode2(statusCode, dropSpansForIncomingRequestStatusCodes);
41491
- if (shouldDrop) {
41492
- DEBUG_BUILD4 && debug.log("Dropping transaction due to status code", statusCode);
41493
- return null;
41494
- }
41495
- }
41496
- }
41497
- return event;
41909
+ return serverSpans.processEvent(event);
41498
41910
  }
41499
41911
  };
41500
41912
  });
@@ -41525,23 +41937,14 @@ function getConfigWithDefaults(options = {}) {
41525
41937
  };
41526
41938
  return instrumentationConfig;
41527
41939
  }
41528
- function shouldFilterStatusCode2(statusCode, dropForStatusCodes) {
41529
- return dropForStatusCodes.some((code) => {
41530
- if (typeof code === "number") {
41531
- return code === statusCode;
41532
- }
41533
- const [min, max] = code;
41534
- return statusCode >= min && statusCode <= max;
41535
- });
41536
- }
41537
41940
 
41538
41941
  // ../../node_modules/@sentry/node/build/esm/integrations/node-fetch.js
41539
41942
  var import_instrumentation_undici = __toESM(require_src11(), 1);
41540
- var INTEGRATION_NAME19 = "NodeFetch";
41541
- var instrumentOtelNodeFetch = generateInstrumentOnce(INTEGRATION_NAME19, import_instrumentation_undici.UndiciInstrumentation, (options) => {
41943
+ var INTEGRATION_NAME21 = "NodeFetch";
41944
+ var instrumentOtelNodeFetch = generateInstrumentOnce(INTEGRATION_NAME21, import_instrumentation_undici.UndiciInstrumentation, (options) => {
41542
41945
  return getConfigWithDefaults2(options);
41543
41946
  });
41544
- var instrumentSentryNodeFetch2 = generateInstrumentOnce(`${INTEGRATION_NAME19}.sentry`, SentryNodeFetchInstrumentation, (options) => {
41947
+ var instrumentSentryNodeFetch2 = generateInstrumentOnce(`${INTEGRATION_NAME21}.sentry`, SentryNodeFetchInstrumentation, (options) => {
41545
41948
  return options;
41546
41949
  });
41547
41950
  var _nativeNodeFetchIntegration2 = (options = {}) => {
@@ -41590,7 +41993,12 @@ function getConfigWithDefaults2(options = {}) {
41590
41993
 
41591
41994
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/express.js
41592
41995
  var import_instrumentation_express = __toESM(require_src12(), 1);
41593
- var INTEGRATION_NAME20 = "Express";
41996
+
41997
+ // ../../node_modules/@sentry/node/build/esm/debug-build.js
41998
+ var DEBUG_BUILD4 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
41999
+
42000
+ // ../../node_modules/@sentry/node/build/esm/integrations/tracing/express.js
42001
+ var INTEGRATION_NAME22 = "Express";
41594
42002
  function requestHook(span) {
41595
42003
  addOriginToSpan2(span, "auto.http.otel.express");
41596
42004
  const attributes = spanToJSON(span).data;
@@ -41615,13 +42023,13 @@ function spanNameHook(info, defaultName) {
41615
42023
  }
41616
42024
  return defaultName;
41617
42025
  }
41618
- var instrumentExpress = generateInstrumentOnce(INTEGRATION_NAME20, () => new import_instrumentation_express.ExpressInstrumentation({
42026
+ var instrumentExpress = generateInstrumentOnce(INTEGRATION_NAME22, () => new import_instrumentation_express.ExpressInstrumentation({
41619
42027
  requestHook: (span) => requestHook(span),
41620
42028
  spanNameHook: (info, defaultName) => spanNameHook(info, defaultName)
41621
42029
  }));
41622
42030
  var _expressIntegration = () => {
41623
42031
  return {
41624
- name: INTEGRATION_NAME20,
42032
+ name: INTEGRATION_NAME22,
41625
42033
  setupOnce() {
41626
42034
  instrumentExpress();
41627
42035
  }
@@ -41633,8 +42041,8 @@ var expressIntegration = defineIntegration(_expressIntegration);
41633
42041
  import * as dc from "node:diagnostics_channel";
41634
42042
 
41635
42043
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/fastify/fastify-otel/index.js
41636
- var import_api10 = __toESM(require_src(), 1);
41637
- var import_core72 = __toESM(require_src3(), 1);
42044
+ var import_api11 = __toESM(require_src(), 1);
42045
+ var import_core73 = __toESM(require_src3(), 1);
41638
42046
  var import_instrumentation5 = __toESM(require_src6(), 1);
41639
42047
  var import_semantic_conventions3 = __toESM(require_src2(), 1);
41640
42048
  import dc__default from "node:diagnostics_channel";
@@ -42890,7 +43298,7 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
42890
43298
  super(PACKAGE_NAME, PACKAGE_VERSION, config);
42891
43299
  this.servername = config?.servername ?? process.env.OTEL_SERVICE_NAME ?? "fastify";
42892
43300
  this[kIgnorePaths] = null;
42893
- this._logger = import_api10.diag.createComponentLogger({ namespace: PACKAGE_NAME });
43301
+ this._logger = import_api11.diag.createComponentLogger({ namespace: PACKAGE_NAME });
42894
43302
  if (config?.ignorePaths != null || process.env.OTEL_FASTIFY_IGNORE_PATHS != null) {
42895
43303
  const ignorePaths = config?.ignorePaths ?? process.env.OTEL_FASTIFY_IGNORE_PATHS;
42896
43304
  if ((typeof ignorePaths !== "string" || ignorePaths.length === 0) && typeof ignorePaths !== "function") {
@@ -42947,10 +43355,10 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
42947
43355
  tracer: instrumentation.tracer,
42948
43356
  context: ctx,
42949
43357
  inject: (carrier, setter) => {
42950
- return import_api10.propagation.inject(ctx, carrier, setter);
43358
+ return import_api11.propagation.inject(ctx, carrier, setter);
42951
43359
  },
42952
43360
  extract: (carrier, getter) => {
42953
- return import_api10.propagation.extract(ctx, carrier, getter);
43361
+ return import_api11.propagation.extract(ctx, carrier, getter);
42954
43362
  }
42955
43363
  };
42956
43364
  });
@@ -43015,12 +43423,12 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
43015
43423
  this[kInstrumentation]._logger.debug(`Ignoring request ${request2.method} ${request2.url} because it matches the ignore path`);
43016
43424
  return hookDone();
43017
43425
  }
43018
- let ctx = import_api10.context.active();
43019
- if (import_api10.trace.getSpan(ctx) == null) {
43020
- ctx = import_api10.propagation.extract(ctx, request2.headers);
43426
+ let ctx = import_api11.context.active();
43427
+ if (import_api11.trace.getSpan(ctx) == null) {
43428
+ ctx = import_api11.propagation.extract(ctx, request2.headers);
43021
43429
  }
43022
- const rpcMetadata = import_core72.getRPCMetadata(ctx);
43023
- if (request2.routeOptions.url != null && rpcMetadata?.type === import_core72.RPCType.HTTP) {
43430
+ const rpcMetadata = import_core73.getRPCMetadata(ctx);
43431
+ if (request2.routeOptions.url != null && rpcMetadata?.type === import_core73.RPCType.HTTP) {
43024
43432
  rpcMetadata.route = request2.routeOptions.url;
43025
43433
  }
43026
43434
  const span = this[kInstrumentation].tracer.startSpan("request", {
@@ -43031,9 +43439,9 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
43031
43439
  [import_semantic_conventions3.ATTR_HTTP_REQUEST_METHOD]: request2.method
43032
43440
  }
43033
43441
  }, ctx);
43034
- request2[kRequestContext] = import_api10.trace.setSpan(ctx, span);
43442
+ request2[kRequestContext] = import_api11.trace.setSpan(ctx, span);
43035
43443
  request2[kRequestSpan] = span;
43036
- import_api10.context.with(request2[kRequestContext], () => {
43444
+ import_api11.context.with(request2[kRequestContext], () => {
43037
43445
  hookDone();
43038
43446
  });
43039
43447
  });
@@ -43041,7 +43449,7 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
43041
43449
  const span = request2[kRequestSpan];
43042
43450
  if (span != null) {
43043
43451
  span.setStatus({
43044
- code: import_api10.SpanStatusCode.OK,
43452
+ code: import_api11.SpanStatusCode.OK,
43045
43453
  message: "OK"
43046
43454
  });
43047
43455
  span.setAttributes({
@@ -43060,7 +43468,7 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
43060
43468
  if (span != null) {
43061
43469
  if (reply.statusCode < 500) {
43062
43470
  span.setStatus({
43063
- code: import_api10.SpanStatusCode.OK,
43471
+ code: import_api11.SpanStatusCode.OK,
43064
43472
  message: "OK"
43065
43473
  });
43066
43474
  }
@@ -43076,7 +43484,7 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
43076
43484
  const span = request2[kRequestSpan];
43077
43485
  if (span != null) {
43078
43486
  span.setStatus({
43079
- code: import_api10.SpanStatusCode.ERROR,
43487
+ code: import_api11.SpanStatusCode.ERROR,
43080
43488
  message: error2.message
43081
43489
  });
43082
43490
  span.recordException(error2);
@@ -43139,11 +43547,11 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
43139
43547
  if (instrumentation2.isEnabled() === false) {
43140
43548
  return handler.call(this, ...args);
43141
43549
  }
43142
- const ctx = request2[kRequestContext] ?? import_api10.context.active();
43550
+ const ctx = request2[kRequestContext] ?? import_api11.context.active();
43143
43551
  const span = instrumentation2.tracer.startSpan(`handler - ${handler.name?.length > 0 ? handler.name : this.pluginName ?? ANONYMOUS_FUNCTION_NAME}`, {
43144
43552
  attributes: spanAttributes
43145
43553
  }, ctx);
43146
- return import_api10.context.with(import_api10.trace.setSpan(ctx, span), function() {
43554
+ return import_api11.context.with(import_api11.trace.setSpan(ctx, span), function() {
43147
43555
  try {
43148
43556
  const res = handler.call(this, ...args);
43149
43557
  if (typeof res?.then === "function") {
@@ -43152,7 +43560,7 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
43152
43560
  return result;
43153
43561
  }, (error2) => {
43154
43562
  span.setStatus({
43155
- code: import_api10.SpanStatusCode.ERROR,
43563
+ code: import_api11.SpanStatusCode.ERROR,
43156
43564
  message: error2.message
43157
43565
  });
43158
43566
  span.recordException(error2);
@@ -43164,7 +43572,7 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
43164
43572
  return res;
43165
43573
  } catch (error2) {
43166
43574
  span.setStatus({
43167
- code: import_api10.SpanStatusCode.ERROR,
43575
+ code: import_api11.SpanStatusCode.ERROR,
43168
43576
  message: error2.message
43169
43577
  });
43170
43578
  span.recordException(error2);
@@ -43179,8 +43587,8 @@ class FastifyOtelInstrumentation extends import_instrumentation5.Instrumentation
43179
43587
  }
43180
43588
 
43181
43589
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/fastify/v3/instrumentation.js
43182
- var import_api12 = __toESM(require_src(), 1);
43183
- var import_core73 = __toESM(require_src3(), 1);
43590
+ var import_api13 = __toESM(require_src(), 1);
43591
+ var import_core74 = __toESM(require_src3(), 1);
43184
43592
  var import_instrumentation6 = __toESM(require_src6(), 1);
43185
43593
  var import_semantic_conventions4 = __toESM(require_src2(), 1);
43186
43594
 
@@ -43212,7 +43620,7 @@ var FastifyNames;
43212
43620
  })(FastifyNames || (FastifyNames = {}));
43213
43621
 
43214
43622
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/fastify/v3/utils.js
43215
- var import_api11 = __toESM(require_src(), 1);
43623
+ var import_api12 = __toESM(require_src(), 1);
43216
43624
 
43217
43625
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/fastify/v3/constants.js
43218
43626
  var spanRequestSymbol = Symbol("opentelemetry.instrumentation.fastify.request_active_span");
@@ -43237,7 +43645,7 @@ function endSpan(reply, err) {
43237
43645
  spans.forEach((span) => {
43238
43646
  if (err) {
43239
43647
  span.setStatus({
43240
- code: import_api11.SpanStatusCode.ERROR,
43648
+ code: import_api12.SpanStatusCode.ERROR,
43241
43649
  message: err.message
43242
43650
  });
43243
43651
  span.recordException(err);
@@ -43305,9 +43713,9 @@ class FastifyInstrumentationV3 extends import_instrumentation6.InstrumentationBa
43305
43713
  }
43306
43714
  instrumentation._wrap(reply, "send", instrumentation._patchSend());
43307
43715
  const anyRequest = request2;
43308
- const rpcMetadata = import_core73.getRPCMetadata(import_api12.context.active());
43716
+ const rpcMetadata = import_core74.getRPCMetadata(import_api13.context.active());
43309
43717
  const routeName = anyRequest.routeOptions ? anyRequest.routeOptions.url : request2.routerPath;
43310
- if (routeName && rpcMetadata?.type === import_core73.RPCType.HTTP) {
43718
+ if (routeName && rpcMetadata?.type === import_core74.RPCType.HTTP) {
43311
43719
  rpcMetadata.route = routeName;
43312
43720
  }
43313
43721
  const method = request2.method || "GET";
@@ -43337,13 +43745,13 @@ class FastifyInstrumentationV3 extends import_instrumentation6.InstrumentationBa
43337
43745
  origDone.apply(this, doneArgs);
43338
43746
  };
43339
43747
  }
43340
- return import_api12.context.with(import_api12.trace.setSpan(import_api12.context.active(), span), () => {
43748
+ return import_api13.context.with(import_api13.trace.setSpan(import_api13.context.active(), span), () => {
43341
43749
  return safeExecuteInTheMiddleMaybePromise(() => {
43342
43750
  return original.apply(this, args);
43343
43751
  }, (err) => {
43344
43752
  if (err instanceof Error) {
43345
43753
  span.setStatus({
43346
- code: import_api12.SpanStatusCode.ERROR,
43754
+ code: import_api13.SpanStatusCode.ERROR,
43347
43755
  message: err.message
43348
43756
  });
43349
43757
  span.recordException(err);
@@ -43440,7 +43848,7 @@ class FastifyInstrumentationV3 extends import_instrumentation6.InstrumentationBa
43440
43848
  }
43441
43849
  }, true);
43442
43850
  }
43443
- return import_api12.context.with(import_api12.trace.setSpan(import_api12.context.active(), span), () => {
43851
+ return import_api13.context.with(import_api13.trace.setSpan(import_api13.context.active(), span), () => {
43444
43852
  done();
43445
43853
  });
43446
43854
  };
@@ -43472,14 +43880,14 @@ function addFastifyV3SpanAttributes(span) {
43472
43880
  }
43473
43881
 
43474
43882
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/fastify/index.js
43475
- var INTEGRATION_NAME21 = "Fastify";
43476
- var instrumentFastifyV3 = generateInstrumentOnce(`${INTEGRATION_NAME21}.v3`, () => new FastifyInstrumentationV3);
43883
+ var INTEGRATION_NAME23 = "Fastify";
43884
+ var instrumentFastifyV3 = generateInstrumentOnce(`${INTEGRATION_NAME23}.v3`, () => new FastifyInstrumentationV3);
43477
43885
  function getFastifyIntegration() {
43478
43886
  const client = getClient();
43479
43887
  if (!client) {
43480
43888
  return;
43481
43889
  } else {
43482
- return client.getIntegrationByName(INTEGRATION_NAME21);
43890
+ return client.getIntegrationByName(INTEGRATION_NAME23);
43483
43891
  }
43484
43892
  }
43485
43893
  function handleFastifyError(error2, request2, reply, handlerOrigin) {
@@ -43495,7 +43903,7 @@ function handleFastifyError(error2, request2, reply, handlerOrigin) {
43495
43903
  captureException(error2, { mechanism: { handled: false, type: "auto.function.fastify" } });
43496
43904
  }
43497
43905
  }
43498
- var instrumentFastify = generateInstrumentOnce(`${INTEGRATION_NAME21}.v5`, () => {
43906
+ var instrumentFastify = generateInstrumentOnce(`${INTEGRATION_NAME23}.v5`, () => {
43499
43907
  const fastifyOtelInstrumentationInstance = new FastifyOtelInstrumentation;
43500
43908
  const plugin = fastifyOtelInstrumentationInstance.plugin();
43501
43909
  dc.subscribe("fastify.initialization", (message) => {
@@ -43520,7 +43928,7 @@ var instrumentFastify = generateInstrumentOnce(`${INTEGRATION_NAME21}.v5`, () =>
43520
43928
  var _fastifyIntegration = ({ shouldHandleError }) => {
43521
43929
  let _shouldHandleError;
43522
43930
  return {
43523
- name: INTEGRATION_NAME21,
43931
+ name: INTEGRATION_NAME23,
43524
43932
  setupOnce() {
43525
43933
  _shouldHandleError = shouldHandleError || defaultShouldHandleError;
43526
43934
  instrumentFastifyV3();
@@ -43584,10 +43992,10 @@ function instrumentOnRequest(fastify) {
43584
43992
  }
43585
43993
 
43586
43994
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/graphql.js
43587
- var import_api13 = __toESM(require_src(), 1);
43995
+ var import_api14 = __toESM(require_src(), 1);
43588
43996
  var import_instrumentation_graphql = __toESM(require_src13(), 1);
43589
- var INTEGRATION_NAME22 = "Graphql";
43590
- var instrumentGraphql = generateInstrumentOnce(INTEGRATION_NAME22, import_instrumentation_graphql.GraphQLInstrumentation, (_options) => {
43997
+ var INTEGRATION_NAME24 = "Graphql";
43998
+ var instrumentGraphql = generateInstrumentOnce(INTEGRATION_NAME24, import_instrumentation_graphql.GraphQLInstrumentation, (_options) => {
43591
43999
  const options = getOptionsWithDefaults(_options);
43592
44000
  return {
43593
44001
  ...options,
@@ -43595,7 +44003,7 @@ var instrumentGraphql = generateInstrumentOnce(INTEGRATION_NAME22, import_instru
43595
44003
  addOriginToSpan2(span, "auto.graphql.otel.graphql");
43596
44004
  const resultWithMaybeError = result;
43597
44005
  if (resultWithMaybeError.errors?.length && !spanToJSON(span).status) {
43598
- span.setStatus({ code: import_api13.SpanStatusCode.ERROR });
44006
+ span.setStatus({ code: import_api14.SpanStatusCode.ERROR });
43599
44007
  }
43600
44008
  const attributes = spanToJSON(span).data;
43601
44009
  const operationType = attributes["graphql.operation.type"];
@@ -43623,7 +44031,7 @@ var instrumentGraphql = generateInstrumentOnce(INTEGRATION_NAME22, import_instru
43623
44031
  });
43624
44032
  var _graphqlIntegration = (options = {}) => {
43625
44033
  return {
43626
- name: INTEGRATION_NAME22,
44034
+ name: INTEGRATION_NAME24,
43627
44035
  setupOnce() {
43628
44036
  instrumentGraphql(getOptionsWithDefaults(options));
43629
44037
  }
@@ -43652,8 +44060,8 @@ function getGraphqlOperationNamesFromAttribute2(attr) {
43652
44060
 
43653
44061
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/kafka.js
43654
44062
  var import_instrumentation_kafkajs = __toESM(require_src14(), 1);
43655
- var INTEGRATION_NAME23 = "Kafka";
43656
- var instrumentKafka = generateInstrumentOnce(INTEGRATION_NAME23, () => new import_instrumentation_kafkajs.KafkaJsInstrumentation({
44063
+ var INTEGRATION_NAME25 = "Kafka";
44064
+ var instrumentKafka = generateInstrumentOnce(INTEGRATION_NAME25, () => new import_instrumentation_kafkajs.KafkaJsInstrumentation({
43657
44065
  consumerHook(span) {
43658
44066
  addOriginToSpan2(span, "auto.kafkajs.otel.consumer");
43659
44067
  },
@@ -43663,7 +44071,7 @@ var instrumentKafka = generateInstrumentOnce(INTEGRATION_NAME23, () => new impor
43663
44071
  }));
43664
44072
  var _kafkaIntegration = () => {
43665
44073
  return {
43666
- name: INTEGRATION_NAME23,
44074
+ name: INTEGRATION_NAME25,
43667
44075
  setupOnce() {
43668
44076
  instrumentKafka();
43669
44077
  }
@@ -43673,11 +44081,11 @@ var kafkaIntegration = defineIntegration(_kafkaIntegration);
43673
44081
 
43674
44082
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/lrumemoizer.js
43675
44083
  var import_instrumentation_lru_memoizer = __toESM(require_src15(), 1);
43676
- var INTEGRATION_NAME24 = "LruMemoizer";
43677
- var instrumentLruMemoizer = generateInstrumentOnce(INTEGRATION_NAME24, () => new import_instrumentation_lru_memoizer.LruMemoizerInstrumentation);
44084
+ var INTEGRATION_NAME26 = "LruMemoizer";
44085
+ var instrumentLruMemoizer = generateInstrumentOnce(INTEGRATION_NAME26, () => new import_instrumentation_lru_memoizer.LruMemoizerInstrumentation);
43678
44086
  var _lruMemoizerIntegration = () => {
43679
44087
  return {
43680
- name: INTEGRATION_NAME24,
44088
+ name: INTEGRATION_NAME26,
43681
44089
  setupOnce() {
43682
44090
  instrumentLruMemoizer();
43683
44091
  }
@@ -43687,8 +44095,8 @@ var lruMemoizerIntegration = defineIntegration(_lruMemoizerIntegration);
43687
44095
 
43688
44096
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/mongo.js
43689
44097
  var import_instrumentation_mongodb = __toESM(require_src16(), 1);
43690
- var INTEGRATION_NAME25 = "Mongo";
43691
- var instrumentMongo = generateInstrumentOnce(INTEGRATION_NAME25, () => new import_instrumentation_mongodb.MongoDBInstrumentation({
44098
+ var INTEGRATION_NAME27 = "Mongo";
44099
+ var instrumentMongo = generateInstrumentOnce(INTEGRATION_NAME27, () => new import_instrumentation_mongodb.MongoDBInstrumentation({
43692
44100
  dbStatementSerializer: _defaultDbStatementSerializer,
43693
44101
  responseHook(span) {
43694
44102
  addOriginToSpan2(span, "auto.db.otel.mongo");
@@ -43728,7 +44136,7 @@ function isCommandEntry(value) {
43728
44136
  }
43729
44137
  var _mongoIntegration = () => {
43730
44138
  return {
43731
- name: INTEGRATION_NAME25,
44139
+ name: INTEGRATION_NAME27,
43732
44140
  setupOnce() {
43733
44141
  instrumentMongo();
43734
44142
  }
@@ -43738,15 +44146,15 @@ var mongoIntegration = defineIntegration(_mongoIntegration);
43738
44146
 
43739
44147
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/mongoose.js
43740
44148
  var import_instrumentation_mongoose = __toESM(require_src17(), 1);
43741
- var INTEGRATION_NAME26 = "Mongoose";
43742
- var instrumentMongoose = generateInstrumentOnce(INTEGRATION_NAME26, () => new import_instrumentation_mongoose.MongooseInstrumentation({
44149
+ var INTEGRATION_NAME28 = "Mongoose";
44150
+ var instrumentMongoose = generateInstrumentOnce(INTEGRATION_NAME28, () => new import_instrumentation_mongoose.MongooseInstrumentation({
43743
44151
  responseHook(span) {
43744
44152
  addOriginToSpan2(span, "auto.db.otel.mongoose");
43745
44153
  }
43746
44154
  }));
43747
44155
  var _mongooseIntegration = () => {
43748
44156
  return {
43749
- name: INTEGRATION_NAME26,
44157
+ name: INTEGRATION_NAME28,
43750
44158
  setupOnce() {
43751
44159
  instrumentMongoose();
43752
44160
  }
@@ -43756,11 +44164,11 @@ var mongooseIntegration = defineIntegration(_mongooseIntegration);
43756
44164
 
43757
44165
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/mysql.js
43758
44166
  var import_instrumentation_mysql = __toESM(require_src18(), 1);
43759
- var INTEGRATION_NAME27 = "Mysql";
43760
- var instrumentMysql = generateInstrumentOnce(INTEGRATION_NAME27, () => new import_instrumentation_mysql.MySQLInstrumentation({}));
44167
+ var INTEGRATION_NAME29 = "Mysql";
44168
+ var instrumentMysql = generateInstrumentOnce(INTEGRATION_NAME29, () => new import_instrumentation_mysql.MySQLInstrumentation({}));
43761
44169
  var _mysqlIntegration = () => {
43762
44170
  return {
43763
- name: INTEGRATION_NAME27,
44171
+ name: INTEGRATION_NAME29,
43764
44172
  setupOnce() {
43765
44173
  instrumentMysql();
43766
44174
  }
@@ -43770,15 +44178,15 @@ var mysqlIntegration = defineIntegration(_mysqlIntegration);
43770
44178
 
43771
44179
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/mysql2.js
43772
44180
  var import_instrumentation_mysql2 = __toESM(require_src20(), 1);
43773
- var INTEGRATION_NAME28 = "Mysql2";
43774
- var instrumentMysql2 = generateInstrumentOnce(INTEGRATION_NAME28, () => new import_instrumentation_mysql2.MySQL2Instrumentation({
44181
+ var INTEGRATION_NAME30 = "Mysql2";
44182
+ var instrumentMysql2 = generateInstrumentOnce(INTEGRATION_NAME30, () => new import_instrumentation_mysql2.MySQL2Instrumentation({
43775
44183
  responseHook(span) {
43776
44184
  addOriginToSpan2(span, "auto.db.otel.mysql2");
43777
44185
  }
43778
44186
  }));
43779
44187
  var _mysql2Integration = () => {
43780
44188
  return {
43781
- name: INTEGRATION_NAME28,
44189
+ name: INTEGRATION_NAME30,
43782
44190
  setupOnce() {
43783
44191
  instrumentMysql2();
43784
44192
  }
@@ -43880,7 +44288,7 @@ function flatten(input) {
43880
44288
  }
43881
44289
 
43882
44290
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/redis.js
43883
- var INTEGRATION_NAME29 = "Redis";
44291
+ var INTEGRATION_NAME31 = "Redis";
43884
44292
  var _redisOptions = {};
43885
44293
  var cacheResponseHook = (span, redisCommand, cmdArgs, response) => {
43886
44294
  span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, "auto.db.otel.redis");
@@ -43908,12 +44316,12 @@ var cacheResponseHook = (span, redisCommand, cmdArgs, response) => {
43908
44316
  const spanDescription = safeKey.join(", ");
43909
44317
  span.updateName(truncate(spanDescription, 1024));
43910
44318
  };
43911
- var instrumentIORedis = generateInstrumentOnce(`${INTEGRATION_NAME29}.IORedis`, () => {
44319
+ var instrumentIORedis = generateInstrumentOnce(`${INTEGRATION_NAME31}.IORedis`, () => {
43912
44320
  return new import_instrumentation_ioredis.IORedisInstrumentation({
43913
44321
  responseHook: cacheResponseHook
43914
44322
  });
43915
44323
  });
43916
- var instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME29}.Redis`, () => {
44324
+ var instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME31}.Redis`, () => {
43917
44325
  return new import_instrumentation_redis.RedisInstrumentation({
43918
44326
  responseHook: cacheResponseHook
43919
44327
  });
@@ -43921,10 +44329,10 @@ var instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME29}.Redis`
43921
44329
  var instrumentRedis = Object.assign(() => {
43922
44330
  instrumentIORedis();
43923
44331
  instrumentRedisModule();
43924
- }, { id: INTEGRATION_NAME29 });
44332
+ }, { id: INTEGRATION_NAME31 });
43925
44333
  var _redisIntegration = (options = {}) => {
43926
44334
  return {
43927
- name: INTEGRATION_NAME29,
44335
+ name: INTEGRATION_NAME31,
43928
44336
  setupOnce() {
43929
44337
  _redisOptions = options;
43930
44338
  instrumentRedis();
@@ -43935,8 +44343,8 @@ var redisIntegration = defineIntegration(_redisIntegration);
43935
44343
 
43936
44344
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/postgres.js
43937
44345
  var import_instrumentation_pg = __toESM(require_src24(), 1);
43938
- var INTEGRATION_NAME30 = "Postgres";
43939
- var instrumentPostgres = generateInstrumentOnce(INTEGRATION_NAME30, () => new import_instrumentation_pg.PgInstrumentation({
44346
+ var INTEGRATION_NAME32 = "Postgres";
44347
+ var instrumentPostgres = generateInstrumentOnce(INTEGRATION_NAME32, () => new import_instrumentation_pg.PgInstrumentation({
43940
44348
  requireParentSpan: true,
43941
44349
  requestHook(span) {
43942
44350
  addOriginToSpan2(span, "auto.db.otel.postgres");
@@ -43944,7 +44352,7 @@ var instrumentPostgres = generateInstrumentOnce(INTEGRATION_NAME30, () => new im
43944
44352
  }));
43945
44353
  var _postgresIntegration = () => {
43946
44354
  return {
43947
- name: INTEGRATION_NAME30,
44355
+ name: INTEGRATION_NAME32,
43948
44356
  setupOnce() {
43949
44357
  instrumentPostgres();
43950
44358
  }
@@ -43953,12 +44361,12 @@ var _postgresIntegration = () => {
43953
44361
  var postgresIntegration = defineIntegration(_postgresIntegration);
43954
44362
 
43955
44363
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/postgresjs.js
43956
- var import_api14 = __toESM(require_src(), 1);
44364
+ var import_api15 = __toESM(require_src(), 1);
43957
44365
  var import_instrumentation8 = __toESM(require_src6(), 1);
43958
44366
  var import_semantic_conventions5 = __toESM(require_src2(), 1);
43959
- var INTEGRATION_NAME31 = "PostgresJs";
44367
+ var INTEGRATION_NAME33 = "PostgresJs";
43960
44368
  var SUPPORTED_VERSIONS2 = [">=3.0.0 <4"];
43961
- var instrumentPostgresJs = generateInstrumentOnce(INTEGRATION_NAME31, (options) => new PostgresJsInstrumentation({
44369
+ var instrumentPostgresJs = generateInstrumentOnce(INTEGRATION_NAME33, (options) => new PostgresJsInstrumentation({
43962
44370
  requireParentSpan: options?.requireParentSpan ?? true,
43963
44371
  requestHook: options?.requestHook
43964
44372
  }));
@@ -43977,7 +44385,7 @@ class PostgresJsInstrumentation extends import_instrumentation8.InstrumentationB
43977
44385
  }
43978
44386
  _shouldCreateSpans() {
43979
44387
  const config = this.getConfig();
43980
- const hasParentSpan = import_api14.trace.getSpan(import_api14.context.active()) !== undefined;
44388
+ const hasParentSpan = import_api15.trace.getSpan(import_api15.context.active()) !== undefined;
43981
44389
  return hasParentSpan || !config.requireParentSpan;
43982
44390
  }
43983
44391
  _patchReject(rejectTarget, span) {
@@ -44026,7 +44434,7 @@ class PostgresJsInstrumentation extends import_instrumentation8.InstrumentationB
44026
44434
  if (requestHook2) {
44027
44435
  import_instrumentation8.safeExecuteInTheMiddle(() => requestHook2(span, sanitizedSqlQuery, postgresConnectionContext), (error2) => {
44028
44436
  if (error2) {
44029
- debug.error(`Error in requestHook for ${INTEGRATION_NAME31} integration:`, error2);
44437
+ debug.error(`Error in requestHook for ${INTEGRATION_NAME33} integration:`, error2);
44030
44438
  }
44031
44439
  });
44032
44440
  }
@@ -44079,7 +44487,7 @@ class PostgresJsInstrumentation extends import_instrumentation8.InstrumentationB
44079
44487
  }
44080
44488
  var _postgresJsIntegration = () => {
44081
44489
  return {
44082
- name: INTEGRATION_NAME31,
44490
+ name: INTEGRATION_NAME33,
44083
44491
  setupOnce() {
44084
44492
  instrumentPostgresJs();
44085
44493
  }
@@ -44088,21 +44496,21 @@ var _postgresJsIntegration = () => {
44088
44496
  var postgresJsIntegration = defineIntegration(_postgresJsIntegration);
44089
44497
 
44090
44498
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/prisma.js
44091
- var import_api17 = __toESM(require_src(), 1);
44499
+ var import_api18 = __toESM(require_src(), 1);
44092
44500
 
44093
44501
  // ../../node_modules/@prisma/instrumentation/dist/index.mjs
44094
- var import_api15 = __toESM(require_src(), 1);
44095
- var import_instrumentation9 = __toESM(require_src26(), 1);
44096
44502
  var import_api16 = __toESM(require_src(), 1);
44503
+ var import_instrumentation9 = __toESM(require_src26(), 1);
44504
+ var import_api17 = __toESM(require_src(), 1);
44097
44505
  var showAllTraces = process.env.PRISMA_SHOW_ALL_TRACES === "true";
44098
44506
  var nonSampledTraceParent = `00-10-10-00`;
44099
44507
  function engineSpanKindToOtelSpanKind(engineSpanKind) {
44100
44508
  switch (engineSpanKind) {
44101
44509
  case "client":
44102
- return import_api16.SpanKind.CLIENT;
44510
+ return import_api17.SpanKind.CLIENT;
44103
44511
  case "internal":
44104
44512
  default:
44105
- return import_api16.SpanKind.INTERNAL;
44513
+ return import_api17.SpanKind.INTERNAL;
44106
44514
  }
44107
44515
  }
44108
44516
  var ActiveTracingHelper = class {
@@ -44115,8 +44523,8 @@ var ActiveTracingHelper = class {
44115
44523
  isEnabled() {
44116
44524
  return true;
44117
44525
  }
44118
- getTraceParent(context9) {
44119
- const span = import_api16.trace.getSpanContext(context9 ?? import_api16.context.active());
44526
+ getTraceParent(context10) {
44527
+ const span = import_api17.trace.getSpanContext(context10 ?? import_api17.context.active());
44120
44528
  if (span) {
44121
44529
  return `00-${span.traceId}-${span.spanId}-0${span.traceFlags}`;
44122
44530
  }
@@ -44131,7 +44539,7 @@ var ActiveTracingHelper = class {
44131
44539
  }
44132
44540
  }
44133
44541
  getActiveContext() {
44134
- return import_api16.context.active();
44542
+ return import_api17.context.active();
44135
44543
  }
44136
44544
  runInChildSpan(options, callback) {
44137
44545
  if (typeof options === "string") {
@@ -44141,16 +44549,16 @@ var ActiveTracingHelper = class {
44141
44549
  return callback();
44142
44550
  }
44143
44551
  const tracer = this.tracerProvider.getTracer("prisma");
44144
- const context9 = options.context ?? this.getActiveContext();
44552
+ const context10 = options.context ?? this.getActiveContext();
44145
44553
  const name = `prisma:client:${options.name}`;
44146
44554
  if (shouldIgnoreSpan2(name, this.ignoreSpanTypes)) {
44147
44555
  return callback();
44148
44556
  }
44149
44557
  if (options.active === false) {
44150
- const span = tracer.startSpan(name, options, context9);
44151
- return endSpan2(span, callback(span, context9));
44558
+ const span = tracer.startSpan(name, options, context10);
44559
+ return endSpan2(span, callback(span, context10));
44152
44560
  }
44153
- return tracer.startActiveSpan(name, options, (span) => endSpan2(span, callback(span, context9)));
44561
+ return tracer.startActiveSpan(name, options, (span) => endSpan2(span, callback(span, context10)));
44154
44562
  }
44155
44563
  };
44156
44564
  function dispatchEngineSpan(tracer, engineSpan, allSpans, linkIds, ignoreSpanTypes) {
@@ -44286,7 +44694,7 @@ var PrismaInstrumentation = class extends import_instrumentation9.Instrumentatio
44286
44694
  const config = this._config;
44287
44695
  const globalValue = {
44288
44696
  helper: new ActiveTracingHelper({
44289
- tracerProvider: this.tracerProvider ?? import_api15.trace.getTracerProvider(),
44697
+ tracerProvider: this.tracerProvider ?? import_api16.trace.getTracerProvider(),
44290
44698
  ignoreSpanTypes: config.ignoreSpanTypes ?? []
44291
44699
  })
44292
44700
  };
@@ -44303,7 +44711,7 @@ var PrismaInstrumentation = class extends import_instrumentation9.Instrumentatio
44303
44711
  };
44304
44712
 
44305
44713
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/prisma.js
44306
- var INTEGRATION_NAME32 = "Prisma";
44714
+ var INTEGRATION_NAME34 = "Prisma";
44307
44715
  function isPrismaV6TracingHelper(helper) {
44308
44716
  return !!helper && typeof helper === "object" && "dispatchEngineSpans" in helper;
44309
44717
  }
@@ -44322,7 +44730,7 @@ class SentryPrismaInteropInstrumentation extends PrismaInstrumentation {
44322
44730
  const prismaTracingHelper = getPrismaTracingHelper();
44323
44731
  if (isPrismaV6TracingHelper(prismaTracingHelper)) {
44324
44732
  prismaTracingHelper.createEngineSpan = (engineSpanEvent) => {
44325
- const tracer = import_api17.trace.getTracer("prismaV5Compatibility");
44733
+ const tracer = import_api18.trace.getTracer("prismaV5Compatibility");
44326
44734
  const initialIdGenerator = tracer._idGenerator;
44327
44735
  if (!initialIdGenerator) {
44328
44736
  consoleSandbox(() => {
@@ -44341,16 +44749,16 @@ class SentryPrismaInteropInstrumentation extends PrismaInstrumentation {
44341
44749
  context: {
44342
44750
  traceId: link.trace_id,
44343
44751
  spanId: link.span_id,
44344
- traceFlags: import_api17.TraceFlags.SAMPLED
44752
+ traceFlags: import_api18.TraceFlags.SAMPLED
44345
44753
  }
44346
44754
  };
44347
44755
  });
44348
- const ctx = import_api17.trace.setSpanContext(import_api17.context.active(), {
44756
+ const ctx = import_api18.trace.setSpanContext(import_api18.context.active(), {
44349
44757
  traceId,
44350
44758
  spanId: parentSpanId,
44351
- traceFlags: import_api17.TraceFlags.SAMPLED
44759
+ traceFlags: import_api18.TraceFlags.SAMPLED
44352
44760
  });
44353
- import_api17.context.with(ctx, () => {
44761
+ import_api18.context.with(ctx, () => {
44354
44762
  const temporaryIdGenerator = {
44355
44763
  generateTraceId: () => {
44356
44764
  return traceId;
@@ -44380,18 +44788,18 @@ class SentryPrismaInteropInstrumentation extends PrismaInstrumentation {
44380
44788
  function engineSpanKindToOTELSpanKind(engineSpanKind) {
44381
44789
  switch (engineSpanKind) {
44382
44790
  case "client":
44383
- return import_api17.SpanKind.CLIENT;
44791
+ return import_api18.SpanKind.CLIENT;
44384
44792
  case "internal":
44385
44793
  default:
44386
- return import_api17.SpanKind.INTERNAL;
44794
+ return import_api18.SpanKind.INTERNAL;
44387
44795
  }
44388
44796
  }
44389
- var instrumentPrisma = generateInstrumentOnce(INTEGRATION_NAME32, (_options) => {
44797
+ var instrumentPrisma = generateInstrumentOnce(INTEGRATION_NAME34, (_options) => {
44390
44798
  return new SentryPrismaInteropInstrumentation;
44391
44799
  });
44392
44800
  var prismaIntegration = defineIntegration((_options) => {
44393
44801
  return {
44394
- name: INTEGRATION_NAME32,
44802
+ name: INTEGRATION_NAME34,
44395
44803
  setupOnce() {
44396
44804
  instrumentPrisma();
44397
44805
  },
@@ -44417,11 +44825,11 @@ var prismaIntegration = defineIntegration((_options) => {
44417
44825
 
44418
44826
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/hapi/index.js
44419
44827
  var import_instrumentation_hapi = __toESM(require_src27(), 1);
44420
- var INTEGRATION_NAME33 = "Hapi";
44421
- var instrumentHapi = generateInstrumentOnce(INTEGRATION_NAME33, () => new import_instrumentation_hapi.HapiInstrumentation);
44828
+ var INTEGRATION_NAME35 = "Hapi";
44829
+ var instrumentHapi = generateInstrumentOnce(INTEGRATION_NAME35, () => new import_instrumentation_hapi.HapiInstrumentation);
44422
44830
  var _hapiIntegration = () => {
44423
44831
  return {
44424
- name: INTEGRATION_NAME33,
44832
+ name: INTEGRATION_NAME35,
44425
44833
  setupOnce() {
44426
44834
  instrumentHapi();
44427
44835
  }
@@ -44443,7 +44851,7 @@ var HonoTypes = {
44443
44851
  };
44444
44852
 
44445
44853
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/hono/instrumentation.js
44446
- var import_api18 = __toESM(require_src(), 1);
44854
+ var import_api19 = __toESM(require_src(), 1);
44447
44855
  var import_instrumentation11 = __toESM(require_src6(), 1);
44448
44856
  var PACKAGE_NAME3 = "@sentry/instrumentation-hono";
44449
44857
  var PACKAGE_VERSION3 = "0.0.1";
@@ -44539,7 +44947,7 @@ class HonoInstrumentation extends import_instrumentation11.InstrumentationBase {
44539
44947
  }
44540
44948
  const path8 = c.req.path;
44541
44949
  const span = instrumentation.tracer.startSpan(path8);
44542
- return import_api18.context.with(import_api18.trace.setSpan(import_api18.context.active(), span), () => {
44950
+ return import_api19.context.with(import_api19.trace.setSpan(import_api19.context.active(), span), () => {
44543
44951
  return instrumentation._safeExecute(() => {
44544
44952
  const result = handler.apply(this, [c, next]);
44545
44953
  if (isThenable(result)) {
@@ -44588,7 +44996,7 @@ class HonoInstrumentation extends import_instrumentation11.InstrumentationBase {
44588
44996
  _handleError(span, error2) {
44589
44997
  if (error2 instanceof Error) {
44590
44998
  span.setStatus({
44591
- code: import_api18.SpanStatusCode.ERROR,
44999
+ code: import_api19.SpanStatusCode.ERROR,
44592
45000
  message: error2.message
44593
45001
  });
44594
45002
  span.recordException(error2);
@@ -44597,7 +45005,7 @@ class HonoInstrumentation extends import_instrumentation11.InstrumentationBase {
44597
45005
  }
44598
45006
 
44599
45007
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/hono/index.js
44600
- var INTEGRATION_NAME34 = "Hono";
45008
+ var INTEGRATION_NAME36 = "Hono";
44601
45009
  function addHonoSpanAttributes(span) {
44602
45010
  const attributes = spanToJSON(span).data;
44603
45011
  const type = attributes[AttributeNames2.HONO_TYPE];
@@ -44622,14 +45030,14 @@ function addHonoSpanAttributes(span) {
44622
45030
  getIsolationScope().setTransactionName(`${method} ${route}`);
44623
45031
  }
44624
45032
  }
44625
- var instrumentHono = generateInstrumentOnce(INTEGRATION_NAME34, () => new HonoInstrumentation({
45033
+ var instrumentHono = generateInstrumentOnce(INTEGRATION_NAME36, () => new HonoInstrumentation({
44626
45034
  responseHook: (span) => {
44627
45035
  addHonoSpanAttributes(span);
44628
45036
  }
44629
45037
  }));
44630
45038
  var _honoIntegration = () => {
44631
45039
  return {
44632
- name: INTEGRATION_NAME34,
45040
+ name: INTEGRATION_NAME36,
44633
45041
  setupOnce() {
44634
45042
  instrumentHono();
44635
45043
  }
@@ -44640,8 +45048,8 @@ var honoIntegration = defineIntegration(_honoIntegration);
44640
45048
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/koa.js
44641
45049
  var import_instrumentation_koa = __toESM(require_src28(), 1);
44642
45050
  var import_semantic_conventions7 = __toESM(require_src2(), 1);
44643
- var INTEGRATION_NAME35 = "Koa";
44644
- var instrumentKoa = generateInstrumentOnce(INTEGRATION_NAME35, import_instrumentation_koa.KoaInstrumentation, (options = {}) => {
45051
+ var INTEGRATION_NAME37 = "Koa";
45052
+ var instrumentKoa = generateInstrumentOnce(INTEGRATION_NAME37, import_instrumentation_koa.KoaInstrumentation, (options = {}) => {
44645
45053
  return {
44646
45054
  ignoreLayersType: options.ignoreLayersType,
44647
45055
  requestHook(span, info) {
@@ -44669,7 +45077,7 @@ var instrumentKoa = generateInstrumentOnce(INTEGRATION_NAME35, import_instrument
44669
45077
  });
44670
45078
  var _koaIntegration = (options = {}) => {
44671
45079
  return {
44672
- name: INTEGRATION_NAME35,
45080
+ name: INTEGRATION_NAME37,
44673
45081
  setupOnce() {
44674
45082
  instrumentKoa(options);
44675
45083
  }
@@ -44679,11 +45087,11 @@ var koaIntegration = defineIntegration(_koaIntegration);
44679
45087
 
44680
45088
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/connect.js
44681
45089
  var import_instrumentation_connect = __toESM(require_src29(), 1);
44682
- var INTEGRATION_NAME36 = "Connect";
44683
- var instrumentConnect = generateInstrumentOnce(INTEGRATION_NAME36, () => new import_instrumentation_connect.ConnectInstrumentation);
45090
+ var INTEGRATION_NAME38 = "Connect";
45091
+ var instrumentConnect = generateInstrumentOnce(INTEGRATION_NAME38, () => new import_instrumentation_connect.ConnectInstrumentation);
44684
45092
  var _connectIntegration = () => {
44685
45093
  return {
44686
- name: INTEGRATION_NAME36,
45094
+ name: INTEGRATION_NAME38,
44687
45095
  setupOnce() {
44688
45096
  instrumentConnect();
44689
45097
  }
@@ -44701,12 +45109,12 @@ var TEDIUS_INSTRUMENTED_METHODS = new Set([
44701
45109
  "prepare",
44702
45110
  "execute"
44703
45111
  ]);
44704
- var INTEGRATION_NAME37 = "Tedious";
44705
- var instrumentTedious = generateInstrumentOnce(INTEGRATION_NAME37, () => new import_instrumentation_tedious.TediousInstrumentation({}));
45112
+ var INTEGRATION_NAME39 = "Tedious";
45113
+ var instrumentTedious = generateInstrumentOnce(INTEGRATION_NAME39, () => new import_instrumentation_tedious.TediousInstrumentation({}));
44706
45114
  var _tediousIntegration = () => {
44707
45115
  let instrumentationWrappedCallback;
44708
45116
  return {
44709
- name: INTEGRATION_NAME37,
45117
+ name: INTEGRATION_NAME39,
44710
45118
  setupOnce() {
44711
45119
  const instrumentation = instrumentTedious();
44712
45120
  instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);
@@ -44729,12 +45137,12 @@ var tediousIntegration = defineIntegration(_tediousIntegration);
44729
45137
 
44730
45138
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/genericPool.js
44731
45139
  var import_instrumentation_generic_pool = __toESM(require_src31(), 1);
44732
- var INTEGRATION_NAME38 = "GenericPool";
44733
- var instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME38, () => new import_instrumentation_generic_pool.GenericPoolInstrumentation({}));
45140
+ var INTEGRATION_NAME40 = "GenericPool";
45141
+ var instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME40, () => new import_instrumentation_generic_pool.GenericPoolInstrumentation({}));
44734
45142
  var _genericPoolIntegration = () => {
44735
45143
  let instrumentationWrappedCallback;
44736
45144
  return {
44737
- name: INTEGRATION_NAME38,
45145
+ name: INTEGRATION_NAME40,
44738
45146
  setupOnce() {
44739
45147
  const instrumentation = instrumentGenericPool();
44740
45148
  instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);
@@ -44755,7 +45163,7 @@ var genericPoolIntegration = defineIntegration(_genericPoolIntegration);
44755
45163
 
44756
45164
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/amqplib.js
44757
45165
  var import_instrumentation_amqplib = __toESM(require_src32(), 1);
44758
- var INTEGRATION_NAME39 = "Amqplib";
45166
+ var INTEGRATION_NAME41 = "Amqplib";
44759
45167
  var config = {
44760
45168
  consumeEndHook: (span) => {
44761
45169
  addOriginToSpan2(span, "auto.amqplib.otel.consumer");
@@ -44764,10 +45172,10 @@ var config = {
44764
45172
  addOriginToSpan2(span, "auto.amqplib.otel.publisher");
44765
45173
  }
44766
45174
  };
44767
- var instrumentAmqplib = generateInstrumentOnce(INTEGRATION_NAME39, () => new import_instrumentation_amqplib.AmqplibInstrumentation(config));
45175
+ var instrumentAmqplib = generateInstrumentOnce(INTEGRATION_NAME41, () => new import_instrumentation_amqplib.AmqplibInstrumentation(config));
44768
45176
  var _amqplibIntegration = () => {
44769
45177
  return {
44770
- name: INTEGRATION_NAME39,
45178
+ name: INTEGRATION_NAME41,
44771
45179
  setupOnce() {
44772
45180
  instrumentAmqplib();
44773
45181
  }
@@ -44776,7 +45184,7 @@ var _amqplibIntegration = () => {
44776
45184
  var amqplibIntegration = defineIntegration(_amqplibIntegration);
44777
45185
 
44778
45186
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/vercelai/constants.js
44779
- var INTEGRATION_NAME40 = "VercelAI";
45187
+ var INTEGRATION_NAME42 = "VercelAI";
44780
45188
 
44781
45189
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/vercelai/instrumentation.js
44782
45190
  var import_instrumentation13 = __toESM(require_src6(), 1);
@@ -44879,7 +45287,7 @@ class SentryVercelAiInstrumentation extends import_instrumentation13.Instrumenta
44879
45287
  const existingExperimentalTelemetry = args[0].experimental_telemetry || {};
44880
45288
  const isEnabled3 = existingExperimentalTelemetry.isEnabled;
44881
45289
  const client = getClient();
44882
- const integration = client?.getIntegrationByName(INTEGRATION_NAME40);
45290
+ const integration = client?.getIntegrationByName(INTEGRATION_NAME42);
44883
45291
  const integrationOptions = integration?.options;
44884
45292
  const shouldRecordInputsAndOutputs = integration ? Boolean(client?.getOptions().sendDefaultPii) : false;
44885
45293
  const { recordInputs, recordOutputs } = determineRecordingSettings(integrationOptions, existingExperimentalTelemetry, isEnabled3, shouldRecordInputsAndOutputs);
@@ -44915,7 +45323,7 @@ class SentryVercelAiInstrumentation extends import_instrumentation13.Instrumenta
44915
45323
  }
44916
45324
 
44917
45325
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/vercelai/index.js
44918
- var instrumentVercelAi = generateInstrumentOnce(INTEGRATION_NAME40, () => new SentryVercelAiInstrumentation({}));
45326
+ var instrumentVercelAi = generateInstrumentOnce(INTEGRATION_NAME42, () => new SentryVercelAiInstrumentation({}));
44919
45327
  function shouldForceIntegration(client) {
44920
45328
  const modules = client.getIntegrationByName("Modules");
44921
45329
  return !!modules?.getModules?.()?.ai;
@@ -44923,7 +45331,7 @@ function shouldForceIntegration(client) {
44923
45331
  var _vercelAIIntegration = (options = {}) => {
44924
45332
  let instrumentation;
44925
45333
  return {
44926
- name: INTEGRATION_NAME40,
45334
+ name: INTEGRATION_NAME42,
44927
45335
  options,
44928
45336
  setupOnce() {
44929
45337
  instrumentation = instrumentVercelAi();
@@ -45157,7 +45565,7 @@ var googleGenAIIntegration = defineIntegration(_googleGenAIIntegration);
45157
45565
  var import_instrumentation22 = __toESM(require_src6(), 1);
45158
45566
 
45159
45567
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/firebase/otel/patches/firestore.js
45160
- var import_api19 = __toESM(require_src(), 1);
45568
+ var import_api20 = __toESM(require_src(), 1);
45161
45569
  var import_instrumentation21 = __toESM(require_src6(), 1);
45162
45570
  var import_semantic_conventions8 = __toESM(require_src2(), 1);
45163
45571
  import * as net2 from "node:net";
@@ -45171,7 +45579,7 @@ function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config
45171
45579
  if (!error2) {
45172
45580
  return;
45173
45581
  }
45174
- import_api19.diag.error(error2?.message);
45582
+ import_api20.diag.error(error2?.message);
45175
45583
  }, true);
45176
45584
  };
45177
45585
  }
@@ -45248,7 +45656,7 @@ function patchSetDoc(tracer, firestoreSpanCreationHook) {
45248
45656
  };
45249
45657
  }
45250
45658
  function executeContextWithSpan(span, callback) {
45251
- return import_api19.context.with(import_api19.trace.setSpan(import_api19.context.active(), span), () => {
45659
+ return import_api20.context.with(import_api20.trace.setSpan(import_api20.context.active(), span), () => {
45252
45660
  return import_instrumentation21.safeExecuteInTheMiddle(() => {
45253
45661
  return callback();
45254
45662
  }, (err) => {
@@ -45260,7 +45668,7 @@ function executeContextWithSpan(span, callback) {
45260
45668
  });
45261
45669
  }
45262
45670
  function startDBSpan(tracer, spanName, reference) {
45263
- const span = tracer.startSpan(`${spanName} ${reference.path}`, { kind: import_api19.SpanKind.CLIENT });
45671
+ const span = tracer.startSpan(`${spanName} ${reference.path}`, { kind: import_api20.SpanKind.CLIENT });
45264
45672
  addAttributes(span, reference);
45265
45673
  span.setAttribute(import_semantic_conventions8.ATTR_DB_OPERATION_NAME, spanName);
45266
45674
  return span;
@@ -45342,17 +45750,17 @@ class FirebaseInstrumentation extends import_instrumentation22.InstrumentationBa
45342
45750
  }
45343
45751
 
45344
45752
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/firebase/firebase.js
45345
- var INTEGRATION_NAME41 = "Firebase";
45753
+ var INTEGRATION_NAME43 = "Firebase";
45346
45754
  var config2 = {
45347
45755
  firestoreSpanCreationHook: (span) => {
45348
45756
  addOriginToSpan2(span, "auto.firebase.otel.firestore");
45349
45757
  span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, "db.query");
45350
45758
  }
45351
45759
  };
45352
- var instrumentFirebase = generateInstrumentOnce(INTEGRATION_NAME41, () => new FirebaseInstrumentation(config2));
45760
+ var instrumentFirebase = generateInstrumentOnce(INTEGRATION_NAME43, () => new FirebaseInstrumentation(config2));
45353
45761
  var _firebaseIntegration = () => {
45354
45762
  return {
45355
- name: INTEGRATION_NAME41,
45763
+ name: INTEGRATION_NAME43,
45356
45764
  setupOnce() {
45357
45765
  instrumentFirebase();
45358
45766
  }
@@ -45392,7 +45800,7 @@ function getAutoPerformanceIntegrations() {
45392
45800
  }
45393
45801
 
45394
45802
  // ../../node_modules/@sentry/node/build/esm/sdk/initOtel.js
45395
- var import_api20 = __toESM(require_src(), 1);
45803
+ var import_api21 = __toESM(require_src(), 1);
45396
45804
  var import_resources = __toESM(require_src8(), 1);
45397
45805
  var import_sdk_trace_base2 = __toESM(require_src9(), 1);
45398
45806
  var import_semantic_conventions9 = __toESM(require_src2(), 1);
@@ -45420,9 +45828,9 @@ function setupOtel(client, options = {}) {
45420
45828
  ...options.spanProcessors || []
45421
45829
  ]
45422
45830
  });
45423
- import_api20.trace.setGlobalTracerProvider(provider);
45424
- import_api20.propagation.setGlobalPropagator(new SentryPropagator);
45425
- import_api20.context.setGlobalContextManager(new SentryContextManager);
45831
+ import_api21.trace.setGlobalTracerProvider(provider);
45832
+ import_api21.propagation.setGlobalPropagator(new SentryPropagator);
45833
+ import_api21.context.setGlobalContextManager(new SentryContextManager);
45426
45834
  return provider;
45427
45835
  }
45428
45836
  function _clampSpanProcessorTimeout(maxSpanWaitDuration) {
@@ -45469,277 +45877,9 @@ function _init2(options = {}, getDefaultIntegrationsImpl) {
45469
45877
  }
45470
45878
  // src/index.ts
45471
45879
  import sqlPlugin, { createDatabaseAdapter, DatabaseMigrationService } from "@elizaos/plugin-sql";
45472
-
45473
- // src/managers/PluginLoader.ts
45474
- import { logger as logger31 } from "@elizaos/core";
45475
-
45476
- // src/managers/PluginInstaller.ts
45477
- import { logger as logger30 } from "@elizaos/core";
45478
-
45479
- class PluginInstaller {
45480
- attempted = new Set;
45481
- async tryInstall(pluginName) {
45482
- try {
45483
- if (!this.isAllowed()) {
45484
- logger30.debug(`Auto-install disabled or not allowed in this environment. Skipping install for ${pluginName}.`);
45485
- return false;
45486
- }
45487
- if (this.attempted.has(pluginName)) {
45488
- logger30.debug(`Auto-install already attempted for ${pluginName}. Skipping.`);
45489
- return false;
45490
- }
45491
- this.attempted.add(pluginName);
45492
- try {
45493
- const check = Bun.spawn(["bun", "--version"], { stdout: "pipe", stderr: "pipe" });
45494
- const code = await check.exited;
45495
- if (code !== 0) {
45496
- logger30.warn(`Bun not available on PATH. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
45497
- return false;
45498
- }
45499
- } catch {
45500
- logger30.warn(`Bun not available on PATH. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
45501
- return false;
45502
- }
45503
- logger30.info(`Attempting to auto-install missing plugin: ${pluginName}`);
45504
- const install = Bun.spawn(["bun", "add", pluginName], {
45505
- cwd: process.cwd(),
45506
- env: process.env,
45507
- stdout: "inherit",
45508
- stderr: "inherit"
45509
- });
45510
- const exit = await install.exited;
45511
- if (exit === 0) {
45512
- logger30.info(`Successfully installed ${pluginName}. Retrying import...`);
45513
- return true;
45514
- }
45515
- logger30.error(`bun add ${pluginName} failed with exit code ${exit}. Please install manually.`);
45516
- return false;
45517
- } catch (e) {
45518
- const message = e instanceof Error ? e.message : String(e);
45519
- logger30.error(`Unexpected error during auto-install of ${pluginName}: ${message}`);
45520
- return false;
45521
- }
45522
- }
45523
- isAllowed() {
45524
- if (process.env.ELIZA_NO_AUTO_INSTALL === "true")
45525
- return false;
45526
- if (process.env.ELIZA_NO_PLUGIN_AUTO_INSTALL === "true")
45527
- return false;
45528
- if (process.env.CI === "true")
45529
- return false;
45530
- if (process.env.ELIZA_TEST_MODE === "true")
45531
- return false;
45532
- if (false)
45533
- ;
45534
- return true;
45535
- }
45536
- }
45537
- var pluginInstaller = new PluginInstaller;
45538
-
45539
- // src/managers/PluginLoader.ts
45540
- class PluginLoader {
45541
- isValidPluginShape(obj) {
45542
- if (!obj || typeof obj !== "object" || !obj.name) {
45543
- return false;
45544
- }
45545
- return !!(obj.init || obj.services || obj.providers || obj.actions || obj.evaluators || obj.description);
45546
- }
45547
- validatePlugin(plugin) {
45548
- const errors = [];
45549
- if (!plugin) {
45550
- errors.push("Plugin is null or undefined");
45551
- return { isValid: false, errors };
45552
- }
45553
- if (!plugin.name) {
45554
- errors.push("Plugin must have a name");
45555
- }
45556
- if (plugin.actions) {
45557
- if (!Array.isArray(plugin.actions)) {
45558
- errors.push("Plugin actions must be an array");
45559
- } else {
45560
- const invalidActions = plugin.actions.filter((a) => typeof a !== "object" || !a);
45561
- if (invalidActions.length > 0) {
45562
- errors.push("Plugin actions must be an array of action objects");
45563
- }
45564
- }
45565
- }
45566
- if (plugin.services) {
45567
- if (!Array.isArray(plugin.services)) {
45568
- errors.push("Plugin services must be an array");
45569
- } else {
45570
- const invalidServices = plugin.services.filter((s) => typeof s !== "function" && (typeof s !== "object" || !s));
45571
- if (invalidServices.length > 0) {
45572
- errors.push("Plugin services must be an array of service classes or objects");
45573
- }
45574
- }
45575
- }
45576
- if (plugin.providers && !Array.isArray(plugin.providers)) {
45577
- errors.push("Plugin providers must be an array");
45578
- }
45579
- if (plugin.evaluators && !Array.isArray(plugin.evaluators)) {
45580
- errors.push("Plugin evaluators must be an array");
45581
- }
45582
- return {
45583
- isValid: errors.length === 0,
45584
- errors
45585
- };
45586
- }
45587
- async loadAndPreparePlugin(pluginName) {
45588
- try {
45589
- let pluginModule;
45590
- try {
45591
- pluginModule = await import(pluginName);
45592
- } catch (error2) {
45593
- logger31.warn(`Failed to load plugin ${pluginName}: ${error2}`);
45594
- const attempted = await pluginInstaller.tryInstall(pluginName);
45595
- if (!attempted) {
45596
- return null;
45597
- }
45598
- try {
45599
- pluginModule = await import(pluginName);
45600
- } catch (secondError) {
45601
- logger31.error(`Auto-install attempted for ${pluginName} but import still failed: ${secondError}`);
45602
- return null;
45603
- }
45604
- }
45605
- if (!pluginModule) {
45606
- logger31.error(`Failed to load module for plugin ${pluginName}.`);
45607
- return null;
45608
- }
45609
- const expectedFunctionName = `${pluginName.replace(/^@elizaos\/plugin-/, "").replace(/^@elizaos\//, "").replace(/-./g, (match3) => match3[1].toUpperCase())}Plugin`;
45610
- const exportsToCheck = [
45611
- pluginModule[expectedFunctionName],
45612
- pluginModule.default,
45613
- ...Object.values(pluginModule)
45614
- ];
45615
- for (const potentialPlugin of exportsToCheck) {
45616
- if (this.isValidPluginShape(potentialPlugin)) {
45617
- return potentialPlugin;
45618
- }
45619
- if (typeof potentialPlugin === "function" && potentialPlugin.length === 0) {
45620
- try {
45621
- const produced = potentialPlugin();
45622
- if (this.isValidPluginShape(produced)) {
45623
- return produced;
45624
- }
45625
- } catch (err) {
45626
- logger31.debug(`Factory export threw for ${pluginName}: ${err}`);
45627
- }
45628
- }
45629
- }
45630
- logger31.warn(`Could not find a valid plugin export in ${pluginName}.`);
45631
- return null;
45632
- } catch (error2) {
45633
- logger31.error(`Error loading plugin ${pluginName}: ${error2}`);
45634
- return null;
45635
- }
45636
- }
45637
- resolvePluginDependencies(availablePlugins, isTestMode = false) {
45638
- const resolutionOrder = [];
45639
- const visited = new Set;
45640
- const visiting = new Set;
45641
- function visit2(pluginName) {
45642
- if (!availablePlugins.has(pluginName)) {
45643
- logger31.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
45644
- return;
45645
- }
45646
- if (visited.has(pluginName))
45647
- return;
45648
- if (visiting.has(pluginName)) {
45649
- logger31.error(`Circular dependency detected involving plugin: ${pluginName}`);
45650
- return;
45651
- }
45652
- visiting.add(pluginName);
45653
- const plugin = availablePlugins.get(pluginName);
45654
- if (plugin) {
45655
- const deps = [...plugin.dependencies || []];
45656
- if (isTestMode) {
45657
- deps.push(...plugin.testDependencies || []);
45658
- }
45659
- for (const dep of deps) {
45660
- visit2(dep);
45661
- }
45662
- }
45663
- visiting.delete(pluginName);
45664
- visited.add(pluginName);
45665
- resolutionOrder.push(pluginName);
45666
- }
45667
- for (const name of availablePlugins.keys()) {
45668
- if (!visited.has(name)) {
45669
- visit2(name);
45670
- }
45671
- }
45672
- const finalPlugins = resolutionOrder.map((name) => availablePlugins.get(name)).filter((p) => p);
45673
- logger31.info({ plugins: finalPlugins.map((p) => p.name) }, `Final plugins being loaded:`);
45674
- return finalPlugins;
45675
- }
45676
- }
45677
-
45678
- // src/managers/ConfigManager.ts
45679
- var import_dotenv2 = __toESM(require_main(), 1);
45680
- import * as fs6 from "node:fs";
45681
- import * as path8 from "node:path";
45682
-
45683
- class ConfigManager {
45684
- async loadEnvConfig() {
45685
- const envPath = this.findEnvFile();
45686
- if (envPath) {
45687
- import_dotenv2.default.config({ path: envPath });
45688
- }
45689
- return process.env;
45690
- }
45691
- findEnvFile() {
45692
- const possiblePaths = [
45693
- path8.join(process.cwd(), ".env"),
45694
- path8.join(process.cwd(), ".env.local")
45695
- ];
45696
- for (const envPath of possiblePaths) {
45697
- if (fs6.existsSync(envPath)) {
45698
- return envPath;
45699
- }
45700
- }
45701
- return null;
45702
- }
45703
- hasCharacterSecrets(character) {
45704
- return Boolean(character?.settings?.secrets && Object.keys(character.settings.secrets).length > 0);
45705
- }
45706
- ensureCharacterSettings(character) {
45707
- if (!character.settings) {
45708
- character.settings = {};
45709
- }
45710
- }
45711
- async loadLocalEnvSecrets() {
45712
- const envPath = this.findEnvFile();
45713
- if (!envPath)
45714
- return null;
45715
- try {
45716
- const buf = fs6.readFileSync(envPath);
45717
- return import_dotenv2.default.parse(buf);
45718
- } catch {
45719
- return null;
45720
- }
45721
- }
45722
- async setDefaultSecretsFromEnv(character) {
45723
- this.ensureCharacterSettings(character);
45724
- if (this.hasCharacterSecrets(character)) {
45725
- return false;
45726
- }
45727
- const envSecrets = await this.loadLocalEnvSecrets();
45728
- if (!envSecrets) {
45729
- return false;
45730
- }
45731
- if (!character.settings) {
45732
- character.settings = {};
45733
- }
45734
- character.settings.secrets = envSecrets;
45735
- return true;
45736
- }
45737
- }
45738
-
45739
- // src/index.ts
45740
45880
  import { encryptedCharacter, stringToUuid as stringToUuid2 } from "@elizaos/core";
45741
- import { existsSync as existsSync5 } from "node:fs";
45742
- var import_dotenv3 = __toESM(require_main(), 1);
45881
+ import { existsSync as existsSync4 } from "node:fs";
45882
+ var import_dotenv2 = __toESM(require_main(), 1);
45743
45883
  import { ElizaOS as ElizaOS3 } from "@elizaos/core";
45744
45884
  function expandTildePath(filepath) {
45745
45885
  if (!filepath) {
@@ -45749,19 +45889,19 @@ function expandTildePath(filepath) {
45749
45889
  if (filepath === "~") {
45750
45890
  return process.cwd();
45751
45891
  } else if (filepath.startsWith("~/")) {
45752
- return path9.join(process.cwd(), filepath.slice(2));
45892
+ return path8.join(process.cwd(), filepath.slice(2));
45753
45893
  } else if (filepath.startsWith("~~")) {
45754
45894
  return filepath;
45755
45895
  } else {
45756
- return path9.join(process.cwd(), filepath.slice(1));
45896
+ return path8.join(process.cwd(), filepath.slice(1));
45757
45897
  }
45758
45898
  }
45759
45899
  return filepath;
45760
45900
  }
45761
45901
  function resolvePgliteDir(dir, fallbackDir) {
45762
45902
  const envPath = resolveEnvFile();
45763
- if (existsSync5(envPath)) {
45764
- import_dotenv3.default.config({ path: envPath });
45903
+ if (existsSync4(envPath)) {
45904
+ import_dotenv2.default.config({ path: envPath });
45765
45905
  }
45766
45906
  if (dir) {
45767
45907
  const resolved2 = expandTildePath(dir);
@@ -45796,71 +45936,32 @@ class AgentServer {
45796
45936
  isWebUIEnabled = true;
45797
45937
  clientPath;
45798
45938
  elizaOS;
45799
- pluginLoader;
45800
- configManager;
45801
45939
  database;
45802
45940
  loadCharacterTryPath;
45803
45941
  jsonToCharacter;
45804
- async startAgents(characters, plugins = []) {
45805
- if (!this.elizaOS || !this.pluginLoader || !this.configManager) {
45942
+ async startAgents(agents, options) {
45943
+ if (!this.elizaOS) {
45806
45944
  throw new Error("Server not properly initialized");
45807
45945
  }
45808
- const preparations = await Promise.all(characters.map(async (character) => {
45809
- character.id ??= stringToUuid2(character.name);
45810
- if (!this.configManager?.hasCharacterSecrets(character)) {
45811
- await this.configManager?.setDefaultSecretsFromEnv(character);
45812
- }
45813
- const loadedPlugins = new Map;
45814
- const pluginsToLoad = new Set(character.plugins || []);
45815
- for (const p of plugins) {
45816
- if (typeof p === "string") {
45817
- pluginsToLoad.add(p);
45818
- } else if (this.pluginLoader?.isValidPluginShape(p) && !loadedPlugins.has(p.name)) {
45819
- loadedPlugins.set(p.name, p);
45820
- (p.dependencies || []).forEach((dep) => {
45821
- pluginsToLoad.add(dep);
45822
- });
45823
- }
45824
- }
45825
- const allAvailablePlugins = new Map;
45826
- for (const p of loadedPlugins.values()) {
45827
- allAvailablePlugins.set(p.name, p);
45828
- }
45829
- for (const name of pluginsToLoad) {
45830
- if (!allAvailablePlugins.has(name)) {
45831
- const loaded = await this.pluginLoader?.loadAndPreparePlugin(name);
45832
- if (loaded) {
45833
- allAvailablePlugins.set(loaded.name, loaded);
45834
- }
45835
- }
45836
- }
45837
- let haveSql = false;
45838
- for (const [name] of allAvailablePlugins.entries()) {
45839
- if (name === sqlPlugin.name || name === "mysql") {
45840
- haveSql = true;
45841
- break;
45842
- }
45843
- }
45844
- if (!haveSql) {
45845
- allAvailablePlugins.set(sqlPlugin.name, sqlPlugin);
45846
- }
45847
- allAvailablePlugins.set(messageBusConnectorPlugin.name, messageBusConnectorPlugin);
45848
- const finalPlugins = this.pluginLoader?.resolvePluginDependencies(allAvailablePlugins, false);
45849
- const preparedCharacter = encryptedCharacter(character);
45850
- return { character: preparedCharacter, plugins: finalPlugins };
45851
- }));
45852
- const settings = await this.configManager?.loadEnvConfig();
45853
- const agentIds = await this.elizaOS.addAgents(preparations.map((p) => ({
45854
- character: p.character,
45855
- plugins: p.plugins,
45856
- settings: settings || {}
45857
- })));
45946
+ const agentConfigs = agents.map((agent) => {
45947
+ agent.character.id ??= stringToUuid2(agent.character.name);
45948
+ const allPlugins = [
45949
+ ...agent.character.plugins || [],
45950
+ ...agent.plugins || [],
45951
+ sqlPlugin
45952
+ ];
45953
+ return {
45954
+ character: encryptedCharacter(agent.character),
45955
+ plugins: allPlugins,
45956
+ init: agent.init
45957
+ };
45958
+ });
45959
+ const agentIds = await this.elizaOS.addAgents(agentConfigs, options);
45858
45960
  await this.elizaOS.startAgents(agentIds);
45859
45961
  const runtimes = [];
45860
45962
  for (const id of agentIds) {
45861
45963
  const runtime = this.elizaOS.getAgent(id);
45862
45964
  if (runtime) {
45863
- await this.registerAgent(runtime);
45864
45965
  if (this.database) {
45865
45966
  try {
45866
45967
  const existingAgent = await this.database.getAgent(runtime.agentId);
@@ -45869,12 +45970,13 @@ class AgentServer {
45869
45970
  ...runtime.character,
45870
45971
  id: runtime.agentId
45871
45972
  });
45872
- logger32.info(`Persisted agent ${runtime.character.name} (${runtime.agentId}) to database`);
45973
+ logger30.info(`Persisted agent ${runtime.character.name} (${runtime.agentId}) to database`);
45873
45974
  }
45874
45975
  } catch (error2) {
45875
- logger32.error({ error: error2 }, `Failed to persist agent ${runtime.agentId} to database`);
45976
+ logger30.error({ error: error2 }, `Failed to persist agent ${runtime.agentId} to database`);
45876
45977
  }
45877
45978
  }
45979
+ await this.registerAgent(runtime);
45878
45980
  runtimes.push(runtime);
45879
45981
  }
45880
45982
  }
@@ -45900,126 +46002,124 @@ class AgentServer {
45900
46002
  }
45901
46003
  constructor() {
45902
46004
  try {
45903
- logger32.debug("Initializing AgentServer (constructor)...");
46005
+ logger30.debug("Initializing AgentServer (constructor)...");
45904
46006
  this.loadCharacterTryPath = loadCharacterTryPath;
45905
46007
  this.jsonToCharacter = jsonToCharacter;
45906
46008
  this.registerSignalHandlers();
45907
46009
  } catch (error2) {
45908
- logger32.error({ error: error2 }, "Failed to initialize AgentServer (constructor):");
46010
+ logger30.error({ error: error2 }, "Failed to initialize AgentServer (constructor):");
45909
46011
  throw error2;
45910
46012
  }
45911
46013
  }
45912
- async initialize(options) {
46014
+ async initialize(config3) {
45913
46015
  if (this.isInitialized) {
45914
- logger32.warn("AgentServer is already initialized, skipping initialization");
46016
+ logger30.warn("AgentServer is already initialized, skipping initialization");
45915
46017
  return;
45916
46018
  }
45917
46019
  try {
45918
- logger32.debug("Initializing AgentServer (async operations)...");
45919
- const agentDataDir = resolvePgliteDir(options?.dataDir);
45920
- logger32.info(`[INIT] Database Dir for SQL plugin: ${agentDataDir}`);
45921
- const dbDir = path9.dirname(agentDataDir);
45922
- if (!fs7.existsSync(dbDir)) {
45923
- fs7.mkdirSync(dbDir, { recursive: true });
45924
- logger32.info(`[INIT] Created database directory: ${dbDir}`);
46020
+ logger30.debug("Initializing AgentServer (async operations)...");
46021
+ const agentDataDir = resolvePgliteDir(config3?.dataDir);
46022
+ logger30.info(`[INIT] Database Dir for SQL plugin: ${agentDataDir}`);
46023
+ const dbDir = path8.dirname(agentDataDir);
46024
+ if (!fs6.existsSync(dbDir)) {
46025
+ fs6.mkdirSync(dbDir, { recursive: true });
46026
+ logger30.info(`[INIT] Created database directory: ${dbDir}`);
45925
46027
  }
45926
46028
  const tempServerAgentId = "00000000-0000-0000-0000-000000000000";
45927
46029
  this.database = createDatabaseAdapter({
45928
46030
  dataDir: agentDataDir,
45929
- postgresUrl: options?.postgresUrl
46031
+ postgresUrl: config3?.postgresUrl
45930
46032
  }, tempServerAgentId);
45931
46033
  await this.database.init();
45932
- logger32.success("Database initialized for server operations");
45933
- logger32.info("[INIT] Running database migrations for messaging tables...");
46034
+ logger30.success("Database initialized for server operations");
46035
+ logger30.info("[INIT] Running database migrations for messaging tables...");
45934
46036
  try {
45935
46037
  const migrationService = new DatabaseMigrationService;
45936
46038
  const db = this.database.getDatabase();
45937
46039
  await migrationService.initializeWithDatabase(db);
45938
46040
  migrationService.discoverAndRegisterPluginSchemas([sqlPlugin]);
45939
46041
  await migrationService.runAllPluginMigrations();
45940
- logger32.success("[INIT] Database migrations completed successfully");
46042
+ logger30.success("[INIT] Database migrations completed successfully");
45941
46043
  } catch (migrationError) {
45942
- logger32.error({ error: migrationError }, "[INIT] Failed to run database migrations:");
46044
+ logger30.error({ error: migrationError }, "[INIT] Failed to run database migrations:");
45943
46045
  throw new Error(`Database migration failed: ${migrationError instanceof Error ? migrationError.message : String(migrationError)}`);
45944
46046
  }
45945
46047
  await new Promise((resolve2) => setTimeout(resolve2, 500));
45946
- logger32.info("[INIT] Ensuring default server exists...");
46048
+ logger30.info("[INIT] Ensuring default server exists...");
45947
46049
  await this.ensureDefaultServer();
45948
- logger32.success("[INIT] Default server setup complete");
45949
- logger32.info("[INIT] Server uses temporary adapter for migrations only");
45950
- logger32.info("[INIT] Initializing ElizaOS...");
45951
- logger32.debug("[INIT] ElizaOS will use agent-specific database adapters from SQL plugin");
46050
+ logger30.success("[INIT] Default server setup complete");
46051
+ logger30.info("[INIT] Server uses temporary adapter for migrations only");
46052
+ logger30.info("[INIT] Initializing ElizaOS...");
46053
+ logger30.debug("[INIT] ElizaOS will use agent-specific database adapters from SQL plugin");
45952
46054
  this.elizaOS = new ElizaOS2;
45953
46055
  this.elizaOS.enableEditableMode();
45954
- this.pluginLoader = new PluginLoader;
45955
- this.configManager = new ConfigManager;
45956
- logger32.success("[INIT] ElizaOS initialized");
45957
- await this.initializeServer(options);
46056
+ logger30.success("[INIT] ElizaOS initialized");
46057
+ await this.initializeServer(config3);
45958
46058
  await new Promise((resolve2) => setTimeout(resolve2, 250));
45959
46059
  this.isInitialized = true;
45960
46060
  } catch (error2) {
45961
- logger32.error({ error: error2 }, "Failed to initialize AgentServer (async operations):");
46061
+ logger30.error({ error: error2 }, "Failed to initialize AgentServer (async operations):");
45962
46062
  console.trace(error2);
45963
46063
  throw error2;
45964
46064
  }
45965
46065
  }
45966
46066
  async ensureDefaultServer() {
45967
46067
  try {
45968
- logger32.info("[AgentServer] Checking for default server...");
46068
+ logger30.info("[AgentServer] Checking for default server...");
45969
46069
  const servers = await this.database.getMessageServers();
45970
- logger32.debug(`[AgentServer] Found ${servers.length} existing servers`);
46070
+ logger30.debug(`[AgentServer] Found ${servers.length} existing servers`);
45971
46071
  servers.forEach((s) => {
45972
- logger32.debug(`[AgentServer] Existing server: ID=${s.id}, Name=${s.name}`);
46072
+ logger30.debug(`[AgentServer] Existing server: ID=${s.id}, Name=${s.name}`);
45973
46073
  });
45974
46074
  const defaultServer = servers.find((s) => s.id === "00000000-0000-0000-0000-000000000000");
45975
46075
  if (!defaultServer) {
45976
- logger32.info("[AgentServer] Creating default server with UUID 00000000-0000-0000-0000-000000000000...");
46076
+ logger30.info("[AgentServer] Creating default server with UUID 00000000-0000-0000-0000-000000000000...");
45977
46077
  try {
45978
46078
  await this.database.db.execute(`
45979
46079
  INSERT INTO message_servers (id, name, source_type, created_at, updated_at)
45980
46080
  VALUES ('00000000-0000-0000-0000-000000000000', 'Default Server', 'eliza_default', NOW(), NOW())
45981
46081
  ON CONFLICT (id) DO NOTHING
45982
46082
  `);
45983
- logger32.success("[AgentServer] Default server created via raw SQL");
46083
+ logger30.success("[AgentServer] Default server created via raw SQL");
45984
46084
  const checkResult = await this.database.db.execute("SELECT id, name FROM message_servers WHERE id = '00000000-0000-0000-0000-000000000000'");
45985
- logger32.debug("[AgentServer] Raw SQL check result:", checkResult);
46085
+ logger30.debug("[AgentServer] Raw SQL check result:", checkResult);
45986
46086
  } catch (sqlError) {
45987
- logger32.error("[AgentServer] Raw SQL insert failed:", sqlError);
46087
+ logger30.error("[AgentServer] Raw SQL insert failed:", sqlError);
45988
46088
  try {
45989
46089
  const server = await this.database.createMessageServer({
45990
46090
  id: "00000000-0000-0000-0000-000000000000",
45991
46091
  name: "Default Server",
45992
46092
  sourceType: "eliza_default"
45993
46093
  });
45994
- logger32.success("[AgentServer] Default server created via ORM with ID:", server.id);
46094
+ logger30.success("[AgentServer] Default server created via ORM with ID:", server.id);
45995
46095
  } catch (ormError) {
45996
- logger32.error("[AgentServer] Both SQL and ORM creation failed:", ormError);
46096
+ logger30.error("[AgentServer] Both SQL and ORM creation failed:", ormError);
45997
46097
  throw new Error(`Failed to create default server: ${ormError.message}`);
45998
46098
  }
45999
46099
  }
46000
46100
  const verifyServers = await this.database.getMessageServers();
46001
- logger32.debug(`[AgentServer] After creation attempt, found ${verifyServers.length} servers`);
46101
+ logger30.debug(`[AgentServer] After creation attempt, found ${verifyServers.length} servers`);
46002
46102
  verifyServers.forEach((s) => {
46003
- logger32.debug(`[AgentServer] Server after creation: ID=${s.id}, Name=${s.name}`);
46103
+ logger30.debug(`[AgentServer] Server after creation: ID=${s.id}, Name=${s.name}`);
46004
46104
  });
46005
46105
  const verifyDefault = verifyServers.find((s) => s.id === "00000000-0000-0000-0000-000000000000");
46006
46106
  if (!verifyDefault) {
46007
46107
  throw new Error(`Failed to create or verify default server with ID ${DEFAULT_SERVER_ID6}`);
46008
46108
  } else {
46009
- logger32.success("[AgentServer] Default server creation verified successfully");
46109
+ logger30.success("[AgentServer] Default server creation verified successfully");
46010
46110
  }
46011
46111
  } else {
46012
- logger32.info("[AgentServer] Default server already exists with ID:", defaultServer.id);
46112
+ logger30.info("[AgentServer] Default server already exists with ID:", defaultServer.id);
46013
46113
  }
46014
46114
  } catch (error2) {
46015
- logger32.error({ error: error2 }, "[AgentServer] Error ensuring default server:");
46115
+ logger30.error({ error: error2 }, "[AgentServer] Error ensuring default server:");
46016
46116
  throw error2;
46017
46117
  }
46018
46118
  }
46019
- async initializeServer(options) {
46119
+ async initializeServer(config3) {
46020
46120
  try {
46021
- if (options?.clientPath) {
46022
- this.clientPath = options.clientPath;
46121
+ if (config3?.clientPath) {
46122
+ this.clientPath = config3.clientPath;
46023
46123
  }
46024
46124
  this.app = express33();
46025
46125
  const DEFAULT_SENTRY_DSN = "https://c20e2d51b66c14a783b0689d536f7e5c@o4509349865259008.ingest.us.sentry.io/4509352524120064";
@@ -46033,16 +46133,16 @@ class AgentServer {
46033
46133
  integrations: [vercelAIIntegration({ force: sentryEnabled })],
46034
46134
  tracesSampleRate: Number(process.env.SENTRY_TRACES_SAMPLE_RATE || 0)
46035
46135
  });
46036
- logger32.info("[Sentry] Initialized Sentry for @elizaos/server");
46136
+ logger30.info("[Sentry] Initialized Sentry for @elizaos/server");
46037
46137
  } catch (sentryInitError) {
46038
- logger32.error({ error: sentryInitError }, "[Sentry] Failed to initialize Sentry");
46138
+ logger30.error({ error: sentryInitError }, "[Sentry] Failed to initialize Sentry");
46039
46139
  }
46040
46140
  }
46041
46141
  const isProd = false;
46042
- logger32.debug("Setting up security headers...");
46142
+ logger30.debug("Setting up security headers...");
46043
46143
  if (!isProd) {
46044
- logger32.debug(`NODE_ENV: ${"development"}`);
46045
- logger32.debug(`CSP will be: ${isProd ? "ENABLED" : "MINIMAL_DEV"}`);
46144
+ logger30.debug(`NODE_ENV: ${"development"}`);
46145
+ logger30.debug(`CSP will be: ${isProd ? "ENABLED" : "MINIMAL_DEV"}`);
46046
46146
  }
46047
46147
  this.app.use(helmet({
46048
46148
  contentSecurityPolicy: isProd ? {
@@ -46089,13 +46189,13 @@ class AgentServer {
46089
46189
  referrerPolicy: { policy: "no-referrer-when-downgrade" },
46090
46190
  xssFilter: true
46091
46191
  }));
46092
- if (options?.middlewares) {
46093
- logger32.debug("Applying custom middlewares...");
46094
- for (const middleware2 of options.middlewares) {
46192
+ if (config3?.middlewares) {
46193
+ logger30.debug("Applying custom middlewares...");
46194
+ for (const middleware2 of config3.middlewares) {
46095
46195
  this.app.use(middleware2);
46096
46196
  }
46097
46197
  }
46098
- logger32.debug("Setting up standard middlewares...");
46198
+ logger30.debug("Setting up standard middlewares...");
46099
46199
  this.app.use(cors2({
46100
46200
  origin: process.env.CORS_ORIGIN || true,
46101
46201
  credentials: true,
@@ -46107,28 +46207,28 @@ class AgentServer {
46107
46207
  }));
46108
46208
  const serverAuthToken = process.env.ELIZA_SERVER_AUTH_TOKEN;
46109
46209
  if (serverAuthToken) {
46110
- logger32.info("Server authentication enabled. Requires X-API-KEY header for /api routes.");
46210
+ logger30.info("Server authentication enabled. Requires X-API-KEY header for /api routes.");
46111
46211
  this.app.use("/api", (req, res, next) => {
46112
46212
  apiKeyAuthMiddleware(req, res, next);
46113
46213
  });
46114
46214
  } else {
46115
- logger32.warn("Server authentication is disabled. Set ELIZA_SERVER_AUTH_TOKEN environment variable to enable.");
46215
+ logger30.warn("Server authentication is disabled. Set ELIZA_SERVER_AUTH_TOKEN environment variable to enable.");
46116
46216
  }
46117
46217
  this.isWebUIEnabled = isWebUIEnabled();
46118
46218
  if (this.isWebUIEnabled) {
46119
- logger32.info("Web UI enabled");
46219
+ logger30.info("Web UI enabled");
46120
46220
  } else {
46121
46221
  const uiEnabledEnv = process.env.ELIZA_UI_ENABLE;
46122
46222
  if (uiEnabledEnv !== undefined && uiEnabledEnv.trim() !== "") {
46123
- logger32.info(`Web UI disabled by environment variable (ELIZA_UI_ENABLE=${uiEnabledEnv})`);
46223
+ logger30.info(`Web UI disabled by environment variable (ELIZA_UI_ENABLE=${uiEnabledEnv})`);
46124
46224
  } else {
46125
- logger32.info("Web UI disabled for security (production mode)");
46225
+ logger30.info("Web UI disabled for security (production mode)");
46126
46226
  }
46127
46227
  }
46128
46228
  const uploadsBasePath = getUploadsAgentsDir4();
46129
46229
  const generatedBasePath = getGeneratedDir2();
46130
- fs7.mkdirSync(uploadsBasePath, { recursive: true });
46131
- fs7.mkdirSync(generatedBasePath, { recursive: true });
46230
+ fs6.mkdirSync(uploadsBasePath, { recursive: true });
46231
+ fs6.mkdirSync(generatedBasePath, { recursive: true });
46132
46232
  this.app.get("/media/uploads/agents/:agentId/:filename", (req, res) => {
46133
46233
  const agentId = req.params.agentId;
46134
46234
  const filename = req.params.filename;
@@ -46138,26 +46238,26 @@ class AgentServer {
46138
46238
  return;
46139
46239
  }
46140
46240
  const sanitizedFilename = basename2(filename);
46141
- const agentUploadsPath = join5(uploadsBasePath, agentId);
46142
- const filePath = join5(agentUploadsPath, sanitizedFilename);
46241
+ const agentUploadsPath = join4(uploadsBasePath, agentId);
46242
+ const filePath = join4(agentUploadsPath, sanitizedFilename);
46143
46243
  if (!filePath.startsWith(agentUploadsPath)) {
46144
46244
  res.status(403).json({ error: "Access denied" });
46145
46245
  return;
46146
46246
  }
46147
- if (!fs7.existsSync(filePath)) {
46247
+ if (!fs6.existsSync(filePath)) {
46148
46248
  res.status(404).json({ error: "File does not exist!!!!!!!" });
46149
46249
  return;
46150
46250
  }
46151
46251
  res.sendFile(sanitizedFilename, { root: agentUploadsPath }, (err) => {
46152
46252
  if (err) {
46153
46253
  if (err.message === "Request aborted") {
46154
- logger32.warn(`[MEDIA] Download aborted: ${req.originalUrl}`);
46254
+ logger30.warn(`[MEDIA] Download aborted: ${req.originalUrl}`);
46155
46255
  } else if (!res.headersSent) {
46156
- logger32.warn(`[MEDIA] File not found: ${agentUploadsPath}/${sanitizedFilename}`);
46256
+ logger30.warn(`[MEDIA] File not found: ${agentUploadsPath}/${sanitizedFilename}`);
46157
46257
  res.status(404).json({ error: "File not found" });
46158
46258
  }
46159
46259
  } else {
46160
- logger32.debug(`[MEDIA] Successfully served: ${sanitizedFilename}`);
46260
+ logger30.debug(`[MEDIA] Successfully served: ${sanitizedFilename}`);
46161
46261
  }
46162
46262
  });
46163
46263
  });
@@ -46170,26 +46270,26 @@ class AgentServer {
46170
46270
  return;
46171
46271
  }
46172
46272
  const sanitizedFilename = basename2(filename);
46173
- const agentGeneratedPath = join5(generatedBasePath, agentId);
46174
- const filePath = join5(agentGeneratedPath, sanitizedFilename);
46273
+ const agentGeneratedPath = join4(generatedBasePath, agentId);
46274
+ const filePath = join4(agentGeneratedPath, sanitizedFilename);
46175
46275
  if (!filePath.startsWith(agentGeneratedPath)) {
46176
46276
  res.status(403).json({ error: "Access denied" });
46177
46277
  return;
46178
46278
  }
46179
- if (!existsSync5(filePath)) {
46279
+ if (!existsSync4(filePath)) {
46180
46280
  res.status(404).json({ error: "File not found" });
46181
46281
  return;
46182
46282
  }
46183
- const absolutePath = path9.resolve(filePath);
46184
- const options2 = {
46283
+ const absolutePath = path8.resolve(filePath);
46284
+ const options = {
46185
46285
  dotfiles: "deny"
46186
46286
  };
46187
- res.sendFile(absolutePath, options2, (err) => {
46287
+ res.sendFile(absolutePath, options, (err) => {
46188
46288
  if (err) {
46189
46289
  const ext2 = extname(filename).toLowerCase();
46190
46290
  const mimeType = ext2 === ".png" ? "image/png" : ext2 === ".jpg" || ext2 === ".jpeg" ? "image/jpeg" : "application/octet-stream";
46191
46291
  res.setHeader("Content-Type", mimeType);
46192
- const stream = fs7.createReadStream(absolutePath);
46292
+ const stream = fs6.createReadStream(absolutePath);
46193
46293
  stream.on("error", () => res.status(404).json({ error: "File not found" }));
46194
46294
  stream.pipe(res);
46195
46295
  }
@@ -46204,20 +46304,20 @@ class AgentServer {
46204
46304
  return;
46205
46305
  }
46206
46306
  const sanitizedFilename = basename2(filename);
46207
- const channelUploadsPath = join5(uploadsBasePath, "channels", channelId);
46208
- const filePath = join5(channelUploadsPath, sanitizedFilename);
46307
+ const channelUploadsPath = join4(uploadsBasePath, "channels", channelId);
46308
+ const filePath = join4(channelUploadsPath, sanitizedFilename);
46209
46309
  if (!filePath.startsWith(channelUploadsPath)) {
46210
46310
  res.status(403).json({ error: "Access denied" });
46211
46311
  return;
46212
46312
  }
46213
46313
  res.sendFile(filePath, (err) => {
46214
46314
  if (err) {
46215
- logger32.warn({ err, filePath }, `[STATIC] Channel media file not found: ${filePath}`);
46315
+ logger30.warn({ err, filePath }, `[STATIC] Channel media file not found: ${filePath}`);
46216
46316
  if (!res.headersSent) {
46217
46317
  res.status(404).json({ error: "File not found" });
46218
46318
  }
46219
46319
  } else {
46220
- logger32.debug(`[STATIC] Served channel media file: ${filePath}`);
46320
+ logger30.debug(`[STATIC] Served channel media file: ${filePath}`);
46221
46321
  }
46222
46322
  });
46223
46323
  });
@@ -46261,11 +46361,11 @@ class AgentServer {
46261
46361
  if (this.isWebUIEnabled) {
46262
46362
  const possiblePaths = [
46263
46363
  this.clientPath,
46264
- path9.resolve(__dirname3, "client"),
46265
- path9.resolve(__dirname3, "../../client/dist"),
46364
+ path8.resolve(__dirname3, "client"),
46365
+ path8.resolve(__dirname3, "../../client/dist"),
46266
46366
  (() => {
46267
46367
  try {
46268
- return path9.resolve(path9.dirname(__require.resolve("@elizaos/client/package.json")), "dist");
46368
+ return path8.resolve(path8.dirname(__require.resolve("@elizaos/client/package.json")), "dist");
46269
46369
  } catch {
46270
46370
  return null;
46271
46371
  }
@@ -46273,12 +46373,12 @@ class AgentServer {
46273
46373
  (() => {
46274
46374
  try {
46275
46375
  if (process.argv[1]) {
46276
- const serverPath = path9.dirname(process.argv[1]);
46277
- const possibleClientPath = path9.join(serverPath, "client");
46278
- if (existsSync5(path9.join(possibleClientPath, "index.html"))) {
46376
+ const serverPath = path8.dirname(process.argv[1]);
46377
+ const possibleClientPath = path8.join(serverPath, "client");
46378
+ if (existsSync4(path8.join(possibleClientPath, "index.html"))) {
46279
46379
  return possibleClientPath;
46280
46380
  }
46281
- if (existsSync5(path9.join(serverPath, "index.html"))) {
46381
+ if (existsSync4(path8.join(serverPath, "index.html"))) {
46282
46382
  return serverPath;
46283
46383
  }
46284
46384
  }
@@ -46287,8 +46387,8 @@ class AgentServer {
46287
46387
  })(),
46288
46388
  (() => {
46289
46389
  try {
46290
- const bunGlobalPath = path9.join(os3.homedir(), ".bun/install/global/node_modules/@elizaos/server/dist/client");
46291
- if (existsSync5(path9.join(bunGlobalPath, "index.html"))) {
46390
+ const bunGlobalPath = path8.join(os3.homedir(), ".bun/install/global/node_modules/@elizaos/server/dist/client");
46391
+ if (existsSync4(path8.join(bunGlobalPath, "index.html"))) {
46292
46392
  return bunGlobalPath;
46293
46393
  }
46294
46394
  try {
@@ -46298,8 +46398,8 @@ class AgentServer {
46298
46398
  });
46299
46399
  if (proc.exitCode === 0 && proc.stdout) {
46300
46400
  const npmRoot = new TextDecoder().decode(proc.stdout).trim();
46301
- const globalServerPath = path9.join(npmRoot, "@elizaos/server/dist/client");
46302
- if (existsSync5(path9.join(globalServerPath, "index.html"))) {
46401
+ const globalServerPath = path8.join(npmRoot, "@elizaos/server/dist/client");
46402
+ if (existsSync4(path8.join(globalServerPath, "index.html"))) {
46303
46403
  return globalServerPath;
46304
46404
  }
46305
46405
  }
@@ -46310,15 +46410,15 @@ class AgentServer {
46310
46410
  ...[
46311
46411
  "/usr/local/lib/node_modules/@elizaos/server/dist/client",
46312
46412
  "/usr/lib/node_modules/@elizaos/server/dist/client",
46313
- path9.join(os3.homedir(), ".npm-global/lib/node_modules/@elizaos/server/dist/client"),
46413
+ path8.join(os3.homedir(), ".npm-global/lib/node_modules/@elizaos/server/dist/client"),
46314
46414
  (() => {
46315
46415
  try {
46316
- const nvmPath = path9.join(os3.homedir(), ".nvm/versions/node");
46317
- if (existsSync5(nvmPath)) {
46318
- const versions = fs7.readdirSync(nvmPath);
46416
+ const nvmPath = path8.join(os3.homedir(), ".nvm/versions/node");
46417
+ if (existsSync4(nvmPath)) {
46418
+ const versions = fs6.readdirSync(nvmPath);
46319
46419
  for (const version of versions) {
46320
- const cliPath = path9.join(nvmPath, version, "lib/node_modules/@elizaos/server/dist/client");
46321
- if (existsSync5(path9.join(cliPath, "index.html"))) {
46420
+ const cliPath = path8.join(nvmPath, version, "lib/node_modules/@elizaos/server/dist/client");
46421
+ if (existsSync4(path8.join(cliPath, "index.html"))) {
46322
46422
  return cliPath;
46323
46423
  }
46324
46424
  }
@@ -46328,29 +46428,29 @@ class AgentServer {
46328
46428
  })()
46329
46429
  ].filter(Boolean)
46330
46430
  ].filter(Boolean);
46331
- logger32.debug(`[STATIC] process.argv[0]: ${process.argv[0]}`);
46332
- logger32.debug(`[STATIC] process.argv[1]: ${process.argv[1]}`);
46333
- logger32.debug(`[STATIC] __dirname: ${__dirname3}`);
46431
+ logger30.debug(`[STATIC] process.argv[0]: ${process.argv[0]}`);
46432
+ logger30.debug(`[STATIC] process.argv[1]: ${process.argv[1]}`);
46433
+ logger30.debug(`[STATIC] __dirname: ${__dirname3}`);
46334
46434
  for (const possiblePath of possiblePaths) {
46335
- if (possiblePath && existsSync5(path9.join(possiblePath, "index.html"))) {
46435
+ if (possiblePath && existsSync4(path8.join(possiblePath, "index.html"))) {
46336
46436
  clientPath = possiblePath;
46337
- logger32.info(`[STATIC] Found client files at: ${clientPath}`);
46437
+ logger30.info(`[STATIC] Found client files at: ${clientPath}`);
46338
46438
  break;
46339
46439
  }
46340
46440
  }
46341
46441
  if (clientPath) {
46342
46442
  this.clientPath = clientPath;
46343
46443
  this.app.use(express33.static(clientPath, staticOptions));
46344
- logger32.info(`[STATIC] Serving static files from: ${clientPath}`);
46444
+ logger30.info(`[STATIC] Serving static files from: ${clientPath}`);
46345
46445
  } else {
46346
- logger32.warn("[STATIC] Client dist path not found. Searched locations:");
46446
+ logger30.warn("[STATIC] Client dist path not found. Searched locations:");
46347
46447
  possiblePaths.forEach((p) => {
46348
46448
  if (p)
46349
- logger32.warn(`[STATIC] - ${p}`);
46449
+ logger30.warn(`[STATIC] - ${p}`);
46350
46450
  });
46351
- logger32.warn("[STATIC] The web UI will not be available.");
46352
- logger32.warn("[STATIC] To fix this, ensure the client is built: cd packages/client && bun run build");
46353
- logger32.warn("[STATIC] Then rebuild the server: cd packages/server && bun run build");
46451
+ logger30.warn("[STATIC] The web UI will not be available.");
46452
+ logger30.warn("[STATIC] To fix this, ensure the client is built: cd packages/client && bun run build");
46453
+ logger30.warn("[STATIC] Then rebuild the server: cd packages/server && bun run build");
46354
46454
  }
46355
46455
  }
46356
46456
  const pluginRouteHandler = createPluginRouteHandler(this.elizaOS);
@@ -46358,7 +46458,7 @@ class AgentServer {
46358
46458
  const apiRouter = createApiRouter(this.elizaOS, this);
46359
46459
  this.app.use("/api", (req, _res, next) => {
46360
46460
  if (req.path !== "/ping") {
46361
- logger32.debug(`API request: ${req.method} ${req.path}`);
46461
+ logger30.debug(`API request: ${req.method} ${req.path}`);
46362
46462
  }
46363
46463
  next();
46364
46464
  }, apiRouter, (err, req, res, _next) => {
@@ -46373,7 +46473,7 @@ class AgentServer {
46373
46473
  return scope;
46374
46474
  });
46375
46475
  }
46376
- logger32.error({ err }, `API error: ${req.method} ${req.path}`);
46476
+ logger30.error({ err }, `API error: ${req.method} ${req.path}`);
46377
46477
  res.status(500).json({
46378
46478
  success: false,
46379
46479
  error: {
@@ -46421,29 +46521,29 @@ class AgentServer {
46421
46521
  }
46422
46522
  const resolvedClientPath = clientPath || this.clientPath;
46423
46523
  if (resolvedClientPath) {
46424
- const indexFilePath = path9.join(resolvedClientPath, "index.html");
46425
- if (!existsSync5(indexFilePath)) {
46426
- logger32.error(`[STATIC] index.html not found at expected path: ${indexFilePath}`);
46427
- logger32.error(`[STATIC] Client path was: ${resolvedClientPath}`);
46524
+ const indexFilePath = path8.join(resolvedClientPath, "index.html");
46525
+ if (!existsSync4(indexFilePath)) {
46526
+ logger30.error(`[STATIC] index.html not found at expected path: ${indexFilePath}`);
46527
+ logger30.error(`[STATIC] Client path was: ${resolvedClientPath}`);
46428
46528
  res.status(404).send("Client application not found");
46429
46529
  return;
46430
46530
  }
46431
46531
  res.sendFile("index.html", { root: resolvedClientPath }, (err) => {
46432
46532
  if (err) {
46433
- logger32.warn(`[STATIC] Failed to serve index.html: ${err.message}`);
46434
- logger32.warn(`[STATIC] Attempted root: ${resolvedClientPath}`);
46435
- logger32.warn(`[STATIC] Full path was: ${indexFilePath}`);
46436
- logger32.warn(`[STATIC] Error code: ${err.code || "unknown"}`);
46533
+ logger30.warn(`[STATIC] Failed to serve index.html: ${err.message}`);
46534
+ logger30.warn(`[STATIC] Attempted root: ${resolvedClientPath}`);
46535
+ logger30.warn(`[STATIC] Full path was: ${indexFilePath}`);
46536
+ logger30.warn(`[STATIC] Error code: ${err.code || "unknown"}`);
46437
46537
  if (!res.headersSent) {
46438
46538
  res.status(404).send("Client application not found");
46439
46539
  }
46440
46540
  } else {
46441
- logger32.debug(`[STATIC] Successfully served index.html for route: ${req.path}`);
46541
+ logger30.debug(`[STATIC] Successfully served index.html for route: ${req.path}`);
46442
46542
  }
46443
46543
  });
46444
46544
  } else {
46445
- logger32.warn("[STATIC] Client dist path not found in SPA fallback");
46446
- logger32.warn("[STATIC] Neither local nor instance clientPath variables are set");
46545
+ logger30.warn("[STATIC] Client dist path not found in SPA fallback");
46546
+ logger30.warn("[STATIC] Neither local nor instance clientPath variables are set");
46447
46547
  res.status(404).send("Client application not found");
46448
46548
  }
46449
46549
  });
@@ -46454,9 +46554,9 @@ class AgentServer {
46454
46554
  }
46455
46555
  this.server = http4.createServer(this.app);
46456
46556
  this.socketIO = setupSocketIO(this.server, this.elizaOS, this);
46457
- logger32.success("AgentServer HTTP server and Socket.IO initialized");
46557
+ logger30.success("AgentServer HTTP server and Socket.IO initialized");
46458
46558
  } catch (error2) {
46459
- logger32.error({ error: error2 }, "Failed to complete server initialization:");
46559
+ logger30.error({ error: error2 }, "Failed to complete server initialization:");
46460
46560
  throw error2;
46461
46561
  }
46462
46562
  }
@@ -46471,78 +46571,138 @@ class AgentServer {
46471
46571
  if (!runtime.character) {
46472
46572
  throw new Error("Runtime missing character configuration");
46473
46573
  }
46474
- logger32.debug(`Agent ${runtime.character.name} (${runtime.agentId}) registered`);
46574
+ logger30.debug(`Agent ${runtime.character.name} (${runtime.agentId}) registered`);
46475
46575
  try {
46476
46576
  if (messageBusConnectorPlugin) {
46477
46577
  await runtime.registerPlugin(messageBusConnectorPlugin);
46478
- logger32.info(`[AgentServer] Automatically registered MessageBusConnector for agent ${runtime.character.name}`);
46578
+ logger30.info(`[AgentServer] Registered MessageBusConnector for agent ${runtime.character.name}`);
46479
46579
  } else {
46480
- logger32.error(`[AgentServer] CRITICAL: MessageBusConnector plugin definition not found.`);
46580
+ logger30.error(`[AgentServer] CRITICAL: MessageBusConnector plugin definition not found.`);
46481
46581
  }
46482
46582
  } catch (e) {
46483
- logger32.error({ error: e }, `[AgentServer] CRITICAL: Failed to register MessageBusConnector for agent ${runtime.character.name}`);
46583
+ logger30.error({ error: e }, `[AgentServer] CRITICAL: Failed to register MessageBusConnector for agent ${runtime.character.name}`);
46484
46584
  }
46485
46585
  const teePlugin = runtime.plugins.find((p) => p.name === "phala-tee-plugin");
46486
46586
  if (teePlugin) {
46487
- logger32.debug(`Found TEE plugin for agent ${runtime.agentId}`);
46587
+ logger30.debug(`Found TEE plugin for agent ${runtime.agentId}`);
46488
46588
  if (teePlugin.providers) {
46489
46589
  for (const provider of teePlugin.providers) {
46490
46590
  runtime.registerProvider(provider);
46491
- logger32.debug(`Registered TEE provider: ${provider.name}`);
46591
+ logger30.debug(`Registered TEE provider: ${provider.name}`);
46492
46592
  }
46493
46593
  }
46494
46594
  if (teePlugin.actions) {
46495
46595
  for (const action of teePlugin.actions) {
46496
46596
  runtime.registerAction(action);
46497
- logger32.debug(`Registered TEE action: ${action.name}`);
46597
+ logger30.debug(`Registered TEE action: ${action.name}`);
46498
46598
  }
46499
46599
  }
46500
46600
  }
46501
- logger32.success(`Successfully registered agent ${runtime.character.name} (${runtime.agentId}) with core services.`);
46601
+ logger30.success(`Successfully registered agent ${runtime.character.name} (${runtime.agentId}) with core services.`);
46502
46602
  await this.addAgentToServer(DEFAULT_SERVER_ID6, runtime.agentId);
46503
- logger32.info(`[AgentServer] Auto-associated agent ${runtime.character.name} with server ID: ${DEFAULT_SERVER_ID6}`);
46603
+ logger30.info(`[AgentServer] Auto-associated agent ${runtime.character.name} with server ID: ${DEFAULT_SERVER_ID6}`);
46504
46604
  } catch (error2) {
46505
- logger32.error({ error: error2 }, "Failed to register agent:");
46605
+ logger30.error({ error: error2 }, "Failed to register agent:");
46506
46606
  throw error2;
46507
46607
  }
46508
46608
  }
46509
46609
  async unregisterAgent(agentId) {
46510
46610
  if (!agentId) {
46511
- logger32.warn("[AGENT UNREGISTER] Attempted to unregister undefined or invalid agent runtime");
46611
+ logger30.warn("[AGENT UNREGISTER] Attempted to unregister undefined or invalid agent runtime");
46512
46612
  return;
46513
46613
  }
46514
46614
  try {
46515
46615
  const agent = this.elizaOS?.getAgent(agentId);
46516
46616
  if (agent) {
46517
46617
  try {
46518
- agent.stop().catch((stopError) => {
46519
- logger32.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error stopping agent services for ${agentId}:`);
46520
- });
46521
- logger32.debug(`[AGENT UNREGISTER] Stopping services for agent ${agentId}`);
46618
+ logger30.debug(`[AGENT UNREGISTER] Stopping services for agent ${agentId}`);
46619
+ await agent.stop();
46620
+ logger30.debug(`[AGENT UNREGISTER] All services stopped for agent ${agentId}`);
46522
46621
  } catch (stopError) {
46523
- logger32.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error initiating stop for agent ${agentId}:`);
46622
+ logger30.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error stopping agent services for ${agentId}:`);
46524
46623
  }
46525
46624
  }
46526
46625
  if (this.elizaOS) {
46527
46626
  await this.elizaOS.deleteAgents([agentId]);
46528
46627
  }
46529
- logger32.debug(`Agent ${agentId} unregistered`);
46628
+ logger30.debug(`Agent ${agentId} unregistered`);
46530
46629
  } catch (error2) {
46531
- logger32.error({ error: error2, agentId }, `Error removing agent ${agentId}:`);
46630
+ logger30.error({ error: error2, agentId }, `Error removing agent ${agentId}:`);
46532
46631
  }
46533
46632
  }
46534
46633
  registerMiddleware(middleware2) {
46535
46634
  this.app.use(middleware2);
46536
46635
  }
46537
- start(port) {
46636
+ async start(config3) {
46637
+ if (!this.isInitialized) {
46638
+ await this.initialize(config3);
46639
+ }
46640
+ if (!config3?.isTestMode) {
46641
+ const port = await this.resolveAndFindPort(config3?.port);
46642
+ await this.startHttpServer(port);
46643
+ }
46644
+ if (config3?.agents && config3.agents.length > 0) {
46645
+ await this.startAgents(config3.agents, { isTestMode: config3.isTestMode });
46646
+ logger30.info(`Started ${config3.agents.length} agents`);
46647
+ }
46648
+ }
46649
+ async resolveAndFindPort(port) {
46650
+ if (port !== undefined) {
46651
+ if (typeof port !== "number" || port < 1 || port > 65535) {
46652
+ throw new Error(`Invalid port number: ${port}. Must be between 1 and 65535.`);
46653
+ }
46654
+ return port;
46655
+ }
46656
+ let requestedPort = 3000;
46657
+ const envPort = process.env.SERVER_PORT;
46658
+ if (envPort) {
46659
+ const parsed = parseInt(envPort, 10);
46660
+ if (!isNaN(parsed) && parsed >= 1 && parsed <= 65535) {
46661
+ requestedPort = parsed;
46662
+ } else {
46663
+ logger30.warn(`Invalid SERVER_PORT "${envPort}", falling back to 3000`);
46664
+ }
46665
+ }
46666
+ return await this.findAvailablePort(requestedPort);
46667
+ }
46668
+ async findAvailablePort(startPort, maxAttempts = 10) {
46669
+ for (let attempt = 0;attempt < maxAttempts; attempt++) {
46670
+ const port = startPort + attempt;
46671
+ if (port > 65535) {
46672
+ throw new Error(`Could not find available port (exceeded max port 65535, tried up to ${port - 1})`);
46673
+ }
46674
+ if (await this.isPortAvailable(port)) {
46675
+ if (attempt > 0) {
46676
+ logger30.info(`Port ${startPort} is in use, using port ${port} instead`);
46677
+ }
46678
+ return port;
46679
+ }
46680
+ }
46681
+ throw new Error(`Could not find available port after ${maxAttempts} attempts starting from ${startPort}`);
46682
+ }
46683
+ async isPortAvailable(port) {
46684
+ return new Promise((resolve2) => {
46685
+ const server = net3.createServer();
46686
+ server.once("error", (err) => {
46687
+ if (err.code === "EADDRINUSE") {
46688
+ resolve2(false);
46689
+ } else {
46690
+ resolve2(false);
46691
+ }
46692
+ });
46693
+ server.once("listening", () => {
46694
+ server.close();
46695
+ resolve2(true);
46696
+ });
46697
+ server.listen(port);
46698
+ });
46699
+ }
46700
+ startHttpServer(port) {
46538
46701
  return new Promise((resolve2, reject) => {
46539
46702
  try {
46540
- if (!port || typeof port !== "number") {
46541
- throw new Error(`Invalid port number: ${port}`);
46542
- }
46543
- logger32.debug(`Starting server on port ${port}...`);
46544
- logger32.debug(`Current agents count: ${this.elizaOS?.getAgents().length || 0}`);
46545
- logger32.debug(`Environment: ${"development"}`);
46703
+ logger30.debug(`Starting server on port ${port}...`);
46704
+ logger30.debug(`Current agents count: ${this.elizaOS?.getAgents().length || 0}`);
46705
+ logger30.debug(`Environment: ${"development"}`);
46546
46706
  const host = process.env.SERVER_HOST || "0.0.0.0";
46547
46707
  this.server.listen(port, host, () => {
46548
46708
  if (this.isWebUIEnabled && false) {} else if (!this.isWebUIEnabled) {
@@ -46555,26 +46715,26 @@ class AgentServer {
46555
46715
  ` + ` \x1B[1m${baseUrl}/api/messaging\x1B[22m\x1B[0m`);
46556
46716
  }
46557
46717
  console.log(`AgentServer is listening on port ${port}`);
46558
- logger32.success(`REST API bound to ${host}:${port}. If running locally, access it at http://localhost:${port}.`);
46718
+ logger30.success(`REST API bound to ${host}:${port}. If running locally, access it at http://localhost:${port}.`);
46559
46719
  const agents = this.elizaOS?.getAgents() || [];
46560
- logger32.debug(`Active agents: ${agents.length}`);
46720
+ logger30.debug(`Active agents: ${agents.length}`);
46561
46721
  agents.forEach((agent) => {
46562
- logger32.debug(`- Agent ${agent.agentId}: ${agent.character.name}`);
46722
+ logger30.debug(`- Agent ${agent.agentId}: ${agent.character.name}`);
46563
46723
  });
46564
46724
  resolve2();
46565
46725
  }).on("error", (error2) => {
46566
- logger32.error({ error: error2, host, port }, `Failed to bind server to ${host}:${port}:`);
46726
+ logger30.error({ error: error2, host, port }, `Failed to bind server to ${host}:${port}:`);
46567
46727
  if (error2.code === "EADDRINUSE") {
46568
- logger32.error(`Port ${port} is already in use. Please try a different port or stop the process using that port.`);
46728
+ logger30.error(`Port ${port} is already in use. Please try a different port or stop the process using that port.`);
46569
46729
  } else if (error2.code === "EACCES") {
46570
- logger32.error(`Permission denied to bind to port ${port}. Try using a port above 1024 or running with appropriate permissions.`);
46730
+ logger30.error(`Permission denied to bind to port ${port}. Try using a port above 1024 or running with appropriate permissions.`);
46571
46731
  } else if (error2.code === "EADDRNOTAVAIL") {
46572
- logger32.error(`Cannot bind to ${host}:${port} - address not available. Check if the host address is correct.`);
46732
+ logger30.error(`Cannot bind to ${host}:${port} - address not available. Check if the host address is correct.`);
46573
46733
  }
46574
46734
  reject(error2);
46575
46735
  });
46576
46736
  } catch (error2) {
46577
- logger32.error({ error: error2 }, "Failed to start server:");
46737
+ logger30.error({ error: error2 }, "Failed to start server:");
46578
46738
  reject(error2);
46579
46739
  }
46580
46740
  });
@@ -46582,7 +46742,7 @@ class AgentServer {
46582
46742
  async stop() {
46583
46743
  if (this.server) {
46584
46744
  this.server.close(() => {
46585
- logger32.success("Server stopped");
46745
+ logger30.success("Server stopped");
46586
46746
  });
46587
46747
  }
46588
46748
  }
@@ -46629,7 +46789,7 @@ class AgentServer {
46629
46789
  for (const message of messages) {
46630
46790
  await this.database.deleteMessage(message.id);
46631
46791
  }
46632
- logger32.info(`[AgentServer] Cleared all messages for central channel: ${channelId}`);
46792
+ logger30.info(`[AgentServer] Cleared all messages for central channel: ${channelId}`);
46633
46793
  }
46634
46794
  async findOrCreateCentralDmChannel(user1Id, user2Id, messageServerId) {
46635
46795
  return this.database.findOrCreateDmChannel(user1Id, user2Id, messageServerId);
@@ -46652,7 +46812,7 @@ class AgentServer {
46652
46812
  metadata: createdMessage.metadata
46653
46813
  };
46654
46814
  bus_default.emit("new_message", messageForBus);
46655
- logger32.info(`[AgentServer] Published message ${createdMessage.id} to internal message bus`);
46815
+ logger30.info(`[AgentServer] Published message ${createdMessage.id} to internal message bus`);
46656
46816
  }
46657
46817
  return createdMessage;
46658
46818
  }
@@ -46663,7 +46823,7 @@ class AgentServer {
46663
46823
  return this.database.updateMessage(messageId, patch);
46664
46824
  }
46665
46825
  async removeParticipantFromChannel() {
46666
- logger32.warn(`[AgentServer] Remove participant operation not directly supported in database adapter`);
46826
+ logger30.warn(`[AgentServer] Remove participant operation not directly supported in database adapter`);
46667
46827
  }
46668
46828
  async addAgentToServer(serverId, agentId) {
46669
46829
  const server = await this.getServerById(serverId);
@@ -46691,32 +46851,32 @@ class AgentServer {
46691
46851
  }
46692
46852
  registerSignalHandlers() {
46693
46853
  const gracefulShutdown = async () => {
46694
- logger32.info("Received shutdown signal, initiating graceful shutdown...");
46695
- logger32.debug("Stopping all agents...");
46854
+ logger30.info("Received shutdown signal, initiating graceful shutdown...");
46855
+ logger30.debug("Stopping all agents...");
46696
46856
  const agents = this.elizaOS?.getAgents() || [];
46697
46857
  for (const agent of agents) {
46698
46858
  try {
46699
46859
  await agent.stop();
46700
- logger32.debug(`Stopped agent ${agent.agentId}`);
46860
+ logger30.debug(`Stopped agent ${agent.agentId}`);
46701
46861
  } catch (error2) {
46702
- logger32.error({ error: error2, agentId: agent.agentId }, `Error stopping agent ${agent.agentId}:`);
46862
+ logger30.error({ error: error2, agentId: agent.agentId }, `Error stopping agent ${agent.agentId}:`);
46703
46863
  }
46704
46864
  }
46705
46865
  if (this.database) {
46706
46866
  try {
46707
46867
  await this.database.close();
46708
- logger32.info("Database closed.");
46868
+ logger30.info("Database closed.");
46709
46869
  } catch (error2) {
46710
- logger32.error({ error: error2 }, "Error closing database:");
46870
+ logger30.error({ error: error2 }, "Error closing database:");
46711
46871
  }
46712
46872
  }
46713
46873
  if (this.server) {
46714
46874
  this.server.close(() => {
46715
- logger32.success("Server closed successfully");
46875
+ logger30.success("Server closed successfully");
46716
46876
  process.exit(0);
46717
46877
  });
46718
46878
  setTimeout(() => {
46719
- logger32.error("Could not close connections in time, forcing shutdown");
46879
+ logger30.error("Could not close connections in time, forcing shutdown");
46720
46880
  process.exit(1);
46721
46881
  }, 5000);
46722
46882
  } else {
@@ -46725,7 +46885,7 @@ class AgentServer {
46725
46885
  };
46726
46886
  process.on("SIGTERM", gracefulShutdown);
46727
46887
  process.on("SIGINT", gracefulShutdown);
46728
- logger32.debug("Shutdown handlers registered");
46888
+ logger30.debug("Shutdown handlers registered");
46729
46889
  }
46730
46890
  }
46731
46891
  export {
@@ -46739,8 +46899,6 @@ export {
46739
46899
  isWebUIEnabled,
46740
46900
  hasValidRemoteUrls,
46741
46901
  expandTildePath,
46742
- PluginLoader,
46743
46902
  ElizaOS3 as ElizaOS,
46744
- ConfigManager,
46745
46903
  AgentServer
46746
46904
  };