braintrust 3.11.0 → 3.13.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 (77) hide show
  1. package/README.md +8 -8
  2. package/dev/dist/index.d.mts +26 -7
  3. package/dev/dist/index.d.ts +26 -7
  4. package/dev/dist/index.js +2717 -335
  5. package/dev/dist/index.mjs +2499 -117
  6. package/dist/apply-auto-instrumentation.browser.d.mts +2 -0
  7. package/dist/apply-auto-instrumentation.browser.d.ts +2 -0
  8. package/dist/apply-auto-instrumentation.browser.js +18 -0
  9. package/dist/apply-auto-instrumentation.browser.mjs +0 -0
  10. package/dist/apply-auto-instrumentation.d.mts +2 -0
  11. package/dist/apply-auto-instrumentation.d.ts +2 -0
  12. package/dist/apply-auto-instrumentation.js +2534 -0
  13. package/dist/apply-auto-instrumentation.mjs +2534 -0
  14. package/dist/auto-instrumentations/bundler/esbuild.cjs +1803 -1283
  15. package/dist/auto-instrumentations/bundler/esbuild.d.mts +9 -5
  16. package/dist/auto-instrumentations/bundler/esbuild.d.ts +9 -5
  17. package/dist/auto-instrumentations/bundler/esbuild.mjs +10 -2
  18. package/dist/auto-instrumentations/bundler/next.cjs +3269 -0
  19. package/dist/auto-instrumentations/bundler/next.d.mts +3 -0
  20. package/dist/auto-instrumentations/bundler/next.d.ts +3 -0
  21. package/dist/auto-instrumentations/bundler/next.mjs +189 -0
  22. package/dist/auto-instrumentations/bundler/rollup.cjs +1803 -1283
  23. package/dist/auto-instrumentations/bundler/rollup.d.mts +9 -5
  24. package/dist/auto-instrumentations/bundler/rollup.d.ts +9 -5
  25. package/dist/auto-instrumentations/bundler/rollup.mjs +10 -2
  26. package/dist/auto-instrumentations/bundler/vite.cjs +1803 -1283
  27. package/dist/auto-instrumentations/bundler/vite.d.mts +9 -5
  28. package/dist/auto-instrumentations/bundler/vite.d.ts +9 -5
  29. package/dist/auto-instrumentations/bundler/vite.mjs +10 -2
  30. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1861 -1308
  31. package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +3 -3
  32. package/dist/auto-instrumentations/bundler/webpack.cjs +1803 -1283
  33. package/dist/auto-instrumentations/bundler/webpack.d.mts +9 -5
  34. package/dist/auto-instrumentations/bundler/webpack.d.ts +9 -5
  35. package/dist/auto-instrumentations/bundler/webpack.mjs +6 -6
  36. package/dist/auto-instrumentations/{chunk-DIV5TO4S.mjs → chunk-E5DUYJWK.mjs} +338 -1
  37. package/dist/auto-instrumentations/chunk-GJOO4ESL.mjs +300 -0
  38. package/dist/auto-instrumentations/chunk-WFEUJACP.mjs +18 -0
  39. package/dist/auto-instrumentations/hook.mjs +1713 -1460
  40. package/dist/auto-instrumentations/index.cjs +94 -0
  41. package/dist/auto-instrumentations/index.d.mts +5 -1
  42. package/dist/auto-instrumentations/index.d.ts +5 -1
  43. package/dist/auto-instrumentations/index.mjs +6 -247
  44. package/dist/auto-instrumentations/loader/esm-hook.mjs +19 -2
  45. package/dist/auto-instrumentations/plugin-D7nDswtC.d.mts +44 -0
  46. package/dist/auto-instrumentations/plugin-D7nDswtC.d.ts +44 -0
  47. package/dist/browser.d.mts +264 -47
  48. package/dist/browser.d.ts +264 -47
  49. package/dist/browser.js +2521 -159
  50. package/dist/browser.mjs +2521 -159
  51. package/dist/chunk-26JGOELH.js +817 -0
  52. package/dist/chunk-75IQCUB2.mjs +817 -0
  53. package/dist/cli.js +2510 -122
  54. package/dist/edge-light.d.mts +1 -1
  55. package/dist/edge-light.d.ts +1 -1
  56. package/dist/edge-light.js +2521 -159
  57. package/dist/edge-light.mjs +2521 -159
  58. package/dist/index.d.mts +264 -47
  59. package/dist/index.d.ts +264 -47
  60. package/dist/index.js +3498 -1850
  61. package/dist/index.mjs +2635 -987
  62. package/dist/instrumentation/index.d.mts +7897 -48
  63. package/dist/instrumentation/index.d.ts +7897 -48
  64. package/dist/instrumentation/index.js +2408 -95
  65. package/dist/instrumentation/index.mjs +2407 -95
  66. package/dist/workerd.d.mts +1 -1
  67. package/dist/workerd.d.ts +1 -1
  68. package/dist/workerd.js +2521 -159
  69. package/dist/workerd.mjs +2521 -159
  70. package/package.json +23 -17
  71. package/util/dist/index.d.mts +3 -1
  72. package/util/dist/index.d.ts +3 -1
  73. package/util/dist/index.js +6 -0
  74. package/util/dist/index.mjs +6 -0
  75. package/dist/auto-instrumentations/chunk-G6ZWXGZB.mjs +0 -116
  76. package/dist/auto-instrumentations/plugin-Df3qKIl2.d.mts +0 -22
  77. package/dist/auto-instrumentations/plugin-Df3qKIl2.d.ts +0 -22
