bitfab 0.58.3 → 0.58.5

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.
Files changed (40) hide show
  1. package/dist/autoTrace.cjs +50 -4
  2. package/dist/autoTrace.cjs.map +1 -1
  3. package/dist/autoTrace.d.cts +2 -1
  4. package/dist/autoTrace.d.ts +2 -1
  5. package/dist/autoTrace.js +4 -2
  6. package/dist/{chunk-EIWNY3FF.js → chunk-7SPNHC33.js} +6 -21
  7. package/dist/chunk-7SPNHC33.js.map +1 -0
  8. package/dist/{chunk-VCRFFCLY.js → chunk-BAOIRE5T.js} +20 -2
  9. package/dist/chunk-BAOIRE5T.js.map +1 -0
  10. package/dist/{chunk-RCHSYWKI.js → chunk-ETZUSSF6.js} +38 -8
  11. package/dist/chunk-ETZUSSF6.js.map +1 -0
  12. package/dist/{chunk-HNUEEGIB.js → chunk-OTQA6MCF.js} +3 -3
  13. package/dist/{chunk-YWWDW5FX.js → chunk-QIBFNIIF.js} +2 -2
  14. package/dist/{chunk-YWWDW5FX.js.map → chunk-QIBFNIIF.js.map} +1 -1
  15. package/dist/{chunk-HJLWJ3L2.js → chunk-TAEWAXPA.js} +6 -6
  16. package/dist/{chunk-34VY4J27.js → chunk-UYAQRSCB.js} +43 -18
  17. package/dist/chunk-UYAQRSCB.js.map +1 -0
  18. package/dist/{http-XH36DD6T.js → http-F6QV3YLY.js} +3 -3
  19. package/dist/{http-Q75A3OKB.js → http-XDKEIZNV.js} +2 -2
  20. package/dist/index.cjs +58 -12
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +3 -1
  23. package/dist/index.d.ts +3 -1
  24. package/dist/index.js +5 -5
  25. package/dist/node.cjs +58 -12
  26. package/dist/node.cjs.map +1 -1
  27. package/dist/node.js +5 -5
  28. package/dist/{replay-QN6M3Q6H.js → replay-WLJFWS6T.js} +4 -4
  29. package/dist/replayCli.js +2 -2
  30. package/dist/seedCli.js +2 -2
  31. package/package.json +1 -1
  32. package/dist/chunk-34VY4J27.js.map +0 -1
  33. package/dist/chunk-EIWNY3FF.js.map +0 -1
  34. package/dist/chunk-RCHSYWKI.js.map +0 -1
  35. package/dist/chunk-VCRFFCLY.js.map +0 -1
  36. /package/dist/{chunk-HNUEEGIB.js.map → chunk-OTQA6MCF.js.map} +0 -0
  37. /package/dist/{chunk-HJLWJ3L2.js.map → chunk-TAEWAXPA.js.map} +0 -0
  38. /package/dist/{http-Q75A3OKB.js.map → http-F6QV3YLY.js.map} +0 -0
  39. /package/dist/{http-XH36DD6T.js.map → http-XDKEIZNV.js.map} +0 -0
  40. /package/dist/{replay-QN6M3Q6H.js.map → replay-WLJFWS6T.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -3372,6 +3372,8 @@ declare class Bitfab {
3372
3372
  * Queued on the client's span transport; delivery is the transport's job.
3373
3373
  */
3374
3374
  private sendTraceCompletion;
3375
+ private sendsSpanOnCompletion;
3376
+ private nearestCapturedAncestorSpanIdOf;
3375
3377
  private contentOffBySimulationPlan;
3376
3378
  /**
3377
3379
  * Send a wrapper span from function execution.
@@ -3657,7 +3659,7 @@ interface CommitRef {
3657
3659
  /**
3658
3660
  * SDK version from package.json (injected at build time)
3659
3661
  */
3660
- declare const __version__ = "0.58.3";
3662
+ declare const __version__ = "0.58.5";
3661
3663
 
3662
3664
  /**
3663
3665
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -3372,6 +3372,8 @@ declare class Bitfab {
3372
3372
  * Queued on the client's span transport; delivery is the transport's job.
3373
3373
  */
3374
3374
  private sendTraceCompletion;
3375
+ private sendsSpanOnCompletion;
3376
+ private nearestCapturedAncestorSpanIdOf;
3375
3377
  private contentOffBySimulationPlan;
3376
3378
  /**
3377
3379
  * Send a wrapper span from function execution.
@@ -3657,7 +3659,7 @@ interface CommitRef {
3657
3659
  /**
3658
3660
  * SDK version from package.json (injected at build time)
3659
3661
  */
3660
- declare const __version__ = "0.58.3";
3662
+ declare const __version__ = "0.58.5";
3661
3663
 
3662
3664
  /**
3663
3665
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -31,8 +31,8 @@ import {
31
31
  getCurrentTrace,
32
32
  reseedFromRegistry,
33
33
  seedFromRegistry
34
- } from "./chunk-34VY4J27.js";
35
- import "./chunk-RCHSYWKI.js";
34
+ } from "./chunk-UYAQRSCB.js";
35
+ import "./chunk-ETZUSSF6.js";
36
36
  import {
37
37
  BITFAB_PROGRESS_PREFIX,
38
38
  DbBranchReplayError,
@@ -40,7 +40,7 @@ import {
40
40
  ReplayError,
41
41
  reportReplayProgress,
42
42
  serializeReplayResult
43
- } from "./chunk-HJLWJ3L2.js";
43
+ } from "./chunk-TAEWAXPA.js";
44
44
  import {
45
45
  BitfabError,
46
46
  DEFAULT_SERVICE_URL,
@@ -48,8 +48,8 @@ import {
48
48
  MixedTracingError,
49
49
  __version__,
50
50
  flushTraces
51
- } from "./chunk-EIWNY3FF.js";
52
- import "./chunk-VCRFFCLY.js";
51
+ } from "./chunk-7SPNHC33.js";
52
+ import "./chunk-BAOIRE5T.js";
53
53
  export {
54
54
  AssertionCategoriesClient,
55
55
  BITFAB_PROGRESS_PREFIX,
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.58.3";
100
+ __version__ = "0.58.5";
101
101
  __packageName__ = "bitfab";
102
102
  }
103
103
  });
@@ -5120,6 +5120,7 @@ init_asyncStorage();
5120
5120
  // src/autoTrace.ts
5121
5121
  init_asyncStorage();
5122
5122
  init_captureSuppression();
5123
+ init_warnOnce();
5123
5124
  var autoTraceGlobal = globalThis;
5124
5125
  var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {
5125
5126
  storage: null,
@@ -5187,6 +5188,26 @@ function runWithAutoTraceNodeConfiguration(nodeConfiguration, fn) {
5187
5188
  }
5188
5189
  return result;
5189
5190
  }
5191
+ var SUBTREE_TRACING_DOCS_URL = "https://docs.bitfab.ai/typescript-sdk#experimental-subtree-tracing";
5192
+ function transformInstalled() {
5193
+ return autoTraceGlobal.__bitfab_auto_trace_transformed_v1__ === true;
5194
+ }
5195
+ function runsOnNode() {
5196
+ return typeof process !== "undefined" && Boolean(process.versions?.node);
5197
+ }
5198
+ function closeAutoTraceRoot() {
5199
+ autoTraceState.activeRoots -= 1;
5200
+ }
5201
+ function settleAutoTraceRoot(context) {
5202
+ closeAutoTraceRoot();
5203
+ if (transformInstalled() || !runsOnNode()) {
5204
+ return;
5205
+ }
5206
+ warnOnce(
5207
+ "auto-trace-transform-missing",
5208
+ `trace root "${context.traceFunctionKey}" recorded only its own span. No module in this build was compiled by @bitfab/transform, so calls beneath the root were not discovered. Install @bitfab/transform and add its adapter to the server build: ${SUBTREE_TRACING_DOCS_URL}`
5209
+ );
5210
+ }
5190
5211
  function runWithAutoTraceRootContext(context, spanStack, fn) {
5191
5212
  autoTraceState.activeRoots += 1;
5192
5213
  const entries = [
@@ -5197,19 +5218,19 @@ function runWithAutoTraceRootContext(context, spanStack, fn) {
5197
5218
  try {
5198
5219
  result = runWithAutoTraceScope({ entries }, fn);
5199
5220
  } catch (error) {
5200
- autoTraceState.activeRoots -= 1;
5221
+ settleAutoTraceRoot(context);
5201
5222
  throw error;
5202
5223
  }
5203
5224
  if (isAutoTraceAsyncGenerator(result)) {
5204
- autoTraceState.activeRoots -= 1;
5225
+ closeAutoTraceRoot();
5205
5226
  return wrapAutoTraceAsyncGenerator(context, spanStack, result);
5206
5227
  }
5207
5228
  if (result instanceof Promise) {
5208
5229
  return result.finally(() => {
5209
- autoTraceState.activeRoots -= 1;
5230
+ settleAutoTraceRoot(context);
5210
5231
  });
5211
5232
  }
5212
- autoTraceState.activeRoots -= 1;
5233
+ settleAutoTraceRoot(context);
5213
5234
  return result;
5214
5235
  }
5215
5236
  function invokeThroughAutoTraceEntries(entries, step, fn) {
@@ -9832,13 +9853,23 @@ var Bitfab = class {
9832
9853
  traceFunctionKey
9833
9854
  );
9834
9855
  const openAiAgentsSpanIds = openAiAgentsSpanChain();
9856
+ const functionNameAtOpen = fn.name !== "" ? fn.name : void 0;
9835
9857
  const newContext = {
9836
9858
  traceId,
9837
9859
  spanId,
9838
9860
  contexts: [],
9861
+ spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionNameAtOpen) ?? traceFunctionKey,
9862
+ rootTraceFunctionKey: rootTraceFunctionKeyOfTrace(
9863
+ traceId,
9864
+ traceFunctionKey
9865
+ ),
9866
+ instrumentation: options.instrumentation ?? "span",
9867
+ declaredNode: options.declaredNode === true,
9868
+ isRoot: isRootSpan,
9839
9869
  ...surface !== void 0 && { surface },
9840
9870
  ...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
9841
9871
  };
9872
+ const nearestCapturedAncestorSpanId = self.nearestCapturedAncestorSpanIdOf(currentStack);
9842
9873
  newStack = [...currentStack, newContext];
9843
9874
  const inputs = args;
9844
9875
  const startedAt = nowIsoTimestamp();
@@ -9865,19 +9896,16 @@ var Bitfab = class {
9865
9896
  }
9866
9897
  self.httpClient.traceCompletion.start(traceId, spanId);
9867
9898
  startedSpan = { traceId, spanId };
9868
- const functionName = fn.name !== "" ? fn.name : void 0;
9869
- const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
9870
- traceId,
9871
- traceFunctionKey
9872
- );
9899
+ const functionName = functionNameAtOpen;
9873
9900
  const baseSpanParams = {
9874
9901
  traceFunctionKey,
9875
- rootTraceFunctionKey,
9902
+ rootTraceFunctionKey: newContext.rootTraceFunctionKey,
9876
9903
  functionName,
9877
- spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionName) ?? traceFunctionKey,
9904
+ spanName: newContext.spanName,
9878
9905
  traceId,
9879
9906
  spanId,
9880
9907
  parentSpanId,
9908
+ nearestCapturedAncestorSpanId,
9881
9909
  inputs,
9882
9910
  startedAt,
9883
9911
  spanType: options.type ?? "custom",
@@ -10396,6 +10424,21 @@ var Bitfab = class {
10396
10424
  ...params.testRunId && { testRunId: params.testRunId }
10397
10425
  });
10398
10426
  }
10427
+ sendsSpanOnCompletion(context) {
10428
+ return context.isRoot || context.declaredNode || isFrameworkInstrumentation(context.instrumentation) || !this.simulationPlan.contentOffNow(
10429
+ context.rootTraceFunctionKey,
10430
+ context.spanName
10431
+ );
10432
+ }
10433
+ nearestCapturedAncestorSpanIdOf(stack) {
10434
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
10435
+ const candidate = stack[index];
10436
+ if (candidate !== void 0 && this.sendsSpanOnCompletion(candidate)) {
10437
+ return candidate.spanId;
10438
+ }
10439
+ }
10440
+ return null;
10441
+ }
10399
10442
  contentOffBySimulationPlan(params) {
10400
10443
  if (params.rootTraceFunctionKey === void 0 || isFrameworkInstrumentation(params.instrumentation)) {
10401
10444
  return false;
@@ -10472,6 +10515,9 @@ var Bitfab = class {
10472
10515
  if (params.parentSpanId) {
10473
10516
  externalSpan.parent_id = params.parentSpanId;
10474
10517
  }
10518
+ if (params.nearestCapturedAncestorSpanId !== void 0 && params.nearestCapturedAncestorSpanId !== null && params.nearestCapturedAncestorSpanId !== params.parentSpanId) {
10519
+ externalSpan.nearest_captured_ancestor_id = params.nearestCapturedAncestorSpanId;
10520
+ }
10475
10521
  if (params.inputSourceSpanId) {
10476
10522
  externalSpan.input_source_span_id = params.inputSourceSpanId;
10477
10523
  }