bitfab 0.14.0 → 0.16.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
@@ -380,7 +380,46 @@ interface ReplayOptions {
380
380
  environment?: ReplayEnvironment;
381
381
  /** Group ID to associate this replay with an experiment group for live streaming in Studio. */
382
382
  experimentGroupId?: string;
383
+ /**
384
+ * Reshape recorded inputs before they are spread into `fn`.
385
+ *
386
+ * Replay pulls each trace's inputs exactly as they were captured against the
387
+ * function's signature AT TRACE TIME. When the function's shape has since
388
+ * changed (params renamed, reordered, collapsed into an options object, etc.),
389
+ * the recorded inputs no longer line up and `fn(...inputs)` throws. This hook
390
+ * lets a caller map the recorded inputs onto the current signature so replay
391
+ * can still run.
392
+ *
393
+ * Receives the deserialized recorded inputs and a per-trace {@link AdaptContext}
394
+ * (so a table-driven adapter can look up the adapted inputs by `traceId`), and
395
+ * returns the array actually spread into `fn`. The returned array is also what
396
+ * `ReplayItem.input` reports, so the experiment shows what was really run.
397
+ *
398
+ * Runs per item, inside the same try/catch as `fn`: if the adapter throws, the
399
+ * failure is surfaced on that item's `error` rather than crashing the run.
400
+ * Omit it to spread the recorded inputs unchanged.
401
+ */
402
+ adaptInputs?: (inputs: unknown[], ctx: AdaptContext) => unknown[];
403
+ }
404
+ /** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
405
+ interface AdaptContext {
406
+ /** Bitfab trace ID of the historical trace being replayed. */
407
+ traceId: string;
408
+ /** External span ID the recorded inputs were read from. */
409
+ sourceSpanId: string;
383
410
  }
411
+ /**
412
+ * The shape an adapter module must export as `adaptInputs`.
413
+ *
414
+ * Author an adapter in its own file (e.g. `scripts/replay-adapters/<name>.ts`),
415
+ * import it in your replay script, and pass it to `replay({ adaptInputs })`:
416
+ *
417
+ * ```ts
418
+ * import type { AdaptInputsFn } from "@bitfab/sdk"
419
+ * export const adaptInputs: AdaptInputsFn = (inputs, ctx) => [reshape(inputs)]
420
+ * ```
421
+ */
422
+ type AdaptInputsFn = (inputs: unknown[], ctx: AdaptContext) => unknown[];
384
423
  interface ReplayItem<T> {
385
424
  /** Trace ID of the new trace created during replay. */
386
425
  traceId: string | null;
@@ -988,7 +1027,7 @@ declare class BitfabFunction {
988
1027
  /**
989
1028
  * SDK version from package.json (injected at build time)
990
1029
  */
991
- declare const __version__ = "0.14.0";
1030
+ declare const __version__ = "0.16.0";
992
1031
 
993
1032
  /**
994
1033
  * Constants for the Bitfab SDK.
@@ -998,4 +1037,4 @@ declare const __version__ = "0.14.0";
998
1037
  */
999
1038
  declare const DEFAULT_SERVICE_URL = "https://bitfab.ai";
1000
1039
 
1001
- export { type ActiveSpanContext, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
1040
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
package/dist/index.d.ts CHANGED
@@ -380,7 +380,46 @@ interface ReplayOptions {
380
380
  environment?: ReplayEnvironment;
381
381
  /** Group ID to associate this replay with an experiment group for live streaming in Studio. */
382
382
  experimentGroupId?: string;
383
+ /**
384
+ * Reshape recorded inputs before they are spread into `fn`.
385
+ *
386
+ * Replay pulls each trace's inputs exactly as they were captured against the
387
+ * function's signature AT TRACE TIME. When the function's shape has since
388
+ * changed (params renamed, reordered, collapsed into an options object, etc.),
389
+ * the recorded inputs no longer line up and `fn(...inputs)` throws. This hook
390
+ * lets a caller map the recorded inputs onto the current signature so replay
391
+ * can still run.
392
+ *
393
+ * Receives the deserialized recorded inputs and a per-trace {@link AdaptContext}
394
+ * (so a table-driven adapter can look up the adapted inputs by `traceId`), and
395
+ * returns the array actually spread into `fn`. The returned array is also what
396
+ * `ReplayItem.input` reports, so the experiment shows what was really run.
397
+ *
398
+ * Runs per item, inside the same try/catch as `fn`: if the adapter throws, the
399
+ * failure is surfaced on that item's `error` rather than crashing the run.
400
+ * Omit it to spread the recorded inputs unchanged.
401
+ */
402
+ adaptInputs?: (inputs: unknown[], ctx: AdaptContext) => unknown[];
403
+ }
404
+ /** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
405
+ interface AdaptContext {
406
+ /** Bitfab trace ID of the historical trace being replayed. */
407
+ traceId: string;
408
+ /** External span ID the recorded inputs were read from. */
409
+ sourceSpanId: string;
383
410
  }
411
+ /**
412
+ * The shape an adapter module must export as `adaptInputs`.
413
+ *
414
+ * Author an adapter in its own file (e.g. `scripts/replay-adapters/<name>.ts`),
415
+ * import it in your replay script, and pass it to `replay({ adaptInputs })`:
416
+ *
417
+ * ```ts
418
+ * import type { AdaptInputsFn } from "@bitfab/sdk"
419
+ * export const adaptInputs: AdaptInputsFn = (inputs, ctx) => [reshape(inputs)]
420
+ * ```
421
+ */
422
+ type AdaptInputsFn = (inputs: unknown[], ctx: AdaptContext) => unknown[];
384
423
  interface ReplayItem<T> {
385
424
  /** Trace ID of the new trace created during replay. */
386
425
  traceId: string | null;
@@ -988,7 +1027,7 @@ declare class BitfabFunction {
988
1027
  /**
989
1028
  * SDK version from package.json (injected at build time)
990
1029
  */
991
- declare const __version__ = "0.14.0";
1030
+ declare const __version__ = "0.16.0";
992
1031
 
993
1032
  /**
994
1033
  * Constants for the Bitfab SDK.
@@ -998,4 +1037,4 @@ declare const __version__ = "0.14.0";
998
1037
  */
999
1038
  declare const DEFAULT_SERVICE_URL = "https://bitfab.ai";
1000
1039
 
1001
- export { type ActiveSpanContext, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
1040
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
package/dist/index.js CHANGED
@@ -13,17 +13,17 @@ import {
13
13
  BitfabFunction,
14
14
  BitfabLangGraphCallbackHandler,
15
15
  BitfabOpenAITracingProcessor,
16
+ DEFAULT_SERVICE_URL,
16
17
  ReplayEnvironment,
17
18
  SUPPORTED_PROVIDERS,
19
+ __version__,
20
+ flushTraces,
18
21
  getCurrentSpan,
19
22
  getCurrentTrace
20
- } from "./chunk-RMQX546G.js";
23
+ } from "./chunk-53G5GR7B.js";
21
24
  import {
22
- BitfabError,
23
- DEFAULT_SERVICE_URL,
24
- __version__,
25
- flushTraces
26
- } from "./chunk-OW2EJK7T.js";
25
+ BitfabError
26
+ } from "./chunk-QT7HWOKU.js";
27
27
  export {
28
28
  Bitfab,
29
29
  BitfabClaudeAgentHandler,