braintrust 3.25.0 → 3.26.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 (78) hide show
  1. package/NOTICE +6 -0
  2. package/dev/dist/index.d.mts +130 -2
  3. package/dev/dist/index.d.ts +130 -2
  4. package/dev/dist/index.js +2455 -1116
  5. package/dev/dist/index.mjs +1599 -260
  6. package/dist/apply-auto-instrumentation.js +439 -398
  7. package/dist/apply-auto-instrumentation.mjs +242 -201
  8. package/dist/auto-instrumentations/bundler/esbuild.cjs +853 -337
  9. package/dist/auto-instrumentations/bundler/esbuild.d.mts +4 -4
  10. package/dist/auto-instrumentations/bundler/esbuild.d.ts +4 -4
  11. package/dist/auto-instrumentations/bundler/esbuild.mjs +5 -8
  12. package/dist/auto-instrumentations/bundler/next.cjs +852 -356
  13. package/dist/auto-instrumentations/bundler/next.mjs +6 -29
  14. package/dist/auto-instrumentations/bundler/rollup.cjs +853 -337
  15. package/dist/auto-instrumentations/bundler/rollup.d.mts +4 -4
  16. package/dist/auto-instrumentations/bundler/rollup.d.ts +4 -4
  17. package/dist/auto-instrumentations/bundler/rollup.mjs +5 -8
  18. package/dist/auto-instrumentations/bundler/vite.cjs +853 -337
  19. package/dist/auto-instrumentations/bundler/vite.d.mts +4 -4
  20. package/dist/auto-instrumentations/bundler/vite.d.ts +4 -4
  21. package/dist/auto-instrumentations/bundler/vite.mjs +5 -8
  22. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1006 -266
  23. package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
  24. package/dist/auto-instrumentations/bundler/webpack.cjs +853 -337
  25. package/dist/auto-instrumentations/bundler/webpack.d.mts +4 -4
  26. package/dist/auto-instrumentations/bundler/webpack.d.ts +4 -4
  27. package/dist/auto-instrumentations/bundler/webpack.mjs +5 -4
  28. package/dist/auto-instrumentations/{chunk-JPVCUKTY.mjs → chunk-6E22MYSW.mjs} +165 -73
  29. package/dist/auto-instrumentations/{chunk-VT6DDNKM.mjs → chunk-AKKPLXTP.mjs} +631 -194
  30. package/dist/auto-instrumentations/chunk-NRE4QUQR.mjs +509 -0
  31. package/dist/auto-instrumentations/{chunk-7P6563SW.mjs → chunk-V5LEODRX.mjs} +2 -6
  32. package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-XYN63IG5.mjs} +124 -194
  33. package/dist/auto-instrumentations/{chunk-CZ24KNHT.mjs → chunk-XZHHE4Y3.mjs} +77 -68
  34. package/dist/auto-instrumentations/hook.mjs +247 -182
  35. package/dist/auto-instrumentations/index.cjs +557 -48
  36. package/dist/auto-instrumentations/index.d.mts +6 -2
  37. package/dist/auto-instrumentations/index.d.ts +6 -2
  38. package/dist/auto-instrumentations/index.mjs +6 -1
  39. package/dist/auto-instrumentations/loader/cjs-patch.cjs +492 -195
  40. package/dist/auto-instrumentations/loader/cjs-patch.d.mts +2 -2
  41. package/dist/auto-instrumentations/loader/cjs-patch.d.ts +2 -2
  42. package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -2
  43. package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
  44. package/dist/auto-instrumentations/plugin-B-aZh7EP.d.ts +30 -0
  45. package/dist/auto-instrumentations/plugin-Bnj4E_6B.d.mts +30 -0
  46. package/dist/auto-instrumentations/{types-RNPaKi9o.d.mts → types-C1fVeiCp.d.mts} +1 -1
  47. package/dist/auto-instrumentations/{types-RNPaKi9o.d.ts → types-C1fVeiCp.d.ts} +1 -1
  48. package/dist/browser.d.mts +817 -197
  49. package/dist/browser.d.ts +817 -197
  50. package/dist/browser.js +1883 -265
  51. package/dist/browser.mjs +1883 -265
  52. package/dist/{chunk-ABR2QWDP.mjs → chunk-PN7EWK66.mjs} +581 -133
  53. package/dist/{chunk-GSIDVFE6.js → chunk-VRZZQPAA.js} +1670 -736
  54. package/dist/{chunk-P25IOOU4.js → chunk-VYNNEKSA.js} +586 -138
  55. package/dist/{chunk-2SANLSWX.mjs → chunk-XIZOM2HO.mjs} +1052 -118
  56. package/dist/cli.js +1601 -263
  57. package/dist/edge-light.d.mts +1 -1
  58. package/dist/edge-light.d.ts +1 -1
  59. package/dist/edge-light.js +1883 -268
  60. package/dist/edge-light.mjs +1883 -268
  61. package/dist/index.d.mts +817 -197
  62. package/dist/index.d.ts +817 -197
  63. package/dist/index.js +695 -435
  64. package/dist/index.mjs +264 -4
  65. package/dist/instrumentation/index.d.mts +130 -6
  66. package/dist/instrumentation/index.d.ts +130 -6
  67. package/dist/instrumentation/index.js +1510 -80
  68. package/dist/instrumentation/index.mjs +1510 -80
  69. package/dist/vitest-evals-reporter.js +16 -16
  70. package/dist/vitest-evals-reporter.mjs +2 -2
  71. package/dist/workerd.d.mts +1 -1
  72. package/dist/workerd.d.ts +1 -1
  73. package/dist/workerd.js +1883 -268
  74. package/dist/workerd.mjs +1883 -268
  75. package/licenses/node-diagnostics-channel/LICENSE +19 -0
  76. package/package.json +34 -35
  77. package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
  78. package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
