bitfab 0.61.3 → 0.61.5

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 (32) hide show
  1. package/dist/{chunk-6IMUONDN.js → chunk-4TRH3X3S.js} +31 -3
  2. package/dist/chunk-4TRH3X3S.js.map +1 -0
  3. package/dist/{chunk-IZUZ5NBB.js → chunk-7OXXBUGQ.js} +178 -11
  4. package/dist/chunk-7OXXBUGQ.js.map +1 -0
  5. package/dist/{chunk-PAUXHTNF.js → chunk-KOANTEGQ.js} +6 -6
  6. package/dist/{chunk-PAUXHTNF.js.map → chunk-KOANTEGQ.js.map} +1 -1
  7. package/dist/{chunk-HVEZHLVQ.js → chunk-R5RMFRHX.js} +30 -3
  8. package/dist/{chunk-HVEZHLVQ.js.map → chunk-R5RMFRHX.js.map} +1 -1
  9. package/dist/{chunk-WOHIAKZF.js → chunk-VD5PS6WE.js} +28 -4
  10. package/dist/chunk-VD5PS6WE.js.map +1 -0
  11. package/dist/{http-BYICBOWP.js → http-CR2SEMK4.js} +2 -2
  12. package/dist/{http-3IYU5Z54.js → http-SK2QESXJ.js} +2 -2
  13. package/dist/index.cjs +220 -11
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +24 -4
  16. package/dist/index.d.ts +24 -4
  17. package/dist/index.js +3 -3
  18. package/dist/node.cjs +220 -11
  19. package/dist/node.cjs.map +1 -1
  20. package/dist/node.d.cts +1 -1
  21. package/dist/node.d.ts +1 -1
  22. package/dist/node.js +3 -3
  23. package/dist/{replay-SXHX5BBU.js → replay-YSR7FD4I.js} +3 -3
  24. package/dist/replayCli.js +2 -2
  25. package/dist/seedCli.js +2 -2
  26. package/package.json +1 -1
  27. package/dist/chunk-6IMUONDN.js.map +0 -1
  28. package/dist/chunk-IZUZ5NBB.js.map +0 -1
  29. package/dist/chunk-WOHIAKZF.js.map +0 -1
  30. /package/dist/{http-3IYU5Z54.js.map → http-CR2SEMK4.js.map} +0 -0
  31. /package/dist/{http-BYICBOWP.js.map → http-SK2QESXJ.js.map} +0 -0
  32. /package/dist/{replay-SXHX5BBU.js.map → replay-YSR7FD4I.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -697,7 +697,7 @@ declare class HttpClient {
697
697
  * Start a replay session by fetching historical traces.
698
698
  * Blocking call - creates an experiment and returns lightweight item references.
699
699
  */
700
- startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetIds?: string[], graderIds?: string[], dbBranchSettings?: DbBranchSettings, attempts?: number, includeOriginalMetadata?: boolean, onlyWithAssertions?: boolean, judgeAssertions?: boolean, experimentalSelectiveReplay?: SelectiveReplayOptions): Promise<StartReplayResponse>;
700
+ startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetIds?: string[], graderIds?: string[], dbBranchSettings?: DbBranchSettings, attempts?: number, includeOriginalMetadata?: boolean, onlyWithAssertions?: boolean, judgeAssertions?: boolean, experimentalSelectiveReplay?: SelectiveReplayOptions, notes?: string): Promise<StartReplayResponse>;
701
701
  resumeReplay(experimentId: string, traceFunctionKey: string, codeChangeFiles?: CodeChangeFile[] | null, force?: boolean): Promise<ResumeReplayResponse>;
702
702
  /**
703
703
  * Fetch an external span by ID.
@@ -733,6 +733,8 @@ declare class HttpClient {
733
733
  * Blocking call.
734
734
  */
735
735
  completeReplay(experimentId: string): Promise<CompleteReplayResponse>;
736
+ interruptReplay(experimentId: string): Promise<boolean>;
737
+ heartbeatReplay(experimentId: string): Promise<void>;
736
738
  getReseedSource(traceId: string): Promise<ReseedSourceResponse>;
