@bitfab/sdk 0.74.5 → 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/replayCli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, o as checkReplayCliArgs, r as resolveRegistry, s as runReplayCli, t as importRegistry } from "./registryCommand-Bm2-Peq8.js";
2
+ import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, o as checkReplayCliArgs, r as resolveRegistry, s as runReplayCli, t as importRegistry } from "./registryCommand-DdNn4qGL.js";
3
3
  //#region src/cloudReplayCli.ts
4
4
  const CLOUD_REPLAY_HINT = "Add --cloud to run the same replay on GitHub Actions; bitfab-replay --cloud --help explains it.";
5
5
  function isCloudReplayCommand(argv) {
package/dist/seedCli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-Bm2-Peq8.js";
2
+ import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-DdNn4qGL.js";
3
3
  //#region src/seedCli.ts
4
4
  const USAGE = "Usage: bitfab-seed --registry <path> <pipeline> --from-trace <id>[,<id>...]\n bitfab-seed --registry <path> <pipeline> --cases <cases.jsonl> [--run]\nRun bitfab-seed --registry <path> <pipeline> --help for details.";
5
5
  async function runSeedCommand(argv, io = {}, importer = importRegistry) {
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { C as BitfabError, E as __version__, S as gitRunner, T as readEnv$1, _ as MAX_SPAN_CARRIER_BYTES, b as replayContextReady, c as recordCallerTraceMetadata, f as ROOT_TRACE_FUNCTION_KEY_FIELD, g as MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES, h as makeSpanOrigin, i as flushTraces, l as retireTraceMetadata, m as isFrameworkInstrumentation, n as SPAN_TYPES, o as unrefTimer, p as SimulationPlan, r as experimentIdWireFields, s as callerTraceMetadata, t as HttpClient, v as byteLength, w as MixedTracingError, x as runWithReplayContext, y as getReplayContext } from "./http-C_t7m9b_.js";
2
+ import { C as BitfabError, E as __version__, S as gitRunner, T as readEnv$1, _ as MAX_SPAN_CARRIER_BYTES, b as replayContextReady, c as recordCallerTraceMetadata, f as ROOT_TRACE_FUNCTION_KEY_FIELD, g as MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES, h as makeSpanOrigin, i as flushTraces, l as retireTraceMetadata, m as isFrameworkInstrumentation, n as SPAN_TYPES, o as unrefTimer, p as SimulationPlan, r as experimentIdWireFields, s as callerTraceMetadata, t as HttpClient, v as byteLength, w as MixedTracingError, x as runWithReplayContext, y as getReplayContext } from "./http-Br-jOeI6.js";
3
3
  import { A as unmapOpenAiAgentsTrace, B as asyncStorageReady, C as recordAutoTracedClientCall, D as mapOpenAiAgentsTrace, E as endOpenAiAgentsSpan, F as warnOnce, H as isAsyncStorageInitDone, I as writeOnce, L as isCaptureSuppressed, M as installLangChainRunScopes, N as markLangChainRunRecorded, O as openAiAgentsParentSpanId, R as runWithCaptureSuppressed, S as frameworkRecordsClientCall, T as watchClientCall, V as createAsyncLocalStorage, _ as runWithAutoTraceRootContext, b as OPENROUTER, f as invokeThroughAutoTraceEntries, g as runWithAutoTraceNodeConfiguration, h as runWithAutoTraceFramesAt, j as forgetLangChainRun, k as openAiAgentsSpanChain, l as clearAutoTraceNodeConfiguration, m as runWithAutoTraceEntry, o as __bitfabAutoTraceActive, p as runAsAutoTraceRootFunction, u as currentAutoTraceEntries, v as ANTHROPIC, w as recordWatchedClientCall, x as clientCallProvider, y as OPENAI_RESPONSES } from "./autoTrace-kHOBg49M.js";
4
4
  import { t as importOptionalPeer } from "./optionalPeer-CczrzrXx.js";
5
5
  import { t as loadBamlModule } from "./bamlPeer-Dyeb3e5o.js";
@@ -51,7 +51,135 @@ function unserializableStub(value, reason) {
51
51
  function serializeValue(value) {
52
52
  return 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.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.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
- 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
+ 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;
@@ -7084,7 +7214,7 @@ var Bitfab = class {
7084
7214
  await runWithSeedContext({ traceId }, async () => target(...args));
7085
7215
  } finally {
7086
7216
  try {
7087
- const { flushTraces } = await import("./http-C_t7m9b_.js").then((n) => n.a);
7217
+ const { flushTraces } = await import("./http-Br-jOeI6.js").then((n) => n.a);
7088
7218
  await flushTraces(3e4);
7089
7219
  } finally {
7090
7220
  unrecorded = activeTraceStates.delete(traceId);
@@ -7290,7 +7420,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
7290
7420
  metadata: seedCase.metadata,
7291
7421
  sessionId: seedCase.sessionId
7292
7422
  }));
7293
- const { flushTraces } = await import("./http-C_t7m9b_.js").then((n) => n.a);
7423
+ const { flushTraces } = await import("./http-Br-jOeI6.js").then((n) => n.a);
7294
7424
  await flushTraces(3e4);
7295
7425
  return {
7296
7426
  pipeline,
@@ -7307,4 +7437,4 @@ function resolveTraceFunctionKey(registration) {
7307
7437
  //#endregion
7308
7438
  export { VerdictsClient as A, OrganizationMembersClient as C, BitfabLangGraphCallbackHandler as D, BitfabLangGraphIntegration as E, GraderRerunTimeoutError as F, BitfabClaudeAgentHandler as I, DEFAULT_SERVICE_URL as L, SUPPORTED_PROVIDERS as M, DatasetsClient as N, GradersClient as O, GraderRerunError as P, AssertionCategoriesClient as R, BitfabPiIntegration as S, NO_MOCK_OVERRIDE as T, BITFAB_PROGRESS_PREFIX as _, Bitfab as a, reportReplayProgress as b, getCurrentSpan as c, BitfabOpenAITracingProcessor as d, AssertionGenerationError as f, BitfabRivetIntegration as g, SpansClient as h, finalizers as i, ExperimentsClient as j, LabelsClient as k, getCurrentTrace as l, TracesClient as m, reseedFromRegistry as n, BitfabFunction as o, AssertionGenerationTimeoutError as p, seedFromRegistry as r, getCurrentReplayBranch as s, defineReplayRegistry as t, BitfabVercelAiHandler as u, DbBranchReplayError as v, BitfabOpenAIAgentHandler as w, serializeReplayResult as x, ReplayError as y, CategoriesClient as z };
7309
7439
 
7310
- //# sourceMappingURL=src-Ch86hs9i.js.map
7440
+ //# sourceMappingURL=src-CRrvnhok.js.map