bitfab 0.13.6 → 0.13.8

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. */
@@ -1010,7 +990,7 @@ declare class BitfabFunction {
1010
990
  /**
1011
991
  * SDK version from package.json (injected at build time)
1012
992
  */
1013
- declare const __version__ = "0.13.6";
993
+ declare const __version__ = "0.13.8";
1014
994
 
1015
995
  /**
1016
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. */
@@ -1010,7 +990,7 @@ declare class BitfabFunction {
1010
990
  /**
1011
991
  * SDK version from package.json (injected at build time)
1012
992
  */
1013
- declare const __version__ = "0.13.6";
993
+ declare const __version__ = "0.13.8";
1014
994
 
1015
995
  /**
1016
996
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -17,13 +17,13 @@ import {
17
17
  SUPPORTED_PROVIDERS,
18
18
  getCurrentSpan,
19
19
  getCurrentTrace
20
- } from "./chunk-6757PVPS.js";
20
+ } from "./chunk-4ANYHNQJ.js";
21
21
  import {
22
22
  BitfabError,
23
23
  DEFAULT_SERVICE_URL,
24
24
  __version__,
25
25
  flushTraces
26
- } from "./chunk-TMSVIA5J.js";
26
+ } from "./chunk-VFGUZWAV.js";
27
27
  export {
28
28
  Bitfab,
29
29
  BitfabClaudeAgentHandler,
package/dist/node.cjs CHANGED
@@ -90,7 +90,7 @@ var __version__;
90
90
  var init_version_generated = __esm({
91
91
  "src/version.generated.ts"() {
92
92
  "use strict";
93
- __version__ = "0.13.6";
93
+ __version__ = "0.13.8";
94
94
  }
95
95
  });
96
96
 
@@ -197,7 +197,9 @@ var init_http = __esm({
197
197
  )
198
198
  ),
199
199
  rawSpan: {},
200
- errors: [{ step: "json_serialize", error: serializationError }]
200
+ errors: [
201
+ { source: "sdk", step: "json_serialize", error: serializationError }
202
+ ]
201
203
  });
202
204
  }
203
205
  try {
@@ -439,11 +441,11 @@ var init_http = __esm({
439
441
  { timeout: 9e4 }
440
442
  );
441
443
  }
442
- /** Release a previously-resolved DB branch lease. Idempotent server-side. */
443
- async releaseDbBranchLease(leaseId) {
444
+ /** Release a previously-resolved DB branch by deleting its Neon branch. Idempotent server-side. */
445
+ async releaseDbBranchLease(neonBranchId) {
444
446
  await this.request(
445
447
  "/api/sdk/replay/releaseDbBranchLease",
446
- { leaseId },
448
+ { neonBranchId },
447
449
  { timeout: 3e4 }
448
450
  );
449
451
  }
@@ -624,11 +626,11 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
624
626
  } finally {
625
627
  if (lease) {
626
628
  try {
627
- await httpClient.releaseDbBranchLease(lease.leaseId);
629
+ await httpClient.releaseDbBranchLease(lease.neonBranchId);
628
630
  } catch (e) {
629
631
  try {
630
632
  console.warn(
631
- `Bitfab: failed to release DB branch lease ${lease.leaseId} (TTL janitor will catch it): ${e instanceof Error ? e.message : String(e)}`
633
+ `Bitfab: failed to release DB branch ${lease.neonBranchId} (TTL janitor will catch it): ${e instanceof Error ? e.message : String(e)}`
632
634
  );
633
635
  } catch {
634
636
  }
@@ -1521,16 +1523,7 @@ init_constants();
1521
1523
 
1522
1524
  // src/dbSnapshot.ts
1523
1525
  init_errors();
1524
- var SUPPORTED_PROVIDERS = [
1525
- "neon",
1526
- "ardent",
1527
- "dolt",
1528
- "gfs",
1529
- "mongodb-atlas",
1530
- "dynamodb",
1531
- "snowflake",
1532
- "bigquery"
1533
- ];
1526
+ var SUPPORTED_PROVIDERS = ["neon"];
1534
1527
  function validateDbSnapshotConfig(config) {
1535
1528
  if (!SUPPORTED_PROVIDERS.includes(config.provider)) {
1536
1529
  throw new BitfabError(
@@ -2057,14 +2050,6 @@ var ReplayEnvironment = class {
2057
2050
  get traceId() {
2058
2051
  return this.require().traceId;
2059
2052
  }
2060
- /**
2061
- * How the resolver pinned this branch.
2062
- * - "timestamp": snapshot at SDK wall clock; bounded by replication lag.
2063
- * - "lsn": customer LSN mapped to a replica snapshot (future).
2064
- */
2065
- get precision() {
2066
- return this.require().precision;
2067
- }
2068
2053
  /** True when read inside a replay item that has a resolved branch. */
2069
2054
  get active() {
2070
2055
  return this.read() !== null;
@@ -2088,8 +2073,7 @@ var ReplayEnvironment = class {
2088
2073
  expiresAt: lease.expiresAt,
2089
2074
  providerConsoleUrl: lease.providerConsoleUrl,
2090
2075
  readOnly: lease.readOnly,
2091
- traceId,
2092
- precision: lease.precision
2076
+ traceId
2093
2077
  };
2094
2078
  }
2095
2079
  require() {
@@ -2209,6 +2193,7 @@ var BitfabOpenAITracingProcessor = class {
2209
2193
  const jsonResult = span.toJSON();
2210
2194
  if (typeof jsonResult !== "object" || jsonResult === null) {
2211
2195
  errors.push({
2196
+ source: "sdk",
2212
2197
  step: "span.toJSON()",
2213
2198
  error: `Returned unexpected type: ${typeof jsonResult}`
2214
2199
  });
@@ -2218,6 +2203,7 @@ var BitfabOpenAITracingProcessor = class {
2218
2203
  }
2219
2204
  } catch (error) {
2220
2205
  errors.push({
2206
+ source: "sdk",
2221
2207
  step: "span.toJSON()",
2222
2208
  error: error instanceof Error ? error.message : String(error)
2223
2209
  });
@@ -2237,6 +2223,7 @@ var BitfabOpenAITracingProcessor = class {
2237
2223
  spanData.input = span.spanData?._input || [];
2238
2224
  } catch (error) {
2239
2225
  errors.push({
2226
+ source: "sdk",
2240
2227
  step: "access_input",
2241
2228
  error: error instanceof Error ? error.message : String(error)
2242
2229
  });
@@ -2245,6 +2232,7 @@ var BitfabOpenAITracingProcessor = class {
2245
2232
  spanData.response = span.spanData?._response || null;
2246
2233
  } catch (error) {
2247
2234
  errors.push({
2235
+ source: "sdk",
2248
2236
  step: "access_response",
2249
2237
  error: error instanceof Error ? error.message : String(error)
2250
2238
  });
@@ -2941,7 +2929,6 @@ var Bitfab = class {
2941
2929
  try {
2942
2930
  const endedAt = (/* @__PURE__ */ new Date()).toISOString();
2943
2931
  const replayCtx = getReplayContext();
2944
- const dbSnapshotRefForSpan = isRootSpan ? activeTraceStates.get(traceId)?.dbSnapshotRef : void 0;
2945
2932
  const spanPromise = self.sendWrapperSpan({
2946
2933
  ...baseSpanParams,
2947
2934
  ...params,
@@ -2951,9 +2938,6 @@ var Bitfab = class {
2951
2938
  ...replayCtx?.testRunId && { testRunId: replayCtx.testRunId },
2952
2939
  ...replayCtx?.inputSourceSpanId && {
2953
2940
  inputSourceSpanId: replayCtx.inputSourceSpanId
2954
- },
2955
- ...dbSnapshotRefForSpan && {
2956
- dbSnapshotRef: dbSnapshotRefForSpan
2957
2941
  }
2958
2942
  });
2959
2943
  if (isRootSpan) {
@@ -3177,14 +3161,14 @@ var Bitfab = class {
3177
3161
  ...params.functionName !== void 0 && {
3178
3162
  function_name: params.functionName
3179
3163
  },
3180
- ...params.error !== void 0 && { error: params.error },
3164
+ ...params.error !== void 0 && {
3165
+ error: params.error,
3166
+ error_source: "code"
3167
+ },
3181
3168
  ...params.contexts && params.contexts.length > 0 && {
3182
3169
  contexts: params.contexts
3183
3170
  },
3184
- ...params.prompt !== void 0 && { prompt: params.prompt },
3185
- ...params.dbSnapshotRef && {
3186
- db_snapshot_ref: params.dbSnapshotRef
3187
- }
3171
+ ...params.prompt !== void 0 && { prompt: params.prompt }
3188
3172
  }
3189
3173
  };
3190
3174
  if (params.parentSpanId) {