@bitfab/sdk 0.38.7 → 0.38.9

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
@@ -1881,13 +1881,14 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
1881
1881
  */
1882
1882
  onTraceEnd(trace: Trace): Promise<void>;
1883
1883
  /**
1884
- * Called when a span is started.
1884
+ * Called when a span is started. Span payloads are authoritative completed
1885
+ * snapshots, so start notifications do not cross the transport boundary.
1885
1886
  */
1886
- onSpanStart(span: Span<any>): Promise<void>;
1887
+ onSpanStart(_span: Span<any>): Promise<void>;
1887
1888
  /**
1888
1889
  * Called when a span is ended.
1889
1890
  *
1890
- * Send all spans to Bitfab for complete trace capture.
1891
+ * Send the finalized span snapshot to Bitfab for complete trace capture.
1891
1892
  */
1892
1893
  onSpanEnd(span: Span<any>): Promise<void>;
1893
1894
  /**
@@ -2884,7 +2885,7 @@ declare class BitfabFunction {
2884
2885
  /**
2885
2886
  * SDK version from package.json (injected at build time)
2886
2887
  */
2887
- declare const __version__ = "0.38.7";
2888
+ declare const __version__ = "0.38.9";
2888
2889
 
2889
2890
  /**
2890
2891
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -1881,13 +1881,14 @@ declare class BitfabOpenAITracingProcessor implements TracingProcessor {
1881
1881
  */
1882
1882
  onTraceEnd(trace: Trace): Promise<void>;
1883
1883
  /**
1884
- * Called when a span is started.
1884
+ * Called when a span is started. Span payloads are authoritative completed
1885
+ * snapshots, so start notifications do not cross the transport boundary.
1885
1886
  */
1886
- onSpanStart(span: Span<any>): Promise<void>;
1887
+ onSpanStart(_span: Span<any>): Promise<void>;
1887
1888
  /**
1888
1889
  * Called when a span is ended.
1889
1890
  *
1890
- * Send all spans to Bitfab for complete trace capture.
1891
+ * Send the finalized span snapshot to Bitfab for complete trace capture.
1891
1892
  */
1892
1893
  onSpanEnd(span: Span<any>): Promise<void>;
1893
1894
  /**
@@ -2884,7 +2885,7 @@ declare class BitfabFunction {
2884
2885
  /**
2885
2886
  * SDK version from package.json (injected at build time)
2886
2887
  */
2887
- declare const __version__ = "0.38.7";
2888
+ declare const __version__ = "0.38.9";
2888
2889
 
2889
2890
  /**
2890
2891
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  getCurrentReplayBranch,
14
14
  getCurrentSpan,
15
15
  getCurrentTrace
16
- } from "./chunk-RZ3P6ICN.js";
16
+ } from "./chunk-B4XXAK74.js";
17
17
  import "./chunk-ZUD7OFYB.js";
18
18
  import {
19
19
  BITFAB_PROGRESS_PREFIX,
@@ -27,7 +27,7 @@ import {
27
27
  flushTraces,
28
28
  reportReplayProgress,
29
29
  serializeReplayResult
30
- } from "./chunk-7E6KCBTH.js";
30
+ } from "./chunk-2I5TFNGK.js";
31
31
  import "./chunk-H6LZRFMN.js";
32
32
  export {
33
33
  BITFAB_PROGRESS_PREFIX,
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.38.7";
91
+ __version__ = "0.38.9";
92
92
  __packageName__ = "@bitfab/sdk";
93
93
  }
94
94
  });
@@ -3231,8 +3231,20 @@ function finalizeTracePayload(payload) {
3231
3231
  // src/claudeAgentSdk.ts
3232
3232
  init_randomUuid();
3233
3233
  init_serialize();
3234
+
3235
+ // src/timestamp.ts
3236
+ var lastTimestampMicros = 0;
3237
+ function nowIsoTimestamp() {
3238
+ const wallClockMicros = Date.now() * 1e3;
3239
+ lastTimestampMicros = Math.max(wallClockMicros, lastTimestampMicros + 1);
3240
+ const milliseconds = Math.floor(lastTimestampMicros / 1e3);
3241
+ const remainingMicros = lastTimestampMicros % 1e3;
3242
+ return new Date(milliseconds).toISOString().replace("Z", `${remainingMicros.toString().padStart(3, "0")}Z`);
3243
+ }
3244
+
3245
+ // src/claudeAgentSdk.ts
3234
3246
  function nowIso() {
3235
- return (/* @__PURE__ */ new Date()).toISOString();
3247
+ return nowIsoTimestamp();
3236
3248
  }
