braintrust 3.10.0 → 3.12.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 (78) hide show
  1. package/README.md +8 -8
  2. package/dev/dist/index.d.mts +51 -3
  3. package/dev/dist/index.d.ts +51 -3
  4. package/dev/dist/index.js +13138 -8915
  5. package/dev/dist/index.mjs +13015 -8792
  6. package/dist/apply-auto-instrumentation.browser.d.mts +2 -0
  7. package/dist/apply-auto-instrumentation.browser.d.ts +2 -0
  8. package/dist/apply-auto-instrumentation.browser.js +18 -0
  9. package/dist/apply-auto-instrumentation.browser.mjs +0 -0
  10. package/dist/apply-auto-instrumentation.d.mts +2 -0
  11. package/dist/apply-auto-instrumentation.d.ts +2 -0
  12. package/dist/apply-auto-instrumentation.js +2534 -0
  13. package/dist/apply-auto-instrumentation.mjs +2534 -0
  14. package/dist/auto-instrumentations/bundler/esbuild.cjs +1775 -737
  15. package/dist/auto-instrumentations/bundler/esbuild.d.mts +9 -5
  16. package/dist/auto-instrumentations/bundler/esbuild.d.ts +9 -5
  17. package/dist/auto-instrumentations/bundler/esbuild.mjs +10 -2
  18. package/dist/auto-instrumentations/bundler/next.cjs +3268 -0
  19. package/dist/auto-instrumentations/bundler/next.d.mts +3 -0
  20. package/dist/auto-instrumentations/bundler/next.d.ts +3 -0
  21. package/dist/auto-instrumentations/bundler/next.mjs +189 -0
  22. package/dist/auto-instrumentations/bundler/rollup.cjs +1775 -737
  23. package/dist/auto-instrumentations/bundler/rollup.d.mts +9 -5
  24. package/dist/auto-instrumentations/bundler/rollup.d.ts +9 -5
  25. package/dist/auto-instrumentations/bundler/rollup.mjs +10 -2
  26. package/dist/auto-instrumentations/bundler/vite.cjs +1775 -737
  27. package/dist/auto-instrumentations/bundler/vite.d.mts +9 -5
  28. package/dist/auto-instrumentations/bundler/vite.d.ts +9 -5
  29. package/dist/auto-instrumentations/bundler/vite.mjs +10 -2
  30. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1713 -690
  31. package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +3 -3
  32. package/dist/auto-instrumentations/bundler/webpack.cjs +1775 -737
  33. package/dist/auto-instrumentations/bundler/webpack.d.mts +9 -5
  34. package/dist/auto-instrumentations/bundler/webpack.d.ts +9 -5
  35. package/dist/auto-instrumentations/bundler/webpack.mjs +6 -6
  36. package/dist/auto-instrumentations/{chunk-GZNXBBPU.mjs → chunk-2DPA74KK.mjs} +856 -5
  37. package/dist/auto-instrumentations/chunk-73BZUKVI.mjs +300 -0
  38. package/dist/auto-instrumentations/chunk-AFXRW7I7.mjs +18 -0
  39. package/dist/auto-instrumentations/{chunk-ITP7RAUY.mjs → chunk-MWZXZQUO.mjs} +23 -1
  40. package/dist/auto-instrumentations/hook.mjs +1912 -1125
  41. package/dist/auto-instrumentations/index.cjs +615 -4
  42. package/dist/auto-instrumentations/index.d.mts +18 -1
  43. package/dist/auto-instrumentations/index.d.ts +18 -1
  44. package/dist/auto-instrumentations/index.mjs +12 -247
  45. package/dist/auto-instrumentations/loader/cjs-patch.cjs +26 -1
  46. package/dist/auto-instrumentations/loader/cjs-patch.mjs +28 -1
  47. package/dist/auto-instrumentations/loader/esm-hook.mjs +35 -3
  48. package/dist/auto-instrumentations/plugin-D7nDswtC.d.mts +44 -0
  49. package/dist/auto-instrumentations/plugin-D7nDswtC.d.ts +44 -0
  50. package/dist/browser.d.mts +577 -287
  51. package/dist/browser.d.ts +577 -287
  52. package/dist/browser.js +10221 -5524
  53. package/dist/browser.mjs +10221 -5524
  54. package/dist/chunk-BW4DF4CY.js +816 -0
  55. package/dist/chunk-MSLBGITU.mjs +816 -0
  56. package/dist/cli.js +13143 -8892
  57. package/dist/edge-light.d.mts +1 -1
  58. package/dist/edge-light.d.ts +1 -1
  59. package/dist/edge-light.js +10221 -5524
  60. package/dist/edge-light.mjs +10221 -5524
  61. package/dist/index.d.mts +590 -300
  62. package/dist/index.d.ts +590 -300
  63. package/dist/index.js +9309 -5371
  64. package/dist/index.mjs +10340 -6402
  65. package/dist/instrumentation/index.d.mts +7863 -39
  66. package/dist/instrumentation/index.d.ts +7863 -39
  67. package/dist/instrumentation/index.js +10263 -6034
  68. package/dist/instrumentation/index.mjs +10262 -6034
  69. package/dist/workerd.d.mts +1 -1
  70. package/dist/workerd.d.ts +1 -1
  71. package/dist/workerd.js +10221 -5524
  72. package/dist/workerd.mjs +10221 -5524
  73. package/package.json +33 -19
  74. package/util/dist/index.js +6 -0
  75. package/util/dist/index.mjs +6 -0
  76. package/dist/auto-instrumentations/chunk-XWEQQOQH.mjs +0 -106
  77. package/dist/auto-instrumentations/plugin-Df3qKIl2.d.mts +0 -22
  78. package/dist/auto-instrumentations/plugin-Df3qKIl2.d.ts +0 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braintrust",
