bitfab 0.43.0 → 0.44.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.
package/dist/index.d.cts CHANGED
@@ -98,6 +98,9 @@ declare class BitfabError extends Error {
98
98
  */
99
99
  retryAfterMs?: number | undefined);
100
100
  }
101
+ declare class MixedTracingError extends Error {
102
+ constructor(message: string);
103
+ }
101
104
 
102
105
  /**
103
106
  * Selective mock overrides for replay.
@@ -1434,12 +1437,6 @@ declare class BitfabOpenAIAgentHandler {
1434
1437
  */
1435
1438
 
1436
1439
  type MockStrategy = "none" | "all" | "marked";
1437
- /**
1438
- * How a source trace came to exist. A `seeded` trace was written from a case
1439
- * with {@link Bitfab.seedTrace} rather than executed, so it has no recorded
1440
- * child spans to mock from and no database state to restore, and its recorded
1441
- * output is the value the case expected rather than a previous run's result.
1442
- */
1443
1440
  type TraceIngestionType = "captured" | "seeded";
1444
1441
  /**
1445
1442
  * How the DB-snapshot branch each replay item runs against is sized and warmed.
@@ -1787,11 +1784,6 @@ interface ReplayItem<T> {
1787
1784
  input: unknown[];
1788
1785
  /** The result returned by the function during replay, or undefined on error. */
1789
1786
  result: T | undefined;
1790
- /**
1791
- * The original output from the historical trace. For a `seeded` source this
1792
- * is the value the case expected, not a previous run's result, so a
1793
- * difference means the code missed the expectation rather than drifted.
1794
- */
1795
1787
  originalOutput: unknown;
1796
1788
  /**
1797
1789
  * How the source trace came to exist. Absent on servers that predate the
@@ -2107,6 +2099,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
2107
2099
  }
2108
2100
 
2109
2101
  type CaptureSurface = "opt-in" | "opt-out";
2102
+
2110
2103
  /**
2111
2104
  * Options for wrapBAML.
2112
2105
  */
@@ -3089,7 +3082,7 @@ declare class BitfabFunction {
3089
3082
  /**
3090
3083
  * SDK version from package.json (injected at build time)
3091
3084
  */
3092
- declare const __version__ = "0.43.0";
3085
+ declare const __version__ = "0.44.0";
3093
3086
 
3094
3087
  /**
3095
3088
  * Constants for the Bitfab SDK.
@@ -3219,4 +3212,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
3219
3212
  run?: boolean;
3220
3213
  }): Promise<SeedResult>;
3221
3214
 
3222
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, HttpClient, type LangGraphIntegrationOptions, type ListDatasetsParams, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceIngestionType, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
3215
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, HttpClient, type LangGraphIntegrationOptions, type ListDatasetsParams, MixedTracingError, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceIngestionType, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
package/dist/index.d.ts CHANGED
@@ -98,6 +98,9 @@ declare class BitfabError extends Error {
98
98
  */
99
99
  retryAfterMs?: number | undefined);
100
100
  }
101
+ declare class MixedTracingError extends Error {
102
+ constructor(message: string);
103
+ }
101
104
 
102
105
  /**
103
106
  * Selective mock overrides for replay.
@@ -1434,12 +1437,6 @@ declare class BitfabOpenAIAgentHandler {
1434
1437
  */
1435
1438
 
1436
1439
  type MockStrategy = "none" | "all" | "marked";
1437
- /**
1438
- * How a source trace came to exist. A `seeded` trace was written from a case
1439
- * with {@link Bitfab.seedTrace} rather than executed, so it has no recorded
1440
- * child spans to mock from and no database state to restore, and its recorded
1441
- * output is the value the case expected rather than a previous run's result.
1442
- */
1443
1440
  type TraceIngestionType = "captured" | "seeded";
1444
1441
  /**
1445
1442
  * How the DB-snapshot branch each replay item runs against is sized and warmed.
@@ -1787,11 +1784,6 @@ interface ReplayItem<T> {
1787
1784
  input: unknown[];
1788
1785
  /** The result returned by the function during replay, or undefined on error. */
1789
1786
  result: T | undefined;
1790
- /**
1791
- * The original output from the historical trace. For a `seeded` source this
1792
- * is the value the case expected, not a previous run's result, so a
1793
- * difference means the code missed the expectation rather than drifted.
1794
- */
1795
1787
  originalOutput: unknown;
