bitfab 0.58.4 → 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/autoTrace.cjs +50 -4
- package/dist/autoTrace.cjs.map +1 -1
- package/dist/autoTrace.d.cts +2 -1
- package/dist/autoTrace.d.ts +2 -1
- package/dist/autoTrace.js +4 -2
- package/dist/{chunk-VCRFFCLY.js → chunk-BAOIRE5T.js} +20 -2
- package/dist/chunk-BAOIRE5T.js.map +1 -0
- package/dist/{chunk-RCHSYWKI.js → chunk-ETZUSSF6.js} +38 -8
- package/dist/chunk-ETZUSSF6.js.map +1 -0
- package/dist/{chunk-NSD5YKCE.js → chunk-FHEEAPG2.js} +6 -6
- package/dist/{chunk-KADON3SF.js → chunk-KFZ5OIN5.js} +6 -21
- package/dist/chunk-KFZ5OIN5.js.map +1 -0
- package/dist/{chunk-32ZY3DYR.js → chunk-R5MUOBRK.js} +2 -2
- package/dist/{chunk-32ZY3DYR.js.map → chunk-R5MUOBRK.js.map} +1 -1
- package/dist/{chunk-IVF7JQHF.js → chunk-RYSCYPHQ.js} +123 -26
- package/dist/chunk-RYSCYPHQ.js.map +1 -0
- package/dist/{chunk-UOW7VDNB.js → chunk-Y6FVWJKU.js} +3 -3
- package/dist/{http-XQGMIDFR.js → http-7WLON2BH.js} +2 -2
- package/dist/{http-TIOONTDB.js → http-D7P4JL6C.js} +3 -3
- package/dist/index.cjs +142 -20
- 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 +13 -5
- package/dist/node.cjs +142 -20
- 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 +13 -5
- package/dist/node.js.map +1 -1
- package/dist/{replay-CUHT4GUT.js → replay-5TZNJ2DL.js} +4 -4
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-IVF7JQHF.js.map +0 -1
- package/dist/chunk-KADON3SF.js.map +0 -1
- package/dist/chunk-RCHSYWKI.js.map +0 -1
- package/dist/chunk-VCRFFCLY.js.map +0 -1
- /package/dist/{chunk-NSD5YKCE.js.map → chunk-FHEEAPG2.js.map} +0 -0
- /package/dist/{chunk-UOW7VDNB.js.map → chunk-Y6FVWJKU.js.map} +0 -0
- /package/dist/{http-TIOONTDB.js.map → http-7WLON2BH.js.map} +0 -0
- /package/dist/{http-XQGMIDFR.js.map → http-D7P4JL6C.js.map} +0 -0
- /package/dist/{replay-CUHT4GUT.js.map → replay-5TZNJ2DL.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BitfabError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-R5MUOBRK.js";
|
|
4
4
|
|
|
5
5
|
// src/codeChange.ts
|
|
6
6
|
var NUL = String.fromCharCode(0);
|
|
@@ -234,7 +234,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
234
234
|
sessionId: seedCase.sessionId
|
|
235
235
|
})
|
|
236
236
|
);
|
|
237
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
237
|
+
const { flushTraces: flushTraces2 } = await import("./http-7WLON2BH.js");
|
|
238
238
|
await flushTraces2(3e4);
|
|
239
239
|
return { pipeline, traceFunctionKey, traceIds };
|
|
240
240
|
}
|
|
@@ -782,4 +782,4 @@ export {
|
|
|
782
782
|
runRegistryMain,
|
|
783
783
|
runIfEntrypoint
|
|
784
784
|
};
|
|
785
|
-
//# sourceMappingURL=chunk-
|
|
785
|
+
//# sourceMappingURL=chunk-Y6FVWJKU.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-R5MUOBRK.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-7WLON2BH.js.map
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-KFZ5OIN5.js";
|
|
10
|
+
import "./chunk-BAOIRE5T.js";
|
|
11
11
|
export {
|
|
12
12
|
BitfabError,
|
|
13
13
|
HttpClient,
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
parseRetryAfterMs,
|
|
18
18
|
serializePayloadBody
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=http-
|
|
20
|
+
//# sourceMappingURL=http-D7P4JL6C.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -51,7 +51,7 @@ var __version__, __packageName__;
|
|
|
51
51
|
var init_version_generated = __esm({
|
|
52
52
|
"src/version.generated.ts"() {
|
|
53
53
|
"use strict";
|
|
54
|
-
__version__ = "0.
|
|
54
|
+
__version__ = "0.59.0";
|
|
55
55
|
__packageName__ = "bitfab";
|
|
56
56
|
}
|
|
57
57
|
});
|
|
@@ -4399,6 +4399,8 @@ var init_replay = __esm({
|
|
|
4399
4399
|
var index_exports = {};
|
|
4400
4400
|
__export(index_exports, {
|
|
4401
4401
|
AssertionCategoriesClient: () => AssertionCategoriesClient,
|
|
4402
|
+
AssertionGenerationError: () => AssertionGenerationError,
|
|
4403
|
+
AssertionGenerationTimeoutError: () => AssertionGenerationTimeoutError,
|
|
4402
4404
|
BITFAB_PROGRESS_PREFIX: () => BITFAB_PROGRESS_PREFIX,
|
|
4403
4405
|
Bitfab: () => Bitfab,
|
|
4404
4406
|
BitfabClaudeAgentHandler: () => BitfabClaudeAgentHandler,
|
|
@@ -4414,6 +4416,8 @@ __export(index_exports, {
|
|
|
4414
4416
|
DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
|
|
4415
4417
|
DatasetsClient: () => DatasetsClient,
|
|
4416
4418
|
DbBranchReplayError: () => DbBranchReplayError,
|
|
4419
|
+
GraderRerunError: () => GraderRerunError,
|
|
4420
|
+
GraderRerunTimeoutError: () => GraderRerunTimeoutError,
|
|
4417
4421
|
GradersClient: () => GradersClient,
|
|
4418
4422
|
HttpClient: () => HttpClient,
|
|
4419
4423
|
LabelsClient: () => LabelsClient,
|
|
@@ -5106,6 +5110,7 @@ init_asyncStorage();
|
|
|
5106
5110
|
// src/autoTrace.ts
|
|
5107
5111
|
init_asyncStorage();
|
|
5108
5112
|
init_captureSuppression();
|
|
5113
|
+
init_warnOnce();
|
|
5109
5114
|
var autoTraceGlobal = globalThis;
|
|
5110
5115
|
var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {
|
|
5111
5116
|
storage: null,
|
|
@@ -5173,6 +5178,26 @@ function runWithAutoTraceNodeConfiguration(nodeConfiguration, fn) {
|
|
|
5173
5178
|
}
|
|
5174
5179
|
return result;
|
|
5175
5180
|
}
|
|
5181
|
+
var SUBTREE_TRACING_DOCS_URL = "https://docs.bitfab.ai/typescript-sdk#experimental-subtree-tracing";
|
|
5182
|
+
function transformInstalled() {
|
|
5183
|
+
return autoTraceGlobal.__bitfab_auto_trace_transformed_v1__ === true;
|
|
5184
|
+
}
|
|
5185
|
+
function runsOnNode() {
|
|
5186
|
+
return typeof process !== "undefined" && Boolean(process.versions?.node);
|
|
5187
|
+
}
|
|
5188
|
+
function closeAutoTraceRoot() {
|
|
5189
|
+
autoTraceState.activeRoots -= 1;
|
|
5190
|
+
}
|
|
5191
|
+
function settleAutoTraceRoot(context) {
|
|
5192
|
+
closeAutoTraceRoot();
|
|
5193
|
+
if (transformInstalled() || !runsOnNode()) {
|
|
5194
|
+
return;
|
|
5195
|
+
}
|
|
5196
|
+
warnOnce(
|
|
5197
|
+
"auto-trace-transform-missing",
|
|
5198
|
+
`trace root "${context.traceFunctionKey}" recorded only its own span. No module in this build was compiled by @bitfab/transform, so calls beneath the root were not discovered. Install @bitfab/transform and add its adapter to the server build: ${SUBTREE_TRACING_DOCS_URL}`
|
|
5199
|
+
);
|
|
5200
|
+
}
|
|
5176
5201
|
function runWithAutoTraceRootContext(context, spanStack, fn) {
|
|
5177
5202
|
autoTraceState.activeRoots += 1;
|
|
5178
5203
|
const entries = [
|
|
@@ -5183,19 +5208,19 @@ function runWithAutoTraceRootContext(context, spanStack, fn) {
|
|
|
5183
5208
|
try {
|
|
5184
5209
|
result = runWithAutoTraceScope({ entries }, fn);
|
|
5185
5210
|
} catch (error) {
|
|
5186
|
-
|
|
5211
|
+
settleAutoTraceRoot(context);
|
|
5187
5212
|
throw error;
|
|
5188
5213
|
}
|
|
5189
5214
|
if (isAutoTraceAsyncGenerator(result)) {
|
|
5190
|
-
|
|
5215
|
+
closeAutoTraceRoot();
|
|
5191
5216
|
return wrapAutoTraceAsyncGenerator(context, spanStack, result);
|
|
5192
5217
|
}
|
|
5193
5218
|
if (result instanceof Promise) {
|
|
5194
5219
|
return result.finally(() => {
|
|
5195
|
-
|
|
5220
|
+
settleAutoTraceRoot(context);
|
|
5196
5221
|
});
|
|
5197
5222
|
}
|
|
5198
|
-
|
|
5223
|
+
settleAutoTraceRoot(context);
|
|
5199
5224
|
return result;
|
|
5200
5225
|
}
|
|
5201
5226
|
function invokeThroughAutoTraceEntries(entries, step, fn) {
|
|
@@ -5820,11 +5845,39 @@ init_constants();
|
|
|
5820
5845
|
|
|
5821
5846
|
// src/datasets.ts
|
|
5822
5847
|
var DEFAULT_RERUN_TIMEOUT_MS = 9e4;
|
|
5823
|
-
var
|
|
5848
|
+
var RERUN_POLL_INTERVAL_MS = 1e3;
|
|
5824
5849
|
var TERMINAL_RERUN_STATUSES = /* @__PURE__ */ new Set([
|
|
5825
5850
|
"completed",
|
|
5826
5851
|
"errored"
|
|
5827
5852
|
]);
|
|
5853
|
+
var GraderRerunError = class extends Error {
|
|
5854
|
+
constructor(message, run) {
|
|
5855
|
+
super(message);
|
|
5856
|
+
this.run = run;
|
|
5857
|
+
this.name = "GraderRerunError";
|
|
5858
|
+
}
|
|
5859
|
+
};
|
|
5860
|
+
var GraderRerunTimeoutError = class extends GraderRerunError {
|
|
5861
|
+
constructor(datasetId, run, timeoutMs) {
|
|
5862
|
+
super(
|
|
5863
|
+
`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.`,
|
|
5864
|
+
run
|
|
5865
|
+
);
|
|
5866
|
+
this.name = "GraderRerunTimeoutError";
|
|
5867
|
+
}
|
|
5868
|
+
};
|
|
5869
|
+
function finishedRerun(datasetId, run, joinedExisting) {
|
|
5870
|
+
if (!TERMINAL_RERUN_STATUSES.has(run.status)) {
|
|
5871
|
+
return null;
|
|
5872
|
+
}
|
|
5873
|
+
if (run.status === "errored") {
|
|
5874
|
+
throw new GraderRerunError(
|
|
5875
|
+
`Grader re-run ${run.id} on dataset ${datasetId} errored: ${run.error ?? "no reason recorded"}`,
|
|
5876
|
+
run
|
|
5877
|
+
);
|
|
5878
|
+
}
|
|
5879
|
+
return { run, joinedExisting };
|
|
5880
|
+
}
|
|
5828
5881
|
function sleep(ms) {
|
|
5829
5882
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5830
5883
|
}
|
|
@@ -5924,28 +5977,25 @@ var DatasetsClient = class {
|
|
|
5924
5977
|
{ graderIds }
|
|
5925
5978
|
);
|
|
5926
5979
|
}
|
|
5927
|
-
/**
|
|
5928
|
-
* Re-run graders over every trace in the dataset. Defaults to every assigned
|
|
5929
|
-
* grader; an unassigned id is rejected. Waits for the run to finish (up to
|
|
5930
|
-
* `timeoutMs`, default 90s) unless `wait` is `false`, and returns the last
|
|
5931
|
-
* run state seen either way. A request matching an in-flight run joins it.
|
|
5932
|
-
*/
|
|
5933
5980
|
async rerunGraders(datasetId, options = {}) {
|
|
5934
5981
|
const started = await this.httpClient.request(
|
|
5935
5982
|
datasetPath(datasetId, "/rerunGraders"),
|
|
5936
5983
|
options.graderIds === void 0 ? {} : { graderIds: options.graderIds }
|
|
5937
5984
|
);
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
}
|
|
5941
|
-
const deadline = Date.now() + (options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS);
|
|
5942
|
-
const interval = options.pollIntervalMs ?? DEFAULT_RERUN_POLL_INTERVAL_MS;
|
|
5985
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS;
|
|
5986
|
+
const deadline = Date.now() + timeoutMs;
|
|
5943
5987
|
let run = started.run;
|
|
5944
|
-
while (
|
|
5945
|
-
|
|
5988
|
+
while (true) {
|
|
5989
|
+
const finished = finishedRerun(datasetId, run, started.joinedExisting);
|
|
5990
|
+
if (finished !== null) {
|
|
5991
|
+
return finished;
|
|
5992
|
+
}
|
|
5993
|
+
if (Date.now() >= deadline) {
|
|
5994
|
+
throw new GraderRerunTimeoutError(datasetId, run, timeoutMs);
|
|
5995
|
+
}
|
|
5996
|
+
await sleep(RERUN_POLL_INTERVAL_MS);
|
|
5946
5997
|
run = await this.getGraderRerun(datasetId, run.id) ?? run;
|
|
5947
5998
|
}
|
|
5948
|
-
return { run, joinedExisting: started.joinedExisting };
|
|
5949
5999
|
}
|
|
5950
6000
|
/**
|
|
5951
6001
|
* The dataset's active grader re-run, or the run named by `runId`. Returns
|
|
@@ -7801,6 +7851,46 @@ init_traceMetadata();
|
|
|
7801
7851
|
// src/traces.ts
|
|
7802
7852
|
var ASSERTIONS_PATH = "/api/sdk/traces/assertions";
|
|
7803
7853
|
var SEARCH_PATH = "/api/sdk/traces/search";
|
|
7854
|
+
var DEFAULT_GENERATION_TIMEOUT_MS = 6e5;
|
|
7855
|
+
var GENERATION_POLL_INTERVAL_MS = 2e3;
|
|
7856
|
+
var AssertionGenerationError = class extends Error {
|
|
7857
|
+
constructor(message, traceId) {
|
|
7858
|
+
super(message);
|
|
7859
|
+
this.traceId = traceId;
|
|
7860
|
+
this.name = "AssertionGenerationError";
|
|
7861
|
+
}
|
|
7862
|
+
};
|
|
7863
|
+
var AssertionGenerationTimeoutError = class extends AssertionGenerationError {
|
|
7864
|
+
constructor(traceId, timeoutMs) {
|
|
7865
|
+
super(
|
|
7866
|
+
`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.`,
|
|
7867
|
+
traceId
|
|
7868
|
+
);
|
|
7869
|
+
this.name = "AssertionGenerationTimeoutError";
|
|
7870
|
+
}
|
|
7871
|
+
};
|
|
7872
|
+
function sleep2(ms) {
|
|
7873
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7874
|
+
}
|
|
7875
|
+
function isGenerationFinished(traceId, generation) {
|
|
7876
|
+
if (generation === null || generation.status === "running") {
|
|
7877
|
+
return false;
|
|
7878
|
+
}
|
|
7879
|
+
if (generation.status === "failed") {
|
|
7880
|
+
throw new AssertionGenerationError(
|
|
7881
|
+
`Assertion generation for trace ${traceId} failed: ${generation.error ?? "no reason recorded"}. Pass regenerate: true to try again.`,
|
|
7882
|
+
traceId
|
|
7883
|
+
);
|
|
7884
|
+
}
|
|
7885
|
+
return true;
|
|
7886
|
+
}
|
|
7887
|
+
function draftsInGenerationOrder(assertions, assertionIds) {
|
|
7888
|
+
const byId = new Map(assertions.map((assertion) => [assertion.id, assertion]));
|
|
7889
|
+
return assertionIds.flatMap((id) => {
|
|
7890
|
+
const assertion = byId.get(id);
|
|
7891
|
+
return assertion === void 0 ? [] : [assertion];
|
|
7892
|
+
});
|
|
7893
|
+
}
|
|
7804
7894
|
function traceAssertionsPath(traceId, suffix = "") {
|
|
7805
7895
|
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
|
|
7806
7896
|
}
|
|
@@ -7832,6 +7922,34 @@ var TracesClient = class {
|
|
|
7832
7922
|
});
|
|
7833
7923
|
return response.assertions;
|
|
7834
7924
|
}
|
|
7925
|
+
async generateAssertions(traceId, options = {}) {
|
|
7926
|
+
const started = await this.httpClient.request(
|
|
7927
|
+
traceAssertionsPath(traceId, "/generate"),
|
|
7928
|
+
{
|
|
7929
|
+
...options.guidance === void 0 ? {} : { guidance: options.guidance },
|
|
7930
|
+
...options.categoryIds === void 0 ? {} : { categoryIds: options.categoryIds },
|
|
7931
|
+
...options.regenerate === void 0 ? {} : { regenerate: options.regenerate }
|
|
7932
|
+
}
|
|
7933
|
+
);
|
|
7934
|
+
if (isGenerationFinished(traceId, started.generation)) {
|
|
7935
|
+
return started.assertions;
|
|
7936
|
+
}
|
|
7937
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_GENERATION_TIMEOUT_MS;
|
|
7938
|
+
const deadline = Date.now() + timeoutMs;
|
|
7939
|
+
while (true) {
|
|
7940
|
+
if (Date.now() >= deadline) {
|
|
7941
|
+
throw new AssertionGenerationTimeoutError(traceId, timeoutMs);
|
|
7942
|
+
}
|
|
7943
|
+
await sleep2(GENERATION_POLL_INTERVAL_MS);
|
|
7944
|
+
const read2 = await this.getAssertions(traceId);
|
|
7945
|
+
if (isGenerationFinished(traceId, read2.generation)) {
|
|
7946
|
+
return draftsInGenerationOrder(
|
|
7947
|
+
read2.assertions,
|
|
7948
|
+
read2.generation.assertionIds
|
|
7949
|
+
);
|
|
7950
|
+
}
|
|
7951
|
+
}
|
|
7952
|
+
}
|
|
7835
7953
|
async archiveAssertions(params) {
|
|
7836
7954
|
const response = await this.httpClient.request(
|
|
7837
7955
|
traceAssertionsPath(params.traceId, "/archive"),
|
|
@@ -11050,6 +11168,8 @@ function resolveTraceFunctionKey(registration) {
|
|
|
11050
11168
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11051
11169
|
0 && (module.exports = {
|
|
11052
11170
|
AssertionCategoriesClient,
|
|
11171
|
+
AssertionGenerationError,
|
|
11172
|
+
AssertionGenerationTimeoutError,
|
|
11053
11173
|
BITFAB_PROGRESS_PREFIX,
|
|
11054
11174
|
Bitfab,
|
|
11055
11175
|
BitfabClaudeAgentHandler,
|
|
@@ -11065,6 +11185,8 @@ function resolveTraceFunctionKey(registration) {
|
|
|
11065
11185
|
DEFAULT_SERVICE_URL,
|
|
11066
11186
|
DatasetsClient,
|
|
11067
11187
|
DbBranchReplayError,
|
|
11188
|
+
GraderRerunError,
|
|
11189
|
+
GraderRerunTimeoutError,
|
|
11068
11190
|
GradersClient,
|
|
11069
11191
|
HttpClient,
|
|
11070
11192
|
LabelsClient,
|