bitfab 0.53.0 → 0.53.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -317,6 +317,16 @@ interface ReplayContext {
317
317
  dbSnapshotAccessed?: boolean;
318
318
  }
319
319
 
320
+ interface SimulationPlanNode {
321
+ traceFunctionKey: string;
322
+ name: string;
323
+ captureContent: boolean;
324
+ }
325
+ interface SimulationPlanResponse {
326
+ nodes: SimulationPlanNode[];
327
+ }
328
+ type SimulationPlanSubmit = (payload: Record<string, unknown>) => void;
329
+
320
330
  /**
321
331
  * HTTP client utilities for Bitfab API requests.
322
332
  *
@@ -399,6 +409,10 @@ declare class HttpClient {
399
409
  private readonly deferredWork;
400
410
  private closed;
401
411
  private closing;
412
+ externalSpanTransform: ((payload: Record<string, unknown>, submit: SimulationPlanSubmit) => void) | undefined;
413
+ externalTraceTransform: ((payload: Record<string, unknown>, submit: SimulationPlanSubmit) => void) | undefined;
414
+ releaseHeldExternalSpans: ((timeoutMs: number) => Promise<void>) | undefined;
415
+ stopSimulationPlan: (() => void) | undefined;
402
416
  constructor(config: HttpClientConfig);
403
417
  /**
404
418
  * Resolve the API key at the moment it is needed (request time), invoking
@@ -511,25 +525,21 @@ declare class HttpClient {
511
525
  */
512
526
  lookupFunction<T>(name: string): Promise<T>;
513
527
  getAutoTracePolicy<T>(traceFunctionKey: string, protocol: string): Promise<T>;
528
+ getSimulationPlan(): Promise<SimulationPlanResponse>;
514
529
  getTraceSpan(traceId: string, lookup: SpanLookup): Promise<CapturedSpan | null>;
515
530
  /**
516
531
  * GET a JSON endpoint on the service with the client's API key. Throws a
517
532
  * `BitfabError` carrying the status text for any non-2xx response.
518
533
  */
519
- get<T>(endpoint: string): Promise<T>;
534
+ get<T>(endpoint: string, timeoutMs?: number, extraHeaders?: Record<string, string>): Promise<T>;
520
535
  /**
521
536
  * Queue an internal trace (from local BAML execution via `call()`) onto this
522
537
  * client's batching transport. `functionId` moves into the payload because
523
538
  * the OTLP carrier has no path to carry it.
524
539
  */
525
540
  sendInternalTrace(functionId: string, payload: Record<string, unknown>): void;
526
- /**
527
- * Queue an external span (from withSpan wrapper or OpenAI tracing) onto this
528
- * client's batching transport. Fire-and-forget: the transport owns delivery,
529
- * so callers await `flushTraces()` or `close()` rather than a per-span
530
- * promise.
531
- */
532
541
  sendExternalSpan(payload: Record<string, unknown>): void;
542
+ submitExternalSpan(payload: Record<string, unknown>): void;
533
543
  /**
534
544
  * Queue an external trace completion (from OpenAI tracing) onto this
535
545
  * client's batching transport. Fire-and-forget for the same reason as
@@ -537,6 +547,7 @@ declare class HttpClient {
537
547
  * server-authoritative barrier in `replay.ts`, not by awaiting this call.
538
548
  */
539
549
  sendExternalTrace(rawPayload: Record<string, unknown>): void;