3237
3249
  var safeSerialize = toJsonSafe;
3238
3250
  function extractContentBlocks(content) {
@@ -4252,7 +4264,7 @@ var LANGGRAPH_METADATA_KEYS = [
4252
4264
  "langgraph_checkpoint_ns"
4253
4265
  ];
4254
4266
  function nowIso2() {
4255
- return (/* @__PURE__ */ new Date()).toISOString();
4267
+ return nowIsoTimestamp();
4256
4268
  }
4257
4269
  function normalizeChainStartArgs(parentRunIdOrRunType, runTypeOrRunName, runNameOrParentRunId) {
4258
4270
  if (parentRunIdOrRunType && CHAIN_RUN_TYPES.has(parentRunIdOrRunType)) {
@@ -5294,16 +5306,16 @@ var BitfabOpenAITracingProcessor = class {
5294
5306
  delete this.activeTraces[trace.traceId];
5295
5307
  }
5296
5308
  /**
5297
- * Called when a span is started.
5309
+ * Called when a span is started. Span payloads are authoritative completed
5310
+ * snapshots, so start notifications do not cross the transport boundary.
5298
5311
  */
5299
5312
  // biome-ignore lint/suspicious/noExplicitAny: OpenAI Agents SDK uses any for span data
5300
- async onSpanStart(span) {
5301
- this.sendSpan(span);
5313
+ async onSpanStart(_span) {
5302
5314
  }
5303
5315
  /**
5304
5316
  * Called when a span is ended.
5305
5317
  *
5306
- * Send all spans to Bitfab for complete trace capture.
5318
+ * Send the finalized span snapshot to Bitfab for complete trace capture.
5307
5319
  */
5308
5320
  // biome-ignore lint/suspicious/noExplicitAny: OpenAI Agents SDK uses any for span data
5309
5321
  async onSpanEnd(span) {
@@ -5863,7 +5875,7 @@ function getCurrentTrace() {
5863
5875
  if (!traceState) {
5864
5876
  traceState = {
5865
5877
  traceId,
5866
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
5878
+ startedAt: nowIsoTimestamp(),
5867
5879
  contexts: []
5868
5880
  };
5869
5881
  activeTraceStates.set(traceId, traceState);
@@ -6797,7 +6809,7 @@ var Bitfab = class {
6797
6809
  const newContext = { traceId, spanId, contexts: [] };
6798
6810
  newStack = [...currentStack, newContext];
6799
6811
  const inputs = args;
6800
- const startedAt = (/* @__PURE__ */ new Date()).toISOString();
6812
+ const startedAt = nowIsoTimestamp();
6801
6813
  const replayCtxAtStart = getReplayContext();
6802
6814
  const testRunId = replayCtxAtStart?.testRunId ?? options.testRunId;
6803
6815
  if (isRootSpan && !activeTraceStates.has(traceId)) {
@@ -6832,7 +6844,7 @@ var Bitfab = class {
6832
6844
  const sendSpan = async (params) => {
6833
6845
  const replayCtx = getReplayContext();
6834
6846
  try {
6835
- const endedAt = (/* @__PURE__ */ new Date()).toISOString();
6847
+ const endedAt = nowIsoTimestamp();
6836
6848
  const traceDropped = activeTraceStates.get(traceId)?.dropped === true;
6837
6849
  if (!traceDropped) {
6838
6850
  self.sendWrapperSpan({