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.cjs
CHANGED
|
@@ -403,7 +403,8 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
|
|
|
403
403
|
options?.codeChangeFiles,
|
|
404
404
|
options?.environment !== void 0,
|
|
405
405
|
// includeDbBranchLease
|
|
406
|
-
options?.experimentGroupId
|
|
406
|
+
options?.experimentGroupId,
|
|
407
|
+
options?.datasetId
|
|
407
408
|
);
|
|
408
409
|
const mockStrategy = options?.mock ?? "none";
|
|
409
410
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
@@ -497,7 +498,7 @@ __export(index_exports, {
|
|
|
497
498
|
module.exports = __toCommonJS(index_exports);
|
|
498
499
|
|
|
499
500
|
// src/version.generated.ts
|
|
500
|
-
var __version__ = "0.
|
|
501
|
+
var __version__ = "0.20.0";
|
|
501
502
|
|
|
502
503
|
// src/constants.ts
|
|
503
504
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -775,7 +776,7 @@ var HttpClient = class {
|
|
|
775
776
|
* Start a replay session by fetching historical traces.
|
|
776
777
|
* Blocking call — creates a test run and returns lightweight item references.
|
|
777
778
|
*/
|
|
778
|
-
async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId) {
|
|
779
|
+
async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId) {
|
|
779
780
|
const payload = { traceFunctionKey };
|
|
780
781
|
if (limit !== void 0) {
|
|
781
782
|
payload.limit = limit;
|
|
@@ -795,6 +796,9 @@ var HttpClient = class {
|
|
|
795
796
|
if (experimentGroupId !== void 0) {
|
|
796
797
|
payload.experimentGroupId = experimentGroupId;
|
|
797
798
|
}
|
|
799
|
+
if (datasetId !== void 0) {
|
|
800
|
+
payload.datasetId = datasetId;
|
|
801
|
+
}
|
|
798
802
|
const timeout = includeDbBranchLease ? 18e4 : 3e4;
|
|
799
803
|
return this.request("/api/sdk/replay/start", payload, {
|
|
800
804
|
timeout
|
|
@@ -918,23 +922,30 @@ function extractContentBlocks(content) {
|
|
|
918
922
|
}
|
|
919
923
|
return content.map((block) => safeSerialize(block));
|
|
920
924
|
}
|
|
925
|
+
function asTokenCount(val) {
|
|
926
|
+
return typeof val === "number" && Number.isFinite(val) ? val : null;
|
|
927
|
+
}
|
|
921
928
|
function extractUsage(message) {
|
|
922
929
|
const usageInfo = {};
|
|
923
930
|
const usage = message.usage;
|
|
924
931
|
if (!usage) {
|
|
925
932
|
return usageInfo;
|
|
926
933
|
}
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
934
|
+
const baseInput = asTokenCount(usage.input_tokens);
|
|
935
|
+
const cacheRead = asTokenCount(usage.cache_read_input_tokens);
|
|
936
|
+
const cacheCreation = asTokenCount(usage.cache_creation_input_tokens);
|
|
937
|
+
if (baseInput !== null || cacheRead !== null || cacheCreation !== null) {
|
|
938
|
+
usageInfo.inputTokens = (baseInput ?? 0) + (cacheRead ?? 0) + (cacheCreation ?? 0);
|
|
939
|
+
}
|
|
940
|
+
const output = asTokenCount(usage.output_tokens);
|
|
941
|
+
if (output !== null) {
|
|
942
|
+
usageInfo.outputTokens = output;
|
|
943
|
+
}
|
|
944
|
+
if (cacheRead !== null) {
|
|
945
|
+
usageInfo.cacheReadTokens = cacheRead;
|
|
946
|
+
}
|
|
947
|
+
if (cacheCreation !== null) {
|
|
948
|
+
usageInfo.cacheCreationTokens = cacheCreation;
|
|
938
949
|
}
|
|
939
950
|
return usageInfo;
|
|
940
951
|
}
|
|
@@ -1728,7 +1739,7 @@ function extractModelName(serialized, metadata) {
|
|
|
1728
1739
|
}
|
|
1729
1740
|
return void 0;
|
|
1730
1741
|
}
|
|
1731
|
-
function
|
|
1742
|
+
function asTokenCount2(value) {
|
|
1732
1743
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1733
1744
|
}
|
|
1734
1745
|
function normalizeTokenUsage(raw) {
|
|
@@ -1737,10 +1748,10 @@ function normalizeTokenUsage(raw) {
|
|
|
1737
1748
|
}
|
|
1738
1749
|
const u = raw;
|
|
1739
1750
|
if ("cache_read_input_tokens" in u || "cache_creation_input_tokens" in u) {
|
|
1740
|
-
const cacheRead =
|
|
1741
|
-
const cacheCreation =
|
|
1742
|
-
const baseInput =
|
|
1743
|
-
const outputTokens =
|
|
1751
|
+
const cacheRead = asTokenCount2(u.cache_read_input_tokens);
|
|
1752
|
+
const cacheCreation = asTokenCount2(u.cache_creation_input_tokens);
|
|
1753
|
+
const baseInput = asTokenCount2(u.input_tokens);
|
|
1754
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1744
1755
|
if (cacheRead === null && cacheCreation === null && baseInput === null && outputTokens === null) {
|
|
1745
1756
|
return null;
|
|
1746
1757
|
}
|
|
@@ -1755,25 +1766,25 @@ function normalizeTokenUsage(raw) {
|
|
|
1755
1766
|
if ("prompt_tokens" in u || "completion_tokens" in u || "promptTokens" in u || "completionTokens" in u) {
|
|
1756
1767
|
const promptDetails = u.prompt_tokens_details ?? {};
|
|
1757
1768
|
return withAnyTokenCount({
|
|
1758
|
-
inputTokens:
|
|
1759
|
-
outputTokens:
|
|
1760
|
-
totalTokens:
|
|
1761
|
-
cachedInputTokens:
|
|
1769
|
+
inputTokens: asTokenCount2(u.prompt_tokens) ?? asTokenCount2(u.promptTokens),
|
|
1770
|
+
outputTokens: asTokenCount2(u.completion_tokens) ?? asTokenCount2(u.completionTokens),
|
|
1771
|
+
totalTokens: asTokenCount2(u.total_tokens) ?? asTokenCount2(u.totalTokens),
|
|
1772
|
+
cachedInputTokens: asTokenCount2(promptDetails.cached_tokens)
|
|
1762
1773
|
});
|
|
1763
1774
|
}
|
|
1764
1775
|
if ("prompt_token_count" in u || "candidates_token_count" in u) {
|
|
1765
1776
|
return withAnyTokenCount({
|
|
1766
|
-
inputTokens:
|
|
1767
|
-
outputTokens:
|
|
1768
|
-
totalTokens:
|
|
1769
|
-
cachedInputTokens:
|
|
1777
|
+
inputTokens: asTokenCount2(u.prompt_token_count),
|
|
1778
|
+
outputTokens: asTokenCount2(u.candidates_token_count),
|
|
1779
|
+
totalTokens: asTokenCount2(u.total_token_count),
|
|
1780
|
+
cachedInputTokens: asTokenCount2(u.cached_content_token_count)
|
|
1770
1781
|
});
|
|
1771
1782
|
}
|
|
1772
1783
|
if ("input_tokens" in u || "output_tokens" in u) {
|
|
1773
1784
|
const inputDetails = u.input_token_details ?? {};
|
|
1774
|
-
const inputTokens =
|
|
1775
|
-
const outputTokens =
|
|
1776
|
-
let totalTokens =
|
|
1785
|
+
const inputTokens = asTokenCount2(u.input_tokens);
|
|
1786
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1787
|
+
let totalTokens = asTokenCount2(u.total_tokens);
|
|
1777
1788
|
if (totalTokens === null && inputTokens !== null && outputTokens !== null) {
|
|
1778
1789
|
totalTokens = inputTokens + outputTokens;
|
|
1779
1790
|
}
|
|
@@ -1781,7 +1792,7 @@ function normalizeTokenUsage(raw) {
|
|
|
1781
1792
|
inputTokens,
|
|
1782
1793
|
outputTokens,
|
|
1783
1794
|
totalTokens,
|
|
1784
|
-
cachedInputTokens:
|
|
1795
|
+
cachedInputTokens: asTokenCount2(inputDetails.cache_read)
|
|
1785
1796
|
});
|
|
1786
1797
|
}
|
|
1787
1798
|
return null;
|