737
739
  reseedTrace(traceId: string, runTraceId: string): Promise<ReseedTraceResponse>;
738
740
  /**
@@ -1951,6 +1953,14 @@ declare class OrganizationMembersClient {
1951
1953
  list(): Promise<OrganizationMember[]>;
1952
1954
  }
1953
1955
 
1956
+ type ReplayInterruptSignal = "SIGINT" | "SIGTERM";
1957
+ interface ReplayInterrupt {
1958
+ experimentId: string;
1959
+ experimentUrl: string;
1960
+ signal: ReplayInterruptSignal;
1961
+ markedInterrupted: boolean;
1962
+ }
1963
+
1954
1964
  /**
1955
1965
  * Replay historical traces through a function and create an experiment.
1956
1966
  *
@@ -2018,8 +2028,17 @@ interface ReplayOptions {
2018
2028
  * it selects by ID with no dataset attribution.
2019
2029
  */
2020
2030
  traceIds?: string[];
2021
- /** Optional display name for the resulting experiment. */
2031
+ /**
2032
+ * What this run is testing, in a few words, such as 'baseline' or 'shorter
2033
+ * system prompt'. Bitfab records the commit, branch, tree state, datasets,
2034
+ * and who ran it with every experiment, so do not repeat them here.
2035
+ */
2022
2036
  name?: string;
2037
+ /**
2038
+ * Run conditions Bitfab cannot see on its own, such as an environment
2039
+ * override or a forced feature flag. Kept on the experiment next to its name.
2040
+ */
2041
+ notes?: string;
2023
2042
  /** Positive integer limiting parallel items. Set to 1 for sequential. Default 10. */
2024
2043
  maxConcurrency?: number;
2025
2044
  /**
@@ -2174,6 +2193,7 @@ interface ReplayOptions {
2174
2193
  * callback never crashes the run.
2175
2194
  */
2176
2195
  onExperimentStart?: (experiment: ReplayExperiment) => void;
2196
+ onInterrupt?: (interrupt: ReplayInterrupt) => void;
2177
2197
  resume?: string;
2178
2198
  force?: boolean;
2179
2199
  }
@@ -3862,7 +3882,7 @@ interface CommitRef {
3862
3882
  /**
3863
3883
  * SDK version from package.json (injected at build time)
3864
3884
  */
3865
- declare const __version__ = "0.61.3";
3885
+ declare const __version__ = "0.61.5";
3866
3886
 
3867
3887
  /**
3868
3888
  * Constants for the Bitfab SDK.
@@ -4001,4 +4021,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
4001
4021
  run?: boolean;
4002
4022
  }): Promise<SeedResult>;
4003
4023
 
4004
- 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 ReplayExperiment, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayNodeIdentity, 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 SelectiveReplayDecision, type SelectiveReplayOptions, type SelectiveReplayReport, 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 };
4024
+ 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 ReplayExperiment, type ReplayInterrupt, type ReplayInterruptSignal, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayNodeIdentity, 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 SelectiveReplayDecision, type SelectiveReplayOptions, type SelectiveReplayReport, 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
@@ -697,7 +697,7 @@ declare class HttpClient {
697
697
  * Start a replay session by fetching historical traces.
698
698
  * Blocking call - creates an experiment and returns lightweight item references.
699
699
  */
700
- startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetIds?: string[], graderIds?: string[], dbBranchSettings?: DbBranchSettings, attempts?: number, includeOriginalMetadata?: boolean, onlyWithAssertions?: boolean, judgeAssertions?: boolean, experimentalSelectiveReplay?: SelectiveReplayOptions): Promise<StartReplayResponse>;
700
+ startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetIds?: string[], graderIds?: string[], dbBranchSettings?: DbBranchSettings, attempts?: number, includeOriginalMetadata?: boolean, onlyWithAssertions?: boolean, judgeAssertions?: boolean, experimentalSelectiveReplay?: SelectiveReplayOptions, notes?: string): Promise<StartReplayResponse>;
701
701
  resumeReplay(experimentId: string, traceFunctionKey: string, codeChangeFiles?: CodeChangeFile[] | null, force?: boolean): Promise<ResumeReplayResponse>;
