bitfab 0.22.0 → 0.23.1

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.
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-EQI6ZJC3.js";
11
11
 
12
12
  // src/version.generated.ts
13
- var __version__ = "0.22.0";
13
+ var __version__ = "0.23.1";
14
14
 
15
15
  // src/constants.ts
16
16
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -1454,8 +1454,9 @@ function extractLangGraphMetadata(metadata) {
1454
1454
  var BitfabLangGraphCallbackHandler = class {
1455
1455
  constructor(config) {
1456
1456
  this.name = "BitfabLangGraphCallbackHandler";
1457
- this.ignoreRetriever = true;
1458
1457
  this.ignoreRetry = true;
1458
+ // Retriever callbacks ARE captured (retriever queries -> function spans).
1459
+ this.ignoreRetriever = false;
1459
1460
  this.ignoreCustomEvent = true;
1460
1461
  this.runToSpan = /* @__PURE__ */ new Map();
1461
1462
  this.invocations = /* @__PURE__ */ new Map();
@@ -1790,9 +1791,17 @@ var BitfabOpenAIAgentHandler = class {
1790
1791
  constructor(config) {
1791
1792
  this.traceFunctionKey = config.traceFunctionKey;
1792
1793
  this.withSpanFn = config.withSpan;
1794
+ this.getActiveSpanContext = config.getActiveSpanContext;
1793
1795
  }
1794
1796
  async wrapRun(agent, input, options) {
1795
1797
  const { run } = await import("@openai/agents");
1798
+ if (this.getActiveSpanContext?.() != null) {
1799
+ return run(
1800
+ agent,
1801
+ input,
1802
+ options
1803
+ );
1804
+ }
1796
1805
  const isStreaming = options?.stream === true;
1797
1806
  const finalize = async (result) => {
1798
1807
  const res = result;
@@ -2529,7 +2538,11 @@ var Bitfab = class {
2529
2538
  getOpenAiAgentHandler(traceFunctionKey) {
2530
2539
  return new BitfabOpenAIAgentHandler({
2531
2540
  traceFunctionKey,
2532
- withSpan: this.withSpan.bind(this)
2541
+ withSpan: this.withSpan.bind(this),
2542
+ getActiveSpanContext: () => {
2543
+ const stack = getSpanStack();
2544
+ return stack[stack.length - 1] ?? null;
2545
+ }
2533
2546
  });
2534
2547
  }
2535
2548
  /**
@@ -3154,7 +3167,7 @@ var Bitfab = class {
3154
3167
  if (wrappedKey === void 0) {
3155
3168
  replayFn = this.withSpan(
3156
3169
  traceFunctionKey,
3157
- { name: fn.name || "Replay", type: "agent" },
3170
+ { name: traceFunctionKey, type: "agent" },
3158
3171
  fn
3159
3172
  );
3160
3173
  } else if (wrappedKey !== traceFunctionKey) {
@@ -3291,4 +3304,4 @@ export {
3291
3304
  BitfabFunction,
3292
3305
  finalizers
3293
3306
  };
3294
- //# sourceMappingURL=chunk-4SLFC266.js.map
3307
+ //# sourceMappingURL=chunk-2EDITKO2.js.map