@bitfab/sdk 0.38.2 → 0.38.3

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
@@ -1234,7 +1234,7 @@ interface ReplayOptions {
1234
1234
  * because either source already determines how many traces replay.
1235
1235
  */
1236
1236
  limit?: number;
1237
- /** Optional list of specific trace IDs to replay (max 100). */
1237
+ /** Optional list of specific trace IDs to replay (max 100). Mutually exclusive with `datasetId`. */
1238
1238
  traceIds?: string[];
1239
1239
  /** Optional display name for the resulting experiment/test run. */
1240
1240
  name?: string;
@@ -1291,7 +1291,8 @@ interface ReplayOptions {
1291
1291
  /** Group ID to associate this replay with an experiment group for live streaming in Studio. */
1292
1292
  experimentGroupId?: string;
1293
1293
  /**
1294
- * Dataset this replay runs against. When set, the resulting experiment is
1294
+ * Dataset this replay runs against. Mutually exclusive with `traceIds`. When
1295
+ * set, the resulting experiment is
1295
1296
  * durably attributed to the dataset (stored on the test run), so it appears
1296
1297
  * under the dataset's experiments even if the trace lineage can't be
1297
1298
  * reconstructed. Validated server-side against the org.
@@ -2717,7 +2718,7 @@ declare class BitfabFunction {
2717
2718
  /**
2718
2719
  * SDK version from package.json (injected at build time)
2719
2720
  */
2720
- declare const __version__ = "0.38.2";
2721
+ declare const __version__ = "0.38.3";
2721
2722
 
2722
2723
  /**
2723
2724
  * Constants for the Bitfab SDK.
@@ -2785,4 +2786,39 @@ declare const finalizers: {
2785
2786
  readableStream: typeof readableStream;
2786
2787
  };
2787
2788
 
2788
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayProgress, type ReplayProgressItem, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
2789
+ type ReplayFunction = (...args: any[]) => unknown | Promise<unknown>;
2790
+ type ReplayRegistryOptions = Omit<ReplayOptions, "onItemStart" | "onItemFinish" | "onProgress">;
2791
+ interface ReplayRegistryContext {
2792
+ /** Values supplied through `--params` and repeated `--param name=value`. */
2793
+ params: Readonly<Record<string, unknown>>;
2794
+ }
2795
+ type ReplayOptionsFactory = (context: ReplayRegistryContext) => ReplayRegistryOptions | Promise<ReplayRegistryOptions>;
2796
+ interface ReplayRegistration {
2797
+ /** Client instance used by the production traced function. */
2798
+ client: Bitfab;
2799
+ /** The exact traced function production calls. */
2800
+ fn: ReplayFunction;
2801
+ /**
2802
+ * Required for handler-instrumented or otherwise plain callables. Omit for a
2803
+ * `withSpan`-wrapped function and the registry reads the wrapper's key.
2804
+ */
2805
+ traceFunctionKey?: string;
2806
+ /**
2807
+ * Per-function replay behavior and defaults. Put executable configuration
2808
+ * such as `mockOverride` and `adaptInputs` here; command-line values override
2809
+ * overlapping scalar defaults such as `mock` and `maxConcurrency`.
2810
+ */
2811
+ options?: ReplayRegistryOptions;
2812
+ /** Build executable replay behavior from caller-supplied CLI parameters. */
2813
+ optionsFactory?: ReplayOptionsFactory;
2814
+ }
2815
+ type ReplayRegistry = Record<string, ReplayRegistration>;
2816
+ /**
2817
+ * Define the project-owned list of replayable functions.
2818
+ *
2819
+ * The registry is deliberately data-only: the SDK owns the replay CLI, so an
2820
+ * SDK upgrade can add replay features without regenerating the project file.
2821
+ */
2822
+ declare function defineReplayRegistry<TRegistry extends ReplayRegistry>(registry: TRegistry): TRegistry;
2823
+
2824
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, 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, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
package/dist/index.d.ts CHANGED
@@ -1234,7 +1234,7 @@ interface ReplayOptions {
1234
1234
  * because either source already determines how many traces replay.
1235
1235
  */
1236
1236
  limit?: number;
1237
- /** Optional list of specific trace IDs to replay (max 100). */
1237
+ /** Optional list of specific trace IDs to replay (max 100). Mutually exclusive with `datasetId`. */
1238
1238
  traceIds?: string[];
1239
1239
  /** Optional display name for the resulting experiment/test run. */
1240
1240
  name?: string;
@@ -1291,7 +1291,8 @@ interface ReplayOptions {
1291
1291
  /** Group ID to associate this replay with an experiment group for live streaming in Studio. */
1292
1292
  experimentGroupId?: string;
1293
1293
  /**
1294
- * Dataset this replay runs against. When set, the resulting experiment is
1294
+ * Dataset this replay runs against. Mutually exclusive with `traceIds`. When
1295
+ * set, the resulting experiment is
1295
1296
  * durably attributed to the dataset (stored on the test run), so it appears
1296
1297
  * under the dataset's experiments even if the trace lineage can't be
1297
1298
  * reconstructed. Validated server-side against the org.
@@ -2717,7 +2718,7 @@ declare class BitfabFunction {
2717
2718
  /**
2718
2719
  * SDK version from package.json (injected at build time)
2719
2720
  */
2720
- declare const __version__ = "0.38.2";
2721
+ declare const __version__ = "0.38.3";
2721
2722
 
2722
2723
  /**
2723
2724
  * Constants for the Bitfab SDK.
@@ -2785,4 +2786,39 @@ declare const finalizers: {
2785
2786
  readableStream: typeof readableStream;
2786
2787
  };
2787
2788
 
2788
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayProgress, type ReplayProgressItem, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
2789
+ type ReplayFunction = (...args: any[]) => unknown | Promise<unknown>;
2790
+ type ReplayRegistryOptions = Omit<ReplayOptions, "onItemStart" | "onItemFinish" | "onProgress">;
2791
+ interface ReplayRegistryContext {
2792
+ /** Values supplied through `--params` and repeated `--param name=value`. */
2793
+ params: Readonly<Record<string, unknown>>;
2794
+ }
2795
+ type ReplayOptionsFactory = (context: ReplayRegistryContext) => ReplayRegistryOptions | Promise<ReplayRegistryOptions>;
2796
+ interface ReplayRegistration {
2797
+ /** Client instance used by the production traced function. */
2798
+ client: Bitfab;
2799
+ /** The exact traced function production calls. */
2800
+ fn: ReplayFunction;
2801
+ /**
2802
+ * Required for handler-instrumented or otherwise plain callables. Omit for a
2803
+ * `withSpan`-wrapped function and the registry reads the wrapper's key.
2804
+ */
2805
+ traceFunctionKey?: string;
2806
+ /**
2807
+ * Per-function replay behavior and defaults. Put executable configuration
2808
+ * such as `mockOverride` and `adaptInputs` here; command-line values override
2809
+ * overlapping scalar defaults such as `mock` and `maxConcurrency`.
2810
+ */
2811
+ options?: ReplayRegistryOptions;
2812
+ /** Build executable replay behavior from caller-supplied CLI parameters. */
2813
+ optionsFactory?: ReplayOptionsFactory;
2814
+ }
2815
+ type ReplayRegistry = Record<string, ReplayRegistration>;
2816
+ /**
2817
+ * Define the project-owned list of replayable functions.
2818
+ *
2819
+ * The registry is deliberately data-only: the SDK owns the replay CLI, so an
2820
+ * SDK upgrade can add replay features without regenerating the project file.
2821
+ */
2822
+ declare function defineReplayRegistry<TRegistry extends ReplayRegistry>(registry: TRegistry): TRegistry;
2823
+
2824
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, 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, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
package/dist/index.js CHANGED
@@ -7,11 +7,12 @@ import {
7
7
  BitfabOpenAITracingProcessor,
8
8
  BitfabVercelAiHandler,
9
9
  SUPPORTED_PROVIDERS,
10
+ defineReplayRegistry,
10
11
  finalizers,
11
12
  getCurrentReplayBranch,
12
13
  getCurrentSpan,
13
14
  getCurrentTrace
14
- } from "./chunk-CWXCVY75.js";
15
+ } from "./chunk-RJPHMJWO.js";
15
16
  import "./chunk-GFBQ2AMO.js";
16
17
  import {
17
18
  BITFAB_PROGRESS_PREFIX,
@@ -24,7 +25,7 @@ import {
24
25
  flushTraces,
25
26
  reportReplayProgress,
26
27
  serializeReplayResult
27
- } from "./chunk-SU7EAKOV.js";
28
+ } from "./chunk-WX6AEFCP.js";
28
29
  import "./chunk-H6LZRFMN.js";
29
30
  export {
30
31
  BITFAB_PROGRESS_PREFIX,
@@ -43,6 +44,7 @@ export {
43
44
  ReplayError,
44
45
  SUPPORTED_PROVIDERS,
45
46
  __version__,
47
+ defineReplayRegistry,
46
48
  finalizers,
47
49
  flushTraces,
48
50
  getCurrentReplayBranch,
package/dist/node.cjs CHANGED
@@ -88,7 +88,7 @@ var __version__, __packageName__;
88
88
  var init_version_generated = __esm({
89
89
  "src/version.generated.ts"() {
90
90
  "use strict";
91
- __version__ = "0.38.2";
91
+ __version__ = "0.38.3";
92
92
  __packageName__ = "@bitfab/sdk";
93
93
  }
94
94
  });
@@ -2811,6 +2811,11 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2811
2811
  );
2812
2812
  }
2813
2813
  }
