@bitfab/sdk 0.41.0 → 0.43.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.
package/dist/index.d.cts CHANGED
@@ -306,6 +306,7 @@ interface ReplayContext {
306
306
  * customer sees in the Bitfab dashboard.
307
307
  */
308
308
  sourceBitfabTraceId?: string;
309
+ replayAttempt?: number;
309
310
  mockTree?: MockTree;
310
311
  callCounters?: Map<string, number>;
311
312
  mockStrategy?: "none" | "all" | "marked";
@@ -584,7 +585,7 @@ declare class HttpClient {
584
585
  * Start a replay session by fetching historical traces.
585
586
  * Blocking call - creates a test run and returns lightweight item references.
586
587
  */
587
- startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetId?: string, graderIds?: string[], dbBranchSettings?: DbBranchSettings): Promise<StartReplayResponse>;
588
+ startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetId?: string, graderIds?: string[], dbBranchSettings?: DbBranchSettings, attempts?: number, includeOriginalMetadata?: boolean): Promise<StartReplayResponse>;
588
589
  /**
589
590
  * Fetch an external span by ID.
590
591
  * Blocking GET request.
@@ -625,7 +626,7 @@ declare class HttpClient {
625
626
  * snapshot + preview branch and polls operations to readiness, which
626
627
  * can take seconds.
627
628
  */
