@bitfab/sdk 0.36.12 → 0.38.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/{chunk-OCJSHTJR.js → chunk-LCGQUVKR.js} +18 -6
- package/dist/chunk-LCGQUVKR.js.map +1 -0
- package/dist/{chunk-VUYTATF5.js → chunk-SSNTMROV.js} +36 -16
- package/dist/chunk-SSNTMROV.js.map +1 -0
- package/dist/index.cjs +50 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -55
- package/dist/index.d.ts +143 -55
- package/dist/index.js +2 -2
- package/dist/node.cjs +50 -18
- 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 +2 -2
- package/dist/{replay-P35CUNGH.js → replay-XWBIMYEE.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-OCJSHTJR.js.map +0 -1
- package/dist/chunk-VUYTATF5.js.map +0 -1
- /package/dist/{replay-P35CUNGH.js.map → replay-XWBIMYEE.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -182,8 +182,9 @@ interface MockOverride {
|
|
|
182
182
|
* A single span entry in the mock tree.
|
|
183
183
|
*
|
|
184
184
|
* Under the eager path (`mock: "all"`) `output`/`outputMeta` are populated
|
|
185
|
-
* inline
|
|
186
|
-
*
|
|
185
|
+
* inline, even when overrides are present. Under a non-`all` path that needs a
|
|
186
|
+
* tree (`marked`, or `none` with overrides), they are absent and the recorded
|
|
187
|
+
* output is fetched on demand via `externalSpanId` - see
|
|
187
188
|
* {@link ReplayContext.fetchSpanOutput}.
|
|
188
189
|
*/
|
|
189
190
|
interface MockSpan {
|
|
@@ -222,6 +223,39 @@ interface DbBranchLease {
|
|
|
222
223
|
*/
|
|
223
224
|
region?: string;
|
|
224
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* How long each phase of provisioning one replay branch took, measured
|
|
228
|
+
* server-side. A runner in another region sees these plus its own round trip.
|
|
229
|
+
*
|
|
230
|
+
* Durations, not instants: an instant is approximately `startedAt` plus the
|
|
231
|
+
* running sum, and per-phase wall-clock stamps would make clock skew between
|
|
232
|
+
* the server and your runner look like latency. Approximately, because
|
|
233
|
+
* `totalMs` is the resolve's true wall time and covers a little work no phase
|
|
234
|
+
* owns, so the phases account for it without summing to it exactly.
|
|
235
|
+
*
|
|
236
|
+
* `startedAt` and `totalMs` are always present. The phases are optional
|
|
237
|
+
* because a failed resolve reports only the ones it reached, and `totalMs` is
|
|
238
|
+
* then time-to-failure. On success every phase is present except `warmupMs`,
|
|
239
|
+
* which is absent when no warm-up SQL was supplied.
|
|
240
|
+
*/
|
|
241
|
+
interface DbBranchTimings {
|
|
242
|
+
/** When the resolve began, ISO. */
|
|
243
|
+
startedAt: string;
|
|
244
|
+
/** Resolving the project, plus its retention and region reads. */
|
|
245
|
+
projectResolveMs?: number;
|
|
246
|
+
/** Creating the branch, through its provider operations reaching terminal. */
|
|
247
|
+
branchCreateMs?: number;
|
|
248
|
+
/** Resolving the connection URI. 0 when the provider returns one inline. */
|
|
249
|
+
connectionUriMs?: number;
|
|
250
|
+
/** The compute accepting a connection. */
|
|
251
|
+
computeConnectMs?: number;
|
|
252
|
+
/** The branch answering a readiness query. */
|
|
253
|
+
baseProbeMs?: number;
|
|
254
|
+
/** Your warm-up SQL. Absent when you supplied none. */
|
|
255
|
+
warmupMs?: number;
|
|
256
|
+
/** The whole resolve, or time-to-failure when it threw. */
|
|
257
|
+
totalMs: number;
|
|
258
|
+
}
|
|
225
259
|
/**
|
|
226
260
|
* Wire shape of the caller's `ReplayOptions.dbBranch`, sent to
|
|
227
261
|
* `/api/sdk/replay/start` and applied per lease.
|
|
@@ -267,12 +301,21 @@ interface ReplayContext {
|
|
|
267
301
|
mockOverrides?: MockOverride[];
|
|
268
302
|
/**
|
|
269
303
|
* Memoized lazy fetch of a span's recorded output (deserialized), keyed by
|
|
270
|
-
* `externalSpanId`. Present ONLY on
|
|
271
|
-
* absent under `mock: "all"`, where
|
|
272
|
-
*
|
|
304
|
+
* `externalSpanId`. Present ONLY on a non-`all` path that needs a tree
|
|
305
|
+
* (`marked`, or `none` with overrides); absent under `mock: "all"`, where
|
|
306
|
+
* outputs are inline even when overrides are present. Its presence is the
|
|
307
|
+
* signal that outputs must be fetched rather than read inline.
|
|
273
308
|
*/
|
|
274
309
|
fetchSpanOutput?: (externalSpanId: string) => Promise<unknown>;
|
|
275
310
|
dbBranchLease?: DbBranchLease;
|
|
311
|
+
/**
|
|
312
|
+
* Server-measured provisioning timings for this item's branch, echoed back
|
|
313
|
+
* on the trace completion so the trace records what it cost to set up. Kept
|
|
314
|
+
* off `ReplayBranch`: customer code reads that mid-replay to reach the
|
|
315
|
+
* branch, and provisioning latency is a property of the run, not of the
|
|
316
|
+
* connection.
|
|
317
|
+
*/
|
|
318
|
+
dbBranchTimings?: DbBranchTimings;
|
|
276
319
|
/**
|
|
277
320
|
* Set to true by `ReplayBranch` the first time customer code actually
|
|
278
321
|
* obtains `databaseUrl` for this item. Reported on the trace completion inside
|
|
@@ -568,6 +611,7 @@ declare class HttpClient {
|
|
|
568
611
|
code: string;
|
|
569
612
|
message: string;
|
|
570
613
|
} | null;
|
|
614
|
+
timings: DbBranchTimings | null;
|
|
571
615
|
}>;
|
|
572
616
|
/** Release a previously-resolved DB branch by deleting its Neon branch. Idempotent server-side. */
|
|
573
617
|
releaseDbBranchLease(neonBranchId: string): Promise<void>;
|
|
@@ -626,6 +670,13 @@ interface StartReplayResponse {
|
|
|
626
670
|
code: string;
|
|
627
671
|
message: string;
|
|
628
672
|
};
|
|
673
|
+
/**
|
|
674
|
+
* How long provisioning took, per phase. Sits beside the two fields above
|
|
675
|
+
* rather than inside either: it is reported on both outcomes, complete on
|
|
676
|
+
* success and partial up to the failing phase on error. Absent from
|
|
677
|
+
* servers that predate it.
|
|
678
|
+
*/
|
|
679
|
+
dbBranchTimings?: DbBranchTimings;
|
|
629
680
|
}>;
|
|
630
681
|
}
|
|
631
682
|
interface ExternalSpanResponse {
|
|
@@ -1177,9 +1228,9 @@ interface DbBranchOptions {
|
|
|
1177
1228
|
}
|
|
1178
1229
|
interface ReplayOptions {
|
|
1179
1230
|
/**
|
|
1180
|
-
* Maximum number of traces to replay (1-
|
|
1181
|
-
* `traceIds` is passed (with a warning)
|
|
1182
|
-
* determines how many traces replay.
|
|
1231
|
+
* Maximum number of traces to replay (1-5,000, default 5). Ignored when
|
|
1232
|
+
* `traceIds` is passed (with a warning), or when `datasetId` is passed,
|
|
1233
|
+
* because either source already determines how many traces replay.
|
|
1183
1234
|
*/
|
|
1184
1235
|
limit?: number;
|
|
1185
1236
|
/** Optional list of specific trace IDs to replay (max 100). */
|
|
@@ -1209,7 +1260,8 @@ interface ReplayOptions {
|
|
|
1209
1260
|
* Mock strategy for child spans during replay.
|
|
1210
1261
|
* - "marked": only spans tagged with { mockOnReplay: true } in SpanOptions are mocked (default)
|
|
1211
1262
|
* - "none": everything runs real code
|
|
1212
|
-
* - "all": every child withSpan returns historical output
|
|
1263
|
+
* - "all": every matched recorded child withSpan returns historical output;
|
|
1264
|
+
* a missing occurrence fails the replay item closed
|
|
1213
1265
|
*/
|
|
1214
1266
|
mock?: MockStrategy;
|
|
1215
1267
|
/**
|
|
@@ -1229,9 +1281,10 @@ interface ReplayOptions {
|
|
|
1229
1281
|
* branch with `getCurrentReplayBranch()`.
|
|
1230
1282
|
*
|
|
1231
1283
|
* Items whose source trace carried no DB snapshot reference get no branch and
|
|
1232
|
-
*
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1284
|
+
* use the app's normal database path. Unsafe calls on that path still require
|
|
1285
|
+
* replay mocking. An item whose branch was requested but could not be resolved
|
|
1286
|
+
* fails instead of running, so replay never silently reports a result that did
|
|
1287
|
+
* not use the historical data you asked for.
|
|
1235
1288
|
*/
|
|
1236
1289
|
dbBranch?: DbBranchOptions | boolean;
|
|
1237
1290
|
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
@@ -1339,42 +1392,52 @@ interface ReplayItemFinishProgress {
|
|
|
1339
1392
|
/** Of the completed items, how many have `item.error` set. */
|
|
1340
1393
|
errored: number;
|
|
1341
1394
|
/**
|
|
1342
|
-
* The single item that just finished to produce this event.
|
|
1343
|
-
*
|
|
1344
|
-
* `
|
|
1345
|
-
*
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1348
|
-
*
|
|
1395
|
+
* The single item that just finished to produce this event. Field-for-field
|
|
1396
|
+
* the same shape and meaning as {@link ReplayItem}, so a progress UI and a
|
|
1397
|
+
* final-result UI read one contract. `traceId` is null at this stage (the
|
|
1398
|
+
* server replay id arrives at completion), and `tokens` is null for the same
|
|
1399
|
+
* reason: the replayed run's usage is aggregated server-side by
|
|
1400
|
+
* completeReplay. `durationMs` is how long this item took to replay; the
|
|
1401
|
+
* `original*` fields describe the trace it replayed.
|
|
1349
1402
|
*/
|
|
1350
|
-
item:
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1403
|
+
item: ReplayProgressItem;
|
|
1404
|
+
}
|
|
1405
|
+
/** See {@link ReplayItemFinishProgress.item}. Mirrors {@link ReplayItem}. */
|
|
1406
|
+
interface ReplayProgressItem {
|
|
1407
|
+
/** Trace ID of the new replay trace (null during the run; the server id arrives at completion). */
|
|
1408
|
+
traceId?: string | null;
|
|
1409
|
+
/** Bitfab trace ID of the original (historical) trace being replayed. */
|
|
1410
|
+
originalTraceId: string | null;
|
|
1411
|
+
/** External span ID the recorded inputs were read from (the original root span). */
|
|
1412
|
+
originalSpanId?: string | null;
|
|
1413
|
+
/** @deprecated alias for `originalTraceId`. */
|
|
1414
|
+
sourceTraceId: string | null;
|
|
1415
|
+
/** @deprecated alias for `originalSpanId`. */
|
|
1416
|
+
sourceSpanId?: string | null;
|
|
1417
|
+
/** Deserialized inputs from the original trace. */
|
|
1418
|
+
input?: unknown[];
|
|
1419
|
+
/** The result returned by the replayed function, or undefined on error. */
|
|
1420
|
+
result?: unknown;
|
|
1421
|
+
/** The original output from the historical trace. */
|
|
1422
|
+
originalOutput?: unknown;
|
|
1423
|
+
/** Backward-compatible message for either error kind. */
|
|
1424
|
+
error: string | null;
|
|
1425
|
+
/** The actual value thrown by the replayed customer function. */
|
|
1426
|
+
traceError?: unknown | null;
|
|
1427
|
+
/** The actual value thrown while Bitfab prepared this replay item. */
|
|
1428
|
+
replayError?: unknown | null;
|
|
1429
|
+
/** How long the replayed function took on this run. */
|
|
1430
|
+
durationMs?: number | null;
|
|
1431
|
+
/** The original trace's duration, tokens, and model. */
|
|
1432
|
+
originalDurationMs?: number | null;
|
|
1433
|
+
originalTokens?: TokenUsage | null;
|
|
1434
|
+
originalModel?: string | null;
|
|
1435
|
+
/** Always null here: the replayed run's usage is only known at completion. */
|
|
1436
|
+
tokens?: TokenUsage | null;
|
|
1437
|
+
/** @deprecated renamed to `originalModel`. */
|
|
1438
|
+
model?: string | null;
|
|
1439
|
+
dbSnapshotRef?: DbSnapshotRef | null;
|
|
1440
|
+
dbBranchTimings?: DbBranchTimings | null;
|
|
1378
1441
|
}
|
|
1379
1442
|
/**
|
|
1380
1443
|
* @deprecated Use {@link ReplayItemFinishProgress}. This legacy shape also
|
|
@@ -1478,17 +1541,32 @@ interface ReplayItem<T> {
|
|
|
1478
1541
|
* such as database warmup, input hydration, or mock preparation.
|
|
1479
1542
|
*/
|
|
1480
1543
|
replayError: unknown | null;
|
|
1481
|
-
/**
|
|
1544
|
+
/**
|
|
1545
|
+
* How long the replayed function took on this run, in ms. Null if the item
|
|
1546
|
+
* failed before it ran. Compare against
|
|
1547
|
+
* {@link ReplayItem.originalDurationMs} for the before/after.
|
|
1548
|
+
*/
|
|
1482
1549
|
durationMs: number | null;
|
|
1550
|
+
/** The original trace's duration in ms, or null if its timestamps are missing. */
|
|
1551
|
+
originalDurationMs: number | null;
|
|
1552
|
+
/**
|
|
1553
|
+
* Token usage recorded on the original trace, or null if it captured none.
|
|
1554
|
+
* The "old" side of a token delta; {@link ReplayItem.tokens} is the new one.
|
|
1555
|
+
*/
|
|
1556
|
+
originalTokens: TokenUsage | null;
|
|
1557
|
+
/** Model name from the original trace, or null if not captured. */
|
|
1558
|
+
originalModel: string | null;
|
|
1483
1559
|
/**
|
|
1484
1560
|
* Token usage from the REPLAYED run (this item's new execution), aggregated
|
|
1485
1561
|
* server-side from the spans it produced, or null if the run captured no
|
|
1486
|
-
* token data.
|
|
1487
|
-
* the
|
|
1488
|
-
*
|
|
1562
|
+
* token data. Compare against {@link ReplayItem.originalTokens} to see how
|
|
1563
|
+
* the code change moved cost. Matches what Studio's experiments view shows.
|
|
1564
|
+
*
|
|
1565
|
+
* Unprefixed because the replay is this item's subject: anything describing
|
|
1566
|
+
* the trace being replayed carries `original`.
|
|
1489
1567
|
*/
|
|
1490
1568
|
tokens: TokenUsage | null;
|
|
1491
|
-
/**
|
|
1569
|
+
/** @deprecated renamed to {@link ReplayItem.originalModel}. */
|
|
1492
1570
|
model: string | null;
|
|
1493
1571
|
/**
|
|
1494
1572
|
* The DB snapshot ref the SDK captured at trace open. Useful for debugging
|
|
@@ -1497,6 +1575,14 @@ interface ReplayItem<T> {
|
|
|
1497
1575
|
* without `dbSnapshot` configured.
|
|
1498
1576
|
*/
|
|
1499
1577
|
dbSnapshotRef: DbSnapshotRef | null;
|
|
1578
|
+
/**
|
|
1579
|
+
* How long this item's DB branch took to provision, per phase, measured
|
|
1580
|
+
* server-side. Present whenever a branch was attempted, on both outcomes:
|
|
1581
|
+
* complete on success, partial up to the failing phase when the resolve
|
|
1582
|
+
* failed. Null when no branch was asked for, when the source trace carried
|
|
1583
|
+
* no snapshot ref, or against a server that predates timings.
|
|
1584
|
+
*/
|
|
1585
|
+
dbBranchTimings: DbBranchTimings | null;
|
|
1500
1586
|
}
|
|
1501
1587
|
|
|
1502
1588
|
interface ReplayResult<T> {
|
|
@@ -1966,7 +2052,9 @@ interface SpanOptions {
|
|
|
1966
2052
|
*
|
|
1967
2053
|
* Use this for child spans that are expensive (paid LLM/API calls),
|
|
1968
2054
|
* slow, or non-deterministic - the root function still runs real code,
|
|
1969
|
-
* only the marked descendants return their recorded output.
|
|
2055
|
+
* only the marked descendants return their recorded output. If a selected
|
|
2056
|
+
* occurrence is unavailable, replay fails the item without executing the
|
|
2057
|
+
* real child.
|
|
1970
2058
|
*/
|
|
1971
2059
|
mockOnReplay?: boolean;
|
|
1972
2060
|
/**
|
|
@@ -2575,7 +2663,7 @@ declare class BitfabFunction {
|
|
|
2575
2663
|
/**
|
|
2576
2664
|
* SDK version from package.json (injected at build time)
|
|
2577
2665
|
*/
|
|
2578
|
-
declare const __version__ = "0.
|
|
2666
|
+
declare const __version__ = "0.38.0";
|
|
2579
2667
|
|
|
2580
2668
|
/**
|
|
2581
2669
|
* Constants for the Bitfab SDK.
|
|
@@ -2643,4 +2731,4 @@ declare const finalizers: {
|
|
|
2643
2731
|
readableStream: typeof readableStream;
|
|
2644
2732
|
};
|
|
2645
2733
|
|
|
2646
|
-
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
|
|
2734
|
+
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayProgress, type ReplayProgressItem, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -182,8 +182,9 @@ interface MockOverride {
|
|
|
182
182
|
* A single span entry in the mock tree.
|
|
183
183
|
*
|
|
184
184
|
* Under the eager path (`mock: "all"`) `output`/`outputMeta` are populated
|
|
185
|
-
* inline
|
|
186
|
-
*
|
|
185
|
+
* inline, even when overrides are present. Under a non-`all` path that needs a
|
|
186
|
+
* tree (`marked`, or `none` with overrides), they are absent and the recorded
|
|
187
|
+
* output is fetched on demand via `externalSpanId` - see
|
|
187
188
|
* {@link ReplayContext.fetchSpanOutput}.
|
|
188
189
|
*/
|
|
189
190
|
interface MockSpan {
|
|
@@ -222,6 +223,39 @@ interface DbBranchLease {
|
|
|
222
223
|
*/
|
|
223
224
|
region?: string;
|
|
224
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* How long each phase of provisioning one replay branch took, measured
|
|
228
|
+
* server-side. A runner in another region sees these plus its own round trip.
|
|
229
|
+
*
|
|
230
|
+
* Durations, not instants: an instant is approximately `startedAt` plus the
|
|
231
|
+
* running sum, and per-phase wall-clock stamps would make clock skew between
|
|
232
|
+
* the server and your runner look like latency. Approximately, because
|
|
233
|
+
* `totalMs` is the resolve's true wall time and covers a little work no phase
|
|
234
|
+
* owns, so the phases account for it without summing to it exactly.
|
|
235
|
+
*
|
|
236
|
+
* `startedAt` and `totalMs` are always present. The phases are optional
|
|
237
|
+
* because a failed resolve reports only the ones it reached, and `totalMs` is
|
|
238
|
+
* then time-to-failure. On success every phase is present except `warmupMs`,
|
|
239
|
+
* which is absent when no warm-up SQL was supplied.
|
|
240
|
+
*/
|
|
241
|
+
interface DbBranchTimings {
|
|
242
|
+
/** When the resolve began, ISO. */
|
|
243
|
+
startedAt: string;
|
|
244
|
+
/** Resolving the project, plus its retention and region reads. */
|
|
245
|
+
projectResolveMs?: number;
|
|
246
|
+
/** Creating the branch, through its provider operations reaching terminal. */
|
|
247
|
+
branchCreateMs?: number;
|
|
248
|
+
/** Resolving the connection URI. 0 when the provider returns one inline. */
|
|
249
|
+
connectionUriMs?: number;
|
|
250
|
+
/** The compute accepting a connection. */
|
|
251
|
+
computeConnectMs?: number;
|
|
252
|
+
/** The branch answering a readiness query. */
|
|
253
|
+
baseProbeMs?: number;
|
|
254
|
+
/** Your warm-up SQL. Absent when you supplied none. */
|
|
255
|
+
warmupMs?: number;
|
|
256
|
+
/** The whole resolve, or time-to-failure when it threw. */
|
|
257
|
+
totalMs: number;
|
|
258
|
+
}
|
|
225
259
|
/**
|
|
226
260
|
* Wire shape of the caller's `ReplayOptions.dbBranch`, sent to
|
|
227
261
|
* `/api/sdk/replay/start` and applied per lease.
|
|
@@ -267,12 +301,21 @@ interface ReplayContext {
|
|
|
267
301
|
mockOverrides?: MockOverride[];
|
|
268
302
|
/**
|
|
269
303
|
* Memoized lazy fetch of a span's recorded output (deserialized), keyed by
|
|
270
|
-
* `externalSpanId`. Present ONLY on
|
|
271
|
-
* absent under `mock: "all"`, where
|
|
272
|
-
*
|
|
304
|
+
* `externalSpanId`. Present ONLY on a non-`all` path that needs a tree
|
|
305
|
+
* (`marked`, or `none` with overrides); absent under `mock: "all"`, where
|
|
306
|
+
* outputs are inline even when overrides are present. Its presence is the
|
|
307
|
+
* signal that outputs must be fetched rather than read inline.
|
|
273
308
|
*/
|
|
274
309
|
fetchSpanOutput?: (externalSpanId: string) => Promise<unknown>;
|
|
275
310
|
dbBranchLease?: DbBranchLease;
|
|
311
|
+
/**
|
|
312
|
+
* Server-measured provisioning timings for this item's branch, echoed back
|
|
313
|
+
* on the trace completion so the trace records what it cost to set up. Kept
|
|
314
|
+
* off `ReplayBranch`: customer code reads that mid-replay to reach the
|
|
315
|
+
* branch, and provisioning latency is a property of the run, not of the
|
|
316
|
+
* connection.
|
|
317
|
+
*/
|
|
318
|
+
dbBranchTimings?: DbBranchTimings;
|
|
276
319
|
/**
|
|
277
320
|
* Set to true by `ReplayBranch` the first time customer code actually
|
|
278
321
|
* obtains `databaseUrl` for this item. Reported on the trace completion inside
|
|
@@ -568,6 +611,7 @@ declare class HttpClient {
|
|
|
568
611
|
code: string;
|
|
569
612
|
message: string;
|
|
570
613
|
} | null;
|
|
614
|
+
timings: DbBranchTimings | null;
|
|
571
615
|
}>;
|
|
572
616
|
/** Release a previously-resolved DB branch by deleting its Neon branch. Idempotent server-side. */
|
|
573
617
|
releaseDbBranchLease(neonBranchId: string): Promise<void>;
|
|
@@ -626,6 +670,13 @@ interface StartReplayResponse {
|
|
|
626
670
|
code: string;
|
|
627
671
|
message: string;
|
|
628
672
|
};
|
|
673
|
+
/**
|
|
674
|
+
* How long provisioning took, per phase. Sits beside the two fields above
|
|
675
|
+
* rather than inside either: it is reported on both outcomes, complete on
|
|
676
|
+
* success and partial up to the failing phase on error. Absent from
|
|
677
|
+
* servers that predate it.
|
|
678
|
+
*/
|
|
679
|
+
dbBranchTimings?: DbBranchTimings;
|
|
629
680
|
}>;
|
|
630
681
|
}
|
|
631
682
|
interface ExternalSpanResponse {
|
|
@@ -1177,9 +1228,9 @@ interface DbBranchOptions {
|
|
|
1177
1228
|
}
|
|
1178
1229
|
interface ReplayOptions {
|
|
1179
1230
|
/**
|
|
1180
|
-
* Maximum number of traces to replay (1-
|
|
1181
|
-
* `traceIds` is passed (with a warning)
|
|
1182
|
-
* determines how many traces replay.
|
|
1231
|
+
* Maximum number of traces to replay (1-5,000, default 5). Ignored when
|
|
1232
|
+
* `traceIds` is passed (with a warning), or when `datasetId` is passed,
|
|
1233
|
+
* because either source already determines how many traces replay.
|
|
1183
1234
|
*/
|
|
1184
1235
|
limit?: number;
|
|
1185
1236
|
/** Optional list of specific trace IDs to replay (max 100). */
|
|
@@ -1209,7 +1260,8 @@ interface ReplayOptions {
|
|
|
1209
1260
|
* Mock strategy for child spans during replay.
|
|
1210
1261
|
* - "marked": only spans tagged with { mockOnReplay: true } in SpanOptions are mocked (default)
|
|
1211
1262
|
* - "none": everything runs real code
|
|
1212
|
-
* - "all": every child withSpan returns historical output
|
|
1263
|
+
* - "all": every matched recorded child withSpan returns historical output;
|
|
1264
|
+
* a missing occurrence fails the replay item closed
|
|
1213
1265
|
*/
|
|
1214
1266
|
mock?: MockStrategy;
|
|
1215
1267
|
/**
|
|
@@ -1229,9 +1281,10 @@ interface ReplayOptions {
|
|
|
1229
1281
|
* branch with `getCurrentReplayBranch()`.
|
|
1230
1282
|
*
|
|
1231
1283
|
* Items whose source trace carried no DB snapshot reference get no branch and
|
|
1232
|
-
*
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1284
|
+
* use the app's normal database path. Unsafe calls on that path still require
|
|
1285
|
+
* replay mocking. An item whose branch was requested but could not be resolved
|
|
1286
|
+
* fails instead of running, so replay never silently reports a result that did
|
|
1287
|
+
* not use the historical data you asked for.
|
|
1235
1288
|
*/
|
|
1236
1289
|
dbBranch?: DbBranchOptions | boolean;
|
|
1237
1290
|
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
@@ -1339,42 +1392,52 @@ interface ReplayItemFinishProgress {
|
|
|
1339
1392
|
/** Of the completed items, how many have `item.error` set. */
|
|
1340
1393
|
errored: number;
|
|
1341
1394
|
/**
|
|
1342
|
-
* The single item that just finished to produce this event.
|
|
1343
|
-
*
|
|
1344
|
-
* `
|
|
1345
|
-
*
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1348
|
-
*
|
|
1395
|
+
* The single item that just finished to produce this event. Field-for-field
|
|
1396
|
+
* the same shape and meaning as {@link ReplayItem}, so a progress UI and a
|
|
1397
|
+
* final-result UI read one contract. `traceId` is null at this stage (the
|
|
1398
|
+
* server replay id arrives at completion), and `tokens` is null for the same
|
|
1399
|
+
* reason: the replayed run's usage is aggregated server-side by
|
|
1400
|
+
* completeReplay. `durationMs` is how long this item took to replay; the
|
|
1401
|
+
* `original*` fields describe the trace it replayed.
|
|
1349
1402
|
*/
|
|
1350
|
-
item:
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1403
|
+
item: ReplayProgressItem;
|
|
1404
|
+
}
|
|
1405
|
+
/** See {@link ReplayItemFinishProgress.item}. Mirrors {@link ReplayItem}. */
|
|
1406
|
+
interface ReplayProgressItem {
|
|
1407
|
+
/** Trace ID of the new replay trace (null during the run; the server id arrives at completion). */
|
|
1408
|
+
traceId?: string | null;
|
|
1409
|
+
/** Bitfab trace ID of the original (historical) trace being replayed. */
|
|
1410
|
+
originalTraceId: string | null;
|
|
1411
|
+
/** External span ID the recorded inputs were read from (the original root span). */
|
|
1412
|
+
originalSpanId?: string | null;
|
|
1413
|
+
/** @deprecated alias for `originalTraceId`. */
|
|
1414
|
+
sourceTraceId: string | null;
|
|
1415
|
+
/** @deprecated alias for `originalSpanId`. */
|
|
1416
|
+
sourceSpanId?: string | null;
|
|
1417
|
+
/** Deserialized inputs from the original trace. */
|
|
1418
|
+
input?: unknown[];
|
|
1419
|
+
/** The result returned by the replayed function, or undefined on error. */
|
|
1420
|
+
result?: unknown;
|
|
1421
|
+
/** The original output from the historical trace. */
|
|
1422
|
+
originalOutput?: unknown;
|
|
1423
|
+
/** Backward-compatible message for either error kind. */
|
|
1424
|
+
error: string | null;
|
|
1425
|
+
/** The actual value thrown by the replayed customer function. */
|
|
1426
|
+
traceError?: unknown | null;
|
|
1427
|
+
/** The actual value thrown while Bitfab prepared this replay item. */
|
|
1428
|
+
replayError?: unknown | null;
|
|
1429
|
+
/** How long the replayed function took on this run. */
|
|
1430
|
+
durationMs?: number | null;
|
|
1431
|
+
/** The original trace's duration, tokens, and model. */
|
|
1432
|
+
originalDurationMs?: number | null;
|
|
1433
|
+
originalTokens?: TokenUsage | null;
|
|
1434
|
+
originalModel?: string | null;
|
|
1435
|
+
/** Always null here: the replayed run's usage is only known at completion. */
|
|
1436
|
+
tokens?: TokenUsage | null;
|
|
1437
|
+
/** @deprecated renamed to `originalModel`. */
|
|
1438
|
+
model?: string | null;
|
|
1439
|
+
dbSnapshotRef?: DbSnapshotRef | null;
|
|
1440
|
+
dbBranchTimings?: DbBranchTimings | null;
|
|
1378
1441
|
}
|
|
1379
1442
|
/**
|
|
1380
1443
|
* @deprecated Use {@link ReplayItemFinishProgress}. This legacy shape also
|
|
@@ -1478,17 +1541,32 @@ interface ReplayItem<T> {
|
|
|
1478
1541
|
* such as database warmup, input hydration, or mock preparation.
|
|
1479
1542
|
*/
|
|
1480
1543
|
replayError: unknown | null;
|
|
1481
|
-
/**
|
|
1544
|
+
/**
|
|
1545
|
+
* How long the replayed function took on this run, in ms. Null if the item
|
|
1546
|
+
* failed before it ran. Compare against
|
|
1547
|
+
* {@link ReplayItem.originalDurationMs} for the before/after.
|
|
1548
|
+
*/
|
|
1482
1549
|
durationMs: number | null;
|
|
1550
|
+
/** The original trace's duration in ms, or null if its timestamps are missing. */
|
|
1551
|
+
originalDurationMs: number | null;
|
|
1552
|
+
/**
|
|
1553
|
+
* Token usage recorded on the original trace, or null if it captured none.
|
|
1554
|
+
* The "old" side of a token delta; {@link ReplayItem.tokens} is the new one.
|
|
1555
|
+
*/
|
|
1556
|
+
originalTokens: TokenUsage | null;
|
|
1557
|
+
/** Model name from the original trace, or null if not captured. */
|
|
1558
|
+
originalModel: string | null;
|
|
1483
1559
|
/**
|
|
1484
1560
|
* Token usage from the REPLAYED run (this item's new execution), aggregated
|
|
1485
1561
|
* server-side from the spans it produced, or null if the run captured no
|
|
1486
|
-
* token data.
|
|
1487
|
-
* the
|
|
1488
|
-
*
|
|
1562
|
+
* token data. Compare against {@link ReplayItem.originalTokens} to see how
|
|
1563
|
+
* the code change moved cost. Matches what Studio's experiments view shows.
|
|
1564
|
+
*
|
|
1565
|
+
* Unprefixed because the replay is this item's subject: anything describing
|
|
1566
|
+
* the trace being replayed carries `original`.
|
|
1489
1567
|
*/
|
|
1490
1568
|
tokens: TokenUsage | null;
|
|
1491
|
-
/**
|
|
1569
|
+
/** @deprecated renamed to {@link ReplayItem.originalModel}. */
|
|
1492
1570
|
model: string | null;
|
|
1493
1571
|
/**
|
|
1494
1572
|
* The DB snapshot ref the SDK captured at trace open. Useful for debugging
|
|
@@ -1497,6 +1575,14 @@ interface ReplayItem<T> {
|
|
|
1497
1575
|
* without `dbSnapshot` configured.
|
|
1498
1576
|
*/
|
|
1499
1577
|
dbSnapshotRef: DbSnapshotRef | null;
|
|
1578
|
+
/**
|
|
1579
|
+
* How long this item's DB branch took to provision, per phase, measured
|
|
1580
|
+
* server-side. Present whenever a branch was attempted, on both outcomes:
|
|
1581
|
+
* complete on success, partial up to the failing phase when the resolve
|
|
1582
|
+
* failed. Null when no branch was asked for, when the source trace carried
|
|
1583
|
+
* no snapshot ref, or against a server that predates timings.
|
|
1584
|
+
*/
|
|
1585
|
+
dbBranchTimings: DbBranchTimings | null;
|
|
1500
1586
|
}
|
|
1501
1587
|
|
|
1502
1588
|
interface ReplayResult<T> {
|
|
@@ -1966,7 +2052,9 @@ interface SpanOptions {
|
|
|
1966
2052
|
*
|
|
1967
2053
|
* Use this for child spans that are expensive (paid LLM/API calls),
|
|
1968
2054
|
* slow, or non-deterministic - the root function still runs real code,
|
|
1969
|
-
* only the marked descendants return their recorded output.
|
|
2055
|
+
* only the marked descendants return their recorded output. If a selected
|
|
2056
|
+
* occurrence is unavailable, replay fails the item without executing the
|
|
2057
|
+
* real child.
|
|
1970
2058
|
*/
|
|
1971
2059
|
mockOnReplay?: boolean;
|
|
1972
2060
|
/**
|
|
@@ -2575,7 +2663,7 @@ declare class BitfabFunction {
|
|
|
2575
2663
|
/**
|
|
2576
2664
|
* SDK version from package.json (injected at build time)
|
|
2577
2665
|
*/
|
|
2578
|
-
declare const __version__ = "0.
|
|
2666
|
+
declare const __version__ = "0.38.0";
|
|
2579
2667
|
|
|
2580
2668
|
/**
|
|
2581
2669
|
* Constants for the Bitfab SDK.
|
|
@@ -2643,4 +2731,4 @@ declare const finalizers: {
|
|
|
2643
2731
|
readableStream: typeof readableStream;
|
|
2644
2732
|
};
|
|
2645
2733
|
|
|
2646
|
-
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
|
|
2734
|
+
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayProgress, type ReplayProgressItem, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getCurrentReplayBranch,
|
|
12
12
|
getCurrentSpan,
|
|
13
13
|
getCurrentTrace
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LCGQUVKR.js";
|
|
15
15
|
import {
|
|
16
16
|
BITFAB_PROGRESS_PREFIX,
|
|
17
17
|
BitfabError,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
flushTraces,
|
|
24
24
|
reportReplayProgress,
|
|
25
25
|
serializeReplayResult
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-SSNTMROV.js";
|
|
27
27
|
export {
|
|
28
28
|
BITFAB_PROGRESS_PREFIX,
|
|
29
29
|
Bitfab,
|