@bitfab/sdk 0.74.4 → 0.74.6
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/{http-BM1TSXDd.js → http-Br-jOeI6.js} +2 -2
- package/dist/{http-BM1TSXDd.js.map → http-Br-jOeI6.js.map} +1 -1
- package/dist/{http-VtGRzeNI.cjs → http-C_f9vk_C.cjs} +2 -2
- package/dist/{http-VtGRzeNI.cjs.map → http-C_f9vk_C.cjs.map} +1 -1
- package/dist/{index-BiSZ0rGD.d.cts → index-Dcog1sZv.d.cts} +40 -8
- package/dist/{index-BiSZ0rGD.d.ts → index-Dcog1sZv.d.ts} +40 -8
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/node.cjs +2 -2
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +2 -2
- package/dist/{registryCommand-Bm2-Peq8.js → registryCommand-DdNn4qGL.js} +3 -2
- package/dist/registryCommand-DdNn4qGL.js.map +1 -0
- package/dist/replayCli.js +1 -1
- package/dist/seedCli.js +1 -1
- package/dist/{src-Dp8OX46R.js → src-CRrvnhok.js} +148 -13
- package/dist/src-CRrvnhok.js.map +1 -0
- package/dist/{src-Cr4ZJLeB.cjs → src-atyS216N.cjs} +148 -13
- package/dist/src-atyS216N.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/registryCommand-Bm2-Peq8.js.map +0 -1
- package/dist/src-Cr4ZJLeB.cjs.map +0 -1
- package/dist/src-Dp8OX46R.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_bamlPeer = require("./bamlPeer-5Ohpq8q9.cjs");
|
|
2
|
-
const require_http = require("./http-
|
|
2
|
+
const require_http = require("./http-C_f9vk_C.cjs");
|
|
3
3
|
const require_autoTrace = require("./autoTrace-DPWV1Xzr.cjs");
|
|
4
4
|
const require_optionalPeer = require("./optionalPeer-CUH756lt.cjs");
|
|
5
5
|
let superjson = require("superjson");
|
|
@@ -51,7 +51,135 @@ function unserializableStub(value, reason) {
|
|
|
51
51
|
function serializeValue(value) {
|
|
52
52
|
return require_autoTrace.runWithCaptureSuppressed(() => serializeWithSuperjson(value));
|
|
53
53
|
}
|
|
54
|
+
function exceedsSerializedBudget(value, budget, frameworkWalk = false, dropped) {
|
|
55
|
+
let total = 0;
|
|
56
|
+
let steps = 0;
|
|
57
|
+
const maxSteps = 4 * budget + 1024;
|
|
58
|
+
const giveUp = /* @__PURE__ */ new Error("size walk step limit");
|
|
59
|
+
const step = () => {
|
|
60
|
+
steps += 1;
|
|
61
|
+
if (steps > maxSteps) throw giveUp;
|
|
62
|
+
};
|
|
63
|
+
const found = [];
|
|
64
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
65
|
+
const visit = (node, depth, jsonRules) => {
|
|
66
|
+
if (total > budget) return;
|
|
67
|
+
step();
|
|
68
|
+
if (node === null) {
|
|
69
|
+
total += 4;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
switch (typeof node) {
|
|
73
|
+
case "string":
|
|
74
|
+
total += node.length + 2;
|
|
75
|
+
return;
|
|
76
|
+
case "number":
|
|
77
|
+
total += 1;
|
|
78
|
+
return;
|
|
79
|
+
case "boolean":
|
|
80
|
+
total += 4;
|
|
81
|
+
return;
|
|
82
|
+
case "undefined": return;
|
|
83
|
+
}
|
|
84
|
+
if (frameworkWalk && depth > MAX_SAFE_DEPTH) {
|
|
85
|
+
found.push(describeValue(node));
|
|
86
|
+
total += 2;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (typeof node === "bigint") {
|
|
90
|
+
total += 1;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (typeof node !== "object") {
|
|
94
|
+
found.push(describeValue(node));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (ancestors.has(node)) {
|
|
98
|
+
found.push(describeValue(node));
|
|
99
|
+
total += 4;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (!jsonRules && registeredOnSuperjson(node)) {
|
|
103
|
+
total += 1;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (ArrayBuffer.isView(node)) {
|
|
107
|
+
total += node instanceof DataView ? 2 : Math.max(2, 2 * node.length);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (typeof node.toJSON === "function") {
|
|
111
|
+
total += 2;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!jsonRules && node instanceof Error) {
|
|
115
|
+
total += node.name.length + node.message.length + 4;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
total += 2;
|
|
119
|
+
const childRules = jsonRules || !walkedBySuperjson(node);
|
|
120
|
+
ancestors.add(node);
|
|
121
|
+
let written = 0;
|
|
122
|
+
const separate = () => {
|
|
123
|
+
if (written > 0) total += 1;
|
|
124
|
+
written += 1;
|
|
125
|
+
};
|
|
126
|
+
if (Array.isArray(node)) for (let index = 0; index < node.length && total <= budget; index += 1) {
|
|
127
|
+
if (!jsonRules && !(index in node)) {
|
|
128
|
+
step();
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
separate();
|
|
132
|
+
visit(node[index], depth + 1, childRules);
|
|
133
|
+
}
|
|
134
|
+
else if (jsonRules && (node instanceof Map || node instanceof Set)) {} else if (node instanceof Map) for (const [key, entry] of node) {
|
|
135
|
+
if (total > budget) break;
|
|
136
|
+
separate();
|
|
137
|
+
total += 3;
|
|
138
|
+
visit(key, depth + 1, childRules);
|
|
139
|
+
visit(entry, depth + 1, childRules);
|
|
140
|
+
}
|
|
141
|
+
else if (node instanceof Set) for (const entry of node) {
|
|
142
|
+
if (total > budget) break;
|
|
143
|
+
separate();
|
|
144
|
+
visit(entry, depth + 1, childRules);
|
|
145
|
+
}
|
|
146
|
+
else for (const key of Object.keys(node)) {
|
|
147
|
+
if (total > budget) break;
|
|
148
|
+
if (frameworkWalk && key.startsWith("_")) continue;
|
|
149
|
+
const entry = node[key];
|
|
150
|
+
if (entry !== void 0 && typeof entry !== "function" && typeof entry !== "symbol") {
|
|
151
|
+
separate();
|
|
152
|
+
total += key.length + 3;
|
|
153
|
+
}
|
|
154
|
+
visit(entry, depth + 1, childRules);
|
|
155
|
+
}
|
|
156
|
+
ancestors.delete(node);
|
|
157
|
+
};
|
|
158
|
+
try {
|
|
159
|
+
visit(value, 0, frameworkWalk);
|
|
160
|
+
} catch {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
if (total <= budget) return false;
|
|
164
|
+
dropped?.push(...found);
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
const superjsonDefault = superjson.default.defaultInstance;
|
|
168
|
+
function registeredOnSuperjson(node) {
|
|
169
|
+
if (superjsonDefault === void 0) return false;
|
|
170
|
+
const ownConstructor = node.constructor;
|
|
171
|
+
return superjsonDefault.customTransformerRegistry.findApplicable(node) !== void 0 || typeof ownConstructor === "function" && superjsonDefault.classRegistry.getIdentifier(ownConstructor) !== void 0;
|
|
172
|
+
}
|
|
173
|
+
function walkedBySuperjson(node) {
|
|
174
|
+
if (Array.isArray(node) || node instanceof Map || node instanceof Set) return true;
|
|
175
|
+
const prototype = Object.getPrototypeOf(node);
|
|
176
|
+
return prototype === null || prototype === Object.prototype;
|
|
177
|
+
}
|
|
178
|
+
function tooLargeReason(budget) {
|
|
179
|
+
return `too_large_over_${budget}_bytes`;
|
|
180
|
+
}
|
|
54
181
|
function serializeWithSuperjson(value) {
|
|
182
|
+
if (exceedsSerializedBudget(value, MAX_SERIALIZED_BYTES)) return unserializableStub(value, tooLargeReason(MAX_SERIALIZED_BYTES));
|
|
55
183
|
try {
|
|
56
184
|
const { json, meta } = superjson.default.serialize(value);
|
|
57
185
|
let size;
|
|
@@ -89,22 +217,24 @@ function toJsonSafeReport(value) {
|
|
|
89
217
|
}
|
|
90
218
|
function jsonSafeReport(value) {
|
|
91
219
|
const dropped = [];
|
|
220
|
+
if (exceedsSerializedBudget(value, MAX_FRAMEWORK_SERIALIZED_BYTES, true, dropped)) return frameworkTooLarge(tooLargeReason(MAX_FRAMEWORK_SERIALIZED_BYTES), dropped);
|
|
92
221
|
const safe = toJsonSafeInner(value, 0, /* @__PURE__ */ new WeakSet(), dropped);
|
|
93
222
|
try {
|
|
94
223
|
const size = JSON.stringify(safe)?.length ?? 0;
|
|
95
|
-
if (size > MAX_FRAMEWORK_SERIALIZED_BYTES) {
|
|
96
|
-
require_autoTrace.warnOnce("toJsonSafe:too_large", `a framework payload exceeded ${MAX_FRAMEWORK_SERIALIZED_BYTES} bytes and was replaced with a placeholder so the span still ships. The captured state for this span is incomplete.`);
|
|
97
|
-
return {
|
|
98
|
-
safe: `<unserializable: too_large_${size}_bytes>`,
|
|
99
|
-
dropped: [...dropped, `too_large_${size}_bytes`]
|
|
100
|
-
};
|
|
101
|
-
}
|
|
224
|
+
if (size > MAX_FRAMEWORK_SERIALIZED_BYTES) return frameworkTooLarge(`too_large_${size}_bytes`, dropped);
|
|
102
225
|
} catch {}
|
|
103
226
|
return {
|
|
104
227
|
safe,
|
|
105
228
|
dropped
|
|
106
229
|
};
|
|
107
230
|
}
|
|
231
|
+
function frameworkTooLarge(reason, dropped) {
|
|
232
|
+
require_autoTrace.warnOnce("toJsonSafe:too_large", `a framework payload exceeded ${MAX_FRAMEWORK_SERIALIZED_BYTES} bytes and was replaced with a placeholder so the span still ships. The captured state for this span is incomplete.`);
|
|
233
|
+
return {
|
|
234
|
+
safe: `<unserializable: ${reason}>`,
|
|
235
|
+
dropped: [...dropped, "too_large"]
|
|
236
|
+
};
|
|
237
|
+
}
|
|
108
238
|
function toJsonSafeInner(value, depth, seen, dropped) {
|
|
109
239
|
if (value === null || value === void 0) return value;
|
|
110
240
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
@@ -4958,6 +5088,7 @@ var SpansClient = class {
|
|
|
4958
5088
|
//#region src/traces.ts
|
|
4959
5089
|
const ASSERTIONS_PATH = "/api/sdk/traces/assertions";
|
|
4960
5090
|
const SEARCH_PATH = "/api/sdk/traces/search";
|
|
5091
|
+
const CODE_DRAFT_SAVE_TIMEOUT_MS = 3e5;
|
|
4961
5092
|
const DEFAULT_GENERATION_TIMEOUT_MS = 6e5;
|
|
4962
5093
|
const GENERATION_POLL_INTERVAL_MS = 2e3;
|
|
4963
5094
|
var AssertionGenerationError = class extends Error {
|
|
@@ -5007,6 +5138,9 @@ function toWireAssertion({ category_assertion_id, ...assertion }) {
|
|
|
5007
5138
|
category_id: categoryId
|
|
5008
5139
|
};
|
|
5009
5140
|
}
|
|
5141
|
+
function asksBitfabToWriteCode(assertion) {
|
|
5142
|
+
return (assertion.kind === "code" || assertion.kind === "hybrid") && assertion.code === void 0;
|
|
5143
|
+
}
|
|
5010
5144
|
function traceAssertionsPath(traceId, suffix = "") {
|
|
5011
5145
|
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
|
|
5012
5146
|
}
|
|
@@ -5039,14 +5173,15 @@ var TracesClient = class {
|
|
|
5039
5173
|
}
|
|
5040
5174
|
async saveAssertionsAll(params) {
|
|
5041
5175
|
if (params.updates.length === 0) return [];
|
|
5042
|
-
|
|
5176
|
+
const body = {
|
|
5043
5177
|
updates: params.updates.map((update) => ({
|
|
5044
5178
|
...update,
|
|
5045
5179
|
assertions: update.assertions.map(toWireAssertion)
|
|
5046
5180
|
})),
|
|
5047
5181
|
source: params.source ?? "agent",
|
|
5048
5182
|
guidedRewrite: params.skipGuidedRewrite !== true
|
|
5049
|
-
}
|
|
5183
|
+
};
|
|
5184
|
+
return withCategoryIds((params.updates.some((update) => update.assertions.some(asksBitfabToWriteCode)) ? await this.httpClient.request(ASSERTIONS_PATH, body, { timeout: CODE_DRAFT_SAVE_TIMEOUT_MS }) : await this.httpClient.request(ASSERTIONS_PATH, body)).assertions);
|
|
5050
5185
|
}
|
|
5051
5186
|
async generateAssertions(traceId, options = {}) {
|
|
5052
5187
|
const started = await this.httpClient.request(traceAssertionsPath(traceId, "/generate"), {
|
|
@@ -7079,7 +7214,7 @@ var Bitfab = class {
|
|
|
7079
7214
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
7080
7215
|
} finally {
|
|
7081
7216
|
try {
|
|
7082
|
-
const { flushTraces } = await Promise.resolve().then(() => require("./http-
|
|
7217
|
+
const { flushTraces } = await Promise.resolve().then(() => require("./http-C_f9vk_C.cjs")).then((n) => n.http_exports);
|
|
7083
7218
|
await flushTraces(3e4);
|
|
7084
7219
|
} finally {
|
|
7085
7220
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -7285,7 +7420,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
7285
7420
|
metadata: seedCase.metadata,
|
|
7286
7421
|
sessionId: seedCase.sessionId
|
|
7287
7422
|
}));
|
|
7288
|
-
const { flushTraces } = await Promise.resolve().then(() => require("./http-
|
|
7423
|
+
const { flushTraces } = await Promise.resolve().then(() => require("./http-C_f9vk_C.cjs")).then((n) => n.http_exports);
|
|
7289
7424
|
await flushTraces(3e4);
|
|
7290
7425
|
return {
|
|
7291
7426
|
pipeline,
|
|
@@ -7535,4 +7670,4 @@ Object.defineProperty(exports, "serializeReplayResult", {
|
|
|
7535
7670
|
}
|
|
7536
7671
|
});
|
|
7537
7672
|
|
|
7538
|
-
//# sourceMappingURL=src-
|
|
7673
|
+
//# sourceMappingURL=src-atyS216N.cjs.map
|