bitfab 0.11.4 → 0.11.6

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
@@ -171,6 +171,18 @@ interface TokenUsage {
171
171
  cached: number | null;
172
172
  total: number | null;
173
173
  }
174
+ /**
175
+ * Describes a single file edited as part of a code change.
176
+ *
177
+ * - `path`: file path (relative to the repo root, or any consistent root)
178
+ * - `before`: file contents before the change ("" for newly created files)
179
+ * - `after`: file contents after the change ("" for deleted files)
180
+ */
181
+ interface CodeChangeFile {
182
+ path: string;
183
+ before: string;
184
+ after: string;
185
+ }
174
186
 
175
187
  /**
176
188
  * LangGraph/LangChain callback handler for Bitfab tracing.
@@ -253,6 +265,18 @@ interface ReplayOptions {
253
265
  traceIds?: string[];
254
266
  /** Maximum number of items to process in parallel. Set to 1 for sequential. Default 10. */
255
267
  maxConcurrency?: number;
268
+ /**
269
+ * Description of the code change being tested in this replay. Stored on
270
+ * the resulting experiment so the change can be reviewed alongside results.
271
+ */
272
+ codeChangeDescription?: string;
273
+ /**
274
+ * Files edited as part of this code change. Each entry holds the file path
275
+ * and the full `before`/`after` contents — the agent reads each file before
276
+ * and after editing and passes the two strings. Use `""` for newly created
277
+ * files (`before`) or deleted files (`after`).
278
+ */
279
+ codeChangeFiles?: CodeChangeFile[];
256
280
  }
257
281
  interface ReplayItem<T> {
258
282
  /** Deserialized inputs from the original trace. */
@@ -714,6 +738,8 @@ declare class Bitfab {
714
738
  limit?: number;
715
739
  traceIds?: string[];
716
740
  maxConcurrency?: number;
741
+ codeChangeDescription?: string;
742
+ codeChangeFiles?: CodeChangeFile[];
717
743
  }): Promise<ReplayResult<TReturn>>;
718
744
  }
719
745
  /**
@@ -777,7 +803,7 @@ declare class BitfabFunction {
777
803
  /**
778
804
  * SDK version from package.json (injected at build time)
779
805
  */
780
- declare const __version__ = "0.11.4";
806
+ declare const __version__ = "0.11.6";
781
807
 
782
808
  /**
783
809
  * Constants for the Bitfab SDK.
@@ -787,4 +813,4 @@ declare const __version__ = "0.11.4";
787
813
  */
788
814
  declare const DEFAULT_SERVICE_URL = "https://bitfab.ai";
789
815
 
790
- export { type ActiveSpanContext, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, 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 };
816
+ 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 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 };
package/dist/index.d.ts CHANGED
@@ -171,6 +171,18 @@ interface TokenUsage {
171
171
  cached: number | null;
172
172
  total: number | null;
173
173
  }
174
+ /**
175
+ * Describes a single file edited as part of a code change.
176
+ *
177
+ * - `path`: file path (relative to the repo root, or any consistent root)
178
+ * - `before`: file contents before the change ("" for newly created files)
179
+ * - `after`: file contents after the change ("" for deleted files)
180
+ */
181
+ interface CodeChangeFile {
182
+ path: string;
183
+ before: string;
184
+ after: string;
185
+ }
174
186
 
175
187
  /**
176
188
  * LangGraph/LangChain callback handler for Bitfab tracing.
@@ -253,6 +265,18 @@ interface ReplayOptions {
253
265
  traceIds?: string[];
254
266
  /** Maximum number of items to process in parallel. Set to 1 for sequential. Default 10. */
255
267
  maxConcurrency?: number;
268
+ /**
269
+ * Description of the code change being tested in this replay. Stored on
270
+ * the resulting experiment so the change can be reviewed alongside results.
271
+ */
272
+ codeChangeDescription?: string;
273
+ /**
274
+ * Files edited as part of this code change. Each entry holds the file path
275
+ * and the full `before`/`after` contents — the agent reads each file before
276
+ * and after editing and passes the two strings. Use `""` for newly created
277
+ * files (`before`) or deleted files (`after`).
278
+ */
279
+ codeChangeFiles?: CodeChangeFile[];
256
280
  }
257
281
  interface ReplayItem<T> {
258
282
  /** Deserialized inputs from the original trace. */
@@ -714,6 +738,8 @@ declare class Bitfab {
714
738
  limit?: number;
715
739
  traceIds?: string[];
716
740
  maxConcurrency?: number;
741
+ codeChangeDescription?: string;
742
+ codeChangeFiles?: CodeChangeFile[];
717
743
  }): Promise<ReplayResult<TReturn>>;
718
744
  }
719
745
  /**
@@ -777,7 +803,7 @@ declare class BitfabFunction {
777
803
  /**
778
804
  * SDK version from package.json (injected at build time)
779
805
  */
780
- declare const __version__ = "0.11.4";
806
+ declare const __version__ = "0.11.6";
781
807
 