@@ -1,12 +1,12 @@
1
1
  import { WebpackPluginInstance } from 'unplugin';
2
- import { L as LegacyBundlerPluginOptions, B as BundlerPluginOptions } from '../plugin-D0KHwSJv.mjs';
3
- export { I as InstrumentationConfig } from '../types-RNPaKi9o.mjs';
2
+ import { B as BundlerPluginOptions } from '../plugin-Bnj4E_6B.mjs';
3
+ export { I as InstrumentationConfig } from '../types-C1fVeiCp.mjs';
4
4
 
5
5
  declare function braintrustWebpackPlugin(options?: BundlerPluginOptions): WebpackPluginInstance;
6
- type WebpackPluginOptions = LegacyBundlerPluginOptions;
6
+ type WebpackPluginOptions = BundlerPluginOptions;
7
7
  /**
8
8
  * @deprecated Use {@link braintrustWebpackPlugin} instead.
9
9
  */
10
- declare const webpackPlugin: (options: LegacyBundlerPluginOptions) => WebpackPluginInstance;
10
+ declare const webpackPlugin: (options: BundlerPluginOptions) => WebpackPluginInstance;
11
11
 
12
12
  export { type WebpackPluginOptions, braintrustWebpackPlugin, webpackPlugin };
@@ -1,12 +1,12 @@
1
1
  import { WebpackPluginInstance } from 'unplugin';
2
- import { L as LegacyBundlerPluginOptions, B as BundlerPluginOptions } from '../plugin-G6fgxk1b.js';
3
- export { I as InstrumentationConfig } from '../types-RNPaKi9o.js';
2
+ import { B as BundlerPluginOptions } from '../plugin-B-aZh7EP.js';
3
+ export { I as InstrumentationConfig } from '../types-C1fVeiCp.js';
4
4
 
5
5
  declare function braintrustWebpackPlugin(options?: BundlerPluginOptions): WebpackPluginInstance;
6
- type WebpackPluginOptions = LegacyBundlerPluginOptions;
6
+ type WebpackPluginOptions = BundlerPluginOptions;
7
7
  /**
8
8
  * @deprecated Use {@link braintrustWebpackPlugin} instead.
9
9
  */
10
- declare const webpackPlugin: (options: LegacyBundlerPluginOptions) => WebpackPluginInstance;
10
+ declare const webpackPlugin: (options: BundlerPluginOptions) => WebpackPluginInstance;
11
11
 
12
12
  export { type WebpackPluginOptions, braintrustWebpackPlugin, webpackPlugin };
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  braintrustWebpackPlugin,
3
3
  webpackPlugin