550
+ submitExternalTrace(payload: Record<string, unknown>): void;
540
551
  /**
541
552
  * Partial update of an existing trace identified by its Bitfab trace ID.
542
553
  * Used by the detached `client.getTrace(id)` handle.
@@ -1058,9 +1069,9 @@ declare class BitfabClaudeAgentHandler {
1058
1069
  * The span records the call parameters (the prompt/messages) as its input and a
1059
1070
  * serializable summary (`{ text, toolCalls, usage, finishReason }`) as its
1060
1071
  * output. Streaming is handled by passing the model's stream through a
1061
- * transform that accumulates the assembled text/usage as the caller consumes
1062
- * it: the live stream is handed back unchanged (first-byte latency untouched)
1063
- * and the span is finalized once the stream completes.
1072
+ * reader that accumulates text and usage as the caller consumes it. Parts,
1073
+ * upstream errors, and cancellation propagate to the caller unchanged; the
1074
+ * span finalizes on completion, error, or cancellation with partial output.
1064
1075
  *
1065
1076
  * The middleware is fully duck-typed (no static or dynamic `ai` import), so it
1066
1077
  * adds no dependency and is browser-safe. It works with `ai` v5 and v6.
@@ -1069,6 +1080,7 @@ type LlmSpanOptions = {
1069
1080
  type: "llm";
1070
1081
  finalize: (result: unknown) => unknown | Promise<unknown>;
1071
1082
  surface: "inherit";
1083
+ instrumentation: "vercel-ai";
1072
1084
  };
1073
1085
  type WithSpanFn$1 = <TArgs extends unknown[], TReturn>(traceFunctionKey: string, options: LlmSpanOptions, fn: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
1074
1086
  /**
@@ -1100,6 +1112,7 @@ interface VercelGenerateResult {
1100
1112
  /** Duck-typed subset of a single streaming part from `doStream`. */
1101
1113
  interface VercelStreamPart {
1102
1114
  type: string;
1115
+ error?: unknown;
1103
1116
  delta?: string;
1104
1117
  textDelta?: string;
1105
1118
  toolCallId?: string;
@@ -1473,6 +1486,7 @@ interface SpanClient {
1473
1486
  mockOnReplay?: boolean;
1474
1487
  finalize?: (result: unknown) => unknown | Promise<unknown>;
1475
1488
  surface?: "inherit";
1489
+ instrumentation?: "langgraph";
1476
1490
  }, fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
1477
1491
  }
