@bitfab/sdk 0.61.3 → 0.61.4

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-TZSTKVZF.js → chunk-2ZZBNQVA.js} +6 -6
  2. package/dist/{chunk-TZSTKVZF.js.map → chunk-2ZZBNQVA.js.map} +1 -1
  3. package/dist/{chunk-7BU5LUMR.js → chunk-3GSEECNP.js} +26 -2
  4. package/dist/{chunk-7BU5LUMR.js.map → chunk-3GSEECNP.js.map} +1 -1
  5. package/dist/{chunk-OWXP3YXA.js → chunk-BRSQCK3F.js} +21 -3
  6. package/dist/chunk-BRSQCK3F.js.map +1 -0
  7. package/dist/{chunk-34UFYAE6.js → chunk-FL6BNPSO.js} +176 -10
  8. package/dist/chunk-FL6BNPSO.js.map +1 -0
  9. package/dist/{chunk-65QKCHI2.js → chunk-THGHTVB6.js} +27 -2
  10. package/dist/chunk-THGHTVB6.js.map +1 -0
  11. package/dist/{http-VTIALK4P.js → http-J2DYDKWJ.js} +2 -2
  12. package/dist/{http-ZWENQXQA.js → http-RH3SW32W.js} +2 -2
  13. package/dist/index.cjs +214 -9
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +13 -2
  16. package/dist/index.d.ts +13 -2
  17. package/dist/index.js +3 -3
  18. package/dist/node.cjs +214 -9
  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-CZWFAAIY.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-J2DYDKWJ.js.map} +0 -0
  31. /package/dist/{http-ZWENQXQA.js.map → http-RH3SW32W.js.map} +0 -0
  32. /package/dist/{replay-YQG3OGDN.js.map → replay-CZWFAAIY.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -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
  *
@@ -2174,6 +2184,7 @@ interface ReplayOptions {
2174
2184
  * callback never crashes the run.
2175
2185
  */
2176
2186
  onExperimentStart?: (experiment: ReplayExperiment) => void;
2187
+ onInterrupt?: (interrupt: ReplayInterrupt) => void;
2177
2188
  resume?: string;
2178
2189
  force?: boolean;
2179
2190
  }
@@ -3862,7 +3873,7 @@ interface CommitRef {
3862
3873
  /**
3863
3874
  * SDK version from package.json (injected at build time)
3864
3875
  */
3865
- declare const __version__ = "0.61.3";
3876
+ declare const __version__ = "0.61.4";
3866
3877
 
3867
3878
  /**
3868
3879
  * Constants for the Bitfab SDK.
@@ -4001,4 +4012,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
4001
4012
  run?: boolean;
4002
4013
  }): Promise<SeedResult>;
4003
4014
 
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 };
4015
+ 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
@@ -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
  *
@@ -2174,6 +2184,7 @@ interface ReplayOptions {
2174
2184
  * callback never crashes the run.
2175
2185
  */
2176
2186
  onExperimentStart?: (experiment: ReplayExperiment) => void;
2187
+ onInterrupt?: (interrupt: ReplayInterrupt) => void;
2177
2188
  resume?: string;
2178
2189
  force?: boolean;
2179
2190
  }
@@ -3862,7 +3873,7 @@ interface CommitRef {
3862
3873
  /**
3863
3874
  * SDK version from package.json (injected at build time)
3864
3875
  */
3865
- declare const __version__ = "0.61.3";
3876
+ declare const __version__ = "0.61.4";
3866
3877
 
3867
3878
  /**
3868
3879
  * Constants for the Bitfab SDK.
@@ -4001,4 +4012,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
4001
4012
  run?: boolean;
4002
4013
  }): Promise<SeedResult>;
4003
4014
 
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 };
4015
+ 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-2ZZBNQVA.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-FL6BNPSO.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-THGHTVB6.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.4";
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;
@@ -3115,6 +3117,28 @@ var init_http = __esm({
3115
3117
  { timeout: REPLAY_COMPLETE_REQUEST_TIMEOUT_MS }
3116
3118
  );
3117
3119
  }
3120
+ async interruptReplay(experimentId) {
3121
+ try {
3122
+ await this.request(
3123
+ "/api/sdk/replay/interrupt",
3124
+ experimentIdWireFields(experimentId),
3125
+ { timeout: REPLAY_INTERRUPT_REQUEST_TIMEOUT_MS }
3126
+ );
3127
+ return true;
3128
+ } catch {
3129
+ return false;
3130
+ }
3131
+ }
3132
+ async heartbeatReplay(experimentId) {
3133
+ try {
3134
+ await this.request(
3135
+ "/api/sdk/replay/heartbeat",
3136
+ experimentIdWireFields(experimentId),
3137
+ { timeout: REPLAY_HEARTBEAT_REQUEST_TIMEOUT_MS }
3138
+ );
3139
+ } catch {
3140
+ }
3141
+ }
3118
3142
  async getReseedSource(traceId) {
3119
3143
  return this.get(
3120
3144
  `/api/sdk/traces/${encodeURIComponent(traceId)}/reseedSource`
@@ -3618,6 +3642,114 @@ var init_integrationFixture = __esm({
3618
3642
  }
3619
3643
  });
3620
3644
 
3645
+ // src/replayHeartbeat.ts
3646
+ function startReplayHeartbeat(send) {
3647
+ let stopped = false;
3648
+ let inFlight;
3649
+ const timer = setInterval(() => {
3650
+ if (stopped || inFlight !== void 0) {
3651
+ return;
3652
+ }
3653
+ inFlight = send().catch(() => void 0).finally(() => {
3654
+ inFlight = void 0;
3655
+ });
3656
+ }, REPLAY_HEARTBEAT_INTERVAL_MS);
3657
+ unrefTimer(timer);
3658
+ return {
3659
+ stop: async () => {
3660
+ stopped = true;
3661
+ clearInterval(timer);
3662
+ await inFlight;
3663
+ }
3664
+ };
3665
+ }
3666
+ var REPLAY_HEARTBEAT_INTERVAL_MS;
3667
+ var init_replayHeartbeat = __esm({
3668
+ "src/replayHeartbeat.ts"() {
3669
+ "use strict";
3670
+ init_unrefTimer();
3671
+ REPLAY_HEARTBEAT_INTERVAL_MS = 6e4;
3672
+ }
3673
+ });
3674
+
3675
+ // src/replayInterrupt.ts
3676
+ function signalCapableProcess() {
3677
+ if (typeof process === "undefined" || typeof process.on !== "function") {
3678
+ return void 0;
3679
+ }
3680
+ return process;
3681
+ }
3682
+ function describeReplayInterrupt(experimentId, markedInterrupted) {
3683
+ if (markedInterrupted) {
3684
+ return `[replay] Experiment ${experimentId} interrupted.`;
3685
+ }
3686
+ 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.`;
3687
+ }
3688
+ function reportInterrupted(experimentId, markedInterrupted) {
3689
+ try {
3690
+ console.error(describeReplayInterrupt(experimentId, markedInterrupted));
3691
+ } catch {
3692
+ }
3693
+ }
3694
+ function installReplayInterruptHandlers(target) {
3695
+ const host = signalCapableProcess();
3696
+ if (host === void 0) {
3697
+ return { remove: () => {
3698
+ }, interrupted: () => false };
3699
+ }
3700
+ const handlers = /* @__PURE__ */ new Map();
3701
+ const removeHandlers = () => {
3702
+ for (const [signal, handler] of handlers) {
3703
+ host.removeListener(signal, handler);
3704
+ }
3705
+ handlers.clear();
3706
+ };
3707
+ let interrupting = false;
3708
+ const handleSignal = async (signal) => {
3709
+ const hostHandlesSignal = host.listenerCount(signal) > 1;
3710
+ const markedInterrupted = await target.interrupt();
3711
+ removeHandlers();
3712
+ if (target.onInterrupt !== void 0) {
3713
+ try {
3714
+ target.onInterrupt({
3715
+ experimentId: target.experimentId,
3716
+ experimentUrl: target.experimentUrl,
3717
+ signal,
3718
+ markedInterrupted
3719
+ });
3720
+ } catch {
3721
+ }
3722
+ return;
3723
+ }
3724
+ reportInterrupted(target.experimentId, markedInterrupted);
3725
+ if (!hostHandlesSignal) {
3726
+ host.kill(host.pid, signal);
3727
+ }
3728
+ };
3729
+ for (const signal of REPLAY_INTERRUPT_SIGNALS) {
3730
+ const handler = () => {
3731
+ if (interrupting) {
3732
+ return;
3733
+ }
3734
+ interrupting = true;
3735
+ void handleSignal(signal);
3736
+ };
3737
+ handlers.set(signal, handler);
3738
+ host.on(signal, handler);
3739
+ }
3740
+ return { remove: removeHandlers, interrupted: () => interrupting };
3741
+ }
3742
+ var REPLAY_INTERRUPT_SIGNALS;
3743
+ var init_replayInterrupt = __esm({
3744
+ "src/replayInterrupt.ts"() {
3745
+ "use strict";
3746
+ REPLAY_INTERRUPT_SIGNALS = [
3747
+ "SIGINT",
3748
+ "SIGTERM"
3749
+ ];
3750
+ }
3751
+ });
3752
+
3621
3753
  // src/selectiveReplay.ts
3622
3754
  function replayNodeKey(node) {
3623
3755
  return JSON.stringify([node.traceFunctionKey, node.spanName]);
@@ -4527,7 +4659,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4527
4659
  const includeDbBranchLease = dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true;
4528
4660
  let session;
4529
4661
  if (options?.resume === void 0) {
4530
- const started2 = await httpClient.startReplay(
4662
+ const started = await httpClient.startReplay(
4531
4663
  traceFunctionKey,
4532
4664
  // limit is meaningless with explicit traceIds (the ID list determines
4533
4665
  // the count), so it's omitted from the request entirely.
@@ -4550,7 +4682,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4550
4682
  options?.judgeAssertions,
4551
4683
  options?.experimentalSelectiveReplay
4552
4684
  );
4553
- if (started2.items.length === 0) {
4685
+ if (started.items.length === 0) {
4554
4686
  try {
4555
4687
  console.warn(
4556
4688
  `Bitfab: no traces matched "${traceFunctionKey}", so this replay ran nothing. Capture a trace, or seed one with seedTrace, before replaying.`
@@ -4559,10 +4691,10 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4559
4691
  }
4560
4692
  }
4561
4693
  session = {
4562
- experimentId: started2.experimentId,
4563
- experimentUrl: started2.experimentUrl,
4694
+ experimentId: started.experimentId,
4695
+ experimentUrl: started.experimentUrl,
4564
4696
  attempts: requestedAttempts,
4565
- work: expandReplayWork(started2.items, requestedAttempts),
4697
+ work: expandReplayWork(started.items, requestedAttempts),
4566
4698
  finished: [],
4567
4699
  includeDbBranchLease,
4568
4700
  dbBranchSettings: resolveDbBranchSettings(options?.dbBranch)
@@ -4577,9 +4709,68 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4577
4709
  options.dbBranch
4578
4710
  );
4579
4711
  }
4580
- const { experimentId, experimentUrl, attempts } = session;
4712
+ const { experimentId } = session;
4713
+ const fullExperimentUrl = `${serviceUrl}${session.experimentUrl}`;
4714
+ const heartbeat = startReplayHeartbeat(
4715
+ () => httpClient.heartbeatReplay(experimentId)
4716
+ );
4717
+ const interruptReplay = async () => {
4718
+ await heartbeat.stop();
4719
+ return httpClient.interruptReplay(experimentId);
4720
+ };
4721
+ const interruptHandlers = installReplayInterruptHandlers({
4722
+ experimentId,
4723
+ experimentUrl: fullExperimentUrl,
4724
+ interrupt: interruptReplay,
4725
+ onInterrupt: options?.onInterrupt
4726
+ });
4727
+ let completeReturned = false;
4728
+ const markCompleteReturned = () => {
4729
+ completeReturned = true;
4730
+ void heartbeat.stop();
4731
+ };
4732
+ try {
4733
+ return await runReplaySession(
4734
+ httpClient,
4735
+ fn,
4736
+ session,
4737
+ fullExperimentUrl,
4738
+ maxConcurrency,
4739
+ interruptHandlers.remove,
4740
+ markCompleteReturned,
4741
+ interruptHandlers.interrupted,
4742
+ options,
4743
+ registeredOverrides
4744
+ );
4745
+ } catch (error) {
4746
+ if (!completeReturned && !interruptHandlers.interrupted()) {
4747
+ await interruptReplay();
4748
+ }
4749
+ throw error;
4750
+ } finally {
4751
+ interruptHandlers.remove();
4752
+ await heartbeat.stop();
4753
+ }
4754
+ }
4755
+ function throwIfInterrupted(interrupted, items, experimentId, experimentUrl) {
4756
+ if (!interrupted()) {
4757
+ return;
4758
+ }
4759
+ const cause = new BitfabError(
4760
+ `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}.`,
4761
+ experimentUrl
4762
+ );
4763
+ throw new ReplayError(
4764
+ cause.message,
4765
+ items,
4766
+ experimentId,
4767
+ experimentUrl,
4768
+ cause
4769
+ );
4770
+ }
4771
+ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxConcurrency, stopInterruptingOnSignal, markCompleteReturned, interrupted, options, registeredOverrides) {
4772
+ const { experimentId, attempts } = session;
4581
4773
  const mockStrategy = options?.mock ?? "marked";
4582
- const fullExperimentUrl = `${serviceUrl}${experimentUrl}`;
4583
4774
  try {
4584
4775
  options?.onExperimentStart?.({
4585
4776
  experimentId,
@@ -4729,7 +4920,15 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4729
4920
  );
4730
4921
  const resultItems = [...carriedOverItems, ...ranItems];
4731
4922
  if (options?.dryRun === true) {
4923
+ throwIfInterrupted(
4924
+ interrupted,
4925
+ resultItems,
4926
+ experimentId,
4927
+ fullExperimentUrl
4928
+ );
4929
+ stopInterruptingOnSignal();
4732
4930
  await httpClient.completeReplay(experimentId).catch(() => void 0);
4931
+ markCompleteReturned();
4733
4932
  const dryResult = {
4734
4933
  items: resultItems,
4735
4934
  experimentId,
@@ -4754,12 +4953,15 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4754
4953
  ranItems[index].traceId = readBack;
4755
4954
  }
4756
4955
  }
4956
+ throwIfInterrupted(interrupted, resultItems, experimentId, fullExperimentUrl);
4957
+ stopInterruptingOnSignal();
4757
4958
  const completeResult = await preserveReplayFailure(
4758
4959
  () => httpClient.completeReplay(experimentId),
4759
4960
  resultItems,
4760
4961
  experimentId,
4761
4962
  fullExperimentUrl
4762
4963
  );
4964
+ markCompleteReturned();
4763
4965
  const serverTraceIds = completeResult.traceIds;
4764
4966
  const replayTokens = completeResult.tokens;
4765
4967
  if (serverTraceIds !== void 0) {
@@ -4863,6 +5065,8 @@ var init_replay = __esm({
4863
5065
  init_mockOverride();
4864
5066
  init_randomUuid();
4865
5067
  init_replayContext();
5068
+ init_replayHeartbeat();
5069
+ init_replayInterrupt();
4866
5070
  init_selectiveReplayRuntime();
4867
5071
  init_serialize();
4868
5072
  REPLAY_PERSISTENCE_TIMEOUT_MS = 3e4;
@@ -11646,6 +11850,7 @@ init_replay();
11646
11850
  // src/replayRegistry.ts
11647
11851
  init_errors();
11648
11852
  init_replay();
11853
+ init_replayInterrupt();
11649
11854
  function defineReplayRegistry(registry) {
11650
11855
  return registry;
11651
11856
  }