bitfab 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
package/dist/index.d.cts
CHANGED
|
@@ -1491,7 +1491,7 @@ declare class BitfabFunction {
|
|
|
1491
1491
|
/**
|
|
1492
1492
|
* SDK version from package.json (injected at build time)
|
|
1493
1493
|
*/
|
|
1494
|
-
declare const __version__ = "0.26.
|
|
1494
|
+
declare const __version__ = "0.26.2";
|
|
1495
1495
|
|
|
1496
1496
|
/**
|
|
1497
1497
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -1491,7 +1491,7 @@ declare class BitfabFunction {
|
|
|
1491
1491
|
/**
|
|
1492
1492
|
* SDK version from package.json (injected at build time)
|
|
1493
1493
|
*/
|
|
1494
|
-
declare const __version__ = "0.26.
|
|
1494
|
+
declare const __version__ = "0.26.2";
|
|
1495
1495
|
|
|
1496
1496
|
/**
|
|
1497
1497
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
|
@@ -23,10 +23,10 @@ import {
|
|
|
23
23
|
flushTraces,
|
|
24
24
|
getCurrentSpan,
|
|
25
25
|
getCurrentTrace
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-DW7VTEO2.js";
|
|
27
27
|
import {
|
|
28
28
|
BitfabError
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-IDGR2OIX.js";
|
|
30
30
|
export {
|
|
31
31
|
Bitfab,
|
|
32
32
|
BitfabClaudeAgentHandler,
|
package/dist/node.cjs
CHANGED
|
@@ -119,35 +119,6 @@ var init_warnOnce = __esm({
|
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
// src/randomUuid.ts
|
|
123
|
-
function randomUuid() {
|
|
124
|
-
const globalCrypto = globalThis.crypto;
|
|
125
|
-
if (typeof globalCrypto?.randomUUID === "function") {
|
|
126
|
-
try {
|
|
127
|
-
return globalCrypto.randomUUID();
|
|
128
|
-
} catch {
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
warnOnce(
|
|
132
|
-
"crypto-unavailable",
|
|
133
|
-
"global crypto.randomUUID is unavailable; using a non-cryptographic fallback for trace/span ids. Tracing works normally (ids are correlation-only, not security-sensitive)."
|
|
134
|
-
);
|
|
135
|
-
return fallbackUuidV4();
|
|
136
|
-
}
|
|
137
|
-
function fallbackUuidV4() {
|
|
138
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (char) => {
|
|
139
|
-
const rand = Math.random() * 16 | 0;
|
|
140
|
-
const value = char === "x" ? rand : rand & 3 | 8;
|
|
141
|
-
return value.toString(16);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
var init_randomUuid = __esm({
|
|
145
|
-
"src/randomUuid.ts"() {
|
|
146
|
-
"use strict";
|
|
147
|
-
init_warnOnce();
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
122
|
// src/serialize.ts
|
|
152
123
|
function describeValue(value) {
|
|
153
124
|
try {
|
|
@@ -203,7 +174,11 @@ function deserializeValue(serialized) {
|
|
|
203
174
|
});
|
|
204
175
|
}
|
|
205
176
|
function toJsonSafe(value) {
|
|
206
|
-
|
|
177
|
+
return toJsonSafeReport(value).safe;
|
|
178
|
+
}
|
|
179
|
+
function toJsonSafeReport(value) {
|
|
180
|
+
const dropped = [];
|
|
181
|
+
const safe = toJsonSafeInner(value, 0, /* @__PURE__ */ new WeakSet(), dropped);
|
|
207
182
|
try {
|
|
208
183
|
const size = JSON.stringify(safe)?.length ?? 0;
|
|
209
184
|
if (size > MAX_FRAMEWORK_SERIALIZED_BYTES) {
|
|
@@ -211,13 +186,16 @@ function toJsonSafe(value) {
|
|
|
211
186
|
"toJsonSafe:too_large",
|
|
212
187
|
`a framework payload exceeded ${MAX_FRAMEWORK_SERIALIZED_BYTES} bytes and was replaced with a placeholder so the span still ships. The captured state for this span is incomplete.`
|
|
213
188
|
);
|
|
214
|
-
return
|
|
189
|
+
return {
|
|
190
|
+
safe: `<unserializable: too_large_${size}_bytes>`,
|
|
191
|
+
dropped: [...dropped, `too_large_${size}_bytes`]
|
|
192
|
+
};
|
|
215
193
|
}
|
|
216
194
|
} catch {
|
|
217
195
|
}
|
|
218
|
-
return safe;
|
|
196
|
+
return { safe, dropped };
|
|
219
197
|
}
|
|
220
|
-
function toJsonSafeInner(value, depth, seen) {
|
|
198
|
+
function toJsonSafeInner(value, depth, seen, dropped) {
|
|
221
199
|
if (value === null || value === void 0) {
|
|
222
200
|
return value;
|
|
223
201
|
}
|
|
@@ -226,30 +204,40 @@ function toJsonSafeInner(value, depth, seen) {
|
|
|
226
204
|
}
|
|
227
205
|
const className = value?.constructor?.name ?? typeof value;
|
|
228
206
|
if (depth > MAX_SAFE_DEPTH) {
|
|
207
|
+
dropped.push(className);
|
|
229
208
|
return `<${className}>`;
|
|
230
209
|
}
|
|
231
210
|
if (typeof value !== "object") {
|
|
211
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
212
|
+
dropped.push(className);
|
|
213
|
+
}
|
|
232
214
|
try {
|
|
233
215
|
return String(value);
|
|
234
216
|
} catch {
|
|
217
|
+
dropped.push(className);
|
|
235
218
|
return `<${className}>`;
|
|
236
219
|
}
|
|
237
220
|
}
|
|
238
221
|
if (seen.has(value)) {
|
|
222
|
+
dropped.push(className);
|
|
239
223
|
return `<cycle ${className}>`;
|
|
240
224
|
}
|
|
241
225
|
seen.add(value);
|
|
242
226
|
let result;
|
|
243
227
|
if (Array.isArray(value)) {
|
|
244
|
-
result = value.map(
|
|
228
|
+
result = value.map(
|
|
229
|
+
(item) => toJsonSafeInner(item, depth + 1, seen, dropped)
|
|
230
|
+
);
|
|
245
231
|
} else if (typeof value.toJSON === "function") {
|
|
246
232
|
try {
|
|
247
233
|
result = toJsonSafeInner(
|
|
248
234
|
value.toJSON(),
|
|
249
235
|
depth + 1,
|
|
250
|
-
seen
|
|
236
|
+
seen,
|
|
237
|
+
dropped
|
|
251
238
|
);
|
|
252
239
|
} catch {
|
|
240
|
+
dropped.push(className);
|
|
253
241
|
result = `<${className}>`;
|
|
254
242
|
}
|
|
255
243
|
} else {
|
|
@@ -257,11 +245,12 @@ function toJsonSafeInner(value, depth, seen) {
|
|
|
257
245
|
const obj = {};
|
|
258
246
|
for (const [k, v] of Object.entries(value)) {
|
|
259
247
|
if (!k.startsWith("_")) {
|
|
260
|
-
obj[k] = toJsonSafeInner(v, depth + 1, seen);
|
|
248
|
+
obj[k] = toJsonSafeInner(v, depth + 1, seen, dropped);
|
|
261
249
|
}
|
|
262
250
|
}
|
|
263
251
|
result = obj;
|
|
264
252
|
} catch {
|
|
253
|
+
dropped.push(className);
|
|
265
254
|
result = `<${className}>`;
|
|
266
255
|
}
|
|
267
256
|
}
|
|
@@ -280,6 +269,35 @@ var init_serialize = __esm({
|
|
|
280
269
|
}
|
|
281
270
|
});
|
|
282
271
|
|
|
272
|
+
// src/randomUuid.ts
|
|
273
|
+
function randomUuid() {
|
|
274
|
+
const globalCrypto = globalThis.crypto;
|
|
275
|
+
if (typeof globalCrypto?.randomUUID === "function") {
|
|
276
|
+
try {
|
|
277
|
+
return globalCrypto.randomUUID();
|
|
278
|
+
} catch {
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
warnOnce(
|
|
282
|
+
"crypto-unavailable",
|
|
283
|
+
"global crypto.randomUUID is unavailable; using a non-cryptographic fallback for trace/span ids. Tracing works normally (ids are correlation-only, not security-sensitive)."
|
|
284
|
+
);
|
|
285
|
+
return fallbackUuidV4();
|
|
286
|
+
}
|
|
287
|
+
function fallbackUuidV4() {
|
|
288
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (char) => {
|
|
289
|
+
const rand = Math.random() * 16 | 0;
|
|
290
|
+
const value = char === "x" ? rand : rand & 3 | 8;
|
|
291
|
+
return value.toString(16);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
var init_randomUuid = __esm({
|
|
295
|
+
"src/randomUuid.ts"() {
|
|
296
|
+
"use strict";
|
|
297
|
+
init_warnOnce();
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
283
301
|
// src/replayContext.ts
|
|
284
302
|
function getReplayContext() {
|
|
285
303
|
return replayContextStorage?.getStore() ?? null;
|
|
@@ -610,7 +628,7 @@ registerAsyncLocalStorageClass(
|
|
|
610
628
|
);
|
|
611
629
|
|
|
612
630
|
// src/version.generated.ts
|
|
613
|
-
var __version__ = "0.26.
|
|
631
|
+
var __version__ = "0.26.2";
|
|
614
632
|
|
|
615
633
|
// src/constants.ts
|
|
616
634
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1052,6 +1070,62 @@ var HttpClient = class {
|
|
|
1052
1070
|
}
|
|
1053
1071
|
};
|
|
1054
1072
|
|
|
1073
|
+
// src/processorPayload.ts
|
|
1074
|
+
init_serialize();
|
|
1075
|
+
init_warnOnce();
|
|
1076
|
+
var SERIALIZATION_DEGRADED_STEP = "serialization_degraded";
|
|
1077
|
+
function degradedError(dropped) {
|
|
1078
|
+
const names = [...new Set(dropped)].sort().join(", ");
|
|
1079
|
+
return {
|
|
1080
|
+
source: "sdk",
|
|
1081
|
+
step: SERIALIZATION_DEGRADED_STEP,
|
|
1082
|
+
error: `non-replayable: could not faithfully capture ${names}`
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
var ENVELOPE_FIELDS = [
|
|
1086
|
+
"type",
|
|
1087
|
+
"source",
|
|
1088
|
+
"traceFunctionKey",
|
|
1089
|
+
"sourceTraceId",
|
|
1090
|
+
"completed"
|
|
1091
|
+
];
|
|
1092
|
+
function rebuildEnvelope(payload, bodyKey, placeholder) {
|
|
1093
|
+
const rebuilt = {};
|
|
1094
|
+
for (const k of ENVELOPE_FIELDS) {
|
|
1095
|
+
if (k in payload) {
|
|
1096
|
+
rebuilt[k] = payload[k];
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
rebuilt[bodyKey] = { serialized: placeholder };
|
|
1100
|
+
return rebuilt;
|
|
1101
|
+
}
|
|
1102
|
+
function finalizeSpanPayload(payload, extraDropped) {
|
|
1103
|
+
const { safe, dropped } = toJsonSafeReport(payload);
|
|
1104
|
+
const allDropped = [...extraDropped ?? [], ...dropped];
|
|
1105
|
+
const collapsed = safe === null || typeof safe !== "object" || Array.isArray(safe);
|
|
1106
|
+
const result = collapsed ? rebuildEnvelope(payload, "rawSpan", safe) : safe;
|
|
1107
|
+
if (allDropped.length > 0) {
|
|
1108
|
+
const existing = result.errors;
|
|
1109
|
+
const errors = Array.isArray(existing) ? existing : [];
|
|
1110
|
+
errors.push(degradedError(allDropped));
|
|
1111
|
+
result.errors = errors;
|
|
1112
|
+
}
|
|
1113
|
+
return result;
|
|
1114
|
+
}
|
|
1115
|
+
function finalizeTracePayload(payload) {
|
|
1116
|
+
const { safe, dropped } = toJsonSafeReport(payload);
|
|
1117
|
+
const collapsed = safe === null || typeof safe !== "object" || Array.isArray(safe);
|
|
1118
|
+
const result = collapsed ? rebuildEnvelope(payload, "externalTrace", safe) : safe;
|
|
1119
|
+
if (dropped.length > 0 || collapsed) {
|
|
1120
|
+
const names = dropped.length > 0 ? [...new Set(dropped)].sort().join(", ") : "trace";
|
|
1121
|
+
warnOnce(
|
|
1122
|
+
`finalizeTrace:${names.replace(/\d+/g, "N")}`,
|
|
1123
|
+
`a trace held non-serializable value(s) (${names}); they were captured as placeholders, so the trace may not be replayable.`
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
return result;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1055
1129
|
// src/claudeAgentSdk.ts
|
|
1056
1130
|
init_randomUuid();
|
|
1057
1131
|
init_serialize();
|
|
@@ -1181,6 +1255,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1181
1255
|
// ── span helpers ─────────────────────────────────────────────
|
|
1182
1256
|
startSpan(spanId, name, spanType, inputData, parentId) {
|
|
1183
1257
|
const traceId = this.ensureTrace();
|
|
1258
|
+
const { safe: safeInput, dropped: inputDropped } = toJsonSafeReport(inputData);
|
|
1184
1259
|
const spanInfo = {
|
|
1185
1260
|
spanId,
|
|
1186
1261
|
traceId,
|
|
@@ -1188,9 +1263,12 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1188
1263
|
startedAt: nowIso(),
|
|
1189
1264
|
name,
|
|
1190
1265
|
type: spanType,
|
|
1191
|
-
input:
|
|
1266
|
+
input: safeInput,
|
|
1192
1267
|
contexts: []
|
|
1193
1268
|
};
|
|
1269
|
+
if (inputDropped.length > 0) {
|
|
1270
|
+
spanInfo.dropped = [...inputDropped];
|
|
1271
|
+
}
|
|
1194
1272
|
this.runToSpan.set(spanId, spanInfo);
|
|
1195
1273
|
return spanInfo;
|
|
1196
1274
|
}
|
|
@@ -1201,7 +1279,11 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1201
1279
|
}
|
|
1202
1280
|
this.runToSpan.delete(spanId);
|
|
1203
1281
|
spanInfo.endedAt = nowIso();
|
|
1204
|
-
|
|
1282
|
+
const { safe: safeOutput, dropped: outputDropped } = toJsonSafeReport(output);
|
|
1283
|
+
spanInfo.output = safeOutput;
|
|
1284
|
+
if (outputDropped.length > 0) {
|
|
1285
|
+
spanInfo.dropped = [...spanInfo.dropped ?? [], ...outputDropped];
|
|
1286
|
+
}
|
|
1205
1287
|
if (error !== void 0) {
|
|
1206
1288
|
spanInfo.error = error;
|
|
1207
1289
|
}
|
|
@@ -1244,8 +1326,9 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1244
1326
|
sourceTraceId: spanInfo.traceId,
|
|
1245
1327
|
rawSpan
|
|
1246
1328
|
};
|
|
1329
|
+
const finalized = finalizeSpanPayload(payload, spanInfo.dropped);
|
|
1247
1330
|
try {
|
|
1248
|
-
this.httpClient.sendExternalSpan(
|
|
1331
|
+
this.httpClient.sendExternalSpan(finalized);
|
|
1249
1332
|
} catch {
|
|
1250
1333
|
}
|
|
1251
1334
|
}
|
|
@@ -1272,8 +1355,9 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1272
1355
|
externalTrace,
|
|
1273
1356
|
completed
|
|
1274
1357
|
};
|
|
1358
|
+
const finalized = finalizeTracePayload(traceData);
|
|
1275
1359
|
try {
|
|
1276
|
-
this.httpClient.sendExternalTrace(
|
|
1360
|
+
this.httpClient.sendExternalTrace(finalized);
|
|
1277
1361
|
} catch {
|
|
1278
1362
|
}
|
|
1279
1363
|
}
|
|
@@ -1911,7 +1995,6 @@ var LANGGRAPH_METADATA_KEYS = [
|
|
|
1911
1995
|
function nowIso2() {
|
|
1912
1996
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
1913
1997
|
}
|
|
1914
|
-
var safeSerialize2 = toJsonSafe;
|
|
1915
1998
|
function convertMessage(message) {
|
|
1916
1999
|
if (typeof message !== "object" || message === null) {
|
|
1917
2000
|
return { role: "unknown", content: String(message) };
|
|
@@ -2156,6 +2239,7 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
2156
2239
|
}
|
|
2157
2240
|
const lgMetadata = extractLangGraphMetadata(metadata);
|
|
2158
2241
|
const contexts = Object.keys(lgMetadata).length > 0 ? [lgMetadata] : [];
|
|
2242
|
+
const { safe: safeInput, dropped: inputDropped } = toJsonSafeReport(inputData);
|
|
2159
2243
|
const spanInfo = {
|
|
2160
2244
|
spanId: runId,
|
|
2161
2245
|
traceId: invocation.traceId,
|
|
@@ -2164,9 +2248,12 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
2164
2248
|
startedAt: nowIso2(),
|
|
2165
2249
|
name,
|
|
2166
2250
|
type: spanType,
|
|
2167
|
-
input:
|
|
2251
|
+
input: safeInput,
|
|
2168
2252
|
contexts
|
|
2169
2253
|
};
|
|
2254
|
+
if (inputDropped.length > 0) {
|
|
2255
|
+
spanInfo.dropped = [...inputDropped];
|
|
2256
|
+
}
|
|
2170
2257
|
if (willHide) {
|
|
2171
2258
|
spanInfo.hidden = true;
|
|
2172
2259
|
}
|
|
@@ -2180,7 +2267,11 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
2180
2267
|
}
|
|
2181
2268
|
this.runToSpan.delete(runId);
|
|
2182
2269
|
spanInfo.endedAt = nowIso2();
|
|
2183
|
-
|
|
2270
|
+
const { safe: safeOutput, dropped: outputDropped } = toJsonSafeReport(output);
|
|
2271
|
+
spanInfo.output = safeOutput;
|
|
2272
|
+
if (outputDropped.length > 0) {
|
|
2273
|
+
spanInfo.dropped = [...spanInfo.dropped ?? [], ...outputDropped];
|
|
2274
|
+
}
|
|
2184
2275
|
if (error !== void 0) {
|
|
2185
2276
|
spanInfo.error = error;
|
|
2186
2277
|
}
|
|
@@ -2231,8 +2322,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
2231
2322
|
sourceTraceId: spanInfo.traceId,
|
|
2232
2323
|
rawSpan
|
|
2233
2324
|
};
|
|
2325
|
+
const finalized = finalizeSpanPayload(payload, spanInfo.dropped);
|
|
2234
2326
|
try {
|
|
2235
|
-
this.httpClient.sendExternalSpan(
|
|
2327
|
+
this.httpClient.sendExternalSpan(finalized);
|
|
2236
2328
|
} catch {
|
|
2237
2329
|
}
|
|
2238
2330
|
}
|
|
@@ -2250,8 +2342,9 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
2250
2342
|
},
|
|
2251
2343
|
completed
|
|
2252
2344
|
};
|
|
2345
|
+
const finalized = finalizeTracePayload(traceData);
|
|
2253
2346
|
try {
|
|
2254
|
-
this.httpClient.sendExternalTrace(
|
|
2347
|
+
this.httpClient.sendExternalTrace(finalized);
|
|
2255
2348
|
} catch {
|
|
2256
2349
|
}
|
|
2257
2350
|
}
|
|
@@ -2766,7 +2859,7 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
2766
2859
|
if (errors.length > 0) {
|
|
2767
2860
|
payload.errors = errors;
|
|
2768
2861
|
}
|
|
2769
|
-
return payload;
|
|
2862
|
+
return finalizeSpanPayload(payload);
|
|
2770
2863
|
}
|
|
2771
2864
|
/**
|
|
2772
2865
|
* Send span to Bitfab API (fire-and-forget).
|