1478
1492
  interface LangGraphTool {
@@ -1580,6 +1594,7 @@ type RootSpanOptions = {
1580
1594
  type: "agent";
1581
1595
  finalize: (result: unknown) => unknown | Promise<unknown>;
1582
1596
  surface: "inherit";
1597
+ instrumentation: "openai-agents";
1583
1598
  };
1584
1599
  type WithSpanFn = <TArgs extends unknown[], TReturn>(traceFunctionKey: string, options: RootSpanOptions, fn: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
1585
1600
  type GetActiveSpanContextFn = () => unknown | null;
@@ -2522,6 +2537,7 @@ interface BitfabConfig {
2522
2537
  * a branch materialized from that point.
2523
2538
  */
2524
2539
  dbSnapshot?: DbSnapshotConfig;
2540
+ simulationPlan?: boolean;
2525
2541
  }
2526
2542
  /**
2527
2543
  * Span types matching the backend enum.
@@ -2675,6 +2691,7 @@ declare class Bitfab {
2675
2691
  private readonly bamlClient;
2676
2692
  private readonly dbSnapshot;
2677
2693
  private readonly autoTracePolicyRefreshes;
2694
+ private readonly simulationPlan;
2678
2695
  /**
2679
2696
  * Mock overrides registered via {@link Bitfab.registerMockOverride}, applied
2680
2697
  * to every `replay` on this client (after any per-call `mockOverride`). In
@@ -2750,6 +2767,7 @@ declare class Bitfab {
2750
2767
  private resolveNodeConfiguration;
2751
2768
  private createAutoTraceNode;
2752
2769
  private createAutoTraceRoot;
2770
+ private applySimulationPlan;
2753
2771
  private refreshAutoTraceCapturePolicy;
2754
2772
  /**
2755
2773
  * Flush and permanently close this client's tracing resources: its pending
@@ -3326,7 +3344,7 @@ interface CommitRef {
3326
3344
  /**
3327
3345
  * SDK version from package.json (injected at build time)
3328
3346
  */
3329
- declare const __version__ = "0.53.0";
3347
+ declare const __version__ = "0.53.2";
3330
3348
 
3331
3349
  /**
3332
3350
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -317,6 +317,16 @@ interface ReplayContext {
317
317
  dbSnapshotAccessed?: boolean;
318
318
  }
319
319
 
320
+ interface SimulationPlanNode {
321
+ traceFunctionKey: string;
322
+ name: string;
323
+ captureContent: boolean;
324
+ }
325
+ interface SimulationPlanResponse {
326
+ nodes: SimulationPlanNode[];
327
+ }
328
+ type SimulationPlanSubmit = (payload: Record<string, unknown>) => void;
329
+
320
330
  /**
321
331
  * HTTP client utilities for Bitfab API requests.
322
332
  *
@@ -399,6 +409,10 @@ declare class HttpClient {
399
409
  private readonly deferredWork;
400
410
  private closed;
401
411
  private closing;
412
+ externalSpanTransform: ((payload: Record<string, unknown>, submit: SimulationPlanSubmit) => void) | undefined;
413
+ externalTraceTransform: ((payload: Record<string, unknown>, submit: SimulationPlanSubmit) => void) | undefined;
414
+ releaseHeldExternalSpans: ((timeoutMs: number) => Promise<void>) | undefined;
415
+ stopSimulationPlan: (() => void) | undefined;
402
416
  constructor(config: HttpClientConfig);
403
417
  /**
404
418
  * Resolve the API key at the moment it is needed (request time), invoking
@@ -511,25 +525,21 @@ declare class HttpClient {
511
525
  */
512
526
  lookupFunction<T>(name: string): Promise<T>;
513
527
  getAutoTracePolicy<T>(traceFunctionKey: string, protocol: string): Promise<T>;
528
+ getSimulationPlan(): Promise<SimulationPlanResponse>;
514
529
  getTraceSpan(traceId: string, lookup: SpanLookup): Promise<CapturedSpan | null>;
515
530
  /**
516
531
  * GET a JSON endpoint on the service with the client's API key. Throws a
517
532
  * `BitfabError` carrying the status text for any non-2xx response.
518
533
  */
519
- get<T>(endpoint: string): Promise<T>;
534
+ get<T>(endpoint: string, timeoutMs?: number, extraHeaders?: Record<string, string>): Promise<T>;
520
535
  /**
521
536
  * Queue an internal trace (from local BAML execution via `call()`) onto this
522
537
  * client's batching transport. `functionId` moves into the payload because
523
538
  * the OTLP carrier has no path to carry it.
524
539
  */
525
540
  sendInternalTrace(functionId: string, payload: Record<string, unknown>): void;
526
- /**
527
- * Queue an external span (from withSpan wrapper or OpenAI tracing) onto this
528
- * client's batching transport. Fire-and-forget: the transport owns delivery,
529
- * so callers await `flushTraces()` or `close()` rather than a per-span
530
- * promise.
531
- */
532
541
  sendExternalSpan(payload: Record<string, unknown>): void;
542
+ submitExternalSpan(payload: Record<string, unknown>): void;
533
543
  /**
534
544
  * Queue an external trace completion (from OpenAI tracing) onto this
535
545
  * client's batching transport. Fire-and-forget for the same reason as
@@ -537,6 +547,7 @@ declare class HttpClient {
537
547
  * server-authoritative barrier in `replay.ts`, not by awaiting this call.
538
548
  */
539
549
  sendExternalTrace(rawPayload: Record<string, unknown>): void;
550
+ submitExternalTrace(payload: Record<string, unknown>): void;
540
551
  /**
541
552
  * Partial update of an existing trace identified by its Bitfab trace ID.
542
553
  * Used by the detached `client.getTrace(id)` handle.
@@ -1058,9 +1069,9 @@ declare class BitfabClaudeAgentHandler {
1058
1069
  * The span records the call parameters (the prompt/messages) as its input and a
1059
1070
  * serializable summary (`{ text, toolCalls, usage, finishReason }`) as its
1060
1071
  * output. Streaming is handled by passing the model's stream through a
1061
- * transform that accumulates the assembled text/usage as the caller consumes
1062
- * it: the live stream is handed back unchanged (first-byte latency untouched)
1063
- * and the span is finalized once the stream completes.
1072
+ * reader that accumulates text and usage as the caller consumes it. Parts,
1073
+ * upstream errors, and cancellation propagate to the caller unchanged; the
1074
+ * span finalizes on completion, error, or cancellation with partial output.
1064
1075
  *
1065
1076
  * The middleware is fully duck-typed (no static or dynamic `ai` import), so it
1066
1077
  * adds no dependency and is browser-safe. It works with `ai` v5 and v6.
@@ -1069,6 +1080,7 @@ type LlmSpanOptions = {
1069
1080
  type: "llm";
1070
1081
  finalize: (result: unknown) => unknown | Promise<unknown>;
1071
1082
  surface: "inherit";
1083
+ instrumentation: "vercel-ai";
1072
1084
  };
1073
1085
  type WithSpanFn$1 = <TArgs extends unknown[], TReturn>(traceFunctionKey: string, options: LlmSpanOptions, fn: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
1074
1086
  /**
@@ -1100,6 +1112,7 @@ interface VercelGenerateResult {
1100
1112
  /** Duck-typed subset of a single streaming part from `doStream`. */
1101
1113
  interface VercelStreamPart {
1102
1114
  type: string;
1115
+ error?: unknown;
1103
1116
  delta?: string;
1104
1117
  textDelta?: string;
1105
1118
  toolCallId?: string;
@@ -1473,6 +1486,7 @@ interface SpanClient {
1473
1486
  mockOnReplay?: boolean;
1474
1487
  finalize?: (result: unknown) => unknown | Promise<unknown>;
1475
1488
  surface?: "inherit";
1489
+ instrumentation?: "langgraph";
1476
1490
  }, fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
1477
1491
  }
1478
1492
  interface LangGraphTool {
@@ -1580,6 +1594,7 @@ type RootSpanOptions = {
1580
1594
  type: "agent";
1581
1595
  finalize: (result: unknown) => unknown | Promise<unknown>;
1582
1596
  surface: "inherit";
1597
+ instrumentation: "openai-agents";
1583
1598
  };
1584
1599
  type WithSpanFn = <TArgs extends unknown[], TReturn>(traceFunctionKey: string, options: RootSpanOptions, fn: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
1585
1600
  type GetActiveSpanContextFn = () => unknown | null;
@@ -2522,6 +2537,7 @@ interface BitfabConfig {
2522
2537
  * a branch materialized from that point.
2523
2538
  */
2524
2539
  dbSnapshot?: DbSnapshotConfig;
2540
+ simulationPlan?: boolean;
2525
2541
  }
2526
2542
  /**
2527
2543
  * Span types matching the backend enum.
@@ -2675,6 +2691,7 @@ declare class Bitfab {
2675
2691
  private readonly bamlClient;
2676
2692
  private readonly dbSnapshot;
2677
2693
  private readonly autoTracePolicyRefreshes;
2694
+ private readonly simulationPlan;
2678
2695
  /**
2679
2696
  * Mock overrides registered via {@link Bitfab.registerMockOverride}, applied
2680
2697
  * to every `replay` on this client (after any per-call `mockOverride`). In
@@ -2750,6 +2767,7 @@ declare class Bitfab {
2750
2767
  private resolveNodeConfiguration;
2751
2768
  private createAutoTraceNode;
2752
2769
  private createAutoTraceRoot;
2770
+ private applySimulationPlan;
2753
2771
  private refreshAutoTraceCapturePolicy;
2754
2772
  /**
2755
2773
  * Flush and permanently close this client's tracing resources: its pending
@@ -3326,7 +3344,7 @@ interface CommitRef {
3326
3344
  /**
3327
3345
  * SDK version from package.json (injected at build time)
3328
3346
  */
3329
- declare const __version__ = "0.53.0";
3347
+ declare const __version__ = "0.53.2";
3330
3348
 
3331
3349
  /**
3332
3350
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  getCurrentTrace,
29
29
  reseedFromRegistry,
30
30
  seedFromRegistry
31
- } from "./chunk-SCXR43UF.js";
31
+ } from "./chunk-6SPWEVFD.js";
32
32
  import "./chunk-E5BLYL5X.js";
33
33
  import {
34
34
  BITFAB_PROGRESS_PREFIX,
@@ -37,7 +37,7 @@ import {
37
37
  ReplayError,
38
38
  reportReplayProgress,
39
39
  serializeReplayResult
40
- } from "./chunk-SJKWUQ3G.js";
40
+ } from "./chunk-V3KD7B3B.js";
41
41
  import {
42
42
  BitfabError,
43
43
  DEFAULT_SERVICE_URL,
@@ -45,7 +45,7 @@ import {
45
45
  MixedTracingError,
46
46
  __version__,
47
47
  flushTraces
48
- } from "./chunk-6IMGAODW.js";
48
+ } from "./chunk-JZAKQDGR.js";
49
49
  import "./chunk-H6LZRFMN.js";
50
50
  export {
51
51
  BITFAB_PROGRESS_PREFIX,