bitfab 0.21.2 → 0.22.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-4SLFC266.js} +64 -2
- package/dist/chunk-4SLFC266.js.map +1 -0
- package/dist/index.cjs +64 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +96 -3
- package/dist/index.d.ts +96 -3
- package/dist/index.js +3 -1
- package/dist/node.cjs +64 -1
- 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
package/dist/index.cjs
CHANGED
|
@@ -486,6 +486,7 @@ __export(index_exports, {
|
|
|
486
486
|
BitfabFunction: () => BitfabFunction,
|
|
487
487
|
BitfabLangChainCallbackHandler: () => BitfabLangGraphCallbackHandler,
|
|
488
488
|
BitfabLangGraphCallbackHandler: () => BitfabLangGraphCallbackHandler,
|
|
489
|
+
BitfabOpenAIAgentHandler: () => BitfabOpenAIAgentHandler,
|
|
489
490
|
BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
|
|
490
491
|
DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
|
|
491
492
|
ReplayEnvironment: () => ReplayEnvironment,
|
|
@@ -499,7 +500,7 @@ __export(index_exports, {
|
|
|
499
500
|
module.exports = __toCommonJS(index_exports);
|
|
500
501
|
|
|
501
502
|
// src/version.generated.ts
|
|
502
|
-
var __version__ = "0.
|
|
503
|
+
var __version__ = "0.22.0";
|
|
503
504
|
|
|
504
505
|
// src/constants.ts
|
|
505
506
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -2281,6 +2282,39 @@ var BitfabLangGraphCallbackHandler = class {
|
|
|
2281
2282
|
}
|
|
2282
2283
|
};
|
|
2283
2284
|
|
|
2285
|
+
// src/openaiAgentSdk.ts
|
|
2286
|
+
var BitfabOpenAIAgentHandler = class {
|
|
2287
|
+
constructor(config) {
|
|
2288
|
+
this.traceFunctionKey = config.traceFunctionKey;
|
|
2289
|
+
this.withSpanFn = config.withSpan;
|
|
2290
|
+
}
|
|
2291
|
+
async wrapRun(agent, input, options) {
|
|
2292
|
+
const { run } = await import("@openai/agents");
|
|
2293
|
+
const isStreaming = options?.stream === true;
|
|
2294
|
+
const finalize = async (result) => {
|
|
2295
|
+
const res = result;
|
|
2296
|
+
if (isStreaming && res?.completed) {
|
|
2297
|
+
try {
|
|
2298
|
+
await res.completed;
|
|
2299
|
+
} catch {
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
return res?.finalOutput;
|
|
2303
|
+
};
|
|
2304
|
+
const options_ = { type: "agent", finalize };
|
|
2305
|
+
const traced = this.withSpanFn(
|
|
2306
|
+
this.traceFunctionKey,
|
|
2307
|
+
options_,
|
|
2308
|
+
(agentInput) => run(
|
|
2309
|
+
agent,
|
|
2310
|
+
agentInput,
|
|
2311
|
+
options
|
|
2312
|
+
)
|
|
2313
|
+
);
|
|
2314
|
+
return traced(input);
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
|
|
2284
2318
|
// src/client.ts
|
|
2285
2319
|
init_replayContext();
|
|
2286
2320
|
|
|
@@ -2974,6 +3008,34 @@ var Bitfab = class {
|
|
|
2974
3008
|
}
|
|
2975
3009
|
});
|
|
2976
3010
|
}
|
|
3011
|
+
/**
|
|
3012
|
+
* Get an OpenAI Agents SDK handler that records a replayable root span.
|
|
3013
|
+
*
|
|
3014
|
+
* The processor from {@link getOpenAiTracingProcessor} captures everything
|
|
3015
|
+
* inside a run (LLM calls, tools, handoffs) but never sees the caller's
|
|
3016
|
+
* input, so a processor-only run records an empty-input root and is not
|
|
3017
|
+
* replayable. This handler's `wrapRun` is a drop-in for `run()` that opens a
|
|
3018
|
+
* `withSpan` root carrying the input and final output; the processor's spans
|
|
3019
|
+
* nest beneath it. Register the processor once at startup, then call
|
|
3020
|
+
* `handler.wrapRun(agent, input)` in place of `run(agent, input)`.
|
|
3021
|
+
*
|
|
3022
|
+
* ```typescript
|
|
3023
|
+
* import { addTraceProcessor, Agent, run } from "@openai/agents";
|
|
3024
|
+
*
|
|
3025
|
+
* addTraceProcessor(client.getOpenAiTracingProcessor());
|
|
3026
|
+
* const handler = client.getOpenAiAgentHandler("research-topic");
|
|
3027
|
+
* const result = await handler.wrapRun(agent, "Find X");
|
|
3028
|
+
* ```
|
|
3029
|
+
*
|
|
3030
|
+
* @param traceFunctionKey - Groups traces under this key in Bitfab
|
|
3031
|
+
* @returns A BitfabOpenAIAgentHandler configured for this client
|
|
3032
|
+
*/
|
|
3033
|
+
getOpenAiAgentHandler(traceFunctionKey) {
|
|
3034
|
+
return new BitfabOpenAIAgentHandler({
|
|
3035
|
+
traceFunctionKey,
|
|
3036
|
+
withSpan: this.withSpan.bind(this)
|
|
3037
|
+
});
|
|
3038
|
+
}
|
|
2977
3039
|
/**
|
|
2978
3040
|
* Get a LangGraph/LangChain callback handler for tracing.
|
|
2979
3041
|
*
|
|
@@ -3724,6 +3786,7 @@ var finalizers = {
|
|
|
3724
3786
|
BitfabFunction,
|
|
3725
3787
|
BitfabLangChainCallbackHandler,
|
|
3726
3788
|
BitfabLangGraphCallbackHandler,
|
|
3789
|
+
BitfabOpenAIAgentHandler,
|
|
3727
3790
|
BitfabOpenAITracingProcessor,
|
|
3728
3791
|
DEFAULT_SERVICE_URL,
|
|
3729
3792
|
ReplayEnvironment,
|