@bitfab/sdk 0.52.2 → 0.52.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 (36) hide show
  1. package/dist/{chunk-XXKM4EL2.js → chunk-DP3QEGTV.js} +3 -2
  2. package/dist/chunk-DP3QEGTV.js.map +1 -0
  3. package/dist/{chunk-XLSKI7UA.js → chunk-LQ32JQNZ.js} +61 -11
  4. package/dist/chunk-LQ32JQNZ.js.map +1 -0
  5. package/dist/{chunk-36ARJJ6S.js → chunk-MM4A6UWJ.js} +48 -21
  6. package/dist/chunk-MM4A6UWJ.js.map +1 -0
  7. package/dist/{chunk-QWAWERYM.js → chunk-OF5GWNGU.js} +79 -28
  8. package/dist/chunk-OF5GWNGU.js.map +1 -0
  9. package/dist/chunk-P2AZ7RUM.js +747 -0
  10. package/dist/chunk-P2AZ7RUM.js.map +1 -0
  11. package/dist/{http-CVTQ3N5S.js → http-UA54C2J2.js} +2 -2
  12. package/dist/{http-V2WU4EN3.js → http-WBNDRQIV.js} +2 -2
  13. package/dist/index.cjs +134 -31
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +36 -2
  16. package/dist/index.d.ts +36 -2
  17. package/dist/index.js +5 -3
  18. package/dist/node.cjs +134 -31
  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 +5 -3
  23. package/dist/node.js.map +1 -1
  24. package/dist/{replay-5UAWEGXP.js → replay-RUONYMHD.js} +5 -3
  25. package/dist/replayCli.js +18 -687
  26. package/dist/replayCli.js.map +1 -1
  27. package/dist/seedCli.js +30 -0
  28. package/dist/seedCli.js.map +1 -0
  29. package/package.json +3 -2
  30. package/dist/chunk-36ARJJ6S.js.map +0 -1
  31. package/dist/chunk-QWAWERYM.js.map +0 -1
  32. package/dist/chunk-XLSKI7UA.js.map +0 -1
  33. package/dist/chunk-XXKM4EL2.js.map +0 -1
  34. /package/dist/{http-CVTQ3N5S.js.map → http-UA54C2J2.js.map} +0 -0
  35. /package/dist/{http-V2WU4EN3.js.map → http-WBNDRQIV.js.map} +0 -0
  36. /package/dist/{replay-5UAWEGXP.js.map → replay-RUONYMHD.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -591,6 +591,8 @@ declare class HttpClient {
591
591
  * Blocking call.
592
592
  */
593
593
  completeReplay(testRunId: string): Promise<CompleteReplayResponse>;
594
+ getReseedSource(traceId: string): Promise<ReseedSourceResponse>;
595
+ reseedTrace(traceId: string, runTraceId: string): Promise<ReseedTraceResponse>;
594
596
  /**
595
597
  * Ask the server to materialize a per-trace DB branch lease from a
596
598
  * captured `dbSnapshotRef`. Blocking - the resolver creates a Neon
@@ -749,6 +751,21 @@ interface CompleteReplayResponse {
749
751
  */
750
752
  traceCount?: number;
751
753
  }
754
+ interface ReseedSourceResponse {
755
+ traceId: string;
756
+ traceFunctionKey: string;
757
+ ingestionType: string;
758
+ name: string | null;
759
+ sessionId: string | null;
760
+ metadata: Record<string, unknown>;
761
+ input: unknown;
762
+ inputMeta: unknown;
763
+ inputSerialized: unknown;
764
+ }
765
+ interface ReseedTraceResponse {
766
+ traceId: string;
767
+ previousRunTraceId: string;
768
+ }
752
769
  interface SpanTreeNode {
753
770
  /** Upstream platform span id. Stable structural identity; NOT the row id. */
754
771
  sourceSpanId: string;
@@ -2459,6 +2476,13 @@ interface SeedRunOptions<TArgs extends unknown[]> {
2459
2476
  sessionId?: string;
2460
2477
  name?: string;
2461
2478
  }
2479
+ interface ReseedOptions {
2480
+ traceId: string;
2481
+ }
2482
+ interface ReseedResult {
2483
+ traceId: string;
2484
+ previousRunTraceId: string;
2485
+ }
2462
2486
  interface BitfabConfig {
2463
2487
  /**
2464
2488
  * The API key for Bitfab API authentication. Resolved lazily, the first
@@ -3118,6 +3142,7 @@ declare class Bitfab {
3118
3142
  seedTrace<TArgs extends unknown[], TReturn>(traceFunctionKey: string, fn: (...args: TArgs) => TReturn, options?: SeedRunOptions<TArgs>): Promise<string>;
3119
3143
  private seedTraceFromCase;
3120
3144
  private seedTraceByRunning;
3145
+ reseedTrace(traceFunctionKey: string, fn: (...args: any[]) => unknown, options: ReseedOptions): Promise<ReseedResult>;
3121
3146
  replay<TReturn>(traceFunctionKey: string, fn: (...args: any[]) => TReturn | Promise<TReturn>, options?: ReplayOptions): Promise<ReplayResult<TReturn>>;
3122
3147
  }
3123
3148
  /**
@@ -3293,7 +3318,7 @@ declare class BitfabFunction {
3293
3318
  /**
3294
3319
  * SDK version from package.json (injected at build time)
3295
3320
  */
3296
- declare const __version__ = "0.52.2";
3321
+ declare const __version__ = "0.52.4";
3297
3322
 
3298
3323
  /**
3299
3324
  * Constants for the Bitfab SDK.
@@ -3410,6 +3435,15 @@ interface SeedResult {
3410
3435
  traceFunctionKey: string;
3411
3436
  traceIds: string[];
3412
3437
  }
3438
+ interface ReseedRegistryResult {
3439
+ pipeline: string;
3440
+ traceFunctionKey: string;
3441
+ reseeded: {
3442
+ traceId: string;
3443
+ previousRunTraceId: string;
3444
+ }[];
3445
+ }
3446
+ declare function reseedFromRegistry(registry: ReplayRegistry, pipeline: string, traceIds: readonly string[]): Promise<ReseedRegistryResult>;
3413
3447
  /**
3414
3448
  * Seed cases through an already-registered pipeline.
3415
3449
  *
@@ -3423,4 +3457,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
3423
3457
  run?: boolean;
3424
3458
  }): Promise<SeedResult>;
3425
3459
 
3426
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, 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 ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionsAllParams, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceAssertionsUpdate, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type TraceTarget, type TraceTargetOccurrence, TracesClient, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
3460
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, 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 ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, type ReseedOptions, type ReseedRegistryResult, type ReseedResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionsAllParams, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceAssertionsUpdate, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type 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
@@ -591,6 +591,8 @@ declare class HttpClient {
591
591
  * Blocking call.
592
592
  */
593
593
  completeReplay(testRunId: string): Promise<CompleteReplayResponse>;
594
+ getReseedSource(traceId: string): Promise<ReseedSourceResponse>;
595
+ reseedTrace(traceId: string, runTraceId: string): Promise<ReseedTraceResponse>;
594
596
  /**
595
597
  * Ask the server to materialize a per-trace DB branch lease from a
596
598
  * captured `dbSnapshotRef`. Blocking - the resolver creates a Neon
@@ -749,6 +751,21 @@ interface CompleteReplayResponse {
749
751
  */
750
752
  traceCount?: number;
751
753
  }
754
+ interface ReseedSourceResponse {
755
+ traceId: string;
756
+ traceFunctionKey: string;
757
+ ingestionType: string;
758
+ name: string | null;
759
+ sessionId: string | null;
760
+ metadata: Record<string, unknown>;
761
+ input: unknown;
762
+ inputMeta: unknown;
763
+ inputSerialized: unknown;
764
+ }
765
+ interface ReseedTraceResponse {
766
+ traceId: string;
767
+ previousRunTraceId: string;
768
+ }
752
769
  interface SpanTreeNode {
753
770
  /** Upstream platform span id. Stable structural identity; NOT the row id. */
754
771
  sourceSpanId: string;
@@ -2459,6 +2476,13 @@ interface SeedRunOptions<TArgs extends unknown[]> {
2459
2476
  sessionId?: string;
2460
2477
  name?: string;
2461
2478
  }
2479
+ interface ReseedOptions {
2480
+ traceId: string;
2481
+ }
2482
+ interface ReseedResult {
2483
+ traceId: string;
2484
+ previousRunTraceId: string;
2485
+ }
2462
2486
  interface BitfabConfig {
2463
2487
  /**
2464
2488
  * The API key for Bitfab API authentication. Resolved lazily, the first
@@ -3118,6 +3142,7 @@ declare class Bitfab {
3118
3142
  seedTrace<TArgs extends unknown[], TReturn>(traceFunctionKey: string, fn: (...args: TArgs) => TReturn, options?: SeedRunOptions<TArgs>): Promise<string>;
3119
3143
  private seedTraceFromCase;
3120
3144
  private seedTraceByRunning;
3145
+ reseedTrace(traceFunctionKey: string, fn: (...args: any[]) => unknown, options: ReseedOptions): Promise<ReseedResult>;
3121
3146
  replay<TReturn>(traceFunctionKey: string, fn: (...args: any[]) => TReturn | Promise<TReturn>, options?: ReplayOptions): Promise<ReplayResult<TReturn>>;
3122
3147
  }
3123
3148
  /**
@@ -3293,7 +3318,7 @@ declare class BitfabFunction {
3293
3318
  /**
3294
3319
  * SDK version from package.json (injected at build time)
3295
3320
  */
3296
- declare const __version__ = "0.52.2";
3321
+ declare const __version__ = "0.52.4";
3297
3322
 
3298
3323
  /**
3299
3324
  * Constants for the Bitfab SDK.
@@ -3410,6 +3435,15 @@ interface SeedResult {
3410
3435
  traceFunctionKey: string;
3411
3436
  traceIds: string[];
3412
3437
  }
3438
+ interface ReseedRegistryResult {
3439
+ pipeline: string;
3440
+ traceFunctionKey: string;
3441
+ reseeded: {
3442
+ traceId: string;
3443
+ previousRunTraceId: string;
3444
+ }[];
3445
+ }
3446
+ declare function reseedFromRegistry(registry: ReplayRegistry, pipeline: string, traceIds: readonly string[]): Promise<ReseedRegistryResult>;
3413
3447
  /**
3414
3448
  * Seed cases through an already-registered pipeline.
3415
3449
  *
@@ -3423,4 +3457,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
3423
3457
  run?: boolean;
3424
3458
  }): Promise<SeedResult>;
3425
3459
 
3426
- export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, 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 ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionsAllParams, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceAssertionsUpdate, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type TraceTarget, type TraceTargetOccurrence, TracesClient, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
3460
+ export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, 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 ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, type ReseedOptions, type ReseedRegistryResult, type ReseedResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionsAllParams, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceAssertionsUpdate, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type 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
@@ -17,8 +17,9 @@ import {
17
17
  getCurrentReplayBranch,
18
18
  getCurrentSpan,
19
19
  getCurrentTrace,
20
+ reseedFromRegistry,
20
21
  seedFromRegistry
21
- } from "./chunk-XLSKI7UA.js";
22
+ } from "./chunk-LQ32JQNZ.js";
22
23
  import "./chunk-ZUD7OFYB.js";
23
24
  import {
24
25
  BITFAB_PROGRESS_PREFIX,
@@ -27,7 +28,7 @@ import {
27
28
  ReplayError,
28
29
  reportReplayProgress,
29
30
  serializeReplayResult
30
- } from "./chunk-XXKM4EL2.js";
31
+ } from "./chunk-DP3QEGTV.js";
31
32
  import {
32
33
  BitfabError,
33
34
  DEFAULT_SERVICE_URL,
@@ -35,7 +36,7 @@ import {
35
36
  MixedTracingError,
36
37
  __version__,
37
38
  flushTraces
38
- } from "./chunk-QWAWERYM.js";
39
+ } from "./chunk-OF5GWNGU.js";
39
40
  import "./chunk-H6LZRFMN.js";
40
41
  export {
41
42
  BITFAB_PROGRESS_PREFIX,
@@ -68,6 +69,7 @@ export {
68
69
  getCurrentSpan,
69
70
  getCurrentTrace,
70
71
  reportReplayProgress,
72
+ reseedFromRegistry,
71
73
  seedFromRegistry,
72
74
  serializeReplayResult
73
75
  };
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.52.2";
91
+ __version__ = "0.52.4";
92
92
  __packageName__ = "@bitfab/sdk";
93
93
  }
94
94
  });
@@ -392,15 +392,18 @@ var init_payloadBudget = __esm({
392
392
  });
393
393
 
394
394
  // src/warnOnce.ts
395
+ function warn(message) {
396
+ try {
397
+ console.warn(`[bitfab] ${message}`);
398
+ } catch {
399
+ }
400
+ }
395
401
  function warnOnce(key, message) {
396
402
  if (warned.has(key)) {
397
403
  return;
398
404
  }
399
405
  warned.add(key);
400
- try {
401
- console.warn(`[bitfab] ${message}`);
402
- } catch {
403
- }
406
+ warn(message);
404
407
  }
405
408
  var warned;
406
409
  var init_warnOnce = __esm({
@@ -542,6 +545,9 @@ var init_serializePayload = __esm({
542
545
  });
543
546
 
544
547
  // src/traceMetadata.ts
548
+ function findRecord(traceId) {
549
+ return activeRecords.get(traceId) ?? completedRecords.get(traceId);
550
+ }
545
551
  function recordCallerTraceMetadata(traceId, metadata) {
546
552
  if (typeof traceId !== "string" || traceId === "") {
547
553
  return;
@@ -552,15 +558,52 @@ function recordCallerTraceMetadata(traceId, metadata) {
552
558
  if (Object.keys(metadata).length === 0) {
553
559
  return;
554
560
  }
555
- callerMetadata.set(traceId, { ...callerMetadata.get(traceId), ...metadata });
561
+ const existing = findRecord(traceId);
562
+ if (existing) {
563
+ Object.assign(existing.caller, metadata);
564
+ return;
565
+ }
566
+ activeRecords.set(traceId, {
567
+ caller: { ...metadata },
568
+ derived: {},
569
+ warnedKeys: /* @__PURE__ */ new Set()
570
+ });
556
571
  }
557
572
  function callerTraceMetadata(traceId) {
558
- const recorded = callerMetadata.get(traceId);
559
- return recorded ? { ...recorded } : void 0;
573
+ const record = findRecord(traceId);
574
+ if (!record || Object.keys(record.caller).length === 0) {
575
+ return void 0;
576
+ }
577
+ return { ...record.caller };
560
578
  }
561
- function forgetTraceMetadata(traceId) {
562
- callerMetadata.delete(traceId);
563
- derivedMetadata.delete(traceId);
579
+ function retireTraceMetadata(traceId) {
580
+ const record = activeRecords.get(traceId);
581
+ if (!record) {
582
+ return;
583
+ }
584
+ activeRecords.delete(traceId);
585
+ completedRecords.set(traceId, record);
586
+ while (completedRecords.size > RETAINED_COMPLETED_TRACES) {
587
+ const oldest = completedRecords.keys().next();
588
+ if (oldest.done) {
589
+ return;
590
+ }
591
+ completedRecords.delete(oldest.value);
592
+ }
593
+ }
594
+ function warnAboutShadowedKeys(traceId, record) {
595
+ const shadowed = Object.keys(record.derived).filter(
596
+ (key) => key in record.caller && record.caller[key] !== record.derived[key] && !record.warnedKeys.has(key)
597
+ ).sort();
598
+ if (shadowed.length === 0) {
599
+ return;
600
+ }
601
+ for (const key of shadowed) {
602
+ record.warnedKeys.add(key);
603
+ }
604
+ warn(
605
+ `trace metadata key(s) ${shadowed.join(", ")} on trace ${traceId} were set both by the caller and by an integration's own trace export; the caller's value is the one kept on the trace.`
606
+ );
564
607
  }
565
608
  function mergeCallerMetadataIntoTracePayload(payload) {
566
609
  const externalTrace = payload.externalTrace;
@@ -572,35 +615,31 @@ function mergeCallerMetadataIntoTracePayload(payload) {
572
615
  if (typeof traceId !== "string" || traceId === "") {
573
616
  return payload;
574
617
  }
575
- const caller = callerMetadata.get(traceId);
576
- if (!caller) {
618
+ const record = findRecord(traceId);
619
+ if (!record || Object.keys(record.caller).length === 0) {
577
620
  return payload;
578
621
  }
579
- const derived = derivedMetadata.get(traceId) ?? {};
580
622
  const exported = external.metadata;
581
623
  if (typeof exported === "object" && exported !== null) {
582
- Object.assign(derived, exported);
583
- }
584
- derivedMetadata.set(traceId, derived);
585
- const shadowed = Object.keys(derived).filter((key) => key in caller && caller[key] !== derived[key]).sort();
586
- if (shadowed.length > 0) {
587
- warnOnce(
588
- `trace-metadata-shadowed:${shadowed.join(",")}`,
589
- `trace metadata key(s) ${shadowed.join(", ")} were set both by the caller and by an integration's own trace export; the caller's value is the one kept on the trace.`
590
- );
624
+ Object.assign(record.derived, exported);
591
625
  }
626
+ warnAboutShadowedKeys(traceId, record);
592
627
  return {
593
628
  ...payload,
594
- externalTrace: { ...external, metadata: { ...derived, ...caller } }
629
+ externalTrace: {
630
+ ...external,
631
+ metadata: { ...record.derived, ...record.caller }
632
+ }
595
633
  };
596
634
  }
597
- var callerMetadata, derivedMetadata;
635
+ var RETAINED_COMPLETED_TRACES, activeRecords, completedRecords;
598
636
  var init_traceMetadata = __esm({
599
637
  "src/traceMetadata.ts"() {
600
638
  "use strict";
601
639
  init_warnOnce();
602
- callerMetadata = /* @__PURE__ */ new Map();
603
- derivedMetadata = /* @__PURE__ */ new Map();
640
+ RETAINED_COMPLETED_TRACES = 128;
641
+ activeRecords = /* @__PURE__ */ new Map();
642
+ completedRecords = /* @__PURE__ */ new Map();
604
643
  }
605
644
  });
606
645
 
@@ -2083,6 +2122,18 @@ var init_http = __esm({
2083
2122
  { timeout: REPLAY_COMPLETE_REQUEST_TIMEOUT_MS }
2084
2123
  );
2085
2124
  }
2125
+ async getReseedSource(traceId) {
2126
+ return this.get(
2127
+ `/api/sdk/traces/${encodeURIComponent(traceId)}/reseedSource`
2128
+ );
2129
+ }
2130
+ async reseedTrace(traceId, runTraceId) {
2131
+ return this.request(
2132
+ `/api/sdk/traces/${encodeURIComponent(traceId)}/reseed`,
2133
+ { runTraceId },
2134
+ { timeout: 3e4 }
2135
+ );
2136
+ }
2086
2137
  /**
2087
2138
  * Ask the server to materialize a per-trace DB branch lease from a
2088
2139
  * captured `dbSnapshotRef`. Blocking - the resolver creates a Neon
@@ -2527,6 +2578,7 @@ __export(replay_exports, {
2527
2578
  BITFAB_PROGRESS_PREFIX: () => BITFAB_PROGRESS_PREFIX,
2528
2579
  DbBranchReplayError: () => DbBranchReplayError,
2529
2580
  ReplayError: () => ReplayError,
2581
+ deserializeInputs: () => deserializeInputs,
2530
2582
  replay: () => replay,
2531
2583
  reportReplayProgress: () => reportReplayProgress,
2532
2584
  serializeReplayResult: () => serializeReplayResult,
@@ -3377,6 +3429,7 @@ __export(node_exports, {
3377
3429
  getCurrentSpan: () => getCurrentSpan,
3378
3430
  getCurrentTrace: () => getCurrentTrace,
3379
3431
  reportReplayProgress: () => reportReplayProgress,
3432
+ reseedFromRegistry: () => reseedFromRegistry,
3380
3433
  seedFromRegistry: () => seedFromRegistry,
3381
3434
  serializeReplayResult: () => serializeReplayResult
3382
3435
  });
@@ -5693,6 +5746,7 @@ var BitfabOpenAIAgentHandler = class {
5693
5746
 
5694
5747
  // src/client.ts
5695
5748
  init_randomUuid();
5749
+ init_replay();
5696
5750
 
5697
5751
  // src/replayBranch.ts
5698
5752
  var _url, _context;
@@ -7472,7 +7526,7 @@ var Bitfab = class {
7472
7526
  }
7473
7527
  });
7474
7528
  activeTraceStates.delete(traceId);
7475
- forgetTraceMetadata(traceId);
7529
+ retireTraceMetadata(traceId);
7476
7530
  }
7477
7531
  } catch {
7478
7532
  }
@@ -7665,7 +7719,7 @@ var Bitfab = class {
7665
7719
  } catch (setupError) {
7666
7720
  if (registeredTraceId) {
7667
7721
  activeTraceStates.delete(registeredTraceId);
7668
- forgetTraceMetadata(registeredTraceId);
7722
+ retireTraceMetadata(registeredTraceId);
7669
7723
  }
7670
7724
  if (setupError instanceof MixedTracingError) {
7671
7725
  throw setupError;
@@ -8064,7 +8118,7 @@ var Bitfab = class {
8064
8118
  });
8065
8119
  } finally {
8066
8120
  activeTraceStates.delete(traceId);
8067
- forgetTraceMetadata(traceId);
8121
+ retireTraceMetadata(traceId);
8068
8122
  }
8069
8123
  return traceId;
8070
8124
  }
@@ -8110,7 +8164,7 @@ var Bitfab = class {
8110
8164
  await flushTraces2(3e4);
8111
8165
  } finally {
8112
8166
  unrecorded = activeTraceStates.delete(traceId);
8113
- forgetTraceMetadata(traceId);
8167
+ retireTraceMetadata(traceId);
8114
8168
  }
8115
8169
  }
8116
8170
  if (unrecorded) {
@@ -8120,6 +8174,36 @@ var Bitfab = class {
8120
8174
  }
8121
8175
  return traceId;
8122
8176
  }
8177
+ async reseedTrace(traceFunctionKey, fn, options) {
8178
+ const source = await this.httpClient.getReseedSource(options.traceId);
8179
+ if (source.traceFunctionKey !== traceFunctionKey) {
8180
+ throw new BitfabError(
8181
+ `Trace ${options.traceId} belongs to '${source.traceFunctionKey}', not '${traceFunctionKey}'.`
8182
+ );
8183
+ }
8184
+ const args = deserializeInputs({
8185
+ input: source.input,
8186
+ input_meta: source.inputMeta
8187
+ });
8188
+ const runTraceId = await this.seedTraceByRunning(
8189
+ traceFunctionKey,
8190
+ fn,
8191
+ {
8192
+ args,
8193
+ metadata: source.metadata,
8194
+ ...source.sessionId === null ? {} : { sessionId: source.sessionId },
8195
+ ...source.name === null ? {} : { name: source.name }
8196
+ }
8197
+ );
8198
+ const adopted = await this.httpClient.reseedTrace(
8199
+ options.traceId,
8200
+ runTraceId
8201
+ );
8202
+ return {
8203
+ traceId: adopted.traceId,
8204
+ previousRunTraceId: adopted.previousRunTraceId
8205
+ };
8206
+ }
8123
8207
  async replay(traceFunctionKey, fn, options) {
8124
8208
  const wrappedKey = fn._bitfabTraceFunctionKey;
8125
8209
  let replayFn = fn;
@@ -8381,6 +8465,24 @@ init_replay();
8381
8465
  function defineReplayRegistry(registry) {
8382
8466
  return registry;
8383
8467
  }
8468
+ async function reseedFromRegistry(registry, pipeline, traceIds) {
8469
+ const registration = registry[pipeline];
8470
+ if (registration === void 0) {
8471
+ throw new BitfabError(
8472
+ `Unknown pipeline '${pipeline}'. Registered: ${Object.keys(registry).join(", ")}`
8473
+ );
8474
+ }
8475
+ const traceFunctionKey = resolveTraceFunctionKey(registration);
8476
+ const reseeded = [];
8477
+ for (const traceId of traceIds) {
8478
+ reseeded.push(
8479
+ await registration.client.reseedTrace(traceFunctionKey, registration.fn, {
8480
+ traceId
8481
+ })
8482
+ );
8483
+ }
8484
+ return { pipeline, traceFunctionKey, reseeded };
8485
+ }
8384
8486
  async function seedFromRegistry(registry, pipeline, cases, options = {}) {
8385
8487
  const registration = registry[pipeline];
8386
8488
  if (registration === void 0) {
@@ -8461,6 +8563,7 @@ assertAsyncStorageRegistered();
8461
8563
  getCurrentSpan,
8462
8564
  getCurrentTrace,
8463
8565
  reportReplayProgress,
8566
+ reseedFromRegistry,
8464
8567
  seedFromRegistry,
8465
8568
  serializeReplayResult
8466
8569
  });