braintrust 3.28.0 → 3.30.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 (54) hide show
  1. package/README.md +1 -1
  2. package/dev/dist/index.d.mts +356 -7
  3. package/dev/dist/index.d.ts +356 -7
  4. package/dev/dist/index.js +2679 -1828
  5. package/dev/dist/index.mjs +1862 -1011
  6. package/dist/apply-auto-instrumentation.js +298 -265
  7. package/dist/apply-auto-instrumentation.mjs +85 -52
  8. package/dist/auto-instrumentations/bundler/esbuild.cjs +56 -6
  9. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  10. package/dist/auto-instrumentations/bundler/next.cjs +56 -6
  11. package/dist/auto-instrumentations/bundler/next.mjs +3 -3
  12. package/dist/auto-instrumentations/bundler/rollup.cjs +56 -6
  13. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  14. package/dist/auto-instrumentations/bundler/vite.cjs +56 -6
  15. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  16. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +56 -6
  17. package/dist/auto-instrumentations/bundler/webpack.cjs +56 -6
  18. package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
  19. package/dist/auto-instrumentations/{chunk-26PKVUKB.mjs → chunk-LW4HDHXT.mjs} +12 -4
  20. package/dist/auto-instrumentations/{chunk-HD35AM3M.mjs → chunk-OXINGIEZ.mjs} +1 -1
  21. package/dist/auto-instrumentations/{chunk-NP7V4XB2.mjs → chunk-U64OYU4Q.mjs} +45 -3
  22. package/dist/auto-instrumentations/hook.mjs +967 -136
  23. package/dist/auto-instrumentations/index.cjs +45 -3
  24. package/dist/auto-instrumentations/index.mjs +1 -1
  25. package/dist/browser.d.mts +893 -24
  26. package/dist/browser.d.ts +893 -24
  27. package/dist/browser.js +2795 -1136
  28. package/dist/browser.mjs +2795 -1136
  29. package/dist/{chunk-BBE7SNRV.js → chunk-2XDW3UCG.js} +155 -23
  30. package/dist/{chunk-UPFNQCGB.mjs → chunk-BU6SM54N.mjs} +1830 -1045
  31. package/dist/{chunk-ZHUHZWFY.mjs → chunk-N3JKQ3D3.mjs} +152 -20
  32. package/dist/{chunk-OBBWQW6K.js → chunk-TWCDSYJN.js} +2890 -2105
  33. package/dist/cli.js +5976 -1348
  34. package/dist/edge-light.d.mts +1 -1
  35. package/dist/edge-light.d.ts +1 -1
  36. package/dist/edge-light.js +2795 -1136
  37. package/dist/edge-light.mjs +2795 -1136
  38. package/dist/index.d.mts +893 -24
  39. package/dist/index.d.ts +893 -24
  40. package/dist/index.js +1448 -699
  41. package/dist/index.mjs +848 -99
  42. package/dist/instrumentation/index.d.mts +563 -9
  43. package/dist/instrumentation/index.d.ts +563 -9
  44. package/dist/instrumentation/index.js +2794 -989
  45. package/dist/instrumentation/index.mjs +2794 -989
  46. package/dist/vitest-evals-reporter.js +16 -16
  47. package/dist/vitest-evals-reporter.mjs +2 -2
  48. package/dist/workerd.d.mts +1 -1
  49. package/dist/workerd.d.ts +1 -1
  50. package/dist/workerd.js +2795 -1136
  51. package/dist/workerd.mjs +2795 -1136
  52. package/package.json +1 -1
  53. package/util/dist/index.d.mts +42 -0
  54. package/util/dist/index.d.ts +42 -0
@@ -3334,6 +3334,15 @@ declare const PromptData: z.ZodObject<{
3334
3334
  type: "global";
3335
3335
  name: string;
3336
3336
  function_type?: "preprocessor" | undefined;
3337
+ }>, z.ZodObject<{
3338
+ type: z.ZodLiteral<"inline">;
3339
+ code: z.ZodString;
3340
+ }, "strip", z.ZodTypeAny, {
3341
+ code: string;
3342
+ type: "inline";
3343
+ }, {
3344
+ code: string;
3345
+ type: "inline";
3337
3346
  }>, z.ZodNull]>>;