2814
+ if (options?.traceIds !== void 0 && options?.datasetId !== void 0) {
2815
+ throw new BitfabError(
2816
+ "traceIds and datasetId select different replay sources and cannot be used together."
2817
+ );
2818
+ }
2814
2819
  if (options?.limit !== void 0 && options?.traceIds !== void 0) {
2815
2820
  try {
2816
2821
  console.warn(
@@ -3138,6 +3143,7 @@ __export(node_exports, {
3138
3143
  ReplayError: () => ReplayError,
3139
3144
  SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
3140
3145
  __version__: () => __version__,
3146
+ defineReplayRegistry: () => defineReplayRegistry,
3141
3147
  finalizers: () => finalizers,
3142
3148
  flushTraces: () => flushTraces,
3143
3149
  getCurrentReplayBranch: () => getCurrentReplayBranch,
@@ -7078,6 +7084,13 @@ var finalizers = {
7078
7084
  init_http();
7079
7085
  init_replay();
7080
7086
 
7087
+ // src/replayRegistry.ts
7088
+ init_errors();
7089
+ init_replay();
7090
+ function defineReplayRegistry(registry) {
7091
+ return registry;
7092
+ }
7093
+
7081
7094
  // src/node.ts
7082
7095
  init_asyncStorage();
7083
7096
  assertAsyncStorageRegistered();
@@ -7099,6 +7112,7 @@ assertAsyncStorageRegistered();
7099
7112
  ReplayError,
7100
7113
  SUPPORTED_PROVIDERS,
7101
7114
  __version__,
7115
+ defineReplayRegistry,
7102
7116
  finalizers,
7103
7117
  flushTraces,
7104
7118
  getCurrentReplayBranch,