@bitfab/sdk 0.28.7 → 0.28.10

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.
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-5E4BUIYA.js";
14
14
 
15
15
  // src/version.generated.ts
16
- var __version__ = "0.28.7";
16
+ var __version__ = "0.28.10";
17
17
 
18
18
  // src/constants.ts
19
19
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -2436,8 +2436,11 @@ var BitfabVercelAiHandler = class {
2436
2436
  var activeTraceStates = /* @__PURE__ */ new Map();
2437
2437
  var pendingSpanPromises = /* @__PURE__ */ new Map();
2438
2438
  var asyncLocalStorage = null;
2439
+ var initializeAsyncContext = () => {
2440
+ asyncLocalStorage ?? (asyncLocalStorage = createAsyncLocalStorage());
2441
+ };
2439
2442
  var asyncLocalStorageReady = asyncStorageReady.then(() => {
2440
- asyncLocalStorage = createAsyncLocalStorage();
2443
+ initializeAsyncContext();
2441
2444
  });
2442
2445
  var browserSpanStack = [];
2443
2446
  function getSpanStack() {
@@ -3206,6 +3209,7 @@ var Bitfab = class {
3206
3209
  if (!self.isTracingEnabled()) {
3207
3210
  return fn.apply(this, args);
3208
3211
  }
3212
+ initializeAsyncContext();
3209
3213
  if (!asyncLocalStorage && !isAsyncStorageInitDone()) {
3210
3214
  return asyncLocalStorageReady.then(
3211
3215
  () => wrappedFn.apply(this, args)
@@ -3269,13 +3273,16 @@ var Bitfab = class {
3269
3273
  }
3270
3274
  try {
3271
3275
  const endedAt = (/* @__PURE__ */ new Date()).toISOString();
3272
- const spanPromise = self.sendWrapperSpan({
3276
+ const traceDropped = activeTraceStates.get(traceId)?.dropped === true;
3277
+ const spanPromise = traceDropped ? Promise.resolve() : self.sendWrapperSpan({
3273
3278
  ...baseSpanParams,
3274
3279
  ...params,
3275
3280
  contexts: newContext.contexts,
3276
3281
  prompt: newContext.prompt,
3277
3282
  endedAt,
3278
- ...replayCtx?.testRunId && { testRunId: replayCtx.testRunId },
3283
+ ...replayCtx?.testRunId && {
3284
+ testRunId: replayCtx.testRunId
3285
+ },
3279
3286
  ...replayCtx?.inputSourceSpanId && {
3280
3287
  inputSourceSpanId: replayCtx.inputSourceSpanId
3281
3288
  }
@@ -3363,7 +3370,7 @@ var Bitfab = class {
3363
3370
  meta: mockSpan.outputMeta
3364
3371
  });
3365
3372
  }
3366
- void sendSpan({ result: output });
3373
+ void sendSpan({ result: output, mocked: true });
3367
3374
  if (fnReturnsPromise) {
3368
3375
  return Promise.resolve(output);
3369
3376
  }
@@ -3615,7 +3622,8 @@ var Bitfab = class {
3615
3622
  sourceTraceId: params.traceId,
3616
3623
  traceFunctionKey: params.traceFunctionKey,
3617
3624
  rawSpan: externalSpan,
3618
- ...params.testRunId && { testRunId: params.testRunId }
3625
+ ...params.testRunId && { testRunId: params.testRunId },
3626
+ ...params.mocked && { mocked: true }
3619
3627
  });
3620
3628
  }
3621
3629
  /**
@@ -3877,4 +3885,4 @@ export {
3877
3885
  BitfabFunction,
3878
3886
  finalizers
3879
3887
  };
3880
- //# sourceMappingURL=chunk-TIMBGA3A.js.map
3888
+ //# sourceMappingURL=chunk-SK4TNXRC.js.map