bitfab 0.54.5 → 0.54.7

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
@@ -426,6 +426,8 @@ declare class HttpClient {
426
426
  * the function form if one was supplied. Never read at construction.
427
427
  */
428
428
  private resolveApiKey;
429
+ /** @internal Whether this client currently has credentials for trace delivery. */
430
+ hasApiKey(): boolean;
429
431
  /**
430
432
  * This client's span transport, built on first use.
431
433
  *
@@ -917,6 +919,7 @@ declare class BitfabClaudeAgentHandler {
917
919
  private readonly ownsHttpClient;
918
920
  private readonly traceFunctionKey;
919
921
  private readonly getActiveSpanContext;
922
+ private readonly shouldRecord;
920
923
  private runToSpan;
921
924
  private traceId;
922
925
  private rootSpanId;
@@ -941,6 +944,7 @@ declare class BitfabClaudeAgentHandler {
941
944
  serviceUrl?: string;
942
945
  timeout?: number;
943
946
  getActiveSpanContext?: () => ActiveSpanContext$2 | null;
947
+ shouldRecord?: () => boolean;
944
948
  /**
945
949
  * The owning `Bitfab` client's HTTP client. Supplied by
946
950
  * `getClaudeAgentHandler()` so this handler shares that client's single
@@ -1412,6 +1416,7 @@ declare class BitfabLangGraphCallbackHandler {
1412
1416
  private readonly ownsHttpClient;
1413
1417
  private readonly traceFunctionKey;
1414
1418
  private readonly getActiveSpanContext;
1419
+ private readonly shouldRecord;
1415
1420
  private readonly captureTools;
1416
1421
  private runToSpan;
1417
1422
  private invocations;
@@ -1421,6 +1426,7 @@ declare class BitfabLangGraphCallbackHandler {
1421
1426
  serviceUrl?: string;
1422
1427
  timeout?: number;
1423
1428
  getActiveSpanContext?: () => ActiveSpanContext$1 | null;
1429
+ shouldRecord?: () => boolean;
1424
1430
  /** Whether callback tool events should emit spans. Defaults to true. */
1425
1431
  captureTools?: boolean;
1426
1432
  /**
@@ -2178,14 +2184,20 @@ type TraceTarget = {
2178
2184
  occurrence?: TraceTargetOccurrence;
2179
2185
  };
2180
2186
  type TraceAssertionSource = "human" | "agent";
2181
- type TraceSearchParams = {
2182
- /** Exact, case-insensitive key/value matches. Multiple entries are ANDed. */
2187
+ type TraceSearchFilters = {
2188
+ callerMetadata?: Record<string, string>;
2189
+ name?: string;
2190
+ nameContains?: string;
2191
+ };
2192
+ type TraceSearchParams = TraceSearchFilters & ({
2183
2193
  callerMetadata: Record<string, string>;
2184
- /** Optionally restrict results to one traced function. */
2194
+ } | {
2195
+ name: string;
2196
+ } | {
2197
+ nameContains: string;
2198
+ }) & {
2185
2199
  traceFunctionKey?: string;
2186
- /** Opaque cursor returned by the previous page. */
2187
2200
  cursor?: string | null;
2188
- /** Page size (default 50, maximum 500). */
2189
2201
  limit?: number;
2190
2202
  };
2191
2203
  type TraceSearchResult = {
@@ -2247,12 +2259,6 @@ type ArchiveAssertionsParams = {
2247
2259
  declare class TracesClient {
2248
2260
  private readonly httpClient;
2249
2261
  constructor(httpClient: HttpClient);
2250
- /**
2251
- * Search traces by exact caller metadata.
2252
- *
2253
- * Keys and values are matched case-insensitively. Up to 10 supplied pairs
2254
- * must match. Use `nextCursor` from the result to fetch another page.
2255
- */
2256
2262
  search(params: TraceSearchParams): Promise<TraceSearchResult>;
2257
2263
  getAssertions(traceId: string): Promise<TraceAssertionsResult>;
2258
2264
  saveAssertions(params: SaveAssertionsParams): Promise<TraceAssertion[]>;
@@ -2322,6 +2328,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
2322
2328
  private readonly ownsHttpClient;
2323
2329
  private activeTraces;
2324
2330
  private readonly getActiveSpanContext;
2331
+ private readonly shouldRecord;
2325
2332
  private activeSpanMappings;
2326
2333
  private canonicalTraceIds;
2327
2334
  private getCanonicalTraceId;
@@ -2335,6 +2342,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
2335
2342
  serviceUrl?: string;
2336
2343
  timeout?: number;
2337
2344
  getActiveSpanContext?: () => ActiveSpanContext | null;
2345
+ shouldRecord?: () => boolean;
2338
2346
  /**
2339
2347
  * The owning `Bitfab` client's HTTP client. Supplied by
2340
2348
  * `getOpenAiTracingProcessor()` so this processor shares that client's
@@ -2878,6 +2886,7 @@ declare class Bitfab {
2878
2886
  private resolveApiKey;
2879
2887
  private isCaptureEnabled;
2880
2888
  private shouldRecord;
2889
+ private prepareFrameworkIntegration;
2881
2890
  get captureEnabled(): boolean;
2882
2891
  /**
2883
2892
  * Fetch the function with its current version and BAML prompt from the server.
@@ -3420,7 +3429,7 @@ interface CommitRef {
3420
3429
  /**
3421
3430
  * SDK version from package.json (injected at build time)
3422
3431
  */
3423
- declare const __version__ = "0.54.5";
3432
+ declare const __version__ = "0.54.7";
3424
3433
 
3425
3434
  /**
3426
3435
  * Constants for the Bitfab SDK.
@@ -3559,4 +3568,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
3559
3568
  run?: boolean;
3560
3569
  }): Promise<SeedResult>;
3561
3570
 
3562
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, AssertionCategoriesClient, type AssertionCategory, type AssertionCategorySummary, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CommitRef, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelUpdate, LabelsClient, type LangGraphIntegrationOptions, type ListDatasetsParams, MixedTracingError, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, type ReseedOptions, type ReseedRegistryResult, type ReseedResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionCategoryParams, type SaveAssertionsAllParams, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceAssertionsUpdate, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type TraceSearchParams, type TraceSearchResult, type TraceTarget, type TraceTargetOccurrence, TracesClient, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, reseedFromRegistry, seedFromRegistry, serializeReplayResult };
3571
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, AssertionCategoriesClient, type AssertionCategory, type AssertionCategorySummary, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CommitRef, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelUpdate, LabelsClient, type LangGraphIntegrationOptions, type ListDatasetsParams, MixedTracingError, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, type ReseedOptions, type ReseedRegistryResult, type ReseedResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionCategoryParams, type SaveAssertionsAllParams, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceAssertionsUpdate, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type TraceSearchFilters, type TraceSearchParams, type TraceSearchResult, type TraceTarget, type TraceTargetOccurrence, TracesClient, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, reseedFromRegistry, seedFromRegistry, serializeReplayResult };
package/dist/index.d.ts CHANGED
@@ -426,6 +426,8 @@ declare class HttpClient {
426
426
  * the function form if one was supplied. Never read at construction.
427
427
  */
428
428
  private resolveApiKey;
429
+ /** @internal Whether this client currently has credentials for trace delivery. */
430
+ hasApiKey(): boolean;
429
431
  /**
430
432
  * This client's span transport, built on first use.
431
433
  *
@@ -917,6 +919,7 @@ declare class BitfabClaudeAgentHandler {
917
919
  private readonly ownsHttpClient;
918
920
  private readonly traceFunctionKey;
919
921
  private readonly getActiveSpanContext;
922
+ private readonly shouldRecord;
920
923
  private runToSpan;
921
924
  private traceId;
922
925
  private rootSpanId;
@@ -941,6 +944,7 @@ declare class BitfabClaudeAgentHandler {
941
944
  serviceUrl?: string;
942
945
  timeout?: number;
943
946
  getActiveSpanContext?: () => ActiveSpanContext$2 | null;
947
+ shouldRecord?: () => boolean;
944
948
  /**
945
949
  * The owning `Bitfab` client's HTTP client. Supplied by
946
950
  * `getClaudeAgentHandler()` so this handler shares that client's single
@@ -1412,6 +1416,7 @@ declare class BitfabLangGraphCallbackHandler {
1412
1416
  private readonly ownsHttpClient;
1413
1417
  private readonly traceFunctionKey;
1414
1418
  private readonly getActiveSpanContext;
1419
+ private readonly shouldRecord;
1415
1420
  private readonly captureTools;
1416
1421
  private runToSpan;
1417
1422
  private invocations;
@@ -1421,6 +1426,7 @@ declare class BitfabLangGraphCallbackHandler {
1421
1426
  serviceUrl?: string;
1422
1427
  timeout?: number;
1423
1428
  getActiveSpanContext?: () => ActiveSpanContext$1 | null;
1429
+ shouldRecord?: () => boolean;
1424
1430
  /** Whether callback tool events should emit spans. Defaults to true. */
1425
1431
  captureTools?: boolean;
1426
1432
  /**
@@ -2178,14 +2184,20 @@ type TraceTarget = {
2178
2184
  occurrence?: TraceTargetOccurrence;
2179
2185
  };
2180
2186
  type TraceAssertionSource = "human" | "agent";
2181
- type TraceSearchParams = {
2182
- /** Exact, case-insensitive key/value matches. Multiple entries are ANDed. */
2187
+ type TraceSearchFilters = {
2188
+ callerMetadata?: Record<string, string>;
2189
+ name?: string;
2190
+ nameContains?: string;
2191
+ };
2192
+ type TraceSearchParams = TraceSearchFilters & ({
2183
2193
  callerMetadata: Record<string, string>;
2184
- /** Optionally restrict results to one traced function. */
2194
+ } | {
2195
+ name: string;
2196
+ } | {
2197
+ nameContains: string;
2198
+ }) & {
2185
2199
  traceFunctionKey?: string;
2186
- /** Opaque cursor returned by the previous page. */
2187
2200
  cursor?: string | null;
2188
- /** Page size (default 50, maximum 500). */
2189
2201
  limit?: number;
2190
2202
  };
2191
2203
  type TraceSearchResult = {
@@ -2247,12 +2259,6 @@ type ArchiveAssertionsParams = {
2247
2259
  declare class TracesClient {
2248
2260
  private readonly httpClient;
2249
2261
  constructor(httpClient: HttpClient);
2250
- /**
2251
- * Search traces by exact caller metadata.
2252
- *
2253
- * Keys and values are matched case-insensitively. Up to 10 supplied pairs
2254
- * must match. Use `nextCursor` from the result to fetch another page.
2255
- */
2256
2262
  search(params: TraceSearchParams): Promise<TraceSearchResult>;
2257
2263
  getAssertions(traceId: string): Promise<TraceAssertionsResult>;
2258
2264
  saveAssertions(params: SaveAssertionsParams): Promise<TraceAssertion[]>;
@@ -2322,6 +2328,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
2322
2328
  private readonly ownsHttpClient;
2323
2329
  private activeTraces;
2324
2330
  private readonly getActiveSpanContext;
2331
+ private readonly shouldRecord;
2325
2332
  private activeSpanMappings;
2326
2333
  private canonicalTraceIds;
2327
2334
  private getCanonicalTraceId;
@@ -2335,6 +2342,7 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
2335
2342
  serviceUrl?: string;
2336
2343
  timeout?: number;
2337
2344
  getActiveSpanContext?: () => ActiveSpanContext | null;
2345
+ shouldRecord?: () => boolean;
2338
2346
  /**
2339
2347
  * The owning `Bitfab` client's HTTP client. Supplied by
2340
2348
  * `getOpenAiTracingProcessor()` so this processor shares that client's
@@ -2878,6 +2886,7 @@ declare class Bitfab {
2878
2886
  private resolveApiKey;
2879
2887
  private isCaptureEnabled;
2880
2888
  private shouldRecord;
2889
+ private prepareFrameworkIntegration;
2881
2890
  get captureEnabled(): boolean;
2882
2891
  /**
2883
2892
  * Fetch the function with its current version and BAML prompt from the server.
@@ -3420,7 +3429,7 @@ interface CommitRef {
3420
3429
  /**
3421
3430
  * SDK version from package.json (injected at build time)
3422
3431
  */
3423
- declare const __version__ = "0.54.5";
3432
+ declare const __version__ = "0.54.7";
3424
3433
 
3425
3434
  /**
3426
3435
  * Constants for the Bitfab SDK.
@@ -3559,4 +3568,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
3559
3568
  run?: boolean;
3560
3569
  }): Promise<SeedResult>;
3561
3570
 
3562
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, AssertionCategoriesClient, type AssertionCategory, type AssertionCategorySummary, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CommitRef, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelUpdate, LabelsClient, type LangGraphIntegrationOptions, type ListDatasetsParams, MixedTracingError, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, type ReseedOptions, type ReseedRegistryResult, type ReseedResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionCategoryParams, type SaveAssertionsAllParams, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceAssertionsUpdate, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type TraceSearchParams, type TraceSearchResult, type TraceTarget, type TraceTargetOccurrence, TracesClient, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, reseedFromRegistry, seedFromRegistry, serializeReplayResult };
3571
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, AssertionCategoriesClient, type AssertionCategory, type AssertionCategorySummary, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CommitRef, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelUpdate, LabelsClient, type LangGraphIntegrationOptions, type ListDatasetsParams, MixedTracingError, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, type ReseedOptions, type ReseedRegistryResult, type ReseedResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionCategoryParams, type SaveAssertionsAllParams, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceAssertionsUpdate, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type TraceSearchFilters, type TraceSearchParams, type TraceSearchResult, type TraceTarget, type TraceTargetOccurrence, TracesClient, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, reseedFromRegistry, seedFromRegistry, serializeReplayResult };
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  getCurrentTrace,
30
30
  reseedFromRegistry,
31
31
  seedFromRegistry
32
- } from "./chunk-NATC7L2W.js";
32
+ } from "./chunk-MFMTLYDW.js";
33
33
  import "./chunk-EGWJYCNT.js";
34
34
  import {
35
35
  BITFAB_PROGRESS_PREFIX,
@@ -38,7 +38,7 @@ import {
38
38
  ReplayError,
39
39
  reportReplayProgress,
40
40
  serializeReplayResult
41
- } from "./chunk-3O5MS4XJ.js";
41
+ } from "./chunk-ONMN7WXS.js";
42
42
  import {
43
43
  BitfabError,
44
44
  DEFAULT_SERVICE_URL,
@@ -46,7 +46,7 @@ import {
46
46
  MixedTracingError,
47
47
  __version__,
48
48
  flushTraces
49
- } from "./chunk-GVK7AES5.js";
49
+ } from "./chunk-GGMFD2ZE.js";
50
50
  import "./chunk-VCRFFCLY.js";
51
51
  export {
52
52
  AssertionCategoriesClient,
package/dist/node.cjs CHANGED
@@ -97,7 +97,7 @@ var __version__, __packageName__;
97
97
  var init_version_generated = __esm({
98
98
  "src/version.generated.ts"() {
99
99
  "use strict";
100
- __version__ = "0.54.5";
100
+ __version__ = "0.54.7";
101
101
  __packageName__ = "bitfab";
102
102
  }
103
103
  });
@@ -2329,6 +2329,15 @@ var init_http = __esm({
2329
2329
  resolveApiKey() {
2330
2330
  return typeof this.apiKey === "function" ? this.apiKey() : this.apiKey;
2331
2331
  }
2332
+ /** @internal Whether this client currently has credentials for trace delivery. */
2333
+ hasApiKey() {
2334
+ try {
2335
+ const apiKey = this.resolveApiKey();
2336
+ return apiKey !== void 0 && apiKey.trim() !== "";
2337
+ } catch {
2338
+ return false;
2339
+ }
2340
+ }
2332
2341
  /**
2333
2342
  * This client's span transport, built on first use.
2334
2343
  *
@@ -4513,6 +4522,7 @@ var BitfabClaudeAgentHandler = class {
4513
4522
  });
4514
4523
  this.traceFunctionKey = config.traceFunctionKey;
4515
4524
  this.getActiveSpanContext = config.getActiveSpanContext ?? null;
4525
+ this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
4516
4526
  this.preToolUseHook = this.preToolUseHook.bind(this);
4517
4527
  this.postToolUseHook = this.postToolUseHook.bind(this);
4518
4528
  this.postToolUseFailureHook = this.postToolUseFailureHook.bind(this);
@@ -4617,6 +4627,9 @@ var BitfabClaudeAgentHandler = class {
4617
4627
  this.httpClient.traceCompletion.end(spanInfo.traceId, spanInfo.spanId);
4618
4628
  }
4619
4629
  sendSpan(spanInfo) {
4630
+ if (!this.shouldRecord()) {
4631
+ return;
4632
+ }
4620
4633
  const spanData = {
4621
4634
  name: spanInfo.name,
4622
4635
  type: spanInfo.type
@@ -4660,6 +4673,9 @@ var BitfabClaudeAgentHandler = class {
4660
4673
  }
4661
4674
  }
4662
4675
  sendTraceCompletion(endedAt, metadata) {
4676
+ if (!this.shouldRecord()) {
4677
+ return;
4678
+ }
4663
4679
  if (this.traceId === null) {
4664
4680
  return;
4665
4681
  }
@@ -6201,6 +6217,7 @@ var BitfabLangGraphCallbackHandler = class {
6201
6217
  });
6202
6218
  this.traceFunctionKey = config.traceFunctionKey;
6203
6219
  this.getActiveSpanContext = config.getActiveSpanContext ?? null;
6220
+ this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
6204
6221
  this.captureTools = config.captureTools ?? true;
6205
6222
  }
6206
6223
  /**
@@ -6309,6 +6326,9 @@ var BitfabLangGraphCallbackHandler = class {
6309
6326
  this.httpClient.traceCompletion.end(spanInfo.traceId, spanInfo.spanId);
6310
6327
  }
6311
6328
  sendSpan(spanInfo) {
6329
+ if (!this.shouldRecord()) {
6330
+ return;
6331
+ }
6312
6332
  const spanData = {
6313
6333
  name: spanInfo.name,
6314
6334
  type: spanInfo.type
@@ -6352,6 +6372,9 @@ var BitfabLangGraphCallbackHandler = class {
6352
6372
  }
6353
6373
  }
6354
6374
  sendTraceCompletion(rootSpan, activeContext) {
6375
+ if (!this.shouldRecord()) {
6376
+ return;
6377
+ }
6355
6378
  const completed = activeContext === null;
6356
6379
  const traceData = {
6357
6380
  id: rootSpan.traceId,
@@ -6372,6 +6395,9 @@ var BitfabLangGraphCallbackHandler = class {
6372
6395
  }
6373
6396
  }
6374
6397
  sendTraceStart(rootSpan) {
6398
+ if (!this.shouldRecord()) {
6399
+ return;
6400
+ }
6375
6401
  const traceData = {
6376
6402
  id: rootSpan.traceId,
6377
6403
  type: "sdk-function",
@@ -7023,12 +7049,6 @@ var TracesClient = class {
7023
7049
  constructor(httpClient) {
7024
7050
  this.httpClient = httpClient;
7025
7051
  }
7026
- /**
7027
- * Search traces by exact caller metadata.
7028
- *
7029
- * Keys and values are matched case-insensitively. Up to 10 supplied pairs
7030
- * must match. Use `nextCursor` from the result to fetch another page.
7031
- */
7032
7052
  async search(params) {
7033
7053
  return this.httpClient.request(SEARCH_PATH, params);
7034
7054
  }
@@ -7086,6 +7106,7 @@ var BitfabOpenAITracingProcessor = class {
7086
7106
  timeout: config.timeout ?? 1e4
7087
7107
  });
7088
7108
  this.getActiveSpanContext = config.getActiveSpanContext ?? null;
7109
+ this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
7089
7110
  }
7090
7111
  getCanonicalTraceId(sourceTraceId) {
7091
7112
  const existing = this.canonicalTraceIds[sourceTraceId];
@@ -7206,6 +7227,9 @@ var BitfabOpenAITracingProcessor = class {
7206
7227
  * the OpenAI trace into an outer withSpan trace.
7207
7228
  */
7208
7229
  sendTrace(trace, options = {}) {
7230
+ if (!this.shouldRecord()) {
7231
+ return;
7232
+ }
7209
7233
  try {
7210
7234
  const traceData = trace.toJSON();
7211
7235
  if (options.sourceTraceId) {
@@ -7320,6 +7344,9 @@ var BitfabOpenAITracingProcessor = class {
7320
7344
  * and parent_id are rewritten to link the span into the withSpan tree.
7321
7345
  */
7322
7346
  sendSpan(span) {
7347
+ if (!this.shouldRecord()) {
7348
+ return;
7349
+ }
7323
7350
  const errors = [];
7324
7351
  const [serializedSpan, exportErrors] = this.exportSpan(span);
7325
7352
  errors.push(...exportErrors);
@@ -8417,6 +8444,11 @@ var Bitfab = class {
8417
8444
  }
8418
8445
  return this.resolveApiKey() !== void 0;
8419
8446
  }
8447
+ prepareFrameworkIntegration() {
8448
+ if (this.captureConfigured && this.strict) {
8449
+ this.resolveApiKey();
8450
+ }
8451
+ }
8420
8452
  get captureEnabled() {
8421
8453
  return this.isCaptureEnabled();
8422
8454
  }
@@ -8474,14 +8506,16 @@ var Bitfab = class {
8474
8506
  resultStr = String(executionResult.result);
8475
8507
  }
8476
8508
  }
8477
- this.httpClient.sendInternalTrace(functionVersion.id, {
8478
- result: resultStr,
8479
- source: "typescript-sdk",
8480
- ...Object.keys(inputs).length > 0 && { inputs },
8481
- ...executionResult.rawCollector != null && {
8482
- rawCollector: executionResult.rawCollector
8483
- }
8484
- });
8509
+ if (this.shouldRecord()) {
8510
+ this.httpClient.sendInternalTrace(functionVersion.id, {
8511
+ result: resultStr,
8512
+ source: "typescript-sdk",
8513
+ ...Object.keys(inputs).length > 0 && { inputs },
8514
+ ...executionResult.rawCollector != null && {
8515
+ rawCollector: executionResult.rawCollector
8516
+ }
8517
+ });
8518
+ }
8485
8519
  return executionResult.result;
8486
8520
  } catch (error) {
8487
8521
  if (error instanceof BitfabError) {
@@ -8511,11 +8545,10 @@ var Bitfab = class {
8511
8545
  * @returns A BitfabOpenAITracingProcessor instance configured for this client
8512
8546
  */
8513
8547
  getOpenAiTracingProcessor() {
8548
+ this.prepareFrameworkIntegration();
8514
8549
  return new BitfabOpenAITracingProcessor({
8515
- // Resolved at getter-call time (framework handlers are set up after env
8516
- // loads); the withSpan path stays lazy via the constructor HttpClient thunk.
8517
- apiKey: this.resolveApiKey(),
8518
8550
  serviceUrl: this.serviceUrl,
8551
+ shouldRecord: () => this.shouldRecord(),
8519
8552
  getActiveSpanContext: () => {
8520
8553
  const stack = getSpanStack();
8521
8554
  return stack[stack.length - 1] ?? null;
@@ -8573,10 +8606,11 @@ var Bitfab = class {
8573
8606
  * @returns A BitfabLangGraphCallbackHandler configured for this client
8574
8607
  */
8575
8608
  getLangGraphCallbackHandler(traceFunctionKey) {
8609
+ this.prepareFrameworkIntegration();
8576
8610
  return new BitfabLangGraphCallbackHandler({
8577
- apiKey: this.resolveApiKey(),
8578
8611
  traceFunctionKey,
8579
8612
  serviceUrl: this.serviceUrl,
8613
+ shouldRecord: () => this.shouldRecord(),
8580
8614
  getActiveSpanContext: () => {
8581
8615
  const stack = getSpanStack();
8582
8616
  return stack[stack.length - 1] ?? null;
@@ -8615,10 +8649,11 @@ var Bitfab = class {
8615
8649
  * @experimental This API may change before it is stable.
8616
8650
  */
8617
8651
  getLangGraphIntegration(traceFunctionKey, options) {
8652
+ this.prepareFrameworkIntegration();
8618
8653
  const callbackHandler = new BitfabLangGraphCallbackHandler({
8619
- apiKey: this.resolveApiKey(),
8620
8654
  traceFunctionKey,
8621
8655
  serviceUrl: this.serviceUrl,
8656
+ shouldRecord: () => this.shouldRecord(),
8622
8657
  getActiveSpanContext: () => {
8623
8658
  const stack = getSpanStack();
8624
8659
  return stack[stack.length - 1] ?? null;
@@ -8657,10 +8692,11 @@ var Bitfab = class {
8657
8692
  * @returns A BitfabClaudeAgentHandler configured for this client
8658
8693
  */
8659
8694
  getClaudeAgentHandler(traceFunctionKey) {
8695
+ this.prepareFrameworkIntegration();
8660
8696
  return new BitfabClaudeAgentHandler({
8661
- apiKey: this.resolveApiKey(),
8662
8697
  traceFunctionKey,
8663
8698
  serviceUrl: this.serviceUrl,
8699
+ shouldRecord: () => this.shouldRecord(),
8664
8700
  getActiveSpanContext: () => {
8665
8701
  const stack = getSpanStack();
8666
8702
  return stack[stack.length - 1] ?? null;