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/replayCli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, o as checkReplayCliArgs, r as resolveRegistry, s as runReplayCli, t as importRegistry } from "./registryCommand-Cr7m6Vif.js";
2
+ import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, o as checkReplayCliArgs, r as resolveRegistry, s as runReplayCli, t as importRegistry } from "./registryCommand-Dk4Y1ZgW.js";
3
3
  //#region src/cloudReplayCli.ts
4
4
  const CLOUD_REPLAY_HINT = "Add --cloud to run the same replay on GitHub Actions; bitfab-replay --cloud --help explains it.";
5
5
  function isCloudReplayCommand(argv) {
package/dist/seedCli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-Cr7m6Vif.js";
2
+ import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-Dk4Y1ZgW.js";
3
3
  //#region src/seedCli.ts
4
4
  const USAGE = "Usage: bitfab-seed --registry <path> <pipeline> --from-trace <id>[,<id>...]\n bitfab-seed --registry <path> <pipeline> --cases <cases.jsonl> [--run]\nRun bitfab-seed --registry <path> <pipeline> --help for details.";
5
5
  async function runSeedCommand(argv, io = {}, importer = importRegistry) {
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { C as readEnv$1, S as MixedTracingError, _ as getReplayContext, b as gitRunner, c as recordCallerTraceMetadata, f as ROOT_TRACE_FUNCTION_KEY_FIELD, g as MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES, h as makeSpanOrigin, i as flushTraces, l as retireTraceMetadata, m as isFrameworkInstrumentation, n as SPAN_TYPES, o as unrefTimer, p as SimulationPlan, r as experimentIdWireFields, s as callerTraceMetadata, t as HttpClient, v as replayContextReady, w as __version__, x as BitfabError, y as runWithReplayContext } from "./http-DdlELWcL.js";
2
+ import { C as readEnv$1, S as MixedTracingError, _ as getReplayContext, b as gitRunner, c as recordCallerTraceMetadata, f as ROOT_TRACE_FUNCTION_KEY_FIELD, g as MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES, h as makeSpanOrigin, i as flushTraces, l as retireTraceMetadata, m as isFrameworkInstrumentation, n as SPAN_TYPES, o as unrefTimer, p as SimulationPlan, r as experimentIdWireFields, s as callerTraceMetadata, t as HttpClient, v as replayContextReady, w as __version__, x as BitfabError, y as runWithReplayContext } from "./http-D91qP2J-.js";
3
3
  import { a as clearAutoTraceNodeConfiguration, b as isAsyncStorageInitDone, c as runAsAutoTraceRootFunction, d as runWithAutoTraceRootContext, g as runWithCaptureSuppressed, h as isCaptureSuppressed, l as runWithAutoTraceEntry, m as writeOnce, n as __bitfabAutoTraceActive, o as currentAutoTraceEntries, p as warnOnce, s as invokeThroughAutoTraceEntries, u as runWithAutoTraceNodeConfiguration, v as asyncStorageReady, y as createAsyncLocalStorage } from "./autoTrace-O40k8f5M.js";
4
4
  import { r as importOptionalPeer, t as loadBamlModule } from "./bamlPeer-CIVwS68E.js";
5
5
  import superjson from "superjson";
@@ -1240,52 +1240,63 @@ var ExperimentsClient = class {
1240
1240
  }
1241
1241
  };
1242
1242
  //#endregion
1243
- //#region src/graders.ts
1244
- const GRADER_LABELS_PATH = "/api/sdk/graderLabels";
1245
- var GradersClient = class {
1246
- constructor(httpClient) {
1247
- this.httpClient = httpClient;
1248
- }
1249
- async getLabels(params) {
1250
- const hasTraceIds = params.traceIds !== void 0 && params.traceIds.length > 0;
1251
- const hasGraderId = params.graderId !== void 0;
1252
- if (!hasTraceIds && !hasGraderId) throw new BitfabError("Pass traceIds, graderId, or both: there is nothing to read otherwise.");
1253
- const query = new URLSearchParams();
1254
- if (params.traceIds !== void 0 && params.traceIds.length > 0) query.set("traceIds", params.traceIds.join(","));
1255
- if (params.graderId !== void 0) query.set("graderId", params.graderId);
1256
- if (params.limit !== void 0) query.set("limit", String(params.limit));
1257
- return (await this.httpClient.get(`${GRADER_LABELS_PATH}?${query.toString()}`)).labels;
1258
- }
1259
- async saveLabel(update) {
1260
- const [outcome] = await this.saveLabelAll([update]);
1261
- return outcome;
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 BitfabError("Pass verdict, or the deprecated label or abstain, not both.");
1255
+ if (legacyLabel && fields.abstain === true) throw new 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 BitfabError("abstain: false is not a verdict. Pass verdict: \"pass\" | \"fail\" | \"abstained\" instead.");
1260
+ }
1261
+ if (legacyLabel) {
1262
+ 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
- async saveLabelAll(updates) {
1264
- return (await this.httpClient.request(GRADER_LABELS_PATH, { labels: updates })).labels;
1268
+ 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 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 BitfabError(`Agent verdicts must name an assertion: ${targets.join(", ")}. Pass the assertionId of the assertion each verdict scores to labels.save, saveAll, skip, and abstain. Only archive may omit it, to clear an old whole-trace verdict.`);
1286
+ throw new 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 BitfabError(`Human verdicts must name an assertion: ${targets.join(", ")}. Pass the assertionId of the assertion each verdict scores to labels.saveHuman and saveHumanAll.`);
1293
+ throw new 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 labelEvidencePath(traceId, assertionId) {
1296
+ function verdictEvidencePath(traceId, assertionId) {
1286
1297
  return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions/${encodeURIComponent(assertionId)}/evidence`;
1287
1298
  }
1288
- var LabelsClient = class {
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
- return (await this.httpClient.request(LABELS_PATH, {
1299
- labels: updates,
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 ? {} : experimentIdWireFields(experimentId)
1301
- })).labels;
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
- abstain: true
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
- return (await this.httpClient.request(HUMAN_LABELS_PATH, { labels: updates })).labels;
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 [labels] = await this.getAll([traceId]);
1331
- return labels ?? null;
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(`${LABELS_PATH}?${query.toString()}`)).labels;
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 (await this.httpClient.get(labelEvidencePath(traceId, assertionId))).evidence;
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 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 labeled.`);
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.labels = new LabelsClient(this.httpClient);
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 import("./http-DdlELWcL.js").then((n) => n.a);
5981
+ const { flushTraces } = await import("./http-D91qP2J-.js").then((n) => n.a);
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 import("./http-DdlELWcL.js").then((n) => n.a);
6169
+ const { flushTraces } = await import("./http-D91qP2J-.js").then((n) => n.a);
6102
6170
  await flushTraces(3e4);
6103
6171
  return {
6104
6172
  pipeline,
@@ -6113,6 +6181,6 @@ function resolveTraceFunctionKey(registration) {
6113
6181
  return key;
6114
6182
  }
6115
6183
  //#endregion
6116
- export { SUPPORTED_PROVIDERS as A, BitfabOpenAIAgentHandler as C, LabelsClient as D, BitfabLangGraphCallbackHandler as E, DEFAULT_SERVICE_URL as F, AssertionCategoriesClient as I, CategoriesClient as L, GraderRerunError as M, GraderRerunTimeoutError as N, GradersClient as O, BitfabClaudeAgentHandler as P, OrganizationMembersClient as S, BitfabLangGraphIntegration as T, BITFAB_PROGRESS_PREFIX as _, Bitfab as a, reportReplayProgress as b, getCurrentSpan as c, BitfabOpenAITracingProcessor as d, AssertionGenerationError as f, BitfabRivetIntegration as g, SpansClient as h, finalizers as i, DatasetsClient as j, ExperimentsClient as k, getCurrentTrace as l, TracesClient as m, reseedFromRegistry as n, BitfabFunction as o, AssertionGenerationTimeoutError as p, seedFromRegistry as r, getCurrentReplayBranch as s, defineReplayRegistry as t, BitfabVercelAiHandler as u, DbBranchReplayError as v, NO_MOCK_OVERRIDE as w, serializeReplayResult as x, ReplayError as y };
6184
+ export { ExperimentsClient as A, BitfabOpenAIAgentHandler as C, GradersClient as D, BitfabLangGraphCallbackHandler as E, BitfabClaudeAgentHandler as F, DEFAULT_SERVICE_URL as I, AssertionCategoriesClient as L, DatasetsClient as M, GraderRerunError as N, LabelsClient as O, GraderRerunTimeoutError as P, CategoriesClient as R, OrganizationMembersClient as S, BitfabLangGraphIntegration as T, BITFAB_PROGRESS_PREFIX as _, Bitfab as a, reportReplayProgress as b, getCurrentSpan as c, BitfabOpenAITracingProcessor as d, AssertionGenerationError as f, BitfabRivetIntegration as g, SpansClient as h, finalizers as i, SUPPORTED_PROVIDERS as j, VerdictsClient as k, getCurrentTrace as l, TracesClient as m, reseedFromRegistry as n, BitfabFunction as o, AssertionGenerationTimeoutError as p, seedFromRegistry as r, getCurrentReplayBranch as s, defineReplayRegistry as t, BitfabVercelAiHandler as u, DbBranchReplayError as v, NO_MOCK_OVERRIDE as w, serializeReplayResult as x, ReplayError as y };
6117
6185
 
6118
- //# sourceMappingURL=src-lTOsAt47.js.map
6186
+ //# sourceMappingURL=src-CL5eQlNk.js.map