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
package/dist/index.d.mts CHANGED
@@ -20364,6 +20364,11 @@ type InferParameters<T extends EvalParameters> = {
20364
20364
  [K in keyof T]: InferParameterValue<T[K]>;
20365
20365
  };
20366
20366
 
20367
+ type SpanOriginEnvironment = {
20368
+ type?: string;
20369
+ name?: string;
20370
+ };
20371
+
20367
20372
  /// <reference lib="dom" />
20368
20373
 
20369
20374
  declare const LOGS3_OVERFLOW_REFERENCE_TYPE = "logs3_overflow";
@@ -20784,6 +20789,7 @@ declare class BraintrustState {
20784
20789
  private _idGenerator;
20785
20790
  private _contextManager;
20786
20791
  private _otelFlushCallback;
20792
+ spanOriginEnvironment: SpanOriginEnvironment | undefined;
20787
20793
  constructor(loginParams: LoginOptions);
20788
20794
  resetLoginInfo(): void;
20789
20795
  resetIdGenState(): void;
@@ -21564,6 +21570,7 @@ type AsyncFlushArg<IsAsyncFlush> = {
21564
21570
  type InitLoggerOptions<IsAsyncFlush> = FullLoginOptions & {
21565
21571
  projectName?: string;
21566
21572
  projectId?: string;
21573
+ environment?: SpanOriginEnvironment;
21567
21574
  setCurrent?: boolean;
21568
21575
  state?: BraintrustState;
21569
21576
  orgProjectMetadata?: OrgProjectMetadata;
@@ -23526,8 +23533,8 @@ type EveJsonObject = {
23526
23533
  readonly [key: string]: EveJsonValue;
23527
23534
  };
23528
23535
  interface EveHookContext {
23529
- readonly session?: {
23530
- readonly id?: string;
23536
+ readonly session: {
23537
+ readonly id: string;
23531
23538
  readonly parent?: {
23532
23539
  readonly callId?: string;
23533
23540
  readonly sessionId?: string;
@@ -23628,6 +23635,15 @@ type EveHandleMessageStreamEvent = {
23628
23635
  };
23629
23636
  readonly meta?: EveStreamEventMeta;
23630
23637
  readonly type: "message.completed";
23638
+ } | {
23639
+ readonly data: {
23640
+ readonly reasoning: string;
23641
+ readonly sequence: number;
23642
+ readonly stepIndex: number;
23643
+ readonly turnId: string;
23644
+ };
23645
+ readonly meta?: EveStreamEventMeta;
23646
+ readonly type: "reasoning.completed";
23631
23647
  } | {
23632
23648
  readonly data: {
23633
23649
  readonly result: EveJsonValue;
@@ -23761,22 +23777,128 @@ interface EveHookDefinition {
23761
23777
  interface EveInstrumentationSetupContext {
23762
23778
  readonly agentName: string;
23763
23779
  }
23780
+ type EveTextPart = {
23781
+ readonly text: string;
23782
+ readonly type: "text";
23783
+ };
23784
+ type EveImagePart = {
23785
+ readonly image: unknown;
23786
+ readonly mediaType?: string;
23787
+ readonly type: "image";
23788
+ };
23789
+ type EveFilePart = {
23790
+ readonly data: unknown;
23791
+ readonly filename?: string;
23792
+ readonly mediaType: string;
23793
+ readonly type: "file";
23794
+ };
23795
+ type EveReasoningPart = {
23796
+ readonly text: string;
23797
+ readonly type: "reasoning";
23798
+ };
23799
+ type EveReasoningFilePart = {
23800
+ readonly data: unknown;
23801
+ readonly mediaType: string;
23802
+ readonly type: "reasoning-file";
23803
+ };
23804
+ type EveCustomPart = {
23805
+ readonly kind: `${string}.${string}`;
23806
+ readonly type: "custom";
23807
+ };
23808
+ type EveToolCallPart = {
23809
+ readonly input: unknown;
23810
+ readonly providerExecuted?: boolean;
23811
+ readonly toolCallId: string;
23812
+ readonly toolName: string;
23813
+ readonly type: "tool-call";
23814
+ };
23815
+ type EveToolResultContentPart = EveTextPart | EveFilePart | {
23816
+ readonly data: string;
23817
+ readonly filename?: string;
23818
+ readonly mediaType: string;
23819
+ readonly type: "file-data";
23820
+ } | {
23821
+ readonly mediaType?: string;
23822
+ readonly type: "file-url";
23823
+ readonly url: string;
23824
+ } | {
23825
+ readonly fileId: string | Readonly<Record<string, string>>;
23826
+ readonly type: "file-id" | "image-file-id";
23827
+ } | {
23828
+ readonly providerReference: Readonly<Record<string, string>>;
23829
+ readonly type: "file-reference" | "image-file-reference";
23830
+ } | {
23831
+ readonly data: string;
23832
+ readonly mediaType: string;
23833
+ readonly type: "image-data";
23834
+ } | {
23835
+ readonly type: "image-url";
23836
+ readonly url: string;
23837
+ } | {
23838
+ readonly type: "custom";
23839
+ };
23840
+ type EveToolResultOutput = {
23841
+ readonly type: "text" | "error-text";
23842
+ readonly value: string;
23843
+ } | {
23844
+ readonly type: "json" | "error-json";
23845
+ readonly value: EveJsonValue;
23846
+ } | {
23847
+ readonly reason?: string;
23848
+ readonly type: "execution-denied";
23849
+ } | {
23850
+ readonly type: "content";
23851
+ readonly value: readonly EveToolResultContentPart[];
23852
+ };
23853
+ type EveToolResultPart = {
23854
+ readonly output: EveToolResultOutput;
23855
+ readonly toolCallId: string;
23856
+ readonly toolName: string;
23857
+ readonly type: "tool-result";
23858
+ };
23859
+ type EveToolApprovalRequest = {
23860
+ readonly approvalId: string;
23861
+ readonly isAutomatic?: boolean;
23862
+ readonly signature?: string;
23863
+ readonly toolCallId: string;
23864
+ readonly type: "tool-approval-request";
23865
+ };
23866
+ type EveToolApprovalResponse = {
23867
+ readonly approvalId: string;
23868
+ readonly approved: boolean;
23869
+ readonly providerExecuted?: boolean;
23870
+ readonly reason?: string;
23871
+ readonly type: "tool-approval-response";
23872
+ };
23873
+ type EveSystemModelMessage = {
23874
+ readonly content: string;
23875
+ readonly role: "system";
23876
+ };
23877
+ type EveModelMessage = EveSystemModelMessage | {
23878
+ readonly content: string | readonly (EveTextPart | EveImagePart | EveFilePart)[];
23879
+ readonly role: "user";
23880
+ } | {
23881
+ readonly content: string | readonly (EveTextPart | EveCustomPart | EveFilePart | EveReasoningPart | EveReasoningFilePart | EveToolCallPart | EveToolResultPart | EveToolApprovalRequest)[];
23882
+ readonly role: "assistant";
23883
+ } | {
23884
+ readonly content: readonly (EveToolResultPart | EveToolApprovalResponse)[];
23885
+ readonly role: "tool";
23886
+ };
23764
23887
  interface EveInstrumentationModelInput {
23765
- readonly instructions?: string | readonly EveJsonObject[];
23766
- readonly messages: readonly EveJsonObject[];
23888
+ readonly instructions?: string | readonly EveSystemModelMessage[];
23889
+ readonly messages: readonly EveModelMessage[];
23767
23890
  }
23768
23891
  interface EveInstrumentationStepStartedEventInput {
23769
- readonly channel?: unknown;
23770
23892
  readonly modelInput: EveInstrumentationModelInput;
23771
23893
  readonly session: {
23772
- readonly id?: string;
23894
+ readonly id: string;
23773
23895
  };
23774
23896
  readonly step: {
23775
- readonly index?: number;
23897
+ readonly index: number;
23776
23898
  };
23777
23899
  readonly turn: {
23778
- readonly id?: string;
23779
- readonly sequence?: number;
23900
+ readonly id: string;
23901
+ readonly sequence: number;
23780
23902
  };
23781
23903
  }
23782
23904
  interface EveInstrumentationDefinition {
package/dist/index.d.ts CHANGED
@@ -20364,6 +20364,11 @@ type InferParameters<T extends EvalParameters> = {
20364
20364
  [K in keyof T]: InferParameterValue<T[K]>;
20365
20365
  };
20366
20366
 
20367
+ type SpanOriginEnvironment = {
20368
+ type?: string;
20369
+ name?: string;
20370
+ };
20371
+
20367
20372
  /// <reference lib="dom" />
20368
20373
 
20369
20374
  declare const LOGS3_OVERFLOW_REFERENCE_TYPE = "logs3_overflow";
@@ -20784,6 +20789,7 @@ declare class BraintrustState {
20784
20789
  private _idGenerator;
20785
20790
  private _contextManager;
20786
20791
  private _otelFlushCallback;
20792
+ spanOriginEnvironment: SpanOriginEnvironment | undefined;
20787
20793
  constructor(loginParams: LoginOptions);
20788
20794
  resetLoginInfo(): void;
20789
20795
  resetIdGenState(): void;
@@ -21564,6 +21570,7 @@ type AsyncFlushArg<IsAsyncFlush> = {
21564
21570
  type InitLoggerOptions<IsAsyncFlush> = FullLoginOptions & {
21565
21571
  projectName?: string;
21566
21572
  projectId?: string;
21573
+ environment?: SpanOriginEnvironment;
21567
21574
  setCurrent?: boolean;
21568
21575
  state?: BraintrustState;
21569
21576
  orgProjectMetadata?: OrgProjectMetadata;
@@ -23526,8 +23533,8 @@ type EveJsonObject = {
23526
23533
  readonly [key: string]: EveJsonValue;
23527
23534
  };
23528
23535
  interface EveHookContext {
23529
- readonly session?: {
23530
- readonly id?: string;
23536
+ readonly session: {
23537
+ readonly id: string;
23531
23538
  readonly parent?: {
23532
23539
  readonly callId?: string;
23533
23540
  readonly sessionId?: string;
@@ -23628,6 +23635,15 @@ type EveHandleMessageStreamEvent = {
23628
23635
  };
23629
23636
  readonly meta?: EveStreamEventMeta;
23630
23637
  readonly type: "message.completed";
23638
+ } | {
23639
+ readonly data: {
23640
+ readonly reasoning: string;
23641
+ readonly sequence: number;
23642
+ readonly stepIndex: number;
23643
+ readonly turnId: string;
23644
+ };
23645
+ readonly meta?: EveStreamEventMeta;
23646
+ readonly type: "reasoning.completed";
23631
23647
  } | {
23632
23648
  readonly data: {
23633
23649
  readonly result: EveJsonValue;
@@ -23761,22 +23777,128 @@ interface EveHookDefinition {
23761
23777
  interface EveInstrumentationSetupContext {
23762
23778
  readonly agentName: string;
23763
23779
  }
23780
+ type EveTextPart = {
23781
+ readonly text: string;
23782
+ readonly type: "text";
23783
+ };
23784
+ type EveImagePart = {
23785
+ readonly image: unknown;
23786
+ readonly mediaType?: string;
23787
+ readonly type: "image";
23788
+ };
23789
+ type EveFilePart = {
23790
+ readonly data: unknown;
23791
+ readonly filename?: string;
23792
+ readonly mediaType: string;
23793
+ readonly type: "file";
23794
+ };
23795
+ type EveReasoningPart = {
23796
+ readonly text: string;
23797
+ readonly type: "reasoning";
23798
+ };
23799
+ type EveReasoningFilePart = {
23800
+ readonly data: unknown;
23801
+ readonly mediaType: string;
23802
+ readonly type: "reasoning-file";
23803
+ };
23804
+ type EveCustomPart = {
23805
+ readonly kind: `${string}.${string}`;
23806
+ readonly type: "custom";
23807
+ };
23808
+ type EveToolCallPart = {
23809
+ readonly input: unknown;
23810
+ readonly providerExecuted?: boolean;
23811
+ readonly toolCallId: string;
23812
+ readonly toolName: string;
23813
+ readonly type: "tool-call";
23814
+ };
23815
+ type EveToolResultContentPart = EveTextPart | EveFilePart | {
23816
+ readonly data: string;
23817
+ readonly filename?: string;
23818
+ readonly mediaType: string;
23819
+ readonly type: "file-data";
23820
+ } | {
23821
+ readonly mediaType?: string;
23822
+ readonly type: "file-url";
23823
+ readonly url: string;
23824
+ } | {
23825
+ readonly fileId: string | Readonly<Record<string, string>>;
23826
+ readonly type: "file-id" | "image-file-id";
23827
+ } | {
23828
+ readonly providerReference: Readonly<Record<string, string>>;
23829
+ readonly type: "file-reference" | "image-file-reference";
23830
+ } | {
23831
+ readonly data: string;
23832
+ readonly mediaType: string;
23833
+ readonly type: "image-data";
23834
+ } | {
23835
+ readonly type: "image-url";
23836
+ readonly url: string;
23837
+ } | {
23838
+ readonly type: "custom";
23839
+ };
23840
+ type EveToolResultOutput = {
23841
+ readonly type: "text" | "error-text";
23842
+ readonly value: string;
23843
+ } | {
23844
+ readonly type: "json" | "error-json";
23845
+ readonly value: EveJsonValue;
23846
+ } | {
23847
+ readonly reason?: string;
23848
+ readonly type: "execution-denied";
23849
+ } | {
23850
+ readonly type: "content";
23851
+ readonly value: readonly EveToolResultContentPart[];
23852
+ };
23853
+ type EveToolResultPart = {
23854
+ readonly output: EveToolResultOutput;
23855
+ readonly toolCallId: string;
23856
+ readonly toolName: string;
23857
+ readonly type: "tool-result";
23858
+ };
23859
+ type EveToolApprovalRequest = {
23860
+ readonly approvalId: string;
23861
+ readonly isAutomatic?: boolean;
23862
+ readonly signature?: string;
23863
+ readonly toolCallId: string;
23864
+ readonly type: "tool-approval-request";
23865
+ };
23866
+ type EveToolApprovalResponse = {
23867
+ readonly approvalId: string;
23868
+ readonly approved: boolean;
23869
+ readonly providerExecuted?: boolean;
23870
+ readonly reason?: string;
23871
+ readonly type: "tool-approval-response";
23872
+ };
23873
+ type EveSystemModelMessage = {
23874
+ readonly content: string;
23875
+ readonly role: "system";
23876
+ };
23877
+ type EveModelMessage = EveSystemModelMessage | {
23878
+ readonly content: string | readonly (EveTextPart | EveImagePart | EveFilePart)[];
23879
+ readonly role: "user";
23880
+ } | {
23881
+ readonly content: string | readonly (EveTextPart | EveCustomPart | EveFilePart | EveReasoningPart | EveReasoningFilePart | EveToolCallPart | EveToolResultPart | EveToolApprovalRequest)[];
23882
+ readonly role: "assistant";
23883
+ } | {
23884
+ readonly content: readonly (EveToolResultPart | EveToolApprovalResponse)[];
23885
+ readonly role: "tool";
23886
+ };
23764
23887
  interface EveInstrumentationModelInput {
23765
- readonly instructions?: string | readonly EveJsonObject[];
23766
- readonly messages: readonly EveJsonObject[];
23888
+ readonly instructions?: string | readonly EveSystemModelMessage[];
23889
+ readonly messages: readonly EveModelMessage[];
23767
23890
  }
23768
23891
  interface EveInstrumentationStepStartedEventInput {
23769
- readonly channel?: unknown;
23770
23892
  readonly modelInput: EveInstrumentationModelInput;
23771
23893
  readonly session: {
23772
- readonly id?: string;
23894
+ readonly id: string;
23773
23895
  };
23774
23896
  readonly step: {
23775
- readonly index?: number;
23897
+ readonly index: number;
23776
23898
  };
23777
23899
  readonly turn: {
23778
- readonly id?: string;
23779
- readonly sequence?: number;
23900
+ readonly id: string;
23901
+ readonly sequence: number;
23780
23902
  };
23781
23903
  }
23782
23904
  interface EveInstrumentationDefinition {