bitfab 0.24.0 → 0.24.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.
package/dist/index.d.cts CHANGED
@@ -684,7 +684,13 @@ interface ReplayItem<T> {
684
684
  error: string | null;
685
685
  /** Original trace duration in milliseconds, or null if timestamps are missing. */
686
686
  durationMs: number | null;
687
- /** Token usage from the original trace, or null if not captured. */
687
+ /**
688
+ * Token usage from the REPLAYED run (this item's new execution), aggregated
689
+ * server-side from the spans it produced, or null if the run captured no
690
+ * token data. This is the "new" side of a token delta: compare it against
691
+ * the original trace's recorded usage to see how the code change moved cost.
692
+ * Matches what Studio's experiments view shows.
693
+ */
688
694
  tokens: TokenUsage | null;
689
695
  /** Model name from the original trace, or null if not captured. */
690
696
  model: string | null;
@@ -1374,7 +1380,7 @@ declare class BitfabFunction {
1374
1380
  /**
1375
1381
  * SDK version from package.json (injected at build time)
1376
1382
  */
1377
- declare const __version__ = "0.24.0";
1383
+ declare const __version__ = "0.24.1";
1378
1384
 
1379
1385
  /**
1380
1386
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -684,7 +684,13 @@ interface ReplayItem<T> {
684
684
  error: string | null;
685
685
  /** Original trace duration in milliseconds, or null if timestamps are missing. */
686
686
  durationMs: number | null;
687
- /** Token usage from the original trace, or null if not captured. */
687
+ /**
688
+ * Token usage from the REPLAYED run (this item's new execution), aggregated
689
+ * server-side from the spans it produced, or null if the run captured no
690
+ * token data. This is the "new" side of a token delta: compare it against
691
+ * the original trace's recorded usage to see how the code change moved cost.
692
+ * Matches what Studio's experiments view shows.
693
+ */
688
694
  tokens: TokenUsage | null;
689
695
  /** Model name from the original trace, or null if not captured. */
690
696
  model: string | null;
@@ -1374,7 +1380,7 @@ declare class BitfabFunction {
1374
1380
  /**
1375
1381
  * SDK version from package.json (injected at build time)
1376
1382
  */
1377
- declare const __version__ = "0.24.0";
1383
+ declare const __version__ = "0.24.1";
1378
1384
 
1379
1385
  /**
1380
1386
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  flushTraces,
24
24
  getCurrentSpan,
25
25
  getCurrentTrace
26
- } from "./chunk-S3PN26RH.js";
26
+ } from "./chunk-J4D6PRM4.js";
27
27
  import {
28
28
  BitfabError
29
29
  } from "./chunk-26MUT4IP.js";
package/dist/node.cjs CHANGED
@@ -421,7 +421,10 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
421
421
  originalOutput,
422
422
  error,
423
423
  durationMs: serverItem.durationMs ?? null,
424
- tokens: serverItem.tokens ?? null,
424
+ // Filled in by replay() from the complete-replay response once the
425
+ // replay traces are persisted and their spans aggregated server-side.
426
+ // Null here (and on older servers) means "replay tokens not known".
427
+ tokens: null,
425
428
  model: serverItem.model ?? null,
426
429
  dbSnapshotRef: serverItem.dbSnapshotRef ?? null
427
430
  };
@@ -495,6 +498,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
495
498
  const resultItems = await mapWithConcurrency(tasks, maxConcurrency);
496
499
  const completeResult = await httpClient.completeReplay(testRunId);
497
500
  const serverTraceIds = completeResult.traceIds;
501
+ const replayTokens = completeResult.tokens;
498
502
  if (serverTraceIds === void 0) {
499
503
  try {
500
504
  console.warn(
@@ -517,6 +521,9 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
517
521
  missing.push(item.traceId);
518
522
  }
519
523
  }
524
+ if (mapped !== void 0) {
525
+ item.tokens = replayTokens?.[mapped] ?? null;
526
+ }
520
527
  item.traceId = mapped ?? null;
521
528
  }
522
529
  }
@@ -582,7 +589,7 @@ registerAsyncLocalStorageClass(
582
589
  );
583
590
 
584
591
  // src/version.generated.ts
585
- var __version__ = "0.24.0";
592
+ var __version__ = "0.24.1";
586
593
 
587
594
  // src/constants.ts
588
595
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";