3338
3347
  tool_functions: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnion<[z.ZodObject<{
3339
3348
  type: z.ZodLiteral<"function">;
@@ -3644,6 +3653,9 @@ declare const PromptData: z.ZodObject<{
3644
3653
  type: "global";
3645
3654
  name: string;
3646
3655
  function_type: "preprocessor";
3656
+ } | {
3657
+ code: string;
3658
+ type: "inline";
3647
3659
  } | null | undefined;
3648
3660
  origin?: {
3649
3661
  project_id?: string | undefined;
@@ -3918,6 +3930,9 @@ declare const PromptData: z.ZodObject<{
3918
3930
  type: "global";
3919
3931
  name: string;
3920
3932
  function_type?: "preprocessor" | undefined;
3933
+ } | {
3934
+ code: string;
3935
+ type: "inline";
3921
3936
  } | null | undefined;
3922
3937
  origin?: {
3923
3938
  project_id?: string | undefined;
@@ -5361,6 +5376,15 @@ declare const Prompt$1: z.ZodObject<{
5361
5376
  type: "global";
5362
5377
  name: string;
5363
5378
  function_type?: "preprocessor" | undefined;
5379
+ }>, z.ZodObject<{
5380
+ type: z.ZodLiteral<"inline">;
5381
+ code: z.ZodString;
5382
+ }, "strip", z.ZodTypeAny, {
5383
+ code: string;
5384
+ type: "inline";
5385
+ }, {
5386
+ code: string;
5387
+ type: "inline";
5364
5388
  }>, z.ZodNull]>>;
5365
5389
  tool_functions: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnion<[z.ZodObject<{
5366
5390
  type: z.ZodLiteral<"function">;
@@ -5671,6 +5695,9 @@ declare const Prompt$1: z.ZodObject<{
5671
5695
  type: "global";
5672
5696
  name: string;
5673
5697
  function_type: "preprocessor";
5698
+ } | {
5699
+ code: string;
5700
+ type: "inline";
5674
5701
  } | null | undefined;
5675
5702
  origin?: {
5676
5703
  project_id?: string | undefined;
@@ -5945,6 +5972,9 @@ declare const Prompt$1: z.ZodObject<{
5945
5972
  type: "global";
5946
5973
  name: string;
5947
5974
  function_type?: "preprocessor" | undefined;
5975
+ } | {
5976
+ code: string;
5977
+ type: "inline";
5948
5978
  } | null | undefined;
5949
5979
  origin?: {
5950
5980
  project_id?: string | undefined;
@@ -6236,6 +6266,9 @@ declare const Prompt$1: z.ZodObject<{
6236
6266
  type: "global";
6237
6267
  name: string;
6238
6268
  function_type: "preprocessor";
6269
+ } | {
6270
+ code: string;
6271
+ type: "inline";
6239
6272
  } | null | undefined;
6240
6273
  origin?: {
6241
6274
  project_id?: string | undefined;
@@ -6524,6 +6557,9 @@ declare const Prompt$1: z.ZodObject<{
6524
6557
  type: "global";
6525
6558
  name: string;
6526
6559
  function_type?: "preprocessor" | undefined;
6560
+ } | {
6561
+ code: string;
6562
+ type: "inline";
6527
6563
  } | null | undefined;
6528
6564
  origin?: {
6529
6565
  project_id?: string | undefined;
@@ -6608,7 +6644,6 @@ declare const PromptSessionEvent: z.ZodObject<{
6608
6644
  type PromptSessionEventType = z.infer<typeof PromptSessionEvent>;
6609
6645
 
6610
6646
  interface GlobalHookAsyncLocalStorage<T> {
6611
- enterWith(store: T): void;
6612
6647
  run<R>(store: T | undefined, callback: () => R): R;
6613
6648
  getStore(): T | undefined;
6614
6649
  }
@@ -7710,6 +7745,14 @@ interface PromptKey {
7710
7745
  */
7711
7746
  id?: string;
7712
7747
  }
7748
+ type PromptMemoryCacheEntry = {
7749
+ value: Prompt;
7750
+ resolvedOrgIdentity?: string;
7751
+ };
7752
+ type PromptDiskCacheEntry = {
7753
+ value: ReturnType<Prompt["_internalSerializeForCache"]>;
7754
+ resolvedOrgIdentity?: string;
7755
+ };
7713
7756
  /**
7714
7757
  * A configurable cache for Braintrust prompts with optional in-memory and filesystem storage.
7715
7758
  *
@@ -7718,10 +7761,19 @@ interface PromptKey {
7718
7761
  declare class PromptCache {
7719
7762
  private readonly memoryCache?;
7720
7763
  private readonly diskCache?;
7764
+ private readonly namespace?;
7765
+ private readonly expectedResolvedOrgIdentity?;
7721
7766
  constructor(options: {
7722
- memoryCache?: LRUCache<string, Prompt>;
7723
- diskCache?: DiskCache<Prompt>;
7767
+ memoryCache?: LRUCache<string, PromptMemoryCacheEntry>;
7768
+ diskCache?: DiskCache<PromptDiskCacheEntry>;
7769
+ namespace?: string;
7770
+ expectedResolvedOrgIdentity?: string;
7724
7771
  });
7772
+ /**
7773
+ * Returns a cache view that shares the same storage layers but isolates all
7774
+ * entries under the provided namespace.
7775
+ */
7776
+ withNamespace(namespace: string, expectedResolvedOrgIdentity?: string): PromptCache;
7725
7777
  /**
7726
7778
  * Retrieves a prompt from the cache.
7727
7779
  * First checks the in-memory LRU cache, then falls back to checking the disk cache if available.
@@ -7745,13 +7797,26 @@ interface ParametersKey {
7745
7797
  projectName?: string;
7746
7798
  id?: string;
7747
7799
  }
7800
+ type ParametersMemoryCacheEntry = {
7801
+ value: RemoteEvalParameters;
7802
+ resolvedOrgIdentity?: string;
7803
+ };
7804
+ type ParametersDiskCacheEntry = {
7805
+ value: ReturnType<RemoteEvalParameters["_internalSerializeForCache"]>;
7806
+ resolvedOrgIdentity?: string;
7807
+ };
7748
7808
  declare class ParametersCache {
7749
7809
  private readonly memoryCache?;
7750
7810
  private readonly diskCache?;
7811
+ private readonly namespace?;
7812
+ private readonly expectedResolvedOrgIdentity?;
7751
7813
  constructor(options: {
7752
- memoryCache?: LRUCache<string, RemoteEvalParameters>;
7753
- diskCache?: DiskCache<RemoteEvalParameters>;
7814
+ memoryCache?: LRUCache<string, ParametersMemoryCacheEntry>;
7815
+ diskCache?: DiskCache<ParametersDiskCacheEntry>;
7816
+ namespace?: string;
7817
+ expectedResolvedOrgIdentity?: string;
7754
7818
  });
7819
+ withNamespace(namespace: string, expectedResolvedOrgIdentity?: string): ParametersCache;
7755
7820
  get(key: ParametersKey): Promise<RemoteEvalParameters | undefined>;
7756
7821
  set(key: ParametersKey, value: RemoteEvalParameters): Promise<void>;
7757
7822
  }
@@ -8224,8 +8289,17 @@ declare const loginSchema: z.ZodObject<{
8224
8289
  debugLogLevelDisabled?: boolean | undefined;
8225
8290
  }>;
8226
8291
  type SerializedBraintrustState = z.infer<typeof loginSchema>;
8292
+ type ResolvedLoaderLoginOptions = Required<Pick<LoginOptions, "apiKey" | "appUrl" | "fetch">> & Pick<LoginOptions, "orgName"> & {
8293
+ forceLogin?: boolean;
8294
+ credentialCacheNamespace: string;
8295
+ existingState?: BraintrustState;
8296
+ };
8297
+ type LoaderCacheViews = {
8298
+ promptCache: PromptCache;
8299
+ parametersCache: ParametersCache;
8300
+ };
8301
+ type LoaderRequestState = Pick<BraintrustState, "appUrl" | "orgId" | "apiConn">;
8227
8302
  declare class BraintrustState {
8228
- private loginParams;
8229
8303
  id: string;
8230
8304
  currentExperiment: Experiment | undefined;
8231
8305
  currentLogger: Logger<false> | undefined;
@@ -8256,12 +8330,23 @@ declare class BraintrustState {
8256
8330
  private _otelFlushCallback;
8257
8331
  spanOriginEnvironment: SpanOriginEnvironment | undefined;
8258
8332
  private traceContextSigningSecret;
8333
+ private loaderLoginCache;
8334
+ private readonly loginParams;
8335
+ private activeLoginOrgNameSelector;
8259
8336
  constructor(loginParams: LoginOptions);
8260
8337
  /** @internal */
8261
8338
  _internalSetTraceContextSigningSecret(secret: string | undefined): void;
8262
8339
  /** @internal */
8263
8340
  _internalGetTraceContextSigningSecret(): string | undefined;
8264
8341
  resetLoginInfo(): void;
8342
+ /** @internal */
8343
+ _internalResolveLoaderLoginOptions({ apiKey, appUrl, orgName, fetch, forceLogin, }: Pick<LoginOptions, "apiKey" | "appUrl" | "orgName" | "fetch"> & {
8344
+ forceLogin?: boolean;
8345
+ }): Promise<ResolvedLoaderLoginOptions>;
8346
+ /** @internal */
8347
+ _internalGetLoaderCacheViews(loginOptions: ResolvedLoaderLoginOptions, requestState?: LoaderRequestState): LoaderCacheViews;
8348
+ /** @internal */
8349
+ _internalGetLoaderState({ apiKey, appUrl, orgName, fetch, forceLogin, existingState, }: ResolvedLoaderLoginOptions): Promise<LoaderRequestState>;
8265
8350
  resetIdGenState(): void;
8266
8351
  [RESET_CONTEXT_MANAGER_STATE](): void;
8267
8352
  get idGenerator(): IDGenerator;
@@ -8300,11 +8385,12 @@ declare class BraintrustState {
8300
8385
  toString(): string;
8301
8386
  }
8302
8387
  declare class HTTPConnection {
8388
+ private readonly classifyTransportErrors;
8303
8389
  base_url: string;
8304
8390
  token: string | null;
8305
8391
  headers: Record<string, string>;
8306
8392
  fetch: typeof globalThis.fetch;
8307
- constructor(base_url: string, fetch: typeof globalThis.fetch);
8393
+ constructor(base_url: string, fetch: typeof globalThis.fetch, classifyTransportErrors?: boolean);
8308
8394
  setFetch(fetch: typeof globalThis.fetch): void;
8309
8395
  ping(): Promise<boolean>;
8310
8396
  make_long_lived(): void;
@@ -8953,6 +9039,251 @@ declare class Prompt<HasId extends boolean = true, HasVersion extends boolean =
8953
9039
  }): PromptBlockDataType;
8954
9040
  private getParsedPromptData;
8955
9041
  static isPrompt(data: unknown): data is Prompt<boolean, boolean>;
9042
+ /** @internal */
9043
+ _internalSerializeForCache(): {
9044
+ metadata: {
9045
+ id: string;
9046
+ created: string;
9047
+ project_id: string;
9048
+ _xact_id: string;
9049
+ prompt_session_id: string;
9050
+ function_type?: "llm" | "scorer" | "task" | "tool" | "custom_view" | "preprocessor" | "facet" | "classifier" | "tag" | "parameters" | "sandbox" | null | undefined;
9051
+ tags?: string[] | null | undefined;
9052
+ _pagination_key?: string | null | undefined;
9053
+ completion?: unknown;
9054
+ prompt_data?: unknown;
9055
+ function_data?: unknown;
9056
+ prompt_session_data?: unknown;
9057
+ object_data?: unknown;
9058
+ } | PromptRowWithId<HasId, HasVersion>;
9059
+ defaults: Partial<Omit<z.objectOutputType<{
9060
+ use_cache: z.ZodOptional<z.ZodBoolean>;
9061
+ reasoning_enabled: z.ZodOptional<z.ZodBoolean>;
9062
+ reasoning_budget: z.ZodOptional<z.ZodNumber>;
9063
+ temperature: z.ZodOptional<z.ZodNumber>;
9064
+ top_p: z.ZodOptional<z.ZodNumber>;
9065
+ max_tokens: z.ZodOptional<z.ZodNumber>;
9066
+ max_completion_tokens: z.ZodOptional<z.ZodNumber>;
9067
+ frequency_penalty: z.ZodOptional<z.ZodNumber>;
9068
+ presence_penalty: z.ZodOptional<z.ZodNumber>;
9069
+ response_format: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
9070
+ type: z.ZodLiteral<"json_object">;
9071
+ }, "strip", z.ZodTypeAny, {
9072
+ type: "json_object";
9073
+ }, {
9074
+ type: "json_object";
9075
+ }>, z.ZodObject<{
9076
+ type: z.ZodLiteral<"json_schema">;
9077
+ json_schema: z.ZodObject<{
9078
+ name: z.ZodString;
9079
+ description: z.ZodOptional<z.ZodString>;
9080
+ schema: z.ZodOptional<z.ZodUnion<[z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, z.ZodString]>>;
9081
+ strict: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodNull]>>;
9082
+ }, "strip", z.ZodTypeAny, {
9083
+ name: string;
9084
+ description?: string | undefined;
9085
+ schema?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
9086
+ strict?: boolean | null | undefined;
9087
+ }, {
9088
+ name: string;
9089
+ description?: string | undefined;
9090
+ schema?: string | z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
9091
+ strict?: boolean | null | undefined;
9092
+ }>;
9093
+ }, "strip", z.ZodTypeAny, {
9094
+ type: "json_schema";
9095
+ json_schema: {
9096
+ name: string;
9097
+ description?: string | undefined;
9098
+ schema?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
9099
+ strict?: boolean | null | undefined;
9100
+ };
9101
+ }, {
9102
+ type: "json_schema";
9103
+ json_schema: {
9104
+ name: string;
9105
+ description?: string | undefined;
9106
+ schema?: string | z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
9107
+ strict?: boolean | null | undefined;
9108
+ };
9109
+ }>, z.ZodObject<{
9110
+ type: z.ZodLiteral<"text">;
9111
+ }, "strip", z.ZodTypeAny, {
9112
+ type: "text";
9113
+ }, {
9114
+ type: "text";
9115
+ }>, z.ZodNull]>>;
9116
+ tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
9117
+ type: z.ZodLiteral<"function">;
9118
+ function: z.ZodObject<{
9119
+ name: z.ZodString;
9120
+ }, "strip", z.ZodTypeAny, {
9121
+ name: string;
9122
+ }, {
9123
+ name: string;
9124
+ }>;
9125
+ }, "strip", z.ZodTypeAny, {
9126
+ function: {
9127
+ name: string;
9128
+ };
9129
+ type: "function";
9130
+ }, {
9131
+ function: {
9132
+ name: string;
9133
+ };
9134
+ type: "function";
9135
+ }>]>>;
9136
+ function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
9137
+ name: z.ZodString;
9138
+ }, "strip", z.ZodTypeAny, {
9139
+ name: string;
9140
+ }, {
9141
+ name: string;
9142
+ }>]>>;
9143
+ n: z.ZodOptional<z.ZodNumber>;
9144
+ stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
9145
+ reasoning_effort: z.ZodOptional<z.ZodEnum<["none", "minimal", "low", "medium", "high"]>>;
9146
+ verbosity: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
9147
+ }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
9148
+ use_cache: z.ZodOptional<z.ZodBoolean>;
9149
+ reasoning_enabled: z.ZodOptional<z.ZodBoolean>;
9150
+ reasoning_budget: z.ZodOptional<z.ZodNumber>;
9151
+ max_tokens: z.ZodNumber;
9152
+ temperature: z.ZodNumber;
9153
+ top_p: z.ZodOptional<z.ZodNumber>;
9154
+ top_k: z.ZodOptional<z.ZodNumber>;
9155
+ stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
9156
+ max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
9157
+ }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
9158
+ use_cache: z.ZodOptional<z.ZodBoolean>;
9159
+ reasoning_enabled: z.ZodOptional<z.ZodBoolean>;
9160
+ reasoning_budget: z.ZodOptional<z.ZodNumber>;
9161
+ temperature: z.ZodOptional<z.ZodNumber>;
9162
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
9163
+ topP: z.ZodOptional<z.ZodNumber>;
9164
+ topK: z.ZodOptional<z.ZodNumber>;
9165
+ }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
9166
+ use_cache: z.ZodOptional<z.ZodBoolean>;
9167
+ reasoning_enabled: z.ZodOptional<z.ZodBoolean>;
9168
+ reasoning_budget: z.ZodOptional<z.ZodNumber>;
9169
+ temperature: z.ZodOptional<z.ZodNumber>;
9170
+ topK: z.ZodOptional<z.ZodNumber>;
9171
+ }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
9172
+ use_cache: z.ZodOptional<z.ZodBoolean>;
9173
+ reasoning_enabled: z.ZodOptional<z.ZodBoolean>;
9174
+ reasoning_budget: z.ZodOptional<z.ZodNumber>;
9175
+ }, z.ZodTypeAny, "passthrough"> | undefined, "response_format" | "reasoning_effort" | "use_cache"> & Omit<{
9176
+ max_tokens: number;
9177
+ temperature?: number | undefined;
9178
+ top_p?: number | undefined;
9179
+ max_completion_tokens?: number | undefined;
9180
+ frequency_penalty?: number | undefined;
9181
+ presence_penalty?: number | undefined;
9182
+ response_format?: {
9183
+ type: "json_object";
9184
+ } | {
9185
+ type: "json_schema";
9186
+ json_schema: {
9187
+ name: string;
9188
+ description?: string | undefined;
9189
+ schema?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
9190
+ strict?: boolean | null | undefined;
9191
+ };
9192
+ } | {
9193
+ type: "text";
9194
+ } | null | undefined;
9195
+ tool_choice?: "auto" | "none" | "required" | {
9196
+ function: {
9197
+ name: string;
9198
+ };
9199
+ type: "function";
9200
+ } | undefined;
9201
+ function_call?: "auto" | "none" | {
9202
+ name: string;
9203
+ } | undefined;
9204
+ n?: number | undefined;
9205
+ stop?: string[] | undefined;
9206
+ reasoning_effort?: "none" | "minimal" | "low" | "medium" | "high" | undefined;
9207
+ verbosity?: "low" | "medium" | "high" | undefined;
9208
+ top_k?: number | undefined;
9209
+ stop_sequences?: string[] | undefined;
9210
+ reasoning_enabled?: boolean | undefined;
9211
+ reasoning_budget?: number | undefined;
9212
+ max_tokens_to_sample?: number | undefined;
9213
+ maxOutputTokens?: number | undefined;
9214
+ topP?: number | undefined;
9215
+ topK?: number | undefined;
9216
+ use_cache?: boolean | undefined;
9217
+ }, "response_format" | "reasoning_effort" | "use_cache"> & {
9218
+ reasoning_effort?: CompiledPromptReasoningEffort;
9219
+ response_format?: {
9220
+ type: "json_object";
9221
+ } | {
9222
+ type: "text";
9223
+ } | (Omit<{
9224
+ type: "json_schema";
9225
+ json_schema: {
9226
+ name: string;
9227
+ description?: string | undefined;
9228
+ schema?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
9229
+ strict?: boolean | null | undefined;
9230
+ };
9231
+ }, "json_schema"> & {
9232
+ json_schema: Omit<{
9233
+ name: string;
9234
+ description?: string | undefined;
9235
+ schema?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
9236
+ strict?: boolean | null | undefined;
9237
+ }, "schema"> & {
9238
+ schema?: Record<string, unknown> | undefined;
9239
+ };
9240
+ }) | undefined;
9241
+ model: string;
9242
+ } & {
9243
+ max_tokens: number;
9244
+ temperature?: number | undefined;
9245
+ top_p?: number | undefined;
9246
+ max_completion_tokens?: number | undefined;
9247
+ frequency_penalty?: number | undefined;
9248
+ presence_penalty?: number | undefined;
9249
+ response_format?: {
9250
+ type: "json_object";
9251
+ } | {
9252
+ type: "json_schema";
9253
+ json_schema: {
9254
+ name: string;
9255
+ description?: string | undefined;
9256
+ schema?: string | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
9257
+ strict?: boolean | null | undefined;
9258
+ };
9259
+ } | {
9260
+ type: "text";
9261
+ } | null | undefined;
9262
+ tool_choice?: "auto" | "none" | "required" | {
9263
+ function: {
9264
+ name: string;
9265
+ };
9266
+ type: "function";
9267
+ } | undefined;
9268
+ function_call?: "auto" | "none" | {
9269
+ name: string;
9270
+ } | undefined;
9271
+ n?: number | undefined;
9272
+ stop?: string[] | undefined;
9273
+ reasoning_effort?: "none" | "minimal" | "low" | "medium" | "high" | undefined;
9274
+ verbosity?: "low" | "medium" | "high" | undefined;
9275
+ top_k?: number | undefined;
9276
+ stop_sequences?: string[] | undefined;
9277
+ reasoning_enabled?: boolean | undefined;
9278
+ reasoning_budget?: number | undefined;
9279
+ max_tokens_to_sample?: number | undefined;
9280
+ maxOutputTokens?: number | undefined;
9281
+ topP?: number | undefined;
9282
+ topK?: number | undefined;
9283
+ use_cache?: boolean | undefined;
9284
+ } & ChatPrompt & CompletionPrompt>;
9285
+ noTrace: boolean;
9286
+ };
8956
9287
  static fromPromptData(name: string, promptData: PromptDataType): Prompt<false, false>;
