bitfab 0.54.12 → 0.54.14
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/autoTrace.cjs +0 -19
- package/dist/autoTrace.cjs.map +1 -1
- package/dist/autoTrace.d.cts +1 -3
- package/dist/autoTrace.d.ts +1 -3
- package/dist/autoTrace.js +1 -5
- package/dist/{chunk-RDSNJFWY.js → chunk-3FL22BEM.js} +37 -7
- package/dist/chunk-3FL22BEM.js.map +1 -0
- package/dist/{chunk-VTFBDA3O.js → chunk-N7ZNDZLR.js} +21 -15
- package/dist/chunk-N7ZNDZLR.js.map +1 -0
- package/dist/{chunk-WKXLCFLT.js → chunk-NIGVK5V7.js} +22 -16
- package/dist/chunk-NIGVK5V7.js.map +1 -0
- package/dist/{chunk-EGWJYCNT.js → chunk-RCHSYWKI.js} +2 -19
- package/dist/chunk-RCHSYWKI.js.map +1 -0
- package/dist/{chunk-YY5BB2YS.js → chunk-SV5FYJQ4.js} +33 -60
- package/dist/chunk-SV5FYJQ4.js.map +1 -0
- package/dist/{chunk-ZR4HGK6G.js → chunk-X6JOFMNV.js} +9 -3
- package/dist/chunk-X6JOFMNV.js.map +1 -0
- package/dist/{http-NWSSB5FA.js → http-HM2SNB6L.js} +2 -2
- package/dist/{http-RJH6VYAM.js → http-ZXMIZQV5.js} +2 -2
- package/dist/index.cjs +54 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -14
- package/dist/index.d.ts +16 -14
- package/dist/index.js +4 -4
- package/dist/node.cjs +54 -83
- 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 +4 -4
- package/dist/{replay-WB5NQNQS.js → replay-XCXNPWMC.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-EGWJYCNT.js.map +0 -1
- package/dist/chunk-RDSNJFWY.js.map +0 -1
- package/dist/chunk-VTFBDA3O.js.map +0 -1
- package/dist/chunk-WKXLCFLT.js.map +0 -1
- package/dist/chunk-YY5BB2YS.js.map +0 -1
- package/dist/chunk-ZR4HGK6G.js.map +0 -1
- /package/dist/{http-NWSSB5FA.js.map → http-HM2SNB6L.js.map} +0 -0
- /package/dist/{http-RJH6VYAM.js.map → http-ZXMIZQV5.js.map} +0 -0
- /package/dist/{replay-WB5NQNQS.js.map → replay-XCXNPWMC.js.map} +0 -0
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.54.
|
|
54
|
+
__version__ = "0.54.14";
|
|
55
55
|
__packageName__ = "bitfab";
|
|
56
56
|
}
|
|
57
57
|
});
|
|
@@ -1265,6 +1265,7 @@ var init_simulationPlan = __esm({
|
|
|
1265
1265
|
}
|
|
1266
1266
|
this.warnNeverLoaded();
|
|
1267
1267
|
this.warnDropped();
|
|
1268
|
+
return this.held.length === 0;
|
|
1268
1269
|
}
|
|
1269
1270
|
waitForFirstLoad(timeoutMs) {
|
|
1270
1271
|
const firstLoad = this.firstLoad();
|
|
@@ -2087,9 +2088,14 @@ __export(http_exports, {
|
|
|
2087
2088
|
});
|
|
2088
2089
|
async function releaseHeldExternalSpans(timeoutMs) {
|
|
2089
2090
|
const deadline = Date.now() + Math.max(timeoutMs, 0);
|
|
2091
|
+
let released = true;
|
|
2090
2092
|
for (const client of [...liveHttpClients]) {
|
|
2091
|
-
await client.releaseHeldExternalSpans?.(
|
|
2093
|
+
const result = await client.releaseHeldExternalSpans?.(
|
|
2094
|
+
Math.max(0, deadline - Date.now())
|
|
2095
|
+
);
|
|
2096
|
+
released = result !== false && released;
|
|
2092
2097
|
}
|
|
2098
|
+
return released;
|
|
2093
2099
|
}
|
|
2094
2100
|
function stopSimulationPlans() {
|
|
2095
2101
|
for (const client of [...liveHttpClients]) {
|
|
@@ -2106,14 +2112,15 @@ function awaitOnExit(promise) {
|
|
|
2106
2112
|
}
|
|
2107
2113
|
async function flushTraces(timeoutMs = 5e3) {
|
|
2108
2114
|
const deadline = Date.now() + Math.max(timeoutMs, 0);
|
|
2109
|
-
await releaseHeldExternalSpans(planWaitSliceMs(timeoutMs));
|
|
2115
|
+
const released = await releaseHeldExternalSpans(planWaitSliceMs(timeoutMs));
|
|
2110
2116
|
const requestsFlushed = await awaitPendingRequests(
|
|
2111
2117
|
Math.max(0, deadline - Date.now())
|
|
2112
2118
|
);
|
|
2119
|
+
const releasedAfterDeferred = await releaseHeldExternalSpans(0);
|
|
2113
2120
|
const transportsFlushed = await flushTraceTransports(
|
|
2114
2121
|
Math.max(0, deadline - Date.now())
|
|
2115
2122
|
);
|
|
2116
|
-
return requestsFlushed && transportsFlushed;
|
|
2123
|
+
return released && releasedAfterDeferred && requestsFlushed && transportsFlushed;
|
|
2117
2124
|
}
|
|
2118
2125
|
async function awaitPendingRequests(timeoutMs = DEFAULT_LIFECYCLE_TIMEOUT_MS2) {
|
|
2119
2126
|
await replayContextReady.catch(() => {
|
|
@@ -2523,13 +2530,17 @@ var init_http = __esm({
|
|
|
2523
2530
|
*/
|
|
2524
2531
|
async settleDeferredWork(timeoutMs = DEFAULT_LIFECYCLE_TIMEOUT_MS2) {
|
|
2525
2532
|
const deadline = Date.now() + Math.max(timeoutMs, 0);
|
|
2526
|
-
await this.releaseHeldExternalSpans?.(
|
|
2533
|
+
const released = await this.releaseHeldExternalSpans?.(
|
|
2534
|
+
planWaitSliceMs(timeoutMs)
|
|
2535
|
+
);
|
|
2527
2536
|
await replayContextReady.catch(() => {
|
|
2528
2537
|
});
|
|
2529
|
-
|
|
2538
|
+
const settled2 = await waitForPromises(
|
|
2530
2539
|
Array.from(this.deferredWork),
|
|
2531
2540
|
Math.max(0, deadline - Date.now())
|
|
2532
2541
|
);
|
|
2542
|
+
const releasedAfterDeferred = await this.releaseHeldExternalSpans?.(0);
|
|
2543
|
+
return released !== false && releasedAfterDeferred !== false && settled2;
|
|
2533
2544
|
}
|
|
2534
2545
|
/**
|
|
2535
2546
|
* Wait for spans queued by this client to be delivered, within one deadline.
|
|
@@ -2554,7 +2565,9 @@ var init_http = __esm({
|
|
|
2554
2565
|
}
|
|
2555
2566
|
const deadline = Date.now() + Math.max(timeoutMs, 0);
|
|
2556
2567
|
this.closing = (async () => {
|
|
2557
|
-
await this.releaseHeldExternalSpans?.(
|
|
2568
|
+
const released = await this.releaseHeldExternalSpans?.(
|
|
2569
|
+
planWaitSliceMs(timeoutMs)
|
|
2570
|
+
);
|
|
2558
2571
|
this.stopSimulationPlan?.();
|
|
2559
2572
|
this.externalSpanTransform = void 0;
|
|
2560
2573
|
this.externalTraceTransform = void 0;
|
|
@@ -2568,7 +2581,7 @@ var init_http = __esm({
|
|
|
2568
2581
|
const transport = this.traceTransport;
|
|
2569
2582
|
this.traceTransport = void 0;
|
|
2570
2583
|
const shutdownOk = await transport?.shutdown(Math.max(0, deadline - Date.now())) ?? true;
|
|
2571
|
-
return settled2 && shutdownOk;
|
|
2584
|
+
return released !== false && settled2 && shutdownOk;
|
|
2572
2585
|
})();
|
|
2573
2586
|
return this.closing;
|
|
2574
2587
|
}
|
|
@@ -2666,12 +2679,6 @@ var init_http = __esm({
|
|
|
2666
2679
|
async lookupFunction(name) {
|
|
2667
2680
|
return this.request("/api/sdk/functions/lookup", { name });
|
|
2668
2681
|
}
|
|
2669
|
-
async getAutoTracePolicy(traceFunctionKey, protocol) {
|
|
2670
|
-
return this.request("/api/sdk/auto-trace/policy", {
|
|
2671
|
-
traceFunctionKey,
|
|
2672
|
-
protocol
|
|
2673
|
-
});
|
|
2674
|
-
}
|
|
2675
2682
|
async getSimulationPlan() {
|
|
2676
2683
|
return this.get(
|
|
2677
2684
|
"/api/sdk/sim-plan",
|
|
@@ -4008,6 +4015,12 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
4008
4015
|
}
|
|
4009
4016
|
}
|
|
4010
4017
|
const attempts = resolveAttempts(options?.attempts);
|
|
4018
|
+
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
4019
|
+
if (!Number.isInteger(maxConcurrency) || maxConcurrency < 1) {
|
|
4020
|
+
throw new BitfabError(
|
|
4021
|
+
`maxConcurrency must be a positive integer (got ${maxConcurrency}).`
|
|
4022
|
+
);
|
|
4023
|
+
}
|
|
4011
4024
|
await replayContextReady;
|
|
4012
4025
|
let codeChangeDescription = options?.codeChangeDescription;
|
|
4013
4026
|
let codeChangeFiles = options?.codeChangeFiles;
|
|
@@ -4054,7 +4067,6 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
4054
4067
|
}
|
|
4055
4068
|
}
|
|
4056
4069
|
const mockStrategy = options?.mock ?? "marked";
|
|
4057
|
-
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
4058
4070
|
const fullTestRunUrl = `${serviceUrl}${testRunUrl}`;
|
|
4059
4071
|
const resolvedOverrides = [
|
|
4060
4072
|
...normalizeMockOverrides(options?.mockOverride),
|
|
@@ -4151,6 +4163,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
4151
4163
|
originalDurationMs: item.originalDurationMs,
|
|
4152
4164
|
originalTokens: item.originalTokens,
|
|
4153
4165
|
originalModel: item.originalModel,
|
|
4166
|
+
ingestionType: item.ingestionType,
|
|
4154
4167
|
tokens: item.tokens,
|
|
4155
4168
|
model: item.model,
|
|
4156
4169
|
dbSnapshotRef: item.dbSnapshotRef,
|
|
@@ -5195,21 +5208,6 @@ function currentAutoTraceScope() {
|
|
|
5195
5208
|
initializeAutoTraceStorage();
|
|
5196
5209
|
return autoTraceState.storage?.getStore() ?? autoTraceState.browserScope;
|
|
5197
5210
|
}
|
|
5198
|
-
function __setBitfabAutoTraceCapturePolicy(client, traceFunctionKey, functionIds) {
|
|
5199
|
-
const policies = autoTraceState.capturePolicies.get(client) ?? /* @__PURE__ */ new Map();
|
|
5200
|
-
if (functionIds === void 0) {
|
|
5201
|
-
policies.delete(traceFunctionKey);
|
|
5202
|
-
if (policies.size === 0) {
|
|
5203
|
-
autoTraceState.capturePolicies.delete(client);
|
|
5204
|
-
}
|
|
5205
|
-
return;
|
|
5206
|
-
}
|
|
5207
|
-
policies.set(traceFunctionKey, new Set(functionIds));
|
|
5208
|
-
autoTraceState.capturePolicies.set(client, policies);
|
|
5209
|
-
}
|
|
5210
|
-
function getAutoTraceCapturePolicy(client, traceFunctionKey) {
|
|
5211
|
-
return autoTraceState.capturePolicies.get(client)?.get(traceFunctionKey);
|
|
5212
|
-
}
|
|
5213
5211
|
|
|
5214
5212
|
// src/optionalPeer.ts
|
|
5215
5213
|
function importOptionalPeer(specifierParts) {
|
|
@@ -5999,6 +5997,14 @@ var LabelsClient = class {
|
|
|
5999
5997
|
);
|
|
6000
5998
|
return response.labels;
|
|
6001
5999
|
}
|
|
6000
|
+
/** Withhold a verdict for a trace or replay attempt whose check did not run. */
|
|
6001
|
+
async skip(target, testRunId) {
|
|
6002
|
+
return this.save({ ...target, skip: true }, testRunId);
|
|
6003
|
+
}
|
|
6004
|
+
/** Clear a previous verdict for a trace, replay attempt, or assertion. */
|
|
6005
|
+
async archive(target, testRunId) {
|
|
6006
|
+
return this.save({ ...target, archive: true }, testRunId);
|
|
6007
|
+
}
|
|
6002
6008
|
async saveHuman(update) {
|
|
6003
6009
|
const [outcome] = await this.saveHumanAll([update]);
|
|
6004
6010
|
return outcome;
|
|
@@ -6917,6 +6923,15 @@ var BitfabLangGraphIntegration = class {
|
|
|
6917
6923
|
// src/client.ts
|
|
6918
6924
|
init_mockOverride();
|
|
6919
6925
|
|
|
6926
|
+
// src/streamFinalizationError.ts
|
|
6927
|
+
var StreamFinalizationError = class extends Error {
|
|
6928
|
+
constructor(message, output) {
|
|
6929
|
+
super(message);
|
|
6930
|
+
this.output = output;
|
|
6931
|
+
this.name = "StreamFinalizationError";
|
|
6932
|
+
}
|
|
6933
|
+
};
|
|
6934
|
+
|
|
6920
6935
|
// src/openaiAgentSdk.ts
|
|
6921
6936
|
var BitfabOpenAIAgentHandler = class {
|
|
6922
6937
|
constructor(config) {
|
|
@@ -6956,7 +6971,11 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
6956
6971
|
if (isStreaming && res?.completed) {
|
|
6957
6972
|
try {
|
|
6958
6973
|
await res.completed;
|
|
6959
|
-
} catch {
|
|
6974
|
+
} catch (error) {
|
|
6975
|
+
throw new StreamFinalizationError(
|
|
6976
|
+
error instanceof Error ? error.message : String(error),
|
|
6977
|
+
res.finalOutput
|
|
6978
|
+
);
|
|
6960
6979
|
}
|
|
6961
6980
|
}
|
|
6962
6981
|
return res?.finalOutput;
|
|
@@ -7058,7 +7077,6 @@ function openAiAgentsParentSpanId(bitfabTraceId, enclosingSpanIds) {
|
|
|
7058
7077
|
}
|
|
7059
7078
|
|
|
7060
7079
|
// src/client.ts
|
|
7061
|
-
init_policyRefresh();
|
|
7062
7080
|
init_randomUuid();
|
|
7063
7081
|
init_replay();
|
|
7064
7082
|
|
|
@@ -7715,17 +7733,6 @@ function runWithSeedContext(ctx, fn) {
|
|
|
7715
7733
|
init_serialize();
|
|
7716
7734
|
init_simulationPlan();
|
|
7717
7735
|
init_spanOrigin();
|
|
7718
|
-
|
|
7719
|
-
// src/streamFinalizationError.ts
|
|
7720
|
-
var StreamFinalizationError = class extends Error {
|
|
7721
|
-
constructor(message, output) {
|
|
7722
|
-
super(message);
|
|
7723
|
-
this.output = output;
|
|
7724
|
-
this.name = "StreamFinalizationError";
|
|
7725
|
-
}
|
|
7726
|
-
};
|
|
7727
|
-
|
|
7728
|
-
// src/client.ts
|
|
7729
7736
|
init_traceMetadata();
|
|
7730
7737
|
|
|
7731
7738
|
// src/traces.ts
|
|
@@ -8642,8 +8649,6 @@ function readBooleanEnv(name) {
|
|
|
8642
8649
|
var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
|
|
8643
8650
|
var DEFAULT_AUTO_TRACE_MAX_SPANS = 500;
|
|
8644
8651
|
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
8645
|
-
var AUTO_TRACE_POLICY_REFRESH_MS = 6e4;
|
|
8646
|
-
var AUTO_TRACE_POLICY_RETRY_MS = 1e4;
|
|
8647
8652
|
function spanOwnerName(receiver) {
|
|
8648
8653
|
if (typeof receiver === "function") {
|
|
8649
8654
|
return receiver.name !== "" ? receiver.name : void 0;
|
|
@@ -8676,7 +8681,6 @@ var Bitfab = class {
|
|
|
8676
8681
|
constructor(config) {
|
|
8677
8682
|
/** Gate the empty-key warning to fire at most once. */
|
|
8678
8683
|
this.apiKeyWarned = false;
|
|
8679
|
-
this.autoTracePolicyRefreshes = /* @__PURE__ */ new Map();
|
|
8680
8684
|
/**
|
|
8681
8685
|
* Mock overrides registered via {@link Bitfab.registerMockOverride}, applied
|
|
8682
8686
|
* to every `replay` on this client (after any per-call `mockOverride`). In
|
|
@@ -8725,12 +8729,12 @@ var Bitfab = class {
|
|
|
8725
8729
|
*
|
|
8726
8730
|
* Build instrumentation turns repository functions called beneath this
|
|
8727
8731
|
* method into nested spans that capture inputs, outputs, and errors by
|
|
8728
|
-
* default.
|
|
8729
|
-
*
|
|
8732
|
+
* default. Source exclusions and sim-plan capture-off decisions are explicit
|
|
8733
|
+
* opt-outs from that default.
|
|
8730
8734
|
* Without a compatible build transform, this still records the decorated
|
|
8731
8735
|
* method as a normal rich root span but cannot discover child calls.
|
|
8732
8736
|
*
|
|
8733
|
-
* @param traceFunctionKey - Groups traces and their capture
|
|
8737
|
+
* @param traceFunctionKey - Groups traces and their capture controls.
|
|
8734
8738
|
* @param options - Root presentation, subtree bounds, and exclusions.
|
|
8735
8739
|
* @experimental Automatic child-call instrumentation is experimental.
|
|
8736
8740
|
*/
|
|
@@ -8888,11 +8892,6 @@ var Bitfab = class {
|
|
|
8888
8892
|
traceFunctionKey,
|
|
8889
8893
|
spanOptions,
|
|
8890
8894
|
function(...args) {
|
|
8891
|
-
const capturePolicy = getAutoTraceCapturePolicy(
|
|
8892
|
-
self,
|
|
8893
|
-
traceFunctionKey
|
|
8894
|
-
);
|
|
8895
|
-
self.refreshAutoTraceCapturePolicy(traceFunctionKey);
|
|
8896
8895
|
self.simulationPlan.refresh();
|
|
8897
8896
|
let spansUsed = 0;
|
|
8898
8897
|
let truncated = false;
|
|
@@ -8972,7 +8971,7 @@ var Bitfab = class {
|
|
|
8972
8971
|
surface: "opt-out",
|
|
8973
8972
|
instrumentation: "trace",
|
|
8974
8973
|
functionId: definition.id,
|
|
8975
|
-
captureContent:
|
|
8974
|
+
captureContent: true,
|
|
8976
8975
|
autoTraceDefinition: definition,
|
|
8977
8976
|
...nodeConfiguration?.testRunId !== void 0 && {
|
|
8978
8977
|
testRunId: nodeConfiguration.testRunId
|
|
@@ -9071,34 +9070,6 @@ var Bitfab = class {
|
|
|
9071
9070
|
applySimulationPlan(payload, submit) {
|
|
9072
9071
|
this.simulationPlan.send(payload, rootTraceFunctionKeyOf(payload), submit);
|
|
9073
9072
|
}
|
|
9074
|
-
refreshAutoTraceCapturePolicy(traceFunctionKey) {
|
|
9075
|
-
const state2 = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
|
|
9076
|
-
this.autoTracePolicyRefreshes.set(traceFunctionKey, state2);
|
|
9077
|
-
state2.run(
|
|
9078
|
-
() => this.httpClient.getAutoTracePolicy(
|
|
9079
|
-
traceFunctionKey,
|
|
9080
|
-
AUTO_TRACE_PROTOCOL
|
|
9081
|
-
),
|
|
9082
|
-
(policy) => {
|
|
9083
|
-
if (policy.protocol !== AUTO_TRACE_PROTOCOL) {
|
|
9084
|
-
state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
|
|
9085
|
-
return;
|
|
9086
|
-
}
|
|
9087
|
-
const functionIds = Array.isArray(policy.functionIds) ? policy.functionIds.filter(
|
|
9088
|
-
(id) => typeof id === "string" && id.startsWith(`${AUTO_TRACE_PROTOCOL}:`)
|
|
9089
|
-
).slice(0, DEFAULT_AUTO_TRACE_MAX_SPANS) : [];
|
|
9090
|
-
__setBitfabAutoTraceCapturePolicy(
|
|
9091
|
-
this,
|
|
9092
|
-
traceFunctionKey,
|
|
9093
|
-
policy.revision === null ? void 0 : functionIds
|
|
9094
|
-
);
|
|
9095
|
-
state2.hold(AUTO_TRACE_POLICY_REFRESH_MS);
|
|
9096
|
-
},
|
|
9097
|
-
() => {
|
|
9098
|
-
state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
|
|
9099
|
-
}
|
|
9100
|
-
);
|
|
9101
|
-
}
|
|
9102
9073
|
/**
|
|
9103
9074
|
* Flush and permanently close this client's tracing resources: its pending
|
|
9104
9075
|
* requests and the single span-transport worker shared by its decorators and
|