@@ -31,7 +31,9 @@ __export(index_exports, {
31
31
  googleGenAIConfigs: () => googleGenAIConfigs,
32
32
  groqConfigs: () => groqConfigs,
33
33
  huggingFaceConfigs: () => huggingFaceConfigs,
34
+ langchainConfigs: () => langchainConfigs,
34
35
  mistralConfigs: () => mistralConfigs,
36
+ openAIAgentsCoreConfigs: () => openAIAgentsCoreConfigs,
35
37
  openAICodexConfigs: () => openAICodexConfigs,
36
38
  openRouterAgentConfigs: () => openRouterAgentConfigs,
37
39
  openRouterConfigs: () => openRouterConfigs,
@@ -124,6 +126,7 @@ var iso = {
124
126
  getRepoInfo: async (_settings) => void 0,
125
127
  getPastNAncestors: async () => [],
126
128
  getEnv: (_name) => void 0,
129
+ getBraintrustApiKey: async () => void 0,
127
130
  getCallerLocation: () => void 0,
128
131
  newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(),
129
132
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1034,6 +1037,51 @@ var cursorSDKConfigs = cursorSDKEntrypoints.flatMap((filePath) => [
1034
1037
  }
1035
1038
  ]);
1036
1039
 
1040
+ // src/instrumentation/plugins/openai-agents-channels.ts
1041
+ var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", {
1042
+ onTraceStart: channel({
1043
+ channelName: "tracing.processor.onTraceStart",
1044
+ kind: "async"
1045
+ }),
1046
+ onTraceEnd: channel({
1047
+ channelName: "tracing.processor.onTraceEnd",
1048
+ kind: "async"
1049
+ }),
1050
+ onSpanStart: channel({
1051
+ channelName: "tracing.processor.onSpanStart",
1052
+ kind: "async"
1053
+ }),
1054
+ onSpanEnd: channel({
1055
+ channelName: "tracing.processor.onSpanEnd",
1056
+ kind: "async"
1057
+ })
1058
+ });
1059
+
1060
+ // src/auto-instrumentations/configs/openai-agents.ts
1061
+ var lifecycleMethods = [
1062
+ ["onTraceStart", openAIAgentsCoreChannels.onTraceStart.channelName],
1063
+ ["onTraceEnd", openAIAgentsCoreChannels.onTraceEnd.channelName],
1064
+ ["onSpanStart", openAIAgentsCoreChannels.onSpanStart.channelName],
1065
+ ["onSpanEnd", openAIAgentsCoreChannels.onSpanEnd.channelName]
1066
+ ];
1067
+ var openAIAgentsCoreConfigs = lifecycleMethods.flatMap(
1068
+ ([methodName, channelName]) => ["dist/tracing/processor.mjs", "dist/tracing/processor.js"].map(
1069
+ (filePath) => ({
1070
+ channelName,
1071
+ module: {
1072
+ name: "@openai/agents-core",
1073
+ versionRange: ">=0.0.14",
1074
+ filePath
1075
+ },
1076
+ functionQuery: {
1077
+ className: "MultiTracingProcessor",
1078
+ methodName,
1079
+ kind: "Async"
1080
+ }
1081
+ })
1082
+ )
1083
+ );
1084
+
1037
1085
  // src/instrumentation/plugins/google-genai-channels.ts
