bitfab 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.cjs CHANGED
@@ -51,7 +51,7 @@ var __version__, __packageName__;
51
51
  var init_version_generated = __esm({
52
52
  "src/version.generated.ts"() {
53
53
  "use strict";
54
- __version__ = "0.38.7";
54
+ __version__ = "0.38.9";
55
55
  __packageName__ = "bitfab";
56
56
  }
57
57
  });
@@ -3226,8 +3226,20 @@ function finalizeTracePayload(payload) {
3226
3226
  // src/claudeAgentSdk.ts
3227
3227
  init_randomUuid();
3228
3228
  init_serialize();
3229
+
3230
+ // src/timestamp.ts
3231
+ var lastTimestampMicros = 0;
3232
+ function nowIsoTimestamp() {
3233
+ const wallClockMicros = Date.now() * 1e3;
3234
+ lastTimestampMicros = Math.max(wallClockMicros, lastTimestampMicros + 1);
3235
+ const milliseconds = Math.floor(lastTimestampMicros / 1e3);
3236
+ const remainingMicros = lastTimestampMicros % 1e3;
3237
+ return new Date(milliseconds).toISOString().replace("Z", `${remainingMicros.toString().padStart(3, "0")}Z`);
3238
+ }
3239
+
3240
+ // src/claudeAgentSdk.ts
3229
3241
  function nowIso() {
3230
- return (/* @__PURE__ */ new Date()).toISOString();
3242
+ return nowIsoTimestamp();
3231
3243
  }
3232
3244
  var safeSerialize = toJsonSafe;
3233
3245
  function extractContentBlocks(content) {
@@ -4247,7 +4259,7 @@ var LANGGRAPH_METADATA_KEYS = [
4247
4259
  "langgraph_checkpoint_ns"
4248
4260
  ];
4249
4261
  function nowIso2() {
4250
- return (/* @__PURE__ */ new Date()).toISOString();
4262
+ return nowIsoTimestamp();
4251
4263
  }
4252
4264
  function normalizeChainStartArgs(parentRunIdOrRunType, runTypeOrRunName, runNameOrParentRunId) {
4253
4265
  if (parentRunIdOrRunType && CHAIN_RUN_TYPES.has(parentRunIdOrRunType)) {
@@ -5289,16 +5301,16 @@ var BitfabOpenAITracingProcessor = class {
5289
5301
  delete this.activeTraces[trace.traceId];
5290
5302
  }
5291
5303
  /**
5292
- * Called when a span is started.
5304
+ * Called when a span is started. Span payloads are authoritative completed
5305
+ * snapshots, so start notifications do not cross the transport boundary.
5293
5306
  */
5294
5307
  // biome-ignore lint/suspicious/noExplicitAny: OpenAI Agents SDK uses any for span data
5295
- async onSpanStart(span) {
5296
- this.sendSpan(span);
5308
+ async onSpanStart(_span) {
5297
5309
  }
5298
5310
  /**
5299
5311
  * Called when a span is ended.
5300
5312
  *
5301
- * Send all spans to Bitfab for complete trace capture.
5313
+ * Send the finalized span snapshot to Bitfab for complete trace capture.
5302
5314
  */
5303
5315
  // biome-ignore lint/suspicious/noExplicitAny: OpenAI Agents SDK uses any for span data
5304
5316
  async onSpanEnd(span) {
@@ -5858,7 +5870,7 @@ function getCurrentTrace() {
5858
5870
  if (!traceState) {
5859
5871
  traceState = {
5860
5872
  traceId,
5861
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
5873
+ startedAt: nowIsoTimestamp(),
5862
5874
  contexts: []
5863
5875
  };
5864
5876
  activeTraceStates.set(traceId, traceState);
@@ -6792,7 +6804,7 @@ var Bitfab = class {
6792
6804
  const newContext = { traceId, spanId, contexts: [] };
6793
6805
  newStack = [...currentStack, newContext];
6794
6806
  const inputs = args;
6795
- const startedAt = (/* @__PURE__ */ new Date()).toISOString();
6807
+ const startedAt = nowIsoTimestamp();
6796
6808
  const replayCtxAtStart = getReplayContext();
6797
6809
  const testRunId = replayCtxAtStart?.testRunId ?? options.testRunId;
6798
6810
  if (isRootSpan && !activeTraceStates.has(traceId)) {
@@ -6827,7 +6839,7 @@ var Bitfab = class {
6827
6839
  const sendSpan = async (params) => {
6828
6840
  const replayCtx = getReplayContext();
6829
6841
  try {
6830
- const endedAt = (/* @__PURE__ */ new Date()).toISOString();
6842
+ const endedAt = nowIsoTimestamp();
6831
6843
  const traceDropped = activeTraceStates.get(traceId)?.dropped === true;
6832
6844
  if (!traceDropped) {
6833
6845
  self.sendWrapperSpan({