@bitfab/sdk 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-7BU5LUMR.js → chunk-2ZUNCC2Q.js} +30 -3
  2. package/dist/{chunk-7BU5LUMR.js.map → chunk-2ZUNCC2Q.js.map} +1 -1
  3. package/dist/{chunk-34UFYAE6.js → chunk-44KG6B5D.js} +178 -11
  4. package/dist/chunk-44KG6B5D.js.map +1 -0
  5. package/dist/{chunk-TZSTKVZF.js → chunk-NISRFSN2.js} +6 -6
  6. package/dist/{chunk-TZSTKVZF.js.map → chunk-NISRFSN2.js.map} +1 -1
  7. package/dist/{chunk-OWXP3YXA.js → chunk-Y4IGLP2Z.js} +28 -4
  8. package/dist/chunk-Y4IGLP2Z.js.map +1 -0
  9. package/dist/{chunk-65QKCHI2.js → chunk-ZPVWVXWC.js} +31 -3
  10. package/dist/chunk-ZPVWVXWC.js.map +1 -0
  11. package/dist/{http-ZWENQXQA.js → http-JPHWWKL5.js} +2 -2
  12. package/dist/{http-VTIALK4P.js → http-VKYDN6PO.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-YQG3OGDN.js → replay-FP3L3X7Q.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-34UFYAE6.js.map +0 -1
  28. package/dist/chunk-65QKCHI2.js.map +0 -1
  29. package/dist/chunk-OWXP3YXA.js.map +0 -1
  30. /package/dist/{http-VTIALK4P.js.map → http-JPHWWKL5.js.map} +0 -0
  31. /package/dist/{http-ZWENQXQA.js.map → http-VKYDN6PO.js.map} +0 -0
  32. /package/dist/{replay-YQG3OGDN.js.map → replay-FP3L3X7Q.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
@@ -26,7 +26,7 @@ import {
26
26
  getCurrentTrace,
27
27
  reseedFromRegistry,
28
28
  seedFromRegistry
29
- } from "./chunk-TZSTKVZF.js";
29
+ } from "./chunk-NISRFSN2.js";
30
30
  import "./chunk-K4XCWQBC.js";
31
31
  import {
32
32
  BITFAB_PROGRESS_PREFIX,
@@ -35,7 +35,7 @@ import {
35
35
  ReplayError,
36
36
  reportReplayProgress,
37
37
  serializeReplayResult
38
- } from "./chunk-34UFYAE6.js";
38
+ } from "./chunk-44KG6B5D.js";
39
39
  import {
40
40
  BitfabError,
41
41
  DEFAULT_SERVICE_URL,
@@ -43,7 +43,7 @@ import {
43
43
  MixedTracingError,
44
44
  __version__,
45
45
  flushTraces
46
- } from "./chunk-65QKCHI2.js";
46
+ } from "./chunk-ZPVWVXWC.js";
47
47
  import "./chunk-BAOIRE5T.js";
48
48
  export {
49
49
  AssertionCategoriesClient,
package/dist/node.cjs CHANGED
@@ -88,7 +88,7 @@ var __version__, __packageName__;
88
88
  var init_version_generated = __esm({
89
89
  "src/version.generated.ts"() {
90
90
  "use strict";
91
- __version__ = "0.61.3";
91
+ __version__ = "0.61.5";
92
92
  __packageName__ = "@bitfab/sdk";
93
93
  }
94
94
  });
@@ -2284,7 +2284,7 @@ function warnDroppedExternalTrace(error) {
2284
2284
  function experimentIdWireFields(experimentId) {
2285
2285
  return { experimentId, testRunId: experimentId };
2286
2286
  }
2287
- 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;
2287
+ 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;
2288
2288
  var init_http = __esm({
2289
2289
  "src/http.ts"() {
2290
2290
  "use strict";
@@ -2303,6 +2303,8 @@ var init_http = __esm({
2303
2303
  init_warnOnce();
2304
2304
  REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS = 3e5;
2305
2305
  REPLAY_COMPLETE_REQUEST_TIMEOUT_MS = 12e4;
2306
+ REPLAY_INTERRUPT_REQUEST_TIMEOUT_MS = 5e3;
2307
+ REPLAY_HEARTBEAT_REQUEST_TIMEOUT_MS = 5e3;
2306
2308
  OTLP_TRACES_ENDPOINT = "/api/sdk/otel/v1/traces";
2307
2309
  RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
2308
2310
  EXIT_FLUSH_TIMEOUT_MS = 5e3;
@@ -2890,7 +2892,7 @@ var init_http = __esm({
2890
2892
  * Start a replay session by fetching historical traces.
2891
2893
  * Blocking call - creates an experiment and returns lightweight item references.
2892
2894
  */
2893
- async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetIds, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions, judgeAssertions, experimentalSelectiveReplay) {
2895
+ async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetIds, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions, judgeAssertions, experimentalSelectiveReplay, notes) {
2894
2896
  const payload = { traceFunctionKey };
2895
2897
  if (experimentalSelectiveReplay !== void 0) {
2896
2898
  payload.experimentalSelectiveReplay = experimentalSelectiveReplay;
@@ -2904,6 +2906,9 @@ var init_http = __esm({
2904
2906
  if (name !== void 0) {
2905
2907
  payload.name = name;
2906
2908
  }
2909
+ if (notes !== void 0) {
2910
+ payload.notes = notes;
2911
+ }
2907
2912
  if (codeChangeDescription !== void 0) {
2908
2913
  payload.codeChangeDescription = codeChangeDescription;
2909
2914
  }
@@ -3115,6 +3120,28 @@ var init_http = __esm({
3115
3120
  { timeout: REPLAY_COMPLETE_REQUEST_TIMEOUT_MS }
3116
3121
  );
3117
3122
  }
3123
+ async interruptReplay(experimentId) {
3124
+ try {
3125
+ await this.request(
3126
+ "/api/sdk/replay/interrupt",
3127
+ experimentIdWireFields(experimentId),
3128
+ { timeout: REPLAY_INTERRUPT_REQUEST_TIMEOUT_MS }
3129
+ );
3130
+ return true;
3131
+ } catch {
3132
+ return false;
3133
+ }
3134
+ }
3135
+ async heartbeatReplay(experimentId) {
3136
+ try {
3137
+ await this.request(
3138
+ "/api/sdk/replay/heartbeat",
3139
+ experimentIdWireFields(experimentId),
3140
+ { timeout: REPLAY_HEARTBEAT_REQUEST_TIMEOUT_MS }
3141
+ );
3142
+ } catch {
3143
+ }
3144
+ }
3118
3145
  async getReseedSource(traceId) {
3119
3146
  return this.get(
3120
3147
  `/api/sdk/traces/${encodeURIComponent(traceId)}/reseedSource`
@@ -3618,6 +3645,114 @@ var init_integrationFixture = __esm({
3618
3645
  }
3619
3646
  });
3620
3647
 
3648
+ // src/replayHeartbeat.ts
3649
+ function startReplayHeartbeat(send) {
3650
+ let stopped = false;
3651
+ let inFlight;
3652
+ const timer = setInterval(() => {
3653
+ if (stopped || inFlight !== void 0) {
3654
+ return;
3655
+ }
3656
+ inFlight = send().catch(() => void 0).finally(() => {
3657
+ inFlight = void 0;
3658
+ });
3659
+ }, REPLAY_HEARTBEAT_INTERVAL_MS);
3660
+ unrefTimer(timer);
3661
+ return {
3662
+ stop: async () => {
3663
+ stopped = true;
3664
+ clearInterval(timer);
3665
+ await inFlight;
3666
+ }
3667
+ };
3668
+ }
3669
+ var REPLAY_HEARTBEAT_INTERVAL_MS;
3670
+ var init_replayHeartbeat = __esm({
3671
+ "src/replayHeartbeat.ts"() {
3672
+ "use strict";
3673
+ init_unrefTimer();
3674
+ REPLAY_HEARTBEAT_INTERVAL_MS = 6e4;
3675
+ }
3676
+ });
3677
+
3678
+ // src/replayInterrupt.ts
3679
+ function signalCapableProcess() {
3680
+ if (typeof process === "undefined" || typeof process.on !== "function") {
3681
+ return void 0;
3682
+ }
3683
+ return process;
3684
+ }
3685
+ function describeReplayInterrupt(experimentId, markedInterrupted) {
3686
+ if (markedInterrupted) {
3687
+ return `[replay] Experiment ${experimentId} interrupted.`;
3688
+ }
3689
+ 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.`;
3690
+ }
3691
+ function reportInterrupted(experimentId, markedInterrupted) {
3692
+ try {
3693
+ console.error(describeReplayInterrupt(experimentId, markedInterrupted));
3694
+ } catch {
3695
+ }
3696
+ }
3697
+ function installReplayInterruptHandlers(target) {
3698
+ const host = signalCapableProcess();
3699
+ if (host === void 0) {
3700
+ return { remove: () => {
3701
+ }, interrupted: () => false };
3702
+ }
3703
+ const handlers = /* @__PURE__ */ new Map();
3704
+ const removeHandlers = () => {
3705
+ for (const [signal, handler] of handlers) {
3706
+ host.removeListener(signal, handler);
3707
+ }
3708
+ handlers.clear();
3709
+ };
3710
+ let interrupting = false;
3711
+ const handleSignal = async (signal) => {
3712
+ const hostHandlesSignal = host.listenerCount(signal) > 1;
3713
+ const markedInterrupted = await target.interrupt();
3714
+ removeHandlers();
3715
+ if (target.onInterrupt !== void 0) {
3716
+ try {
3717
+ target.onInterrupt({
3718
+ experimentId: target.experimentId,
3719
+ experimentUrl: target.experimentUrl,
3720
+ signal,
3721
+ markedInterrupted
3722
+ });
3723
+ } catch {
3724
+ }
3725
+ return;
3726
+ }
3727
+ reportInterrupted(target.experimentId, markedInterrupted);
3728
+ if (!hostHandlesSignal) {
3729
+ host.kill(host.pid, signal);
3730
+ }
3731
+ };
3732
+ for (const signal of REPLAY_INTERRUPT_SIGNALS) {
3733
+ const handler = () => {
3734
+ if (interrupting) {
3735
+ return;
3736
+ }
3737
+ interrupting = true;
3738
+ void handleSignal(signal);
3739
+ };
3740
+ handlers.set(signal, handler);
3741
+ host.on(signal, handler);
3742
+ }
3743
+ return { remove: removeHandlers, interrupted: () => interrupting };
3744
+ }
3745
+ var REPLAY_INTERRUPT_SIGNALS;
3746
+ var init_replayInterrupt = __esm({
3747
+ "src/replayInterrupt.ts"() {
3748
+ "use strict";
3749
+ REPLAY_INTERRUPT_SIGNALS = [
3750
+ "SIGINT",
3751
+ "SIGTERM"
3752
+ ];
3753
+ }
3754
+ });
3755
+
3621
3756
  // src/selectiveReplay.ts
3622
3757
  function replayNodeKey(node) {
3623
3758
  return JSON.stringify([node.traceFunctionKey, node.spanName]);
@@ -4527,7 +4662,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4527
4662
  const includeDbBranchLease = dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true;
4528
4663
  let session;
4529
4664
  if (options?.resume === void 0) {
4530
- const started2 = await httpClient.startReplay(
4665
+ const started = await httpClient.startReplay(
4531
4666
  traceFunctionKey,
4532
4667
  // limit is meaningless with explicit traceIds (the ID list determines
4533
4668
  // the count), so it's omitted from the request entirely.
@@ -4548,9 +4683,10 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4548
4683
  options?.adaptInputs !== void 0,
4549
4684
  options?.onlyWithAssertions,
4550
4685
  options?.judgeAssertions,
4551
- options?.experimentalSelectiveReplay
4686
+ options?.experimentalSelectiveReplay,
4687
+ options?.notes
4552
4688
  );
4553
- if (started2.items.length === 0) {
4689
+ if (started.items.length === 0) {
4554
4690
  try {
4555
4691
  console.warn(
4556
4692
  `Bitfab: no traces matched "${traceFunctionKey}", so this replay ran nothing. Capture a trace, or seed one with seedTrace, before replaying.`
@@ -4559,10 +4695,10 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4559
4695
  }
4560
4696
  }
4561
4697
  session = {
4562
- experimentId: started2.experimentId,
4563
- experimentUrl: started2.experimentUrl,
4698
+ experimentId: started.experimentId,
4699
+ experimentUrl: started.experimentUrl,
4564
4700
  attempts: requestedAttempts,
4565
- work: expandReplayWork(started2.items, requestedAttempts),
4701
+ work: expandReplayWork(started.items, requestedAttempts),
4566
4702
  finished: [],
4567
4703
  includeDbBranchLease,
4568
4704
  dbBranchSettings: resolveDbBranchSettings(options?.dbBranch)
@@ -4577,9 +4713,68 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4577
4713
  options.dbBranch
4578
4714
  );
4579
4715
  }
4580
- const { experimentId, experimentUrl, attempts } = session;
4716
+ const { experimentId } = session;
4717
+ const fullExperimentUrl = `${serviceUrl}${session.experimentUrl}`;
4718
+ const heartbeat = startReplayHeartbeat(
4719
+ () => httpClient.heartbeatReplay(experimentId)
4720
+ );
4721
+ const interruptReplay = async () => {
4722
+ await heartbeat.stop();
4723
+ return httpClient.interruptReplay(experimentId);
4724
+ };
4725
+ const interruptHandlers = installReplayInterruptHandlers({
4726
+ experimentId,
4727
+ experimentUrl: fullExperimentUrl,
4728
+ interrupt: interruptReplay,
4729
+ onInterrupt: options?.onInterrupt
4730
+ });
4731
+ let completeReturned = false;
4732
+ const markCompleteReturned = () => {
4733
+ completeReturned = true;
4734
+ void heartbeat.stop();
4735
+ };
4736
+ try {
4737
+ return await runReplaySession(
4738
+ httpClient,
4739
+ fn,
4740
+ session,
4741
+ fullExperimentUrl,
4742
+ maxConcurrency,
4743
+ interruptHandlers.remove,
4744
+ markCompleteReturned,
4745
+ interruptHandlers.interrupted,
4746
+ options,
4747
+ registeredOverrides
4748
+ );
4749
+ } catch (error) {
4750
+ if (!completeReturned && !interruptHandlers.interrupted()) {
4751
+ await interruptReplay();
4752
+ }
4753
+ throw error;
4754
+ } finally {
4755
+ interruptHandlers.remove();
4756
+ await heartbeat.stop();
4757
+ }
4758
+ }
4759
+ function throwIfInterrupted(interrupted, items, experimentId, experimentUrl) {
4760
+ if (!interrupted()) {
4761
+ return;
4762
+ }
4763
+ const cause = new BitfabError(
4764
+ `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}.`,
4765
+ experimentUrl
4766
+ );
4767
+ throw new ReplayError(
4768
+ cause.message,
4769
+ items,
4770
+ experimentId,
4771
+ experimentUrl,
4772
+ cause
4773
+ );
4774
+ }
4775
+ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxConcurrency, stopInterruptingOnSignal, markCompleteReturned, interrupted, options, registeredOverrides) {
4776
+ const { experimentId, attempts } = session;
4581
4777
  const mockStrategy = options?.mock ?? "marked";
4582
- const fullExperimentUrl = `${serviceUrl}${experimentUrl}`;
4583
4778
  try {
4584
4779
  options?.onExperimentStart?.({
4585
4780
  experimentId,
@@ -4729,7 +4924,15 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4729
4924
  );
4730
4925
  const resultItems = [...carriedOverItems, ...ranItems];
4731
4926
  if (options?.dryRun === true) {
4927
+ throwIfInterrupted(
4928
+ interrupted,
4929
+ resultItems,
4930
+ experimentId,
4931
+ fullExperimentUrl
4932
+ );
4933
+ stopInterruptingOnSignal();
4732
4934
  await httpClient.completeReplay(experimentId).catch(() => void 0);
4935
+ markCompleteReturned();
4733
4936
  const dryResult = {
4734
4937
  items: resultItems,
4735
4938
  experimentId,
@@ -4754,12 +4957,15 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4754
4957
  ranItems[index].traceId = readBack;
4755
4958
  }
4756
4959
  }
4960
+ throwIfInterrupted(interrupted, resultItems, experimentId, fullExperimentUrl);
4961
+ stopInterruptingOnSignal();
4757
4962
  const completeResult = await preserveReplayFailure(
4758
4963
  () => httpClient.completeReplay(experimentId),
4759
4964
  resultItems,
4760
4965
  experimentId,
4761
4966
  fullExperimentUrl
4762
4967
  );
4968
+ markCompleteReturned();
4763
4969
  const serverTraceIds = completeResult.traceIds;
4764
4970
  const replayTokens = completeResult.tokens;
4765
4971
  if (serverTraceIds !== void 0) {
@@ -4863,6 +5069,8 @@ var init_replay = __esm({
4863
5069
  init_mockOverride();
4864
5070
  init_randomUuid();
4865
5071
  init_replayContext();
5072
+ init_replayHeartbeat();
5073
+ init_replayInterrupt();
4866
5074
  init_selectiveReplayRuntime();
4867
5075
  init_serialize();
4868
5076
  REPLAY_PERSISTENCE_TIMEOUT_MS = 3e4;
@@ -11646,6 +11854,7 @@ init_replay();
11646
11854
  // src/replayRegistry.ts
11647
11855
  init_errors();
11648
11856
  init_replay();
11857
+ init_replayInterrupt();
11649
11858
  function defineReplayRegistry(registry) {
11650
11859
  return registry;
11651
11860
  }