braintrust 3.9.0 → 3.11.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 (46) hide show
  1. package/dev/dist/index.d.mts +157 -3
  2. package/dev/dist/index.d.ts +157 -3
  3. package/dev/dist/index.js +10819 -7204
  4. package/dev/dist/index.mjs +7458 -3843
  5. package/dist/auto-instrumentations/bundler/esbuild.cjs +686 -1
  6. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  7. package/dist/auto-instrumentations/bundler/rollup.cjs +686 -1
  8. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  9. package/dist/auto-instrumentations/bundler/vite.cjs +686 -1
  10. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  11. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +634 -0
  12. package/dist/auto-instrumentations/bundler/webpack.cjs +686 -1
  13. package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
  14. package/dist/auto-instrumentations/{chunk-KIMMUFAK.mjs → chunk-DIV5TO4S.mjs} +679 -1
  15. package/dist/auto-instrumentations/{chunk-G7F6HZGE.mjs → chunk-G6ZWXGZB.mjs} +19 -2
  16. package/dist/auto-instrumentations/{chunk-ITP7RAUY.mjs → chunk-MWZXZQUO.mjs} +23 -1
  17. package/dist/auto-instrumentations/hook.mjs +793 -11
  18. package/dist/auto-instrumentations/index.cjs +774 -7
  19. package/dist/auto-instrumentations/index.d.mts +18 -1
  20. package/dist/auto-instrumentations/index.d.ts +18 -1
  21. package/dist/auto-instrumentations/index.mjs +102 -8
  22. package/dist/auto-instrumentations/loader/cjs-patch.cjs +26 -1
  23. package/dist/auto-instrumentations/loader/cjs-patch.mjs +28 -1
  24. package/dist/auto-instrumentations/loader/esm-hook.mjs +16 -1
  25. package/dist/browser.d.mts +600 -265
  26. package/dist/browser.d.ts +600 -265
  27. package/dist/browser.js +6171 -1851
  28. package/dist/browser.mjs +6171 -1851
  29. package/dist/cli.js +6417 -2794
  30. package/dist/edge-light.d.mts +1 -1
  31. package/dist/edge-light.d.ts +1 -1
  32. package/dist/edge-light.js +6171 -1851
  33. package/dist/edge-light.mjs +6171 -1851
  34. package/dist/index.d.mts +613 -278
  35. package/dist/index.d.ts +613 -278
  36. package/dist/index.js +6507 -2187
  37. package/dist/index.mjs +6171 -1851
  38. package/dist/instrumentation/index.d.mts +19 -0
  39. package/dist/instrumentation/index.d.ts +19 -0
  40. package/dist/instrumentation/index.js +10265 -6841
  41. package/dist/instrumentation/index.mjs +10265 -6841
  42. package/dist/workerd.d.mts +1 -1
  43. package/dist/workerd.d.ts +1 -1
  44. package/dist/workerd.js +6171 -1851
  45. package/dist/workerd.mjs +6171 -1851
  46. package/package.json +16 -22
@@ -14,6 +14,8 @@ export { InstrumentationConfig } from '@apm-js-collab/code-transformer';
14
14
  */
15
15
  declare const openaiConfigs: InstrumentationConfig[];
16
16
 
17
+ declare const openAICodexConfigs: InstrumentationConfig[];
18
+
17
19
  /**
18
20
  * Instrumentation configurations for the Anthropic SDK.
19
21
  *
@@ -53,6 +55,8 @@ declare const aiSDKConfigs: InstrumentationConfig[];
53
55
  */
54
56
  declare const claudeAgentSDKConfigs: InstrumentationConfig[];
55
57
 
