bitfab 0.36.5 → 0.36.6

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
@@ -1213,31 +1213,56 @@ interface ReplayOptions {
1213
1213
  * distinguish items whose function ran (`succeeded`) from items that threw
1214
1214
  * (`errored`).
1215
1215
  *
1216
- * Invoked synchronously right after each item settles, so keep it cheap. A
1216
+ * Invoked synchronously right after each item finishes, so keep it cheap. A
1217
1217
  * throwing callback never crashes the run: the error is swallowed so progress
1218
1218
  * UI can't break replay.
1219
1219
  */
1220
- onProgress?: (progress: ReplayProgress) => void;
1221
- }
1222
- /** Running totals reported to {@link ReplayOptions.onProgress} as replay proceeds. */
1223
- interface ReplayProgress {
1220
+ onItemFinish?: (progress: ReplayItemFinishProgress) => void;
1224
1221
  /**
1225
- * Event kind. Omitted (or `"item"`) for the per-trace settle events streamed
1226
- * during the run. `"complete"` marks the single terminal event emitted once
1227
- * the run has settled and been enriched server-side; it carries the full
1228
- * {@link ReplayProgress.result} and has no `item`. The Bitfab plugin reads
1229
- * that terminal event to build the run's final result without parsing stdout.
1222
+ * @deprecated Use {@link onItemFinish}. This compatibility callback receives
1223
+ * the same per-item finish events plus the legacy whole-run `"complete"`
1224
+ * event. It is ignored when `onItemFinish` is also provided.
1230
1225
  */
1231
- type?: "item" | "complete";
1226
+ onProgress?: (progress: ReplayProgress) => void;
1232
1227
  /**
1233
- * The full {@link ReplayResult}, present only on the terminal `"complete"`
1234
- * event. Lets the plugin ingest the enriched result (server-aggregated tokens,
1235
- * server trace ids) over the same channel as progress, so a dependency logging
1236
- * to stdout can never block it.
1228
+ * Called once when each replay item begins processing, before input loading,
1229
+ * mock preparation, database branching, or the customer function runs. Use
1230
+ * it with {@link onItemFinish} to distinguish queued items from items that
1231
+ * are still in flight. A throwing callback never crashes the run.
1237
1232
  */
1238
- result?: ReplayResult<unknown>;
1233
+ onItemStart?: (progress: ReplayItemStartProgress) => void;
1234
+ }
1235
+ /** Emitted through {@link ReplayOptions.onItemStart} when a worker starts an item. */
1236
+ interface ReplayItemStartProgress {
1237
+ type: "started";
1239
1238
  /** Test run ID created for this replay. */
1240
- testRunId?: string;
1239
+ testRunId: string;
1240
+ /** Items whose processing has started so far. */
1241
+ started: number;
1242
+ /** Items that have finished so far, whether they succeeded or errored. */
1243
+ completed: number;
1244
+ /** Total number of items in this replay run. */
1245
+ total: number;
1246
+ /** Of the completed items, how many finished without a code or replay error. */
1247
+ succeeded: number;
1248
+ /** Of the completed items, how many finished with an error. */
1249
+ errored: number;
1250
+ /** The historical trace and span whose replay processing just started. */
1251
+ item: {
1252
+ originalTraceId: string;
1253
+ originalSpanId: string;
1254
+ /** @deprecated alias for `originalTraceId`. */
1255
+ sourceTraceId: string;
1256
+ /** @deprecated alias for `originalSpanId`. */
1257
+ sourceSpanId: string;
1258
+ };
1259
+ }
1260
+ /** Running totals reported to {@link ReplayOptions.onItemFinish} as replay proceeds. */
1261
+ interface ReplayItemFinishProgress {
1262
+ /** Event kind, omitted for backward-compatible per-item events. */
1263
+ type?: "item";
1264
+ /** Test run ID created for this replay. */
1265
+ testRunId: string;
1241
1266
  /** Items that have finished so far, whether they succeeded or errored. */
1242
1267
  completed: number;
1243
1268
  /** Total number of items in this replay run. */
@@ -1247,7 +1272,7 @@ interface ReplayProgress {
1247
1272
  /** Of the completed items, how many have `item.error` set. */
1248
1273
  errored: number;
1249
1274
  /**
1250
- * The single item that just settled to produce this event. `traceId` is null
1275
+ * The single item that just finished to produce this event. `traceId` is null
1251
1276
  * at this stage (the server replay id isn't known until the run completes);
1252
1277
  * `originalTraceId` is the original (historical) trace that was replayed (so
1253
1278
  * a UI can identify or link it); `error` is its replay error, or null when it
@@ -1255,7 +1280,7 @@ interface ReplayProgress {
1255
1280
  * progress UI show per-trace pass/fail and timing as the run streams, without
1256
1281
  * waiting for the full {@link ReplayResult}.
1257
1282
  */
1258
- item?: {
1283
+ item: {
1259
1284
  /** Trace ID of the new replay trace (null during the run; the server id arrives at completion). */
1260
1285
  traceId?: string | null;
1261
1286
  /** Bitfab trace ID of the original (historical) trace being replayed. */
@@ -1284,30 +1309,49 @@ interface ReplayProgress {
1284
1309
  dbSnapshotRef?: DbSnapshotRef | null;
1285
1310
  };
1286
1311
  }
1312
+ /**
1313
+ * @deprecated Use {@link ReplayItemFinishProgress}. This legacy shape also
1314
+ * represents the item-less terminal `"complete"` event emitted by
1315
+ * {@link ReplayOptions.onProgress}.
1316
+ */
1317
+ interface ReplayProgress {
1318
+ type?: "item" | "complete";
1319
+ result?: ReplayResult<unknown>;
1320
+ testRunId?: string;
1321
+ completed: number;
1322
+ total: number;
1323
+ succeeded: number;
1324
+ errored: number;
1325
+ item?: ReplayItemFinishProgress["item"];
1326
+ }
1287
1327
  /**
1288
1328
  * Wire prefix the Bitfab plugin scans for. Each line {@link reportReplayProgress}
1289
1329
  * writes is this prefix followed by the JSON of the running totals (plus the
1290
- * settled `item`). The plugin polls these lines to report live progress while a
1330
+ * finished `item`). The plugin polls these lines to report live progress while a
1291
1331
  * replay runs in the background; keep the SDK emitter and the plugin parser in
1292
1332
  * sync.
1293
1333
  */
1294
1334
  declare const BITFAB_PROGRESS_PREFIX = "@@bitfab:progress ";
1295
1335
  /**
1296
- * A ready-made {@link ReplayOptions.onProgress} callback for replay scripts.
1336
+ * A ready-made replay lifecycle callback for replay scripts.
1297
1337
  * Pass it straight in:
1298
1338
  *
1299
1339
  * ```ts
1300
- * await bitfab.replay("my-fn", fn, { limit, onProgress: reportReplayProgress })
1340
+ * await bitfab.replay("my-fn", fn, {
1341
+ * limit,
1342
+ * onItemStart: reportReplayProgress,
1343
+ * onItemFinish: reportReplayProgress,
1344
+ * })
1301
1345
  * ```
1302
1346
  *
1303
- * It writes one `@@bitfab:progress` line per trace to stderr, which the Bitfab
1304
- * plugin polls to report live progress while the replay runs in the background,
1347
+ * It writes `@@bitfab:progress` lines to stderr, which the Bitfab plugin polls
1348
+ * to report in-flight and finished items while replay runs in the background,
1305
1349
  * so scripts never hand-format the wire protocol.
1306
1350
  * stdout is left untouched for direct-run ReplayResult JSON. Outside Node (no
1307
1351
  * `process.stderr`, e.g. a browser) it is a no-op, and a write failure is
1308
1352
  * swallowed so progress can never crash a run.
1309
1353
  */
1310
- declare function reportReplayProgress(progress: ReplayProgress): void;
1354
+ declare function reportReplayProgress(progress: ReplayItemFinishProgress | ReplayItemStartProgress | ReplayProgress): void;
1311
1355
  /** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
1312
1356
  interface AdaptContext {
1313
1357
  /** Bitfab trace ID of the original (historical) trace being replayed. */
@@ -2464,7 +2508,7 @@ declare class BitfabFunction {
2464
2508
  /**
2465
2509
  * SDK version from package.json (injected at build time)
2466
2510
  */
2467
- declare const __version__ = "0.36.5";
2511
+ declare const __version__ = "0.36.6";
2468
2512
 
2469
2513
  /**
2470
2514
  * Constants for the Bitfab SDK.
@@ -2532,4 +2576,4 @@ declare const finalizers: {
2532
2576
  readableStream: typeof readableStream;
2533
2577
  };
2534
2578
 
2535
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
2579
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
package/dist/index.d.ts CHANGED
@@ -1213,31 +1213,56 @@ interface ReplayOptions {
1213
1213
  * distinguish items whose function ran (`succeeded`) from items that threw
1214
1214
  * (`errored`).
1215
1215
  *
1216
- * Invoked synchronously right after each item settles, so keep it cheap. A
1216
+ * Invoked synchronously right after each item finishes, so keep it cheap. A
1217
1217
  * throwing callback never crashes the run: the error is swallowed so progress
1218
1218
  * UI can't break replay.
1219
1219
  */
1220
- onProgress?: (progress: ReplayProgress) => void;
1221
- }
1222
- /** Running totals reported to {@link ReplayOptions.onProgress} as replay proceeds. */
1223
- interface ReplayProgress {
1220
+ onItemFinish?: (progress: ReplayItemFinishProgress) => void;
1224
1221
  /**
1225
- * Event kind. Omitted (or `"item"`) for the per-trace settle events streamed
1226
- * during the run. `"complete"` marks the single terminal event emitted once
1227
- * the run has settled and been enriched server-side; it carries the full
1228
- * {@link ReplayProgress.result} and has no `item`. The Bitfab plugin reads
1229
- * that terminal event to build the run's final result without parsing stdout.
1222
+ * @deprecated Use {@link onItemFinish}. This compatibility callback receives
1223
+ * the same per-item finish events plus the legacy whole-run `"complete"`
1224
+ * event. It is ignored when `onItemFinish` is also provided.
1230
1225
  */
1231
- type?: "item" | "complete";
1226
+ onProgress?: (progress: ReplayProgress) => void;
1232
1227
  /**
1233
- * The full {@link ReplayResult}, present only on the terminal `"complete"`
1234
- * event. Lets the plugin ingest the enriched result (server-aggregated tokens,
1235
- * server trace ids) over the same channel as progress, so a dependency logging
1236
- * to stdout can never block it.
1228
+ * Called once when each replay item begins processing, before input loading,
1229
+ * mock preparation, database branching, or the customer function runs. Use
1230
+ * it with {@link onItemFinish} to distinguish queued items from items that
1231
+ * are still in flight. A throwing callback never crashes the run.
1237
1232
  */
1238
- result?: ReplayResult<unknown>;
1233
+ onItemStart?: (progress: ReplayItemStartProgress) => void;
1234
+ }
1235
+ /** Emitted through {@link ReplayOptions.onItemStart} when a worker starts an item. */
1236
+ interface ReplayItemStartProgress {
1237
+ type: "started";
1239
1238
  /** Test run ID created for this replay. */
1240
- testRunId?: string;
1239
+ testRunId: string;
1240
+ /** Items whose processing has started so far. */
1241
+ started: number;
1242
+ /** Items that have finished so far, whether they succeeded or errored. */
1243
+ completed: number;
1244
+ /** Total number of items in this replay run. */
1245
+ total: number;
1246
+ /** Of the completed items, how many finished without a code or replay error. */
1247
+ succeeded: number;
1248
+ /** Of the completed items, how many finished with an error. */
1249
+ errored: number;
1250
+ /** The historical trace and span whose replay processing just started. */
1251
+ item: {
1252
+ originalTraceId: string;
1253
+ originalSpanId: string;
1254
+ /** @deprecated alias for `originalTraceId`. */
1255
+ sourceTraceId: string;
1256
+ /** @deprecated alias for `originalSpanId`. */
1257
+ sourceSpanId: string;
1258
+ };
1259
+ }
1260
+ /** Running totals reported to {@link ReplayOptions.onItemFinish} as replay proceeds. */
1261
+ interface ReplayItemFinishProgress {
1262
+ /** Event kind, omitted for backward-compatible per-item events. */
1263
+ type?: "item";
1264
+ /** Test run ID created for this replay. */
1265
+ testRunId: string;
1241
1266
  /** Items that have finished so far, whether they succeeded or errored. */
1242
1267
  completed: number;
1243
1268
  /** Total number of items in this replay run. */
@@ -1247,7 +1272,7 @@ interface ReplayProgress {
1247
1272
  /** Of the completed items, how many have `item.error` set. */
1248
1273
  errored: number;
1249
1274
  /**
1250
- * The single item that just settled to produce this event. `traceId` is null
1275
+ * The single item that just finished to produce this event. `traceId` is null
1251
1276
  * at this stage (the server replay id isn't known until the run completes);
1252
1277
  * `originalTraceId` is the original (historical) trace that was replayed (so
1253
1278
  * a UI can identify or link it); `error` is its replay error, or null when it
@@ -1255,7 +1280,7 @@ interface ReplayProgress {
1255
1280
  * progress UI show per-trace pass/fail and timing as the run streams, without
1256
1281
  * waiting for the full {@link ReplayResult}.
1257
1282
  */
1258
- item?: {
1283
+ item: {
1259
1284
  /** Trace ID of the new replay trace (null during the run; the server id arrives at completion). */
1260
1285
  traceId?: string | null;
1261
1286
  /** Bitfab trace ID of the original (historical) trace being replayed. */
@@ -1284,30 +1309,49 @@ interface ReplayProgress {
1284
1309
  dbSnapshotRef?: DbSnapshotRef | null;
1285
1310
  };
1286
1311
  }
1312
+ /**
1313
+ * @deprecated Use {@link ReplayItemFinishProgress}. This legacy shape also
1314
+ * represents the item-less terminal `"complete"` event emitted by
1315
+ * {@link ReplayOptions.onProgress}.
1316
+ */
1317
+ interface ReplayProgress {
1318
+ type?: "item" | "complete";
1319
+ result?: ReplayResult<unknown>;
1320
+ testRunId?: string;
1321
+ completed: number;
1322
+ total: number;
1323
+ succeeded: number;
1324
+ errored: number;
1325
+ item?: ReplayItemFinishProgress["item"];
1326
+ }
1287
1327
  /**
1288
1328
  * Wire prefix the Bitfab plugin scans for. Each line {@link reportReplayProgress}
1289
1329
  * writes is this prefix followed by the JSON of the running totals (plus the
1290
- * settled `item`). The plugin polls these lines to report live progress while a
1330
+ * finished `item`). The plugin polls these lines to report live progress while a
1291
1331
  * replay runs in the background; keep the SDK emitter and the plugin parser in
1292
1332
  * sync.
1293
1333
  */
1294
1334
  declare const BITFAB_PROGRESS_PREFIX = "@@bitfab:progress ";
1295
1335
  /**
1296
- * A ready-made {@link ReplayOptions.onProgress} callback for replay scripts.
1336
+ * A ready-made replay lifecycle callback for replay scripts.
1297
1337
  * Pass it straight in:
1298
1338
  *
1299
1339
  * ```ts
1300
- * await bitfab.replay("my-fn", fn, { limit, onProgress: reportReplayProgress })
1340
+ * await bitfab.replay("my-fn", fn, {
1341
+ * limit,
1342
+ * onItemStart: reportReplayProgress,
1343
+ * onItemFinish: reportReplayProgress,
1344
+ * })
1301
1345
  * ```
1302
1346
  *
1303
- * It writes one `@@bitfab:progress` line per trace to stderr, which the Bitfab
1304
- * plugin polls to report live progress while the replay runs in the background,
1347
+ * It writes `@@bitfab:progress` lines to stderr, which the Bitfab plugin polls
1348
+ * to report in-flight and finished items while replay runs in the background,
1305
1349
  * so scripts never hand-format the wire protocol.
1306
1350
  * stdout is left untouched for direct-run ReplayResult JSON. Outside Node (no
1307
1351
  * `process.stderr`, e.g. a browser) it is a no-op, and a write failure is
1308
1352
  * swallowed so progress can never crash a run.
1309
1353
  */
1310
- declare function reportReplayProgress(progress: ReplayProgress): void;
1354
+ declare function reportReplayProgress(progress: ReplayItemFinishProgress | ReplayItemStartProgress | ReplayProgress): void;
1311
1355
  /** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
1312
1356
  interface AdaptContext {
1313
1357
  /** Bitfab trace ID of the original (historical) trace being replayed. */
@@ -2464,7 +2508,7 @@ declare class BitfabFunction {
2464
2508
  /**
2465
2509
  * SDK version from package.json (injected at build time)
2466
2510
  */
2467
- declare const __version__ = "0.36.5";
2511
+ declare const __version__ = "0.36.6";
2468
2512
 
2469
2513
  /**
2470
2514
  * Constants for the Bitfab SDK.
@@ -2532,4 +2576,4 @@ declare const finalizers: {
2532
2576
  readableStream: typeof readableStream;
2533
2577
  };
2534
2578
 
2535
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
2579
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  getCurrentReplayBranch,
21
21
  getCurrentSpan,
22
22
  getCurrentTrace
23
- } from "./chunk-IYHBVIPJ.js";
23
+ } from "./chunk-BXWUPEC4.js";
24
24
  import {
25
25
  BITFAB_PROGRESS_PREFIX,
26
26
  BitfabError,
@@ -32,7 +32,7 @@ import {
32
32
  flushTraces,
33
33
  reportReplayProgress,
34
34
  serializeReplayResult
35
- } from "./chunk-FLP6CNRE.js";
35
+ } from "./chunk-ENOQ2K2H.js";
36
36
  export {
37
37
  BITFAB_PROGRESS_PREFIX,
38
38
  Bitfab,
package/dist/node.cjs CHANGED
@@ -97,7 +97,7 @@ var __version__;
97
97
  var init_version_generated = __esm({
98
98
  "src/version.generated.ts"() {
99
99
  "use strict";
100
- __version__ = "0.36.5";
100
+ __version__ = "0.36.6";
101
101
  }
102
102
  });
103
103
 
@@ -2400,12 +2400,13 @@ function sleep(ms) {
2400
2400
  unrefTimer(timer);
2401
2401
  });
2402
2402
  }
2403
- async function mapWithConcurrency2(tasks, maxConcurrency, onSettled) {
2403
+ async function mapWithConcurrency2(tasks, maxConcurrency, onSettled, onStarted) {
2404
2404
  const results = new Array(tasks.length);
2405
2405
  let nextIndex = 0;
2406
2406
  async function worker() {
2407
2407
  while (nextIndex < tasks.length) {
2408
2408
  const index = nextIndex++;
2409
+ onStarted?.(index);
2409
2410
  const result = await tasks[index]();
2410
2411
  results[index] = result;
2411
2412
  onSettled?.(result, index);
@@ -2492,13 +2493,15 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2492
2493
  )
2493
2494
  );
2494
2495
  const total = tasks.length;
2496
+ const onItemFinish = options?.onItemFinish ?? options?.onProgress;
2495
2497
  let completed = 0;
2498
+ let started = 0;
2496
2499
  let succeeded = 0;
2497
2500
  let errored = 0;
2498
2501
  const resultItems = await mapWithConcurrency2(
2499
2502
  tasks,
2500
2503
  maxConcurrency,
2501
- options?.onProgress ? (item) => {
2504
+ (item) => {
2502
2505
  completed += 1;
2503
2506
  if (item.error === null) {
2504
2507
  succeeded += 1;
@@ -2506,18 +2509,17 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2506
2509
  errored += 1;
2507
2510
  }
2508
2511
  try {
2509
- options?.onProgress?.({
2512
+ onItemFinish?.({
2510
2513
  testRunId,
2511
2514
  completed,
2512
2515
  total,
2513
2516
  succeeded,
2514
2517
  errored,
2515
2518
  item: {
2516
- // The server replay trace id isn't known until completeReplay
2517
- // runs (below), so it can't be reported mid-run and we never
2518
- // emit the client-side placeholder. originalTraceId (the
2519
- // historical trace) is known now and is what a UI keys on to
2520
- // identify what just settled.
2519
+ // The server replay trace id isn't known until completeReplay runs
2520
+ // (below), so it can't be reported mid-run and we never emit the
2521
+ // client-side placeholder. originalTraceId (the historical trace)
2522
+ // is known now and is what a UI keys on to identify what settled.
2521
2523
  traceId: null,
2522
2524
  originalTraceId: item.originalTraceId ?? null,
2523
2525
  originalSpanId: item.originalSpanId ?? null,
@@ -2538,6 +2540,30 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2538
2540
  });
2539
2541
  } catch {
2540
2542
  }
2543
+ },
2544
+ options?.onItemStart ? (index) => {
2545
+ started += 1;
2546
+ const serverItem = serverItems[index];
2547
+ const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
2548
+ const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
2549
+ try {
2550
+ options.onItemStart?.({
2551
+ type: "started",
2552
+ testRunId,
2553
+ started,
2554
+ completed,
2555
+ total,
2556
+ succeeded,
2557
+ errored,
2558
+ item: {
2559
+ originalTraceId,
2560
+ originalSpanId,
2561
+ sourceTraceId: originalTraceId,
2562
+ sourceSpanId: originalSpanId
2563
+ }
2564
+ });
2565
+ } catch {
2566
+ }
2541
2567
  } : void 0
2542
2568
  );
2543
2569
  await preserveReplayFailure(
@@ -2600,17 +2626,19 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2600
2626
  testRunUrl: fullTestRunUrl
2601
2627
  };
2602
2628
  await writeReplayResultFile(result);
2603
- try {
2604
- options?.onProgress?.({
2605
- type: "complete",
2606
- testRunId,
2607
- completed: total,
2608
- total,
2609
- succeeded,
2610
- errored,
2611
- result
2612
- });
2613
- } catch {
2629
+ if (!options?.onItemFinish) {
2630
+ try {
2631
+ options?.onProgress?.({
2632
+ type: "complete",
2633
+ testRunId,
2634
+ completed: total,
2635
+ total,
2636
+ succeeded,
2637
+ errored,
2638
+ result
2639
+ });
2640
+ } catch {
2641
+ }
2614
2642
  }
2615
2643
  return result;
2616
2644
  }