braintrust 3.3.0 → 3.5.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 (60) hide show
  1. package/README.md +52 -67
  2. package/dev/dist/index.d.mts +98 -14
  3. package/dev/dist/index.d.ts +98 -14
  4. package/dev/dist/index.js +2751 -1463
  5. package/dev/dist/index.mjs +2383 -1095
  6. package/dist/auto-instrumentations/bundler/esbuild.cjs +476 -31
  7. package/dist/auto-instrumentations/bundler/esbuild.d.mts +2 -2
  8. package/dist/auto-instrumentations/bundler/esbuild.d.ts +2 -2
  9. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  10. package/dist/auto-instrumentations/bundler/rollup.cjs +476 -31
  11. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  12. package/dist/auto-instrumentations/bundler/vite.cjs +476 -31
  13. package/dist/auto-instrumentations/bundler/vite.d.mts +2 -2
  14. package/dist/auto-instrumentations/bundler/vite.d.ts +2 -2
  15. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  16. package/dist/auto-instrumentations/bundler/webpack.cjs +476 -31
  17. package/dist/auto-instrumentations/bundler/webpack.d.mts +2 -2
  18. package/dist/auto-instrumentations/bundler/webpack.d.ts +2 -2
  19. package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
  20. package/dist/auto-instrumentations/chunk-DQTPSXJB.mjs +733 -0
  21. package/dist/auto-instrumentations/chunk-EVUKFMHG.mjs +41 -0
  22. package/dist/auto-instrumentations/{chunk-OLOPGWTJ.mjs → chunk-F3TJZ3Z2.mjs} +1 -1
  23. package/dist/auto-instrumentations/chunk-VLEJ5AEK.mjs +41 -0
  24. package/dist/auto-instrumentations/hook.mjs +540 -37
  25. package/dist/auto-instrumentations/index.cjs +476 -31
  26. package/dist/auto-instrumentations/index.d.mts +5 -5
  27. package/dist/auto-instrumentations/index.d.ts +5 -5
  28. package/dist/auto-instrumentations/index.mjs +1 -1
  29. package/dist/auto-instrumentations/loader/cjs-patch.cjs +32 -10
  30. package/dist/auto-instrumentations/loader/cjs-patch.mjs +10 -5
  31. package/dist/auto-instrumentations/loader/esm-hook.mjs +11 -12
  32. package/dist/auto-instrumentations/loader/get-package-version.cjs +28 -8
  33. package/dist/auto-instrumentations/loader/get-package-version.d.mts +2 -1
  34. package/dist/auto-instrumentations/loader/get-package-version.d.ts +2 -1
  35. package/dist/auto-instrumentations/loader/get-package-version.mjs +3 -1
  36. package/dist/browser.d.mts +806 -306
  37. package/dist/browser.d.ts +806 -306
  38. package/dist/browser.js +3235 -2317
  39. package/dist/browser.mjs +3235 -2317
  40. package/dist/cli.js +2672 -1347
  41. package/dist/edge-light.d.mts +1 -1
  42. package/dist/edge-light.d.ts +1 -1
  43. package/dist/edge-light.js +3035 -2087
  44. package/dist/edge-light.mjs +3035 -2087
  45. package/dist/index.d.mts +806 -306
  46. package/dist/index.d.ts +806 -306
  47. package/dist/index.js +3570 -2654
  48. package/dist/index.mjs +3235 -2319
  49. package/dist/instrumentation/index.d.mts +16 -22
  50. package/dist/instrumentation/index.d.ts +16 -22
  51. package/dist/instrumentation/index.js +2241 -1077
  52. package/dist/instrumentation/index.mjs +2241 -1077
  53. package/dist/workerd.d.mts +1 -1
  54. package/dist/workerd.d.ts +1 -1
  55. package/dist/workerd.js +3035 -2087
  56. package/dist/workerd.mjs +3035 -2087
  57. package/package.json +26 -7
  58. package/dist/auto-instrumentations/chunk-KVX7OFPD.mjs +0 -288
  59. package/dist/auto-instrumentations/chunk-XDBPUTVE.mjs +0 -22
  60. package/dist/auto-instrumentations/chunk-ZEC7BCL4.mjs +0 -22
