braintrust 3.26.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/dev/dist/index.js +2440 -1067
- package/dev/dist/index.mjs +1644 -271
- package/dist/apply-auto-instrumentation.js +320 -261
- package/dist/apply-auto-instrumentation.mjs +118 -59
- package/dist/auto-instrumentations/bundler/esbuild.cjs +377 -59
- package/dist/auto-instrumentations/bundler/esbuild.mjs +5 -4
- package/dist/auto-instrumentations/bundler/next.cjs +379 -61
- package/dist/auto-instrumentations/bundler/next.mjs +6 -5
- package/dist/auto-instrumentations/bundler/rollup.cjs +377 -59
- package/dist/auto-instrumentations/bundler/rollup.mjs +5 -4
- package/dist/auto-instrumentations/bundler/vite.cjs +406 -60
- package/dist/auto-instrumentations/bundler/vite.mjs +34 -5
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +363 -59
- package/dist/auto-instrumentations/bundler/webpack.cjs +377 -59
- package/dist/auto-instrumentations/bundler/webpack.mjs +6 -5
- package/dist/auto-instrumentations/{chunk-AKKPLXTP.mjs → chunk-2AMDGD65.mjs} +160 -57
- package/dist/auto-instrumentations/{chunk-V5LEODRX.mjs → chunk-BW33ULMW.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-XYN63IG5.mjs → chunk-I55G56ZL.mjs} +21 -58
- package/dist/auto-instrumentations/{chunk-NRE4QUQR.mjs → chunk-JPUFNW7X.mjs} +140 -0
- package/dist/auto-instrumentations/{chunk-6E22MYSW.mjs → chunk-XEYKUBLY.mjs} +30 -4
- package/dist/auto-instrumentations/{chunk-XZHHE4Y3.mjs → chunk-ZNHTSSGI.mjs} +155 -2
- package/dist/auto-instrumentations/hook.mjs +161 -3
- package/dist/auto-instrumentations/index.cjs +296 -1
- package/dist/auto-instrumentations/index.d.mts +5 -1
- package/dist/auto-instrumentations/index.d.ts +5 -1
- package/dist/auto-instrumentations/index.mjs +6 -2
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +105 -57
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +2 -2
- package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
- package/dist/browser.d.mts +57 -5
- package/dist/browser.d.ts +57 -5
- package/dist/browser.js +1855 -285
- package/dist/browser.mjs +1855 -285
- package/dist/{chunk-PN7EWK66.mjs → chunk-CZM5JIQL.mjs} +209 -1
- package/dist/{chunk-VYNNEKSA.js → chunk-MF7NU6BT.js} +216 -8
- package/dist/{chunk-VRZZQPAA.js → chunk-QRHGVBKU.js} +2403 -1220
- package/dist/{chunk-XIZOM2HO.mjs → chunk-YKD22IMR.mjs} +1454 -271
- package/dist/cli.js +1645 -272
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +1855 -285
- package/dist/edge-light.mjs +1855 -285
- package/dist/index.d.mts +57 -5
- package/dist/index.d.ts +57 -5
- package/dist/index.js +600 -413
- package/dist/index.mjs +201 -14
- package/dist/instrumentation/index.d.mts +8 -0
- package/dist/instrumentation/index.d.ts +8 -0
- package/dist/instrumentation/index.js +1839 -466
- package/dist/instrumentation/index.mjs +1839 -466
- 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 +1855 -285
- package/dist/workerd.mjs +1855 -285
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
claudeAgentSDKChannels,
|
|
10
10
|
cloudflareAIChatChannels,
|
|
11
11
|
cloudflareAgentsChannels,
|
|
12
|
+
cloudflareThinkChannels,
|
|
12
13
|
cohereChannels,
|
|
13
14
|
cursorSDKChannels,
|
|
14
15
|
flueChannels,
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
langChainChannels,
|
|
26
27
|
langSmithChannels,
|
|
27
28
|
mistralChannels,
|
|
29
|
+
ollamaChannels,
|
|
28
30
|
openAIAgentsCoreChannels,
|
|
29
31
|
openAIChannels,
|
|
30
32
|
openAICodexChannels,
|
|
@@ -36,7 +38,7 @@ import {
|
|
|
36
38
|
smithyClientChannels,
|
|
37
39
|
smithyCoreChannels,
|
|
38
40
|
strandsAgentSDKChannels
|
|
39
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-CZM5JIQL.mjs";
|
|
40
42
|
|
|
41
43
|
// src/node/apply-auto-instrumentation-entry.ts
|
|
42
44
|
import { register } from "node:module";
|
|
@@ -549,7 +551,40 @@ var anthropicConfigs = [
|
|
|
549
551
|
methodName: "toolRunner",
|
|
550
552
|
kind: "Sync"
|
|
551
553
|
}
|
|
552
|
-
}
|
|
554
|
+
},
|
|
555
|
+
// Managed Agents Sessions event streams are discovered automatically, but
|
|
556
|
+
// remain passive until the user calls collectAnthropicSession() on the
|
|
557
|
+
// returned stream.
|
|
558
|
+
...["mjs", "js"].map(
|
|
559
|
+
(extension) => ({
|
|
560
|
+
channelName: anthropicChannels.betaSessionsEventsStream.channelName,
|
|
561
|
+
module: {
|
|
562
|
+
name: "@anthropic-ai/sdk",
|
|
563
|
+
versionRange: ">=0.86.0",
|
|
564
|
+
filePath: `resources/beta/sessions/events.${extension}`
|
|
565
|
+
},
|
|
566
|
+
functionQuery: {
|
|
567
|
+
className: "Events",
|
|
568
|
+
methodName: "stream",
|
|
569
|
+
kind: "Async"
|
|
570
|
+
}
|
|
571
|
+
})
|
|
572
|
+
),
|
|
573
|
+
...["mjs", "js"].map(
|
|
574
|
+
(extension) => ({
|
|
575
|
+
channelName: anthropicChannels.betaSessionsThreadsEventsStream.channelName,
|
|
576
|
+
module: {
|
|
577
|
+
name: "@anthropic-ai/sdk",
|
|
578
|
+
versionRange: ">=0.86.0",
|
|
579
|
+
filePath: `resources/beta/sessions/threads/events.${extension}`
|
|
580
|
+
},
|
|
581
|
+
functionQuery: {
|
|
582
|
+
className: "Events",
|
|
583
|
+
methodName: "stream",
|
|
584
|
+
kind: "Async"
|
|
585
|
+
}
|
|
586
|
+
})
|
|
587
|
+
)
|
|
553
588
|
];
|
|
554
589
|
|
|
555
590
|
// src/auto-instrumentations/configs/bedrock-runtime.ts
|
|
@@ -679,6 +714,24 @@ var cloudflareAgentsConfigs = [
|
|
|
679
714
|
}
|
|
680
715
|
];
|
|
681
716
|
|
|
717
|
+
// src/auto-instrumentations/configs/cloudflare-think.ts
|
|
718
|
+
var cloudflareThinkVersionRange = ">=0.13.0 <0.14.0";
|
|
719
|
+
var cloudflareThinkConfigs = [
|
|
720
|
+
{
|
|
721
|
+
channelName: cloudflareThinkChannels.runInferenceLoop.channelName,
|
|
722
|
+
module: {
|
|
723
|
+
name: "@cloudflare/think",
|
|
724
|
+
versionRange: cloudflareThinkVersionRange,
|
|
725
|
+
filePath: "dist/think.js"
|
|
726
|
+
},
|
|
727
|
+
functionQuery: {
|
|
728
|
+
className: "Think",
|
|
729
|
+
methodName: "_runInferenceLoop",
|
|
730
|
+
kind: "Async"
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
];
|
|
734
|
+
|
|
682
735
|
// src/auto-instrumentations/configs/cohere.ts
|
|
683
736
|
var cohereConfigs = [
|
|
684
737
|
{
|
|
@@ -2248,6 +2301,31 @@ var mistralConfigs = [
|
|
|
2248
2301
|
}
|
|
2249
2302
|
];
|
|
2250
2303
|
|
|
2304
|
+
// src/auto-instrumentations/configs/ollama.ts
|
|
2305
|
+
var methods = [
|
|
2306
|
+
["chat", ollamaChannels.chat.channelName],
|
|
2307
|
+
["generate", ollamaChannels.generate.channelName],
|
|
2308
|
+
["embed", ollamaChannels.embed.channelName]
|
|
2309
|
+
];
|
|
2310
|
+
var implementationFiles = ["dist/browser.mjs", "dist/browser.cjs"];
|
|
2311
|
+
var ollamaConfigs = [
|
|
2312
|
+
...implementationFiles.flatMap(
|
|
2313
|
+
(filePath) => methods.map(([methodName, channelName]) => ({
|
|
2314
|
+
channelName,
|
|
2315
|
+
module: {
|
|
2316
|
+
name: "ollama",
|
|
2317
|
+
versionRange: ">=0.6.0 <0.7.0",
|
|
2318
|
+
filePath
|
|
2319
|
+
},
|
|
2320
|
+
functionQuery: {
|
|
2321
|
+
className: "Ollama",
|
|
2322
|
+
methodName,
|
|
2323
|
+
kind: "Async"
|
|
2324
|
+
}
|
|
2325
|
+
}))
|
|
2326
|
+
)
|
|
2327
|
+
];
|
|
2328
|
+
|
|
2251
2329
|
// src/auto-instrumentations/configs/openai-agents.ts
|
|
2252
2330
|
var lifecycleMethods = [
|
|
2253
2331
|
["onTraceStart", openAIAgentsCoreChannels.onTraceStart.channelName],
|
|
@@ -2537,6 +2615,19 @@ var openRouterConfigs = [
|
|
|
2537
2615
|
kind: "Async"
|
|
2538
2616
|
}
|
|
2539
2617
|
},
|
|
2618
|
+
{
|
|
2619
|
+
channelName: openRouterChannels.betaResponsesSend.channelName,
|
|
2620
|
+
module: {
|
|
2621
|
+
name: "@openrouter/sdk",
|
|
2622
|
+
versionRange: ">=1.1.2 <2.0.0",
|
|
2623
|
+
filePath: "esm/sdk/betaresponses.js"
|
|
2624
|
+
},
|
|
2625
|
+
functionQuery: {
|
|
2626
|
+
className: "BetaResponses",
|
|
2627
|
+
methodName: "send",
|
|
2628
|
+
kind: "Async"
|
|
2629
|
+
}
|
|
2630
|
+
},
|
|
2540
2631
|
{
|
|
2541
2632
|
channelName: openRouterChannels.callModel.channelName,
|
|
2542
2633
|
module: {
|
|
@@ -2658,6 +2749,10 @@ var defaultInstrumentationConfigGroups = [
|
|
|
2658
2749
|
integrations: ["cloudflareAgents"],
|
|
2659
2750
|
configs: cloudflareAgentsConfigs
|
|
2660
2751
|
},
|
|
2752
|
+
{
|
|
2753
|
+
integrations: ["cloudflareThink"],
|
|
2754
|
+
configs: cloudflareThinkConfigs
|
|
2755
|
+
},
|
|
2661
2756
|
{ integrations: ["cursor", "cursorSDK"], configs: cursorSDKConfigs },
|
|
2662
2757
|
{
|
|
2663
2758
|
integrations: ["openAIAgents"],
|
|
@@ -2682,6 +2777,7 @@ var defaultInstrumentationConfigGroups = [
|
|
|
2682
2777
|
configs: openRouterAgentConfigs
|
|
2683
2778
|
},
|
|
2684
2779
|
{ integrations: ["mistral"], configs: mistralConfigs },
|
|
2780
|
+
{ integrations: ["ollama"], configs: ollamaConfigs },
|
|
2685
2781
|
{ integrations: ["googleADK"], configs: googleADKConfigs },
|
|
2686
2782
|
{ integrations: ["cohere"], configs: cohereConfigs },
|
|
2687
2783
|
{ integrations: ["groq"], configs: groqConfigs },
|
|
@@ -2760,8 +2856,7 @@ var transforms = {
|
|
|
2760
2856
|
tracingHookDeclaration(state2, node) {
|
|
2761
2857
|
const {
|
|
2762
2858
|
channelName,
|
|
2763
|
-
module: { name }
|
|
2764
|
-
operator
|
|
2859
|
+
module: { name }
|
|
2765
2860
|
} = state2;
|
|
2766
2861
|
const channelVariable = formatChannelVariable(channelName);
|
|
2767
2862
|
const channelGetter = formatChannelGetter(channelName);
|
|
@@ -2774,7 +2869,7 @@ var transforms = {
|
|
|
2774
2869
|
return;
|
|
2775
2870
|
}
|
|
2776
2871
|
const sharedHookLookup = hasSharedHookLookup ? "" : `
|
|
2777
|
-
const ${SHARED_HOOK_LOOKUP} = (__bt$hookName
|
|
2872
|
+
const ${SHARED_HOOK_LOOKUP} = (__bt$hookName) => {
|
|
2778
2873
|
try {
|
|
2779
2874
|
const __bt$hooks = globalThis[${JSON.stringify(
|
|
2780
2875
|
GLOBAL_INSTRUMENTATION_HOOKS_KEY
|
|
@@ -2796,8 +2891,7 @@ var transforms = {
|
|
|
2796
2891
|
__bt$hook[Symbol.for(${JSON.stringify(
|
|
2797
2892
|
GLOBAL_INSTRUMENTATION_HOOK_BRAND
|
|
2798
2893
|
)})] !== ${GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION} ||
|
|
2799
|
-
typeof __bt$hook.
|
|
2800
|
-
typeof __bt$hook[__bt$operator] !== "function"
|
|
2894
|
+
typeof __bt$hook.traceInvocation !== "function"
|
|
2801
2895
|
) return undefined;
|
|
2802
2896
|
return __bt$hook;
|
|
2803
2897
|
} catch {
|
|
@@ -2810,8 +2904,7 @@ var transforms = {
|
|
|
2810
2904
|
let ${channelVariable};
|
|
2811
2905
|
const ${channelGetter} = () =>
|
|
2812
2906
|
${channelVariable} ??= ${SHARED_HOOK_LOOKUP}(
|
|
2813
|
-
${JSON.stringify(`orchestrion:${name}:${channelName}`)}
|
|
2814
|
-
${JSON.stringify(operator)}
|
|
2907
|
+
${JSON.stringify(`orchestrion:${name}:${channelName}`)}
|
|
2815
2908
|
);
|
|
2816
2909
|
`;
|
|
2817
2910
|
const sharedHookLookupIndex = node.body.findIndex(
|
|
@@ -2886,28 +2979,18 @@ function traceInstanceMethod(state2, node, program) {
|
|
|
2886
2979
|
ctor.value.body.body.push(...ctorBody);
|
|
2887
2980
|
}
|
|
2888
2981
|
function wrap(state2, node) {
|
|
2889
|
-
const
|
|
2890
|
-
const wrapper = operator === "traceCallback" ? wrapCallback(state2) : operator === "tracePromise" ? wrapPromise(state2) : wrapSync(state2);
|
|
2982
|
+
const wrapper = wrapInvocation(state2);
|
|
2891
2983
|
const block = wrapper.body[0].body;
|
|
2892
2984
|
const common = parse(
|
|
2893
2985
|
node.type === "ArrowFunctionExpression" ? `
|
|
2894
|
-
const __bt$
|
|
2895
|
-
arguments,
|
|
2896
|
-
moduleVersion: ${JSON.stringify(moduleVersion)}
|
|
2897
|
-
};
|
|
2898
|
-
const __bt$traced = () => {
|
|
2986
|
+
const __bt$target = (...__bt$args) => {
|
|
2899
2987
|
const __bt$wrapped = () => {};
|
|
2900
|
-
return __bt$wrapped(...
|
|
2988
|
+
return __bt$wrapped(...__bt$args);
|
|
2901
2989
|
};
|
|
2902
2990
|
` : `
|
|
2903
|
-
const __bt$
|
|
2904
|
-
arguments,
|
|
2905
|
-
self: this,
|
|
2906
|
-
moduleVersion: ${JSON.stringify(moduleVersion)}
|
|
2907
|
-
};
|
|
2908
|
-
const __bt$traced = () => {
|
|
2991
|
+
const __bt$target = function (...__bt$args) {
|
|
2909
2992
|
const __bt$wrapped = () => {};
|
|
2910
|
-
return __bt$wrapped.apply(this,
|
|
2993
|
+
return __bt$wrapped.apply(this, __bt$args);
|
|
2911
2994
|
};
|
|
2912
2995
|
`
|
|
2913
2996
|
).body;
|
|
@@ -2949,49 +3032,25 @@ function wrapSuper(node) {
|
|
|
2949
3032
|
node.body.body.unshift(parse("const __bt$super = {}").body[0]);
|
|
2950
3033
|
}
|
|
2951
3034
|
}
|
|
2952
|
-
function
|
|
2953
|
-
const {
|
|
2954
|
-
channelName,
|
|
2955
|
-
functionQuery: { callbackIndex = -1 }
|
|
2956
|
-
} = state2;
|
|
3035
|
+
function wrapInvocation(state2) {
|
|
3036
|
+
const { channelName, moduleVersion, operator, functionQuery } = state2;
|
|
2957
3037
|
const channelGetter = formatChannelGetter(channelName);
|
|
3038
|
+
const callbackIndex = functionQuery.callbackIndex ?? -1;
|
|
2958
3039
|
return parse(`
|
|
2959
3040
|
function wrapper () {
|
|
2960
3041
|
const __bt$hook = ${channelGetter}();
|
|
2961
|
-
if (!__bt$hook
|
|
2962
|
-
__bt$
|
|
2963
|
-
|
|
2964
|
-
__bt$
|
|
2965
|
-
|
|
2966
|
-
|
|
3042
|
+
if (!__bt$hook) return __bt$target.apply(this, arguments);
|
|
3043
|
+
return __bt$hook.traceInvocation(
|
|
3044
|
+
${JSON.stringify(operator)},
|
|
3045
|
+
__bt$target,
|
|
3046
|
+
this,
|
|
3047
|
+
arguments,
|
|
3048
|
+
{ moduleVersion: ${JSON.stringify(moduleVersion)} },
|
|
3049
|
+
${callbackIndex}
|
|
2967
3050
|
);
|
|
2968
3051
|
}
|
|
2969
3052
|
`);
|
|
2970
3053
|
}
|
|
2971
|
-
function wrapPromise(state2) {
|
|
2972
|
-
const { channelName } = state2;
|
|
2973
|
-
const channelGetter = formatChannelGetter(channelName);
|
|
2974
|
-
return parse(`
|
|
2975
|
-
function wrapper () {
|
|
2976
|
-
const __bt$hook = ${channelGetter}();
|
|
2977
|
-
if (!__bt$hook?.hasSubscribers) return __bt$traced();
|
|
2978
|
-
__bt$ctx.self ??= this;
|
|
2979
|
-
return __bt$hook.tracePromise(__bt$traced, __bt$ctx);
|
|
2980
|
-
}
|
|
2981
|
-
`);
|
|
2982
|
-
}
|
|
2983
|
-
function wrapSync(state2) {
|
|
2984
|
-
const { channelName } = state2;
|
|
2985
|
-
const channelGetter = formatChannelGetter(channelName);
|
|
2986
|
-
return parse(`
|
|
2987
|
-
function wrapper () {
|
|
2988
|
-
const __bt$hook = ${channelGetter}();
|
|
2989
|
-
if (!__bt$hook?.hasSubscribers) return __bt$traced();
|
|
2990
|
-
__bt$ctx.self ??= this;
|
|
2991
|
-
return __bt$hook.traceSync(__bt$traced, __bt$ctx);
|
|
2992
|
-
}
|
|
2993
|
-
`);
|
|
2994
|
-
}
|
|
2995
3054
|
|
|
2996
3055
|
// src/auto-instrumentations/orchestrion-js/transformer.ts
|
|
2997
3056
|
var Transformer = class {
|