bitfab 0.16.1 → 0.17.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/index.d.cts CHANGED
@@ -147,9 +147,12 @@ declare class BitfabClaudeAgentHandler {
147
147
  /**
148
148
  * Per-trace database snapshot ref capture.
149
149
  *
150
- * When the customer configures `dbSnapshot`, every root span carries a
151
- * `DbSnapshotRef` that pins the DB state at trace open by wall-clock
152
- * timestamp. The Bitfab service uses that timestamp at replay time to
150
+ * Every root span carries a `DbSnapshotRef` that pins the DB state at trace
151
+ * open by wall-clock timestamp. Capturing the timestamp is free (no IO) and
152
+ * harmless, so it happens on every trace regardless of configuration: that
153
+ * lets any trace be replayed against a historical branch later. A `provider`
154
+ * is attached only when the customer configured `dbSnapshot`; when absent it
155
+ * is resolved at replay time. The Bitfab service uses the timestamp to
153
156
  * materialize an ephemeral branch from `customer-main`.
154
157
  */
155
158
  declare const SUPPORTED_PROVIDERS: readonly ["neon"];
@@ -159,14 +162,19 @@ interface DbSnapshotConfig {
159
162
  provider: DbSnapshotProvider;
160
163
  }
161
164
  interface DbSnapshotRef {
162
- provider: DbSnapshotProvider;
163
165
  /**
164
166
  * The wall-clock ISO timestamp the SDK observed immediately before
165
167
  * invoking the wrapped function. The name encodes its provenance:
166
168
  * SDK-observed, wall clock (not monotonic), captured before user code
167
- * began executing.
169
+ * began executing. Always present.
168
170
  */
169
171
  sdkWallClockBeforeFn: string;
172
+ /**
173
+ * The configured provider for server-side branch resolution. Only set when
174
+ * the customer configured `dbSnapshot`; otherwise the provider is resolved
175
+ * at replay time.
176
+ */
177
+ provider?: DbSnapshotProvider;
170
178
  }
171
179
 
172
180
  /**
@@ -812,6 +820,22 @@ declare class Bitfab {
812
820
  * @returns A BitfabLangGraphCallbackHandler configured for this client
813
821
  */
814
822
  getLangGraphCallbackHandler(traceFunctionKey: string): BitfabLangGraphCallbackHandler;
823
+ /**
824
+ * Get a LangChain callback handler for tracing.
825
+ *
826
+ * Alias of {@link getLangGraphCallbackHandler}: LangChain chains and
827
+ * LangGraph graphs share the same callback system, so one handler serves
828
+ * both.
829
+ *
830
+ * ```typescript
831
+ * const handler = client.getLangChainCallbackHandler("my-chain");
832
+ * const result = await chain.invoke(input, { callbacks: [handler] });
833
+ * ```
834
+ *
835
+ * @param traceFunctionKey - Groups traces under this key in Bitfab
836
+ * @returns A BitfabLangGraphCallbackHandler configured for this client
837
+ */
838
+ getLangChainCallbackHandler(traceFunctionKey: string): BitfabLangGraphCallbackHandler;
815
839
  /**
816
840
  * Get a Claude Agent SDK handler for tracing.
817
841
  *
@@ -1027,7 +1051,7 @@ declare class BitfabFunction {
1027
1051
  /**
1028
1052
  * SDK version from package.json (injected at build time)
1029
1053
  */
1030
- declare const __version__ = "0.16.1";
1054
+ declare const __version__ = "0.17.0";
1031
1055
 
1032
1056
  /**
1033
1057
  * Constants for the Bitfab SDK.
@@ -1037,4 +1061,4 @@ declare const __version__ = "0.16.1";
1037
1061
  */
1038
1062
  declare const DEFAULT_SERVICE_URL = "https://bitfab.ai";
1039
1063
 
1040
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
1064
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
package/dist/index.d.ts CHANGED
@@ -147,9 +147,12 @@ declare class BitfabClaudeAgentHandler {
147
147
  /**
148
148
  * Per-trace database snapshot ref capture.
149
149
  *
150
- * When the customer configures `dbSnapshot`, every root span carries a
151
- * `DbSnapshotRef` that pins the DB state at trace open by wall-clock
152
- * timestamp. The Bitfab service uses that timestamp at replay time to
150
+ * Every root span carries a `DbSnapshotRef` that pins the DB state at trace
151
+ * open by wall-clock timestamp. Capturing the timestamp is free (no IO) and
152
+ * harmless, so it happens on every trace regardless of configuration: that
153
+ * lets any trace be replayed against a historical branch later. A `provider`
154
+ * is attached only when the customer configured `dbSnapshot`; when absent it
155
+ * is resolved at replay time. The Bitfab service uses the timestamp to
153
156
  * materialize an ephemeral branch from `customer-main`.
154
157
  */
155
158
  declare const SUPPORTED_PROVIDERS: readonly ["neon"];
@@ -159,14 +162,19 @@ interface DbSnapshotConfig {
159
162
  provider: DbSnapshotProvider;
160
163
  }
161
164
  interface DbSnapshotRef {
162
- provider: DbSnapshotProvider;
163
165
  /**
164
166
  * The wall-clock ISO timestamp the SDK observed immediately before
165
167
  * invoking the wrapped function. The name encodes its provenance:
166
168
  * SDK-observed, wall clock (not monotonic), captured before user code
167
- * began executing.
169
+ * began executing. Always present.
168
170
  */
169
171
  sdkWallClockBeforeFn: string;
172
+ /**
173
+ * The configured provider for server-side branch resolution. Only set when
174
+ * the customer configured `dbSnapshot`; otherwise the provider is resolved
175
+ * at replay time.
176
+ */
177
+ provider?: DbSnapshotProvider;
170
178
  }
171
179
 
172
180
  /**
@@ -812,6 +820,22 @@ declare class Bitfab {
812
820
  * @returns A BitfabLangGraphCallbackHandler configured for this client
813
821
  */
814
822
  getLangGraphCallbackHandler(traceFunctionKey: string): BitfabLangGraphCallbackHandler;
823
+ /**
824
+ * Get a LangChain callback handler for tracing.
825
+ *
826
+ * Alias of {@link getLangGraphCallbackHandler}: LangChain chains and
827
+ * LangGraph graphs share the same callback system, so one handler serves
828
+ * both.
829
+ *
830
+ * ```typescript
831
+ * const handler = client.getLangChainCallbackHandler("my-chain");
832
+ * const result = await chain.invoke(input, { callbacks: [handler] });
833
+ * ```
834
+ *
835
+ * @param traceFunctionKey - Groups traces under this key in Bitfab
836
+ * @returns A BitfabLangGraphCallbackHandler configured for this client
837
+ */
838
+ getLangChainCallbackHandler(traceFunctionKey: string): BitfabLangGraphCallbackHandler;
815
839
  /**
816
840
  * Get a Claude Agent SDK handler for tracing.
817
841
  *
@@ -1027,7 +1051,7 @@ declare class BitfabFunction {
1027
1051
  /**
1028
1052
  * SDK version from package.json (injected at build time)
1029
1053
  */
1030
- declare const __version__ = "0.16.1";
1054
+ declare const __version__ = "0.17.0";
1031
1055
 
1032
1056
  /**
1033
1057
  * Constants for the Bitfab SDK.
@@ -1037,4 +1061,4 @@ declare const __version__ = "0.16.1";
1037
1061
  */
1038
1062
  declare const DEFAULT_SERVICE_URL = "https://bitfab.ai";
1039
1063
 
1040
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
1064
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabOpenAITracingProcessor, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockStrategy, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, type ReplayItem, type ReplayOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type WrapBAMLOptions, type WrappedBamlFn, __version__, flushTraces, getCurrentSpan, getCurrentTrace };
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  flushTraces,
21
21
  getCurrentSpan,
22
22
  getCurrentTrace
23
- } from "./chunk-P4WFJ5O3.js";
23
+ } from "./chunk-M6N633CX.js";
24
24
  import {
25
25
  BitfabError
26
26
  } from "./chunk-QT7HWOKU.js";
