bitfab 0.66.0 → 0.67.0

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.
Files changed (46) hide show
  1. package/dist/autoTrace-CQw0qMBt.cjs.map +1 -1
  2. package/dist/autoTrace-O40k8f5M.js.map +1 -1
  3. package/dist/autoTrace.d.cts +2 -0
  4. package/dist/autoTrace.d.ts +2 -0
  5. package/dist/{babelPlugin-C70OxrqA.js → babelPlugin-CBjx6aJe.js} +28 -3
  6. package/dist/babelPlugin-CBjx6aJe.js.map +1 -0
  7. package/dist/{babelPlugin-Nta4-VcL.cjs → babelPlugin-ZR9ilYct.cjs} +28 -3
  8. package/dist/babelPlugin-ZR9ilYct.cjs.map +1 -0
  9. package/dist/{http-D91qP2J-.js → http-CcYPHER5.js} +2 -2
  10. package/dist/{http-D91qP2J-.js.map → http-CcYPHER5.js.map} +1 -1
  11. package/dist/{http-DIz8mEMq.cjs → http-CxT_WDAh.cjs} +2 -2
  12. package/dist/{http-DIz8mEMq.cjs.map → http-CxT_WDAh.cjs.map} +1 -1
  13. package/dist/{index-DiYFr-KV.d.cts → index-BFgtvRni.d.cts} +1 -1
  14. package/dist/{index-DiYFr-KV.d.ts → index-BFgtvRni.d.ts} +1 -1
  15. package/dist/index.cjs +2 -2
  16. package/dist/index.d.cts +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +2 -2
  19. package/dist/node.cjs +2 -2
  20. package/dist/node.d.cts +1 -1
  21. package/dist/node.d.ts +1 -1
  22. package/dist/node.js +2 -2
  23. package/dist/registryCommand-Dk4Y1ZgW.js.map +1 -1
  24. package/dist/{src-CL5eQlNk.js → src-CFDoTgXw.js} +70 -13
  25. package/dist/{src-CL5eQlNk.js.map → src-CFDoTgXw.js.map} +1 -1
  26. package/dist/{src-rJcHXJEz.cjs → src-DXmdXbOL.cjs} +70 -13
  27. package/dist/{src-rJcHXJEz.cjs.map → src-DXmdXbOL.cjs.map} +1 -1
  28. package/dist/transform/babel.cjs +1 -1
  29. package/dist/transform/babel.d.cts +1 -0
  30. package/dist/transform/babel.d.ts +1 -0
  31. package/dist/transform/babel.js +1 -1
  32. package/dist/transform/loaderRuntime.cjs +2 -2
  33. package/dist/transform/loaderRuntime.js +2 -2
  34. package/dist/transform/nodeLoader.js +27 -2
  35. package/dist/transform/nodeLoader.js.map +1 -1
  36. package/dist/transform/swc.cjs +1 -1
  37. package/dist/transform/swc.js +1 -1
  38. package/dist/transform/unplugin.cjs +2 -2
  39. package/dist/transform/unplugin.js +2 -2
  40. package/dist/{transform-BcyUocwm.js → transform-DP1qnD8u.js} +2 -2
  41. package/dist/{transform-BcyUocwm.js.map → transform-DP1qnD8u.js.map} +1 -1
  42. package/dist/{transform-BjxHGGKc.cjs → transform-D_pSvPJc.cjs} +2 -2
  43. package/dist/{transform-BjxHGGKc.cjs.map → transform-D_pSvPJc.cjs.map} +1 -1
  44. package/package.json +1 -1
  45. package/dist/babelPlugin-C70OxrqA.js.map +0 -1
  46. package/dist/babelPlugin-Nta4-VcL.cjs.map +0 -1
@@ -1,5 +1,5 @@
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-D91qP2J-.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-CcYPHER5.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
4
  import { r as importOptionalPeer, t as loadBamlModule } from "./bamlPeer-CIVwS68E.js";
5
5
  import superjson from "superjson";
@@ -4713,6 +4713,61 @@ function extractContextFromCollector(collector) {
4713
4713
  return null;
4714
4714
  }
4715
4715
  }