1796
1788
  /**
1797
1789
  * How the source trace came to exist. Absent on servers that predate the
@@ -2107,6 +2099,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
2107
2099
  }
2108
2100
 
2109
2101
  type CaptureSurface = "opt-in" | "opt-out";
2102
+
2110
2103
  /**
2111
2104
  * Options for wrapBAML.
2112
2105
  */
@@ -3089,7 +3082,7 @@ declare class BitfabFunction {
3089
3082
  /**
3090
3083
  * SDK version from package.json (injected at build time)
3091
3084
  */
3092
- declare const __version__ = "0.43.0";
3085
+ declare const __version__ = "0.44.0";
3093
3086
 
3094
3087
  /**
3095
3088
  * Constants for the Bitfab SDK.
@@ -3219,4 +3212,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
3219
3212
  run?: boolean;
3220
3213
  }): Promise<SeedResult>;
3221
3214
 
3222
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, HttpClient, type LangGraphIntegrationOptions, type ListDatasetsParams, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceIngestionType, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
3215
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, HttpClient, type LangGraphIntegrationOptions, type ListDatasetsParams, MixedTracingError, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceIngestionType, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  getCurrentSpan,
25
25
  getCurrentTrace,
26
26
  seedFromRegistry
27
- } from "./chunk-EI356U5Y.js";
27
+ } from "./chunk-WKGQM7HI.js";
28
28
  import "./chunk-ZUD7OFYB.js";
29
29
  import {
30
30
  BITFAB_PROGRESS_PREFIX,
@@ -33,14 +33,15 @@ import {
33
33
  ReplayError,
34
34
  reportReplayProgress,
35
35
  serializeReplayResult
36
- } from "./chunk-PLJOOK4G.js";
36
+ } from "./chunk-J25AP452.js";
37
37
  import {
38
38
  BitfabError,
39
39
  DEFAULT_SERVICE_URL,
40
40
  HttpClient,
41
+ MixedTracingError,
41
42
  __version__,
42
43
  flushTraces
43
- } from "./chunk-DCQR5MF4.js";
44
+ } from "./chunk-DCF7NJK7.js";
44
45
  import "./chunk-H6LZRFMN.js";
45
46
  export {
46
47
  BITFAB_PROGRESS_PREFIX,
@@ -58,6 +59,7 @@ export {
58
59
  DatasetsClient,
59
60
  DbBranchReplayError,
60
61
  HttpClient,
62
+ MixedTracingError,
61
63
  NO_MOCK_OVERRIDE,
62
64
  ReplayError,
63
65
  SUPPORTED_PROVIDERS,
package/dist/node.cjs CHANGED
@@ -97,7 +97,7 @@ var __version__, __packageName__;
97
97
  var init_version_generated = __esm({
98
98
  "src/version.generated.ts"() {
99
99
  "use strict";
100
- __version__ = "0.43.0";
100
+ __version__ = "0.44.0";
101
101
  __packageName__ = "bitfab";
102
102
  }
103
103
  });
@@ -219,7 +219,7 @@ var init_compress = __esm({
219
219
  });
220
220
 
221
221
  // src/errors.ts
222
- var BitfabError;
222
+ var BitfabError, MixedTracingError;
223
223
  var init_errors = __esm({
224
224
  "src/errors.ts"() {
225
225
  "use strict";
@@ -232,6 +232,12 @@ var init_errors = __esm({
232
232
  this.name = "BitfabError";
233
233
  }
234
234
  };
235
+ MixedTracingError = class extends Error {
236
+ constructor(message) {
237
+ super(message);
238
+ this.name = "MixedTracingError";
239
+ }
240
+ };
235
241
  }
236
242
  });
237
243
 
@@ -3271,6 +3277,7 @@ __export(node_exports, {
3271
3277
  DatasetsClient: () => DatasetsClient,
3272
3278
  DbBranchReplayError: () => DbBranchReplayError,
3273
3279
  HttpClient: () => HttpClient,
3280
+ MixedTracingError: () => MixedTracingError,
3274
3281
  NO_MOCK_OVERRIDE: () => NO_MOCK_OVERRIDE,
3275
3282
  ReplayError: () => ReplayError,
3276
3283
  SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
@@ -4351,6 +4358,50 @@ async function runFunctionWithBaml(bamlSource, inputs, providers, envVars) {
4351
4358
  };
4352
4359
  }
4353
4360
 
4361
+ // src/captureSurface.ts
4362
+ init_errors();
4363
+ var DEFAULT_SURFACE = "opt-in";
4364
+ var SURFACE_API = {
4365
+ "opt-in": "withSpan()",
4366
+ "opt-out": "withTrace()"
4367
+ };
4368
+ var MIXED_SURFACE_REMEDY = {
4369
+ "opt-in": "Inside a withTrace/trace subtree, configure a discovered call with node()/withNode() instead, or trace this workflow with withSpan() only.",
4370
+ "opt-out": "Wrap the caller with withTrace()/trace() as well, or wrap this function with withSpan()."
4371
+ };
4372
+ function resolveSurface(requested, parentSurface) {
4373
+ if (requested === "neutral") {
4374
+ return void 0;
4375
+ }
4376
+ if (requested === "inherit") {
4377
+ return parentSurface ?? DEFAULT_SURFACE;
4378
+ }
4379
+ return requested;
4380
+ }
4381
+ function mixedTracingError(enteredApi, entered, enclosing, traceFunctionKey) {
4382
+ const subject = traceFunctionKey === void 0 ? "" : ` for "${traceFunctionKey}"`;
4383
+ return new MixedTracingError(
4384
+ `opt-in and opt-out tracing can't be mixed in one call stack: ${enteredApi} (${entered})${subject} was entered inside a ${SURFACE_API[enclosing]} call (${enclosing}). ${MIXED_SURFACE_REMEDY[entered]}`
4385
+ );
4386
+ }
4387
+ function assertSurfacesCompatible(requested, resolved, parentSurface, traceFunctionKey) {
4388
+ if (requested === "inherit" || requested === "neutral") {
4389
+ return;
4390
+ }
4391
+ if (resolved === void 0 || parentSurface === void 0) {
4392
+ return;
4393
+ }
4394
+ if (parentSurface === resolved) {
4395
+ return;
4396
+ }
4397
+ throw mixedTracingError(
4398
+ SURFACE_API[resolved],
4399
+ resolved,
4400
+ parentSurface,
4401
+ traceFunctionKey
4402
+ );
4403
+ }
4404
+
4354
4405
  // src/client.ts
4355
4406
  init_constants();
4356
4407
 
@@ -4497,6 +4548,7 @@ function buildSnapshotRef(config, sdkWallClockBeforeFn) {
4497
4548
  }
4498
4549
 
4499
4550
  // src/client.ts
4551
+ init_errors();
4500
4552
  init_http();
4501
4553
 
4502
4554
  // src/langgraph.ts
@@ -5886,18 +5938,6 @@ var BitfabVercelAiHandler = class {
5886
5938
 
5887
5939
  // src/client.ts
5888
5940
  init_warnOnce();
5889
- var MIXED_SURFACE_REMEDY = {
5890
- "opt-in": "Inside a withTrace/trace subtree, configure a discovered call with node()/withNode() instead, or trace this workflow with withSpan() only.",
5891
- "opt-out": "Wrap the caller with withTrace()/trace() as well, or wrap this function with withSpan()."
5892
- };
5893
- function warnMixedTracingSurfaces(traceFunctionKey, entered, enclosing) {
5894
- const enteredApi = entered === "opt-in" ? "withSpan()" : "withTrace()";
5895
- const enclosingApi = enclosing === "opt-in" ? "withSpan()" : "withTrace()";
5896
- warnOnce(
5897
- `mixed-tracing-surface:${traceFunctionKey}:${entered}`,
5898
- `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]}`
5899
- );
5900
- }
5901
5941
  var activeTraceStates = /* @__PURE__ */ new Map();
5902
5942
  var asyncLocalStorage = null;
5903
5943
  var SPAN_CONTEXT_STORAGE_SYMBOL = /* @__PURE__ */ Symbol.for("bitfab.spanContextStorage");
@@ -5927,6 +5967,10 @@ function getSpanStack() {
5927
5967
  }
5928
5968
  return browserSpanStack;
5929
5969
  }