702
702
  /**
703
703
  * Fetch an external span by ID.
@@ -733,6 +733,8 @@ declare class HttpClient {
733
733
  * Blocking call.
734
734
  */
735
735
  completeReplay(experimentId: string): Promise<CompleteReplayResponse>;
736
+ interruptReplay(experimentId: string): Promise<boolean>;
737
+ heartbeatReplay(experimentId: string): Promise<void>;
736
738
  getReseedSource(traceId: string): Promise<ReseedSourceResponse>;
737
739
  reseedTrace(traceId: string, runTraceId: string): Promise<ReseedTraceResponse>;
738
740
  /**
@@ -1951,6 +1953,14 @@ declare class OrganizationMembersClient {
1951
1953
  list(): Promise<OrganizationMember[]>;
1952
1954
  }
1953
1955
 
1956
+ type ReplayInterruptSignal = "SIGINT" | "SIGTERM";
1957
+ interface ReplayInterrupt {
1958
+ experimentId: string;
1959
+ experimentUrl: string;
1960
+ signal: ReplayInterruptSignal;
1961
+ markedInterrupted: boolean;
1962
+ }
1963
+
1954
1964
  /**
1955
1965
  * Replay historical traces through a function and create an experiment.
1956
1966
  *
@@ -2018,8 +2028,17 @@ interface ReplayOptions {
2018
2028
  * it selects by ID with no dataset attribution.
2019
2029
  */
2020
2030
  traceIds?: string[];
2021
- /** Optional display name for the resulting experiment. */
2031
+ /**
2032
+ * What this run is testing, in a few words, such as 'baseline' or 'shorter
2033
+ * system prompt'. Bitfab records the commit, branch, tree state, datasets,
2034
+ * and who ran it with every experiment, so do not repeat them here.
2035
+ */
2022
2036
  name?: string;
2037
+ /**
2038
+ * Run conditions Bitfab cannot see on its own, such as an environment
2039
+ * override or a forced feature flag. Kept on the experiment next to its name.
2040
+ */
2041
+ notes?: string;
2023
2042
  /** Positive integer limiting parallel items. Set to 1 for sequential. Default 10. */
2024
2043
  maxConcurrency?: number;
2025
2044
  /**
@@ -2174,6 +2193,7 @@ interface ReplayOptions {
2174
2193
  * callback never crashes the run.
2175
2194
  */
2176
2195
  onExperimentStart?: (experiment: ReplayExperiment) => void;
2196
+ onInterrupt?: (interrupt: ReplayInterrupt) => void;
2177
2197
  resume?: string;
2178
2198
  force?: boolean;
2179
2199
  }
