bitfab 0.13.3 → 0.13.4
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/{chunk-LOZFAPCS.js → chunk-SKJWF5VX.js} +32 -5
- package/dist/chunk-SKJWF5VX.js.map +1 -0
- package/dist/{chunk-NHYPYRQB.js → chunk-XUW46356.js} +131 -6
- package/dist/chunk-XUW46356.js.map +1 -0
- package/dist/index.cjs +225 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +139 -8
- package/dist/index.d.ts +139 -8
- package/dist/index.js +6 -2
- package/dist/node.cjs +225 -28
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +6 -2
- package/dist/node.js.map +1 -1
- package/dist/{replay-JX33WJUT.js → replay-HGU5YAOK.js} +46 -16
- package/dist/replay-HGU5YAOK.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-LOZFAPCS.js.map +0 -1
- package/dist/chunk-NHYPYRQB.js.map +0 -1
- package/dist/replay-JX33WJUT.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -145,19 +145,61 @@ declare class BitfabClaudeAgentHandler {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
*
|
|
148
|
+
* Per-trace database snapshot ref capture.
|
|
149
149
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
|
|
150
|
+
* When the customer configures `dbSnapshot`, every root span carries a
|
|
151
|
+
* `DbSnapshotRef` that pins the DB state at trace open by wall-clock
|
|
152
|
+
* timestamp. The Bitfab service uses that timestamp at replay time to
|
|
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
|
+
*/
|
|
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"];
|
|
162
|
+
type DbSnapshotProvider = (typeof SUPPORTED_PROVIDERS)[number];
|
|
163
|
+
interface DbSnapshotConfig {
|
|
164
|
+
/** Discriminator for the server-side resolver. */
|
|
165
|
+
provider: DbSnapshotProvider;
|
|
166
|
+
}
|
|
167
|
+
interface DbSnapshotRef {
|
|
168
|
+
provider: DbSnapshotProvider;
|
|
169
|
+
/**
|
|
170
|
+
* 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.
|
|
176
|
+
*/
|
|
177
|
+
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
|
+
}
|
|
184
|
+
|
|
154
185
|
/**
|
|
155
|
-
*
|
|
186
|
+
* Shared error type for Bitfab SDK runtime errors. Lives in its own
|
|
187
|
+
* module to avoid import cycles between `http.ts` and modules that need
|
|
188
|
+
* to throw structured errors (e.g. `dbSnapshot.ts` validation).
|
|
156
189
|
*/
|
|
157
190
|
declare class BitfabError extends Error {
|
|
158
191
|
readonly url?: string | undefined;
|
|
159
192
|
constructor(message: string, url?: string | undefined);
|
|
160
193
|
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* HTTP client utilities for Bitfab API requests.
|
|
197
|
+
*
|
|
198
|
+
* This module provides:
|
|
199
|
+
* - HttpClient class for making API requests
|
|
200
|
+
* - awaitOnExit helper for fire-and-forget operations that must complete before process exit
|
|
201
|
+
*/
|
|
202
|
+
|
|
161
203
|
/**
|
|
162
204
|
* Wait for all pending fire-and-forget operations (spans, traces) to complete.
|
|
163
205
|
* Useful in tests and scripts to ensure all data has been sent before asserting or exiting.
|
|
@@ -249,6 +291,66 @@ declare class BitfabLangGraphCallbackHandler {
|
|
|
249
291
|
handleRetrieverError(error: unknown, runId: string): Promise<void>;
|
|
250
292
|
}
|
|
251
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Per-trace environment exposed to customer code during replay.
|
|
296
|
+
*
|
|
297
|
+
* The customer instantiates one `ReplayEnvironment` and passes it to
|
|
298
|
+
* `bitfab.replay({ environment })`. Inside the replayed function they read
|
|
299
|
+
* `env.databaseUrl` (and friends) to pick up the per-trace branch URL the
|
|
300
|
+
* Bitfab service resolved from the source trace's snapshot reference.
|
|
301
|
+
*
|
|
302
|
+
* Outside replay, accessing `env.databaseUrl` throws. Customer code uses
|
|
303
|
+
* the env only on the replay path; live request code keeps reading
|
|
304
|
+
* `process.env.DATABASE_URL` the normal way.
|
|
305
|
+
*
|
|
306
|
+
* Concurrency-safe: getters resolve through the replay AsyncLocalStorage
|
|
307
|
+
* context, so each in-flight replay item sees its own per-trace values
|
|
308
|
+
* even when the SDK runs items in parallel.
|
|
309
|
+
*
|
|
310
|
+
* Internally, the resolved per-item state is a `DbBranchLease` (see
|
|
311
|
+
* replayContext.ts) — that's the SDK ↔ server protocol term. We expose
|
|
312
|
+
* its useful fields directly here so customer code never sees the word.
|
|
313
|
+
*/
|
|
314
|
+
interface ReplayEnvironmentSnapshot {
|
|
315
|
+
databaseUrl: string;
|
|
316
|
+
expiresAt: string;
|
|
317
|
+
providerConsoleUrl?: string;
|
|
318
|
+
readOnly?: boolean;
|
|
319
|
+
traceId: string;
|
|
320
|
+
precision: "timestamp" | "lsn";
|
|
321
|
+
}
|
|
322
|
+
declare class ReplayEnvironment {
|
|
323
|
+
/**
|
|
324
|
+
* The per-trace branch URL for the item currently being replayed.
|
|
325
|
+
* Throws if read outside a replay item.
|
|
326
|
+
*/
|
|
327
|
+
get databaseUrl(): string;
|
|
328
|
+
/** When the per-trace branch URL stops being valid. ISO-8601. */
|
|
329
|
+
get expiresAt(): string;
|
|
330
|
+
/** Deep link to the branch in the provider console, if available. */
|
|
331
|
+
get providerConsoleUrl(): string | undefined;
|
|
332
|
+
/**
|
|
333
|
+
* True if the branch is read-only. Customer code can use this to skip
|
|
334
|
+
* write operations during replay when the provider returned a read-only
|
|
335
|
+
* lease.
|
|
336
|
+
*/
|
|
337
|
+
get readOnly(): boolean | undefined;
|
|
338
|
+
/** The historical trace ID that produced the input for this replay item. */
|
|
339
|
+
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
|
+
/** True when read inside a replay item that has a resolved branch. */
|
|
347
|
+
get active(): boolean;
|
|
348
|
+
/** Non-throwing variant for callers that handle the inactive case. */
|
|
349
|
+
snapshot(): ReplayEnvironmentSnapshot | null;
|
|
350
|
+
private read;
|
|
351
|
+
private require;
|
|
352
|
+
}
|
|
353
|
+
|
|
252
354
|
/**
|
|
253
355
|
* Replay historical traces through a function and create a test run.
|
|
254
356
|
*
|
|
@@ -285,6 +387,13 @@ interface ReplayOptions {
|
|
|
285
387
|
* - "marked": only spans tagged with { mockOnReplay: true } in SpanOptions are mocked
|
|
286
388
|
*/
|
|
287
389
|
mock?: MockStrategy;
|
|
390
|
+
/**
|
|
391
|
+
* Per-trace environment. When the source trace carries a DB branching
|
|
392
|
+
* snapshot, the SDK populates `environment.databaseUrl` before invoking
|
|
393
|
+
* `fn` for that item and resets it after. Customer code reads from the
|
|
394
|
+
* environment to pick up the per-trace branch URL.
|
|
395
|
+
*/
|
|
396
|
+
environment?: ReplayEnvironment;
|
|
288
397
|
}
|
|
289
398
|
interface ReplayItem<T> {
|
|
290
399
|
/** Deserialized inputs from the original trace. */
|
|
@@ -301,6 +410,13 @@ interface ReplayItem<T> {
|
|
|
301
410
|
tokens: TokenUsage | null;
|
|
302
411
|
/** Model name from the original trace, or null if not captured. */
|
|
303
412
|
model: string | null;
|
|
413
|
+
/**
|
|
414
|
+
* The DB snapshot ref the SDK captured at trace open. Useful for debugging
|
|
415
|
+
* ("what state was this trace pinned to?") and for customers building
|
|
416
|
+
* their own resolvers. Undefined when the source trace was captured
|
|
417
|
+
* without `dbSnapshot` configured.
|
|
418
|
+
*/
|
|
419
|
+
dbSnapshotRef: DbSnapshotRef | null;
|
|
304
420
|
}
|
|
305
421
|
|
|
306
422
|
interface ReplayResult<T> {
|
|
@@ -549,6 +665,13 @@ interface BitfabConfig {
|
|
|
549
665
|
enabled?: boolean;
|
|
550
666
|
/** The generated BAML client instance (e.g., `b` from your baml_client). Used by wrapBAML() when no explicit client is passed. */
|
|
551
667
|
bamlClient?: unknown;
|
|
668
|
+
/**
|
|
669
|
+
* Per-trace database snapshot config. When set, every root span captures
|
|
670
|
+
* a wall-clock timestamp (and, if `captureRef` is provided, a provider-
|
|
671
|
+
* specific point-in-time ref) so the trace can later be replayed against
|
|
672
|
+
* a branch materialized from that point.
|
|
673
|
+
*/
|
|
674
|
+
dbSnapshot?: DbSnapshotConfig;
|
|
552
675
|
}
|
|
553
676
|
/**
|
|
554
677
|
* Span types matching the backend enum.
|
|
@@ -589,6 +712,12 @@ interface SpanOptions {
|
|
|
589
712
|
* Client for making provider-based API calls via BAML.
|
|
590
713
|
*/
|
|
591
714
|
declare class Bitfab {
|
|
715
|
+
/**
|
|
716
|
+
* Per-trace environment for `replay({ environment })`. Construct one,
|
|
717
|
+
* pass it to replay, and read `env.databaseUrl` inside the replayed
|
|
718
|
+
* function to pick up the per-trace branch URL.
|
|
719
|
+
*/
|
|
720
|
+
static readonly ReplayEnvironment: typeof ReplayEnvironment;
|
|
592
721
|
private readonly apiKey;
|
|
593
722
|
private readonly serviceUrl;
|
|
594
723
|
private readonly timeout;
|
|
@@ -596,6 +725,7 @@ declare class Bitfab {
|
|
|
596
725
|
private readonly enabled;
|
|
597
726
|
private readonly httpClient;
|
|
598
727
|
private readonly bamlClient;
|
|
728
|
+
private readonly dbSnapshot;
|
|
599
729
|
/**
|
|
600
730
|
* Initialize the Bitfab client.
|
|
601
731
|
*
|
|
@@ -812,6 +942,7 @@ declare class Bitfab {
|
|
|
812
942
|
codeChangeDescription?: string;
|
|
813
943
|
codeChangeFiles?: CodeChangeFile[];
|
|
814
944
|
mock?: "none" | "all" | "marked";
|
|
945
|
+
environment?: ReplayEnvironment;
|
|
815
946
|
}): Promise<ReplayResult<TReturn>>;
|
|
816
947
|
}
|
|
817
948
|
/**
|
|
@@ -875,7 +1006,7 @@ declare class BitfabFunction {
|
|
|
875
1006
|
/**
|
|
876
1007
|
* SDK version from package.json (injected at build time)
|
|
877
1008
|
*/
|
|
878
|
-
declare const __version__ = "0.13.
|
|
1009
|
+
declare const __version__ = "0.13.4";
|
|
879
1010
|
|
|
880
1011
|
/**
|
|
881
1012
|
* Constants for the Bitfab SDK.
|
|
@@ -885,4 +1016,4 @@ declare const __version__ = "0.13.3";
|
|
|
885
1016
|
*/
|
|
886
1017
|
declare const DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
887
1018
|
|
|
888
|
-
export { type ActiveSpanContext, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DetachedTrace, type MockStrategy, type ProviderDefinition, type ReplayItem, type ReplayOptions, type ReplayResult, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
|
|
1019
|
+
export { type ActiveSpanContext, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
|
package/dist/index.d.ts
CHANGED
|
@@ -145,19 +145,61 @@ declare class BitfabClaudeAgentHandler {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
*
|
|
148
|
+
* Per-trace database snapshot ref capture.
|
|
149
149
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
|
|
150
|
+
* When the customer configures `dbSnapshot`, every root span carries a
|
|
151
|
+
* `DbSnapshotRef` that pins the DB state at trace open by wall-clock
|
|
152
|
+
* timestamp. The Bitfab service uses that timestamp at replay time to
|
|
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
|
+
*/
|
|
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"];
|
|
162
|
+
type DbSnapshotProvider = (typeof SUPPORTED_PROVIDERS)[number];
|
|
163
|
+
interface DbSnapshotConfig {
|
|
164
|
+
/** Discriminator for the server-side resolver. */
|
|
165
|
+
provider: DbSnapshotProvider;
|
|
166
|
+
}
|
|
167
|
+
interface DbSnapshotRef {
|
|
168
|
+
provider: DbSnapshotProvider;
|
|
169
|
+
/**
|
|
170
|
+
* 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.
|
|
176
|
+
*/
|
|
177
|
+
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
|
+
}
|
|
184
|
+
|
|
154
185
|
/**
|
|
155
|
-
*
|
|
186
|
+
* Shared error type for Bitfab SDK runtime errors. Lives in its own
|
|
187
|
+
* module to avoid import cycles between `http.ts` and modules that need
|
|
188
|
+
* to throw structured errors (e.g. `dbSnapshot.ts` validation).
|
|
156
189
|
*/
|
|
157
190
|
declare class BitfabError extends Error {
|
|
158
191
|
readonly url?: string | undefined;
|
|
159
192
|
constructor(message: string, url?: string | undefined);
|
|
160
193
|
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* HTTP client utilities for Bitfab API requests.
|
|
197
|
+
*
|
|
198
|
+
* This module provides:
|
|
199
|
+
* - HttpClient class for making API requests
|
|
200
|
+
* - awaitOnExit helper for fire-and-forget operations that must complete before process exit
|
|
201
|
+
*/
|
|
202
|
+
|
|
161
203
|
/**
|
|
162
204
|
* Wait for all pending fire-and-forget operations (spans, traces) to complete.
|
|
163
205
|
* Useful in tests and scripts to ensure all data has been sent before asserting or exiting.
|
|
@@ -249,6 +291,66 @@ declare class BitfabLangGraphCallbackHandler {
|
|
|
249
291
|
handleRetrieverError(error: unknown, runId: string): Promise<void>;
|
|
250
292
|
}
|
|
251
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Per-trace environment exposed to customer code during replay.
|
|
296
|
+
*
|
|
297
|
+
* The customer instantiates one `ReplayEnvironment` and passes it to
|
|
298
|
+
* `bitfab.replay({ environment })`. Inside the replayed function they read
|
|
299
|
+
* `env.databaseUrl` (and friends) to pick up the per-trace branch URL the
|
|
300
|
+
* Bitfab service resolved from the source trace's snapshot reference.
|
|
301
|
+
*
|
|
302
|
+
* Outside replay, accessing `env.databaseUrl` throws. Customer code uses
|
|
303
|
+
* the env only on the replay path; live request code keeps reading
|
|
304
|
+
* `process.env.DATABASE_URL` the normal way.
|
|
305
|
+
*
|
|
306
|
+
* Concurrency-safe: getters resolve through the replay AsyncLocalStorage
|
|
307
|
+
* context, so each in-flight replay item sees its own per-trace values
|
|
308
|
+
* even when the SDK runs items in parallel.
|
|
309
|
+
*
|
|
310
|
+
* Internally, the resolved per-item state is a `DbBranchLease` (see
|
|
311
|
+
* replayContext.ts) — that's the SDK ↔ server protocol term. We expose
|
|
312
|
+
* its useful fields directly here so customer code never sees the word.
|
|
313
|
+
*/
|
|
314
|
+
interface ReplayEnvironmentSnapshot {
|
|
315
|
+
databaseUrl: string;
|
|
316
|
+
expiresAt: string;
|
|
317
|
+
providerConsoleUrl?: string;
|
|
318
|
+
readOnly?: boolean;
|
|
319
|
+
traceId: string;
|
|
320
|
+
precision: "timestamp" | "lsn";
|
|
321
|
+
}
|
|
322
|
+
declare class ReplayEnvironment {
|
|
323
|
+
/**
|
|
324
|
+
* The per-trace branch URL for the item currently being replayed.
|
|
325
|
+
* Throws if read outside a replay item.
|
|
326
|
+
*/
|
|
327
|
+
get databaseUrl(): string;
|
|
328
|
+
/** When the per-trace branch URL stops being valid. ISO-8601. */
|
|
329
|
+
get expiresAt(): string;
|
|
330
|
+
/** Deep link to the branch in the provider console, if available. */
|
|
331
|
+
get providerConsoleUrl(): string | undefined;
|
|
332
|
+
/**
|
|
333
|
+
* True if the branch is read-only. Customer code can use this to skip
|
|
334
|
+
* write operations during replay when the provider returned a read-only
|
|
335
|
+
* lease.
|
|
336
|
+
*/
|
|
337
|
+
get readOnly(): boolean | undefined;
|
|
338
|
+
/** The historical trace ID that produced the input for this replay item. */
|
|
339
|
+
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
|
+
/** True when read inside a replay item that has a resolved branch. */
|
|
347
|
+
get active(): boolean;
|
|
348
|
+
/** Non-throwing variant for callers that handle the inactive case. */
|
|
349
|
+
snapshot(): ReplayEnvironmentSnapshot | null;
|
|
350
|
+
private read;
|
|
351
|
+
private require;
|
|
352
|
+
}
|
|
353
|
+
|
|
252
354
|
/**
|
|
253
355
|
* Replay historical traces through a function and create a test run.
|
|
254
356
|
*
|
|
@@ -285,6 +387,13 @@ interface ReplayOptions {
|
|
|
285
387
|
* - "marked": only spans tagged with { mockOnReplay: true } in SpanOptions are mocked
|
|
286
388
|
*/
|
|
287
389
|
mock?: MockStrategy;
|
|
390
|
+
/**
|
|
391
|
+
* Per-trace environment. When the source trace carries a DB branching
|
|
392
|
+
* snapshot, the SDK populates `environment.databaseUrl` before invoking
|
|
393
|
+
* `fn` for that item and resets it after. Customer code reads from the
|
|
394
|
+
* environment to pick up the per-trace branch URL.
|
|
395
|
+
*/
|
|
396
|
+
environment?: ReplayEnvironment;
|
|
288
397
|
}
|
|
289
398
|
interface ReplayItem<T> {
|
|
290
399
|
/** Deserialized inputs from the original trace. */
|
|
@@ -301,6 +410,13 @@ interface ReplayItem<T> {
|
|
|
301
410
|
tokens: TokenUsage | null;
|
|
302
411
|
/** Model name from the original trace, or null if not captured. */
|
|
303
412
|
model: string | null;
|
|
413
|
+
/**
|
|
414
|
+
* The DB snapshot ref the SDK captured at trace open. Useful for debugging
|
|
415
|
+
* ("what state was this trace pinned to?") and for customers building
|
|
416
|
+
* their own resolvers. Undefined when the source trace was captured
|
|
417
|
+
* without `dbSnapshot` configured.
|
|
418
|
+
*/
|
|
419
|
+
dbSnapshotRef: DbSnapshotRef | null;
|
|
304
420
|
}
|
|
305
421
|
|
|
306
422
|
interface ReplayResult<T> {
|
|
@@ -549,6 +665,13 @@ interface BitfabConfig {
|
|
|
549
665
|
enabled?: boolean;
|
|
550
666
|
/** The generated BAML client instance (e.g., `b` from your baml_client). Used by wrapBAML() when no explicit client is passed. */
|
|
551
667
|
bamlClient?: unknown;
|
|
668
|
+
/**
|
|
669
|
+
* Per-trace database snapshot config. When set, every root span captures
|
|
670
|
+
* a wall-clock timestamp (and, if `captureRef` is provided, a provider-
|
|
671
|
+
* specific point-in-time ref) so the trace can later be replayed against
|
|
672
|
+
* a branch materialized from that point.
|
|
673
|
+
*/
|
|
674
|
+
dbSnapshot?: DbSnapshotConfig;
|
|
552
675
|
}
|
|
553
676
|
/**
|
|
554
677
|
* Span types matching the backend enum.
|
|
@@ -589,6 +712,12 @@ interface SpanOptions {
|
|
|
589
712
|
* Client for making provider-based API calls via BAML.
|
|
590
713
|
*/
|
|
591
714
|
declare class Bitfab {
|
|
715
|
+
/**
|
|
716
|
+
* Per-trace environment for `replay({ environment })`. Construct one,
|
|
717
|
+
* pass it to replay, and read `env.databaseUrl` inside the replayed
|
|
718
|
+
* function to pick up the per-trace branch URL.
|
|
719
|
+
*/
|
|
720
|
+
static readonly ReplayEnvironment: typeof ReplayEnvironment;
|
|
592
721
|
private readonly apiKey;
|
|
593
722
|
private readonly serviceUrl;
|
|
594
723
|
private readonly timeout;
|
|
@@ -596,6 +725,7 @@ declare class Bitfab {
|
|
|
596
725
|
private readonly enabled;
|
|
597
726
|
private readonly httpClient;
|
|
598
727
|
private readonly bamlClient;
|
|
728
|
+
private readonly dbSnapshot;
|
|
599
729
|
/**
|
|
600
730
|
* Initialize the Bitfab client.
|
|
601
731
|
*
|
|
@@ -812,6 +942,7 @@ declare class Bitfab {
|
|
|
812
942
|
codeChangeDescription?: string;
|
|
813
943
|
codeChangeFiles?: CodeChangeFile[];
|
|
814
944
|
mock?: "none" | "all" | "marked";
|
|
945
|
+
environment?: ReplayEnvironment;
|
|
815
946
|
}): Promise<ReplayResult<TReturn>>;
|
|
816
947
|
}
|
|
817
948
|
/**
|
|
@@ -875,7 +1006,7 @@ declare class BitfabFunction {
|
|
|
875
1006
|
/**
|
|
876
1007
|
* SDK version from package.json (injected at build time)
|
|
877
1008
|
*/
|
|
878
|
-
declare const __version__ = "0.13.
|
|
1009
|
+
declare const __version__ = "0.13.4";
|
|
879
1010
|
|
|
880
1011
|
/**
|
|
881
1012
|
* Constants for the Bitfab SDK.
|
|
@@ -885,4 +1016,4 @@ declare const __version__ = "0.13.3";
|
|
|
885
1016
|
*/
|
|
886
1017
|
declare const DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
887
1018
|
|
|
888
|
-
export { type ActiveSpanContext, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DetachedTrace, type MockStrategy, type ProviderDefinition, type ReplayItem, type ReplayOptions, type ReplayResult, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
|
|
1019
|
+
export { type ActiveSpanContext, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
|
package/dist/index.js
CHANGED
|
@@ -13,15 +13,17 @@ import {
|
|
|
13
13
|
BitfabFunction,
|
|
14
14
|
BitfabLangGraphCallbackHandler,
|
|
15
15
|
BitfabOpenAITracingProcessor,
|
|
16
|
+
ReplayEnvironment,
|
|
17
|
+
SUPPORTED_PROVIDERS,
|
|
16
18
|
getCurrentSpan,
|
|
17
19
|
getCurrentTrace
|
|
18
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-XUW46356.js";
|
|
19
21
|
import {
|
|
20
22
|
BitfabError,
|
|
21
23
|
DEFAULT_SERVICE_URL,
|
|
22
24
|
__version__,
|
|
23
25
|
flushTraces
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-SKJWF5VX.js";
|
|
25
27
|
export {
|
|
26
28
|
Bitfab,
|
|
27
29
|
BitfabClaudeAgentHandler,
|
|
@@ -30,6 +32,8 @@ export {
|
|
|
30
32
|
BitfabLangGraphCallbackHandler,
|
|
31
33
|
BitfabOpenAITracingProcessor,
|
|
32
34
|
DEFAULT_SERVICE_URL,
|
|
35
|
+
ReplayEnvironment,
|
|
36
|
+
SUPPORTED_PROVIDERS,
|
|
33
37
|
__version__,
|
|
34
38
|
flushTraces,
|
|
35
39
|
getCurrentSpan,
|