4716
+ const BOUND_FUNCTION_NAME_PREFIX = /^bound /;
4717
+ function discoveredSpanType(definition, nodeConfiguration) {
4718
+ const ownType = definition.baml === true ? "llm" : "function";
4719
+ if (nodeConfiguration === void 0) return ownType;
4720
+ if (definition.baml === true && nodeConfiguration.defaultType === true) return ownType;
4721
+ return nodeConfiguration.type ?? ownType;
4722
+ }
4723
+ const collectorsRecordedByAutoTrace = /* @__PURE__ */ new WeakSet();
4724
+ function isPlainObject(value) {
4725
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4726
+ }
4727
+ function collectorsIn(options) {
4728
+ const collector = options.collector;
4729
+ if (collector === void 0 || collector === null) return [];
4730
+ return Array.isArray(collector) ? collector : [collector];
4731
+ }
4732
+ function recordBamlCollector(collector) {
4733
+ try {
4734
+ const prompt = extractPromptFromCollector(collector);
4735
+ if (prompt) getCurrentSpan().setPrompt(prompt);
4736
+ const metadata = extractContextFromCollector(collector);
4737
+ if (metadata) getCurrentSpan().addContext(metadata);
4738
+ } catch {}
4739
+ }
4740
+ function invokeBamlWithCollector(invokeFn, CollectorClass) {
4741
+ const collector = new CollectorClass("bitfab-baml-tracing");
4742
+ let existingCollectors = [];
4743
+ const result = invokeFn((callerOptions, clientOptions) => {
4744
+ const caller = isPlainObject(callerOptions) ? callerOptions : {};
4745
+ const client = isPlainObject(clientOptions) ? clientOptions : {};
4746
+ existingCollectors = collectorsIn(caller.collector === void 0 ? client : caller);
4747
+ return {
4748
+ ...caller,
4749
+ collector: [...existingCollectors, collector]
4750
+ };
4751
+ });
4752
+ const settle = () => {
4753
+ for (const existing of existingCollectors) if (typeof existing === "object" && existing !== null) collectorsRecordedByAutoTrace.add(existing);
4754
+ recordBamlCollector(collector);
4755
+ };
4756
+ if (result instanceof Promise) return result.then((value) => {
4757
+ settle();
4758
+ return value;
4759
+ });
4760
+ settle();
4761
+ return result;
4762
+ }
4763
+ function invokeAutoTracedBaml(invokeFn, isAsync) {
4764
+ if (cachedCollectorClass) return invokeBamlWithCollector(invokeFn, cachedCollectorClass);
4765
+ if (cachedCollectorClass === null || !isAsync) {
4766
+ loadCollectorClass();
4767
+ return invokeFn();
4768
+ }
4769
+ return loadCollectorClass().then((CollectorClass) => CollectorClass ? invokeBamlWithCollector(invokeFn, CollectorClass) : invokeFn());
4770
+ }
4716
4771
  function isSpanType(value) {
4717
4772
  return SPAN_TYPES.some((spanType) => spanType === value);
4718
4773
  }
@@ -4936,7 +4991,7 @@ var Bitfab = class {
4936
4991
  const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
4937
4992
  if (!fn) throw new BitfabError("bitfab.withNode requires a function");
4938
4993
  const configuration = this.resolveNodeConfiguration(options);
4939
- const functionName = internalFunctionName ?? fn.name;
4994
+ const functionName = (internalFunctionName ?? fn.name).replace(BOUND_FUNCTION_NAME_PREFIX, "");
4940
4995
  if (functionName === "") throw new BitfabError("bitfab.withNode requires a named function so the subtree transform can bind its configuration to the correct call.");
4941
4996
  return this.createAutoTraceNode(configuration, fn, functionName);
4942
4997
  }
