bitfab 0.57.6 → 0.57.8
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-ICL6RSND.js → chunk-2E7Q52KB.js} +131 -54
- package/dist/chunk-2E7Q52KB.js.map +1 -0
- package/dist/{chunk-GT4IDECP.js → chunk-CPVOJHEH.js} +2 -2
- package/dist/{chunk-EC7EZXDV.js → chunk-GUE4W5QV.js} +27 -14
- package/dist/chunk-GUE4W5QV.js.map +1 -0
- package/dist/{chunk-UTBA3ASY.js → chunk-HKRCT4OE.js} +37 -17
- package/dist/chunk-HKRCT4OE.js.map +1 -0
- package/dist/{chunk-IF7GVAWV.js → chunk-SSEXCJHP.js} +3 -3
- package/dist/{http-EYKH2EPD.js → http-2EGLRQUQ.js} +2 -2
- package/dist/{http-U3V6WNLO.js → http-PDTDCLCH.js} +2 -2
- package/dist/index.cjs +161 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -3
- package/dist/node.cjs +161 -64
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-W2KNVMMJ.js → replay-BWUZ2NDQ.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-EC7EZXDV.js.map +0 -1
- package/dist/chunk-ICL6RSND.js.map +0 -1
- package/dist/chunk-UTBA3ASY.js.map +0 -1
- /package/dist/{chunk-GT4IDECP.js.map → chunk-CPVOJHEH.js.map} +0 -0
- /package/dist/{chunk-IF7GVAWV.js.map → chunk-SSEXCJHP.js.map} +0 -0
- /package/dist/{http-EYKH2EPD.js.map → http-2EGLRQUQ.js.map} +0 -0
- /package/dist/{http-U3V6WNLO.js.map → http-PDTDCLCH.js.map} +0 -0
- /package/dist/{replay-W2KNVMMJ.js.map → replay-BWUZ2NDQ.js.map} +0 -0
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
serializeValue,
|
|
18
18
|
toJsonSafe,
|
|
19
19
|
toJsonSafeReport
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-CPVOJHEH.js";
|
|
21
21
|
import {
|
|
22
22
|
BitfabError,
|
|
23
23
|
CONTENT_OFF_KEY,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
retireTraceMetadata,
|
|
38
38
|
traceIdOf,
|
|
39
39
|
warnOnce
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-HKRCT4OE.js";
|
|
41
41
|
import {
|
|
42
42
|
__privateAdd,
|
|
43
43
|
__privateGet,
|
|
@@ -296,6 +296,11 @@ var BitfabClaudeAgentHandler = class {
|
|
|
296
296
|
}
|
|
297
297
|
this.runToSpan.set(spanId, spanInfo);
|
|
298
298
|
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
299
|
+
this.httpClient.reserveFrameworkSpan(
|
|
300
|
+
spanInfo.traceId,
|
|
301
|
+
spanInfo.spanId,
|
|
302
|
+
spanInfo.parentId
|
|
303
|
+
);
|
|
299
304
|
return spanInfo;
|
|
300
305
|
}
|
|
301
306
|
completeSpan(spanId, output, error, extraContexts) {
|
|
@@ -575,6 +580,11 @@ var BitfabClaudeAgentHandler = class {
|
|
|
575
580
|
this.conversationHistory.push(...this.pendingMessages);
|
|
576
581
|
this.pendingMessages = [];
|
|
577
582
|
this.currentLlmSpanId = randomUuid();
|
|
583
|
+
this.httpClient.reserveFrameworkSpan(
|
|
584
|
+
this.ensureTrace(),
|
|
585
|
+
this.currentLlmSpanId,
|
|
586
|
+
this.getParentId()
|
|
587
|
+
);
|
|
578
588
|
this.currentLlmMessageId = messageId ?? null;
|
|
579
589
|
this.currentLlmContent = [];
|
|
580
590
|
this.currentLlmModel = inner.model ?? null;
|
|
@@ -1815,6 +1825,11 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1815
1825
|
this.runToSpan.set(runId, spanInfo);
|
|
1816
1826
|
if (spanInfo.hidden !== true) {
|
|
1817
1827
|
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
1828
|
+
this.httpClient.reserveFrameworkSpan(
|
|
1829
|
+
spanInfo.traceId,
|
|
1830
|
+
spanInfo.spanId,
|
|
1831
|
+
spanInfo.parentId
|
|
1832
|
+
);
|
|
1818
1833
|
}
|
|
1819
1834
|
if (isRootInvocation) {
|
|
1820
1835
|
this.sendTraceStart(spanInfo);
|
|
@@ -3331,8 +3346,14 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
3331
3346
|
async onSpanStart(span) {
|
|
3332
3347
|
if (span.spanId !== void 0 && span.traceId !== null && span.traceId !== void 0) {
|
|
3333
3348
|
this.startedSpans.set(span.spanId, span.traceId);
|
|
3334
|
-
const
|
|
3349
|
+
const mapping = this.activeSpanMappings[span.traceId];
|
|
3350
|
+
const traceId = mapping?.traceId ?? span.traceId;
|
|
3335
3351
|
this.httpClient.traceCompletion.start(traceId, span.spanId);
|
|
3352
|
+
this.httpClient.reserveFrameworkSpan(
|
|
3353
|
+
traceId,
|
|
3354
|
+
span.spanId,
|
|
3355
|
+
span.parentId ?? mapping?.spanId
|
|
3356
|
+
);
|
|
3336
3357
|
}
|
|
3337
3358
|
}
|
|
3338
3359
|
/**
|
|
@@ -3718,22 +3739,68 @@ var BitfabVercelAiHandler = class {
|
|
|
3718
3739
|
};
|
|
3719
3740
|
|
|
3720
3741
|
// src/client.ts
|
|
3742
|
+
var TRUNCATION_LIMIT_ORDER = [
|
|
3743
|
+
"max_depth",
|
|
3744
|
+
"max_spans",
|
|
3745
|
+
"max_captured_subtree_spans"
|
|
3746
|
+
];
|
|
3721
3747
|
var activeTraceStates = /* @__PURE__ */ new Map();
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3748
|
+
var REFUSED_FRAMEWORK_SPAN_TRACES_RETAINED = 1024;
|
|
3749
|
+
var refusedFrameworkSpans = /* @__PURE__ */ new Map();
|
|
3750
|
+
function frameworkSpanRefused(traceId, spanId) {
|
|
3751
|
+
return refusedFrameworkSpans.get(traceId)?.has(spanId) === true;
|
|
3752
|
+
}
|
|
3753
|
+
function refuseFrameworkSpan(traceId, spanId) {
|
|
3754
|
+
const refused = refusedFrameworkSpans.get(traceId);
|
|
3755
|
+
if (refused !== void 0) {
|
|
3756
|
+
refused.add(spanId);
|
|
3757
|
+
return;
|
|
3725
3758
|
}
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3759
|
+
refusedFrameworkSpans.set(traceId, /* @__PURE__ */ new Set([spanId]));
|
|
3760
|
+
while (refusedFrameworkSpans.size > REFUSED_FRAMEWORK_SPAN_TRACES_RETAINED) {
|
|
3761
|
+
const oldest = refusedFrameworkSpans.keys().next();
|
|
3762
|
+
if (oldest.done) {
|
|
3763
|
+
return;
|
|
3764
|
+
}
|
|
3765
|
+
refusedFrameworkSpans.delete(oldest.value);
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
function reserveFrameworkSpan(traceId, spanId, parentSpanId) {
|
|
3769
|
+
const spanBudget = activeTraceStates.get(traceId)?.spanBudget;
|
|
3770
|
+
const parentRefused = parentSpanId !== null && frameworkSpanRefused(traceId, parentSpanId);
|
|
3771
|
+
if (!parentRefused && (spanBudget === void 0 || spanBudget.spansUsed < spanBudget.maxSpans)) {
|
|
3772
|
+
if (spanBudget !== void 0) {
|
|
3773
|
+
spanBudget.spansUsed += 1;
|
|
3774
|
+
}
|
|
3775
|
+
return;
|
|
3730
3776
|
}
|
|
3731
|
-
|
|
3732
|
-
|
|
3777
|
+
refuseFrameworkSpan(traceId, spanId);
|
|
3778
|
+
spanBudget?.truncate("max_spans");
|
|
3779
|
+
}
|
|
3780
|
+
function isRefusedFrameworkSpan(payload) {
|
|
3781
|
+
if (!recordedByFramework(payload)) {
|
|
3733
3782
|
return false;
|
|
3734
3783
|
}
|
|
3735
|
-
|
|
3736
|
-
|
|
3784
|
+
const rawSpan = payload.rawSpan;
|
|
3785
|
+
const spanId = rawSpan?.id;
|
|
3786
|
+
if (typeof spanId !== "string") {
|
|
3787
|
+
return false;
|
|
3788
|
+
}
|
|
3789
|
+
const traceIds = [payload.sourceTraceId, traceIdOf(payload)];
|
|
3790
|
+
return traceIds.some(
|
|
3791
|
+
(traceId) => typeof traceId === "string" && frameworkSpanRefused(traceId, spanId)
|
|
3792
|
+
);
|
|
3793
|
+
}
|
|
3794
|
+
function truncationMetadata(truncation) {
|
|
3795
|
+
if (truncation === void 0 || truncation.limits.size === 0) {
|
|
3796
|
+
return void 0;
|
|
3797
|
+
}
|
|
3798
|
+
return {
|
|
3799
|
+
"bitfab.truncated_by": TRUNCATION_LIMIT_ORDER.filter(
|
|
3800
|
+
(limit) => truncation.limits.has(limit)
|
|
3801
|
+
).join(","),
|
|
3802
|
+
"bitfab.dropped_spans": truncation.droppedSpans
|
|
3803
|
+
};
|
|
3737
3804
|
}
|
|
3738
3805
|
function rootTraceFunctionKeyOfTrace(traceId, fallback) {
|
|
3739
3806
|
return activeTraceStates.get(traceId)?.traceFunctionKey ?? fallback;
|
|
@@ -4113,9 +4180,8 @@ function readBooleanEnv(name) {
|
|
|
4113
4180
|
return void 0;
|
|
4114
4181
|
}
|
|
4115
4182
|
var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
|
|
4116
|
-
var DEFAULT_AUTO_TRACE_MAX_SPANS =
|
|
4117
|
-
var DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS =
|
|
4118
|
-
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
4183
|
+
var DEFAULT_AUTO_TRACE_MAX_SPANS = 1e4;
|
|
4184
|
+
var DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS = 500;
|
|
4119
4185
|
function spanOwnerName(receiver) {
|
|
4120
4186
|
if (typeof receiver === "function") {
|
|
4121
4187
|
return receiver.name !== "" ? receiver.name : void 0;
|
|
@@ -4181,7 +4247,8 @@ var Bitfab = class {
|
|
|
4181
4247
|
this.httpClient,
|
|
4182
4248
|
config.simulationPlan ?? true
|
|
4183
4249
|
);
|
|
4184
|
-
this.httpClient.externalSpanTransform = (payload, submit) => this.applySimulationPlan(payload, submit);
|
|
4250
|
+
this.httpClient.externalSpanTransform = (payload, submit, drop) => this.applySimulationPlan(payload, submit, drop);
|
|
4251
|
+
this.httpClient.frameworkSpanStart = reserveFrameworkSpan;
|
|
4185
4252
|
this.httpClient.externalTraceTransform = (payload, submit) => this.simulationPlan.sendTrace(payload, submit);
|
|
4186
4253
|
this.httpClient.releaseHeldExternalSpans = (timeoutMs) => this.simulationPlan.release(timeoutMs);
|
|
4187
4254
|
this.httpClient.stopSimulationPlan = () => this.simulationPlan.stop();
|
|
@@ -4377,35 +4444,31 @@ var Bitfab = class {
|
|
|
4377
4444
|
function(...args) {
|
|
4378
4445
|
self.simulationPlan.refresh();
|
|
4379
4446
|
let capturedSubtreeCount = 0;
|
|
4380
|
-
|
|
4381
|
-
const
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
maxCapturedSubtreeSpans
|
|
4391
|
-
}
|
|
4392
|
-
});
|
|
4393
|
-
}
|
|
4447
|
+
const rootSpanStack = getSpanStack();
|
|
4448
|
+
const rootSpan = rootSpanStack[rootSpanStack.length - 1];
|
|
4449
|
+
const rootTraceState = rootSpan === void 0 ? void 0 : activeTraceStates.get(rootSpan.traceId);
|
|
4450
|
+
const truncation = rootTraceState?.truncation ?? {
|
|
4451
|
+
limits: /* @__PURE__ */ new Set(),
|
|
4452
|
+
droppedSpans: 0
|
|
4453
|
+
};
|
|
4454
|
+
const truncate = (limit) => {
|
|
4455
|
+
truncation.limits.add(limit);
|
|
4456
|
+
truncation.droppedSpans += 1;
|
|
4394
4457
|
warnOnce(
|
|
4395
4458
|
`auto-trace-truncated:${traceFunctionKey}`,
|
|
4396
4459
|
`"${traceFunctionKey}" hit an automatic subtree capture limit (maxDepth=${maxDepth}, maxCapturedSubtreeSpans=${maxCapturedSubtreeSpans}, maxSpans=${maxSpans}); its trace is incomplete. Raise the limits, declare the calls you need with node(), or narrow the subtree with exclude.`
|
|
4397
4460
|
);
|
|
4398
4461
|
};
|
|
4399
|
-
const rootSpanStack = getSpanStack();
|
|
4400
4462
|
const spanBudget = {
|
|
4401
4463
|
spansUsed: 1,
|
|
4402
4464
|
maxSpans,
|
|
4403
|
-
truncate
|
|
4465
|
+
truncate
|
|
4404
4466
|
};
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4467
|
+
if (rootTraceState !== void 0) {
|
|
4468
|
+
rootTraceState.truncation = truncation;
|
|
4469
|
+
if (rootTraceState.spanBudget === void 0) {
|
|
4470
|
+
rootTraceState.spanBudget = spanBudget;
|
|
4471
|
+
}
|
|
4409
4472
|
}
|
|
4410
4473
|
const spanStackOf = (entry) => entry.spanStack;
|
|
4411
4474
|
const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
|
|
@@ -4445,15 +4508,16 @@ var Bitfab = class {
|
|
|
4445
4508
|
rootTraceFunctionKeyOfEntry(entry),
|
|
4446
4509
|
spanName
|
|
4447
4510
|
);
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4511
|
+
const refusedBy = entry.depth >= maxDepth ? "max_depth" : spanBudget.spansUsed >= maxSpans ? "max_spans" : countsTowardCapturedSubtree && capturedSubtreeCount >= maxCapturedSubtreeSpans ? "max_captured_subtree_spans" : void 0;
|
|
4512
|
+
if (refusedBy !== void 0) {
|
|
4513
|
+
truncate(refusedBy);
|
|
4514
|
+
return false;
|
|
4515
|
+
}
|
|
4516
|
+
spanBudget.spansUsed += 1;
|
|
4517
|
+
if (countsTowardCapturedSubtree) {
|
|
4518
|
+
capturedSubtreeCount += 1;
|
|
4454
4519
|
}
|
|
4455
|
-
|
|
4456
|
-
return false;
|
|
4520
|
+
return true;
|
|
4457
4521
|
};
|
|
4458
4522
|
const autoTraceContext = {
|
|
4459
4523
|
traceFunctionKey,
|
|
@@ -4580,11 +4644,17 @@ var Bitfab = class {
|
|
|
4580
4644
|
Object.defineProperty(autoTraceRoot, "_bitfabWrappedFn", { value: fn });
|
|
4581
4645
|
return autoTraceRoot;
|
|
4582
4646
|
}
|
|
4583
|
-
applySimulationPlan(payload, submit) {
|
|
4584
|
-
if (
|
|
4647
|
+
applySimulationPlan(payload, submit, drop) {
|
|
4648
|
+
if (isRefusedFrameworkSpan(payload)) {
|
|
4649
|
+
drop();
|
|
4585
4650
|
return;
|
|
4586
4651
|
}
|
|
4587
|
-
this.simulationPlan.send(
|
|
4652
|
+
this.simulationPlan.send(
|
|
4653
|
+
payload,
|
|
4654
|
+
rootTraceFunctionKeyOf(payload),
|
|
4655
|
+
submit,
|
|
4656
|
+
drop
|
|
4657
|
+
);
|
|
4588
4658
|
}
|
|
4589
4659
|
/**
|
|
4590
4660
|
* Flush and permanently close this client's tracing resources: its pending
|
|
@@ -5253,6 +5323,9 @@ var Bitfab = class {
|
|
|
5253
5323
|
registeredTraceId = traceId;
|
|
5254
5324
|
}
|
|
5255
5325
|
self.httpClient.traceCompletion.start(traceId, spanId);
|
|
5326
|
+
if (isFrameworkInstrumentation(options.instrumentation)) {
|
|
5327
|
+
reserveFrameworkSpan(traceId, spanId, parentSpanId);
|
|
5328
|
+
}
|
|
5256
5329
|
startedSpan = { traceId, spanId };
|
|
5257
5330
|
const functionName = fn.name !== "" ? fn.name : void 0;
|
|
5258
5331
|
const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
|
|
@@ -5297,6 +5370,10 @@ var Bitfab = class {
|
|
|
5297
5370
|
}
|
|
5298
5371
|
if (isRootSpan) {
|
|
5299
5372
|
const traceState = activeTraceStates.get(traceId);
|
|
5373
|
+
const truncated = truncationMetadata(traceState?.truncation);
|
|
5374
|
+
if (truncated !== void 0) {
|
|
5375
|
+
recordCallerTraceMetadata(traceId, truncated);
|
|
5376
|
+
}
|
|
5300
5377
|
self.sendTraceCompletion({
|
|
5301
5378
|
traceFunctionKey,
|
|
5302
5379
|
traceId,
|
|
@@ -5849,7 +5926,7 @@ var Bitfab = class {
|
|
|
5849
5926
|
...params.captureContent && params.contexts && params.contexts.length > 0 && {
|
|
5850
5927
|
contexts: params.contexts
|
|
5851
5928
|
},
|
|
5852
|
-
...
|
|
5929
|
+
...buildsContent && params.prompt !== void 0 && { prompt: params.prompt },
|
|
5853
5930
|
...contentOff && { [CONTENT_OFF_KEY]: true }
|
|
5854
5931
|
}
|
|
5855
5932
|
};
|
|
@@ -6016,7 +6093,7 @@ var Bitfab = class {
|
|
|
6016
6093
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
6017
6094
|
} finally {
|
|
6018
6095
|
try {
|
|
6019
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
6096
|
+
const { flushTraces: flushTraces2 } = await import("./http-2EGLRQUQ.js");
|
|
6020
6097
|
await flushTraces2(3e4);
|
|
6021
6098
|
} finally {
|
|
6022
6099
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -6075,7 +6152,7 @@ var Bitfab = class {
|
|
|
6075
6152
|
`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.`
|
|
6076
6153
|
);
|
|
6077
6154
|
}
|
|
6078
|
-
const { replay: doReplay } = await import("./replay-
|
|
6155
|
+
const { replay: doReplay } = await import("./replay-BWUZ2NDQ.js");
|
|
6079
6156
|
return doReplay(
|
|
6080
6157
|
this.httpClient,
|
|
6081
6158
|
this.serviceUrl,
|
|
@@ -6395,7 +6472,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
6395
6472
|
sessionId: seedCase.sessionId
|
|
6396
6473
|
})
|
|
6397
6474
|
);
|
|
6398
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
6475
|
+
const { flushTraces: flushTraces2 } = await import("./http-2EGLRQUQ.js");
|
|
6399
6476
|
await flushTraces2(3e4);
|
|
6400
6477
|
return { pipeline, traceFunctionKey, traceIds };
|
|
6401
6478
|
}
|
|
@@ -6434,4 +6511,4 @@ export {
|
|
|
6434
6511
|
reseedFromRegistry,
|
|
6435
6512
|
seedFromRegistry
|
|
6436
6513
|
};
|
|
6437
|
-
//# sourceMappingURL=chunk-
|
|
6514
|
+
//# sourceMappingURL=chunk-2E7Q52KB.js.map
|