@sentry/cloudflare 10.68.0 → 11.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (759) hide show
  1. package/README.md +3 -7
  2. package/build/cjs/dev/baseSdk.js +83 -0
  3. package/build/cjs/dev/baseSdk.js.map +1 -0
  4. package/build/cjs/{client.js → dev/client.js} +5 -0
  5. package/build/cjs/dev/client.js.map +1 -0
  6. package/build/cjs/dev/debug-build.js.map +1 -0
  7. package/build/cjs/dev/defineCloudflareOptions.js.map +1 -0
  8. package/build/cjs/dev/durableobject.js +234 -0
  9. package/build/cjs/dev/durableobject.js.map +1 -0
  10. package/build/cjs/dev/flush.js.map +1 -0
  11. package/build/cjs/{index.js → dev/index.js} +18 -17
  12. package/build/cjs/{index.js.map → dev/index.js.map} +1 -1
  13. package/build/cjs/dev/instrument.js.map +1 -0
  14. package/build/cjs/dev/instrumentations/agents/index.js +16 -0
  15. package/build/cjs/dev/instrumentations/agents/index.js.map +1 -0
  16. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js +52 -0
  17. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  18. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js +19 -0
  19. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  20. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js +31 -0
  21. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  22. package/build/cjs/dev/instrumentations/agents/types.js +77 -0
  23. package/build/cjs/dev/instrumentations/agents/types.js.map +1 -0
  24. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  25. package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectStorage.js +6 -0
  26. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  27. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  28. package/build/cjs/{instrumentations → dev/instrumentations}/instrumentSqlStorage.js +1 -1
  29. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -0
  30. package/build/cjs/{instrumentations → dev/instrumentations}/instrumentWorkerEntrypoint.js +3 -3
  31. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  32. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentD1.js +0 -4
  33. package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -0
  34. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentEmail.js +3 -1
  35. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -0
  36. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentEnv.js +3 -4
  37. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -0
  38. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentFetch.js +9 -3
  39. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -0
  40. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -0
  41. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentQueue.js +3 -2
  42. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -0
  43. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  44. package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -0
  45. package/build/cjs/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  46. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentScheduled.js +3 -1
  47. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -0
  48. package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -0
  49. package/build/cjs/{integrations → dev/integrations}/fetch.js +1 -1
  50. package/build/cjs/dev/integrations/fetch.js.map +1 -0
  51. package/build/cjs/{integrations → dev/integrations}/httpServer.js +5 -4
  52. package/build/cjs/dev/integrations/httpServer.js.map +1 -0
  53. package/build/cjs/dev/integrations/spotlight.js +64 -0
  54. package/build/cjs/dev/integrations/spotlight.js.map +1 -0
  55. package/build/cjs/{nodejs_compat → dev}/integrations/tracing/vercelai.js +6 -6
  56. package/build/cjs/dev/integrations/tracing/vercelai.js.map +1 -0
  57. package/build/cjs/dev/opentelemetry/tracer.js.map +1 -0
  58. package/build/cjs/dev/options.js +50 -0
  59. package/build/cjs/dev/options.js.map +1 -0
  60. package/build/cjs/{pages-plugin.js → dev/pages-plugin.js} +8 -3
  61. package/build/cjs/dev/pages-plugin.js.map +1 -0
  62. package/build/cjs/{request.js → dev/request.js} +23 -12
  63. package/build/cjs/dev/request.js.map +1 -0
  64. package/build/cjs/dev/scope-utils.js.map +1 -0
  65. package/build/cjs/dev/sdk.js +19 -0
  66. package/build/cjs/dev/sdk.js.map +1 -0
  67. package/build/cjs/dev/transport.js.map +1 -0
  68. package/build/cjs/{utils → dev/utils}/instrumentContext.js +8 -13
  69. package/build/cjs/dev/utils/instrumentContext.js.map +1 -0
  70. package/build/cjs/dev/utils/internalSqlQuery.js +25 -0
  71. package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -0
  72. package/build/cjs/dev/utils/internalStorageKey.js +44 -0
  73. package/build/cjs/dev/utils/internalStorageKey.js.map +1 -0
  74. package/build/cjs/dev/utils/invocationScope.js +12 -0
  75. package/build/cjs/dev/utils/invocationScope.js.map +1 -0
  76. package/build/cjs/dev/utils/isBinding.js.map +1 -0
  77. package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -0
  78. package/build/cjs/{utils → dev/utils}/rpcMeta.js +4 -0
  79. package/build/cjs/dev/utils/rpcMeta.js.map +1 -0
  80. package/build/cjs/dev/utils/streaming.js.map +1 -0
  81. package/build/cjs/dev/utils/traceLinks.js.map +1 -0
  82. package/build/cjs/dev/vendor/stacktrace.js.map +1 -0
  83. package/build/cjs/dev/vite/agentClass.js +114 -0
  84. package/build/cjs/dev/vite/agentClass.js.map +1 -0
  85. package/build/cjs/{vite → dev/vite}/autoInstrument.js +17 -4
  86. package/build/cjs/dev/vite/autoInstrument.js.map +1 -0
  87. package/build/cjs/{vite → dev/vite}/index.js +4 -2
  88. package/build/cjs/dev/vite/index.js.map +1 -0
  89. package/build/cjs/dev/vite/instrumentFile.js.map +1 -0
  90. package/build/cjs/dev/vite/moduleShape.js +231 -0
  91. package/build/cjs/dev/vite/moduleShape.js.map +1 -0
  92. package/build/cjs/{vite → dev/vite}/transform.js +6 -1
  93. package/build/cjs/dev/vite/transform.js.map +1 -0
  94. package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -0
  95. package/build/cjs/{vite → dev/vite}/wranglerConfig.js +1 -1
  96. package/build/cjs/dev/vite/wranglerConfig.js.map +1 -0
  97. package/build/cjs/{withSentry.js → dev/withSentry.js} +2 -19
  98. package/build/cjs/dev/withSentry.js.map +1 -0
  99. package/build/cjs/{workflows.js → dev/workflows.js} +9 -4
  100. package/build/cjs/dev/workflows.js.map +1 -0
  101. package/build/cjs/{wrapMethodWithSentry.js → dev/wrapMethodWithSentry.js} +2 -3
  102. package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -0
  103. package/build/cjs/{sdk.js → prod/baseSdk.js} +25 -17
  104. package/build/cjs/prod/baseSdk.js.map +1 -0
  105. package/build/cjs/prod/client.js +122 -0
  106. package/build/cjs/prod/client.js.map +1 -0
  107. package/build/cjs/prod/debug-build.js +6 -0
  108. package/build/cjs/prod/debug-build.js.map +1 -0
  109. package/build/cjs/prod/defineCloudflareOptions.js +11 -0
  110. package/build/cjs/prod/defineCloudflareOptions.js.map +1 -0
  111. package/build/cjs/prod/durableobject.js +234 -0
  112. package/build/cjs/prod/durableobject.js.map +1 -0
  113. package/build/cjs/prod/flush.js +87 -0
  114. package/build/cjs/prod/flush.js.map +1 -0
  115. package/build/cjs/{nodejs_compat → prod}/index.js +34 -35
  116. package/build/cjs/{nodejs_compat → prod}/index.js.map +1 -1
  117. package/build/cjs/prod/instrument.js +52 -0
  118. package/build/cjs/prod/instrument.js.map +1 -0
  119. package/build/cjs/prod/instrumentations/agents/index.js +16 -0
  120. package/build/cjs/prod/instrumentations/agents/index.js.map +1 -0
  121. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +52 -0
  122. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  123. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +19 -0
  124. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  125. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +31 -0
  126. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  127. package/build/cjs/prod/instrumentations/agents/types.js +77 -0
  128. package/build/cjs/prod/instrumentations/agents/types.js.map +1 -0
  129. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +41 -0
  130. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  131. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +72 -0
  132. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  133. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +40 -0
  134. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  135. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +42 -0
  136. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -0
  137. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +139 -0
  138. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  139. package/build/cjs/prod/instrumentations/worker/instrumentD1.js +161 -0
  140. package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -0
  141. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -0
  142. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -0
  143. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +90 -0
  144. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -0
  145. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +54 -0
  146. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -0
  147. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +24 -0
  148. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -0
  149. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +82 -0
  150. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -0
  151. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +80 -0
  152. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  153. package/build/cjs/prod/instrumentations/worker/instrumentR2.js +124 -0
  154. package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -0
  155. package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js +29 -0
  156. package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  157. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +78 -0
  158. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -0
  159. package/build/cjs/prod/instrumentations/worker/instrumentTail.js +60 -0
  160. package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -0
  161. package/build/cjs/prod/integrations/fetch.js +119 -0
  162. package/build/cjs/prod/integrations/fetch.js.map +1 -0
  163. package/build/cjs/prod/integrations/httpServer.js +36 -0
  164. package/build/cjs/prod/integrations/httpServer.js.map +1 -0
  165. package/build/cjs/prod/integrations/spotlight.js +64 -0
  166. package/build/cjs/prod/integrations/spotlight.js.map +1 -0
  167. package/build/cjs/{integrations → prod/integrations}/tracing/vercelai.js +5 -5
  168. package/build/cjs/prod/integrations/tracing/vercelai.js.map +1 -0
  169. package/build/cjs/prod/opentelemetry/tracer.js +49 -0
  170. package/build/cjs/prod/opentelemetry/tracer.js.map +1 -0
  171. package/build/cjs/{options.js → prod/options.js} +5 -1
  172. package/build/cjs/prod/options.js.map +1 -0
  173. package/build/cjs/prod/pages-plugin.js +24 -0
  174. package/build/cjs/prod/pages-plugin.js.map +1 -0
  175. package/build/cjs/prod/request.js +132 -0
  176. package/build/cjs/prod/request.js.map +1 -0
  177. package/build/cjs/prod/scope-utils.js +22 -0
  178. package/build/cjs/prod/scope-utils.js.map +1 -0
  179. package/build/cjs/prod/sdk.js +19 -0
  180. package/build/cjs/prod/sdk.js.map +1 -0
  181. package/build/cjs/prod/transport.js +75 -0
  182. package/build/cjs/prod/transport.js.map +1 -0
  183. package/build/cjs/prod/utils/instrumentContext.js +63 -0
  184. package/build/cjs/prod/utils/instrumentContext.js.map +1 -0
  185. package/build/cjs/prod/utils/internalSqlQuery.js +25 -0
  186. package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -0
  187. package/build/cjs/prod/utils/internalStorageKey.js +44 -0
  188. package/build/cjs/prod/utils/internalStorageKey.js.map +1 -0
  189. package/build/cjs/prod/utils/invocationScope.js +12 -0
  190. package/build/cjs/prod/utils/invocationScope.js.map +1 -0
  191. package/build/cjs/prod/utils/isBinding.js +37 -0
  192. package/build/cjs/prod/utils/isBinding.js.map +1 -0
  193. package/build/cjs/prod/utils/isCloudflareClass.js +23 -0
  194. package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -0
  195. package/build/cjs/prod/utils/rpcMeta.js +39 -0
  196. package/build/cjs/prod/utils/rpcMeta.js.map +1 -0
  197. package/build/cjs/prod/utils/streaming.js +16 -0
  198. package/build/cjs/prod/utils/streaming.js.map +1 -0
  199. package/build/cjs/prod/utils/traceLinks.js +54 -0
  200. package/build/cjs/prod/utils/traceLinks.js.map +1 -0
  201. package/build/cjs/prod/vendor/stacktrace.js +28 -0
  202. package/build/cjs/prod/vendor/stacktrace.js.map +1 -0
  203. package/build/cjs/prod/vite/agentClass.js +114 -0
  204. package/build/cjs/prod/vite/agentClass.js.map +1 -0
  205. package/build/cjs/prod/vite/autoInstrument.js +94 -0
  206. package/build/cjs/prod/vite/autoInstrument.js.map +1 -0
  207. package/build/cjs/prod/vite/index.js +16 -0
  208. package/build/cjs/prod/vite/index.js.map +1 -0
  209. package/build/cjs/prod/vite/instrumentFile.js +31 -0
  210. package/build/cjs/prod/vite/instrumentFile.js.map +1 -0
  211. package/build/cjs/prod/vite/moduleShape.js +231 -0
  212. package/build/cjs/prod/vite/moduleShape.js.map +1 -0
  213. package/build/cjs/prod/vite/transform.js +149 -0
  214. package/build/cjs/prod/vite/transform.js.map +1 -0
  215. package/build/cjs/prod/vite/workerEntrypoint.js +66 -0
  216. package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -0
  217. package/build/cjs/prod/vite/wranglerConfig.js +54 -0
  218. package/build/cjs/prod/vite/wranglerConfig.js.map +1 -0
  219. package/build/cjs/prod/withSentry.js +29 -0
  220. package/build/cjs/prod/withSentry.js.map +1 -0
  221. package/build/cjs/prod/workflows.js +139 -0
  222. package/build/cjs/prod/workflows.js.map +1 -0
  223. package/build/cjs/prod/wrapMethodWithSentry.js +134 -0
  224. package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -0
  225. package/build/esm/dev/baseSdk.js +79 -0
  226. package/build/esm/dev/baseSdk.js.map +1 -0
  227. package/build/esm/{client.js → dev/client.js} +6 -1
  228. package/build/esm/dev/client.js.map +1 -0
  229. package/build/esm/dev/debug-build.js.map +1 -0
  230. package/build/esm/dev/defineCloudflareOptions.js.map +1 -0
  231. package/build/esm/dev/durableobject.js +229 -0
  232. package/build/esm/dev/durableobject.js.map +1 -0
  233. package/build/esm/dev/flush.js.map +1 -0
  234. package/build/esm/dev/index.js +15 -0
  235. package/build/esm/{index.js.map → dev/index.js.map} +1 -1
  236. package/build/esm/dev/instrument.js.map +1 -0
  237. package/build/esm/dev/instrumentations/agents/index.js +14 -0
  238. package/build/esm/dev/instrumentations/agents/index.js.map +1 -0
  239. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js +50 -0
  240. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  241. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js +17 -0
  242. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  243. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js +29 -0
  244. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  245. package/build/esm/dev/instrumentations/agents/types.js +69 -0
  246. package/build/esm/dev/instrumentations/agents/types.js.map +1 -0
  247. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  248. package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectStorage.js +7 -1
  249. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  250. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  251. package/build/esm/{instrumentations → dev/instrumentations}/instrumentSqlStorage.js +1 -1
  252. package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -0
  253. package/build/esm/{instrumentations → dev/instrumentations}/instrumentWorkerEntrypoint.js +2 -2
  254. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  255. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentD1.js +1 -4
  256. package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -0
  257. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentEmail.js +3 -1
  258. package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -0
  259. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentEnv.js +3 -4
  260. package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -0
  261. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentFetch.js +10 -4
  262. package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -0
  263. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -0
  264. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentQueue.js +4 -3
  265. package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -0
  266. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  267. package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -0
  268. package/build/esm/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  269. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentScheduled.js +3 -1
  270. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -0
  271. package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -0
  272. package/build/esm/{integrations → dev/integrations}/fetch.js +1 -1
  273. package/build/esm/dev/integrations/fetch.js.map +1 -0
  274. package/build/esm/{integrations → dev/integrations}/httpServer.js +5 -4
  275. package/build/esm/dev/integrations/httpServer.js.map +1 -0
  276. package/build/esm/dev/integrations/spotlight.js +61 -0
  277. package/build/esm/dev/integrations/spotlight.js.map +1 -0
  278. package/build/esm/{integrations → dev/integrations}/tracing/vercelai.js +5 -5
  279. package/build/esm/dev/integrations/tracing/vercelai.js.map +1 -0
  280. package/build/esm/dev/opentelemetry/tracer.js.map +1 -0
  281. package/build/esm/dev/options.js +48 -0
  282. package/build/esm/dev/options.js.map +1 -0
  283. package/build/esm/dev/package.json +1 -0
  284. package/build/esm/{pages-plugin.js → dev/pages-plugin.js} +8 -3
  285. package/build/esm/dev/pages-plugin.js.map +1 -0
  286. package/build/esm/{request.js → dev/request.js} +24 -14
  287. package/build/esm/dev/request.js.map +1 -0
  288. package/build/esm/dev/scope-utils.js.map +1 -0
  289. package/build/esm/dev/sdk.js +16 -0
  290. package/build/esm/dev/sdk.js.map +1 -0
  291. package/build/esm/dev/transport.js.map +1 -0
  292. package/build/esm/{utils → dev/utils}/instrumentContext.js +8 -13
  293. package/build/esm/dev/utils/instrumentContext.js.map +1 -0
  294. package/build/esm/dev/utils/internalSqlQuery.js +23 -0
  295. package/build/esm/dev/utils/internalSqlQuery.js.map +1 -0
  296. package/build/esm/dev/utils/internalStorageKey.js +41 -0
  297. package/build/esm/dev/utils/internalStorageKey.js.map +1 -0
  298. package/build/esm/dev/utils/invocationScope.js +10 -0
  299. package/build/esm/dev/utils/invocationScope.js.map +1 -0
  300. package/build/esm/dev/utils/isBinding.js.map +1 -0
  301. package/build/esm/dev/utils/isCloudflareClass.js.map +1 -0
  302. package/build/esm/{utils → dev/utils}/rpcMeta.js +4 -1
  303. package/build/esm/dev/utils/rpcMeta.js.map +1 -0
  304. package/build/esm/dev/utils/streaming.js.map +1 -0
  305. package/build/esm/dev/utils/traceLinks.js.map +1 -0
  306. package/build/esm/dev/vendor/stacktrace.js.map +1 -0
  307. package/build/esm/dev/vite/agentClass.js +111 -0
  308. package/build/esm/dev/vite/agentClass.js.map +1 -0
  309. package/build/esm/{vite → dev/vite}/autoInstrument.js +17 -4
  310. package/build/esm/dev/vite/autoInstrument.js.map +1 -0
  311. package/build/esm/{vite → dev/vite}/index.js +4 -2
  312. package/build/esm/dev/vite/index.js.map +1 -0
  313. package/build/esm/dev/vite/instrumentFile.js.map +1 -0
  314. package/build/esm/dev/vite/moduleShape.js +227 -0
  315. package/build/esm/dev/vite/moduleShape.js.map +1 -0
  316. package/build/esm/{vite → dev/vite}/transform.js +6 -1
  317. package/build/esm/dev/vite/transform.js.map +1 -0
  318. package/build/esm/dev/vite/workerEntrypoint.js.map +1 -0
  319. package/build/esm/{vite → dev/vite}/wranglerConfig.js +1 -1
  320. package/build/esm/dev/vite/wranglerConfig.js.map +1 -0
  321. package/build/esm/{withSentry.js → dev/withSentry.js} +1 -18
  322. package/build/esm/dev/withSentry.js.map +1 -0
  323. package/build/esm/{workflows.js → dev/workflows.js} +9 -4
  324. package/build/esm/dev/workflows.js.map +1 -0
  325. package/build/esm/{wrapMethodWithSentry.js → dev/wrapMethodWithSentry.js} +3 -4
  326. package/build/esm/dev/wrapMethodWithSentry.js.map +1 -0
  327. package/build/esm/{sdk.js → prod/baseSdk.js} +24 -17
  328. package/build/esm/prod/baseSdk.js.map +1 -0
  329. package/build/esm/prod/client.js +120 -0
  330. package/build/esm/prod/client.js.map +1 -0
  331. package/build/esm/prod/debug-build.js +4 -0
  332. package/build/esm/prod/debug-build.js.map +1 -0
  333. package/build/esm/prod/defineCloudflareOptions.js +9 -0
  334. package/build/esm/prod/defineCloudflareOptions.js.map +1 -0
  335. package/build/esm/prod/durableobject.js +229 -0
  336. package/build/esm/prod/durableobject.js.map +1 -0
  337. package/build/esm/prod/flush.js +83 -0
  338. package/build/esm/prod/flush.js.map +1 -0
  339. package/build/esm/prod/index.js +15 -0
  340. package/build/esm/{nodejs_compat → prod}/index.js.map +1 -1
  341. package/build/esm/prod/instrument.js +48 -0
  342. package/build/esm/prod/instrument.js.map +1 -0
  343. package/build/esm/prod/instrumentations/agents/index.js +14 -0
  344. package/build/esm/prod/instrumentations/agents/index.js.map +1 -0
  345. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +50 -0
  346. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  347. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +17 -0
  348. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  349. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +29 -0
  350. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  351. package/build/esm/prod/instrumentations/agents/types.js +69 -0
  352. package/build/esm/prod/instrumentations/agents/types.js.map +1 -0
  353. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +38 -0
  354. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  355. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -0
  356. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  357. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +38 -0
  358. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  359. package/build/esm/prod/instrumentations/instrumentSqlStorage.js +40 -0
  360. package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -0
  361. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +137 -0
  362. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  363. package/build/esm/prod/instrumentations/worker/instrumentD1.js +159 -0
  364. package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -0
  365. package/build/esm/prod/instrumentations/worker/instrumentEmail.js +61 -0
  366. package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -0
  367. package/build/esm/prod/instrumentations/worker/instrumentEnv.js +88 -0
  368. package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -0
  369. package/build/esm/prod/instrumentations/worker/instrumentFetch.js +51 -0
  370. package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -0
  371. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +22 -0
  372. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -0
  373. package/build/esm/prod/instrumentations/worker/instrumentQueue.js +79 -0
  374. package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -0
  375. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +78 -0
  376. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  377. package/build/esm/prod/instrumentations/worker/instrumentR2.js +122 -0
  378. package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -0
  379. package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js +27 -0
  380. package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  381. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +75 -0
  382. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -0
  383. package/build/esm/prod/instrumentations/worker/instrumentTail.js +57 -0
  384. package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -0
  385. package/build/esm/prod/integrations/fetch.js +117 -0
  386. package/build/esm/prod/integrations/fetch.js.map +1 -0
  387. package/build/esm/prod/integrations/httpServer.js +33 -0
  388. package/build/esm/prod/integrations/httpServer.js.map +1 -0
  389. package/build/esm/prod/integrations/spotlight.js +61 -0
  390. package/build/esm/prod/integrations/spotlight.js.map +1 -0
  391. package/build/esm/prod/integrations/tracing/vercelai.js +16 -0
  392. package/build/esm/prod/integrations/tracing/vercelai.js.map +1 -0
  393. package/build/esm/prod/opentelemetry/tracer.js +47 -0
  394. package/build/esm/prod/opentelemetry/tracer.js.map +1 -0
  395. package/build/esm/{options.js → prod/options.js} +5 -1
  396. package/build/esm/prod/options.js.map +1 -0
  397. package/build/esm/prod/package.json +1 -0
  398. package/build/esm/prod/pages-plugin.js +22 -0
  399. package/build/esm/prod/pages-plugin.js.map +1 -0
  400. package/build/esm/prod/request.js +129 -0
  401. package/build/esm/prod/request.js.map +1 -0
  402. package/build/esm/prod/scope-utils.js +18 -0
  403. package/build/esm/prod/scope-utils.js.map +1 -0
  404. package/build/esm/prod/sdk.js +16 -0
  405. package/build/esm/prod/sdk.js.map +1 -0
  406. package/build/esm/prod/transport.js +72 -0
  407. package/build/esm/prod/transport.js.map +1 -0
  408. package/build/esm/prod/utils/instrumentContext.js +61 -0
  409. package/build/esm/prod/utils/instrumentContext.js.map +1 -0
  410. package/build/esm/prod/utils/internalSqlQuery.js +23 -0
  411. package/build/esm/prod/utils/internalSqlQuery.js.map +1 -0
  412. package/build/esm/prod/utils/internalStorageKey.js +41 -0
  413. package/build/esm/prod/utils/internalStorageKey.js.map +1 -0
  414. package/build/esm/prod/utils/invocationScope.js +10 -0
  415. package/build/esm/prod/utils/invocationScope.js.map +1 -0
  416. package/build/esm/prod/utils/isBinding.js +29 -0
  417. package/build/esm/prod/utils/isBinding.js.map +1 -0
  418. package/build/esm/prod/utils/isCloudflareClass.js +21 -0
  419. package/build/esm/prod/utils/isCloudflareClass.js.map +1 -0
  420. package/build/esm/prod/utils/rpcMeta.js +35 -0
  421. package/build/esm/prod/utils/rpcMeta.js.map +1 -0
  422. package/build/esm/prod/utils/streaming.js +14 -0
  423. package/build/esm/prod/utils/streaming.js.map +1 -0
  424. package/build/esm/prod/utils/traceLinks.js +49 -0
  425. package/build/esm/prod/utils/traceLinks.js.map +1 -0
  426. package/build/esm/prod/vendor/stacktrace.js +25 -0
  427. package/build/esm/prod/vendor/stacktrace.js.map +1 -0
  428. package/build/esm/prod/vite/agentClass.js +111 -0
  429. package/build/esm/prod/vite/agentClass.js.map +1 -0
  430. package/build/esm/prod/vite/autoInstrument.js +92 -0
  431. package/build/esm/prod/vite/autoInstrument.js.map +1 -0
  432. package/build/esm/prod/vite/index.js +14 -0
  433. package/build/esm/prod/vite/index.js.map +1 -0
  434. package/build/esm/prod/vite/instrumentFile.js +27 -0
  435. package/build/esm/prod/vite/instrumentFile.js.map +1 -0
  436. package/build/esm/prod/vite/moduleShape.js +227 -0
  437. package/build/esm/prod/vite/moduleShape.js.map +1 -0
  438. package/build/esm/prod/vite/transform.js +147 -0
  439. package/build/esm/prod/vite/transform.js.map +1 -0
  440. package/build/esm/prod/vite/workerEntrypoint.js +64 -0
  441. package/build/esm/prod/vite/workerEntrypoint.js.map +1 -0
  442. package/build/esm/prod/vite/wranglerConfig.js +52 -0
  443. package/build/esm/prod/vite/wranglerConfig.js.map +1 -0
  444. package/build/esm/prod/withSentry.js +27 -0
  445. package/build/esm/prod/withSentry.js.map +1 -0
  446. package/build/esm/prod/workflows.js +136 -0
  447. package/build/esm/prod/workflows.js.map +1 -0
  448. package/build/esm/prod/wrapMethodWithSentry.js +132 -0
  449. package/build/esm/prod/wrapMethodWithSentry.js.map +1 -0
  450. package/build/types/baseSdk.d.ts +28 -0
  451. package/build/types/baseSdk.d.ts.map +1 -0
  452. package/build/types/client.d.ts +43 -33
  453. package/build/types/client.d.ts.map +1 -1
  454. package/build/types/defineCloudflareOptions.d.ts +2 -2
  455. package/build/types/defineCloudflareOptions.d.ts.map +1 -1
  456. package/build/types/durableobject.d.ts +93 -2
  457. package/build/types/durableobject.d.ts.map +1 -1
  458. package/build/types/flush.d.ts +1 -1
  459. package/build/types/flush.d.ts.map +1 -1
  460. package/build/types/index.d.ts +5 -6
  461. package/build/types/index.d.ts.map +1 -1
  462. package/build/types/instrumentations/agents/index.d.ts +25 -0
  463. package/build/types/instrumentations/agents/index.d.ts.map +1 -0
  464. package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts +14 -0
  465. package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts.map +1 -0
  466. package/build/types/instrumentations/agents/instrumentAgentRequestConversation.d.ts +16 -0
  467. package/build/types/instrumentations/agents/instrumentAgentRequestConversation.d.ts.map +1 -0
  468. package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts +23 -0
  469. package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts.map +1 -0
  470. package/build/types/instrumentations/agents/types.d.ts +94 -0
  471. package/build/types/instrumentations/agents/types.d.ts.map +1 -0
  472. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
  473. package/build/types/instrumentations/instrumentSqlStorage.d.ts.map +1 -1
  474. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +2 -1
  475. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -1
  476. package/build/types/instrumentations/worker/instrumentD1.d.ts +0 -16
  477. package/build/types/instrumentations/worker/instrumentD1.d.ts.map +1 -1
  478. package/build/types/instrumentations/worker/instrumentEmail.d.ts +2 -2
  479. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  480. package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -1
  481. package/build/types/instrumentations/worker/instrumentFetch.d.ts +2 -2
  482. package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
  483. package/build/types/instrumentations/worker/instrumentQueue.d.ts +2 -2
  484. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  485. package/build/types/instrumentations/worker/instrumentScheduled.d.ts +2 -2
  486. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  487. package/build/types/instrumentations/worker/instrumentTail.d.ts +2 -2
  488. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  489. package/build/types/integrations/httpServer.d.ts.map +1 -1
  490. package/build/types/integrations/spotlight.d.ts +22 -0
  491. package/build/types/integrations/spotlight.d.ts.map +1 -0
  492. package/build/types/integrations/tracing/vercelai.d.ts +2 -9
  493. package/build/types/integrations/tracing/vercelai.d.ts.map +1 -1
  494. package/build/types/options.d.ts.map +1 -1
  495. package/build/types/pages-plugin.d.ts +1 -1
  496. package/build/types/pages-plugin.d.ts.map +1 -1
  497. package/build/types/request.d.ts +17 -2
  498. package/build/types/request.d.ts.map +1 -1
  499. package/build/types/sdk.d.ts +8 -3
  500. package/build/types/sdk.d.ts.map +1 -1
  501. package/build/types/transport.d.ts.map +1 -1
  502. package/build/types/types.d.ts +85 -0
  503. package/build/types/types.d.ts.map +1 -0
  504. package/build/types/utils/instrumentContext.d.ts.map +1 -1
  505. package/build/types/utils/internalSqlQuery.d.ts +4 -2
  506. package/build/types/utils/internalSqlQuery.d.ts.map +1 -1
  507. package/build/types/utils/internalStorageKey.d.ts +22 -0
  508. package/build/types/utils/internalStorageKey.d.ts.map +1 -0
  509. package/build/types/utils/invocationScope.d.ts +24 -0
  510. package/build/types/utils/invocationScope.d.ts.map +1 -0
  511. package/build/types/utils/isCloudflareClass.d.ts +1 -1
  512. package/build/types/utils/isCloudflareClass.d.ts.map +1 -1
  513. package/build/types/utils/rpcMeta.d.ts +8 -0
  514. package/build/types/utils/rpcMeta.d.ts.map +1 -1
  515. package/build/types/vite/agentClass.d.ts +41 -0
  516. package/build/types/vite/agentClass.d.ts.map +1 -0
  517. package/build/types/vite/autoInstrument.d.ts +7 -6
  518. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  519. package/build/types/vite/index.d.ts +31 -45
  520. package/build/types/vite/index.d.ts.map +1 -1
  521. package/build/types/vite/moduleShape.d.ts +52 -0
  522. package/build/types/vite/moduleShape.d.ts.map +1 -0
  523. package/build/types/vite/transform.d.ts +6 -1
  524. package/build/types/vite/transform.d.ts.map +1 -1
  525. package/build/types/withSentry.d.ts +2 -2
  526. package/build/types/withSentry.d.ts.map +1 -1
  527. package/build/types/workflows.d.ts +5 -4
  528. package/build/types/workflows.d.ts.map +1 -1
  529. package/build/types/wrapMethodWithSentry.d.ts +1 -1
  530. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  531. package/package.json +28 -51
  532. package/build/cjs/async.js +0 -63
  533. package/build/cjs/async.js.map +0 -1
  534. package/build/cjs/client.js.map +0 -1
  535. package/build/cjs/debug-build.js.map +0 -1
  536. package/build/cjs/defineCloudflareOptions.js.map +0 -1
  537. package/build/cjs/durableobject.js +0 -120
  538. package/build/cjs/durableobject.js.map +0 -1
  539. package/build/cjs/flush.js.map +0 -1
  540. package/build/cjs/instrument.js.map +0 -1
  541. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +0 -1
  542. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +0 -1
  543. package/build/cjs/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +0 -1
  544. package/build/cjs/instrumentations/instrumentSqlStorage.js.map +0 -1
  545. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +0 -1
  546. package/build/cjs/instrumentations/worker/instrumentD1.js.map +0 -1
  547. package/build/cjs/instrumentations/worker/instrumentEmail.js.map +0 -1
  548. package/build/cjs/instrumentations/worker/instrumentEnv.js.map +0 -1
  549. package/build/cjs/instrumentations/worker/instrumentFetch.js.map +0 -1
  550. package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +0 -1
  551. package/build/cjs/instrumentations/worker/instrumentQueue.js.map +0 -1
  552. package/build/cjs/instrumentations/worker/instrumentQueueProducer.js.map +0 -1
  553. package/build/cjs/instrumentations/worker/instrumentR2.js.map +0 -1
  554. package/build/cjs/instrumentations/worker/instrumentRateLimit.js.map +0 -1
  555. package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +0 -1
  556. package/build/cjs/instrumentations/worker/instrumentTail.js.map +0 -1
  557. package/build/cjs/integrations/fetch.js.map +0 -1
  558. package/build/cjs/integrations/hono.js +0 -52
  559. package/build/cjs/integrations/hono.js.map +0 -1
  560. package/build/cjs/integrations/httpServer.js.map +0 -1
  561. package/build/cjs/integrations/tracing/vercelai.js.map +0 -1
  562. package/build/cjs/nodejs_compat/integrations/tracing/vercelai.js.map +0 -1
  563. package/build/cjs/opentelemetry/tracer.js.map +0 -1
  564. package/build/cjs/options.js.map +0 -1
  565. package/build/cjs/pages-plugin.js.map +0 -1
  566. package/build/cjs/request.js.map +0 -1
  567. package/build/cjs/scope-utils.js.map +0 -1
  568. package/build/cjs/sdk.js.map +0 -1
  569. package/build/cjs/transport.js.map +0 -1
  570. package/build/cjs/utils/instrumentContext.js.map +0 -1
  571. package/build/cjs/utils/internalSqlQuery.js +0 -19
  572. package/build/cjs/utils/internalSqlQuery.js.map +0 -1
  573. package/build/cjs/utils/isBinding.js.map +0 -1
  574. package/build/cjs/utils/isCloudflareClass.js.map +0 -1
  575. package/build/cjs/utils/rpcMeta.js.map +0 -1
  576. package/build/cjs/utils/rpcOptions.js +0 -26
  577. package/build/cjs/utils/rpcOptions.js.map +0 -1
  578. package/build/cjs/utils/streaming.js.map +0 -1
  579. package/build/cjs/utils/traceLinks.js.map +0 -1
  580. package/build/cjs/vendor/stacktrace.js.map +0 -1
  581. package/build/cjs/vite/autoInstrument.js.map +0 -1
  582. package/build/cjs/vite/index.js.map +0 -1
  583. package/build/cjs/vite/instrumentFile.js.map +0 -1
  584. package/build/cjs/vite/transform.js.map +0 -1
  585. package/build/cjs/vite/workerEntrypoint.js.map +0 -1
  586. package/build/cjs/vite/wranglerConfig.js.map +0 -1
  587. package/build/cjs/withSentry.js.map +0 -1
  588. package/build/cjs/workflows.js.map +0 -1
  589. package/build/cjs/wrapMethodWithSentry.js.map +0 -1
  590. package/build/esm/async.js +0 -61
  591. package/build/esm/async.js.map +0 -1
  592. package/build/esm/client.js.map +0 -1
  593. package/build/esm/debug-build.js.map +0 -1
  594. package/build/esm/defineCloudflareOptions.js.map +0 -1
  595. package/build/esm/durableobject.js +0 -118
  596. package/build/esm/durableobject.js.map +0 -1
  597. package/build/esm/flush.js.map +0 -1
  598. package/build/esm/index.js +0 -16
  599. package/build/esm/instrument.js.map +0 -1
  600. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +0 -1
  601. package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +0 -1
  602. package/build/esm/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +0 -1
  603. package/build/esm/instrumentations/instrumentSqlStorage.js.map +0 -1
  604. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +0 -1
  605. package/build/esm/instrumentations/worker/instrumentD1.js.map +0 -1
  606. package/build/esm/instrumentations/worker/instrumentEmail.js.map +0 -1
  607. package/build/esm/instrumentations/worker/instrumentEnv.js.map +0 -1
  608. package/build/esm/instrumentations/worker/instrumentFetch.js.map +0 -1
  609. package/build/esm/instrumentations/worker/instrumentFetcher.js.map +0 -1
  610. package/build/esm/instrumentations/worker/instrumentQueue.js.map +0 -1
  611. package/build/esm/instrumentations/worker/instrumentQueueProducer.js.map +0 -1
  612. package/build/esm/instrumentations/worker/instrumentR2.js.map +0 -1
  613. package/build/esm/instrumentations/worker/instrumentRateLimit.js.map +0 -1
  614. package/build/esm/instrumentations/worker/instrumentScheduled.js.map +0 -1
  615. package/build/esm/instrumentations/worker/instrumentTail.js.map +0 -1
  616. package/build/esm/integrations/fetch.js.map +0 -1
  617. package/build/esm/integrations/hono.js +0 -49
  618. package/build/esm/integrations/hono.js.map +0 -1
  619. package/build/esm/integrations/httpServer.js.map +0 -1
  620. package/build/esm/integrations/tracing/vercelai.js.map +0 -1
  621. package/build/esm/nodejs_compat/index.js +0 -17
  622. package/build/esm/nodejs_compat/integrations/tracing/vercelai.js +0 -16
  623. package/build/esm/nodejs_compat/integrations/tracing/vercelai.js.map +0 -1
  624. package/build/esm/opentelemetry/tracer.js.map +0 -1
  625. package/build/esm/options.js.map +0 -1
  626. package/build/esm/package.json +0 -1
  627. package/build/esm/pages-plugin.js.map +0 -1
  628. package/build/esm/request.js.map +0 -1
  629. package/build/esm/scope-utils.js.map +0 -1
  630. package/build/esm/sdk.js.map +0 -1
  631. package/build/esm/transport.js.map +0 -1
  632. package/build/esm/utils/instrumentContext.js.map +0 -1
  633. package/build/esm/utils/internalSqlQuery.js +0 -17
  634. package/build/esm/utils/internalSqlQuery.js.map +0 -1
  635. package/build/esm/utils/isBinding.js.map +0 -1
  636. package/build/esm/utils/isCloudflareClass.js.map +0 -1
  637. package/build/esm/utils/rpcMeta.js.map +0 -1
  638. package/build/esm/utils/rpcOptions.js +0 -24
  639. package/build/esm/utils/rpcOptions.js.map +0 -1
  640. package/build/esm/utils/streaming.js.map +0 -1
  641. package/build/esm/utils/traceLinks.js.map +0 -1
  642. package/build/esm/vendor/stacktrace.js.map +0 -1
  643. package/build/esm/vite/autoInstrument.js.map +0 -1
  644. package/build/esm/vite/index.js.map +0 -1
  645. package/build/esm/vite/instrumentFile.js.map +0 -1
  646. package/build/esm/vite/transform.js.map +0 -1
  647. package/build/esm/vite/workerEntrypoint.js.map +0 -1
  648. package/build/esm/vite/wranglerConfig.js.map +0 -1
  649. package/build/esm/withSentry.js.map +0 -1
  650. package/build/esm/workflows.js.map +0 -1
  651. package/build/esm/wrapMethodWithSentry.js.map +0 -1
  652. package/build/types/async.d.ts +0 -11
  653. package/build/types/async.d.ts.map +0 -1
  654. package/build/types/integrations/hono.d.ts +0 -42
  655. package/build/types/integrations/hono.d.ts.map +0 -1
  656. package/build/types/nodejs_compat/index.d.ts +0 -4
  657. package/build/types/nodejs_compat/index.d.ts.map +0 -1
  658. package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts +0 -37
  659. package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts.map +0 -1
  660. package/build/types/utils/rpcOptions.d.ts +0 -13
  661. package/build/types/utils/rpcOptions.d.ts.map +0 -1
  662. package/build/types-ts3.8/async.d.ts +0 -11
  663. package/build/types-ts3.8/client.d.ts +0 -166
  664. package/build/types-ts3.8/debug-build.d.ts +0 -7
  665. package/build/types-ts3.8/defineCloudflareOptions.d.ts +0 -38
  666. package/build/types-ts3.8/durableobject.d.ts +0 -37
  667. package/build/types-ts3.8/executionContext.d.ts +0 -13
  668. package/build/types-ts3.8/flush.d.ts +0 -47
  669. package/build/types-ts3.8/index.d.ts +0 -18
  670. package/build/types-ts3.8/instrument.d.ts +0 -20
  671. package/build/types-ts3.8/instrumentations/instrumentDurableObjectNamespace.d.ts +0 -13
  672. package/build/types-ts3.8/instrumentations/instrumentDurableObjectStorage.d.ts +0 -19
  673. package/build/types-ts3.8/instrumentations/instrumentDurableObjectSyncKvStorage.d.ts +0 -3
  674. package/build/types-ts3.8/instrumentations/instrumentSqlStorage.d.ts +0 -9
  675. package/build/types-ts3.8/instrumentations/instrumentWorkerEntrypoint.d.ts +0 -42
  676. package/build/types-ts3.8/instrumentations/worker/instrumentD1.d.ts +0 -19
  677. package/build/types-ts3.8/instrumentations/worker/instrumentEmail.d.ts +0 -8
  678. package/build/types-ts3.8/instrumentations/worker/instrumentEnv.d.ts +0 -18
  679. package/build/types-ts3.8/instrumentations/worker/instrumentFetch.d.ts +0 -12
  680. package/build/types-ts3.8/instrumentations/worker/instrumentFetcher.d.ts +0 -10
  681. package/build/types-ts3.8/instrumentations/worker/instrumentQueue.d.ts +0 -12
  682. package/build/types-ts3.8/instrumentations/worker/instrumentQueueProducer.d.ts +0 -10
  683. package/build/types-ts3.8/instrumentations/worker/instrumentR2.d.ts +0 -9
  684. package/build/types-ts3.8/instrumentations/worker/instrumentRateLimit.d.ts +0 -6
  685. package/build/types-ts3.8/instrumentations/worker/instrumentScheduled.d.ts +0 -12
  686. package/build/types-ts3.8/instrumentations/worker/instrumentTail.d.ts +0 -12
  687. package/build/types-ts3.8/integrations/fetch.d.ts +0 -19
  688. package/build/types-ts3.8/integrations/hono.d.ts +0 -42
  689. package/build/types-ts3.8/integrations/httpServer.d.ts +0 -63
  690. package/build/types-ts3.8/integrations/tracing/vercelai.d.ts +0 -47
  691. package/build/types-ts3.8/nodejs_compat/index.d.ts +0 -4
  692. package/build/types-ts3.8/nodejs_compat/integrations/tracing/vercelai.d.ts +0 -37
  693. package/build/types-ts3.8/opentelemetry/tracer.d.ts +0 -6
  694. package/build/types-ts3.8/options.d.ts +0 -17
  695. package/build/types-ts3.8/pages-plugin.d.ts +0 -34
  696. package/build/types-ts3.8/request.d.ts +0 -25
  697. package/build/types-ts3.8/scope-utils.d.ts +0 -15
  698. package/build/types-ts3.8/sdk.d.ts +0 -10
  699. package/build/types-ts3.8/transport.d.ts +0 -34
  700. package/build/types-ts3.8/utils/instrumentContext.d.ts +0 -16
  701. package/build/types-ts3.8/utils/internalSqlQuery.d.ts +0 -18
  702. package/build/types-ts3.8/utils/isBinding.d.ts +0 -77
  703. package/build/types-ts3.8/utils/isCloudflareClass.d.ts +0 -30
  704. package/build/types-ts3.8/utils/rpcMeta.d.ts +0 -15
  705. package/build/types-ts3.8/utils/rpcOptions.d.ts +0 -13
  706. package/build/types-ts3.8/utils/streaming.d.ts +0 -17
  707. package/build/types-ts3.8/utils/traceLinks.d.ts +0 -28
  708. package/build/types-ts3.8/vendor/stacktrace.d.ts +0 -11
  709. package/build/types-ts3.8/vite/autoInstrument.d.ts +0 -21
  710. package/build/types-ts3.8/vite/index.d.ts +0 -88
  711. package/build/types-ts3.8/vite/instrumentFile.d.ts +0 -22
  712. package/build/types-ts3.8/vite/transform.d.ts +0 -60
  713. package/build/types-ts3.8/vite/workerEntrypoint.d.ts +0 -12
  714. package/build/types-ts3.8/vite/wranglerConfig.d.ts +0 -43
  715. package/build/types-ts3.8/withSentry.d.ts +0 -16
  716. package/build/types-ts3.8/workflows.d.ts +0 -25
  717. package/build/types-ts3.8/wrapMethodWithSentry.d.ts +0 -43
  718. /package/build/cjs/{debug-build.js → dev/debug-build.js} +0 -0
  719. /package/build/cjs/{defineCloudflareOptions.js → dev/defineCloudflareOptions.js} +0 -0
  720. /package/build/cjs/{flush.js → dev/flush.js} +0 -0
  721. /package/build/cjs/{instrument.js → dev/instrument.js} +0 -0
  722. /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectNamespace.js +0 -0
  723. /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectSyncKvStorage.js +0 -0
  724. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentFetcher.js +0 -0
  725. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentQueueProducer.js +0 -0
  726. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentR2.js +0 -0
  727. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentRateLimit.js +0 -0
  728. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentTail.js +0 -0
  729. /package/build/cjs/{opentelemetry → dev/opentelemetry}/tracer.js +0 -0
  730. /package/build/cjs/{scope-utils.js → dev/scope-utils.js} +0 -0
  731. /package/build/cjs/{transport.js → dev/transport.js} +0 -0
  732. /package/build/cjs/{utils → dev/utils}/isBinding.js +0 -0
  733. /package/build/cjs/{utils → dev/utils}/isCloudflareClass.js +0 -0
  734. /package/build/cjs/{utils → dev/utils}/streaming.js +0 -0
  735. /package/build/cjs/{utils → dev/utils}/traceLinks.js +0 -0
  736. /package/build/cjs/{vendor → dev/vendor}/stacktrace.js +0 -0
  737. /package/build/cjs/{vite → dev/vite}/instrumentFile.js +0 -0
  738. /package/build/cjs/{vite → dev/vite}/workerEntrypoint.js +0 -0
  739. /package/build/esm/{debug-build.js → dev/debug-build.js} +0 -0
  740. /package/build/esm/{defineCloudflareOptions.js → dev/defineCloudflareOptions.js} +0 -0
  741. /package/build/esm/{flush.js → dev/flush.js} +0 -0
  742. /package/build/esm/{instrument.js → dev/instrument.js} +0 -0
  743. /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectNamespace.js +0 -0
  744. /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectSyncKvStorage.js +0 -0
  745. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentFetcher.js +0 -0
  746. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentQueueProducer.js +0 -0
  747. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentR2.js +0 -0
  748. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentRateLimit.js +0 -0
  749. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentTail.js +0 -0
  750. /package/build/esm/{opentelemetry → dev/opentelemetry}/tracer.js +0 -0
  751. /package/build/esm/{scope-utils.js → dev/scope-utils.js} +0 -0
  752. /package/build/esm/{transport.js → dev/transport.js} +0 -0
  753. /package/build/esm/{utils → dev/utils}/isBinding.js +0 -0
  754. /package/build/esm/{utils → dev/utils}/isCloudflareClass.js +0 -0
  755. /package/build/esm/{utils → dev/utils}/streaming.js +0 -0
  756. /package/build/esm/{utils → dev/utils}/traceLinks.js +0 -0
  757. /package/build/esm/{vendor → dev/vendor}/stacktrace.js +0 -0
  758. /package/build/esm/{vite → dev/vite}/instrumentFile.js +0 -0
  759. /package/build/esm/{vite → dev/vite}/workerEntrypoint.js +0 -0
