braintrust 3.23.0 → 3.24.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 (51) hide show
  1. package/dev/dist/index.d.mts +6 -0
  2. package/dev/dist/index.d.ts +6 -0
  3. package/dev/dist/index.js +902 -588
  4. package/dev/dist/index.mjs +320 -6
  5. package/dist/apply-auto-instrumentation.js +211 -189
  6. package/dist/apply-auto-instrumentation.mjs +23 -1
  7. package/dist/auto-instrumentations/bundler/esbuild.cjs +40 -0
  8. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  9. package/dist/auto-instrumentations/bundler/next.cjs +40 -0
  10. package/dist/auto-instrumentations/bundler/next.mjs +3 -3
  11. package/dist/auto-instrumentations/bundler/rollup.cjs +40 -0
  12. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  13. package/dist/auto-instrumentations/bundler/vite.cjs +40 -0
  14. package/dist/auto-instrumentations/bundler/vite.d.mts +1 -1
  15. package/dist/auto-instrumentations/bundler/vite.d.ts +1 -1
  16. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  17. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +40 -0
  18. package/dist/auto-instrumentations/bundler/webpack.cjs +40 -0
  19. package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
  20. package/dist/auto-instrumentations/{chunk-KIMLYPRW.mjs → chunk-BURMPO7L.mjs} +1 -1
  21. package/dist/auto-instrumentations/{chunk-YXLNSAMJ.mjs → chunk-F43DNLPD.mjs} +40 -0
  22. package/dist/auto-instrumentations/{chunk-EXY7QCJD.mjs → chunk-GSZHTAQW.mjs} +1 -1
  23. package/dist/auto-instrumentations/hook.mjs +150 -1
  24. package/dist/auto-instrumentations/index.cjs +40 -0
  25. package/dist/auto-instrumentations/index.mjs +1 -1
  26. package/dist/browser.d.mts +131 -9
  27. package/dist/browser.d.ts +131 -9
  28. package/dist/browser.js +703 -67
  29. package/dist/browser.mjs +703 -67
  30. package/dist/{chunk-CDIKAHDZ.js → chunk-7AUY2XWX.js} +21 -1
  31. package/dist/{chunk-36IPYKMG.mjs → chunk-7F6GCRHH.mjs} +20 -0
  32. package/dist/{chunk-FZWPFCVE.js → chunk-SU6EHKJV.js} +1085 -801
  33. package/dist/{chunk-IXL4PMY4.mjs → chunk-XE5FS7QY.mjs} +291 -7
  34. package/dist/cli.js +328 -10
  35. package/dist/edge-light.js +703 -67
  36. package/dist/edge-light.mjs +703 -67
  37. package/dist/index.d.mts +131 -9
  38. package/dist/index.d.ts +131 -9
  39. package/dist/index.js +891 -532
  40. package/dist/index.mjs +423 -64
  41. package/dist/instrumentation/index.d.mts +130 -9
  42. package/dist/instrumentation/index.d.ts +130 -9
  43. package/dist/instrumentation/index.js +601 -67
  44. package/dist/instrumentation/index.mjs +601 -67
  45. package/dist/vitest-evals-reporter.js +17 -16
  46. package/dist/vitest-evals-reporter.mjs +3 -2
  47. package/dist/workerd.js +703 -67
  48. package/dist/workerd.mjs +703 -67
  49. package/package.json +3 -3
  50. package/util/dist/index.js +4 -0
  51. package/util/dist/index.mjs +4 -0
@@ -7571,6 +7571,11 @@ declare class SpanCache {
7571
7571
  dispose(): void;
7572
7572
  }
7573
7573
 
7574
+ type SpanOriginEnvironment = {
7575
+ type?: string;
7576
+ name?: string;
7577
+ };
7578
+
7574
7579
  /// <reference lib="dom" />
7575
7580
 
7576
7581
  declare const RESET_CONTEXT_MANAGER_STATE: unique symbol;
