@bitfab/sdk 0.64.19 → 0.64.21

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.
Files changed (37) hide show
  1. package/cloudReplay.py +202 -3
  2. package/dist/{chunk-BWPW6I3Z.js → chunk-2NO2LENJ.js} +2 -2
  3. package/dist/{chunk-LMQMTWKS.js → chunk-EPUDNPB4.js} +4 -4
  4. package/dist/chunk-EPUDNPB4.js.map +1 -0
  5. package/dist/{chunk-THOWQGGK.js → chunk-GOUY4654.js} +62 -22
  6. package/dist/chunk-GOUY4654.js.map +1 -0
  7. package/dist/{chunk-2S6LDAYM.js → chunk-K2JJOHUJ.js} +17 -3
  8. package/dist/{chunk-2S6LDAYM.js.map → chunk-K2JJOHUJ.js.map} +1 -1
  9. package/dist/{chunk-XA5VTEAE.js → chunk-KB22OETK.js} +2 -2
  10. package/dist/{chunk-UIKFZWVQ.js → chunk-XNETXRNK.js} +17 -3
  11. package/dist/{chunk-UIKFZWVQ.js.map → chunk-XNETXRNK.js.map} +1 -1
  12. package/dist/{http-A64VT2NH.js → http-OS6BKRZL.js} +4 -2
  13. package/dist/{http-MAYDYAUH.js → http-R5ZXASMI.js} +4 -2
  14. package/dist/index.cjs +76 -19
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +73 -14
  17. package/dist/index.d.ts +73 -14
  18. package/dist/index.js +5 -3
  19. package/dist/node.cjs +76 -19
  20. package/dist/node.cjs.map +1 -1
  21. package/dist/node.d.cts +1 -1
  22. package/dist/node.d.ts +1 -1
  23. package/dist/node.js +5 -3
  24. package/dist/node.js.map +1 -1
  25. package/dist/{replay-RWZSRTHU.js → replay-PTPAO3KN.js} +3 -3
  26. package/dist/{replay-XO46T56C.js → replay-T4S4WIN5.js} +3 -3
  27. package/dist/replayCli.js +3 -3
  28. package/dist/seedCli.js +3 -3
  29. package/package.json +1 -1
  30. package/dist/chunk-LMQMTWKS.js.map +0 -1
  31. package/dist/chunk-THOWQGGK.js.map +0 -1
  32. /package/dist/{chunk-BWPW6I3Z.js.map → chunk-2NO2LENJ.js.map} +0 -0
  33. /package/dist/{chunk-XA5VTEAE.js.map → chunk-KB22OETK.js.map} +0 -0
  34. /package/dist/{http-A64VT2NH.js.map → http-OS6BKRZL.js.map} +0 -0
  35. /package/dist/{http-MAYDYAUH.js.map → http-R5ZXASMI.js.map} +0 -0
  36. /package/dist/{replay-RWZSRTHU.js.map → replay-PTPAO3KN.js.map} +0 -0
  37. /package/dist/{replay-XO46T56C.js.map → replay-T4S4WIN5.js.map} +0 -0
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  BitfabError,
3
3
  HttpClient,
4
+ SPAN_TYPES,
4
5
  awaitOnExit,
5
6
  awaitPendingRequests,
6
7
  experimentIdWireFields,
7
8
  flushTraces,
8
9
  parseRetryAfterMs,
9
10
  serializePayloadBody
10
- } from "./chunk-2S6LDAYM.js";
11
+ } from "./chunk-K2JJOHUJ.js";
11
12
  export {
12
13
  BitfabError,
13
14
  HttpClient,
15
+ SPAN_TYPES,
14
16
  awaitOnExit,
15
17
  awaitPendingRequests,
16
18
  experimentIdWireFields,
@@ -18,4 +20,4 @@ export {
18
20
  parseRetryAfterMs,
19
21
  serializePayloadBody
20
22
  };
21
- //# sourceMappingURL=http-A64VT2NH.js.map
23
+ //# sourceMappingURL=http-OS6BKRZL.js.map
@@ -1,17 +1,19 @@
1
1
  import {
2
2
  BitfabError,
3
3
  HttpClient,
4
+ SPAN_TYPES,
4
5
  awaitOnExit,
5
6
  awaitPendingRequests,
6
7
  experimentIdWireFields,
7
8
  flushTraces,
8
9
  parseRetryAfterMs,
9
10
  serializePayloadBody
10
- } from "./chunk-UIKFZWVQ.js";
11
+ } from "./chunk-XNETXRNK.js";
11
12
  import "./chunk-MT36GJMW.js";
12
13
  export {
13
14
  BitfabError,
14
15
  HttpClient,
16
+ SPAN_TYPES,
15
17
  awaitOnExit,
16
18
  awaitPendingRequests,
17
19
  experimentIdWireFields,
@@ -19,4 +21,4 @@ export {
19
21
  parseRetryAfterMs,
20
22
  serializePayloadBody
21
23
  };
22
- //# sourceMappingURL=http-MAYDYAUH.js.map
24
+ //# sourceMappingURL=http-R5ZXASMI.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.64.19";
45
+ __version__ = "0.64.21";
46
46
  __packageName__ = "@bitfab/sdk";
47
47
  }
