@bitfab/sdk 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-I6MWT34L.js";
9
+ } from "./chunk-4CLJF2DZ.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-CGTUTKK3.js.map
19
+ //# sourceMappingURL=http-AKFJONE7.js.map
@@ -6,7 +6,7 @@ import {
6
6
  flushTraces,
7
7
  parseRetryAfterMs,
8
8
  serializePayloadBody
9
- } from "./chunk-OKSCUFJ6.js";
9
+ } from "./chunk-RGC7IEOI.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-MO5ZRPA6.js.map
20
+ //# sourceMappingURL=http-HLRWCSFF.js.map
package/dist/index.cjs CHANGED
@@ -42,7 +42,7 @@ var __version__, __packageName__;
42
42
  var init_version_generated = __esm({
43
43
  "src/version.generated.ts"() {
44
44
  "use strict";
45
- __version__ = "0.48.0";
45
+ __version__ = "0.51.0";
46
46
  __packageName__ = "@bitfab/sdk";
47
47
  }
48
48
  });
@@ -1847,7 +1847,7 @@ var init_http = __esm({
1847
1847
  * Start a replay session by fetching historical traces.
1848
1848
  * Blocking call - creates a test run and returns lightweight item references.
1849
1849
  */
1850
- async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions) {
1850
+ async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetIds, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions) {
1851
1851
  const payload = { traceFunctionKey };
1852
1852
  if (limit !== void 0) {
1853
1853
  payload.limit = limit;
@@ -1871,8 +1871,12 @@ var init_http = __esm({
1871
1871
  if (experimentGroupId !== void 0) {
1872
1872
  payload.experimentGroupId = experimentGroupId;
1873
1873
  }
1874
- if (datasetId !== void 0) {
1875
- payload.datasetId = datasetId;
1874
+ if (datasetIds !== void 0) {
1875
+ if (datasetIds.length === 1) {
1876
+ payload.datasetId = datasetIds[0];
1877
+ } else {
1878
+ payload.datasetIds = datasetIds;
1879
+ }
1876
1880
  }
1877
1881
  if (graderIds !== void 0) {
1878
1882
  payload.graderIds = graderIds;
@@ -2474,6 +2478,23 @@ function resolveAttempts(attempts) {
2474
2478
  }
2475
2479
  return attempts;
2476
2480
  }
2481
+ function resolveDatasetIds(options) {
2482
+ if (options?.datasetId !== void 0 && options?.datasetIds !== void 0) {
2483
+ throw new BitfabError(
2484
+ "datasetId and datasetIds are the same selector: pass one dataset through datasetId, or several through datasetIds."
2485
+ );
2486
+ }
2487
+ if (options?.datasetId !== void 0) {
2488
+ return [options.datasetId];
2489
+ }
2490
+ if (options?.datasetIds === void 0) {
2491
+ return void 0;
2492
+ }
2493
+ if (options.datasetIds.length === 0) {
2494
+ throw new BitfabError("datasetIds must contain at least one dataset ID.");
2495
+ }
2496
+ return [...new Set(options.datasetIds)];
2497
+ }
2477
2498
  function dbBranchEnabled(dbBranch) {
2478
2499
  return dbBranch !== void 0 && dbBranch !== false;
2479
2500
  }
@@ -2906,9 +2927,10 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2906
2927
  );
2907
2928
  }
2908
2929
  }
2909
- if (options?.traceIds !== void 0 && options?.datasetId !== void 0) {
2930
+ const datasetIds = resolveDatasetIds(options);
2931
+ if (options?.traceIds !== void 0 && datasetIds !== void 0) {
2910
2932
  throw new BitfabError(
2911
- "traceIds and datasetId select different replay sources and cannot be used together."
2933
+ "traceIds and datasetIds select different replay sources and cannot be used together."
2912
2934
  );
2913
2935
  }
2914
2936
  if (options?.limit !== void 0 && options?.traceIds !== void 0) {
@@ -2950,7 +2972,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2950
2972
  // before it could report its resolved inputs.
2951
2973
  dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true,
2952
2974
  options?.experimentGroupId,
2953
- options?.datasetId,
2975
+ datasetIds,
2954
2976
  options?.graderIds,
2955
2977
  resolveDbBranchSettings(options?.dbBranch),
2956
2978
  attempts,
@@ -3272,6 +3294,7 @@ __export(index_exports, {
3272
3294
  DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
3273
3295
  DatasetsClient: () => DatasetsClient,
3274
3296
  DbBranchReplayError: () => DbBranchReplayError,
3297
+ GradersClient: () => GradersClient,
3275
3298
  HttpClient: () => HttpClient,
3276
3299
  LabelsClient: () => LabelsClient,
3277
3300
  MixedTracingError: () => MixedTracingError,
@@ -4567,10 +4590,45 @@ function buildSnapshotRef(config, sdkWallClockBeforeFn) {
4567
4590
 
4568
4591
  // src/client.ts
4569
4592
  init_errors();
4593
+
4594
+ // src/graders.ts
4595
+ init_errors();
4596
+ var GRADER_LABELS_PATH = "/api/sdk/graderLabels";
4597
+ var GradersClient = class {
4598
+ constructor(httpClient) {
4599
+ this.httpClient = httpClient;
4600
+ }
4601
+ async getLabels(params) {
4602
+ const hasTraceIds = params.traceIds !== void 0 && params.traceIds.length > 0;
4603
+ const hasGraderId = params.graderId !== void 0;
4604
+ if (!hasTraceIds && !hasGraderId) {
4605
+ throw new BitfabError(
4606
+ "Pass traceIds, graderId, or both: there is nothing to read otherwise."
4607
+ );
4608
+ }
4609
+ const query = new URLSearchParams();
4610
+ if (params.traceIds !== void 0 && params.traceIds.length > 0) {
4611
+ query.set("traceIds", params.traceIds.join(","));
4612
+ }
4613
+ if (params.graderId !== void 0) {
4614
+ query.set("graderId", params.graderId);
4615
+ }
4616
+ if (params.limit !== void 0) {
4617
+ query.set("limit", String(params.limit));
4618
+ }
4619
+ const response = await this.httpClient.get(
4620
+ `${GRADER_LABELS_PATH}?${query.toString()}`
4621
+ );
4622
+ return response.labels;
4623
+ }
4624
+ };
4625
+
4626
+ // src/client.ts
4570
4627
  init_http();
4571
4628
 
4572
4629
  // src/labels.ts
4573
4630
  var LABELS_PATH = "/api/sdk/traces/labels";
4631
+ var HUMAN_LABELS_PATH = "/api/sdk/traces/labels/human";
4574
4632
  var LabelsClient = class {
4575
4633
  constructor(httpClient) {
4576
4634
  this.httpClient = httpClient;
@@ -4589,6 +4647,28 @@ var LabelsClient = class {
4589
4647
  );
4590
4648
  return response.labels;
4591
4649
  }
4650
+ async saveHuman(update) {
4651
+ const [outcome] = await this.saveHumanAll([update]);
4652
+ return outcome;
4653
+ }
4654
+ async saveHumanAll(updates) {
4655
+ const response = await this.httpClient.request(HUMAN_LABELS_PATH, { labels: updates });
4656
+ return response.labels;
4657
+ }
4658
+ async get(traceId) {
4659
+ const [labels] = await this.getAll([traceId]);
4660
+ return labels ?? null;
4661
+ }
4662
+ async getAll(traceIds) {
4663
+ if (traceIds.length === 0) {
4664
+ return [];
4665
+ }
4666
+ const query = new URLSearchParams({ traceIds: traceIds.join(",") });
4667
+ const response = await this.httpClient.get(
4668
+ `${LABELS_PATH}?${query.toString()}`
4669
+ );
4670
+ return response.labels;
4671
+ }
4592
4672
  };
4593
4673
 
4594
4674
  // src/langgraph.ts
@@ -6366,6 +6446,7 @@ var Bitfab = class {
6366
6446
  this.datasets = new DatasetsClient(this.httpClient);
6367
6447
  this.traces = new TracesClient(this.httpClient);
6368
6448
  this.labels = new LabelsClient(this.httpClient);
6449
+ this.graders = new GradersClient(this.httpClient);
6369
6450
  }
6370
6451
  /**
6371
6452
  * Decorate a class method as an automatically expanded trace root.
@@ -8266,6 +8347,7 @@ function resolveTraceFunctionKey(registration) {
8266
8347
  DEFAULT_SERVICE_URL,
8267
8348
  DatasetsClient,
8268
8349
  DbBranchReplayError,
8350
+ GradersClient,
8269
8351
  HttpClient,
8270
8352
  LabelsClient,
8271
8353
  MixedTracingError,