@bitfab/sdk 0.58.5 → 0.59.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-YGZA3H67.js → chunk-4BNE5ETI.js} +2 -2
- package/dist/{chunk-E25HU4YZ.js → chunk-6IM35I7O.js} +2 -2
- package/dist/{chunk-E25HU4YZ.js.map → chunk-6IM35I7O.js.map} +1 -1
- package/dist/{chunk-IP2AYKT7.js → chunk-FBMHGUIK.js} +2 -2
- package/dist/{chunk-IP2AYKT7.js.map → chunk-FBMHGUIK.js.map} +1 -1
- package/dist/{chunk-NNSJVCR3.js → chunk-IW23QVY3.js} +3 -3
- package/dist/{chunk-Y47DQCCK.js → chunk-KGIKT4UT.js} +118 -21
- package/dist/chunk-KGIKT4UT.js.map +1 -0
- package/dist/{http-6K4GQC4S.js → http-FXLIHCQK.js} +2 -2
- package/dist/{http-PVE62D6W.js → http-HJJR2ZCE.js} +2 -2
- package/dist/index.cjs +117 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -10
- package/dist/index.d.ts +32 -10
- package/dist/index.js +11 -3
- package/dist/node.cjs +117 -16
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +11 -3
- package/dist/node.js.map +1 -1
- package/dist/{replay-6WA5GD4R.js → replay-WBWGCZF7.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-Y47DQCCK.js.map +0 -1
- /package/dist/{chunk-YGZA3H67.js.map → chunk-4BNE5ETI.js.map} +0 -0
- /package/dist/{chunk-NNSJVCR3.js.map → chunk-IW23QVY3.js.map} +0 -0
- /package/dist/{http-6K4GQC4S.js.map → http-FXLIHCQK.js.map} +0 -0
- /package/dist/{http-PVE62D6W.js.map → http-HJJR2ZCE.js.map} +0 -0
- /package/dist/{replay-6WA5GD4R.js.map → replay-WBWGCZF7.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6IM35I7O.js";
|
|
10
10
|
export {
|
|
11
11
|
BitfabError,
|
|
12
12
|
HttpClient,
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
parseRetryAfterMs,
|
|
17
17
|
serializePayloadBody
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=http-
|
|
19
|
+
//# sourceMappingURL=http-FXLIHCQK.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-FBMHGUIK.js";
|
|
10
10
|
import "./chunk-BAOIRE5T.js";
|
|
11
11
|
export {
|
|
12
12
|
BitfabError,
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
parseRetryAfterMs,
|
|
18
18
|
serializePayloadBody
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=http-
|
|
20
|
+
//# sourceMappingURL=http-HJJR2ZCE.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var __version__, __packageName__;
|
|
|
42
42
|
var init_version_generated = __esm({
|
|
43
43
|
"src/version.generated.ts"() {
|
|
44
44
|
"use strict";
|
|
45
|
-
__version__ = "0.
|
|
45
|
+
__version__ = "0.59.0";
|
|
46
46
|
__packageName__ = "@bitfab/sdk";
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -4390,6 +4390,8 @@ var init_replay = __esm({
|
|
|
4390
4390
|
var index_exports = {};
|
|
4391
4391
|
__export(index_exports, {
|
|
4392
4392
|
AssertionCategoriesClient: () => AssertionCategoriesClient,
|
|
4393
|
+
AssertionGenerationError: () => AssertionGenerationError,
|
|
4394
|
+
AssertionGenerationTimeoutError: () => AssertionGenerationTimeoutError,
|
|
4393
4395
|
BITFAB_PROGRESS_PREFIX: () => BITFAB_PROGRESS_PREFIX,
|
|
4394
4396
|
Bitfab: () => Bitfab,
|
|
4395
4397
|
BitfabClaudeAgentHandler: () => BitfabClaudeAgentHandler,
|
|
@@ -4405,6 +4407,8 @@ __export(index_exports, {
|
|
|
4405
4407
|
DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
|
|
4406
4408
|
DatasetsClient: () => DatasetsClient,
|
|
4407
4409
|
DbBranchReplayError: () => DbBranchReplayError,
|
|
4410
|
+
GraderRerunError: () => GraderRerunError,
|
|
4411
|
+
GraderRerunTimeoutError: () => GraderRerunTimeoutError,
|
|
4408
4412
|
GradersClient: () => GradersClient,
|
|
4409
4413
|
HttpClient: () => HttpClient,
|
|
4410
4414
|
LabelsClient: () => LabelsClient,
|
|
@@ -5832,11 +5836,39 @@ init_constants();
|
|
|
5832
5836
|
|
|
5833
5837
|
// src/datasets.ts
|
|
5834
5838
|
var DEFAULT_RERUN_TIMEOUT_MS = 9e4;
|
|
5835
|
-
var
|
|
5839
|
+
var RERUN_POLL_INTERVAL_MS = 1e3;
|
|
5836
5840
|
var TERMINAL_RERUN_STATUSES = /* @__PURE__ */ new Set([
|
|
5837
5841
|
"completed",
|
|
5838
5842
|
"errored"
|
|
5839
5843
|
]);
|
|
5844
|
+
var GraderRerunError = class extends Error {
|
|
5845
|
+
constructor(message, run) {
|
|
5846
|
+
super(message);
|
|
5847
|
+
this.run = run;
|
|
5848
|
+
this.name = "GraderRerunError";
|
|
5849
|
+
}
|
|
5850
|
+
};
|
|
5851
|
+
var GraderRerunTimeoutError = class extends GraderRerunError {
|
|
5852
|
+
constructor(datasetId, run, timeoutMs) {
|
|
5853
|
+
super(
|
|
5854
|
+
`Grader re-run ${run.id} on dataset ${datasetId} was still ${run.status} after ${timeoutMs}ms. It keeps running on Bitfab; read it later with getGraderRerun.`,
|
|
5855
|
+
run
|
|
5856
|
+
);
|
|
5857
|
+
this.name = "GraderRerunTimeoutError";
|
|
5858
|
+
}
|
|
5859
|
+
};
|
|
5860
|
+
function finishedRerun(datasetId, run, joinedExisting) {
|
|
5861
|
+
if (!TERMINAL_RERUN_STATUSES.has(run.status)) {
|
|
5862
|
+
return null;
|
|
5863
|
+
}
|
|
5864
|
+
if (run.status === "errored") {
|
|
5865
|
+
throw new GraderRerunError(
|
|
5866
|
+
`Grader re-run ${run.id} on dataset ${datasetId} errored: ${run.error ?? "no reason recorded"}`,
|
|
5867
|
+
run
|
|
5868
|
+
);
|
|
5869
|
+
}
|
|
5870
|
+
return { run, joinedExisting };
|
|
5871
|
+
}
|
|
5840
5872
|
function sleep(ms) {
|
|
5841
5873
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5842
5874
|
}
|
|
@@ -5936,28 +5968,25 @@ var DatasetsClient = class {
|
|
|
5936
5968
|
{ graderIds }
|
|
5937
5969
|
);
|
|
5938
5970
|
}
|
|
5939
|
-
/**
|
|
5940
|
-
* Re-run graders over every trace in the dataset. Defaults to every assigned
|
|
5941
|
-
* grader; an unassigned id is rejected. Waits for the run to finish (up to
|
|
5942
|
-
* `timeoutMs`, default 90s) unless `wait` is `false`, and returns the last
|
|
5943
|
-
* run state seen either way. A request matching an in-flight run joins it.
|
|
5944
|
-
*/
|
|
5945
5971
|
async rerunGraders(datasetId, options = {}) {
|
|
5946
5972
|
const started = await this.httpClient.request(
|
|
5947
5973
|
datasetPath(datasetId, "/rerunGraders"),
|
|
5948
5974
|
options.graderIds === void 0 ? {} : { graderIds: options.graderIds }
|
|
5949
5975
|
);
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
}
|
|
5953
|
-
const deadline = Date.now() + (options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS);
|
|
5954
|
-
const interval = options.pollIntervalMs ?? DEFAULT_RERUN_POLL_INTERVAL_MS;
|
|
5976
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS;
|
|
5977
|
+
const deadline = Date.now() + timeoutMs;
|
|
5955
5978
|
let run = started.run;
|
|
5956
|
-
while (
|
|
5957
|
-
|
|
5979
|
+
while (true) {
|
|
5980
|
+
const finished = finishedRerun(datasetId, run, started.joinedExisting);
|
|
5981
|
+
if (finished !== null) {
|
|
5982
|
+
return finished;
|
|
5983
|
+
}
|
|
5984
|
+
if (Date.now() >= deadline) {
|
|
5985
|
+
throw new GraderRerunTimeoutError(datasetId, run, timeoutMs);
|
|
5986
|
+
}
|
|
5987
|
+
await sleep(RERUN_POLL_INTERVAL_MS);
|
|
5958
5988
|
run = await this.getGraderRerun(datasetId, run.id) ?? run;
|
|
5959
5989
|
}
|
|
5960
|
-
return { run, joinedExisting: started.joinedExisting };
|
|
5961
5990
|
}
|
|
5962
5991
|
/**
|
|
5963
5992
|
* The dataset's active grader re-run, or the run named by `runId`. Returns
|
|
@@ -7813,6 +7842,46 @@ init_traceMetadata();
|
|
|
7813
7842
|
// src/traces.ts
|
|
7814
7843
|
var ASSERTIONS_PATH = "/api/sdk/traces/assertions";
|
|
7815
7844
|
var SEARCH_PATH = "/api/sdk/traces/search";
|
|
7845
|
+
var DEFAULT_GENERATION_TIMEOUT_MS = 6e5;
|
|
7846
|
+
var GENERATION_POLL_INTERVAL_MS = 2e3;
|
|
7847
|
+
var AssertionGenerationError = class extends Error {
|
|
7848
|
+
constructor(message, traceId) {
|
|
7849
|
+
super(message);
|
|
7850
|
+
this.traceId = traceId;
|
|
7851
|
+
this.name = "AssertionGenerationError";
|
|
7852
|
+
}
|
|
7853
|
+
};
|
|
7854
|
+
var AssertionGenerationTimeoutError = class extends AssertionGenerationError {
|
|
7855
|
+
constructor(traceId, timeoutMs) {
|
|
7856
|
+
super(
|
|
7857
|
+
`Assertion generation for trace ${traceId} did not finish within ${timeoutMs}ms. Generation keeps running on Bitfab. Call getAssertions and read its generation field to check its status.`,
|
|
7858
|
+
traceId
|
|
7859
|
+
);
|
|
7860
|
+
this.name = "AssertionGenerationTimeoutError";
|
|
7861
|
+
}
|
|
7862
|
+
};
|
|
7863
|
+
function sleep2(ms) {
|
|
7864
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7865
|
+
}
|
|
7866
|
+
function isGenerationFinished(traceId, generation) {
|
|
7867
|
+
if (generation === null || generation.status === "running") {
|
|
7868
|
+
return false;
|
|
7869
|
+
}
|
|
7870
|
+
if (generation.status === "failed") {
|
|
7871
|
+
throw new AssertionGenerationError(
|
|
7872
|
+
`Assertion generation for trace ${traceId} failed: ${generation.error ?? "no reason recorded"}. Pass regenerate: true to try again.`,
|
|
7873
|
+
traceId
|
|
7874
|
+
);
|
|
7875
|
+
}
|
|
7876
|
+
return true;
|
|
7877
|
+
}
|
|
7878
|
+
function draftsInGenerationOrder(assertions, assertionIds) {
|
|
7879
|
+
const byId = new Map(assertions.map((assertion) => [assertion.id, assertion]));
|
|
7880
|
+
return assertionIds.flatMap((id) => {
|
|
7881
|
+
const assertion = byId.get(id);
|
|
7882
|
+
return assertion === void 0 ? [] : [assertion];
|
|
7883
|
+
});
|
|
7884
|
+
}
|
|
7816
7885
|
function traceAssertionsPath(traceId, suffix = "") {
|
|
7817
7886
|
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
|
|
7818
7887
|
}
|
|
@@ -7844,6 +7913,34 @@ var TracesClient = class {
|
|
|
7844
7913
|
});
|
|
7845
7914
|
return response.assertions;
|
|
7846
7915
|
}
|
|
7916
|
+
async generateAssertions(traceId, options = {}) {
|
|
7917
|
+
const started = await this.httpClient.request(
|
|
7918
|
+
traceAssertionsPath(traceId, "/generate"),
|
|
7919
|
+
{
|
|
7920
|
+
...options.guidance === void 0 ? {} : { guidance: options.guidance },
|
|
7921
|
+
...options.categoryIds === void 0 ? {} : { categoryIds: options.categoryIds },
|
|
7922
|
+
...options.regenerate === void 0 ? {} : { regenerate: options.regenerate }
|
|
7923
|
+
}
|
|
7924
|
+
);
|
|
7925
|
+
if (isGenerationFinished(traceId, started.generation)) {
|
|
7926
|
+
return started.assertions;
|
|
7927
|
+
}
|
|
7928
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_GENERATION_TIMEOUT_MS;
|
|
7929
|
+
const deadline = Date.now() + timeoutMs;
|
|
7930
|
+
while (true) {
|
|
7931
|
+
if (Date.now() >= deadline) {
|
|
7932
|
+
throw new AssertionGenerationTimeoutError(traceId, timeoutMs);
|
|
7933
|
+
}
|
|
7934
|
+
await sleep2(GENERATION_POLL_INTERVAL_MS);
|
|
7935
|
+
const read2 = await this.getAssertions(traceId);
|
|
7936
|
+
if (isGenerationFinished(traceId, read2.generation)) {
|
|
7937
|
+
return draftsInGenerationOrder(
|
|
7938
|
+
read2.assertions,
|
|
7939
|
+
read2.generation.assertionIds
|
|
7940
|
+
);
|
|
7941
|
+
}
|
|
7942
|
+
}
|
|
7943
|
+
}
|
|
7847
7944
|
async archiveAssertions(params) {
|
|
7848
7945
|
const response = await this.httpClient.request(
|
|
7849
7946
|
traceAssertionsPath(params.traceId, "/archive"),
|
|
@@ -11062,6 +11159,8 @@ function resolveTraceFunctionKey(registration) {
|
|
|
11062
11159
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11063
11160
|
0 && (module.exports = {
|
|
11064
11161
|
AssertionCategoriesClient,
|
|
11162
|
+
AssertionGenerationError,
|
|
11163
|
+
AssertionGenerationTimeoutError,
|
|
11065
11164
|
BITFAB_PROGRESS_PREFIX,
|
|
11066
11165
|
Bitfab,
|
|
11067
11166
|
BitfabClaudeAgentHandler,
|
|
@@ -11077,6 +11176,8 @@ function resolveTraceFunctionKey(registration) {
|
|
|
11077
11176
|
DEFAULT_SERVICE_URL,
|
|
11078
11177
|
DatasetsClient,
|
|
11079
11178
|
DbBranchReplayError,
|
|
11179
|
+
GraderRerunError,
|
|
11180
|
+
GraderRerunTimeoutError,
|
|
11080
11181
|
GradersClient,
|
|
11081
11182
|
HttpClient,
|
|
11082
11183
|
LabelsClient,
|