braintrust 3.23.1 → 3.25.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 +11 -0
  2. package/dev/dist/index.d.ts +11 -0
  3. package/dev/dist/index.js +2881 -1518
  4. package/dev/dist/index.mjs +2298 -935
  5. package/dist/apply-auto-instrumentation.js +218 -195
  6. package/dist/apply-auto-instrumentation.mjs +30 -7
  7. package/dist/auto-instrumentations/bundler/esbuild.cjs +618 -444
  8. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  9. package/dist/auto-instrumentations/bundler/next.cjs +618 -444
  10. package/dist/auto-instrumentations/bundler/next.mjs +3 -3
  11. package/dist/auto-instrumentations/bundler/rollup.cjs +618 -444
  12. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  13. package/dist/auto-instrumentations/bundler/vite.cjs +618 -444
  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 +618 -444
  18. package/dist/auto-instrumentations/bundler/webpack.cjs +618 -444
  19. package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
  20. package/dist/auto-instrumentations/{chunk-KIMLYPRW.mjs → chunk-7P6563SW.mjs} +1 -1
  21. package/dist/auto-instrumentations/{chunk-YXLNSAMJ.mjs → chunk-CZ24KNHT.mjs} +591 -424
  22. package/dist/auto-instrumentations/{chunk-EXY7QCJD.mjs → chunk-JPVCUKTY.mjs} +30 -21
  23. package/dist/auto-instrumentations/hook.mjs +778 -457
  24. package/dist/auto-instrumentations/index.cjs +590 -424
  25. package/dist/auto-instrumentations/index.mjs +1 -1
  26. package/dist/browser.d.mts +138 -9
  27. package/dist/browser.d.ts +138 -9
  28. package/dist/browser.js +2700 -1011
  29. package/dist/browser.mjs +2700 -1011
  30. package/dist/{chunk-RBXD2KYN.mjs → chunk-2SANLSWX.mjs} +1577 -513
  31. package/dist/{chunk-36IPYKMG.mjs → chunk-ABR2QWDP.mjs} +704 -438
  32. package/dist/{chunk-B6ZQIAK3.js → chunk-GSIDVFE6.js} +2361 -1297
  33. package/dist/{chunk-CDIKAHDZ.js → chunk-P25IOOU4.js} +706 -440
  34. package/dist/cli.js +2307 -940
  35. package/dist/edge-light.js +2700 -1011
  36. package/dist/edge-light.mjs +2700 -1011
  37. package/dist/index.d.mts +138 -9
  38. package/dist/index.d.ts +138 -9
  39. package/dist/index.js +955 -551
  40. package/dist/index.mjs +493 -89
  41. package/dist/instrumentation/index.d.mts +135 -9
  42. package/dist/instrumentation/index.d.ts +135 -9
  43. package/dist/instrumentation/index.js +2554 -1009
  44. package/dist/instrumentation/index.mjs +2554 -1009
  45. package/dist/vitest-evals-reporter.js +17 -16
  46. package/dist/vitest-evals-reporter.mjs +3 -2
  47. package/dist/workerd.js +2700 -1011
  48. package/dist/workerd.mjs +2700 -1011
  49. package/package.json +4 -4
  50. package/util/dist/index.js +4 -0
  51. package/util/dist/index.mjs +4 -0
