@bitfab/sdk 0.65.6 → 0.65.8

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.
@@ -1,6 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { C as readEnv$1, S as MixedTracingError, _ as getReplayContext, b as gitRunner, 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 replayContextReady, w as __version__, x as BitfabError, y as runWithReplayContext } from "./http-lnqCEnB1.js";
2
+ import { C as readEnv$1, S as MixedTracingError, _ as getReplayContext, b as gitRunner, 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 replayContextReady, w as __version__, x as BitfabError, y as runWithReplayContext } from "./http-C9d2uNjI.js";
3
3
  import { a as clearAutoTraceNodeConfiguration, b as isAsyncStorageInitDone, c as runAsAutoTraceRootFunction, d as runWithAutoTraceRootContext, g as runWithCaptureSuppressed, h as isCaptureSuppressed, l as runWithAutoTraceEntry, m as writeOnce, n as __bitfabAutoTraceActive, o as currentAutoTraceEntries, p as warnOnce, s as invokeThroughAutoTraceEntries, u as runWithAutoTraceNodeConfiguration, v as asyncStorageReady, y as createAsyncLocalStorage } from "./autoTrace-O40k8f5M.js";
4
+ import { r as importOptionalPeer, t as loadBamlModule } from "./bamlPeer-CIVwS68E.js";
4
5
  import superjson from "superjson";
5
6
  //#region src/categories.ts
6
7
  const CATEGORIES_PATH = "/api/sdk/categories";
@@ -617,25 +618,11 @@ var BitfabClaudeAgentHandler = class {
617
618
  }
618
619
  };
619
620
  //#endregion
620
- //#region src/optionalPeer.ts
621
- function importOptionalPeer(specifierParts) {
622
- return import(
623
- /* webpackIgnore: true */
624
- /* @vite-ignore */
625
- specifierParts.join("/")
626
- );
627
- }
628
- //#endregion
629
621
  //#region src/baml.ts
630
- let cachedBaml = null;
631
622
  async function loadBaml() {
632
- if (cachedBaml) return cachedBaml;
633
- try {
634
- cachedBaml = await importOptionalPeer(["@boundaryml", "baml"]);
635
- return cachedBaml;
636
- } catch {
637
- throw new Error("@boundaryml/baml is required for Bitfab.call(). Install it with: npm install @boundaryml/baml");
638
- }
623
+ const baml = await loadBamlModule();
624
+ if (!baml) throw new Error("@boundaryml/baml is required for Bitfab.call(). Install it with: npm install @boundaryml/baml. If it is installed and your app is bundled (Next.js with Turbopack, for example), add `import \"@bitfab/sdk/baml\"` once in your server code.");
625
+ return baml;
639
626
  }