3
- "version": "3.10.0",
3
+ "version": "3.12.0",
4
4
  "description": "SDK for integrating Braintrust",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,6 +11,7 @@
11
11
  "main": "./dist/index.js",
12
12
  "module": "./dist/index.mjs",
13
13
  "types": "./dist/index.d.ts",
14
+ "sideEffects": true,
14
15
  "browser": {
15
16
  "./dist/index.js": "./dist/browser.js",
16
17
  "./dist/index.d.ts": "./dist/browser.d.ts",
@@ -50,6 +51,19 @@
50
51
  "require": "./dist/browser.js",
51
52
  "default": "./dist/browser.mjs"
52
53
  },
54
+ "./apply-auto-instrumentation": {
55
+ "types": "./dist/apply-auto-instrumentation.d.ts",
56
+ "edge-light": "./dist/apply-auto-instrumentation.browser.mjs",
57
+ "workerd": "./dist/apply-auto-instrumentation.browser.mjs",
58
+ "node": {
59
+ "import": "./dist/apply-auto-instrumentation.mjs",
60
+ "require": "./dist/apply-auto-instrumentation.js"
61
+ },
62
+ "browser": "./dist/apply-auto-instrumentation.browser.mjs",
63
+ "import": "./dist/apply-auto-instrumentation.mjs",
64
+ "require": "./dist/apply-auto-instrumentation.js",
65
+ "default": "./dist/apply-auto-instrumentation.mjs"
66
+ },
53
67
  "./node": {
54
68
  "types": "./dist/index.d.ts",
55
69
  "import": "./dist/index.mjs",
@@ -87,6 +101,12 @@
87
101
  "module": "./dist/auto-instrumentations/bundler/webpack.mjs",
88
102
  "require": "./dist/auto-instrumentations/bundler/webpack.cjs"
89
103
  },