4
- } from "../chunk-7P6563SW.mjs";
5
- import "../chunk-JPVCUKTY.mjs";
6
- import "../chunk-CZ24KNHT.mjs";
7
- import "../chunk-M6DLIJ2Z.mjs";
4
+ } from "../chunk-V5LEODRX.mjs";
5
+ import "../chunk-6E22MYSW.mjs";
6
+ import "../chunk-XZHHE4Y3.mjs";
7
+ import "../chunk-XYN63IG5.mjs";
8
+ import "../chunk-NRE4QUQR.mjs";
8
9
  export {
9
10
  braintrustWebpackPlugin,
10
11
  webpackPlugin
@@ -5,6 +5,8 @@ import {
5
5
  bedrockRuntimeConfigs,
6
6
  channel,
7
7
  claudeAgentSDKConfigs,
8
+ cloudflareAIChatConfigs,
9
+ cloudflareAgentsConfigs,
8
10
  cohereConfigs,
9
11
  cursorSDKConfigs,
10
12
  defineChannels,
@@ -23,11 +25,11 @@ import {
23
25
  openRouterConfigs,
24
26
  openaiConfigs,
25
27
  piCodingAgentConfigs
26
- } from "./chunk-CZ24KNHT.mjs";
28
+ } from "./chunk-XZHHE4Y3.mjs";
27
29
  import {
28
30
  applySpecialCasePatch,
29
31
  create
30
- } from "./chunk-M6DLIJ2Z.mjs";
32
+ } from "./chunk-XYN63IG5.mjs";
31
33
 
32
34
  // src/auto-instrumentations/bundler/plugin.ts
33
35
  import { createUnplugin } from "unplugin";