@@ -3862,7 +3882,7 @@ interface CommitRef {
3862
3882
  /**
3863
3883
  * SDK version from package.json (injected at build time)
3864
3884
  */
3865
- declare const __version__ = "0.61.3";
3885
+ declare const __version__ = "0.61.5";
3866
3886
 
3867
3887
  /**
3868
3888
  * Constants for the Bitfab SDK.
@@ -4001,4 +4021,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
4001
4021
  run?: boolean;
4002
4022
  }): Promise<SeedResult>;
4003
4023
 
4004
- 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 ReplayExperiment, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayNodeIdentity, 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 SelectiveReplayDecision, type SelectiveReplayOptions, type SelectiveReplayReport, 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 };
4024
+ 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 ReplayExperiment, type ReplayInterrupt, type ReplayInterruptSignal, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayNodeIdentity, 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 SelectiveReplayDecision, type SelectiveReplayOptions, type SelectiveReplayReport, 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
@@ -35,7 +35,7 @@ import {
35
35
  getCurrentTrace,
36
36
  reseedFromRegistry,
37
37
  seedFromRegistry
38
- } from "./chunk-PAUXHTNF.js";
38
+ } from "./chunk-KOANTEGQ.js";
39
39
  import "./chunk-K4XCWQBC.js";
40
40
  import {
41
41
  BITFAB_PROGRESS_PREFIX,
@@ -44,7 +44,7 @@ import {
44
44
  ReplayError,
45
45
  reportReplayProgress,
46
46
  serializeReplayResult
47
- } from "./chunk-IZUZ5NBB.js";
47
+ } from "./chunk-7OXXBUGQ.js";
48
48
  import {
49
49
  BitfabError,
50
50
  DEFAULT_SERVICE_URL,
@@ -52,7 +52,7 @@ import {
52
52
  MixedTracingError,
53
53
  __version__,
54
54
  flushTraces
55
- } from "./chunk-6IMUONDN.js";
55
+ } from "./chunk-4TRH3X3S.js";
56
56
  import "./chunk-BAOIRE5T.js";
57
57
  export {
58
58
  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.61.3";
100
+ __version__ = "0.61.5";
101
101
  __packageName__ = "bitfab";
102
102
  }
103
103
  });
@@ -2293,7 +2293,7 @@ function warnDroppedExternalTrace(error) {
2293
2293
  function experimentIdWireFields(experimentId) {
2294
2294
  return { experimentId, testRunId: experimentId };
2295
2295
  }
2296
- var REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS, REPLAY_COMPLETE_REQUEST_TIMEOUT_MS, OTLP_TRACES_ENDPOINT, RETRYABLE_STATUSES, EXIT_FLUSH_TIMEOUT_MS, DEFAULT_LIFECYCLE_TIMEOUT_MS2, pendingTracePromises, liveHttpClients, carrierSeq, HttpClient;
2296
+ var REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS, REPLAY_COMPLETE_REQUEST_TIMEOUT_MS, REPLAY_INTERRUPT_REQUEST_TIMEOUT_MS, REPLAY_HEARTBEAT_REQUEST_TIMEOUT_MS, OTLP_TRACES_ENDPOINT, RETRYABLE_STATUSES, EXIT_FLUSH_TIMEOUT_MS, DEFAULT_LIFECYCLE_TIMEOUT_MS2, pendingTracePromises, liveHttpClients, carrierSeq, HttpClient;
2297
2297
  var init_http = __esm({
2298
2298
  "src/http.ts"() {
2299
2299
  "use strict";
@@ -2312,6 +2312,8 @@ var init_http = __esm({
2312
2312
  init_warnOnce();
2313
2313
  REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS = 3e5;
2314
2314
  REPLAY_COMPLETE_REQUEST_TIMEOUT_MS = 12e4;
2315
+ REPLAY_INTERRUPT_REQUEST_TIMEOUT_MS = 5e3;
2316
+ REPLAY_HEARTBEAT_REQUEST_TIMEOUT_MS = 5e3;
2315
2317
  OTLP_TRACES_ENDPOINT = "/api/sdk/otel/v1/traces";
2316
2318
  RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
2317
2319
  EXIT_FLUSH_TIMEOUT_MS = 5e3;
@@ -2899,7 +2901,7 @@ var init_http = __esm({
2899
2901
  * Start a replay session by fetching historical traces.
2900
2902
  * Blocking call - creates an experiment and returns lightweight item references.
2901
2903
  */
2902
- async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetIds, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions, judgeAssertions, experimentalSelectiveReplay) {
2904
+ async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetIds, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions, judgeAssertions, experimentalSelectiveReplay, notes) {
2903
2905
  const payload = { traceFunctionKey };
2904
2906
  if (experimentalSelectiveReplay !== void 0) {
2905
2907
  payload.experimentalSelectiveReplay = experimentalSelectiveReplay;
@@ -2913,6 +2915,9 @@ var init_http = __esm({
2913
2915
  if (name !== void 0) {
2914
2916
  payload.name = name;
2915
2917
  }
2918
+ if (notes !== void 0) {
2919
+ payload.notes = notes;
2920
+ }
2916
2921
  if (codeChangeDescription !== void 0) {
2917
2922
  payload.codeChangeDescription = codeChangeDescription;
2918
2923
  }
@@ -3124,6 +3129,28 @@ var init_http = __esm({
3124
3129
  { timeout: REPLAY_COMPLETE_REQUEST_TIMEOUT_MS }
3125
3130
  );
3126
3131
  }
3132
+ async interruptReplay(experimentId) {
3133
+ try {
3134
+ await this.request(
3135
+ "/api/sdk/replay/interrupt",
3136
+ experimentIdWireFields(experimentId),
3137
+ { timeout: REPLAY_INTERRUPT_REQUEST_TIMEOUT_MS }
3138
+ );
3139
+ return true;
3140
+ } catch {
3141
+ return false;
3142
+ }
3143
+ }
3144
+ async heartbeatReplay(experimentId) {
3145
+ try {
3146
+ await this.request(
3147
+ "/api/sdk/replay/heartbeat",
3148
+ experimentIdWireFields(experimentId),
3149
+ { timeout: REPLAY_HEARTBEAT_REQUEST_TIMEOUT_MS }
3150
+ );
3151
+ } catch {
3152
+ }
3153
+ }
3127
3154
  async getReseedSource(traceId) {
3128
3155
  return this.get(
3129
3156
  `/api/sdk/traces/${encodeURIComponent(traceId)}/reseedSource`
@@ -3627,6 +3654,114 @@ var init_integrationFixture = __esm({
3627
3654
  }
3628
3655
  });
3629
3656
 
3657
+ // src/replayHeartbeat.ts
3658
+ function startReplayHeartbeat(send) {
3659
+ let stopped = false;
3660
+ let inFlight;
3661
+ const timer = setInterval(() => {
3662
+ if (stopped || inFlight !== void 0) {
3663
+ return;
3664
+ }
3665
+ inFlight = send().catch(() => void 0).finally(() => {
3666
+ inFlight = void 0;
3667
+ });
3668
+ }, REPLAY_HEARTBEAT_INTERVAL_MS);
3669
+ unrefTimer(timer);
3670
+ return {
3671
+ stop: async () => {
3672
+ stopped = true;
3673
+ clearInterval(timer);
3674
+ await inFlight;
3675
+ }
3676
+ };
3677
+ }
3678
+ var REPLAY_HEARTBEAT_INTERVAL_MS;
3679
+ var init_replayHeartbeat = __esm({
3680
+ "src/replayHeartbeat.ts"() {
3681
+ "use strict";
3682
+ init_unrefTimer();
3683
+ REPLAY_HEARTBEAT_INTERVAL_MS = 6e4;
3684
+ }
3685
+ });
3686
+
3687
+ // src/replayInterrupt.ts
3688
+ function signalCapableProcess() {
3689
+ if (typeof process === "undefined" || typeof process.on !== "function") {
3690
+ return void 0;
3691
+ }
3692
+ return process;
3693
+ }
3694
+ function describeReplayInterrupt(experimentId, markedInterrupted) {
3695
+ if (markedInterrupted) {
3696
+ return `[replay] Experiment ${experimentId} interrupted.`;
3697
+ }
3698
+ return `[replay] Experiment ${experimentId} stopped, but Bitfab could not mark it interrupted. It will be marked interrupted within 15 minutes. A resume in the next two minutes may be refused as still running.`;
3699
+ }
3700
+ function reportInterrupted(experimentId, markedInterrupted) {
3701
+ try {
3702
+ console.error(describeReplayInterrupt(experimentId, markedInterrupted));
3703
+ } catch {
3704
+ }
3705
+ }
3706
+ function installReplayInterruptHandlers(target) {
3707
+ const host = signalCapableProcess();
3708
+ if (host === void 0) {
3709
+ return { remove: () => {
3710
+ }, interrupted: () => false };
3711
+ }
3712
+ const handlers = /* @__PURE__ */ new Map();
3713
+ const removeHandlers = () => {
3714
+ for (const [signal, handler] of handlers) {
3715
+ host.removeListener(signal, handler);
3716
+ }
3717
+ handlers.clear();
3718
+ };
3719
+ let interrupting = false;
3720
+ const handleSignal = async (signal) => {
3721
+ const hostHandlesSignal = host.listenerCount(signal) > 1;
3722
+ const markedInterrupted = await target.interrupt();
3723
+ removeHandlers();
3724
+ if (target.onInterrupt !== void 0) {
3725
+ try {
3726
+ target.onInterrupt({
3727
+ experimentId: target.experimentId,
3728
+ experimentUrl: target.experimentUrl,
3729
+ signal,
3730
+ markedInterrupted
3731
+ });
3732
+ } catch {
3733
+ }
3734
+ return;
3735
+ }
3736
+ reportInterrupted(target.experimentId, markedInterrupted);
3737
+ if (!hostHandlesSignal) {
3738
+ host.kill(host.pid, signal);
3739
+ }
3740
+ };
3741
+ for (const signal of REPLAY_INTERRUPT_SIGNALS) {
3742
+ const handler = () => {
3743
+ if (interrupting) {
3744
+ return;
3745
+ }
3746
+ interrupting = true;
3747
+ void handleSignal(signal);
3748
+ };
3749
+ handlers.set(signal, handler);
3750
+ host.on(signal, handler);
3751
+ }
3752
+ return { remove: removeHandlers, interrupted: () => interrupting };
3753
+ }
3754
+ var REPLAY_INTERRUPT_SIGNALS;
3755
+ var init_replayInterrupt = __esm({
3756
+ "src/replayInterrupt.ts"() {
3757
+ "use strict";
3758
+ REPLAY_INTERRUPT_SIGNALS = [
3759
+ "SIGINT",
3760
+ "SIGTERM"
3761
+ ];
3762
+ }
3763
+ });
3764
+
3630
3765
  // src/selectiveReplay.ts
3631
3766
  function replayNodeKey(node) {
3632
3767
  return JSON.stringify([node.traceFunctionKey, node.spanName]);
@@ -4536,7 +4671,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4536
4671
  const includeDbBranchLease = dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true;
4537
4672
  let session;
4538
4673
  if (options?.resume === void 0) {
4539
- const started2 = await httpClient.startReplay(
4674
+ const started = await httpClient.startReplay(
4540
4675
  traceFunctionKey,
4541
4676
  // limit is meaningless with explicit traceIds (the ID list determines
4542
4677
  // the count), so it's omitted from the request entirely.
@@ -4557,9 +4692,10 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4557
4692
  options?.adaptInputs !== void 0,
4558
4693
  options?.onlyWithAssertions,
4559
4694
  options?.judgeAssertions,
4560
- options?.experimentalSelectiveReplay
4695
+ options?.experimentalSelectiveReplay,
4696
+ options?.notes
4561
4697
  );
4562
- if (started2.items.length === 0) {
4698
+ if (started.items.length === 0) {
4563
4699
  try {
4564
4700
  console.warn(
4565
4701
  `Bitfab: no traces matched "${traceFunctionKey}", so this replay ran nothing. Capture a trace, or seed one with seedTrace, before replaying.`
@@ -4568,10 +4704,10 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4568
4704
  }
4569
4705
  }
4570
4706
  session = {
4571
- experimentId: started2.experimentId,
4572
- experimentUrl: started2.experimentUrl,
4707
+ experimentId: started.experimentId,
4708
+ experimentUrl: started.experimentUrl,
4573
4709
  attempts: requestedAttempts,
4574
- work: expandReplayWork(started2.items, requestedAttempts),
4710
+ work: expandReplayWork(started.items, requestedAttempts),
4575
4711
  finished: [],
4576
4712
  includeDbBranchLease,
4577
4713
  dbBranchSettings: resolveDbBranchSettings(options?.dbBranch)
@@ -4586,9 +4722,68 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4586
4722
  options.dbBranch
4587
4723
  );
4588
4724
  }
4589
- const { experimentId, experimentUrl, attempts } = session;
4725
+ const { experimentId } = session;
4726
+ const fullExperimentUrl = `${serviceUrl}${session.experimentUrl}`;
4727
+ const heartbeat = startReplayHeartbeat(
4728
+ () => httpClient.heartbeatReplay(experimentId)
4729
+ );
4730
+ const interruptReplay = async () => {
4731
+ await heartbeat.stop();
4732
+ return httpClient.interruptReplay(experimentId);
4733
+ };
4734
+ const interruptHandlers = installReplayInterruptHandlers({
4735
+ experimentId,
4736
+ experimentUrl: fullExperimentUrl,
4737
+ interrupt: interruptReplay,
4738
+ onInterrupt: options?.onInterrupt
4739
+ });
4740
+ let completeReturned = false;
4741
+ const markCompleteReturned = () => {
4742
+ completeReturned = true;
4743
+ void heartbeat.stop();
4744
+ };
4745
+ try {
4746
+ return await runReplaySession(
4747
+ httpClient,
4748
+ fn,
4749
+ session,
4750
+ fullExperimentUrl,
4751
+ maxConcurrency,
4752
+ interruptHandlers.remove,
4753
+ markCompleteReturned,
4754
+ interruptHandlers.interrupted,
4755
+ options,
4756
+ registeredOverrides
4757
+ );
4758
+ } catch (error) {
4759
+ if (!completeReturned && !interruptHandlers.interrupted()) {
4760
+ await interruptReplay();
4761
+ }
4762
+ throw error;
4763
+ } finally {
4764
+ interruptHandlers.remove();
4765
+ await heartbeat.stop();
4766
+ }
4767
+ }
4768
+ function throwIfInterrupted(interrupted, items, experimentId, experimentUrl) {
4769
+ if (!interrupted()) {
4770
+ return;
4771
+ }
4772
+ const cause = new BitfabError(
4773
+ `Experiment ${experimentId} was interrupted, so it was not completed or graded. Resume it by passing { resume: "${experimentId}" } to replay, or with bitfab-replay --resume ${experimentId}.`,
4774
+ experimentUrl
4775
+ );
4776
+ throw new ReplayError(
4777
+ cause.message,
4778
+ items,
4779
+ experimentId,
4780
+ experimentUrl,
4781
+ cause
4782
+ );
4783
+ }
4784
+ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxConcurrency, stopInterruptingOnSignal, markCompleteReturned, interrupted, options, registeredOverrides) {
4785
+ const { experimentId, attempts } = session;
4590
4786
  const mockStrategy = options?.mock ?? "marked";
4591
- const fullExperimentUrl = `${serviceUrl}${experimentUrl}`;
4592
4787
  try {
4593
4788
  options?.onExperimentStart?.({
4594
4789
  experimentId,
@@ -4738,7 +4933,15 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4738
4933
  );
4739
4934
  const resultItems = [...carriedOverItems, ...ranItems];
4740
4935
  if (options?.dryRun === true) {
4936
+ throwIfInterrupted(
4937
+ interrupted,
4938
+ resultItems,
4939
+ experimentId,
4940
+ fullExperimentUrl
4941
+ );
4942
+ stopInterruptingOnSignal();
4741
4943
  await httpClient.completeReplay(experimentId).catch(() => void 0);
4944
+ markCompleteReturned();
4742
4945
  const dryResult = {
4743
4946
  items: resultItems,
4744
4947
  experimentId,
@@ -4763,12 +4966,15 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4763
4966
  ranItems[index].traceId = readBack;
4764
4967
  }
4765
4968
  }
4969
+ throwIfInterrupted(interrupted, resultItems, experimentId, fullExperimentUrl);
4970
+ stopInterruptingOnSignal();
4766
4971
  const completeResult = await preserveReplayFailure(
4767
4972
  () => httpClient.completeReplay(experimentId),
4768
4973
  resultItems,
4769
4974
  experimentId,
4770
4975
  fullExperimentUrl
4771
4976
  );
4977
+ markCompleteReturned();
4772
4978
  const serverTraceIds = completeResult.traceIds;
4773
4979
  const replayTokens = completeResult.tokens;
4774
4980
  if (serverTraceIds !== void 0) {
@@ -4872,6 +5078,8 @@ var init_replay = __esm({
4872
5078
  init_mockOverride();
4873
5079
  init_randomUuid();
4874
5080
  init_replayContext();
5081
+ init_replayHeartbeat();
5082
+ init_replayInterrupt();
4875
5083
  init_selectiveReplayRuntime();
4876
5084
  init_serialize();
4877
5085
  REPLAY_PERSISTENCE_TIMEOUT_MS = 3e4;
@@ -11655,6 +11863,7 @@ init_replay();
11655
11863
  // src/replayRegistry.ts
11656
11864
  init_errors();
11657
11865
  init_replay();
11866
+ init_replayInterrupt();
11658
11867
  function defineReplayRegistry(registry) {
11659
11868
  return registry;
11660
11869
  }