@bitfab/sdk 0.28.2 → 0.28.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-NZFPJRD3.js → chunk-3F46BMPM.js} +18 -18
- package/dist/chunk-3F46BMPM.js.map +1 -0
- package/dist/{chunk-3PCOUZZP.js → chunk-SAGZ674W.js} +22 -7
- package/dist/chunk-SAGZ674W.js.map +1 -0
- package/dist/index.cjs +35 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -18
- package/dist/index.d.ts +18 -18
- package/dist/index.js +2 -2
- package/dist/node.cjs +36 -21
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +2 -2
- package/dist/node.js.map +1 -1
- package/dist/{replay-PZKPWKMV.js → replay-3E43G7OC.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-3PCOUZZP.js.map +0 -1
- package/dist/chunk-NZFPJRD3.js.map +0 -1
- /package/dist/{replay-PZKPWKMV.js.map → replay-3E43G7OC.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -137,7 +137,7 @@ interface ActiveSpanContext$2 {
|
|
|
137
137
|
* Bitfab spans with proper parent-child hierarchy.
|
|
138
138
|
*
|
|
139
139
|
* The TypeScript Claude Agent SDK exposes a single `query()` entry point (there
|
|
140
|
-
* is no `ClaudeSDKClient` class
|
|
140
|
+
* is no `ClaudeSDKClient` class - that exists only in the Python SDK). Wrap the
|
|
141
141
|
* `query()` async iterator with `wrapQuery`; tool and subagent spans come from
|
|
142
142
|
* the hooks injected by `instrumentOptions`.
|
|
143
143
|
*
|
|
@@ -221,7 +221,7 @@ declare class BitfabClaudeAgentHandler {
|
|
|
221
221
|
* SDK's `wrapResponse` (which wraps `ClaudeSDKClient.receiveResponse()`);
|
|
222
222
|
* in TypeScript, prefer `wrapQuery` around `query()`.
|
|
223
223
|
*
|
|
224
|
-
* Pass `{ input }` (the prompt) to record a replayable root span
|
|
224
|
+
* Pass `{ input }` (the prompt) to record a replayable root span - see
|
|
225
225
|
* `wrapQuery`.
|
|
226
226
|
*/
|
|
227
227
|
wrapResponse(stream: AsyncIterable<unknown>, opts?: {
|
|
@@ -233,8 +233,8 @@ declare class BitfabClaudeAgentHandler {
|
|
|
233
233
|
* Tool and subagent spans are captured separately via the hooks injected
|
|
234
234
|
* by `instrumentOptions` into the `options` passed to `query()`.
|
|
235
235
|
*
|
|
236
|
-
* Pass `{ input }`
|
|
237
|
-
*
|
|
236
|
+
* Pass `{ input }` - the prompt (or the serializable args that produced it)
|
|
237
|
+
* - to make a handler-only run replayable: the handler records a root `agent`
|
|
238
238
|
* span with that input, so `replay(key, fn)` can re-feed it. Omit it only
|
|
239
239
|
* when an enclosing `withSpan` already supplies the replayable root.
|
|
240
240
|
*
|
|
@@ -445,7 +445,7 @@ declare class BitfabLangGraphCallbackHandler {
|
|
|
445
445
|
*
|
|
446
446
|
* 1. A process-wide `TracingProcessor` (see `getOpenAiTracingProcessor` /
|
|
447
447
|
* `BitfabOpenAITracingProcessor`) registered once with `addTraceProcessor`.
|
|
448
|
-
* It captures everything *inside* a run
|
|
448
|
+
* It captures everything *inside* a run - LLM calls, tool calls, handoffs -
|
|
449
449
|
* as Bitfab spans.
|
|
450
450
|
* 2. This handler's `wrapRun`, which owns the *root*. The processor never sees
|
|
451
451
|
* the caller's input (the SDK's trace events don't carry it), so a
|
|
@@ -516,7 +516,7 @@ declare class BitfabOpenAIAgentHandler {
|
|
|
516
516
|
* argument, so `replay(key, fn)` re-feeds it), and the run's `finalOutput`
|
|
517
517
|
* is recorded as the root output. For streaming runs (`{ stream: true }`),
|
|
518
518
|
* the result is handed back immediately and the final output is recorded
|
|
519
|
-
* once the stream completes
|
|
519
|
+
* once the stream completes - first-byte latency is untouched.
|
|
520
520
|
*
|
|
521
521
|
* The process-wide tracing processor (`getOpenAiTracingProcessor`) must still
|
|
522
522
|
* be registered: it captures the LLM/tool/handoff spans that nest beneath
|
|
@@ -542,7 +542,7 @@ declare class BitfabOpenAIAgentHandler {
|
|
|
542
542
|
* even when the SDK runs items in parallel.
|
|
543
543
|
*
|
|
544
544
|
* Internally, the resolved per-item state is a `DbBranchLease` (see
|
|
545
|
-
* replayContext.ts)
|
|
545
|
+
* replayContext.ts) - that's the SDK ↔ server protocol term. We expose
|
|
546
546
|
* its useful fields directly here so customer code never sees the word.
|
|
547
547
|
*/
|
|
548
548
|
interface ReplayEnvironmentSnapshot {
|
|
@@ -576,7 +576,7 @@ declare class ReplayEnvironment {
|
|
|
576
576
|
snapshot(): ReplayEnvironmentSnapshot | null;
|
|
577
577
|
/**
|
|
578
578
|
* Record on the replay context that customer code obtained the branch
|
|
579
|
-
* URL. Only `databaseUrl` and `snapshot()` count
|
|
579
|
+
* URL. Only `databaseUrl` and `snapshot()` count - `active`, `readOnly`
|
|
580
580
|
* and friends inspect the lease without exposing the connection string,
|
|
581
581
|
* so they don't prove the replayed code could have connected to the
|
|
582
582
|
* branch.
|
|
@@ -623,9 +623,9 @@ interface ReplayOptions {
|
|
|
623
623
|
codeChangeFiles?: CodeChangeFile[];
|
|
624
624
|
/**
|
|
625
625
|
* Mock strategy for child spans during replay.
|
|
626
|
-
* - "
|
|
626
|
+
* - "marked": only spans tagged with { mockOnReplay: true } in SpanOptions are mocked (default)
|
|
627
|
+
* - "none": everything runs real code
|
|
627
628
|
* - "all": every child withSpan returns historical output
|
|
628
|
-
* - "marked": only spans tagged with { mockOnReplay: true } in SpanOptions are mocked
|
|
629
629
|
*/
|
|
630
630
|
mock?: MockStrategy;
|
|
631
631
|
/**
|
|
@@ -968,7 +968,7 @@ interface CurrentSpan {
|
|
|
968
968
|
* A detached handle to a previously-created trace, looked up by its
|
|
969
969
|
* caller-supplied id (the same id passed when the trace was started).
|
|
970
970
|
*
|
|
971
|
-
* Unlike `getCurrentTrace()`, this handle is not tied to AsyncLocalStorage
|
|
971
|
+
* Unlike `getCurrentTrace()`, this handle is not tied to AsyncLocalStorage -
|
|
972
972
|
* each method sends to the server immediately. Useful for adding context
|
|
973
973
|
* to a trace from a different process, request, or thread (e.g. a forked
|
|
974
974
|
* agent that wants to annotate the original conversation's trace).
|
|
@@ -1102,7 +1102,7 @@ interface SpanOptions {
|
|
|
1102
1102
|
* ignored outside replay and under the "all"/"none" strategies.
|
|
1103
1103
|
*
|
|
1104
1104
|
* Use this for child spans that are expensive (paid LLM/API calls),
|
|
1105
|
-
* slow, or non-deterministic
|
|
1105
|
+
* slow, or non-deterministic - the root function still runs real code,
|
|
1106
1106
|
* only the marked descendants return their recorded output.
|
|
1107
1107
|
*/
|
|
1108
1108
|
mockOnReplay?: boolean;
|
|
@@ -1324,7 +1324,7 @@ declare class Bitfab {
|
|
|
1324
1324
|
* Wrap a BAML client method to automatically capture prompt and LLM metadata.
|
|
1325
1325
|
*
|
|
1326
1326
|
* Creates a BAML Collector, calls the method through a tracked client,
|
|
1327
|
-
* then extracts rendered messages and token usage
|
|
1327
|
+
* then extracts rendered messages and token usage - calling setPrompt()
|
|
1328
1328
|
* and addContext() on the current span automatically.
|
|
1329
1329
|
*
|
|
1330
1330
|
* The BAML client can be provided in the constructor or passed explicitly:
|
|
@@ -1385,7 +1385,7 @@ declare class Bitfab {
|
|
|
1385
1385
|
* Get a detached handle to a previously-created trace, looked up by the
|
|
1386
1386
|
* caller-supplied id (the same id passed at trace creation).
|
|
1387
1387
|
*
|
|
1388
|
-
* The returned handle is not tied to AsyncLocalStorage
|
|
1388
|
+
* The returned handle is not tied to AsyncLocalStorage - each method sends
|
|
1389
1389
|
* to the server immediately. Useful for adding context to a trace from a
|
|
1390
1390
|
* different process or thread than the one that created it.
|
|
1391
1391
|
*
|
|
@@ -1443,7 +1443,7 @@ declare class Bitfab {
|
|
|
1443
1443
|
* plain callable: plain callables are wrapped internally so each replayed
|
|
1444
1444
|
* invocation records a trace tied to the test run. The plain-callable form
|
|
1445
1445
|
* is how handler-instrumented workflows (LangGraph/LangChain, Claude Agent
|
|
1446
|
-
* SDK) replay
|
|
1446
|
+
* SDK) replay - those record traces under a key with no `withSpan`-wrapped
|
|
1447
1447
|
* root in the app.
|
|
1448
1448
|
*
|
|
1449
1449
|
* @param traceFunctionKey - The trace function key to replay
|
|
@@ -1571,7 +1571,7 @@ declare class BitfabFunction {
|
|
|
1571
1571
|
*/
|
|
1572
1572
|
getLangGraphCallbackHandler(): BitfabLangGraphCallbackHandler;
|
|
1573
1573
|
/**
|
|
1574
|
-
* Alias of {@link getLangGraphCallbackHandler}
|
|
1574
|
+
* Alias of {@link getLangGraphCallbackHandler} - LangChain and LangGraph
|
|
1575
1575
|
* share one callback system, so the same bound handler serves both.
|
|
1576
1576
|
*
|
|
1577
1577
|
* @returns A LangChain callback handler for this client and key
|
|
@@ -1584,7 +1584,7 @@ declare class BitfabFunction {
|
|
|
1584
1584
|
* Unlike the other methods on this handle, `wrapBAML` does NOT use the bound
|
|
1585
1585
|
* key: it opens no span of its own. It enriches the *current* span (via
|
|
1586
1586
|
* `getCurrentSpan().setPrompt()` / `addContext()`), so call it inside a
|
|
1587
|
-
* function wrapped by this handle's `withSpan`
|
|
1587
|
+
* function wrapped by this handle's `withSpan` - the bound key keys that
|
|
1588
1588
|
* wrapper, and the BAML prompt/metadata attach to it.
|
|
1589
1589
|
*
|
|
1590
1590
|
* @param methodOrClient - Either a BAML method (uses constructor bamlClient) or the BAML client instance
|
|
@@ -1603,7 +1603,7 @@ declare class BitfabFunction {
|
|
|
1603
1603
|
/**
|
|
1604
1604
|
* SDK version from package.json (injected at build time)
|
|
1605
1605
|
*/
|
|
1606
|
-
declare const __version__ = "0.28.
|
|
1606
|
+
declare const __version__ = "0.28.4";
|
|
1607
1607
|
|
|
1608
1608
|
/**
|
|
1609
1609
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -137,7 +137,7 @@ interface ActiveSpanContext$2 {
|
|
|
137
137
|
* Bitfab spans with proper parent-child hierarchy.
|
|
138
138
|
*
|
|
139
139
|
* The TypeScript Claude Agent SDK exposes a single `query()` entry point (there
|
|
140
|
-
* is no `ClaudeSDKClient` class
|
|
140
|
+
* is no `ClaudeSDKClient` class - that exists only in the Python SDK). Wrap the
|
|
141
141
|
* `query()` async iterator with `wrapQuery`; tool and subagent spans come from
|
|
142
142
|
* the hooks injected by `instrumentOptions`.
|
|
143
143
|
*
|
|
@@ -221,7 +221,7 @@ declare class BitfabClaudeAgentHandler {
|
|
|
221
221
|
* SDK's `wrapResponse` (which wraps `ClaudeSDKClient.receiveResponse()`);
|
|
222
222
|
* in TypeScript, prefer `wrapQuery` around `query()`.
|
|
223
223
|
*
|
|
224
|
-
* Pass `{ input }` (the prompt) to record a replayable root span
|
|
224
|
+
* Pass `{ input }` (the prompt) to record a replayable root span - see
|
|
225
225
|
* `wrapQuery`.
|
|
226
226
|
*/
|
|
227
227
|
wrapResponse(stream: AsyncIterable<unknown>, opts?: {
|
|
@@ -233,8 +233,8 @@ declare class BitfabClaudeAgentHandler {
|
|
|
233
233
|
* Tool and subagent spans are captured separately via the hooks injected
|
|
234
234
|
* by `instrumentOptions` into the `options` passed to `query()`.
|
|
235
235
|
*
|
|
236
|
-
* Pass `{ input }`
|
|
237
|
-
*
|
|
236
|
+
* Pass `{ input }` - the prompt (or the serializable args that produced it)
|
|
237
|
+
* - to make a handler-only run replayable: the handler records a root `agent`
|
|
238
238
|
* span with that input, so `replay(key, fn)` can re-feed it. Omit it only
|
|
239
239
|
* when an enclosing `withSpan` already supplies the replayable root.
|
|
240
240
|
*
|
|
@@ -445,7 +445,7 @@ declare class BitfabLangGraphCallbackHandler {
|
|
|
445
445
|
*
|
|
446
446
|
* 1. A process-wide `TracingProcessor` (see `getOpenAiTracingProcessor` /
|
|
447
447
|
* `BitfabOpenAITracingProcessor`) registered once with `addTraceProcessor`.
|
|
448
|
-
* It captures everything *inside* a run
|
|
448
|
+
* It captures everything *inside* a run - LLM calls, tool calls, handoffs -
|
|
449
449
|
* as Bitfab spans.
|
|
450
450
|
* 2. This handler's `wrapRun`, which owns the *root*. The processor never sees
|
|
451
451
|
* the caller's input (the SDK's trace events don't carry it), so a
|
|
@@ -516,7 +516,7 @@ declare class BitfabOpenAIAgentHandler {
|
|
|
516
516
|
* argument, so `replay(key, fn)` re-feeds it), and the run's `finalOutput`
|
|
517
517
|
* is recorded as the root output. For streaming runs (`{ stream: true }`),
|
|
518
518
|
* the result is handed back immediately and the final output is recorded
|
|
519
|
-
* once the stream completes
|
|
519
|
+
* once the stream completes - first-byte latency is untouched.
|
|
520
520
|
*
|
|
521
521
|
* The process-wide tracing processor (`getOpenAiTracingProcessor`) must still
|
|
522
522
|
* be registered: it captures the LLM/tool/handoff spans that nest beneath
|
|
@@ -542,7 +542,7 @@ declare class BitfabOpenAIAgentHandler {
|
|
|
542
542
|
* even when the SDK runs items in parallel.
|
|
543
543
|
*
|
|
544
544
|
* Internally, the resolved per-item state is a `DbBranchLease` (see
|
|
545
|
-
* replayContext.ts)
|
|
545
|
+
* replayContext.ts) - that's the SDK ↔ server protocol term. We expose
|
|
546
546
|
* its useful fields directly here so customer code never sees the word.
|
|
547
547
|
*/
|
|
548
548
|
interface ReplayEnvironmentSnapshot {
|
|
@@ -576,7 +576,7 @@ declare class ReplayEnvironment {
|
|
|
576
576
|
snapshot(): ReplayEnvironmentSnapshot | null;
|
|
577
577
|
/**
|
|
578
578
|
* Record on the replay context that customer code obtained the branch
|
|
579
|
-
* URL. Only `databaseUrl` and `snapshot()` count
|
|
579
|
+
* URL. Only `databaseUrl` and `snapshot()` count - `active`, `readOnly`
|
|
580
580
|
* and friends inspect the lease without exposing the connection string,
|
|
581
581
|
* so they don't prove the replayed code could have connected to the
|
|
582
582
|
* branch.
|
|
@@ -623,9 +623,9 @@ interface ReplayOptions {
|
|
|
623
623
|
codeChangeFiles?: CodeChangeFile[];
|
|
624
624
|
/**
|
|
625
625
|
* Mock strategy for child spans during replay.
|
|
626
|
-
* - "
|
|
626
|
+
* - "marked": only spans tagged with { mockOnReplay: true } in SpanOptions are mocked (default)
|
|
627
|
+
* - "none": everything runs real code
|
|
627
628
|
* - "all": every child withSpan returns historical output
|
|
628
|
-
* - "marked": only spans tagged with { mockOnReplay: true } in SpanOptions are mocked
|
|
629
629
|
*/
|
|
630
630
|
mock?: MockStrategy;
|
|
631
631
|
/**
|
|
@@ -968,7 +968,7 @@ interface CurrentSpan {
|
|
|
968
968
|
* A detached handle to a previously-created trace, looked up by its
|
|
969
969
|
* caller-supplied id (the same id passed when the trace was started).
|
|
970
970
|
*
|
|
971
|
-
* Unlike `getCurrentTrace()`, this handle is not tied to AsyncLocalStorage
|
|
971
|
+
* Unlike `getCurrentTrace()`, this handle is not tied to AsyncLocalStorage -
|
|
972
972
|
* each method sends to the server immediately. Useful for adding context
|
|
973
973
|
* to a trace from a different process, request, or thread (e.g. a forked
|
|
974
974
|
* agent that wants to annotate the original conversation's trace).
|
|
@@ -1102,7 +1102,7 @@ interface SpanOptions {
|
|
|
1102
1102
|
* ignored outside replay and under the "all"/"none" strategies.
|
|
1103
1103
|
*
|
|
1104
1104
|
* Use this for child spans that are expensive (paid LLM/API calls),
|
|
1105
|
-
* slow, or non-deterministic
|
|
1105
|
+
* slow, or non-deterministic - the root function still runs real code,
|
|
1106
1106
|
* only the marked descendants return their recorded output.
|
|
1107
1107
|
*/
|
|
1108
1108
|
mockOnReplay?: boolean;
|
|
@@ -1324,7 +1324,7 @@ declare class Bitfab {
|
|
|
1324
1324
|
* Wrap a BAML client method to automatically capture prompt and LLM metadata.
|
|
1325
1325
|
*
|
|
1326
1326
|
* Creates a BAML Collector, calls the method through a tracked client,
|
|
1327
|
-
* then extracts rendered messages and token usage
|
|
1327
|
+
* then extracts rendered messages and token usage - calling setPrompt()
|
|
1328
1328
|
* and addContext() on the current span automatically.
|
|
1329
1329
|
*
|
|
1330
1330
|
* The BAML client can be provided in the constructor or passed explicitly:
|
|
@@ -1385,7 +1385,7 @@ declare class Bitfab {
|
|
|
1385
1385
|
* Get a detached handle to a previously-created trace, looked up by the
|
|
1386
1386
|
* caller-supplied id (the same id passed at trace creation).
|
|
1387
1387
|
*
|
|
1388
|
-
* The returned handle is not tied to AsyncLocalStorage
|
|
1388
|
+
* The returned handle is not tied to AsyncLocalStorage - each method sends
|
|
1389
1389
|
* to the server immediately. Useful for adding context to a trace from a
|
|
1390
1390
|
* different process or thread than the one that created it.
|
|
1391
1391
|
*
|
|
@@ -1443,7 +1443,7 @@ declare class Bitfab {
|
|
|
1443
1443
|
* plain callable: plain callables are wrapped internally so each replayed
|
|
1444
1444
|
* invocation records a trace tied to the test run. The plain-callable form
|
|
1445
1445
|
* is how handler-instrumented workflows (LangGraph/LangChain, Claude Agent
|
|
1446
|
-
* SDK) replay
|
|
1446
|
+
* SDK) replay - those record traces under a key with no `withSpan`-wrapped
|
|
1447
1447
|
* root in the app.
|
|
1448
1448
|
*
|
|
1449
1449
|
* @param traceFunctionKey - The trace function key to replay
|
|
@@ -1571,7 +1571,7 @@ declare class BitfabFunction {
|
|
|
1571
1571
|
*/
|
|
1572
1572
|
getLangGraphCallbackHandler(): BitfabLangGraphCallbackHandler;
|
|
1573
1573
|
/**
|
|
1574
|
-
* Alias of {@link getLangGraphCallbackHandler}
|
|
1574
|
+
* Alias of {@link getLangGraphCallbackHandler} - LangChain and LangGraph
|
|
1575
1575
|
* share one callback system, so the same bound handler serves both.
|
|
1576
1576
|
*
|
|
1577
1577
|
* @returns A LangChain callback handler for this client and key
|
|
@@ -1584,7 +1584,7 @@ declare class BitfabFunction {
|
|
|
1584
1584
|
* Unlike the other methods on this handle, `wrapBAML` does NOT use the bound
|
|
1585
1585
|
* key: it opens no span of its own. It enriches the *current* span (via
|
|
1586
1586
|
* `getCurrentSpan().setPrompt()` / `addContext()`), so call it inside a
|
|
1587
|
-
* function wrapped by this handle's `withSpan`
|
|
1587
|
+
* function wrapped by this handle's `withSpan` - the bound key keys that
|
|
1588
1588
|
* wrapper, and the BAML prompt/metadata attach to it.
|
|
1589
1589
|
*
|
|
1590
1590
|
* @param methodOrClient - Either a BAML method (uses constructor bamlClient) or the BAML client instance
|
|
@@ -1603,7 +1603,7 @@ declare class BitfabFunction {
|
|
|
1603
1603
|
/**
|
|
1604
1604
|
* SDK version from package.json (injected at build time)
|
|
1605
1605
|
*/
|
|
1606
|
-
declare const __version__ = "0.28.
|
|
1606
|
+
declare const __version__ = "0.28.4";
|
|
1607
1607
|
|
|
1608
1608
|
/**
|
|
1609
1609
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
flushTraces,
|
|
15
15
|
getCurrentSpan,
|
|
16
16
|
getCurrentTrace
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-3F46BMPM.js";
|
|
18
18
|
import {
|
|
19
19
|
BITFAB_PROGRESS_PREFIX,
|
|
20
20
|
BitfabError,
|
|
21
21
|
reportReplayProgress
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-SAGZ674W.js";
|
|
23
23
|
export {
|
|
24
24
|
BITFAB_PROGRESS_PREFIX,
|
|
25
25
|
Bitfab,
|
package/dist/node.cjs
CHANGED
|
@@ -40,7 +40,7 @@ function registerAsyncLocalStorageClass(cls) {
|
|
|
40
40
|
function assertAsyncStorageRegistered() {
|
|
41
41
|
if (!AsyncLocalStorageClass) {
|
|
42
42
|
console.warn(
|
|
43
|
-
"Bitfab: AsyncLocalStorage not available
|
|
43
|
+
"Bitfab: AsyncLocalStorage not available - nested span context will not propagate."
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -398,10 +398,25 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
398
398
|
}
|
|
399
399
|
let mockTree;
|
|
400
400
|
if (mockStrategy === "all" || mockStrategy === "marked") {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
401
|
+
try {
|
|
402
|
+
const treeResponse = await httpClient.getSpanTree(
|
|
403
|
+
serverItem.externalSpanId
|
|
404
|
+
);
|
|
405
|
+
if (treeResponse.root) {
|
|
406
|
+
mockTree = buildMockTree(treeResponse.root);
|
|
407
|
+
} else if (mockStrategy === "all") {
|
|
408
|
+
throw new BitfabError(
|
|
409
|
+
`Replay mock strategy "all" requires a span tree root for source span ${serverItem.externalSpanId}.`
|
|
410
|
+
);
|
|
411
|
+
} else {
|
|
412
|
+
mockTree = void 0;
|
|
413
|
+
}
|
|
414
|
+
} catch (e) {
|
|
415
|
+
if (mockStrategy === "all") {
|
|
416
|
+
throw e;
|
|
417
|
+
}
|
|
418
|
+
mockTree = void 0;
|
|
419
|
+
}
|
|
405
420
|
}
|
|
406
421
|
const maybePromise = runWithReplayContext(
|
|
407
422
|
{
|
|
@@ -507,7 +522,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
|
|
|
507
522
|
options?.experimentGroupId,
|
|
508
523
|
options?.datasetId
|
|
509
524
|
);
|
|
510
|
-
const mockStrategy = options?.mock ?? "
|
|
525
|
+
const mockStrategy = options?.mock ?? "marked";
|
|
511
526
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
512
527
|
const tasks = serverItems.map(
|
|
513
528
|
(serverItem) => () => processItem(
|
|
@@ -658,7 +673,7 @@ registerAsyncLocalStorageClass(
|
|
|
658
673
|
);
|
|
659
674
|
|
|
660
675
|
// src/version.generated.ts
|
|
661
|
-
var __version__ = "0.28.
|
|
676
|
+
var __version__ = "0.28.4";
|
|
662
677
|
|
|
663
678
|
// src/constants.ts
|
|
664
679
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -971,7 +986,7 @@ var HttpClient = class {
|
|
|
971
986
|
}
|
|
972
987
|
/**
|
|
973
988
|
* Start a replay session by fetching historical traces.
|
|
974
|
-
* Blocking call
|
|
989
|
+
* Blocking call - creates a test run and returns lightweight item references.
|
|
975
990
|
*/
|
|
976
991
|
async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId) {
|
|
977
992
|
const payload = { traceFunctionKey };
|
|
@@ -1089,7 +1104,7 @@ var HttpClient = class {
|
|
|
1089
1104
|
}
|
|
1090
1105
|
/**
|
|
1091
1106
|
* Ask the server to materialize a per-trace DB branch lease from a
|
|
1092
|
-
* captured `dbSnapshotRef`. Blocking
|
|
1107
|
+
* captured `dbSnapshotRef`. Blocking - the resolver creates a Neon
|
|
1093
1108
|
* snapshot + preview branch and polls operations to readiness, which
|
|
1094
1109
|
* can take seconds.
|
|
1095
1110
|
*/
|
|
@@ -1229,7 +1244,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1229
1244
|
// Synthetic root span (handler-only replay). When an `input` is supplied to
|
|
1230
1245
|
// wrapQuery/wrapResponse, the handler emits a root `agent` span carrying that
|
|
1231
1246
|
// input, so a handler-instrumented run is replayable WITHOUT an enclosing
|
|
1232
|
-
// withSpan
|
|
1247
|
+
// withSpan - matching the LangGraph handler, which records the graph input as
|
|
1233
1248
|
// its root. The prompt is not present anywhere in the message stream, so it
|
|
1234
1249
|
// must be handed in explicitly.
|
|
1235
1250
|
this.hasRootInput = false;
|
|
@@ -1503,7 +1518,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1503
1518
|
* SDK's `wrapResponse` (which wraps `ClaudeSDKClient.receiveResponse()`);
|
|
1504
1519
|
* in TypeScript, prefer `wrapQuery` around `query()`.
|
|
1505
1520
|
*
|
|
1506
|
-
* Pass `{ input }` (the prompt) to record a replayable root span
|
|
1521
|
+
* Pass `{ input }` (the prompt) to record a replayable root span - see
|
|
1507
1522
|
* `wrapQuery`.
|
|
1508
1523
|
*/
|
|
1509
1524
|
async *wrapResponse(stream, opts) {
|
|
@@ -1516,8 +1531,8 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1516
1531
|
* Tool and subagent spans are captured separately via the hooks injected
|
|
1517
1532
|
* by `instrumentOptions` into the `options` passed to `query()`.
|
|
1518
1533
|
*
|
|
1519
|
-
* Pass `{ input }`
|
|
1520
|
-
*
|
|
1534
|
+
* Pass `{ input }` - the prompt (or the serializable args that produced it)
|
|
1535
|
+
* - to make a handler-only run replayable: the handler records a root `agent`
|
|
1521
1536
|
* span with that input, so `replay(key, fn)` can re-feed it. Omit it only
|
|
1522
1537
|
* when an enclosing `withSpan` already supplies the replayable root.
|
|
1523
1538
|
*
|
|
@@ -2629,7 +2644,7 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
2629
2644
|
* argument, so `replay(key, fn)` re-feeds it), and the run's `finalOutput`
|
|
2630
2645
|
* is recorded as the root output. For streaming runs (`{ stream: true }`),
|
|
2631
2646
|
* the result is handed back immediately and the final output is recorded
|
|
2632
|
-
* once the stream completes
|
|
2647
|
+
* once the stream completes - first-byte latency is untouched.
|
|
2633
2648
|
*
|
|
2634
2649
|
* The process-wide tracing processor (`getOpenAiTracingProcessor`) must still
|
|
2635
2650
|
* be registered: it captures the LLM/tool/handoff spans that nest beneath
|
|
@@ -2722,7 +2737,7 @@ var ReplayEnvironment = class {
|
|
|
2722
2737
|
}
|
|
2723
2738
|
/**
|
|
2724
2739
|
* Record on the replay context that customer code obtained the branch
|
|
2725
|
-
* URL. Only `databaseUrl` and `snapshot()` count
|
|
2740
|
+
* URL. Only `databaseUrl` and `snapshot()` count - `active`, `readOnly`
|
|
2726
2741
|
* and friends inspect the lease without exposing the connection string,
|
|
2727
2742
|
* so they don't prove the replayed code could have connected to the
|
|
2728
2743
|
* branch.
|
|
@@ -3447,7 +3462,7 @@ var Bitfab = class {
|
|
|
3447
3462
|
if (this.explicitlyEnabled && !this.apiKeyWarned) {
|
|
3448
3463
|
this.apiKeyWarned = true;
|
|
3449
3464
|
console.warn(
|
|
3450
|
-
"Bitfab: apiKey is empty
|
|
3465
|
+
"Bitfab: apiKey is empty - tracing is disabled. Provide a valid API key to enable tracing."
|
|
3451
3466
|
);
|
|
3452
3467
|
}
|
|
3453
3468
|
return void 0;
|
|
@@ -3711,7 +3726,7 @@ var Bitfab = class {
|
|
|
3711
3726
|
* Wrap a BAML client method to automatically capture prompt and LLM metadata.
|
|
3712
3727
|
*
|
|
3713
3728
|
* Creates a BAML Collector, calls the method through a tracked client,
|
|
3714
|
-
* then extracts rendered messages and token usage
|
|
3729
|
+
* then extracts rendered messages and token usage - calling setPrompt()
|
|
3715
3730
|
* and addContext() on the current span automatically.
|
|
3716
3731
|
*
|
|
3717
3732
|
* The BAML client can be provided in the constructor or passed explicitly:
|
|
@@ -4098,7 +4113,7 @@ var Bitfab = class {
|
|
|
4098
4113
|
* Get a detached handle to a previously-created trace, looked up by the
|
|
4099
4114
|
* caller-supplied id (the same id passed at trace creation).
|
|
4100
4115
|
*
|
|
4101
|
-
* The returned handle is not tied to AsyncLocalStorage
|
|
4116
|
+
* The returned handle is not tied to AsyncLocalStorage - each method sends
|
|
4102
4117
|
* to the server immediately. Useful for adding context to a trace from a
|
|
4103
4118
|
* different process or thread than the one that created it.
|
|
4104
4119
|
*
|
|
@@ -4279,7 +4294,7 @@ var Bitfab = class {
|
|
|
4279
4294
|
* plain callable: plain callables are wrapped internally so each replayed
|
|
4280
4295
|
* invocation records a trace tied to the test run. The plain-callable form
|
|
4281
4296
|
* is how handler-instrumented workflows (LangGraph/LangChain, Claude Agent
|
|
4282
|
-
* SDK) replay
|
|
4297
|
+
* SDK) replay - those record traces under a key with no `withSpan`-wrapped
|
|
4283
4298
|
* root in the app.
|
|
4284
4299
|
*
|
|
4285
4300
|
* @param traceFunctionKey - The trace function key to replay
|
|
@@ -4431,7 +4446,7 @@ var BitfabFunction = class {
|
|
|
4431
4446
|
return this.client.getLangGraphCallbackHandler(this.traceFunctionKey);
|
|
4432
4447
|
}
|
|
4433
4448
|
/**
|
|
4434
|
-
* Alias of {@link getLangGraphCallbackHandler}
|
|
4449
|
+
* Alias of {@link getLangGraphCallbackHandler} - LangChain and LangGraph
|
|
4435
4450
|
* share one callback system, so the same bound handler serves both.
|
|
4436
4451
|
*
|
|
4437
4452
|
* @returns A LangChain callback handler for this client and key
|
|
@@ -4446,7 +4461,7 @@ var BitfabFunction = class {
|
|
|
4446
4461
|
* Unlike the other methods on this handle, `wrapBAML` does NOT use the bound
|
|
4447
4462
|
* key: it opens no span of its own. It enriches the *current* span (via
|
|
4448
4463
|
* `getCurrentSpan().setPrompt()` / `addContext()`), so call it inside a
|
|
4449
|
-
* function wrapped by this handle's `withSpan`
|
|
4464
|
+
* function wrapped by this handle's `withSpan` - the bound key keys that
|
|
4450
4465
|
* wrapper, and the BAML prompt/metadata attach to it.
|
|
4451
4466
|
*
|
|
4452
4467
|
* @param methodOrClient - Either a BAML method (uses constructor bamlClient) or the BAML client instance
|