@bitfab/sdk 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-2ZPZUOD6.js → chunk-4V66SLXD.js} +26 -13
- package/dist/chunk-4V66SLXD.js.map +1 -0
- package/dist/{chunk-4R5G55MG.js → chunk-77YNCRPM.js} +137 -67
- package/dist/chunk-77YNCRPM.js.map +1 -0
- package/dist/{chunk-7KY75E3I.js → chunk-C4TUWV6G.js} +3 -3
- package/dist/{chunk-AMILC6CQ.js → chunk-VP3BZFIS.js} +2 -2
- package/dist/{chunk-NK25R6UX.js → chunk-W3JGWZ4M.js} +36 -16
- package/dist/chunk-W3JGWZ4M.js.map +1 -0
- package/dist/{http-N62YN7QQ.js → http-4T66JWE4.js} +2 -2
- package/dist/{http-MKYC373Q.js → http-APBBWPJE.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-4IVG6F7L.js → replay-7PD2ESNG.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-2ZPZUOD6.js.map +0 -1
- package/dist/chunk-4R5G55MG.js.map +0 -1
- package/dist/chunk-NK25R6UX.js.map +0 -1
- /package/dist/{chunk-7KY75E3I.js.map → chunk-C4TUWV6G.js.map} +0 -0
- /package/dist/{chunk-AMILC6CQ.js.map → chunk-VP3BZFIS.js.map} +0 -0
- /package/dist/{http-MKYC373Q.js.map → http-4T66JWE4.js.map} +0 -0
- /package/dist/{http-N62YN7QQ.js.map → http-APBBWPJE.js.map} +0 -0
- /package/dist/{replay-4IVG6F7L.js.map → replay-7PD2ESNG.js.map} +0 -0
package/dist/node.cjs
CHANGED
|
@@ -88,7 +88,7 @@ var __version__, __packageName__;
|
|
|
88
88
|
var init_version_generated = __esm({
|
|
89
89
|
"src/version.generated.ts"() {
|
|
90
90
|
"use strict";
|
|
91
|
-
__version__ = "0.57.
|
|
91
|
+
__version__ = "0.57.7";
|
|
92
92
|
__packageName__ = "@bitfab/sdk";
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -1062,7 +1062,13 @@ var init_simulationPlan = __esm({
|
|
|
1062
1062
|
DISABLE_SIMULATION_PLAN_ENV = "BITFAB_DISABLE_SIM_PLAN";
|
|
1063
1063
|
ROOT_TRACE_FUNCTION_KEY_FIELD = "rootTraceFunctionKey";
|
|
1064
1064
|
CONTENT_OFF_KEY = "content_off_by_simulation_plan";
|
|
1065
|
-
CONTENT_KEYS = [
|
|
1065
|
+
CONTENT_KEYS = [
|
|
1066
|
+
"input",
|
|
1067
|
+
"input_meta",
|
|
1068
|
+
"output",
|
|
1069
|
+
"output_meta",
|
|
1070
|
+
"prompt"
|
|
1071
|
+
];
|
|
1066
1072
|
SimulationPlan = class {
|
|
1067
1073
|
constructor(source, enabled = true) {
|
|
1068
1074
|
this.source = source;
|
|
@@ -1181,13 +1187,13 @@ var init_simulationPlan = __esm({
|
|
|
1181
1187
|
}
|
|
1182
1188
|
return this.loaded;
|
|
1183
1189
|
}
|
|
1184
|
-
send(payload, traceFunctionKey, submit) {
|
|
1190
|
+
send(payload, traceFunctionKey, submit, drop) {
|
|
1185
1191
|
this.refresh();
|
|
1186
1192
|
if (this.disabled() || traceFunctionKey === void 0 || spanNameOf(payload) === void 0 || recordedByFramework(payload)) {
|
|
1187
1193
|
submit(payload);
|
|
1188
1194
|
return;
|
|
1189
1195
|
}
|
|
1190
|
-
const entry = { payload, traceFunctionKey, submit };
|
|
1196
|
+
const entry = { payload, traceFunctionKey, submit, drop };
|
|
1191
1197
|
if (this.holdingForFirstRead()) {
|
|
1192
1198
|
this.hold(entry);
|
|
1193
1199
|
return;
|
|
@@ -1241,6 +1247,7 @@ var init_simulationPlan = __esm({
|
|
|
1241
1247
|
try {
|
|
1242
1248
|
entry.submit(this.payloadToSend(entry));
|
|
1243
1249
|
} catch (error) {
|
|
1250
|
+
entry.drop?.();
|
|
1244
1251
|
warnOnce(
|
|
1245
1252
|
"sim-plan-held-span-dropped",
|
|
1246
1253
|
`a span held for the sim plan was dropped when released: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -2571,23 +2578,21 @@ var init_http = __esm({
|
|
|
2571
2578
|
}
|
|
2572
2579
|
const deadline = Date.now() + Math.max(timeoutMs, 0);
|
|
2573
2580
|
this.closing = (async () => {
|
|
2574
|
-
|
|
2575
|
-
|
|
2581
|
+
liveHttpClients.delete(this);
|
|
2582
|
+
const settled2 = await this.settleDeferredWork(
|
|
2583
|
+
Math.max(0, deadline - Date.now())
|
|
2576
2584
|
);
|
|
2577
2585
|
this.stopSimulationPlan?.();
|
|
2586
|
+
this.closed = true;
|
|
2578
2587
|
this.externalSpanTransform = void 0;
|
|
2579
2588
|
this.externalTraceTransform = void 0;
|
|
2589
|
+
this.frameworkSpanStart = void 0;
|
|
2580
2590
|
this.releaseHeldExternalSpans = void 0;
|
|
2581
2591
|
this.stopSimulationPlan = void 0;
|
|
2582
|
-
liveHttpClients.delete(this);
|
|
2583
|
-
const settled2 = await this.settleDeferredWork(
|
|
2584
|
-
Math.max(0, deadline - Date.now())
|
|
2585
|
-
);
|
|
2586
|
-
this.closed = true;
|
|
2587
2592
|
const transport = this.traceTransport;
|
|
2588
2593
|
this.traceTransport = void 0;
|
|
2589
2594
|
const shutdownOk = await transport?.shutdown(Math.max(0, deadline - Date.now())) ?? true;
|
|
2590
|
-
return
|
|
2595
|
+
return settled2 && shutdownOk;
|
|
2591
2596
|
})();
|
|
2592
2597
|
return this.closing;
|
|
2593
2598
|
}
|
|
@@ -2688,8 +2693,7 @@ var init_http = __esm({
|
|
|
2688
2693
|
async getSimulationPlan() {
|
|
2689
2694
|
return this.get(
|
|
2690
2695
|
"/api/sdk/sim-plan",
|
|
2691
|
-
SIMULATION_PLAN_READ_TIMEOUT_MS
|
|
2692
|
-
{ Connection: "close" }
|
|
2696
|
+
SIMULATION_PLAN_READ_TIMEOUT_MS
|
|
2693
2697
|
);
|
|
2694
2698
|
}
|
|
2695
2699
|
async getTraceSpan(traceId, lookup) {
|
|
@@ -2765,19 +2769,35 @@ var init_http = __esm({
|
|
|
2765
2769
|
carrierMeta("internal_trace", body, void 0)
|
|
2766
2770
|
);
|
|
2767
2771
|
}
|
|
2772
|
+
reserveFrameworkSpan(traceId, spanId, parentSpanId) {
|
|
2773
|
+
try {
|
|
2774
|
+
this.frameworkSpanStart?.(traceId, spanId, parentSpanId ?? null);
|
|
2775
|
+
} catch (error) {
|
|
2776
|
+
warnOnce(
|
|
2777
|
+
"framework-span-reservation-failed",
|
|
2778
|
+
`a framework span could not be counted toward its trace's span limit: ${describeError(error)}`
|
|
2779
|
+
);
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2768
2782
|
sendExternalSpan(payload) {
|
|
2769
2783
|
const ref2 = carrierRef(payload);
|
|
2770
2784
|
if (ref2?.spanId !== void 0) {
|
|
2771
2785
|
this.traceCompletion.record(ref2.traceId, ref2.spanId);
|
|
2772
2786
|
}
|
|
2787
|
+
const drop = () => {
|
|
2788
|
+
if (ref2?.spanId !== void 0) {
|
|
2789
|
+
this.traceCompletion.abort(ref2.traceId, ref2.spanId);
|
|
2790
|
+
}
|
|
2791
|
+
};
|
|
2773
2792
|
const gate = this.externalSpanTransform;
|
|
2774
2793
|
if (gate === void 0) {
|
|
2775
2794
|
this.submitExternalSpan(payload);
|
|
2776
2795
|
return;
|
|
2777
2796
|
}
|
|
2778
2797
|
try {
|
|
2779
|
-
gate(payload, (ready) => this.submitExternalSpan(ready));
|
|
2798
|
+
gate(payload, (ready) => this.submitExternalSpan(ready), drop);
|
|
2780
2799
|
} catch (error) {
|
|
2800
|
+
drop();
|
|
2781
2801
|
warnDroppedExternalSpan(error);
|
|
2782
2802
|
}
|
|
2783
2803
|
}
|
|
@@ -4389,7 +4409,6 @@ __export(node_exports, {
|
|
|
4389
4409
|
NO_MOCK_OVERRIDE: () => NO_MOCK_OVERRIDE,
|
|
4390
4410
|
ReplayError: () => ReplayError,
|
|
4391
4411
|
SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
|
|
4392
|
-
TraceAssertionsClient: () => TraceAssertionsClient,
|
|
4393
4412
|
TracesClient: () => TracesClient,
|
|
4394
4413
|
__version__: () => __version__,
|
|
4395
4414
|
defineReplayRegistry: () => defineReplayRegistry,
|
|
@@ -4671,6 +4690,11 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4671
4690
|
}
|
|
4672
4691
|
this.runToSpan.set(spanId, spanInfo);
|
|
4673
4692
|
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
4693
|
+
this.httpClient.reserveFrameworkSpan(
|
|
4694
|
+
spanInfo.traceId,
|
|
4695
|
+
spanInfo.spanId,
|
|
4696
|
+
spanInfo.parentId
|
|
4697
|
+
);
|
|
4674
4698
|
return spanInfo;
|
|
4675
4699
|
}
|
|
4676
4700
|
completeSpan(spanId, output, error, extraContexts) {
|
|
@@ -4950,6 +4974,11 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4950
4974
|
this.conversationHistory.push(...this.pendingMessages);
|
|
4951
4975
|
this.pendingMessages = [];
|
|
4952
4976
|
this.currentLlmSpanId = randomUuid();
|
|
4977
|
+
this.httpClient.reserveFrameworkSpan(
|
|
4978
|
+
this.ensureTrace(),
|
|
4979
|
+
this.currentLlmSpanId,
|
|
4980
|
+
this.getParentId()
|
|
4981
|
+
);
|
|
4953
4982
|
this.currentLlmMessageId = messageId ?? null;
|
|
4954
4983
|
this.currentLlmContent = [];
|
|
4955
4984
|
this.currentLlmModel = inner.model ?? null;
|
|
@@ -5993,6 +6022,9 @@ init_http();
|
|
|
5993
6022
|
// src/labels.ts
|
|
5994
6023
|
var LABELS_PATH = "/api/sdk/traces/labels";
|
|
5995
6024
|
var HUMAN_LABELS_PATH = "/api/sdk/traces/labels/human";
|
|
6025
|
+
function labelEvidencePath(traceId, assertionId) {
|
|
6026
|
+
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions/${encodeURIComponent(assertionId)}/evidence`;
|
|
6027
|
+
}
|
|
5996
6028
|
var LabelsClient = class {
|
|
5997
6029
|
constructor(httpClient) {
|
|
5998
6030
|
this.httpClient = httpClient;
|
|
@@ -6041,6 +6073,11 @@ var LabelsClient = class {
|
|
|
6041
6073
|
);
|
|
6042
6074
|
return response.labels;
|
|
6043
6075
|
}
|
|
6076
|
+
/** Generate suggested evidence for an assertion on an original or replay trace. */
|
|
6077
|
+
async generateLabelEvidence(traceId, assertionId) {
|
|
6078
|
+
const response = await this.httpClient.get(labelEvidencePath(traceId, assertionId));
|
|
6079
|
+
return response.evidence;
|
|
6080
|
+
}
|
|
6044
6081
|
};
|
|
6045
6082
|
|
|
6046
6083
|
// src/langgraph.ts
|
|
@@ -6352,6 +6389,11 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6352
6389
|
this.runToSpan.set(runId, spanInfo);
|
|
6353
6390
|
if (spanInfo.hidden !== true) {
|
|
6354
6391
|
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
6392
|
+
this.httpClient.reserveFrameworkSpan(
|
|
6393
|
+
spanInfo.traceId,
|
|
6394
|
+
spanInfo.spanId,
|
|
6395
|
+
spanInfo.parentId
|
|
6396
|
+
);
|
|
6355
6397
|
}
|
|
6356
6398
|
if (isRootInvocation) {
|
|
6357
6399
|
this.sendTraceStart(spanInfo);
|
|
@@ -7755,23 +7797,9 @@ var SEARCH_PATH = "/api/sdk/traces/search";
|
|
|
7755
7797
|
function traceAssertionsPath(traceId, suffix = "") {
|
|
7756
7798
|
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
|
|
7757
7799
|
}
|
|
7758
|
-
function assertionEvidencePath(assertionId) {
|
|
7759
|
-
return `/api/sdk/traces/assertions/${encodeURIComponent(assertionId)}/evidence`;
|
|
7760
|
-
}
|
|
7761
|
-
var TraceAssertionsClient = class {
|
|
7762
|
-
constructor(httpClient) {
|
|
7763
|
-
this.httpClient = httpClient;
|
|
7764
|
-
}
|
|
7765
|
-
/** Suggest evidence for an assertion, enriched with its span context. */
|
|
7766
|
-
async getAssertionEvidence(assertionId) {
|
|
7767
|
-
const response = await this.httpClient.get(assertionEvidencePath(assertionId));
|
|
7768
|
-
return response.evidence;
|
|
7769
|
-
}
|
|
7770
|
-
};
|
|
7771
7800
|
var TracesClient = class {
|
|
7772
7801
|
constructor(httpClient) {
|
|
7773
7802
|
this.httpClient = httpClient;
|
|
7774
|
-
this.assertions = new TraceAssertionsClient(httpClient);
|
|
7775
7803
|
}
|
|
7776
7804
|
async search(params) {
|
|
7777
7805
|
return this.httpClient.request(SEARCH_PATH, params);
|
|
@@ -7911,8 +7939,14 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7911
7939
|
async onSpanStart(span) {
|
|
7912
7940
|
if (span.spanId !== void 0 && span.traceId !== null && span.traceId !== void 0) {
|
|
7913
7941
|
this.startedSpans.set(span.spanId, span.traceId);
|
|
7914
|
-
const
|
|
7942
|
+
const mapping = this.activeSpanMappings[span.traceId];
|
|
7943
|
+
const traceId = mapping?.traceId ?? span.traceId;
|
|
7915
7944
|
this.httpClient.traceCompletion.start(traceId, span.spanId);
|
|
7945
|
+
this.httpClient.reserveFrameworkSpan(
|
|
7946
|
+
traceId,
|
|
7947
|
+
span.spanId,
|
|
7948
|
+
span.parentId ?? mapping?.spanId
|
|
7949
|
+
);
|
|
7916
7950
|
}
|
|
7917
7951
|
}
|
|
7918
7952
|
/**
|
|
@@ -8299,22 +8333,68 @@ var BitfabVercelAiHandler = class {
|
|
|
8299
8333
|
|
|
8300
8334
|
// src/client.ts
|
|
8301
8335
|
init_warnOnce();
|
|
8336
|
+
var TRUNCATION_LIMIT_ORDER = [
|
|
8337
|
+
"max_depth",
|
|
8338
|
+
"max_spans",
|
|
8339
|
+
"max_captured_subtree_spans"
|
|
8340
|
+
];
|
|
8302
8341
|
var activeTraceStates = /* @__PURE__ */ new Map();
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8342
|
+
var REFUSED_FRAMEWORK_SPAN_TRACES_RETAINED = 1024;
|
|
8343
|
+
var refusedFrameworkSpans = /* @__PURE__ */ new Map();
|
|
8344
|
+
function frameworkSpanRefused(traceId, spanId) {
|
|
8345
|
+
return refusedFrameworkSpans.get(traceId)?.has(spanId) === true;
|
|
8346
|
+
}
|
|
8347
|
+
function refuseFrameworkSpan(traceId, spanId) {
|
|
8348
|
+
const refused = refusedFrameworkSpans.get(traceId);
|
|
8349
|
+
if (refused !== void 0) {
|
|
8350
|
+
refused.add(spanId);
|
|
8351
|
+
return;
|
|
8306
8352
|
}
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8353
|
+
refusedFrameworkSpans.set(traceId, /* @__PURE__ */ new Set([spanId]));
|
|
8354
|
+
while (refusedFrameworkSpans.size > REFUSED_FRAMEWORK_SPAN_TRACES_RETAINED) {
|
|
8355
|
+
const oldest = refusedFrameworkSpans.keys().next();
|
|
8356
|
+
if (oldest.done) {
|
|
8357
|
+
return;
|
|
8358
|
+
}
|
|
8359
|
+
refusedFrameworkSpans.delete(oldest.value);
|
|
8360
|
+
}
|
|
8361
|
+
}
|
|
8362
|
+
function reserveFrameworkSpan(traceId, spanId, parentSpanId) {
|
|
8363
|
+
const spanBudget = activeTraceStates.get(traceId)?.spanBudget;
|
|
8364
|
+
const parentRefused = parentSpanId !== null && frameworkSpanRefused(traceId, parentSpanId);
|
|
8365
|
+
if (!parentRefused && (spanBudget === void 0 || spanBudget.spansUsed < spanBudget.maxSpans)) {
|
|
8366
|
+
if (spanBudget !== void 0) {
|
|
8367
|
+
spanBudget.spansUsed += 1;
|
|
8368
|
+
}
|
|
8369
|
+
return;
|
|
8311
8370
|
}
|
|
8312
|
-
|
|
8313
|
-
|
|
8371
|
+
refuseFrameworkSpan(traceId, spanId);
|
|
8372
|
+
spanBudget?.truncate("max_spans");
|
|
8373
|
+
}
|
|
8374
|
+
function isRefusedFrameworkSpan(payload) {
|
|
8375
|
+
if (!recordedByFramework(payload)) {
|
|
8314
8376
|
return false;
|
|
8315
8377
|
}
|
|
8316
|
-
|
|
8317
|
-
|
|
8378
|
+
const rawSpan = payload.rawSpan;
|
|
8379
|
+
const spanId = rawSpan?.id;
|
|
8380
|
+
if (typeof spanId !== "string") {
|
|
8381
|
+
return false;
|
|
8382
|
+
}
|
|
8383
|
+
const traceIds = [payload.sourceTraceId, traceIdOf(payload)];
|
|
8384
|
+
return traceIds.some(
|
|
8385
|
+
(traceId) => typeof traceId === "string" && frameworkSpanRefused(traceId, spanId)
|
|
8386
|
+
);
|
|
8387
|
+
}
|
|
8388
|
+
function truncationMetadata(truncation) {
|
|
8389
|
+
if (truncation === void 0 || truncation.limits.size === 0) {
|
|
8390
|
+
return void 0;
|
|
8391
|
+
}
|
|
8392
|
+
return {
|
|
8393
|
+
"bitfab.truncated_by": TRUNCATION_LIMIT_ORDER.filter(
|
|
8394
|
+
(limit) => truncation.limits.has(limit)
|
|
8395
|
+
).join(","),
|
|
8396
|
+
"bitfab.dropped_spans": truncation.droppedSpans
|
|
8397
|
+
};
|
|
8318
8398
|
}
|
|
8319
8399
|
function rootTraceFunctionKeyOfTrace(traceId, fallback) {
|
|
8320
8400
|
return activeTraceStates.get(traceId)?.traceFunctionKey ?? fallback;
|
|
@@ -8696,7 +8776,6 @@ function readBooleanEnv(name) {
|
|
|
8696
8776
|
var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
|
|
8697
8777
|
var DEFAULT_AUTO_TRACE_MAX_SPANS = 2048;
|
|
8698
8778
|
var DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS = 512;
|
|
8699
|
-
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
8700
8779
|
function spanOwnerName(receiver) {
|
|
8701
8780
|
if (typeof receiver === "function") {
|
|
8702
8781
|
return receiver.name !== "" ? receiver.name : void 0;
|
|
@@ -8762,7 +8841,8 @@ var Bitfab = class {
|
|
|
8762
8841
|
this.httpClient,
|
|
8763
8842
|
config.simulationPlan ?? true
|
|
8764
8843
|
);
|
|
8765
|
-
this.httpClient.externalSpanTransform = (payload, submit) => this.applySimulationPlan(payload, submit);
|
|
8844
|
+
this.httpClient.externalSpanTransform = (payload, submit, drop) => this.applySimulationPlan(payload, submit, drop);
|
|
8845
|
+
this.httpClient.frameworkSpanStart = reserveFrameworkSpan;
|
|
8766
8846
|
this.httpClient.externalTraceTransform = (payload, submit) => this.simulationPlan.sendTrace(payload, submit);
|
|
8767
8847
|
this.httpClient.releaseHeldExternalSpans = (timeoutMs) => this.simulationPlan.release(timeoutMs);
|
|
8768
8848
|
this.httpClient.stopSimulationPlan = () => this.simulationPlan.stop();
|
|
@@ -8958,35 +9038,31 @@ var Bitfab = class {
|
|
|
8958
9038
|
function(...args) {
|
|
8959
9039
|
self.simulationPlan.refresh();
|
|
8960
9040
|
let capturedSubtreeCount = 0;
|
|
8961
|
-
|
|
8962
|
-
const
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
maxCapturedSubtreeSpans
|
|
8972
|
-
}
|
|
8973
|
-
});
|
|
8974
|
-
}
|
|
9041
|
+
const rootSpanStack = getSpanStack();
|
|
9042
|
+
const rootSpan = rootSpanStack[rootSpanStack.length - 1];
|
|
9043
|
+
const rootTraceState = rootSpan === void 0 ? void 0 : activeTraceStates.get(rootSpan.traceId);
|
|
9044
|
+
const truncation = rootTraceState?.truncation ?? {
|
|
9045
|
+
limits: /* @__PURE__ */ new Set(),
|
|
9046
|
+
droppedSpans: 0
|
|
9047
|
+
};
|
|
9048
|
+
const truncate = (limit) => {
|
|
9049
|
+
truncation.limits.add(limit);
|
|
9050
|
+
truncation.droppedSpans += 1;
|
|
8975
9051
|
warnOnce(
|
|
8976
9052
|
`auto-trace-truncated:${traceFunctionKey}`,
|
|
8977
9053
|
`"${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.`
|
|
8978
9054
|
);
|
|
8979
9055
|
};
|
|
8980
|
-
const rootSpanStack = getSpanStack();
|
|
8981
9056
|
const spanBudget = {
|
|
8982
9057
|
spansUsed: 1,
|
|
8983
9058
|
maxSpans,
|
|
8984
|
-
truncate
|
|
9059
|
+
truncate
|
|
8985
9060
|
};
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
9061
|
+
if (rootTraceState !== void 0) {
|
|
9062
|
+
rootTraceState.truncation = truncation;
|
|
9063
|
+
if (rootTraceState.spanBudget === void 0) {
|
|
9064
|
+
rootTraceState.spanBudget = spanBudget;
|
|
9065
|
+
}
|
|
8990
9066
|
}
|
|
8991
9067
|
const spanStackOf = (entry) => entry.spanStack;
|
|
8992
9068
|
const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
|
|
@@ -9026,15 +9102,16 @@ var Bitfab = class {
|
|
|
9026
9102
|
rootTraceFunctionKeyOfEntry(entry),
|
|
9027
9103
|
spanName
|
|
9028
9104
|
);
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
}
|
|
9034
|
-
return true;
|
|
9105
|
+
const refusedBy = entry.depth >= maxDepth ? "max_depth" : spanBudget.spansUsed >= maxSpans ? "max_spans" : countsTowardCapturedSubtree && capturedSubtreeCount >= maxCapturedSubtreeSpans ? "max_captured_subtree_spans" : void 0;
|
|
9106
|
+
if (refusedBy !== void 0) {
|
|
9107
|
+
truncate(refusedBy);
|
|
9108
|
+
return false;
|
|
9035
9109
|
}
|
|
9036
|
-
|
|
9037
|
-
|
|
9110
|
+
spanBudget.spansUsed += 1;
|
|
9111
|
+
if (countsTowardCapturedSubtree) {
|
|
9112
|
+
capturedSubtreeCount += 1;
|
|
9113
|
+
}
|
|
9114
|
+
return true;
|
|
9038
9115
|
};
|
|
9039
9116
|
const autoTraceContext = {
|
|
9040
9117
|
traceFunctionKey,
|
|
@@ -9161,11 +9238,17 @@ var Bitfab = class {
|
|
|
9161
9238
|
Object.defineProperty(autoTraceRoot, "_bitfabWrappedFn", { value: fn });
|
|
9162
9239
|
return autoTraceRoot;
|
|
9163
9240
|
}
|
|
9164
|
-
applySimulationPlan(payload, submit) {
|
|
9165
|
-
if (
|
|
9241
|
+
applySimulationPlan(payload, submit, drop) {
|
|
9242
|
+
if (isRefusedFrameworkSpan(payload)) {
|
|
9243
|
+
drop();
|
|
9166
9244
|
return;
|
|
9167
9245
|
}
|
|
9168
|
-
this.simulationPlan.send(
|
|
9246
|
+
this.simulationPlan.send(
|
|
9247
|
+
payload,
|
|
9248
|
+
rootTraceFunctionKeyOf(payload),
|
|
9249
|
+
submit,
|
|
9250
|
+
drop
|
|
9251
|
+
);
|
|
9169
9252
|
}
|
|
9170
9253
|
/**
|
|
9171
9254
|
* Flush and permanently close this client's tracing resources: its pending
|
|
@@ -9834,6 +9917,9 @@ var Bitfab = class {
|
|
|
9834
9917
|
registeredTraceId = traceId;
|
|
9835
9918
|
}
|
|
9836
9919
|
self.httpClient.traceCompletion.start(traceId, spanId);
|
|
9920
|
+
if (isFrameworkInstrumentation(options.instrumentation)) {
|
|
9921
|
+
reserveFrameworkSpan(traceId, spanId, parentSpanId);
|
|
9922
|
+
}
|
|
9837
9923
|
startedSpan = { traceId, spanId };
|
|
9838
9924
|
const functionName = fn.name !== "" ? fn.name : void 0;
|
|
9839
9925
|
const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
|
|
@@ -9878,6 +9964,10 @@ var Bitfab = class {
|
|
|
9878
9964
|
}
|
|
9879
9965
|
if (isRootSpan) {
|
|
9880
9966
|
const traceState = activeTraceStates.get(traceId);
|
|
9967
|
+
const truncated = truncationMetadata(traceState?.truncation);
|
|
9968
|
+
if (truncated !== void 0) {
|
|
9969
|
+
recordCallerTraceMetadata(traceId, truncated);
|
|
9970
|
+
}
|
|
9881
9971
|
self.sendTraceCompletion({
|
|
9882
9972
|
traceFunctionKey,
|
|
9883
9973
|
traceId,
|
|
@@ -10430,7 +10520,7 @@ var Bitfab = class {
|
|
|
10430
10520
|
...params.captureContent && params.contexts && params.contexts.length > 0 && {
|
|
10431
10521
|
contexts: params.contexts
|
|
10432
10522
|
},
|
|
10433
|
-
...
|
|
10523
|
+
...buildsContent && params.prompt !== void 0 && { prompt: params.prompt },
|
|
10434
10524
|
...contentOff && { [CONTENT_OFF_KEY]: true }
|
|
10435
10525
|
}
|
|
10436
10526
|
};
|
|
@@ -11029,7 +11119,6 @@ assertAsyncStorageRegistered();
|
|
|
11029
11119
|
NO_MOCK_OVERRIDE,
|
|
11030
11120
|
ReplayError,
|
|
11031
11121
|
SUPPORTED_PROVIDERS,
|
|
11032
|
-
TraceAssertionsClient,
|
|
11033
11122
|
TracesClient,
|
|
11034
11123
|
__version__,
|
|
11035
11124
|
defineReplayRegistry,
|