@bitfab/sdk 0.13.4 → 0.13.6
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-XUW46356.js → chunk-6757PVPS.js} +5 -4
- package/dist/{chunk-XUW46356.js.map → chunk-6757PVPS.js.map} +1 -1
- package/dist/{chunk-SKJWF5VX.js → chunk-TMSVIA5J.js} +6 -3
- package/dist/chunk-TMSVIA5J.js.map +1 -0
- package/dist/index.cjs +20 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -2
- package/dist/node.cjs +20 -5
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +2 -2
- package/dist/{replay-HGU5YAOK.js → replay-UBXCO6QU.js} +15 -4
- package/dist/replay-UBXCO6QU.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-SKJWF5VX.js.map +0 -1
- package/dist/replay-HGU5YAOK.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -394,8 +394,12 @@ interface ReplayOptions {
|
|
|
394
394
|
* environment to pick up the per-trace branch URL.
|
|
395
395
|
*/
|
|
396
396
|
environment?: ReplayEnvironment;
|
|
397
|
+
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
398
|
+
experimentGroupId?: string;
|
|
397
399
|
}
|
|
398
400
|
interface ReplayItem<T> {
|
|
401
|
+
/** Trace ID of the new trace created during replay. */
|
|
402
|
+
traceId: string | null;
|
|
399
403
|
/** Deserialized inputs from the original trace. */
|
|
400
404
|
input: unknown[];
|
|
401
405
|
/** The result returned by the function during replay, or undefined on error. */
|
|
@@ -1006,7 +1010,7 @@ declare class BitfabFunction {
|
|
|
1006
1010
|
/**
|
|
1007
1011
|
* SDK version from package.json (injected at build time)
|
|
1008
1012
|
*/
|
|
1009
|
-
declare const __version__ = "0.13.
|
|
1013
|
+
declare const __version__ = "0.13.6";
|
|
1010
1014
|
|
|
1011
1015
|
/**
|
|
1012
1016
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -394,8 +394,12 @@ interface ReplayOptions {
|
|
|
394
394
|
* environment to pick up the per-trace branch URL.
|
|
395
395
|
*/
|
|
396
396
|
environment?: ReplayEnvironment;
|
|
397
|
+
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
398
|
+
experimentGroupId?: string;
|
|
397
399
|
}
|
|
398
400
|
interface ReplayItem<T> {
|
|
401
|
+
/** Trace ID of the new trace created during replay. */
|
|
402
|
+
traceId: string | null;
|
|
399
403
|
/** Deserialized inputs from the original trace. */
|
|
400
404
|
input: unknown[];
|
|
401
405
|
/** The result returned by the function during replay, or undefined on error. */
|
|
@@ -1006,7 +1010,7 @@ declare class BitfabFunction {
|
|
|
1006
1010
|
/**
|
|
1007
1011
|
* SDK version from package.json (injected at build time)
|
|
1008
1012
|
*/
|
|
1009
|
-
declare const __version__ = "0.13.
|
|
1013
|
+
declare const __version__ = "0.13.6";
|
|
1010
1014
|
|
|
1011
1015
|
/**
|
|
1012
1016
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
SUPPORTED_PROVIDERS,
|
|
9
9
|
getCurrentSpan,
|
|
10
10
|
getCurrentTrace
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6757PVPS.js";
|
|
12
12
|
import {
|
|
13
13
|
BitfabError,
|
|
14
14
|
DEFAULT_SERVICE_URL,
|
|
15
15
|
__version__,
|
|
16
16
|
flushTraces
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TMSVIA5J.js";
|
|
18
18
|
export {
|
|
19
19
|
Bitfab,
|
|
20
20
|
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.13.
|
|
84
|
+
__version__ = "0.13.6";
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
|
|
@@ -312,7 +312,7 @@ var init_http = __esm({
|
|
|
312
312
|
* Start a replay session by fetching historical traces.
|
|
313
313
|
* Blocking call — creates a test run and returns lightweight item references.
|
|
314
314
|
*/
|
|
315
|
-
async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles, includeDbBranchLease) {
|
|
315
|
+
async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId) {
|
|
316
316
|
const payload = { traceFunctionKey, limit };
|
|
317
317
|
if (traceIds) {
|
|
318
318
|
payload.traceIds = traceIds;
|
|
@@ -326,6 +326,9 @@ var init_http = __esm({
|
|
|
326
326
|
if (includeDbBranchLease) {
|
|
327
327
|
payload.includeDbBranchLease = true;
|
|
328
328
|
}
|
|
329
|
+
if (experimentGroupId !== void 0) {
|
|
330
|
+
payload.experimentGroupId = experimentGroupId;
|
|
331
|
+
}
|
|
329
332
|
const timeout = includeDbBranchLease ? 18e4 : 3e4;
|
|
330
333
|
return this.request("/api/sdk/replay/start", payload, {
|
|
331
334
|
timeout
|
|
@@ -579,6 +582,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
579
582
|
let originalOutput;
|
|
580
583
|
let result;
|
|
581
584
|
let error = null;
|
|
585
|
+
const replayedTraceId = crypto.randomUUID();
|
|
582
586
|
try {
|
|
583
587
|
const span = await httpClient.getExternalSpan(serverItem.externalSpanId);
|
|
584
588
|
const spanData = span.rawData?.span_data ?? {};
|
|
@@ -594,6 +598,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
594
598
|
const maybePromise = runWithReplayContext(
|
|
595
599
|
{
|
|
596
600
|
testRunId,
|
|
601
|
+
traceId: replayedTraceId,
|
|
597
602
|
inputSourceSpanId: span.id,
|
|
598
603
|
inputSourceTraceId: span.externalTraceId,
|
|
599
604
|
sourceBitfabTraceId: serverItem.traceId,
|
|
@@ -622,6 +627,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
622
627
|
}
|
|
623
628
|
}
|
|
624
629
|
return {
|
|
630
|
+
traceId: replayedTraceId,
|
|
625
631
|
input: inputs,
|
|
626
632
|
result,
|
|
627
633
|
originalOutput,
|
|
@@ -660,8 +666,9 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
|
|
|
660
666
|
options?.traceIds,
|
|
661
667
|
options?.codeChangeDescription,
|
|
662
668
|
options?.codeChangeFiles,
|
|
663
|
-
options?.environment !== void 0
|
|
669
|
+
options?.environment !== void 0,
|
|
664
670
|
// includeDbBranchLease
|
|
671
|
+
options?.experimentGroupId
|
|
665
672
|
);
|
|
666
673
|
const mockStrategy = options?.mock ?? "none";
|
|
667
674
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
@@ -677,14 +684,21 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
|
|
|
677
684
|
);
|
|
678
685
|
const resultItems = await mapWithConcurrency(tasks, maxConcurrency);
|
|
679
686
|
await flushTraces();
|
|
687
|
+
let serverTraceIds = {};
|
|
680
688
|
try {
|
|
681
|
-
await httpClient.completeReplay(testRunId);
|
|
689
|
+
const completeResult = await httpClient.completeReplay(testRunId);
|
|
690
|
+
serverTraceIds = completeResult.traceIds ?? {};
|
|
682
691
|
} catch (e) {
|
|
683
692
|
try {
|
|
684
693
|
console.error("Bitfab: Failed to complete replay:", e);
|
|
685
694
|
} catch {
|
|
686
695
|
}
|
|
687
696
|
}
|
|
697
|
+
for (const item of resultItems) {
|
|
698
|
+
if (item.traceId) {
|
|
699
|
+
item.traceId = serverTraceIds[item.traceId] ?? null;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
688
702
|
return {
|
|
689
703
|
items: resultItems,
|
|
690
704
|
testRunId,
|
|
@@ -2876,7 +2890,8 @@ var Bitfab = class {
|
|
|
2876
2890
|
}
|
|
2877
2891
|
const currentStack = getSpanStack();
|
|
2878
2892
|
const parentContext = currentStack[currentStack.length - 1];
|
|
2879
|
-
const
|
|
2893
|
+
const replayCtxForTraceId = parentContext ? null : getReplayContext();
|
|
2894
|
+
const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? crypto.randomUUID();
|
|
2880
2895
|
const spanId = crypto.randomUUID();
|
|
2881
2896
|
const parentSpanId = parentContext?.spanId ?? null;
|
|
2882
2897
|
const isRootSpan = parentSpanId === null;
|