bitfab 0.23.0 → 0.23.1
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-QOPP5TSO.js → chunk-2EDITKO2.js} +16 -4
- package/dist/{chunk-QOPP5TSO.js.map → chunk-2EDITKO2.js.map} +1 -1
- package/dist/index.cjs +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +1 -1
- package/dist/node.cjs +15 -3
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -330,6 +330,14 @@ declare class BitfabLangGraphCallbackHandler {
|
|
|
330
330
|
* replayable with no hand-written `withSpan`. The processor's spans nest
|
|
331
331
|
* underneath it automatically (it remaps onto the active span context).
|
|
332
332
|
*
|
|
333
|
+
* When `wrapRun` runs inside an enclosing Bitfab span (the replay auto-wrap, or
|
|
334
|
+
* a caller's own `withSpan`), that span is already the replayable root: the
|
|
335
|
+
* handler skips opening a second one and lets the processor nest the run's spans
|
|
336
|
+
* under the existing root. This mirrors the Claude Agent SDK and LangGraph
|
|
337
|
+
* handlers, which no-op their root span under an enclosing span, and keeps a
|
|
338
|
+
* replayed run's span tree identical to the original (no doubled root agent
|
|
339
|
+
* span).
|
|
340
|
+
*
|
|
333
341
|
* Use both together: register the processor once at startup, then call
|
|
334
342
|
* `handler.wrapRun(agent, input)` instead of `run(agent, input)`.
|
|
335
343
|
*/
|
|
@@ -339,6 +347,7 @@ type RootSpanOptions = {
|
|
|
339
347
|
finalize: (result: unknown) => unknown | Promise<unknown>;
|
|
340
348
|
};
|
|
341
349
|
type WithSpanFn = <TArgs extends unknown[], TReturn>(traceFunctionKey: string, options: RootSpanOptions, fn: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
|
|
350
|
+
type GetActiveSpanContextFn = () => unknown | null;
|
|
342
351
|
type RunInput<TContext, TAgent extends Agent<any, any>> = string | AgentInputItem[] | RunState<TContext, TAgent>;
|
|
343
352
|
/**
|
|
344
353
|
* OpenAI Agents SDK handler that records a replayable root span around a run.
|
|
@@ -361,9 +370,11 @@ type RunInput<TContext, TAgent extends Agent<any, any>> = string | AgentInputIte
|
|
|
361
370
|
declare class BitfabOpenAIAgentHandler {
|
|
362
371
|
private readonly traceFunctionKey;
|
|
363
372
|
private readonly withSpanFn;
|
|
373
|
+
private readonly getActiveSpanContext?;
|
|
364
374
|
constructor(config: {
|
|
365
375
|
traceFunctionKey: string;
|
|
366
376
|
withSpan: WithSpanFn;
|
|
377
|
+
getActiveSpanContext?: GetActiveSpanContextFn;
|
|
367
378
|
});
|
|
368
379
|
/**
|
|
369
380
|
* Drop-in replacement for the OpenAI Agents SDK's `run()` that records a
|
|
@@ -1210,7 +1221,7 @@ declare class BitfabFunction {
|
|
|
1210
1221
|
/**
|
|
1211
1222
|
* SDK version from package.json (injected at build time)
|
|
1212
1223
|
*/
|
|
1213
|
-
declare const __version__ = "0.23.
|
|
1224
|
+
declare const __version__ = "0.23.1";
|
|
1214
1225
|
|
|
1215
1226
|
/**
|
|
1216
1227
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -330,6 +330,14 @@ declare class BitfabLangGraphCallbackHandler {
|
|
|
330
330
|
* replayable with no hand-written `withSpan`. The processor's spans nest
|
|
331
331
|
* underneath it automatically (it remaps onto the active span context).
|
|
332
332
|
*
|
|
333
|
+
* When `wrapRun` runs inside an enclosing Bitfab span (the replay auto-wrap, or
|
|
334
|
+
* a caller's own `withSpan`), that span is already the replayable root: the
|
|
335
|
+
* handler skips opening a second one and lets the processor nest the run's spans
|
|
336
|
+
* under the existing root. This mirrors the Claude Agent SDK and LangGraph
|
|
337
|
+
* handlers, which no-op their root span under an enclosing span, and keeps a
|
|
338
|
+
* replayed run's span tree identical to the original (no doubled root agent
|
|
339
|
+
* span).
|
|
340
|
+
*
|
|
333
341
|
* Use both together: register the processor once at startup, then call
|
|
334
342
|
* `handler.wrapRun(agent, input)` instead of `run(agent, input)`.
|
|
335
343
|
*/
|
|
@@ -339,6 +347,7 @@ type RootSpanOptions = {
|
|
|
339
347
|
finalize: (result: unknown) => unknown | Promise<unknown>;
|
|
340
348
|
};
|
|
341
349
|
type WithSpanFn = <TArgs extends unknown[], TReturn>(traceFunctionKey: string, options: RootSpanOptions, fn: (...args: TArgs) => TReturn) => (...args: TArgs) => TReturn;
|
|
350
|
+
type GetActiveSpanContextFn = () => unknown | null;
|
|
342
351
|
type RunInput<TContext, TAgent extends Agent<any, any>> = string | AgentInputItem[] | RunState<TContext, TAgent>;
|
|
343
352
|
/**
|
|
344
353
|
* OpenAI Agents SDK handler that records a replayable root span around a run.
|
|
@@ -361,9 +370,11 @@ type RunInput<TContext, TAgent extends Agent<any, any>> = string | AgentInputIte
|
|
|
361
370
|
declare class BitfabOpenAIAgentHandler {
|
|
362
371
|
private readonly traceFunctionKey;
|
|
363
372
|
private readonly withSpanFn;
|
|
373
|
+
private readonly getActiveSpanContext?;
|
|
364
374
|
constructor(config: {
|
|
365
375
|
traceFunctionKey: string;
|
|
366
376
|
withSpan: WithSpanFn;
|
|
377
|
+
getActiveSpanContext?: GetActiveSpanContextFn;
|
|
367
378
|
});
|
|
368
379
|
/**
|
|
369
380
|
* Drop-in replacement for the OpenAI Agents SDK's `run()` that records a
|
|
@@ -1210,7 +1221,7 @@ declare class BitfabFunction {
|
|
|
1210
1221
|
/**
|
|
1211
1222
|
* SDK version from package.json (injected at build time)
|
|
1212
1223
|
*/
|
|
1213
|
-
declare const __version__ = "0.23.
|
|
1224
|
+
declare const __version__ = "0.23.1";
|
|
1214
1225
|
|
|
1215
1226
|
/**
|
|
1216
1227
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
package/dist/node.cjs
CHANGED
|
@@ -514,7 +514,7 @@ registerAsyncLocalStorageClass(
|
|
|
514
514
|
);
|
|
515
515
|
|
|
516
516
|
// src/version.generated.ts
|
|
517
|
-
var __version__ = "0.23.
|
|
517
|
+
var __version__ = "0.23.1";
|
|
518
518
|
|
|
519
519
|
// src/constants.ts
|
|
520
520
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -2302,9 +2302,17 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
2302
2302
|
constructor(config) {
|
|
2303
2303
|
this.traceFunctionKey = config.traceFunctionKey;
|
|
2304
2304
|
this.withSpanFn = config.withSpan;
|
|
2305
|
+
this.getActiveSpanContext = config.getActiveSpanContext;
|
|
2305
2306
|
}
|
|
2306
2307
|
async wrapRun(agent, input, options) {
|
|
2307
2308
|
const { run } = await import("@openai/agents");
|
|
2309
|
+
if (this.getActiveSpanContext?.() != null) {
|
|
2310
|
+
return run(
|
|
2311
|
+
agent,
|
|
2312
|
+
input,
|
|
2313
|
+
options
|
|
2314
|
+
);
|
|
2315
|
+
}
|
|
2308
2316
|
const isStreaming = options?.stream === true;
|
|
2309
2317
|
const finalize = async (result) => {
|
|
2310
2318
|
const res = result;
|
|
@@ -3048,7 +3056,11 @@ var Bitfab = class {
|
|
|
3048
3056
|
getOpenAiAgentHandler(traceFunctionKey) {
|
|
3049
3057
|
return new BitfabOpenAIAgentHandler({
|
|
3050
3058
|
traceFunctionKey,
|
|
3051
|
-
withSpan: this.withSpan.bind(this)
|
|
3059
|
+
withSpan: this.withSpan.bind(this),
|
|
3060
|
+
getActiveSpanContext: () => {
|
|
3061
|
+
const stack = getSpanStack();
|
|
3062
|
+
return stack[stack.length - 1] ?? null;
|
|
3063
|
+
}
|
|
3052
3064
|
});
|
|
3053
3065
|
}
|
|
3054
3066
|
/**
|
|
@@ -3673,7 +3685,7 @@ var Bitfab = class {
|
|
|
3673
3685
|
if (wrappedKey === void 0) {
|
|
3674
3686
|
replayFn = this.withSpan(
|
|
3675
3687
|
traceFunctionKey,
|
|
3676
|
-
{ name:
|
|
3688
|
+
{ name: traceFunctionKey, type: "agent" },
|
|
3677
3689
|
fn
|
|
3678
3690
|
);
|
|
3679
3691
|
} else if (wrappedKey !== traceFunctionKey) {
|