bitfab 0.58.4 → 0.59.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.
Files changed (43) hide show
  1. package/dist/autoTrace.cjs +50 -4
  2. package/dist/autoTrace.cjs.map +1 -1
  3. package/dist/autoTrace.d.cts +2 -1
  4. package/dist/autoTrace.d.ts +2 -1
  5. package/dist/autoTrace.js +4 -2
  6. package/dist/{chunk-VCRFFCLY.js → chunk-BAOIRE5T.js} +20 -2
  7. package/dist/chunk-BAOIRE5T.js.map +1 -0
  8. package/dist/{chunk-RCHSYWKI.js → chunk-ETZUSSF6.js} +38 -8
  9. package/dist/chunk-ETZUSSF6.js.map +1 -0
  10. package/dist/{chunk-NSD5YKCE.js → chunk-FHEEAPG2.js} +6 -6
  11. package/dist/{chunk-KADON3SF.js → chunk-KFZ5OIN5.js} +6 -21
  12. package/dist/chunk-KFZ5OIN5.js.map +1 -0
  13. package/dist/{chunk-32ZY3DYR.js → chunk-R5MUOBRK.js} +2 -2
  14. package/dist/{chunk-32ZY3DYR.js.map → chunk-R5MUOBRK.js.map} +1 -1
  15. package/dist/{chunk-IVF7JQHF.js → chunk-RYSCYPHQ.js} +123 -26
  16. package/dist/chunk-RYSCYPHQ.js.map +1 -0
  17. package/dist/{chunk-UOW7VDNB.js → chunk-Y6FVWJKU.js} +3 -3
  18. package/dist/{http-XQGMIDFR.js → http-7WLON2BH.js} +2 -2
  19. package/dist/{http-TIOONTDB.js → http-D7P4JL6C.js} +3 -3
  20. package/dist/index.cjs +142 -20
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +32 -10
  23. package/dist/index.d.ts +32 -10
  24. package/dist/index.js +13 -5
  25. package/dist/node.cjs +142 -20
  26. package/dist/node.cjs.map +1 -1
  27. package/dist/node.d.cts +1 -1
  28. package/dist/node.d.ts +1 -1
  29. package/dist/node.js +13 -5
  30. package/dist/node.js.map +1 -1
  31. package/dist/{replay-CUHT4GUT.js → replay-5TZNJ2DL.js} +4 -4
  32. package/dist/replayCli.js +2 -2
  33. package/dist/seedCli.js +2 -2
  34. package/package.json +1 -1
  35. package/dist/chunk-IVF7JQHF.js.map +0 -1
  36. package/dist/chunk-KADON3SF.js.map +0 -1
  37. package/dist/chunk-RCHSYWKI.js.map +0 -1
  38. package/dist/chunk-VCRFFCLY.js.map +0 -1
  39. /package/dist/{chunk-NSD5YKCE.js.map → chunk-FHEEAPG2.js.map} +0 -0
  40. /package/dist/{chunk-UOW7VDNB.js.map → chunk-Y6FVWJKU.js.map} +0 -0
  41. /package/dist/{http-TIOONTDB.js.map → http-7WLON2BH.js.map} +0 -0
  42. /package/dist/{http-XQGMIDFR.js.map → http-D7P4JL6C.js.map} +0 -0
  43. /package/dist/{replay-CUHT4GUT.js.map → replay-5TZNJ2DL.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -1244,14 +1244,19 @@ interface GraderRerun {
1244
1244
  }
1245
1245
  interface RerunGradersOptions {
1246
1246
  graderIds?: string[];
1247
- wait?: boolean;
1248
1247
  timeoutMs?: number;
1249
- pollIntervalMs?: number;
1250
1248
  }
1251
1249
  interface RerunGradersResult {
1252
1250
  run: GraderRerun;
1253
1251
  joinedExisting: boolean;
1254
1252
  }
1253
+ declare class GraderRerunError extends Error {
1254
+ readonly run: GraderRerun;
1255
+ constructor(message: string, run: GraderRerun);
1256
+ }
1257
+ declare class GraderRerunTimeoutError extends GraderRerunError {
1258
+ constructor(datasetId: string, run: GraderRerun, timeoutMs: number);
1259
+ }
1255
1260
  /**
1256
1261
  * Dataset operations for the authenticated organization, reached as
1257
1262
  * `client.datasets`. A dataset is a named bucket of traces scoped to one trace
@@ -1291,12 +1296,6 @@ declare class DatasetsClient {
1291
1296
  addGraders(datasetId: string, graderIds: string[]): Promise<AddDatasetGradersResult>;
1292
1297
  /** Unassign graders from the dataset. */
1293
1298
  removeGraders(datasetId: string, graderIds: string[]): Promise<RemoveDatasetGradersResult>;
1294
- /**
1295
- * Re-run graders over every trace in the dataset. Defaults to every assigned
1296
- * grader; an unassigned id is rejected. Waits for the run to finish (up to
1297
- * `timeoutMs`, default 90s) unless `wait` is `false`, and returns the last
1298
- * run state seen either way. A request matching an in-flight run joins it.
1299
- */
1300
1299
  rerunGraders(datasetId: string, options?: RerunGradersOptions): Promise<RerunGradersResult>;
1301
1300
  /**
1302
1301
  * The dataset's active grader re-run, or the run named by `runId`. Returns
@@ -1400,9 +1399,18 @@ type SaveAssertion = {
1400
1399
  */
1401
1400
  assigneeEmail?: string | null;
1402
1401
  };