@@ -7936,6 +7941,7 @@ declare class BraintrustState {
7936
7941
  private _idGenerator;
7937
7942
  private _contextManager;
7938
7943
  private _otelFlushCallback;
7944
+ spanOriginEnvironment: SpanOriginEnvironment | undefined;
7939
7945
  constructor(loginParams: LoginOptions);
7940
7946
  resetLoginInfo(): void;
7941
7947
  resetIdGenState(): void;
@@ -8963,8 +8969,8 @@ type EveJsonObject = {
8963
8969
  readonly [key: string]: EveJsonValue;
8964
8970
  };
8965
8971
  interface EveHookContext {
8966
- readonly session?: {
8967
- readonly id?: string;
8972
+ readonly session: {
8973
+ readonly id: string;
8968
8974
  readonly parent?: {
8969
8975
  readonly callId?: string;
8970
8976
  readonly sessionId?: string;
@@ -9065,6 +9071,15 @@ type EveHandleMessageStreamEvent = {
9065
9071
  };
9066
9072
  readonly meta?: EveStreamEventMeta;
9067
9073
  readonly type: "message.completed";
9074
+ } | {
9075
+ readonly data: {
9076
+ readonly reasoning: string;
9077
+ readonly sequence: number;
9078
+ readonly stepIndex: number;
9079
+ readonly turnId: string;
9080
+ };
9081
+ readonly meta?: EveStreamEventMeta;
9082
+ readonly type: "reasoning.completed";
9068
9083
  } | {
9069
9084
  readonly data: {
9070
9085
  readonly result: EveJsonValue;
@@ -9198,22 +9213,128 @@ interface EveHookDefinition {
9198
9213
  interface EveInstrumentationSetupContext {
9199
9214
  readonly agentName: string;
9200
9215
  }
9216
+ type EveTextPart = {
9217
+ readonly text: string;
9218
+ readonly type: "text";
9219
+ };
9220
+ type EveImagePart = {
9221
+ readonly image: unknown;
9222
+ readonly mediaType?: string;
9223
+ readonly type: "image";
9224
+ };
9225
+ type EveFilePart = {
9226
+ readonly data: unknown;
9227
+ readonly filename?: string;
9228
+ readonly mediaType: string;
9229
+ readonly type: "file";
9230
+ };
9231
+ type EveReasoningPart = {
9232
+ readonly text: string;
9233
+ readonly type: "reasoning";
9234
+ };
9235
+ type EveReasoningFilePart = {
9236
+ readonly data: unknown;
9237
+ readonly mediaType: string;
9238
+ readonly type: "reasoning-file";
9239
+ };
9240
+ type EveCustomPart = {
9241
+ readonly kind: `${string}.${string}`;
9242
+ readonly type: "custom";
9243
+ };
9244
+ type EveToolCallPart = {
9245
+ readonly input: unknown;
9246
+ readonly providerExecuted?: boolean;
9247
+ readonly toolCallId: string;
9248
+ readonly toolName: string;
9249
+ readonly type: "tool-call";
9250
+ };
9251
+ type EveToolResultContentPart = EveTextPart | EveFilePart | {
9252
+ readonly data: string;
9253
+ readonly filename?: string;
9254
+ readonly mediaType: string;
9255
+ readonly type: "file-data";
9256
+ } | {
9257
+ readonly mediaType?: string;
9258
+ readonly type: "file-url";
9259
+ readonly url: string;
9260
+ } | {
9261
+ readonly fileId: string | Readonly<Record<string, string>>;
9262
+ readonly type: "file-id" | "image-file-id";
9263
+ } | {
9264
+ readonly providerReference: Readonly<Record<string, string>>;
9265
+ readonly type: "file-reference" | "image-file-reference";
9266
+ } | {
9267
+ readonly data: string;
9268
+ readonly mediaType: string;
9269
+ readonly type: "image-data";
9270
+ } | {
9271
+ readonly type: "image-url";
9272
+ readonly url: string;
9273
+ } | {
9274
+ readonly type: "custom";
9275
+ };
9276
+ type EveToolResultOutput = {
9277
+ readonly type: "text" | "error-text";
9278
+ readonly value: string;
9279
+ } | {
9280
+ readonly type: "json" | "error-json";
9281
+ readonly value: EveJsonValue;
9282
+ } | {
9283
+ readonly reason?: string;
9284
+ readonly type: "execution-denied";
9285
+ } | {
9286
+ readonly type: "content";
9287
+ readonly value: readonly EveToolResultContentPart[];
9288
+ };
9289
+ type EveToolResultPart = {
9290
+ readonly output: EveToolResultOutput;
9291
+ readonly toolCallId: string;
9292
+ readonly toolName: string;
9293
+ readonly type: "tool-result";
9294
+ };
9295
+ type EveToolApprovalRequest = {
9296
+ readonly approvalId: string;
9297
+ readonly isAutomatic?: boolean;
9298
+ readonly signature?: string;
9299
+ readonly toolCallId: string;
9300
+ readonly type: "tool-approval-request";
9301
+ };
9302
+ type EveToolApprovalResponse = {
9303
+ readonly approvalId: string;
9304
+ readonly approved: boolean;
9305
+ readonly providerExecuted?: boolean;
9306
+ readonly reason?: string;
9307
+ readonly type: "tool-approval-response";
9308
+ };
9309
+ type EveSystemModelMessage = {
9310
+ readonly content: string;
9311
+ readonly role: "system";
9312
+ };
9313
+ type EveModelMessage = EveSystemModelMessage | {
9314
+ readonly content: string | readonly (EveTextPart | EveImagePart | EveFilePart)[];
9315
+ readonly role: "user";
9316
+ } | {
9317
+ readonly content: string | readonly (EveTextPart | EveCustomPart | EveFilePart | EveReasoningPart | EveReasoningFilePart | EveToolCallPart | EveToolResultPart | EveToolApprovalRequest)[];
9318
+ readonly role: "assistant";
9319
+ } | {
9320
+ readonly content: readonly (EveToolResultPart | EveToolApprovalResponse)[];
9321
+ readonly role: "tool";
9322
+ };
9201
9323
  interface EveInstrumentationModelInput {
9202
- readonly instructions?: string | readonly EveJsonObject[];
9203
- readonly messages: readonly EveJsonObject[];
9324
+ readonly instructions?: string | readonly EveSystemModelMessage[];
9325
+ readonly messages: readonly EveModelMessage[];
9204
9326
  }
9205
9327
  interface EveInstrumentationStepStartedEventInput {
9206
- readonly channel?: unknown;
9207
9328
  readonly modelInput: EveInstrumentationModelInput;
9208
9329
  readonly session: {
9209
- readonly id?: string;
9330
+ readonly id: string;
9210
9331
  };
9211
9332
  readonly step: {
9212
- readonly index?: number;
9333
+ readonly index: number;
9213
9334
  };
9214
9335
  readonly turn: {
9215
- readonly id?: string;
9216
- readonly sequence?: number;
9336
+ readonly id: string;
9337
+ readonly sequence: number;
9217
9338
  };
9218
9339
  }
9219
9340
  interface EveInstrumentationDefinition {
@@ -7571,6 +7571,11 @@ declare class SpanCache {
7571
7571
  dispose(): void;
7572
7572
  }
7573
7573
 
7574
+ type SpanOriginEnvironment = {
7575
+ type?: string;
7576
+ name?: string;
7577
+ };
7578
+
7574
7579
  /// <reference lib="dom" />
7575
7580
 
7576
7581
  declare const RESET_CONTEXT_MANAGER_STATE: unique symbol;
@@ -7936,6 +7941,7 @@ declare class BraintrustState {
7936
7941
  private _idGenerator;
7937
7942
  private _contextManager;
7938
7943
  private _otelFlushCallback;
7944
+ spanOriginEnvironment: SpanOriginEnvironment | undefined;
7939
7945
  constructor(loginParams: LoginOptions);
7940
7946
  resetLoginInfo(): void;
7941
7947
  resetIdGenState(): void;
@@ -8963,8 +8969,8 @@ type EveJsonObject = {
8963
8969
  readonly [key: string]: EveJsonValue;
8964
8970
  };
8965
8971
  interface EveHookContext {
8966
- readonly session?: {
8967
- readonly id?: string;
8972
+ readonly session: {
8973
+ readonly id: string;
8968
8974
  readonly parent?: {
8969
8975
  readonly callId?: string;
8970
8976
  readonly sessionId?: string;
@@ -9065,6 +9071,15 @@ type EveHandleMessageStreamEvent = {
9065
9071
  };
9066
9072
  readonly meta?: EveStreamEventMeta;
9067
9073
  readonly type: "message.completed";
9074
+ } | {
9075
+ readonly data: {
9076
+ readonly reasoning: string;
9077
+ readonly sequence: number;
9078
+ readonly stepIndex: number;
9079
+ readonly turnId: string;
9080
+ };
9081
+ readonly meta?: EveStreamEventMeta;
9082
+ readonly type: "reasoning.completed";
9068
9083
  } | {
9069
9084
  readonly data: {
9070
9085
  readonly result: EveJsonValue;
@@ -9198,22 +9213,128 @@ interface EveHookDefinition {
9198
9213
  interface EveInstrumentationSetupContext {
9199
9214
  readonly agentName: string;
9200
9215
  }
9216
+ type EveTextPart = {
9217
+ readonly text: string;
9218
+ readonly type: "text";
9219
+ };
9220
+ type EveImagePart = {
9221
+ readonly image: unknown;
9222
+ readonly mediaType?: string;
9223
+ readonly type: "image";
9224
+ };
9225
+ type EveFilePart = {
9226
+ readonly data: unknown;
9227
+ readonly filename?: string;
9228
+ readonly mediaType: string;
9229
+ readonly type: "file";
9230
+ };
9231
+ type EveReasoningPart = {
9232
+ readonly text: string;
9233
+ readonly type: "reasoning";
9234
+ };
9235
+ type EveReasoningFilePart = {
9236
+ readonly data: unknown;
9237
+ readonly mediaType: string;
9238
+ readonly type: "reasoning-file";
9239
+ };
9240
+ type EveCustomPart = {
9241
+ readonly kind: `${string}.${string}`;
9242
+ readonly type: "custom";
9243
+ };
9244
+ type EveToolCallPart = {
9245
+ readonly input: unknown;
9246
+ readonly providerExecuted?: boolean;
9247
+ readonly toolCallId: string;
9248
+ readonly toolName: string;
9249
+ readonly type: "tool-call";
9250
+ };
9251
+ type EveToolResultContentPart = EveTextPart | EveFilePart | {
9252
+ readonly data: string;
9253
+ readonly filename?: string;
9254
+ readonly mediaType: string;
9255
+ readonly type: "file-data";
9256
+ } | {
9257
+ readonly mediaType?: string;
9258
+ readonly type: "file-url";
9259
+ readonly url: string;
9260
+ } | {
9261
+ readonly fileId: string | Readonly<Record<string, string>>;
9262
+ readonly type: "file-id" | "image-file-id";
9263
+ } | {
9264
+ readonly providerReference: Readonly<Record<string, string>>;
9265
+ readonly type: "file-reference" | "image-file-reference";
9266
+ } | {
9267
+ readonly data: string;
9268
+ readonly mediaType: string;
9269
+ readonly type: "image-data";
9270
+ } | {
9271
+ readonly type: "image-url";
9272
+ readonly url: string;
9273
+ } | {
9274
+ readonly type: "custom";
9275
+ };
9276
+ type EveToolResultOutput = {
9277
+ readonly type: "text" | "error-text";
9278
+ readonly value: string;
9279
+ } | {
9280
+ readonly type: "json" | "error-json";
9281
+ readonly value: EveJsonValue;
9282
+ } | {
9283
+ readonly reason?: string;
9284
+ readonly type: "execution-denied";
9285
+ } | {
9286
+ readonly type: "content";
9287
+ readonly value: readonly EveToolResultContentPart[];
9288
+ };
9289
+ type EveToolResultPart = {
9290
+ readonly output: EveToolResultOutput;
9291
+ readonly toolCallId: string;
9292
+ readonly toolName: string;
9293
+ readonly type: "tool-result";
9294
+ };
9295
+ type EveToolApprovalRequest = {
9296
+ readonly approvalId: string;
9297
+ readonly isAutomatic?: boolean;
9298
+ readonly signature?: string;
9299
+ readonly toolCallId: string;
9300
+ readonly type: "tool-approval-request";
9301
+ };
9302
+ type EveToolApprovalResponse = {
9303
+ readonly approvalId: string;
9304
+ readonly approved: boolean;
9305
+ readonly providerExecuted?: boolean;
9306
+ readonly reason?: string;
9307
+ readonly type: "tool-approval-response";
9308
+ };
9309
+ type EveSystemModelMessage = {
9310
+ readonly content: string;
9311
+ readonly role: "system";
9312
+ };
9313
+ type EveModelMessage = EveSystemModelMessage | {
9314
+ readonly content: string | readonly (EveTextPart | EveImagePart | EveFilePart)[];
9315
+ readonly role: "user";
9316
+ } | {
9317
+ readonly content: string | readonly (EveTextPart | EveCustomPart | EveFilePart | EveReasoningPart | EveReasoningFilePart | EveToolCallPart | EveToolResultPart | EveToolApprovalRequest)[];
9318
+ readonly role: "assistant";
9319
+ } | {
9320
+ readonly content: readonly (EveToolResultPart | EveToolApprovalResponse)[];
9321
+ readonly role: "tool";
9322
+ };
9201
9323
  interface EveInstrumentationModelInput {
9202
- readonly instructions?: string | readonly EveJsonObject[];
9203
- readonly messages: readonly EveJsonObject[];
9324
+ readonly instructions?: string | readonly EveSystemModelMessage[];
9325
+ readonly messages: readonly EveModelMessage[];
9204
9326
  }
9205
9327
  interface EveInstrumentationStepStartedEventInput {
9206
- readonly channel?: unknown;
9207
9328
  readonly modelInput: EveInstrumentationModelInput;
9208
9329
  readonly session: {
9209
- readonly id?: string;
9330
+ readonly id: string;
9210
9331
  };
9211
9332
  readonly step: {
9212
- readonly index?: number;
9333
+ readonly index: number;
9213
9334
  };
9214
9335
  readonly turn: {
9215
- readonly id?: string;
9216
- readonly sequence?: number;
9336
+ readonly id: string;
9337
+ readonly sequence: number;
9217
9338
  };
9218
9339
  }
9219
9340
  interface EveInstrumentationDefinition {