@bitfab/sdk 0.41.0 → 0.43.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.
@@ -14,14 +14,14 @@ import {
14
14
  serializeValue,
15
15
  toJsonSafe,
16
16
  toJsonSafeReport
17
- } from "./chunk-RWZYZRYI.js";
17
+ } from "./chunk-BXBRVWWW.js";
18
18
  import {
19
19
  BitfabError,
20
20
  DEFAULT_SERVICE_URL,
21
21
  HttpClient,
22
22
  getReplayContext,
23
23
  warnOnce
24
- } from "./chunk-IFYX3KW6.js";
24
+ } from "./chunk-6EM2S5H5.js";
25
25
  import {
26
26
  __privateAdd,
27
27
  __privateGet,
@@ -1902,7 +1902,8 @@ var BitfabLangGraphIntegration = class {
1902
1902
  type: "function",
1903
1903
  captureWhen: "nested",
1904
1904
  mockOnReplay: shouldMock,
1905
- finalize: finalizeToolResult
1905
+ finalize: finalizeToolResult,
1906
+ surface: "inherit"
1906
1907
  },
1907
1908
  async (_args) => await originalInvoke(input, ...rest)
1908
1909
  );
@@ -1945,7 +1946,7 @@ var BitfabLangGraphIntegration = class {
1945
1946
  wrapInvoke(fn) {
1946
1947
  return this.client.withSpan(
1947
1948
  this.traceFunctionKey,
1948
- { name: this.traceFunctionKey, type: "agent" },
1949
+ { name: this.traceFunctionKey, type: "agent", surface: "inherit" },
1949
1950
  fn
1950
1951
  );
1951
1952
  }
@@ -1995,7 +1996,11 @@ var BitfabOpenAIAgentHandler = class {
1995
1996
  }
1996
1997
  return res?.finalOutput;
1997
1998
  };