782
808
  /**
783
809
  * Constants for the Bitfab SDK.
@@ -787,4 +813,4 @@ declare const __version__ = "0.11.4";
787
813
  */
788
814
  declare const DEFAULT_SERVICE_URL = "https://bitfab.ai";
789
815
 
790
- export { type ActiveSpanContext, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, 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 };
816
+ 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 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 };
package/dist/index.js CHANGED
@@ -6,13 +6,13 @@ import {
6
6
  BitfabOpenAITracingProcessor,
7
7
  getCurrentSpan,
8
8
  getCurrentTrace
9
- } from "./chunk-I3OKZ2TF.js";
9
+ } from "./chunk-MTHBHBOD.js";
10
10
  import {
11
11
  BitfabError,
12
12
  DEFAULT_SERVICE_URL,
13
13
  __version__,
14
14
  flushTraces
15
- } from "./chunk-KAX2QQPS.js";
15
+ } from "./chunk-VOSASRED.js";
16
16
  export {
17
17
  Bitfab,
18
18
  BitfabClaudeAgentHandler,
package/dist/node.cjs CHANGED
@@ -81,7 +81,7 @@ var __version__;
81
81
  var init_version_generated = __esm({
82
82
  "src/version.generated.ts"() {
83
83
  "use strict";
84
- __version__ = "0.11.4";
84
+ __version__ = "0.11.6";
85
85
  }
86
86
  });
87
87
 
@@ -285,11 +285,17 @@ var init_http = __esm({
285
285
  * Start a replay session by fetching historical traces.
286
286
  * Blocking call — creates a test run and returns lightweight item references.
287
287
  */
288
- async startReplay(traceFunctionKey, limit, traceIds) {
288
+ async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles) {
289
289
  const payload = { traceFunctionKey, limit };
290
290
  if (traceIds) {
291
291
  payload.traceIds = traceIds;
292
292
  }
293
+ if (codeChangeDescription !== void 0) {
294
+ payload.codeChangeDescription = codeChangeDescription;
295
+ }
296
+ if (codeChangeFiles !== void 0) {
297
+ payload.codeChangeFiles = codeChangeFiles;
298
+ }
293
299
  return this.request("/api/sdk/replay/start", payload, {
294
300
  timeout: 3e4
295
301
  });
@@ -434,7 +440,11 @@ async function processItem(httpClient, serverItem, fn, testRunId) {
434
440
  let error = null;
435
441
  try {
436
442
  const maybePromise = runWithReplayContext(
437
- { testRunId, inputSourceSpanId: span.id },
443
+ {
444
+ testRunId,
445
+ inputSourceSpanId: span.id,
446
+ inputSourceTraceId: span.externalTraceId
447
+ },
438
448
  () => fn(...inputs)
439
449
  );
440
450
  result = maybePromise instanceof Promise ? await maybePromise : maybePromise;
@@ -476,7 +486,9 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
476
486
  } = await httpClient.startReplay(
477
487
  traceFunctionKey,
478
488
  options?.limit ?? 5,
479
- options?.traceIds
489
+ options?.traceIds,
490
+ options?.codeChangeDescription,
491
+ options?.codeChangeFiles
480
492
  );
481
493
  const maxConcurrency = options?.maxConcurrency ?? 10;
482
494
  const tasks = serverItems.map(
@@ -2561,6 +2573,9 @@ var Bitfab = class {
2561
2573
  contexts: [],
2562
2574
  ...replayCtxAtRoot?.testRunId && {
2563
2575
  testRunId: replayCtxAtRoot.testRunId
2576
+ },
2577
+ ...replayCtxAtRoot?.inputSourceTraceId && {
2578
+ inputSourceTraceId: replayCtxAtRoot.inputSourceTraceId
2564
2579
  }
2565
2580
  });
2566
2581
  pendingSpanPromises.set(traceId, []);
@@ -2609,7 +2624,8 @@ var Bitfab = class {
2609
2624
  sessionId: traceState?.sessionId,
2610
2625
  metadata: traceState?.metadata,
2611
2626
  contexts: traceState?.contexts ?? [],
2612
- testRunId: traceState?.testRunId
2627
+ testRunId: traceState?.testRunId,
2628
+ inputSourceTraceId: traceState?.inputSourceTraceId
2613
2629
  });
2614
2630
  activeTraceStates.delete(traceId);
2615
2631
  } else {
@@ -2686,6 +2702,9 @@ var Bitfab = class {
2686
2702
  if (params.contexts && params.contexts.length > 0) {
2687
2703
  rawTrace.contexts = params.contexts;
2688
2704
  }
2705
+ if (params.inputSourceTraceId) {
2706
+ rawTrace.input_source_trace_id = params.inputSourceTraceId;
2707
+ }
2689
2708
  this.httpClient.sendExternalTrace({
2690
2709
  type: "sdk-function",
2691
2710
  source: "typescript-sdk-function",