bitfab 0.68.4 → 0.68.5
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-D3-OZcmR.cjs → autoTrace-DUmR1KJ8.cjs} +417 -62
- package/dist/autoTrace-DUmR1KJ8.cjs.map +1 -0
- package/dist/{autoTrace-ghnojSj9.js → autoTrace-DVnpnuMb.js} +322 -57
- package/dist/autoTrace-DVnpnuMb.js.map +1 -0
- package/dist/autoTrace.cjs +3 -1
- package/dist/autoTrace.d.cts +29 -1
- package/dist/autoTrace.d.ts +29 -1
- package/dist/autoTrace.js +1 -1
- package/dist/{babelPlugin-0uOq-j1Q.cjs → babelPlugin-C0Im6AZ2.cjs} +37 -14
- package/dist/babelPlugin-C0Im6AZ2.cjs.map +1 -0
- package/dist/{babelPlugin-Muq0uuuu.js → babelPlugin-hS2Hb2vt.js} +37 -14
- package/dist/babelPlugin-hS2Hb2vt.js.map +1 -0
- package/dist/baml.cjs +1 -1
- package/dist/baml.js +1 -1
- package/dist/{bamlPeer-BUoZgNxZ.cjs → bamlPeer-5Ohpq8q9.cjs} +3 -17
- package/dist/bamlPeer-5Ohpq8q9.cjs.map +1 -0
- package/dist/{bamlPeer-CIVwS68E.js → bamlPeer-Dyeb3e5o.js} +3 -11
- package/dist/bamlPeer-Dyeb3e5o.js.map +1 -0
- package/dist/{http-BGY4ULH5.js → http-CDqaLdge.js} +3 -3
- package/dist/{http-BGY4ULH5.js.map → http-CDqaLdge.js.map} +1 -1
- package/dist/{http-C-HrwUb8.cjs → http-DFqFW_hG.cjs} +4 -4
- package/dist/{http-C-HrwUb8.cjs.map → http-DFqFW_hG.cjs.map} +1 -1
- package/dist/{index-BcGxu85i.d.cts → index-DMJ6qrtL.d.cts} +109 -2
- package/dist/{index-BcGxu85i.d.ts → index-DMJ6qrtL.d.ts} +109 -2
- 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 +3 -3
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/dist/optionalPeer-CUH756lt.cjs +17 -0
- package/dist/optionalPeer-CUH756lt.cjs.map +1 -0
- package/dist/optionalPeer-CczrzrXx.js +12 -0
- package/dist/optionalPeer-CczrzrXx.js.map +1 -0
- package/dist/{registryCommand-Dk4Y1ZgW.js → registryCommand-D7bfo0Au.js} +179 -8
- package/dist/registryCommand-D7bfo0Au.js.map +1 -0
- package/dist/replayCli.js +1 -1
- package/dist/seedCli.js +1 -1
- package/dist/{src-BG2_8Fpf.cjs → src-CxELko3f.cjs} +52 -80
- package/dist/src-CxELko3f.cjs.map +1 -0
- package/dist/{src-Cmfs_7Ib.js → src-DvVk1aLi.js} +41 -69
- package/dist/src-DvVk1aLi.js.map +1 -0
- package/dist/transform/babel.cjs +1 -1
- 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 +36 -13
- 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-CAJyLLe2.js → transform-BL1fJW-C.js} +2 -2
- package/dist/{transform-CAJyLLe2.js.map → transform-BL1fJW-C.js.map} +1 -1
- package/dist/{transform-ClCOpCZ2.cjs → transform-C4H7TKW-.cjs} +2 -2
- package/dist/{transform-ClCOpCZ2.cjs.map → transform-C4H7TKW-.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/autoTrace-D3-OZcmR.cjs.map +0 -1
- package/dist/autoTrace-ghnojSj9.js.map +0 -1
- package/dist/babelPlugin-0uOq-j1Q.cjs.map +0 -1
- package/dist/babelPlugin-Muq0uuuu.js.map +0 -1
- package/dist/bamlPeer-BUoZgNxZ.cjs.map +0 -1
- package/dist/bamlPeer-CIVwS68E.js.map +0 -1
- package/dist/registryCommand-Dk4Y1ZgW.js.map +0 -1
- package/dist/src-BG2_8Fpf.cjs.map +0 -1
- package/dist/src-Cmfs_7Ib.js.map +0 -1
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-
|
|
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-D7bfo0Au.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-
|
|
2
|
+
import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-D7bfo0Au.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,6 +1,7 @@
|
|
|
1
|
-
const require_bamlPeer = require("./bamlPeer-
|
|
2
|
-
const require_http = require("./http-
|
|
3
|
-
const require_autoTrace = require("./autoTrace-
|
|
1
|
+
const require_bamlPeer = require("./bamlPeer-5Ohpq8q9.cjs");
|
|
2
|
+
const require_http = require("./http-DFqFW_hG.cjs");
|
|
3
|
+
const require_autoTrace = require("./autoTrace-DUmR1KJ8.cjs");
|
|
4
|
+
const require_optionalPeer = require("./optionalPeer-CUH756lt.cjs");
|
|
4
5
|
let superjson = require("superjson");
|
|
5
6
|
superjson = require_bamlPeer.__toESM(superjson, 1);
|
|
6
7
|
//#region src/categories.ts
|
|
@@ -1696,6 +1697,7 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1696
1697
|
this.getActiveSpanContext = config.getActiveSpanContext ?? null;
|
|
1697
1698
|
this.shouldRecord = config.shouldRecord ?? (() => this.httpClient.hasApiKey());
|
|
1698
1699
|
this.captureTools = config.captureTools ?? true;
|
|
1700
|
+
require_autoTrace.installLangChainRunScopes();
|
|
1699
1701
|
}
|
|
1700
1702
|
async close(timeoutMs) {
|
|
1701
1703
|
return this.ownsHttpClient ? this.httpClient.close(timeoutMs) : true;
|
|
@@ -1907,6 +1909,7 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1907
1909
|
const converted = messages.map((batch) => batch.map(convertMessage));
|
|
1908
1910
|
const spanInfo = this.startSpan(runId, parentRunId, String(name), "llm", converted, metadata, tags);
|
|
1909
1911
|
spanInfo.model = model;
|
|
1912
|
+
if (this.shouldRecord()) require_autoTrace.markLangChainRunRecorded(runId);
|
|
1910
1913
|
} catch {}
|
|
1911
1914
|
}
|
|
1912
1915
|
async handleLLMStart(llm, prompts, runId, parentRunId, _extraParams, tags, metadata, runName) {
|
|
@@ -1917,10 +1920,12 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1917
1920
|
const name = runName ?? model ?? idArr?.[idArr.length - 1] ?? "llm";
|
|
1918
1921
|
const spanInfo = this.startSpan(runId, parentRunId, String(name), "llm", prompts, metadata, tags);
|
|
1919
1922
|
spanInfo.model = model;
|
|
1923
|
+
if (this.shouldRecord()) require_autoTrace.markLangChainRunRecorded(runId);
|
|
1920
1924
|
} catch {}
|
|
1921
1925
|
}
|
|
1922
1926
|
async handleLLMEnd(output, runId) {
|
|
1923
1927
|
try {
|
|
1928
|
+
require_autoTrace.forgetLangChainRun(runId);
|
|
1924
1929
|
let llmOutput;
|
|
1925
1930
|
const generations = output.generations;
|
|
1926
1931
|
if (generations?.length && generations[generations.length - 1]?.length) {
|
|
@@ -1938,6 +1943,7 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1938
1943
|
}
|
|
1939
1944
|
async handleLLMError(error, runId) {
|
|
1940
1945
|
try {
|
|
1946
|
+
require_autoTrace.forgetLangChainRun(runId);
|
|
1941
1947
|
this.completeSpan(runId, void 0, error instanceof Error ? error.message : String(error));
|
|
1942
1948
|
} catch {}
|
|
1943
1949
|
}
|
|
@@ -2043,7 +2049,7 @@ function fromBase64(text) {
|
|
|
2043
2049
|
}
|
|
2044
2050
|
async function loadLangGraphPeer() {
|
|
2045
2051
|
try {
|
|
2046
|
-
return await
|
|
2052
|
+
return await require_optionalPeer.importOptionalPeer(["@langchain", "langgraph"]);
|
|
2047
2053
|
} catch {
|
|
2048
2054
|
throw new require_http.BitfabError("Restoring a LangGraph thread during replay requires @langchain/langgraph.", "https://docs.bitfab.ai/frameworks/langgraph");
|
|
2049
2055
|
}
|
|
@@ -2285,14 +2291,14 @@ function isEncodedToolResult(value) {
|
|
|
2285
2291
|
}
|
|
2286
2292
|
async function loadPeer(specifierParts, packageName, docsPath) {
|
|
2287
2293
|
try {
|
|
2288
|
-
return await
|
|
2294
|
+
return await require_optionalPeer.importOptionalPeer(specifierParts);
|
|
2289
2295
|
} catch {
|
|
2290
2296
|
throw new require_http.BitfabError(`This LangGraph integration method requires ${packageName}. Install it to use it.`, `https://docs.bitfab.ai${docsPath}`);
|
|
2291
2297
|
}
|
|
2292
2298
|
}
|
|
2293
2299
|
async function loadLangChainCore() {
|
|
2294
2300
|
try {
|
|
2295
|
-
return await
|
|
2301
|
+
return await require_optionalPeer.importOptionalPeer([
|
|
2296
2302
|
"@langchain",
|
|
2297
2303
|
"core",
|
|
2298
2304
|
"messages"
|
|
@@ -2303,7 +2309,7 @@ async function loadLangChainCore() {
|
|
|
2303
2309
|
}
|
|
2304
2310
|
async function loadLangGraph() {
|
|
2305
2311
|
try {
|
|
2306
|
-
return await
|
|
2312
|
+
return await require_optionalPeer.importOptionalPeer(["@langchain", "langgraph"]);
|
|
2307
2313
|
} catch {
|
|
2308
2314
|
throw new require_http.BitfabError("Replaying a LangGraph Command requires @langchain/langgraph.", "https://docs.bitfab.ai/frameworks/langgraph");
|
|
2309
2315
|
}
|
|
@@ -2548,7 +2554,7 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
2548
2554
|
this.getActiveSpanContext = config.getActiveSpanContext;
|
|
2549
2555
|
}
|
|
2550
2556
|
async wrapRun(agent, input, options) {
|
|
2551
|
-
const { run } = await
|
|
2557
|
+
const { run } = await require_optionalPeer.importOptionalPeer(["@openai", "agents"]);
|
|
2552
2558
|
if (this.getActiveSpanContext?.() != null) return run(agent, input, options);
|
|
2553
2559
|
const isStreaming = options?.stream === true;
|
|
2554
2560
|
const finalize = async (result) => {
|
|
@@ -2570,64 +2576,6 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
2570
2576
|
}
|
|
2571
2577
|
};
|
|
2572
2578
|
//#endregion
|
|
2573
|
-
//#region src/openaiAgentsSpanContext.ts
|
|
2574
|
-
const OPENAI_AGENTS_CONTEXT_STORAGE = Symbol.for("openai.agents.core.asyncLocalStorage");
|
|
2575
|
-
const MAX_OPENAI_AGENTS_SPAN_CHAIN = 64;
|
|
2576
|
-
const spanGlobal = globalThis;
|
|
2577
|
-
const state = spanGlobal.__bitfabOpenAiAgentsSpansV1 ?? {
|
|
2578
|
-
bitfabTraceIds: /* @__PURE__ */ new Map(),
|
|
2579
|
-
endedSpanIds: /* @__PURE__ */ new Map()
|
|
2580
|
-
};
|
|
2581
|
-
spanGlobal.__bitfabOpenAiAgentsSpansV1 = state;
|
|
2582
|
-
function mapOpenAiAgentsTrace(agentsTraceId, bitfabTraceId) {
|
|
2583
|
-
state.bitfabTraceIds.set(agentsTraceId, bitfabTraceId);
|
|
2584
|
-
}
|
|
2585
|
-
function unmapOpenAiAgentsTrace(agentsTraceId) {
|
|
2586
|
-
state.bitfabTraceIds.delete(agentsTraceId);
|
|
2587
|
-
state.endedSpanIds.delete(agentsTraceId);
|
|
2588
|
-
}
|
|
2589
|
-
function endOpenAiAgentsSpan(agentsTraceId, spanId) {
|
|
2590
|
-
if (!state.bitfabTraceIds.has(agentsTraceId)) return;
|
|
2591
|
-
const ended = state.endedSpanIds.get(agentsTraceId) ?? /* @__PURE__ */ new Set();
|
|
2592
|
-
ended.add(spanId);
|
|
2593
|
-
state.endedSpanIds.set(agentsTraceId, ended);
|
|
2594
|
-
}
|
|
2595
|
-
function isOpenAiAgentsContextStorage(value) {
|
|
2596
|
-
return value !== null && typeof value === "object" && typeof value.getStore === "function";
|
|
2597
|
-
}
|
|
2598
|
-
function currentOpenAiAgentsSpan() {
|
|
2599
|
-
const storage = spanGlobal[OPENAI_AGENTS_CONTEXT_STORAGE];
|
|
2600
|
-
if (!isOpenAiAgentsContextStorage(storage)) return;
|
|
2601
|
-
try {
|
|
2602
|
-
const store = storage.getStore();
|
|
2603
|
-
return store?.active === true ? store.span ?? void 0 : void 0;
|
|
2604
|
-
} catch {
|
|
2605
|
-
return;
|
|
2606
|
-
}
|
|
2607
|
-
}
|
|
2608
|
-
function currentOpenAiAgentsSpans() {
|
|
2609
|
-
const spans = [];
|
|
2610
|
-
let span = currentOpenAiAgentsSpan();
|
|
2611
|
-
while (span !== void 0 && spans.length < MAX_OPENAI_AGENTS_SPAN_CHAIN) {
|
|
2612
|
-
spans.push(span);
|
|
2613
|
-
span = span.previousSpan ?? void 0;
|
|
2614
|
-
}
|
|
2615
|
-
return spans;
|
|
2616
|
-
}
|
|
2617
|
-
function openAiAgentsSpanChain() {
|
|
2618
|
-
if (state.bitfabTraceIds.size === 0) return [];
|
|
2619
|
-
return currentOpenAiAgentsSpans().map((span) => span.spanId).filter((spanId) => typeof spanId === "string");
|
|
2620
|
-
}
|
|
2621
|
-
function openAiAgentsParentSpanId(bitfabTraceId, enclosingSpanIds) {
|
|
2622
|
-
if (state.bitfabTraceIds.size === 0) return;
|
|
2623
|
-
for (const span of currentOpenAiAgentsSpans()) {
|
|
2624
|
-
if (typeof span.spanId !== "string" || typeof span.traceId !== "string") return;
|
|
2625
|
-
if (state.bitfabTraceIds.get(span.traceId) !== bitfabTraceId) return;
|
|
2626
|
-
if (enclosingSpanIds?.includes(span.spanId)) return;
|
|
2627
|
-
if (!state.endedSpanIds.get(span.traceId)?.has(span.spanId)) return span.spanId;
|
|
2628
|
-
}
|
|
2629
|
-
}
|
|
2630
|
-
//#endregion
|
|
2631
2579
|
//#region src/organizationMembers.ts
|
|
2632
2580
|
const MEMBERS_PATH = "/api/sdk/organizationMembers";
|
|
2633
2581
|
var OrganizationMembersClient = class {
|
|
@@ -4688,7 +4636,7 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
4688
4636
|
const activeContext = this.getActiveSpanContext?.();
|
|
4689
4637
|
if (activeContext) {
|
|
4690
4638
|
this.activeSpanMappings[trace.traceId] = activeContext;
|
|
4691
|
-
if (this.shouldRecord()) mapOpenAiAgentsTrace(trace.traceId, activeContext.traceId);
|
|
4639
|
+
if (this.shouldRecord()) require_autoTrace.mapOpenAiAgentsTrace(trace.traceId, activeContext.traceId);
|
|
4692
4640
|
}
|
|
4693
4641
|
const canonicalTraceId = activeContext?.traceId ?? this.getCanonicalTraceId(trace.traceId);
|
|
4694
4642
|
this.canonicalTraceIds[trace.traceId] = canonicalTraceId;
|
|
@@ -4713,7 +4661,7 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
4713
4661
|
if (!this.endedTraces.has(traceId) || [...this.startedSpans.values()].includes(traceId)) return;
|
|
4714
4662
|
this.endedTraces.delete(traceId);
|
|
4715
4663
|
delete this.activeSpanMappings[traceId];
|
|
4716
|
-
unmapOpenAiAgentsTrace(traceId);
|
|
4664
|
+
require_autoTrace.unmapOpenAiAgentsTrace(traceId);
|
|
4717
4665
|
delete this.canonicalTraceIds[traceId];
|
|
4718
4666
|
delete this.activeTraces[traceId];
|
|
4719
4667
|
}
|
|
@@ -4727,7 +4675,7 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
4727
4675
|
async onSpanEnd(span) {
|
|
4728
4676
|
const originalTraceId = span.traceId ?? "";
|
|
4729
4677
|
const traceId = this.activeSpanMappings[originalTraceId]?.traceId ?? originalTraceId;
|
|
4730
|
-
if (span.spanId !== void 0) endOpenAiAgentsSpan(originalTraceId, span.spanId);
|
|
4678
|
+
if (span.spanId !== void 0) require_autoTrace.endOpenAiAgentsSpan(originalTraceId, span.spanId);
|
|
4731
4679
|
try {
|
|
4732
4680
|
this.sendSpan(span);
|
|
4733
4681
|
} finally {
|
|
@@ -4742,7 +4690,7 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
4742
4690
|
await this.httpClient.waitForPendingRequests();
|
|
4743
4691
|
}
|
|
4744
4692
|
async shutdown(timeout) {
|
|
4745
|
-
for (const traceId of Object.keys(this.activeSpanMappings)) unmapOpenAiAgentsTrace(traceId);
|
|
4693
|
+
for (const traceId of Object.keys(this.activeSpanMappings)) require_autoTrace.unmapOpenAiAgentsTrace(traceId);
|
|
4746
4694
|
this.activeTraces = {};
|
|
4747
4695
|
this.activeSpanMappings = {};
|
|
4748
4696
|
this.canonicalTraceIds = {};
|
|
@@ -5220,7 +5168,7 @@ function extractContextFromCollector(collector) {
|
|
|
5220
5168
|
}
|
|
5221
5169
|
const BOUND_FUNCTION_NAME_PREFIX = /^bound /;
|
|
5222
5170
|
function discoveredSpanType(definition, nodeConfiguration) {
|
|
5223
|
-
const recordsModelCall = definition.baml === true || definition.jev === true || definition.
|
|
5171
|
+
const recordsModelCall = definition.baml === true || definition.jev === true || definition.clientCall !== void 0;
|
|
5224
5172
|
const ownType = recordsModelCall ? "llm" : "function";
|
|
5225
5173
|
if (nodeConfiguration === void 0) return ownType;
|
|
5226
5174
|
if (recordsModelCall && nodeConfiguration.defaultType === true) return ownType;
|
|
@@ -5541,6 +5489,7 @@ var Bitfab = class {
|
|
|
5541
5489
|
const self = this;
|
|
5542
5490
|
self.simulationPlan.refresh();
|
|
5543
5491
|
loadCollectorClass();
|
|
5492
|
+
require_autoTrace.installLangChainRunScopes();
|
|
5544
5493
|
const runRootFunction = (receiver, args) => require_autoTrace.runAsAutoTraceRootFunction(rootFunctionName, () => fn.apply(receiver, args));
|
|
5545
5494
|
const maxDepth = autoTraceLimit(options.maxDepth, DEFAULT_AUTO_TRACE_MAX_DEPTH);
|
|
5546
5495
|
const maxCapturedSubtreeSpans = autoTraceLimit(options.maxCapturedSubtreeSpans, DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS);
|
|
@@ -5629,7 +5578,8 @@ var Bitfab = class {
|
|
|
5629
5578
|
...nodeConfiguration?.finalize !== void 0 && { finalize: nodeConfiguration.finalize }
|
|
5630
5579
|
};
|
|
5631
5580
|
const isAsync = definition.async === true;
|
|
5632
|
-
|
|
5581
|
+
const clientCall = require_autoTrace.clientCallProvider(definition.clientCall);
|
|
5582
|
+
return openChild(entry, childOptions, inputs, isAsync, definition.baml === true ? () => invokeAutoTracedBaml(invokeFn, isAsync) : definition.jev === true ? () => recordAutoTracedJev(invokeFn, getCurrentSpan()) : clientCall !== void 0 ? () => require_autoTrace.recordAutoTracedClientCall(clientCall, invokeFn, inputs[0], getCurrentSpan()) : invokeFn);
|
|
5633
5583
|
},
|
|
5634
5584
|
invokeNestedRoot(nestedName, nestedFunctionName, inputs, invokeFn, entry, link, spanDetails) {
|
|
5635
5585
|
if (excluded.has(nestedName) || excluded.has(nestedFunctionName) || !recordsSpan(entry, nestedName, true)) return invokeFn();
|
|
@@ -5941,14 +5891,30 @@ var Bitfab = class {
|
|
|
5941
5891
|
return wrappedFn;
|
|
5942
5892
|
}
|
|
5943
5893
|
wrapOpenRouter(method, options) {
|
|
5894
|
+
return this.wrapClientCall(require_autoTrace.OPENROUTER, "wrapOpenRouter requires a named function (e.g., openai.chat.completions.create.bind(openai.chat.completions)).", method, options);
|
|
5895
|
+
}
|
|
5896
|
+
wrapAnthropic(method, options) {
|
|
5897
|
+
return this.wrapClientCall(require_autoTrace.ANTHROPIC, "wrapAnthropic requires a named function (e.g., anthropic.messages.create.bind(anthropic.messages)).", method, options);
|
|
5898
|
+
}
|
|
5899
|
+
wrapOpenAIResponses(method, options) {
|
|
5900
|
+
return this.wrapClientCall(require_autoTrace.OPENAI_RESPONSES, "wrapOpenAIResponses requires a named function (e.g., openai.responses.create.bind(openai.responses)).", method, options);
|
|
5901
|
+
}
|
|
5902
|
+
wrapClientCall(provider, anonymousError, method, options) {
|
|
5944
5903
|
const methodName = method.name.replace(BOUND_FUNCTION_NAME_PREFIX, "");
|
|
5945
|
-
if (!methodName) throw new require_http.BitfabError(
|
|
5904
|
+
if (!methodName) throw new require_http.BitfabError(anonymousError);
|
|
5946
5905
|
const wrappedFn = async (...args) => {
|
|
5947
5906
|
const span = getCurrentSpan();
|
|
5948
5907
|
const startedAt = Date.now();
|
|
5949
|
-
|
|
5908
|
+
if (require_autoTrace.frameworkRecordsClientCall()) {
|
|
5909
|
+
const response = await method(...args);
|
|
5910
|
+
try {
|
|
5911
|
+
options?.onResponse?.(response);
|
|
5912
|
+
} catch {}
|
|
5913
|
+
return response;
|
|
5914
|
+
}
|
|
5915
|
+
const { watch, result } = require_autoTrace.watchClientCall(() => method(...args));
|
|
5950
5916
|
const response = await result;
|
|
5951
|
-
require_autoTrace.
|
|
5917
|
+
require_autoTrace.recordWatchedClientCall(provider, span, watch, args[0], response, Date.now() - startedAt);
|
|
5952
5918
|
try {
|
|
5953
5919
|
options?.onResponse?.(response);
|
|
5954
5920
|
} catch {}
|
|
@@ -6011,7 +5977,7 @@ var Bitfab = class {
|
|
|
6011
5977
|
const seedCtxForTraceId = parentContext ? null : getSeedContext();
|
|
6012
5978
|
const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? seedCtxForTraceId?.traceId ?? randomUuid();
|
|
6013
5979
|
const spanId = randomUuid();
|
|
6014
|
-
const openAiAgentsParent = parentContext !== void 0 && options.instrumentation === "trace" ? openAiAgentsParentSpanId(parentContext.traceId, parentContext.openAiAgentsSpanIds) : void 0;
|
|
5980
|
+
const openAiAgentsParent = parentContext !== void 0 && options.instrumentation === "trace" ? require_autoTrace.openAiAgentsParentSpanId(parentContext.traceId, parentContext.openAiAgentsSpanIds) : void 0;
|
|
6015
5981
|
const frameworkParent = parentContext !== void 0 ? options.frameworkParentSpanId : void 0;
|
|
6016
5982
|
const parentSpanId = openAiAgentsParent ?? frameworkParent ?? parentContext?.spanId ?? null;
|
|
6017
5983
|
const isRootSpan = parentSpanId === null;
|
|
@@ -6022,7 +5988,7 @@ var Bitfab = class {
|
|
|
6022
5988
|
const requestedSurface = options.surface ?? "opt-in";
|
|
6023
5989
|
const surface = resolveSurface(requestedSurface, parentContext?.surface);
|
|
6024
5990
|
assertSurfacesCompatible(requestedSurface, surface, parentContext?.surface, traceFunctionKey);
|
|
6025
|
-
const openAiAgentsSpanIds = openAiAgentsSpanChain();
|
|
5991
|
+
const openAiAgentsSpanIds = require_autoTrace.openAiAgentsSpanChain();
|
|
6026
5992
|
const functionNameAtOpen = fn.name !== "" ? fn.name : void 0;
|
|
6027
5993
|
const newContext = {
|
|
6028
5994
|
traceId,
|
|
@@ -6598,7 +6564,7 @@ var Bitfab = class {
|
|
|
6598
6564
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
6599
6565
|
} finally {
|
|
6600
6566
|
try {
|
|
6601
|
-
const { flushTraces } = await Promise.resolve().then(() => require("./http-
|
|
6567
|
+
const { flushTraces } = await Promise.resolve().then(() => require("./http-DFqFW_hG.cjs")).then((n) => n.http_exports);
|
|
6602
6568
|
await flushTraces(3e4);
|
|
6603
6569
|
} finally {
|
|
6604
6570
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -6693,6 +6659,12 @@ var BitfabFunction = class {
|
|
|
6693
6659
|
wrapOpenRouter(method, options) {
|
|
6694
6660
|
return this.client.wrapOpenRouter(method, options);
|
|
6695
6661
|
}
|
|
6662
|
+
wrapAnthropic(method, options) {
|
|
6663
|
+
return this.client.wrapAnthropic(method, options);
|
|
6664
|
+
}
|
|
6665
|
+
wrapOpenAIResponses(method, options) {
|
|
6666
|
+
return this.client.wrapOpenAIResponses(method, options);
|
|
6667
|
+
}
|
|
6696
6668
|
};
|
|
6697
6669
|
//#endregion
|
|
6698
6670
|
//#region src/finalizers.ts
|
|
@@ -6795,7 +6767,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
6795
6767
|
metadata: seedCase.metadata,
|
|
6796
6768
|
sessionId: seedCase.sessionId
|
|
6797
6769
|
}));
|
|
6798
|
-
const { flushTraces } = await Promise.resolve().then(() => require("./http-
|
|
6770
|
+
const { flushTraces } = await Promise.resolve().then(() => require("./http-DFqFW_hG.cjs")).then((n) => n.http_exports);
|
|
6799
6771
|
await flushTraces(3e4);
|
|
6800
6772
|
return {
|
|
6801
6773
|
pipeline,
|
|
@@ -7039,4 +7011,4 @@ Object.defineProperty(exports, "serializeReplayResult", {
|
|
|
7039
7011
|
}
|
|
7040
7012
|
});
|
|
7041
7013
|
|
|
7042
|
-
//# sourceMappingURL=src-
|
|
7014
|
+
//# sourceMappingURL=src-CxELko3f.cjs.map
|