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.
- package/dist/autoTrace-CQw0qMBt.cjs.map +1 -1
- package/dist/autoTrace-O40k8f5M.js.map +1 -1
- package/dist/autoTrace.d.cts +2 -0
- package/dist/autoTrace.d.ts +2 -0
- package/dist/{babelPlugin-C70OxrqA.js → babelPlugin-CBjx6aJe.js} +28 -3
- package/dist/babelPlugin-CBjx6aJe.js.map +1 -0
- package/dist/{babelPlugin-Nta4-VcL.cjs → babelPlugin-ZR9ilYct.cjs} +28 -3
- package/dist/babelPlugin-ZR9ilYct.cjs.map +1 -0
- package/dist/{http-D91qP2J-.js → http-CcYPHER5.js} +2 -2
- package/dist/{http-D91qP2J-.js.map → http-CcYPHER5.js.map} +1 -1
- package/dist/{http-DIz8mEMq.cjs → http-CxT_WDAh.cjs} +2 -2
- package/dist/{http-DIz8mEMq.cjs.map → http-CxT_WDAh.cjs.map} +1 -1
- package/dist/{index-DiYFr-KV.d.cts → index-BFgtvRni.d.cts} +1 -1
- package/dist/{index-DiYFr-KV.d.ts → index-BFgtvRni.d.ts} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/node.cjs +2 -2
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +2 -2
- package/dist/registryCommand-Dk4Y1ZgW.js.map +1 -1
- package/dist/{src-CL5eQlNk.js → src-CFDoTgXw.js} +70 -13
- package/dist/{src-CL5eQlNk.js.map → src-CFDoTgXw.js.map} +1 -1
- package/dist/{src-rJcHXJEz.cjs → src-DXmdXbOL.cjs} +70 -13
- package/dist/{src-rJcHXJEz.cjs.map → src-DXmdXbOL.cjs.map} +1 -1
- package/dist/transform/babel.cjs +1 -1
- package/dist/transform/babel.d.cts +1 -0
- package/dist/transform/babel.d.ts +1 -0
- package/dist/transform/babel.js +1 -1
- package/dist/transform/loaderRuntime.cjs +2 -2
- package/dist/transform/loaderRuntime.js +2 -2
- package/dist/transform/nodeLoader.js +27 -2
- package/dist/transform/nodeLoader.js.map +1 -1
- package/dist/transform/swc.cjs +1 -1
- package/dist/transform/swc.js +1 -1
- package/dist/transform/unplugin.cjs +2 -2
- package/dist/transform/unplugin.js +2 -2
- package/dist/{transform-BcyUocwm.js → transform-DP1qnD8u.js} +2 -2
- package/dist/{transform-BcyUocwm.js.map → transform-DP1qnD8u.js.map} +1 -1
- package/dist/{transform-BjxHGGKc.cjs → transform-D_pSvPJc.cjs} +2 -2
- package/dist/{transform-BjxHGGKc.cjs.map → transform-D_pSvPJc.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/babelPlugin-C70OxrqA.js.map +0 -1
- package/dist/babelPlugin-Nta4-VcL.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_bamlPeer = require("./bamlPeer-BUoZgNxZ.cjs");
|
|
2
|
-
const require_http = require("./http-
|
|
2
|
+
const require_http = require("./http-CxT_WDAh.cjs");
|
|
3
3
|
const require_autoTrace = require("./autoTrace-CQw0qMBt.cjs");
|
|
4
4
|
let superjson = require("superjson");
|
|
5
5
|
superjson = require_bamlPeer.__toESM(superjson, 1);
|
|
@@ -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 require_http.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 require_http.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 require_http.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) => require_autoTrace.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
|
|
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
|
-
|
|
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
|
-
|
|
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 Promise.resolve().then(() => require("./http-
|
|
6038
|
+
const { flushTraces } = await Promise.resolve().then(() => require("./http-CxT_WDAh.cjs")).then((n) => n.http_exports);
|
|
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 Promise.resolve().then(() => require("./http-
|
|
6226
|
+
const { flushTraces } = await Promise.resolve().then(() => require("./http-CxT_WDAh.cjs")).then((n) => n.http_exports);
|
|
6170
6227
|
await flushTraces(3e4);
|
|
6171
6228
|
return {
|
|
6172
6229
|
pipeline,
|
|
@@ -6410,4 +6467,4 @@ Object.defineProperty(exports, "serializeReplayResult", {
|
|
|
6410
6467
|
}
|
|
6411
6468
|
});
|
|
6412
6469
|
|
|
6413
|
-
//# sourceMappingURL=src-
|
|
6470
|
+
//# sourceMappingURL=src-DXmdXbOL.cjs.map
|