braintrust 3.25.0 → 3.27.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 +4133 -1421
- package/dev/dist/index.mjs +3242 -530
- package/dist/apply-auto-instrumentation.js +526 -426
- package/dist/apply-auto-instrumentation.mjs +329 -229
- package/dist/auto-instrumentations/bundler/esbuild.cjs +1198 -364
- 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 +6 -8
- package/dist/auto-instrumentations/bundler/next.cjs +1227 -413
- package/dist/auto-instrumentations/bundler/next.mjs +7 -29
- package/dist/auto-instrumentations/bundler/rollup.cjs +1198 -364
- 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 +6 -8
- package/dist/auto-instrumentations/bundler/vite.cjs +1249 -387
- 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 +34 -8
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1368 -324
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
- package/dist/auto-instrumentations/bundler/webpack.cjs +1198 -364
- 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 +6 -4
- package/dist/auto-instrumentations/chunk-2AMDGD65.mjs +1396 -0
- package/dist/auto-instrumentations/{chunk-7P6563SW.mjs → chunk-BW33ULMW.mjs} +2 -6
- package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-I55G56ZL.mjs} +114 -221
- package/dist/auto-instrumentations/chunk-JPUFNW7X.mjs +649 -0
- package/dist/auto-instrumentations/{chunk-JPVCUKTY.mjs → chunk-XEYKUBLY.mjs} +191 -73
- package/dist/auto-instrumentations/{chunk-CZ24KNHT.mjs → chunk-ZNHTSSGI.mjs} +231 -69
- package/dist/auto-instrumentations/hook.mjs +406 -183
- package/dist/auto-instrumentations/index.cjs +853 -49
- package/dist/auto-instrumentations/index.d.mts +10 -2
- package/dist/auto-instrumentations/index.d.ts +10 -2
- package/dist/auto-instrumentations/index.mjs +10 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +566 -221
- 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 +871 -199
- package/dist/browser.d.ts +871 -199
- package/dist/browser.js +3737 -549
- package/dist/browser.mjs +3737 -549
- package/dist/{chunk-ABR2QWDP.mjs → chunk-CZM5JIQL.mjs} +788 -132
- package/dist/{chunk-P25IOOU4.js → chunk-MF7NU6BT.js} +795 -139
- package/dist/{chunk-GSIDVFE6.js → chunk-QRHGVBKU.js} +3580 -1463
- package/dist/{chunk-2SANLSWX.mjs → chunk-YKD22IMR.mjs} +2505 -388
- package/dist/cli.js +3244 -533
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +3737 -552
- package/dist/edge-light.mjs +3737 -552
- package/dist/index.d.mts +871 -199
- package/dist/index.d.ts +871 -199
- package/dist/index.js +893 -446
- package/dist/index.mjs +463 -16
- package/dist/instrumentation/index.d.mts +138 -6
- package/dist/instrumentation/index.d.ts +138 -6
- package/dist/instrumentation/index.js +3362 -559
- package/dist/instrumentation/index.mjs +3362 -559
- package/dist/vitest-evals-reporter.js +45 -43
- package/dist/vitest-evals-reporter.mjs +5 -3
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +3737 -552
- package/dist/workerd.mjs +3737 -552
- package/licenses/node-diagnostics-channel/LICENSE +19 -0
- package/package.json +34 -35
- package/dist/auto-instrumentations/chunk-VT6DDNKM.mjs +0 -856
- package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
- package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
bedrockRuntimeConfigs,
|
|
6
6
|
channel,
|
|
7
7
|
claudeAgentSDKConfigs,
|
|
8
|
+
cloudflareAIChatConfigs,
|
|
9
|
+
cloudflareAgentsConfigs,
|
|
10
|
+
cloudflareThinkConfigs,
|
|
8
11
|
cohereConfigs,
|
|
9
12
|
cursorSDKConfigs,
|
|
10
13
|
defineChannels,
|
|
@@ -17,21 +20,25 @@ import {
|
|
|
17
20
|
langSmithConfigs,
|
|
18
21
|
langchainConfigs,
|
|
19
22
|
mistralConfigs,
|
|
23
|
+
ollamaConfigs,
|
|
20
24
|
openAIAgentsCoreConfigs,
|
|
21
25
|
openAICodexConfigs,
|
|
22
26
|
openRouterAgentConfigs,
|
|
23
27
|
openRouterConfigs,
|
|
24
28
|
openaiConfigs,
|
|
25
29
|
piCodingAgentConfigs
|
|
26
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-ZNHTSSGI.mjs";
|
|
27
31
|
import {
|
|
28
32
|
applySpecialCasePatch,
|
|
29
33
|
create
|
|
30
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-I55G56ZL.mjs";
|
|
35
|
+
import {
|
|
36
|
+
getPackageName
|
|
37
|
+
} from "./chunk-P5YLNB2A.mjs";
|
|
31
38
|
|
|
32
39
|
// src/auto-instrumentations/bundler/plugin.ts
|
|
33
40
|
import { createUnplugin } from "unplugin";
|
|
34
|
-
import { extname, join, sep } from "path";
|
|
41
|
+
import { extname, isAbsolute, join, sep } from "path";
|
|
35
42
|
import { readFileSync } from "fs";
|
|
36
43
|
import { fileURLToPath } from "url";
|
|
37
44
|
import moduleDetailsFromPath from "module-details-from-path";
|
|
@@ -53,6 +60,9 @@ var envIntegrationAliases = {
|
|
|
53
60
|
strandsagentsdk: "strandsAgentSDK",
|
|
54
61
|
"strands-agent-sdk": "strandsAgentSDK",
|
|
55
62
|
"@strands-agents/sdk": "strandsAgentSDK",
|
|
63
|
+
agents: "cloudflareAgents",
|
|
64
|
+
"cloudflare-agents": "cloudflareAgents",
|
|
65
|
+
cloudflareagents: "cloudflareAgents",
|
|
56
66
|
anthropic: "anthropic",
|
|
57
67
|
aisdk: "aisdk",
|
|
58
68
|
"ai-sdk": "aisdk",
|
|
@@ -60,6 +70,10 @@ var envIntegrationAliases = {
|
|
|
60
70
|
vercel: "vercel",
|
|
61
71
|
claudeagentsdk: "claudeAgentSDK",
|
|
62
72
|
"claude-agent-sdk": "claudeAgentSDK",
|
|
73
|
+
cloudflareaichat: "cloudflareAIChat",
|
|
74
|
+
"cloudflare-ai-chat": "cloudflareAIChat",
|
|
75
|
+
"@cloudflare/ai-chat": "cloudflareAIChat",
|
|
76
|
+
cloudflarethink: "cloudflareThink",
|
|
63
77
|
cursor: "cursor",
|
|
64
78
|
"cursor-sdk": "cursorSDK",
|
|
65
79
|
cursorsdk: "cursorSDK",
|
|
@@ -74,10 +88,13 @@ var envIntegrationAliases = {
|
|
|
74
88
|
"google-genai": "googleGenAI",
|
|
75
89
|
googlegenai: "googleGenAI",
|
|
76
90
|
huggingface: "huggingface",
|
|
91
|
+
"@huggingface/transformers": "huggingface",
|
|
92
|
+
transformers: "huggingface",
|
|
77
93
|
openrouter: "openrouter",
|
|
78
94
|
openrouteragent: "openrouterAgent",
|
|
79
95
|
"openrouter-agent": "openrouterAgent",
|
|
80
96
|
mistral: "mistral",
|
|
97
|
+
ollama: "ollama",
|
|
81
98
|
googleadk: "googleADK",
|
|
82
99
|
"google-adk": "googleADK",
|
|
83
100
|
cohere: "cohere",
|
|
@@ -146,6 +163,83 @@ var flueConfigs = [
|
|
|
146
163
|
}
|
|
147
164
|
];
|
|
148
165
|
|
|
166
|
+
// src/instrumentation/plugins/huggingface-transformers-channels.ts
|
|
167
|
+
var huggingFaceTransformersChannels = defineChannels(
|
|
168
|
+
"@huggingface/transformers",
|
|
169
|
+
{
|
|
170
|
+
pipeline: channel({
|
|
171
|
+
channelName: "pipeline",
|
|
172
|
+
kind: "async"
|
|
173
|
+
}),
|
|
174
|
+
pipelineCall: channel({
|
|
175
|
+
channelName: "pipeline.call",
|
|
176
|
+
kind: "async"
|
|
177
|
+
})
|
|
178
|
+
},
|
|
179
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.HUGGINGFACE }
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
// src/auto-instrumentations/configs/huggingface-transformers.ts
|
|
183
|
+
var moduleFiles = [
|
|
184
|
+
{
|
|
185
|
+
filePath: "dist/transformers.mjs",
|
|
186
|
+
versionRange: ">=3.0.0 <3.4.0"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
filePath: "dist/transformers.cjs",
|
|
190
|
+
versionRange: ">=3.0.0 <3.4.0"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
filePath: "dist/transformers.js",
|
|
194
|
+
versionRange: ">=3.0.0 <3.4.0"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
filePath: "dist/transformers.node.mjs",
|
|
198
|
+
versionRange: ">=3.4.0 <5.0.0"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
filePath: "dist/transformers.node.cjs",
|
|
202
|
+
versionRange: ">=3.4.0 <5.0.0"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
filePath: "dist/transformers.web.js",
|
|
206
|
+
versionRange: ">=3.4.0 <5.0.0"
|
|
207
|
+
}
|
|
208
|
+
];
|
|
209
|
+
var pipelineClasses = [
|
|
210
|
+
"TextGenerationPipeline",
|
|
211
|
+
"Text2TextGenerationPipeline",
|
|
212
|
+
"FeatureExtractionPipeline",
|
|
213
|
+
"QuestionAnsweringPipeline"
|
|
214
|
+
];
|
|
215
|
+
var huggingFaceTransformersConfigs = moduleFiles.flatMap(({ filePath, versionRange }) => [
|
|
216
|
+
{
|
|
217
|
+
channelName: huggingFaceTransformersChannels.pipeline.channelName,
|
|
218
|
+
module: {
|
|
219
|
+
name: "@huggingface/transformers",
|
|
220
|
+
versionRange,
|
|
221
|
+
filePath
|
|
222
|
+
},
|
|
223
|
+
functionQuery: {
|
|
224
|
+
functionName: "pipeline",
|
|
225
|
+
kind: "Async"
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
...pipelineClasses.map((className) => ({
|
|
229
|
+
channelName: huggingFaceTransformersChannels.pipelineCall.channelName,
|
|
230
|
+
module: {
|
|
231
|
+
name: "@huggingface/transformers",
|
|
232
|
+
versionRange,
|
|
233
|
+
filePath
|
|
234
|
+
},
|
|
235
|
+
functionQuery: {
|
|
236
|
+
className,
|
|
237
|
+
methodName: "_call",
|
|
238
|
+
kind: "Async"
|
|
239
|
+
}
|
|
240
|
+
}))
|
|
241
|
+
]);
|
|
242
|
+
|
|
149
243
|
// src/instrumentation/plugins/strands-agent-sdk-channels.ts
|
|
150
244
|
var strandsAgentSDKChannels = defineChannels(
|
|
151
245
|
"@strands-agents/sdk",
|
|
@@ -230,6 +324,18 @@ var defaultInstrumentationConfigGroups = [
|
|
|
230
324
|
integrations: ["claudeAgentSDK"],
|
|
231
325
|
configs: claudeAgentSDKConfigs
|
|
232
326
|
},
|
|
327
|
+
{
|
|
328
|
+
integrations: ["cloudflareAIChat"],
|
|
329
|
+
configs: cloudflareAIChatConfigs
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
integrations: ["cloudflareAgents"],
|
|
333
|
+
configs: cloudflareAgentsConfigs
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
integrations: ["cloudflareThink"],
|
|
337
|
+
configs: cloudflareThinkConfigs
|
|
338
|
+
},
|
|
233
339
|
{ integrations: ["cursor", "cursorSDK"], configs: cursorSDKConfigs },
|
|
234
340
|
{
|
|
235
341
|
integrations: ["openAIAgents"],
|
|
@@ -239,7 +345,10 @@ var defaultInstrumentationConfigGroups = [
|
|
|
239
345
|
integrations: ["google", "googleGenAI"],
|
|
240
346
|
configs: googleGenAIConfigs
|
|
241
347
|
},
|
|
242
|
-
{
|
|
348
|
+
{
|
|
349
|
+
integrations: ["huggingface"],
|
|
350
|
+
configs: [...huggingFaceConfigs, ...huggingFaceTransformersConfigs]
|
|
351
|
+
},
|
|
243
352
|
{
|
|
244
353
|
integrations: ["langchain", "langgraph"],
|
|
245
354
|
configs: langchainConfigs
|
|
@@ -251,6 +360,7 @@ var defaultInstrumentationConfigGroups = [
|
|
|
251
360
|
configs: openRouterAgentConfigs
|
|
252
361
|
},
|
|
253
362
|
{ integrations: ["mistral"], configs: mistralConfigs },
|
|
363
|
+
{ integrations: ["ollama"], configs: ollamaConfigs },
|
|
254
364
|
{ integrations: ["googleADK"], configs: googleADKConfigs },
|
|
255
365
|
{ integrations: ["cohere"], configs: cohereConfigs },
|
|
256
366
|
{ integrations: ["groq"], configs: groqConfigs },
|
|
@@ -310,78 +420,86 @@ function getModuleVersion(basedir) {
|
|
|
310
420
|
}
|
|
311
421
|
return void 0;
|
|
312
422
|
}
|
|
313
|
-
var unplugin = createUnplugin(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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
|
|
362
|
-
);
|
|
363
|
-
if (!transformer) {
|
|
364
|
-
return null;
|
|
365
|
-
}
|
|
423
|
+
var unplugin = createUnplugin((options = {}) => {
|
|
424
|
+
const browser = options.browser ?? options.useDiagnosticChannelCompatShim ?? false;
|
|
425
|
+
const allInstrumentations = getDefaultInstrumentationConfigs({
|
|
426
|
+
additionalInstrumentations: options.instrumentations
|
|
427
|
+
});
|
|
428
|
+
const instrumentationMatcher = create(allInstrumentations);
|
|
429
|
+
return {
|
|
430
|
+
name: "code-transformer",
|
|
431
|
+
enforce: "pre",
|
|
432
|
+
transformInclude(id) {
|
|
433
|
+
const pathWithoutQuery = id.split("?", 1)[0];
|
|
434
|
+
if (!pathWithoutQuery) {
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
if (pathWithoutQuery.startsWith("file:")) {
|
|
366
438
|
try {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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;
|
|
439
|
+
return isAbsolute(fileURLToPath(pathWithoutQuery));
|
|
440
|
+
} catch {
|
|
441
|
+
return false;
|
|
380
442
|
}
|
|
381
443
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
)
|
|
444
|
+
return isAbsolute(pathWithoutQuery);
|
|
445
|
+
},
|
|
446
|
+
transform(code, id) {
|
|
447
|
+
if (!id) {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
const cleanId = id.replace(/[?#].*$/, "");
|
|
451
|
+
const filePath = cleanId.startsWith("file:") ? fileURLToPath(cleanId) : cleanId;
|
|
452
|
+
const ext = extname(filePath);
|
|
453
|
+
let isModule = ext === ".mjs" || ext === ".ts" || ext === ".tsx";
|
|
454
|
+
if (ext === ".js") {
|
|
455
|
+
isModule = code.includes("export ") || code.includes("import ");
|
|
456
|
+
}
|
|
457
|
+
const normalizedForPlatform = filePath.split("/").join(sep);
|
|
458
|
+
const moduleDetails = moduleDetailsFromPath(normalizedForPlatform);
|
|
459
|
+
if (!moduleDetails) {
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
const moduleName = getPackageName(moduleDetails.basedir) ?? moduleDetails.name;
|
|
463
|
+
const normalizedModulePath = moduleDetails.path.replace(/\\/g, "/");
|
|
464
|
+
const moduleVersion = getModuleVersion(moduleDetails.basedir);
|
|
465
|
+
const patched = applySpecialCasePatch({
|
|
466
|
+
packageName: moduleName,
|
|
467
|
+
modulePath: normalizedModulePath,
|
|
468
|
+
source: code,
|
|
469
|
+
format: isModule ? "esm" : "cjs",
|
|
470
|
+
browser
|
|
471
|
+
});
|
|
472
|
+
if (patched !== null) {
|
|
473
|
+
return { code: patched, map: null };
|
|
474
|
+
}
|
|
475
|
+
if (!moduleVersion) {
|
|
476
|
+
console.warn(
|
|
477
|
+
`No 'package.json' version found for module ${moduleName} at ${moduleDetails.basedir}. Skipping transformation.`
|
|
478
|
+
);
|
|
479
|
+
return null;
|
|
480
|
+
}
|
|
481
|
+
const transformer = instrumentationMatcher.getTransformer(
|
|
482
|
+
moduleName,
|
|
483
|
+
moduleVersion,
|
|
484
|
+
normalizedModulePath
|
|
485
|
+
);
|
|
486
|
+
if (!transformer) {
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
try {
|
|
490
|
+
const moduleType = isModule ? "esm" : "cjs";
|
|
491
|
+
const result = transformer.transform(code, moduleType);
|
|
492
|
+
return {
|
|
493
|
+
code: result.code,
|
|
494
|
+
map: result.map
|
|
495
|
+
};
|
|
496
|
+
} catch (error) {
|
|
497
|
+
console.warn(`Code transformation failed for ${id}: ${error}`);
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
});
|
|
385
503
|
|
|
386
504
|
export {
|
|
387
505
|
unplugin
|