104
+ "./next": {
105
+ "types": "./dist/auto-instrumentations/bundler/next.d.ts",
106
+ "import": "./dist/auto-instrumentations/bundler/next.mjs",
107
+ "module": "./dist/auto-instrumentations/bundler/next.mjs",
108
+ "require": "./dist/auto-instrumentations/bundler/next.cjs"
109
+ },
90
110
  "./webpack-loader": {
91
111
  "types": "./dist/auto-instrumentations/bundler/webpack-loader.d.ts",
92
112
  "require": "./dist/auto-instrumentations/bundler/webpack-loader.cjs"
@@ -118,7 +138,8 @@
118
138
  "test": "vitest run --exclude \"src/wrappers/**/*.test.ts\" --exclude \"src/otel/**/*.test.ts\" --exclude \"smoke/**/*.test.ts\" --exclude \"src/zod/**/*.test.ts\" --exclude \"tests/api-compatibility/**\"",
119
139
  "test:core": "pnpm prune && pnpm test",
120
140
  "test:checks": "pnpm run test:core && pnpm run test:vitest",
121
- "test:external": "pnpm run test:external:openai && pnpm run test:external:anthropic && pnpm run test:external:google-genai && pnpm run test:external:ai-sdk && pnpm run test:external:claude-agent-sdk",
141
+ "test:external": "pnpm run test:external:sequential && node scripts/run-parallel.mjs test:external:ai-sdk-v5 test:external:ai-sdk-v6 test:external:claude-agent-sdk",
142
+ "test:external:sequential": "pnpm run test:external:openai && pnpm run test:external:anthropic && pnpm run test:external:google-genai",
122
143
  "test:external:openai": "bash scripts/test-provider.sh test:openai openai",
123
144
  "test:external:anthropic": "bash scripts/test-provider.sh test:anthropic @anthropic-ai/sdk",
124
145
  "test:external:google-genai": "bash scripts/test-provider.sh test:google-genai @google/genai",
@@ -148,7 +169,8 @@
148
169
  "playground": "tsx playground.ts",
149
170
  "playground:auto": "mkdir -p .context && pnpm exec esbuild playground.ts --platform=node --format=esm --outfile=.context/playground.auto.mjs && node --import ./dist/auto-instrumentations/hook.mjs ./.context/playground.auto.mjs",
150
171
  "playground:cli:push": "node dist/cli.js push playground.ts",
151
- "playground:cli:eval": "node dist/cli.js eval playground.ts"
172
+ "playground:cli:eval": "node dist/cli.js eval playground.ts",
173
+ "yalc:publish": "yalc publish"
152
174
  },
153
175
  "author": "",
154
176
  "license": "MIT",
@@ -157,9 +179,7 @@
157
179
  "@anthropic-ai/sdk": "^0.60.0",
158
180
  "@google/adk": "^0.6.1",
159
181
  "@google/genai": "^1.25.0",
160
- "@jest/globals": "^29.7.0",
161
182
  "@nodelib/fs.walk": "^1.2.8",
162
- "@openai/agents": "^0.0.14",
163
183
  "@types/argparse": "^2.0.14",
164
184
  "@types/async": "^3.2.24",
165
185
  "@types/cli-progress": "^3.11.5",
@@ -179,13 +199,10 @@
179
199
  "autoevals": "^0.0.131",
180
200
  "cross-env": "^7.0.3",
181
201
  "eslint-plugin-node-import": "^1.0.5",
182
- "jiti": "^2.6.1",
183
202
  "openai": "6.25.0",
184
- "openapi-zod-client": "^1.18.3",
185
- "rollup": "^4.28.1",
203
+ "rollup": "^4.60.3",
186
204
  "tar": "^7.5.2",
187
205
  "tinybench": "^4.0.1",
188
- "ts-jest": "^29.1.4",
189
206
  "tsup": "^8.5.1",
190
207
  "tsx": "^4.21.0",
191
208
  "typedoc": "^0.25.13",
@@ -193,34 +210,31 @@
193
210
  "typescript": "5.4.4",
194
211
  "vite": "^6.4.2",
195
212
  "vite-tsconfig-paths": "^4.3.2",
196
- "vitest": "^4.1.2",
197
- "webpack": "^5.97.1",
213
+ "vitest": "4.1.5",
214
+ "webpack": "^5.106.2",
198
215
  "zod": "^3.25.34"
199
216
  },
