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
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION,
|
|
2
3
|
applySpecialCasePatch,
|
|
3
4
|
create,
|
|
4
5
|
getPackageName,
|
|
5
6
|
getPackageVersion,
|
|
6
|
-
installMastraExporterFactory
|
|
7
|
-
|
|
7
|
+
installMastraExporterFactory,
|
|
8
|
+
newGlobalTracingChannel,
|
|
9
|
+
setGlobalHookErrorReporter
|
|
10
|
+
} from "./chunk-2AMDGD65.mjs";
|
|
8
11
|
|
|
9
12
|
// src/auto-instrumentations/hook.mts
|
|
10
13
|
import { register } from "module";
|
|
@@ -26,6 +29,9 @@ var envIntegrationAliases = {
|
|
|
26
29
|
strandsagentsdk: "strandsAgentSDK",
|
|
27
30
|
"strands-agent-sdk": "strandsAgentSDK",
|
|
28
31
|
"@strands-agents/sdk": "strandsAgentSDK",
|
|
32
|
+
agents: "cloudflareAgents",
|
|
33
|
+
"cloudflare-agents": "cloudflareAgents",
|
|
34
|
+
cloudflareagents: "cloudflareAgents",
|
|
29
35
|
anthropic: "anthropic",
|
|
30
36
|
aisdk: "aisdk",
|
|
31
37
|
"ai-sdk": "aisdk",
|
|
@@ -33,6 +39,10 @@ var envIntegrationAliases = {
|
|
|
33
39
|
vercel: "vercel",
|
|
34
40
|
claudeagentsdk: "claudeAgentSDK",
|
|
35
41
|
"claude-agent-sdk": "claudeAgentSDK",
|
|
42
|
+
cloudflareaichat: "cloudflareAIChat",
|
|
43
|
+
"cloudflare-ai-chat": "cloudflareAIChat",
|
|
44
|
+
"@cloudflare/ai-chat": "cloudflareAIChat",
|
|
45
|
+
cloudflarethink: "cloudflareThink",
|
|
36
46
|
cursor: "cursor",
|
|
37
47
|
"cursor-sdk": "cursorSDK",
|
|
38
48
|
cursorsdk: "cursorSDK",
|
|
@@ -47,10 +57,13 @@ var envIntegrationAliases = {
|
|
|
47
57
|
"google-genai": "googleGenAI",
|
|
48
58
|
googlegenai: "googleGenAI",
|
|
49
59
|
huggingface: "huggingface",
|
|
60
|
+
"@huggingface/transformers": "huggingface",
|
|
61
|
+
transformers: "huggingface",
|
|
50
62
|
openrouter: "openrouter",
|
|
51
63
|
openrouteragent: "openrouterAgent",
|
|
52
64
|
"openrouter-agent": "openrouterAgent",
|
|
53
65
|
mistral: "mistral",
|
|
66
|
+
ollama: "ollama",
|
|
54
67
|
googleadk: "googleADK",
|
|
55
68
|
"google-adk": "googleADK",
|
|
56
69
|
cohere: "cohere",
|
|
@@ -103,73 +116,6 @@ var DefaultAsyncLocalStorage = class {
|
|
|
103
116
|
return void 0;
|
|
104
117
|
}
|
|
105
118
|
};
|
|
106
|
-
var DefaultChannel = class {
|
|
107
|
-
constructor(name) {
|
|
108
|
-
this.name = name;
|
|
109
|
-
}
|
|
110
|
-
name;
|
|
111
|
-
hasSubscribers = false;
|
|
112
|
-
subscribe(_subscription) {
|
|
113
|
-
}
|
|
114
|
-
unsubscribe(_subscription) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
bindStore(_store, _transform) {
|
|
118
|
-
}
|
|
119
|
-
unbindStore(_store) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
publish(_message) {
|
|
123
|
-
}
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
|
-
runStores(_message, fn, thisArg, ...args) {
|
|
126
|
-
return fn.apply(thisArg, args);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
var DefaultTracingChannel = class {
|
|
130
|
-
start;
|
|
131
|
-
end;
|
|
132
|
-
asyncStart;
|
|
133
|
-
asyncEnd;
|
|
134
|
-
error;
|
|
135
|
-
constructor(nameOrChannels) {
|
|
136
|
-
if (typeof nameOrChannels === "string") {
|
|
137
|
-
this.start = new DefaultChannel(`tracing:${nameOrChannels}:start`);
|
|
138
|
-
this.end = new DefaultChannel(`tracing:${nameOrChannels}:end`);
|
|
139
|
-
this.asyncStart = new DefaultChannel(
|
|
140
|
-
`tracing:${nameOrChannels}:asyncStart`
|
|
141
|
-
);
|
|
142
|
-
this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`);
|
|
143
|
-
this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
this.start = nameOrChannels.start ?? new DefaultChannel("tracing:start");
|
|
147
|
-
this.end = nameOrChannels.end ?? new DefaultChannel("tracing:end");
|
|
148
|
-
this.asyncStart = nameOrChannels.asyncStart ?? new DefaultChannel("tracing:asyncStart");
|
|
149
|
-
this.asyncEnd = nameOrChannels.asyncEnd ?? new DefaultChannel("tracing:asyncEnd");
|
|
150
|
-
this.error = nameOrChannels.error ?? new DefaultChannel("tracing:error");
|
|
151
|
-
}
|
|
152
|
-
get hasSubscribers() {
|
|
153
|
-
return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers;
|
|
154
|
-
}
|
|
155
|
-
subscribe(_handlers) {
|
|
156
|
-
}
|
|
157
|
-
unsubscribe(_handlers) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
|
-
traceSync(fn, _message, thisArg, ...args) {
|
|
162
|
-
return fn.apply(thisArg, args);
|
|
163
|
-
}
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
|
-
tracePromise(fn, _message, thisArg, ...args) {
|
|
166
|
-
return fn.apply(thisArg, args);
|
|
167
|
-
}
|
|
168
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
|
-
traceCallback(fn, _position, _message, thisArg, ...args) {
|
|
170
|
-
return fn.apply(thisArg, args);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
119
|
var iso = {
|
|
174
120
|
buildType: "unknown",
|
|
175
121
|
// Will be set by configureBrowser() or configureNode()
|
|
@@ -180,7 +126,7 @@ var iso = {
|
|
|
180
126
|
getCallerLocation: () => void 0,
|
|
181
127
|
newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(),
|
|
182
128
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
-
newTracingChannel: (nameOrChannels) =>
|
|
129
|
+
newTracingChannel: (nameOrChannels) => newGlobalTracingChannel(nameOrChannels),
|
|
184
130
|
processOn: (_0, _1) => {
|
|
185
131
|
},
|
|
186
132
|
basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
|
|
@@ -293,6 +239,9 @@ var debugLogger = {
|
|
|
293
239
|
return createDebugLogger(state2);
|
|
294
240
|
}
|
|
295
241
|
};
|
|
242
|
+
setGlobalHookErrorReporter((error) => {
|
|
243
|
+
debugLogger.error("Global instrumentation hook error:", error);
|
|
244
|
+
});
|
|
296
245
|
|
|
297
246
|
// src/logger.ts
|
|
298
247
|
import { v4 as uuidv42 } from "uuid";
|
|
@@ -1935,7 +1884,8 @@ var ApiKey = z6.object({
|
|
|
1935
1884
|
user_email: z6.union([z6.string(), z6.null()]).optional(),
|
|
1936
1885
|
user_given_name: z6.union([z6.string(), z6.null()]).optional(),
|
|
1937
1886
|
user_family_name: z6.union([z6.string(), z6.null()]).optional(),
|
|
1938
|
-
org_id: z6.union([z6.string(), z6.null()]).optional()
|
|
1887
|
+
org_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
1888
|
+
expires_at: z6.union([z6.string(), z6.null()]).optional()
|
|
1939
1889
|
});
|
|
1940
1890
|
var TriggeredFunctionState = z6.object({
|
|
1941
1891
|
triggered_xact_id: z6.string(),
|
|
@@ -2055,6 +2005,7 @@ var TopicMapData = z6.object({
|
|
|
2055
2005
|
topic_names: z6.record(z6.string()).optional(),
|
|
2056
2006
|
generation_settings: TopicMapGenerationSettings.optional(),
|
|
2057
2007
|
disable_reconciliation: z6.boolean().optional(),
|
|
2008
|
+
reconcile_mode: z6.enum(["evolve", "names_only"]).optional(),
|
|
2058
2009
|
distance_threshold: z6.number().optional(),
|
|
2059
2010
|
btql_filter: z6.string().optional(),
|
|
2060
2011
|
automation_btql_filter: z6.string().optional()
|
|
@@ -2635,7 +2586,12 @@ var ModelParams = z6.union([
|
|
|
2635
2586
|
}).partial().passthrough()
|
|
2636
2587
|
]);
|
|
2637
2588
|
var PromptOptionsNullish = z6.union([
|
|
2638
|
-
z6.object({
|
|
2589
|
+
z6.object({
|
|
2590
|
+
model: z6.string(),
|
|
2591
|
+
params: ModelParams,
|
|
2592
|
+
position: z6.string(),
|
|
2593
|
+
endpoint_name: z6.union([z6.string(), z6.null()])
|
|
2594
|
+
}).partial(),
|
|
2639
2595
|
z6.null()
|
|
2640
2596
|
]);
|
|
2641
2597
|
var PromptParserNullish = z6.union([
|
|
@@ -2649,11 +2605,25 @@ var PromptParserNullish = z6.union([
|
|
|
2649
2605
|
}),
|
|
2650
2606
|
z6.null()
|
|
2651
2607
|
]);
|
|
2608
|
+
var PreprocessorSavedFunctionId = z6.union([
|
|
2609
|
+
z6.object({
|
|
2610
|
+
type: z6.literal("function"),
|
|
2611
|
+
id: z6.string(),
|
|
2612
|
+
version: z6.string().optional()
|
|
2613
|
+
}),
|
|
2614
|
+
z6.object({
|
|
2615
|
+
type: z6.literal("global"),
|
|
2616
|
+
name: z6.string(),
|
|
2617
|
+
function_type: z6.literal("preprocessor").optional().default("preprocessor")
|
|
2618
|
+
}),
|
|
2619
|
+
z6.null()
|
|
2620
|
+
]);
|
|
2652
2621
|
var PromptDataNullish = z6.union([
|
|
2653
2622
|
z6.object({
|
|
2654
2623
|
prompt: PromptBlockDataNullish,
|
|
2655
2624
|
options: PromptOptionsNullish,
|
|
2656
2625
|
parser: PromptParserNullish,
|
|
2626
|
+
preprocessor: PreprocessorSavedFunctionId,
|
|
2657
2627
|
tool_functions: z6.union([z6.array(SavedFunctionId), z6.null()]),
|
|
2658
2628
|
template_format: z6.union([
|
|
2659
2629
|
z6.enum(["mustache", "nunjucks", "none"]),
|
|
@@ -2855,6 +2825,7 @@ var PromptData = z6.object({
|
|
|
2855
2825
|
prompt: PromptBlockDataNullish,
|
|
2856
2826
|
options: PromptOptionsNullish,
|
|
2857
2827
|
parser: PromptParserNullish,
|
|
2828
|
+
preprocessor: PreprocessorSavedFunctionId,
|
|
2858
2829
|
tool_functions: z6.union([z6.array(SavedFunctionId), z6.null()]),
|
|
2859
2830
|
template_format: z6.union([
|
|
2860
2831
|
z6.enum(["mustache", "nunjucks", "none"]),
|
|
@@ -3017,7 +2988,8 @@ var InvokeFunction = FunctionId.and(
|
|
|
3017
2988
|
mode: StreamingMode,
|
|
3018
2989
|
strict: z6.union([z6.boolean(), z6.null()]),
|
|
3019
2990
|
mcp_auth: z6.record(z6.object({ oauth_token: z6.string() }).partial()),
|
|
3020
|
-
overrides: z6.union([z6.object({}).partial().passthrough(), z6.null()])
|
|
2991
|
+
overrides: z6.union([z6.object({}).partial().passthrough(), z6.null()]),
|
|
2992
|
+
endpoint_name: z6.union([z6.string(), z6.null()])
|
|
3021
2993
|
}).partial()
|
|
3022
2994
|
);
|
|
3023
2995
|
var MCPServer = z6.object({
|
|
@@ -3081,6 +3053,24 @@ var Organization = z6.object({
|
|
|
3081
3053
|
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
3082
3054
|
image_rendering_mode: ImageRenderingMode.optional()
|
|
3083
3055
|
});
|
|
3056
|
+
var RetentionObjectType = z6.enum([
|
|
3057
|
+
"project_logs",
|
|
3058
|
+
"experiment",
|
|
3059
|
+
"dataset"
|
|
3060
|
+
]);
|
|
3061
|
+
var OrgAutomation = z6.object({
|
|
3062
|
+
id: z6.string().uuid(),
|
|
3063
|
+
org_id: z6.string().uuid(),
|
|
3064
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
3065
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
3066
|
+
name: z6.string(),
|
|
3067
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
3068
|
+
config: z6.object({
|
|
3069
|
+
event_type: z6.literal("retention"),
|
|
3070
|
+
object_type: RetentionObjectType,
|
|
3071
|
+
retention_days: z6.number().int().gte(0)
|
|
3072
|
+
})
|
|
3073
|
+
});
|
|
3084
3074
|
var ProjectSettings = z6.union([
|
|
3085
3075
|
z6.object({
|
|
3086
3076
|
comparison_key: z6.union([z6.string(), z6.null()]),
|
|
@@ -3107,6 +3097,7 @@ var ProjectSettings = z6.union([
|
|
|
3107
3097
|
z6.null()
|
|
3108
3098
|
]),
|
|
3109
3099
|
disable_realtime_queries: z6.union([z6.boolean(), z6.null()]),
|
|
3100
|
+
monitor_charts_use_metrics_start: z6.union([z6.boolean(), z6.null()]),
|
|
3110
3101
|
default_preprocessor: NullableSavedFunctionId
|
|
3111
3102
|
}).partial(),
|
|
3112
3103
|
z6.null()
|
|
@@ -3121,11 +3112,6 @@ var Project = z6.object({
|
|
|
3121
3112
|
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
3122
3113
|
settings: ProjectSettings.optional()
|
|
3123
3114
|
});
|
|
3124
|
-
var RetentionObjectType = z6.enum([
|
|
3125
|
-
"project_logs",
|
|
3126
|
-
"experiment",
|
|
3127
|
-
"dataset"
|
|
3128
|
-
]);
|
|
3129
3115
|
var TopicAutomationFacetModel = z6.union([
|
|
3130
3116
|
z6.enum(["brain-facet-latest", "brain-facet-1", "brain-facet-2"]),
|
|
3131
3117
|
z6.null()
|
|
@@ -3236,7 +3222,7 @@ var ProjectAutomation = z6.object({
|
|
|
3236
3222
|
z6.object({
|
|
3237
3223
|
event_type: z6.literal("retention"),
|
|
3238
3224
|
object_type: RetentionObjectType,
|
|
3239
|
-
retention_days: z6.number().gte(0)
|
|
3225
|
+
retention_days: z6.number().int().gte(0)
|
|
3240
3226
|
}),
|
|
3241
3227
|
z6.object({
|
|
3242
3228
|
event_type: z6.literal("environment_update"),
|
|
@@ -3408,7 +3394,12 @@ var Prompt = z6.object({
|
|
|
3408
3394
|
metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional(),
|
|
3409
3395
|
function_type: FunctionTypeEnumNullish.optional()
|
|
3410
3396
|
});
|
|
3411
|
-
var PromptOptions = z6.object({
|
|
3397
|
+
var PromptOptions = z6.object({
|
|
3398
|
+
model: z6.string(),
|
|
3399
|
+
params: ModelParams,
|
|
3400
|
+
position: z6.string(),
|
|
3401
|
+
endpoint_name: z6.union([z6.string(), z6.null()])
|
|
3402
|
+
}).partial();
|
|
3412
3403
|
var PromptSessionEvent = z6.object({
|
|
3413
3404
|
id: z6.string(),
|
|
3414
3405
|
_xact_id: z6.string(),
|
|
@@ -3491,7 +3482,8 @@ var RunEval = z6.object({
|
|
|
3491
3482
|
stop_token: z6.union([z6.string(), z6.null()]).optional(),
|
|
3492
3483
|
extra_messages: z6.string().optional(),
|
|
3493
3484
|
tags: z6.array(z6.string()).optional(),
|
|
3494
|
-
mcp_auth: z6.record(z6.object({ oauth_token: z6.string() }).partial()).optional()
|
|
3485
|
+
mcp_auth: z6.record(z6.object({ oauth_token: z6.string() }).partial()).optional(),
|
|
3486
|
+
endpoint_name: z6.union([z6.string(), z6.null()]).optional()
|
|
3495
3487
|
});
|
|
3496
3488
|
var ServiceToken = z6.object({
|
|
3497
3489
|
id: z6.string().uuid(),
|
|
@@ -3501,7 +3493,8 @@ var ServiceToken = z6.object({
|
|
|
3501
3493
|
service_account_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
3502
3494
|
service_account_email: z6.union([z6.string(), z6.null()]).optional(),
|
|
3503
3495
|
service_account_name: z6.union([z6.string(), z6.null()]).optional(),
|
|
3504
|
-
org_id: z6.union([z6.string(), z6.null()]).optional()
|
|
3496
|
+
org_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
3497
|
+
expires_at: z6.union([z6.string(), z6.null()]).optional()
|
|
3505
3498
|
});
|
|
3506
3499
|
var SpanIFrame = z6.object({
|
|
3507
3500
|
id: z6.string().uuid(),
|
|
@@ -3623,6 +3616,13 @@ var ViewOptions = z6.union([
|
|
|
3623
3616
|
}),
|
|
3624
3617
|
z6.null()
|
|
3625
3618
|
]),
|
|
3619
|
+
pointSizeMetric: z6.union([
|
|
3620
|
+
z6.object({
|
|
3621
|
+
type: z6.enum(["none", "score", "metric", "metadata"]),
|
|
3622
|
+
value: z6.string()
|
|
3623
|
+
}),
|
|
3624
|
+
z6.null()
|
|
3625
|
+
]),
|
|
3626
3626
|
xAxisAggregation: z6.union([z6.string(), z6.null()]),
|
|
3627
3627
|
chartAnnotations: z6.union([
|
|
3628
3628
|
z6.array(z6.object({ id: z6.string(), text: z6.string() })),
|
|
@@ -4738,6 +4738,9 @@ var INSTRUMENTATION_NAMES = {
|
|
|
4738
4738
|
BEDROCK_RUNTIME: "bedrock-runtime",
|
|
4739
4739
|
BRAINTRUST_JS_LOGGER: "braintrust-js-logger",
|
|
4740
4740
|
CLAUDE_AGENT_SDK: "claude-agent-sdk",
|
|
4741
|
+
CLOUDFLARE_AI_CHAT: "cloudflare-ai-chat",
|
|
4742
|
+
CLOUDFLARE_AGENTS: "cloudflare-agents",
|
|
4743
|
+
CLOUDFLARE_THINK: "cloudflare-think",
|
|
4741
4744
|
COHERE: "cohere",
|
|
4742
4745
|
CURSOR_SDK: "cursor-sdk",
|
|
4743
4746
|
EVE: "eve",
|
|
@@ -4752,6 +4755,7 @@ var INSTRUMENTATION_NAMES = {
|
|
|
4752
4755
|
LANGSMITH: "langsmith",
|
|
4753
4756
|
MASTRA: "mastra",
|
|
4754
4757
|
MISTRAL: "mistral",
|
|
4758
|
+
OLLAMA: "ollama",
|
|
4755
4759
|
OPENAI: "openai",
|
|
4756
4760
|
OPENAI_AGENTS: "openai-agents",
|
|
4757
4761
|
OPENAI_CODEX: "openai-codex",
|
|
@@ -4763,7 +4767,7 @@ var INSTRUMENTATION_NAMES = {
|
|
|
4763
4767
|
var INTERNAL_SPAN_INSTRUMENTATION_NAME = /* @__PURE__ */ Symbol.for(
|
|
4764
4768
|
"braintrust.spanInstrumentationName"
|
|
4765
4769
|
);
|
|
4766
|
-
var SDK_VERSION = true ? "3.
|
|
4770
|
+
var SDK_VERSION = true ? "3.27.0" : "0.0.0";
|
|
4767
4771
|
function withSpanInstrumentationName(args, instrumentationName) {
|
|
4768
4772
|
return {
|
|
4769
4773
|
...args,
|
|
@@ -4958,12 +4962,13 @@ function applyMaskingToField(maskingFunction, data, fieldName) {
|
|
|
4958
4962
|
var INITIAL_SPAN_WRITE_AS_MERGE = /* @__PURE__ */ Symbol(
|
|
4959
4963
|
"braintrust.initial-span-write-as-merge"
|
|
4960
4964
|
);
|
|
4965
|
+
var INTERNAL_SPAN_CONTEXT = /* @__PURE__ */ Symbol("braintrust.internal-span-context");
|
|
4961
4966
|
var BRAINTRUST_CURRENT_SPAN_STORE = /* @__PURE__ */ Symbol.for(
|
|
4962
4967
|
"braintrust.currentSpanStore"
|
|
4963
4968
|
);
|
|
4964
4969
|
var ContextManager = class {
|
|
4965
4970
|
/**
|
|
4966
|
-
* Returns the value to store in the ALS bound to a
|
|
4971
|
+
* Returns the value to store in the ALS bound to a global hook's start event.
|
|
4967
4972
|
* In default mode this is the Span itself; in OTEL mode it is the OTEL Context
|
|
4968
4973
|
* containing the span so that OTEL's own ALS stores a proper Context object.
|
|
4969
4974
|
*/
|
|
@@ -8229,7 +8234,7 @@ var SpanImpl = class _SpanImpl {
|
|
|
8229
8234
|
start: args.startTime ?? getCurrentUnixTimestamp()
|
|
8230
8235
|
},
|
|
8231
8236
|
context: mergeSpanOriginContext(
|
|
8232
|
-
{ ...callerLocation },
|
|
8237
|
+
{ ...callerLocation, ...args[INTERNAL_SPAN_CONTEXT] },
|
|
8233
8238
|
instrumentationName,
|
|
8234
8239
|
this._state.spanOriginEnvironment
|
|
8235
8240
|
),
|
|
@@ -9181,11 +9186,21 @@ function defineChannels(pkg, channels, options) {
|
|
|
9181
9186
|
const tracingChannel2 = () => isomorph_default.newTracingChannel(
|
|
9182
9187
|
fullChannelName
|
|
9183
9188
|
);
|
|
9189
|
+
const intercept2 = (interceptor) => {
|
|
9190
|
+
const hook = tracingChannel2();
|
|
9191
|
+
return typeof hook.intercept === "function" ? hook.intercept(interceptor) : () => {
|
|
9192
|
+
};
|
|
9193
|
+
};
|
|
9184
9194
|
return [
|
|
9185
9195
|
key,
|
|
9186
9196
|
{
|
|
9187
9197
|
...asyncSpec,
|
|
9188
9198
|
instrumentationName,
|
|
9199
|
+
intercept: intercept2,
|
|
9200
|
+
invoke: (target, thisArg, args, additional) => {
|
|
9201
|
+
const hook = tracingChannel2();
|
|
9202
|
+
return typeof hook.invoke === "function" ? hook.invoke(target, thisArg, args, additional) : Reflect.apply(target, thisArg, args);
|
|
9203
|
+
},
|
|
9189
9204
|
tracingChannel: tracingChannel2,
|
|
9190
9205
|
tracePromise: (fn, context) => tracingChannel2().tracePromise(
|
|
9191
9206
|
fn,
|
|
@@ -9199,11 +9214,21 @@ function defineChannels(pkg, channels, options) {
|
|
|
9199
9214
|
const tracingChannel = () => isomorph_default.newTracingChannel(
|
|
9200
9215
|
fullChannelName
|
|
9201
9216
|
);
|
|
9217
|
+
const intercept = (interceptor) => {
|
|
9218
|
+
const hook = tracingChannel();
|
|
9219
|
+
return typeof hook.intercept === "function" ? hook.intercept(interceptor) : () => {
|
|
9220
|
+
};
|
|
9221
|
+
};
|
|
9202
9222
|
return [
|
|
9203
9223
|
key,
|
|
9204
9224
|
{
|
|
9205
9225
|
...syncSpec,
|
|
9206
9226
|
instrumentationName,
|
|
9227
|
+
intercept,
|
|
9228
|
+
invoke: (target, thisArg, args, additional) => {
|
|
9229
|
+
const hook = tracingChannel();
|
|
9230
|
+
return typeof hook.invoke === "function" ? hook.invoke(target, thisArg, args, additional) : Reflect.apply(target, thisArg, args);
|
|
9231
|
+
},
|
|
9207
9232
|
tracingChannel,
|
|
9208
9233
|
traceSync: (fn, context) => tracingChannel().traceSync(
|
|
9209
9234
|
fn,
|
|
@@ -9723,6 +9748,14 @@ var anthropicChannels = defineChannels(
|
|
|
9723
9748
|
betaMessagesToolRunner: channel({
|
|
9724
9749
|
channelName: "beta.messages.toolRunner",
|
|
9725
9750
|
kind: "sync-stream"
|
|
9751
|
+
}),
|
|
9752
|
+
betaSessionsEventsStream: channel({
|
|
9753
|
+
channelName: "beta.sessions.events.stream",
|
|
9754
|
+
kind: "async"
|
|
9755
|
+
}),
|
|
9756
|
+
betaSessionsThreadsEventsStream: channel({
|
|
9757
|
+
channelName: "beta.sessions.threads.events.stream",
|
|
9758
|
+
kind: "async"
|
|
9726
9759
|
})
|
|
9727
9760
|
},
|
|
9728
9761
|
{ instrumentationName: INSTRUMENTATION_NAMES.ANTHROPIC }
|
|
@@ -9841,7 +9874,40 @@ var anthropicConfigs = [
|
|
|
9841
9874
|
methodName: "toolRunner",
|
|
9842
9875
|
kind: "Sync"
|
|
9843
9876
|
}
|
|
9844
|
-
}
|
|
9877
|
+
},
|
|
9878
|
+
// Managed Agents Sessions event streams are discovered automatically, but
|
|
9879
|
+
// remain passive until the user calls collectAnthropicSession() on the
|
|
9880
|
+
// returned stream.
|
|
9881
|
+
...["mjs", "js"].map(
|
|
9882
|
+
(extension) => ({
|
|
9883
|
+
channelName: anthropicChannels.betaSessionsEventsStream.channelName,
|
|
9884
|
+
module: {
|
|
9885
|
+
name: "@anthropic-ai/sdk",
|
|
9886
|
+
versionRange: ">=0.86.0",
|
|
9887
|
+
filePath: `resources/beta/sessions/events.${extension}`
|
|
9888
|
+
},
|
|
9889
|
+
functionQuery: {
|
|
9890
|
+
className: "Events",
|
|
9891
|
+
methodName: "stream",
|
|
9892
|
+
kind: "Async"
|
|
9893
|
+
}
|
|
9894
|
+
})
|
|
9895
|
+
),
|
|
9896
|
+
...["mjs", "js"].map(
|
|
9897
|
+
(extension) => ({
|
|
9898
|
+
channelName: anthropicChannels.betaSessionsThreadsEventsStream.channelName,
|
|
9899
|
+
module: {
|
|
9900
|
+
name: "@anthropic-ai/sdk",
|
|
9901
|
+
versionRange: ">=0.86.0",
|
|
9902
|
+
filePath: `resources/beta/sessions/threads/events.${extension}`
|
|
9903
|
+
},
|
|
9904
|
+
functionQuery: {
|
|
9905
|
+
className: "Events",
|
|
9906
|
+
methodName: "stream",
|
|
9907
|
+
kind: "Async"
|
|
9908
|
+
}
|
|
9909
|
+
})
|
|
9910
|
+
)
|
|
9845
9911
|
];
|
|
9846
9912
|
|
|
9847
9913
|
// src/instrumentation/plugins/bedrock-runtime-channels.ts
|
|
@@ -9970,6 +10036,104 @@ var claudeAgentSDKConfigs = [
|
|
|
9970
10036
|
}
|
|
9971
10037
|
];
|
|
9972
10038
|
|
|
10039
|
+
// src/instrumentation/plugins/cloudflare-ai-chat-channels.ts
|
|
10040
|
+
var cloudflareAIChatChannels = defineChannels(
|
|
10041
|
+
"@cloudflare/ai-chat",
|
|
10042
|
+
{
|
|
10043
|
+
runExclusiveChatTurn: channel({
|
|
10044
|
+
channelName: "AIChatAgent._runExclusiveChatTurn",
|
|
10045
|
+
kind: "async"
|
|
10046
|
+
}),
|
|
10047
|
+
onChatResponse: channel({
|
|
10048
|
+
channelName: "AIChatAgent.onChatResponse",
|
|
10049
|
+
kind: "sync-stream"
|
|
10050
|
+
})
|
|
10051
|
+
},
|
|
10052
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_AI_CHAT }
|
|
10053
|
+
);
|
|
10054
|
+
|
|
10055
|
+
// src/auto-instrumentations/configs/cloudflare-ai-chat.ts
|
|
10056
|
+
var cloudflareAIChatVersionRange = ">=0.9.0 <0.10.0";
|
|
10057
|
+
var cloudflareAIChatConfigs = [
|
|
10058
|
+
{
|
|
10059
|
+
// AIChatAgent subclasses replace onChatMessage, so there is no stable
|
|
10060
|
+
// public implementation for the transformer to target. This runner is
|
|
10061
|
+
// the narrowest shared boundary around every chat turn; keep the version
|
|
10062
|
+
// range tight because it is an internal method.
|
|
10063
|
+
channelName: cloudflareAIChatChannels.runExclusiveChatTurn.channelName,
|
|
10064
|
+
module: {
|
|
10065
|
+
name: "@cloudflare/ai-chat",
|
|
10066
|
+
versionRange: cloudflareAIChatVersionRange,
|
|
10067
|
+
filePath: "dist/index.js"
|
|
10068
|
+
},
|
|
10069
|
+
functionQuery: {
|
|
10070
|
+
className: "AIChatAgent",
|
|
10071
|
+
methodName: "_runExclusiveChatTurn",
|
|
10072
|
+
kind: "Async"
|
|
10073
|
+
}
|
|
10074
|
+
}
|
|
10075
|
+
];
|
|
10076
|
+
|
|
10077
|
+
// src/instrumentation/plugins/cloudflare-agents-channels.ts
|
|
10078
|
+
var cloudflareAgentsChannels = defineChannels(
|
|
10079
|
+
"agents",
|
|
10080
|
+
{
|
|
10081
|
+
runAgentTool: channel({
|
|
10082
|
+
channelName: "Agent.runAgentTool",
|
|
10083
|
+
kind: "async"
|
|
10084
|
+
})
|
|
10085
|
+
},
|
|
10086
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_AGENTS }
|
|
10087
|
+
);
|
|
10088
|
+
|
|
10089
|
+
// src/auto-instrumentations/configs/cloudflare-agents.ts
|
|
10090
|
+
var cloudflareAgentsVersionRange = ">=0.17.0 <0.18.0";
|
|
10091
|
+
var cloudflareAgentsConfigs = [
|
|
10092
|
+
{
|
|
10093
|
+
channelName: cloudflareAgentsChannels.runAgentTool.channelName,
|
|
10094
|
+
module: {
|
|
10095
|
+
name: "agents",
|
|
10096
|
+
versionRange: cloudflareAgentsVersionRange,
|
|
10097
|
+
filePath: "dist/index.js"
|
|
10098
|
+
},
|
|
10099
|
+
functionQuery: {
|
|
10100
|
+
className: "Agent",
|
|
10101
|
+
methodName: "runAgentTool",
|
|
10102
|
+
kind: "Async"
|
|
10103
|
+
}
|
|
10104
|
+
}
|
|
10105
|
+
];
|
|
10106
|
+
|
|
10107
|
+
// src/instrumentation/plugins/cloudflare-think-channels.ts
|
|
10108
|
+
var cloudflareThinkChannels = defineChannels(
|
|
10109
|
+
"@cloudflare/think",
|
|
10110
|
+
{
|
|
10111
|
+
runInferenceLoop: channel({
|
|
10112
|
+
channelName: "Think.runInferenceLoop",
|
|
10113
|
+
kind: "async"
|
|
10114
|
+
})
|
|
10115
|
+
},
|
|
10116
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.CLOUDFLARE_THINK }
|
|
10117
|
+
);
|
|
10118
|
+
|
|
10119
|
+
// src/auto-instrumentations/configs/cloudflare-think.ts
|
|
10120
|
+
var cloudflareThinkVersionRange = ">=0.13.0 <0.14.0";
|
|
10121
|
+
var cloudflareThinkConfigs = [
|
|
10122
|
+
{
|
|
10123
|
+
channelName: cloudflareThinkChannels.runInferenceLoop.channelName,
|
|
10124
|
+
module: {
|
|
10125
|
+
name: "@cloudflare/think",
|
|
10126
|
+
versionRange: cloudflareThinkVersionRange,
|
|
10127
|
+
filePath: "dist/think.js"
|
|
10128
|
+
},
|
|
10129
|
+
functionQuery: {
|
|
10130
|
+
className: "Think",
|
|
10131
|
+
methodName: "_runInferenceLoop",
|
|
10132
|
+
kind: "Async"
|
|
10133
|
+
}
|
|
10134
|
+
}
|
|
10135
|
+
];
|
|
10136
|
+
|
|
9973
10137
|
// src/instrumentation/plugins/cohere-channels.ts
|
|
9974
10138
|
var cohereChannels = defineChannels(
|
|
9975
10139
|
"cohere-ai",
|
|
@@ -11332,6 +11496,83 @@ var huggingFaceConfigs = [
|
|
|
11332
11496
|
}
|
|
11333
11497
|
];
|
|
11334
11498
|
|
|
11499
|
+
// src/instrumentation/plugins/huggingface-transformers-channels.ts
|
|
11500
|
+
var huggingFaceTransformersChannels = defineChannels(
|
|
11501
|
+
"@huggingface/transformers",
|
|
11502
|
+
{
|
|
11503
|
+
pipeline: channel({
|
|
11504
|
+
channelName: "pipeline",
|
|
11505
|
+
kind: "async"
|
|
11506
|
+
}),
|
|
11507
|
+
pipelineCall: channel({
|
|
11508
|
+
channelName: "pipeline.call",
|
|
11509
|
+
kind: "async"
|
|
11510
|
+
})
|
|
11511
|
+
},
|
|
11512
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.HUGGINGFACE }
|
|
11513
|
+
);
|
|
11514
|
+
|
|
11515
|
+
// src/auto-instrumentations/configs/huggingface-transformers.ts
|
|
11516
|
+
var moduleFiles = [
|
|
11517
|
+
{
|
|
11518
|
+
filePath: "dist/transformers.mjs",
|
|
11519
|
+
versionRange: ">=3.0.0 <3.4.0"
|
|
11520
|
+
},
|
|
11521
|
+
{
|
|
11522
|
+
filePath: "dist/transformers.cjs",
|
|
11523
|
+
versionRange: ">=3.0.0 <3.4.0"
|
|
11524
|
+
},
|
|
11525
|
+
{
|
|
11526
|
+
filePath: "dist/transformers.js",
|
|
11527
|
+
versionRange: ">=3.0.0 <3.4.0"
|
|
11528
|
+
},
|
|
11529
|
+
{
|
|
11530
|
+
filePath: "dist/transformers.node.mjs",
|
|
11531
|
+
versionRange: ">=3.4.0 <5.0.0"
|
|
11532
|
+
},
|
|
11533
|
+
{
|
|
11534
|
+
filePath: "dist/transformers.node.cjs",
|
|
11535
|
+
versionRange: ">=3.4.0 <5.0.0"
|
|
11536
|
+
},
|
|
11537
|
+
{
|
|
11538
|
+
filePath: "dist/transformers.web.js",
|
|
11539
|
+
versionRange: ">=3.4.0 <5.0.0"
|
|
11540
|
+
}
|
|
11541
|
+
];
|
|
11542
|
+
var pipelineClasses = [
|
|
11543
|
+
"TextGenerationPipeline",
|
|
11544
|
+
"Text2TextGenerationPipeline",
|
|
11545
|
+
"FeatureExtractionPipeline",
|
|
11546
|
+
"QuestionAnsweringPipeline"
|
|
11547
|
+
];
|
|
11548
|
+
var huggingFaceTransformersConfigs = moduleFiles.flatMap(({ filePath, versionRange: versionRange2 }) => [
|
|
11549
|
+
{
|
|
11550
|
+
channelName: huggingFaceTransformersChannels.pipeline.channelName,
|
|
11551
|
+
module: {
|
|
11552
|
+
name: "@huggingface/transformers",
|
|
11553
|
+
versionRange: versionRange2,
|
|
11554
|
+
filePath
|
|
11555
|
+
},
|
|
11556
|
+
functionQuery: {
|
|
11557
|
+
functionName: "pipeline",
|
|
11558
|
+
kind: "Async"
|
|
11559
|
+
}
|
|
11560
|
+
},
|
|
11561
|
+
...pipelineClasses.map((className) => ({
|
|
11562
|
+
channelName: huggingFaceTransformersChannels.pipelineCall.channelName,
|
|
11563
|
+
module: {
|
|
11564
|
+
name: "@huggingface/transformers",
|
|
11565
|
+
versionRange: versionRange2,
|
|
11566
|
+
filePath
|
|
11567
|
+
},
|
|
11568
|
+
functionQuery: {
|
|
11569
|
+
className,
|
|
11570
|
+
methodName: "_call",
|
|
11571
|
+
kind: "Async"
|
|
11572
|
+
}
|
|
11573
|
+
}))
|
|
11574
|
+
]);
|
|
11575
|
+
|
|
11335
11576
|
// src/instrumentation/plugins/langchain-channels.ts
|
|
11336
11577
|
var langChainChannels = defineChannels(
|
|
11337
11578
|
"@langchain/core",
|
|
@@ -11776,6 +12017,51 @@ var mistralConfigs = [
|
|
|
11776
12017
|
}
|
|
11777
12018
|
];
|
|
11778
12019
|
|
|
12020
|
+
// src/instrumentation/plugins/ollama-channels.ts
|
|
12021
|
+
var ollamaChannels = defineChannels(
|
|
12022
|
+
"ollama",
|
|
12023
|
+
{
|
|
12024
|
+
chat: channel({
|
|
12025
|
+
channelName: "chat",
|
|
12026
|
+
kind: "async"
|
|
12027
|
+
}),
|
|
12028
|
+
generate: channel({
|
|
12029
|
+
channelName: "generate",
|
|
12030
|
+
kind: "async"
|
|
12031
|
+
}),
|
|
12032
|
+
embed: channel({
|
|
12033
|
+
channelName: "embed",
|
|
12034
|
+
kind: "async"
|
|
12035
|
+
})
|
|
12036
|
+
},
|
|
12037
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.OLLAMA }
|
|
12038
|
+
);
|
|
12039
|
+
|
|
12040
|
+
// src/auto-instrumentations/configs/ollama.ts
|
|
12041
|
+
var methods = [
|
|
12042
|
+
["chat", ollamaChannels.chat.channelName],
|
|
12043
|
+
["generate", ollamaChannels.generate.channelName],
|
|
12044
|
+
["embed", ollamaChannels.embed.channelName]
|
|
12045
|
+
];
|
|
12046
|
+
var implementationFiles = ["dist/browser.mjs", "dist/browser.cjs"];
|
|
12047
|
+
var ollamaConfigs = [
|
|
12048
|
+
...implementationFiles.flatMap(
|
|
12049
|
+
(filePath) => methods.map(([methodName, channelName]) => ({
|
|
12050
|
+
channelName,
|
|
12051
|
+
module: {
|
|
12052
|
+
name: "ollama",
|
|
12053
|
+
versionRange: ">=0.6.0 <0.7.0",
|
|
12054
|
+
filePath
|
|
12055
|
+
},
|
|
12056
|
+
functionQuery: {
|
|
12057
|
+
className: "Ollama",
|
|
12058
|
+
methodName,
|
|
12059
|
+
kind: "Async"
|
|
12060
|
+
}
|
|
12061
|
+
}))
|
|
12062
|
+
)
|
|
12063
|
+
];
|
|
12064
|
+
|
|
11779
12065
|
// src/instrumentation/plugins/openai-agents-channels.ts
|
|
11780
12066
|
var openAIAgentsCoreChannels = defineChannels(
|
|
11781
12067
|
"@openai/agents-core",
|
|
@@ -12185,6 +12471,19 @@ var openRouterConfigs = [
|
|
|
12185
12471
|
kind: "Async"
|
|
12186
12472
|
}
|
|
12187
12473
|
},
|
|
12474
|
+
{
|
|
12475
|
+
channelName: openRouterChannels.betaResponsesSend.channelName,
|
|
12476
|
+
module: {
|
|
12477
|
+
name: "@openrouter/sdk",
|
|
12478
|
+
versionRange: ">=1.1.2 <2.0.0",
|
|
12479
|
+
filePath: "esm/sdk/betaresponses.js"
|
|
12480
|
+
},
|
|
12481
|
+
functionQuery: {
|
|
12482
|
+
className: "BetaResponses",
|
|
12483
|
+
methodName: "send",
|
|
12484
|
+
kind: "Async"
|
|
12485
|
+
}
|
|
12486
|
+
},
|
|
12188
12487
|
{
|
|
12189
12488
|
channelName: openRouterChannels.callModel.channelName,
|
|
12190
12489
|
module: {
|
|
@@ -12350,6 +12649,18 @@ var defaultInstrumentationConfigGroups = [
|
|
|
12350
12649
|
integrations: ["claudeAgentSDK"],
|
|
12351
12650
|
configs: claudeAgentSDKConfigs
|
|
12352
12651
|
},
|
|
12652
|
+
{
|
|
12653
|
+
integrations: ["cloudflareAIChat"],
|
|
12654
|
+
configs: cloudflareAIChatConfigs
|
|
12655
|
+
},
|
|
12656
|
+
{
|
|
12657
|
+
integrations: ["cloudflareAgents"],
|
|
12658
|
+
configs: cloudflareAgentsConfigs
|
|
12659
|
+
},
|
|
12660
|
+
{
|
|
12661
|
+
integrations: ["cloudflareThink"],
|
|
12662
|
+
configs: cloudflareThinkConfigs
|
|
12663
|
+
},
|
|
12353
12664
|
{ integrations: ["cursor", "cursorSDK"], configs: cursorSDKConfigs },
|
|
12354
12665
|
{
|
|
12355
12666
|
integrations: ["openAIAgents"],
|
|
@@ -12359,7 +12670,10 @@ var defaultInstrumentationConfigGroups = [
|
|
|
12359
12670
|
integrations: ["google", "googleGenAI"],
|
|
12360
12671
|
configs: googleGenAIConfigs
|
|
12361
12672
|
},
|
|
12362
|
-
{
|
|
12673
|
+
{
|
|
12674
|
+
integrations: ["huggingface"],
|
|
12675
|
+
configs: [...huggingFaceConfigs, ...huggingFaceTransformersConfigs]
|
|
12676
|
+
},
|
|
12363
12677
|
{
|
|
12364
12678
|
integrations: ["langchain", "langgraph"],
|
|
12365
12679
|
configs: langchainConfigs
|
|
@@ -12371,6 +12685,7 @@ var defaultInstrumentationConfigGroups = [
|
|
|
12371
12685
|
configs: openRouterAgentConfigs
|
|
12372
12686
|
},
|
|
12373
12687
|
{ integrations: ["mistral"], configs: mistralConfigs },
|
|
12688
|
+
{ integrations: ["ollama"], configs: ollamaConfigs },
|
|
12374
12689
|
{ integrations: ["googleADK"], configs: googleADKConfigs },
|
|
12375
12690
|
{ integrations: ["cohere"], configs: cohereConfigs },
|
|
12376
12691
|
{ integrations: ["groq"], configs: groqConfigs },
|
|
@@ -12446,7 +12761,7 @@ var ModulePatch = class {
|
|
|
12446
12761
|
/**
|
|
12447
12762
|
* Patches the Node.js module class method that is responsible for compiling code.
|
|
12448
12763
|
* If a module is found that has an instrumentator, it will transform the code before compiling it
|
|
12449
|
-
* with
|
|
12764
|
+
* with global hook calls.
|
|
12450
12765
|
*/
|
|
12451
12766
|
patch() {
|
|
12452
12767
|
const self = this;
|
|
@@ -12504,103 +12819,11 @@ function resolveModulePrototype() {
|
|
|
12504
12819
|
return NodeModule.prototype;
|
|
12505
12820
|
}
|
|
12506
12821
|
|
|
12507
|
-
// src/auto-instrumentations/patch-tracing-channel.ts
|
|
12508
|
-
function patchTracingChannel(tracingChannelFn) {
|
|
12509
|
-
const dummyChannel = tracingChannelFn("__braintrust_probe__");
|
|
12510
|
-
const TracingChannel = dummyChannel?.constructor;
|
|
12511
|
-
if (!TracingChannel?.prototype) {
|
|
12512
|
-
return;
|
|
12513
|
-
}
|
|
12514
|
-
if (!Object.getOwnPropertyDescriptor(TracingChannel.prototype, "hasSubscribers")) {
|
|
12515
|
-
Object.defineProperty(TracingChannel.prototype, "hasSubscribers", {
|
|
12516
|
-
configurable: true,
|
|
12517
|
-
enumerable: false,
|
|
12518
|
-
get() {
|
|
12519
|
-
return Boolean(
|
|
12520
|
-
this.start?.hasSubscribers || this.end?.hasSubscribers || this.asyncStart?.hasSubscribers || this.asyncEnd?.hasSubscribers || this.error?.hasSubscribers
|
|
12521
|
-
);
|
|
12522
|
-
}
|
|
12523
|
-
});
|
|
12524
|
-
}
|
|
12525
|
-
if (TracingChannel.prototype.tracePromise) {
|
|
12526
|
-
TracingChannel.prototype.tracePromise = function(fn, context = {}, thisArg, ...args) {
|
|
12527
|
-
const start = this.start;
|
|
12528
|
-
const end = this.end;
|
|
12529
|
-
const asyncStart = this.asyncStart;
|
|
12530
|
-
const asyncEnd = this.asyncEnd;
|
|
12531
|
-
const error = this.error;
|
|
12532
|
-
function publishRejected(err) {
|
|
12533
|
-
context.error = err;
|
|
12534
|
-
error?.publish(context);
|
|
12535
|
-
asyncStart?.publish(context);
|
|
12536
|
-
asyncEnd?.publish(context);
|
|
12537
|
-
}
|
|
12538
|
-
function publishResolved(result) {
|
|
12539
|
-
context.result = result;
|
|
12540
|
-
asyncStart?.publish(context);
|
|
12541
|
-
asyncEnd?.publish(context);
|
|
12542
|
-
}
|
|
12543
|
-
return start.runStores(context, () => {
|
|
12544
|
-
try {
|
|
12545
|
-
const result = Reflect.apply(fn, thisArg, args);
|
|
12546
|
-
end?.publish(context);
|
|
12547
|
-
if (result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function") {
|
|
12548
|
-
if (result.constructor === Promise) {
|
|
12549
|
-
return result.then(
|
|
12550
|
-
(res) => {
|
|
12551
|
-
publishResolved(res);
|
|
12552
|
-
return res;
|
|
12553
|
-
},
|
|
12554
|
-
(err) => {
|
|
12555
|
-
publishRejected(err);
|
|
12556
|
-
return Promise.reject(err);
|
|
12557
|
-
}
|
|
12558
|
-
);
|
|
12559
|
-
}
|
|
12560
|
-
void result.then(
|
|
12561
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12562
|
-
(resolved) => {
|
|
12563
|
-
try {
|
|
12564
|
-
publishResolved(resolved);
|
|
12565
|
-
} catch {
|
|
12566
|
-
}
|
|
12567
|
-
},
|
|
12568
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12569
|
-
(err) => {
|
|
12570
|
-
try {
|
|
12571
|
-
publishRejected(err);
|
|
12572
|
-
} catch {
|
|
12573
|
-
}
|
|
12574
|
-
}
|
|
12575
|
-
);
|
|
12576
|
-
return result;
|
|
12577
|
-
}
|
|
12578
|
-
context.result = result;
|
|
12579
|
-
asyncStart?.publish(context);
|
|
12580
|
-
asyncEnd?.publish(context);
|
|
12581
|
-
return result;
|
|
12582
|
-
} catch (err) {
|
|
12583
|
-
context.error = err;
|
|
12584
|
-
error?.publish(context);
|
|
12585
|
-
end?.publish(context);
|
|
12586
|
-
throw err;
|
|
12587
|
-
}
|
|
12588
|
-
});
|
|
12589
|
-
};
|
|
12590
|
-
}
|
|
12591
|
-
}
|
|
12592
|
-
|
|
12593
12822
|
// src/auto-instrumentations/hook.mts
|
|
12594
|
-
var state = globalThis[/* @__PURE__ */ Symbol.for(
|
|
12823
|
+
var state = globalThis[/* @__PURE__ */ Symbol.for(
|
|
12824
|
+
`braintrust.applyAutoInstrumentation.global-hooks.v${GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION}`
|
|
12825
|
+
)] ??= {};
|
|
12595
12826
|
var alreadyApplied = state.applied;
|
|
12596
|
-
if (!alreadyApplied) {
|
|
12597
|
-
const dcPath = ["node", "diagnostics_channel"].join(":");
|
|
12598
|
-
const dc = await import(
|
|
12599
|
-
/* @vite-ignore */
|
|
12600
|
-
dcPath
|
|
12601
|
-
);
|
|
12602
|
-
patchTracingChannel(dc.tracingChannel);
|
|
12603
|
-
}
|
|
12604
12827
|
if (!alreadyApplied) {
|
|
12605
12828
|
const allConfigs = getDefaultAutoInstrumentationConfigs();
|
|
12606
12829
|
const disabled = readDisabledInstrumentationEnvConfig(
|