bitfab 0.12.0 → 0.12.2
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/{chunk-QUCK3IU2.js → chunk-3HBV4GQO.js} +19 -6
- package/dist/{chunk-QUCK3IU2.js.map → chunk-3HBV4GQO.js.map} +1 -1
- package/dist/{chunk-VMJPNYAG.js → chunk-HUSTKOQI.js} +2 -2
- package/dist/{chunk-VMJPNYAG.js.map → chunk-HUSTKOQI.js.map} +1 -1
- package/dist/index.cjs +22 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/node.cjs +22 -7
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +2 -2
- package/dist/{replay-6FKD2UEU.js → replay-RJZGLEHI.js} +7 -5
- package/dist/replay-RJZGLEHI.js.map +1 -0
- package/package.json +1 -1
- package/dist/replay-6FKD2UEU.js.map +0 -1
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
BitfabOpenAITracingProcessor,
|
|
7
7
|
getCurrentSpan,
|
|
8
8
|
getCurrentTrace
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3HBV4GQO.js";
|
|
10
10
|
import {
|
|
11
11
|
BitfabError,
|
|
12
12
|
DEFAULT_SERVICE_URL,
|
|
13
13
|
__version__,
|
|
14
14
|
flushTraces
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-HUSTKOQI.js";
|
|
16
16
|
export {
|
|
17
17
|
Bitfab,
|
|
18
18
|
BitfabClaudeAgentHandler,
|
package/dist/node.cjs
CHANGED
|
@@ -81,7 +81,7 @@ var __version__;
|
|
|
81
81
|
var init_version_generated = __esm({
|
|
82
82
|
"src/version.generated.ts"() {
|
|
83
83
|
"use strict";
|
|
84
|
-
__version__ = "0.12.
|
|
84
|
+
__version__ = "0.12.2";
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
|
|
@@ -473,9 +473,11 @@ function buildMockTree(rootNode) {
|
|
|
473
473
|
function walk(node) {
|
|
474
474
|
const key = node.traceFunctionKey;
|
|
475
475
|
if (key) {
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
476
|
+
const name = node.spanName;
|
|
477
|
+
const counterKey = `${key}:${name}`;
|
|
478
|
+
const index = counters.get(counterKey) ?? 0;
|
|
479
|
+
counters.set(counterKey, index + 1);
|
|
480
|
+
spans.set(`${counterKey}:${index}`, {
|
|
479
481
|
sourceSpanId: node.sourceSpanId,
|
|
480
482
|
output: node.output,
|
|
481
483
|
outputMeta: node.outputMeta
|
|
@@ -2617,6 +2619,15 @@ var Bitfab = class {
|
|
|
2617
2619
|
const options = typeof optionsOrFn === "function" ? {} : optionsOrFn;
|
|
2618
2620
|
const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
|
|
2619
2621
|
const self = this;
|
|
2622
|
+
const fnIsAsyncFunction = fn.constructor.name === "AsyncFunction";
|
|
2623
|
+
const fnReturnsPromise = fnIsAsyncFunction || (() => {
|
|
2624
|
+
try {
|
|
2625
|
+
const src = fn.toString();
|
|
2626
|
+
return /\b(?:Promise|await)\b/.test(src);
|
|
2627
|
+
} catch {
|
|
2628
|
+
return false;
|
|
2629
|
+
}
|
|
2630
|
+
})();
|
|
2620
2631
|
const wrappedFn = function(...args) {
|
|
2621
2632
|
if (!asyncLocalStorage && !isAsyncStorageInitDone()) {
|
|
2622
2633
|
return asyncLocalStorageReady.then(
|
|
@@ -2710,11 +2721,12 @@ var Bitfab = class {
|
|
|
2710
2721
|
const replayCtxForMock = getReplayContext();
|
|
2711
2722
|
if (replayCtxForMock?.mockTree && !isRootSpan) {
|
|
2712
2723
|
const counters = replayCtxForMock.callCounters;
|
|
2713
|
-
const
|
|
2714
|
-
counters.
|
|
2724
|
+
const counterKey = `${traceFunctionKey}:${baseSpanParams.spanName}`;
|
|
2725
|
+
const callIndex = counters.get(counterKey) ?? 0;
|
|
2726
|
+
counters.set(counterKey, callIndex + 1);
|
|
2715
2727
|
const shouldMock = replayCtxForMock.mockStrategy === "all" || replayCtxForMock.mockStrategy === "marked" && options.mockOnReplay === true;
|
|
2716
2728
|
if (shouldMock) {
|
|
2717
|
-
const mockKey = `${
|
|
2729
|
+
const mockKey = `${counterKey}:${callIndex}`;
|
|
2718
2730
|
const mockSpan = replayCtxForMock.mockTree.spans.get(mockKey);
|
|
2719
2731
|
if (mockSpan) {
|
|
2720
2732
|
let output = mockSpan.output;
|
|
@@ -2725,6 +2737,9 @@ var Bitfab = class {
|
|
|
2725
2737
|
});
|
|
2726
2738
|
}
|
|
2727
2739
|
void sendSpan({ result: output });
|
|
2740
|
+
if (fnReturnsPromise) {
|
|
2741
|
+
return Promise.resolve(output);
|
|
2742
|
+
}
|
|
2728
2743
|
return output;
|
|
2729
2744
|
}
|
|
2730
2745
|
}
|