braintrust 3.11.0 → 3.12.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 (75) hide show
  1. package/README.md +8 -8
  2. package/dev/dist/index.d.mts +1 -1
  3. package/dev/dist/index.d.ts +1 -1
  4. package/dev/dist/index.js +2607 -316
  5. package/dev/dist/index.mjs +2388 -97
  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 +1802 -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 +3268 -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 +1802 -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 +1802 -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 +1860 -1308
  31. package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +3 -3
  32. package/dist/auto-instrumentations/bundler/webpack.cjs +1802 -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-2DPA74KK.mjs} +337 -1
  37. package/dist/auto-instrumentations/chunk-73BZUKVI.mjs +300 -0
  38. package/dist/auto-instrumentations/chunk-AFXRW7I7.mjs +18 -0
  39. package/dist/auto-instrumentations/hook.mjs +1712 -1460
  40. package/dist/auto-instrumentations/index.cjs +93 -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 +120 -31
  48. package/dist/browser.d.ts +120 -31
  49. package/dist/browser.js +2395 -123
  50. package/dist/browser.mjs +2395 -123
  51. package/dist/chunk-BW4DF4CY.js +816 -0
  52. package/dist/chunk-MSLBGITU.mjs +816 -0
  53. package/dist/cli.js +2407 -96
  54. package/dist/edge-light.d.mts +1 -1
  55. package/dist/edge-light.d.ts +1 -1
  56. package/dist/edge-light.js +2395 -123
  57. package/dist/edge-light.mjs +2395 -123
  58. package/dist/index.d.mts +120 -31
  59. package/dist/index.d.ts +120 -31
  60. package/dist/index.js +3362 -1849
  61. package/dist/index.mjs +2505 -992
  62. package/dist/instrumentation/index.d.mts +7860 -48
  63. package/dist/instrumentation/index.d.ts +7860 -48
  64. package/dist/instrumentation/index.js +2395 -95
  65. package/dist/instrumentation/index.mjs +2394 -95
  66. package/dist/workerd.d.mts +1 -1
  67. package/dist/workerd.d.ts +1 -1
  68. package/dist/workerd.js +2395 -123
  69. package/dist/workerd.mjs +2395 -123
  70. package/package.json +23 -3
  71. package/util/dist/index.js +6 -0
  72. package/util/dist/index.mjs +6 -0
  73. package/dist/auto-instrumentations/chunk-G6ZWXGZB.mjs +0 -116
  74. package/dist/auto-instrumentations/plugin-Df3qKIl2.d.mts +0 -22
  75. 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,
@@ -1034,6 +1036,51 @@ var cursorSDKConfigs = cursorSDKEntrypoints.flatMap((filePath) => [
1034
1036
  }
1035
1037
  ]);
1036
1038
 
1039
+ // src/instrumentation/plugins/openai-agents-channels.ts
1040
+ var openAIAgentsCoreChannels = defineChannels("@openai/agents-core", {
1041
+ onTraceStart: channel({
1042
+ channelName: "tracing.processor.onTraceStart",
1043
+ kind: "async"
1044
+ }),
1045
+ onTraceEnd: channel({
1046
+ channelName: "tracing.processor.onTraceEnd",
1047
+ kind: "async"
1048
+ }),
1049
+ onSpanStart: channel({
1050
+ channelName: "tracing.processor.onSpanStart",
1051
+ kind: "async"
1052
+ }),
1053
+ onSpanEnd: channel({
1054
+ channelName: "tracing.processor.onSpanEnd",
1055
+ kind: "async"
1056
+ })
1057
+ });
1058
+
1059
+ // src/auto-instrumentations/configs/openai-agents.ts
1060
+ var lifecycleMethods = [
1061
+ ["onTraceStart", openAIAgentsCoreChannels.onTraceStart.channelName],
1062
+ ["onTraceEnd", openAIAgentsCoreChannels.onTraceEnd.channelName],
1063
+ ["onSpanStart", openAIAgentsCoreChannels.onSpanStart.channelName],
1064
+ ["onSpanEnd", openAIAgentsCoreChannels.onSpanEnd.channelName]
1065
+ ];
1066
+ var openAIAgentsCoreConfigs = lifecycleMethods.flatMap(
1067
+ ([methodName, channelName]) => ["dist/tracing/processor.mjs", "dist/tracing/processor.js"].map(
1068
+ (filePath) => ({
1069
+ channelName,
1070
+ module: {
1071
+ name: "@openai/agents-core",
1072
+ versionRange: ">=0.0.14",
1073
+ filePath
1074
+ },
1075
+ functionQuery: {
1076
+ className: "MultiTracingProcessor",
1077
+ methodName,
1078
+ kind: "Async"
1079
+ }
1080
+ })
1081
+ )
1082
+ );
1083
+
1037
1084
  // src/instrumentation/plugins/google-genai-channels.ts
1038
1085
  var googleGenAIChannels = defineChannels("@google/genai", {
1039
1086
  generateContent: channel({
@@ -2722,6 +2769,50 @@ var gitHubCopilotConfigs = [
2722
2769
  }
2723
2770
  }
2724
2771
  ];
2772
+
2773
+ // src/instrumentation/plugins/langchain-channels.ts
2774
+ var langChainChannels = defineChannels("@langchain/core", {
2775
+ configure: channel({
2776
+ channelName: "CallbackManager.configure",
2777
+ kind: "sync-stream"
2778
+ }),
2779
+ configureSync: channel({
2780
+ channelName: "CallbackManager._configureSync",
2781
+ kind: "sync-stream"
2782
+ })
2783
+ });
2784
+
2785
+ // src/auto-instrumentations/configs/langchain.ts
2786
+ var langChainCoreVersionRange = ">=0.3.42";
2787
+ var langChainCallbackManagerFilePath = "dist/callbacks/manager.js";
2788
+ var langchainConfigs = [
2789
+ {
2790
+ channelName: langChainChannels.configure.channelName,
2791
+ module: {
2792
+ name: "@langchain/core",
2793
+ versionRange: langChainCoreVersionRange,
2794
+ filePath: langChainCallbackManagerFilePath
2795
+ },
2796
+ functionQuery: {
2797
+ className: "CallbackManager",
2798
+ methodName: "configure",
2799
+ kind: "Sync"
2800
+ }
2801
+ },
2802
+ {
2803
+ channelName: langChainChannels.configureSync.channelName,
2804
+ module: {
2805
+ name: "@langchain/core",
2806
+ versionRange: langChainCoreVersionRange,
2807
+ filePath: langChainCallbackManagerFilePath
2808
+ },
2809
+ functionQuery: {
2810
+ className: "CallbackManager",
2811
+ methodName: "_configureSync",
2812
+ kind: "Sync"
2813
+ }
2814
+ }
2815
+ ];
2725
2816
  // Annotate the CommonJS export names for ESM import in node:
2726
2817
  0 && (module.exports = {
2727
2818
  aiSDKConfigs,
@@ -2735,7 +2826,9 @@ var gitHubCopilotConfigs = [
2735
2826
  googleGenAIConfigs,
2736
2827
  groqConfigs,
2737
2828
  huggingFaceConfigs,
2829
+ langchainConfigs,
2738
2830
  mistralConfigs,
2831
+ openAIAgentsCoreConfigs,
2739
2832
  openAICodexConfigs,
2740
2833
  openRouterAgentConfigs,
2741
2834
  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-2DPA74KK.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 };