bitfab 0.13.3 → 0.13.5
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-NHYPYRQB.js → chunk-4IHJJRMU.js} +133 -7
- package/dist/chunk-4IHJJRMU.js.map +1 -0
- package/dist/{chunk-LOZFAPCS.js → chunk-BVFST7Q3.js} +32 -5
- package/dist/chunk-BVFST7Q3.js.map +1 -0
- package/dist/index.cjs +238 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +141 -8
- package/dist/index.d.ts +141 -8
- package/dist/index.js +6 -2
- package/dist/node.cjs +238 -30
- 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-CLQKO7U7.js} +57 -17
- package/dist/replay-CLQKO7U7.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,8 +387,17 @@ 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> {
|
|
399
|
+
/** Trace ID of the new trace created during replay. */
|
|
400
|
+
traceId: string | null;
|
|
290
401
|
/** Deserialized inputs from the original trace. */
|
|
291
402
|
input: unknown[];
|
|
292
403
|
/** The result returned by the function during replay, or undefined on error. */
|
|
@@ -301,6 +412,13 @@ interface ReplayItem<T> {
|
|
|
301
412
|
tokens: TokenUsage | null;
|
|
302
413
|
/** Model name from the original trace, or null if not captured. */
|
|
303
414
|
model: string | null;
|
|
415
|
+
/**
|
|
416
|
+
* The DB snapshot ref the SDK captured at trace open. Useful for debugging
|
|
417
|
+
* ("what state was this trace pinned to?") and for customers building
|
|
418
|
+
* their own resolvers. Undefined when the source trace was captured
|
|
419
|
+
* without `dbSnapshot` configured.
|
|
420
|
+
*/
|
|
421
|
+
dbSnapshotRef: DbSnapshotRef | null;
|
|
304
422
|
}
|
|
305
423
|
|
|
306
424
|
interface ReplayResult<T> {
|
|
@@ -549,6 +667,13 @@ interface BitfabConfig {
|
|
|
549
667
|
enabled?: boolean;
|
|
550
668
|
/** The generated BAML client instance (e.g., `b` from your baml_client). Used by wrapBAML() when no explicit client is passed. */
|
|
551
669
|
bamlClient?: unknown;
|
|
670
|
+
/**
|
|
671
|
+
* Per-trace database snapshot config. When set, every root span captures
|
|
672
|
+
* a wall-clock timestamp (and, if `captureRef` is provided, a provider-
|
|
673
|
+
* specific point-in-time ref) so the trace can later be replayed against
|
|
674
|
+
* a branch materialized from that point.
|
|
675
|
+
*/
|
|
676
|
+
dbSnapshot?: DbSnapshotConfig;
|
|
552
677
|
}
|
|
553
678
|
/**
|
|
554
679
|
* Span types matching the backend enum.
|
|
@@ -589,6 +714,12 @@ interface SpanOptions {
|
|
|
589
714
|
* Client for making provider-based API calls via BAML.
|
|
590
715
|
*/
|
|
591
716
|
declare class Bitfab {
|
|
717
|
+
/**
|
|
718
|
+
* Per-trace environment for `replay({ environment })`. Construct one,
|
|
719
|
+
* pass it to replay, and read `env.databaseUrl` inside the replayed
|
|
720
|
+
* function to pick up the per-trace branch URL.
|
|
721
|
+
*/
|
|
722
|
+
static readonly ReplayEnvironment: typeof ReplayEnvironment;
|
|
592
723
|
private readonly apiKey;
|
|
593
724
|
private readonly serviceUrl;
|
|
594
725
|
private readonly timeout;
|
|
@@ -596,6 +727,7 @@ declare class Bitfab {
|
|
|
596
727
|
private readonly enabled;
|
|
597
728
|
private readonly httpClient;
|
|
598
729
|
private readonly bamlClient;
|
|
730
|
+
private readonly dbSnapshot;
|
|
599
731
|
/**
|
|
600
732
|
* Initialize the Bitfab client.
|
|
601
733
|
*
|
|
@@ -812,6 +944,7 @@ declare class Bitfab {
|
|
|
812
944
|
codeChangeDescription?: string;
|
|
813
945
|
codeChangeFiles?: CodeChangeFile[];
|
|
814
946
|
mock?: "none" | "all" | "marked";
|
|
947
|
+
environment?: ReplayEnvironment;
|
|
815
948
|
}): Promise<ReplayResult<TReturn>>;
|
|
816
949
|
}
|
|
817
950
|
/**
|
|
@@ -875,7 +1008,7 @@ declare class BitfabFunction {
|
|
|
875
1008
|
/**
|
|
876
1009
|
* SDK version from package.json (injected at build time)
|
|
877
1010
|
*/
|
|
878
|
-
declare const __version__ = "0.13.
|
|
1011
|
+
declare const __version__ = "0.13.5";
|
|
879
1012
|
|
|
880
1013
|
/**
|
|
881
1014
|
* Constants for the Bitfab SDK.
|
|
@@ -885,4 +1018,4 @@ declare const __version__ = "0.13.3";
|
|
|
885
1018
|
*/
|
|
886
1019
|
declare const DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
887
1020
|
|
|
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 };
|
|
1021
|
+
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,8 +387,17 @@ 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> {
|
|
399
|
+
/** Trace ID of the new trace created during replay. */
|
|
400
|
+
traceId: string | null;
|
|
290
401
|
/** Deserialized inputs from the original trace. */
|
|
291
402
|
input: unknown[];
|
|
292
403
|
/** The result returned by the function during replay, or undefined on error. */
|
|
@@ -301,6 +412,13 @@ interface ReplayItem<T> {
|
|
|
301
412
|
tokens: TokenUsage | null;
|
|
302
413
|
/** Model name from the original trace, or null if not captured. */
|
|
303
414
|
model: string | null;
|
|
415
|
+
/**
|
|
416
|
+
* The DB snapshot ref the SDK captured at trace open. Useful for debugging
|
|
417
|
+
* ("what state was this trace pinned to?") and for customers building
|
|
418
|
+
* their own resolvers. Undefined when the source trace was captured
|
|
419
|
+
* without `dbSnapshot` configured.
|
|
420
|
+
*/
|
|
421
|
+
dbSnapshotRef: DbSnapshotRef | null;
|
|
304
422
|
}
|
|
305
423
|
|
|
306
424
|
interface ReplayResult<T> {
|
|
@@ -549,6 +667,13 @@ interface BitfabConfig {
|
|
|
549
667
|
enabled?: boolean;
|
|
550
668
|
/** The generated BAML client instance (e.g., `b` from your baml_client). Used by wrapBAML() when no explicit client is passed. */
|
|
551
669
|
bamlClient?: unknown;
|
|
670
|
+
/**
|
|
671
|
+
* Per-trace database snapshot config. When set, every root span captures
|
|
672
|
+
* a wall-clock timestamp (and, if `captureRef` is provided, a provider-
|
|
673
|
+
* specific point-in-time ref) so the trace can later be replayed against
|
|
674
|
+
* a branch materialized from that point.
|
|
675
|
+
*/
|
|
676
|
+
dbSnapshot?: DbSnapshotConfig;
|
|
552
677
|
}
|
|
553
678
|
/**
|
|
554
679
|
* Span types matching the backend enum.
|
|
@@ -589,6 +714,12 @@ interface SpanOptions {
|
|
|
589
714
|
* Client for making provider-based API calls via BAML.
|
|
590
715
|
*/
|
|
591
716
|
declare class Bitfab {
|
|
717
|
+
/**
|
|
718
|
+
* Per-trace environment for `replay({ environment })`. Construct one,
|
|
719
|
+
* pass it to replay, and read `env.databaseUrl` inside the replayed
|
|
720
|
+
* function to pick up the per-trace branch URL.
|
|
721
|
+
*/
|
|
722
|
+
static readonly ReplayEnvironment: typeof ReplayEnvironment;
|
|
592
723
|
private readonly apiKey;
|
|
593
724
|
private readonly serviceUrl;
|
|
594
725
|
private readonly timeout;
|
|
@@ -596,6 +727,7 @@ declare class Bitfab {
|
|
|
596
727
|
private readonly enabled;
|
|
597
728
|
private readonly httpClient;
|
|
598
729
|
private readonly bamlClient;
|
|
730
|
+
private readonly dbSnapshot;
|
|
599
731
|
/**
|
|
600
732
|
* Initialize the Bitfab client.
|
|
601
733
|
*
|
|
@@ -812,6 +944,7 @@ declare class Bitfab {
|
|
|
812
944
|
codeChangeDescription?: string;
|
|
813
945
|
codeChangeFiles?: CodeChangeFile[];
|
|
814
946
|
mock?: "none" | "all" | "marked";
|
|
947
|
+
environment?: ReplayEnvironment;
|
|
815
948
|
}): Promise<ReplayResult<TReturn>>;
|
|
816
949
|
}
|
|
817
950
|
/**
|
|
@@ -875,7 +1008,7 @@ declare class BitfabFunction {
|
|
|
875
1008
|
/**
|
|
876
1009
|
* SDK version from package.json (injected at build time)
|
|
877
1010
|
*/
|
|
878
|
-
declare const __version__ = "0.13.
|
|
1011
|
+
declare const __version__ = "0.13.5";
|
|
879
1012
|
|
|
880
1013
|
/**
|
|
881
1014
|
* Constants for the Bitfab SDK.
|
|
@@ -885,4 +1018,4 @@ declare const __version__ = "0.13.3";
|
|
|
885
1018
|
*/
|
|
886
1019
|
declare const DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
887
1020
|
|
|
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 };
|
|
1021
|
+
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-4IHJJRMU.js";
|
|
19
21
|
import {
|
|
20
22
|
BitfabError,
|
|
21
23
|
DEFAULT_SERVICE_URL,
|
|
22
24
|
__version__,
|
|
23
25
|
flushTraces
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-BVFST7Q3.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,
|