@sentry/server-utils 11.16.0 → 11.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/build/cjs/chunks/config.js +62 -2
  2. package/build/cjs/chunks/config.js.map +1 -1
  3. package/build/cjs/chunks/exports.js +231 -66
  4. package/build/cjs/chunks/exports.js.map +1 -1
  5. package/build/cjs/chunks/moduleInjectedTransform.js +8 -0
  6. package/build/cjs/chunks/moduleInjectedTransform.js.map +1 -1
  7. package/build/cjs/index.js +447 -199
  8. package/build/cjs/index.js.map +1 -1
  9. package/build/cjs/index.no-diagnostic-channels.js +1 -0
  10. package/build/cjs/index.request-handler.js +48 -3
  11. package/build/cjs/index.request-handler.js.map +1 -1
  12. package/build/esm/ai/langchain/embeddings.js +23 -8
  13. package/build/esm/ai/langchain/embeddings.js.map +1 -1
  14. package/build/esm/ai/langchain/index.js +41 -30
  15. package/build/esm/ai/langchain/index.js.map +1 -1
  16. package/build/esm/ai/langchain/utils.js +1 -5
  17. package/build/esm/ai/langchain/utils.js.map +1 -1
  18. package/build/esm/ai/langgraph/agent-span.js +6 -2
  19. package/build/esm/ai/langgraph/agent-span.js.map +1 -1
  20. package/build/esm/ai/langgraph/index.js +5 -1
  21. package/build/esm/ai/langgraph/index.js.map +1 -1
  22. package/build/esm/ai/langgraph/stream.js +4 -1
  23. package/build/esm/ai/langgraph/stream.js.map +1 -1
  24. package/build/esm/ai/mistral/streaming.js.map +1 -1
  25. package/build/esm/ai/pi-durable/index.js +10 -13
  26. package/build/esm/ai/pi-durable/index.js.map +1 -1
  27. package/build/esm/ai/pi-durable/runs.js +6 -5
  28. package/build/esm/ai/pi-durable/runs.js.map +1 -1
  29. package/build/esm/ai/pi-durable/tools.js +21 -17
  30. package/build/esm/ai/pi-durable/tools.js.map +1 -1
  31. package/build/esm/exports.js +2 -1
  32. package/build/esm/index.js +5 -2
  33. package/build/esm/index.js.map +1 -1
  34. package/build/esm/index.no-diagnostic-channels.js +2 -1
  35. package/build/esm/index.request-handler.js +3 -1
  36. package/build/esm/integrations/amqplib.js.map +1 -1
  37. package/build/esm/integrations/anthropic.js.map +1 -1
  38. package/build/esm/integrations/bullmq/tracer.js.map +1 -1
  39. package/build/esm/integrations/clickhouse-sql.js +31 -0
  40. package/build/esm/integrations/clickhouse-sql.js.map +1 -0
  41. package/build/esm/integrations/clickhouse.js +88 -0
  42. package/build/esm/integrations/clickhouse.js.map +1 -0
  43. package/build/esm/integrations/express/instrumentation.js +1 -0
  44. package/build/esm/integrations/express/instrumentation.js.map +1 -1
  45. package/build/esm/integrations/fastify/instrumentation.js +3 -1
  46. package/build/esm/integrations/fastify/instrumentation.js.map +1 -1
  47. package/build/esm/integrations/graphql/utils.js.map +1 -1
  48. package/build/esm/integrations/hapi/hapi-utils.js +6 -9
  49. package/build/esm/integrations/hapi/hapi-utils.js.map +1 -1
  50. package/build/esm/integrations/hapi/index.js +15 -1
  51. package/build/esm/integrations/hapi/index.js.map +1 -1
  52. package/build/esm/integrations/hono/isMiddleware.js.map +1 -1
  53. package/build/esm/integrations/hono/middlewareHandlers.js +3 -1
  54. package/build/esm/integrations/hono/middlewareHandlers.js.map +1 -1
  55. package/build/esm/integrations/hono/patchRoute.js +2 -1
  56. package/build/esm/integrations/hono/patchRoute.js.map +1 -1
  57. package/build/esm/integrations/hono/unwrapThrownValue.js +20 -0
  58. package/build/esm/integrations/hono/unwrapThrownValue.js.map +1 -0
  59. package/build/esm/integrations/index.js +2 -0
  60. package/build/esm/integrations/index.js.map +1 -1
  61. package/build/esm/integrations/langchain.js +10 -3
  62. package/build/esm/integrations/langchain.js.map +1 -1
  63. package/build/esm/integrations/mongodb/mongodb-span.js +7 -9
  64. package/build/esm/integrations/mongodb/mongodb-span.js.map +1 -1
  65. package/build/esm/integrations/pino.js +2 -2
  66. package/build/esm/integrations/pino.js.map +1 -1
  67. package/build/esm/integrations/prisma/tracing-helper.js.map +1 -1
  68. package/build/esm/integrations/serveTunnel.js +2 -2
  69. package/build/esm/integrations/serveTunnel.js.map +1 -1
  70. package/build/esm/integrations/vercel-ai/extract.js +88 -0
  71. package/build/esm/integrations/vercel-ai/extract.js.map +1 -0
  72. package/build/esm/integrations/vercel-ai/util.js +5 -1
  73. package/build/esm/integrations/vercel-ai/util.js.map +1 -1
  74. package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js +19 -9
  75. package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  76. package/build/esm/integrations/winston.js +2 -2
  77. package/build/esm/integrations/winston.js.map +1 -1
  78. package/build/esm/orchestrion/channels.js +2 -0
  79. package/build/esm/orchestrion/channels.js.map +1 -1
  80. package/build/esm/orchestrion/config/channel-integration-definitions.js +8 -0
  81. package/build/esm/orchestrion/config/channel-integration-definitions.js.map +1 -1
  82. package/build/esm/orchestrion/config/clickhouse.js +51 -0
  83. package/build/esm/orchestrion/config/clickhouse.js.map +1 -0
  84. package/build/esm/orchestrion/config/hono.js +2 -2
  85. package/build/esm/orchestrion/config/hono.js.map +1 -1
  86. package/build/esm/orchestrion/config/index.js +2 -0
  87. package/build/esm/orchestrion/config/index.js.map +1 -1
  88. package/build/esm/package.json +1 -1
  89. package/build/esm/utils/installedModules.js +87 -0
  90. package/build/esm/utils/installedModules.js.map +1 -0
  91. package/build/esm/utils/module.js +29 -0
  92. package/build/esm/utils/module.js.map +1 -0
  93. package/build/esm/utils/serverTimingTraceHeader.js +49 -0
  94. package/build/esm/utils/serverTimingTraceHeader.js.map +1 -0
  95. package/build/esm/utils/sql.js +41 -19
  96. package/build/esm/utils/sql.js.map +1 -1
  97. package/build/esm/utils/tunnelServer.js +3 -3
  98. package/build/esm/utils/tunnelServer.js.map +1 -1
  99. package/build/esm/utils/wrapServerRequestHandler.js +5 -4
  100. package/build/esm/utils/wrapServerRequestHandler.js.map +1 -1
  101. package/build/types/ai/langchain/embeddings.d.ts +2 -2
  102. package/build/types/ai/langchain/embeddings.d.ts.map +1 -1
  103. package/build/types/ai/langchain/index.d.ts.map +1 -1
  104. package/build/types/ai/langchain/types.d.ts +8 -4
  105. package/build/types/ai/langchain/types.d.ts.map +1 -1
  106. package/build/types/ai/langchain/utils.d.ts.map +1 -1
  107. package/build/types/ai/langgraph/agent-span.d.ts +5 -2
  108. package/build/types/ai/langgraph/agent-span.d.ts.map +1 -1
  109. package/build/types/ai/langgraph/index.d.ts.map +1 -1
  110. package/build/types/ai/langgraph/stream.d.ts.map +1 -1
  111. package/build/types/ai/langgraph/types.d.ts +10 -2
  112. package/build/types/ai/langgraph/types.d.ts.map +1 -1
  113. package/build/types/ai/mistral/streaming.d.ts.map +1 -1
  114. package/build/types/ai/pi-durable/index.d.ts.map +1 -1
  115. package/build/types/ai/pi-durable/runs.d.ts +4 -2
  116. package/build/types/ai/pi-durable/runs.d.ts.map +1 -1
  117. package/build/types/ai/pi-durable/tools.d.ts +4 -6
  118. package/build/types/ai/pi-durable/tools.d.ts.map +1 -1
  119. package/build/types/ai/pi-durable/types.d.ts +10 -1
  120. package/build/types/ai/pi-durable/types.d.ts.map +1 -1
  121. package/build/types/exports.d.ts +1 -0
  122. package/build/types/exports.d.ts.map +1 -1
  123. package/build/types/index.d.ts +5 -3
  124. package/build/types/index.d.ts.map +1 -1
  125. package/build/types/index.request-handler.d.ts +1 -0
  126. package/build/types/index.request-handler.d.ts.map +1 -1
  127. package/build/types/integrations/amqplib.d.ts.map +1 -1
  128. package/build/types/integrations/anthropic.d.ts.map +1 -1
  129. package/build/types/integrations/bullmq/tracer.d.ts.map +1 -1
  130. package/build/types/integrations/clickhouse-sql.d.ts +8 -0
  131. package/build/types/integrations/clickhouse-sql.d.ts.map +1 -0
  132. package/build/types/integrations/clickhouse.d.ts +11 -0
  133. package/build/types/integrations/clickhouse.d.ts.map +1 -0
  134. package/build/types/integrations/express/types.d.ts +1 -0
  135. package/build/types/integrations/express/types.d.ts.map +1 -1
  136. package/build/types/integrations/fastify/instrumentation.d.ts.map +1 -1
  137. package/build/types/integrations/hapi/hapi-utils.d.ts.map +1 -1
  138. package/build/types/integrations/hapi/index.d.ts +12 -0
  139. package/build/types/integrations/hapi/index.d.ts.map +1 -1
  140. package/build/types/integrations/hono/isMiddleware.d.ts.map +1 -1
  141. package/build/types/integrations/hono/middlewareHandlers.d.ts.map +1 -1
  142. package/build/types/integrations/hono/patchRoute.d.ts.map +1 -1
  143. package/build/types/integrations/hono/unwrapThrownValue.d.ts +10 -0
  144. package/build/types/integrations/hono/unwrapThrownValue.d.ts.map +1 -0
  145. package/build/types/integrations/index.d.ts.map +1 -1
  146. package/build/types/integrations/langchain.d.ts.map +1 -1
  147. package/build/types/integrations/mongodb/mongodb-span.d.ts.map +1 -1
  148. package/build/types/integrations/prisma/tracing-helper.d.ts.map +1 -1
  149. package/build/types/integrations/vercel-ai/extract.d.ts +27 -0
  150. package/build/types/integrations/vercel-ai/extract.d.ts.map +1 -0
  151. package/build/types/integrations/vercel-ai/util.d.ts +2 -0
  152. package/build/types/integrations/vercel-ai/util.d.ts.map +1 -1
  153. package/build/types/integrations/vercel-ai/vercel-ai-dc-subscriber.d.ts +1 -1
  154. package/build/types/integrations/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
  155. package/build/types/orchestrion/channels.d.ts +12 -0
  156. package/build/types/orchestrion/channels.d.ts.map +1 -1
  157. package/build/types/orchestrion/config/channel-integration-definitions.d.ts +3 -0
  158. package/build/types/orchestrion/config/channel-integration-definitions.d.ts.map +1 -1
  159. package/build/types/orchestrion/config/clickhouse.d.ts +18 -0
  160. package/build/types/orchestrion/config/clickhouse.d.ts.map +1 -0
  161. package/build/types/orchestrion/config/index.d.ts.map +1 -1
  162. package/build/types/utils/installedModules.d.ts +17 -0
  163. package/build/types/utils/installedModules.d.ts.map +1 -0
  164. package/build/types/utils/module.d.ts +3 -0
  165. package/build/types/utils/module.d.ts.map +1 -0
  166. package/build/types/utils/serverTimingTraceHeader.d.ts +18 -0
  167. package/build/types/utils/serverTimingTraceHeader.d.ts.map +1 -0
  168. package/build/types/utils/sql.d.ts +28 -3
  169. package/build/types/utils/sql.d.ts.map +1 -1
  170. package/build/types/utils/tunnelServer.d.ts.map +1 -1
  171. package/build/types/utils/wrapServerRequestHandler.d.ts.map +1 -1
  172. package/package.json +4 -4