5970
+ function enclosingSurface() {
5971
+ const stack = getSpanStack();
5972
+ return stack[stack.length - 1]?.surface;
5973
+ }
5930
5974
  function runWithSpanStack(stack, fn) {
5931
5975
  if (asyncLocalStorage) {
5932
5976
  return asyncLocalStorage.run(stack, fn);
@@ -6413,6 +6457,9 @@ var Bitfab = class {
6413
6457
  const nodeConfiguration = { ...configuration, functionName };
6414
6458
  return function(...args) {
6415
6459
  if (!__bitfabAutoTraceActive()) {
6460
+ if (enclosingSurface() === "opt-in") {
6461
+ throw mixedTracingError("node()", "opt-out", "opt-in");
6462
+ }
6416
6463
  return fn.apply(this, args);
6417
6464
  }
6418
6465
  return runWithAutoTraceNodeConfiguration(
@@ -7114,20 +7161,19 @@ var Bitfab = class {
7114
7161
  const spanId = randomUuid();
7115
7162
  const parentSpanId = parentContext?.spanId ?? null;
7116
7163
  const isRootSpan = parentSpanId === null;
7117
- const requestedSurface = options.surface ?? "opt-in";
7118
- const surface = requestedSurface === "inherit" ? parentContext?.surface ?? "opt-in" : requestedSurface;
7119
- if (requestedSurface !== "inherit" && parentContext?.surface !== void 0 && parentContext.surface !== surface) {
7120
- warnMixedTracingSurfaces(
7121
- traceFunctionKey,
7122
- surface,
7123
- parentContext.surface
7124
- );
7125
- }
7164
+ const requestedSurface = options.surface ?? DEFAULT_SURFACE;
7165
+ const surface = resolveSurface(requestedSurface, parentContext?.surface);
7166
+ assertSurfacesCompatible(
7167
+ requestedSurface,
7168
+ surface,
7169
+ parentContext?.surface,
7170
+ traceFunctionKey
7171
+ );
7126
7172
  const newContext = {
7127
7173
  traceId,
7128
7174
  spanId,
7129
7175
  contexts: [],
7130
- surface
7176
+ ...surface !== void 0 && { surface }
7131
7177
  };
7132
7178
  newStack = [...currentStack, newContext];
7133
7179
  const inputs = args;
@@ -7410,6 +7456,9 @@ var Bitfab = class {
7410
7456
  if (registeredTraceId) {
7411
7457
  activeTraceStates.delete(registeredTraceId);
7412
7458
  }
7459
+ if (setupError instanceof MixedTracingError) {
7460
+ throw setupError;
7461
+ }
7413
7462
  if (getReplayContext() || inSeedScope()) {
7414
7463
  throw setupError;
7415
7464
  }
@@ -7809,9 +7858,14 @@ var Bitfab = class {
7809
7858
  const wrappedKey = fn._bitfabTraceFunctionKey;
7810
7859
  let target = fn;
7811
7860
  if (wrappedKey === void 0) {
7861
+ const seedRootOptions = {
7862
+ name: traceFunctionKey,
7863
+ type: "agent",
7864
+ surface: "neutral"
7865
+ };
7812
7866
  target = this.withSpan(
7813
7867
  traceFunctionKey,
7814
- { name: traceFunctionKey, type: "agent" },
7868
+ seedRootOptions,
7815
7869
  fn
7816
7870
  );
7817
7871
  } else if (wrappedKey !== traceFunctionKey) {
@@ -7853,11 +7907,12 @@ var Bitfab = class {
7853
7907
  const wrappedKey = fn._bitfabTraceFunctionKey;
7854
7908
  let replayFn = fn;
7855
7909
  if (wrappedKey === void 0) {
7856
- replayFn = this.withSpan(
7857
- traceFunctionKey,
7858
- { name: traceFunctionKey, type: "agent" },
7859
- fn
7860
- );
7910
+ const replayRootOptions = {
7911
+ name: traceFunctionKey,
7912
+ type: "agent",
7913
+ surface: "neutral"
7914
+ };
7915
+ replayFn = this.withSpan(traceFunctionKey, replayRootOptions, fn);
7861
7916
  } else if (wrappedKey !== traceFunctionKey) {
7862
7917
  throw new BitfabError(
7863
7918
  `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.`
@@ -8174,6 +8229,7 @@ assertAsyncStorageRegistered();
8174
8229
  DatasetsClient,
8175
8230
  DbBranchReplayError,
8176
8231
  HttpClient,
8232
+ MixedTracingError,
8177
8233
  NO_MOCK_OVERRIDE,
8178
8234
  ReplayError,
8179
8235
  SUPPORTED_PROVIDERS,