628
- resolveDbBranchLease(testRunId: string, traceId: string, dbBranchSettings?: DbBranchSettings): Promise<{
629
+ resolveDbBranchLease(testRunId: string, traceId: string, dbBranchSettings?: DbBranchSettings, attempt?: number): Promise<{
629
630
  dbSnapshotRef: DbSnapshotRef | null;
630
631
  lease: DbBranchLease | null;
631
632
  leaseError: {
@@ -658,6 +659,7 @@ interface CodeChangeFile {
658
659
  interface StartReplayResponse {
659
660
  testRunId: string;
660
661
  testRunUrl: string;
662
+ attempts?: number;
661
663
  items: Array<{
662
664
  /** Bitfab trace ID of the original (historical) trace being replayed. */
663
665
  originalTraceId?: string;
@@ -698,6 +700,7 @@ interface StartReplayResponse {
698
700
  * servers that predate it.
699
701
  */
700
702
  dbBranchTimings?: DbBranchTimings;
703
+ originalMetadata?: Record<string, unknown>;
701
704
  }>;
702
705
  }
703
706
  interface ExternalSpanResponse {
@@ -960,6 +963,7 @@ declare class BitfabClaudeAgentHandler {
960
963
  type LlmSpanOptions = {
961
964
  type: "llm";
962
965
  finalize: (result: unknown) => unknown | Promise<unknown>;
966
+ surface: "inherit";
963
967
  };
964
968
  type WithSpanFn$1 = <TArgs extends unknown[], TReturn>(traceFunctionKey: string, options: LlmSpanOptions, fn: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
965
969
  /**
@@ -1265,6 +1269,7 @@ interface SpanClient {
1265
1269
  captureWhen?: "always" | "nested";
1266
1270
  mockOnReplay?: boolean;
1267
1271
  finalize?: (result: unknown) => unknown | Promise<unknown>;
1272
+ surface?: "inherit";
1268
1273
  }, fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
1269
1274
  }
1270
1275
  interface LangGraphTool {
@@ -1371,6 +1376,7 @@ type RunResultLike = {
1371
1376
  type RootSpanOptions = {
1372
1377
  type: "agent";
1373
1378
  finalize: (result: unknown) => unknown | Promise<unknown>;
1379
+ surface: "inherit";
1374
1380
  };
1375
1381
  type WithSpanFn = <TArgs extends unknown[], TReturn>(traceFunctionKey: string, options: RootSpanOptions, fn: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
1376
1382
  type GetActiveSpanContextFn = () => unknown | null;
@@ -1472,6 +1478,7 @@ interface ReplayOptions {
1472
1478
  * because either source already determines how many traces replay.
1473
1479
  */
1474
1480
  limit?: number;
1481
+ attempts?: number;
1475
1482
  /** Optional list of specific trace IDs to replay (max 100). Mutually exclusive with `datasetId`. */
1476
1483
  traceIds?: string[];
1477
1484
  /** Optional display name for the resulting experiment/test run. */
@@ -1624,6 +1631,7 @@ interface ReplayItemStartProgress {
1624
1631
  sourceTraceId: string;
1625
1632
  /** @deprecated alias for `originalSpanId`. */
1626
1633
  sourceSpanId: string;
1634
+ attempt: number;
1627
1635
  };
1628
1636
  }
1629
1637
  /** Running totals reported to {@link ReplayOptions.onItemFinish} as replay proceeds. */
@@ -1663,6 +1671,7 @@ interface ReplayProgressItem {
1663
1671
  sourceTraceId: string | null;
1664
1672
  /** @deprecated alias for `originalSpanId`. */
1665
1673
  sourceSpanId?: string | null;
1674
+ attempt: number;
1666
1675
  /** Deserialized inputs from the original trace. */
1667
1676
  input?: unknown[];
1668
1677
  /** The result returned by the replayed function, or undefined on error. */
@@ -1741,6 +1750,7 @@ interface AdaptContext {
1741
1750
  sourceTraceId: string;
1742
1751
  /** @deprecated alias for {@link AdaptContext.originalSpanId}. */
1743
1752
  sourceSpanId: string;
1753
+ metadata: Record<string, unknown>;
1744
1754
  }
1745
1755
  /**
1746
1756
  * The shape an adapter module must export as `adaptInputs`.
@@ -1772,6 +1782,7 @@ interface ReplayItem<T> {
1772
1782
  sourceTraceId: string;
1773
1783
  /** @deprecated alias for {@link ReplayItem.originalSpanId}. */
1774
1784
  sourceSpanId: string;
1785
+ attempt: number;
1775
1786
  /** Deserialized inputs from the original trace. */
1776
1787
  input: unknown[];
1777
1788
  /** The result returned by the function during replay, or undefined on error. */
@@ -1850,6 +1861,7 @@ interface ReplayResult<T> {
1850
1861
  testRunId: string;
1851
1862
  /** Full URL to view the test run in the dashboard. */
1852
1863
  testRunUrl: string;
1864
+ attempts: number;
1853
1865
  }
1854
1866
  /**
1855
1867
  * Whole-run replay failure that preserves every item collected before the run
@@ -2094,6 +2106,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
2094
2106
  private sendSpan;
2095
2107
  }
2096
2108
 
2109
+ type CaptureSurface = "opt-in" | "opt-out";
2097
2110
  /**
2098
2111
  * Options for wrapBAML.
2099
2112
  */
@@ -2229,6 +2242,22 @@ declare function getCurrentReplayBranch(): ReplayBranch | null;
2229
2242
  * Returns a no-op object if called outside of a span context (methods do nothing).
2230
2243
  */
2231
2244
  declare function getCurrentTrace(): CurrentTrace;
2245
+ interface SeedCaseOptions {
2246
+ input: unknown[];
2247
+ expected?: unknown;
2248
+ fn?: (...args: any[]) => unknown;
2249
+ metadata?: Record<string, unknown>;
2250
+ sessionId?: string;
2251
+ name?: string;
2252
+ spanName?: string;
2253
+ spanType?: SpanType;
2254
+ }
2255
+ interface SeedRunOptions<TArgs extends unknown[]> {
2256
+ args?: TArgs;
2257
+ metadata?: Record<string, unknown>;
2258
+ sessionId?: string;
2259
+ name?: string;
2260
+ }
2232
2261
  interface BitfabConfig {
2233
2262
  /**
2234
2263
  * The API key for Bitfab API authentication. Resolved lazily, the first
@@ -2249,7 +2278,7 @@ interface BitfabConfig {
2249
2278
  timeout?: number;
2250
2279
  /** Environment variables for LLM provider API keys (only OPENAI_API_KEY is supported) */
2251
2280
  envVars?: AllowedEnvVars;
2252
- /** Whether the client is enabled. Defaults to true. When false, withSpan returns the original function unwrapped. */
2281
+ captureEnabled?: boolean;
2253
2282
  enabled?: boolean;
2254
2283
  /**
2255
2284
  * Fail loud instead of degrading quietly. When true, the first traced call
@@ -2410,8 +2439,7 @@ declare class Bitfab {
2410
2439
  private readonly serviceUrl;
2411
2440
  private readonly timeout;
2412
2441
  private readonly envVars;
2413
- /** The user's on/off intent. The effective enabled state ANDs this with "a key resolved" (see isTracingEnabled). */
2414
- private readonly explicitlyEnabled;
2442
+ private readonly captureConfigured;
2415
2443
  private readonly strict;
2416
2444
  private readonly httpClient;
2417
2445
  /** Dataset operations for the authenticated organization. */
@@ -2526,12 +2554,9 @@ declare class Bitfab {
2526
2554
  * early resolve that found nothing never poisons a later one.
2527
2555
  */
2528
2556
  private resolveApiKey;
2529
- /**
2530
- * Whether tracing should run, decided lazily at call time (not frozen at
2531
- * construction). An explicit `enabled: false` short-circuits without ever
2532
- * touching the key.
2533
- */
2534
- private isTracingEnabled;
2557
+ private isCaptureEnabled;
2558
+ private shouldRecord;
2559
+ get captureEnabled(): boolean;
2535
2560
  /**
2536
2561
  * Fetch the function with its current version and BAML prompt from the server.
2537
2562
  *
@@ -2885,46 +2910,10 @@ declare class Bitfab {
2885
2910
  registerMockOverride(traceFunctionKey: string, override: MockOverride | MockOverrideResolver): void;
2886
2911
  /** Remove all overrides registered via {@link registerMockOverride}. */
2887
2912
  clearMockOverrides(): void;
2888
- /**
2889
- * Write a replayable trace from a case, without running anything.
2890
- *
2891
- * Use this to turn a corpus you already hold (a Braintrust dataset, a
2892
- * spreadsheet, hand-written cases) into traces that {@link replay} can
2893
- * select. The recorded root span carries `input` as its input and `expected`
2894
- * as its output, so replay reports each item against the value you expected
2895
- * rather than against a previous run.
2896
- *
2897
- * A seeded trace has no child spans and no database pin, so replay mocking
2898
- * has nothing recorded to substitute and `dbBranch` refuses it. Pass
2899
- * `mockOverride` at replay time for calls that must not run.
2900
- *
2901
- * @returns The trace ID, usable with `replay({ traceIds: [...] })`.
2902
- */
2903
- seedTrace(traceFunctionKey: string, options: {
2904
- /** Arguments spread into the function at replay, as `fn(...input)`. */
2905
- input: unknown[];
2906
- /**
2907
- * The output this case should produce. Optional, but without it the
2908
- * replay has nothing to be judged against.
2909
- */
2910
- expected?: unknown;
2911
- /**
2912
- * The function these inputs will replay through. When given, the call is
2913
- * checked against its arity here, so a case that cannot supply the
2914
- * function's required arguments fails now instead of at replay. Omit it
2915
- * when the seeding script cannot import the function.
2916
- */
2917
- fn?: (...args: any[]) => unknown;
2918
- /**
2919
- * Recorded on the trace. Put the source row's id here so a seeded trace
2920
- * can be traced back to the case it came from.
2921
- */
2922
- metadata?: Record<string, unknown>;
2923
- sessionId?: string;
2924
- name?: string;
2925
- spanName?: string;
2926
- spanType?: SpanType;
2927
- }): string;
2913
+ seedTrace(traceFunctionKey: string, options: SeedCaseOptions): string;
2914
+ seedTrace<TArgs extends unknown[], TReturn>(traceFunctionKey: string, fn: (...args: TArgs) => TReturn, options?: SeedRunOptions<TArgs>): Promise<string>;
2915
+ private seedTraceFromCase;
2916
+ private seedTraceByRunning;
2928
2917
  replay<TReturn>(traceFunctionKey: string, fn: (...args: any[]) => TReturn | Promise<TReturn>, options?: ReplayOptions): Promise<ReplayResult<TReturn>>;
2929
2918
  }
2930
2919
  /**
@@ -3100,7 +3089,7 @@ declare class BitfabFunction {
3100
3089
  /**
3101
3090
  * SDK version from package.json (injected at build time)
3102
3091
  */
3103
- declare const __version__ = "0.41.0";
3092
+ declare const __version__ = "0.43.0";
3104
3093
 
3105
3094
  /**
3106
3095
  * Constants for the Bitfab SDK.
@@ -3226,6 +3215,8 @@ interface SeedResult {
3226
3215
  * Passing the registered function to `seedTrace` also means a case that cannot
3227
3216
  * supply its required arguments is rejected here rather than at replay.
3228
3217
  */
3229
- declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, cases: readonly SeedCase[]): Promise<SeedResult>;
3218
+ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, cases: readonly SeedCase[], options?: {
3219
+ run?: boolean;
3220
+ }): Promise<SeedResult>;
3230
3221
 
3231
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, HttpClient, type LangGraphIntegrationOptions, type ListDatasetsParams, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedResult, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceIngestionType, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
3222
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, HttpClient, type LangGraphIntegrationOptions, type ListDatasetsParams, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceIngestionType, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
package/dist/index.d.ts CHANGED
@@ -306,6 +306,7 @@ interface ReplayContext {
306
306
  * customer sees in the Bitfab dashboard.
307
307
  */
308
308
  sourceBitfabTraceId?: string;
309
+ replayAttempt?: number;
309
310
  mockTree?: MockTree;
310
311
  callCounters?: Map<string, number>;
311
312
  mockStrategy?: "none" | "all" | "marked";
@@ -584,7 +585,7 @@ declare class HttpClient {
584
585
  * Start a replay session by fetching historical traces.
585
586
  * Blocking call - creates a test run and returns lightweight item references.
586
587
  */
587
- startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetId?: string, graderIds?: string[], dbBranchSettings?: DbBranchSettings): Promise<StartReplayResponse>;
588
+ startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetId?: string, graderIds?: string[], dbBranchSettings?: DbBranchSettings, attempts?: number, includeOriginalMetadata?: boolean): Promise<StartReplayResponse>;
588
589
  /**
589
590
  * Fetch an external span by ID.
590
591
  * Blocking GET request.
@@ -625,7 +626,7 @@ declare class HttpClient {
625
626
  * snapshot + preview branch and polls operations to readiness, which
626
627
  * can take seconds.
627
628
  */
628
- resolveDbBranchLease(testRunId: string, traceId: string, dbBranchSettings?: DbBranchSettings): Promise<{
629
+ resolveDbBranchLease(testRunId: string, traceId: string, dbBranchSettings?: DbBranchSettings, attempt?: number): Promise<{
629
630
  dbSnapshotRef: DbSnapshotRef | null;
630
631
  lease: DbBranchLease | null;
631
632
  leaseError: {
@@ -658,6 +659,7 @@ interface CodeChangeFile {
658
659
  interface StartReplayResponse {
659
660
  testRunId: string;
660
661
  testRunUrl: string;
662
+ attempts?: number;
661
663
  items: Array<{
662
664
  /** Bitfab trace ID of the original (historical) trace being replayed. */
663
665
  originalTraceId?: string;
@@ -698,6 +700,7 @@ interface StartReplayResponse {
698
700
  * servers that predate it.
699
701
  */
700
702
  dbBranchTimings?: DbBranchTimings;
703
+ originalMetadata?: Record<string, unknown>;
701
704
  }>;
702
705
  }
703
706
  interface ExternalSpanResponse {
@@ -960,6 +963,7 @@ declare class BitfabClaudeAgentHandler {
960
963
  type LlmSpanOptions = {
961
964
  type: "llm";
962
965
  finalize: (result: unknown) => unknown | Promise<unknown>;
966
+ surface: "inherit";
963
967
  };
964
968
  type WithSpanFn$1 = <TArgs extends unknown[], TReturn>(traceFunctionKey: string, options: LlmSpanOptions, fn: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
965
969
  /**
@@ -1265,6 +1269,7 @@ interface SpanClient {
1265
1269
  captureWhen?: "always" | "nested";
1266
1270
  mockOnReplay?: boolean;
1267
1271
  finalize?: (result: unknown) => unknown | Promise<unknown>;
1272
+ surface?: "inherit";
1268
1273
  }, fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
1269
1274
  }
1270
1275
  interface LangGraphTool {
@@ -1371,6 +1376,7 @@ type RunResultLike = {
1371
1376
  type RootSpanOptions = {
1372
1377
  type: "agent";
1373
1378
  finalize: (result: unknown) => unknown | Promise<unknown>;
1379
+ surface: "inherit";
1374
1380
  };
1375
1381
  type WithSpanFn = <TArgs extends unknown[], TReturn>(traceFunctionKey: string, options: RootSpanOptions, fn: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
1376
1382
  type GetActiveSpanContextFn = () => unknown | null;
@@ -1472,6 +1478,7 @@ interface ReplayOptions {
1472
1478
  * because either source already determines how many traces replay.
1473
1479
  */
1474
1480
  limit?: number;
1481
+ attempts?: number;
1475
1482
  /** Optional list of specific trace IDs to replay (max 100). Mutually exclusive with `datasetId`. */
1476
1483
  traceIds?: string[];
1477
1484
  /** Optional display name for the resulting experiment/test run. */
@@ -1624,6 +1631,7 @@ interface ReplayItemStartProgress {
1624
1631
  sourceTraceId: string;
1625
1632
  /** @deprecated alias for `originalSpanId`. */
1626
1633
  sourceSpanId: string;
1634
+ attempt: number;
1627
1635
  };
1628
1636
  }
1629
1637
  /** Running totals reported to {@link ReplayOptions.onItemFinish} as replay proceeds. */
@@ -1663,6 +1671,7 @@ interface ReplayProgressItem {
1663
1671
  sourceTraceId: string | null;
1664
1672
  /** @deprecated alias for `originalSpanId`. */
1665
1673
  sourceSpanId?: string | null;
1674
+ attempt: number;
1666
1675
  /** Deserialized inputs from the original trace. */
1667
1676
  input?: unknown[];
1668
1677
  /** The result returned by the replayed function, or undefined on error. */
@@ -1741,6 +1750,7 @@ interface AdaptContext {
1741
1750
  sourceTraceId: string;
1742
1751
  /** @deprecated alias for {@link AdaptContext.originalSpanId}. */
1743
1752
  sourceSpanId: string;
1753
+ metadata: Record<string, unknown>;
1744
1754
  }
1745
1755
  /**
1746
1756
  * The shape an adapter module must export as `adaptInputs`.
@@ -1772,6 +1782,7 @@ interface ReplayItem<T> {
1772
1782
  sourceTraceId: string;
1773
1783
  /** @deprecated alias for {@link ReplayItem.originalSpanId}. */
1774
1784
  sourceSpanId: string;
1785
+ attempt: number;
1775
1786
  /** Deserialized inputs from the original trace. */
1776
1787
  input: unknown[];
1777
1788
  /** The result returned by the function during replay, or undefined on error. */
@@ -1850,6 +1861,7 @@ interface ReplayResult<T> {
1850
1861
  testRunId: string;
1851
1862
  /** Full URL to view the test run in the dashboard. */
1852
1863
  testRunUrl: string;
1864
+ attempts: number;
1853
1865
  }
1854
1866
  /**
1855
1867
  * Whole-run replay failure that preserves every item collected before the run
@@ -2094,6 +2106,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
2094
2106
  private sendSpan;
2095
2107
  }
2096
2108
 
2109
+ type CaptureSurface = "opt-in" | "opt-out";
2097
2110
  /**
2098
2111
  * Options for wrapBAML.
2099
2112
  */
@@ -2229,6 +2242,22 @@ declare function getCurrentReplayBranch(): ReplayBranch | null;
2229
2242
  * Returns a no-op object if called outside of a span context (methods do nothing).
2230
2243
  */
2231
2244
  declare function getCurrentTrace(): CurrentTrace;
2245
+ interface SeedCaseOptions {
2246
+ input: unknown[];
2247
+ expected?: unknown;
2248
+ fn?: (...args: any[]) => unknown;
2249
+ metadata?: Record<string, unknown>;
2250
+ sessionId?: string;
2251
+ name?: string;
2252
+ spanName?: string;
2253
+ spanType?: SpanType;
2254
+ }
2255
+ interface SeedRunOptions<TArgs extends unknown[]> {
2256
+ args?: TArgs;
2257
+ metadata?: Record<string, unknown>;
2258
+ sessionId?: string;
2259
+ name?: string;
2260
+ }
2232
2261
  interface BitfabConfig {
2233
2262
  /**
2234
2263
  * The API key for Bitfab API authentication. Resolved lazily, the first
@@ -2249,7 +2278,7 @@ interface BitfabConfig {
2249
2278
  timeout?: number;
2250
2279
  /** Environment variables for LLM provider API keys (only OPENAI_API_KEY is supported) */
2251
2280
  envVars?: AllowedEnvVars;
2252
- /** Whether the client is enabled. Defaults to true. When false, withSpan returns the original function unwrapped. */
2281
+ captureEnabled?: boolean;
2253
2282
  enabled?: boolean;
2254
2283
  /**
2255
2284
  * Fail loud instead of degrading quietly. When true, the first traced call
@@ -2410,8 +2439,7 @@ declare class Bitfab {
2410
2439
  private readonly serviceUrl;
2411
2440
  private readonly timeout;
2412
2441
  private readonly envVars;
2413
- /** The user's on/off intent. The effective enabled state ANDs this with "a key resolved" (see isTracingEnabled). */
2414
- private readonly explicitlyEnabled;
2442
+ private readonly captureConfigured;
2415
2443
  private readonly strict;
2416
2444
  private readonly httpClient;
2417
2445
  /** Dataset operations for the authenticated organization. */
@@ -2526,12 +2554,9 @@ declare class Bitfab {
2526
2554
  * early resolve that found nothing never poisons a later one.
2527
2555
  */
2528
2556
  private resolveApiKey;
2529
- /**
2530
- * Whether tracing should run, decided lazily at call time (not frozen at
2531
- * construction). An explicit `enabled: false` short-circuits without ever
2532
- * touching the key.
2533
- */
2534
- private isTracingEnabled;
2557
+ private isCaptureEnabled;
2558
+ private shouldRecord;
2559
+ get captureEnabled(): boolean;
2535
2560
  /**
2536
2561
  * Fetch the function with its current version and BAML prompt from the server.
2537
2562
  *
@@ -2885,46 +2910,10 @@ declare class Bitfab {
2885
2910
  registerMockOverride(traceFunctionKey: string, override: MockOverride | MockOverrideResolver): void;
2886
2911
  /** Remove all overrides registered via {@link registerMockOverride}. */
2887
2912
  clearMockOverrides(): void;
2888
- /**
2889
- * Write a replayable trace from a case, without running anything.
2890
- *
2891
- * Use this to turn a corpus you already hold (a Braintrust dataset, a
2892
- * spreadsheet, hand-written cases) into traces that {@link replay} can
2893
- * select. The recorded root span carries `input` as its input and `expected`
2894
- * as its output, so replay reports each item against the value you expected
2895
- * rather than against a previous run.
2896
- *
2897
- * A seeded trace has no child spans and no database pin, so replay mocking
2898
- * has nothing recorded to substitute and `dbBranch` refuses it. Pass
2899
- * `mockOverride` at replay time for calls that must not run.
2900
- *
2901
- * @returns The trace ID, usable with `replay({ traceIds: [...] })`.
2902
- */
2903
- seedTrace(traceFunctionKey: string, options: {
2904
- /** Arguments spread into the function at replay, as `fn(...input)`. */
2905
- input: unknown[];
2906
- /**
2907
- * The output this case should produce. Optional, but without it the
2908
- * replay has nothing to be judged against.
2909
- */
2910
- expected?: unknown;
2911
- /**
2912
- * The function these inputs will replay through. When given, the call is
2913
- * checked against its arity here, so a case that cannot supply the
2914
- * function's required arguments fails now instead of at replay. Omit it
2915
- * when the seeding script cannot import the function.
2916
- */
2917
- fn?: (...args: any[]) => unknown;
2918
- /**
2919
- * Recorded on the trace. Put the source row's id here so a seeded trace
2920
- * can be traced back to the case it came from.
2921
- */
2922
- metadata?: Record<string, unknown>;
2923
- sessionId?: string;
2924
- name?: string;
2925
- spanName?: string;
2926
- spanType?: SpanType;
2927
- }): string;
2913
+ seedTrace(traceFunctionKey: string, options: SeedCaseOptions): string;
2914
+ seedTrace<TArgs extends unknown[], TReturn>(traceFunctionKey: string, fn: (...args: TArgs) => TReturn, options?: SeedRunOptions<TArgs>): Promise<string>;
2915
+ private seedTraceFromCase;
2916
+ private seedTraceByRunning;
2928
2917
  replay<TReturn>(traceFunctionKey: string, fn: (...args: any[]) => TReturn | Promise<TReturn>, options?: ReplayOptions): Promise<ReplayResult<TReturn>>;
2929
2918
  }
2930
2919
  /**
@@ -3100,7 +3089,7 @@ declare class BitfabFunction {
3100
3089
  /**
3101
3090
  * SDK version from package.json (injected at build time)
3102
3091
  */
3103
- declare const __version__ = "0.41.0";
3092
+ declare const __version__ = "0.43.0";
3104
3093
 
3105
3094
  /**
3106
3095
  * Constants for the Bitfab SDK.
@@ -3226,6 +3215,8 @@ interface SeedResult {
3226
3215
  * Passing the registered function to `seedTrace` also means a case that cannot
3227
3216
  * supply its required arguments is rejected here rather than at replay.
3228
3217
  */
3229
- declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, cases: readonly SeedCase[]): Promise<SeedResult>;
3218
+ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, cases: readonly SeedCase[], options?: {
3219
+ run?: boolean;
3220
+ }): Promise<SeedResult>;
3230
3221
 
3231
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, HttpClient, type LangGraphIntegrationOptions, type ListDatasetsParams, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedResult, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceIngestionType, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
3222
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, HttpClient, type LangGraphIntegrationOptions, type ListDatasetsParams, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceIngestionType, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  getCurrentSpan,
16
16
  getCurrentTrace,
17
17
  seedFromRegistry
18
- } from "./chunk-U3AKIFW3.js";
18
+ } from "./chunk-5BBJ5BQD.js";
19
19
  import "./chunk-ZUD7OFYB.js";
20
20
  import {
21
21
  BITFAB_PROGRESS_PREFIX,
@@ -24,14 +24,14 @@ import {
24
24
  ReplayError,
25
25
  reportReplayProgress,
26
26
  serializeReplayResult
27
- } from "./chunk-RWZYZRYI.js";
27
+ } from "./chunk-BXBRVWWW.js";
28
28
  import {
29
29
  BitfabError,
30
30
  DEFAULT_SERVICE_URL,
31
31
  HttpClient,
32
32
  __version__,
33
33
  flushTraces
34
- } from "./chunk-IFYX3KW6.js";
34
+ } from "./chunk-6EM2S5H5.js";
35
35
  import "./chunk-H6LZRFMN.js";
36
36
  export {
37
37
  BITFAB_PROGRESS_PREFIX,