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
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
runWithAutoTraceEntry,
|
|
7
7
|
runWithAutoTraceNodeConfiguration,
|
|
8
8
|
runWithAutoTraceRootContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ETZUSSF6.js";
|
|
10
10
|
import {
|
|
11
11
|
NO_MOCK_OVERRIDE,
|
|
12
12
|
createIntegrationFixtureContext,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
serializeValue,
|
|
18
18
|
toJsonSafe,
|
|
19
19
|
toJsonSafeReport
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-FHEEAPG2.js";
|
|
21
21
|
import {
|
|
22
22
|
BitfabError,
|
|
23
23
|
CONTENT_OFF_KEY,
|
|
@@ -34,9 +34,8 @@ import {
|
|
|
34
34
|
makeSpanOrigin,
|
|
35
35
|
readEnv,
|
|
36
36
|
recordCallerTraceMetadata,
|
|
37
|
-
retireTraceMetadata
|
|
38
|
-
|
|
39
|
-
} from "./chunk-KADON3SF.js";
|
|
37
|
+
retireTraceMetadata
|
|
38
|
+
} from "./chunk-KFZ5OIN5.js";
|
|
40
39
|
import {
|
|
41
40
|
__privateAdd,
|
|
42
41
|
__privateGet,
|
|
@@ -44,8 +43,9 @@ import {
|
|
|
44
43
|
asyncStorageReady,
|
|
45
44
|
createAsyncLocalStorage,
|
|
46
45
|
isAsyncStorageInitDone,
|
|
47
|
-
isCaptureSuppressed
|
|
48
|
-
|
|
46
|
+
isCaptureSuppressed,
|
|
47
|
+
warnOnce
|
|
48
|
+
} from "./chunk-BAOIRE5T.js";
|
|
49
49
|
|
|
50
50
|
// src/assertionCategories.ts
|
|
51
51
|
var CATEGORIES_PATH = "/api/sdk/assertionCategories";
|
|
@@ -1262,11 +1262,39 @@ function currentCommitRef() {
|
|
|
1262
1262
|
|
|
1263
1263
|
// src/datasets.ts
|
|
1264
1264
|
var DEFAULT_RERUN_TIMEOUT_MS = 9e4;
|
|
1265
|
-
var
|
|
1265
|
+
var RERUN_POLL_INTERVAL_MS = 1e3;
|
|
1266
1266
|
var TERMINAL_RERUN_STATUSES = /* @__PURE__ */ new Set([
|
|
1267
1267
|
"completed",
|
|
1268
1268
|
"errored"
|
|
1269
1269
|
]);
|
|
1270
|
+
var GraderRerunError = class extends Error {
|
|
1271
|
+
constructor(message, run) {
|
|
1272
|
+
super(message);
|
|
1273
|
+
this.run = run;
|
|
1274
|
+
this.name = "GraderRerunError";
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
var GraderRerunTimeoutError = class extends GraderRerunError {
|
|
1278
|
+
constructor(datasetId, run, timeoutMs) {
|
|
1279
|
+
super(
|
|
1280
|
+
`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.`,
|
|
1281
|
+
run
|
|
1282
|
+
);
|
|
1283
|
+
this.name = "GraderRerunTimeoutError";
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
function finishedRerun(datasetId, run, joinedExisting) {
|
|
1287
|
+
if (!TERMINAL_RERUN_STATUSES.has(run.status)) {
|
|
1288
|
+
return null;
|
|
1289
|
+
}
|
|
1290
|
+
if (run.status === "errored") {
|
|
1291
|
+
throw new GraderRerunError(
|
|
1292
|
+
`Grader re-run ${run.id} on dataset ${datasetId} errored: ${run.error ?? "no reason recorded"}`,
|
|
1293
|
+
run
|
|
1294
|
+
);
|
|
1295
|
+
}
|
|
1296
|
+
return { run, joinedExisting };
|
|
1297
|
+
}
|
|
1270
1298
|
function sleep(ms) {
|
|
1271
1299
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1272
1300
|
}
|
|
@@ -1366,28 +1394,25 @@ var DatasetsClient = class {
|
|
|
1366
1394
|
{ graderIds }
|
|
1367
1395
|
);
|
|
1368
1396
|
}
|
|
1369
|
-
/**
|
|
1370
|
-
* Re-run graders over every trace in the dataset. Defaults to every assigned
|
|
1371
|
-
* grader; an unassigned id is rejected. Waits for the run to finish (up to
|
|
1372
|
-
* `timeoutMs`, default 90s) unless `wait` is `false`, and returns the last
|
|
1373
|
-
* run state seen either way. A request matching an in-flight run joins it.
|
|
1374
|
-
*/
|
|
1375
1397
|
async rerunGraders(datasetId, options = {}) {
|
|
1376
1398
|
const started = await this.httpClient.request(
|
|
1377
1399
|
datasetPath(datasetId, "/rerunGraders"),
|
|
1378
1400
|
options.graderIds === void 0 ? {} : { graderIds: options.graderIds }
|
|
1379
1401
|
);
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
}
|
|
1383
|
-
const deadline = Date.now() + (options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS);
|
|
1384
|
-
const interval = options.pollIntervalMs ?? DEFAULT_RERUN_POLL_INTERVAL_MS;
|
|
1402
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS;
|
|
1403
|
+
const deadline = Date.now() + timeoutMs;
|
|
1385
1404
|
let run = started.run;
|
|
1386
|
-
while (
|
|
1387
|
-
|
|
1405
|
+
while (true) {
|
|
1406
|
+
const finished = finishedRerun(datasetId, run, started.joinedExisting);
|
|
1407
|
+
if (finished !== null) {
|
|
1408
|
+
return finished;
|
|
1409
|
+
}
|
|
1410
|
+
if (Date.now() >= deadline) {
|
|
1411
|
+
throw new GraderRerunTimeoutError(datasetId, run, timeoutMs);
|
|
1412
|
+
}
|
|
1413
|
+
await sleep(RERUN_POLL_INTERVAL_MS);
|
|
1388
1414
|
run = await this.getGraderRerun(datasetId, run.id) ?? run;
|
|
1389
1415
|
}
|
|
1390
|
-
return { run, joinedExisting: started.joinedExisting };
|
|
1391
1416
|
}
|
|
1392
1417
|
/**
|
|
1393
1418
|
* The dataset's active grader re-run, or the run named by `runId`. Returns
|
|
@@ -3205,6 +3230,46 @@ function runWithSeedContext(ctx, fn) {
|
|
|
3205
3230
|
// src/traces.ts
|
|
3206
3231
|
var ASSERTIONS_PATH = "/api/sdk/traces/assertions";
|
|
3207
3232
|
var SEARCH_PATH = "/api/sdk/traces/search";
|
|
3233
|
+
var DEFAULT_GENERATION_TIMEOUT_MS = 6e5;
|
|
3234
|
+
var GENERATION_POLL_INTERVAL_MS = 2e3;
|
|
3235
|
+
var AssertionGenerationError = class extends Error {
|
|
3236
|
+
constructor(message, traceId) {
|
|
3237
|
+
super(message);
|
|
3238
|
+
this.traceId = traceId;
|
|
3239
|
+
this.name = "AssertionGenerationError";
|
|
3240
|
+
}
|
|
3241
|
+
};
|
|
3242
|
+
var AssertionGenerationTimeoutError = class extends AssertionGenerationError {
|
|
3243
|
+
constructor(traceId, timeoutMs) {
|
|
3244
|
+
super(
|
|
3245
|
+
`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.`,
|
|
3246
|
+
traceId
|
|
3247
|
+
);
|
|
3248
|
+
this.name = "AssertionGenerationTimeoutError";
|
|
3249
|
+
}
|
|
3250
|
+
};
|
|
3251
|
+
function sleep2(ms) {
|
|
3252
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3253
|
+
}
|
|
3254
|
+
function isGenerationFinished(traceId, generation) {
|
|
3255
|
+
if (generation === null || generation.status === "running") {
|
|
3256
|
+
return false;
|
|
3257
|
+
}
|
|
3258
|
+
if (generation.status === "failed") {
|
|
3259
|
+
throw new AssertionGenerationError(
|
|
3260
|
+
`Assertion generation for trace ${traceId} failed: ${generation.error ?? "no reason recorded"}. Pass regenerate: true to try again.`,
|
|
3261
|
+
traceId
|
|
3262
|
+
);
|
|
3263
|
+
}
|
|
3264
|
+
return true;
|
|
3265
|
+
}
|
|
3266
|
+
function draftsInGenerationOrder(assertions, assertionIds) {
|
|
3267
|
+
const byId = new Map(assertions.map((assertion) => [assertion.id, assertion]));
|
|
3268
|
+
return assertionIds.flatMap((id) => {
|
|
3269
|
+
const assertion = byId.get(id);
|
|
3270
|
+
return assertion === void 0 ? [] : [assertion];
|
|
3271
|
+
});
|
|
3272
|
+
}
|
|
3208
3273
|
function traceAssertionsPath(traceId, suffix = "") {
|
|
3209
3274
|
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
|
|
3210
3275
|
}
|
|
@@ -3236,6 +3301,34 @@ var TracesClient = class {
|
|
|
3236
3301
|
});
|
|
3237
3302
|
return response.assertions;
|
|
3238
3303
|
}
|
|
3304
|
+
async generateAssertions(traceId, options = {}) {
|
|
3305
|
+
const started = await this.httpClient.request(
|
|
3306
|
+
traceAssertionsPath(traceId, "/generate"),
|
|
3307
|
+
{
|
|
3308
|
+
...options.guidance === void 0 ? {} : { guidance: options.guidance },
|
|
3309
|
+
...options.categoryIds === void 0 ? {} : { categoryIds: options.categoryIds },
|
|
3310
|
+
...options.regenerate === void 0 ? {} : { regenerate: options.regenerate }
|
|
3311
|
+
}
|
|
3312
|
+
);
|
|
3313
|
+
if (isGenerationFinished(traceId, started.generation)) {
|
|
3314
|
+
return started.assertions;
|
|
3315
|
+
}
|
|
3316
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_GENERATION_TIMEOUT_MS;
|
|
3317
|
+
const deadline = Date.now() + timeoutMs;
|
|
3318
|
+
while (true) {
|
|
3319
|
+
if (Date.now() >= deadline) {
|
|
3320
|
+
throw new AssertionGenerationTimeoutError(traceId, timeoutMs);
|
|
3321
|
+
}
|
|
3322
|
+
await sleep2(GENERATION_POLL_INTERVAL_MS);
|
|
3323
|
+
const read2 = await this.getAssertions(traceId);
|
|
3324
|
+
if (isGenerationFinished(traceId, read2.generation)) {
|
|
3325
|
+
return draftsInGenerationOrder(
|
|
3326
|
+
read2.assertions,
|
|
3327
|
+
read2.generation.assertionIds
|
|
3328
|
+
);
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3239
3332
|
async archiveAssertions(params) {
|
|
3240
3333
|
const response = await this.httpClient.request(
|
|
3241
3334
|
traceAssertionsPath(params.traceId, "/archive"),
|
|
@@ -6043,7 +6136,7 @@ var Bitfab = class {
|
|
|
6043
6136
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
6044
6137
|
} finally {
|
|
6045
6138
|
try {
|
|
6046
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
6139
|
+
const { flushTraces: flushTraces2 } = await import("./http-D7P4JL6C.js");
|
|
6047
6140
|
await flushTraces2(3e4);
|
|
6048
6141
|
} finally {
|
|
6049
6142
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -6102,7 +6195,7 @@ var Bitfab = class {
|
|
|
6102
6195
|
`Function is wrapped with trace function key '${wrappedKey}' but replay was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to replay it under the explicit key.`
|
|
6103
6196
|
);
|
|
6104
6197
|
}
|
|
6105
|
-
const { replay: doReplay } = await import("./replay-
|
|
6198
|
+
const { replay: doReplay } = await import("./replay-5TZNJ2DL.js");
|
|
6106
6199
|
return doReplay(
|
|
6107
6200
|
this.httpClient,
|
|
6108
6201
|
this.serviceUrl,
|
|
@@ -6422,7 +6515,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
6422
6515
|
sessionId: seedCase.sessionId
|
|
6423
6516
|
})
|
|
6424
6517
|
);
|
|
6425
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
6518
|
+
const { flushTraces: flushTraces2 } = await import("./http-D7P4JL6C.js");
|
|
6426
6519
|
await flushTraces2(3e4);
|
|
6427
6520
|
return { pipeline, traceFunctionKey, traceIds };
|
|
6428
6521
|
}
|
|
@@ -6440,6 +6533,8 @@ function resolveTraceFunctionKey(registration) {
|
|
|
6440
6533
|
export {
|
|
6441
6534
|
AssertionCategoriesClient,
|
|
6442
6535
|
BitfabClaudeAgentHandler,
|
|
6536
|
+
GraderRerunError,
|
|
6537
|
+
GraderRerunTimeoutError,
|
|
6443
6538
|
DatasetsClient,
|
|
6444
6539
|
SUPPORTED_PROVIDERS,
|
|
6445
6540
|
GradersClient,
|
|
@@ -6449,6 +6544,8 @@ export {
|
|
|
6449
6544
|
BitfabOpenAIAgentHandler,
|
|
6450
6545
|
OrganizationMembersClient,
|
|
6451
6546
|
BitfabRivetIntegration,
|
|
6547
|
+
AssertionGenerationError,
|
|
6548
|
+
AssertionGenerationTimeoutError,
|
|
6452
6549
|
TracesClient,
|
|
6453
6550
|
BitfabOpenAITracingProcessor,
|
|
6454
6551
|
BitfabVercelAiHandler,
|
|
@@ -6462,4 +6559,4 @@ export {
|
|
|
6462
6559
|
reseedFromRegistry,
|
|
6463
6560
|
seedFromRegistry
|
|
6464
6561
|
};
|
|
6465
|
-
//# sourceMappingURL=chunk-
|
|
6562
|
+
//# sourceMappingURL=chunk-RYSCYPHQ.js.map
|