bitfab 0.57.8 → 0.58.1
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-CPVOJHEH.js → chunk-4GTG3VPY.js} +2 -2
- package/dist/{chunk-2E7Q52KB.js → chunk-756R63DD.js} +21 -113
- package/dist/chunk-756R63DD.js.map +1 -0
- package/dist/{chunk-HKRCT4OE.js → chunk-EQLQVY2O.js} +23 -18
- package/dist/chunk-EQLQVY2O.js.map +1 -0
- package/dist/{chunk-SSEXCJHP.js → chunk-QSLJE2DR.js} +3 -3
- package/dist/{chunk-GUE4W5QV.js → chunk-UETYTJEO.js} +5 -14
- package/dist/chunk-UETYTJEO.js.map +1 -0
- package/dist/{http-2EGLRQUQ.js → http-7BKMLT23.js} +2 -2
- package/dist/{http-PDTDCLCH.js → http-LAXF2MGX.js} +2 -2
- package/dist/index.cjs +36 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.js +3 -3
- package/dist/node.cjs +36 -121
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-BWUZ2NDQ.js → replay-FMSQGE2H.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-2E7Q52KB.js.map +0 -1
- package/dist/chunk-GUE4W5QV.js.map +0 -1
- package/dist/chunk-HKRCT4OE.js.map +0 -1
- /package/dist/{chunk-CPVOJHEH.js.map → chunk-4GTG3VPY.js.map} +0 -0
- /package/dist/{chunk-SSEXCJHP.js.map → chunk-QSLJE2DR.js.map} +0 -0
- /package/dist/{http-2EGLRQUQ.js.map → http-7BKMLT23.js.map} +0 -0
- /package/dist/{http-PDTDCLCH.js.map → http-LAXF2MGX.js.map} +0 -0
- /package/dist/{replay-BWUZ2NDQ.js.map → replay-FMSQGE2H.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
replayContextReady,
|
|
7
7
|
runWithReplayContext,
|
|
8
8
|
warnOnce
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EQLQVY2O.js";
|
|
10
10
|
import {
|
|
11
11
|
runWithCaptureSuppressed
|
|
12
12
|
} from "./chunk-VCRFFCLY.js";
|
|
@@ -1263,4 +1263,4 @@ export {
|
|
|
1263
1263
|
sleepForReplayPersistence,
|
|
1264
1264
|
replay
|
|
1265
1265
|
};
|
|
1266
|
-
//# sourceMappingURL=chunk-
|
|
1266
|
+
//# sourceMappingURL=chunk-4GTG3VPY.js.map
|
|
@@ -17,10 +17,11 @@ import {
|
|
|
17
17
|
serializeValue,
|
|
18
18
|
toJsonSafe,
|
|
19
19
|
toJsonSafeReport
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-4GTG3VPY.js";
|
|
21
21
|
import {
|
|
22
22
|
BitfabError,
|
|
23
23
|
CONTENT_OFF_KEY,
|
|
24
|
+
DECLARED_NODE_FIELD,
|
|
24
25
|
DEFAULT_SERVICE_URL,
|
|
25
26
|
HttpClient,
|
|
26
27
|
MixedTracingError,
|
|
@@ -33,11 +34,9 @@ import {
|
|
|
33
34
|
makeSpanOrigin,
|
|
34
35
|
readEnv,
|
|
35
36
|
recordCallerTraceMetadata,
|
|
36
|
-
recordedByFramework,
|
|
37
37
|
retireTraceMetadata,
|
|
38
|
-
traceIdOf,
|
|
39
38
|
warnOnce
|
|
40
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-EQLQVY2O.js";
|
|
41
40
|
import {
|
|
42
41
|
__privateAdd,
|
|
43
42
|
__privateGet,
|
|
@@ -296,11 +295,6 @@ var BitfabClaudeAgentHandler = class {
|
|
|
296
295
|
}
|
|
297
296
|
this.runToSpan.set(spanId, spanInfo);
|
|
298
297
|
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
299
|
-
this.httpClient.reserveFrameworkSpan(
|
|
300
|
-
spanInfo.traceId,
|
|
301
|
-
spanInfo.spanId,
|
|
302
|
-
spanInfo.parentId
|
|
303
|
-
);
|
|
304
298
|
return spanInfo;
|
|
305
299
|
}
|
|
306
300
|
completeSpan(spanId, output, error, extraContexts) {
|
|
@@ -580,11 +574,6 @@ var BitfabClaudeAgentHandler = class {
|
|
|
580
574
|
this.conversationHistory.push(...this.pendingMessages);
|
|
581
575
|
this.pendingMessages = [];
|
|
582
576
|
this.currentLlmSpanId = randomUuid();
|
|
583
|
-
this.httpClient.reserveFrameworkSpan(
|
|
584
|
-
this.ensureTrace(),
|
|
585
|
-
this.currentLlmSpanId,
|
|
586
|
-
this.getParentId()
|
|
587
|
-
);
|
|
588
577
|
this.currentLlmMessageId = messageId ?? null;
|
|
589
578
|
this.currentLlmContent = [];
|
|
590
579
|
this.currentLlmModel = inner.model ?? null;
|
|
@@ -1825,11 +1814,6 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1825
1814
|
this.runToSpan.set(runId, spanInfo);
|
|
1826
1815
|
if (spanInfo.hidden !== true) {
|
|
1827
1816
|
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
1828
|
-
this.httpClient.reserveFrameworkSpan(
|
|
1829
|
-
spanInfo.traceId,
|
|
1830
|
-
spanInfo.spanId,
|
|
1831
|
-
spanInfo.parentId
|
|
1832
|
-
);
|
|
1833
1817
|
}
|
|
1834
1818
|
if (isRootInvocation) {
|
|
1835
1819
|
this.sendTraceStart(spanInfo);
|
|
@@ -3349,11 +3333,6 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
3349
3333
|
const mapping = this.activeSpanMappings[span.traceId];
|
|
3350
3334
|
const traceId = mapping?.traceId ?? span.traceId;
|
|
3351
3335
|
this.httpClient.traceCompletion.start(traceId, span.spanId);
|
|
3352
|
-
this.httpClient.reserveFrameworkSpan(
|
|
3353
|
-
traceId,
|
|
3354
|
-
span.spanId,
|
|
3355
|
-
span.parentId ?? mapping?.spanId
|
|
3356
|
-
);
|
|
3357
3336
|
}
|
|
3358
3337
|
}
|
|
3359
3338
|
/**
|
|
@@ -3741,56 +3720,9 @@ var BitfabVercelAiHandler = class {
|
|
|
3741
3720
|
// src/client.ts
|
|
3742
3721
|
var TRUNCATION_LIMIT_ORDER = [
|
|
3743
3722
|
"max_depth",
|
|
3744
|
-
"max_spans",
|
|
3745
3723
|
"max_captured_subtree_spans"
|
|
3746
3724
|
];
|
|
3747
3725
|
var activeTraceStates = /* @__PURE__ */ new Map();
|
|
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;
|
|
3758
|
-
}
|
|
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;
|
|
3776
|
-
}
|
|
3777
|
-
refuseFrameworkSpan(traceId, spanId);
|
|
3778
|
-
spanBudget?.truncate("max_spans");
|
|
3779
|
-
}
|
|
3780
|
-
function isRefusedFrameworkSpan(payload) {
|
|
3781
|
-
if (!recordedByFramework(payload)) {
|
|
3782
|
-
return false;
|
|
3783
|
-
}
|
|
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
3726
|
function truncationMetadata(truncation) {
|
|
3795
3727
|
if (truncation === void 0 || truncation.limits.size === 0) {
|
|
3796
3728
|
return void 0;
|
|
@@ -4180,7 +4112,6 @@ function readBooleanEnv(name) {
|
|
|
4180
4112
|
return void 0;
|
|
4181
4113
|
}
|
|
4182
4114
|
var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
|
|
4183
|
-
var DEFAULT_AUTO_TRACE_MAX_SPANS = 1e4;
|
|
4184
4115
|
var DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS = 500;
|
|
4185
4116
|
function spanOwnerName(receiver) {
|
|
4186
4117
|
if (typeof receiver === "function") {
|
|
@@ -4248,7 +4179,6 @@ var Bitfab = class {
|
|
|
4248
4179
|
config.simulationPlan ?? true
|
|
4249
4180
|
);
|
|
4250
4181
|
this.httpClient.externalSpanTransform = (payload, submit, drop) => this.applySimulationPlan(payload, submit, drop);
|
|
4251
|
-
this.httpClient.frameworkSpanStart = reserveFrameworkSpan;
|
|
4252
4182
|
this.httpClient.externalTraceTransform = (payload, submit) => this.simulationPlan.sendTrace(payload, submit);
|
|
4253
4183
|
this.httpClient.releaseHeldExternalSpans = (timeoutMs) => this.simulationPlan.release(timeoutMs);
|
|
4254
4184
|
this.httpClient.stopSimulationPlan = () => this.simulationPlan.stop();
|
|
@@ -4411,21 +4341,9 @@ var Bitfab = class {
|
|
|
4411
4341
|
options.maxDepth,
|
|
4412
4342
|
DEFAULT_AUTO_TRACE_MAX_DEPTH
|
|
4413
4343
|
);
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
);
|
|
4418
|
-
}
|
|
4419
|
-
const maxSpans = autoTraceLimit(
|
|
4420
|
-
options.maxSpans,
|
|
4421
|
-
DEFAULT_AUTO_TRACE_MAX_SPANS
|
|
4422
|
-
);
|
|
4423
|
-
const maxCapturedSubtreeSpans = Math.min(
|
|
4424
|
-
autoTraceLimit(
|
|
4425
|
-
options.maxCapturedSubtreeSpans,
|
|
4426
|
-
DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS
|
|
4427
|
-
),
|
|
4428
|
-
maxSpans
|
|
4344
|
+
const maxCapturedSubtreeSpans = autoTraceLimit(
|
|
4345
|
+
options.maxCapturedSubtreeSpans,
|
|
4346
|
+
DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS
|
|
4429
4347
|
);
|
|
4430
4348
|
const rootIsAsync = fn.constructor.name === "AsyncFunction";
|
|
4431
4349
|
const excluded = new Set(options.exclude ?? []);
|
|
@@ -4456,19 +4374,11 @@ var Bitfab = class {
|
|
|
4456
4374
|
truncation.droppedSpans += 1;
|
|
4457
4375
|
warnOnce(
|
|
4458
4376
|
`auto-trace-truncated:${traceFunctionKey}`,
|
|
4459
|
-
`"${traceFunctionKey}" hit an automatic subtree capture limit (maxDepth=${maxDepth}, maxCapturedSubtreeSpans=${maxCapturedSubtreeSpans}
|
|
4377
|
+
`"${traceFunctionKey}" hit an automatic subtree capture limit (maxDepth=${maxDepth}, maxCapturedSubtreeSpans=${maxCapturedSubtreeSpans}); its trace is incomplete. Raise the limits, declare the calls you need with node(), or narrow the subtree with exclude.`
|
|
4460
4378
|
);
|
|
4461
4379
|
};
|
|
4462
|
-
const spanBudget = {
|
|
4463
|
-
spansUsed: 1,
|
|
4464
|
-
maxSpans,
|
|
4465
|
-
truncate
|
|
4466
|
-
};
|
|
4467
4380
|
if (rootTraceState !== void 0) {
|
|
4468
4381
|
rootTraceState.truncation = truncation;
|
|
4469
|
-
if (rootTraceState.spanBudget === void 0) {
|
|
4470
|
-
rootTraceState.spanBudget = spanBudget;
|
|
4471
|
-
}
|
|
4472
4382
|
}
|
|
4473
4383
|
const spanStackOf = (entry) => entry.spanStack;
|
|
4474
4384
|
const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
|
|
@@ -4504,16 +4414,16 @@ var Bitfab = class {
|
|
|
4504
4414
|
return innermost === void 0 ? traceFunctionKey : rootTraceFunctionKeyOfTrace(innermost.traceId, traceFunctionKey);
|
|
4505
4415
|
};
|
|
4506
4416
|
const recordsSpan = (entry, spanName, declared) => {
|
|
4507
|
-
const
|
|
4417
|
+
const contentOff = !declared && self.simulationPlan.contentOffNow(
|
|
4508
4418
|
rootTraceFunctionKeyOfEntry(entry),
|
|
4509
4419
|
spanName
|
|
4510
4420
|
);
|
|
4511
|
-
const
|
|
4421
|
+
const countsTowardCapturedSubtree = !declared && !contentOff;
|
|
4422
|
+
const refusedBy = entry.depth >= maxDepth ? "max_depth" : countsTowardCapturedSubtree && capturedSubtreeCount >= maxCapturedSubtreeSpans ? "max_captured_subtree_spans" : void 0;
|
|
4512
4423
|
if (refusedBy !== void 0) {
|
|
4513
4424
|
truncate(refusedBy);
|
|
4514
4425
|
return false;
|
|
4515
4426
|
}
|
|
4516
|
-
spanBudget.spansUsed += 1;
|
|
4517
4427
|
if (countsTowardCapturedSubtree) {
|
|
4518
4428
|
capturedSubtreeCount += 1;
|
|
4519
4429
|
}
|
|
@@ -4532,7 +4442,8 @@ var Bitfab = class {
|
|
|
4532
4442
|
return clearAutoTraceNodeConfiguration(invokeFn);
|
|
4533
4443
|
}
|
|
4534
4444
|
const spanName = nodeConfiguration?.name ?? definition.name;
|
|
4535
|
-
|
|
4445
|
+
const declaredNode = nodeConfiguration !== void 0;
|
|
4446
|
+
if (!recordsSpan(entry, spanName, declaredNode)) {
|
|
4536
4447
|
return invokeWithoutNode();
|
|
4537
4448
|
}
|
|
4538
4449
|
const mockOnReplay = nodeConfiguration?.mockOnReplay ?? options.mockOnReplayDefault;
|
|
@@ -4545,6 +4456,7 @@ var Bitfab = class {
|
|
|
4545
4456
|
functionId: definition.id,
|
|
4546
4457
|
captureContent: true,
|
|
4547
4458
|
autoTraceDefinition: definition,
|
|
4459
|
+
...declaredNode && { declaredNode },
|
|
4548
4460
|
...nodeConfiguration?.testRunId !== void 0 && {
|
|
4549
4461
|
testRunId: nodeConfiguration.testRunId
|
|
4550
4462
|
},
|
|
@@ -4574,6 +4486,7 @@ var Bitfab = class {
|
|
|
4574
4486
|
surface: "opt-out",
|
|
4575
4487
|
instrumentation: "trace",
|
|
4576
4488
|
captureContent: true,
|
|
4489
|
+
declaredNode: true,
|
|
4577
4490
|
...link !== void 0 && { nestedTrace: link }
|
|
4578
4491
|
};
|
|
4579
4492
|
return openChild(entry, childOptions, inputs, false, invokeFn);
|
|
@@ -4645,10 +4558,6 @@ var Bitfab = class {
|
|
|
4645
4558
|
return autoTraceRoot;
|
|
4646
4559
|
}
|
|
4647
4560
|
applySimulationPlan(payload, submit, drop) {
|
|
4648
|
-
if (isRefusedFrameworkSpan(payload)) {
|
|
4649
|
-
drop();
|
|
4650
|
-
return;
|
|
4651
|
-
}
|
|
4652
4561
|
this.simulationPlan.send(
|
|
4653
4562
|
payload,
|
|
4654
4563
|
rootTraceFunctionKeyOf(payload),
|
|
@@ -5323,9 +5232,6 @@ var Bitfab = class {
|
|
|
5323
5232
|
registeredTraceId = traceId;
|
|
5324
5233
|
}
|
|
5325
5234
|
self.httpClient.traceCompletion.start(traceId, spanId);
|
|
5326
|
-
if (isFrameworkInstrumentation(options.instrumentation)) {
|
|
5327
|
-
reserveFrameworkSpan(traceId, spanId, parentSpanId);
|
|
5328
|
-
}
|
|
5329
5235
|
startedSpan = { traceId, spanId };
|
|
5330
5236
|
const functionName = fn.name !== "" ? fn.name : void 0;
|
|
5331
5237
|
const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
|
|
@@ -5347,6 +5253,7 @@ var Bitfab = class {
|
|
|
5347
5253
|
functionId: options.functionId,
|
|
5348
5254
|
captureContent: options.captureContent ?? true,
|
|
5349
5255
|
autoTraceDefinition: options.autoTraceDefinition,
|
|
5256
|
+
declaredNode: options.declaredNode === true,
|
|
5350
5257
|
nestedTrace: options.nestedTrace,
|
|
5351
5258
|
enclosingTrace: options.enclosingTrace
|
|
5352
5259
|
};
|
|
@@ -5872,7 +5779,7 @@ var Bitfab = class {
|
|
|
5872
5779
|
* Queued on the client's span transport; delivery is the transport's job.
|
|
5873
5780
|
*/
|
|
5874
5781
|
sendWrapperSpan(params) {
|
|
5875
|
-
const contentOff = this.contentOffBySimulationPlan(params);
|
|
5782
|
+
const contentOff = params.declaredNode !== true && this.contentOffBySimulationPlan(params);
|
|
5876
5783
|
const buildsContent = params.captureContent && !contentOff;
|
|
5877
5784
|
const serializedInputs = buildsContent ? serializeValue(params.inputs) : void 0;
|
|
5878
5785
|
const serializedResult = buildsContent ? serializeValue(params.result) : void 0;
|
|
@@ -5946,6 +5853,7 @@ var Bitfab = class {
|
|
|
5946
5853
|
...params.rootTraceFunctionKey !== void 0 && {
|
|
5947
5854
|
[ROOT_TRACE_FUNCTION_KEY_FIELD]: params.rootTraceFunctionKey
|
|
5948
5855
|
},
|
|
5856
|
+
...params.declaredNode === true && { [DECLARED_NODE_FIELD]: true },
|
|
5949
5857
|
rawSpan: externalSpan,
|
|
5950
5858
|
...params.testRunId && { testRunId: params.testRunId },
|
|
5951
5859
|
...params.mocked && { mocked: true },
|
|
@@ -6093,7 +6001,7 @@ var Bitfab = class {
|
|
|
6093
6001
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
6094
6002
|
} finally {
|
|
6095
6003
|
try {
|
|
6096
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
6004
|
+
const { flushTraces: flushTraces2 } = await import("./http-7BKMLT23.js");
|
|
6097
6005
|
await flushTraces2(3e4);
|
|
6098
6006
|
} finally {
|
|
6099
6007
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -6152,7 +6060,7 @@ var Bitfab = class {
|
|
|
6152
6060
|
`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.`
|
|
6153
6061
|
);
|
|
6154
6062
|
}
|
|
6155
|
-
const { replay: doReplay } = await import("./replay-
|
|
6063
|
+
const { replay: doReplay } = await import("./replay-FMSQGE2H.js");
|
|
6156
6064
|
return doReplay(
|
|
6157
6065
|
this.httpClient,
|
|
6158
6066
|
this.serviceUrl,
|
|
@@ -6472,7 +6380,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
6472
6380
|
sessionId: seedCase.sessionId
|
|
6473
6381
|
})
|
|
6474
6382
|
);
|
|
6475
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
6383
|
+
const { flushTraces: flushTraces2 } = await import("./http-7BKMLT23.js");
|
|
6476
6384
|
await flushTraces2(3e4);
|
|
6477
6385
|
return { pipeline, traceFunctionKey, traceIds };
|
|
6478
6386
|
}
|
|
@@ -6511,4 +6419,4 @@ export {
|
|
|
6511
6419
|
reseedFromRegistry,
|
|
6512
6420
|
seedFromRegistry
|
|
6513
6421
|
};
|
|
6514
|
-
//# sourceMappingURL=chunk-
|
|
6422
|
+
//# sourceMappingURL=chunk-756R63DD.js.map
|