package/dist/index.d.mts CHANGED
@@ -18137,6 +18137,8 @@ interface Common {
18137
18137
  newTracingChannel: <M = any>(nameOrChannels: string | IsoTracingChannelCollection<M>) => IsoTracingChannel<M>;
18138
18138
  processOn: (event: string, handler: (code: any) => void) => void;
18139
18139
  hash?: (data: string) => string;
18140
+ hmacSha256?: (key: string, data: string) => string;
18141
+ timingSafeEqual?: (left: string, right: string) => boolean;
18140
18142
  basename: (filepath: string) => string;
18141
18143
  writeln: (text: string) => void;
18142
18144
  pathJoin?: (...args: string[]) => string;
@@ -20364,6 +20366,11 @@ type InferParameters<T extends EvalParameters> = {
20364
20366
  [K in keyof T]: InferParameterValue<T[K]>;
20365
20367
  };
20366
20368
 
20369
+ type SpanOriginEnvironment = {
20370
+ type?: string;
20371
+ name?: string;
20372
+ };
20373
+
20367
20374
  /// <reference lib="dom" />
20368
20375
 
20369
20376
  declare const LOGS3_OVERFLOW_REFERENCE_TYPE = "logs3_overflow";
@@ -20784,7 +20791,13 @@ declare class BraintrustState {
20784
20791
  private _idGenerator;
20785
20792
  private _contextManager;
20786
20793
  private _otelFlushCallback;
20794
+ spanOriginEnvironment: SpanOriginEnvironment | undefined;
20795
+ private traceContextSigningSecret;
20787
20796
  constructor(loginParams: LoginOptions);
20797
+ /** @internal */
20798
+ _internalSetTraceContextSigningSecret(secret: string | undefined): void;
20799
+ /** @internal */
20800
+ _internalGetTraceContextSigningSecret(): string | undefined;
20788
20801
  resetLoginInfo(): void;
20789
20802
  resetIdGenState(): void;
20790
20803
  [RESET_CONTEXT_MANAGER_STATE](): void;
@@ -21564,6 +21577,7 @@ type AsyncFlushArg<IsAsyncFlush> = {
21564
21577
  type InitLoggerOptions<IsAsyncFlush> = FullLoginOptions & {
21565
21578
  projectName?: string;
21566
21579
  projectId?: string;
21580
+ environment?: SpanOriginEnvironment;
21567
21581
  setCurrent?: boolean;
21568
21582
  state?: BraintrustState;
21569
21583
  orgProjectMetadata?: OrgProjectMetadata;
@@ -23526,8 +23540,8 @@ type EveJsonObject = {
23526
23540
  readonly [key: string]: EveJsonValue;
23527
23541
  };
23528
23542
  interface EveHookContext {
23529
- readonly session?: {
23530
- readonly id?: string;
23543
+ readonly session: {
23544
+ readonly id: string;
23531
23545
  readonly parent?: {
23532
23546
  readonly callId?: string;
23533
23547
  readonly sessionId?: string;
@@ -23628,6 +23642,15 @@ type EveHandleMessageStreamEvent = {
23628
23642
  };
23629
23643
  readonly meta?: EveStreamEventMeta;
23630
23644
  readonly type: "message.completed";
23645
+ } | {
23646
+ readonly data: {
23647
+ readonly reasoning: string;
23648
+ readonly sequence: number;
23649
+ readonly stepIndex: number;
23650
+ readonly turnId: string;
23651
+ };
23652
+ readonly meta?: EveStreamEventMeta;
23653
+ readonly type: "reasoning.completed";
23631
23654
  } | {
23632
23655
  readonly data: {
23633
23656
  readonly result: EveJsonValue;
@@ -23761,22 +23784,128 @@ interface EveHookDefinition {
23761
23784
  interface EveInstrumentationSetupContext {
23762
23785
  readonly agentName: string;
23763
23786
  }
23787
+ type EveTextPart = {
23788
+ readonly text: string;
23789
+ readonly type: "text";
23790
+ };
23791
+ type EveImagePart = {
23792
+ readonly image: unknown;
23793
+ readonly mediaType?: string;
23794
+ readonly type: "image";
23795
+ };
23796
+ type EveFilePart = {
23797
+ readonly data: unknown;
23798
+ readonly filename?: string;
23799
+ readonly mediaType: string;
23800
+ readonly type: "file";
23801
+ };
23802
+ type EveReasoningPart = {
23803
+ readonly text: string;
23804
+ readonly type: "reasoning";
23805
+ };
23806
+ type EveReasoningFilePart = {
23807
+ readonly data: unknown;
23808
+ readonly mediaType: string;
23809
+ readonly type: "reasoning-file";
23810
+ };
23811
+ type EveCustomPart = {
23812
+ readonly kind: `${string}.${string}`;
23813
+ readonly type: "custom";
23814
+ };
23815
+ type EveToolCallPart = {
23816
+ readonly input: unknown;
23817
+ readonly providerExecuted?: boolean;
23818
+ readonly toolCallId: string;
23819
+ readonly toolName: string;
23820
+ readonly type: "tool-call";
23821
+ };
23822
+ type EveToolResultContentPart = EveTextPart | EveFilePart | {
23823
+ readonly data: string;
23824
+ readonly filename?: string;
23825
+ readonly mediaType: string;
23826
+ readonly type: "file-data";
23827
+ } | {
23828
+ readonly mediaType?: string;
23829
+ readonly type: "file-url";
23830
+ readonly url: string;
23831
+ } | {
23832
+ readonly fileId: string | Readonly<Record<string, string>>;
23833
+ readonly type: "file-id" | "image-file-id";
23834
+ } | {
23835
+ readonly providerReference: Readonly<Record<string, string>>;
23836
+ readonly type: "file-reference" | "image-file-reference";
23837
+ } | {
23838
+ readonly data: string;
23839
+ readonly mediaType: string;
23840
+ readonly type: "image-data";
23841
+ } | {
23842
+ readonly type: "image-url";
23843
+ readonly url: string;
23844
+ } | {
23845
+ readonly type: "custom";
23846
+ };
23847
+ type EveToolResultOutput = {
23848
+ readonly type: "text" | "error-text";
23849
+ readonly value: string;
23850
+ } | {
23851
+ readonly type: "json" | "error-json";
23852
+ readonly value: EveJsonValue;
23853
+ } | {
23854
+ readonly reason?: string;
23855
+ readonly type: "execution-denied";
23856
+ } | {
23857
+ readonly type: "content";
23858
+ readonly value: readonly EveToolResultContentPart[];
23859
+ };
23860
+ type EveToolResultPart = {
23861
+ readonly output: EveToolResultOutput;
23862
+ readonly toolCallId: string;
23863
+ readonly toolName: string;
23864
+ readonly type: "tool-result";
23865
+ };
23866
+ type EveToolApprovalRequest = {
23867
+ readonly approvalId: string;
23868
+ readonly isAutomatic?: boolean;
23869
+ readonly signature?: string;
23870
+ readonly toolCallId: string;
23871
+ readonly type: "tool-approval-request";
23872
+ };
23873
+ type EveToolApprovalResponse = {
23874
+ readonly approvalId: string;
23875
+ readonly approved: boolean;
23876
+ readonly providerExecuted?: boolean;
23877
+ readonly reason?: string;
23878
+ readonly type: "tool-approval-response";
23879
+ };
23880
+ type EveSystemModelMessage = {
23881
+ readonly content: string;
23882
+ readonly role: "system";
23883
+ };
23884
+ type EveModelMessage = EveSystemModelMessage | {
23885
+ readonly content: string | readonly (EveTextPart | EveImagePart | EveFilePart)[];
23886
+ readonly role: "user";
23887
+ } | {
23888
+ readonly content: string | readonly (EveTextPart | EveCustomPart | EveFilePart | EveReasoningPart | EveReasoningFilePart | EveToolCallPart | EveToolResultPart | EveToolApprovalRequest)[];
23889
+ readonly role: "assistant";
23890
+ } | {
23891
+ readonly content: readonly (EveToolResultPart | EveToolApprovalResponse)[];
23892
+ readonly role: "tool";
23893
+ };
23764
23894
  interface EveInstrumentationModelInput {
23765
- readonly instructions?: string | readonly EveJsonObject[];
23766
- readonly messages: readonly EveJsonObject[];
23895
+ readonly instructions?: string | readonly EveSystemModelMessage[];
23896
+ readonly messages: readonly EveModelMessage[];
23767
23897
  }
23768
23898
  interface EveInstrumentationStepStartedEventInput {
23769
- readonly channel?: unknown;
23770
23899
  readonly modelInput: EveInstrumentationModelInput;
23771
23900
  readonly session: {
23772
- readonly id?: string;
23901
+ readonly id: string;
23773
23902
  };
23774
23903
  readonly step: {
23775
- readonly index?: number;
23904
+ readonly index: number;
23776
23905
  };
23777
23906
  readonly turn: {
23778
- readonly id?: string;
23779
- readonly sequence?: number;
23907
+ readonly id: string;
23908
+ readonly sequence: number;
23780
23909
  };
23781
23910
  }
23782
23911
  interface EveInstrumentationDefinition {
package/dist/index.d.ts CHANGED
@@ -18137,6 +18137,8 @@ interface Common {
18137
18137
  newTracingChannel: <M = any>(nameOrChannels: string | IsoTracingChannelCollection<M>) => IsoTracingChannel<M>;
18138
18138
  processOn: (event: string, handler: (code: any) => void) => void;
18139
18139
  hash?: (data: string) => string;
18140
+ hmacSha256?: (key: string, data: string) => string;
18141
+ timingSafeEqual?: (left: string, right: string) => boolean;
18140
18142
  basename: (filepath: string) => string;
18141
18143
  writeln: (text: string) => void;
18142
18144
  pathJoin?: (...args: string[]) => string;
@@ -20364,6 +20366,11 @@ type InferParameters<T extends EvalParameters> = {
20364
20366
  [K in keyof T]: InferParameterValue<T[K]>;
20365
20367
  };
20366
20368
 
20369
+ type SpanOriginEnvironment = {
20370
+ type?: string;
20371
+ name?: string;
20372
+ };
20373
+
20367
20374
  /// <reference lib="dom" />
20368
20375
 
20369
20376
  declare const LOGS3_OVERFLOW_REFERENCE_TYPE = "logs3_overflow";
@@ -20784,7 +20791,13 @@ declare class BraintrustState {
20784
20791
  private _idGenerator;
20785
20792
  private _contextManager;
20786
20793
  private _otelFlushCallback;
20794
+ spanOriginEnvironment: SpanOriginEnvironment | undefined;
20795
+ private traceContextSigningSecret;
20787
20796
  constructor(loginParams: LoginOptions);
20797
+ /** @internal */
20798
+ _internalSetTraceContextSigningSecret(secret: string | undefined): void;
20799
+ /** @internal */
20800
+ _internalGetTraceContextSigningSecret(): string | undefined;
20788
20801
  resetLoginInfo(): void;
20789
20802
  resetIdGenState(): void;
20790
20803
  [RESET_CONTEXT_MANAGER_STATE](): void;
@@ -21564,6 +21577,7 @@ type AsyncFlushArg<IsAsyncFlush> = {
21564
21577
  type InitLoggerOptions<IsAsyncFlush> = FullLoginOptions & {
21565
21578
  projectName?: string;
21566
21579
  projectId?: string;
21580
+ environment?: SpanOriginEnvironment;
21567
21581
  setCurrent?: boolean;
21568
21582
  state?: BraintrustState;
21569
21583
  orgProjectMetadata?: OrgProjectMetadata;
@@ -23526,8 +23540,8 @@ type EveJsonObject = {
23526
23540
  readonly [key: string]: EveJsonValue;
23527
23541
  };
23528
23542
  interface EveHookContext {
23529
- readonly session?: {
23530
- readonly id?: string;
23543
+ readonly session: {
23544
+ readonly id: string;
23531
23545
  readonly parent?: {
23532
23546
  readonly callId?: string;
23533
23547
  readonly sessionId?: string;
@@ -23628,6 +23642,15 @@ type EveHandleMessageStreamEvent = {
23628
23642
  };
23629
23643
  readonly meta?: EveStreamEventMeta;
23630
23644
  readonly type: "message.completed";
23645
+ } | {
23646
+ readonly data: {
23647
+ readonly reasoning: string;
23648
+ readonly sequence: number;
23649
+ readonly stepIndex: number;
23650
+ readonly turnId: string;
23651
+ };
23652
+ readonly meta?: EveStreamEventMeta;
23653
+ readonly type: "reasoning.completed";
23631
23654
  } | {
23632
23655
  readonly data: {
23633
23656
  readonly result: EveJsonValue;
@@ -23761,22 +23784,128 @@ interface EveHookDefinition {
23761
23784
  interface EveInstrumentationSetupContext {
23762
23785
  readonly agentName: string;
23763
23786
  }
23787
+ type EveTextPart = {
23788
+ readonly text: string;
23789
+ readonly type: "text";
23790
+ };
23791
+ type EveImagePart = {
23792
+ readonly image: unknown;
23793
+ readonly mediaType?: string;
23794
+ readonly type: "image";
23795
+ };
23796
+ type EveFilePart = {
23797
+ readonly data: unknown;
23798
+ readonly filename?: string;
23799
+ readonly mediaType: string;
23800
+ readonly type: "file";
23801
+ };
23802
+ type EveReasoningPart = {
23803
+ readonly text: string;
23804
+ readonly type: "reasoning";
23805
+ };
23806
+ type EveReasoningFilePart = {
23807
+ readonly data: unknown;
23808
+ readonly mediaType: string;
23809
+ readonly type: "reasoning-file";
23810
+ };
23811
+ type EveCustomPart = {
23812
+ readonly kind: `${string}.${string}`;
23813
+ readonly type: "custom";
23814
+ };
23815
+ type EveToolCallPart = {
23816
+ readonly input: unknown;
23817
+ readonly providerExecuted?: boolean;
23818
+ readonly toolCallId: string;
23819
+ readonly toolName: string;
23820
+ readonly type: "tool-call";
23821
+ };
23822
+ type EveToolResultContentPart = EveTextPart | EveFilePart | {
23823
+ readonly data: string;
23824
+ readonly filename?: string;
23825
+ readonly mediaType: string;
23826
+ readonly type: "file-data";
23827
+ } | {
23828
+ readonly mediaType?: string;
23829
+ readonly type: "file-url";
23830
+ readonly url: string;
23831
+ } | {
23832
+ readonly fileId: string | Readonly<Record<string, string>>;
23833
+ readonly type: "file-id" | "image-file-id";
23834
+ } | {
23835
+ readonly providerReference: Readonly<Record<string, string>>;
23836
+ readonly type: "file-reference" | "image-file-reference";
23837
+ } | {
23838
+ readonly data: string;
23839
+ readonly mediaType: string;
23840
+ readonly type: "image-data";
23841
+ } | {
23842
+ readonly type: "image-url";
23843
+ readonly url: string;
23844
+ } | {
23845
+ readonly type: "custom";
23846
+ };
23847
+ type EveToolResultOutput = {
23848
+ readonly type: "text" | "error-text";
23849
+ readonly value: string;
23850
+ } | {
23851
+ readonly type: "json" | "error-json";
23852
+ readonly value: EveJsonValue;
23853
+ } | {
23854
+ readonly reason?: string;
23855
+ readonly type: "execution-denied";
23856
+ } | {
23857
+ readonly type: "content";
23858
+ readonly value: readonly EveToolResultContentPart[];
23859
+ };
23860
+ type EveToolResultPart = {
23861
+ readonly output: EveToolResultOutput;
23862
+ readonly toolCallId: string;
23863
+ readonly toolName: string;
23864
+ readonly type: "tool-result";
23865
+ };
23866
+ type EveToolApprovalRequest = {
23867
+ readonly approvalId: string;
23868
+ readonly isAutomatic?: boolean;
23869
+ readonly signature?: string;
23870
+ readonly toolCallId: string;
23871
+ readonly type: "tool-approval-request";
23872
+ };
23873
+ type EveToolApprovalResponse = {
23874
+ readonly approvalId: string;
23875
+ readonly approved: boolean;
23876
+ readonly providerExecuted?: boolean;
23877
+ readonly reason?: string;
23878
+ readonly type: "tool-approval-response";
23879
+ };
23880
+ type EveSystemModelMessage = {
23881
+ readonly content: string;
23882
+ readonly role: "system";
23883
+ };
23884
+ type EveModelMessage = EveSystemModelMessage | {
23885
+ readonly content: string | readonly (EveTextPart | EveImagePart | EveFilePart)[];
23886
+ readonly role: "user";
23887
+ } | {
23888
+ readonly content: string | readonly (EveTextPart | EveCustomPart | EveFilePart | EveReasoningPart | EveReasoningFilePart | EveToolCallPart | EveToolResultPart | EveToolApprovalRequest)[];
23889
+ readonly role: "assistant";
23890
+ } | {
23891
+ readonly content: readonly (EveToolResultPart | EveToolApprovalResponse)[];
23892
+ readonly role: "tool";
23893
+ };
23764
23894
  interface EveInstrumentationModelInput {
23765
- readonly instructions?: string | readonly EveJsonObject[];
23766
- readonly messages: readonly EveJsonObject[];
23895
+ readonly instructions?: string | readonly EveSystemModelMessage[];
23896
+ readonly messages: readonly EveModelMessage[];
23767
23897
  }
23768
23898
  interface EveInstrumentationStepStartedEventInput {
23769
- readonly channel?: unknown;
23770
23899
  readonly modelInput: EveInstrumentationModelInput;
23771
23900
  readonly session: {
23772
- readonly id?: string;
23901
+ readonly id: string;
23773
23902
  };
23774
23903
  readonly step: {
23775
- readonly index?: number;
23904
+ readonly index: number;
23776
23905
  };
23777
23906
  readonly turn: {
23778
- readonly id?: string;
23779
- readonly sequence?: number;
23907
+ readonly id: string;
23908
+ readonly sequence: number;
23780
23909
  };
23781
23910
  }
23782
23911
  interface EveInstrumentationDefinition {