@@ -29,6 +29,7 @@ export {
29
29
  BitfabClaudeAgentHandler,
30
30
  BitfabError,
31
31
  BitfabFunction,
32
+ BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler,
32
33
  BitfabLangGraphCallbackHandler,
33
34
  BitfabOpenAITracingProcessor,
34
35
  DEFAULT_SERVICE_URL,
package/dist/node.cjs CHANGED
@@ -435,6 +435,7 @@ __export(node_exports, {
435
435
  BitfabClaudeAgentHandler: () => BitfabClaudeAgentHandler,
436
436
  BitfabError: () => BitfabError,
437
437
  BitfabFunction: () => BitfabFunction,
438
+ BitfabLangChainCallbackHandler: () => BitfabLangGraphCallbackHandler,
438
439
  BitfabLangGraphCallbackHandler: () => BitfabLangGraphCallbackHandler,
439
440
  BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
440
441
  DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
@@ -455,7 +456,7 @@ registerAsyncLocalStorageClass(
455
456
  );
456
457
 
457
458
  // src/version.generated.ts
458
- var __version__ = "0.16.1";
459
+ var __version__ = "0.17.0";
459
460
 
460
461
  // src/constants.ts
461
462
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -1570,8 +1571,8 @@ function validateDbSnapshotConfig(config) {
1570
1571
  }
1571
1572
  function buildSnapshotRef(config, sdkWallClockBeforeFn) {
1572
1573
  return {
1573
- provider: config.provider,
1574
- sdkWallClockBeforeFn
1574
+ sdkWallClockBeforeFn,
1575
+ ...config && { provider: config.provider }
1575
1576
  };
1576
1577
  }
1577
1578
 
@@ -2742,6 +2743,24 @@ var Bitfab = class {
2742
2743
  }
2743
2744
  });
2744
2745
  }
