bitfab 0.22.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-4SLFC266.js → chunk-2EDITKO2.js} +18 -5
- package/dist/chunk-2EDITKO2.js.map +1 -0
- package/dist/index.cjs +17 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +1 -1
- package/dist/node.cjs +17 -4
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4SLFC266.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -278,8 +278,8 @@ interface ActiveSpanContext$1 {
|
|
|
278
278
|
*/
|
|
279
279
|
declare class BitfabLangGraphCallbackHandler {
|
|
280
280
|
name: string;
|
|
281
|
-
ignoreRetriever: boolean;
|
|
282
281
|
ignoreRetry: boolean;
|
|
282
|
+
ignoreRetriever: boolean;
|
|
283
283
|
ignoreCustomEvent: boolean;
|
|
284
284
|
private readonly httpClient;
|
|
285
285
|
private readonly traceFunctionKey;
|
|
@@ -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.
|
|
1224
|
+
declare const __version__ = "0.23.1";
|
|
1214
1225
|
|
|
1215
1226
|
/**
|
|
1216
1227
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -278,8 +278,8 @@ interface ActiveSpanContext$1 {
|
|
|
278
278
|
*/
|
|
279
279
|
declare class BitfabLangGraphCallbackHandler {
|
|
280
280
|
name: string;
|
|
281
|
-
ignoreRetriever: boolean;
|
|
282
281
|
ignoreRetry: boolean;
|
|
282
|
+
ignoreRetriever: boolean;
|
|
283
283
|
ignoreCustomEvent: boolean;
|
|
284
284
|
private readonly httpClient;
|
|
285
285
|
private readonly traceFunctionKey;
|
|
@@ -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.
|
|
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.
|
|
517
|
+
var __version__ = "0.23.1";
|
|
518
518
|
|
|
519
519
|
// src/constants.ts
|
|
520
520
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1965,8 +1965,9 @@ function extractLangGraphMetadata(metadata) {
|
|
|
1965
1965
|
var BitfabLangGraphCallbackHandler = class {
|
|
1966
1966
|
constructor(config) {
|
|
1967
1967
|
this.name = "BitfabLangGraphCallbackHandler";
|
|
1968
|
-
this.ignoreRetriever = true;
|
|
1969
1968
|
this.ignoreRetry = true;
|
|
1969
|
+
// Retriever callbacks ARE captured (retriever queries -> function spans).
|
|
1970
|
+
this.ignoreRetriever = false;
|
|
1970
1971
|
this.ignoreCustomEvent = true;
|
|
1971
1972
|
this.runToSpan = /* @__PURE__ */ new Map();
|
|
1972
1973
|
this.invocations = /* @__PURE__ */ new Map();
|
|
@@ -2301,9 +2302,17 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
2301
2302
|
constructor(config) {
|
|
2302
2303
|
this.traceFunctionKey = config.traceFunctionKey;
|
|
2303
2304
|
this.withSpanFn = config.withSpan;
|
|
2305
|
+
this.getActiveSpanContext = config.getActiveSpanContext;
|
|
2304
2306
|
}
|
|
2305
2307
|
async wrapRun(agent, input, options) {
|
|
2306
2308
|
const { run } = await import("@openai/agents");
|
|
2309
|
+
if (this.getActiveSpanContext?.() != null) {
|
|
2310
|
+
return run(
|
|
2311
|
+
agent,
|
|
2312
|
+
input,
|
|
2313
|
+
options
|
|
2314
|
+
);
|
|
2315
|
+
}
|
|
2307
2316
|
const isStreaming = options?.stream === true;
|
|
2308
2317
|
const finalize = async (result) => {
|
|
2309
2318
|
const res = result;
|
|
@@ -3047,7 +3056,11 @@ var Bitfab = class {
|
|
|
3047
3056
|
getOpenAiAgentHandler(traceFunctionKey) {
|
|
3048
3057
|
return new BitfabOpenAIAgentHandler({
|
|
3049
3058
|
traceFunctionKey,
|
|
3050
|
-
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
|
+
}
|
|
3051
3064
|
});
|
|
3052
3065
|
}
|
|
3053
3066
|
/**
|
|
@@ -3672,7 +3685,7 @@ var Bitfab = class {
|
|
|
3672
3685
|
if (wrappedKey === void 0) {
|
|
3673
3686
|
replayFn = this.withSpan(
|
|
3674
3687
|
traceFunctionKey,
|
|
3675
|
-
{ name:
|
|
3688
|
+
{ name: traceFunctionKey, type: "agent" },
|
|
3676
3689
|
fn
|
|
3677
3690
|
);
|
|
3678
3691
|
} else if (wrappedKey !== traceFunctionKey) {
|