@bitfab/sdk 0.13.5 → 0.13.7

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
@@ -151,14 +151,8 @@ declare class BitfabClaudeAgentHandler {
151
151
  * `DbSnapshotRef` that pins the DB state at trace open by wall-clock
152
152
  * timestamp. The Bitfab service uses that timestamp at replay time to
153
153
  * materialize an ephemeral branch from `customer-main`.
154
- *
155
- * v0 is timestamp-only. LSN-based pinning is intentionally not exposed
156
- * yet — the customer-LSN to replica-LSN mapping isn't built, so the
157
- * mapping primitive would have no resolver to consume it. The
158
- * `DbSnapshotRef.ref` field is reserved for that future use.
159
154
  */
160
- /** Providers the SDK accepts for `dbSnapshot.provider`. Server-side resolver dispatches on this. */
161
- declare const SUPPORTED_PROVIDERS: readonly ["neon", "ardent", "dolt", "gfs", "mongodb-atlas", "dynamodb", "snowflake", "bigquery"];
155
+ declare const SUPPORTED_PROVIDERS: readonly ["neon"];
162
156
  type DbSnapshotProvider = (typeof SUPPORTED_PROVIDERS)[number];
163
157
  interface DbSnapshotConfig {
164
158
  /** Discriminator for the server-side resolver. */
@@ -168,18 +162,11 @@ interface DbSnapshotRef {
168
162
  provider: DbSnapshotProvider;
169
163
  /**
170
164
  * The wall-clock ISO timestamp the SDK observed immediately before
171
- * invoking the wrapped function. This is the moment used as the
172
- * "snapshot pin" by the timestamp-based resolver path. The name encodes
173
- * its provenance: SDK-observed, wall clock (not monotonic), captured
174
- * before user code began executing — distinct from server-side or
175
- * DB-side timestamps recorded elsewhere on the trace.
165
+ * invoking the wrapped function. The name encodes its provenance:
166
+ * SDK-observed, wall clock (not monotonic), captured before user code
167
+ * began executing.
176
168
  */
177
169
  sdkWallClockBeforeFn: string;
178
- /**
179
- * Reserved for future provider-specific opaque payload (e.g. customer
180
- * LSN once a source-to-replica mapping exists). Unused in v0.
181
- */
182
- ref?: Record<string, unknown>;
183
170
  }
184
171
 
185
172
  /**
@@ -317,7 +304,6 @@ interface ReplayEnvironmentSnapshot {
317
304
  providerConsoleUrl?: string;
318
305
  readOnly?: boolean;
319
306
  traceId: string;
320
- precision: "timestamp" | "lsn";
321
307
  }
322
308
  declare class ReplayEnvironment {
323
309
  /**
@@ -337,12 +323,6 @@ declare class ReplayEnvironment {
337
323
  get readOnly(): boolean | undefined;
338
324
  /** The historical trace ID that produced the input for this replay item. */
339
325
  get traceId(): string;
340
- /**
341
- * How the resolver pinned this branch.
342
- * - "timestamp": snapshot at SDK wall clock; bounded by replication lag.
343
- * - "lsn": customer LSN mapped to a replica snapshot (future).
344
- */
345
- get precision(): "timestamp" | "lsn";
346
326
  /** True when read inside a replay item that has a resolved branch. */
347
327
  get active(): boolean;
348
328
  /** Non-throwing variant for callers that handle the inactive case. */
@@ -394,6 +374,8 @@ interface ReplayOptions {
394
374
  * environment to pick up the per-trace branch URL.
395
375
  */
396
376
  environment?: ReplayEnvironment;
377
+ /** Group ID to associate this replay with an experiment group for live streaming in Studio. */
378
+ experimentGroupId?: string;
397
379
  }
398
380
  interface ReplayItem<T> {
399
381
  /** Trace ID of the new trace created during replay. */
@@ -1008,7 +990,7 @@ declare class BitfabFunction {
1008
990
  /**
1009
991
  * SDK version from package.json (injected at build time)
1010
992
  */
1011
- declare const __version__ = "0.13.5";
993
+ declare const __version__ = "0.13.7";
1012
994
 
1013
995
  /**
1014
996
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -151,14 +151,8 @@ declare class BitfabClaudeAgentHandler {
151
151
  * `DbSnapshotRef` that pins the DB state at trace open by wall-clock
152
152
  * timestamp. The Bitfab service uses that timestamp at replay time to
153
153
  * materialize an ephemeral branch from `customer-main`.
154
- *
155
- * v0 is timestamp-only. LSN-based pinning is intentionally not exposed
156
- * yet — the customer-LSN to replica-LSN mapping isn't built, so the
157
- * mapping primitive would have no resolver to consume it. The
158
- * `DbSnapshotRef.ref` field is reserved for that future use.
159
154
  */
160
- /** Providers the SDK accepts for `dbSnapshot.provider`. Server-side resolver dispatches on this. */
161
- declare const SUPPORTED_PROVIDERS: readonly ["neon", "ardent", "dolt", "gfs", "mongodb-atlas", "dynamodb", "snowflake", "bigquery"];
155
+ declare const SUPPORTED_PROVIDERS: readonly ["neon"];
162
156
  type DbSnapshotProvider = (typeof SUPPORTED_PROVIDERS)[number];
163
157
  interface DbSnapshotConfig {
164
158
  /** Discriminator for the server-side resolver. */
@@ -168,18 +162,11 @@ interface DbSnapshotRef {
168
162
  provider: DbSnapshotProvider;
169
163
  /**
170
164
  * The wall-clock ISO timestamp the SDK observed immediately before
171
- * invoking the wrapped function. This is the moment used as the
172
- * "snapshot pin" by the timestamp-based resolver path. The name encodes
173
- * its provenance: SDK-observed, wall clock (not monotonic), captured
174
- * before user code began executing — distinct from server-side or
175
- * DB-side timestamps recorded elsewhere on the trace.
165
+ * invoking the wrapped function. The name encodes its provenance:
166
+ * SDK-observed, wall clock (not monotonic), captured before user code
167
+ * began executing.
176
168
  */
177
169
  sdkWallClockBeforeFn: string;
178
- /**
179
- * Reserved for future provider-specific opaque payload (e.g. customer
180
- * LSN once a source-to-replica mapping exists). Unused in v0.
181
- */
182
- ref?: Record<string, unknown>;
183
170
  }
184
171
 
185
172
  /**
@@ -317,7 +304,6 @@ interface ReplayEnvironmentSnapshot {
317
304
  providerConsoleUrl?: string;
318
305
  readOnly?: boolean;
319
306
  traceId: string;
320
- precision: "timestamp" | "lsn";
321
307
  }
322
308
  declare class ReplayEnvironment {
323
309
  /**
@@ -337,12 +323,6 @@ declare class ReplayEnvironment {
337
323
  get readOnly(): boolean | undefined;
338
324
  /** The historical trace ID that produced the input for this replay item. */
339
325
  get traceId(): string;
340
- /**
341
- * How the resolver pinned this branch.
342
- * - "timestamp": snapshot at SDK wall clock; bounded by replication lag.
343
- * - "lsn": customer LSN mapped to a replica snapshot (future).
344
- */
345
- get precision(): "timestamp" | "lsn";
346
326
  /** True when read inside a replay item that has a resolved branch. */
347
327
  get active(): boolean;
348
328
  /** Non-throwing variant for callers that handle the inactive case. */
@@ -394,6 +374,8 @@ interface ReplayOptions {
394
374
  * environment to pick up the per-trace branch URL.
395
375
  */
396
376
  environment?: ReplayEnvironment;
377
+ /** Group ID to associate this replay with an experiment group for live streaming in Studio. */
378
+ experimentGroupId?: string;
397
379
  }
398
380
  interface ReplayItem<T> {
399
381
  /** Trace ID of the new trace created during replay. */
@@ -1008,7 +990,7 @@ declare class BitfabFunction {
1008
990
  /**
1009
991
  * SDK version from package.json (injected at build time)
1010
992
  */
1011
- declare const __version__ = "0.13.5";
993
+ declare const __version__ = "0.13.7";
1012
994
 
1013
995
  /**
1014
996
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -8,13 +8,13 @@ import {
8
8
  SUPPORTED_PROVIDERS,
9
9
  getCurrentSpan,
10
10
  getCurrentTrace
11
- } from "./chunk-4IHJJRMU.js";
11
+ } from "./chunk-LUZVIGER.js";
12
12
  import {
13
13
  BitfabError,
14
14
  DEFAULT_SERVICE_URL,
15
15
  __version__,
16
16
  flushTraces
17
- } from "./chunk-BVFST7Q3.js";
17
+ } from "./chunk-EGRWBJYR.js";
18
18
  export {
19
19
  Bitfab,
20
20
  BitfabClaudeAgentHandler,
package/dist/node.cjs CHANGED
@@ -81,7 +81,7 @@ var __version__;
81
81
  var init_version_generated = __esm({
82
82
  "src/version.generated.ts"() {
83
83
  "use strict";
84
- __version__ = "0.13.5";
84
+ __version__ = "0.13.7";
85
85
  }
86
86
  });
87
87
 
@@ -312,7 +312,7 @@ var init_http = __esm({
312
312
  * Start a replay session by fetching historical traces.
313
313
  * Blocking call — creates a test run and returns lightweight item references.
314
314
  */
315
- async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles, includeDbBranchLease) {
315
+ async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId) {
316
316
  const payload = { traceFunctionKey, limit };
317
317
  if (traceIds) {
318
318
  payload.traceIds = traceIds;
@@ -326,6 +326,9 @@ var init_http = __esm({
326
326
  if (includeDbBranchLease) {
327
327
  payload.includeDbBranchLease = true;
328
328
  }
329
+ if (experimentGroupId !== void 0) {
330
+ payload.experimentGroupId = experimentGroupId;
331
+ }
329
332
  const timeout = includeDbBranchLease ? 18e4 : 3e4;
330
333
  return this.request("/api/sdk/replay/start", payload, {
331
334
  timeout
@@ -427,11 +430,11 @@ var init_http = __esm({
427
430
  { timeout: 9e4 }
428
431
  );
429
432
  }
430
- /** Release a previously-resolved DB branch lease. Idempotent server-side. */
431
- async releaseDbBranchLease(leaseId) {
433
+ /** Release a previously-resolved DB branch by deleting its Neon branch. Idempotent server-side. */
434
+ async releaseDbBranchLease(neonBranchId) {
432
435
  await this.request(
433
436
  "/api/sdk/replay/releaseDbBranchLease",
434
- { leaseId },
437
+ { neonBranchId },
435
438
  { timeout: 3e4 }
436
439
  );
437
440
  }
@@ -612,11 +615,11 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
612
615
  } finally {
613
616
  if (lease) {
614
617
  try {
615
- await httpClient.releaseDbBranchLease(lease.leaseId);
618
+ await httpClient.releaseDbBranchLease(lease.neonBranchId);
616
619
  } catch (e) {
617
620
  try {
618
621
  console.warn(
619
- `Bitfab: failed to release DB branch lease ${lease.leaseId} (TTL janitor will catch it): ${e instanceof Error ? e.message : String(e)}`
622
+ `Bitfab: failed to release DB branch ${lease.neonBranchId} (TTL janitor will catch it): ${e instanceof Error ? e.message : String(e)}`
620
623
  );
621
624
  } catch {
622
625
  }
@@ -663,8 +666,9 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
663
666
  options?.traceIds,
664
667
  options?.codeChangeDescription,
665
668
  options?.codeChangeFiles,
666
- options?.environment !== void 0
669
+ options?.environment !== void 0,
667
670
  // includeDbBranchLease
671
+ options?.experimentGroupId
668
672
  );
669
673
  const mockStrategy = options?.mock ?? "none";
670
674
  const maxConcurrency = options?.maxConcurrency ?? 10;
@@ -1508,16 +1512,7 @@ init_constants();
1508
1512
 
1509
1513
  // src/dbSnapshot.ts
1510
1514
  init_errors();
1511
- var SUPPORTED_PROVIDERS = [
1512
- "neon",
1513
- "ardent",
1514
- "dolt",
1515
- "gfs",
1516
- "mongodb-atlas",
1517
- "dynamodb",
1518
- "snowflake",
1519
- "bigquery"
1520
- ];
1515
+ var SUPPORTED_PROVIDERS = ["neon"];
1521
1516
  function validateDbSnapshotConfig(config) {
1522
1517
  if (!SUPPORTED_PROVIDERS.includes(config.provider)) {
1523
1518
  throw new BitfabError(
@@ -2044,14 +2039,6 @@ var ReplayEnvironment = class {
2044
2039
  get traceId() {
2045
2040
  return this.require().traceId;
2046
2041
  }
2047
- /**
2048
- * How the resolver pinned this branch.
2049
- * - "timestamp": snapshot at SDK wall clock; bounded by replication lag.
2050
- * - "lsn": customer LSN mapped to a replica snapshot (future).
2051
- */
2052
- get precision() {
2053
- return this.require().precision;
2054
- }
2055
2042
  /** True when read inside a replay item that has a resolved branch. */
2056
2043
  get active() {
2057
2044
  return this.read() !== null;
@@ -2075,8 +2062,7 @@ var ReplayEnvironment = class {
2075
2062
  expiresAt: lease.expiresAt,
2076
2063
  providerConsoleUrl: lease.providerConsoleUrl,
2077
2064
  readOnly: lease.readOnly,
2078
- traceId,
2079
- precision: lease.precision
2065
+ traceId
2080
2066
  };
2081
2067
  }
2082
2068
  require() {
@@ -2928,7 +2914,6 @@ var Bitfab = class {
2928
2914
  try {
2929
2915
  const endedAt = (/* @__PURE__ */ new Date()).toISOString();
2930
2916
  const replayCtx = getReplayContext();
2931
- const dbSnapshotRefForSpan = isRootSpan ? activeTraceStates.get(traceId)?.dbSnapshotRef : void 0;
2932
2917
  const spanPromise = self.sendWrapperSpan({
2933
2918
  ...baseSpanParams,
2934
2919
  ...params,
@@ -2938,9 +2923,6 @@ var Bitfab = class {
2938
2923
  ...replayCtx?.testRunId && { testRunId: replayCtx.testRunId },
2939
2924
  ...replayCtx?.inputSourceSpanId && {
2940
2925
  inputSourceSpanId: replayCtx.inputSourceSpanId
2941
- },
2942
- ...dbSnapshotRefForSpan && {
2943
- dbSnapshotRef: dbSnapshotRefForSpan
2944
2926
  }
2945
2927
  });
2946
2928
  if (isRootSpan) {
@@ -3168,10 +3150,7 @@ var Bitfab = class {
3168
3150
  ...params.contexts && params.contexts.length > 0 && {
3169
3151
  contexts: params.contexts
3170
3152
  },
3171
- ...params.prompt !== void 0 && { prompt: params.prompt },
3172
- ...params.dbSnapshotRef && {
3173
- db_snapshot_ref: params.dbSnapshotRef
3174
- }
3153
+ ...params.prompt !== void 0 && { prompt: params.prompt }
3175
3154
  }
3176
3155
  };
3177
3156
  if (params.parentSpanId) {