2746
+ /**
2747
+ * Get a LangChain callback handler for tracing.
2748
+ *
2749
+ * Alias of {@link getLangGraphCallbackHandler}: LangChain chains and
2750
+ * LangGraph graphs share the same callback system, so one handler serves
2751
+ * both.
2752
+ *
2753
+ * ```typescript
2754
+ * const handler = client.getLangChainCallbackHandler("my-chain");
2755
+ * const result = await chain.invoke(input, { callbacks: [handler] });
2756
+ * ```
2757
+ *
2758
+ * @param traceFunctionKey - Groups traces under this key in Bitfab
2759
+ * @returns A BitfabLangGraphCallbackHandler configured for this client
2760
+ */
2761
+ getLangChainCallbackHandler(traceFunctionKey) {
2762
+ return this.getLangGraphCallbackHandler(traceFunctionKey);
2763
+ }
2745
2764
  /**
2746
2765
  * Get a Claude Agent SDK handler for tracing.
2747
2766
  *
@@ -2928,7 +2947,7 @@ var Bitfab = class {
2928
2947
  const startedAt = (/* @__PURE__ */ new Date()).toISOString();
2929
2948
  if (isRootSpan && !activeTraceStates.has(traceId)) {
2930
2949
  const replayCtxAtRoot = getReplayContext();
2931
- const dbSnapshotRef = self.dbSnapshot ? buildSnapshotRef(self.dbSnapshot, startedAt) : void 0;
2950
+ const dbSnapshotRef = buildSnapshotRef(self.dbSnapshot, startedAt);
2932
2951
  activeTraceStates.set(traceId, {
2933
2952
  traceId,
2934
2953
  startedAt,
@@ -2939,7 +2958,7 @@ var Bitfab = class {
2939
2958
  ...replayCtxAtRoot?.inputSourceTraceId && {
2940
2959
  inputSourceTraceId: replayCtxAtRoot.inputSourceTraceId
2941
2960
  },
2942
- ...dbSnapshotRef && { dbSnapshotRef }
2961
+ dbSnapshotRef
2943
2962
  });
2944
2963
  pendingSpanPromises.set(traceId, []);
2945
2964
  }
@@ -3325,6 +3344,7 @@ assertAsyncStorageRegistered();
3325
3344
  BitfabClaudeAgentHandler,
3326
3345
  BitfabError,
3327
3346
  BitfabFunction,
3347
+ BitfabLangChainCallbackHandler,
3328
3348
  BitfabLangGraphCallbackHandler,
3329
3349
  BitfabOpenAITracingProcessor,
3330
3350
  DEFAULT_SERVICE_URL,