58
+ declare const cursorSDKConfigs: InstrumentationConfig[];
59
+
56
60
  /**
57
61
  * Instrumentation configurations for the Google GenAI SDK.
58
62
  *
@@ -89,4 +93,17 @@ declare const googleADKConfigs: InstrumentationConfig[];
89
93
 
90
94
  declare const cohereConfigs: InstrumentationConfig[];
91
95
 
92
- export { aiSDKConfigs, anthropicConfigs, claudeAgentSDKConfigs, cohereConfigs, googleADKConfigs, googleGenAIConfigs, huggingFaceConfigs, mistralConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs };
96
+ declare const groqConfigs: InstrumentationConfig[];
97
+
98
+ /**
99
+ * Instrumentation configurations for Genkit's JavaScript SDK.
100
+ *
101
+ * Genkit's public instance methods live on the GenkitAI base class in
102
+ * @genkit-ai/ai. The top-level `genkit` package subclasses that class, so
103
+ * targeting these methods instruments regular `genkit({ ... })` instances.
104
+ */
105
+ declare const genkitConfigs: InstrumentationConfig[];
106
+
107
+ declare const gitHubCopilotConfigs: InstrumentationConfig[];
108
+
109
+ export { aiSDKConfigs, anthropicConfigs, claudeAgentSDKConfigs, cohereConfigs, cursorSDKConfigs, genkitConfigs, gitHubCopilotConfigs, googleADKConfigs, googleGenAIConfigs, groqConfigs, huggingFaceConfigs, mistralConfigs, openAICodexConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs };
@@ -14,6 +14,8 @@ export { InstrumentationConfig } from '@apm-js-collab/code-transformer';
14
14
  */
15
15
  declare const openaiConfigs: InstrumentationConfig[];
16
16
 
17
+ declare const openAICodexConfigs: InstrumentationConfig[];
18
+
17
19
  /**
18
20
  * Instrumentation configurations for the Anthropic SDK.
19
21
  *
@@ -53,6 +55,8 @@ declare const aiSDKConfigs: InstrumentationConfig[];
53
55
  */
54
56
  declare const claudeAgentSDKConfigs: InstrumentationConfig[];
55
57
 
58
+ declare const cursorSDKConfigs: InstrumentationConfig[];
59
+
56
60
  /**
57
61
  * Instrumentation configurations for the Google GenAI SDK.
58
62
  *
@@ -89,4 +93,17 @@ declare const googleADKConfigs: InstrumentationConfig[];
89
93
 
90
94
  declare const cohereConfigs: InstrumentationConfig[];
91
95
 
92
- export { aiSDKConfigs, anthropicConfigs, claudeAgentSDKConfigs, cohereConfigs, googleADKConfigs, googleGenAIConfigs, huggingFaceConfigs, mistralConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs };
96
+ declare const groqConfigs: InstrumentationConfig[];
97
+
98
+ /**
99
+ * Instrumentation configurations for Genkit's JavaScript SDK.
100
+ *
101
+ * Genkit's public instance methods live on the GenkitAI base class in
102
+ * @genkit-ai/ai. The top-level `genkit` package subclasses that class, so
103
+ * targeting these methods instruments regular `genkit({ ... })` instances.
104
+ */
105
+ declare const genkitConfigs: InstrumentationConfig[];
106
+
107
+ declare const gitHubCopilotConfigs: InstrumentationConfig[];
108
+
109
+ export { aiSDKConfigs, anthropicConfigs, claudeAgentSDKConfigs, cohereConfigs, cursorSDKConfigs, genkitConfigs, gitHubCopilotConfigs, googleADKConfigs, googleGenAIConfigs, groqConfigs, huggingFaceConfigs, mistralConfigs, openAICodexConfigs, openRouterAgentConfigs, openRouterConfigs, openaiConfigs };
@@ -4,14 +4,19 @@ import {
4
4
  channel,
5
5
  claudeAgentSDKConfigs,
6
6
  cohereConfigs,
7
+ cursorSDKConfigs,
7
8
  defineChannels,
9
+ genkitConfigs,
10
+ gitHubCopilotConfigs,
8
11
  googleGenAIConfigs,
12
+ groqConfigs,
9
13
  huggingFaceConfigs,
10
14
  mistralConfigs,
15
+ openAICodexConfigs,
11
16
  openRouterAgentConfigs,
12
17
  openRouterConfigs,
13
18
  openaiConfigs
14
- } from "./chunk-KIMMUFAK.mjs";
19
+ } from "./chunk-DIV5TO4S.mjs";
15
20
 
16
21
  // src/instrumentation/plugins/google-adk-channels.ts
