bitfab 0.48.0 → 0.51.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.
@@ -6,7 +6,7 @@ import {
6
6
  flushTraces,
7
7
  parseRetryAfterMs,
8
8
  serializePayloadBody
9
- } from "./chunk-3VHHLXEJ.js";
9
+ } from "./chunk-4Z5FCOMO.js";
10
10
  import "./chunk-H6LZRFMN.js";
11
11
  export {
12
12
  BitfabError,
@@ -17,4 +17,4 @@ export {
17
17
  parseRetryAfterMs,
18
18
  serializePayloadBody
19
19
  };
20
- //# sourceMappingURL=http-42E3SI2N.js.map
20
+ //# sourceMappingURL=http-CS565CIX.js.map
@@ -6,7 +6,7 @@ import {
6
6
  flushTraces,
7
7
  parseRetryAfterMs,
8
8
  serializePayloadBody
9
- } from "./chunk-CPMT6Y43.js";
9
+ } from "./chunk-WBV4YW7X.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-YN67UB3K.js.map
19
+ //# sourceMappingURL=http-RQXNGCUQ.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.48.0";
54
+ __version__ = "0.51.0";
55
55
  __packageName__ = "bitfab";
56
56
  }
57
57
  });
@@ -1856,7 +1856,7 @@ var init_http = __esm({
1856
1856
  * Start a replay session by fetching historical traces.
1857
1857
  * Blocking call - creates a test run and returns lightweight item references.
1858
1858
  */
1859
- async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions) {
1859
+ async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetIds, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions) {
1860
1860
  const payload = { traceFunctionKey };
1861
1861
  if (limit !== void 0) {
1862
1862
  payload.limit = limit;
@@ -1880,8 +1880,12 @@ var init_http = __esm({
1880
1880
  if (experimentGroupId !== void 0) {
1881
1881
  payload.experimentGroupId = experimentGroupId;
1882
1882
  }
1883
- if (datasetId !== void 0) {
1884
- payload.datasetId = datasetId;
1883
+ if (datasetIds !== void 0) {
1884
+ if (datasetIds.length === 1) {
1885
+ payload.datasetId = datasetIds[0];
1886
+ } else {
1887
+ payload.datasetIds = datasetIds;
1888
+ }
1885
1889
  }
1886
1890
  if (graderIds !== void 0) {
1887
1891
  payload.graderIds = graderIds;
@@ -2483,6 +2487,23 @@ function resolveAttempts(attempts) {
2483
2487
  }
2484
2488
  return attempts;
2485
2489
  }
2490
+ function resolveDatasetIds(options) {
2491
+ if (options?.datasetId !== void 0 && options?.datasetIds !== void 0) {
2492
+ throw new BitfabError(
2493
+ "datasetId and datasetIds are the same selector: pass one dataset through datasetId, or several through datasetIds."
2494
+ );
2495
+ }
2496
+ if (options?.datasetId !== void 0) {
2497
+ return [options.datasetId];
2498
+ }
2499
+ if (options?.datasetIds === void 0) {
2500
+ return void 0;
2501
+ }
2502
+ if (options.datasetIds.length === 0) {
2503
+ throw new BitfabError("datasetIds must contain at least one dataset ID.");
2504
+ }
2505
+ return [...new Set(options.datasetIds)];
2506
+ }
2486
2507
  function dbBranchEnabled(dbBranch) {
2487
2508
  return dbBranch !== void 0 && dbBranch !== false;
2488
2509
  }
@@ -2915,9 +2936,10 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2915
2936
  );
2916
2937
  }
2917
2938
  }
2918
- if (options?.traceIds !== void 0 && options?.datasetId !== void 0) {
2939
+ const datasetIds = resolveDatasetIds(options);
2940
+ if (options?.traceIds !== void 0 && datasetIds !== void 0) {
2919
2941
  throw new BitfabError(
2920
- "traceIds and datasetId select different replay sources and cannot be used together."
2942
+ "traceIds and datasetIds select different replay sources and cannot be used together."
2921
2943
  );
2922
2944
  }
2923
2945
  if (options?.limit !== void 0 && options?.traceIds !== void 0) {
@@ -2959,7 +2981,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2959
2981
  // before it could report its resolved inputs.
2960
2982
  dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true,
2961
2983
  options?.experimentGroupId,
2962
- options?.datasetId,
2984
+ datasetIds,
2963
2985
  options?.graderIds,
2964
2986
  resolveDbBranchSettings(options?.dbBranch),
2965
2987
  attempts,
@@ -3281,6 +3303,7 @@ __export(index_exports, {
3281
3303
  DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
3282
3304
  DatasetsClient: () => DatasetsClient,
3283
3305
  DbBranchReplayError: () => DbBranchReplayError,
3306
+ GradersClient: () => GradersClient,
3284
3307
  HttpClient: () => HttpClient,
3285
3308
  LabelsClient: () => LabelsClient,
3286
3309
  MixedTracingError: () => MixedTracingError,
@@ -4576,10 +4599,45 @@ function buildSnapshotRef(config, sdkWallClockBeforeFn) {
4576
4599
 
4577
4600
  // src/client.ts
4578
4601
  init_errors();
4602
+
4603
+ // src/graders.ts
4604
+ init_errors();
4605
+ var GRADER_LABELS_PATH = "/api/sdk/graderLabels";
4606
+ var GradersClient = class {
4607
+ constructor(httpClient) {
4608
+ this.httpClient = httpClient;
4609
+ }
4610
+ async getLabels(params) {
4611
+ const hasTraceIds = params.traceIds !== void 0 && params.traceIds.length > 0;
4612
+ const hasGraderId = params.graderId !== void 0;
4613
+ if (!hasTraceIds && !hasGraderId) {
4614
+ throw new BitfabError(
4615
+ "Pass traceIds, graderId, or both: there is nothing to read otherwise."
4616
+ );
4617
+ }
4618
+ const query = new URLSearchParams();
4619
+ if (params.traceIds !== void 0 && params.traceIds.length > 0) {
4620
+ query.set("traceIds", params.traceIds.join(","));
4621
+ }
4622
+ if (params.graderId !== void 0) {
4623
+ query.set("graderId", params.graderId);
4624
+ }
4625
+ if (params.limit !== void 0) {
4626
+ query.set("limit", String(params.limit));
4627
+ }
4628
+ const response = await this.httpClient.get(
4629
+ `${GRADER_LABELS_PATH}?${query.toString()}`
4630
+ );
4631
+ return response.labels;
4632
+ }
4633
+ };
4634
+
4635
+ // src/client.ts
4579
4636
  init_http();
4580
4637
 
4581
4638
  // src/labels.ts
4582
4639
  var LABELS_PATH = "/api/sdk/traces/labels";
4640
+ var HUMAN_LABELS_PATH = "/api/sdk/traces/labels/human";
4583
4641
  var LabelsClient = class {
4584
4642
  constructor(httpClient) {
4585
4643
  this.httpClient = httpClient;
@@ -4598,6 +4656,28 @@ var LabelsClient = class {
4598
4656
  );
4599
4657
  return response.labels;
4600
4658
  }
4659
+ async saveHuman(update) {
4660
+ const [outcome] = await this.saveHumanAll([update]);
4661
+ return outcome;
4662
+ }
4663
+ async saveHumanAll(updates) {
4664
+ const response = await this.httpClient.request(HUMAN_LABELS_PATH, { labels: updates });
4665
+ return response.labels;
4666
+ }
4667
+ async get(traceId) {
4668
+ const [labels] = await this.getAll([traceId]);
4669
+ return labels ?? null;
4670
+ }
4671
+ async getAll(traceIds) {
4672
+ if (traceIds.length === 0) {
4673
+ return [];
4674
+ }
4675
+ const query = new URLSearchParams({ traceIds: traceIds.join(",") });
4676
+ const response = await this.httpClient.get(
4677
+ `${LABELS_PATH}?${query.toString()}`
4678
+ );
4679
+ return response.labels;
4680
+ }
4601
4681
  };
4602
4682
 
4603
4683
  // src/langgraph.ts
@@ -6375,6 +6455,7 @@ var Bitfab = class {
6375
6455
  this.datasets = new DatasetsClient(this.httpClient);
6376
6456
  this.traces = new TracesClient(this.httpClient);
6377
6457
  this.labels = new LabelsClient(this.httpClient);
6458
+ this.graders = new GradersClient(this.httpClient);
6378
6459
  }
6379
6460
  /**
6380
6461
  * Decorate a class method as an automatically expanded trace root.
@@ -8275,6 +8356,7 @@ function resolveTraceFunctionKey(registration) {
8275
8356
  DEFAULT_SERVICE_URL,
8276
8357
  DatasetsClient,
8277
8358
  DbBranchReplayError,
8359
+ GradersClient,
8278
8360
  HttpClient,
8279
8361
  LabelsClient,
8280
8362
  MixedTracingError,