@bitfab/sdk 0.36.12 → 0.38.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.
@@ -314,7 +314,7 @@ function encodeRequestBody(body) {
314
314
  }
315
315
 
316
316
  // src/version.generated.ts
317
- var __version__ = "0.36.12";
317
+ var __version__ = "0.38.0";
318
318
 
319
319
  // src/constants.ts
320
320
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -2385,12 +2385,15 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2385
2385
  let lease = includeDbBranchLease ? serverItem.dbBranchLease : void 0;
2386
2386
  let leaseError = includeDbBranchLease ? serverItem.dbBranchLeaseError : void 0;
2387
2387
  let dbSnapshotRef = serverItem.dbSnapshotRef;
2388
+ let dbBranchTimings = includeDbBranchLease ? serverItem.dbBranchTimings : void 0;
2388
2389
  let inputs = [];
2389
2390
  let originalOutput;
2390
2391
  let result;
2391
2392
  let error = null;
2392
2393
  let traceError = null;
2393
2394
  let replayError = null;
2395
+ let replayDurationMs = null;
2396
+ let replayStarted = null;
2394
2397
  const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
2395
2398
  const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
2396
2399
  try {
@@ -2413,6 +2416,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2413
2416
  lease = resolved.lease ?? void 0;
2414
2417
  leaseError = resolved.leaseError ?? void 0;
2415
2418
  dbSnapshotRef = resolved.dbSnapshotRef ?? dbSnapshotRef;
2419
+ dbBranchTimings = resolved.timings ?? dbBranchTimings;
2416
2420
  }
2417
2421
  if (leaseError) {
2418
2422
  throw new DbBranchReplayError(
@@ -2446,20 +2450,17 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2446
2450
  includeOutputs,
2447
2451
  includeRootOutput: false
2448
2452
  });
2449
- if (treeResponse.root) {
2450
- mockTree = buildMockTree(treeResponse.root);
2451
- } else if (mockStrategy === "all" || hasOverrides) {
2453
+ if (!treeResponse.root) {
2452
2454
  throw new BitfabError(
2453
2455
  `Replay mock strategy "${mockStrategy}"${hasOverrides ? " with overrides" : ""} requires a span tree root for original span ${originalSpanId}.`
2454
2456
  );
2455
- } else {
2456
- mockTree = void 0;
2457
2457
  }
2458
- } catch (e) {
2459
- if (mockStrategy === "all" || hasOverrides) {
2460
- throw e;
2458
+ mockTree = buildMockTree(treeResponse.root);
2459
+ } catch (error2) {
2460
+ if (mockStrategy !== "marked" || hasOverrides) {
2461
+ throw error2;
2461
2462
  }
2462
- mockTree = void 0;
2463
+ mockTree = { spans: /* @__PURE__ */ new Map() };
2463
2464
  }
2464
2465
  }
2465
2466
  const outputCache = /* @__PURE__ */ new Map();
@@ -2476,6 +2477,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2476
2477
  return pending;
2477
2478
  } : void 0;
2478
2479
  try {
2480
+ replayStarted = performance.now();
2479
2481
  const maybePromise = runWithReplayContext(
2480
2482
  {
2481
2483
  testRunId,
@@ -2488,16 +2490,24 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2488
2490
  mockStrategy,
2489
2491
  mockOverrides: hasOverrides ? resolvedOverrides : void 0,
2490
2492
  fetchSpanOutput,
2491
- dbBranchLease: lease
2493
+ dbBranchLease: lease,
2494
+ dbBranchTimings
2492
2495
  },
2493
2496
  () => fn(...inputs)
2494
2497
  );
2495
2498
  result = maybePromise instanceof Promise ? await maybePromise : maybePromise;
2499
+ replayDurationMs = Math.round(performance.now() - replayStarted);
2496
2500
  } catch (e) {
2501
+ if (replayStarted !== null) {
2502
+ replayDurationMs = Math.round(performance.now() - replayStarted);
2503
+ }
2497
2504
  traceError = e;
2498
2505
  error = errorMessage(e);
2499
2506
  }
2500
2507
  } catch (e) {
2508
+ if (replayStarted !== null) {
2509
+ replayDurationMs = Math.round(performance.now() - replayStarted);
2510
+ }
2501
2511
  replayError = e;
2502
2512
  error = replayItemErrorMessage(e);
2503
2513
  } finally {
@@ -2514,6 +2524,8 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2514
2524
  }
2515
2525
  }
2516
2526
  }
2527
+ const originalDurationMs = serverItem.originalDurationMs ?? serverItem.durationMs ?? null;
2528
+ const originalModel = serverItem.originalModel ?? serverItem.model ?? null;
2517
2529
  return {
2518
2530
  // Written in by replay() from the complete-replay response once the server
2519
2531
  // has minted this replay trace's row. Null until then: the client-side
@@ -2530,13 +2542,17 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2530
2542
  error,
2531
2543
  traceError,
2532
2544
  replayError,
2533
- durationMs: serverItem.durationMs ?? null,
2545
+ durationMs: replayDurationMs,
2546
+ originalDurationMs,
2547
+ originalTokens: serverItem.originalTokens ?? serverItem.tokens ?? null,
2548
+ originalModel,
2534
2549
  // Filled in by replay() from the complete-replay response once the
2535
2550
  // replay traces are persisted and their spans aggregated server-side.
2536
2551
  // Null here (and on older servers) means "replay tokens not known".
2537
2552
  tokens: null,
2538
- model: serverItem.model ?? null,
2539
- dbSnapshotRef: dbSnapshotRef ?? null
2553
+ model: originalModel,
2554
+ dbSnapshotRef: dbSnapshotRef ?? null,
2555
+ dbBranchTimings: dbBranchTimings ?? null
2540
2556
  };
2541
2557
  }
2542
2558
  async function waitForReplayPersistence(httpClient, testRunId, replayedTraceIds) {
@@ -2763,9 +2779,13 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2763
2779
  traceError: item.traceError,
2764
2780
  replayError: item.replayError,
2765
2781
  durationMs: item.durationMs,
2782
+ originalDurationMs: item.originalDurationMs,
2783
+ originalTokens: item.originalTokens,
2784
+ originalModel: item.originalModel,
2766
2785
  tokens: item.tokens,
2767
2786
  model: item.model,
2768
- dbSnapshotRef: item.dbSnapshotRef
2787
+ dbSnapshotRef: item.dbSnapshotRef,
2788
+ dbBranchTimings: item.dbBranchTimings
2769
2789
  }
2770
2790
  });
2771
2791
  } catch {
@@ -2933,4 +2953,4 @@ export {
2933
2953
  sleepForReplayPersistence,
2934
2954
  replay
2935
2955
  };
2936
- //# sourceMappingURL=chunk-VUYTATF5.js.map
2956
+ //# sourceMappingURL=chunk-SSNTMROV.js.map