@bitfab/sdk 0.26.1 → 0.26.2
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-SJFOTDP3.js → chunk-DW7VTEO2.js} +88 -14
- package/dist/chunk-DW7VTEO2.js.map +1 -0
- package/dist/{chunk-26MUT4IP.js → chunk-IDGR2OIX.js} +54 -33
- package/dist/chunk-IDGR2OIX.js.map +1 -0
- package/dist/index.cjs +140 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/node.cjs +140 -47
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +2 -2
- package/dist/{replay-KYGI6LJY.js → replay-CORDD7TR.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-26MUT4IP.js.map +0 -1
- package/dist/chunk-SJFOTDP3.js.map +0 -1
- /package/dist/{replay-KYGI6LJY.js.map → replay-CORDD7TR.js.map} +0 -0
|
@@ -8,11 +8,12 @@ import {
|
|
|
8
8
|
randomUuid,
|
|
9
9
|
serializeValue,
|
|
10
10
|
toJsonSafe,
|
|
11
|
+
toJsonSafeReport,
|
|
11
12
|
warnOnce
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-IDGR2OIX.js";
|
|
13
14
|
|
|
14
15
|
// src/version.generated.ts
|
|
15
|
-
var __version__ = "0.26.
|
|
16
|
+
var __version__ = "0.26.2";
|
|
16
17
|
|
|
17
18
|
// src/constants.ts
|
|
18
19
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -450,6 +451,60 @@ var HttpClient = class {
|
|
|
450
451
|
}
|
|
451
452
|
};
|
|
452
453
|
|
|
454
|
+
// src/processorPayload.ts
|
|
455
|
+
var SERIALIZATION_DEGRADED_STEP = "serialization_degraded";
|
|
456
|
+
function degradedError(dropped) {
|
|
457
|
+
const names = [...new Set(dropped)].sort().join(", ");
|
|
458
|
+
return {
|
|
459
|
+
source: "sdk",
|
|
460
|
+
step: SERIALIZATION_DEGRADED_STEP,
|
|
461
|
+
error: `non-replayable: could not faithfully capture ${names}`
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
var ENVELOPE_FIELDS = [
|
|
465
|
+
"type",
|
|
466
|
+
"source",
|
|
467
|
+
"traceFunctionKey",
|
|
468
|
+
"sourceTraceId",
|
|
469
|
+
"completed"
|
|
470
|
+
];
|
|
471
|
+
function rebuildEnvelope(payload, bodyKey, placeholder) {
|
|
472
|
+
const rebuilt = {};
|
|
473
|
+
for (const k of ENVELOPE_FIELDS) {
|
|
474
|
+
if (k in payload) {
|
|
475
|
+
rebuilt[k] = payload[k];
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
rebuilt[bodyKey] = { serialized: placeholder };
|
|
479
|
+
return rebuilt;
|
|
480
|
+
}
|
|
481
|
+
function finalizeSpanPayload(payload, extraDropped) {
|
|
482
|
+
const { safe, dropped } = toJsonSafeReport(payload);
|
|
483
|
+
const allDropped = [...extraDropped ?? [], ...dropped];
|
|
484
|
+
const collapsed = safe === null || typeof safe !== "object" || Array.isArray(safe);
|
|
485
|
+
const result = collapsed ? rebuildEnvelope(payload, "rawSpan", safe) : safe;
|
|
486
|
+
if (allDropped.length > 0) {
|
|
487
|
+
const existing = result.errors;
|
|
488
|
+
const errors = Array.isArray(existing) ? existing : [];
|
|
489
|
+
errors.push(degradedError(allDropped));
|
|
490
|
+
result.errors = errors;
|
|
491
|
+
}
|
|
492
|
+
return result;
|
|
493
|
+
}
|
|
494
|
+
function finalizeTracePayload(payload) {
|
|
495
|
+
const { safe, dropped } = toJsonSafeReport(payload);
|
|
496
|
+
const collapsed = safe === null || typeof safe !== "object" || Array.isArray(safe);
|
|
497
|
+
const result = collapsed ? rebuildEnvelope(payload, "externalTrace", safe) : safe;
|
|
498
|
+
if (dropped.length > 0 || collapsed) {
|
|
499
|
+
const names = dropped.length > 0 ? [...new Set(dropped)].sort().join(", ") : "trace";
|
|
500
|
+
warnOnce(
|
|
501
|
+
`finalizeTrace:${names.replace(/\d+/g, "N")}`,
|
|
502
|
+
`a trace held non-serializable value(s) (${names}); they were captured as placeholders, so the trace may not be replayable.`
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
return result;
|
|
506
|
+
}
|
|
507
|
+
|
|
453
508
|
// src/claudeAgentSdk.ts
|
|
454
509
|
function nowIso() {
|
|
455
510
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -577,6 +632,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
577
632
|
// ── span helpers ─────────────────────────────────────────────
|
|
578
633
|
startSpan(spanId, name, spanType, inputData, parentId) {
|
|
579
634
|
const traceId = this.ensureTrace();
|
|
635
|
+
const { safe: safeInput, dropped: inputDropped } = toJsonSafeReport(inputData);
|
|
580
636
|
const spanInfo = {
|
|
581
637
|
spanId,
|
|
582
638
|
traceId,
|
|
@@ -584,9 +640,12 @@ var BitfabClaudeAgentHandler = class {
|
|
|
584
640
|
startedAt: nowIso(),
|
|
585
641
|
name,
|
|
586
642
|
type: spanType,
|
|
587
|
-
input:
|
|
643
|
+
input: safeInput,
|
|
588
644
|
contexts: []
|
|
589
645
|
};
|
|
646
|
+
if (inputDropped.length > 0) {
|
|
647
|
+
spanInfo.dropped = [...inputDropped];
|
|
648
|
+
}
|
|
590
649
|
this.runToSpan.set(spanId, spanInfo);
|
|
591
650
|
return spanInfo;
|
|
592
651
|
}
|
|
@@ -597,7 +656,11 @@ var BitfabClaudeAgentHandler = class {
|
|
|
597
656
|
}
|
|
598
657
|
this.runToSpan.delete(spanId);
|
|
599
658
|
spanInfo.endedAt = nowIso();
|
|
600
|
-
|
|
659
|
+
const { safe: safeOutput, dropped: outputDropped } = toJsonSafeReport(output);
|
|
660
|
+
spanInfo.output = safeOutput;
|
|
661
|
+
if (outputDropped.length > 0) {
|
|
662
|
+
spanInfo.dropped = [...spanInfo.dropped ?? [], ...outputDropped];
|
|
663
|
+
}
|
|
601
664
|
if (error !== void 0) {
|
|
602
665
|
spanInfo.error = error;
|
|
603
666
|
}
|
|
@@ -640,8 +703,9 @@ var BitfabClaudeAgentHandler = class {
|
|
|
640
703
|
sourceTraceId: spanInfo.traceId,
|
|
641
704
|
rawSpan
|
|
642
705
|
};
|
|
706
|
+
const finalized = finalizeSpanPayload(payload, spanInfo.dropped);
|
|
643
707
|
try {
|
|
644
|
-
this.httpClient.sendExternalSpan(
|
|
708
|
+
this.httpClient.sendExternalSpan(finalized);
|
|
645
709
|
} catch {
|
|
646
710
|
}
|
|
647
711
|
}
|
|
@@ -668,8 +732,9 @@ var BitfabClaudeAgentHandler = class {
|
|
|
668
732
|
externalTrace,
|
|
669
733
|
completed
|
|
670
734
|
};
|
|
735
|
+
const finalized = finalizeTracePayload(traceData);
|
|
671
736
|
try {
|
|
672
|
-
this.httpClient.sendExternalTrace(
|
|
737
|
+
this.httpClient.sendExternalTrace(finalized);
|
|
673
738
|
} catch {
|
|
674
739
|
}
|
|
675
740
|
}
|
|
@@ -1301,7 +1366,6 @@ var LANGGRAPH_METADATA_KEYS = [
|
|
|
1301
1366
|
function nowIso2() {
|
|
1302
1367
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
1303
1368
|
}
|
|
1304
|
-
var safeSerialize2 = toJsonSafe;
|
|
1305
1369
|
function convertMessage(message) {
|
|
1306
1370
|
if (typeof message !== "object" || message === null) {
|
|
1307
1371
|
return { role: "unknown", content: String(message) };
|
|
@@ -1546,6 +1610,7 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1546
1610
|
}
|
|
1547
1611
|
const lgMetadata = extractLangGraphMetadata(metadata);
|
|
1548
1612
|
const contexts = Object.keys(lgMetadata).length > 0 ? [lgMetadata] : [];
|
|
1613
|
+
const { safe: safeInput, dropped: inputDropped } = toJsonSafeReport(inputData);
|
|
1549
1614
|
const spanInfo = {
|
|
1550
1615
|
spanId: runId,
|
|
1551
1616
|
traceId: invocation.traceId,
|
|
@@ -1554,9 +1619,12 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1554
1619
|
startedAt: nowIso2(),
|
|
1555
1620
|
name,
|
|
1556
1621
|
type: spanType,
|
|
1557
|
-
input:
|
|
1622
|
+
input: safeInput,
|
|
1558
1623
|
contexts
|
|
1559
1624
|
};
|
|
1625
|
+
if (inputDropped.length > 0) {
|
|
1626
|
+
spanInfo.dropped = [...inputDropped];
|
|
1627
|
+
}
|
|
1560
1628
|
if (willHide) {
|
|
1561
1629
|
spanInfo.hidden = true;
|
|
1562
1630
|
}
|
|
@@ -1570,7 +1638,11 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1570
1638
|
}
|
|
1571
1639
|
this.runToSpan.delete(runId);
|
|
1572
1640
|
spanInfo.endedAt = nowIso2();
|
|
1573
|
-
|
|
1641
|
+
const { safe: safeOutput, dropped: outputDropped } = toJsonSafeReport(output);
|
|
1642
|
+
spanInfo.output = safeOutput;
|
|
1643
|
+
if (outputDropped.length > 0) {
|
|
1644
|
+
spanInfo.dropped = [...spanInfo.dropped ?? [], ...outputDropped];
|
|
1645
|
+
}
|
|
1574
1646
|
if (error !== void 0) {
|
|
1575
1647
|
spanInfo.error = error;
|
|
1576
1648
|
}
|
|
@@ -1621,8 +1693,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1621
1693
|
sourceTraceId: spanInfo.traceId,
|
|
1622
1694
|
rawSpan
|
|
1623
1695
|
};
|
|
1696
|
+
const finalized = finalizeSpanPayload(payload, spanInfo.dropped);
|
|
1624
1697
|
try {
|
|
1625
|
-
this.httpClient.sendExternalSpan(
|
|
1698
|
+
this.httpClient.sendExternalSpan(finalized);
|
|
1626
1699
|
} catch {
|
|
1627
1700
|
}
|
|
1628
1701
|
}
|
|
@@ -1640,8 +1713,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1640
1713
|
},
|
|
1641
1714
|
completed
|
|
1642
1715
|
};
|
|
1716
|
+
const finalized = finalizeTracePayload(traceData);
|
|
1643
1717
|
try {
|
|
1644
|
-
this.httpClient.sendExternalTrace(
|
|
1718
|
+
this.httpClient.sendExternalTrace(finalized);
|
|
1645
1719
|
} catch {
|
|
1646
1720
|
}
|
|
1647
1721
|
}
|
|
@@ -2148,7 +2222,7 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
2148
2222
|
if (errors.length > 0) {
|
|
2149
2223
|
payload.errors = errors;
|
|
2150
2224
|
}
|
|
2151
|
-
return payload;
|
|
2225
|
+
return finalizeSpanPayload(payload);
|
|
2152
2226
|
}
|
|
2153
2227
|
/**
|
|
2154
2228
|
* Send span to Bitfab API (fire-and-forget).
|
|
@@ -3450,7 +3524,7 @@ var Bitfab = class {
|
|
|
3450
3524
|
`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.`
|
|
3451
3525
|
);
|
|
3452
3526
|
}
|
|
3453
|
-
const { replay: doReplay } = await import("./replay-
|
|
3527
|
+
const { replay: doReplay } = await import("./replay-CORDD7TR.js");
|
|
3454
3528
|
return doReplay(
|
|
3455
3529
|
this.httpClient,
|
|
3456
3530
|
this.serviceUrl,
|
|
@@ -3675,4 +3749,4 @@ export {
|
|
|
3675
3749
|
BitfabFunction,
|
|
3676
3750
|
finalizers
|
|
3677
3751
|
};
|
|
3678
|
-
//# sourceMappingURL=chunk-
|
|
3752
|
+
//# sourceMappingURL=chunk-DW7VTEO2.js.map
|