@bitfab/sdk 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
@@ -14,7 +14,7 @@ import {
14
14
  flushTraces,
15
15
  getCurrentSpan,
16
16
  getCurrentTrace
17
- } from "./chunk-S3PN26RH.js";
17
+ } from "./chunk-J4D6PRM4.js";
18
18
  import {
19
19
  BitfabError
20
20
  } from "./chunk-26MUT4IP.js";
package/dist/node.cjs CHANGED
@@ -412,7 +412,10 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
412
412
  originalOutput,
413
413
  error,
414
414
  durationMs: serverItem.durationMs ?? null,
415
- tokens: serverItem.tokens ?? null,
415
+ // Filled in by replay() from the complete-replay response once the
416
+ // replay traces are persisted and their spans aggregated server-side.
417
+ // Null here (and on older servers) means "replay tokens not known".
418
+ tokens: null,
416
419
  model: serverItem.model ?? null,
417
420
  dbSnapshotRef: serverItem.dbSnapshotRef ?? null
418
421
  };
@@ -486,6 +489,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
486
489
  const resultItems = await mapWithConcurrency(tasks, maxConcurrency);
487
490
  const completeResult = await httpClient.completeReplay(testRunId);
488
491
  const serverTraceIds = completeResult.traceIds;
492
+ const replayTokens = completeResult.tokens;
489
493
  if (serverTraceIds === void 0) {
490
494
  try {
491
495
  console.warn(
@@ -508,6 +512,9 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
508
512
  missing.push(item.traceId);
509
513
  }
510
514
  }
515
+ if (mapped !== void 0) {
516
+ item.tokens = replayTokens?.[mapped] ?? null;
517
+ }
511
518
  item.traceId = mapped ?? null;
512
519
  }
513
520
  }
@@ -573,7 +580,7 @@ registerAsyncLocalStorageClass(
573
580
  );
574
581
 
575
582
  // src/version.generated.ts
576
- var __version__ = "0.24.0";
583
+ var __version__ = "0.24.1";
577
584
 
578
585
  // src/constants.ts
579
586
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";