@@ -0,0 +1,231 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const DEFAULT_EXPORT = "default";
4
+ function emptyShape() {
5
+ return {
6
+ classes: /* @__PURE__ */ new Map(),
7
+ imports: /* @__PURE__ */ new Map(),
8
+ namespaces: /* @__PURE__ */ new Map(),
9
+ reexports: /* @__PURE__ */ new Map(),
10
+ localExports: /* @__PURE__ */ new Map(),
11
+ starExports: []
12
+ };
13
+ }
14
+ function shapeFromAst(ast) {
15
+ const shape = emptyShape();
16
+ for (const node of ast.body) {
17
+ switch (node.type) {
18
+ case "ClassDeclaration":
19
+ addAstClass(shape, node);
20
+ break;
21
+ case "ImportDeclaration":
22
+ addAstImports(shape, node);
23
+ break;
24
+ case "ExportNamedDeclaration":
25
+ addAstNamedExport(shape, node);
26
+ break;
27
+ case "ExportDefaultDeclaration": {
28
+ const decl = node.declaration;
29
+ if (decl.type === "ClassDeclaration" || decl.type === "ClassExpression") {
30
+ shape.defaultExportIsClass = true;
31
+ shape.defaultExportSuper = superRefFromNode(decl.superClass);
32
+ addAstClass(shape, decl);
33
+ } else if (decl.type === "Identifier") {
34
+ shape.defaultExportName = decl.name;
35
+ }
36
+ break;
37
+ }
38
+ case "ExportAllDeclaration": {
39
+ const starNode = node;
40
+ const source = starNode.exported ? void 0 : asString(starNode.source?.value);
41
+ if (source) shape.starExports.push(source);
42
+ break;
43
+ }
44
+ }
45
+ }
46
+ return shape;
47
+ }
48
+ function superRefFromNode(superClass) {
49
+ if (!superClass) return void 0;
50
+ if (superClass.type === "Identifier") {
51
+ return { kind: "identifier", name: superClass.name };
52
+ }
53
+ if (superClass.type === "MemberExpression") {
54
+ const member = superClass;
55
+ const object = member.object?.type === "Identifier" ? member.object.name : void 0;
56
+ const property = member.property?.name;
57
+ if (object && property) return { kind: "member", object, property };
58
+ }
59
+ return void 0;
60
+ }
61
+ function addAstClass(shape, classNode) {
62
+ if (classNode.id?.name) shape.classes.set(classNode.id.name, superRefFromNode(classNode.superClass));
63
+ }
64
+ function addAstImports(shape, node) {
65
+ const source = asString(node.source?.value);
66
+ if (!source) return;
67
+ for (const specifier of node.specifiers ?? []) {
68
+ const local = specifier.local?.name;
69
+ if (!local) continue;
70
+ if (specifier.type === "ImportSpecifier" && specifier.imported?.name) {
71
+ shape.imports.set(local, { source, imported: specifier.imported.name });
72
+ } else if (specifier.type === "ImportDefaultSpecifier") {
73
+ shape.imports.set(local, { source, imported: DEFAULT_EXPORT });
74
+ } else if (specifier.type === "ImportNamespaceSpecifier") {
75
+ shape.namespaces.set(local, source);
76
+ }
77
+ }
78
+ }
79
+ function addAstNamedExport(shape, node) {
80
+ if (node.declaration?.type === "ClassDeclaration") {
81
+ addAstClass(shape, node.declaration);
82
+ return;
83
+ }
84
+ const source = asString(node.source?.value);
85
+ for (const specifier of node.specifiers ?? []) {
86
+ const exported = specifier.exported?.name;
87
+ const local = specifier.local?.name;
88
+ if (!exported || !local) continue;
89
+ if (source) {
90
+ shape.reexports.set(exported, { source, imported: local });
91
+ } else {
92
+ shape.localExports.set(exported, local);
93
+ }
94
+ }
95
+ }
96
+ function shapeFromSource(rawCode) {
97
+ const code = stripComments(rawCode);
98
+ const shape = emptyShape();
99
+ const CLASS_RE = /\b(?:export\s+(?:default\s+)?)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)([^{]*)\{/g;
100
+ for (const match of code.matchAll(CLASS_RE)) {
101
+ const className = match[1];
102
+ const isDefault = /\bexport\s+default\b/.test(match[0]);
103
+ const superRef = superRefFromHeader(match[2] ?? "");
104
+ shape.classes.set(className, superRef);
105
+ if (isDefault) {
106
+ shape.defaultExportIsClass = true;
107
+ shape.defaultExportSuper = superRef;
108
+ }
109
+ }
110
+ const defaultExprMatch = /\bexport\s+default\s+([A-Za-z_$][\w$]*)\s*;/.exec(code);
111
+ if (defaultExprMatch && !shape.defaultExportIsClass) {
112
+ shape.defaultExportName = defaultExprMatch[1];
113
+ }
114
+ for (const match of code.matchAll(/\bexport\s*\*\s*from\s*['"]([^'"]+)['"]/g)) {
115
+ if (match[1]) shape.starExports.push(match[1]);
116
+ }
117
+ for (const match of code.matchAll(/\bexport\s*\{([^}]*)\}\s*(?:from\s*['"]([^'"]+)['"])?/g)) {
118
+ const source = match[2];
119
+ for (const { imported, local } of parseSpecifierList(match[1] ?? "")) {
120
+ if (source) {
121
+ shape.reexports.set(local, { source, imported });
122
+ } else {
123
+ shape.localExports.set(local, imported);
124
+ }
125
+ }
126
+ }
127
+ for (const match of code.matchAll(/\bimport\s+([^'";]+?)\s+from\s*['"]([^'"]+)['"]/g)) {
128
+ addSourceImports(shape, match[1] ?? "", match[2]);
129
+ }
130
+ return shape;
131
+ }
132
+ function superRefFromHeader(header) {
133
+ const withoutParams = stripLeadingGenerics(header);
134
+ const match = /\bextends\s+([A-Za-z_$][\w$]*)\s*(?:\.\s*([A-Za-z_$][\w$]*))?/.exec(withoutParams);
135
+ if (!match) return void 0;
136
+ return match[2] ? { kind: "member", object: match[1], property: match[2] } : { kind: "identifier", name: match[1] };
137
+ }
138
+ function stripLeadingGenerics(header) {
139
+ const start = header.indexOf("<");
140
+ if (start === -1 || header.slice(0, start).trim() !== "") return header;
141
+ let depth = 0;
142
+ for (let i = start; i < header.length; i++) {
143
+ const char = header[i];
144
+ if (char === "<") depth++;
145
+ else if (char === ">") {
146
+ depth--;
147
+ if (depth === 0) return header.slice(i + 1);
148
+ }
149
+ }
150
+ return header;
151
+ }
152
+ function parseSpecifierList(clause) {
153
+ const specifiers = [];
154
+ for (const rawPart of clause.split(",")) {
155
+ const part = rawPart.trim().replace(/^type\s+/, "");
156
+ if (!part) continue;
157
+ const aliased = /^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/.exec(part);
158
+ if (aliased) {
159
+ specifiers.push({ imported: aliased[1], local: aliased[2] });
160
+ } else if (/^[A-Za-z_$][\w$]*$/.test(part)) {
161
+ specifiers.push({ imported: part, local: part });
162
+ }
163
+ }
164
+ return specifiers;
165
+ }
166
+ function addSourceImports(shape, clause, source) {
167
+ if (/^type\s/.test(clause.trim())) return;
168
+ const namespaceMatch = /\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(clause);
169
+ if (namespaceMatch) {
170
+ shape.namespaces.set(namespaceMatch[1], source);
171
+ }
172
+ const bracesMatch = /\{([^}]*)\}/.exec(clause);
173
+ if (bracesMatch) {
174
+ for (const { imported, local } of parseSpecifierList(bracesMatch[1] ?? "")) {
175
+ shape.imports.set(local, { source, imported });
176
+ }
177
+ }
178
+ const defaultMatch = /^\s*([A-Za-z_$][\w$]*)\s*(?:,|$)/.exec(clause);
179
+ if (defaultMatch) {
180
+ shape.imports.set(defaultMatch[1], { source, imported: DEFAULT_EXPORT });
181
+ }
182
+ }
183
+ function stripComments(code) {
184
+ let result = "";
185
+ let index = 0;
186
+ while (index < code.length) {
187
+ const char = code[index];
188
+ const next = code[index + 1];
189
+ if (char === "/" && next === "/") {
190
+ while (index < code.length && code[index] !== "\n") index++;
191
+ continue;
192
+ }
193
+ if (char === "/" && next === "*") {
194
+ index += 2;
195
+ while (index < code.length && !(code[index] === "*" && code[index + 1] === "/")) index++;
196
+ index += 2;
197
+ result += " ";
198
+ continue;
199
+ }
200
+ if (char === '"' || char === "'" || char === "`") {
201
+ const quote = char;
202
+ result += char;
203
+ index++;
204
+ while (index < code.length) {
205
+ const inner = code[index];
206
+ result += inner;
207
+ index++;
208
+ if (inner === "\\") {
209
+ if (index < code.length) {
210
+ result += code[index];
211
+ index++;
212
+ }
213
+ continue;
214
+ }
215
+ if (inner === quote) break;
216
+ }
217
+ continue;
218
+ }
219
+ result += char;
220
+ index++;
221
+ }
222
+ return result;
223
+ }
224
+ function asString(value) {
225
+ return typeof value === "string" && value ? value : void 0;
226
+ }
227
+
228
+ exports.DEFAULT_EXPORT = DEFAULT_EXPORT;
229
+ exports.shapeFromAst = shapeFromAst;
230
+ exports.shapeFromSource = shapeFromSource;
231
+ //# sourceMappingURL=moduleShape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moduleShape.js","sources":["../../../../src/vite/moduleShape.ts"],"sourcesContent":["import type { BaseNode, ProgramBody } from './transform';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node shapes for structural Agent detection.\n// ---------------------------------------------------------------------------\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface ClassNode extends BaseNode {\n id?: IdentifierNode | null;\n superClass?: BaseNode | null;\n}\n\ninterface MemberExpressionNode extends BaseNode {\n object?: { type: string; name?: string };\n property?: { type: string; name?: string };\n}\n\ninterface ImportSpecifierNode {\n type: string;\n imported?: { type: string; name?: string };\n local?: { type: string; name?: string };\n}\n\ninterface ImportDeclarationNode extends BaseNode {\n source?: { value?: unknown };\n specifiers?: ImportSpecifierNode[];\n}\n\ninterface ExportSpecifierNode {\n type: string;\n local?: { type: string; name?: string };\n exported?: { type: string; name?: string };\n}\n\ninterface ExportNamedNode extends BaseNode {\n declaration?: BaseNode | null;\n source?: { value?: unknown } | null;\n specifiers?: ExportSpecifierNode[];\n}\n\ninterface ExportDefaultNode extends BaseNode {\n declaration: BaseNode;\n}\n\ninterface ExportAllNode extends BaseNode {\n source?: { value?: unknown };\n exported?: { type: string; name?: string } | null;\n}\n\n/** Binding name used for a module's default export. */\nexport const DEFAULT_EXPORT = 'default';\n\n/** A resolved superclass reference: a bare identifier or a `ns.Member` expression. */\nexport type SuperRef = { kind: 'identifier'; name: string } | { kind: 'member'; object: string; property: string };\n\n/** The declarations of a single module that binding resolution needs. */\nexport interface ModuleShape {\n /** Top-level class names → their superclass reference (absent when the class has no `extends`). */\n classes: Map<string, SuperRef | undefined>;\n /** Local binding name → the import it came from (`imported` is `default` for a default import). */\n imports: Map<string, { source: string; imported: string }>;\n /** Local binding name → module specifier, for `import * as ns from '...'`. */\n namespaces: Map<string, string>;\n /** Exported name → the re-export it came from, for `export { x as y } from '...'`. */\n reexports: Map<string, { source: string; imported: string }>;\n /** Exported name → local binding name, for `export { x as y }` without a source. */\n localExports: Map<string, string>;\n /** Module specifiers of bare `export * from '...'` declarations. */\n starExports: string[];\n /** `export default <Identifier>` — the local name it refers to. */\n defaultExportName?: string;\n /** True when the module's default export is a class declaration/expression. */\n defaultExportIsClass?: boolean;\n /** Superclass of an anonymous `export default class extends X`. */\n defaultExportSuper?: SuperRef;\n}\n\nfunction emptyShape(): ModuleShape {\n return {\n classes: new Map(),\n imports: new Map(),\n namespaces: new Map(),\n reexports: new Map(),\n localExports: new Map(),\n starExports: [],\n };\n}\n\n// ---------------------------------------------------------------------------\n// Shape from a parsed AST (used for the entry module)\n// ---------------------------------------------------------------------------\n\n/** Collect the shape of a module from its parsed AST — used for the already-parsed entry module. */\nexport function shapeFromAst(ast: ProgramBody): ModuleShape {\n const shape = emptyShape();\n\n for (const node of ast.body) {\n switch (node.type) {\n case 'ClassDeclaration':\n addAstClass(shape, node);\n break;\n case 'ImportDeclaration':\n addAstImports(shape, node);\n break;\n case 'ExportNamedDeclaration':\n addAstNamedExport(shape, node);\n break;\n case 'ExportDefaultDeclaration': {\n const decl = (node as ExportDefaultNode).declaration;\n if (decl.type === 'ClassDeclaration' || decl.type === 'ClassExpression') {\n shape.defaultExportIsClass = true;\n shape.defaultExportSuper = superRefFromNode((decl as ClassNode).superClass);\n // `export default class Foo {}` also binds `Foo` locally.\n addAstClass(shape, decl);\n } else if (decl.type === 'Identifier') {\n shape.defaultExportName = (decl as IdentifierNode).name;\n }\n break;\n }\n case 'ExportAllDeclaration': {\n const starNode = node as ExportAllNode;\n // `export * as ns from '...'` binds a namespace object, not the individual exports.\n const source = starNode.exported ? undefined : asString(starNode.source?.value);\n if (source) shape.starExports.push(source);\n break;\n }\n }\n }\n\n return shape;\n}\n\nfunction superRefFromNode(superClass: BaseNode | null | undefined): SuperRef | undefined {\n if (!superClass) return undefined;\n\n if (superClass.type === 'Identifier') {\n return { kind: 'identifier', name: (superClass as IdentifierNode).name };\n }\n\n if (superClass.type === 'MemberExpression') {\n const member = superClass as MemberExpressionNode;\n const object = member.object?.type === 'Identifier' ? member.object.name : undefined;\n const property = member.property?.name;\n if (object && property) return { kind: 'member', object, property };\n }\n\n return undefined;\n}\n\nfunction addAstClass(shape: ModuleShape, classNode: ClassNode): void {\n if (classNode.id?.name) shape.classes.set(classNode.id.name, superRefFromNode(classNode.superClass));\n}\n\nfunction addAstImports(shape: ModuleShape, node: ImportDeclarationNode): void {\n const source = asString(node.source?.value);\n if (!source) return;\n\n for (const specifier of node.specifiers ?? []) {\n const local = specifier.local?.name;\n if (!local) continue;\n\n if (specifier.type === 'ImportSpecifier' && specifier.imported?.name) {\n shape.imports.set(local, { source, imported: specifier.imported.name });\n } else if (specifier.type === 'ImportDefaultSpecifier') {\n shape.imports.set(local, { source, imported: DEFAULT_EXPORT });\n } else if (specifier.type === 'ImportNamespaceSpecifier') {\n shape.namespaces.set(local, source);\n }\n }\n}\n\nfunction addAstNamedExport(shape: ModuleShape, node: ExportNamedNode): void {\n if (node.declaration?.type === 'ClassDeclaration') {\n addAstClass(shape, node.declaration);\n return;\n }\n\n const source = asString(node.source?.value);\n for (const specifier of node.specifiers ?? []) {\n const exported = specifier.exported?.name;\n const local = specifier.local?.name;\n if (!exported || !local) continue;\n\n if (source) {\n shape.reexports.set(exported, { source, imported: local });\n } else {\n shape.localExports.set(exported, local);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Shape from raw source (used for sibling modules read off disk)\n// ---------------------------------------------------------------------------\n\n/**\n * Extract the module shape from **unprocessed source**.\n *\n * Sibling modules are read straight from disk (the plugin context's `load()` would deadlock inside a\n * transform hook), so they may still be TypeScript — which no JS parser will accept. Only\n * import/export statements and `class X extends Y` headers matter here, and those are\n * declaration-level syntax a scan can pick out reliably; class bodies, type annotations and generics\n * are irrelevant and simply skipped.\n */\nexport function shapeFromSource(rawCode: string): ModuleShape {\n const code = stripComments(rawCode);\n const shape = emptyShape();\n\n // `class X extends Y {` / `class X<T> extends Y<T> {`, optionally exported and/or abstract.\n const CLASS_RE = /\\b(?:export\\s+(?:default\\s+)?)?(?:abstract\\s+)?class\\s+([A-Za-z_$][\\w$]*)([^{]*)\\{/g;\n for (const match of code.matchAll(CLASS_RE)) {\n const className = match[1]!;\n const isDefault = /\\bexport\\s+default\\b/.test(match[0]);\n const superRef = superRefFromHeader(match[2] ?? '');\n\n shape.classes.set(className, superRef);\n if (isDefault) {\n shape.defaultExportIsClass = true;\n shape.defaultExportSuper = superRef;\n }\n }\n\n // `export default Identifier;`\n const defaultExprMatch = /\\bexport\\s+default\\s+([A-Za-z_$][\\w$]*)\\s*;/.exec(code);\n if (defaultExprMatch && !shape.defaultExportIsClass) {\n shape.defaultExportName = defaultExprMatch[1];\n }\n\n // `export * from '...'` (but not `export * as ns from '...'`).\n for (const match of code.matchAll(/\\bexport\\s*\\*\\s*from\\s*['\"]([^'\"]+)['\"]/g)) {\n if (match[1]) shape.starExports.push(match[1]);\n }\n\n // `export { a, b as c } from '...'` and `export { a, b as c }`.\n for (const match of code.matchAll(/\\bexport\\s*\\{([^}]*)\\}\\s*(?:from\\s*['\"]([^'\"]+)['\"])?/g)) {\n const source = match[2];\n for (const { imported, local } of parseSpecifierList(match[1] ?? '')) {\n // In an export clause the first name is local and the alias is the exported name.\n if (source) {\n shape.reexports.set(local, { source, imported });\n } else {\n shape.localExports.set(local, imported);\n }\n }\n }\n\n // `import Default, { a as b }, * as ns from '...'` in its various shapes.\n for (const match of code.matchAll(/\\bimport\\s+([^'\";]+?)\\s+from\\s*['\"]([^'\"]+)['\"]/g)) {\n addSourceImports(shape, match[1] ?? '', match[2]!);\n }\n\n return shape;\n}\n\n/** Pull the superclass out of the text between a class name and its body. */\nfunction superRefFromHeader(header: string): SuperRef | undefined {\n // The header still carries the class's own generic parameter list (`<T extends S>`), whose\n // constraint `extends` would otherwise be mistaken for the superclass clause. Strip a leading\n // balanced `<...>` first, then read the (possibly dotted) base name. Trailing generic args on the\n // base (`extends Agent<Env>`) stop the match naturally.\n const withoutParams = stripLeadingGenerics(header);\n const match = /\\bextends\\s+([A-Za-z_$][\\w$]*)\\s*(?:\\.\\s*([A-Za-z_$][\\w$]*))?/.exec(withoutParams);\n if (!match) return undefined;\n\n return match[2] ? { kind: 'member', object: match[1]!, property: match[2] } : { kind: 'identifier', name: match[1]! };\n}\n\n/**\n * Remove a leading `<...>` generic parameter list, honoring nesting (`<T extends Map<K, V>>`).\n * Anything after the balanced close — the superclass clause — is returned unchanged. When the\n * header doesn't start with `<` (no generics), it is returned as-is.\n */\nfunction stripLeadingGenerics(header: string): string {\n const start = header.indexOf('<');\n // Only treat it as a parameter list when `<` is the first meaningful token — a `<` appearing\n // later is part of the superclass's own generic args and must be left alone.\n if (start === -1 || header.slice(0, start).trim() !== '') return header;\n\n let depth = 0;\n for (let i = start; i < header.length; i++) {\n const char = header[i];\n if (char === '<') depth++;\n else if (char === '>') {\n depth--;\n if (depth === 0) return header.slice(i + 1);\n }\n }\n // Unbalanced `<` — fall back to the untouched header rather than dropping the superclass.\n return header;\n}\n\n/** Parse `a, b as c` into `{ imported: 'b', local: 'c' }` pairs (type-only specifiers dropped). */\nfunction parseSpecifierList(clause: string): Array<{ imported: string; local: string }> {\n const specifiers: Array<{ imported: string; local: string }> = [];\n\n for (const rawPart of clause.split(',')) {\n const part = rawPart.trim().replace(/^type\\s+/, '');\n if (!part) continue;\n\n const aliased = /^([A-Za-z_$][\\w$]*)\\s+as\\s+([A-Za-z_$][\\w$]*)$/.exec(part);\n if (aliased) {\n specifiers.push({ imported: aliased[1]!, local: aliased[2]! });\n } else if (/^[A-Za-z_$][\\w$]*$/.test(part)) {\n specifiers.push({ imported: part, local: part });\n }\n }\n\n return specifiers;\n}\n\nfunction addSourceImports(shape: ModuleShape, clause: string, source: string): void {\n // Type-only imports never contribute a runtime base class.\n if (/^type\\s/.test(clause.trim())) return;\n\n const namespaceMatch = /\\*\\s*as\\s+([A-Za-z_$][\\w$]*)/.exec(clause);\n if (namespaceMatch) {\n shape.namespaces.set(namespaceMatch[1]!, source);\n }\n\n const bracesMatch = /\\{([^}]*)\\}/.exec(clause);\n if (bracesMatch) {\n for (const { imported, local } of parseSpecifierList(bracesMatch[1] ?? '')) {\n shape.imports.set(local, { source, imported });\n }\n }\n\n // A leading bare identifier (before any brace/star) is the default import.\n const defaultMatch = /^\\s*([A-Za-z_$][\\w$]*)\\s*(?:,|$)/.exec(clause);\n if (defaultMatch) {\n shape.imports.set(defaultMatch[1]!, { source, imported: DEFAULT_EXPORT });\n }\n}\n\n/** Remove line and block comments, leaving string literals (module specifiers) intact. */\nfunction stripComments(code: string): string {\n let result = '';\n let index = 0;\n\n while (index < code.length) {\n const char = code[index]!;\n const next = code[index + 1];\n\n if (char === '/' && next === '/') {\n while (index < code.length && code[index] !== '\\n') index++;\n continue;\n }\n\n if (char === '/' && next === '*') {\n index += 2;\n while (index < code.length && !(code[index] === '*' && code[index + 1] === '/')) index++;\n index += 2;\n // Keep a separator so `*/class` doesn't fuse into one token.\n result += ' ';\n continue;\n }\n\n if (char === '\"' || char === \"'\" || char === '`') {\n const quote = char;\n result += char;\n index++;\n while (index < code.length) {\n const inner = code[index]!;\n result += inner;\n index++;\n if (inner === '\\\\') {\n if (index < code.length) {\n result += code[index]!;\n index++;\n }\n continue;\n }\n if (inner === quote) break;\n }\n continue;\n }\n\n result += char;\n index++;\n }\n\n return result;\n}\n\nfunction asString(value: unknown): string | undefined {\n return typeof value === 'string' && value ? value : undefined;\n}\n"],"names":[],"mappings":";;AAqDO,MAAM,cAAA,GAAiB;AA2B9B,SAAS,UAAA,GAA0B;AACjC,EAAA,OAAO;AAAA,IACL,OAAA,sBAAa,GAAA,EAAI;AAAA,IACjB,OAAA,sBAAa,GAAA,EAAI;AAAA,IACjB,UAAA,sBAAgB,GAAA,EAAI;AAAA,IACpB,SAAA,sBAAe,GAAA,EAAI;AAAA,IACnB,YAAA,sBAAkB,GAAA,EAAI;AAAA,IACtB,aAAa;AAAC,GAChB;AACF;AAOO,SAAS,aAAa,GAAA,EAA+B;AAC1D,EAAA,MAAM,QAAQ,UAAA,EAAW;AAEzB,EAAA,KAAA,MAAW,IAAA,IAAQ,IAAI,IAAA,EAAM;AAC3B,IAAA,QAAQ,KAAK,IAAA;AAAM,MACjB,KAAK,kBAAA;AACH,QAAA,WAAA,CAAY,OAAO,IAAI,CAAA;AACvB,QAAA;AAAA,MACF,KAAK,mBAAA;AACH,QAAA,aAAA,CAAc,OAAO,IAAI,CAAA;AACzB,QAAA;AAAA,MACF,KAAK,wBAAA;AACH,QAAA,iBAAA,CAAkB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,IAAO,IAAA,KAAS,GAAA,IAAO,SAAS,GAAA,EAAK;AAChD,MAAA,MAAM,KAAA,GAAQ,IAAA;AACd,MAAA,MAAA,IAAU,IAAA;AACV,MAAA,KAAA,EAAA;AACA,MAAA,OAAO,KAAA,GAAQ,KAAK,MAAA,EAAQ;AAC1B,QAAA,MAAM,KAAA,GAAQ,KAAK,KAAK,CAAA;AACxB,QAAA,MAAA,IAAU,KAAA;AACV,QAAA,KAAA,EAAA;AACA,QAAA,IAAI,UAAU,IAAA,EAAM;AAClB,UAAA,IAAI,KAAA,GAAQ,KAAK,MAAA,EAAQ;AACvB,YAAA,MAAA,IAAU,KAAK,KAAK,CAAA;AACpB,YAAA,KAAA,EAAA;AAAA,UACF;AACA,UAAA;AAAA,QACF;AACA,QAAA,IAAI,UAAU,KAAA,EAAO;AAAA,MACvB;AACA,MAAA;AAAA,IACF;AAEA,IAAA,MAAA,IAAU,IAAA;AACV,IAAA,KAAA,EAAA;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,SAAS,KAAA,EAAoC;AACpD,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,GAAQ,KAAA,GAAQ,MAAA;AACtD;;;;;;"}
@@ -12,6 +12,7 @@ function isCallToMethod(node, methodName) {
12
12
  }
13
13
  const WRAPPER_METHODS = {
14
14
  durableObject: "instrumentDurableObjectWithSentry",
15
+ agent: "instrumentAgentWithSentry",
15
16
  workflow: "instrumentWorkflowWithSentry",
16
17
  workerEntrypoint: "withSentry"
17
18
  };
@@ -25,6 +26,7 @@ function applyAutoInstrumentTransforms(code, ast, ctx) {
25
26
  topLevelClasses,
26
27
  renamedLocals: /* @__PURE__ */ new Set(),
27
28
  classWrappers: ctx.classWrappers,
29
+ agentClasses: ctx.agentClasses ?? /* @__PURE__ */ new Set(),
28
30
  workerEntrypointClasses: workerEntrypoint.detectWorkerEntrypointClasses(ast)
29
31
  };
30
32
  const { wrappedClasses } = state;
@@ -52,6 +54,7 @@ function applyAutoInstrumentTransforms(code, ast, ctx) {
52
54
  }
53
55
  function resolveWrapperKind(exportedName, localName, state) {
54
56
  const configured = state.classWrappers.get(exportedName);
57
+ if (configured === "durableObject" && localName && state.agentClasses.has(localName)) return "agent";
55
58
  if (configured) return configured;
56
59
  if (localName && state.workerEntrypointClasses.has(localName)) return "workerEntrypoint";
57
60
  return void 0;
@@ -94,7 +97,9 @@ function collectManuallyWrappedClassExports(varDecl, ctx, state) {
94
97
  for (const declarator of varDecl.declarations ?? []) {
95
98
  const name = declarator.id?.type === "Identifier" ? declarator.id.name : void 0;
96
99
  const kind = name ? ctx.classWrappers.get(name) : void 0;
97
- if (name && kind && declarator.init && isCallToMethod(declarator.init, WRAPPER_METHODS[kind])) {
100
+ if (!name || !kind || !declarator.init) continue;
101
+ const accepted = kind === "durableObject" ? [WRAPPER_METHODS.durableObject, WRAPPER_METHODS.agent] : [WRAPPER_METHODS[kind]];
102
+ if (accepted.some((method) => isCallToMethod(declarator.init, method))) {
98
103
  state.wrappedClasses.add(name);
99
104
  }
100
105
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sources":["../../../../src/vite/transform.ts"],"sourcesContent":["import MagicString from 'magic-string';\nimport { detectWorkerEntrypointClasses } from './workerEntrypoint';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node types for the AST nodes we inspect.\n// ---------------------------------------------------------------------------\n\nexport interface BaseNode {\n type: string;\n start: number;\n end: number;\n}\n\nexport interface ProgramBody {\n body: BaseNode[];\n}\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface CalleeNode {\n type: string;\n name?: string;\n property?: { type: string; name?: string };\n}\n\ninterface CallExpressionNode extends BaseNode {\n callee?: CalleeNode;\n}\n\ninterface ClassDeclarationNode extends BaseNode {\n id?: IdentifierNode | null;\n}\n\ninterface ExportDefaultNode extends BaseNode {\n declaration: BaseNode;\n}\n\ninterface ExportSpecifierNode {\n type: string;\n local?: { type: string; name?: string };\n exported?: { type: string; name?: string };\n}\n\ninterface ExportNamedNode extends BaseNode {\n declaration?: BaseNode | null;\n source?: unknown;\n specifiers?: ExportSpecifierNode[];\n}\n\ninterface VariableDeclaratorNode {\n id?: { type: string; name?: string };\n init?: BaseNode | null;\n}\n\ninterface VariableDeclarationNode extends BaseNode {\n declarations?: VariableDeclaratorNode[];\n}\n\nfunction isCallToMethod(node: BaseNode, methodName: string): boolean {\n if (node.type !== 'CallExpression') return false;\n const callee = (node as CallExpressionNode).callee;\n if (!callee) return false;\n if (callee.type === 'Identifier' && callee.name === methodName) return true;\n return (\n callee.type === 'MemberExpression' && callee.property?.type === 'Identifier' && callee.property.name === methodName\n );\n}\n\n/**\n * The kind of Sentry wrapper to apply to an exported class.\n *\n * `durableObject` and `workflow` are keyed by name from the wrangler config\n * (`durable_objects.bindings`, `workflows`), since those class names are\n * authoritative there. `workerEntrypoint` is different: a worker's own\n * entrypoints aren't enumerated in its config, so they're detected structurally\n * (a class extending `WorkerEntrypoint` from `cloudflare:workers`), with the\n * config providing only a fallback for self-bound entrypoints whose base class\n * lives in another module.\n */\nexport type ClassWrapperKind = 'durableObject' | 'agent' | 'workflow' | 'workerEntrypoint';\n\n/**\n * The `@sentry/cloudflare` helper each wrapper kind emits. All share the same\n * `(optionsCallback, Class)` signature. `WorkerEntrypoint` classes use\n * `withSentry`, which runtime-detects the class type and routes accordingly.\n */\nconst WRAPPER_METHODS: Record<ClassWrapperKind, string> = {\n durableObject: 'instrumentDurableObjectWithSentry',\n agent: 'instrumentAgentWithSentry',\n workflow: 'instrumentWorkflowWithSentry',\n workerEntrypoint: 'withSentry',\n};\n\nexport interface TransformContext {\n /**\n * Exported class name → the kind of Sentry wrapper to apply. Populated from\n * the wrangler config, so the transform can wrap by name without resolving\n * each class's base type.\n */\n classWrappers: Map<string, ClassWrapperKind>;\n /**\n * Local class names detected as `agents` Agents. An Agent is configured as a Durable Object in\n * wrangler, so this upgrades those entries from `durableObject` to `agent`.\n */\n agentClasses?: ReadonlySet<string>;\n optionsFn: string;\n /** Import statement prepended when `optionsFn` references a separate module. */\n optionsImport?: string;\n}\n\nexport interface TransformResult {\n code: string;\n map: ReturnType<MagicString['generateMap']>;\n /**\n * The configured class names that were actually wrapped. Lets the plugin warn\n * about configured classes it could not find, instead of silently leaving\n * them uninstrumented.\n */\n wrappedClasses: Set<string>;\n}\n\n/**\n * Rewrite the worker entry source to wrap its default export with `withSentry`\n * and any configured class export with its matching Sentry wrapper (see\n * {@link TransformContext.classWrappers}, e.g. Durable Object classes with\n * `instrumentDurableObjectWithSentry`).\n *\n * Handles both `export class MyDO {}` and the specifier form\n * (`class MyDO {}` … `export { MyDO }` / `export { Foo as MyDO }`).\n * Re-exports from other modules (`export { MyDO } from './do'`) cannot be\n * wrapped here and are left alone — the plugin warns about them via\n * {@link TransformResult.wrappedClasses}.\n *\n * Exported (rather than inlined into the plugin) so it can be unit-tested with a\n * plain AST and no Vite context. Returns `undefined` when nothing was wrapped and\n * there are no already-manually-wrapped classes to report.\n */\nexport function applyAutoInstrumentTransforms(\n code: string,\n ast: ProgramBody,\n ctx: TransformContext,\n): TransformResult | undefined {\n const ms = new MagicString(code);\n const topLevelClasses = collectTopLevelClasses(ast);\n const state: TransformState = {\n ms,\n needsImport: false,\n wrappedClasses: new Set<string>(),\n topLevelClasses,\n renamedLocals: new Set<string>(),\n classWrappers: ctx.classWrappers,\n agentClasses: ctx.agentClasses ?? new Set<string>(),\n workerEntrypointClasses: detectWorkerEntrypointClasses(ast),\n };\n const { wrappedClasses } = state;\n\n // Named exports first, regardless of source order: the default-export handler\n // needs to know which local bindings a named export already wrapped, so it can\n // skip a class that is both exported by name and re-exported as default (which\n // would otherwise wrap it twice).\n for (const node of ast.body) {\n if (node.type === 'ExportNamedDeclaration') {\n handleNamedExport(node, ctx, state);\n }\n }\n for (const node of ast.body) {\n if (node.type === 'ExportDefaultDeclaration') {\n wrapDefaultExport(node as ExportDefaultNode, ctx, state);\n }\n }\n\n if (!state.needsImport) {\n // Nothing was rewritten. Still surface any classes found already wrapped\n // manually (via `wrappedClasses`) so the caller doesn't warn about them;\n // return undefined only when there was nothing to report either.\n if (wrappedClasses.size === 0) return undefined;\n return { code, map: ms.generateMap({ hires: true }), wrappedClasses };\n }\n\n if (ctx.optionsImport) ms.prepend(ctx.optionsImport);\n ms.prepend(\"import * as __SENTRY__ from '@sentry/cloudflare';\\n\");\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ hires: true }),\n wrappedClasses,\n };\n}\n\ninterface TransformState {\n ms: MagicString;\n needsImport: boolean;\n wrappedClasses: Set<string>;\n /**\n * Top-level (non-exported) class declarations, so specifier exports like\n * `export { MyDO }` can locate the class they refer to.\n */\n topLevelClasses: Map<string, ClassDeclarationNode>;\n /**\n * Local class names already renamed + wrapped, so two specifiers pointing at\n * the same class don't produce duplicate bindings.\n */\n renamedLocals: Set<string>;\n /** Class name → wrapper kind, keyed by the *exported* name (from config). */\n classWrappers: Map<string, ClassWrapperKind>;\n /** Local class names detected as `agents` Agents (see {@link TransformContext.agentClasses}). */\n agentClasses: ReadonlySet<string>;\n /**\n * Local class names detected as `WorkerEntrypoint` subclasses in this module,\n * so they can be wrapped without a config entry.\n */\n workerEntrypointClasses: Set<string>;\n}\n\n/**\n * Resolve the wrapper kind for a class export.\n *\n * Config (`classWrappers`) wins — it's authoritative for Durable Objects and\n * Workflows, and provides the self-binding fallback for WorkerEntrypoints whose\n * base class this module can't see. Otherwise a structurally-detected\n * `WorkerEntrypoint` subclass (matched by its *local* name) gets wrapped with\n * `withSentry`.\n *\n * The one case where config is refined rather than obeyed is an `agents` Agent:\n * it *is* a Durable Object, so wrangler can only ever describe it as one, and\n * only the detected base chain distinguishes the two.\n */\nfunction resolveWrapperKind(\n exportedName: string,\n localName: string | undefined,\n state: TransformState,\n): ClassWrapperKind | undefined {\n const configured = state.classWrappers.get(exportedName);\n if (configured === 'durableObject' && localName && state.agentClasses.has(localName)) return 'agent';\n if (configured) return configured;\n if (localName && state.workerEntrypointClasses.has(localName)) return 'workerEntrypoint';\n return undefined;\n}\n\nfunction collectTopLevelClasses(ast: ProgramBody): Map<string, ClassDeclarationNode> {\n const classes = new Map<string, ClassDeclarationNode>();\n for (const node of ast.body) {\n if (node.type !== 'ClassDeclaration') continue;\n const classNode = node as ClassDeclarationNode;\n if (classNode.id?.name) classes.set(classNode.id.name, classNode);\n }\n return classes;\n}\n\nfunction wrapDefaultExport(node: ExportDefaultNode, ctx: TransformContext, state: TransformState): void {\n const decl = node.declaration;\n\n // Already wrapped — leave it alone\n if (isCallToMethod(decl, 'withSentry')) return;\n\n // `export default Foo` where `Foo` is a local class already wrapped by a named\n // export (e.g. a self-bound WorkerEntrypoint also used as the default handler).\n // Wrapping again would produce `withSentry(withSentry(...))`.\n if (decl.type === 'Identifier' && state.renamedLocals.has((decl as IdentifierNode).name)) return;\n\n // `export default <expr>` → `const __SENTRY_DEFAULT_EXPORT__ = <expr>`\n // MagicString positions are always relative to the original source.\n state.ms.overwrite(node.start, decl.start, 'const __SENTRY_DEFAULT_EXPORT__ = ');\n state.ms.append(`\\nexport default __SENTRY__.withSentry(${ctx.optionsFn}, __SENTRY_DEFAULT_EXPORT__);\\n`);\n state.needsImport = true;\n}\n\nfunction handleNamedExport(node: ExportNamedNode, ctx: TransformContext, state: TransformState): void {\n const decl = node.declaration;\n\n // ---- Manually wrapped class export ----\n // `export const MyDO = instrumentDurableObjectWithSentry(...)` — count it\n // as wrapped so the plugin doesn't warn about it, but leave it alone.\n if (decl?.type === 'VariableDeclaration') {\n collectManuallyWrappedClassExports(decl, ctx, state);\n return;\n }\n\n // ---- Named class export matching a configured binding ----\n if (decl?.type === 'ClassDeclaration') {\n wrapInlineClassExport(node, decl, ctx, state);\n return;\n }\n\n // ---- Specifier export of a local class (`export { Foo as MyDO }`) ----\n // Re-exports from another module carry a `source` — nothing local to wrap.\n if (node.source) return;\n for (const specifier of node.specifiers ?? []) {\n wrapSpecifierExport(specifier, ctx, state);\n }\n}\n\nfunction collectManuallyWrappedClassExports(\n varDecl: VariableDeclarationNode,\n ctx: TransformContext,\n state: TransformState,\n): void {\n for (const declarator of varDecl.declarations ?? []) {\n const name = declarator.id?.type === 'Identifier' ? declarator.id.name : undefined;\n const kind = name ? ctx.classWrappers.get(name) : undefined;\n if (!name || !kind || !declarator.init) continue;\n\n // A hand-wrapped Agent is configured as a Durable Object, so accept either helper there —\n // otherwise an already-instrumented Agent would be reported as unwrapped.\n const accepted =\n kind === 'durableObject' ? [WRAPPER_METHODS.durableObject, WRAPPER_METHODS.agent] : [WRAPPER_METHODS[kind]];\n\n if (accepted.some(method => isCallToMethod(declarator.init as BaseNode, method))) {\n state.wrappedClasses.add(name);\n }\n }\n}\n\nfunction wrapInlineClassExport(\n exportNode: ExportNamedNode,\n classDecl: ClassDeclarationNode,\n ctx: TransformContext,\n state: TransformState,\n): void {\n const classId = classDecl.id;\n // Inline export: the exported name and the local class name are the same.\n const kind = classId ? resolveWrapperKind(classId.name, classId.name, state) : undefined;\n if (!classId || !kind) return;\n\n const className = classId.name;\n const renamedClass = `__SENTRY_ORIGINAL_${className}__`;\n\n // Strip the `export ` keyword\n state.ms.overwrite(exportNode.start, classDecl.start, '');\n\n // Rename the class to avoid a duplicate binding\n state.ms.overwrite(classId.start, classId.end, renamedClass);\n\n // Insert the wrapped re-export after the class body\n state.ms.appendLeft(\n exportNode.end,\n `\\nexport const ${className} = __SENTRY__.${WRAPPER_METHODS[kind]}(${ctx.optionsFn}, ${renamedClass});\\n`,\n );\n\n state.wrappedClasses.add(className);\n state.renamedLocals.add(className);\n state.needsImport = true;\n}\n\nfunction wrapSpecifierExport(specifier: ExportSpecifierNode, ctx: TransformContext, state: TransformState): void {\n if (specifier.type !== 'ExportSpecifier' || specifier.exported?.type !== 'Identifier') return;\n const exportedName = specifier.exported.name;\n if (!exportedName) return;\n\n const localName = specifier.local?.type === 'Identifier' ? specifier.local.name : undefined;\n const kind = resolveWrapperKind(exportedName, localName, state);\n if (!kind) return;\n\n const localClass = localName ? state.topLevelClasses.get(localName) : undefined;\n if (!localName || !localClass?.id) return;\n\n state.wrappedClasses.add(exportedName);\n state.needsImport = true;\n if (state.renamedLocals.has(localName)) return;\n state.renamedLocals.add(localName);\n\n const renamedClass = `__SENTRY_ORIGINAL_${localName}__`;\n state.ms.overwrite(localClass.id.start, localClass.id.end, renamedClass);\n // The existing `export { ... }` statement keeps exporting the (now\n // wrapped) `localName` binding, so the wrapper is NOT exported here.\n state.ms.appendLeft(\n localClass.end,\n `\\nconst ${localName} = __SENTRY__.${WRAPPER_METHODS[kind]}(${ctx.optionsFn}, ${renamedClass});\\n`,\n );\n}\n"],"names":["MagicString","detectWorkerEntrypointClasses"],"mappings":";;;;;AA4DA,SAAS,cAAA,CAAe,MAAgB,UAAA,EAA6B;AACnE,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,gBAAA,EAAkB,OAAO,KAAA;AAC3C,EAAA,MAAM,SAAU,IAAA,CAA4B,MAAA;AAC5C,EAAA,IAAI,CAAC,QAAQ,OAAO,KAAA;AACpB,EAAA,IAAI,OAAO,IAAA,KAAS,YAAA,IAAgB,MAAA,CAAO,IAAA,KAAS,YAAY,OAAO,IAAA;AACvE,EAAA,OACE,MAAA,CAAO,SAAS,kBAAA,IAAsB,MAAA,CAAO,UAAU,IAAA,KAAS,YAAA,IAAgB,MAAA,CAAO,QAAA,CAAS,IAAA,KAAS,UAAA;AAE7G;AAoBA,MAAM,eAAA,GAAoD;AAAA,EACxD,aAAA,EAAe,mCAAA;AAAA,EACf,KAAA,EAAO,2BAAA;AAAA,EACP,QAAA,EAAU,8BAAA;AAAA,EACV,gBAAA,EAAkB;AACpB,CAAA;AA8CO,SAAS,6BAAA,CACd,IAAA,EACA,GAAA,EACA,GAAA,EAC6B;AAC7B,EAAA,MAAM,EAAA,GAAK,IAAIA,mBAAA,CAAY,IAAI,CAAA;AAC/B,EAAA,MAAM,eAAA,GAAkB,uBAAuB,GAAG,CAAA;AAClD,EAAA,MAAM,KAAA,GAA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
+ {"version":3,"file":"workerEntrypoint.js","sources":["../../../../src/vite/workerEntrypoint.ts"],"sourcesContent":["import type { BaseNode, ProgramBody } from './transform';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node shapes for structural WorkerEntrypoint detection.\n// ---------------------------------------------------------------------------\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface MemberExpressionNode extends BaseNode {\n object?: { type: string; name?: string };\n property?: { type: string; name?: string };\n}\n\ninterface ClassDeclarationNode extends BaseNode {\n id?: IdentifierNode | null;\n superClass?: BaseNode | null;\n}\n\ninterface ExportNamedDeclNode extends BaseNode {\n declaration?: BaseNode | null;\n}\n\ninterface ImportSpecifierNode {\n type: string;\n imported?: { type: string; name?: string };\n local?: { type: string; name?: string };\n}\n\ninterface ImportDeclarationNode extends BaseNode {\n source?: { value?: unknown };\n specifiers?: ImportSpecifierNode[];\n}\n\ninterface WorkerEntrypointBases {\n /** Local identifiers bound to the named `WorkerEntrypoint` import. */\n named: Set<string>;\n /** Local identifiers bound to a `* as ns` import of `cloudflare:workers`. */\n namespaces: Set<string>;\n}\n\n/**\n * Find top-level classes that (transitively, within this module) extend\n * `WorkerEntrypoint` imported from `cloudflare:workers`. esbuild has already\n * stripped TypeScript by transform time, so a superclass is a plain identifier\n * (`extends WorkerEntrypoint`) or member access (`extends cf.WorkerEntrypoint`).\n *\n * Only same-file base chains are resolvable here; a base class imported from\n * another module is invisible and relies on the config self-binding fallback.\n */\nexport function detectWorkerEntrypointClasses(ast: ProgramBody): Set<string> {\n const bases = collectWorkerEntrypointImports(ast);\n if (bases.named.size === 0 && bases.namespaces.size === 0) {\n return new Set<string>();\n }\n\n // Every top-level class, including the `export class Foo {}` form (where the\n // class is nested inside an ExportNamedDeclaration) so directly-exported\n // entrypoints are seen too.\n const classes = new Map<string, ClassDeclarationNode>();\n for (const node of ast.body) {\n const classNode = asClassDeclaration(node);\n if (classNode?.id?.name) classes.set(classNode.id.name, classNode);\n }\n\n const entrypoints = new Set<string>();\n // Iterate to a fixed point so an indirect chain (A extends B extends WE) is\n // fully resolved regardless of declaration order.\n let changed = true;\n while (changed) {\n changed = false;\n for (const [name, classNode] of classes) {\n if (entrypoints.has(name)) continue;\n if (extendsWorkerEntrypoint(classNode.superClass, bases, entrypoints)) {\n entrypoints.add(name);\n changed = true;\n }\n }\n }\n return entrypoints;\n}\n\n/** Unwrap `export class Foo {}` to its ClassDeclaration; pass bare classes through. */\nfunction asClassDeclaration(node: BaseNode): ClassDeclarationNode | undefined {\n if (node.type === 'ClassDeclaration') return node;\n if (node.type === 'ExportNamedDeclaration') {\n const decl = (node as ExportNamedDeclNode).declaration;\n if (decl?.type === 'ClassDeclaration') return decl;\n }\n return undefined;\n}\n\nfunction collectWorkerEntrypointImports(ast: ProgramBody): WorkerEntrypointBases {\n const named = new Set<string>();\n const namespaces = new Set<string>();\n for (const node of ast.body) {\n if (node.type !== 'ImportDeclaration') continue;\n const importNode = node as ImportDeclarationNode;\n if (importNode.source?.value !== 'cloudflare:workers') continue;\n for (const specifier of importNode.specifiers ?? []) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.imported?.name === 'WorkerEntrypoint' &&\n specifier.local?.name\n ) {\n named.add(specifier.local.name);\n } else if (specifier.type === 'ImportNamespaceSpecifier' && specifier.local?.name) {\n namespaces.add(specifier.local.name);\n }\n }\n }\n return { named, namespaces };\n}\n\n/**\n * Whether a superclass expression resolves to `WorkerEntrypoint` — either a bare\n * identifier from the named import (or an already-detected local subclass), or a\n * `ns.WorkerEntrypoint` member access off a namespace import.\n */\nfunction extendsWorkerEntrypoint(\n superClass: BaseNode | null | undefined,\n bases: WorkerEntrypointBases,\n detected: Set<string>,\n): boolean {\n if (!superClass) return false;\n if (superClass.type === 'Identifier') {\n const name = (superClass as IdentifierNode).name;\n return bases.named.has(name) || detected.has(name);\n }\n if (superClass.type === 'MemberExpression') {\n const member = superClass as MemberExpressionNode;\n return (\n member.object?.type === 'Identifier' &&\n !!member.object.name &&\n bases.namesp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CAAI,IAAI,CAAA,IAAK,QAAA,CAAS,IAAI,IAAI,CAAA;AAAA,EACnD;AACA,EAAA,IAAI,UAAA,CAAW,SAAS,kBAAA,EAAoB;AAC1C,IAAA,MAAM,MAAA,GAAS,UAAA;AACf,IAAA,OACE,OAAO,MAAA,EAAQ,IAAA,KAAS,gBACxB,CAAC,CAAC,OAAO,MAAA,CAAO,IAAA,IAChB,KAAA,CAAM,UAAA,CAAW,IAAI,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,IACvC,MAAA,CAAO,UAAU,IAAA,KAAS,kBAAA;AAAA,EAE9B;AACA,EAAA,OAAO,KAAA;AACT;;;;"}
@@ -5,7 +5,7 @@ const node_path = require('node:path');
5
5
  const wrangler = require('wrangler');
6
6
 
7
7
  function resolveWranglerConfig(root, explicitPath) {
8
- const configPath = ["wrangler.json", "wrangler.jsonc", "wrangler.toml"].map((name) => node_path.resolve(root, name)).find(node_fs.existsSync);
8
+ const configPath = explicitPath ? node_path.resolve(root, explicitPath) : ["wrangler.json", "wrangler.jsonc", "wrangler.toml"].map((name) => node_path.resolve(root, name)).find(node_fs.existsSync);
9
9
  if (!configPath || !node_fs.existsSync(configPath)) {
10
10
  return void 0;
11
11
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wranglerConfig.js","sources":["../../../../src/vite/wranglerConfig.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { type Unstable_Config, unstable_readConfig } from 'wrangler';\n\n/**\n * The slice of the wrangler configuration the auto-instrument plugin cares\n * about. `main` is an absolute path (wrangler resolves it against the config\n * file's directory).\n */\nexport interface WranglerConfig {\n main?: string;\n durableObjects: Array<{ name: string; className: string }>;\n workflows: Array<{ name: string; className: string }>;\n /**\n * Named `WorkerEntrypoint` exports this worker binds to itself via a service\n * binding (`services[]` whose `service` is this worker's own `name`). Only\n * self-bindings appear here: a service binding's `entrypoint` otherwise names\n * an export on a *different* worker, which this build can't wrap.\n */\n workerEntrypoints: string[];\n}\n\n/**\n * Locate and resolve the wrangler configuration via wrangler's own\n * `unstable_readConfig` — the API `@cloudflare/vite-plugin` uses.\n *\n * We only locate the file (probing `wrangler.json`, `.jsonc`, `.toml` inside\n * `root` with wrangler's own precedence, since it discovers from `cwd` rather\n * than an arbitrary root); wrangler then parses it, flattens the active\n * environment (honoring `CLOUDFLARE_ENV`), and resolves `main` to an absolute\n * path. Durable Object and Workflow bindings are the active environment's,\n * matching what the deployed Worker actually binds.\n *\n * Returns `undefined` when no config file is found or it can't be read/parsed\n * (the caller warns and disables auto-instrumentation rather than failing the\n * whole build).\n */\nexport function resolveWranglerConfig(\n root: string,\n explicitPath?: string,\n): { config: WranglerConfig; configDir: string } | undefined {\n const configPath = explicitPath\n ? resolve(root, explicitPath)\n : ['wrangler.json', 'wrangler.jsonc', 'wrangler.toml'].map(name => resolve(root, name)).find(existsSync);\n\n if (!configPath || !existsSync(configPath)) {\n return undefined;\n }\n\n let raw: Unstable_Config;\n try {\n // `hideWarnings` keeps wrangler's config diagnostics (e.g. missing DO\n // migrations) out of the Vite build output.\n raw = unstable_readConfig({ config: configPath }, { hideWarnings: true });\n } catch {\n return undefined;\n }\n\n return {\n config: {\n main: raw.main,\n durableObjects: collectClassBindings(raw.durable_objects?.bindings),\n workflows: collectClassBindings(raw.workflows),\n workerEntrypoints: collectSelfBoundEntrypoints(raw),\n },\n configDir: dirname(raw.configPath ?? configPath),\n };\n}\n\n/**\n * Collect named `WorkerEntrypoint` exports the worker binds to itself. A service\n * binding's `entrypoint` normally names an export on the *target* worker, so it\n * is only ours when `service` equals this worker's own `name`. Without a `name`\n * there is nothing to match against, so no entrypoints are derivable.\n */\nfunction collectSelfBoundEntrypoints(raw: Unstable_Config): string[] {\n if (!raw.name) {\n return [];\n }\n const entrypoints = new Set<string>();\n for (const binding of raw.services ?? []) {\n if (binding?.service === raw.name && typeof binding.entrypoint === 'string') {\n entrypoints.add(binding.entrypoint);\n }\n }\n return [...entrypoints];\n}\n\n/**\n * Map wrangler class bindings (Durable Objects, Workflows — same shape) to the\n * `{ name, className }` the transform needs, skipping duplicates and bindings\n * with a `script_name` (those reference a class exported by a *different*\n * worker, so there is nothing to wrap in this worker's entry file).\n */\nfunction collectClassBindings(\n bindings: ReadonlyArray<{ name: string; class_name?: string; script_name?: string }> | undefined,\n): Array<{ name: string; className: string }> {\n const result: Array<{ name: string; className: string }> = [];\n const seenClassNames = new Set<string>();\n for (const binding of bindings ?? []) {\n if (typeof binding?.class_name !== 'string' || binding.script_name || seenClassNames.has(binding.class_name)) {\n continue;\n }\n seenClassNames.add(binding.class_name);\n result.push({ name: binding.name, className: binding.class_name });\n }\n return result;\n}\n"],"names":["resolve","existsSync","unstable_readConfig","dirname"],"mappings":";;;;;;AAqCO,SAAS,qBAAA,CACd,MACA,YAAA,EAC2D;AAC3D,EAAA,MAAM,aAAa,YAAA,GACfA,iBAAA,CAAQ,MAAM,YAAY,CAAA,GAC1B,CAAC,eAAA,EAAiB,gBAAA,EAAkB,eAAe,CAAA,CAAE,GAAA,CAAI,UAAQA,iBAAA,CAAQ,IAAA,EAAM,IAAI,CAAC,CAAA,CAAE,KAAKC,kBAAU,CAAA;AAEzG,EAAA,IAAI,CAAC,UAAA,IAAc,CAACA,kBAAA,CAAW,UAAU,CAAA,EAAG;AAC1C,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AAGF,IAAA,GAAA,GAAMC,4BAAA,CAAoB,EAAE,MAAA,EAAQ,UAAA,IAAc,EAAE,YAAA,EAAc,MAAM,CAAA;AAAA,EAC1E,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ;AAAA,MACN,MAAM,GAAA,CAAI,IAAA;AAAA,MACV,cAAA,EAAgB,oBAAA,CAAqB,GAAA,CAAI,eAAA,EAAiB,QAAQ,CAAA;AAAA,MAClE,SAAA,EAAW,oB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3
- const async = require('./async.js');
4
- const instrument = require('./instrument.js');
3
+ const noDiagnosticChannels = require('@sentry/server-utils/no-diagnostic-channels');
5
4
  const instrumentEmail = require('./instrumentations/worker/instrumentEmail.js');
6
5
  const instrumentFetch = require('./instrumentations/worker/instrumentFetch.js');
7
6
  const instrumentQueue = require('./instrumentations/worker/instrumentQueue.js');
8
7
  const instrumentScheduled = require('./instrumentations/worker/instrumentScheduled.js');
9
8
  const instrumentTail = require('./instrumentations/worker/instrumentTail.js');
10
- const hono = require('./integrations/hono.js');
11
9
  const isCloudflareClass = require('./utils/isCloudflareClass.js');
12
10
  const instrumentWorkerEntrypoint = require('./instrumentations/instrumentWorkerEntrypoint.js');
13
11
 
@@ -15,10 +13,9 @@ function withSentry(optionsCallback, handler) {
15
13
  if (isCloudflareClass.isCloudflareClass(handler, "WorkerEntrypoint")) {
16
14
  return instrumentWorkerEntrypoint.instrumentWorkerEntrypoint(optionsCallback, handler);
17
15
  }
18
- async.setAsyncLocalStorageAsyncContextStrategy();
16
+ noDiagnosticChannels.setAsyncLocalStorageAsyncContextStrategy();
19
17
  try {
20
18
  instrumentFetch.instrumentExportedHandlerFetch(handler, optionsCallback);
21
- instrumentHonoErrorHandler(handler);
22
19
  instrumentScheduled.instrumentExportedHandlerScheduled(handler, optionsCallback);
23
20
  instrumentEmail.instrumentExportedHandlerEmail(handler, optionsCallback);
24
21
  instrumentQueue.instrumentExportedHandlerQueue(handler, optionsCallback);
@@ -27,20 +24,6 @@ function withSentry(optionsCallback, handler) {
27
24
  }
28
25
  return handler;
29
26
  }
30
- function instrumentHonoErrorHandler(handler) {
31
- if ("onError" in handler && "errorHandler" in handler && typeof handler.errorHandler === "function") {
32
- handler.errorHandler = instrument.ensureInstrumented(
33
- handler.errorHandler,
34
- (original) => new Proxy(original, {
35
- apply(target, thisArg, args) {
36
- const [err, context] = args;
37
- hono.getHonoIntegration()?.handleHonoException(err, context);
38
- return Reflect.apply(target, thisArg, args);
39
- }
40
- })
41
- );
42
- }
43
- }
44
27
 
45
28
  exports.withSentry = withSentry;
46
29
  //# sourceMappingURL=withSentry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withSentry.js","sources":["../../../src/withSentry.ts"],"sourcesContent":["import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\nimport type { CloudflareOptions } from './client';\nimport { instrumentExportedHandlerEmail } from './instrumentations/worker/instrumentEmail';\nimport { instrumentExportedHandlerFetch } from './instrumentations/worker/instrumentFetch';\nimport { instrumentExportedHandlerQueue } from './instrumentations/worker/instrumentQueue';\nimport { instrumentExportedHandlerScheduled } from './instrumentations/worker/instrumentScheduled';\nimport { instrumentExportedHandlerTail } from './instrumentations/worker/instrumentTail';\nimport { isCloudflareClass } from './utils/isCloudflareClass';\nimport type { AnyExportedHandler, DefaultEnv, ResolveEnv } from './types';\nimport {\n instrumentWorkerEntrypoint,\n type WorkerEntrypointConstructor,\n} from './instrumentations/instrumentWorkerEntrypoint';\n\n/**\n * Wrapper for Cloudflare handlers.\n *\n * Initializes the SDK and wraps the handler with Sentry instrumentation.\n *\n * Automatically instruments the `fetch` method of the handler.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param handler {ExportedHandler} The handler to wrap.\n * @returns The wrapped handler.\n */\nexport function withSentry<\n Env = DefaultEnv,\n QueueHandlerMessage = unknown,\n CfHostMetadata = unknown,\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends AnyExportedHandler | WorkerEntrypointConstructor<any, any> =\n | ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata>\n | WorkerEntrypointConstructor<Env>,\n>(optionsCallback: (env: ResolveEnv<T, Env>) => CloudflareOptions | undefined, handler: T): T {\n if (isCloudflareClass(handler, 'WorkerEntrypoint')) {\n // oxlint-disable-next-line typescript/no-explicit-any\n return instrumentWorkerEntrypoint(optionsCallback as any, handler);\n }\n\n setAsyncLocalStorageAsyncContextStrategy();\n\n try {\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerFetch(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerScheduled(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerEmail(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerQueue(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerTail(handler, optionsCallback as any);\n // This is here because Miniflare sometimes cannot get instrumented\n } catch {\n // Do not console anything here, we don't want to spam the console with errors\n }\n\n return handler;\n}\n"],"names":["isCloudflareClass","instrumentWorkerEntrypoint","setAsyncLocalStorageAsyncContextStrategy","instrumentExportedHandlerFetch","instrumentExportedHandlerScheduled","instrumentExportedHandlerEmail","instrumentExportedHandlerQueue","instrumentExportedHandlerTail"],"mappings":";;;;;;;;;;;AAyBO,SAAS,UAAA,CAQd,iBAA6E,OAAA,EAAe;AAC5F,EAAA,IAAIA,mCAAA,CAAkB,OAAA,EAAS,kBAAkB,CAAA,EAAG;AAElD,IAAA,OAAOC,qDAAA,CAA2B,iBAAwB,OAAO,CAAA;AAAA,EACnE;AAEA,EAAAC,6DAAA,EAAyC;AAEzC,EAAA,IAAI;AAEF,IAAAC,8CAAA,CAA+B,SAAS,eAAsB,CAAA;AAE9D,IAAAC,sDAAA,CAAmC,SAAS,eAAsB,CAAA;AAElE,IAAAC,8CAAA,CAA+B,SAAS,eAAsB,CAAA;AAE9D,IAAAC,8CAAA,CAA+B,SAAS,eAAsB,CAAA;AAE9D,IAAAC,4CAAA,CAA8B,SAAS,eAAsB,CAAA;AAAA,EAE/D,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
@@ -1,7 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
+ const attributes = require('@sentry/conventions/attributes');
4
+ const op = require('@sentry/conventions/op');
3
5
  const core = require('@sentry/core');
4
- const async = require('./async.js');
6
+ const noDiagnosticChannels = require('@sentry/server-utils/no-diagnostic-channels');
5
7
  const flush = require('./flush.js');
6
8
  const instrumentEnv = require('./instrumentations/worker/instrumentEnv.js');
7
9
  const scopeUtils = require('./scope-utils.js');
@@ -42,10 +44,12 @@ class WrappedWorkflowStep {
42
44
  const isFinalAttempt = !hasStepContext || attempt > retryLimit;
43
45
  return core.startSpan(
44
46
  {
45
- op: "function.step.do",
46
47
  name,
47
48
  scope: scopeForStep,
48
49
  attributes: {
50
+ [attributes.SENTRY_OP]: op.GENERAL_FUNCTION_SPAN_OP,
51
+ [attributes.CODE_FUNCTION_NAME]: name,
52
+ "workflow.step.name": name,
49
53
  "cloudflare.workflow.timeout": config?.timeout,
50
54
  "cloudflare.workflow.retries.backoff": config?.retries?.backoff,
51
55
  // In workers-types v5, `delay` may be a `WorkflowDelayFunction`, which isn't a valid span attribute value.
@@ -89,6 +93,7 @@ class WrappedWorkflowStep {
89
93
  }
90
94
  function instrumentWorkflowWithSentry(optionsCallback, WorkFlowClass) {
91
95
  return new Proxy(WorkFlowClass, {
96
+ // oxlint-disable-next-line typescript/no-explicit-any
92
97
  construct(target, args, newTarget) {
93
98
  const [ctx, env] = args;
94
99
  const context = instrumentContext.instrumentContext(ctx);
@@ -100,9 +105,9 @@ function instrumentWorkflowWithSentry(optionsCallback, WorkFlowClass) {
100
105
  get(obj, prop, receiver) {
101
106
  if (prop === "run") {
102
107
  return async function(event, step) {
103
- async.setAsyncLocalStorageAsyncContextStrategy();
108
+ noDiagnosticChannels.setAsyncLocalStorageAsyncContextStrategy();
104
109
  return core.withIsolationScope(async (isolationScope) => {
105
- const waitUntil = context.waitUntil.bind(context);
110
+ const waitUntil = flush.getOriginalWaitUntil(context).bind(context);
106
111
  const client = sdk.init({ ...options, ctx: context, enableDedupe: false });
107
112
  isolationScope.setClient(client);
108
113
  scopeUtils.addCloudResourceContext(isolationScope);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.js","sources":["../../../src/workflows.ts"],"sourcesContent":["import { CODE_FUNCTION_NAME, SENTRY_OP } from '@sentry/conventions/attributes';\nimport { GENERAL_FUNCTION_SPAN_OP } from '@sentry/conventions/op';\nimport type { PropagationContext } from '@sentry/core';\nimport {\n captureException,\n flush,\n getCurrentScope,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type {\n WorkflowDelayDuration,\n WorkflowEntrypoint,\n WorkflowEvent,\n WorkflowSleepDuration,\n WorkflowStep,\n WorkflowStepConfig,\n WorkflowStepContext,\n WorkflowStepEvent,\n WorkflowStepRollbackOptions,\n WorkflowTimeoutDuration,\n} from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { instrumentEnv } from './instrumentations/worker/instrumentEnv';\nimport { addCloudResourceContext } from './scope-utils';\nimport { init } from './sdk';\nimport { instrumentContext } from './utils/instrumentContext';\nimport type { DefaultEnv, ResolveEnv } from './types';\n\nconst UUID_REGEX = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i;\n\n/**\n * Hashes a string to a UUID using SHA-1.\n */\nexport async function deterministicTraceIdFromInstanceId(instanceId: string): Promise<string> {\n const buf = await crypto.subtle.digest('SHA-1', new TextEncoder().encode(instanceId));\n return (\n Array.from(new Uint8Array(buf))\n // We only need the first 16 bytes for the 32 characters\n .slice(0, 16)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('')\n );\n}\n\nasync function propagationContextFromInstanceId(instanceId: string): Promise<PropagationContext> {\n const traceId = UUID_REGEX.test(instanceId)\n ? instanceId.replace(/-/g, '')\n : await deterministicTraceIdFromInstanceId(instanceId);\n\n // Derive sampleRand from last 4 characters of the random UUID\n //\n // We cannot store any state between workflow steps, so we derive the\n // sampleRand from the traceId itself. This ensures that the sampling is\n // consistent across all steps in the same workflow instance.\n const sampleRand = parseInt(traceId.slice(-4), 16) / 0xffff;\n\n return {\n traceId,\n sampleRand,\n };\n}\n\nclass WrappedWorkflowStep implements WorkflowStep {\n public constructor(\n private _instanceId: string,\n private _options: CloudflareOptions,\n private _step: WorkflowStep,\n private _waitUntil: ExecutionContext['waitUntil'],\n ) {}\n\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n callback: (ctx: WorkflowStepContext) => Promise<T>,\n rollbackOptions?: WorkflowStepRollbackOptions<T>,\n ): Promise<T>;\n public async do<T extends Rpc.Serializable<T>, const C extends WorkflowStepConfig>(\n name: string,\n config: C,\n callback: (\n ctx: WorkflowStepContext<C['retries'] extends { delay: infer D } ? D : WorkflowDelayDuration | number>,\n ) => Promise<T>,\n rollbackOptions?: WorkflowStepRollbackOptions<T>,\n ): Promise<T>;\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n configOrCallback: WorkflowStepConfig | ((ctx: WorkflowStepContext) => Promise<T>),\n callbackOrRollback?: ((ctx: WorkflowStepContext) => Promise<T>) | WorkflowStepRollbackOptions<T>,\n maybeRollback?: WorkflowStepRollbackOptions<T>,\n ): Promise<T> {\n // Capture the current scope, so parent span (e.g., a startSpan surrounding step.do) is preserved\n const scopeForStep = getCurrentScope();\n\n const hasConfig = typeof configOrCallback !== 'function';\n const config = hasConfig ? configOrCallback : undefined;\n const userCallback = (hasConfig ? callbackOrRollback : configOrCallback) as (\n ctx: WorkflowStepContext,\n ) => Promise<T>;\n const rollbackOptions = (hasConfig ? maybeRollback : callbackOrRollback) as\n | WorkflowStepRollbackOptions<T>\n | undefined;\n\n const instrumentedCallback = async (...args: unknown[]): Promise<T> => {\n // Feature detection: Cloudflare Workflows (April 2026+) pass a step context\n // with `attempt` and `config.retries.limit`. When available, we only capture\n // errors on the final attempt to avoid duplicates during retries.\n const stepContext = args[0] as { attempt?: number; config?: { retries?: { limit?: number } } } | undefined;\n const attempt = stepContext?.attempt;\n const retryLimit = stepContext?.config?.retries?.limit;\n const hasStepContext = typeof attempt === 'number' && typeof retryLimit === 'number';\n\n // Only capture error on final attempt (attempt > retryLimit means no more retries left)\n // or when step context is unavailable (legacy behavior - capture all errors)\n const isFinalAttempt = !hasStepContext || attempt > retryLimit;\n\n return startSpan(\n {\n name,\n scope: scopeForStep,\n attributes: {\n [SENTRY_OP]: GENERAL_FUNCTION_SPAN_OP,\n [CODE_FUNCTION_NAME]: name,\n 'workflow.step.name': name,\n 'cloudflare.workflow.timeout': config?.timeout,\n 'cloudflare.workflow.retries.backoff': config?.retries?.backoff,\n // In workers-types v5, `delay` may be a `WorkflowDelayFunction`, which isn't a valid span attribute value.\n 'cloudflare.workflow.retries.delay':\n typeof config?.retries?.delay === 'function' ? undefined : config?.retries?.delay,\n 'cloudflare.workflow.retries.limit': config?.retries?.limit,\n 'cloudflare.workflow.attempt': attempt,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async span => {\n try {\n const result = await (userCallback as (...args: unknown[]) => Promise<T>)(...args);\n span.setStatus({ code: 1 });\n return result;\n } catch (error) {\n if (isFinalAttempt) {\n captureException(error, { mechanism: { handled: true, type: 'auto.faas.cloudflare.workflow' } });\n }\n throw error;\n } finally {\n this._waitUntil(flush(2000));\n }\n },\n );\n };\n\n if (config) {\n return rollbackOptions\n ? this._step.do(name, config, instrumentedCallback, rollbackOptions)\n : this._step.do(name, config, instrumentedCallback);\n }\n\n return rollbackOptions\n ? this._step.do(name, instrumentedCallback, rollbackOptions)\n : this._step.do(name, instrumentedCallback);\n }\n\n public async sleep(name: string, duration: WorkflowSleepDuration): Promise<void> {\n return this._step.sleep(name, duration);\n }\n\n public async sleepUntil(name: string, timestamp: Date | number): Promise<void> {\n return this._step.sleepUntil(name, timestamp);\n }\n\n public async waitForEvent<T extends Rpc.Serializable<T>>(\n name: string,\n options: { type: string; timeout?: WorkflowTimeoutDuration | number },\n ): Promise<WorkflowStepEvent<T>> {\n return this._step.waitForEvent<T>(name, options);\n }\n}\n\n/**\n * Instruments a Cloudflare Workflow class with Sentry.\n *\n * @example\n * ```typescript\n * const InstrumentedWorkflow = instrumentWorkflowWithSentry(\n * (env) => ({ dsn: env.SENTRY_DSN }),\n * MyWorkflowClass\n * );\n *\n * export default InstrumentedWorkflow;\n * ```\n *\n * @param optionsCallback - Function that returns Sentry options to initialize Sentry\n * @param WorkflowClass - The workflow class to instrument\n * @returns Instrumented workflow class with the same interface\n */\nexport function instrumentWorkflowWithSentry<\n E = DefaultEnv, // Environment type\n P = unknown, // Payload type\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends WorkflowEntrypoint<any, any> = WorkflowEntrypoint<E, P>, // WorkflowEntrypoint type\n // The constraint must not route through `T`: workers-types defaults `WorkflowEntrypoint`'s\n // `Env` to `unknown` (unlike `WorkerEntrypoint`/`DurableObject`, which default to\n // `Cloudflare.Env`), so a bare subclass would be rejected in a `wrangler types` project.\n // The callback env is resolved from the inferred constructor via `ResolveEnv` instead.\n // oxlint-disable-next-line typescript/no-explicit-any\n C extends new (ctx: ExecutionContext, env: any) => WorkflowEntrypoint<any, any> = new (\n ctx: ExecutionContext,\n // oxlint-disable-next-line typescript/no-explicit-any\n env: any,\n ) => T, // Constructor type of the WorkflowEntrypoint class\n>(optionsCallback: (env: ResolveEnv<C, E>) => CloudflareOptions, WorkFlowClass: C): C {\n return new Proxy(WorkFlowClass, {\n // oxlint-disable-next-line typescript/no-explicit-any\n construct(target: C, args: [ctx: ExecutionContext, env: any], newTarget) {\n const [ctx, env] = args;\n const context = instrumentContext(ctx);\n const options = optionsCallback(env);\n args[0] = context;\n args[1] = instrumentEnv(env as Record<string, unknown>, options) as E;\n const instance = Reflect.construct(target, args, newTarget) as T;\n return new Proxy(instance, {\n get(obj, prop, receiver) {\n if (prop === 'run') {\n return async function (event: WorkflowEvent<P>, step: WorkflowStep): Promise<unknown> {\n setAsyncLocalStorageAsyncContextStrategy();\n\n return withIsolationScope(async isolationScope => {\n const waitUntil = getOriginalWaitUntil(context).bind(context);\n const client = init({ ...options, ctx: context, enableDedupe: false });\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n return withScope(async scope => {\n const propagationContext = await propagationContextFromInstanceId(event.instanceId);\n scope.setPropagationContext(propagationContext);\n\n try {\n return await obj.run.call(\n obj,\n event,\n new WrappedWorkflowStep(event.instanceId, options, step, waitUntil),\n );\n } finally {\n waitUntil(flushAndDispose(client));\n }\n });\n });\n };\n }\n return Reflect.get(obj, prop, receiver);\n },\n });\n },\n });\n}\n"],"names":["getCurrentScope","startSpan","SENTRY_OP","GENERAL_FUNCTION_SPAN_OP","CODE_FUNCTION_NAME","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","captureException","flush","instrumentContext","instrumentEnv","setAsyncLocalStorageAsyncContextStrategy","withIsolationScope","getOriginalWaitUntil","init","addCloudResourceContext","withScope","flushAndDispose"],"mappings":";;;;;;;;;;;;AAkCA,MAAM,UAAA,GAAa,qEAAA;AAKnB,eAAsB,mCAAmC,UAAA,EAAqC;AAC5F,EAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,OAAA,EAAS,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,UAAU,CAAC,CAAA;AACpF,EAAA,OACE,KAAA,CAAM,KAAK,IAAI,UAAA,CAAW,GAAG,CAAC,CAAA,CAE3B,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,CACX,IAAI,CAAA,CAAA,KAAK,CAAA,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,QAAA,CAAS,GAAG,GAAG,CAAC,CAAA,CACxC,IAAA,CAAK,EAAE,CAAA;AAE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AAAA,gBACF,CAAC,CAAA;AAAA,cACH,CAAC,CAAA;AAAA,YACH,CAAA;AAAA,UACF;AACA,UAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,GAAA,EAAK,IAAA,EAAM,QAAQ,CAAA;AAAA,QACxC;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;;"}
@@ -4,6 +4,7 @@ const core = require('@sentry/core');
4
4
  const flush = require('./flush.js');
5
5
  const instrument = require('./instrument.js');
6
6
  const sdk = require('./sdk.js');
7
+ const invocationScope = require('./utils/invocationScope.js');
7
8
  const rpcMeta = require('./utils/rpcMeta.js');
8
9
  const traceLinks = require('./utils/traceLinks.js');
9
10
 
@@ -32,8 +33,6 @@ function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
32
33
  args = extracted.args;
33
34
  rpcMeta$1 = extracted.rpcMeta;
34
35
  }
35
- const currentClient = core.getClient();
36
- const sentryWithScope = startNewTrace ? core.withIsolationScope : currentClient ? core.withScope : core.withIsolationScope;
37
36
  const wrappedFunction = (scope) => {
38
37
  const context = wrapperOptions.context;
39
38
  const waitUntil = context ? flush.getOriginalWaitUntil(context)?.bind(context) : void 0;
@@ -124,7 +123,7 @@ function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
124
123
  }
125
124
  return executeSpan();
126
125
  };
127
- return sentryWithScope(wrappedFunction);
126
+ return invocationScope.withInvocationIsolationScope(wrappedFunction);
128
127
  }
129
128
  }),
130
129
  noMark
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapMethodWithSentry.js","sources":["../../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport {\n isObjectLike,\n captureException,\n continueTrace,\n isThenable,\n type Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startNewTrace as startNewTraceCore,\n startSpan,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { withInvocationIsolationScope } from './utils/invocationScope';\nimport { extractRpcMeta } from './utils/rpcMeta';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\nexport interface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\n/**\n * Resolves uninstrumented DO storage for the current invocation.\n * Prefer `thisArg.ctx` (the live Durable Object instance) over the context captured at\n * construction time to avoid cross-DO I/O errors in the same isolate.\n */\nfunction resolveOriginalStorage(\n context: ExecutionContext | InstrumentedDurableObjectState | undefined,\n thisArg: unknown,\n): DurableObjectStorage | undefined {\n if (isObjectLike(thisArg) && 'ctx' in thisArg) {\n const doCtx = (thisArg as { ctx: InstrumentedDurableObjectState }).ctx;\n if (doCtx?.originalStorage) {\n return doCtx.originalStorage;\n }\n }\n\n if (context && 'originalStorage' in context && context.originalStorage) {\n return context.originalStorage;\n }\n\n return undefined;\n}\n\ntype MethodWrapperOptions = {\n spanName?: string;\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | InstrumentedDurableObjectState;\n /**\n * If true, starts a fresh trace instead of inheriting from a parent trace.\n * Useful for scheduled/independent invocations like alarms.\n *\n * If true, it also stores the current span context and links to the previous invocation's span.\n * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`\n * in a `waitUntil` to avoid blocking.\n *\n * @default false\n */\n startNewTrace?: boolean;\n /**\n * The trace origin identifying which instrumentation created the span, e.g. `auto.faas.cloudflare.durable_object`.\n * Used both as the span's `sentry.origin` attribute and as the `mechanism.type` for captured exceptions.\n */\n origin: string;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry error tracking and optional tracing.\n * Supports starting new traces and linking to previous invocations via Durable Object storage.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n return ensureInstrumented(\n handler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, rawArgs: Parameters<T>) {\n const { startNewTrace, origin } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\n\n const wrappedFunction = (scope: Scope): unknown | Promise<unknown> => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context: typeof wrapperOptions.context | undefined = wrapperOptions.context;\n\n // see: https://github.com/getsentry/sentry-javascript/issues/22328\n const waitUntil = context\n ? getOriginalWaitUntil(context as ExecutionContextCompat)?.bind(context)\n : undefined;\n const storage = resolveOriginalStorage(context, thisArg);\n\n let scopeClient = scope.getClient();\n // Check if client exists AND is still usable (transport not disposed)\n // This handles the case where a previous handler disposed the client\n // but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)\n // For startNewTrace, always create a fresh client\n if (startNewTrace || !scopeClient?.getTransport()) {\n const client = init({\n ...wrapperOptions.options,\n ctx: context as unknown as ExecutionContext | undefined,\n });\n scope.setClient(client);\n scopeClient = client;\n }\n\n const clientToDispose = scopeClient;\n const methodName = wrapperOptions.spanName || 'unknown';\n\n const teardown = async (): Promise<void> => {\n if (startNewTrace && storage) {\n storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n const onFulfilled = (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n };\n\n const onRejected = (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: origin,\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n };\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n if (startNewTrace && storage) {\n const storedContext = getStoredSpanContext(storage, methodName);\n\n if (storedContext) {\n span.addLinks(buildSpanLinks(storedContext));\n // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we\n // can obtain the previous trace information from the EAP store. Long-term, EAP will handle\n // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us\n // to check this at v11 time :)\n const sampledFlag = storedContext.sampled ? '1' : '0';\n span.setAttribute(\n 'sentry.previous_trace',\n `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,\n );\n }\n }\n\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n });\n };\n\n if (rpcMeta) {\n return continueTrace(\n { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },\n executeSpan,\n );\n }\n\n if (startNewTrace) {\n return startNewTraceCore(() => executeSpan());\n }\n\n return executeSpan();\n };\n\n return withInvocationIsolationScope(wrappedFunction);\n },\n }),\n noMark,\n );\n}\n"],"names":["isObjectLike","ensureInstrumented","rpcMeta","extractRpcMeta","getOriginalWaitUntil","init","storeSpanContext","flushAndDispose","captureException","isThenable","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","startSpan","getStoredSpanContext","buildSpanLinks","continueTrace","startNewTraceCore","withInvocationIsolationScope"],"mappings":";;;;;;;;;;AAgCA,SAAS,sBAAA,CACP,SACA,OAAA,EACkC;AAClC,EAAA,IAAIA,iBAAA,CAAa,OAAO,CAAA,IAAK,KAAA,IAAS,OAAA,EAAS;AAC7C,IAAA,MAAM,QAAS,OAAA,CAAoD,GAAA;AACnE,IAAA,IAAI,OAAO,eAAA,EAAiB;AAC1B,MAAA,OAAO,KAAA,CAAM,eAAA;AAAA,IACf;AAAA,EACF;AAEA,EAAA,IAAI,OAAA,IAAW,iBAAA,IAAqB,OAAA,IAAW,OAAA,CAAQ,eAAA,EAAiB;AACtE,IAAA,OAAO,OAAA,CAAQ,eAAA;AAAA,EACjB;AAEA,EAAA,OAAO,MAAA;AACT;AAuCO,SAAS,oBAAA,CACd,cAAA,EACA,OAAA,EACA,QAAA,EACA,MAAA,EACG;AACH,EAAA,OAAOC,6BAAA;AAAA,IACL,OAAA;AAAA,IACA,CAAA,QAAA,KACE,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,MAClB,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAwB;AAC7C,QAAA,MAAM,EAAE,aAAA,EAAe,MAAA,EAAO,GAAI,cAAA;AAKlC,QAAA,IAAI,IAAA,GAAO,OAAA;AACX,QAAA,IAAIC,SAAA;AAEJ,QAAA,IAAI,cAAA,CAAe,WAAW,KAAA,EAAO;AACnC,UAAA,MAAM,SAAA,GAAYC,uBAAe,OAAO,CAAA;AACxC,UAAA,IAAA,GAAO,SAAA,CAAU,IAAA;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