bitfab 0.21.2 → 0.23.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/{chunk-3YKMCCDV.js → chunk-QOPP5TSO.js} +66 -3
- package/dist/chunk-QOPP5TSO.js.map +1 -0
- package/dist/index.cjs +66 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -4
- package/dist/index.d.ts +97 -4
- package/dist/index.js +3 -1
- package/dist/node.cjs +66 -2
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +3 -1
- package/dist/node.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3YKMCCDV.js.map +0 -1
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-EQI6ZJC3.js";
|
|
11
11
|
|
|
12
12
|
// src/version.generated.ts
|
|
13
|
-
var __version__ = "0.
|
|
13
|
+
var __version__ = "0.23.0";
|
|
14
14
|
|
|
15
15
|
// src/constants.ts
|
|
16
16
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1454,8 +1454,9 @@ function extractLangGraphMetadata(metadata) {
|
|
|
1454
1454
|
var BitfabLangGraphCallbackHandler = class {
|
|
1455
1455
|
constructor(config) {
|
|
1456
1456
|
this.name = "BitfabLangGraphCallbackHandler";
|
|
1457
|
-
this.ignoreRetriever = true;
|
|
1458
1457
|
this.ignoreRetry = true;
|
|
1458
|
+
// Retriever callbacks ARE captured (retriever queries -> function spans).
|
|
1459
|
+
this.ignoreRetriever = false;
|
|
1459
1460
|
this.ignoreCustomEvent = true;
|
|
1460
1461
|
this.runToSpan = /* @__PURE__ */ new Map();
|
|
1461
1462
|
this.invocations = /* @__PURE__ */ new Map();
|
|
@@ -1785,6 +1786,39 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
1785
1786
|
}
|
|
1786
1787
|
};
|
|
1787
1788
|
|
|
1789
|
+
// src/openaiAgentSdk.ts
|
|
1790
|
+
var BitfabOpenAIAgentHandler = class {
|
|
1791
|
+
constructor(config) {
|
|
1792
|
+
this.traceFunctionKey = config.traceFunctionKey;
|
|
1793
|
+
this.withSpanFn = config.withSpan;
|
|
1794
|
+
}
|
|
1795
|
+
async wrapRun(agent, input, options) {
|
|
1796
|
+
const { run } = await import("@openai/agents");
|
|
1797
|
+
const isStreaming = options?.stream === true;
|
|
1798
|
+
const finalize = async (result) => {
|
|
1799
|
+
const res = result;
|
|
1800
|
+
if (isStreaming && res?.completed) {
|
|
1801
|
+
try {
|
|
1802
|
+
await res.completed;
|
|
1803
|
+
} catch {
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
return res?.finalOutput;
|
|
1807
|
+
};
|
|
1808
|
+
const options_ = { type: "agent", finalize };
|
|
1809
|
+
const traced = this.withSpanFn(
|
|
1810
|
+
this.traceFunctionKey,
|
|
1811
|
+
options_,
|
|
1812
|
+
(agentInput) => run(
|
|
1813
|
+
agent,
|
|
1814
|
+
agentInput,
|
|
1815
|
+
options
|
|
1816
|
+
)
|
|
1817
|
+
);
|
|
1818
|
+
return traced(input);
|
|
1819
|
+
}
|
|
1820
|
+
};
|
|
1821
|
+
|
|
1788
1822
|
// src/replayEnvironment.ts
|
|
1789
1823
|
var ReplayEnvironment = class {
|
|
1790
1824
|
/**
|
|
@@ -2471,6 +2505,34 @@ var Bitfab = class {
|
|
|
2471
2505
|
}
|
|
2472
2506
|
});
|
|
2473
2507
|
}
|
|
2508
|
+
/**
|
|
2509
|
+
* Get an OpenAI Agents SDK handler that records a replayable root span.
|
|
2510
|
+
*
|
|
2511
|
+
* The processor from {@link getOpenAiTracingProcessor} captures everything
|
|
2512
|
+
* inside a run (LLM calls, tools, handoffs) but never sees the caller's
|
|
2513
|
+
* input, so a processor-only run records an empty-input root and is not
|
|
2514
|
+
* replayable. This handler's `wrapRun` is a drop-in for `run()` that opens a
|
|
2515
|
+
* `withSpan` root carrying the input and final output; the processor's spans
|
|
2516
|
+
* nest beneath it. Register the processor once at startup, then call
|
|
2517
|
+
* `handler.wrapRun(agent, input)` in place of `run(agent, input)`.
|
|
2518
|
+
*
|
|
2519
|
+
* ```typescript
|
|
2520
|
+
* import { addTraceProcessor, Agent, run } from "@openai/agents";
|
|
2521
|
+
*
|
|
2522
|
+
* addTraceProcessor(client.getOpenAiTracingProcessor());
|
|
2523
|
+
* const handler = client.getOpenAiAgentHandler("research-topic");
|
|
2524
|
+
* const result = await handler.wrapRun(agent, "Find X");
|
|
2525
|
+
* ```
|
|
2526
|
+
*
|
|
2527
|
+
* @param traceFunctionKey - Groups traces under this key in Bitfab
|
|
2528
|
+
* @returns A BitfabOpenAIAgentHandler configured for this client
|
|
2529
|
+
*/
|
|
2530
|
+
getOpenAiAgentHandler(traceFunctionKey) {
|
|
2531
|
+
return new BitfabOpenAIAgentHandler({
|
|
2532
|
+
traceFunctionKey,
|
|
2533
|
+
withSpan: this.withSpan.bind(this)
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2474
2536
|
/**
|
|
2475
2537
|
* Get a LangGraph/LangChain callback handler for tracing.
|
|
2476
2538
|
*
|
|
@@ -3221,6 +3283,7 @@ export {
|
|
|
3221
3283
|
BitfabClaudeAgentHandler,
|
|
3222
3284
|
SUPPORTED_PROVIDERS,
|
|
3223
3285
|
BitfabLangGraphCallbackHandler,
|
|
3286
|
+
BitfabOpenAIAgentHandler,
|
|
3224
3287
|
ReplayEnvironment,
|
|
3225
3288
|
BitfabOpenAITracingProcessor,
|
|
3226
3289
|
getCurrentSpan,
|
|
@@ -3229,4 +3292,4 @@ export {
|
|
|
3229
3292
|
BitfabFunction,
|
|
3230
3293
|
finalizers
|
|
3231
3294
|
};
|
|
3232
|
-
//# sourceMappingURL=chunk-
|
|
3295
|
+
//# sourceMappingURL=chunk-QOPP5TSO.js.map
|