@bitfab/sdk 0.57.6 → 0.57.7

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
@@ -440,7 +440,8 @@ declare class HttpClient {
440
440
  readonly traceCompletion: TraceCompletion;
441
441
  private closed;
442
442
  private closing;
443
- externalSpanTransform: ((payload: Record<string, unknown>, submit: SimulationPlanSubmit) => void) | undefined;
443
+ externalSpanTransform: ((payload: Record<string, unknown>, submit: SimulationPlanSubmit, drop: () => void) => void) | undefined;
444
+ frameworkSpanStart: ((traceId: string, spanId: string, parentSpanId: string | null) => void) | undefined;
444
445
  externalTraceTransform: ((payload: Record<string, unknown>, submit: SimulationPlanSubmit) => void) | undefined;
445
446
  releaseHeldExternalSpans: ((timeoutMs: number) => Promise<boolean> | Promise<void>) | undefined;
446
447
  stopSimulationPlan: (() => void) | undefined;
@@ -570,6 +571,7 @@ declare class HttpClient {
570
571
  * the OTLP carrier has no path to carry it.
571
572
  */
572
573
  sendInternalTrace(functionId: string, payload: Record<string, unknown>): void;
574
+ reserveFrameworkSpan(traceId: string, spanId: string, parentSpanId: string | null | undefined): void;
573
575
  sendExternalSpan(payload: Record<string, unknown>): void;
574
576
  submitExternalSpan(payload: Record<string, unknown>): void;
575
577
  /**
@@ -2427,6 +2429,7 @@ interface Trace {
2427
2429
  interface Span<_T = any> {
2428
2430
  spanId?: string;
2429
2431
  traceId?: string;
2432
+ parentId?: string | null;
2430
2433
  toJSON(): unknown;
2431
2434
  spanData?: {
2432
2435
  type?: string;
@@ -3622,7 +3625,7 @@ interface CommitRef {
3622
3625
  /**
3623
3626
  * SDK version from package.json (injected at build time)
3624
3627
  */
3625
- declare const __version__ = "0.57.6";
3628
+ declare const __version__ = "0.57.7";
3626
3629
 
3627
3630
  /**
3628
3631
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -440,7 +440,8 @@ declare class HttpClient {
440
440
  readonly traceCompletion: TraceCompletion;
441
441
  private closed;
442
442
  private closing;
443
- externalSpanTransform: ((payload: Record<string, unknown>, submit: SimulationPlanSubmit) => void) | undefined;
443
+ externalSpanTransform: ((payload: Record<string, unknown>, submit: SimulationPlanSubmit, drop: () => void) => void) | undefined;
444
+ frameworkSpanStart: ((traceId: string, spanId: string, parentSpanId: string | null) => void) | undefined;
444
445
  externalTraceTransform: ((payload: Record<string, unknown>, submit: SimulationPlanSubmit) => void) | undefined;
445
446
  releaseHeldExternalSpans: ((timeoutMs: number) => Promise<boolean> | Promise<void>) | undefined;
446
447
  stopSimulationPlan: (() => void) | undefined;
@@ -570,6 +571,7 @@ declare class HttpClient {
570
571
  * the OTLP carrier has no path to carry it.
571
572
  */
572
573
  sendInternalTrace(functionId: string, payload: Record<string, unknown>): void;
574
+ reserveFrameworkSpan(traceId: string, spanId: string, parentSpanId: string | null | undefined): void;
573
575
  sendExternalSpan(payload: Record<string, unknown>): void;
574
576
  submitExternalSpan(payload: Record<string, unknown>): void;
575
577
  /**
@@ -2427,6 +2429,7 @@ interface Trace {
2427
2429
  interface Span<_T = any> {
2428
2430
  spanId?: string;
2429
2431
  traceId?: string;
2432
+ parentId?: string | null;
2430
2433
  toJSON(): unknown;
2431
2434
  spanData?: {
2432
2435
  type?: string;
@@ -3622,7 +3625,7 @@ interface CommitRef {
3622
3625
  /**
3623
3626
  * SDK version from package.json (injected at build time)
3624
3627
  */
3625
- declare const __version__ = "0.57.6";
3628
+ declare const __version__ = "0.57.7";
3626
3629
 
3627
3630
  /**
3628
3631
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  getCurrentTrace,
22
22
  reseedFromRegistry,
23
23
  seedFromRegistry
24
- } from "./chunk-36PIGPJ7.js";
24
+ } from "./chunk-77YNCRPM.js";
25
25
  import "./chunk-RCHSYWKI.js";
26
26
  import {
27
27
  BITFAB_PROGRESS_PREFIX,
@@ -30,7 +30,7 @@ import {
30
30
  ReplayError,
31
31
  reportReplayProgress,
32
32
  serializeReplayResult
33
- } from "./chunk-3ZKAW5PB.js";
33
+ } from "./chunk-VP3BZFIS.js";
34
34
  import {
35
35
  BitfabError,
36
36
  DEFAULT_SERVICE_URL,
@@ -38,7 +38,7 @@ import {
38
38
  MixedTracingError,
39
39
  __version__,
40
40
  flushTraces
41
- } from "./chunk-ATJLJEG4.js";
41
+ } from "./chunk-W3JGWZ4M.js";
42
42
  import "./chunk-VCRFFCLY.js";
43
43
  export {
44
44
  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.57.6";
91
+ __version__ = "0.57.7";
92
92
  __packageName__ = "@bitfab/sdk";
93
93
  }
94
94
  });
@@ -1062,7 +1062,13 @@ var init_simulationPlan = __esm({
1062
1062
  DISABLE_SIMULATION_PLAN_ENV = "BITFAB_DISABLE_SIM_PLAN";
1063
1063
  ROOT_TRACE_FUNCTION_KEY_FIELD = "rootTraceFunctionKey";
1064
1064
  CONTENT_OFF_KEY = "content_off_by_simulation_plan";
1065
- CONTENT_KEYS = ["input", "input_meta", "output", "output_meta"];
1065
+ CONTENT_KEYS = [
1066
+ "input",
1067
+ "input_meta",
1068
+ "output",
1069
+ "output_meta",
1070
+ "prompt"
1071
+ ];
1066
1072
  SimulationPlan = class {
1067
1073
  constructor(source, enabled = true) {
1068
1074
  this.source = source;
@@ -1181,13 +1187,13 @@ var init_simulationPlan = __esm({
1181
1187
  }
1182
1188
  return this.loaded;
1183
1189
  }
1184
- send(payload, traceFunctionKey, submit) {
1190
+ send(payload, traceFunctionKey, submit, drop) {
1185
1191
  this.refresh();
1186
1192
  if (this.disabled() || traceFunctionKey === void 0 || spanNameOf(payload) === void 0 || recordedByFramework(payload)) {
1187
1193
  submit(payload);
1188
1194
  return;
1189
1195
  }
1190
- const entry = { payload, traceFunctionKey, submit };
1196
+ const entry = { payload, traceFunctionKey, submit, drop };
1191
1197
  if (this.holdingForFirstRead()) {
1192
1198
  this.hold(entry);
1193
1199
  return;
@@ -1241,6 +1247,7 @@ var init_simulationPlan = __esm({
1241
1247
  try {
1242
1248
  entry.submit(this.payloadToSend(entry));
1243
1249
  } catch (error) {
1250
+ entry.drop?.();
1244
1251
  warnOnce(
1245
1252
  "sim-plan-held-span-dropped",
1246
1253
  `a span held for the sim plan was dropped when released: ${error instanceof Error ? error.message : String(error)}`
@@ -2571,23 +2578,21 @@ var init_http = __esm({
2571
2578
  }
2572
2579
  const deadline = Date.now() + Math.max(timeoutMs, 0);
2573
2580
  this.closing = (async () => {
2574
- const released = await this.releaseHeldExternalSpans?.(
2575
- planWaitSliceMs(timeoutMs)
2581
+ liveHttpClients.delete(this);
2582
+ const settled2 = await this.settleDeferredWork(
2583
+ Math.max(0, deadline - Date.now())
2576
2584
  );
2577
2585
  this.stopSimulationPlan?.();
2586
+ this.closed = true;
2578
2587
  this.externalSpanTransform = void 0;
2579
2588
  this.externalTraceTransform = void 0;
2589
+ this.frameworkSpanStart = void 0;
2580
2590
  this.releaseHeldExternalSpans = void 0;
2581
2591
  this.stopSimulationPlan = void 0;
2582
- liveHttpClients.delete(this);
2583
- const settled2 = await this.settleDeferredWork(
2584
- Math.max(0, deadline - Date.now())
2585
- );
2586
- this.closed = true;
2587
2592
  const transport = this.traceTransport;
2588
2593
  this.traceTransport = void 0;
2589
2594
  const shutdownOk = await transport?.shutdown(Math.max(0, deadline - Date.now())) ?? true;
2590
- return released !== false && settled2 && shutdownOk;
2595
+ return settled2 && shutdownOk;
2591
2596
  })();
2592
2597
  return this.closing;
2593
2598
  }
@@ -2688,8 +2693,7 @@ var init_http = __esm({
2688
2693
  async getSimulationPlan() {
2689
2694
  return this.get(
2690
2695
  "/api/sdk/sim-plan",
2691
- SIMULATION_PLAN_READ_TIMEOUT_MS,
2692
- { Connection: "close" }
2696
+ SIMULATION_PLAN_READ_TIMEOUT_MS
2693
2697
  );
2694
2698
  }
2695
2699
  async getTraceSpan(traceId, lookup) {
@@ -2765,19 +2769,35 @@ var init_http = __esm({
2765
2769
  carrierMeta("internal_trace", body, void 0)
2766
2770
  );
2767
2771
  }
2772
+ reserveFrameworkSpan(traceId, spanId, parentSpanId) {
2773
+ try {
2774
+ this.frameworkSpanStart?.(traceId, spanId, parentSpanId ?? null);
2775
+ } catch (error) {
2776
+ warnOnce(
2777
+ "framework-span-reservation-failed",
2778
+ `a framework span could not be counted toward its trace's span limit: ${describeError(error)}`
2779
+ );
2780
+ }
2781
+ }
2768
2782
  sendExternalSpan(payload) {
2769
2783
  const ref2 = carrierRef(payload);
2770
2784
  if (ref2?.spanId !== void 0) {
2771
2785
  this.traceCompletion.record(ref2.traceId, ref2.spanId);
2772
2786
  }
2787
+ const drop = () => {
2788
+ if (ref2?.spanId !== void 0) {
2789
+ this.traceCompletion.abort(ref2.traceId, ref2.spanId);
2790
+ }
2791
+ };
2773
2792
  const gate = this.externalSpanTransform;
2774
2793
  if (gate === void 0) {
2775
2794
  this.submitExternalSpan(payload);
2776
2795
  return;
2777
2796
  }
2778
2797
  try {
2779
- gate(payload, (ready) => this.submitExternalSpan(ready));
2798
+ gate(payload, (ready) => this.submitExternalSpan(ready), drop);
2780
2799
  } catch (error) {
2800
+ drop();
2781
2801
  warnDroppedExternalSpan(error);
2782
2802
  }
2783
2803
  }
@@ -4670,6 +4690,11 @@ var BitfabClaudeAgentHandler = class {
4670
4690
  }
4671
4691
  this.runToSpan.set(spanId, spanInfo);
4672
4692
  this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
4693
+ this.httpClient.reserveFrameworkSpan(
4694
+ spanInfo.traceId,
4695
+ spanInfo.spanId,
4696
+ spanInfo.parentId
4697
+ );
4673
4698
  return spanInfo;
4674
4699
  }
4675
4700
  completeSpan(spanId, output, error, extraContexts) {
@@ -4949,6 +4974,11 @@ var BitfabClaudeAgentHandler = class {
4949
4974
  this.conversationHistory.push(...this.pendingMessages);
4950
4975
  this.pendingMessages = [];
4951
4976
  this.currentLlmSpanId = randomUuid();
4977
+ this.httpClient.reserveFrameworkSpan(
4978
+ this.ensureTrace(),
4979
+ this.currentLlmSpanId,
4980
+ this.getParentId()
4981
+ );
4952
4982
  this.currentLlmMessageId = messageId ?? null;
4953
4983
  this.currentLlmContent = [];
4954
4984
  this.currentLlmModel = inner.model ?? null;
@@ -6359,6 +6389,11 @@ var BitfabLangGraphCallbackHandler = class {
6359
6389
  this.runToSpan.set(runId, spanInfo);
6360
6390
  if (spanInfo.hidden !== true) {
6361
6391
  this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
6392
+ this.httpClient.reserveFrameworkSpan(
6393
+ spanInfo.traceId,
6394
+ spanInfo.spanId,
6395
+ spanInfo.parentId
6396
+ );
6362
6397
  }
6363
6398
  if (isRootInvocation) {
6364
6399
  this.sendTraceStart(spanInfo);
@@ -7904,8 +7939,14 @@ var BitfabOpenAITracingProcessor = class {
7904
7939
  async onSpanStart(span) {
7905
7940
  if (span.spanId !== void 0 && span.traceId !== null && span.traceId !== void 0) {
7906
7941
  this.startedSpans.set(span.spanId, span.traceId);
7907
- const traceId = this.activeSpanMappings[span.traceId]?.traceId ?? span.traceId;
7942
+ const mapping = this.activeSpanMappings[span.traceId];
7943
+ const traceId = mapping?.traceId ?? span.traceId;
7908
7944
  this.httpClient.traceCompletion.start(traceId, span.spanId);
7945
+ this.httpClient.reserveFrameworkSpan(
7946
+ traceId,
7947
+ span.spanId,
7948
+ span.parentId ?? mapping?.spanId
7949
+ );
7909
7950
  }
7910
7951
  }
7911
7952
  /**
@@ -8292,22 +8333,68 @@ var BitfabVercelAiHandler = class {
8292
8333
 
8293
8334
  // src/client.ts
8294
8335
  init_warnOnce();
8336
+ var TRUNCATION_LIMIT_ORDER = [
8337
+ "max_depth",
8338
+ "max_spans",
8339
+ "max_captured_subtree_spans"
8340
+ ];
8295
8341
  var activeTraceStates = /* @__PURE__ */ new Map();
8296
- function fitsTraceSpanBudget(payload) {
8297
- if (!recordedByFramework(payload)) {
8298
- return true;
8342
+ var REFUSED_FRAMEWORK_SPAN_TRACES_RETAINED = 1024;
8343
+ var refusedFrameworkSpans = /* @__PURE__ */ new Map();
8344
+ function frameworkSpanRefused(traceId, spanId) {
8345
+ return refusedFrameworkSpans.get(traceId)?.has(spanId) === true;
8346
+ }
8347
+ function refuseFrameworkSpan(traceId, spanId) {
8348
+ const refused = refusedFrameworkSpans.get(traceId);
8349
+ if (refused !== void 0) {
8350
+ refused.add(spanId);
8351
+ return;
8299
8352
  }
8300
- const traceId = traceIdOf(payload);
8301
- const spanBudget = traceId === void 0 ? void 0 : activeTraceStates.get(traceId)?.spanBudget;
8302
- if (spanBudget === void 0) {
8303
- return true;
8353
+ refusedFrameworkSpans.set(traceId, /* @__PURE__ */ new Set([spanId]));
8354
+ while (refusedFrameworkSpans.size > REFUSED_FRAMEWORK_SPAN_TRACES_RETAINED) {
8355
+ const oldest = refusedFrameworkSpans.keys().next();
8356
+ if (oldest.done) {
8357
+ return;
8358
+ }
8359
+ refusedFrameworkSpans.delete(oldest.value);
8304
8360
  }
8305
- if (spanBudget.spansUsed >= spanBudget.maxSpans) {
8306
- spanBudget.truncate();
8361
+ }
8362
+ function reserveFrameworkSpan(traceId, spanId, parentSpanId) {
8363
+ const spanBudget = activeTraceStates.get(traceId)?.spanBudget;
8364
+ const parentRefused = parentSpanId !== null && frameworkSpanRefused(traceId, parentSpanId);
8365
+ if (!parentRefused && (spanBudget === void 0 || spanBudget.spansUsed < spanBudget.maxSpans)) {
8366
+ if (spanBudget !== void 0) {
8367
+ spanBudget.spansUsed += 1;
8368
+ }
8369
+ return;
8370
+ }
8371
+ refuseFrameworkSpan(traceId, spanId);
8372
+ spanBudget?.truncate("max_spans");
8373
+ }
8374
+ function isRefusedFrameworkSpan(payload) {
8375
+ if (!recordedByFramework(payload)) {
8307
8376
  return false;
8308
8377
  }
8309
- spanBudget.spansUsed += 1;
8310
- return true;
8378
+ const rawSpan = payload.rawSpan;
8379
+ const spanId = rawSpan?.id;
8380
+ if (typeof spanId !== "string") {
8381
+ return false;
8382
+ }
8383
+ const traceIds = [payload.sourceTraceId, traceIdOf(payload)];
8384
+ return traceIds.some(
8385
+ (traceId) => typeof traceId === "string" && frameworkSpanRefused(traceId, spanId)
8386
+ );
8387
+ }
8388
+ function truncationMetadata(truncation) {
8389
+ if (truncation === void 0 || truncation.limits.size === 0) {
8390
+ return void 0;
8391
+ }
8392
+ return {
8393
+ "bitfab.truncated_by": TRUNCATION_LIMIT_ORDER.filter(
8394
+ (limit) => truncation.limits.has(limit)
8395
+ ).join(","),
8396
+ "bitfab.dropped_spans": truncation.droppedSpans
8397
+ };
8311
8398
  }
8312
8399
  function rootTraceFunctionKeyOfTrace(traceId, fallback) {
8313
8400
  return activeTraceStates.get(traceId)?.traceFunctionKey ?? fallback;
@@ -8689,7 +8776,6 @@ function readBooleanEnv(name) {
8689
8776
  var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
8690
8777
  var DEFAULT_AUTO_TRACE_MAX_SPANS = 2048;
8691
8778
  var DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS = 512;
8692
- var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
8693
8779
  function spanOwnerName(receiver) {
8694
8780
  if (typeof receiver === "function") {
8695
8781
  return receiver.name !== "" ? receiver.name : void 0;
@@ -8755,7 +8841,8 @@ var Bitfab = class {
8755
8841
  this.httpClient,
8756
8842
  config.simulationPlan ?? true
8757
8843
  );
8758
- this.httpClient.externalSpanTransform = (payload, submit) => this.applySimulationPlan(payload, submit);
8844
+ this.httpClient.externalSpanTransform = (payload, submit, drop) => this.applySimulationPlan(payload, submit, drop);
8845
+ this.httpClient.frameworkSpanStart = reserveFrameworkSpan;
8759
8846
  this.httpClient.externalTraceTransform = (payload, submit) => this.simulationPlan.sendTrace(payload, submit);
8760
8847
  this.httpClient.releaseHeldExternalSpans = (timeoutMs) => this.simulationPlan.release(timeoutMs);
8761
8848
  this.httpClient.stopSimulationPlan = () => this.simulationPlan.stop();
@@ -8951,35 +9038,31 @@ var Bitfab = class {
8951
9038
  function(...args) {
8952
9039
  self.simulationPlan.refresh();
8953
9040
  let capturedSubtreeCount = 0;
8954
- let truncated = false;
8955
- const warnTruncated = () => {
8956
- if (!truncated) {
8957
- truncated = true;
8958
- getCurrentTrace().setMetadata({
8959
- bitfabAutoTrace: {
8960
- protocol: AUTO_TRACE_PROTOCOL,
8961
- truncated: true,
8962
- maxDepth,
8963
- maxSpans,
8964
- maxCapturedSubtreeSpans
8965
- }
8966
- });
8967
- }
9041
+ const rootSpanStack = getSpanStack();
9042
+ const rootSpan = rootSpanStack[rootSpanStack.length - 1];
9043
+ const rootTraceState = rootSpan === void 0 ? void 0 : activeTraceStates.get(rootSpan.traceId);
9044
+ const truncation = rootTraceState?.truncation ?? {
9045
+ limits: /* @__PURE__ */ new Set(),
9046
+ droppedSpans: 0
9047
+ };
9048
+ const truncate = (limit) => {
9049
+ truncation.limits.add(limit);
9050
+ truncation.droppedSpans += 1;
8968
9051
  warnOnce(
8969
9052
  `auto-trace-truncated:${traceFunctionKey}`,
8970
9053
  `"${traceFunctionKey}" hit an automatic subtree capture limit (maxDepth=${maxDepth}, maxCapturedSubtreeSpans=${maxCapturedSubtreeSpans}, maxSpans=${maxSpans}); its trace is incomplete. Raise the limits, declare the calls you need with node(), or narrow the subtree with exclude.`
8971
9054
  );
8972
9055
  };
8973
- const rootSpanStack = getSpanStack();
8974
9056
  const spanBudget = {
8975
9057
  spansUsed: 1,
8976
9058
  maxSpans,
8977
- truncate: () => runWithSpanStack(rootSpanStack, warnTruncated)
9059
+ truncate
8978
9060
  };
8979
- const rootSpan = rootSpanStack[rootSpanStack.length - 1];
8980
- const rootTraceState = rootSpan === void 0 ? void 0 : activeTraceStates.get(rootSpan.traceId);
8981
- if (rootTraceState !== void 0 && rootTraceState.spanBudget === void 0) {
8982
- rootTraceState.spanBudget = spanBudget;
9061
+ if (rootTraceState !== void 0) {
9062
+ rootTraceState.truncation = truncation;
9063
+ if (rootTraceState.spanBudget === void 0) {
9064
+ rootTraceState.spanBudget = spanBudget;
9065
+ }
8983
9066
  }
8984
9067
  const spanStackOf = (entry) => entry.spanStack;
8985
9068
  const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
@@ -9019,15 +9102,16 @@ var Bitfab = class {
9019
9102
  rootTraceFunctionKeyOfEntry(entry),
9020
9103
  spanName
9021
9104
  );
9022
- if (entry.depth < maxDepth && spanBudget.spansUsed < maxSpans && (!countsTowardCapturedSubtree || capturedSubtreeCount < maxCapturedSubtreeSpans)) {
9023
- spanBudget.spansUsed += 1;
9024
- if (countsTowardCapturedSubtree) {
9025
- capturedSubtreeCount += 1;
9026
- }
9027
- return true;
9105
+ const refusedBy = entry.depth >= maxDepth ? "max_depth" : spanBudget.spansUsed >= maxSpans ? "max_spans" : countsTowardCapturedSubtree && capturedSubtreeCount >= maxCapturedSubtreeSpans ? "max_captured_subtree_spans" : void 0;
9106
+ if (refusedBy !== void 0) {
9107
+ truncate(refusedBy);
9108
+ return false;
9028
9109
  }
9029
- runWithSpanStack(spanStackOf(entry), warnTruncated);
9030
- return false;
9110
+ spanBudget.spansUsed += 1;
9111
+ if (countsTowardCapturedSubtree) {
9112
+ capturedSubtreeCount += 1;
9113
+ }
9114
+ return true;
9031
9115
  };
9032
9116
  const autoTraceContext = {
9033
9117
  traceFunctionKey,
@@ -9154,11 +9238,17 @@ var Bitfab = class {
9154
9238
  Object.defineProperty(autoTraceRoot, "_bitfabWrappedFn", { value: fn });
9155
9239
  return autoTraceRoot;
9156
9240
  }
9157
- applySimulationPlan(payload, submit) {
9158
- if (!fitsTraceSpanBudget(payload)) {
9241
+ applySimulationPlan(payload, submit, drop) {
9242
+ if (isRefusedFrameworkSpan(payload)) {
9243
+ drop();
9159
9244
  return;
9160
9245
  }
9161
- this.simulationPlan.send(payload, rootTraceFunctionKeyOf(payload), submit);
9246
+ this.simulationPlan.send(
9247
+ payload,
9248
+ rootTraceFunctionKeyOf(payload),
9249
+ submit,
9250
+ drop
9251
+ );
9162
9252
  }
9163
9253
  /**
9164
9254
  * Flush and permanently close this client's tracing resources: its pending
@@ -9827,6 +9917,9 @@ var Bitfab = class {
9827
9917
  registeredTraceId = traceId;
9828
9918
  }
9829
9919
  self.httpClient.traceCompletion.start(traceId, spanId);
9920
+ if (isFrameworkInstrumentation(options.instrumentation)) {
9921
+ reserveFrameworkSpan(traceId, spanId, parentSpanId);
9922
+ }
9830
9923
  startedSpan = { traceId, spanId };
9831
9924
  const functionName = fn.name !== "" ? fn.name : void 0;
9832
9925
  const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
@@ -9871,6 +9964,10 @@ var Bitfab = class {
9871
9964
  }
9872
9965
  if (isRootSpan) {
9873
9966
  const traceState = activeTraceStates.get(traceId);
9967
+ const truncated = truncationMetadata(traceState?.truncation);
9968
+ if (truncated !== void 0) {
9969
+ recordCallerTraceMetadata(traceId, truncated);
9970
+ }
9874
9971
  self.sendTraceCompletion({
9875
9972
  traceFunctionKey,
9876
9973
  traceId,
@@ -10423,7 +10520,7 @@ var Bitfab = class {
10423
10520
  ...params.captureContent && params.contexts && params.contexts.length > 0 && {
10424
10521
  contexts: params.contexts
10425
10522
  },
10426
- ...params.captureContent && params.prompt !== void 0 && { prompt: params.prompt },
10523
+ ...buildsContent && params.prompt !== void 0 && { prompt: params.prompt },
10427
10524
  ...contentOff && { [CONTENT_OFF_KEY]: true }
10428
10525
  }
10429
10526
  };