@@ -4947,6 +5002,7 @@ var Bitfab = class {
4947
5002
  return {
4948
5003
  capture,
4949
5004
  type: options.type ?? "custom",
5005
+ ...options.type === void 0 && { defaultType: true },
4950
5006
  ...options.name !== void 0 && { name: options.name },
4951
5007
  ...experimentId !== void 0 && { experimentId },
4952
5008
  ...options.mockOnReplay !== void 0 && { mockOnReplay: options.mockOnReplay },
@@ -4970,6 +5026,7 @@ var Bitfab = class {
4970
5026
  createAutoTraceRoot(traceFunctionKey, name, options, fn, rootFunctionName = "") {
4971
5027
  const self = this;
4972
5028
  self.simulationPlan.refresh();
5029
+ loadCollectorClass();
4973
5030
  const runRootFunction = (receiver, args) => runAsAutoTraceRootFunction(rootFunctionName, () => fn.apply(receiver, args));
4974
5031
  const maxDepth = autoTraceLimit(options.maxDepth, DEFAULT_AUTO_TRACE_MAX_DEPTH);
4975
5032
  const maxCapturedSubtreeSpans = autoTraceLimit(options.maxCapturedSubtreeSpans, DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS);
@@ -5043,7 +5100,7 @@ var Bitfab = class {
5043
5100
  const nodeExperimentId = nodeConfiguration === void 0 ? void 0 : resolveSpanExperimentId(nodeConfiguration);
5044
5101
  const childOptions = {
5045
5102
  name: spanName,
5046
- type: nodeConfiguration?.type ?? "function",
5103
+ type: discoveredSpanType(definition, nodeConfiguration),
5047
5104
  captureWhen: "nested",
5048
5105
  surface: "opt-out",
5049
5106
  instrumentation: "trace",
@@ -5057,7 +5114,8 @@ var Bitfab = class {
5057
5114
  ...nodeConfiguration?.replayReusable !== void 0 && { replayReusable: nodeConfiguration.replayReusable },
5058
5115
  ...nodeConfiguration?.finalize !== void 0 && { finalize: nodeConfiguration.finalize }
5059
5116
  };
5060
- return openChild(entry, childOptions, inputs, definition.async === true, invokeFn);
5117
+ const isAsync = definition.async === true;
5118
+ return openChild(entry, childOptions, inputs, isAsync, definition.baml === true ? () => invokeAutoTracedBaml(invokeFn, isAsync) : invokeFn);
5061
5119
  },
5062
5120
  invokeNestedRoot(nestedName, nestedFunctionName, inputs, invokeFn, entry, link, spanDetails) {
5063
5121
  if (excluded.has(nestedName) || excluded.has(nestedFunctionName) || !recordsSpan(entry, nestedName, true)) return invokeFn();
@@ -5328,18 +5386,17 @@ var Bitfab = class {
5328
5386
  }
5329
5387
  const result = await trackedMethod.bind(trackedClient)(...args);
5330
5388
  wrappedFn.collector = collector;
5331
- try {
5332
- const prompt = extractPromptFromCollector(collector);
5333
- if (prompt) getCurrentSpan().setPrompt(prompt);
5334
- const metadata = extractContextFromCollector(collector);
5335
- if (metadata) getCurrentSpan().addContext(metadata);
5336
- } catch {}
5389
+ if (!collectorsRecordedByAutoTrace.has(collector)) recordBamlCollector(collector);
5337
5390
  try {
5338
5391
  options?.onCollector?.(collector);
5339
5392
  } catch {}
5340
5393
  return result;
5341
5394
  };
5342
5395
  wrappedFn.collector = null;
5396
+ Object.defineProperty(wrappedFn, "name", {
5397
+ configurable: true,
5398
+ value: methodName
5399
+ });
5343
5400
  return wrappedFn;
5344
5401
  }
5345
5402
  withSpan(traceFunctionKey, optionsOrFn, maybeFn) {
@@ -5978,7 +6035,7 @@ var Bitfab = class {
5978
6035
  await runWithSeedContext({ traceId }, async () => target(...args));
5979
6036
  } finally {
5980
6037
  try {
5981
- const { flushTraces } = await import("./http-D91qP2J-.js").then((n) => n.a);
6038
+ const { flushTraces } = await import("./http-CcYPHER5.js").then((n) => n.a);
5982
6039
  await flushTraces(3e4);
5983
6040
  } finally {
5984
6041
  unrecorded = activeTraceStates.delete(traceId);
@@ -6166,7 +6223,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
6166
6223
  metadata: seedCase.metadata,
6167
6224
  sessionId: seedCase.sessionId
6168
6225
  }));
6169
- const { flushTraces } = await import("./http-D91qP2J-.js").then((n) => n.a);
6226
+ const { flushTraces } = await import("./http-CcYPHER5.js").then((n) => n.a);
6170
6227
  await flushTraces(3e4);
6171
6228
  return {
6172
6229
  pipeline,
@@ -6183,4 +6240,4 @@ function resolveTraceFunctionKey(registration) {
6183
6240
  //#endregion
6184
6241
  export { ExperimentsClient as A, BitfabOpenAIAgentHandler as C, GradersClient as D, BitfabLangGraphCallbackHandler as E, BitfabClaudeAgentHandler as F, DEFAULT_SERVICE_URL as I, AssertionCategoriesClient as L, DatasetsClient as M, GraderRerunError as N, LabelsClient as O, GraderRerunTimeoutError as P, CategoriesClient as R, 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, SUPPORTED_PROVIDERS as j, VerdictsClient 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 };
6185
6242
 
6186
- //# sourceMappingURL=src-CL5eQlNk.js.map
6243
+ //# sourceMappingURL=src-CFDoTgXw.js.map