bitfab 0.58.5 → 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 (31) hide show
  1. package/dist/{chunk-TAEWAXPA.js → chunk-FHEEAPG2.js} +2 -2
  2. package/dist/{chunk-7SPNHC33.js → chunk-KFZ5OIN5.js} +2 -2
  3. package/dist/{chunk-7SPNHC33.js.map → chunk-KFZ5OIN5.js.map} +1 -1
  4. package/dist/{chunk-QIBFNIIF.js → chunk-R5MUOBRK.js} +2 -2
  5. package/dist/{chunk-QIBFNIIF.js.map → chunk-R5MUOBRK.js.map} +1 -1
  6. package/dist/{chunk-UYAQRSCB.js → chunk-RYSCYPHQ.js} +118 -21
  7. package/dist/chunk-RYSCYPHQ.js.map +1 -0
  8. package/dist/{chunk-OTQA6MCF.js → chunk-Y6FVWJKU.js} +3 -3
  9. package/dist/{http-XDKEIZNV.js → http-7WLON2BH.js} +2 -2
  10. package/dist/{http-F6QV3YLY.js → http-D7P4JL6C.js} +2 -2
  11. package/dist/index.cjs +117 -16
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +32 -10
  14. package/dist/index.d.ts +32 -10
  15. package/dist/index.js +11 -3
  16. package/dist/node.cjs +117 -16
  17. package/dist/node.cjs.map +1 -1
  18. package/dist/node.d.cts +1 -1
  19. package/dist/node.d.ts +1 -1
  20. package/dist/node.js +11 -3
  21. package/dist/node.js.map +1 -1
  22. package/dist/{replay-WLJFWS6T.js → replay-5TZNJ2DL.js} +3 -3
  23. package/dist/replayCli.js +2 -2
  24. package/dist/seedCli.js +2 -2
  25. package/package.json +1 -1
  26. package/dist/chunk-UYAQRSCB.js.map +0 -1
  27. /package/dist/{chunk-TAEWAXPA.js.map → chunk-FHEEAPG2.js.map} +0 -0
  28. /package/dist/{chunk-OTQA6MCF.js.map → chunk-Y6FVWJKU.js.map} +0 -0
  29. /package/dist/{http-F6QV3YLY.js.map → http-7WLON2BH.js.map} +0 -0
  30. /package/dist/{http-XDKEIZNV.js.map → http-D7P4JL6C.js.map} +0 -0
  31. /package/dist/{replay-WLJFWS6T.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.5";
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.5";
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,7 +35,7 @@ import {
31
35
  getCurrentTrace,
32
36
  reseedFromRegistry,
33
37
  seedFromRegistry
34
- } from "./chunk-UYAQRSCB.js";
38
+ } from "./chunk-RYSCYPHQ.js";
35
39
  import "./chunk-ETZUSSF6.js";
36
40
  import {
37
41
  BITFAB_PROGRESS_PREFIX,
@@ -40,7 +44,7 @@ import {
40
44
  ReplayError,
41
45
  reportReplayProgress,
42
46
  serializeReplayResult
43
- } from "./chunk-TAEWAXPA.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-7SPNHC33.js";
55
+ } from "./chunk-KFZ5OIN5.js";
52
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.5";
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,
@@ -5855,11 +5859,39 @@ init_constants();
5855
5859
 
5856
5860
  // src/datasets.ts
5857
5861
  var DEFAULT_RERUN_TIMEOUT_MS = 9e4;
5858
- var DEFAULT_RERUN_POLL_INTERVAL_MS = 1e3;
5862
+ var RERUN_POLL_INTERVAL_MS = 1e3;
5859
5863
  var TERMINAL_RERUN_STATUSES = /* @__PURE__ */ new Set([
5860
5864
  "completed",
5861
5865
  "errored"
5862
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
+ }
5863
5895
  function sleep(ms) {
5864
5896
  return new Promise((resolve) => setTimeout(resolve, ms));
5865
5897
  }
@@ -5959,28 +5991,25 @@ var DatasetsClient = class {
5959
5991
  { graderIds }
5960
5992
  );
5961
5993
  }
5962
- /**
5963
- * Re-run graders over every trace in the dataset. Defaults to every assigned
5964
- * grader; an unassigned id is rejected. Waits for the run to finish (up to
5965
- * `timeoutMs`, default 90s) unless `wait` is `false`, and returns the last
5966
- * run state seen either way. A request matching an in-flight run joins it.
5967
- */
5968
5994
  async rerunGraders(datasetId, options = {}) {
5969
5995
  const started = await this.httpClient.request(
5970
5996
  datasetPath(datasetId, "/rerunGraders"),
5971
5997
  options.graderIds === void 0 ? {} : { graderIds: options.graderIds }
5972
5998
  );
5973
- if (options.wait === false) {
5974
- return started;
5975
- }
5976
- const deadline = Date.now() + (options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS);
5977
- const interval = options.pollIntervalMs ?? DEFAULT_RERUN_POLL_INTERVAL_MS;
5999
+ const timeoutMs = options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS;
6000
+ const deadline = Date.now() + timeoutMs;
5978
6001
  let run = started.run;
5979
- while (!TERMINAL_RERUN_STATUSES.has(run.status) && Date.now() < deadline) {
5980
- 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);
5981
6011
  run = await this.getGraderRerun(datasetId, run.id) ?? run;
5982
6012
  }
5983
- return { run, joinedExisting: started.joinedExisting };
5984
6013
  }
5985
6014
  /**
5986
6015
  * The dataset's active grader re-run, or the run named by `runId`. Returns
@@ -7836,6 +7865,46 @@ init_traceMetadata();
7836
7865
  // src/traces.ts
7837
7866
  var ASSERTIONS_PATH = "/api/sdk/traces/assertions";
7838
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
+ }
7839
7908
  function traceAssertionsPath(traceId, suffix = "") {
7840
7909
  return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
7841
7910
  }
@@ -7867,6 +7936,34 @@ var TracesClient = class {
7867
7936
  });
7868
7937
  return response.assertions;
7869
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
+ }
7870
7967
  async archiveAssertions(params) {
7871
7968
  const response = await this.httpClient.request(
7872
7969
  traceAssertionsPath(params.traceId, "/archive"),
@@ -11089,6 +11186,8 @@ assertAsyncStorageRegistered();
11089
11186
  // Annotate the CommonJS export names for ESM import in node:
11090
11187
  0 && (module.exports = {
11091
11188
  AssertionCategoriesClient,
11189
+ AssertionGenerationError,
11190
+ AssertionGenerationTimeoutError,
11092
11191
  BITFAB_PROGRESS_PREFIX,
11093
11192
  Bitfab,
11094
11193
  BitfabClaudeAgentHandler,
@@ -11104,6 +11203,8 @@ assertAsyncStorageRegistered();
11104
11203
  DEFAULT_SERVICE_URL,
11105
11204
  DatasetsClient,
11106
11205
  DbBranchReplayError,
11206
+ GraderRerunError,
11207
+ GraderRerunTimeoutError,
11107
11208
  GradersClient,
11108
11209
  HttpClient,
11109
11210
  LabelsClient,