@bitfab/sdk 0.31.0 → 0.32.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/index.d.cts CHANGED
@@ -629,6 +629,10 @@ declare class BitfabOpenAIAgentHandler {
629
629
  * `env.databaseUrl` (and friends) to pick up the per-trace branch URL the
630
630
  * Bitfab service resolved from the source trace's snapshot reference.
631
631
  *
632
+ * The constructor takes how each branch should be sized and warmed. That lives
633
+ * here rather than on the replay options because the settings only mean
634
+ * anything for a replay that has an environment.
635
+ *
632
636
  * Outside replay, accessing `env.databaseUrl` throws. Customer code uses
633
637
  * the env only on the replay path; live request code keeps reading
634
638
  * `process.env.DATABASE_URL` the normal way.
@@ -649,7 +653,42 @@ interface ReplayEnvironmentSnapshot {
649
653
  region?: string;
650
654
  traceId: string;
651
655
  }
656
+ /**
657
+ * Per-lease settings for the DB-snapshot branch a replay item runs against.
658
+ * Passed to the `ReplayEnvironment` constructor, since branching only happens
659
+ * for a replay that has an environment.
660
+ */
661
+ interface DbBranchOptions {
662
+ /**
663
+ * Autoscaling floor for the branch's compute, in Neon Compute Units (0.25 to
664
+ * 56). Omit to keep the mirror project's own default. Raise it when the
665
+ * mirror is provisioned smaller than the database it stands in for, so
666
+ * replay latency reflects your code rather than a cold, undersized branch.
667
+ */
668
+ minCu?: number;
669
+ /**
670
+ * Autoscaling ceiling for the branch's compute, in Neon Compute Units.
671
+ * Setting it equal to `minCu` pins the size, which keeps items comparable:
672
+ * otherwise a later item can run against an endpoint that has already
673
+ * scaled up and post a better number for the same code.
674
+ */
675
+ maxCu?: number;
676
+ /**
677
+ * SQL that warms the branch's cache. The server appends it to the branch's
678
+ * readiness check, so it runs BEFORE your function sees the lease and its
679
+ * time is not charged to the replayed call. Invalid SQL fails the lease
680
+ * rather than silently leaving the branch cold.
681
+ */
682
+ warmupSql?: string;
683
+ }
652
684
  declare class ReplayEnvironment {
685
+ /**
686
+ * The branch settings this environment was constructed with, readable
687
+ * anywhere. Every other accessor reports the lease the server resolved and
688
+ * is therefore replay-only.
689
+ */
690
+ readonly dbBranch: DbBranchOptions;
691
+ constructor(options?: DbBranchOptions);
653
692
  /**
654
693
  * The per-trace branch URL for the item currently being replayed.
655
694
  * Throws if read outside a replay item.
@@ -698,33 +737,6 @@ declare class ReplayEnvironment {
698
737
  */
699
738
 
700
739
  type MockStrategy = "none" | "all" | "marked";
701
- /**
702
- * Per-lease settings for the DB-snapshot branch a replay item runs against.
703
- * Only read when `environment` is set, since that is what turns branching on.
704
- */
705
- interface DbBranchOptions {
706
- /**
707
- * Autoscaling floor for the branch's compute, in Neon Compute Units (0.25 to
708
- * 56). Omit to keep the mirror project's own default. Raise it when the
709
- * mirror is provisioned smaller than the database it stands in for, so
710
- * replay latency reflects your code rather than a cold, undersized branch.
711
- */
712
- minCu?: number;
713
- /**
714
- * Autoscaling ceiling for the branch's compute, in Neon Compute Units.
715
- * Setting it equal to `minCu` pins the size, which keeps items comparable:
716
- * otherwise a later item can run against an endpoint that has already
717
- * scaled up and post a better number for the same code.
718
- */
719
- maxCu?: number;
720
- /**
721
- * SQL that warms the branch's cache. The server appends it to the branch's
722
- * readiness check, so it runs BEFORE your function sees the lease and its
723
- * time is not charged to the replayed call. Invalid SQL fails the lease
724
- * rather than silently leaving the branch cold.
725
- */
726
- warmupSql?: string;
727
- }
728
740
  interface ReplayOptions {
729
741
  /**
730
742
  * Maximum number of traces to replay (1-100, default 5). Ignored when
@@ -770,11 +782,10 @@ interface ReplayOptions {
770
782
  * Per-trace environment. When the source trace carries a DB branching
771
783
  * snapshot, the SDK populates `environment.databaseUrl` before invoking
772
784
  * `fn` for that item and resets it after. Customer code reads from the
773
- * environment to pick up the per-trace branch URL.
785
+ * environment to pick up the per-trace branch URL. Compute size and cache
786
+ * warm-up for each branch are configured on the environment's constructor.
774
787
  */
775
788
  environment?: ReplayEnvironment;
776
- /** Compute size and cache warm-up for the per-item DB snapshot branch. */
777
- dbBranch?: DbBranchOptions;
778
789
  /** Group ID to associate this replay with an experiment group for live streaming in Studio. */
779
790
  experimentGroupId?: string;
780
791
  /**
@@ -1843,7 +1854,7 @@ declare class BitfabFunction {
1843
1854
  /**
1844
1855
  * SDK version from package.json (injected at build time)
1845
1856
  */
1846
- declare const __version__ = "0.31.0";
1857
+ declare const __version__ = "0.32.0";
1847
1858
 
1848
1859
  /**
1849
1860
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -629,6 +629,10 @@ declare class BitfabOpenAIAgentHandler {
629
629
  * `env.databaseUrl` (and friends) to pick up the per-trace branch URL the
630
630
  * Bitfab service resolved from the source trace's snapshot reference.
631
631
  *
632
+ * The constructor takes how each branch should be sized and warmed. That lives
633
+ * here rather than on the replay options because the settings only mean
634
+ * anything for a replay that has an environment.
635
+ *
632
636
  * Outside replay, accessing `env.databaseUrl` throws. Customer code uses
633
637
  * the env only on the replay path; live request code keeps reading
634
638
  * `process.env.DATABASE_URL` the normal way.
@@ -649,7 +653,42 @@ interface ReplayEnvironmentSnapshot {
649
653
  region?: string;
650
654
  traceId: string;
651
655
  }
656
+ /**
657
+ * Per-lease settings for the DB-snapshot branch a replay item runs against.
658
+ * Passed to the `ReplayEnvironment` constructor, since branching only happens
659
+ * for a replay that has an environment.
660
+ */
661
+ interface DbBranchOptions {
662
+ /**
663
+ * Autoscaling floor for the branch's compute, in Neon Compute Units (0.25 to
664
+ * 56). Omit to keep the mirror project's own default. Raise it when the
665
+ * mirror is provisioned smaller than the database it stands in for, so
666
+ * replay latency reflects your code rather than a cold, undersized branch.
667
+ */
668
+ minCu?: number;
669
+ /**
670
+ * Autoscaling ceiling for the branch's compute, in Neon Compute Units.
671
+ * Setting it equal to `minCu` pins the size, which keeps items comparable:
672
+ * otherwise a later item can run against an endpoint that has already
673
+ * scaled up and post a better number for the same code.
674
+ */
675
+ maxCu?: number;
676
+ /**
677
+ * SQL that warms the branch's cache. The server appends it to the branch's
678
+ * readiness check, so it runs BEFORE your function sees the lease and its
679
+ * time is not charged to the replayed call. Invalid SQL fails the lease
680
+ * rather than silently leaving the branch cold.
681
+ */
682
+ warmupSql?: string;
683
+ }
652
684
  declare class ReplayEnvironment {
685
+ /**
686
+ * The branch settings this environment was constructed with, readable
687
+ * anywhere. Every other accessor reports the lease the server resolved and
688
+ * is therefore replay-only.
689
+ */
690
+ readonly dbBranch: DbBranchOptions;
691
+ constructor(options?: DbBranchOptions);
653
692
  /**
654
693
  * The per-trace branch URL for the item currently being replayed.
655
694
  * Throws if read outside a replay item.
@@ -698,33 +737,6 @@ declare class ReplayEnvironment {
698
737
  */
699
738
 
700
739
  type MockStrategy = "none" | "all" | "marked";
701
- /**
702
- * Per-lease settings for the DB-snapshot branch a replay item runs against.
703
- * Only read when `environment` is set, since that is what turns branching on.
704
- */
705
- interface DbBranchOptions {
706
- /**
707
- * Autoscaling floor for the branch's compute, in Neon Compute Units (0.25 to
708
- * 56). Omit to keep the mirror project's own default. Raise it when the
709
- * mirror is provisioned smaller than the database it stands in for, so
710
- * replay latency reflects your code rather than a cold, undersized branch.
711
- */
712
- minCu?: number;
713
- /**
714
- * Autoscaling ceiling for the branch's compute, in Neon Compute Units.
715
- * Setting it equal to `minCu` pins the size, which keeps items comparable:
716
- * otherwise a later item can run against an endpoint that has already
717
- * scaled up and post a better number for the same code.
718
- */
719
- maxCu?: number;
720
- /**
721
- * SQL that warms the branch's cache. The server appends it to the branch's
722
- * readiness check, so it runs BEFORE your function sees the lease and its
723
- * time is not charged to the replayed call. Invalid SQL fails the lease
724
- * rather than silently leaving the branch cold.
725
- */
726
- warmupSql?: string;
727
- }
728
740
  interface ReplayOptions {
729
741
  /**
730
742
  * Maximum number of traces to replay (1-100, default 5). Ignored when
@@ -770,11 +782,10 @@ interface ReplayOptions {
770
782
  * Per-trace environment. When the source trace carries a DB branching
771
783
  * snapshot, the SDK populates `environment.databaseUrl` before invoking
772
784
  * `fn` for that item and resets it after. Customer code reads from the
773
- * environment to pick up the per-trace branch URL.
785
+ * environment to pick up the per-trace branch URL. Compute size and cache
786
+ * warm-up for each branch are configured on the environment's constructor.
774
787
  */
775
788
  environment?: ReplayEnvironment;
776
- /** Compute size and cache warm-up for the per-item DB snapshot branch. */
777
- dbBranch?: DbBranchOptions;
778
789
  /** Group ID to associate this replay with an experiment group for live streaming in Studio. */
779
790
  experimentGroupId?: string;
780
791
  /**
@@ -1843,7 +1854,7 @@ declare class BitfabFunction {
1843
1854
  /**
1844
1855
  * SDK version from package.json (injected at build time)
1845
1856
  */
1846
- declare const __version__ = "0.31.0";
1857
+ declare const __version__ = "0.32.0";
1847
1858
 
1848
1859
  /**
1849
1860
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -14,12 +14,12 @@ import {
14
14
  flushTraces,
15
15
  getCurrentSpan,
16
16
  getCurrentTrace
17
- } from "./chunk-A7K5JOBV.js";
17
+ } from "./chunk-YZZO475T.js";
18
18
  import {
19
19
  BITFAB_PROGRESS_PREFIX,
20
20
  BitfabError,
21
21
  reportReplayProgress
22
- } from "./chunk-6UJ3E3H5.js";
22
+ } from "./chunk-NMNVPON4.js";
23
23
  export {
24
24
  BITFAB_PROGRESS_PREFIX,
25
25
  Bitfab,
package/dist/node.cjs CHANGED
@@ -531,14 +531,15 @@ __export(replay_exports, {
531
531
  replay: () => replay,
532
532
  reportReplayProgress: () => reportReplayProgress
533
533
  });
534
- function resolveDbBranchSettings(dbBranch) {
535
- if (!dbBranch) {
534
+ function resolveDbBranchSettings(environment) {
535
+ if (!environment) {
536
536
  return void 0;
537
537
  }
538
+ const { minCu, maxCu, warmupSql } = environment.dbBranch;
538
539
  const settings = {
539
- ...dbBranch.minCu === void 0 ? {} : { minCu: dbBranch.minCu },
540
- ...dbBranch.maxCu === void 0 ? {} : { maxCu: dbBranch.maxCu },
541
- ...dbBranch.warmupSql === void 0 ? {} : { warmupSql: dbBranch.warmupSql }
540
+ ...minCu === void 0 ? {} : { minCu },
541
+ ...maxCu === void 0 ? {} : { maxCu },
542
+ ...warmupSql === void 0 ? {} : { warmupSql }
542
543
  };
543
544
  return Object.keys(settings).length === 0 ? void 0 : settings;
544
545
  }
@@ -792,7 +793,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
792
793
  options?.experimentGroupId,
793
794
  options?.datasetId,
794
795
  options?.graderIds,
795
- resolveDbBranchSettings(options?.dbBranch)
796
+ resolveDbBranchSettings(options?.environment)
796
797
  );
797
798
  const mockStrategy = options?.mock ?? "marked";
798
799
  const maxConcurrency = options?.maxConcurrency ?? 10;
@@ -986,7 +987,7 @@ registerAsyncLocalStorageClass(
986
987
  );
987
988
 
988
989
  // src/version.generated.ts
989
- var __version__ = "0.31.0";
990
+ var __version__ = "0.32.0";
990
991
 
991
992
  // src/constants.ts
992
993
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -3082,6 +3083,9 @@ init_replayContext();
3082
3083
  // src/replayEnvironment.ts
3083
3084
  init_replayContext();
3084
3085
  var ReplayEnvironment = class {
3086
+ constructor(options = {}) {
3087
+ this.dbBranch = { ...options };
3088
+ }
3085
3089
  /**
3086
3090
  * The per-trace branch URL for the item currently being replayed.
3087
3091
  * Throws if read outside a replay item.