1998
- const options_ = { type: "agent", finalize };
1999
+ const options_ = {
2000
+ type: "agent",
2001
+ finalize,
2002
+ surface: "inherit"
2003
+ };
1999
2004
  const traced = this.withSpanFn(
2000
2005
  this.traceFunctionKey,
2001
2006
  options_,
@@ -2054,6 +2059,35 @@ var ReplayBranch = class {
2054
2059
  _url = new WeakMap();
2055
2060
  _context = new WeakMap();
2056
2061
 
2062
+ // src/seedContext.ts
2063
+ var seedContextStorage = null;
2064
+ var SEED_CONTEXT_STORAGE_SYMBOL = /* @__PURE__ */ Symbol.for("bitfab.seedContextStorage");
2065
+ var seedContextReady = asyncStorageReady.then(() => {
2066
+ const shared = globalThis;
2067
+ const existing = shared[SEED_CONTEXT_STORAGE_SYMBOL];
2068
+ if (existing) {
2069
+ seedContextStorage = existing;
2070
+ return;
2071
+ }
2072
+ const created = createAsyncLocalStorage();
2073
+ if (created) {
2074
+ shared[SEED_CONTEXT_STORAGE_SYMBOL] = created;
2075
+ seedContextStorage = created;
2076
+ }
2077
+ });
2078
+ function getSeedContext() {
2079
+ return seedContextStorage?.getStore() ?? null;
2080
+ }
2081
+ function inSeedScope() {
2082
+ return getSeedContext() !== null;
2083
+ }
2084
+ function runWithSeedContext(ctx, fn) {
2085
+ if (seedContextStorage) {
2086
+ return seedContextStorage.run(ctx, fn);
2087
+ }
2088
+ return fn();
2089
+ }
2090
+
2057
2091
  // src/tracing.ts
2058
2092
  var BitfabOpenAITracingProcessor = class {
2059
2093
  /**
@@ -2384,7 +2418,8 @@ var BitfabVercelAiHandler = class {
2384
2418
  key,
2385
2419
  {
2386
2420
  type: "llm",
2387
- finalize: (result) => summarizeGenerate(result ?? {}, label)
2421
+ finalize: (result) => summarizeGenerate(result ?? {}, label),
2422
+ surface: "inherit"
2388
2423
  },
2389
2424
  () => doGenerate()
2390
2425
  );
@@ -2402,7 +2437,7 @@ var BitfabVercelAiHandler = class {
2402
2437
  // The wrapped fn returns immediately with the live stream, so the span
2403
2438
  // output cannot be read from the return value. `finalize` instead
2404
2439
  // awaits the summary the accumulator resolves once the stream drains.
2405
- { type: "llm", finalize: () => summary },
2440
+ { type: "llm", finalize: () => summary, surface: "inherit" },
2406
2441
  async () => {
2407
2442
  const result = await doStream();
2408
2443
  const stream = result.stream.pipeThrough(
@@ -2418,6 +2453,18 @@ var BitfabVercelAiHandler = class {
2418
2453
  };
2419
2454
 
2420
2455
  // src/client.ts
2456
+ var MIXED_SURFACE_REMEDY = {
2457
+ "opt-in": "Inside a withTrace/trace subtree, configure a discovered call with node()/withNode() instead, or trace this workflow with withSpan() only.",
2458
+ "opt-out": "Wrap the caller with withTrace()/trace() as well, or wrap this function with withSpan()."
2459
+ };
2460
+ function warnMixedTracingSurfaces(traceFunctionKey, entered, enclosing) {
2461
+ const enteredApi = entered === "opt-in" ? "withSpan()" : "withTrace()";
2462
+ const enclosingApi = enclosing === "opt-in" ? "withSpan()" : "withTrace()";
2463
+ warnOnce(
2464
+ `mixed-tracing-surface:${traceFunctionKey}:${entered}`,
2465
+ `opt-in and opt-out tracing are mixed in one call stack: ${enteredApi} (${entered}) for "${traceFunctionKey}" was entered inside a ${enclosingApi} call (${enclosing}). Both are recorded, and the spans nest as written. ${MIXED_SURFACE_REMEDY[entered]}`
2466
+ );
2467
+ }
2421
2468
  var activeTraceStates = /* @__PURE__ */ new Map();
2422
2469
  var asyncLocalStorage = null;
2423
2470
  var SPAN_CONTEXT_STORAGE_SYMBOL = /* @__PURE__ */ Symbol.for("bitfab.spanContextStorage");
@@ -2781,7 +2828,13 @@ var Bitfab = class {
2781
2828
  this.serviceUrl = config.serviceUrl ?? DEFAULT_SERVICE_URL;
2782
2829
  this.timeout = config.timeout ?? 12e4;
2783
2830
  this.envVars = config.envVars ?? {};
2784
- this.explicitlyEnabled = config.enabled ?? true;
2831
+ if (config.enabled !== void 0) {
2832
+ warnOnce(
2833
+ "deprecated-enabled-option",
2834
+ "Bitfab({ enabled }) is deprecated; pass captureEnabled instead."
2835
+ );
2836
+ }
2837
+ this.captureConfigured = (config.captureEnabled ?? true) && (config.enabled ?? true);
2785
2838
  this.strict = config.strict ?? false;
2786
2839
  this.bamlClient = config.bamlClient ?? null;
2787
2840
  if (config.dbSnapshot) {
@@ -2817,9 +2870,6 @@ var Bitfab = class {
2817
2870
  if (!descriptor || typeof descriptor.value !== "function") {
2818
2871
  throw new BitfabError("@bitfab.trace can only decorate methods");
2819
2872
  }
2820
- if (!this.explicitlyEnabled) {
2821
- return;
2822
- }
2823
2873
  descriptor.value = this.createAutoTraceRoot(
2824
2874
  traceFunctionKey,
2825
2875
  String(propertyKey),
@@ -2833,9 +2883,6 @@ var Bitfab = class {
2833
2883
  if (typeof method !== "function" || context?.kind !== "method" || context.name === void 0) {
2834
2884
  throw new BitfabError("@bitfab.trace can only decorate methods");
2835
2885
  }
2836
- if (!this.explicitlyEnabled) {
2837
- return method;
2838
- }
2839
2886
  return this.createAutoTraceRoot(
2840
2887
  traceFunctionKey,
2841
2888
  String(context.name),
@@ -2851,9 +2898,6 @@ var Bitfab = class {
2851
2898
  if (!fn) {
2852
2899
  throw new BitfabError("bitfab.withTrace requires a function");
2853
2900
  }
2854
- if (!this.explicitlyEnabled) {
2855
- return fn;
2856
- }
2857
2901
  const name = fn.name !== "" ? fn.name : traceFunctionKey;
2858
2902
  return this.createAutoTraceRoot(traceFunctionKey, name, options, fn);
2859
2903
  }
@@ -2877,9 +2921,6 @@ var Bitfab = class {
2877
2921
  if (!descriptor || typeof descriptor.value !== "function") {
2878
2922
  throw new BitfabError("@bitfab.node can only decorate methods");
2879
2923
  }
2880
- if (!this.explicitlyEnabled) {
2881
- return;
2882
- }
2883
2924
  descriptor.value = this.createAutoTraceNode(
2884
2925
  configuration,
2885
2926
  descriptor.value,
@@ -2892,9 +2933,6 @@ var Bitfab = class {
2892
2933
  if (typeof method !== "function" || context?.kind !== "method") {
2893
2934
  throw new BitfabError("@bitfab.node can only decorate methods");
2894
2935
  }
2895
- if (!this.explicitlyEnabled) {
2896
- return method;
2897
- }
2898
2936
  return this.createAutoTraceNode(
2899
2937
  configuration,
2900
2938
  method,
@@ -2910,9 +2948,6 @@ var Bitfab = class {
2910
2948
  throw new BitfabError("bitfab.withNode requires a function");
2911
2949
  }
2912
2950
  const configuration = this.resolveNodeConfiguration(options);
2913
- if (!this.explicitlyEnabled) {
2914
- return fn;
2915
- }
2916
2951
  const functionName = internalFunctionName ?? fn.name;
2917
2952
  if (functionName === "") {
2918
2953
  throw new BitfabError(
@@ -2965,9 +3000,14 @@ var Bitfab = class {
2965
3000
  );
2966
3001
  const excluded = new Set(options.exclude ?? []);
2967
3002
  const includeWrappers = options.includeWrappers ?? false;
3003
+ const rootOptions = {
3004
+ name: options.name ?? name,
3005
+ type: options.type ?? "custom",
3006
+ surface: "opt-out"
3007
+ };
2968
3008
  const tracedRoot = this.withSpan(
2969
3009
  traceFunctionKey,
2970
- { name: options.name ?? name, type: options.type ?? "custom" },
3010
+ rootOptions,
2971
3011
  function(...args) {
2972
3012
  const capturePolicy = getAutoTraceCapturePolicy(self, traceFunctionKey);
2973
3013
  self.refreshAutoTraceCapturePolicy(traceFunctionKey);
@@ -3011,6 +3051,7 @@ var Bitfab = class {
3011
3051
  name: nodeConfiguration?.name ?? definition.name,
3012
3052
  type: nodeConfiguration?.type ?? "function",
3013
3053
  captureWhen: "nested",
3054
+ surface: "opt-out",
3014
3055
  functionId: definition.id,
3015
3056
  captureContent: nodeConfiguration !== void 0 || capturePolicy === void 0 || capturePolicy.has(definition.id),
3016
3057
  autoTraceDefinition: definition,
@@ -3048,7 +3089,7 @@ var Bitfab = class {
3048
3089
  }
3049
3090
  );
3050
3091
  const autoTraceRoot = function(...args) {
3051
- if (!self.isTracingEnabled()) {
3092
+ if (!self.shouldRecord()) {
3052
3093
  return fn.apply(this, args);
3053
3094
  }
3054
3095
  return tracedRoot.apply(this, args);
@@ -3056,6 +3097,7 @@ var Bitfab = class {
3056
3097
  Object.defineProperty(autoTraceRoot, "_bitfabTraceFunctionKey", {
3057
3098
  value: traceFunctionKey
3058
3099
  });
3100
+ Object.defineProperty(autoTraceRoot, "_bitfabWrappedFn", { value: fn });
3059
3101
  return autoTraceRoot;
3060
3102
  }
3061
3103
  refreshAutoTraceCapturePolicy(traceFunctionKey) {
@@ -3139,7 +3181,7 @@ var Bitfab = class {
3139
3181
  "Bitfab: no API key resolved. Set BITFAB_API_KEY or pass apiKey to new Bitfab(). If a script loads env with dotenv, load it before the module that constructs the client is imported (e.g. `node --env-file=.env script.ts`), or pass `apiKey: () => process.env.BITFAB_API_KEY`."
3140
3182
  );
3141
3183
  }
3142
- if (this.explicitlyEnabled && !this.apiKeyWarned) {
3184
+ if (this.captureConfigured && !this.apiKeyWarned) {
3143
3185
  this.apiKeyWarned = true;
3144
3186
  console.warn(
3145
3187
  "Bitfab: apiKey is empty - tracing is disabled. Provide a valid API key to enable tracing."
@@ -3147,17 +3189,21 @@ var Bitfab = class {
3147
3189
  }
3148
3190
  return void 0;
3149
3191
  }
3150
- /**
3151
- * Whether tracing should run, decided lazily at call time (not frozen at
3152
- * construction). An explicit `enabled: false` short-circuits without ever
3153
- * touching the key.
3154
- */
3155
- isTracingEnabled() {
3156
- if (!this.explicitlyEnabled) {
3192
+ isCaptureEnabled() {
3193
+ if (!this.captureConfigured) {
3194
+ return false;
3195
+ }
3196
+ return this.resolveApiKey() !== void 0;
3197
+ }
3198
+ shouldRecord() {
3199
+ if (!this.captureConfigured && !getReplayContext() && !inSeedScope()) {
3157
3200
  return false;
3158
3201
  }
3159
3202
  return this.resolveApiKey() !== void 0;
3160
3203
  }
3204
+ get captureEnabled() {
3205
+ return this.isCaptureEnabled();
3206
+ }
3161
3207
  /**
3162
3208
  * Fetch the function with its current version and BAML prompt from the server.
3163
3209
  *
@@ -3569,9 +3615,6 @@ var Bitfab = class {
3569
3615
  * @returns A wrapped function with the same signature that creates spans for inputs and outputs
3570
3616
  */
3571
3617
  withSpan(traceFunctionKey, optionsOrFn, maybeFn) {
3572
- if (!this.explicitlyEnabled) {
3573
- return typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
3574
- }
3575
3618
  const options = typeof optionsOrFn === "function" ? {} : optionsOrFn;
3576
3619
  const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
3577
3620
  const self = this;
@@ -3585,7 +3628,7 @@ var Bitfab = class {
3585
3628
  }
3586
3629
  })();
3587
3630
  const wrappedFn = function(...args) {
3588
- if (!self.isTracingEnabled()) {
3631
+ if (!self.shouldRecord()) {
3589
3632
  return fn.apply(this, args);
3590
3633
  }
3591
3634
  initializeAsyncContext();
@@ -3633,11 +3676,26 @@ var Bitfab = class {
3633
3676
  const currentStack = getSpanStack();
3634
3677
  const parentContext = currentStack[currentStack.length - 1];
3635
3678
  const replayCtxForTraceId = parentContext ? null : getReplayContext();
3636
- const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? randomUuid();
3679
+ const seedCtxForTraceId = parentContext ? null : getSeedContext();
3680
+ const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? seedCtxForTraceId?.traceId ?? randomUuid();
3637
3681
  const spanId = randomUuid();
3638
3682
  const parentSpanId = parentContext?.spanId ?? null;
3639
3683
  const isRootSpan = parentSpanId === null;
3640
- const newContext = { traceId, spanId, contexts: [] };
3684
+ const requestedSurface = options.surface ?? "opt-in";
3685
+ const surface = requestedSurface === "inherit" ? parentContext?.surface ?? "opt-in" : requestedSurface;
3686
+ if (requestedSurface !== "inherit" && parentContext?.surface !== void 0 && parentContext.surface !== surface) {
3687
+ warnMixedTracingSurfaces(
3688
+ traceFunctionKey,
3689
+ surface,
3690
+ parentContext.surface
3691
+ );
3692
+ }
3693
+ const newContext = {
3694
+ traceId,
3695
+ spanId,
3696
+ contexts: [],
3697
+ surface
3698
+ };
3641
3699
  newStack = [...currentStack, newContext];
3642
3700
  const inputs = args;
3643
3701
  const startedAt = nowIsoTimestamp();
@@ -3653,6 +3711,9 @@ var Bitfab = class {
3653
3711
  ...replayCtxAtStart?.inputSourceTraceId && {
3654
3712
  inputSourceTraceId: replayCtxAtStart.inputSourceTraceId
3655
3713
  },
3714
+ ...replayCtxAtStart?.replayAttempt !== void 0 && {
3715
+ replayAttempt: replayCtxAtStart.replayAttempt
3716
+ },
3656
3717
  dbSnapshotRef
3657
3718
  });
3658
3719
  registeredTraceId = traceId;
@@ -3703,6 +3764,7 @@ var Bitfab = class {
3703
3764
  contexts: traceState?.contexts ?? [],
3704
3765
  testRunId: traceState?.testRunId,
3705
3766
  inputSourceTraceId: traceState?.inputSourceTraceId,
3767
+ replayAttempt: traceState?.replayAttempt,
3706
3768
  dbSnapshotRef: traceState?.dbSnapshotRef,
3707
3769
  dropped: traceState?.dropped,
3708
3770
  ingestionType: traceState?.ingestionType,
@@ -3915,7 +3977,7 @@ var Bitfab = class {
3915
3977
  if (registeredTraceId) {
3916
3978
  activeTraceStates.delete(registeredTraceId);
3917
3979
  }
3918
- if (getReplayContext()) {
3980
+ if (getReplayContext() || inSeedScope()) {
3919
3981
  throw setupError;
3920
3982
  }
3921
3983
  warnOnce(
@@ -3990,7 +4052,7 @@ var Bitfab = class {
3990
4052
  return {
3991
4053
  traceId,
3992
4054
  addContext: (context) => {
3993
- if (!this.isTracingEnabled()) {
4055
+ if (!this.shouldRecord()) {
3994
4056
  return Promise.resolve();
3995
4057
  }
3996
4058
  if (typeof context !== "object" || context === null) {
@@ -4001,7 +4063,7 @@ var Bitfab = class {
4001
4063
  });
4002
4064
  },
4003
4065
  setMetadata: (metadata) => {
4004
- if (!this.isTracingEnabled()) {
4066
+ if (!this.shouldRecord()) {
4005
4067
  return Promise.resolve();
4006
4068
  }
4007
4069
  if (typeof metadata !== "object" || metadata === null) {
@@ -4010,7 +4072,7 @@ var Bitfab = class {
4010
4072
  return this.httpClient.patchTrace(traceId, { mergeMetadata: metadata });
4011
4073
  },
4012
4074
  setSessionId: (sessionId) => {
4013
- if (!this.isTracingEnabled()) {
4075
+ if (!this.shouldRecord()) {
4014
4076
  return Promise.resolve();
4015
4077
  }
4016
4078
  if (typeof sessionId !== "string" || sessionId.length === 0) {
@@ -4019,7 +4081,7 @@ var Bitfab = class {
4019
4081
  return this.httpClient.patchTrace(traceId, { setSessionId: sessionId });
4020
4082
  },
4021
4083
  setName: (name) => {
4022
- if (!this.isTracingEnabled()) {
4084
+ if (!this.shouldRecord()) {
4023
4085
  return Promise.resolve();
4024
4086
  }
4025
4087
  if (typeof name !== "string" || name.length === 0) {
@@ -4100,6 +4162,9 @@ var Bitfab = class {
4100
4162
  if (params.inputSourceTraceId) {
4101
4163
  rawTrace.input_source_trace_id = params.inputSourceTraceId;
4102
4164
  }
4165
+ if (params.replayAttempt !== void 0) {
4166
+ rawTrace.replay_attempt = params.replayAttempt;
4167
+ }
4103
4168
  if (params.dbSnapshotRef) {
4104
4169
  rawTrace.db_snapshot_ref = params.dbSnapshotRef;
4105
4170
  }
@@ -4252,22 +4317,13 @@ var Bitfab = class {
4252
4317
  clearMockOverrides() {
4253
4318
  this.mockOverrides.length = 0;
4254
4319
  }
4255
- /**
4256
- * Write a replayable trace from a case, without running anything.
4257
- *
4258
- * Use this to turn a corpus you already hold (a Braintrust dataset, a
4259
- * spreadsheet, hand-written cases) into traces that {@link replay} can
4260
- * select. The recorded root span carries `input` as its input and `expected`
4261
- * as its output, so replay reports each item against the value you expected
4262
- * rather than against a previous run.
4263
- *
4264
- * A seeded trace has no child spans and no database pin, so replay mocking
4265
- * has nothing recorded to substitute and `dbBranch` refuses it. Pass
4266
- * `mockOverride` at replay time for calls that must not run.
4267
- *
4268
- * @returns The trace ID, usable with `replay({ traceIds: [...] })`.
4269
- */
4270
- seedTrace(traceFunctionKey, options) {
4320
+ seedTrace(traceFunctionKey, optionsOrFn, runOptions) {
4321
+ if (typeof optionsOrFn === "function") {
4322
+ return this.seedTraceByRunning(traceFunctionKey, optionsOrFn, runOptions);
4323
+ }
4324
+ return this.seedTraceFromCase(traceFunctionKey, optionsOrFn);
4325
+ }
4326
+ seedTraceFromCase(traceFunctionKey, options) {
4271
4327
  const { input } = options;
4272
4328
  const fn = options.fn?._bitfabWrappedFn ?? options.fn;
4273
4329
  if (fn && input.length < fn.length) {
@@ -4316,6 +4372,50 @@ var Bitfab = class {
4316
4372
  }
4317
4373
  return traceId;
4318
4374
  }
4375
+ async seedTraceByRunning(traceFunctionKey, fn, options) {
4376
+ const wrappedKey = fn._bitfabTraceFunctionKey;
4377
+ let target = fn;
4378
+ if (wrappedKey === void 0) {
4379
+ target = this.withSpan(
4380
+ traceFunctionKey,
4381
+ { name: traceFunctionKey, type: "agent" },
4382
+ fn
4383
+ );
4384
+ } else if (wrappedKey !== traceFunctionKey) {
4385
+ throw new BitfabError(
4386
+ `Function is wrapped with trace function key '${wrappedKey}' but seedTrace was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to seed it under the explicit key.`
4387
+ );
4388
+ }
4389
+ await seedContextReady;
4390
+ const traceId = randomUuid();
4391
+ activeTraceStates.set(traceId, {
4392
+ traceId,
4393
+ startedAt: nowIsoTimestamp(),
4394
+ contexts: [],
4395
+ ingestionType: "seeded",
4396
+ ...options?.sessionId !== void 0 && { sessionId: options.sessionId },
4397
+ ...options?.name !== void 0 && { name: options.name },
4398
+ ...options?.metadata !== void 0 && { metadata: options.metadata }
4399
+ });
4400
+ const args = options?.args ?? [];
4401
+ let unrecorded = true;
4402
+ try {
4403
+ await runWithSeedContext({ traceId }, async () => target(...args));
4404
+ } finally {
4405
+ try {
4406
+ const { flushTraces: flushTraces2 } = await import("./http-IO3Y7ROJ.js");
4407
+ await flushTraces2(3e4);
4408
+ } finally {
4409
+ unrecorded = activeTraceStates.delete(traceId);
4410
+ }
4411
+ }
4412
+ if (unrecorded) {
4413
+ throw new BitfabError(
4414
+ `seedTrace recorded nothing for '${traceFunctionKey}': the call finished without a root span. Check that an API key resolves (BITFAB_API_KEY or apiKey), and that fn is a regular or async function rather than a generator.`
4415
+ );
4416
+ }
4417
+ return traceId;
4418
+ }
4319
4419
  async replay(traceFunctionKey, fn, options) {
4320
4420
  const wrappedKey = fn._bitfabTraceFunctionKey;
4321
4421
  let replayFn = fn;
@@ -4330,7 +4430,7 @@ var Bitfab = class {
4330
4430
  `Function is wrapped with trace function key '${wrappedKey}' but replay was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to replay it under the explicit key.`
4331
4431
  );
4332
4432
  }
4333
- const { replay: doReplay } = await import("./replay-HMMWDSLB.js");
4433
+ const { replay: doReplay } = await import("./replay-LM4GIDVD.js");
4334
4434
  return doReplay(
4335
4435
  this.httpClient,
4336
4436
  this.serviceUrl,
@@ -4566,7 +4666,7 @@ var finalizers = {
4566
4666
  function defineReplayRegistry(registry) {
4567
4667
  return registry;
4568
4668
  }
4569
- async function seedFromRegistry(registry, pipeline, cases) {
4669
+ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
4570
4670
  const registration = registry[pipeline];
4571
4671
  if (registration === void 0) {
4572
4672
  throw new BitfabError(
@@ -4574,6 +4674,19 @@ async function seedFromRegistry(registry, pipeline, cases) {
4574
4674
  );
4575
4675
  }
4576
4676
  const traceFunctionKey = resolveTraceFunctionKey(registration);
4677
+ if (options.run === true) {
4678
+ const traceIds2 = [];
4679
+ for (const seedCase of cases) {
4680
+ traceIds2.push(
4681
+ await registration.client.seedTrace(traceFunctionKey, registration.fn, {
4682
+ args: seedCase.input,
4683
+ metadata: seedCase.metadata,
4684
+ sessionId: seedCase.sessionId
4685
+ })
4686
+ );
4687
+ }
4688
+ return { pipeline, traceFunctionKey, traceIds: traceIds2 };
4689
+ }
4577
4690
  const traceIds = cases.map(
4578
4691
  (seedCase) => registration.client.seedTrace(traceFunctionKey, {
4579
4692
  input: seedCase.input,
@@ -4583,7 +4696,7 @@ async function seedFromRegistry(registry, pipeline, cases) {
4583
4696
  sessionId: seedCase.sessionId
4584
4697
  })
4585
4698
  );
4586
- const { flushTraces: flushTraces2 } = await import("./http-UCJCOKW7.js");
4699
+ const { flushTraces: flushTraces2 } = await import("./http-IO3Y7ROJ.js");
4587
4700
  await flushTraces2(3e4);
4588
4701
  return { pipeline, traceFunctionKey, traceIds };
4589
4702
  }
@@ -4616,4 +4729,4 @@ export {
4616
4729
  defineReplayRegistry,
4617
4730
  seedFromRegistry
4618
4731
  };
4619
- //# sourceMappingURL=chunk-U3AKIFW3.js.map
4732
+ //# sourceMappingURL=chunk-5BBJ5BQD.js.map