bitfab 0.51.0 → 0.52.1

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.
package/dist/index.d.cts CHANGED
@@ -536,7 +536,7 @@ declare class HttpClient {
536
536
  * {@link HttpClient.sendExternalSpan}; replay confirms persistence with the
537
537
  * server-authoritative barrier in `replay.ts`, not by awaiting this call.
538
538
  */
539
- sendExternalTrace(payload: Record<string, unknown>): void;
539
+ sendExternalTrace(rawPayload: Record<string, unknown>): void;
540
540
  /**
541
541
  * Partial update of an existing trace identified by its Bitfab trace ID.
542
542
  * Used by the detached `client.getTrace(id)` handle.
@@ -802,11 +802,19 @@ type TraceAssertionsResult = {
802
802
  assertions: TraceAssertion[];
803
803
  inheritedFrom: string | null;
804
804
  };
805
+ type TraceAssertionsUpdate = {
806
+ traceId: string;
807
+ assertions: SaveAssertion[];
808
+ };
805
809
  type SaveAssertionsParams = {
806
810
  traceId: string;
807
811
  assertions: SaveAssertion[];
808
812
  source?: TraceAssertionSource;
809
813
  };
814
+ type SaveAssertionsAllParams = {
815
+ updates: TraceAssertionsUpdate[];
816
+ source?: TraceAssertionSource;
817
+ };
810
818
  type ArchiveAssertionsParams = {
811
819
  traceId: string;
812
820
  assertionIds: string[];
@@ -816,6 +824,7 @@ declare class TracesClient {
816
824
  constructor(httpClient: HttpClient);
817
825
  getAssertions(traceId: string): Promise<TraceAssertionsResult>;
818
826
  saveAssertions(params: SaveAssertionsParams): Promise<TraceAssertion[]>;
827
+ saveAssertionsAll(params: SaveAssertionsAllParams): Promise<TraceAssertion[]>;
819
828
  archiveAssertions(params: ArchiveAssertionsParams): Promise<string[]>;
820
829
  }
821
830
 
@@ -3279,7 +3288,7 @@ declare class BitfabFunction {
3279
3288
  /**
3280
3289
  * SDK version from package.json (injected at build time)
3281
3290
  */
3282
- declare const __version__ = "0.51.0";
3291
+ declare const __version__ = "0.52.1";
3283
3292
 
3284
3293
  /**
3285
3294
  * Constants for the Bitfab SDK.
@@ -3409,4 +3418,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
3409
3418
  run?: boolean;
3410
3419
  }): Promise<SeedResult>;
3411
3420
 
3412
- 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 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 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 };
3421
+ 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 };
package/dist/index.d.ts CHANGED
@@ -536,7 +536,7 @@ declare class HttpClient {
536
536
  * {@link HttpClient.sendExternalSpan}; replay confirms persistence with the
537
537
  * server-authoritative barrier in `replay.ts`, not by awaiting this call.
538
538
  */
539
- sendExternalTrace(payload: Record<string, unknown>): void;
539
+ sendExternalTrace(rawPayload: Record<string, unknown>): void;
540
540
  /**
541
541
  * Partial update of an existing trace identified by its Bitfab trace ID.
542
542
  * Used by the detached `client.getTrace(id)` handle.
@@ -802,11 +802,19 @@ type TraceAssertionsResult = {
802
802
  assertions: TraceAssertion[];
803
803
  inheritedFrom: string | null;
804
804
  };
805
+ type TraceAssertionsUpdate = {
806
+ traceId: string;
807
+ assertions: SaveAssertion[];
808
+ };
805
809
  type SaveAssertionsParams = {
806
810
  traceId: string;
807
811
  assertions: SaveAssertion[];
808
812
  source?: TraceAssertionSource;
809
813
  };
814
+ type SaveAssertionsAllParams = {
815
+ updates: TraceAssertionsUpdate[];
816
+ source?: TraceAssertionSource;
817
+ };
810
818
  type ArchiveAssertionsParams = {
811
819
  traceId: string;
812
820
  assertionIds: string[];
@@ -816,6 +824,7 @@ declare class TracesClient {
816
824
  constructor(httpClient: HttpClient);
817
825
  getAssertions(traceId: string): Promise<TraceAssertionsResult>;
818
826
  saveAssertions(params: SaveAssertionsParams): Promise<TraceAssertion[]>;
827
+ saveAssertionsAll(params: SaveAssertionsAllParams): Promise<TraceAssertion[]>;
819
828
  archiveAssertions(params: ArchiveAssertionsParams): Promise<string[]>;
820
829
  }
821
830
 
@@ -3279,7 +3288,7 @@ declare class BitfabFunction {
3279
3288
  /**
3280
3289
  * SDK version from package.json (injected at build time)
3281
3290
  */
3282
- declare const __version__ = "0.51.0";
3291
+ declare const __version__ = "0.52.1";
3283
3292
 
3284
3293
  /**
3285
3294
  * Constants for the Bitfab SDK.
@@ -3409,4 +3418,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
3409
3418
  run?: boolean;
3410
3419
  }): Promise<SeedResult>;
3411
3420
 
3412
- 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 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 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 };
3421
+ 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 };
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  getCurrentSpan,
28
28
  getCurrentTrace,
29
29
  seedFromRegistry
30
- } from "./chunk-2RAX75MI.js";
30
+ } from "./chunk-XEARN7AS.js";
31
31
  import "./chunk-ZUD7OFYB.js";
32
32
  import {
33
33
  BITFAB_PROGRESS_PREFIX,
@@ -36,7 +36,7 @@ import {
36
36
  ReplayError,
37
37
  reportReplayProgress,
38
38
  serializeReplayResult
39
- } from "./chunk-TCOMLVHK.js";
39
+ } from "./chunk-6SYDHA4R.js";
40
40
  import {
41
41
  BitfabError,
42
42
  DEFAULT_SERVICE_URL,
@@ -44,7 +44,7 @@ import {
44
44
  MixedTracingError,
45
45
  __version__,
46
46
  flushTraces
47
- } from "./chunk-4Z5FCOMO.js";
47
+ } from "./chunk-SPJPNJEW.js";
48
48
  import "./chunk-H6LZRFMN.js";
49
49
  export {
50
50
  BITFAB_PROGRESS_PREFIX,
package/dist/node.cjs CHANGED
@@ -97,7 +97,7 @@ var __version__, __packageName__;
97
97
  var init_version_generated = __esm({
98
98
  "src/version.generated.ts"() {
99
99
  "use strict";
100
- __version__ = "0.51.0";
100
+ __version__ = "0.52.1";
101
101
  __packageName__ = "bitfab";
102
102
  }
103
103
  });
@@ -550,6 +550,69 @@ var init_serializePayload = __esm({
550
550
  }
551
551
  });
552
552
 
553
+ // src/traceMetadata.ts
554
+ function recordCallerTraceMetadata(traceId, metadata) {
555
+ if (typeof traceId !== "string" || traceId === "") {
556
+ return;
557
+ }
558
+ if (typeof metadata !== "object" || metadata === null) {
559
+ return;
560
+ }
561
+ if (Object.keys(metadata).length === 0) {
562
+ return;
563
+ }
564
+ callerMetadata.set(traceId, { ...callerMetadata.get(traceId), ...metadata });
565
+ }
566
+ function callerTraceMetadata(traceId) {
567
+ const recorded = callerMetadata.get(traceId);
568
+ return recorded ? { ...recorded } : void 0;
569
+ }
570
+ function forgetTraceMetadata(traceId) {
571
+ callerMetadata.delete(traceId);
572
+ derivedMetadata.delete(traceId);
573
+ }
574
+ function mergeCallerMetadataIntoTracePayload(payload) {
575
+ const externalTrace = payload.externalTrace;
576
+ if (typeof externalTrace !== "object" || externalTrace === null) {
577
+ return payload;
578
+ }
579
+ const external = externalTrace;
580
+ const traceId = typeof payload.id === "string" && payload.id !== "" ? payload.id : external.id;
581
+ if (typeof traceId !== "string" || traceId === "") {
582
+ return payload;
583
+ }
584
+ const caller = callerMetadata.get(traceId);
585
+ if (!caller) {
586
+ return payload;
587
+ }
588
+ const derived = derivedMetadata.get(traceId) ?? {};
589
+ const exported = external.metadata;
590
+ if (typeof exported === "object" && exported !== null) {
591
+ Object.assign(derived, exported);
592
+ }
593
+ derivedMetadata.set(traceId, derived);
594
+ const shadowed = Object.keys(derived).filter((key) => key in caller && caller[key] !== derived[key]).sort();
595
+ if (shadowed.length > 0) {
596
+ warnOnce(
597
+ `trace-metadata-shadowed:${shadowed.join(",")}`,
598
+ `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.`
599
+ );
600
+ }
601
+ return {
602
+ ...payload,
603
+ externalTrace: { ...external, metadata: { ...derived, ...caller } }
604
+ };
605
+ }
606
+ var callerMetadata, derivedMetadata;
607
+ var init_traceMetadata = __esm({
608
+ "src/traceMetadata.ts"() {
609
+ "use strict";
610
+ init_warnOnce();
611
+ callerMetadata = /* @__PURE__ */ new Map();
612
+ derivedMetadata = /* @__PURE__ */ new Map();
613
+ }
614
+ });
615
+
553
616
  // src/transportTypes.ts
