bitfab 0.54.2 → 0.54.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.
- package/dist/{chunk-ELGX3GWC.js → chunk-KDLFM5FD.js} +113 -6
- package/dist/chunk-KDLFM5FD.js.map +1 -0
- package/dist/{chunk-V6A3A6PF.js → chunk-UARR7MGL.js} +3 -3
- package/dist/chunk-UARR7MGL.js.map +1 -0
- package/dist/{chunk-GMHABKGI.js → chunk-UJRT3MLT.js} +113 -6
- package/dist/chunk-UJRT3MLT.js.map +1 -0
- package/dist/{chunk-SMNXZVSZ.js → chunk-WFNCKWDC.js} +74 -14
- package/dist/chunk-WFNCKWDC.js.map +1 -0
- package/dist/{chunk-YGVEPWC5.js → chunk-YO332W7L.js} +2 -2
- package/dist/chunk-YO332W7L.js.map +1 -0
- package/dist/{http-5PXP5N7O.js → http-72OO3GAV.js} +2 -2
- package/dist/{http-JD44RSQN.js → http-LSUY52PX.js} +2 -2
- package/dist/index.cjs +187 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -13
- package/dist/index.d.ts +25 -13
- package/dist/index.js +3 -3
- package/dist/node.cjs +187 -13
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-3KZRKPX2.js → replay-2VG6C4O4.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-ELGX3GWC.js.map +0 -1
- package/dist/chunk-GMHABKGI.js.map +0 -1
- package/dist/chunk-SMNXZVSZ.js.map +0 -1
- package/dist/chunk-V6A3A6PF.js.map +0 -1
- package/dist/chunk-YGVEPWC5.js.map +0 -1
- /package/dist/{http-5PXP5N7O.js.map → http-72OO3GAV.js.map} +0 -0
- /package/dist/{http-JD44RSQN.js.map → http-LSUY52PX.js.map} +0 -0
- /package/dist/{replay-3KZRKPX2.js.map → replay-2VG6C4O4.js.map} +0 -0
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
serializeValue,
|
|
19
19
|
toJsonSafe,
|
|
20
20
|
toJsonSafeReport
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-YO332W7L.js";
|
|
22
22
|
import {
|
|
23
23
|
BitfabError,
|
|
24
24
|
DEFAULT_SERVICE_URL,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
recordCallerTraceMetadata,
|
|
36
36
|
retireTraceMetadata,
|
|
37
37
|
warnOnce
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-UJRT3MLT.js";
|
|
39
39
|
import {
|
|
40
40
|
__privateAdd,
|
|
41
41
|
__privateGet,
|
|
@@ -331,6 +331,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
331
331
|
spanInfo.dropped = [...inputDropped];
|
|
332
332
|
}
|
|
333
333
|
this.runToSpan.set(spanId, spanInfo);
|
|
334
|
+
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
334
335
|
return spanInfo;
|
|
335
336
|
}
|
|
336
337
|
completeSpan(spanId, output, error, extraContexts) {
|
|
@@ -352,6 +353,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
352
353
|
spanInfo.contexts.push(extraContexts);
|
|
353
354
|
}
|
|
354
355
|
this.sendSpan(spanInfo);
|
|
356
|
+
this.httpClient.traceCompletion.end(spanInfo.traceId, spanInfo.spanId);
|
|
355
357
|
}
|
|
356
358
|
sendSpan(spanInfo) {
|
|
357
359
|
const spanData = {
|
|
@@ -1824,6 +1826,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1824
1826
|
spanInfo.hidden = true;
|
|
1825
1827
|
}
|
|
1826
1828
|
this.runToSpan.set(runId, spanInfo);
|
|
1829
|
+
if (spanInfo.hidden !== true) {
|
|
1830
|
+
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
1831
|
+
}
|
|
1827
1832
|
if (isRootInvocation) {
|
|
1828
1833
|
this.sendTraceStart(spanInfo);
|
|
1829
1834
|
}
|
|
@@ -1855,6 +1860,7 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1855
1860
|
this.sendTraceCompletion(spanInfo, invocation?.activeContext ?? null);
|
|
1856
1861
|
this.invocations.delete(runId);
|
|
1857
1862
|
}
|
|
1863
|
+
this.httpClient.traceCompletion.end(spanInfo.traceId, spanInfo.spanId);
|
|
1858
1864
|
}
|
|
1859
1865
|
sendSpan(spanInfo) {
|
|
1860
1866
|
const spanData = {
|
|
@@ -2550,6 +2556,8 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
2550
2556
|
this.activeTraces = {};
|
|
2551
2557
|
this.activeSpanMappings = {};
|
|
2552
2558
|
this.canonicalTraceIds = {};
|
|
2559
|
+
this.startedSpans = /* @__PURE__ */ new Map();
|
|
2560
|
+
this.endedTraces = /* @__PURE__ */ new Set();
|
|
2553
2561
|
this.ownsHttpClient = config._httpClient === void 0;
|
|
2554
2562
|
this.httpClient = config._httpClient ?? new HttpClient({
|
|
2555
2563
|
apiKey: config.apiKey,
|
|
@@ -2588,6 +2596,10 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
2588
2596
|
}
|
|
2589
2597
|
const canonicalTraceId = activeContext?.traceId ?? this.getCanonicalTraceId(trace.traceId);
|
|
2590
2598
|
this.canonicalTraceIds[trace.traceId] = canonicalTraceId;
|
|
2599
|
+
this.httpClient.traceCompletion.hold(
|
|
2600
|
+
activeContext?.traceId ?? trace.traceId,
|
|
2601
|
+
`openai:${trace.traceId}`
|
|
2602
|
+
);
|
|
2591
2603
|
this.sendTrace(trace, {
|
|
2592
2604
|
id: canonicalTraceId,
|
|
2593
2605
|
sourceTraceId: activeContext?.traceId
|
|
@@ -2605,16 +2617,33 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
2605
2617
|
id: mapping?.traceId ?? this.getCanonicalTraceId(trace.traceId),
|
|
2606
2618
|
sourceTraceId: mapping?.traceId
|
|
2607
2619
|
});
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2620
|
+
this.endedTraces.add(trace.traceId);
|
|
2621
|
+
this.httpClient.traceCompletion.end(
|
|
2622
|
+
mapping?.traceId ?? trace.traceId,
|
|
2623
|
+
`openai:${trace.traceId}`
|
|
2624
|
+
);
|
|
2625
|
+
this.cleanupTrace(trace.traceId);
|
|
2626
|
+
}
|
|
2627
|
+
cleanupTrace(traceId) {
|
|
2628
|
+
if (!this.endedTraces.has(traceId) || [...this.startedSpans.values()].includes(traceId)) {
|
|
2629
|
+
return;
|
|
2630
|
+
}
|
|
2631
|
+
this.endedTraces.delete(traceId);
|
|
2632
|
+
delete this.activeSpanMappings[traceId];
|
|
2633
|
+
delete this.canonicalTraceIds[traceId];
|
|
2634
|
+
delete this.activeTraces[traceId];
|
|
2611
2635
|
}
|
|
2612
2636
|
/**
|
|
2613
2637
|
* Called when a span is started. Span payloads are authoritative completed
|
|
2614
2638
|
* snapshots, so start notifications do not cross the transport boundary.
|
|
2615
2639
|
*/
|
|
2616
2640
|
// biome-ignore lint/suspicious/noExplicitAny: OpenAI Agents SDK uses any for span data
|
|
2617
|
-
async onSpanStart(
|
|
2641
|
+
async onSpanStart(span) {
|
|
2642
|
+
if (span.spanId !== void 0 && span.traceId !== null && span.traceId !== void 0) {
|
|
2643
|
+
this.startedSpans.set(span.spanId, span.traceId);
|
|
2644
|
+
const traceId = this.activeSpanMappings[span.traceId]?.traceId ?? span.traceId;
|
|
2645
|
+
this.httpClient.traceCompletion.start(traceId, span.spanId);
|
|
2646
|
+
}
|
|
2618
2647
|
}
|
|
2619
2648
|
/**
|
|
2620
2649
|
* Called when a span is ended.
|
|
@@ -2623,7 +2652,17 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
2623
2652
|
*/
|
|
2624
2653
|
// biome-ignore lint/suspicious/noExplicitAny: OpenAI Agents SDK uses any for span data
|
|
2625
2654
|
async onSpanEnd(span) {
|
|
2626
|
-
|
|
2655
|
+
const originalTraceId = span.traceId ?? "";
|
|
2656
|
+
const traceId = this.activeSpanMappings[originalTraceId]?.traceId ?? originalTraceId;
|
|
2657
|
+
try {
|
|
2658
|
+
this.sendSpan(span);
|
|
2659
|
+
} finally {
|
|
2660
|
+
if (span.spanId !== void 0) {
|
|
2661
|
+
this.httpClient.traceCompletion.end(traceId, span.spanId);
|
|
2662
|
+
this.startedSpans.delete(span.spanId);
|
|
2663
|
+
}
|
|
2664
|
+
this.cleanupTrace(originalTraceId);
|
|
2665
|
+
}
|
|
2627
2666
|
}
|
|
2628
2667
|
/**
|
|
2629
2668
|
* Called when a trace is being flushed.
|
|
@@ -4328,6 +4367,7 @@ var Bitfab = class {
|
|
|
4328
4367
|
let newStack;
|
|
4329
4368
|
let executeWithContext;
|
|
4330
4369
|
let registeredTraceId;
|
|
4370
|
+
let startedSpan;
|
|
4331
4371
|
try {
|
|
4332
4372
|
const currentStack = getSpanStack();
|
|
4333
4373
|
const parentContext = currentStack[currentStack.length - 1];
|
|
@@ -4379,6 +4419,8 @@ var Bitfab = class {
|
|
|
4379
4419
|
});
|
|
4380
4420
|
registeredTraceId = traceId;
|
|
4381
4421
|
}
|
|
4422
|
+
self.httpClient.traceCompletion.start(traceId, spanId);
|
|
4423
|
+
startedSpan = { traceId, spanId };
|
|
4382
4424
|
const functionName = fn.name !== "" ? fn.name : void 0;
|
|
4383
4425
|
const rootTraceFunctionKey = activeTraceStates.get(traceId)?.traceFunctionKey ?? traceFunctionKey;
|
|
4384
4426
|
const baseSpanParams = {
|
|
@@ -4453,6 +4495,8 @@ var Bitfab = class {
|
|
|
4453
4495
|
retireTraceMetadata(traceId);
|
|
4454
4496
|
}
|
|
4455
4497
|
} catch {
|
|
4498
|
+
} finally {
|
|
4499
|
+
self.httpClient.traceCompletion.end(traceId, spanId);
|
|
4456
4500
|
}
|
|
4457
4501
|
};
|
|
4458
4502
|
const recordSpan = (result) => {
|
|
@@ -4469,6 +4513,14 @@ var Bitfab = class {
|
|
|
4469
4513
|
void sendSpan({ result });
|
|
4470
4514
|
}
|
|
4471
4515
|
};
|
|
4516
|
+
const resolveMockOrAbort = async (resolve) => {
|
|
4517
|
+
try {
|
|
4518
|
+
return await resolve();
|
|
4519
|
+
} catch (error) {
|
|
4520
|
+
self.httpClient.traceCompletion.abort(traceId, spanId);
|
|
4521
|
+
throw error;
|
|
4522
|
+
}
|
|
4523
|
+
};
|
|
4472
4524
|
executeWithContext = () => {
|
|
4473
4525
|
let result;
|
|
4474
4526
|
try {
|
|
@@ -4525,7 +4577,7 @@ var Bitfab = class {
|
|
|
4525
4577
|
);
|
|
4526
4578
|
}
|
|
4527
4579
|
return (async () => {
|
|
4528
|
-
const output = await pending;
|
|
4580
|
+
const output = await resolveMockOrAbort(() => pending);
|
|
4529
4581
|
void sendSpan({
|
|
4530
4582
|
result: output,
|
|
4531
4583
|
mocked: true,
|
|
@@ -4595,7 +4647,7 @@ var Bitfab = class {
|
|
|
4595
4647
|
);
|
|
4596
4648
|
}
|
|
4597
4649
|
return runWithSpanStack(newStack, async () => {
|
|
4598
|
-
const resolved2 = await resolution;
|
|
4650
|
+
const resolved2 = await resolveMockOrAbort(() => resolution);
|
|
4599
4651
|
if (resolved2.matched) {
|
|
4600
4652
|
void sendSpan({
|
|
4601
4653
|
result: resolved2.output,
|
|
@@ -4611,7 +4663,9 @@ var Bitfab = class {
|
|
|
4611
4663
|
);
|
|
4612
4664
|
}
|
|
4613
4665
|
if (shouldMockWithBaseStrategy) {
|
|
4614
|
-
const output = await
|
|
4666
|
+
const output = await resolveMockOrAbort(
|
|
4667
|
+
() => resolveRecordedOutput()
|
|
4668
|
+
);
|
|
4615
4669
|
void sendSpan({
|
|
4616
4670
|
result: output,
|
|
4617
4671
|
mocked: true,
|
|
@@ -4641,6 +4695,12 @@ var Bitfab = class {
|
|
|
4641
4695
|
}
|
|
4642
4696
|
}
|
|
4643
4697
|
} catch (setupError) {
|
|
4698
|
+
if (startedSpan) {
|
|
4699
|
+
self.httpClient.traceCompletion.abort(
|
|
4700
|
+
startedSpan.traceId,
|
|
4701
|
+
startedSpan.spanId
|
|
4702
|
+
);
|
|
4703
|
+
}
|
|
4644
4704
|
if (registeredTraceId) {
|
|
4645
4705
|
activeTraceStates.delete(registeredTraceId);
|
|
4646
4706
|
retireTraceMetadata(registeredTraceId);
|
|
@@ -5107,7 +5167,7 @@ var Bitfab = class {
|
|
|
5107
5167
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
5108
5168
|
} finally {
|
|
5109
5169
|
try {
|
|
5110
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
5170
|
+
const { flushTraces: flushTraces2 } = await import("./http-72OO3GAV.js");
|
|
5111
5171
|
await flushTraces2(3e4);
|
|
5112
5172
|
} finally {
|
|
5113
5173
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -5166,7 +5226,7 @@ var Bitfab = class {
|
|
|
5166
5226
|
`Function is wrapped with trace function key '${wrappedKey}' but replay was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to replay it under the explicit key.`
|
|
5167
5227
|
);
|
|
5168
5228
|
}
|
|
5169
|
-
const { replay: doReplay } = await import("./replay-
|
|
5229
|
+
const { replay: doReplay } = await import("./replay-2VG6C4O4.js");
|
|
5170
5230
|
return doReplay(
|
|
5171
5231
|
this.httpClient,
|
|
5172
5232
|
this.serviceUrl,
|
|
@@ -5450,7 +5510,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
5450
5510
|
sessionId: seedCase.sessionId
|
|
5451
5511
|
})
|
|
5452
5512
|
);
|
|
5453
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
5513
|
+
const { flushTraces: flushTraces2 } = await import("./http-72OO3GAV.js");
|
|
5454
5514
|
await flushTraces2(3e4);
|
|
5455
5515
|
return { pipeline, traceFunctionKey, traceIds };
|
|
5456
5516
|
}
|
|
@@ -5488,4 +5548,4 @@ export {
|
|
|
5488
5548
|
reseedFromRegistry,
|
|
5489
5549
|
seedFromRegistry
|
|
5490
5550
|
};
|
|
5491
|
-
//# sourceMappingURL=chunk-
|
|
5551
|
+
//# sourceMappingURL=chunk-WFNCKWDC.js.map
|