8957
9288
  }
8958
9289
  declare class RemoteEvalParameters<HasId extends boolean = true, HasVersion extends boolean = true, T extends Record<string, unknown> = Record<string, unknown>> {
@@ -8966,6 +9297,24 @@ declare class RemoteEvalParameters<HasId extends boolean = true, HasVersion exte
8966
9297
  get version(): HasVersion extends true ? TransactionId : TransactionId | undefined;
8967
9298
  get schema(): Record<string, unknown>;
8968
9299
  get data(): T;
9300
+ /** @internal */
9301
+ _internalSerializeForCache(): {
9302
+ metadata: {
9303
+ id: string;
9304
+ project_id: string;
9305
+ name: string;
9306
+ slug: string;
9307
+ function_type: "parameters";
9308
+ _xact_id: string;
9309
+ function_data: {
9310
+ type: "parameters";
9311
+ __schema: Record<string, unknown>;
9312
+ data?: Record<string, unknown> | undefined;
9313
+ };
9314
+ description?: string | null | undefined;
9315
+ metadata?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | null | undefined;
9316
+ };
9317
+ };
8969
9318
  validate(data: unknown): boolean;
8970
9319
  static isParameters(x: unknown): x is RemoteEvalParameters<boolean, boolean, Record<string, unknown>>;
8971
9320
  }