1402
+ type AssertionGenerationStatus = "running" | "completed" | "failed";
1403
+ type AssertionGeneration = {
1404
+ status: AssertionGenerationStatus;
1405
+ error: string | null;
1406
+ assertionIds: string[];
1407
+ startedAt: string;
1408
+ finishedAt: string | null;
1409
+ };
1403
1410
  type TraceAssertionsResult = {
1404
1411
  assertions: TraceAssertion[];
1405
1412
  inheritedFrom: string | null;
1413
+ generation: AssertionGeneration | null;
1406
1414
  };
1407
1415
  type TraceAssertionsUpdate = {
1408
1416
  traceId: string;
@@ -1421,6 +1429,19 @@ type ArchiveAssertionsParams = {
1421
1429
  traceId: string;
1422
1430
  assertionIds: string[];
1423
1431
  };
1432
+ type GenerateAssertionsOptions = {
1433
+ guidance?: string;
1434
+ categoryIds?: string[];
1435
+ regenerate?: boolean;
1436
+ timeoutMs?: number;
1437
+ };
1438
+ declare class AssertionGenerationError extends Error {
1439
+ readonly traceId: string;
1440
+ constructor(message: string, traceId: string);
1441
+ }
1442
+ declare class AssertionGenerationTimeoutError extends AssertionGenerationError {
1443
+ constructor(traceId: string, timeoutMs: number);
1444
+ }
1424
1445
  declare class TracesClient {
1425
1446
  private readonly httpClient;
1426
1447
  constructor(httpClient: HttpClient);
@@ -1428,6 +1449,7 @@ declare class TracesClient {
1428
1449
  getAssertions(traceId: string): Promise<TraceAssertionsResult>;
1429
1450
  saveAssertions(params: SaveAssertionsParams): Promise<TraceAssertion[]>;
1430
1451
  saveAssertionsAll(params: SaveAssertionsAllParams): Promise<TraceAssertion[]>;
1452
+ generateAssertions(traceId: string, options?: GenerateAssertionsOptions): Promise<TraceAssertion[]>;
1431
1453
  archiveAssertions(params: ArchiveAssertionsParams): Promise<string[]>;
1432
1454
  }
1433
1455
 
@@ -3659,7 +3681,7 @@ interface CommitRef {
3659
3681
  /**
3660
3682
  * SDK version from package.json (injected at build time)
3661
3683
  */
3662
- declare const __version__ = "0.58.4";
3684
+ declare const __version__ = "0.59.0";
3663
3685
 
3664
3686
  /**
3665
3687
  * Constants for the Bitfab SDK.
@@ -3798,4 +3820,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
3798
3820
  run?: boolean;
3799
3821
  }): Promise<SeedResult>;
3800
3822
 
3801
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ApprovalFields, type ApprovalState, type Approver, type ArchiveAssertionsParams, AssertionCategoriesClient, type AssertionCategory, type AssertionCategorySummary, type AssertionEvidenceParameter, type AssertionLabelEvidence, type AssertionVerdict, type Assignee, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabRivetIntegration, 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 Justification, type JustificationSpan, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelTarget, 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 OrganizationMember, OrganizationMembersClient, 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, type RivetContextLike, type RivetEffectType, type RivetIntegrationOptions, 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 };
3823
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ApprovalFields, type ApprovalState, type Approver, type ArchiveAssertionsParams, AssertionCategoriesClient, type AssertionCategory, type AssertionCategorySummary, type AssertionEvidenceParameter, type AssertionGeneration, AssertionGenerationError, type AssertionGenerationStatus, AssertionGenerationTimeoutError, type AssertionLabelEvidence, type AssertionVerdict, type Assignee, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabRivetIntegration, 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 GenerateAssertionsOptions, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, GraderRerunError, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GraderRerunTimeoutError, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type Justification, type JustificationSpan, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelTarget, 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 OrganizationMember, OrganizationMembersClient, 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, type RivetContextLike, type RivetEffectType, type RivetIntegrationOptions, 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
@@ -1244,14 +1244,19 @@ interface GraderRerun {
1244
1244
  }
1245
1245
  interface RerunGradersOptions {
1246
1246
  graderIds?: string[];
1247
- wait?: boolean;
1248
1247
  timeoutMs?: number;
1249
- pollIntervalMs?: number;
1250
1248
  }
1251
1249
  interface RerunGradersResult {
1252
1250
  run: GraderRerun;
1253
1251
  joinedExisting: boolean;
1254
1252
  }
1253
+ declare class GraderRerunError extends Error {
1254
+ readonly run: GraderRerun;
1255
+ constructor(message: string, run: GraderRerun);
1256
+ }
1257
+ declare class GraderRerunTimeoutError extends GraderRerunError {
1258
+ constructor(datasetId: string, run: GraderRerun, timeoutMs: number);
1259
+ }
1255
1260
  /**
1256
1261
  * Dataset operations for the authenticated organization, reached as
1257
1262
  * `client.datasets`. A dataset is a named bucket of traces scoped to one trace
@@ -1291,12 +1296,6 @@ declare class DatasetsClient {
1291
1296
  addGraders(datasetId: string, graderIds: string[]): Promise<AddDatasetGradersResult>;
1292
1297
  /** Unassign graders from the dataset. */
1293
1298
  removeGraders(datasetId: string, graderIds: string[]): Promise<RemoveDatasetGradersResult>;
1294
- /**
1295
- * Re-run graders over every trace in the dataset. Defaults to every assigned
1296
- * grader; an unassigned id is rejected. Waits for the run to finish (up to
1297
- * `timeoutMs`, default 90s) unless `wait` is `false`, and returns the last
1298
- * run state seen either way. A request matching an in-flight run joins it.
1299
- */
1300
1299
  rerunGraders(datasetId: string, options?: RerunGradersOptions): Promise<RerunGradersResult>;
1301
1300
  /**
1302
1301
  * The dataset's active grader re-run, or the run named by `runId`. Returns
@@ -1400,9 +1399,18 @@ type SaveAssertion = {
1400
1399
  */
1401
1400
  assigneeEmail?: string | null;
1402
1401
  };
1402
+ type AssertionGenerationStatus = "running" | "completed" | "failed";
1403
+ type AssertionGeneration = {
1404
+ status: AssertionGenerationStatus;
1405
+ error: string | null;
1406
+ assertionIds: string[];
1407
+ startedAt: string;
1408
+ finishedAt: string | null;
1409
+ };
1403
1410
  type TraceAssertionsResult = {
1404
1411
  assertions: TraceAssertion[];
1405
1412
  inheritedFrom: string | null;
1413
+ generation: AssertionGeneration | null;
1406
1414
  };
1407
1415
  type TraceAssertionsUpdate = {
1408
1416
  traceId: string;
@@ -1421,6 +1429,19 @@ type ArchiveAssertionsParams = {
1421
1429
  traceId: string;
1422
1430
  assertionIds: string[];
1423
1431
  };
1432
+ type GenerateAssertionsOptions = {
1433
+ guidance?: string;
1434
+ categoryIds?: string[];
1435
+ regenerate?: boolean;
1436
+ timeoutMs?: number;
1437
+ };
1438
+ declare class AssertionGenerationError extends Error {
1439
+ readonly traceId: string;
1440
+ constructor(message: string, traceId: string);
1441
+ }
1442
+ declare class AssertionGenerationTimeoutError extends AssertionGenerationError {
1443
+ constructor(traceId: string, timeoutMs: number);
1444
+ }
1424
1445
  declare class TracesClient {
1425
1446
  private readonly httpClient;
1426
1447
  constructor(httpClient: HttpClient);
@@ -1428,6 +1449,7 @@ declare class TracesClient {
1428
1449
  getAssertions(traceId: string): Promise<TraceAssertionsResult>;
1429
1450
  saveAssertions(params: SaveAssertionsParams): Promise<TraceAssertion[]>;
1430
1451
  saveAssertionsAll(params: SaveAssertionsAllParams): Promise<TraceAssertion[]>;
1452
+ generateAssertions(traceId: string, options?: GenerateAssertionsOptions): Promise<TraceAssertion[]>;
1431
1453
  archiveAssertions(params: ArchiveAssertionsParams): Promise<string[]>;
1432
1454
  }
1433
1455
 
@@ -3659,7 +3681,7 @@ interface CommitRef {
3659
3681
  /**
3660
3682
  * SDK version from package.json (injected at build time)
3661
3683
  */
3662
- declare const __version__ = "0.58.4";
3684
+ declare const __version__ = "0.59.0";
3663
3685
 
3664
3686
  /**
3665
3687
  * Constants for the Bitfab SDK.
@@ -3798,4 +3820,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
3798
3820
  run?: boolean;
3799
3821
  }): Promise<SeedResult>;
3800
3822
 
3801
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ApprovalFields, type ApprovalState, type Approver, type ArchiveAssertionsParams, AssertionCategoriesClient, type AssertionCategory, type AssertionCategorySummary, type AssertionEvidenceParameter, type AssertionLabelEvidence, type AssertionVerdict, type Assignee, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabRivetIntegration, 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 Justification, type JustificationSpan, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelTarget, 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 OrganizationMember, OrganizationMembersClient, 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, type RivetContextLike, type RivetEffectType, type RivetIntegrationOptions, 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 };
3823
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ApprovalFields, type ApprovalState, type Approver, type ArchiveAssertionsParams, AssertionCategoriesClient, type AssertionCategory, type AssertionCategorySummary, type AssertionEvidenceParameter, type AssertionGeneration, AssertionGenerationError, type AssertionGenerationStatus, AssertionGenerationTimeoutError, type AssertionLabelEvidence, type AssertionVerdict, type Assignee, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabRivetIntegration, 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 GenerateAssertionsOptions, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, GraderRerunError, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GraderRerunTimeoutError, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type Justification, type JustificationSpan, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelTarget, 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 OrganizationMember, OrganizationMembersClient, 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, type RivetContextLike, type RivetEffectType, type RivetIntegrationOptions, 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
@@ -9,6 +9,8 @@ if (typeof globalThis.__bitfab_deprecation_warned === "undefined") {
9
9
  }
10
10
  import {
11
11
  AssertionCategoriesClient,
12
+ AssertionGenerationError,
13
+ AssertionGenerationTimeoutError,
12
14
  Bitfab,
13
15
  BitfabClaudeAgentHandler,
14
16
  BitfabFunction,
@@ -19,6 +21,8 @@ import {
19
21
  BitfabRivetIntegration,
20
22
  BitfabVercelAiHandler,
21
23
  DatasetsClient,
24
+ GraderRerunError,
25
+ GraderRerunTimeoutError,
22
26
  GradersClient,
23
27
  LabelsClient,
24
28
  OrganizationMembersClient,
@@ -31,8 +35,8 @@ import {
31
35
  getCurrentTrace,
32
36
  reseedFromRegistry,
33
37
  seedFromRegistry
34
- } from "./chunk-IVF7JQHF.js";
35
- import "./chunk-RCHSYWKI.js";
38
+ } from "./chunk-RYSCYPHQ.js";
39
+ import "./chunk-ETZUSSF6.js";
36
40
  import {
37
41
  BITFAB_PROGRESS_PREFIX,
38
42
  DbBranchReplayError,
@@ -40,7 +44,7 @@ import {
40
44
  ReplayError,
41
45
  reportReplayProgress,
42
46
  serializeReplayResult
43
- } from "./chunk-NSD5YKCE.js";
47
+ } from "./chunk-FHEEAPG2.js";
44
48
  import {
45
49
  BitfabError,
46
50
  DEFAULT_SERVICE_URL,
@@ -48,10 +52,12 @@ import {
48
52
  MixedTracingError,
49
53
  __version__,
50
54
  flushTraces
51
- } from "./chunk-KADON3SF.js";
52
- import "./chunk-VCRFFCLY.js";
55
+ } from "./chunk-KFZ5OIN5.js";
56
+ import "./chunk-BAOIRE5T.js";
53
57
  export {
54
58
  AssertionCategoriesClient,
59
+ AssertionGenerationError,
60
+ AssertionGenerationTimeoutError,
55
61
  BITFAB_PROGRESS_PREFIX,
56
62
  Bitfab,
57
63
  BitfabClaudeAgentHandler,
@@ -67,6 +73,8 @@ export {
67
73
  DEFAULT_SERVICE_URL,
68
74
  DatasetsClient,
69
75
  DbBranchReplayError,
76
+ GraderRerunError,
77
+ GraderRerunTimeoutError,
70
78
  GradersClient,
71
79
  HttpClient,
72
80
  LabelsClient,
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.58.4";
100
+ __version__ = "0.59.0";
101
101
  __packageName__ = "bitfab";
102
102
  }
103
103
  });
@@ -4406,6 +4406,8 @@ var init_replay = __esm({
4406
4406
  var node_exports = {};
4407
4407
  __export(node_exports, {
4408
4408
  AssertionCategoriesClient: () => AssertionCategoriesClient,
4409
+ AssertionGenerationError: () => AssertionGenerationError,
4410
+ AssertionGenerationTimeoutError: () => AssertionGenerationTimeoutError,
4409
4411
  BITFAB_PROGRESS_PREFIX: () => BITFAB_PROGRESS_PREFIX,
4410
4412
  Bitfab: () => Bitfab,
4411
4413
  BitfabClaudeAgentHandler: () => BitfabClaudeAgentHandler,
@@ -4421,6 +4423,8 @@ __export(node_exports, {
4421
4423
  DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
4422
4424
  DatasetsClient: () => DatasetsClient,
4423
4425
  DbBranchReplayError: () => DbBranchReplayError,
4426
+ GraderRerunError: () => GraderRerunError,
4427
+ GraderRerunTimeoutError: () => GraderRerunTimeoutError,
4424
4428
  GradersClient: () => GradersClient,
4425
4429
  HttpClient: () => HttpClient,
4426
4430
  LabelsClient: () => LabelsClient,
@@ -5120,6 +5124,7 @@ init_asyncStorage();
5120
5124
  // src/autoTrace.ts
5121
5125
  init_asyncStorage();
5122
5126
  init_captureSuppression();
5127
+ init_warnOnce();
5123
5128
  var autoTraceGlobal = globalThis;
5124
5129
  var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {
5125
5130
  storage: null,
@@ -5187,6 +5192,26 @@ function runWithAutoTraceNodeConfiguration(nodeConfiguration, fn) {
5187
5192
  }
5188
5193
  return result;
5189
5194
  }
5195
+ var SUBTREE_TRACING_DOCS_URL = "https://docs.bitfab.ai/typescript-sdk#experimental-subtree-tracing";
5196
+ function transformInstalled() {
5197
+ return autoTraceGlobal.__bitfab_auto_trace_transformed_v1__ === true;
5198
+ }
5199
+ function runsOnNode() {
5200
+ return typeof process !== "undefined" && Boolean(process.versions?.node);
5201
+ }
5202
+ function closeAutoTraceRoot() {
5203
+ autoTraceState.activeRoots -= 1;
5204
+ }
5205
+ function settleAutoTraceRoot(context) {
5206
+ closeAutoTraceRoot();
5207
+ if (transformInstalled() || !runsOnNode()) {
5208
+ return;
5209
+ }
5210
+ warnOnce(
5211
+ "auto-trace-transform-missing",
5212
+ `trace root "${context.traceFunctionKey}" recorded only its own span. No module in this build was compiled by @bitfab/transform, so calls beneath the root were not discovered. Install @bitfab/transform and add its adapter to the server build: ${SUBTREE_TRACING_DOCS_URL}`
5213
+ );
5214
+ }
5190
5215
  function runWithAutoTraceRootContext(context, spanStack, fn) {
5191
5216
  autoTraceState.activeRoots += 1;
5192
5217
  const entries = [
@@ -5197,19 +5222,19 @@ function runWithAutoTraceRootContext(context, spanStack, fn) {
5197
5222
  try {
5198
5223
  result = runWithAutoTraceScope({ entries }, fn);
5199
5224
  } catch (error) {
5200
- autoTraceState.activeRoots -= 1;
5225
+ settleAutoTraceRoot(context);
5201
5226
  throw error;
5202
5227
  }
5203
5228
  if (isAutoTraceAsyncGenerator(result)) {
5204
- autoTraceState.activeRoots -= 1;
5229
+ closeAutoTraceRoot();
5205
5230
  return wrapAutoTraceAsyncGenerator(context, spanStack, result);
5206
5231
  }
5207
5232
  if (result instanceof Promise) {
5208
5233
  return result.finally(() => {
5209
- autoTraceState.activeRoots -= 1;
5234
+ settleAutoTraceRoot(context);
5210
5235
  });
5211
5236
  }
5212
- autoTraceState.activeRoots -= 1;
5237
+ settleAutoTraceRoot(context);
5213
5238
  return result;
5214
5239
  }
5215
5240
  function invokeThroughAutoTraceEntries(entries, step, fn) {
@@ -5834,11 +5859,39 @@ init_constants();
5834
5859
 
5835
5860
  // src/datasets.ts
5836
5861
  var DEFAULT_RERUN_TIMEOUT_MS = 9e4;
5837
- var DEFAULT_RERUN_POLL_INTERVAL_MS = 1e3;
5862
+ var RERUN_POLL_INTERVAL_MS = 1e3;
5838
5863
  var TERMINAL_RERUN_STATUSES = /* @__PURE__ */ new Set([
5839
5864
  "completed",
5840
5865
  "errored"
5841
5866
  ]);
5867
+ var GraderRerunError = class extends Error {
5868
+ constructor(message, run) {
5869
+ super(message);
5870
+ this.run = run;
5871
+ this.name = "GraderRerunError";
5872
+ }
5873
+ };
5874
+ var GraderRerunTimeoutError = class extends GraderRerunError {
5875
+ constructor(datasetId, run, timeoutMs) {
5876
+ super(
5877
+ `Grader re-run ${run.id} on dataset ${datasetId} was still ${run.status} after ${timeoutMs}ms. It keeps running on Bitfab; read it later with getGraderRerun.`,
5878
+ run
5879
+ );
5880
+ this.name = "GraderRerunTimeoutError";
5881
+ }
5882
+ };
5883
+ function finishedRerun(datasetId, run, joinedExisting) {
5884
+ if (!TERMINAL_RERUN_STATUSES.has(run.status)) {
5885
+ return null;
5886
+ }
5887
+ if (run.status === "errored") {
5888
+ throw new GraderRerunError(
5889
+ `Grader re-run ${run.id} on dataset ${datasetId} errored: ${run.error ?? "no reason recorded"}`,
5890
+ run
5891
+ );
5892
+ }
5893
+ return { run, joinedExisting };
5894
+ }
5842
5895
  function sleep(ms) {
5843
5896
  return new Promise((resolve) => setTimeout(resolve, ms));
5844
5897
  }
@@ -5938,28 +5991,25 @@ var DatasetsClient = class {
5938
5991
  { graderIds }
5939
5992
  );
5940
5993
  }
5941
- /**
5942
- * Re-run graders over every trace in the dataset. Defaults to every assigned
5943
- * grader; an unassigned id is rejected. Waits for the run to finish (up to
5944
- * `timeoutMs`, default 90s) unless `wait` is `false`, and returns the last
5945
- * run state seen either way. A request matching an in-flight run joins it.
5946
- */
5947
5994
  async rerunGraders(datasetId, options = {}) {
5948
5995
  const started = await this.httpClient.request(
5949
5996
  datasetPath(datasetId, "/rerunGraders"),
5950
5997
  options.graderIds === void 0 ? {} : { graderIds: options.graderIds }
5951
5998
  );
5952
- if (options.wait === false) {
5953
- return started;
5954
- }
5955
- const deadline = Date.now() + (options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS);
5956
- const interval = options.pollIntervalMs ?? DEFAULT_RERUN_POLL_INTERVAL_MS;
5999
+ const timeoutMs = options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS;
6000
+ const deadline = Date.now() + timeoutMs;
5957
6001
  let run = started.run;
5958
- while (!TERMINAL_RERUN_STATUSES.has(run.status) && Date.now() < deadline) {
5959
- await sleep(interval);
6002
+ while (true) {
6003
+ const finished = finishedRerun(datasetId, run, started.joinedExisting);
6004
+ if (finished !== null) {
6005
+ return finished;
6006
+ }
6007
+ if (Date.now() >= deadline) {
6008
+ throw new GraderRerunTimeoutError(datasetId, run, timeoutMs);
6009
+ }
6010
+ await sleep(RERUN_POLL_INTERVAL_MS);
5960
6011
  run = await this.getGraderRerun(datasetId, run.id) ?? run;
5961
6012
  }
5962
- return { run, joinedExisting: started.joinedExisting };
5963
6013
  }
5964
6014
  /**
5965
6015
  * The dataset's active grader re-run, or the run named by `runId`. Returns
@@ -7815,6 +7865,46 @@ init_traceMetadata();
7815
7865
  // src/traces.ts
7816
7866
  var ASSERTIONS_PATH = "/api/sdk/traces/assertions";
7817
7867
  var SEARCH_PATH = "/api/sdk/traces/search";
7868
+ var DEFAULT_GENERATION_TIMEOUT_MS = 6e5;
7869
+ var GENERATION_POLL_INTERVAL_MS = 2e3;
7870
+ var AssertionGenerationError = class extends Error {
7871
+ constructor(message, traceId) {
7872
+ super(message);
7873
+ this.traceId = traceId;
7874
+ this.name = "AssertionGenerationError";
7875
+ }
7876
+ };
7877
+ var AssertionGenerationTimeoutError = class extends AssertionGenerationError {
7878
+ constructor(traceId, timeoutMs) {
7879
+ super(
7880
+ `Assertion generation for trace ${traceId} did not finish within ${timeoutMs}ms. Generation keeps running on Bitfab. Call getAssertions and read its generation field to check its status.`,
7881
+ traceId
7882
+ );
7883
+ this.name = "AssertionGenerationTimeoutError";
7884
+ }
7885
+ };
7886
+ function sleep2(ms) {
7887
+ return new Promise((resolve) => setTimeout(resolve, ms));
7888
+ }
7889
+ function isGenerationFinished(traceId, generation) {
7890
+ if (generation === null || generation.status === "running") {
7891
+ return false;
7892
+ }
7893
+ if (generation.status === "failed") {
7894
+ throw new AssertionGenerationError(
7895
+ `Assertion generation for trace ${traceId} failed: ${generation.error ?? "no reason recorded"}. Pass regenerate: true to try again.`,
7896
+ traceId
7897
+ );
7898
+ }
7899
+ return true;
7900
+ }
7901
+ function draftsInGenerationOrder(assertions, assertionIds) {
7902
+ const byId = new Map(assertions.map((assertion) => [assertion.id, assertion]));
7903
+ return assertionIds.flatMap((id) => {
7904
+ const assertion = byId.get(id);
7905
+ return assertion === void 0 ? [] : [assertion];
7906
+ });
7907
+ }
7818
7908
  function traceAssertionsPath(traceId, suffix = "") {
7819
7909
  return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
7820
7910
  }
@@ -7846,6 +7936,34 @@ var TracesClient = class {
7846
7936
  });
7847
7937
  return response.assertions;
7848
7938
  }
7939
+ async generateAssertions(traceId, options = {}) {
7940
+ const started = await this.httpClient.request(
7941
+ traceAssertionsPath(traceId, "/generate"),
7942
+ {
7943
+ ...options.guidance === void 0 ? {} : { guidance: options.guidance },
7944
+ ...options.categoryIds === void 0 ? {} : { categoryIds: options.categoryIds },
7945
+ ...options.regenerate === void 0 ? {} : { regenerate: options.regenerate }
7946
+ }
7947
+ );
7948
+ if (isGenerationFinished(traceId, started.generation)) {
7949
+ return started.assertions;
7950
+ }
7951
+ const timeoutMs = options.timeoutMs ?? DEFAULT_GENERATION_TIMEOUT_MS;
7952
+ const deadline = Date.now() + timeoutMs;
7953
+ while (true) {
7954
+ if (Date.now() >= deadline) {
7955
+ throw new AssertionGenerationTimeoutError(traceId, timeoutMs);
7956
+ }
7957
+ await sleep2(GENERATION_POLL_INTERVAL_MS);
7958
+ const read2 = await this.getAssertions(traceId);
7959
+ if (isGenerationFinished(traceId, read2.generation)) {
7960
+ return draftsInGenerationOrder(
7961
+ read2.assertions,
7962
+ read2.generation.assertionIds
7963
+ );
7964
+ }
7965
+ }
7966
+ }
7849
7967
  async archiveAssertions(params) {
7850
7968
  const response = await this.httpClient.request(
7851
7969
  traceAssertionsPath(params.traceId, "/archive"),
@@ -11068,6 +11186,8 @@ assertAsyncStorageRegistered();
11068
11186
  // Annotate the CommonJS export names for ESM import in node:
11069
11187
  0 && (module.exports = {
11070
11188
  AssertionCategoriesClient,
11189
+ AssertionGenerationError,
11190
+ AssertionGenerationTimeoutError,
11071
11191
  BITFAB_PROGRESS_PREFIX,
11072
11192
  Bitfab,
11073
11193
  BitfabClaudeAgentHandler,
@@ -11083,6 +11203,8 @@ assertAsyncStorageRegistered();
11083
11203
  DEFAULT_SERVICE_URL,
11084
11204
  DatasetsClient,
11085
11205
  DbBranchReplayError,
11206
+ GraderRerunError,
11207
+ GraderRerunTimeoutError,
11086
11208
  GradersClient,
11087
11209
  HttpClient,
11088
11210
  LabelsClient,