bitfab 0.57.5 → 0.57.7
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-I5EG523G.js → chunk-IYGYSMSD.js} +3 -3
- package/dist/{chunk-WYNN6NY2.js → chunk-NRUFN7RZ.js} +26 -13
- package/dist/chunk-NRUFN7RZ.js.map +1 -0
- package/dist/{chunk-255I4PN4.js → chunk-P4R3NY2U.js} +36 -16
- package/dist/chunk-P4R3NY2U.js.map +1 -0
- package/dist/{chunk-VPZ2LTU6.js → chunk-VPU6U4WM.js} +2 -2
- package/dist/{chunk-YO3HKQX6.js → chunk-W3HLGZBO.js} +137 -67
- package/dist/chunk-W3HLGZBO.js.map +1 -0
- package/dist/{http-FQ76VRFF.js → http-AFLRC33F.js} +2 -2
- package/dist/{http-CHXMOVLK.js → http-ODKUB6M4.js} +2 -2
- package/dist/index.cjs +166 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +125 -127
- package/dist/index.d.ts +125 -127
- package/dist/index.js +3 -5
- package/dist/node.cjs +166 -77
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +3 -5
- package/dist/node.js.map +1 -1
- package/dist/{replay-CHM7OQ25.js → replay-2VGODDLA.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-255I4PN4.js.map +0 -1
- package/dist/chunk-WYNN6NY2.js.map +0 -1
- package/dist/chunk-YO3HKQX6.js.map +0 -1
- /package/dist/{chunk-I5EG523G.js.map → chunk-IYGYSMSD.js.map} +0 -0
- /package/dist/{chunk-VPZ2LTU6.js.map → chunk-VPU6U4WM.js.map} +0 -0
- /package/dist/{http-CHXMOVLK.js.map → http-AFLRC33F.js.map} +0 -0
- /package/dist/{http-FQ76VRFF.js.map → http-ODKUB6M4.js.map} +0 -0
- /package/dist/{replay-CHM7OQ25.js.map → replay-2VGODDLA.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NRUFN7RZ.js";
|
|
10
10
|
export {
|
|
11
11
|
BitfabError,
|
|
12
12
|
HttpClient,
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
parseRetryAfterMs,
|
|
17
17
|
serializePayloadBody
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=http-
|
|
19
|
+
//# sourceMappingURL=http-AFLRC33F.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-P4R3NY2U.js";
|
|
10
10
|
import "./chunk-VCRFFCLY.js";
|
|
11
11
|
export {
|
|
12
12
|
BitfabError,
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
parseRetryAfterMs,
|
|
18
18
|
serializePayloadBody
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=http-
|
|
20
|
+
//# sourceMappingURL=http-ODKUB6M4.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -51,7 +51,7 @@ var __version__, __packageName__;
|
|
|
51
51
|
var init_version_generated = __esm({
|
|
52
52
|
"src/version.generated.ts"() {
|
|
53
53
|
"use strict";
|
|
54
|
-
__version__ = "0.57.
|
|
54
|
+
__version__ = "0.57.7";
|
|
55
55
|
__packageName__ = "bitfab";
|
|
56
56
|
}
|
|
57
57
|
});
|
|
@@ -1064,7 +1064,13 @@ var init_simulationPlan = __esm({
|
|
|
1064
1064
|
DISABLE_SIMULATION_PLAN_ENV = "BITFAB_DISABLE_SIM_PLAN";
|
|
1065
1065
|
ROOT_TRACE_FUNCTION_KEY_FIELD = "rootTraceFunctionKey";
|
|
1066
1066
|
CONTENT_OFF_KEY = "content_off_by_simulation_plan";
|
|
1067
|
-
CONTENT_KEYS = [
|
|
1067
|
+
CONTENT_KEYS = [
|
|
1068
|
+
"input",
|
|
1069
|
+
"input_meta",
|
|
1070
|
+
"output",
|
|
1071
|
+
"output_meta",
|
|
1072
|
+
"prompt"
|
|
1073
|
+
];
|
|
1068
1074
|
SimulationPlan = class {
|
|
1069
1075
|
constructor(source, enabled = true) {
|
|
1070
1076
|
this.source = source;
|
|
@@ -1183,13 +1189,13 @@ var init_simulationPlan = __esm({
|
|
|
1183
1189
|
}
|
|
1184
1190
|
return this.loaded;
|
|
1185
1191
|
}
|
|
1186
|
-
send(payload, traceFunctionKey, submit) {
|
|
1192
|
+
send(payload, traceFunctionKey, submit, drop) {
|
|
1187
1193
|
this.refresh();
|
|
1188
1194
|
if (this.disabled() || traceFunctionKey === void 0 || spanNameOf(payload) === void 0 || recordedByFramework(payload)) {
|
|
1189
1195
|
submit(payload);
|
|
1190
1196
|
return;
|
|
1191
1197
|
}
|
|
1192
|
-
const entry = { payload, traceFunctionKey, submit };
|
|
1198
|
+
const entry = { payload, traceFunctionKey, submit, drop };
|
|
1193
1199
|
if (this.holdingForFirstRead()) {
|
|
1194
1200
|
this.hold(entry);
|
|
1195
1201
|
return;
|
|
@@ -1243,6 +1249,7 @@ var init_simulationPlan = __esm({
|
|
|
1243
1249
|
try {
|
|
1244
1250
|
entry.submit(this.payloadToSend(entry));
|
|
1245
1251
|
} catch (error) {
|
|
1252
|
+
entry.drop?.();
|
|
1246
1253
|
warnOnce(
|
|
1247
1254
|
"sim-plan-held-span-dropped",
|
|
1248
1255
|
`a span held for the sim plan was dropped when released: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -2573,23 +2580,21 @@ var init_http = __esm({
|
|
|
2573
2580
|
}
|
|
2574
2581
|
const deadline = Date.now() + Math.max(timeoutMs, 0);
|
|
2575
2582
|
this.closing = (async () => {
|
|
2576
|
-
|
|
2577
|
-
|
|
2583
|
+
liveHttpClients.delete(this);
|
|
2584
|
+
const settled2 = await this.settleDeferredWork(
|
|
2585
|
+
Math.max(0, deadline - Date.now())
|
|
2578
2586
|
);
|
|
2579
2587
|
this.stopSimulationPlan?.();
|
|
2588
|
+
this.closed = true;
|
|
2580
2589
|
this.externalSpanTransform = void 0;
|
|
2581
2590
|
this.externalTraceTransform = void 0;
|
|
2591
|
+
this.frameworkSpanStart = void 0;
|
|
2582
2592
|
this.releaseHeldExternalSpans = void 0;
|
|
2583
2593
|
this.stopSimulationPlan = void 0;
|
|
2584
|
-
liveHttpClients.delete(this);
|
|
2585
|
-
const settled2 = await this.settleDeferredWork(
|
|
2586
|
-
Math.max(0, deadline - Date.now())
|
|
2587
|
-
);
|
|
2588
|
-
this.closed = true;
|
|
2589
2594
|
const transport = this.traceTransport;
|
|
2590
2595
|
this.traceTransport = void 0;
|
|
2591
2596
|
const shutdownOk = await transport?.shutdown(Math.max(0, deadline - Date.now())) ?? true;
|
|
2592
|
-
return
|
|
2597
|
+
return settled2 && shutdownOk;
|
|
2593
2598
|
})();
|
|
2594
2599
|
return this.closing;
|
|
2595
2600
|
}
|
|
@@ -2690,8 +2695,7 @@ var init_http = __esm({
|
|
|
2690
2695
|
async getSimulationPlan() {
|
|
2691
2696
|
return this.get(
|
|
2692
2697
|
"/api/sdk/sim-plan",
|
|
2693
|
-
SIMULATION_PLAN_READ_TIMEOUT_MS
|
|
2694
|
-
{ Connection: "close" }
|
|
2698
|
+
SIMULATION_PLAN_READ_TIMEOUT_MS
|
|
2695
2699
|
);
|
|
2696
2700
|
}
|
|
2697
2701
|
async getTraceSpan(traceId, lookup) {
|
|
@@ -2767,19 +2771,35 @@ var init_http = __esm({
|
|
|
2767
2771
|
carrierMeta("internal_trace", body, void 0)
|
|
2768
2772
|
);
|
|
2769
2773
|
}
|
|
2774
|
+
reserveFrameworkSpan(traceId, spanId, parentSpanId) {
|
|
2775
|
+
try {
|
|
2776
|
+
this.frameworkSpanStart?.(traceId, spanId, parentSpanId ?? null);
|
|
2777
|
+
} catch (error) {
|
|
2778
|
+
warnOnce(
|
|
2779
|
+
"framework-span-reservation-failed",
|
|
2780
|
+
`a framework span could not be counted toward its trace's span limit: ${describeError(error)}`
|
|
2781
|
+
);
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2770
2784
|
sendExternalSpan(payload) {
|
|
2771
2785
|
const ref2 = carrierRef(payload);
|
|
2772
2786
|
if (ref2?.spanId !== void 0) {
|
|
2773
2787
|
this.traceCompletion.record(ref2.traceId, ref2.spanId);
|
|
2774
2788
|
}
|
|
2789
|
+
const drop = () => {
|
|
2790
|
+
if (ref2?.spanId !== void 0) {
|
|
2791
|
+
this.traceCompletion.abort(ref2.traceId, ref2.spanId);
|
|
2792
|
+
}
|
|
2793
|
+
};
|
|
2775
2794
|
const gate = this.externalSpanTransform;
|
|
2776
2795
|
if (gate === void 0) {
|
|
2777
2796
|
this.submitExternalSpan(payload);
|
|
2778
2797
|
return;
|
|
2779
2798
|
}
|
|
2780
2799
|
try {
|
|
2781
|
-
gate(payload, (ready) => this.submitExternalSpan(ready));
|
|
2800
|
+
gate(payload, (ready) => this.submitExternalSpan(ready), drop);
|
|
2782
2801
|
} catch (error) {
|
|
2802
|
+
drop();
|
|
2783
2803
|
warnDroppedExternalSpan(error);
|
|
2784
2804
|
}
|
|
2785
2805
|
}
|
|
@@ -4391,7 +4411,6 @@ __export(index_exports, {
|
|
|
4391
4411
|
NO_MOCK_OVERRIDE: () => NO_MOCK_OVERRIDE,
|
|
4392
4412
|
ReplayError: () => ReplayError,
|
|
4393
4413
|
SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
|
|
4394
|
-
TraceAssertionsClient: () => TraceAssertionsClient,
|
|
4395
4414
|
TracesClient: () => TracesClient,
|
|
4396
4415
|
__version__: () => __version__,
|
|
4397
4416
|
defineReplayRegistry: () => defineReplayRegistry,
|
|
@@ -4666,6 +4685,11 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4666
4685
|
}
|
|
4667
4686
|
this.runToSpan.set(spanId, spanInfo);
|
|
4668
4687
|
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
4688
|
+
this.httpClient.reserveFrameworkSpan(
|
|
4689
|
+
spanInfo.traceId,
|
|
4690
|
+
spanInfo.spanId,
|
|
4691
|
+
spanInfo.parentId
|
|
4692
|
+
);
|
|
4669
4693
|
return spanInfo;
|
|
4670
4694
|
}
|
|
4671
4695
|
completeSpan(spanId, output, error, extraContexts) {
|
|
@@ -4945,6 +4969,11 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4945
4969
|
this.conversationHistory.push(...this.pendingMessages);
|
|
4946
4970
|
this.pendingMessages = [];
|
|
4947
4971
|
this.currentLlmSpanId = randomUuid();
|
|
4972
|
+
this.httpClient.reserveFrameworkSpan(
|
|
4973
|
+
this.ensureTrace(),
|
|
4974
|
+
this.currentLlmSpanId,
|
|
4975
|
+
this.getParentId()
|
|
4976
|
+
);
|
|
4948
4977
|
this.currentLlmMessageId = messageId ?? null;
|
|
4949
4978
|
this.currentLlmContent = [];
|
|
4950
4979
|
this.currentLlmModel = inner.model ?? null;
|
|
@@ -5988,6 +6017,9 @@ init_http();
|
|
|
5988
6017
|
// src/labels.ts
|
|
5989
6018
|
var LABELS_PATH = "/api/sdk/traces/labels";
|
|
5990
6019
|
var HUMAN_LABELS_PATH = "/api/sdk/traces/labels/human";
|
|
6020
|
+
function labelEvidencePath(traceId, assertionId) {
|
|
6021
|
+
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions/${encodeURIComponent(assertionId)}/evidence`;
|
|
6022
|
+
}
|
|
5991
6023
|
var LabelsClient = class {
|
|
5992
6024
|
constructor(httpClient) {
|
|
5993
6025
|
this.httpClient = httpClient;
|
|
@@ -6036,6 +6068,11 @@ var LabelsClient = class {
|
|
|
6036
6068
|
);
|
|
6037
6069
|
return response.labels;
|
|
6038
6070
|
}
|
|
6071
|
+
/** Generate suggested evidence for an assertion on an original or replay trace. */
|
|
6072
|
+
async generateLabelEvidence(traceId, assertionId) {
|
|
6073
|
+
const response = await this.httpClient.get(labelEvidencePath(traceId, assertionId));
|
|
6074
|
+
return response.evidence;
|
|
6075
|
+
}
|
|
6039
6076
|
};
|
|
6040
6077
|
|
|
6041
6078
|
// src/langgraph.ts
|
|
@@ -6347,6 +6384,11 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6347
6384
|
this.runToSpan.set(runId, spanInfo);
|
|
6348
6385
|
if (spanInfo.hidden !== true) {
|
|
6349
6386
|
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
6387
|
+
this.httpClient.reserveFrameworkSpan(
|
|
6388
|
+
spanInfo.traceId,
|
|
6389
|
+
spanInfo.spanId,
|
|
6390
|
+
spanInfo.parentId
|
|
6391
|
+
);
|
|
6350
6392
|
}
|
|
6351
6393
|
if (isRootInvocation) {
|
|
6352
6394
|
this.sendTraceStart(spanInfo);
|
|
@@ -7750,23 +7792,9 @@ var SEARCH_PATH = "/api/sdk/traces/search";
|
|
|
7750
7792
|
function traceAssertionsPath(traceId, suffix = "") {
|
|
7751
7793
|
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
|
|
7752
7794
|
}
|
|
7753
|
-
function assertionEvidencePath(assertionId) {
|
|
7754
|
-
return `/api/sdk/traces/assertions/${encodeURIComponent(assertionId)}/evidence`;
|
|
7755
|
-
}
|
|
7756
|
-
var TraceAssertionsClient = class {
|
|
7757
|
-
constructor(httpClient) {
|
|
7758
|
-
this.httpClient = httpClient;
|
|
7759
|
-
}
|
|
7760
|
-
/** Suggest evidence for an assertion, enriched with its span context. */
|
|
7761
|
-
async getAssertionEvidence(assertionId) {
|
|
7762
|
-
const response = await this.httpClient.get(assertionEvidencePath(assertionId));
|
|
7763
|
-
return response.evidence;
|
|
7764
|
-
}
|
|
7765
|
-
};
|
|
7766
7795
|
var TracesClient = class {
|
|
7767
7796
|
constructor(httpClient) {
|
|
7768
7797
|
this.httpClient = httpClient;
|
|
7769
|
-
this.assertions = new TraceAssertionsClient(httpClient);
|
|
7770
7798
|
}
|
|
7771
7799
|
async search(params) {
|
|
7772
7800
|
return this.httpClient.request(SEARCH_PATH, params);
|
|
@@ -7906,8 +7934,14 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7906
7934
|
async onSpanStart(span) {
|
|
7907
7935
|
if (span.spanId !== void 0 && span.traceId !== null && span.traceId !== void 0) {
|
|
7908
7936
|
this.startedSpans.set(span.spanId, span.traceId);
|
|
7909
|
-
const
|
|
7937
|
+
const mapping = this.activeSpanMappings[span.traceId];
|
|
7938
|
+
const traceId = mapping?.traceId ?? span.traceId;
|
|
7910
7939
|
this.httpClient.traceCompletion.start(traceId, span.spanId);
|
|
7940
|
+
this.httpClient.reserveFrameworkSpan(
|
|
7941
|
+
traceId,
|
|
7942
|
+
span.spanId,
|
|
7943
|
+
span.parentId ?? mapping?.spanId
|
|
7944
|
+
);
|
|
7911
7945
|
}
|
|
7912
7946
|
}
|
|
7913
7947
|
/**
|
|
@@ -8294,22 +8328,68 @@ var BitfabVercelAiHandler = class {
|
|
|
8294
8328
|
|
|
8295
8329
|
// src/client.ts
|
|
8296
8330
|
init_warnOnce();
|
|
8331
|
+
var TRUNCATION_LIMIT_ORDER = [
|
|
8332
|
+
"max_depth",
|
|
8333
|
+
"max_spans",
|
|
8334
|
+
"max_captured_subtree_spans"
|
|
8335
|
+
];
|
|
8297
8336
|
var activeTraceStates = /* @__PURE__ */ new Map();
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8337
|
+
var REFUSED_FRAMEWORK_SPAN_TRACES_RETAINED = 1024;
|
|
8338
|
+
var refusedFrameworkSpans = /* @__PURE__ */ new Map();
|
|
8339
|
+
function frameworkSpanRefused(traceId, spanId) {
|
|
8340
|
+
return refusedFrameworkSpans.get(traceId)?.has(spanId) === true;
|
|
8341
|
+
}
|
|
8342
|
+
function refuseFrameworkSpan(traceId, spanId) {
|
|
8343
|
+
const refused = refusedFrameworkSpans.get(traceId);
|
|
8344
|
+
if (refused !== void 0) {
|
|
8345
|
+
refused.add(spanId);
|
|
8346
|
+
return;
|
|
8301
8347
|
}
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8348
|
+
refusedFrameworkSpans.set(traceId, /* @__PURE__ */ new Set([spanId]));
|
|
8349
|
+
while (refusedFrameworkSpans.size > REFUSED_FRAMEWORK_SPAN_TRACES_RETAINED) {
|
|
8350
|
+
const oldest = refusedFrameworkSpans.keys().next();
|
|
8351
|
+
if (oldest.done) {
|
|
8352
|
+
return;
|
|
8353
|
+
}
|
|
8354
|
+
refusedFrameworkSpans.delete(oldest.value);
|
|
8355
|
+
}
|
|
8356
|
+
}
|
|
8357
|
+
function reserveFrameworkSpan(traceId, spanId, parentSpanId) {
|
|
8358
|
+
const spanBudget = activeTraceStates.get(traceId)?.spanBudget;
|
|
8359
|
+
const parentRefused = parentSpanId !== null && frameworkSpanRefused(traceId, parentSpanId);
|
|
8360
|
+
if (!parentRefused && (spanBudget === void 0 || spanBudget.spansUsed < spanBudget.maxSpans)) {
|
|
8361
|
+
if (spanBudget !== void 0) {
|
|
8362
|
+
spanBudget.spansUsed += 1;
|
|
8363
|
+
}
|
|
8364
|
+
return;
|
|
8306
8365
|
}
|
|
8307
|
-
|
|
8308
|
-
|
|
8366
|
+
refuseFrameworkSpan(traceId, spanId);
|
|
8367
|
+
spanBudget?.truncate("max_spans");
|
|
8368
|
+
}
|
|
8369
|
+
function isRefusedFrameworkSpan(payload) {
|
|
8370
|
+
if (!recordedByFramework(payload)) {
|
|
8309
8371
|
return false;
|
|
8310
8372
|
}
|
|
8311
|
-
|
|
8312
|
-
|
|
8373
|
+
const rawSpan = payload.rawSpan;
|
|
8374
|
+
const spanId = rawSpan?.id;
|
|
8375
|
+
if (typeof spanId !== "string") {
|
|
8376
|
+
return false;
|
|
8377
|
+
}
|
|
8378
|
+
const traceIds = [payload.sourceTraceId, traceIdOf(payload)];
|
|
8379
|
+
return traceIds.some(
|
|
8380
|
+
(traceId) => typeof traceId === "string" && frameworkSpanRefused(traceId, spanId)
|
|
8381
|
+
);
|
|
8382
|
+
}
|
|
8383
|
+
function truncationMetadata(truncation) {
|
|
8384
|
+
if (truncation === void 0 || truncation.limits.size === 0) {
|
|
8385
|
+
return void 0;
|
|
8386
|
+
}
|
|
8387
|
+
return {
|
|
8388
|
+
"bitfab.truncated_by": TRUNCATION_LIMIT_ORDER.filter(
|
|
8389
|
+
(limit) => truncation.limits.has(limit)
|
|
8390
|
+
).join(","),
|
|
8391
|
+
"bitfab.dropped_spans": truncation.droppedSpans
|
|
8392
|
+
};
|
|
8313
8393
|
}
|
|
8314
8394
|
function rootTraceFunctionKeyOfTrace(traceId, fallback) {
|
|
8315
8395
|
return activeTraceStates.get(traceId)?.traceFunctionKey ?? fallback;
|
|
@@ -8691,7 +8771,6 @@ function readBooleanEnv(name) {
|
|
|
8691
8771
|
var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
|
|
8692
8772
|
var DEFAULT_AUTO_TRACE_MAX_SPANS = 2048;
|
|
8693
8773
|
var DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS = 512;
|
|
8694
|
-
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
8695
8774
|
function spanOwnerName(receiver) {
|
|
8696
8775
|
if (typeof receiver === "function") {
|
|
8697
8776
|
return receiver.name !== "" ? receiver.name : void 0;
|
|
@@ -8757,7 +8836,8 @@ var Bitfab = class {
|
|
|
8757
8836
|
this.httpClient,
|
|
8758
8837
|
config.simulationPlan ?? true
|
|
8759
8838
|
);
|
|
8760
|
-
this.httpClient.externalSpanTransform = (payload, submit) => this.applySimulationPlan(payload, submit);
|
|
8839
|
+
this.httpClient.externalSpanTransform = (payload, submit, drop) => this.applySimulationPlan(payload, submit, drop);
|
|
8840
|
+
this.httpClient.frameworkSpanStart = reserveFrameworkSpan;
|
|
8761
8841
|
this.httpClient.externalTraceTransform = (payload, submit) => this.simulationPlan.sendTrace(payload, submit);
|
|
8762
8842
|
this.httpClient.releaseHeldExternalSpans = (timeoutMs) => this.simulationPlan.release(timeoutMs);
|
|
8763
8843
|
this.httpClient.stopSimulationPlan = () => this.simulationPlan.stop();
|
|
@@ -8953,35 +9033,31 @@ var Bitfab = class {
|
|
|
8953
9033
|
function(...args) {
|
|
8954
9034
|
self.simulationPlan.refresh();
|
|
8955
9035
|
let capturedSubtreeCount = 0;
|
|
8956
|
-
|
|
8957
|
-
const
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
maxCapturedSubtreeSpans
|
|
8967
|
-
}
|
|
8968
|
-
});
|
|
8969
|
-
}
|
|
9036
|
+
const rootSpanStack = getSpanStack();
|
|
9037
|
+
const rootSpan = rootSpanStack[rootSpanStack.length - 1];
|
|
9038
|
+
const rootTraceState = rootSpan === void 0 ? void 0 : activeTraceStates.get(rootSpan.traceId);
|
|
9039
|
+
const truncation = rootTraceState?.truncation ?? {
|
|
9040
|
+
limits: /* @__PURE__ */ new Set(),
|
|
9041
|
+
droppedSpans: 0
|
|
9042
|
+
};
|
|
9043
|
+
const truncate = (limit) => {
|
|
9044
|
+
truncation.limits.add(limit);
|
|
9045
|
+
truncation.droppedSpans += 1;
|
|
8970
9046
|
warnOnce(
|
|
8971
9047
|
`auto-trace-truncated:${traceFunctionKey}`,
|
|
8972
9048
|
`"${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.`
|
|
8973
9049
|
);
|
|
8974
9050
|
};
|
|
8975
|
-
const rootSpanStack = getSpanStack();
|
|
8976
9051
|
const spanBudget = {
|
|
8977
9052
|
spansUsed: 1,
|
|
8978
9053
|
maxSpans,
|
|
8979
|
-
truncate
|
|
9054
|
+
truncate
|
|
8980
9055
|
};
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
9056
|
+
if (rootTraceState !== void 0) {
|
|
9057
|
+
rootTraceState.truncation = truncation;
|
|
9058
|
+
if (rootTraceState.spanBudget === void 0) {
|
|
9059
|
+
rootTraceState.spanBudget = spanBudget;
|
|
9060
|
+
}
|
|
8985
9061
|
}
|
|
8986
9062
|
const spanStackOf = (entry) => entry.spanStack;
|
|
8987
9063
|
const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
|
|
@@ -9021,15 +9097,16 @@ var Bitfab = class {
|
|
|
9021
9097
|
rootTraceFunctionKeyOfEntry(entry),
|
|
9022
9098
|
spanName
|
|
9023
9099
|
);
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
}
|
|
9029
|
-
return true;
|
|
9100
|
+
const refusedBy = entry.depth >= maxDepth ? "max_depth" : spanBudget.spansUsed >= maxSpans ? "max_spans" : countsTowardCapturedSubtree && capturedSubtreeCount >= maxCapturedSubtreeSpans ? "max_captured_subtree_spans" : void 0;
|
|
9101
|
+
if (refusedBy !== void 0) {
|
|
9102
|
+
truncate(refusedBy);
|
|
9103
|
+
return false;
|
|
9030
9104
|
}
|
|
9031
|
-
|
|
9032
|
-
|
|
9105
|
+
spanBudget.spansUsed += 1;
|
|
9106
|
+
if (countsTowardCapturedSubtree) {
|
|
9107
|
+
capturedSubtreeCount += 1;
|
|
9108
|
+
}
|
|
9109
|
+
return true;
|
|
9033
9110
|
};
|
|
9034
9111
|
const autoTraceContext = {
|
|
9035
9112
|
traceFunctionKey,
|
|
@@ -9156,11 +9233,17 @@ var Bitfab = class {
|
|
|
9156
9233
|
Object.defineProperty(autoTraceRoot, "_bitfabWrappedFn", { value: fn });
|
|
9157
9234
|
return autoTraceRoot;
|
|
9158
9235
|
}
|
|
9159
|
-
applySimulationPlan(payload, submit) {
|
|
9160
|
-
if (
|
|
9236
|
+
applySimulationPlan(payload, submit, drop) {
|
|
9237
|
+
if (isRefusedFrameworkSpan(payload)) {
|
|
9238
|
+
drop();
|
|
9161
9239
|
return;
|
|
9162
9240
|
}
|
|
9163
|
-
this.simulationPlan.send(
|
|
9241
|
+
this.simulationPlan.send(
|
|
9242
|
+
payload,
|
|
9243
|
+
rootTraceFunctionKeyOf(payload),
|
|
9244
|
+
submit,
|
|
9245
|
+
drop
|
|
9246
|
+
);
|
|
9164
9247
|
}
|
|
9165
9248
|
/**
|
|
9166
9249
|
* Flush and permanently close this client's tracing resources: its pending
|
|
@@ -9829,6 +9912,9 @@ var Bitfab = class {
|
|
|
9829
9912
|
registeredTraceId = traceId;
|
|
9830
9913
|
}
|
|
9831
9914
|
self.httpClient.traceCompletion.start(traceId, spanId);
|
|
9915
|
+
if (isFrameworkInstrumentation(options.instrumentation)) {
|
|
9916
|
+
reserveFrameworkSpan(traceId, spanId, parentSpanId);
|
|
9917
|
+
}
|
|
9832
9918
|
startedSpan = { traceId, spanId };
|
|
9833
9919
|
const functionName = fn.name !== "" ? fn.name : void 0;
|
|
9834
9920
|
const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
|
|
@@ -9873,6 +9959,10 @@ var Bitfab = class {
|
|
|
9873
9959
|
}
|
|
9874
9960
|
if (isRootSpan) {
|
|
9875
9961
|
const traceState = activeTraceStates.get(traceId);
|
|
9962
|
+
const truncated = truncationMetadata(traceState?.truncation);
|
|
9963
|
+
if (truncated !== void 0) {
|
|
9964
|
+
recordCallerTraceMetadata(traceId, truncated);
|
|
9965
|
+
}
|
|
9876
9966
|
self.sendTraceCompletion({
|
|
9877
9967
|
traceFunctionKey,
|
|
9878
9968
|
traceId,
|
|
@@ -10425,7 +10515,7 @@ var Bitfab = class {
|
|
|
10425
10515
|
...params.captureContent && params.contexts && params.contexts.length > 0 && {
|
|
10426
10516
|
contexts: params.contexts
|
|
10427
10517
|
},
|
|
10428
|
-
...
|
|
10518
|
+
...buildsContent && params.prompt !== void 0 && { prompt: params.prompt },
|
|
10429
10519
|
...contentOff && { [CONTENT_OFF_KEY]: true }
|
|
10430
10520
|
}
|
|
10431
10521
|
};
|
|
@@ -11020,7 +11110,6 @@ function resolveTraceFunctionKey(registration) {
|
|
|
11020
11110
|
NO_MOCK_OVERRIDE,
|
|
11021
11111
|
ReplayError,
|
|
11022
11112
|
SUPPORTED_PROVIDERS,
|
|
11023
|
-
TraceAssertionsClient,
|
|
11024
11113
|
TracesClient,
|
|
11025
11114
|
__version__,
|
|
11026
11115
|
defineReplayRegistry,
|