554
617
  var DeliveryError;
555
618
  var init_transportTypes = __esm({
@@ -1368,6 +1431,7 @@ var init_http = __esm({
1368
1431
  init_errors();
1369
1432
  init_replayContext();
1370
1433
  init_serializePayload();
1434
+ init_traceMetadata();
1371
1435
  init_transport();
1372
1436
  init_transportTypes();
1373
1437
  init_unrefTimer();
@@ -1831,7 +1895,8 @@ var init_http = __esm({
1831
1895
  * {@link HttpClient.sendExternalSpan}; replay confirms persistence with the
1832
1896
  * server-authoritative barrier in `replay.ts`, not by awaiting this call.
1833
1897
  */
1834
- sendExternalTrace(payload) {
1898
+ sendExternalTrace(rawPayload) {
1899
+ const payload = mergeCallerMetadataIntoTracePayload(rawPayload);
1835
1900
  this.getTraceTransport()?.submit(
1836
1901
  "external_trace",
1837
1902
  {
@@ -3339,7 +3404,8 @@ registerAsyncLocalStorageClass(
3339
3404
  );
3340
3405
 
3341
3406
  // src/assertions.ts
3342
- function expectationsPath(traceId, suffix = "") {
3407
+ var ASSERTIONS_PATH = "/api/sdk/traces/assertions";
3408
+ function traceAssertionsPath(traceId, suffix = "") {
3343
3409
  return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
3344
3410
  }
3345
3411
  var TracesClient = class {
@@ -3347,18 +3413,29 @@ var TracesClient = class {
3347
3413
  this.httpClient = httpClient;
3348
3414
  }
3349
3415
  async getAssertions(traceId) {
3350
- return this.httpClient.get(expectationsPath(traceId));
3416
+ return this.httpClient.get(
3417
+ traceAssertionsPath(traceId)
3418
+ );
3351
3419
  }
3352
3420
  async saveAssertions(params) {
3353
- const response = await this.httpClient.request(expectationsPath(params.traceId), {
3354
- assertions: params.assertions,
3421
+ return this.saveAssertionsAll({
3422
+ updates: [{ traceId: params.traceId, assertions: params.assertions }],
3423
+ source: params.source
3424
+ });
3425
+ }
3426
+ async saveAssertionsAll(params) {
3427
+ if (params.updates.length === 0) {
3428
+ return [];
3429
+ }
3430
+ const response = await this.httpClient.request(ASSERTIONS_PATH, {
3431
+ updates: params.updates,
3355
3432
  source: params.source ?? "agent"
3356
3433
  });
3357
3434
  return response.assertions;
3358
3435
  }
3359
3436
  async archiveAssertions(params) {
3360
3437
  const response = await this.httpClient.request(
3361
- expectationsPath(params.traceId, "/archive"),
3438
+ traceAssertionsPath(params.traceId, "/archive"),
3362
3439
  { assertionIds: params.assertionIds }
3363
3440
  );
3364
3441
  return response.archived;
@@ -5711,6 +5788,7 @@ function runWithSeedContext(ctx, fn) {
5711
5788
 
5712
5789
  // src/client.ts
5713
5790
  init_serialize();
5791
+ init_traceMetadata();
5714
5792
 
5715
5793
  // src/tracing.ts
5716
5794
  init_constants();
@@ -6391,8 +6469,7 @@ function getCurrentTrace() {
6391
6469
  if (typeof metadata !== "object" || metadata === null) {
6392
6470
  return;
6393
6471
  }
6394
- const traceState = getOrCreateTraceState();
6395
- traceState.metadata = { ...traceState.metadata, ...metadata };
6472
+ recordCallerTraceMetadata(traceId, metadata);
6396
6473
  } catch {
6397
6474
  }
6398
6475
  },
@@ -7385,7 +7462,7 @@ var Bitfab = class {
7385
7462
  endedAt,
7386
7463
  sessionId: traceState?.sessionId,
7387
7464
  name: traceState?.name,
7388
- metadata: traceState?.metadata,
7465
+ metadata: callerTraceMetadata(traceId),
7389
7466
  contexts: traceState?.contexts ?? [],
7390
7467
  testRunId: traceState?.testRunId,
7391
7468
  inputSourceTraceId: traceState?.inputSourceTraceId,
@@ -7409,6 +7486,7 @@ var Bitfab = class {
7409
7486
  }
7410
7487
  });
7411
7488
  activeTraceStates.delete(traceId);
7489
+ forgetTraceMetadata(traceId);
7412
7490
  }
7413
7491
  } catch {
7414
7492
  }
@@ -7601,6 +7679,7 @@ var Bitfab = class {
7601
7679
  } catch (setupError) {
7602
7680
  if (registeredTraceId) {
7603
7681
  activeTraceStates.delete(registeredTraceId);
7682
+ forgetTraceMetadata(registeredTraceId);
7604
7683
  }
7605
7684
  if (setupError instanceof MixedTracingError) {
7606
7685
  throw setupError;
@@ -7961,14 +8040,16 @@ var Bitfab = class {
7961
8040
  }
7962
8041
  const traceId = randomUuid();
7963
8042
  const startedAt = nowIsoTimestamp();
8043
+ if (options.metadata !== void 0) {
8044
+ recordCallerTraceMetadata(traceId, options.metadata);
8045
+ }
7964
8046
  activeTraceStates.set(traceId, {
7965
8047
  traceId,
7966
8048
  startedAt,
7967
8049
  contexts: [],
7968
8050
  ingestionType: "seeded",
7969
8051
  ...options.sessionId !== void 0 && { sessionId: options.sessionId },
7970
- ...options.name !== void 0 && { name: options.name },
7971
- ...options.metadata !== void 0 && { metadata: options.metadata }
8052
+ ...options.name !== void 0 && { name: options.name }
7972
8053
  });
7973
8054
  try {
7974
8055
  this.sendWrapperSpan({
@@ -7991,12 +8072,13 @@ var Bitfab = class {
7991
8072
  endedAt: startedAt,
7992
8073
  sessionId: options.sessionId,
7993
8074
  name: options.name,
7994
- metadata: options.metadata,
8075
+ metadata: callerTraceMetadata(traceId),
7995
8076
  contexts: [],
7996
8077
  ingestionType: "seeded"
7997
8078
  });
7998
8079
  } finally {
7999
8080
  activeTraceStates.delete(traceId);
8081
+ forgetTraceMetadata(traceId);
8000
8082
  }
8001
8083
  return traceId;
8002
8084
  }
@@ -8021,14 +8103,16 @@ var Bitfab = class {
8021
8103
  }
8022
8104
  await seedContextReady;
8023
8105
  const traceId = randomUuid();
8106
+ if (options?.metadata !== void 0) {
8107
+ recordCallerTraceMetadata(traceId, options.metadata);
8108
+ }
8024
8109
  activeTraceStates.set(traceId, {
8025
8110
  traceId,
8026
8111
  startedAt: nowIsoTimestamp(),
8027
8112
  contexts: [],
8028
8113
  ingestionType: "seeded",
8029
8114
  ...options?.sessionId !== void 0 && { sessionId: options.sessionId },
8030
- ...options?.name !== void 0 && { name: options.name },
8031
- ...options?.metadata !== void 0 && { metadata: options.metadata }
8115
+ ...options?.name !== void 0 && { name: options.name }
8032
8116
  });
8033
8117
  const args = options?.args ?? [];
8034
8118
  let unrecorded = true;
@@ -8040,6 +8124,7 @@ var Bitfab = class {
8040
8124
  await flushTraces2(3e4);
8041
8125
  } finally {
8042
8126
  unrecorded = activeTraceStates.delete(traceId);
8127
+ forgetTraceMetadata(traceId);
8043
8128
  }
8044
8129
  }
8045
8130
  if (unrecorded) {