@@ -9642,7 +9991,7 @@ type EveModelMessage = EveSystemModelMessage | {
9642
9991
  readonly role: "tool";
9643
9992
  };
9644
9993
  interface EveInstrumentationModelInput {
9645
- readonly instructions?: string | readonly EveSystemModelMessage[];
9994
+ readonly instructions?: string | EveSystemModelMessage | readonly EveSystemModelMessage[];
9646
9995
  readonly messages: readonly EveModelMessage[];
9647
9996
  }
9648
9997
  interface EveInstrumentationStepStartedEventInput {
@@ -9671,6 +10020,198 @@ interface EveInstrumentationDefinition {
9671
10020
  readonly recordOutputs?: boolean;
9672
10021
  readonly setup?: (context: EveInstrumentationSetupContext) => void;
9673
10022
  }
10023
+ /**
10024
+ * Vendored types for Eve's instrumentation-provider API, introduced in
10025
+ * eve@0.34.0. Keep this limited to lifecycle events consumed by Braintrust.
10026
+ */
10027
+ interface EveProviderSetupContext {
10028
+ readonly agentName: string;
10029
+ readonly environment?: "development" | "preview" | "production";
10030
+ readonly evaluation?: {
10031
+ readonly runId: string;
10032
+ };
10033
+ readonly frameworkVersion?: string;
10034
+ }
10035
+ interface EveProviderState {
10036
+ get(): EveJsonValue | undefined;
10037
+ set(value: EveJsonValue | undefined): void;
10038
+ }
10039
+ interface EveProviderContext {
10040
+ readonly state: EveProviderState;
10041
+ }
10042
+ interface EveInstrumentationAttemptScope {
10043
+ readonly attemptId: string;
10044
+ readonly attemptIndex: number;
10045
+ readonly functionId?: string;
10046
+ readonly rootSessionId?: string;
10047
+ readonly sessionId: string;
10048
+ readonly stepIndex: number;
10049
+ readonly turnId: string;
10050
+ }
10051
+ interface EveInstrumentationParentLineage {
10052
+ readonly callId: string;
10053
+ readonly sessionId: string;
10054
+ readonly subagentName?: string;
10055
+ readonly turnId: string;
10056
+ }
10057
+ interface EveInstrumentationTraceContext {
10058
+ readonly isRemote?: boolean;
10059
+ readonly spanId: string;
10060
+ readonly traceFlags: number;
10061
+ readonly traceId: string;
10062
+ }
10063
+ interface EveProviderTurnStartedEvent {
10064
+ readonly idempotencyKey: string;
10065
+ readonly parentLineage?: EveInstrumentationParentLineage;
10066
+ readonly parentTraceContext?: EveInstrumentationTraceContext;
10067
+ readonly rootSessionId: string;
10068
+ readonly sequence: number;
10069
+ readonly sessionId: string;
10070
+ readonly turnId: string;
10071
+ readonly type: "turn.started";
10072
+ }
10073
+ type EveProviderTurnTerminalEvent = {
10074
+ readonly idempotencyKey: string;
10075
+ readonly sessionId: string;
10076
+ readonly turnId: string;
10077
+ readonly type: "turn.cancelled" | "turn.completed";
10078
+ } | {
10079
+ readonly error?: unknown;
10080
+ readonly idempotencyKey: string;
10081
+ readonly sessionId: string;
10082
+ readonly turnId: string;
10083
+ readonly type: "turn.failed";
10084
+ };
10085
+ interface EveProviderModelCallStartedEvent {
10086
+ readonly idempotencyKey: string;
10087
+ readonly input?: EveInstrumentationModelInput;
10088
+ readonly model: {
10089
+ readonly modelId: string;
10090
+ readonly provider: string;
10091
+ };
10092
+ readonly scope: EveInstrumentationAttemptScope;
10093
+ readonly type: "model.call.started";
10094
+ }
10095
+ type EveProviderContentPart = {
10096
+ readonly text: string;
10097
+ readonly type: "text";
10098
+ } | {
10099
+ readonly text: string;
10100
+ readonly type: "reasoning";
10101
+ } | {
10102
+ readonly callId: string;
10103
+ readonly input: unknown;
10104
+ readonly toolName: string;
10105
+ readonly type: "tool-call";
10106
+ } | {
10107
+ readonly callId: string;
10108
+ readonly input: unknown;
10109
+ readonly output: unknown;
10110
+ readonly toolName: string;
10111
+ readonly type: "tool-result";
10112
+ } | {
10113
+ readonly callId: string;
10114
+ readonly error: unknown;
10115
+ readonly input: unknown;
10116
+ readonly toolName: string;
10117
+ readonly type: "tool-error";
10118
+ };
10119
+ interface EveProviderUsage {
10120
+ readonly inputTokenDetails?: {
10121
+ readonly cacheReadTokens?: number;
10122
+ readonly cacheWriteTokens?: number;
10123
+ };
10124
+ readonly inputTokens?: number;
10125
+ readonly outputTokens?: number;
10126
+ }
10127
+ type EveProviderModelCallTerminalEvent = {
10128
+ readonly content?: readonly EveProviderContentPart[];
10129
+ readonly finishReason: string;
10130
+ readonly idempotencyKey: string;
10131
+ readonly scope: EveInstrumentationAttemptScope;
10132
+ readonly type: "model.call.completed";
10133
+ readonly usage: EveProviderUsage;
10134
+ } | {
10135
+ readonly error?: unknown;
10136
+ readonly idempotencyKey: string;
10137
+ readonly scope: EveInstrumentationAttemptScope;
10138
+ readonly type: "model.call.failed";
10139
+ };
10140
+ type EveProviderActionKind = "load-skill" | "remote-agent-call" | "subagent-call" | "tool-call";
10141
+ interface EveProviderActionStartedEvent {
10142
+ readonly callId: string;
10143
+ readonly idempotencyKey: string;
10144
+ readonly input?: unknown;
10145
+ readonly kind: EveProviderActionKind;
10146
+ readonly name: string;
10147
+ readonly scope: EveInstrumentationAttemptScope;
10148
+ readonly type: "action.started";
10149
+ }
10150
+ type EveProviderActionTerminalEvent = {
10151
+ readonly acceptedAtMs?: number;
10152
+ readonly idempotencyKey: string;
10153
+ readonly outcome: "completed";
10154
+ readonly output: {
10155
+ readonly output?: unknown;
10156
+ readonly type: "result";
10157
+ } | {
10158
+ readonly error?: unknown;
10159
+ readonly type: "error";
10160
+ };
10161
+ readonly scope: EveInstrumentationAttemptScope;
10162
+ readonly type: "action.completed";
10163
+ readonly usage?: EveProviderUsage;
10164
+ } | {
10165
+ readonly acceptedAtMs?: number;
10166
+ readonly error?: unknown;
10167
+ readonly errorCode?: string;
10168
+ readonly idempotencyKey: string;
10169
+ readonly outcome: "abandoned" | "cancelled" | "failed" | "rejected";
10170
+ readonly scope: EveInstrumentationAttemptScope;
10171
+ readonly type: "action.failed";
10172
+ };
10173
+ type EveProviderStepAttemptTerminalEvent = {
10174
+ readonly error?: unknown;
10175
+ readonly idempotencyKey: string;
10176
+ readonly scope: EveInstrumentationAttemptScope;
10177
+ readonly type: "step.attempt.completed" | "step.attempt.failed";
10178
+ };
10179
+ type EveProviderHandler<TEvent> = (event: TEvent, context: EveProviderContext) => void | PromiseLike<void>;
10180
+ type EveChannelAudience = "private" | "public" | "unknown";
10181
+ interface EveTraceCaptureContext {
10182
+ readonly agentName?: string;
10183
+ readonly audience: EveChannelAudience;
10184
+ readonly channelType?: string;
10185
+ }
10186
+ type EveTracePolicyDecision = {
10187
+ readonly emit: false;
10188
+ } | {
10189
+ readonly emit: true;
10190
+ readonly recordInputs: boolean;
10191
+ readonly recordOutputs: boolean;
10192
+ };
10193
+ type EveTraceCapturePolicy = (trace: EveTraceCaptureContext) => EveTracePolicyDecision | boolean;
10194
+ interface EveProviderDefinition {
10195
+ readonly capture?: "content" | "metadata";
10196
+ readonly tracePolicy?: EveTraceCapturePolicy;
10197
+ readonly events?: {
10198
+ readonly "action.completed"?: EveProviderHandler<EveProviderActionTerminalEvent>;
10199
+ readonly "action.failed"?: EveProviderHandler<EveProviderActionTerminalEvent>;
10200
+ readonly "action.started"?: EveProviderHandler<EveProviderActionStartedEvent>;
10201
+ readonly "model.call.completed"?: EveProviderHandler<EveProviderModelCallTerminalEvent>;
10202
+ readonly "model.call.failed"?: EveProviderHandler<EveProviderModelCallTerminalEvent>;
10203
+ readonly "model.call.started"?: EveProviderHandler<EveProviderModelCallStartedEvent>;
10204
+ readonly "step.attempt.completed"?: EveProviderHandler<EveProviderStepAttemptTerminalEvent>;
10205
+ readonly "step.attempt.failed"?: EveProviderHandler<EveProviderStepAttemptTerminalEvent>;
10206
+ readonly "turn.cancelled"?: EveProviderHandler<EveProviderTurnTerminalEvent>;
10207
+ readonly "turn.completed"?: EveProviderHandler<EveProviderTurnTerminalEvent>;
10208
+ readonly "turn.failed"?: EveProviderHandler<EveProviderTurnTerminalEvent>;
10209
+ readonly "turn.started"?: EveProviderHandler<EveProviderTurnStartedEvent>;
10210
+ };
10211
+ readonly flush?: () => void | PromiseLike<void>;
10212
+ readonly setup?: (context: EveProviderSetupContext) => void | PromiseLike<void>;
10213
+ readonly shutdown?: () => void | PromiseLike<void>;
10214
+ }
9674
10215
 
9675
10216
  type EveStateHandle<T> = {
9676
10217
  get(): T;
@@ -9682,7 +10223,20 @@ declare function braintrustEveHook(options: {
9682
10223
  defineState: EveDefineState;
9683
10224
  metadata?: Record<string, unknown>;
9684
10225
  }): EveHookDefinition;
9685
- /** Eve instrumentation helper for logger setup and durable LLM input capture. */
10226
+
10227
+ type EveProviderInstrumentationOptions = {
10228
+ metadata?: Record<string, unknown>;
10229
+ setup?: EveProviderDefinition["setup"];
10230
+ };
10231
+ /**
10232
+ * Braintrust instrumentation for Eve.
10233
+ *
10234
+ * Pass `defineState` when using Eve's legacy authored instrumentation API.
10235
+ * With Eve 0.34+, omit `defineState` to use the instrumentation-provider
10236
+ * lifecycle and enable `experimental.instrumentationProviders` on the agent.
10237
+ * The result is ready to export directly from the instrumentation module.
10238
+ */
10239
+ declare function braintrustEveInstrumentation(options: EveProviderInstrumentationOptions): EveProviderDefinition;
9686
10240
  declare function braintrustEveInstrumentation(options: {
9687
10241
  defineState: EveDefineState;
9688
10242
  setup?: EveInstrumentationDefinition["setup"];