bitfab 0.12.1 → 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-NU52P7HA.js → chunk-3HBV4GQO.js} +17 -7
- package/dist/{chunk-NU52P7HA.js.map → chunk-3HBV4GQO.js.map} +1 -1
- package/dist/{chunk-OOKZ6S64.js → chunk-HUSTKOQI.js} +2 -2
- package/dist/{chunk-OOKZ6S64.js.map → chunk-HUSTKOQI.js.map} +1 -1
- package/dist/index.cjs +23 -9
- 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 +23 -9
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +2 -2
- package/dist/{replay-UQP2XXBZ.js → replay-RJZGLEHI.js} +10 -6
- package/dist/replay-RJZGLEHI.js.map +1 -0
- package/package.json +1 -1
- package/dist/replay-UQP2XXBZ.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
|
|
@@ -485,7 +487,9 @@ function buildMockTree(rootNode) {
|
|
|
485
487
|
walk(child);
|
|
486
488
|
}
|
|
487
489
|
}
|
|
488
|
-
|
|
490
|
+
for (const child of rootNode.children) {
|
|
491
|
+
walk(child);
|
|
492
|
+
}
|
|
489
493
|
return { spans };
|
|
490
494
|
}
|
|
491
495
|
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy) {
|
|
@@ -2615,6 +2619,15 @@ var Bitfab = class {
|
|
|
2615
2619
|
const options = typeof optionsOrFn === "function" ? {} : optionsOrFn;
|
|
2616
2620
|
const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
|
|
2617
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
|
+
})();
|
|
2618
2631
|
const wrappedFn = function(...args) {
|
|
2619
2632
|
if (!asyncLocalStorage && !isAsyncStorageInitDone()) {
|
|
2620
2633
|
return asyncLocalStorageReady.then(
|
|
@@ -2708,11 +2721,12 @@ var Bitfab = class {
|
|
|
2708
2721
|
const replayCtxForMock = getReplayContext();
|
|
2709
2722
|
if (replayCtxForMock?.mockTree && !isRootSpan) {
|
|
2710
2723
|
const counters = replayCtxForMock.callCounters;
|
|
2711
|
-
const
|
|
2712
|
-
counters.
|
|
2724
|
+
const counterKey = `${traceFunctionKey}:${baseSpanParams.spanName}`;
|
|
2725
|
+
const callIndex = counters.get(counterKey) ?? 0;
|
|
2726
|
+
counters.set(counterKey, callIndex + 1);
|
|
2713
2727
|
const shouldMock = replayCtxForMock.mockStrategy === "all" || replayCtxForMock.mockStrategy === "marked" && options.mockOnReplay === true;
|
|
2714
2728
|
if (shouldMock) {
|
|
2715
|
-
const mockKey = `${
|
|
2729
|
+
const mockKey = `${counterKey}:${callIndex}`;
|
|
2716
2730
|
const mockSpan = replayCtxForMock.mockTree.spans.get(mockKey);
|
|
2717
2731
|
if (mockSpan) {
|
|
2718
2732
|
let output = mockSpan.output;
|
|
@@ -2723,7 +2737,7 @@ var Bitfab = class {
|
|
|
2723
2737
|
});
|
|
2724
2738
|
}
|
|
2725
2739
|
void sendSpan({ result: output });
|
|
2726
|
-
if (
|
|
2740
|
+
if (fnReturnsPromise) {
|
|
2727
2741
|
return Promise.resolve(output);
|
|
2728
2742
|
}
|
|
2729
2743
|
return output;
|