braintrust 0.3.8 → 0.4.1

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.
@@ -7097,6 +7097,24 @@ type ToolFunctionDefinitionType = z.infer<typeof ToolFunctionDefinition>;
7097
7097
 
7098
7098
  type GenericFunction<Input, Output> = ((input: Input) => Output) | ((input: Input) => Promise<Output>);
7099
7099
 
7100
+ /**
7101
+ * Abstract base class for ID generators
7102
+ */
7103
+ declare abstract class IDGenerator {
7104
+ /**
7105
+ * Generate a span ID
7106
+ */
7107
+ abstract getSpanId(): string;
7108
+ /**
7109
+ * Generate a trace ID
7110
+ */
7111
+ abstract getTraceId(): string;
7112
+ /**
7113
+ * Return true if the generator should use span_id as root_span_id for backwards compatibility
7114
+ */
7115
+ abstract shareRootSpanId(): boolean;
7116
+ }
7117
+
7100
7118
  interface IsoAsyncLocalStorage<T> {
7101
7119
  enterWith(store: T): void;
7102
7120
  run<R>(store: T | undefined, callback: () => R): R;
@@ -7284,8 +7302,10 @@ declare class LazyValue<T> {
7284
7302
  get hasSucceeded(): boolean;
7285
7303
  }
7286
7304
 
7287
- /// <reference lib="dom" />
7288
-
7305
+ interface ContextParentSpanIds {
7306
+ rootSpanId: string;
7307
+ spanParents: string[];
7308
+ }
7289
7309
  type SetCurrentArg = {
7290
7310
  setCurrent?: boolean;
7291
7311
  };
@@ -7436,6 +7456,11 @@ interface Span extends Exportable {
7436
7456
  state(): BraintrustState;
7437
7457
  kind: "span";
7438
7458
  }
7459
+ declare abstract class ContextManager {
7460
+ abstract getParentSpanIds(): ContextParentSpanIds | undefined;
7461
+ abstract runInContext<R>(span: Span, callback: () => R): R;
7462
+ abstract getCurrentSpan(): Span | undefined;
7463
+ }
7439
7464
  /**
7440
7465
  * A fake implementation of the Span API which does nothing. This can be used as the default span.
7441
7466
  */
@@ -7532,8 +7557,13 @@ declare class BraintrustState {
7532
7557
  private _apiConn;
7533
7558
  private _proxyConn;
7534
7559
  promptCache: PromptCache;
7560
+ private _idGenerator;
7561
+ private _contextManager;
7535
7562
  constructor(loginParams: LoginOptions);
7536
7563
  resetLoginInfo(): void;
7564
+ resetIdGenState(): void;
7565
+ get idGenerator(): IDGenerator;
7566
+ get contextManager(): ContextManager;
7537
7567
  copyLoginInfo(other: BraintrustState): void;
7538
7568
  serialize(): SerializedBraintrustState;
7539
7569
  static deserialize(serialized: unknown, opts?: LoginOptions): BraintrustState;
@@ -7097,6 +7097,24 @@ type ToolFunctionDefinitionType = z.infer<typeof ToolFunctionDefinition>;
7097
7097
 
7098
7098
  type GenericFunction<Input, Output> = ((input: Input) => Output) | ((input: Input) => Promise<Output>);
7099
7099
 
7100
+ /**
7101
+ * Abstract base class for ID generators
7102
+ */
7103
+ declare abstract class IDGenerator {
7104
+ /**
7105
+ * Generate a span ID
7106
+ */
7107
+ abstract getSpanId(): string;
7108
+ /**
7109
+ * Generate a trace ID
7110
+ */
7111
+ abstract getTraceId(): string;
7112
+ /**
7113
+ * Return true if the generator should use span_id as root_span_id for backwards compatibility
7114
+ */
7115
+ abstract shareRootSpanId(): boolean;
7116
+ }
7117
+
7100
7118
  interface IsoAsyncLocalStorage<T> {
7101
7119
  enterWith(store: T): void;
7102
7120
  run<R>(store: T | undefined, callback: () => R): R;
@@ -7284,8 +7302,10 @@ declare class LazyValue<T> {
7284
7302
  get hasSucceeded(): boolean;
7285
7303
  }
7286
7304
 
7287
- /// <reference lib="dom" />
7288
-
7305
+ interface ContextParentSpanIds {
7306
+ rootSpanId: string;
7307
+ spanParents: string[];
7308
+ }
7289
7309
  type SetCurrentArg = {
7290
7310
  setCurrent?: boolean;
7291
7311
  };
@@ -7436,6 +7456,11 @@ interface Span extends Exportable {
7436
7456
  state(): BraintrustState;
7437
7457
  kind: "span";
7438
7458
  }
7459
+ declare abstract class ContextManager {
7460
+ abstract getParentSpanIds(): ContextParentSpanIds | undefined;
7461
+ abstract runInContext<R>(span: Span, callback: () => R): R;
7462
+ abstract getCurrentSpan(): Span | undefined;
7463
+ }
7439
7464
  /**
7440
7465
  * A fake implementation of the Span API which does nothing. This can be used as the default span.
7441
7466
  */
@@ -7532,8 +7557,13 @@ declare class BraintrustState {
7532
7557
  private _apiConn;
7533
7558
  private _proxyConn;
7534
7559
  promptCache: PromptCache;
7560
+ private _idGenerator;
7561
+ private _contextManager;
7535
7562
  constructor(loginParams: LoginOptions);
7536
7563
  resetLoginInfo(): void;
7564
+ resetIdGenState(): void;
7565
+ get idGenerator(): IDGenerator;
7566
+ get contextManager(): ContextManager;
7537
7567
  copyLoginInfo(other: BraintrustState): void;
7538
7568
  serialize(): SerializedBraintrustState;
7539
7569
  static deserialize(serialized: unknown, opts?: LoginOptions): BraintrustState;