48
48
  });
@@ -2114,6 +2114,7 @@ var http_exports = {};
2114
2114
  __export(http_exports, {
2115
2115
  BitfabError: () => BitfabError,
2116
2116
  HttpClient: () => HttpClient,
2117
+ SPAN_TYPES: () => SPAN_TYPES,
2117
2118
  awaitOnExit: () => awaitOnExit,
2118
2119
  awaitPendingRequests: () => awaitPendingRequests,
2119
2120
  experimentIdWireFields: () => experimentIdWireFields,
@@ -2288,7 +2289,7 @@ function warnDroppedExternalTrace(error) {
2288
2289
  function experimentIdWireFields(experimentId) {
2289
2290
  return { experimentId, testRunId: experimentId };
2290
2291
  }
2291
- var REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS, REPLAY_COMPLETE_REQUEST_TIMEOUT_MS, REPLAY_INTERRUPT_REQUEST_TIMEOUT_MS, REPLAY_HEARTBEAT_REQUEST_TIMEOUT_MS, OTLP_TRACES_ENDPOINT, RETRYABLE_STATUSES, EXIT_FLUSH_TIMEOUT_MS, DEFAULT_LIFECYCLE_TIMEOUT_MS2, pendingTracePromises, liveHttpClients, carrierSeq, HttpClient;
2292
+ var REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS, REPLAY_COMPLETE_REQUEST_TIMEOUT_MS, REPLAY_INTERRUPT_REQUEST_TIMEOUT_MS, REPLAY_HEARTBEAT_REQUEST_TIMEOUT_MS, OTLP_TRACES_ENDPOINT, RETRYABLE_STATUSES, EXIT_FLUSH_TIMEOUT_MS, DEFAULT_LIFECYCLE_TIMEOUT_MS2, pendingTracePromises, liveHttpClients, SPAN_TYPES, carrierSeq, HttpClient;
2292
2293
  var init_http = __esm({
2293
2294
  "src/http.ts"() {
2294
2295
  "use strict";
@@ -2346,6 +2347,14 @@ var init_http = __esm({
2346
2347
  });
2347
2348
  });
2348
2349
  }
2350
+ SPAN_TYPES = [
2351
+ "llm",
2352
+ "agent",
2353
+ "function",
2354
+ "guardrail",
2355
+ "handoff",
2356
+ "custom"
2357
+ ];
2349
2358
  carrierSeq = 0;
2350
2359
  HttpClient = class {
2351
2360
  constructor(config) {
@@ -2730,7 +2739,12 @@ var init_http = __esm({
2730
2739
  if (lookup.id !== void 0) {
2731
2740
  searchParams.set("id", lookup.id);
2732
2741
  } else {
2733
- searchParams.set("name", lookup.name);
2742
+ if (lookup.name !== void 0) {
2743
+ searchParams.set("name", lookup.name);
2744
+ }
2745
+ if (lookup.type !== void 0) {
2746
+ searchParams.set("type", lookup.type);
2747
+ }
2734
2748
  searchParams.set("occurrence", String(lookup.occurrence ?? "last"));
2735
2749
  }
2736
2750
  const endpoint = `/api/sdk/traces/${encodeURIComponent(traceId)}/span?${searchParams.toString()}`;
@@ -5357,6 +5371,7 @@ __export(index_exports, {
5357
5371
  OrganizationMembersClient: () => OrganizationMembersClient,
5358
5372
  ReplayError: () => ReplayError,
5359
5373
  SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
5374
+ SpansClient: () => SpansClient,
5360
5375
  TracesClient: () => TracesClient,
5361
5376
  __version__: () => __version__,
5362
5377
  defineReplayRegistry: () => defineReplayRegistry,
@@ -6509,6 +6524,20 @@ async function runFunctionWithBaml(bamlSource, inputs, providers, envVars) {
6509
6524
  };
6510
6525
  }
6511
6526
 
6527
+ // src/bitfabIds.ts
6528
+ init_errors();
6529
+ var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6530
+ function validateTraceId(traceId) {
6531
+ if (typeof traceId !== "string" || !UUID_PATTERN.test(traceId)) {
6532
+ throw new BitfabError("traceId must be a valid Bitfab trace ID");
6533
+ }
6534
+ }
6535
+ function validateSpanId(id) {
6536
+ if (typeof id !== "string" || !UUID_PATTERN.test(id)) {
6537
+ throw new BitfabError("id must be a valid Bitfab span ID");
6538
+ }
6539
+ }
6540
+
6512
6541
  // src/client.ts
6513
6542
  init_captureSuppression();
6514
6543
 
@@ -8881,6 +8910,35 @@ function runWithSeedContext(ctx, fn) {
8881
8910
  init_serialize();
8882
8911
  init_simulationPlan();
8883
8912
  init_spanOrigin();
8913
+
8914
+ // src/spans.ts
8915
+ var LIST_PATH = "/api/sdk/spans/list";
8916
+ function withoutUndefined(params) {
8917
+ return Object.fromEntries(
8918
+ Object.entries(params).filter(([, value]) => value !== void 0)
8919
+ );
8920
+ }
8921
+ var SpansClient = class {
8922
+ constructor(httpClient) {
8923
+ this.httpClient = httpClient;
8924
+ }
8925
+ /**
8926
+ * List one trace's spans in the order they ran, one page at a time. No
8927
+ * filter is required: omit `spanType` and `spanName` to page through every
8928
+ * span. Each span carries one extra key per requested `fields` entry. Pass
8929
+ * the returned `nextCursor` back as `cursor` for the next page. Throws a
8930
+ * `BitfabError` with status 404 when the trace is not in your organization.
8931
+ */
8932
+ async list(traceId, params = {}) {
8933
+ validateTraceId(traceId);
8934
+ return this.httpClient.request(
8935
+ LIST_PATH,
8936
+ withoutUndefined({ traceId, ...params })
8937
+ );
8938
+ }
8939
+ };
8940
+
8941
+ // src/client.ts
8884
8942
  init_traceMetadata();
8885
8943
 
8886
8944
  // src/traces.ts
@@ -9761,16 +9819,8 @@ function extractContextFromCollector(collector) {
9761
9819
  return null;
9762
9820
  }
9763
9821
  }
9764
- var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
9765
- function validateTraceId(traceId) {
9766
- if (typeof traceId !== "string" || !UUID_PATTERN.test(traceId)) {
9767
- throw new BitfabError("traceId must be a valid Bitfab trace ID");
9768
- }
9769
- }
9770
- function validateSpanId(id) {
9771
- if (typeof id !== "string" || !UUID_PATTERN.test(id)) {
9772
- throw new BitfabError("id must be a valid Bitfab span ID");
9773
- }
9822
+ function isSpanType(value) {
9823
+ return SPAN_TYPES.some((spanType) => spanType === value);
9774
9824
  }
9775
9825
  var noOpSpan = {
9776
9826
  id: "",
@@ -10004,6 +10054,7 @@ var Bitfab = class {
10004
10054
  this.assertionCategories = new AssertionCategoriesClient(this.httpClient);
10005
10055
  this.organizationMembers = new OrganizationMembersClient(this.httpClient);
10006
10056
  this.traces = new TracesClient(this.httpClient);
10057
+ this.spans = new SpansClient(this.httpClient);
10007
10058
  this.labels = new LabelsClient(this.httpClient);
10008
10059
  this.graders = new GradersClient(this.httpClient);
10009
10060
  this.experiments = new ExperimentsClient(this.httpClient);
@@ -11482,22 +11533,27 @@ var Bitfab = class {
11482
11533
  }
11483
11534
  /**
11484
11535
  * Fetch one persisted span from a trace without loading the full trace.
11485
- * Name lookups return the last matching span by default. Pass `occurrence`
11486
- * as `"first"` or a zero-based index to select a different match.
11536
+ * Look up by `id` alone, or by `name` and/or `type` (both must match when
11537
+ * both are given). Name and type lookups return the last matching span by
11538
+ * default. Pass `occurrence` as `"first"` or a zero-based index to select a
11539
+ * different match. Returns `null` when no span matches.
11487
11540
  */
11488
11541
  async getTraceSpan(traceId, lookup) {
11489
11542
  validateTraceId(traceId);
11490
11543
  const hasId = lookup.id !== void 0;
11491
- const hasName = lookup.name !== void 0;
11492
- if (hasId === hasName) {
11493
- throw new BitfabError("Provide exactly one of id or name");
11544
+ const hasNameOrType = lookup.name !== void 0 || lookup.type !== void 0;
11545
+ if (hasId === hasNameOrType) {
11546
+ throw new BitfabError("Provide id, or name and/or type");
11494
11547
  }
11495
11548
  if (hasId) {
11496
11549
  validateSpanId(lookup.id);
11497
11550
  } else {
11498
- if (lookup.name.length === 0) {
11551
+ if (lookup.name !== void 0 && lookup.name.length === 0) {
11499
11552
  throw new BitfabError("name must be a non-empty string");
11500
11553
  }
11554
+ if (lookup.type !== void 0 && !isSpanType(lookup.type)) {
11555
+ throw new BitfabError(`type must be one of ${SPAN_TYPES.join(", ")}`);
11556
+ }
11501
11557
  const occurrence = lookup.occurrence ?? "last";
11502
11558
  if (occurrence !== "first" && occurrence !== "last" && (!Number.isInteger(occurrence) || occurrence < 0)) {
11503
11559
  throw new BitfabError(
@@ -12328,6 +12384,7 @@ function resolveTraceFunctionKey(registration) {
12328
12384
  OrganizationMembersClient,
12329
12385
  ReplayError,
12330
12386
  SUPPORTED_PROVIDERS,
12387
+ SpansClient,
12331
12388
  TracesClient,
12332
12389
  __version__,
12333
12390
  defineReplayRegistry,