@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/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var __version__, __packageName__;
|
|
|
42
42
|
var init_version_generated = __esm({
|
|
43
43
|
"src/version.generated.ts"() {
|
|
44
44
|
"use strict";
|
|
45
|
-
__version__ = "0.57.
|
|
45
|
+
__version__ = "0.57.7";
|
|
46
46
|
__packageName__ = "@bitfab/sdk";
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -1055,7 +1055,13 @@ var init_simulationPlan = __esm({
|
|
|
1055
1055
|
DISABLE_SIMULATION_PLAN_ENV = "BITFAB_DISABLE_SIM_PLAN";
|
|
1056
1056
|
ROOT_TRACE_FUNCTION_KEY_FIELD = "rootTraceFunctionKey";
|
|
1057
1057
|
CONTENT_OFF_KEY = "content_off_by_simulation_plan";
|
|
1058
|
-
CONTENT_KEYS = [
|
|
1058
|
+
CONTENT_KEYS = [
|
|
1059
|
+
"input",
|
|
1060
|
+
"input_meta",
|
|
1061
|
+
"output",
|
|
1062
|
+
"output_meta",
|
|
1063
|
+
"prompt"
|
|
1064
|
+
];
|
|
1059
1065
|
SimulationPlan = class {
|
|
1060
1066
|
constructor(source, enabled = true) {
|
|
1061
1067
|
this.source = source;
|
|
@@ -1174,13 +1180,13 @@ var init_simulationPlan = __esm({
|
|
|
1174
1180
|
}
|
|
1175
1181
|
return this.loaded;
|
|
1176
1182
|
}
|
|
1177
|
-
send(payload, traceFunctionKey, submit) {
|
|
1183
|
+
send(payload, traceFunctionKey, submit, drop) {
|
|
1178
1184
|
this.refresh();
|
|
1179
1185
|
if (this.disabled() || traceFunctionKey === void 0 || spanNameOf(payload) === void 0 || recordedByFramework(payload)) {
|
|
1180
1186
|
submit(payload);
|
|
1181
1187
|
return;
|
|
1182
1188
|
}
|
|
1183
|
-
const entry = { payload, traceFunctionKey, submit };
|
|
1189
|
+
const entry = { payload, traceFunctionKey, submit, drop };
|
|
1184
1190
|
if (this.holdingForFirstRead()) {
|
|
1185
1191
|
this.hold(entry);
|
|
1186
1192
|
return;
|
|
@@ -1234,6 +1240,7 @@ var init_simulationPlan = __esm({
|
|
|
1234
1240
|
try {
|
|
1235
1241
|
entry.submit(this.payloadToSend(entry));
|
|
1236
1242
|
} catch (error) {
|
|
1243
|
+
entry.drop?.();
|
|
1237
1244
|
warnOnce(
|
|
1238
1245
|
"sim-plan-held-span-dropped",
|
|
1239
1246
|
`a span held for the sim plan was dropped when released: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -2564,23 +2571,21 @@ var init_http = __esm({
|
|
|
2564
2571
|
}
|
|
2565
2572
|
const deadline = Date.now() + Math.max(timeoutMs, 0);
|
|
2566
2573
|
this.closing = (async () => {
|
|
2567
|
-
|
|
2568
|
-
|
|
2574
|
+
liveHttpClients.delete(this);
|
|
2575
|
+
const settled2 = await this.settleDeferredWork(
|
|
2576
|
+
Math.max(0, deadline - Date.now())
|
|
2569
2577
|
);
|
|
2570
2578
|
this.stopSimulationPlan?.();
|
|
2579
|
+
this.closed = true;
|
|
2571
2580
|
this.externalSpanTransform = void 0;
|
|
2572
2581
|
this.externalTraceTransform = void 0;
|
|
2582
|
+
this.frameworkSpanStart = void 0;
|
|
2573
2583
|
this.releaseHeldExternalSpans = void 0;
|
|
2574
2584
|
this.stopSimulationPlan = void 0;
|
|
2575
|
-
liveHttpClients.delete(this);
|
|
2576
|
-
const settled2 = await this.settleDeferredWork(
|
|
2577
|
-
Math.max(0, deadline - Date.now())
|
|
2578
|
-
);
|
|
2579
|
-
this.closed = true;
|
|
2580
2585
|
const transport = this.traceTransport;
|
|
2581
2586
|
this.traceTransport = void 0;
|
|
2582
2587
|
const shutdownOk = await transport?.shutdown(Math.max(0, deadline - Date.now())) ?? true;
|
|
2583
|
-
return
|
|
2588
|
+
return settled2 && shutdownOk;
|
|
2584
2589
|
})();
|
|
2585
2590
|
return this.closing;
|
|
2586
2591
|
}
|
|
@@ -2681,8 +2686,7 @@ var init_http = __esm({
|
|
|
2681
2686
|
async getSimulationPlan() {
|
|
2682
2687
|
return this.get(
|
|
2683
2688
|
"/api/sdk/sim-plan",
|
|
2684
|
-
SIMULATION_PLAN_READ_TIMEOUT_MS
|
|
2685
|
-
{ Connection: "close" }
|
|
2689
|
+
SIMULATION_PLAN_READ_TIMEOUT_MS
|
|
2686
2690
|
);
|
|
2687
2691
|
}
|
|
2688
2692
|
async getTraceSpan(traceId, lookup) {
|
|
@@ -2758,19 +2762,35 @@ var init_http = __esm({
|
|
|
2758
2762
|
carrierMeta("internal_trace", body, void 0)
|
|
2759
2763
|
);
|
|
2760
2764
|
}
|
|
2765
|
+
reserveFrameworkSpan(traceId, spanId, parentSpanId) {
|
|
2766
|
+
try {
|
|
2767
|
+
this.frameworkSpanStart?.(traceId, spanId, parentSpanId ?? null);
|
|
2768
|
+
} catch (error) {
|
|
2769
|
+
warnOnce(
|
|
2770
|
+
"framework-span-reservation-failed",
|
|
2771
|
+
`a framework span could not be counted toward its trace's span limit: ${describeError(error)}`
|
|
2772
|
+
);
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2761
2775
|
sendExternalSpan(payload) {
|
|
2762
2776
|
const ref2 = carrierRef(payload);
|
|
2763
2777
|
if (ref2?.spanId !== void 0) {
|
|
2764
2778
|
this.traceCompletion.record(ref2.traceId, ref2.spanId);
|
|
2765
2779
|
}
|
|
2780
|
+
const drop = () => {
|
|
2781
|
+
if (ref2?.spanId !== void 0) {
|
|
2782
|
+
this.traceCompletion.abort(ref2.traceId, ref2.spanId);
|
|
2783
|
+
}
|
|
2784
|
+
};
|
|
2766
2785
|
const gate = this.externalSpanTransform;
|
|
2767
2786
|
if (gate === void 0) {
|
|
2768
2787
|
this.submitExternalSpan(payload);
|
|
2769
2788
|
return;
|
|
2770
2789
|
}
|
|
2771
2790
|
try {
|
|
2772
|
-
gate(payload, (ready) => this.submitExternalSpan(ready));
|
|
2791
|
+
gate(payload, (ready) => this.submitExternalSpan(ready), drop);
|
|
2773
2792
|
} catch (error) {
|
|
2793
|
+
drop();
|
|
2774
2794
|
warnDroppedExternalSpan(error);
|
|
2775
2795
|
}
|
|
2776
2796
|
}
|
|
@@ -4382,7 +4402,6 @@ __export(index_exports, {
|
|
|
4382
4402
|
NO_MOCK_OVERRIDE: () => NO_MOCK_OVERRIDE,
|
|
4383
4403
|
ReplayError: () => ReplayError,
|
|
4384
4404
|
SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
|
|
4385
|
-
TraceAssertionsClient: () => TraceAssertionsClient,
|
|
4386
4405
|
TracesClient: () => TracesClient,
|
|
4387
4406
|
__version__: () => __version__,
|
|
4388
4407
|
defineReplayRegistry: () => defineReplayRegistry,
|
|
@@ -4657,6 +4676,11 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4657
4676
|
}
|
|
4658
4677
|
this.runToSpan.set(spanId, spanInfo);
|
|
4659
4678
|
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
4679
|
+
this.httpClient.reserveFrameworkSpan(
|
|
4680
|
+
spanInfo.traceId,
|
|
4681
|
+
spanInfo.spanId,
|
|
4682
|
+
spanInfo.parentId
|
|
4683
|
+
);
|
|
4660
4684
|
return spanInfo;
|
|
4661
4685
|
}
|
|
4662
4686
|
completeSpan(spanId, output, error, extraContexts) {
|
|
@@ -4936,6 +4960,11 @@ var BitfabClaudeAgentHandler = class {
|
|
|
4936
4960
|
this.conversationHistory.push(...this.pendingMessages);
|
|
4937
4961
|
this.pendingMessages = [];
|
|
4938
4962
|
this.currentLlmSpanId = randomUuid();
|
|
4963
|
+
this.httpClient.reserveFrameworkSpan(
|
|
4964
|
+
this.ensureTrace(),
|
|
4965
|
+
this.currentLlmSpanId,
|
|
4966
|
+
this.getParentId()
|
|
4967
|
+
);
|
|
4939
4968
|
this.currentLlmMessageId = messageId ?? null;
|
|
4940
4969
|
this.currentLlmContent = [];
|
|
4941
4970
|
this.currentLlmModel = inner.model ?? null;
|
|
@@ -5979,6 +6008,9 @@ init_http();
|
|
|
5979
6008
|
// src/labels.ts
|
|
5980
6009
|
var LABELS_PATH = "/api/sdk/traces/labels";
|
|
5981
6010
|
var HUMAN_LABELS_PATH = "/api/sdk/traces/labels/human";
|
|
6011
|
+
function labelEvidencePath(traceId, assertionId) {
|
|
6012
|
+
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions/${encodeURIComponent(assertionId)}/evidence`;
|
|
6013
|
+
}
|
|
5982
6014
|
var LabelsClient = class {
|
|
5983
6015
|
constructor(httpClient) {
|
|
5984
6016
|
this.httpClient = httpClient;
|
|
@@ -6027,6 +6059,11 @@ var LabelsClient = class {
|
|
|
6027
6059
|
);
|
|
6028
6060
|
return response.labels;
|
|
6029
6061
|
}
|
|
6062
|
+
/** Generate suggested evidence for an assertion on an original or replay trace. */
|
|
6063
|
+
async generateLabelEvidence(traceId, assertionId) {
|
|
6064
|
+
const response = await this.httpClient.get(labelEvidencePath(traceId, assertionId));
|
|
6065
|
+
return response.evidence;
|
|
6066
|
+
}
|
|
6030
6067
|
};
|
|
6031
6068
|
|
|
6032
6069
|
// src/langgraph.ts
|
|
@@ -6338,6 +6375,11 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
6338
6375
|
this.runToSpan.set(runId, spanInfo);
|
|
6339
6376
|
if (spanInfo.hidden !== true) {
|
|
6340
6377
|
this.httpClient.traceCompletion.start(spanInfo.traceId, spanInfo.spanId);
|
|
6378
|
+
this.httpClient.reserveFrameworkSpan(
|
|
6379
|
+
spanInfo.traceId,
|
|
6380
|
+
spanInfo.spanId,
|
|
6381
|
+
spanInfo.parentId
|
|
6382
|
+
);
|
|
6341
6383
|
}
|
|
6342
6384
|
if (isRootInvocation) {
|
|
6343
6385
|
this.sendTraceStart(spanInfo);
|
|
@@ -7741,23 +7783,9 @@ var SEARCH_PATH = "/api/sdk/traces/search";
|
|
|
7741
7783
|
function traceAssertionsPath(traceId, suffix = "") {
|
|
7742
7784
|
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
|
|
7743
7785
|
}
|
|
7744
|
-
function assertionEvidencePath(assertionId) {
|
|
7745
|
-
return `/api/sdk/traces/assertions/${encodeURIComponent(assertionId)}/evidence`;
|
|
7746
|
-
}
|
|
7747
|
-
var TraceAssertionsClient = class {
|
|
7748
|
-
constructor(httpClient) {
|
|
7749
|
-
this.httpClient = httpClient;
|
|
7750
|
-
}
|
|
7751
|
-
/** Suggest evidence for an assertion, enriched with its span context. */
|
|
7752
|
-
async getAssertionEvidence(assertionId) {
|
|
7753
|
-
const response = await this.httpClient.get(assertionEvidencePath(assertionId));
|
|
7754
|
-
return response.evidence;
|
|
7755
|
-
}
|
|
7756
|
-
};
|
|
7757
7786
|
var TracesClient = class {
|
|
7758
7787
|
constructor(httpClient) {
|
|
7759
7788
|
this.httpClient = httpClient;
|
|
7760
|
-
this.assertions = new TraceAssertionsClient(httpClient);
|
|
7761
7789
|
}
|
|
7762
7790
|
async search(params) {
|
|
7763
7791
|
return this.httpClient.request(SEARCH_PATH, params);
|
|
@@ -7897,8 +7925,14 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7897
7925
|
async onSpanStart(span) {
|
|
7898
7926
|
if (span.spanId !== void 0 && span.traceId !== null && span.traceId !== void 0) {
|
|
7899
7927
|
this.startedSpans.set(span.spanId, span.traceId);
|
|
7900
|
-
const
|
|
7928
|
+
const mapping = this.activeSpanMappings[span.traceId];
|
|
7929
|
+
const traceId = mapping?.traceId ?? span.traceId;
|
|
7901
7930
|
this.httpClient.traceCompletion.start(traceId, span.spanId);
|
|
7931
|
+
this.httpClient.reserveFrameworkSpan(
|
|
7932
|
+
traceId,
|
|
7933
|
+
span.spanId,
|
|
7934
|
+
span.parentId ?? mapping?.spanId
|
|
7935
|
+
);
|
|
7902
7936
|
}
|
|
7903
7937
|
}
|
|
7904
7938
|
/**
|
|
@@ -8285,22 +8319,68 @@ var BitfabVercelAiHandler = class {
|
|
|
8285
8319
|
|
|
8286
8320
|
// src/client.ts
|
|
8287
8321
|
init_warnOnce();
|
|
8322
|
+
var TRUNCATION_LIMIT_ORDER = [
|
|
8323
|
+
"max_depth",
|
|
8324
|
+
"max_spans",
|
|
8325
|
+
"max_captured_subtree_spans"
|
|
8326
|
+
];
|
|
8288
8327
|
var activeTraceStates = /* @__PURE__ */ new Map();
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8328
|
+
var REFUSED_FRAMEWORK_SPAN_TRACES_RETAINED = 1024;
|
|
8329
|
+
var refusedFrameworkSpans = /* @__PURE__ */ new Map();
|
|
8330
|
+
function frameworkSpanRefused(traceId, spanId) {
|
|
8331
|
+
return refusedFrameworkSpans.get(traceId)?.has(spanId) === true;
|
|
8332
|
+
}
|
|
8333
|
+
function refuseFrameworkSpan(traceId, spanId) {
|
|
8334
|
+
const refused = refusedFrameworkSpans.get(traceId);
|
|
8335
|
+
if (refused !== void 0) {
|
|
8336
|
+
refused.add(spanId);
|
|
8337
|
+
return;
|
|
8292
8338
|
}
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8339
|
+
refusedFrameworkSpans.set(traceId, /* @__PURE__ */ new Set([spanId]));
|
|
8340
|
+
while (refusedFrameworkSpans.size > REFUSED_FRAMEWORK_SPAN_TRACES_RETAINED) {
|
|
8341
|
+
const oldest = refusedFrameworkSpans.keys().next();
|
|
8342
|
+
if (oldest.done) {
|
|
8343
|
+
return;
|
|
8344
|
+
}
|
|
8345
|
+
refusedFrameworkSpans.delete(oldest.value);
|
|
8346
|
+
}
|
|
8347
|
+
}
|
|
8348
|
+
function reserveFrameworkSpan(traceId, spanId, parentSpanId) {
|
|
8349
|
+
const spanBudget = activeTraceStates.get(traceId)?.spanBudget;
|
|
8350
|
+
const parentRefused = parentSpanId !== null && frameworkSpanRefused(traceId, parentSpanId);
|
|
8351
|
+
if (!parentRefused && (spanBudget === void 0 || spanBudget.spansUsed < spanBudget.maxSpans)) {
|
|
8352
|
+
if (spanBudget !== void 0) {
|
|
8353
|
+
spanBudget.spansUsed += 1;
|
|
8354
|
+
}
|
|
8355
|
+
return;
|
|
8297
8356
|
}
|
|
8298
|
-
|
|
8299
|
-
|
|
8357
|
+
refuseFrameworkSpan(traceId, spanId);
|
|
8358
|
+
spanBudget?.truncate("max_spans");
|
|
8359
|
+
}
|
|
8360
|
+
function isRefusedFrameworkSpan(payload) {
|
|
8361
|
+
if (!recordedByFramework(payload)) {
|
|
8300
8362
|
return false;
|
|
8301
8363
|
}
|
|
8302
|
-
|
|
8303
|
-
|
|
8364
|
+
const rawSpan = payload.rawSpan;
|
|
8365
|
+
const spanId = rawSpan?.id;
|
|
8366
|
+
if (typeof spanId !== "string") {
|
|
8367
|
+
return false;
|
|
8368
|
+
}
|
|
8369
|
+
const traceIds = [payload.sourceTraceId, traceIdOf(payload)];
|
|
8370
|
+
return traceIds.some(
|
|
8371
|
+
(traceId) => typeof traceId === "string" && frameworkSpanRefused(traceId, spanId)
|
|
8372
|
+
);
|
|
8373
|
+
}
|
|
8374
|
+
function truncationMetadata(truncation) {
|
|
8375
|
+
if (truncation === void 0 || truncation.limits.size === 0) {
|
|
8376
|
+
return void 0;
|
|
8377
|
+
}
|
|
8378
|
+
return {
|
|
8379
|
+
"bitfab.truncated_by": TRUNCATION_LIMIT_ORDER.filter(
|
|
8380
|
+
(limit) => truncation.limits.has(limit)
|
|
8381
|
+
).join(","),
|
|
8382
|
+
"bitfab.dropped_spans": truncation.droppedSpans
|
|
8383
|
+
};
|
|
8304
8384
|
}
|
|
8305
8385
|
function rootTraceFunctionKeyOfTrace(traceId, fallback) {
|
|
8306
8386
|
return activeTraceStates.get(traceId)?.traceFunctionKey ?? fallback;
|
|
@@ -8682,7 +8762,6 @@ function readBooleanEnv(name) {
|
|
|
8682
8762
|
var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
|
|
8683
8763
|
var DEFAULT_AUTO_TRACE_MAX_SPANS = 2048;
|
|
8684
8764
|
var DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS = 512;
|
|
8685
|
-
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
8686
8765
|
function spanOwnerName(receiver) {
|
|
8687
8766
|
if (typeof receiver === "function") {
|
|
8688
8767
|
return receiver.name !== "" ? receiver.name : void 0;
|
|
@@ -8748,7 +8827,8 @@ var Bitfab = class {
|
|
|
8748
8827
|
this.httpClient,
|
|
8749
8828
|
config.simulationPlan ?? true
|
|
8750
8829
|
);
|
|
8751
|
-
this.httpClient.externalSpanTransform = (payload, submit) => this.applySimulationPlan(payload, submit);
|
|
8830
|
+
this.httpClient.externalSpanTransform = (payload, submit, drop) => this.applySimulationPlan(payload, submit, drop);
|
|
8831
|
+
this.httpClient.frameworkSpanStart = reserveFrameworkSpan;
|
|
8752
8832
|
this.httpClient.externalTraceTransform = (payload, submit) => this.simulationPlan.sendTrace(payload, submit);
|
|
8753
8833
|
this.httpClient.releaseHeldExternalSpans = (timeoutMs) => this.simulationPlan.release(timeoutMs);
|
|
8754
8834
|
this.httpClient.stopSimulationPlan = () => this.simulationPlan.stop();
|
|
@@ -8944,35 +9024,31 @@ var Bitfab = class {
|
|
|
8944
9024
|
function(...args) {
|
|
8945
9025
|
self.simulationPlan.refresh();
|
|
8946
9026
|
let capturedSubtreeCount = 0;
|
|
8947
|
-
|
|
8948
|
-
const
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
maxCapturedSubtreeSpans
|
|
8958
|
-
}
|
|
8959
|
-
});
|
|
8960
|
-
}
|
|
9027
|
+
const rootSpanStack = getSpanStack();
|
|
9028
|
+
const rootSpan = rootSpanStack[rootSpanStack.length - 1];
|
|
9029
|
+
const rootTraceState = rootSpan === void 0 ? void 0 : activeTraceStates.get(rootSpan.traceId);
|
|
9030
|
+
const truncation = rootTraceState?.truncation ?? {
|
|
9031
|
+
limits: /* @__PURE__ */ new Set(),
|
|
9032
|
+
droppedSpans: 0
|
|
9033
|
+
};
|
|
9034
|
+
const truncate = (limit) => {
|
|
9035
|
+
truncation.limits.add(limit);
|
|
9036
|
+
truncation.droppedSpans += 1;
|
|
8961
9037
|
warnOnce(
|
|
8962
9038
|
`auto-trace-truncated:${traceFunctionKey}`,
|
|
8963
9039
|
`"${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.`
|
|
8964
9040
|
);
|
|
8965
9041
|
};
|
|
8966
|
-
const rootSpanStack = getSpanStack();
|
|
8967
9042
|
const spanBudget = {
|
|
8968
9043
|
spansUsed: 1,
|
|
8969
9044
|
maxSpans,
|
|
8970
|
-
truncate
|
|
9045
|
+
truncate
|
|
8971
9046
|
};
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
9047
|
+
if (rootTraceState !== void 0) {
|
|
9048
|
+
rootTraceState.truncation = truncation;
|
|
9049
|
+
if (rootTraceState.spanBudget === void 0) {
|
|
9050
|
+
rootTraceState.spanBudget = spanBudget;
|
|
9051
|
+
}
|
|
8976
9052
|
}
|
|
8977
9053
|
const spanStackOf = (entry) => entry.spanStack;
|
|
8978
9054
|
const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
|
|
@@ -9012,15 +9088,16 @@ var Bitfab = class {
|
|
|
9012
9088
|
rootTraceFunctionKeyOfEntry(entry),
|
|
9013
9089
|
spanName
|
|
9014
9090
|
);
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
}
|
|
9020
|
-
return true;
|
|
9091
|
+
const refusedBy = entry.depth >= maxDepth ? "max_depth" : spanBudget.spansUsed >= maxSpans ? "max_spans" : countsTowardCapturedSubtree && capturedSubtreeCount >= maxCapturedSubtreeSpans ? "max_captured_subtree_spans" : void 0;
|
|
9092
|
+
if (refusedBy !== void 0) {
|
|
9093
|
+
truncate(refusedBy);
|
|
9094
|
+
return false;
|
|
9021
9095
|
}
|
|
9022
|
-
|
|
9023
|
-
|
|
9096
|
+
spanBudget.spansUsed += 1;
|
|
9097
|
+
if (countsTowardCapturedSubtree) {
|
|
9098
|
+
capturedSubtreeCount += 1;
|
|
9099
|
+
}
|
|
9100
|
+
return true;
|
|
9024
9101
|
};
|
|
9025
9102
|
const autoTraceContext = {
|
|
9026
9103
|
traceFunctionKey,
|
|
@@ -9147,11 +9224,17 @@ var Bitfab = class {
|
|
|
9147
9224
|
Object.defineProperty(autoTraceRoot, "_bitfabWrappedFn", { value: fn });
|
|
9148
9225
|
return autoTraceRoot;
|
|
9149
9226
|
}
|
|
9150
|
-
applySimulationPlan(payload, submit) {
|
|
9151
|
-
if (
|
|
9227
|
+
applySimulationPlan(payload, submit, drop) {
|
|
9228
|
+
if (isRefusedFrameworkSpan(payload)) {
|
|
9229
|
+
drop();
|
|
9152
9230
|
return;
|
|
9153
9231
|
}
|
|
9154
|
-
this.simulationPlan.send(
|
|
9232
|
+
this.simulationPlan.send(
|
|
9233
|
+
payload,
|
|
9234
|
+
rootTraceFunctionKeyOf(payload),
|
|
9235
|
+
submit,
|
|
9236
|
+
drop
|
|
9237
|
+
);
|
|
9155
9238
|
}
|
|
9156
9239
|
/**
|
|
9157
9240
|
* Flush and permanently close this client's tracing resources: its pending
|
|
@@ -9820,6 +9903,9 @@ var Bitfab = class {
|
|
|
9820
9903
|
registeredTraceId = traceId;
|
|
9821
9904
|
}
|
|
9822
9905
|
self.httpClient.traceCompletion.start(traceId, spanId);
|
|
9906
|
+
if (isFrameworkInstrumentation(options.instrumentation)) {
|
|
9907
|
+
reserveFrameworkSpan(traceId, spanId, parentSpanId);
|
|
9908
|
+
}
|
|
9823
9909
|
startedSpan = { traceId, spanId };
|
|
9824
9910
|
const functionName = fn.name !== "" ? fn.name : void 0;
|
|
9825
9911
|
const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
|
|
@@ -9864,6 +9950,10 @@ var Bitfab = class {
|
|
|
9864
9950
|
}
|
|
9865
9951
|
if (isRootSpan) {
|
|
9866
9952
|
const traceState = activeTraceStates.get(traceId);
|
|
9953
|
+
const truncated = truncationMetadata(traceState?.truncation);
|
|
9954
|
+
if (truncated !== void 0) {
|
|
9955
|
+
recordCallerTraceMetadata(traceId, truncated);
|
|
9956
|
+
}
|
|
9867
9957
|
self.sendTraceCompletion({
|
|
9868
9958
|
traceFunctionKey,
|
|
9869
9959
|
traceId,
|
|
@@ -10416,7 +10506,7 @@ var Bitfab = class {
|
|
|
10416
10506
|
...params.captureContent && params.contexts && params.contexts.length > 0 && {
|
|
10417
10507
|
contexts: params.contexts
|
|
10418
10508
|
},
|
|
10419
|
-
...
|
|
10509
|
+
...buildsContent && params.prompt !== void 0 && { prompt: params.prompt },
|
|
10420
10510
|
...contentOff && { [CONTENT_OFF_KEY]: true }
|
|
10421
10511
|
}
|
|
10422
10512
|
};
|
|
@@ -11011,7 +11101,6 @@ function resolveTraceFunctionKey(registration) {
|
|
|
11011
11101
|
NO_MOCK_OVERRIDE,
|
|
11012
11102
|
ReplayError,
|
|
11013
11103
|
SUPPORTED_PROVIDERS,
|
|
11014
|
-
TraceAssertionsClient,
|
|
11015
11104
|
TracesClient,
|
|
11016
11105
|
__version__,
|
|
11017
11106
|
defineReplayRegistry,
|