bitfab 0.19.0 → 0.20.0
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-FA6DBCAT.js → chunk-IUZIGC6T.js} +42 -32
- package/dist/chunk-IUZIGC6T.js.map +1 -0
- package/dist/index.cjs +42 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +1 -1
- package/dist/node.cjs +42 -31
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +1 -1
- package/dist/{replay-QAWGVRCZ.js → replay-V6RPJYXZ.js} +3 -2
- package/dist/replay-V6RPJYXZ.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-FA6DBCAT.js.map +0 -1
- package/dist/replay-QAWGVRCZ.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -396,6 +396,13 @@ interface ReplayOptions {
|
|
|
396
396
|
environment?: ReplayEnvironment;
|
|
397
397
|
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
398
398
|
experimentGroupId?: string;
|
|
399
|
+
/**
|
|
400
|
+
* Dataset this replay runs against. When set, the resulting experiment is
|
|
401
|
+
* durably attributed to the dataset (stored on the test run), so it appears
|
|
402
|
+
* under the dataset's experiments even if the trace lineage can't be
|
|
403
|
+
* reconstructed. Validated server-side against the org.
|
|
404
|
+
*/
|
|
405
|
+
datasetId?: string;
|
|
399
406
|
/**
|
|
400
407
|
* Reshape recorded inputs before they are spread into `fn`.
|
|
401
408
|
*
|
|
@@ -1063,7 +1070,7 @@ declare class BitfabFunction {
|
|
|
1063
1070
|
/**
|
|
1064
1071
|
* SDK version from package.json (injected at build time)
|
|
1065
1072
|
*/
|
|
1066
|
-
declare const __version__ = "0.
|
|
1073
|
+
declare const __version__ = "0.20.0";
|
|
1067
1074
|
|
|
1068
1075
|
/**
|
|
1069
1076
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -396,6 +396,13 @@ interface ReplayOptions {
|
|
|
396
396
|
environment?: ReplayEnvironment;
|
|
397
397
|
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
398
398
|
experimentGroupId?: string;
|
|
399
|
+
/**
|
|
400
|
+
* Dataset this replay runs against. When set, the resulting experiment is
|
|
401
|
+
* durably attributed to the dataset (stored on the test run), so it appears
|
|
402
|
+
* under the dataset's experiments even if the trace lineage can't be
|
|
403
|
+
* reconstructed. Validated server-side against the org.
|
|
404
|
+
*/
|
|
405
|
+
datasetId?: string;
|
|
399
406
|
/**
|
|
400
407
|
* Reshape recorded inputs before they are spread into `fn`.
|
|
401
408
|
*
|
|
@@ -1063,7 +1070,7 @@ declare class BitfabFunction {
|
|
|
1063
1070
|
/**
|
|
1064
1071
|
* SDK version from package.json (injected at build time)
|
|
1065
1072
|
*/
|
|
1066
|
-
declare const __version__ = "0.
|
|
1073
|
+
declare const __version__ = "0.20.0";
|
|
1067
1074
|
|
|
1068
1075
|
/**
|
|
1069
1076
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
package/dist/node.cjs
CHANGED
|
@@ -410,7 +410,8 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
|
|
|
410
410
|
options?.codeChangeFiles,
|
|
411
411
|
options?.environment !== void 0,
|
|
412
412
|
// includeDbBranchLease
|
|
413
|
-
options?.experimentGroupId
|
|
413
|
+
options?.experimentGroupId,
|
|
414
|
+
options?.datasetId
|
|
414
415
|
);
|
|
415
416
|
const mockStrategy = options?.mock ?? "none";
|
|
416
417
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
@@ -511,7 +512,7 @@ registerAsyncLocalStorageClass(
|
|
|
511
512
|
);
|
|
512
513
|
|
|
513
514
|
// src/version.generated.ts
|
|
514
|
-
var __version__ = "0.
|
|
515
|
+
var __version__ = "0.20.0";
|
|
515
516
|
|
|
516
517
|
// src/constants.ts
|
|
517
518
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -789,7 +790,7 @@ var HttpClient = class {
|
|
|
789
790
|
* Start a replay session by fetching historical traces.
|
|
790
791
|
* Blocking call — creates a test run and returns lightweight item references.
|
|
791
792
|
*/
|
|
792
|
-
async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId) {
|
|
793
|
+
async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId) {
|
|
793
794
|
const payload = { traceFunctionKey };
|
|
794
795
|
if (limit !== void 0) {
|
|
795
796
|
payload.limit = limit;
|
|
@@ -809,6 +810,9 @@ var HttpClient = class {
|
|
|
809
810
|
if (experimentGroupId !== void 0) {
|
|
810
811
|
payload.experimentGroupId = experimentGroupId;
|
|
811
812
|
}
|
|
813
|
+
if (datasetId !== void 0) {
|
|
814
|
+
payload.datasetId = datasetId;
|
|
815
|
+
}
|
|
812
816
|
const timeout = includeDbBranchLease ? 18e4 : 3e4;
|
|
813
817
|
return this.request("/api/sdk/replay/start", payload, {
|
|
814
818
|
timeout
|
|
@@ -932,23 +936,30 @@ function extractContentBlocks(content) {
|
|
|
932
936
|
}
|
|
933
937
|
return content.map((block) => safeSerialize(block));
|
|
934
938
|
}
|
|
939
|
+
function asTokenCount(val) {
|
|
940
|
+
return typeof val === "number" && Number.isFinite(val) ? val : null;
|
|
941
|
+
}
|
|
935
942
|
function extractUsage(message) {
|
|
936
943
|
const usageInfo = {};
|
|
937
944
|
const usage = message.usage;
|
|
938
945
|
if (!usage) {
|
|
939
946
|
return usageInfo;
|
|
940
947
|
}
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
948
|
+
const baseInput = asTokenCount(usage.input_tokens);
|
|
949
|
+
const cacheRead = asTokenCount(usage.cache_read_input_tokens);
|
|
950
|
+
const cacheCreation = asTokenCount(usage.cache_creation_input_tokens);
|
|
951
|
+
if (baseInput !== null || cacheRead !== null || cacheCreation !== null) {
|
|
952
|
+
usageInfo.inputTokens = (baseInput ?? 0) + (cacheRead ?? 0) + (cacheCreation ?? 0);
|
|
953
|
+
}
|
|
954
|
+
const output = asTokenCount(usage.output_tokens);
|
|
955
|
+
if (output !== null) {
|
|
956
|
+
usageInfo.outputTokens = output;
|
|
957
|
+
}
|
|
958
|
+
if (cacheRead !== null) {
|
|
959
|
+
usageInfo.cacheReadTokens = cacheRead;
|
|
960
|
+
}
|
|
961
|
+
if (cacheCreation !== null) {
|
|
962
|
+
usageInfo.cacheCreationTokens = cacheCreation;
|
|
952
963
|
}
|
|
953
964
|
return usageInfo;
|
|
954
965
|
}
|
|
@@ -1742,7 +1753,7 @@ function extractModelName(serialized, metadata) {
|
|
|
1742
1753
|
}
|
|
1743
1754
|
return void 0;
|
|
1744
1755
|
}
|
|
1745
|
-
function
|
|
1756
|
+
function asTokenCount2(value) {
|
|
1746
1757
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1747
1758
|
}
|
|
1748
1759
|
function normalizeTokenUsage(raw) {
|
|
@@ -1751,10 +1762,10 @@ function normalizeTokenUsage(raw) {
|
|
|
1751
1762
|
}
|
|
1752
1763
|
const u = raw;
|
|
1753
1764
|
if ("cache_read_input_tokens" in u || "cache_creation_input_tokens" in u) {
|
|
1754
|
-
const cacheRead =
|
|
1755
|
-
const cacheCreation =
|
|
1756
|
-
const baseInput =
|
|
1757
|
-
const outputTokens =
|
|
1765
|
+
const cacheRead = asTokenCount2(u.cache_read_input_tokens);
|
|
1766
|
+
const cacheCreation = asTokenCount2(u.cache_creation_input_tokens);
|
|
1767
|
+
const baseInput = asTokenCount2(u.input_tokens);
|
|
1768
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1758
1769
|
if (cacheRead === null && cacheCreation === null && baseInput === null && outputTokens === null) {
|
|
1759
1770
|
return null;
|
|
1760
1771
|
}
|
|
@@ -1769,25 +1780,25 @@ function normalizeTokenUsage(raw) {
|
|
|
1769
1780
|
if ("prompt_tokens" in u || "completion_tokens" in u || "promptTokens" in u || "completionTokens" in u) {
|
|
1770
1781
|
const promptDetails = u.prompt_tokens_details ?? {};
|
|
1771
1782
|
return withAnyTokenCount({
|
|
1772
|
-
inputTokens:
|
|
1773
|
-
outputTokens:
|
|
1774
|
-
totalTokens:
|
|
1775
|
-
cachedInputTokens:
|
|
1783
|
+
inputTokens: asTokenCount2(u.prompt_tokens) ?? asTokenCount2(u.promptTokens),
|
|
1784
|
+
outputTokens: asTokenCount2(u.completion_tokens) ?? asTokenCount2(u.completionTokens),
|
|
1785
|
+
totalTokens: asTokenCount2(u.total_tokens) ?? asTokenCount2(u.totalTokens),
|
|
1786
|
+
cachedInputTokens: asTokenCount2(promptDetails.cached_tokens)
|
|
1776
1787
|
});
|
|
1777
1788
|
}
|
|
1778
1789
|
if ("prompt_token_count" in u || "candidates_token_count" in u) {
|
|
1779
1790
|
return withAnyTokenCount({
|
|
1780
|
-
inputTokens:
|
|
1781
|
-
outputTokens:
|
|
1782
|
-
totalTokens:
|
|
1783
|
-
cachedInputTokens:
|
|
1791
|
+
inputTokens: asTokenCount2(u.prompt_token_count),
|
|
1792
|
+
outputTokens: asTokenCount2(u.candidates_token_count),
|
|
1793
|
+
totalTokens: asTokenCount2(u.total_token_count),
|
|
1794
|
+
cachedInputTokens: asTokenCount2(u.cached_content_token_count)
|
|
1784
1795
|
});
|
|
1785
1796
|
}
|
|
1786
1797
|
if ("input_tokens" in u || "output_tokens" in u) {
|
|
1787
1798
|
const inputDetails = u.input_token_details ?? {};
|
|
1788
|
-
const inputTokens =
|
|
1789
|
-
const outputTokens =
|
|
1790
|
-
let totalTokens =
|
|
1799
|
+
const inputTokens = asTokenCount2(u.input_tokens);
|
|
1800
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1801
|
+
let totalTokens = asTokenCount2(u.total_tokens);
|
|
1791
1802
|
if (totalTokens === null && inputTokens !== null && outputTokens !== null) {
|
|
1792
1803
|
totalTokens = inputTokens + outputTokens;
|
|
1793
1804
|
}
|
|
@@ -1795,7 +1806,7 @@ function normalizeTokenUsage(raw) {
|
|
|
1795
1806
|
inputTokens,
|
|
1796
1807
|
outputTokens,
|
|
1797
1808
|
totalTokens,
|
|
1798
|
-
cachedInputTokens:
|
|
1809
|
+
cachedInputTokens: asTokenCount2(inputDetails.cache_read)
|
|
1799
1810
|
});
|
|
1800
1811
|
}
|
|
1801
1812
|
return null;
|