@@ -3448,11 +3448,7 @@ function extractLlmResponseAttributes(llmResult, recordOutputs) {
3448
3448
  if (!llmResult) return;
3449
3449
  const attrs = {};
3450
3450
  if (Array.isArray(llmResult.generations)) {
3451
- const finishReasons = llmResult.generations.flat().map((g) => {
3452
- if (g.generationInfo?.finish_reason) return g.generationInfo.finish_reason;
3453
- if (g.generation_info?.finish_reason) return g.generation_info.finish_reason;
3454
- return null;
3455
- }).filter((r) => typeof r === "string");
3451
+ const finishReasons = llmResult.generations.flat().map((g) => g.generationInfo?.finish_reason || g.generation_info?.finish_reason || g.message?.response_metadata?.finish_reason).filter((r) => typeof r === "string");
3456
3452
  if (finishReasons.length > 0) setIfDefined(attrs, _sentry_conventions_attributes.GEN_AI_RESPONSE_FINISH_REASONS, (0, _sentry_core.stringify)(finishReasons, String));
3457
3453
  addToolCallsAttributes(llmResult.generations, attrs);
3458
3454
  if (recordOutputs) {
@@ -3662,11 +3658,9 @@ function extractEmbeddingAttributes(instance) {
3662
3658
  * @internal Exported so the diagnostics-channel (orchestrion) instrumentation can build the same
3663
3659
  * span as the prototype-patching path below.
3664
3660
  */
3665
- function _INTERNAL_getLangChainEmbeddingsSpanOptions(instance, input, options = {}) {
3666
- const { recordInputs } = resolveGenAiCallRecording(options, {
3667
- operation: "embeddings",
3668
- input
3669
- });
3661
+ function _INTERNAL_getLangChainEmbeddingsSpanOptions(instance, call, options = {}) {
3662
+ const { input } = call;
3663
+ const { recordInputs } = resolveGenAiCallRecording(options, call);
3670
3664
  const attributes = extractEmbeddingAttributes(instance);
3671
3665
  const modelName = attributes[_sentry_conventions_attributes.GEN_AI_REQUEST_MODEL] || "unknown";
3672
3666
  const client = (0, _sentry_core.getClient)();
@@ -3683,8 +3677,24 @@ function _INTERNAL_getLangChainEmbeddingsSpanOptions(instance, input, options =
3683
3677
  */
3684
3678
  function instrumentEmbeddingMethod(originalMethod, options = {}) {
3685
3679
  return new Proxy(originalMethod, { apply(target, thisArg, args) {
3686
- return (0, _sentry_core.startSpan)(_INTERNAL_getLangChainEmbeddingsSpanOptions(thisArg, args[0], options), () => {
3687
- return Reflect.apply(target, thisArg, args);
3680
+ const call = {
3681
+ operation: "embeddings",
3682
+ input: args[0]
3683
+ };
3684
+ return (0, _sentry_core.startSpan)(_INTERNAL_getLangChainEmbeddingsSpanOptions(thisArg, call, options), async (span) => {
3685
+ runGenAiSpanStart(options, span, call);
3686
+ try {
3687
+ const response = await Reflect.apply(target, thisArg, args);
3688
+ runGenAiSpanEnd(options, span, call, { response });
3689
+ return response;
3690
+ } catch (error) {
3691
+ span.setStatus({
3692
+ code: _sentry_core.SPAN_STATUS_ERROR,
3693
+ message: "internal_error"
3694
+ });
3695
+ runGenAiSpanEnd(options, span, call, { error });
3696
+ throw error;
3697
+ }
3688
3698
  });
3689
3699
  } });
3690
3700
  }
@@ -3726,9 +3736,12 @@ function createLangChainCallbackHandler(options = {}) {
3726
3736
  /**
3727
3737
  * Exit a span and clean up
3728
3738
  */
3729
- const exitSpan = (runId) => {
3730
- const span = runs.remove(runId)?.span;
3731
- if (span?.isRecording()) span.end();
3739
+ const exitSpan = (runId, result = {}) => {
3740
+ const run = runs.remove(runId);
3741
+ if (run?.span.isRecording()) {
3742
+ runGenAiSpanEnd(options, run.span, run.call, result);
3743
+ run.span.end();
3744
+ }
3732
3745
  };
3733
3746
  let warnedFull = false;
3734
3747
  const trackRun = (runId, run) => {
@@ -3744,7 +3757,7 @@ function createLangChainCallbackHandler(options = {}) {
3744
3757
  };
3745
3758
  const getAncestors = (parentRunId) => {
3746
3759
  const ancestors = [];
3747
- for (let run = getRun(parentRunId); run; run = getRun(run.parentRunId)) ancestors.push(run);
3760
+ for (let run = getRun(parentRunId); run; run = getRun(run.call.parentRunId)) ancestors.push(run);
3748
3761
  return ancestors;
3749
3762
  };
3750
3763
  const getParentRunSpan = (ancestors, activeSpan) => {
@@ -3753,7 +3766,8 @@ function createLangChainCallbackHandler(options = {}) {
3753
3766
  if (!(0, _sentry_core.spanIsIgnored)(run.span) || (0, _sentry_core.getRootSpan)(run.span) === run.span) return run.span;
3754
3767
  }
3755
3768
  };
3756
- const startRunSpan = (runId, parentRunId, recordOutputs, start) => {
3769
+ const startRunSpan = (call, recordOutputs, start) => {
3770
+ const { runId, parentRunId } = call;
3757
3771
  const ancestors = getAncestors(parentRunId);
3758
3772
  const activeSpan = (0, _sentry_core.getActiveSpan)();
3759
3773
  const parentSpan = getParentRunSpan(ancestors, activeSpan);
@@ -3763,7 +3777,7 @@ function createLangChainCallbackHandler(options = {}) {
3763
3777
  if (conversationId && conversationId !== ownId) span.setAttribute(_sentry_conventions_attributes.GEN_AI_CONVERSATION_ID, conversationId);
3764
3778
  const run = {
3765
3779
  span,
3766
- parentRunId,
3780
+ call,
3767
3781
  activeSpan,
3768
3782
  conversationId,
3769
3783
  recordOutputs
@@ -3774,6 +3788,7 @@ function createLangChainCallbackHandler(options = {}) {
3774
3788
  ancestor.conversationId = conversationId;
3775
3789
  ancestor.span.setAttribute(_sentry_conventions_attributes.GEN_AI_CONVERSATION_ID, conversationId);
3776
3790
  }
3791
+ runGenAiSpanStart(options, span, call);
3777
3792
  return run;
3778
3793
  };
3779
3794
  /**
@@ -3807,7 +3822,7 @@ function createLangChainCallbackHandler(options = {}) {
3807
3822
  awaitHandlers: true,
3808
3823
  handleLLMStart(llm, prompts, runId, parentRunId, extraParams, tags, metadata, _runName) {
3809
3824
  const serialized = llm;
3810
- const { recordInputs, recordOutputs } = resolveRecording({
3825
+ const call = {
3811
3826
  operation: "chat",
3812
3827
  serialized,
3813
3828
  prompts,
@@ -3816,12 +3831,13 @@ function createLangChainCallbackHandler(options = {}) {
3816
3831
  extraParams,
3817
3832
  tags,
3818
3833
  metadata
3819
- });
3834
+ };
3835
+ const { recordInputs, recordOutputs } = resolveRecording(call);
3820
3836
  const attributes = extractLLMRequestAttributes(serialized, prompts, recordInputs, getInvocationParams(tags), metadata);
3821
3837
  const modelName = attributes[_sentry_conventions_attributes.GEN_AI_REQUEST_MODEL] || "unknown";
3822
3838
  const operationName = typeof attributes[_sentry_conventions_attributes.GEN_AI_OPERATION_NAME] === "string" ? attributes[_sentry_conventions_attributes.GEN_AI_OPERATION_NAME] : "unknown";
3823
3839
  const client = (0, _sentry_core.getClient)();
3824
- startRunSpan(runId, parentRunId, recordOutputs, () => (0, _sentry_core.startInactiveSpan)({
3840
+ startRunSpan(call, recordOutputs, () => (0, _sentry_core.startInactiveSpan)({
3825
3841
  name: typeof modelName === "string" && modelName !== "unknown" || !(client && (0, _sentry_core.hasSpanStreamingEnabled)(client)) ? `${operationName} ${modelName}` : operationName,
3826
3842
  attributes: {
3827
3843
  ...getAgentNameFromMetadata(metadata),
@@ -3834,7 +3850,7 @@ function createLangChainCallbackHandler(options = {}) {
3834
3850
  handleChatModelStart(llm, messages, runId, parentRunId, extraParams, tags, metadata, _runName) {
3835
3851
  const serialized = llm;
3836
3852
  const chatMessages = messages;
3837
- const { recordInputs, recordOutputs } = resolveRecording({
3853
+ const call = {
3838
3854
  operation: "chat",
3839
3855
  serialized,
3840
3856
  messages: chatMessages,
@@ -3843,14 +3859,15 @@ function createLangChainCallbackHandler(options = {}) {
3843
3859
  extraParams,
3844
3860
  tags,
3845
3861
  metadata
3846
- });
3862
+ };
3863
+ const { recordInputs, recordOutputs } = resolveRecording(call);
3847
3864
  const attributes = extractChatModelRequestAttributes(serialized, chatMessages, recordInputs, getInvocationParams(tags), metadata);
3848
3865
  const toolDefsJson = recordInputs ? extractToolDefinitions(extraParams) : void 0;
3849
3866
  if (toolDefsJson) attributes[_sentry_conventions_attributes.GEN_AI_TOOL_DEFINITIONS] = toolDefsJson;
3850
3867
  const modelName = attributes[_sentry_conventions_attributes.GEN_AI_REQUEST_MODEL] || "unknown";
3851
3868
  const operationName = typeof attributes[_sentry_conventions_attributes.GEN_AI_OPERATION_NAME] === "string" ? attributes[_sentry_conventions_attributes.GEN_AI_OPERATION_NAME] : "unknown";
3852
3869
  const client = (0, _sentry_core.getClient)();
3853
- startRunSpan(runId, parentRunId, recordOutputs, () => (0, _sentry_core.startInactiveSpan)({
3870
+ startRunSpan(call, recordOutputs, () => (0, _sentry_core.startInactiveSpan)({
3854
3871
  name: typeof modelName === "string" && modelName !== "unknown" || !(client && (0, _sentry_core.hasSpanStreamingEnabled)(client)) ? `${operationName} ${modelName}` : operationName,
3855
3872
  attributes: {
3856
3873
  ...getAgentNameFromMetadata(metadata),
@@ -3871,19 +3888,19 @@ function createLangChainCallbackHandler(options = {}) {
3871
3888
  const attributes = extractLlmResponseAttributes(output, run.recordOutputs);
3872
3889
  if (attributes) span.setAttributes(attributes);
3873
3890
  }
3874
- exitSpan(runId);
3891
+ exitSpan(runId, { response: output });
3875
3892
  },
3876
- handleLLMError(_error, runId) {
3893
+ handleLLMError(error, runId) {
3877
3894
  const span = runs.get(runId)?.span;
3878
3895
  if (span?.isRecording()) span.setStatus({
3879
3896
  code: _sentry_core.SPAN_STATUS_ERROR,
3880
3897
  message: "internal_error"
3881
3898
  });
3882
- exitSpan(runId);
3899
+ exitSpan(runId, { error });
3883
3900
  },
3884
3901
  handleChainStart(chain, inputs, runId, parentRunId, tags, metadata, _runType, runName) {
3885
3902
  if (isTypeSafeClassifier(chain)) {
3886
- const { recordInputs, recordOutputs } = resolveRecording({
3903
+ const call = {
3887
3904
  operation: "decide",
3888
3905
  serialized: chain,
3889
3906
  inputs,
@@ -3891,12 +3908,13 @@ function createLangChainCallbackHandler(options = {}) {
3891
3908
  parentRunId,
3892
3909
  tags,
3893
3910
  metadata
3894
- });
3895
- startRunSpan(runId, parentRunId, recordOutputs, () => startTypeSafeClassifierSpan(chain, inputs, metadata, recordInputs)).decide = true;
3911
+ };
3912
+ const { recordInputs, recordOutputs } = resolveRecording(call);
3913
+ startRunSpan(call, recordOutputs, () => startTypeSafeClassifierSpan(chain, inputs, metadata, recordInputs)).decide = true;
3896
3914
  return;
3897
3915
  }
3898
3916
  if (metadata?.__sentry_langgraph__) return;
3899
- const { recordInputs, recordOutputs } = resolveRecording({
3917
+ const call = {
3900
3918
  operation: "invoke_agent",
3901
3919
  serialized: chain,
3902
3920
  inputs,
@@ -3904,7 +3922,8 @@ function createLangChainCallbackHandler(options = {}) {
3904
3922
  parentRunId,
3905
3923
  tags,
3906
3924
  metadata
3907
- });
3925
+ };
3926
+ const { recordInputs, recordOutputs } = resolveRecording(call);
3908
3927
  const chainName = runName || chain.name;
3909
3928
  const attributes = {
3910
3929
  ...getConversationIdFromMetadata(metadata),
@@ -3914,7 +3933,7 @@ function createLangChainCallbackHandler(options = {}) {
3914
3933
  if (chainName) attributes[_sentry_conventions_attributes.GEN_AI_PIPELINE_NAME] = chainName;
3915
3934
  if (recordInputs) attributes["langchain.chain.inputs"] = JSON.stringify(inputs);
3916
3935
  const client = (0, _sentry_core.getClient)();
3917
- startRunSpan(runId, parentRunId, recordOutputs, () => (0, _sentry_core.startInactiveSpan)({
3936
+ startRunSpan(call, recordOutputs, () => (0, _sentry_core.startInactiveSpan)({
3918
3937
  name: !(client && (0, _sentry_core.hasSpanStreamingEnabled)(client)) ? `chain ${chainName || "unknown_chain"}` : chainName ? `invoke_agent ${chainName}` : "invoke_agent",
3919
3938
  attributes: {
3920
3939
  ...attributes,
@@ -3929,19 +3948,19 @@ function createLangChainCallbackHandler(options = {}) {
3929
3948
  if (run.decide) addTypeSafeClassifierResponseAttributes(span, outputs, run.recordOutputs);
3930
3949
  else if (run.recordOutputs) span.setAttributes({ "langchain.chain.outputs": JSON.stringify(outputs) });
3931
3950
  }
3932
- exitSpan(runId);
3951
+ exitSpan(runId, { response: outputs });
3933
3952
  },
3934
- handleChainError(_error, runId) {
3953
+ handleChainError(error, runId) {
3935
3954
  const span = runs.get(runId)?.span;
3936
3955
  if (span?.isRecording()) span.setStatus({
3937
3956
  code: _sentry_core.SPAN_STATUS_ERROR,
3938
3957
  message: "internal_error"
3939
3958
  });
3940
- exitSpan(runId);
3959
+ exitSpan(runId, { error });
3941
3960
  },
3942
3961
  handleToolStart(tool, input, runId, parentRunId, tags, metadata, runName) {
3943
3962
  if (metadata?.__sentry_langgraph__) return;
3944
- const { recordInputs, recordOutputs } = resolveRecording({
3963
+ const call = {
3945
3964
  operation: "execute_tool",
3946
3965
  serialized: tool,
3947
3966
  input,
@@ -3949,7 +3968,8 @@ function createLangChainCallbackHandler(options = {}) {
3949
3968
  parentRunId,
3950
3969
  tags,
3951
3970
  metadata
3952
- });
3971
+ };
3972
+ const { recordInputs, recordOutputs } = resolveRecording(call);
3953
3973
  const toolName = runName || tool.name || "unknown_tool";
3954
3974
  const attributes = {
3955
3975
  ...getAgentNameFromMetadata(metadata),
@@ -3959,7 +3979,7 @@ function createLangChainCallbackHandler(options = {}) {
3959
3979
  [_sentry_conventions_attributes.GEN_AI_TOOL_NAME]: toolName
3960
3980
  };
3961
3981
  if (recordInputs) attributes[_sentry_conventions_attributes.GEN_AI_TOOL_CALL_ARGUMENTS] = input;
3962
- startRunSpan(runId, parentRunId, recordOutputs, () => (0, _sentry_core.startInactiveSpan)({
3982
+ startRunSpan(call, recordOutputs, () => (0, _sentry_core.startInactiveSpan)({
3963
3983
  name: `execute_tool ${toolName}`,
3964
3984
  attributes: {
3965
3985
  ...attributes,
@@ -3977,15 +3997,15 @@ function createLangChainCallbackHandler(options = {}) {
3977
3997
  span.setAttributes({ [_sentry_conventions_attributes.GEN_AI_TOOL_CALL_RESULT]: (0, _sentry_core.stringify)(content, String) });
3978
3998
  }
3979
3999
  }
3980
- exitSpan(runId);
4000
+ exitSpan(runId, { response: output });
3981
4001
  },
3982
- handleToolError(_error, runId) {
4002
+ handleToolError(error, runId) {
3983
4003
  const span = runs.get(runId)?.span;
3984
4004
  if (span?.isRecording()) span.setStatus({
3985
4005
  code: _sentry_core.SPAN_STATUS_ERROR,
3986
4006
  message: "internal_error"
3987
4007
  });
3988
- exitSpan(runId);
4008
+ exitSpan(runId, { error });
3989
4009
  },
3990
4010
  copy() {
3991
4011
  return handler;
@@ -4228,11 +4248,15 @@ function getAgentSpanOptions(args, extraAttributes) {
4228
4248
  }
4229
4249
  /** Decides for one `invoke()`/`stream()` call, from its arguments as passed. */
4230
4250
  function resolveGraphCallRecording(options, args) {
4231
- return resolveGenAiCallRecording(options, {
4251
+ const call = {
4232
4252
  operation: "invoke_agent",
4233
4253
  input: args[0],
4234
4254
  config: args[1]
4235
- });
4255
+ };
4256
+ return {
4257
+ call,
4258
+ recording: resolveGenAiCallRecording(options, call)
4259
+ };
4236
4260
  }
4237
4261
  /** Sets the request attributes on an agent span and injects the callback handler into the call's config. */
4238
4262
  function prepareAgentSpan(span, args, graphInstance, compileOptions, recording, llm, sentryCallbackHandler) {
@@ -4286,7 +4310,7 @@ function prepareAgentSpan(span, args, graphInstance, compileOptions, recording,
4286
4310
  function instrumentCompiledGraphStream(originalStream, graphInstance, compileOptions, options, llm, sentryCallbackHandler) {
4287
4311
  return new Proxy(originalStream, { apply(target, thisArg, args) {
4288
4312
  if (isInvokeInternalStream(graphInstance)) return Reflect.apply(target, thisArg, args);
4289
- const recording = resolveGraphCallRecording(options, args);
4313
+ const { call, recording } = resolveGraphCallRecording(options, args);
4290
4314
  return (0, _sentry_core.startSpanManual)(getAgentSpanOptions(args, { [_sentry_conventions_attributes.GEN_AI_RESPONSE_STREAMING]: true }), async (span) => {
4291
4315
  let inputMessages = null;
4292
4316
  let stream;
@@ -4302,6 +4326,7 @@ function instrumentCompiledGraphStream(originalStream, graphInstance, compileOpt
4302
4326
  });
4303
4327
  } else if (outcome && recording.recordOutputs) setResponseAttributes(span, inputMessages, outcome.outputs);
4304
4328
  } catch {}
4329
+ runGenAiSpanEnd(options, span, call, outcome && "error" in outcome ? { error: outcome.error } : { response: outcome?.outputs });
4305
4330
  span.end();
4306
4331
  inputMessages = null;
4307
4332
  };
@@ -4324,6 +4349,7 @@ function instrumentCompiledGraphStream(originalStream, graphInstance, compileOpt
4324
4349
  };
4325
4350
  try {
4326
4351
  inputMessages = prepareAgentSpan(span, args, graphInstance, compileOptions, recording, llm, sentryCallbackHandler);
4352
+ runGenAiSpanStart(options, span, call);
4327
4353
  const config = args[1];
4328
4354
  config.callbacks = _INTERNAL_addLangChainCallbackHandler(config.callbacks, listener);
4329
4355
  stream = await Reflect.apply(target, thisArg, args);
@@ -4412,18 +4438,21 @@ function instrumentCompiledGraph(graph, compileOptions, options, llm, sentryCall
4412
4438
  */
4413
4439
  function instrumentCompiledGraphInvoke(originalInvoke, graphInstance, compileOptions, options, llm, sentryCallbackHandler) {
4414
4440
  return new Proxy(originalInvoke, { apply(target, thisArg, args) {
4415
- const recording = resolveGraphCallRecording(options, args);
4441
+ const { call, recording } = resolveGraphCallRecording(options, args);
4416
4442
  return (0, _sentry_core.startSpan)(getAgentSpanOptions(args), async (span) => {
4417
4443
  try {
4418
4444
  const inputMessages = prepareAgentSpan(span, args, graphInstance, compileOptions, recording, llm, sentryCallbackHandler);
4445
+ runGenAiSpanStart(options, span, call);
4419
4446
  const result = await callInvoke(graphInstance, () => Reflect.apply(target, thisArg, args));
4420
4447
  if (recording.recordOutputs) setResponseAttributes(span, inputMessages, result);
4448
+ runGenAiSpanEnd(options, span, call, { response: result });
4421
4449
  return result;
4422
4450
  } catch (error) {
4423
4451
  span.setStatus({
4424
4452
  code: _sentry_core.SPAN_STATUS_ERROR,
4425
4453
  message: "internal_error"
4426
4454
  });
4455
+ runGenAiSpanEnd(options, span, call, { error });
4427
4456
  throw error;
4428
4457
  }
4429
4458
  });
@@ -5420,7 +5449,7 @@ const MAX_SUMMARY_LENGTH = 255;
5420
5449
  const IDENTIFIER = "(?:\"[^\"]*\"|'[^']*'|`[^`]*`|[^\\s(,;).'\"`]+)";
5421
5450
  const TABLE_NAME = `${IDENTIFIER}(?:\\.${IDENTIFIER})*`;
5422
5451
  const DDL_RE = new RegExp(`^\\s*(?<operation>(?:CREATE|DROP)\\s+(?:TABLE|INDEX)|ALTER\\s+TABLE)(?:\\s+IF\\s+(?:NOT\\s+)?EXISTS)?\\s+(?<table>${TABLE_NAME})`, "i");
5423
- const INSERT_RE = new RegExp(`^\\s*(?<operation>INSERT|REPLACE)(?:\\s+OR\\s+(?:ROLLBACK|ABORT|FAIL|IGNORE|REPLACE))?\\s+INTO\\s+(?<table>${TABLE_NAME})`, "i");
5452
+ const INSERT_RE = new RegExp(`^\\s*(?<operation>INSERT|REPLACE)(?:\\s+OR\\s+(?:ROLLBACK|ABORT|FAIL|IGNORE|REPLACE))?\\s+INTO(?:\\s+TABLE)?\\s+(?<table>${TABLE_NAME})`, "i");
5424
5453
  const UPDATE_RE = new RegExp(`^\\s*(?<operation>UPDATE)(?:\\s+OR\\s+(?:ROLLBACK|ABORT|FAIL|IGNORE|REPLACE))?\\s+(?<table>${TABLE_NAME})`, "i");
5425
5454
  const DELETE_RE = new RegExp(`^\\s*(?<operation>DELETE)\\s+FROM\\s+(?<table>${TABLE_NAME})`, "i");
5426
5455
  const SELECT_RE = /^\s*(?:\(\s*)?(?<operation>SELECT)\b/i;
@@ -5506,8 +5535,9 @@ function extractTableNames(sql) {
5506
5535
  TOKEN_RE.lastIndex = 0;
5507
5536
  let match;
5508
5537
  while ((match = TOKEN_RE.exec(sql)) !== null) {
5509
- if (match[1] || match[2]) {
5510
- tables.push(match[1] || match[2]);
5538
+ const table = match[1] || match[2];
5539
+ if (table) {
5540
+ tables.push(table);
5511
5541
  continue;
5512
5542
  }
5513
5543
  const rest = sql.slice(match.index + match[0].length);
@@ -5563,6 +5593,7 @@ function toSqlDialect(system) {
5563
5593
  if (system === "mssql" || system === "sqlserver" || system === "microsoft.sql_server") return "mssql";
5564
5594
  return "standard";
5565
5595
  }
5596
+ const NO_RULES = {};
5566
5597
  const DOLLAR_QUOTE_RE = /\$(?:[A-Za-z_]\w*)?\$/y;
5567
5598
  /**
5568
5599
  * Returns the index just past the run's closing `delimiter`, or -1 if the run never closes. The
@@ -5583,6 +5614,18 @@ function findQuotedRunEnd(sql, start, delimiter, backslashEscapes) {
5583
5614
  }
5584
5615
  return -1;
5585
5616
  }
5617
+ function findBlockCommentEnd(sql, start, nested) {
5618
+ let depth = 1;
5619
+ let i = start + 2;
5620
+ while (i < sql.length && depth > 0) if (sql[i] === "*" && sql[i + 1] === "/") {
5621
+ depth--;
5622
+ i += 2;
5623
+ } else if (nested && sql[i] === "/" && sql[i + 1] === "*") {
5624
+ depth++;
5625
+ i += 2;
5626
+ } else i++;
5627
+ return i;
5628
+ }
5586
5629
  /**
5587
5630
  * Replaces every string literal with `?` and drops every comment, in one pass.
5588
5631
  *
@@ -5595,24 +5638,25 @@ function findQuotedRunEnd(sql, start, delimiter, backslashEscapes) {
5595
5638
  * built from.
5596
5639
  */
5597
5640
  function stripLiteralsAndComments(sql, dialect) {
5598
- const isMysql = dialect === "mysql";
5641
+ const [base, rules] = typeof dialect === "string" ? [dialect, NO_RULES] : ["standard", dialect];
5642
+ const isMysql = base === "mysql";
5643
+ const backslashEscapes = !!rules.backslashEscapes;
5599
5644
  const out = [];
5600
5645
  let i = 0;
5601
5646
  while (i < sql.length) {
5602
- const char = sql[i];
5647
+ const char = sql.charAt(i);
5603
5648
  const next = sql[i + 1];
5604
- if (char === "-" && next === "-" || isMysql && char === "#") {
5649
+ if (char === "-" && next === "-" || (isMysql || rules.hashComments) && char === "#") {
5605
5650
  const lineEnd = sql.indexOf("\n", i);
5606
5651
  i = lineEnd === -1 ? sql.length : lineEnd;
5607
5652
  continue;
5608
5653
  }
5609
5654
  if (char === "/" && next === "*") {
5610
- const commentEnd = sql.indexOf("*/", i + 2);
5611
- i = commentEnd === -1 ? sql.length : commentEnd + 2;
5655
+ i = findBlockCommentEnd(sql, i, !!rules.nestedComments);
5612
5656
  continue;
5613
5657
  }
5614
- if (dialect === "standard" && char === "$" && !isIdentifierChar(sql[i - 1])) {
5615
- const tag = matchDollarQuoteTag(sql, i);
5658
+ if (base === "standard" && char === "$" && !isIdentifierChar(sql[i - 1])) {
5659
+ const tag = matchDollarQuoteTag(sql, i, rules.dollarQuote);
5616
5660
  if (tag) {
5617
5661
  const bodyEnd = sql.indexOf(tag, i + tag.length);
5618
5662
  i = bodyEnd === -1 ? sql.length : bodyEnd + tag.length;
@@ -5620,21 +5664,28 @@ function stripLiteralsAndComments(sql, dialect) {
5620
5664
  continue;
5621
5665
  }
5622
5666
  }
5623
- const identifierCloser = getIdentifierCloser(char, dialect);
5667
+ const identifierCloser = getIdentifierCloser(char, base);
5624
5668
  if (identifierCloser) {
5625
- const runEnd = findQuotedRunEnd(sql, i, identifierCloser, false);
5669
+ const runEnd = findQuotedRunEnd(sql, i, identifierCloser, backslashEscapes);
5626
5670
  out.push(runEnd === -1 ? "?" : sql.slice(i, runEnd));
5627
5671
  i = runEnd === -1 ? sql.length : runEnd;
5628
5672
  continue;
5629
5673
  }
5630
5674
  if (char === "'" || char === "\"" && isMysql) {
5631
- const prefix = char === "'" ? getLiteralPrefix(out, dialect) : void 0;
5675
+ const prefix = char === "'" ? getLiteralPrefix(out, base) : void 0;
5632
5676
  if (prefix) out.pop();
5633
- const runEnd = findQuotedRunEnd(sql, i, char, isMysql || prefix === "E");
5677
+ const runEnd = findQuotedRunEnd(sql, i, char, isMysql || backslashEscapes || prefix === "E");
5634
5678
  i = runEnd === -1 ? sql.length : runEnd;
5635
5679
  out.push("?");
5636
5680
  continue;
5637
5681
  }
5682
+ const literalLength = rules.matchLiteral?.(sql, i);
5683
+ if (literalLength) {
5684
+ out.push("?");
5685
+ i += literalLength;
5686
+ continue;
5687
+ }
5688
+ if (rules.isInlineData?.(sql, i, out)) break;
5638
5689
  out.push(char);
5639
5690
  i++;
5640
5691
  }
@@ -5655,9 +5706,9 @@ function isIdentifierChar(char) {
5655
5706
  return char !== void 0 && /[\w$]/.test(char);
5656
5707
  }
5657
5708
  /** Returns the opening dollar-quote tag at `start` (`$$` or `$tag$`), or undefined if there is none. */
5658
- function matchDollarQuoteTag(sql, start) {
5659
- DOLLAR_QUOTE_RE.lastIndex = start;
5660
- return DOLLAR_QUOTE_RE.exec(sql)?.[0];
5709
+ function matchDollarQuoteTag(sql, start, pattern = DOLLAR_QUOTE_RE) {
5710
+ pattern.lastIndex = start;
5711
+ return pattern.exec(sql)?.[0];
5661
5712
  }
5662
5713
  /**
5663
5714
  * Returns the literal-prefix character immediately before a `'`, if there is one: `X`/`B` for
@@ -5680,7 +5731,7 @@ function getLiteralPrefix(out, dialect) {
5680
5731
  * booleans) are sanitized.
5681
5732
  *
5682
5733
  * Pass `dialect` when the statement comes from a driver whose literals are not standard-quoted;
5683
- * see {@link SqlDialect}.
5734
+ * see {@link SqlDialect} and {@link SqlLexerRules}.
5684
5735
  */
5685
5736
  function sanitizeSqlQuery(sqlQuery, dialect = "standard") {
5686
5737
  if (!sqlQuery) return "Unknown SQL Query";
@@ -5722,6 +5773,90 @@ function getSqlSpanName(attributes, fallback) {
5722
5773
  function toSpanName(value, fallback) {
5723
5774
  return typeof value === "string" && value ? value : fallback;
5724
5775
  }
5776
+ // src/utils/installedModules.ts
5777
+ const NODE_MODULES = "/node_modules/";
5778
+ /**
5779
+ * Returns the app's packages: the dependencies declared in its `package.json`, plus loaded packages. Each gets the exact
5780
+ * version that a bare import from the app resolves through `node_modules`, or its declared range otherwise.
5781
+ */
5782
+ function collectInstalledModules({ readFile, entryPath, cwd, loadedFiles = [] }) {
5783
+ const read = (dir) => {
5784
+ try {
5785
+ return JSON.parse(readFile(join(dir, "package.json")) || "null") || void 0;
5786
+ } catch {
5787
+ return;
5788
+ }
5789
+ };
5790
+ const entryDir = entryPath && dirname(toPosix(entryPath));
5791
+ const cwdDir = cwd && toPosix(cwd);
5792
+ const appRoot = findAppRoot(read, entryDir && cwdDir && !isIn(entryDir, cwdDir) ? [cwdDir, entryDir] : [entryDir, cwdDir]);
5793
+ const resolveFrom = entryDir && appRoot && isIn(entryDir, appRoot) && !inNodeModules(entryDir) ? entryDir : appRoot || entryDir || cwdDir;
5794
+ const nodeModulesDirs = resolveFrom ? ancestors(resolveFrom).map((dir) => join(dir, "node_modules")) : [];
5795
+ const resolve = (name) => {
5796
+ for (const dir of nodeModulesDirs) {
5797
+ const version = read(join(dir, name))?.version;
5798
+ if (version) return version;
5799
+ }
5800
+ };
5801
+ const pkg = appRoot ? read(appRoot) : void 0;
5802
+ const declared = {
5803
+ ...pkg?.dependencies,
5804
+ ...pkg?.devDependencies
5805
+ };
5806
+ const installed = {};
5807
+ const seen = /* @__PURE__ */ new Set();
5808
+ for (const file of loadedFiles) {
5809
+ const path = toPosix(file);
5810
+ const start = path.lastIndexOf(NODE_MODULES) + 14;
5811
+ const [first = "", second] = path.slice(start).split("/");
5812
+ const name = first.startsWith("@") ? `${first}/${second}` : first;
5813
+ const dir = path.slice(0, start) + name;
5814
+ if (start < 14 || seen.has(dir) || !nodeModulesDirs.some((d) => isIn(path, d))) continue;
5815
+ seen.add(dir);
5816
+ const version = read(dir)?.version;
5817
+ if (version && installed[name] !== version) installed[name] = name in installed && resolve(name) || installed[name] || version;
5818
+ }
5819
+ for (const name of Object.keys(declared)) {
5820
+ const version = resolve(name);
5821
+ if (version) installed[name] = version;
5822
+ }
5823
+ return {
5824
+ ...declared,
5825
+ ...installed
5826
+ };
5827
+ }
5828
+ /** Skips start dirs inside `node_modules` and `package.json` files that only set fields like `"type"`. */
5829
+ function findAppRoot(read, startDirs) {
5830
+ for (const startDir of startDirs) {
5831
+ const root = startDir && !inNodeModules(startDir) ? ancestors(startDir).find((dir) => {
5832
+ const pkg = read(dir);
5833
+ return pkg && (pkg.name || pkg.dependencies || pkg.devDependencies);
5834
+ }) : void 0;
5835
+ if (root) return root;
5836
+ }
5837
+ }
5838
+ function inNodeModules(dir) {
5839
+ return `${dir}/`.includes(NODE_MODULES);
5840
+ }
5841
+ /** `dir` and its parents, up to the root. */
5842
+ function ancestors(dir) {
5843
+ const dirs = [dir];
5844
+ for (let parent = dirname(dir); parent !== dirs[dirs.length - 1]; parent = dirname(parent)) dirs.push(parent);
5845
+ return dirs;
5846
+ }
5847
+ function dirname(path) {
5848
+ const index = path.lastIndexOf("/");
5849
+ return index > 0 ? path.slice(0, index) : index === 0 ? "/" : path;
5850
+ }
5851
+ function join(dir, name) {
5852
+ return dir.endsWith("/") ? dir + name : `${dir}/${name}`;
5853
+ }
5854
+ function isIn(path, dir) {
5855
+ return path === dir || path.startsWith(dir.endsWith("/") ? dir : `${dir}/`);
5856
+ }
5857
+ function toPosix(path) {
5858
+ return path.replace(/\\/g, "/");
5859
+ }
5725
5860
  // src/integrations/postgresjs-wrapper.ts
5726
5861
  const CONNECTION_CONTEXT_SYMBOL = Symbol("sentryPostgresConnectionContext");
5727
5862
  const INSTRUMENTED_MARKER = Symbol.for("sentry.instrumented.postgresjs");
@@ -6302,12 +6437,13 @@ function installRouteHookOnPrototype(honoBaseProto) {
6302
6437
  require_debug_build.DEBUG_BUILD && _sentry_core.debug.log("[hono] Installed route hook on HonoBase.prototype.");
6303
6438
  return handle;
6304
6439
  }
6440
+ const ERROR_AND_NOT_FOUND_METHODS = /* @__PURE__ */ new Set(["@ERROR", "@NOT_FOUND"]);
6305
6441
  /**
6306
6442
  * Wraps the middleware handlers of a sub-app's routes in spans.
6307
6443
  */
6308
6444
  function wrapSubAppMiddleware(routes) {
6309
6445
  const middlewareFlags = getMiddlewareFlags(routes);
6310
- for (const [i, route] of routes.entries()) if (middlewareFlags[i] && typeof route.handler === "function") route.handler = wrapMiddlewareWithSpan(route.handler);
6446
+ for (const [i, route] of routes.entries()) if (middlewareFlags[i] && !ERROR_AND_NOT_FOUND_METHODS.has(route.method) && typeof route.handler === "function") route.handler = wrapMiddlewareWithSpan(route.handler);
6311
6447
  }
6312
6448
  // src/integrations/hono/applyPatches.ts
6313
6449
  let _routeHook;
@@ -6494,6 +6630,22 @@ function resolveRouteName(context, routes, middlewareFlags) {
6494
6630
  function isSentryMiddleware(handler) {
6495
6631
  return typeof handler === "function" && Boolean(Reflect.get(handler, "__SENTRY_HONO_MIDDLEWARE__"));
6496
6632
  }
6633
+ // src/integrations/hono/unwrapThrownValue.ts
6634
+ /**
6635
+ * Returns the value that a handler threw, so that `shouldHandleError` and the event get that value
6636
+ * and not Hono's wrapper.
6637
+ *
6638
+ * Hono 5 wraps a thrown non-Error before its error handlers run:
6639
+ * `new Error(typeof err === 'string' ? err : undefined, { cause: err })`.
6640
+ * The wrapper has no marker, so it is found by its shape. A user error with the same shape is also unwrapped.
6641
+ */
6642
+ function unwrapThrownValue(error) {
6643
+ if (!(0, _sentry_core.isError)(error) || error.constructor !== Error || !("cause" in error)) return error;
6644
+ const { cause } = error;
6645
+ if ((0, _sentry_core.isError)(cause)) return error;
6646
+ const wrapperMessage = typeof cause === "string" ? cause : "";
6647
+ return error.message === wrapperMessage ? cause : error;
6648
+ }
6497
6649
  // src/integrations/hono/middlewareHandlers.ts
6498
6650
  /**
6499
6651
  * Request handler for Hono framework
@@ -6567,7 +6719,8 @@ function responseHandler(context, shouldHandleError) {
6567
6719
  */
6568
6720
  function captureContextError(context, shouldHandleError) {
6569
6721
  if (context.error) {
6570
- if ((shouldHandleError ?? defaultShouldHandleError)(context.error)) (0, _sentry_core.captureException)(context.error, { mechanism: {
6722
+ const error = unwrapThrownValue(context.error);
6723
+ if ((shouldHandleError ?? defaultShouldHandleError)(error)) (0, _sentry_core.captureException)(error, { mechanism: {
6571
6724
  handled: false,
6572
6725
  type: "auto.http.hono.context_error"
6573
6726
  } });
@@ -6869,6 +7022,12 @@ Object.defineProperty(exports, "applyPatches", {
6869
7022
  return applyPatches;
6870
7023
  }
6871
7024
  });
7025
+ Object.defineProperty(exports, "collectInstalledModules", {
7026
+ enumerable: true,
7027
+ get: function() {
7028
+ return collectInstalledModules;
7029
+ }
7030
+ });
6872
7031
  Object.defineProperty(exports, "createFlueInstrumentation", {
6873
7032
  enumerable: true,
6874
7033
  get: function() {
@@ -7223,6 +7382,12 @@ Object.defineProperty(exports, "isDeno", {
7223
7382
  return isDeno;
7224
7383
  }
7225
7384
  });
7385
+ Object.defineProperty(exports, "isIdentifierChar", {
7386
+ enumerable: true,
7387
+ get: function() {
7388
+ return isIdentifierChar;
7389
+ }
7390
+ });
7226
7391
  Object.defineProperty(exports, "isInsideManualLangGraphInstrumentation", {
7227
7392
  enumerable: true,
7228
7393
  get: function() {