200
217
  "dependencies": {
201
- "@ai-sdk/provider": "^1.1.3",
202
218
  "@apm-js-collab/code-transformer": "^0.12.0",
203
219
  "@next/env": "^14.2.3",
204
220
  "@vercel/functions": "^1.0.2",
205
- "ajv": "^8.17.1",
221
+ "ajv": "^8.20.0",
206
222
  "argparse": "^2.0.1",
207
- "boxen": "^8.0.1",
208
- "chalk": "^4.1.2",
209
223
  "cli-progress": "^3.12.0",
210
224
  "cli-table3": "^0.6.5",
211
225
  "cors": "^2.8.5",
212
226
  "dc-browser": "^1.0.4",
213
227
  "dotenv": "^16.4.5",
214
- "esbuild": "^0.27.0",
228
+ "esbuild": "0.28.0",
215
229
  "eventsource-parser": "^1.1.2",
216
- "express": "^4.21.2",
230
+ "express": "^5.2.1",
217
231
  "graceful-fs": "^4.2.11",
218
232
  "http-errors": "^2.0.0",
219
- "minimatch": "^9.0.3",
233
+ "minimatch": "^10.2.5",
220
234
  "module-details-from-path": "^1.0.4",
221
235
  "mustache": "^4.2.0",
222
236
  "pluralize": "^8.0.0",
223
- "simple-git": "^3.21.0",
237
+ "simple-git": "^3.36.0",
224
238
  "source-map": "^0.7.4",
225
239
  "termi-link": "^1.0.1",
226
240
  "unplugin": "^2.3.5",
@@ -688,6 +688,11 @@ function isPromiseLike(value) {
688
688
 
689
689
  // util/object_util.ts
690
690
  var SET_UNION_FIELDS = /* @__PURE__ */ new Set(["tags"]);
691
+ var FORBIDDEN_MERGE_KEYS = /* @__PURE__ */ new Set([
692
+ "__proto__",
693
+ "constructor",
694
+ "prototype"
695
+ ]);
691
696
  function mergeDictsWithPaths({
692
697
  mergeInto,
693
698
  mergeFrom,
@@ -710,6 +715,7 @@ function mergeDictsWithPathsHelper({
710
715
  mergePaths
711
716
  }) {
712
717
  Object.entries(mergeFrom).forEach(([k, mergeFromV]) => {
718
+ if (FORBIDDEN_MERGE_KEYS.has(k)) return;
713
719
  const fullPath = path.concat([k]);
714
720
  const fullPathSerialized = JSON.stringify(fullPath);
715
721
  const mergeIntoV = recordFind(mergeInto, k);
@@ -688,6 +688,11 @@ function isPromiseLike(value) {
688
688
 
689
689
  // util/object_util.ts
690
690
  var SET_UNION_FIELDS = /* @__PURE__ */ new Set(["tags"]);
691
+ var FORBIDDEN_MERGE_KEYS = /* @__PURE__ */ new Set([
692
+ "__proto__",
693
+ "constructor",
694
+ "prototype"
695
+ ]);
691
696
  function mergeDictsWithPaths({
692
697
  mergeInto,
693
698
  mergeFrom,
@@ -710,6 +715,7 @@ function mergeDictsWithPathsHelper({
710
715
  mergePaths
711
716
  }) {
712
717
  Object.entries(mergeFrom).forEach(([k, mergeFromV]) => {
718
+ if (FORBIDDEN_MERGE_KEYS.has(k)) return;
713
719
  const fullPath = path.concat([k]);
714
720
  const fullPathSerialized = JSON.stringify(fullPath);
715
721
  const mergeIntoV = recordFind(mergeInto, k);
@@ -1,106 +0,0 @@
1
- import {
2
- aiSDKConfigs,
3
- anthropicConfigs,
4
- claudeAgentSDKConfigs,
5
- cohereConfigs,
6
- cursorSDKConfigs,
7
- googleGenAIConfigs,
8
- groqConfigs,
9
- huggingFaceConfigs,
10
- mistralConfigs,
11
- openRouterAgentConfigs,
12
- openRouterConfigs,
13
- openaiConfigs
14
- } from "./chunk-GZNXBBPU.mjs";
15
-
16
- // src/auto-instrumentations/bundler/plugin.ts
17
- import { createUnplugin } from "unplugin";
18
- import {
19
- create
20
- } from "@apm-js-collab/code-transformer";
21
- import { extname, join, sep } from "path";
22
- import { readFileSync } from "fs";
23
- import { fileURLToPath } from "url";
24
- import moduleDetailsFromPath from "module-details-from-path";
25
- function getModuleVersion(basedir) {
26
- try {
27
- const packageJsonPath = join(basedir, "package.json");
28
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
29
- if (packageJson.version) {
30
- return packageJson.version;
31
- }
32
- } catch (error) {
33
- }
34
- return void 0;
35
- }
36
- var unplugin = createUnplugin((options = {}) => {
37
- const allInstrumentations = [
38
- ...openaiConfigs,
39
- ...anthropicConfigs,
40
- ...aiSDKConfigs,
41
- ...claudeAgentSDKConfigs,
42
- ...cursorSDKConfigs,
43
- ...googleGenAIConfigs,
44
- ...huggingFaceConfigs,
45
- ...openRouterConfigs,
46
- ...openRouterAgentConfigs,
47
- ...mistralConfigs,
48
- ...cohereConfigs,
49
- ...groqConfigs,
50
- ...options.instrumentations || []
51
- ];
52
- const dcModule = options.browser === false ? void 0 : "dc-browser";
53
- const instrumentationMatcher = create(allInstrumentations, dcModule);
54
- return {
55
- name: "code-transformer",
56
- enforce: "pre",
57
- transform(code, id) {
58
- if (!id) {
59
- return null;
60
- }
61
- const filePath = id.startsWith("file:") ? fileURLToPath(id) : id;
62
- const ext = extname(filePath);
63
- let isModule = ext === ".mjs" || ext === ".ts" || ext === ".tsx";
64
- if (ext === ".js") {
65
- isModule = code.includes("export ") || code.includes("import ");
66
- }
67
- const normalizedForPlatform = filePath.split("/").join(sep);
68
- const moduleDetails = moduleDetailsFromPath(normalizedForPlatform);
69
- if (!moduleDetails) {
70
- return null;
71
- }
72
- const moduleName = moduleDetails.name;
73
- const moduleVersion = getModuleVersion(moduleDetails.basedir);
74
- if (!moduleVersion) {
75
- console.warn(
76
- `No 'package.json' version found for module ${moduleName} at ${moduleDetails.basedir}. Skipping transformation.`
77
- );
78
- return null;
79
- }
80
- const normalizedModulePath = moduleDetails.path.replace(/\\/g, "/");
81
- const transformer = instrumentationMatcher.getTransformer(
82
- moduleName,
83
- moduleVersion,
84
- normalizedModulePath
85
- );
86
- if (!transformer) {
87
- return null;
88
- }
89
- try {
90
- const moduleType = isModule ? "esm" : "cjs";
91
- const result = transformer.transform(code, moduleType);
92
- return {
93
- code: result.code,
94
- map: result.map
95
- };
96
- } catch (error) {
97
- console.warn(`Code transformation failed for ${id}: ${error}`);
98
- return null;
99
- }
100
- }
101
- };
102
- });
103
-
104
- export {
105
- unplugin
106
- };
@@ -1,22 +0,0 @@
1
- import { InstrumentationConfig } from '@apm-js-collab/code-transformer';
2
-
3
- interface BundlerPluginOptions {
4
- /**
5
- * Enable debug logging
6
- */
7
- debug?: boolean;
8
- /**
9
- * Additional instrumentation configs to apply
10
- */
11
- instrumentations?: InstrumentationConfig[];
12
- /**
13
- * Whether to bundle for browser environments.
14
- *
15
- * When true, uses 'dc-browser' for browser-compatible diagnostics_channel polyfill.
16
- * When false, uses Node.js built-in 'diagnostics_channel' and 'async_hooks'.
17
- * Defaults to true (assumes browser build).
18
- */
19
- browser?: boolean;
20
- }
21
-
22
- export type { BundlerPluginOptions as B };
@@ -1,22 +0,0 @@
1
- import { InstrumentationConfig } from '@apm-js-collab/code-transformer';
2
-
3
- interface BundlerPluginOptions {
4
- /**
5
- * Enable debug logging
6
- */
7
- debug?: boolean;
8
- /**
9
- * Additional instrumentation configs to apply
10
- */
11
- instrumentations?: InstrumentationConfig[];
12
- /**
13
- * Whether to bundle for browser environments.
14
- *
15
- * When true, uses 'dc-browser' for browser-compatible diagnostics_channel polyfill.
16
- * When false, uses Node.js built-in 'diagnostics_channel' and 'async_hooks'.
17
- * Defaults to true (assumes browser build).
18
- */
19
- browser?: boolean;
20
- }
21
-
22
- export type { BundlerPluginOptions as B };