@@ -53,6 +55,9 @@ var envIntegrationAliases = {
53
55
  strandsagentsdk: "strandsAgentSDK",
54
56
  "strands-agent-sdk": "strandsAgentSDK",
55
57
  "@strands-agents/sdk": "strandsAgentSDK",
58
+ agents: "cloudflareAgents",
59
+ "cloudflare-agents": "cloudflareAgents",
60
+ cloudflareagents: "cloudflareAgents",
56
61
  anthropic: "anthropic",
57
62
  aisdk: "aisdk",
58
63
  "ai-sdk": "aisdk",
@@ -60,6 +65,9 @@ var envIntegrationAliases = {
60
65
  vercel: "vercel",
61
66
  claudeagentsdk: "claudeAgentSDK",
62
67
  "claude-agent-sdk": "claudeAgentSDK",
68
+ cloudflareaichat: "cloudflareAIChat",
69
+ "cloudflare-ai-chat": "cloudflareAIChat",
70
+ "@cloudflare/ai-chat": "cloudflareAIChat",
63
71
  cursor: "cursor",
64
72
  "cursor-sdk": "cursorSDK",
65
73
  cursorsdk: "cursorSDK",
@@ -74,6 +82,8 @@ var envIntegrationAliases = {
74
82
  "google-genai": "googleGenAI",
75
83
  googlegenai: "googleGenAI",
76
84
  huggingface: "huggingface",
85
+ "@huggingface/transformers": "huggingface",
86
+ transformers: "huggingface",
77
87
  openrouter: "openrouter",
78
88
  openrouteragent: "openrouterAgent",
79
89
  "openrouter-agent": "openrouterAgent",
@@ -146,6 +156,83 @@ var flueConfigs = [
146
156
  }
147
157
  ];
148
158
 
159
+ // src/instrumentation/plugins/huggingface-transformers-channels.ts
160
+ var huggingFaceTransformersChannels = defineChannels(
161
+ "@huggingface/transformers",
162
+ {
163
+ pipeline: channel({
164
+ channelName: "pipeline",
165
+ kind: "async"
166
+ }),
167
+ pipelineCall: channel({
168
+ channelName: "pipeline.call",
169
+ kind: "async"
170
+ })
171
+ },
172
+ { instrumentationName: INSTRUMENTATION_NAMES.HUGGINGFACE }
173
+ );
174
+
175
+ // src/auto-instrumentations/configs/huggingface-transformers.ts
176
+ var moduleFiles = [
177
+ {
178
+ filePath: "dist/transformers.mjs",
179
+ versionRange: ">=3.0.0 <3.4.0"
180
+ },
181
+ {
182
+ filePath: "dist/transformers.cjs",
183
+ versionRange: ">=3.0.0 <3.4.0"
184
+ },
185
+ {
186
+ filePath: "dist/transformers.js",
187
+ versionRange: ">=3.0.0 <3.4.0"
188
+ },
189
+ {
190
+ filePath: "dist/transformers.node.mjs",
191
+ versionRange: ">=3.4.0 <5.0.0"
192
+ },
193
+ {
194
+ filePath: "dist/transformers.node.cjs",
195
+ versionRange: ">=3.4.0 <5.0.0"
196
+ },
197
+ {
198
+ filePath: "dist/transformers.web.js",
199
+ versionRange: ">=3.4.0 <5.0.0"
200
+ }
201
+ ];
202
+ var pipelineClasses = [
203
+ "TextGenerationPipeline",
204
+ "Text2TextGenerationPipeline",
205
+ "FeatureExtractionPipeline",
206
+ "QuestionAnsweringPipeline"
207
+ ];
208
+ var huggingFaceTransformersConfigs = moduleFiles.flatMap(({ filePath, versionRange }) => [
209
+ {
210
+ channelName: huggingFaceTransformersChannels.pipeline.channelName,
211
+ module: {
212
+ name: "@huggingface/transformers",
213
+ versionRange,
214
+ filePath
215
+ },
216
+ functionQuery: {
217
+ functionName: "pipeline",
218
+ kind: "Async"
219
+ }
220
+ },
221
+ ...pipelineClasses.map((className) => ({
222
+ channelName: huggingFaceTransformersChannels.pipelineCall.channelName,
223
+ module: {
224
+ name: "@huggingface/transformers",
225
+ versionRange,
226
+ filePath
227
+ },
228
+ functionQuery: {
229
+ className,
230
+ methodName: "_call",
231
+ kind: "Async"
232
+ }
233
+ }))
234
+ ]);
235
+
149
236
  // src/instrumentation/plugins/strands-agent-sdk-channels.ts
150
237
  var strandsAgentSDKChannels = defineChannels(
151
238
  "@strands-agents/sdk",
@@ -230,6 +317,14 @@ var defaultInstrumentationConfigGroups = [
230
317
  integrations: ["claudeAgentSDK"],
231
318
  configs: claudeAgentSDKConfigs
232
319
  },
320
+ {
321
+ integrations: ["cloudflareAIChat"],
322
+ configs: cloudflareAIChatConfigs
323
+ },
324
+ {
325
+ integrations: ["cloudflareAgents"],
326
+ configs: cloudflareAgentsConfigs
327
+ },
233
328
  { integrations: ["cursor", "cursorSDK"], configs: cursorSDKConfigs },
234
329
  {
235
330
  integrations: ["openAIAgents"],
@@ -239,7 +334,10 @@ var defaultInstrumentationConfigGroups = [
239
334
  integrations: ["google", "googleGenAI"],
240
335
  configs: googleGenAIConfigs
241
336
  },
242
- { integrations: ["huggingface"], configs: huggingFaceConfigs },
337
+ {
338
+ integrations: ["huggingface"],
339
+ configs: [...huggingFaceConfigs, ...huggingFaceTransformersConfigs]
340
+ },
243
341
  {
244
342
  integrations: ["langchain", "langgraph"],
245
343
  configs: langchainConfigs
@@ -310,78 +408,72 @@ function getModuleVersion(basedir) {
310
408
  }
311
409
  return void 0;
312
410
  }
313
- var unplugin = createUnplugin(
314
- (options = {}) => {
315
- const allInstrumentations = getDefaultInstrumentationConfigs({
316
- additionalInstrumentations: options.instrumentations
317
- });
318
- const dcModule = options.browser === false ? void 0 : "dc-browser";
319
- const instrumentationMatcher = create(allInstrumentations, dcModule);
320
- return {
321
- name: "code-transformer",
322
- enforce: "pre",
323
- transform(code, id) {
324
- if (!id) {
325
- return null;
326
- }
327
- const filePath = id.startsWith("file:") ? fileURLToPath(id) : id;
328
- const ext = extname(filePath);
329
- let isModule = ext === ".mjs" || ext === ".ts" || ext === ".tsx";
330
- if (ext === ".js") {
331
- isModule = code.includes("export ") || code.includes("import ");
332
- }
333
- const normalizedForPlatform = filePath.split("/").join(sep);
334
- const moduleDetails = moduleDetailsFromPath(normalizedForPlatform);
335
- if (!moduleDetails) {
336
- return null;
337
- }
338
- const moduleName = moduleDetails.name;
339
- const normalizedModulePath = moduleDetails.path.replace(/\\/g, "/");
340
- const moduleVersion = getModuleVersion(moduleDetails.basedir);
341
- if (options.browser !== true) {
342
- const patched = applySpecialCasePatch({
343
- packageName: moduleName,
344
- modulePath: normalizedModulePath,
345
- source: code,
346
- format: isModule ? "esm" : "cjs"
347
- });
348
- if (patched !== null) {
349
- return { code: patched, map: null };
350
- }
351
- }
352
- if (!moduleVersion) {
353
- console.warn(
354
- `No 'package.json' version found for module ${moduleName} at ${moduleDetails.basedir}. Skipping transformation.`
355
- );
356
- return null;
357
- }
358
- const transformer = instrumentationMatcher.getTransformer(
359
- moduleName,
360
- moduleVersion,
361
- normalizedModulePath
411
+ var unplugin = createUnplugin((options = {}) => {
412
+ const browser = options.browser ?? options.useDiagnosticChannelCompatShim ?? false;
413
+ const allInstrumentations = getDefaultInstrumentationConfigs({
414
+ additionalInstrumentations: options.instrumentations
415
+ });
416
+ const instrumentationMatcher = create(allInstrumentations);
417
+ return {
418
+ name: "code-transformer",
419
+ enforce: "pre",
420
+ transform(code, id) {
421
+ if (!id) {
422
+ return null;
423
+ }
424
+ const cleanId = id.replace(/[?#].*$/, "");
425
+ const filePath = cleanId.startsWith("file:") ? fileURLToPath(cleanId) : cleanId;
426
+ const ext = extname(filePath);
427
+ let isModule = ext === ".mjs" || ext === ".ts" || ext === ".tsx";
428
+ if (ext === ".js") {
429
+ isModule = code.includes("export ") || code.includes("import ");
430
+ }
431
+ const normalizedForPlatform = filePath.split("/").join(sep);
432
+ const moduleDetails = moduleDetailsFromPath(normalizedForPlatform);
433
+ if (!moduleDetails) {
434
+ return null;
435
+ }
436
+ const moduleName = moduleDetails.name;
437
+ const normalizedModulePath = moduleDetails.path.replace(/\\/g, "/");
438
+ const moduleVersion = getModuleVersion(moduleDetails.basedir);
439
+ const patched = applySpecialCasePatch({
440
+ packageName: moduleName,
441
+ modulePath: normalizedModulePath,
442
+ source: code,
443
+ format: isModule ? "esm" : "cjs",
444
+ browser
445
+ });
446
+ if (patched !== null) {
447
+ return { code: patched, map: null };
448
+ }
449
+ if (!moduleVersion) {
450
+ console.warn(
451
+ `No 'package.json' version found for module ${moduleName} at ${moduleDetails.basedir}. Skipping transformation.`
362
452
  );
363
- if (!transformer) {
364
- return null;
365
- }
366
- try {
367
- const moduleType = isModule ? "esm" : "cjs";
368
- const result = transformer.transform(code, moduleType);
369
- const transformedCode = result.code.replace(
370
- /const \{tracingChannel: ([A-Za-z_$][\w$]*)\} = ([A-Za-z_$][\w$]*);/g,
371
- "const $1 = $2.tracingChannel;"
372
- );
373
- return {
374
- code: transformedCode,
375
- map: result.map
376
- };
377
- } catch (error) {
378
- console.warn(`Code transformation failed for ${id}: ${error}`);
379
- return null;
380
- }
453
+ return null;
381
454
  }
382
- };
383
- }
384
- );
455
+ const transformer = instrumentationMatcher.getTransformer(
456
+ moduleName,
457
+ moduleVersion,
458
+ normalizedModulePath
459
+ );
460
+ if (!transformer) {
461
+ return null;
462
+ }
463
+ try {
464
+ const moduleType = isModule ? "esm" : "cjs";
465
+ const result = transformer.transform(code, moduleType);
466
+ return {
467
+ code: result.code,
468
+ map: result.map
469
+ };
470
+ } catch (error) {
471
+ console.warn(`Code transformation failed for ${id}: ${error}`);
472
+ return null;
473
+ }
474
+ }
475
+ };
476
+ });
385
477
 
386
478
  export {
387
479
  unplugin