package/README.md CHANGED
@@ -1,39 +1,29 @@
1
- An isomorphic JS library for logging data to Braintrust.
1
+ # Braintrust JavaScript SDK
2
2
 
3
- ## Version information
3
+ [![npm version](https://img.shields.io/npm/v/braintrust.svg)](https://www.npmjs.com/package/braintrust)
4
4
 
5
- **2.x** is the current stable release. [Zod](https://zod.dev/) is now a peer dependency instead of a bundled dependency. This gives you control over the Zod version in your project and reduces bundle size if you’re already using Zod.
5
+ An isomorphic JavaScript/TypeScript SDK for logging, tracing, and evaluating AI applications with [Braintrust](https://www.braintrust.dev/). For more details, see the [Braintrust docs](https://www.braintrust.dev/docs)
6
6
 
7
- The SDK requires Zod v3.25.34 or later.
7
+ ## Installation
8
8
 
9
- ### Upgrading from 1.x
10
-
11
- See the [Migrate from v1.x to v2.x guide](https://www.braintrust.dev/docs/reference/sdks/typescript/migrations/v1-to-v2) for instructions.
12
-
13
- ### Upgrading from 0.x
14
-
15
- First follow the [Migrate from v0.x to v1.x guide](https://www.braintrust.dev/docs/reference/sdks/typescript/migrations/v0-to-v1), then proceed to the [Migrate from v1.x to v2.x guide](https://www.braintrust.dev/docs/reference/sdks/typescript/migrations/v1-to-v2).
16
-
17
- **Note:** If you do not have OpenTelemetry you can upgrade directly from v0.x to v2.x.
18
-
19
- ### Quickstart
20
-
21
- Install the library with npm (or yarn).
9
+ Install the SDK:
22
10
 
23
11
  ```bash
24
- npm install braintrust zod
12
+ npm install braintrust
25
13
  ```
26
14
 
27
- Then, run a simple experiment with the following code (replace `YOUR_API_KEY` with
28
- your Braintrust API key):
15
+ ## Quickstart
16
+
17
+ Run a simple experiment (replace `YOUR_API_KEY` with your Braintrust API key):
29
18
 
30
- ```javascript
19
+ ```typescript
31
20
  import * as braintrust from "braintrust";
32
21
 
33
22
  async function main() {
34
23
  const experiment = await braintrust.init("NodeTest", {
35
24
  apiKey: "YOUR_API_KEY",
36
25
  });
26
+
37
27
  experiment.log({
38
28
  input: { test: 1 },
39
29
  output: "foo",
@@ -45,53 +35,32 @@ async function main() {
45
35
  id: 1,
46
36
  },
47
37
  });
38
+
48
39
  console.log(await experiment.summarize());
49
40
  }
50
41
 
51
42
  main().catch(console.error);
52
43
  ```
53
44
 
54
- ### Browser Support
55
-
56
- **For browser-only applications, use the dedicated browser package:**
57
-
58
- ```bash
59
- npm install @braintrust/browser
60
- ```
61
-
62
- The `@braintrust/browser` package is optimized for browser environments and includes the `als-browser` polyfill for AsyncLocalStorage support. It's a standalone package with no peer dependencies.
63
-
64
- **When to use each package:**
65
-
66
- - **`braintrust`** (this package) - For Node.js applications, full-stack frameworks (Next.js, etc.), and edge runtimes with native AsyncLocalStorage (Cloudflare Workers, Vercel Edge)
67
- - **`@braintrust/browser`** - For browser-only applications that need AsyncLocalStorage support in standard browsers
68
-
69
- See the [@braintrust/browser README](../integrations/browser-js/README.md) for more details.
70
-
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
45
+ ## Auto-Instrumentation
74
46
 
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.
47
+ Braintrust can automatically instrument popular AI SDKs (OpenAI, Anthropic, Vercel AI SDK, and others) to log calls without manual wrapper code.
76
48
 
77
- #### Node.js Applications
49
+ ### Node.js
78
50
 
79
- For Node.js applications, use the `--import` flag to load the instrumentation hook:
51
+ Use the runtime import hook:
80
52
 
81
53
  ```bash
82
54
  node --import braintrust/hook.mjs app.js
83
55
  ```
84
56
 
85
- This works with both ESM and CommonJS modules automatically.
57
+ ### Bundled Apps
86
58
 
87
- #### Browser/Bundled Applications
59
+ Use a bundler plugin:
88
60
 
89
- For browser applications or bundled Node.js applications, use the appropriate bundler plugin:
61
+ Vite:
90
62
 
91
- **Vite:**
92
-
93
- ```typescript
94
- // vite.config.ts
63
+ ```ts
95
64
  import { vitePlugin } from "braintrust/vite";
96
65
 
97
66
  export default {
@@ -99,10 +68,9 @@ export default {
99
68
  };
100
69
  ```
101
70
 
102
- **Webpack:**
71
+ Webpack:
103
72
 
104
- ```javascript
105
- // webpack.config.js
73
+ ```js
106
74
  const { webpackPlugin } = require("braintrust/webpack");
107
75
 
108
76
  module.exports = {
@@ -110,9 +78,9 @@ module.exports = {
110
78
  };
111
79
  ```
112
80
 
113
- **esbuild:**
81
+ esbuild:
114
82
 
115
- ```typescript
83
+ ```ts
116
84
  import { esbuildPlugin } from "braintrust/esbuild";
117
85
 
118
86
  await esbuild.build({
@@ -120,9 +88,9 @@ await esbuild.build({
120
88
  });
121
89
  ```
122
90
 
123
- **Rollup:**
91
+ Rollup:
124
92
 
125
- ```typescript
93
+ ```ts
126
94
  import { rollupPlugin } from "braintrust/rollup";
127
95
 
128
96
  export default {
@@ -130,15 +98,32 @@ export default {
130
98
  };
131
99
  ```
132
100
 
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:
101
+ If you use TypeScript or other transpilation plugins, place the Braintrust plugin after them so transformed output is instrumented.
134
102
 
135
- ```typescript
136
- export default {
137
- plugins: [
138
- typescript(), // or other transpilation plugins
139
- vitePlugin(), // Braintrust plugin should come after
140
- ],
141
- };
103
+ For deeper details, see the [auto-instrumentation architecture docs](src/auto-instrumentations/README.md).
104
+
105
+ ## Browser Support
106
+
107
+ For browser-only applications, use the dedicated browser package:
108
+
109
+ ```bash
110
+ npm install @braintrust/browser braintrust
142
111
  ```
143
112
 
144
- For more information on auto-instrumentation, see the [internal architecture docs](src/auto-instrumentations/README.md).
113
+ See the [`@braintrust/browser` README](../integrations/browser-js/README.md) for details and current limitations.
114
+
115
+ ## Migration Guides
116
+
117
+ ### Upgrading from 2.x to 3.x
118
+
119
+ See the [Migrate from v2.x to v3.x guide](https://www.braintrust.dev/docs/reference/sdks/typescript/migrations/v2-to-v3).
120
+
121
+ In 3.x, browser usage should move to `@braintrust/browser` instead of relying on the legacy `braintrust/browser` path.
122
+
123
+ ### Upgrading from 1.x to 2.x
124
+
125
+ See the [Migrate from v1.x to v2.x guide](https://www.braintrust.dev/docs/reference/sdks/typescript/migrations/v1-to-v2).
126
+
127
+ ### Upgrading from 0.x to 1.x
128
+
129
+ See the [Migrate from v1.x to v2.x guide](https://www.braintrust.dev/docs/reference/sdks/typescript/migrations/v0-to-v1).
@@ -363,6 +363,23 @@ declare class SpanComponentsV4 {
363
363
  declare const spanTypeAttributeValues: readonly ["llm", "score", "function", "eval", "task", "tool", "automation", "facet", "preprocessor", "classifier", "review"];
364
364
  type SpanType = (typeof spanTypeAttributeValues)[number];
365
365
 
366
+ declare const ResponseFormatJsonSchema: z.ZodObject<{
367
+ name: z.ZodString;
368
+ description: z.ZodOptional<z.ZodString>;
369
+ schema: z.ZodOptional<z.ZodUnion<[z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, z.ZodString]>>;
370
+ strict: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodNull]>>;
371
+ }, "strip", z.ZodTypeAny, {
372
+ name: string;
373
+ description?: string | undefined;
374
+ schema?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
375
+ strict?: boolean | null | undefined;
376
+ }, {
377
+ name: string;
378
+ description?: string | undefined;
379
+ schema?: string | z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
380
+ strict?: boolean | null | undefined;
381
+ }>;
382
+ type ResponseFormatJsonSchemaType = z.infer<typeof ResponseFormatJsonSchema>;
366
383
  declare const AnyModelParams: z.ZodObject<{
367
384
  temperature: z.ZodOptional<z.ZodNumber>;
368
385
  top_p: z.ZodOptional<z.ZodNumber>;
@@ -3413,21 +3430,21 @@ declare const FunctionData: z.ZodUnion<[z.ZodObject<{
3413
3430
  node: string;
3414
3431
  variable: string;
3415
3432
  };
3433
+ purpose: "data" | "messages" | "control";
3416
3434
  target: {
3417
3435
  node: string;
3418
3436
  variable: string;
3419
3437
  };
3420
- purpose: "data" | "messages" | "control";
3421
3438
  }, {
3422
3439
  source: {
3423
3440
  node: string;
3424
3441
  variable: string;
3425
3442
  };
3443
+ purpose: "data" | "messages" | "control";
3426
3444
  target: {
3427
3445
  node: string;
3428
3446
  variable: string;
3429
3447
  };
3430
- purpose: "data" | "messages" | "control";
3431
3448
  }>>;
3432
3449
  }, "strip", z.ZodTypeAny, {
3433
3450
  type: "graph";
@@ -3593,11 +3610,11 @@ declare const FunctionData: z.ZodUnion<[z.ZodObject<{
3593
3610
  node: string;
3594
3611
  variable: string;
3595
3612
  };
3613
+ purpose: "data" | "messages" | "control";
3596
3614
  target: {
3597
3615
  node: string;
3598
3616
  variable: string;
3599
3617
  };
3600
- purpose: "data" | "messages" | "control";
3601
3618
  }>;
3602
3619
  }, {
3603
3620
  type: "graph";
@@ -3763,11 +3780,11 @@ declare const FunctionData: z.ZodUnion<[z.ZodObject<{
3763
3780
  node: string;
3764
3781
  variable: string;
3765
3782
  };
3783
+ purpose: "data" | "messages" | "control";
3766
3784
  target: {
3767
3785
  node: string;
3768
3786
  variable: string;
3769
3787
  };
3770
- purpose: "data" | "messages" | "control";
3771
3788
  }>;
3772
3789
  }>, z.ZodObject<{
3773
3790
  type: z.ZodLiteral<"remote_eval">;
@@ -8382,6 +8399,14 @@ declare const ToolFunctionDefinition: z.ZodObject<{
8382
8399
  type ToolFunctionDefinitionType = z.infer<typeof ToolFunctionDefinition>;
8383
8400
 
8384
8401
  type GenericFunction<Input, Output> = ((input: Input) => Output) | ((input: Input) => Promise<Output>);
8402
+ interface BaseFnOpts {
8403
+ name: string;
8404
+ slug: string;
8405
+ description: string;
8406
+ ifExists: IfExistsType;
8407
+ tags?: string[];
8408
+ metadata?: Record<string, unknown>;
8409
+ }
8385
8410
 
8386
8411
  interface IsoAsyncLocalStorage<T> {
8387
8412
  enterWith(store: T): void;
@@ -8389,6 +8414,9 @@ interface IsoAsyncLocalStorage<T> {
8389
8414
  getStore(): T | undefined;
8390
8415
  }
8391
8416
 
8417
+ type DebugLogLevel = "error" | "warn" | "info" | "debug";
8418
+ type DebugLogLevelOption = DebugLogLevel | false | undefined;
8419
+
8392
8420
  /**
8393
8421
  * Abstract base class for ID generators
8394
8422
  */
@@ -9678,6 +9706,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
9678
9706
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
9679
9707
  }, z.ZodTypeAny, "passthrough">>]>>;
9680
9708
  templateFormat: z.ZodOptional<z.ZodEnum<["mustache", "nunjucks", "none"]>>;
9709
+ environments: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
9681
9710
  }, "strip", z.ZodTypeAny, {
9682
9711
  model: string;
9683
9712
  params?: z.objectOutputType<{
@@ -9798,6 +9827,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
9798
9827
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
9799
9828
  }, z.ZodTypeAny, "passthrough"> | undefined;
9800
9829
  templateFormat?: "none" | "mustache" | "nunjucks" | undefined;
9830
+ environments?: string[] | undefined;
9801
9831
  }, {
9802
9832
  model: string;
9803
9833
  params?: z.objectInputType<{
@@ -9918,6 +9948,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
9918
9948
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
9919
9949
  }, z.ZodTypeAny, "passthrough"> | undefined;
9920
9950
  templateFormat?: "none" | "mustache" | "nunjucks" | undefined;
9951
+ environments?: string[] | undefined;
9921
9952
  }>>, z.ZodObject<{
9922
9953
  tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
9923
9954
  type: z.ZodLiteral<"function">;
@@ -10189,6 +10220,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
10189
10220
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
10190
10221
  }, z.ZodTypeAny, "passthrough"> | undefined;
10191
10222
  templateFormat?: "none" | "mustache" | "nunjucks" | undefined;
10223
+ environments?: string[] | undefined;
10192
10224
  }) & {
10193
10225
  tools?: {
10194
10226
  function: {
@@ -10413,6 +10445,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
10413
10445
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
10414
10446
  }, z.ZodTypeAny, "passthrough"> | undefined;
10415
10447
  templateFormat?: "none" | "mustache" | "nunjucks" | undefined;
10448
+ environments?: string[] | undefined;
10416
10449
  }) & {
10417
10450
  tools?: {
10418
10451
  function: {
@@ -10424,11 +10457,25 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
10424
10457
  type: "function";
10425
10458
  }[] | undefined;
10426
10459
  }) | undefined;
10460
+ }>, z.ZodObject<{
10461
+ type: z.ZodLiteral<"model">;
10462
+ default: z.ZodOptional<z.ZodString>;
10463
+ description: z.ZodOptional<z.ZodString>;
10464
+ }, "strip", z.ZodTypeAny, {
10465
+ type: "model";
10466
+ description?: string | undefined;
10467
+ default?: string | undefined;
10468
+ }, {
10469
+ type: "model";
10470
+ description?: string | undefined;
10471
+ default?: string | undefined;
10427
10472
  }>, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
10428
10473
  type EvalParameters = z.infer<typeof evalParametersSchema>;
10429
10474
  type InferParameterValue<T> = T extends {
10430
10475
  type: "prompt";
10431
- } ? Prompt : T extends z.ZodType ? z.infer<T> : never;
10476
+ } ? Prompt : T extends {
10477
+ type: "model";
10478
+ } ? string : T extends z.ZodType ? z.infer<T> : never;
10432
10479
  type InferParameters<T extends EvalParameters> = {
10433
10480
  [K in keyof T]: InferParameterValue<T[K]>;
10434
10481
  };
@@ -10706,6 +10753,8 @@ declare const loginSchema: z.ZodObject<{
10706
10753
  collect: "some" | "none" | "all";
10707
10754
  fields?: ("dirty" | "tag" | "commit" | "branch" | "author_name" | "author_email" | "commit_message" | "commit_time" | "git_diff")[] | undefined;
10708
10755
  }>>>;
10756
+ debugLogLevel: z.ZodOptional<z.ZodEnum<["error", "warn", "info", "debug"]>>;
10757
+ debugLogLevelDisabled: z.ZodOptional<z.ZodBoolean>;
10709
10758
  }, "strict", z.ZodTypeAny, {
10710
10759
  appUrl: string;
10711
10760
  appPublicUrl: string;
@@ -10718,6 +10767,8 @@ declare const loginSchema: z.ZodObject<{
10718
10767
  collect: "some" | "none" | "all";
10719
10768
  fields?: ("dirty" | "tag" | "commit" | "branch" | "author_name" | "author_email" | "commit_message" | "commit_time" | "git_diff")[] | undefined;
10720
10769
  } | null | undefined;
10770
+ debugLogLevel?: "error" | "warn" | "info" | "debug" | undefined;
10771
+ debugLogLevelDisabled?: boolean | undefined;
10721
10772
  }, {
10722
10773
  appUrl: string;
10723
10774
  appPublicUrl: string;
@@ -10730,6 +10781,8 @@ declare const loginSchema: z.ZodObject<{
10730
10781
  collect: "some" | "none" | "all";
10731
10782
  fields?: ("dirty" | "tag" | "commit" | "branch" | "author_name" | "author_email" | "commit_message" | "commit_time" | "git_diff")[] | undefined;
10732
10783
  } | null | undefined;
10784
+ debugLogLevel?: "error" | "warn" | "info" | "debug" | undefined;
10785
+ debugLogLevelDisabled?: boolean | undefined;
10733
10786
  }>;
10734
10787
  type SerializedBraintrustState = z.infer<typeof loginSchema>;
10735
10788
  declare class BraintrustState {
@@ -10750,6 +10803,8 @@ declare class BraintrustState {
10750
10803
  proxyUrl: string | null;
10751
10804
  loggedIn: boolean;
10752
10805
  gitMetadataSettings?: GitMetadataSettingsType;
10806
+ debugLogLevel?: DebugLogLevel;
10807
+ private debugLogLevelConfigured;
10753
10808
  fetch: typeof globalThis.fetch;
10754
10809
  private _appConn;
10755
10810
  private _apiConn;
@@ -10780,6 +10835,9 @@ declare class BraintrustState {
10780
10835
  static deserialize(serialized: unknown, opts?: LoginOptions): BraintrustState;
10781
10836
  setFetch(fetch: typeof globalThis.fetch): void;
10782
10837
  setMaskingFunction(maskingFunction: ((value: unknown) => unknown) | null): void;
10838
+ setDebugLogLevel(option: DebugLogLevelOption): void;
10839
+ getDebugLogLevel(): DebugLogLevel | undefined;
10840
+ hasDebugLogLevelOverride(): boolean;
10783
10841
  login(loginParams: LoginOptions & {
10784
10842
  forceLogin?: boolean;
10785
10843
  }): Promise<void>;
@@ -11028,6 +11086,19 @@ interface LoginOptions {
11028
11086
  * server. Defaults to false.
11029
11087
  */
11030
11088
  disableSpanCache?: boolean;
11089
+ /**
11090
+ * Controls internal Braintrust SDK troubleshooting output.
11091
+ *
11092
+ * Use `"error"`, `"warn"`, `"info"`, or `"debug"` to control how much
11093
+ * internal SDK troubleshooting output is emitted. Use `false` to explicitly
11094
+ * disable this output.
11095
+ *
11096
+ * When omitted, the SDK remains silent unless
11097
+ * `BRAINTRUST_DEBUG_LOG_LEVEL` is set to `"error"`, `"warn"`, `"info"`, or
11098
+ * `"debug"`. This option only affects local console output; it does not
11099
+ * change what data is logged to Braintrust.
11100
+ */
11101
+ debugLogLevel?: DebugLogLevel | false;
11031
11102
  }
11032
11103
  type OptionalStateArg = {
11033
11104
  state?: BraintrustState;
@@ -11298,7 +11369,18 @@ declare class Dataset<IsLegacyDataset extends boolean = typeof DEFAULT_IS_LEGACY
11298
11369
  close(): Promise<string>;
11299
11370
  static isDataset(data: unknown): data is Dataset;
11300
11371
  }
11301
- type CompiledPromptParams = Omit<NonNullable<PromptDataType["options"]>["params"], "use_cache"> & {
11372
+ type CompiledPromptResponseFormat = Exclude<AnyModelParamsType["response_format"], null> extends infer ResponseFormat ? ResponseFormat extends {
11373
+ type: "json_schema";
11374
+ json_schema: infer JsonSchema;
11375
+ } ? Omit<ResponseFormat, "json_schema"> & {
11376
+ json_schema: Omit<Extract<JsonSchema, ResponseFormatJsonSchemaType>, "schema"> & {
11377
+ schema?: Record<string, unknown>;
11378
+ };
11379
+ } : ResponseFormat : never;
11380
+ type CompiledPromptReasoningEffort = Exclude<AnyModelParamsType["reasoning_effort"], "none">;
11381
+ type CompiledPromptParams = Omit<NonNullable<PromptDataType["options"]>["params"], "use_cache" | "response_format" | "reasoning_effort"> & Omit<AnyModelParamsType, "use_cache" | "response_format" | "reasoning_effort"> & {
11382
+ reasoning_effort?: CompiledPromptReasoningEffort;
11383
+ response_format?: CompiledPromptResponseFormat;
11302
11384
  model: NonNullable<NonNullable<PromptDataType["options"]>["model"]>;
11303
11385
  };
11304
11386
  type ChatPrompt = {
@@ -12477,6 +12559,7 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
12477
12559
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
12478
12560
  }, z.ZodTypeAny, "passthrough">>]>>;
12479
12561
  templateFormat: z.ZodOptional<z.ZodEnum<["mustache", "nunjucks", "none"]>>;
12562
+ environments: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
12480
12563
  }, "strip", z.ZodTypeAny, {
12481
12564
  model: string;
12482
12565
  params?: z.objectOutputType<{
@@ -12597,6 +12680,7 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
12597
12680
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
12598
12681
  }, z.ZodTypeAny, "passthrough"> | undefined;
12599
12682
  templateFormat?: "none" | "mustache" | "nunjucks" | undefined;
12683
+ environments?: string[] | undefined;
12600
12684
  }, {
12601
12685
  model: string;
12602
12686
  params?: z.objectInputType<{
@@ -12717,17 +12801,10 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
12717
12801
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
12718
12802
  }, z.ZodTypeAny, "passthrough"> | undefined;
12719
12803
  templateFormat?: "none" | "mustache" | "nunjucks" | undefined;
12804
+ environments?: string[] | undefined;
12720
12805
  }>>;
12721
12806
  type PromptDefinition = z.infer<typeof promptDefinitionSchema>;
12722
12807
 
12723
- interface BaseFnOpts {
12724
- name: string;
12725
- slug: string;
12726
- description: string;
12727
- ifExists: IfExistsType;
12728
- metadata?: Record<string, unknown>;
12729
- }
12730
-
12731
12808
  type NameOrId = {
12732
12809
  name: string;
12733
12810
  } | {
@@ -12814,6 +12891,7 @@ declare class CodeFunction<Input, Output, Fn extends GenericFunction<Input, Outp
12814
12891
  readonly parameters?: z.ZodSchema<Input>;
12815
12892
  readonly returns?: z.ZodSchema<Output>;
12816
12893
  readonly ifExists?: IfExistsType;
12894
+ readonly tags?: string[];
12817
12895
  readonly metadata?: Record<string, unknown>;
12818
12896
  constructor(project: Project, opts: Omit<CodeOpts<Input, Output, Fn>, "name" | "slug"> & {
12819
12897
  name: string;
@@ -12833,7 +12911,9 @@ declare class CodePrompt {
12833
12911
  readonly id?: string;
12834
12912
  readonly functionType?: FunctionTypeEnumType;
12835
12913
  readonly toolFunctions: (SavedFunctionIdType | GenericCodeFunction)[];
12914
+ readonly tags?: string[];
12836
12915
  readonly metadata?: Record<string, unknown>;
12916
+ readonly environmentSlugs?: string[];
12837
12917
  constructor(project: Project, prompt: PromptDataType, toolFunctions: (SavedFunctionIdType | GenericCodeFunction)[], opts: Omit<PromptOpts<false, false, false, false>, "name" | "slug"> & {
12838
12918
  name: string;
12839
12919
  slug: string;
@@ -12900,7 +12980,11 @@ interface FunctionEvent {
12900
12980
  function_data: z.infer<typeof FunctionData>;
12901
12981
  function_type?: FunctionTypeEnumType;
12902
12982
  if_exists?: IfExistsType;
12983
+ tags?: string[];
12903
12984
  metadata?: Record<string, unknown>;
12985
+ environments?: {
12986
+ slug: string;
12987
+ }[];
12904
12988
  }
12905
12989
  declare class ProjectNameIdMap {
12906
12990
  private nameToId;