braintrust 3.1.0 → 3.2.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 (63) hide show
  1. package/README.md +73 -0
  2. package/dev/dist/index.d.mts +187 -903
  3. package/dev/dist/index.d.ts +187 -903
  4. package/dev/dist/index.js +2942 -323
  5. package/dev/dist/index.mjs +2704 -85
  6. package/dist/auto-instrumentations/bundler/esbuild.cjs +401 -0
  7. package/dist/auto-instrumentations/bundler/esbuild.d.mts +8 -0
  8. package/dist/auto-instrumentations/bundler/esbuild.d.ts +8 -0
  9. package/dist/auto-instrumentations/bundler/esbuild.mjs +10 -0
  10. package/dist/auto-instrumentations/bundler/rollup.cjs +401 -0
  11. package/dist/auto-instrumentations/bundler/rollup.d.mts +8 -0
  12. package/dist/auto-instrumentations/bundler/rollup.d.ts +8 -0
  13. package/dist/auto-instrumentations/bundler/rollup.mjs +10 -0
  14. package/dist/auto-instrumentations/bundler/vite.cjs +401 -0
  15. package/dist/auto-instrumentations/bundler/vite.d.mts +8 -0
  16. package/dist/auto-instrumentations/bundler/vite.d.ts +8 -0
  17. package/dist/auto-instrumentations/bundler/vite.mjs +10 -0
  18. package/dist/auto-instrumentations/bundler/webpack.cjs +401 -0
  19. package/dist/auto-instrumentations/bundler/webpack.d.mts +8 -0
  20. package/dist/auto-instrumentations/bundler/webpack.d.ts +8 -0
  21. package/dist/auto-instrumentations/bundler/webpack.mjs +10 -0
  22. package/dist/auto-instrumentations/chunk-KVX7OFPD.mjs +288 -0
  23. package/dist/auto-instrumentations/chunk-OLOPGWTJ.mjs +89 -0
  24. package/dist/auto-instrumentations/chunk-XDBPUTVE.mjs +22 -0
  25. package/dist/auto-instrumentations/chunk-ZEC7BCL4.mjs +22 -0
  26. package/dist/auto-instrumentations/hook.mjs +378 -0
  27. package/dist/auto-instrumentations/index.cjs +318 -0
  28. package/dist/auto-instrumentations/index.d.mts +69 -0
  29. package/dist/auto-instrumentations/index.d.ts +69 -0
  30. package/dist/auto-instrumentations/index.mjs +14 -0
  31. package/dist/auto-instrumentations/loader/cjs-patch.cjs +116 -0
  32. package/dist/auto-instrumentations/loader/cjs-patch.d.mts +28 -0
  33. package/dist/auto-instrumentations/loader/cjs-patch.d.ts +28 -0
  34. package/dist/auto-instrumentations/loader/cjs-patch.mjs +66 -0
  35. package/dist/auto-instrumentations/loader/esm-hook.mjs +72 -0
  36. package/dist/auto-instrumentations/loader/get-package-version.cjs +46 -0
  37. package/dist/auto-instrumentations/loader/get-package-version.d.mts +7 -0
  38. package/dist/auto-instrumentations/loader/get-package-version.d.ts +7 -0
  39. package/dist/auto-instrumentations/loader/get-package-version.mjs +6 -0
  40. package/dist/auto-instrumentations/plugin-Df3qKIl2.d.mts +22 -0
  41. package/dist/auto-instrumentations/plugin-Df3qKIl2.d.ts +22 -0
  42. package/dist/browser.d.mts +484 -980
  43. package/dist/browser.d.ts +484 -980
  44. package/dist/browser.js +3437 -386
  45. package/dist/browser.mjs +3437 -386
  46. package/dist/cli.js +2890 -228
  47. package/dist/edge-light.d.mts +1 -1
  48. package/dist/edge-light.d.ts +1 -1
  49. package/dist/edge-light.js +3134 -86
  50. package/dist/edge-light.mjs +3134 -86
  51. package/dist/index.d.mts +484 -980
  52. package/dist/index.d.ts +484 -980
  53. package/dist/index.js +3754 -703
  54. package/dist/index.mjs +3615 -564
  55. package/dist/instrumentation/index.d.mts +323 -0
  56. package/dist/instrumentation/index.d.ts +323 -0
  57. package/dist/instrumentation/index.js +9942 -0
  58. package/dist/instrumentation/index.mjs +9902 -0
  59. package/dist/workerd.d.mts +1 -1
  60. package/dist/workerd.d.ts +1 -1
  61. package/dist/workerd.js +3134 -86
  62. package/dist/workerd.mjs +3134 -86
  63. package/package.json +46 -7
package/README.md CHANGED
@@ -69,3 +69,76 @@ The `@braintrust/browser` package is optimized for browser environments and incl
69
69
  See the [@braintrust/browser README](../integrations/browser-js/README.md) for more details.
70
70
 
71
71
  **Breaking change in v3.0.0:** The `braintrust/browser` subpath export has been deprecated. Browser users should migrate to the `@braintrust/browser` package.
72
+
73
+ ### Auto-Instrumentation
74
+
75
+ Braintrust provides automatic instrumentation for popular AI SDKs, eliminating the need for manual wrapping. This feature automatically logs all AI SDK calls (OpenAI, Anthropic, Vercel AI SDK, etc.) to Braintrust without any code changes.
76
+
77
+ #### Node.js Applications
78
+
79
+ For Node.js applications, use the `--import` flag to load the instrumentation hook:
80
+
81
+ ```bash
82
+ node --import braintrust/hook.mjs app.js
83
+ ```
84
+
85
+ This works with both ESM and CommonJS modules automatically.
86
+
87
+ #### Browser/Bundled Applications
88
+
89
+ For browser applications or bundled Node.js applications, use the appropriate bundler plugin:
90
+
91
+ **Vite:**
92
+
93
+ ```typescript
94
+ // vite.config.ts
95
+ import { vitePlugin } from "braintrust/vite";
96
+
97
+ export default {
98
+ plugins: [vitePlugin()],
99
+ };
100
+ ```
101
+
102
+ **Webpack:**
103
+
104
+ ```javascript
105
+ // webpack.config.js
106
+ const { webpackPlugin } = require("braintrust/webpack");
107
+
108
+ module.exports = {
109
+ plugins: [webpackPlugin()],
110
+ };
111
+ ```
112
+
113
+ **esbuild:**
114
+
115
+ ```typescript
116
+ import { esbuildPlugin } from "braintrust/esbuild";
117
+
118
+ await esbuild.build({
119
+ plugins: [esbuildPlugin()],
120
+ });
121
+ ```
122
+
123
+ **Rollup:**
124
+
125
+ ```typescript
126
+ import { rollupPlugin } from "braintrust/rollup";
127
+
128
+ export default {
129
+ plugins: [rollupPlugin()],
130
+ };
131
+ ```
132
+
133
+ **Important:** If you're using TypeScript or other transpilation plugins, place the Braintrust plugin **after** them in the plugin array to ensure it instruments the transformed code:
134
+
135
+ ```typescript
136
+ export default {
137
+ plugins: [
138
+ typescript(), // or other transpilation plugins
139
+ vitePlugin(), // Braintrust plugin should come after
140
+ ],
141
+ };
142
+ ```
143
+
144
+ For more information on auto-instrumentation, see the [internal architecture docs](src/auto-instrumentations/README.md).