bitfab 0.24.1 → 0.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.
package/dist/index.d.cts CHANGED
@@ -651,6 +651,30 @@ interface ReplayOptions {
651
651
  * Omit it to spread the recorded inputs unchanged.
652
652
  */
653
653
  adaptInputs?: (inputs: unknown[], ctx: AdaptContext) => unknown[];
654
+ /**
655
+ * Called once per item as it finishes, in completion order (not input
656
+ * order), with running totals for the whole run. Use it to render replay
657
+ * progress, for example a terminal progress bar. Replay does not know
658
+ * pass/fail at this point (verdicts are assigned later), so the totals only
659
+ * distinguish items whose function ran (`succeeded`) from items that threw
660
+ * (`errored`).
661
+ *
662
+ * Invoked synchronously right after each item settles, so keep it cheap. A
663
+ * throwing callback never crashes the run: the error is swallowed so progress
664
+ * UI can't break replay.
665
+ */
666
+ onProgress?: (progress: ReplayProgress) => void;
667
+ }
668
+ /** Running totals reported to {@link ReplayOptions.onProgress} as replay proceeds. */
669
+ interface ReplayProgress {
670
+ /** Items that have finished so far, whether they succeeded or errored. */
671
+ completed: number;
672
+ /** Total number of items in this replay run. */
673
+ total: number;
674
+ /** Of the completed items, how many ran the function without throwing. */
675
+ succeeded: number;
676
+ /** Of the completed items, how many threw (their `item.error` is set). */
677
+ errored: number;
654
678
  }
655
679
  /** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
656
680
  interface AdaptContext {
@@ -1380,7 +1404,7 @@ declare class BitfabFunction {
1380
1404
  /**
1381
1405
  * SDK version from package.json (injected at build time)
1382
1406
  */
1383
- declare const __version__ = "0.24.1";
1407
+ declare const __version__ = "0.25.0";
1384
1408
 
1385
1409
  /**
1386
1410
  * Constants for the Bitfab SDK.
@@ -1448,4 +1472,4 @@ declare const finalizers: {
1448
1472
  readableStream: typeof readableStream;
1449
1473
  };
1450
1474
 
1451
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, 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 VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace };
1475
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, 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 ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace };
package/dist/index.d.ts CHANGED
@@ -651,6 +651,30 @@ interface ReplayOptions {
651
651
  * Omit it to spread the recorded inputs unchanged.
652
652
  */
653
653
  adaptInputs?: (inputs: unknown[], ctx: AdaptContext) => unknown[];
654
+ /**
655
+ * Called once per item as it finishes, in completion order (not input
656
+ * order), with running totals for the whole run. Use it to render replay
657
+ * progress, for example a terminal progress bar. Replay does not know
658
+ * pass/fail at this point (verdicts are assigned later), so the totals only
659
+ * distinguish items whose function ran (`succeeded`) from items that threw
660
+ * (`errored`).
661
+ *
662
+ * Invoked synchronously right after each item settles, so keep it cheap. A
663
+ * throwing callback never crashes the run: the error is swallowed so progress
664
+ * UI can't break replay.
665
+ */
666
+ onProgress?: (progress: ReplayProgress) => void;
667
+ }
668
+ /** Running totals reported to {@link ReplayOptions.onProgress} as replay proceeds. */
669
+ interface ReplayProgress {
670
+ /** Items that have finished so far, whether they succeeded or errored. */
671
+ completed: number;
672
+ /** Total number of items in this replay run. */
673
+ total: number;
674
+ /** Of the completed items, how many ran the function without throwing. */
675
+ succeeded: number;
676
+ /** Of the completed items, how many threw (their `item.error` is set). */
677
+ errored: number;
654
678
  }
655
679
  /** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
656
680
  interface AdaptContext {
@@ -1380,7 +1404,7 @@ declare class BitfabFunction {
1380
1404
  /**
1381
1405
  * SDK version from package.json (injected at build time)
1382
1406
  */
1383
- declare const __version__ = "0.24.1";
1407
+ declare const __version__ = "0.25.0";
1384
1408
 
1385
1409
  /**
1386
1410
  * Constants for the Bitfab SDK.
@@ -1448,4 +1472,4 @@ declare const finalizers: {
1448
1472
  readableStream: typeof readableStream;
1449
1473
  };
1450
1474
 
1451
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, 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 VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace };
1475
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, 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 ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace };
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  flushTraces,
24
24
  getCurrentSpan,
25
25
  getCurrentTrace
26
- } from "./chunk-J4D6PRM4.js";
26
+ } from "./chunk-GQLNEYSU.js";
27
27
  import {
28
28
  BitfabError
29
29
  } from "./chunk-26MUT4IP.js";
package/dist/node.cjs CHANGED
@@ -429,13 +429,15 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
429
429
  dbSnapshotRef: serverItem.dbSnapshotRef ?? null
430
430
  };
431
431
  }
432
- async function mapWithConcurrency(tasks, maxConcurrency) {
432
+ async function mapWithConcurrency(tasks, maxConcurrency, onSettled) {
433
433
  const results = new Array(tasks.length);
434
434
  let nextIndex = 0;
435
435
  async function worker() {
436
436
  while (nextIndex < tasks.length) {
437
437
  const index = nextIndex++;
438
- results[index] = await tasks[index]();
438
+ const result = await tasks[index]();
439
+ results[index] = result;
440
+ onSettled?.(result, index);
439
441
  }
440
442
  }
441
443
  const workers = Array.from(
@@ -495,7 +497,26 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
495
497
  options?.adaptInputs
496
498
  )
497
499
  );
498
- const resultItems = await mapWithConcurrency(tasks, maxConcurrency);
500
+ const total = tasks.length;
501
+ let completed = 0;
502
+ let succeeded = 0;
503
+ let errored = 0;
504
+ const resultItems = await mapWithConcurrency(
505
+ tasks,
506
+ maxConcurrency,
507
+ options?.onProgress ? (item) => {
508
+ completed += 1;
509
+ if (item.error === null) {
510
+ succeeded += 1;
511
+ } else {
512
+ errored += 1;
513
+ }
514
+ try {
515
+ options?.onProgress?.({ completed, total, succeeded, errored });
516
+ } catch {
517
+ }
518
+ } : void 0
519
+ );
499
520
  const completeResult = await httpClient.completeReplay(testRunId);
500
521
  const serverTraceIds = completeResult.traceIds;
501
522
  const replayTokens = completeResult.tokens;
@@ -589,7 +610,7 @@ registerAsyncLocalStorageClass(
589
610
  );
590
611
 
591
612
  // src/version.generated.ts
592
- var __version__ = "0.24.1";
613
+ var __version__ = "0.25.0";
593
614
 
594
615
  // src/constants.ts
595
616
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";