640
627
  function capitalize(str) {
641
628
  return str.charAt(0).toUpperCase() + str.slice(1);
@@ -4495,13 +4482,10 @@ function wrapAsyncGenerator(source, spanStack, sendSpan) {
4495
4482
  let cachedCollectorClass;
4496
4483
  async function loadCollectorClass() {
4497
4484
  if (cachedCollectorClass !== void 0) return cachedCollectorClass;
4498
- try {
4499
- cachedCollectorClass = (await importOptionalPeer(["@boundaryml", "baml"])).Collector;
4500
- return cachedCollectorClass;
4501
- } catch {
4502
- cachedCollectorClass = null;
4503
- return null;
4504
- }
4485
+ const baml = await loadBamlModule();
4486
+ if (!baml) return null;
4487
+ cachedCollectorClass = baml.Collector;
4488
+ return cachedCollectorClass;
4505
4489
  }
4506
4490
  function extractPromptFromCollector(collector) {
4507
4491
  try {
@@ -4709,7 +4693,10 @@ var Bitfab = class {
4709
4693
  serviceUrl: this.serviceUrl,
4710
4694
  timeout: this.timeout
4711
4695
  });
4712
- this.simulationPlan = new SimulationPlan(this.httpClient, config.simulationPlan ?? true);
4696
+ this.simulationPlan = new SimulationPlan({
4697
+ getSimulationPlan: () => this.httpClient.getSimulationPlan(),
4698
+ canRead: () => this.canReadSimulationPlan()
4699
+ }, config.simulationPlan ?? true);
4713
4700
  this.httpClient.externalSpanTransform = (payload, submit, drop) => this.applySimulationPlan(payload, submit, drop);
4714
4701
  this.httpClient.externalTraceTransform = (payload, submit) => this.simulationPlan.sendTrace(payload, submit);
4715
4702
  this.httpClient.releaseHeldExternalSpans = (timeoutMs) => this.simulationPlan.release(timeoutMs);
@@ -4981,6 +4968,9 @@ var Bitfab = class {
4981
4968
  if (!this.isCaptureConfigured() && !getReplayContext() && !inSeedScope()) return false;
4982
4969
  return this.resolveApiKey() !== void 0;
4983
4970
  }
4971
+ canReadSimulationPlan() {
4972
+ return ((this.captureConfiguredInCode ?? this.captureConfiguredFromEnv ?? readBooleanEnv(CAPTURE_ENABLED_ENV) ?? true) || getReplayContext() !== null || inSeedScope()) && this.findApiKey(true) !== void 0;
4973
+ }
4984
4974
  prepareFrameworkIntegration() {
4985
4975
  if (this.isCaptureConfigured() && this.strict) this.resolveApiKey();
4986
4976
  }
@@ -5139,6 +5129,7 @@ var Bitfab = class {
5139
5129
  const wrappedFn = async (...args) => {
5140
5130
  const CollectorClass = await loadCollectorClass();
5141
5131
  if (!CollectorClass) {
5132
+ warnOnce("wrapBAML-collector-unavailable", `@boundaryml/baml could not be loaded, so "${methodName}" and every other wrapBAML call run untraced: no prompt, model, or token usage is recorded and onCollector is not called. If @boundaryml/baml is installed and your app is bundled (Next.js with Turbopack, for example), add \`import "@bitfab/sdk/baml"\` once in your server code.`);
5142
5133
  wrappedFn.collector = null;
5143
5134
  return await bamlClient[methodName](...args);
5144
5135
  }
@@ -5807,7 +5798,7 @@ var Bitfab = class {
5807
5798
  await runWithSeedContext({ traceId }, async () => target(...args));
5808
5799
  } finally {
5809
5800
  try {
5810
- const { flushTraces } = await import("./http-lnqCEnB1.js").then((n) => n.a);
5801
+ const { flushTraces } = await import("./http-C9d2uNjI.js").then((n) => n.a);
5811
5802
  await flushTraces(3e4);
5812
5803
  } finally {
5813
5804
  unrecorded = activeTraceStates.delete(traceId);
@@ -5995,7 +5986,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
5995
5986
  metadata: seedCase.metadata,
5996
5987
  sessionId: seedCase.sessionId
5997
5988
  }));
5998
- const { flushTraces } = await import("./http-lnqCEnB1.js").then((n) => n.a);
5989
+ const { flushTraces } = await import("./http-C9d2uNjI.js").then((n) => n.a);
5999
5990
  await flushTraces(3e4);
6000
5991
  return {
6001
5992
  pipeline,
@@ -6012,4 +6003,4 @@ function resolveTraceFunctionKey(registration) {
6012
6003
  //#endregion
6013
6004
  export { SUPPORTED_PROVIDERS as A, BitfabOpenAIAgentHandler as C, LabelsClient as D, BitfabLangGraphCallbackHandler as E, DEFAULT_SERVICE_URL as F, AssertionCategoriesClient as I, CategoriesClient as L, GraderRerunError as M, GraderRerunTimeoutError as N, GradersClient as O, BitfabClaudeAgentHandler as P, OrganizationMembersClient as S, BitfabLangGraphIntegration 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, DatasetsClient as j, ExperimentsClient 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, NO_MOCK_OVERRIDE as w, serializeReplayResult as x, ReplayError as y };
6014
6005
 
6015
- //# sourceMappingURL=src-BungStQw.js.map
6006
+ //# sourceMappingURL=src-D1RisoK8.js.map