1038
1086
  var googleGenAIChannels = defineChannels("@google/genai", {
1039
1087
  generateContent: channel({
@@ -2722,6 +2770,50 @@ var gitHubCopilotConfigs = [
2722
2770
  }
2723
2771
  }
2724
2772
  ];
2773
+
2774
+ // src/instrumentation/plugins/langchain-channels.ts
2775
+ var langChainChannels = defineChannels("@langchain/core", {
2776
+ configure: channel({
2777
+ channelName: "CallbackManager.configure",
2778
+ kind: "sync-stream"
2779
+ }),
2780
+ configureSync: channel({
2781
+ channelName: "CallbackManager._configureSync",
2782
+ kind: "sync-stream"
2783
+ })
2784
+ });
2785
+
2786
+ // src/auto-instrumentations/configs/langchain.ts
2787
+ var langChainCoreVersionRange = ">=0.3.42";
2788
+ var langChainCallbackManagerFilePath = "dist/callbacks/manager.js";
2789
+ var langchainConfigs = [
2790
+ {
2791
+ channelName: langChainChannels.configure.channelName,
2792
+ module: {
2793
+ name: "@langchain/core",
2794
+ versionRange: langChainCoreVersionRange,
2795
+ filePath: langChainCallbackManagerFilePath
2796
+ },
2797
+ functionQuery: {
2798
+ className: "CallbackManager",
2799
+ methodName: "configure",
2800
+ kind: "Sync"
2801
+ }
2802
+ },
2803
+ {
2804
+ channelName: langChainChannels.configureSync.channelName,
2805
+ module: {
2806
+ name: "@langchain/core",
2807
+ versionRange: langChainCoreVersionRange,
2808
+ filePath: langChainCallbackManagerFilePath
2809
+ },
2810
+ functionQuery: {
2811
+ className: "CallbackManager",
2812
+ methodName: "_configureSync",
2813
+ kind: "Sync"
2814
+ }
2815
+ }
2816
+ ];
2725
2817
  // Annotate the CommonJS export names for ESM import in node:
2726
2818
  0 && (module.exports = {
2727
2819
  aiSDKConfigs,
@@ -2735,7 +2827,9 @@ var gitHubCopilotConfigs = [
2735
2827
  googleGenAIConfigs,
2736
2828
  groqConfigs,
2737
2829
  huggingFaceConfigs,
2830
+ langchainConfigs,
2738
2831
  mistralConfigs,
2832
+ openAIAgentsCoreConfigs,
2739
2833
  openAICodexConfigs,
2740
2834
  openRouterAgentConfigs,
2741
2835
  openRouterConfigs,
@@ -57,6 +57,8 @@ declare const claudeAgentSDKConfigs: InstrumentationConfig[];
57
57
 
58
58
  declare const cursorSDKConfigs: InstrumentationConfig[];
59
59
 
60
+ declare const openAIAgentsCoreConfigs: InstrumentationConfig[];
61
+
60
62
  /**
61
63
  * Instrumentation configurations for the Google GenAI SDK.
62
64
  *
@@ -106,4 +108,6 @@ declare const genkitConfigs: InstrumentationConfig[];
106
108
 
107
109
  declare const gitHubCopilotConfigs: InstrumentationConfig[];
108
110
 
109
- export { aiSDKConfigs, anthropicConfigs, claudeAgentSDKConfigs, cohereConfigs, cursorSDKConfigs, genkitConfigs, gitHubCopilotConfigs, googleADKConfigs, googleGenAIConfigs, groqConfigs, huggingFaceConfigs, mistralConfigs, openAICodexConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs };
111
+ declare const langchainConfigs: InstrumentationConfig[];
112
+
113
+ export { aiSDKConfigs, anthropicConfigs, claudeAgentSDKConfigs, cohereConfigs, cursorSDKConfigs, genkitConfigs, gitHubCopilotConfigs, googleADKConfigs, googleGenAIConfigs, groqConfigs, huggingFaceConfigs, langchainConfigs, mistralConfigs, openAIAgentsCoreConfigs, openAICodexConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs };
@@ -57,6 +57,8 @@ declare const claudeAgentSDKConfigs: InstrumentationConfig[];
57
57
 
58
58
  declare const cursorSDKConfigs: InstrumentationConfig[];
59
59
 
60
+ declare const openAIAgentsCoreConfigs: InstrumentationConfig[];
61
+
60
62
  /**
61
63
  * Instrumentation configurations for the Google GenAI SDK.
62
64
  *
@@ -106,4 +108,6 @@ declare const genkitConfigs: InstrumentationConfig[];
106
108
 
107
109
  declare const gitHubCopilotConfigs: InstrumentationConfig[];
108
110
 
109
- export { aiSDKConfigs, anthropicConfigs, claudeAgentSDKConfigs, cohereConfigs, cursorSDKConfigs, genkitConfigs, gitHubCopilotConfigs, googleADKConfigs, googleGenAIConfigs, groqConfigs, huggingFaceConfigs, mistralConfigs, openAICodexConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs };
111
+ declare const langchainConfigs: InstrumentationConfig[];
112
+
113
+ export { aiSDKConfigs, anthropicConfigs, claudeAgentSDKConfigs, cohereConfigs, cursorSDKConfigs, genkitConfigs, gitHubCopilotConfigs, googleADKConfigs, googleGenAIConfigs, groqConfigs, huggingFaceConfigs, langchainConfigs, mistralConfigs, openAIAgentsCoreConfigs, openAICodexConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs };
@@ -1,266 +1,23 @@
1
1
  import {
2
2
  aiSDKConfigs,
3
3
  anthropicConfigs,
4
- channel,
5
4
  claudeAgentSDKConfigs,
6
5
  cohereConfigs,
7
6
  cursorSDKConfigs,
8
- defineChannels,
9
7
  genkitConfigs,
10
8
  gitHubCopilotConfigs,
9
+ googleADKConfigs,
11
10
  googleGenAIConfigs,
12
11
  groqConfigs,
13
12
  huggingFaceConfigs,
13
+ langchainConfigs,
14
14
  mistralConfigs,
15
+ openAIAgentsCoreConfigs,
15
16
  openAICodexConfigs,
16
17
  openRouterAgentConfigs,
17
18
  openRouterConfigs,
18
19
  openaiConfigs
19
- } from "./chunk-DIV5TO4S.mjs";
20
-
21
- // src/instrumentation/plugins/google-adk-channels.ts
22
- var googleADKChannels = defineChannels("@google/adk", {
23
- runnerRunAsync: channel({
24
- channelName: "runner.runAsync",
25
- kind: "sync-stream"
26
- }),
27
- agentRunAsync: channel({
28
- channelName: "agent.runAsync",
29
- kind: "sync-stream"
30
- }),
31
- toolRunAsync: channel({
32
- channelName: "tool.runAsync",
33
- kind: "async"
34
- })
35
- });
36
-
37
- // src/auto-instrumentations/configs/google-adk.ts
38
- var googleADKVersionRange = ">=0.1.0";
39
- var googleADKBundledIndexV06VersionRange = ">=0.6.1 <0.7.0";
40
- var googleADKBundledIndexV1VersionRange = ">=1.0.0 <2.0.0";
41
- var googleADKConfigs = [
42
- // --- Runner.runAsync --- async generator, kind "Sync" + sync-stream channel
43
- // Runner.runAsync — ESM individual module file
44
- {
45
- channelName: googleADKChannels.runnerRunAsync.channelName,
46
- module: {
47
- name: "@google/adk",
48
- versionRange: googleADKVersionRange,
49
- filePath: "dist/esm/runner/runner.js"
50
- },
51
- functionQuery: {
52
- className: "Runner",
53
- methodName: "runAsync",
54
- kind: "Sync"
55
- }
56
- },
57
- // Runner.runAsync — bundled CJS/ESM indexes
58
- // The bundled entrypoints minify class names, so target the 12th sync
59
- // `runAsync` method in file order rather than a class name. This mapping is
60
- // only validated against the current 0.6.x bundle layout, so keep the range
61
- // tight until we verify newer bundled outputs.
62
- {
63
- channelName: googleADKChannels.runnerRunAsync.channelName,
64
- module: {
65
- name: "@google/adk",
66
- versionRange: googleADKBundledIndexV06VersionRange,
67
- filePath: "dist/cjs/index.js"
68
- },
69
- functionQuery: {
70
- methodName: "runAsync",
71
- kind: "Sync",
72
- index: 11
73
- }
74
- },
75
- {
76
- channelName: googleADKChannels.runnerRunAsync.channelName,
77
- module: {
78
- name: "@google/adk",
79
- versionRange: googleADKBundledIndexV06VersionRange,
80
- filePath: "dist/esm/index.js"
81
- },
82
- functionQuery: {
83
- methodName: "runAsync",
84
- kind: "Sync",
85
- index: 11
86
- }
87
- },
88
- // The 1.x bundled entrypoints still inline the runtime into index.js, but
89
- // the minified method order changed. These indices are verified against 1.0.0.
90
- {
91
- channelName: googleADKChannels.runnerRunAsync.channelName,
92
- module: {
93
- name: "@google/adk",
94
- versionRange: googleADKBundledIndexV1VersionRange,
95
- filePath: "dist/cjs/index.js"
96
- },
97
- functionQuery: {
98
- methodName: "runAsync",
99
- kind: "Sync",
100
- index: 12
101
- }
102
- },
103
- {
104
- channelName: googleADKChannels.runnerRunAsync.channelName,
105
- module: {
106
- name: "@google/adk",
107
- versionRange: googleADKBundledIndexV1VersionRange,
108
- filePath: "dist/esm/index.js"
109
- },
110
- functionQuery: {
111
- methodName: "runAsync",
112
- kind: "Sync",
113
- index: 12
114
- }
115
- },
116
- // --- BaseAgent.runAsync --- async generator, kind "Sync" + sync-stream channel
117
- // BaseAgent.runAsync — ESM individual module file
118
- {
119
- channelName: googleADKChannels.agentRunAsync.channelName,
120
- module: {
121
- name: "@google/adk",
122
- versionRange: googleADKVersionRange,
123
- filePath: "dist/esm/agents/base_agent.js"
124
- },
125
- functionQuery: {
126
- className: "BaseAgent",
127
- methodName: "runAsync",
128
- kind: "Sync"
129
- }
130
- },
131
- // BaseAgent.runAsync — bundled CJS/ESM indexes
132
- // The bundled entrypoints minify class names, so target the first sync
133
- // `runAsync` method in file order rather than a class name. This mapping is
134
- // only validated against the current 0.6.x bundle layout, so keep the range
135
- // tight until we verify newer bundled outputs.
136
- {
137
- channelName: googleADKChannels.agentRunAsync.channelName,
138
- module: {
139
- name: "@google/adk",
140
- versionRange: googleADKBundledIndexV06VersionRange,
141
- filePath: "dist/cjs/index.js"
142
- },
143
- functionQuery: {
144
- methodName: "runAsync",
145
- kind: "Sync",
146
- index: 0
147
- }
148
- },
149
- {
150
- channelName: googleADKChannels.agentRunAsync.channelName,
151
- module: {
152
- name: "@google/adk",
153
- versionRange: googleADKBundledIndexV06VersionRange,
154
- filePath: "dist/esm/index.js"
155
- },
156
- functionQuery: {
157
- methodName: "runAsync",
158
- kind: "Sync",
159
- index: 0
160
- }
161
- },
162
- // The 1.x bundled entrypoints keep BaseAgent.runAsync as the first bundled
163
- // async-generator runAsync method in file order.
164
- {
165
- channelName: googleADKChannels.agentRunAsync.channelName,
166
- module: {
167
- name: "@google/adk",
168
- versionRange: googleADKBundledIndexV1VersionRange,
169
- filePath: "dist/cjs/index.js"
170
- },
171
- functionQuery: {
172
- methodName: "runAsync",
173
- kind: "Sync",
174
- index: 0
175
- }
176
- },
177
- {
178
- channelName: googleADKChannels.agentRunAsync.channelName,
179
- module: {
180
- name: "@google/adk",
181
- versionRange: googleADKBundledIndexV1VersionRange,
182
- filePath: "dist/esm/index.js"
183
- },
184
- functionQuery: {
185
- methodName: "runAsync",
186
- kind: "Sync",
187
- index: 0
188
- }
189
- },
190
- // --- FunctionTool.runAsync --- regular async, kind "Async"
191
- // FunctionTool.runAsync — ESM individual module file
192
- {
193
- channelName: googleADKChannels.toolRunAsync.channelName,
194
- module: {
195
- name: "@google/adk",
196
- versionRange: googleADKVersionRange,
197
- filePath: "dist/esm/tools/function_tool.js"
198
- },
199
- functionQuery: {
200
- className: "FunctionTool",
201
- methodName: "runAsync",
202
- kind: "Async"
203
- }
204
- },
205
- // FunctionTool.runAsync — bundled CJS/ESM indexes
206
- // The bundled entrypoints minify class names, so target the first async
207
- // `runAsync` method in file order rather than a class name. This mapping is
208
- // only validated against the current 0.6.x bundle layout, so keep the range
209
- // tight until we verify newer bundled outputs.
210
- {
211
- channelName: googleADKChannels.toolRunAsync.channelName,
212
- module: {
213
- name: "@google/adk",
214
- versionRange: googleADKBundledIndexV06VersionRange,
215
- filePath: "dist/cjs/index.js"
216
- },
217
- functionQuery: {
218
- methodName: "runAsync",
219
- kind: "Async",
220
- index: 1
221
- }
222
- },
223
- {
224
- channelName: googleADKChannels.toolRunAsync.channelName,
225
- module: {
226
- name: "@google/adk",
227
- versionRange: googleADKBundledIndexV06VersionRange,
228
- filePath: "dist/esm/index.js"
229
- },
230
- functionQuery: {
231
- methodName: "runAsync",
232
- kind: "Async",
233
- index: 1
234
- }
235
- },
236
- // The 1.x bundle moves FunctionTool.runAsync behind one helper method.
237
- {
238
- channelName: googleADKChannels.toolRunAsync.channelName,
239
- module: {
240
- name: "@google/adk",
241
- versionRange: googleADKBundledIndexV1VersionRange,
242
- filePath: "dist/cjs/index.js"
243
- },
244
- functionQuery: {
245
- methodName: "runAsync",
246
- kind: "Async",
247
- index: 1
248
- }
249
- },
250
- {
251
- channelName: googleADKChannels.toolRunAsync.channelName,
252
- module: {
253
- name: "@google/adk",
254
- versionRange: googleADKBundledIndexV1VersionRange,
255
- filePath: "dist/esm/index.js"
256
- },
257
- functionQuery: {
258
- methodName: "runAsync",
259
- kind: "Async",
260
- index: 1
261
- }
262
- }
263
- ];
20
+ } from "./chunk-E5DUYJWK.mjs";
264
21
  export {
265
22
  aiSDKConfigs,
266
23
  anthropicConfigs,
@@ -273,7 +30,9 @@ export {
273
30
  googleGenAIConfigs,
274
31
  groqConfigs,
275
32
  huggingFaceConfigs,
33
+ langchainConfigs,
276
34
  mistralConfigs,
35
+ openAIAgentsCoreConfigs,
277
36
  openAICodexConfigs,
278
37
  openRouterAgentConfigs,
279
38
  openRouterConfigs,
@@ -7,7 +7,7 @@ import {
7
7
  // src/auto-instrumentations/loader/esm-hook.mts
8
8
  import { readFile } from "fs/promises";
9
9
  import { fileURLToPath } from "url";
10
- import { sep } from "path";
10
+ import { extname, sep } from "path";
11
11
  import {
12
12
  create
13
13
  } from "@apm-js-collab/code-transformer";
@@ -15,6 +15,23 @@ import moduleDetailsFromPath from "module-details-from-path";
15
15
  var instrumentator;
16
16
  var packages;
17
17
  var transformers = /* @__PURE__ */ new Map();
18
+ function getModuleType(url, format) {
19
+ if (format === "module") {
20
+ return "esm";
21
+ }
22
+ if (format === "commonjs") {
23
+ return "cjs";
24
+ }
25
+ const pathname = url.startsWith("file:") ? fileURLToPath(url) : url;
26
+ const ext = extname(pathname);
27
+ if (ext === ".mjs") {
28
+ return "esm";
29
+ }
30
+ if (ext === ".cjs") {
31
+ return "cjs";
32
+ }
33
+ return "unknown";
34
+ }
18
35
  async function initialize(data = {}) {
19
36
  const configs = data.instrumentations || [];
20
37
  instrumentator = create(configs);
@@ -70,7 +87,7 @@ async function load(url, context, nextLoad) {
70
87
  if (code) {
71
88
  const transformer = transformers.get(url);
72
89
  try {
73
- const moduleType = result.format === "module" ? "esm" : result.format === "commonjs" ? "cjs" : "unknown";
90
+ const moduleType = getModuleType(url, result.format);
74
91
  const transformedCode = transformer.transform(
75
92
  code.toString("utf8"),
76
93
  moduleType
@@ -0,0 +1,44 @@
1
+ import { InstrumentationConfig } from '@apm-js-collab/code-transformer';
2
+
3
+ interface LegacyBundlerPluginOptions {
4
+ /**
5
+ * Enable debug logging
6
+ */
7
+ debug?: boolean;
8
+ /**
9
+ * Additional instrumentation configs to apply
10
+ */
11
+ instrumentations?: InstrumentationConfig[];
12
+ /**
13
+ * Whether to bundle for browser environments.
14
+ *
15
+ * When true, uses 'dc-browser' for browser-compatible diagnostics_channel polyfill.
16
+ * When false, uses Node.js built-in 'diagnostics_channel' and 'async_hooks'.
17
+ * Defaults to true (assumes browser build).
18
+ */
19
+ browser?: boolean;
20
+ }
21
+ interface BundlerPluginOptions {
22
+ /**
23
+ * Enable debug logging
24
+ */
25
+ debug?: boolean;
26
+ /**
27
+ * Additional instrumentation configs to apply
28
+ */
29
+ instrumentations?: InstrumentationConfig[];
30
+ /**
31
+ * Use the `diagnostics_channel` compatibility shim in patched code instead
32
+ * of Node.js's built-in `diagnostics_channel` module.
33
+ *
34
+ * Enable this for browser, edge, or worker bundles where Node's
35
+ * `diagnostics_channel` module is unavailable. Leave it disabled for Node.js
36
+ * bundles so transformed SDK code publishes on the native `diagnostics_channel`
37
+ * registry.
38
+ *
39
+ * @default false
40
+ */
41
+ useDiagnosticChannelCompatShim?: boolean;
42
+ }
43
+
44
+ export type { BundlerPluginOptions as B, LegacyBundlerPluginOptions as L };
@@ -0,0 +1,44 @@
1
+ import { InstrumentationConfig } from '@apm-js-collab/code-transformer';
2
+
3
+ interface LegacyBundlerPluginOptions {
4
+ /**
5
+ * Enable debug logging
6
+ */
7
+ debug?: boolean;
8
+ /**
9
+ * Additional instrumentation configs to apply
10
+ */
11
+ instrumentations?: InstrumentationConfig[];
12
+ /**
13
+ * Whether to bundle for browser environments.
14
+ *
15
+ * When true, uses 'dc-browser' for browser-compatible diagnostics_channel polyfill.
16
+ * When false, uses Node.js built-in 'diagnostics_channel' and 'async_hooks'.
17
+ * Defaults to true (assumes browser build).
18
+ */
19
+ browser?: boolean;
20
+ }
21
+ interface BundlerPluginOptions {
22
+ /**
23
+ * Enable debug logging
24
+ */
25
+ debug?: boolean;
26
+ /**
27
+ * Additional instrumentation configs to apply
28
+ */
29
+ instrumentations?: InstrumentationConfig[];
30
+ /**
31
+ * Use the `diagnostics_channel` compatibility shim in patched code instead
32
+ * of Node.js's built-in `diagnostics_channel` module.
33
+ *
34
+ * Enable this for browser, edge, or worker bundles where Node's
35
+ * `diagnostics_channel` module is unavailable. Leave it disabled for Node.js
36
+ * bundles so transformed SDK code publishes on the native `diagnostics_channel`
37
+ * registry.
38
+ *
39
+ * @default false
40
+ */
41
+ useDiagnosticChannelCompatShim?: boolean;
42
+ }
43
+
44
+ export type { BundlerPluginOptions as B, LegacyBundlerPluginOptions as L };