bitfab 0.65.11 → 0.66.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/{http-DdlELWcL.js → http-D91qP2J-.js} +2 -2
- package/dist/http-D91qP2J-.js.map +1 -0
- package/dist/{http-CFwCJQyF.cjs → http-DIz8mEMq.cjs} +2 -2
- package/dist/http-DIz8mEMq.cjs.map +1 -0
- package/dist/{index-CUstKXuW.d.cts → index-DiYFr-KV.d.cts} +224 -61
- package/dist/{index-CUstKXuW.d.ts → index-DiYFr-KV.d.ts} +224 -61
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/node.cjs +3 -2
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/dist/{registryCommand-Cr7m6Vif.js → registryCommand-Dk4Y1ZgW.js} +2 -2
- package/dist/registryCommand-Dk4Y1ZgW.js.map +1 -0
- package/dist/replayCli.js +1 -1
- package/dist/seedCli.js +1 -1
- package/dist/{src-lTOsAt47.js → src-CL5eQlNk.js} +114 -46
- package/dist/src-CL5eQlNk.js.map +1 -0
- package/dist/{src-mV-7DNLd.cjs → src-rJcHXJEz.cjs} +119 -45
- package/dist/src-rJcHXJEz.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/http-CFwCJQyF.cjs.map +0 -1
- package/dist/http-DdlELWcL.js.map +0 -1
- package/dist/registryCommand-Cr7m6Vif.js.map +0 -1
- package/dist/src-lTOsAt47.js.map +0 -1
- package/dist/src-mV-7DNLd.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_bamlPeer = require("./bamlPeer-BUoZgNxZ.cjs");
|
|
2
|
-
const require_http = require("./http-
|
|
2
|
+
const require_http = require("./http-DIz8mEMq.cjs");
|
|
3
3
|
const require_autoTrace = require("./autoTrace-CQw0qMBt.cjs");
|
|
4
4
|
let superjson = require("superjson");
|
|
5
5
|
superjson = require_bamlPeer.__toESM(superjson, 1);
|
|
@@ -1240,52 +1240,63 @@ var ExperimentsClient = class {
|
|
|
1240
1240
|
}
|
|
1241
1241
|
};
|
|
1242
1242
|
//#endregion
|
|
1243
|
-
//#region src/
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1243
|
+
//#region src/verdicts.ts
|
|
1244
|
+
const VERDICTS_PATH = "/api/sdk/traces/verdicts";
|
|
1245
|
+
const HUMAN_VERDICTS_PATH = "/api/sdk/traces/verdicts/human";
|
|
1246
|
+
function isSkipOrArchive(fields) {
|
|
1247
|
+
return fields.skip === true || fields.archive === true;
|
|
1248
|
+
}
|
|
1249
|
+
function toWireVerdict(update) {
|
|
1250
|
+
const fields = update;
|
|
1251
|
+
const legacyLabel = fields.label !== void 0;
|
|
1252
|
+
const legacyAbstain = fields.abstain !== void 0;
|
|
1253
|
+
if (!legacyLabel && !legacyAbstain) return update;
|
|
1254
|
+
if (fields.verdict !== void 0) throw new require_http.BitfabError("Pass verdict, or the deprecated label or abstain, not both.");
|
|
1255
|
+
if (legacyLabel && fields.abstain === true) throw new require_http.BitfabError("Pass the deprecated label or abstain, not both. Pass verdict: \"pass\" | \"fail\" | \"abstained\" instead.");
|
|
1256
|
+
const { label, abstain, ...rest } = fields;
|
|
1257
|
+
if (!legacyLabel && abstain !== true) {
|
|
1258
|
+
if (isSkipOrArchive(fields)) return rest;
|
|
1259
|
+
throw new require_http.BitfabError("abstain: false is not a verdict. Pass verdict: \"pass\" | \"fail\" | \"abstained\" instead.");
|
|
1260
|
+
}
|
|
1261
|
+
if (legacyLabel) {
|
|
1262
|
+
require_autoTrace.warnOnce("deprecated-label-field", "The label field is deprecated; pass verdict: \"pass\" | \"fail\" instead.");
|
|
1263
|
+
return {
|
|
1264
|
+
...rest,
|
|
1265
|
+
verdict: label === true ? "pass" : "fail"
|
|
1266
|
+
};
|
|
1262
1267
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1268
|
+
require_autoTrace.warnOnce("deprecated-abstain-field", "The abstain field is deprecated; pass verdict: \"abstained\" or call verdicts.abstain instead.");
|
|
1269
|
+
return {
|
|
1270
|
+
...rest,
|
|
1271
|
+
verdict: "abstained"
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
function assertAbstainedCarriesNoExtras(updates) {
|
|
1275
|
+
for (const update of updates) {
|
|
1276
|
+
const fields = update;
|
|
1277
|
+
if (fields.verdict !== "abstained") continue;
|
|
1278
|
+
const extra = fields.confidence !== void 0 ? "confidence" : fields.evidence !== void 0 ? "evidence" : null;
|
|
1279
|
+
if (extra !== null) throw new require_http.BitfabError(`An "abstained" verdict carries no ${extra}, since nothing was found to judge.`);
|
|
1265
1280
|
}
|
|
1266
|
-
}
|
|
1267
|
-
//#endregion
|
|
1268
|
-
//#region src/labels.ts
|
|
1269
|
-
const LABELS_PATH = "/api/sdk/traces/labels";
|
|
1270
|
-
const HUMAN_LABELS_PATH = "/api/sdk/traces/labels/human";
|
|
1281
|
+
}
|
|
1271
1282
|
function assertEveryVerdictNamesAnAssertion(updates) {
|
|
1272
1283
|
const unscoped = updates.filter((update) => !("archive" in update && update.archive === true) && (typeof update.assertionId !== "string" || update.assertionId === ""));
|
|
1273
1284
|
if (unscoped.length > 0) {
|
|
1274
1285
|
const targets = unscoped.map((update) => update.traceId ?? update.originalTraceId);
|
|
1275
|
-
throw new require_http.BitfabError(`Agent verdicts must name an assertion: ${targets.join(", ")}. Pass the assertionId of the assertion each verdict scores to
|
|
1286
|
+
throw new require_http.BitfabError(`Agent verdicts must name an assertion: ${targets.join(", ")}. Pass the assertionId of the assertion each verdict scores to verdicts.save, saveAll, skip, and abstain. Only archive may omit it, to clear an old whole-trace verdict.`);
|
|
1276
1287
|
}
|
|
1277
1288
|
}
|
|
1278
1289
|
function assertEveryHumanVerdictNamesAnAssertion(updates) {
|
|
1279
1290
|
const unscoped = updates.filter((update) => typeof update.assertionId !== "string" || update.assertionId === "");
|
|
1280
1291
|
if (unscoped.length > 0) {
|
|
1281
1292
|
const targets = unscoped.map((update) => update.traceId);
|
|
1282
|
-
throw new require_http.BitfabError(`Human verdicts must name an assertion: ${targets.join(", ")}. Pass the assertionId of the assertion each verdict scores to
|
|
1293
|
+
throw new require_http.BitfabError(`Human verdicts must name an assertion: ${targets.join(", ")}. Pass the assertionId of the assertion each verdict scores to verdicts.saveHuman and saveHumanAll.`);
|
|
1283
1294
|
}
|
|
1284
1295
|
}
|
|
1285
|
-
function
|
|
1296
|
+
function verdictEvidencePath(traceId, assertionId) {
|
|
1286
1297
|
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions/${encodeURIComponent(assertionId)}/evidence`;
|
|
1287
1298
|
}
|
|
1288
|
-
var
|
|
1299
|
+
var VerdictsClient = class {
|
|
1289
1300
|
constructor(httpClient) {
|
|
1290
1301
|
this.httpClient = httpClient;
|
|
1291
1302
|
}
|
|
@@ -1295,10 +1306,12 @@ var LabelsClient = class {
|
|
|
1295
1306
|
}
|
|
1296
1307
|
async saveAll(updates, experimentId) {
|
|
1297
1308
|
assertEveryVerdictNamesAnAssertion(updates);
|
|
1298
|
-
|
|
1299
|
-
|
|
1309
|
+
const verdicts = updates.map((update) => toWireVerdict(update));
|
|
1310
|
+
assertAbstainedCarriesNoExtras(verdicts);
|
|
1311
|
+
return (await this.httpClient.request(VERDICTS_PATH, {
|
|
1312
|
+
verdicts,
|
|
1300
1313
|
...experimentId === void 0 ? {} : require_http.experimentIdWireFields(experimentId)
|
|
1301
|
-
})).
|
|
1314
|
+
})).verdicts;
|
|
1302
1315
|
}
|
|
1303
1316
|
async skip(target, experimentId) {
|
|
1304
1317
|
return this.save({
|
|
@@ -1309,7 +1322,7 @@ var LabelsClient = class {
|
|
|
1309
1322
|
async abstain(target, experimentId) {
|
|
1310
1323
|
return this.save({
|
|
1311
1324
|
...target,
|
|
1312
|
-
|
|
1325
|
+
verdict: "abstained"
|
|
1313
1326
|
}, experimentId);
|
|
1314
1327
|
}
|
|
1315
1328
|
async archive(target, experimentId) {
|
|
@@ -1324,19 +1337,73 @@ var LabelsClient = class {
|
|
|
1324
1337
|
}
|
|
1325
1338
|
async saveHumanAll(updates) {
|
|
1326
1339
|
assertEveryHumanVerdictNamesAnAssertion(updates);
|
|
1327
|
-
|
|
1340
|
+
const verdicts = updates.map((update) => toWireVerdict(update));
|
|
1341
|
+
return (await this.httpClient.request(HUMAN_VERDICTS_PATH, { verdicts })).verdicts.map((outcome) => ({
|
|
1342
|
+
...outcome,
|
|
1343
|
+
label: outcome.verdict === "pass"
|
|
1344
|
+
}));
|
|
1328
1345
|
}
|
|
1329
1346
|
async get(traceId) {
|
|
1330
|
-
const [
|
|
1331
|
-
return
|
|
1347
|
+
const [verdicts] = await this.getAll([traceId]);
|
|
1348
|
+
return verdicts ?? null;
|
|
1332
1349
|
}
|
|
1333
1350
|
async getAll(traceIds) {
|
|
1334
1351
|
if (traceIds.length === 0) return [];
|
|
1335
1352
|
const query = new URLSearchParams({ traceIds: traceIds.join(",") });
|
|
1336
|
-
return (await this.httpClient.get(`${
|
|
1353
|
+
return (await this.httpClient.get(`${VERDICTS_PATH}?${query.toString()}`)).verdicts;
|
|
1354
|
+
}
|
|
1355
|
+
async generateEvidence(traceId, assertionId) {
|
|
1356
|
+
return (await this.httpClient.get(verdictEvidencePath(traceId, assertionId))).evidence;
|
|
1337
1357
|
}
|
|
1338
1358
|
async generateLabelEvidence(traceId, assertionId) {
|
|
1339
|
-
return
|
|
1359
|
+
return this.generateEvidence(traceId, assertionId);
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
const LabelsClient = VerdictsClient;
|
|
1363
|
+
//#endregion
|
|
1364
|
+
//#region src/graders.ts
|
|
1365
|
+
const GRADER_VERDICTS_PATH = "/api/sdk/graderVerdicts";
|
|
1366
|
+
function withDeprecatedGraderFields(row) {
|
|
1367
|
+
return {
|
|
1368
|
+
...row,
|
|
1369
|
+
label: row.verdict === null ? null : row.verdict === "pass",
|
|
1370
|
+
labelReason: row.reason,
|
|
1371
|
+
labelConfidence: row.confidence
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
var GradersClient = class {
|
|
1375
|
+
constructor(httpClient) {
|
|
1376
|
+
this.httpClient = httpClient;
|
|
1377
|
+
}
|
|
1378
|
+
async getVerdicts(params) {
|
|
1379
|
+
const hasTraceIds = params.traceIds !== void 0 && params.traceIds.length > 0;
|
|
1380
|
+
const hasGraderId = params.graderId !== void 0;
|
|
1381
|
+
if (!hasTraceIds && !hasGraderId) throw new require_http.BitfabError("Pass traceIds, graderId, or both: there is nothing to read otherwise.");
|
|
1382
|
+
const query = new URLSearchParams();
|
|
1383
|
+
if (params.traceIds !== void 0 && params.traceIds.length > 0) query.set("traceIds", params.traceIds.join(","));
|
|
1384
|
+
if (params.graderId !== void 0) query.set("graderId", params.graderId);
|
|
1385
|
+
if (params.limit !== void 0) query.set("limit", String(params.limit));
|
|
1386
|
+
return (await this.httpClient.get(`${GRADER_VERDICTS_PATH}?${query.toString()}`)).verdicts.map(withDeprecatedGraderFields);
|
|
1387
|
+
}
|
|
1388
|
+
async saveVerdict(update) {
|
|
1389
|
+
const [outcome] = await this.saveVerdictAll([update]);
|
|
1390
|
+
return outcome;
|
|
1391
|
+
}
|
|
1392
|
+
async saveVerdictAll(updates) {
|
|
1393
|
+
const verdicts = updates.map((update) => toWireVerdict(update));
|
|
1394
|
+
return (await this.httpClient.request(GRADER_VERDICTS_PATH, { verdicts })).verdicts.map((outcome) => ({
|
|
1395
|
+
...outcome,
|
|
1396
|
+
label: outcome.verdict === "pass"
|
|
1397
|
+
}));
|
|
1398
|
+
}
|
|
1399
|
+
async getLabels(params) {
|
|
1400
|
+
return this.getVerdicts(params);
|
|
1401
|
+
}
|
|
1402
|
+
async saveLabel(update) {
|
|
1403
|
+
return this.saveVerdict(update);
|
|
1404
|
+
}
|
|
1405
|
+
async saveLabelAll(updates) {
|
|
1406
|
+
return this.saveVerdictAll(updates);
|
|
1340
1407
|
}
|
|
1341
1408
|
};
|
|
1342
1409
|
//#endregion
|
|
@@ -3465,7 +3532,7 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
|
|
|
3465
3532
|
throw new ReplayError(cause.message, resultItems, experimentId, fullExperimentUrl, cause);
|
|
3466
3533
|
}
|
|
3467
3534
|
if (missing.length > 0) try {
|
|
3468
|
-
console.error(`Bitfab: server has no persisted trace for ${missing.length} of ${completedCount} completed replay item(s) (experiment ${experimentId}). Their replay token usage is unavailable and they cannot be
|
|
3535
|
+
console.error(`Bitfab: server has no persisted trace for ${missing.length} of ${completedCount} completed replay item(s) (experiment ${experimentId}). Their replay token usage is unavailable and they cannot be given a verdict.`);
|
|
3469
3536
|
} catch {}
|
|
3470
3537
|
}
|
|
3471
3538
|
const result = {
|
|
@@ -4820,7 +4887,8 @@ var Bitfab = class {
|
|
|
4820
4887
|
this.organizationMembers = new OrganizationMembersClient(this.httpClient);
|
|
4821
4888
|
this.traces = new TracesClient(this.httpClient);
|
|
4822
4889
|
this.spans = new SpansClient(this.httpClient);
|
|
4823
|
-
this.
|
|
4890
|
+
this.verdicts = new VerdictsClient(this.httpClient);
|
|
4891
|
+
this.labels = this.verdicts;
|
|
4824
4892
|
this.graders = new GradersClient(this.httpClient);
|
|
4825
4893
|
this.experiments = new ExperimentsClient(this.httpClient);
|
|
4826
4894
|
}
|
|
@@ -5910,7 +5978,7 @@ var Bitfab = class {
|
|
|
5910
5978
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
5911
5979
|
} finally {
|
|
5912
5980
|
try {
|
|
5913
|
-
const { flushTraces } = await Promise.resolve().then(() => require("./http-
|
|
5981
|
+
const { flushTraces } = await Promise.resolve().then(() => require("./http-DIz8mEMq.cjs")).then((n) => n.http_exports);
|
|
5914
5982
|
await flushTraces(3e4);
|
|
5915
5983
|
} finally {
|
|
5916
5984
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -6098,7 +6166,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
6098
6166
|
metadata: seedCase.metadata,
|
|
6099
6167
|
sessionId: seedCase.sessionId
|
|
6100
6168
|
}));
|
|
6101
|
-
const { flushTraces } = await Promise.resolve().then(() => require("./http-
|
|
6169
|
+
const { flushTraces } = await Promise.resolve().then(() => require("./http-DIz8mEMq.cjs")).then((n) => n.http_exports);
|
|
6102
6170
|
await flushTraces(3e4);
|
|
6103
6171
|
return {
|
|
6104
6172
|
pipeline,
|
|
@@ -6281,6 +6349,12 @@ Object.defineProperty(exports, "TracesClient", {
|
|
|
6281
6349
|
return TracesClient;
|
|
6282
6350
|
}
|
|
6283
6351
|
});
|
|
6352
|
+
Object.defineProperty(exports, "VerdictsClient", {
|
|
6353
|
+
enumerable: true,
|
|
6354
|
+
get: function() {
|
|
6355
|
+
return VerdictsClient;
|
|
6356
|
+
}
|
|
6357
|
+
});
|
|
6284
6358
|
Object.defineProperty(exports, "defineReplayRegistry", {
|
|
6285
6359
|
enumerable: true,
|
|
6286
6360
|
get: function() {
|
|
@@ -6336,4 +6410,4 @@ Object.defineProperty(exports, "serializeReplayResult", {
|
|
|
6336
6410
|
}
|
|
6337
6411
|
});
|
|
6338
6412
|
|
|
6339
|
-
//# sourceMappingURL=src-
|
|
6413
|
+
//# sourceMappingURL=src-rJcHXJEz.cjs.map
|