17
22
  var googleADKChannels = defineChannels("@google/adk", {
@@ -31,7 +36,8 @@ var googleADKChannels = defineChannels("@google/adk", {
31
36
 
32
37
  // src/auto-instrumentations/configs/google-adk.ts
33
38
  var googleADKVersionRange = ">=0.1.0";
34
- var googleADKBundledIndexVersionRange = ">=0.6.1 <0.7.0";
39
+ var googleADKBundledIndexV06VersionRange = ">=0.6.1 <0.7.0";
40
+ var googleADKBundledIndexV1VersionRange = ">=1.0.0 <2.0.0";
35
41
  var googleADKConfigs = [
36
42
  // --- Runner.runAsync --- async generator, kind "Sync" + sync-stream channel
37
43
  // Runner.runAsync — ESM individual module file
@@ -57,7 +63,7 @@ var googleADKConfigs = [
57
63
  channelName: googleADKChannels.runnerRunAsync.channelName,
58
64
  module: {
59
65
  name: "@google/adk",
60
- versionRange: googleADKBundledIndexVersionRange,
66
+ versionRange: googleADKBundledIndexV06VersionRange,
61
67
  filePath: "dist/cjs/index.js"
62
68
  },
63
69
  functionQuery: {
@@ -70,7 +76,7 @@ var googleADKConfigs = [
70
76
  channelName: googleADKChannels.runnerRunAsync.channelName,
71
77
  module: {
72
78
  name: "@google/adk",
73
- versionRange: googleADKBundledIndexVersionRange,
79
+ versionRange: googleADKBundledIndexV06VersionRange,
74
80
  filePath: "dist/esm/index.js"
75
81
  },
76
82
  functionQuery: {
@@ -79,6 +85,34 @@ var googleADKConfigs = [
79
85
  index: 11
80
86
  }
81
87
  },
88
+ // The 1.x bundled entrypoints still inline the runtime into index.js, but
89
+ // the minified method order changed. These indices are verified against 1.0.0.
90
+ {
91
+ channelName: googleADKChannels.runnerRunAsync.channelName,
92
+ module: {
93
+ name: "@google/adk",
94
+ versionRange: googleADKBundledIndexV1VersionRange,
95
+ filePath: "dist/cjs/index.js"
96
+ },
97
+ functionQuery: {
98
+ methodName: "runAsync",
99
+ kind: "Sync",
100
+ index: 12
101
+ }
102
+ },
103
+ {
104
+ channelName: googleADKChannels.runnerRunAsync.channelName,
105
+ module: {
106
+ name: "@google/adk",
107
+ versionRange: googleADKBundledIndexV1VersionRange,
108
+ filePath: "dist/esm/index.js"
109
+ },
110
+ functionQuery: {
111
+ methodName: "runAsync",
112
+ kind: "Sync",
113
+ index: 12
114
+ }
115
+ },
82
116
  // --- BaseAgent.runAsync --- async generator, kind "Sync" + sync-stream channel
83
117
  // BaseAgent.runAsync — ESM individual module file
84
118
  {
@@ -103,7 +137,35 @@ var googleADKConfigs = [
103
137
  channelName: googleADKChannels.agentRunAsync.channelName,
104
138
  module: {
105
139
  name: "@google/adk",
106
- versionRange: googleADKBundledIndexVersionRange,
140
+ versionRange: googleADKBundledIndexV06VersionRange,
141
+ filePath: "dist/cjs/index.js"
142
+ },
143
+ functionQuery: {
144
+ methodName: "runAsync",
145
+ kind: "Sync",
146
+ index: 0
147
+ }
148
+ },
149
+ {
150
+ channelName: googleADKChannels.agentRunAsync.channelName,
151
+ module: {
152
+ name: "@google/adk",
153
+ versionRange: googleADKBundledIndexV06VersionRange,
154
+ filePath: "dist/esm/index.js"
155
+ },
156
+ functionQuery: {
157
+ methodName: "runAsync",
158
+ kind: "Sync",
159
+ index: 0
160
+ }
161
+ },
162
+ // The 1.x bundled entrypoints keep BaseAgent.runAsync as the first bundled
163
+ // async-generator runAsync method in file order.
164
+ {
165
+ channelName: googleADKChannels.agentRunAsync.channelName,
166
+ module: {
167
+ name: "@google/adk",
168
+ versionRange: googleADKBundledIndexV1VersionRange,
107
169
  filePath: "dist/cjs/index.js"
108
170
  },
109
171
  functionQuery: {
@@ -116,7 +178,7 @@ var googleADKConfigs = [
116
178
  channelName: googleADKChannels.agentRunAsync.channelName,
117
179
  module: {
118
180
  name: "@google/adk",
119
- versionRange: googleADKBundledIndexVersionRange,
181
+ versionRange: googleADKBundledIndexV1VersionRange,
120
182
  filePath: "dist/esm/index.js"
121
183
  },
122
184
  functionQuery: {
@@ -149,7 +211,34 @@ var googleADKConfigs = [
149
211
  channelName: googleADKChannels.toolRunAsync.channelName,
150
212
  module: {
151
213
  name: "@google/adk",
152
- versionRange: googleADKBundledIndexVersionRange,
214
+ versionRange: googleADKBundledIndexV06VersionRange,
215
+ filePath: "dist/cjs/index.js"
216
+ },
217
+ functionQuery: {
218
+ methodName: "runAsync",
219
+ kind: "Async",
220
+ index: 1
221
+ }
222
+ },
223
+ {
224
+ channelName: googleADKChannels.toolRunAsync.channelName,
225
+ module: {
226
+ name: "@google/adk",
227
+ versionRange: googleADKBundledIndexV06VersionRange,
228
+ filePath: "dist/esm/index.js"
229
+ },
230
+ functionQuery: {
231
+ methodName: "runAsync",
232
+ kind: "Async",
233
+ index: 1
234
+ }
235
+ },
236
+ // The 1.x bundle moves FunctionTool.runAsync behind one helper method.
237
+ {
238
+ channelName: googleADKChannels.toolRunAsync.channelName,
239
+ module: {
240
+ name: "@google/adk",
241
+ versionRange: googleADKBundledIndexV1VersionRange,
153
242
  filePath: "dist/cjs/index.js"
154
243
  },
155
244
  functionQuery: {
@@ -162,7 +251,7 @@ var googleADKConfigs = [
162
251
  channelName: googleADKChannels.toolRunAsync.channelName,
163
252
  module: {
164
253
  name: "@google/adk",
165
- versionRange: googleADKBundledIndexVersionRange,
254
+ versionRange: googleADKBundledIndexV1VersionRange,
166
255
  filePath: "dist/esm/index.js"
167
256
  },
168
257
  functionQuery: {
@@ -177,10 +266,15 @@ export {
177
266
  anthropicConfigs,
178
267
  claudeAgentSDKConfigs,
179
268
  cohereConfigs,
269
+ cursorSDKConfigs,
270
+ genkitConfigs,
271
+ gitHubCopilotConfigs,
180
272
  googleADKConfigs,
181
273
  googleGenAIConfigs,
274
+ groqConfigs,
182
275
  huggingFaceConfigs,
183
276
  mistralConfigs,
277
+ openAICodexConfigs,
184
278
  openRouterAgentConfigs,
185
279
  openRouterConfigs,
186
280
  openaiConfigs
@@ -93,6 +93,27 @@ function getPackageName(baseDir) {
93
93
  return void 0;
94
94
  }
95
95
 
96
+ // src/auto-instrumentations/loader/openai-api-promise-patch.ts
97
+ var OPENAI_API_PROMISE_PATCH = `
98
+ ;(function __btPatchAPIPromise() {
99
+ if (typeof APIPromise === "undefined" || APIPromise.prototype.__btParsePatched) return;
100
+ APIPromise.prototype.__btParsePatched = true;
101
+ var _origThen = APIPromise.prototype.then;
102
+ APIPromise.prototype.then = function __btThen(onfulfilled, onrejected) {
103
+ if (!this.__btParseWrapped && Object.prototype.hasOwnProperty.call(this, "parseResponse")) {
104
+ this.__btParseWrapped = true;
105
+ var _origParse = this.parseResponse;
106
+ var _cached;
107
+ this.parseResponse = function() {
108
+ if (!_cached) _cached = _origParse.apply(this, arguments);
109
+ return _cached;
110
+ };
111
+ }
112
+ return _origThen.call(this, onfulfilled, onrejected);
113
+ };
114
+ })();
115
+ `;
116
+
96
117
  // src/auto-instrumentations/loader/cjs-patch.ts
97
118
  var ModulePatch = class {
98
119
  packages;
@@ -124,8 +145,12 @@ var ModulePatch = class {
124
145
  if (!self.packages.has(packageName)) {
125
146
  return self.originalCompile.apply(this, args);
126
147
  }
127
- const version = getPackageVersion(resolvedModule.basedir);
128
148
  const normalizedModulePath = resolvedModule.path.replace(/\\/g, "/");
149
+ if (packageName === "openai" && normalizedModulePath.includes("api-promise")) {
150
+ args[0] = content + OPENAI_API_PROMISE_PATCH;
151
+ return self.originalCompile.apply(this, args);
152
+ }
153
+ const version = getPackageVersion(resolvedModule.basedir);
129
154
  const transformer = self.instrumentator.getTransformer(
130
155
  packageName,
131
156
  version,
@@ -10,6 +10,29 @@ import {
10
10
  import * as NodeModule from "module";
11
11
  import { sep } from "path";
12
12
  import moduleDetailsFromPath from "module-details-from-path";
13
+
14
+ // src/auto-instrumentations/loader/openai-api-promise-patch.ts
15
+ var OPENAI_API_PROMISE_PATCH = `
16
+ ;(function __btPatchAPIPromise() {
17
+ if (typeof APIPromise === "undefined" || APIPromise.prototype.__btParsePatched) return;
18
+ APIPromise.prototype.__btParsePatched = true;
19
+ var _origThen = APIPromise.prototype.then;
20
+ APIPromise.prototype.then = function __btThen(onfulfilled, onrejected) {
21
+ if (!this.__btParseWrapped && Object.prototype.hasOwnProperty.call(this, "parseResponse")) {
22
+ this.__btParseWrapped = true;
23
+ var _origParse = this.parseResponse;
24
+ var _cached;
25
+ this.parseResponse = function() {
26
+ if (!_cached) _cached = _origParse.apply(this, arguments);
27
+ return _cached;
28
+ };
29
+ }
30
+ return _origThen.call(this, onfulfilled, onrejected);
31
+ };
32
+ })();
33
+ `;
34
+
35
+ // src/auto-instrumentations/loader/cjs-patch.ts
13
36
  var ModulePatch = class {
14
37
  packages;
15
38
  instrumentator;
@@ -40,8 +63,12 @@ var ModulePatch = class {
40
63
  if (!self.packages.has(packageName)) {
41
64
  return self.originalCompile.apply(this, args);
42
65
  }
43
- const version = getPackageVersion(resolvedModule.basedir);
44
66
  const normalizedModulePath = resolvedModule.path.replace(/\\/g, "/");
67
+ if (packageName === "openai" && normalizedModulePath.includes("api-promise")) {
68
+ args[0] = content + OPENAI_API_PROMISE_PATCH;
69
+ return self.originalCompile.apply(this, args);
70
+ }
71
+ const version = getPackageVersion(resolvedModule.basedir);
45
72
  const transformer = self.instrumentator.getTransformer(
46
73
  packageName,
47
74
  version,
@@ -1,7 +1,8 @@
1
1
  import {
2
+ OPENAI_API_PROMISE_PATCH,
2
3
  getPackageName,
3
4
  getPackageVersion
4
- } from "../chunk-ITP7RAUY.mjs";
5
+ } from "../chunk-MWZXZQUO.mjs";
5
6
 
6
7
  // src/auto-instrumentations/loader/esm-hook.mts
7
8
  import { readFile } from "fs/promises";
@@ -42,8 +43,22 @@ async function resolve(specifier, context, nextResolve) {
42
43
  }
43
44
  return url;
44
45
  }
46
+ function isOpenAIApiPromise(url) {
47
+ return url.includes("/openai") && url.includes("api-promise");
48
+ }
45
49
  async function load(url, context, nextLoad) {
46
50
  const result = await nextLoad(url, context);
51
+ if (isOpenAIApiPromise(url)) {
52
+ if (result.format === "commonjs") {
53
+ const parsedUrl = new URL(result.responseURL ?? url);
54
+ result.source ??= await readFile(parsedUrl);
55
+ }
56
+ if (result.source) {
57
+ result.source = result.source.toString("utf8") + OPENAI_API_PROMISE_PATCH;
58
+ result.shortCircuit = true;
59
+ }
60
+ return result;
61
+ }
47
62
  if (!transformers.has(url)) {
48
63
  return result;
49
64
  }