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.
- package/NOTICE +6 -0
- package/dev/dist/index.d.mts +130 -2
- package/dev/dist/index.d.ts +130 -2
- package/dev/dist/index.js +2455 -1116
- package/dev/dist/index.mjs +1599 -260
- package/dist/apply-auto-instrumentation.js +439 -398
- package/dist/apply-auto-instrumentation.mjs +242 -201
- package/dist/auto-instrumentations/bundler/esbuild.cjs +853 -337
- package/dist/auto-instrumentations/bundler/esbuild.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/esbuild.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/esbuild.mjs +5 -8
- package/dist/auto-instrumentations/bundler/next.cjs +852 -356
- package/dist/auto-instrumentations/bundler/next.mjs +6 -29
- package/dist/auto-instrumentations/bundler/rollup.cjs +853 -337
- package/dist/auto-instrumentations/bundler/rollup.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/rollup.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/rollup.mjs +5 -8
- package/dist/auto-instrumentations/bundler/vite.cjs +853 -337
- package/dist/auto-instrumentations/bundler/vite.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/vite.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/vite.mjs +5 -8
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1006 -266
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
- package/dist/auto-instrumentations/bundler/webpack.cjs +853 -337
- package/dist/auto-instrumentations/bundler/webpack.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/webpack.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/webpack.mjs +5 -4
- package/dist/auto-instrumentations/{chunk-JPVCUKTY.mjs → chunk-6E22MYSW.mjs} +165 -73
- package/dist/auto-instrumentations/{chunk-VT6DDNKM.mjs → chunk-AKKPLXTP.mjs} +631 -194
- package/dist/auto-instrumentations/chunk-NRE4QUQR.mjs +509 -0
- package/dist/auto-instrumentations/{chunk-7P6563SW.mjs → chunk-V5LEODRX.mjs} +2 -6
- package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-XYN63IG5.mjs} +124 -194
- package/dist/auto-instrumentations/{chunk-CZ24KNHT.mjs → chunk-XZHHE4Y3.mjs} +77 -68
- package/dist/auto-instrumentations/hook.mjs +247 -182
- package/dist/auto-instrumentations/index.cjs +557 -48
- package/dist/auto-instrumentations/index.d.mts +6 -2
- package/dist/auto-instrumentations/index.d.ts +6 -2
- package/dist/auto-instrumentations/index.mjs +6 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +492 -195
- package/dist/auto-instrumentations/loader/cjs-patch.d.mts +2 -2
- package/dist/auto-instrumentations/loader/cjs-patch.d.ts +2 -2
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -2
- package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
- package/dist/auto-instrumentations/plugin-B-aZh7EP.d.ts +30 -0
- package/dist/auto-instrumentations/plugin-Bnj4E_6B.d.mts +30 -0
- package/dist/auto-instrumentations/{types-RNPaKi9o.d.mts → types-C1fVeiCp.d.mts} +1 -1
- package/dist/auto-instrumentations/{types-RNPaKi9o.d.ts → types-C1fVeiCp.d.ts} +1 -1
- package/dist/browser.d.mts +817 -197
- package/dist/browser.d.ts +817 -197
- package/dist/browser.js +1883 -265
- package/dist/browser.mjs +1883 -265
- package/dist/{chunk-ABR2QWDP.mjs → chunk-PN7EWK66.mjs} +581 -133
- package/dist/{chunk-GSIDVFE6.js → chunk-VRZZQPAA.js} +1670 -736
- package/dist/{chunk-P25IOOU4.js → chunk-VYNNEKSA.js} +586 -138
- package/dist/{chunk-2SANLSWX.mjs → chunk-XIZOM2HO.mjs} +1052 -118
- package/dist/cli.js +1601 -263
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +1883 -268
- package/dist/edge-light.mjs +1883 -268
- package/dist/index.d.mts +817 -197
- package/dist/index.d.ts +817 -197
- package/dist/index.js +695 -435
- package/dist/index.mjs +264 -4
- package/dist/instrumentation/index.d.mts +130 -6
- package/dist/instrumentation/index.d.ts +130 -6
- package/dist/instrumentation/index.js +1510 -80
- package/dist/instrumentation/index.mjs +1510 -80
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +1883 -268
- package/dist/workerd.mjs +1883 -268
- package/licenses/node-diagnostics-channel/LICENSE +19 -0
- package/package.json +34 -35
- package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
- package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { WebpackPluginInstance } from 'unplugin';
|
|
2
|
-
import {
|
|
3
|
-
export { I as InstrumentationConfig } from '../types-
|
|
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 =
|
|
6
|
+
type WebpackPluginOptions = BundlerPluginOptions;
|
|
7
7
|
/**
|
|
8
8
|
* @deprecated Use {@link braintrustWebpackPlugin} instead.
|
|
9
9
|
*/
|
|
10
|
-
declare const webpackPlugin: (options:
|
|
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 {
|
|
3
|
-
export { I as InstrumentationConfig } from '../types-
|
|
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 =
|
|
6
|
+
type WebpackPluginOptions = BundlerPluginOptions;
|
|
7
7
|
/**
|
|
8
8
|
* @deprecated Use {@link braintrustWebpackPlugin} instead.
|
|
9
9
|
*/
|
|
10
|
-
declare const webpackPlugin: (options:
|
|
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-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
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-
|
|
28
|
+
} from "./chunk-XZHHE4Y3.mjs";
|
|
27
29
|
import {
|
|
28
30
|
applySpecialCasePatch,
|
|
29
31
|
create
|
|
30
|
-
} from "./chunk-
|
|
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
|
-
{
|
|
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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
-
|
|
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
|