@bitfab/sdk 0.33.3 → 0.33.4
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-NIFTE3J4.js → chunk-OMW6EFXC.js} +34 -2
- package/dist/{chunk-NIFTE3J4.js.map → chunk-OMW6EFXC.js.map} +1 -1
- package/dist/index.cjs +33 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +1 -1
- package/dist/node.cjs +33 -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 +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1419,6 +1419,12 @@ interface BitfabConfig {
|
|
|
1419
1419
|
* - custom: Application-specific tracing (default)
|
|
1420
1420
|
*/
|
|
1421
1421
|
type SpanType = "llm" | "agent" | "function" | "guardrail" | "handoff" | "custom";
|
|
1422
|
+
/**
|
|
1423
|
+
* Controls when a span is captured.
|
|
1424
|
+
* - always: Capture the span even when it becomes the root of a new trace.
|
|
1425
|
+
* - nested: Capture the span only when another Bitfab span is already active.
|
|
1426
|
+
*/
|
|
1427
|
+
type CaptureWhen = "always" | "nested";
|
|
1422
1428
|
/**
|
|
1423
1429
|
* Options for configuring span behavior.
|
|
1424
1430
|
*/
|
|
@@ -1432,6 +1438,14 @@ interface SpanOptions {
|
|
|
1432
1438
|
* The type of span. Defaults to "custom" if not specified.
|
|
1433
1439
|
*/
|
|
1434
1440
|
type?: SpanType;
|
|
1441
|
+
/**
|
|
1442
|
+
* Controls whether this span may start a new trace. Defaults to "always".
|
|
1443
|
+
*
|
|
1444
|
+
* Use "nested" for reusable helpers that should appear inside an existing
|
|
1445
|
+
* trace but should run untraced when called on their own.
|
|
1446
|
+
* Unknown values warn once and default to "always".
|
|
1447
|
+
*/
|
|
1448
|
+
captureWhen?: CaptureWhen;
|
|
1435
1449
|
/**
|
|
1436
1450
|
* When true, replay will reuse this span's historical output instead of
|
|
1437
1451
|
* executing the wrapped function. Read by the "marked" replay strategy;
|
|
@@ -1968,7 +1982,7 @@ declare class BitfabFunction {
|
|
|
1968
1982
|
/**
|
|
1969
1983
|
* SDK version from package.json (injected at build time)
|
|
1970
1984
|
*/
|
|
1971
|
-
declare const __version__ = "0.33.
|
|
1985
|
+
declare const __version__ = "0.33.4";
|
|
1972
1986
|
|
|
1973
1987
|
/**
|
|
1974
1988
|
* Constants for the Bitfab SDK.
|
|
@@ -2036,4 +2050,4 @@ declare const finalizers: {
|
|
|
2036
2050
|
readableStream: typeof readableStream;
|
|
2037
2051
|
};
|
|
2038
2052
|
|
|
2039
|
-
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, type ReplayItem, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress };
|
|
2053
|
+
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, type ReplayItem, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress };
|
package/dist/index.d.ts
CHANGED
|
@@ -1419,6 +1419,12 @@ interface BitfabConfig {
|
|
|
1419
1419
|
* - custom: Application-specific tracing (default)
|
|
1420
1420
|
*/
|
|
1421
1421
|
type SpanType = "llm" | "agent" | "function" | "guardrail" | "handoff" | "custom";
|
|
1422
|
+
/**
|
|
1423
|
+
* Controls when a span is captured.
|
|
1424
|
+
* - always: Capture the span even when it becomes the root of a new trace.
|
|
1425
|
+
* - nested: Capture the span only when another Bitfab span is already active.
|
|
1426
|
+
*/
|
|
1427
|
+
type CaptureWhen = "always" | "nested";
|
|
1422
1428
|
/**
|
|
1423
1429
|
* Options for configuring span behavior.
|
|
1424
1430
|
*/
|
|
@@ -1432,6 +1438,14 @@ interface SpanOptions {
|
|
|
1432
1438
|
* The type of span. Defaults to "custom" if not specified.
|
|
1433
1439
|
*/
|
|
1434
1440
|
type?: SpanType;
|
|
1441
|
+
/**
|
|
1442
|
+
* Controls whether this span may start a new trace. Defaults to "always".
|
|
1443
|
+
*
|
|
1444
|
+
* Use "nested" for reusable helpers that should appear inside an existing
|
|
1445
|
+
* trace but should run untraced when called on their own.
|
|
1446
|
+
* Unknown values warn once and default to "always".
|
|
1447
|
+
*/
|
|
1448
|
+
captureWhen?: CaptureWhen;
|
|
1435
1449
|
/**
|
|
1436
1450
|
* When true, replay will reuse this span's historical output instead of
|
|
1437
1451
|
* executing the wrapped function. Read by the "marked" replay strategy;
|
|
@@ -1968,7 +1982,7 @@ declare class BitfabFunction {
|
|
|
1968
1982
|
/**
|
|
1969
1983
|
* SDK version from package.json (injected at build time)
|
|
1970
1984
|
*/
|
|
1971
|
-
declare const __version__ = "0.33.
|
|
1985
|
+
declare const __version__ = "0.33.4";
|
|
1972
1986
|
|
|
1973
1987
|
/**
|
|
1974
1988
|
* Constants for the Bitfab SDK.
|
|
@@ -2036,4 +2050,4 @@ declare const finalizers: {
|
|
|
2036
2050
|
readableStream: typeof readableStream;
|
|
2037
2051
|
};
|
|
2038
2052
|
|
|
2039
|
-
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, type ReplayItem, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress };
|
|
2053
|
+
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayBranch, type ReplayItem, type ReplayOptions, type ReplayProgress, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress };
|
package/dist/index.js
CHANGED
package/dist/node.cjs
CHANGED
|
@@ -1019,7 +1019,7 @@ registerAsyncLocalStorageClass(
|
|
|
1019
1019
|
);
|
|
1020
1020
|
|
|
1021
1021
|
// src/version.generated.ts
|
|
1022
|
-
var __version__ = "0.33.
|
|
1022
|
+
var __version__ = "0.33.4";
|
|
1023
1023
|
|
|
1024
1024
|
// src/constants.ts
|
|
1025
1025
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -4318,6 +4318,38 @@ var Bitfab = class {
|
|
|
4318
4318
|
() => wrappedFn.apply(this, args)
|
|
4319
4319
|
);
|
|
4320
4320
|
}
|
|
4321
|
+
const captureWhen = options.captureWhen === void 0 ? "always" : options.captureWhen;
|
|
4322
|
+
const resolvedCaptureWhen = captureWhen === "always" || captureWhen === "nested" ? captureWhen : "always";
|
|
4323
|
+
if (resolvedCaptureWhen !== captureWhen) {
|
|
4324
|
+
let invalidValue;
|
|
4325
|
+
try {
|
|
4326
|
+
invalidValue = String(captureWhen);
|
|
4327
|
+
} catch {
|
|
4328
|
+
invalidValue = "<unprintable>";
|
|
4329
|
+
}
|
|
4330
|
+
warnOnce(
|
|
4331
|
+
`invalid-capture-when:${traceFunctionKey}`,
|
|
4332
|
+
`unknown captureWhen value "${invalidValue}"; defaulting to "always". Valid values: "always", "nested".`
|
|
4333
|
+
);
|
|
4334
|
+
}
|
|
4335
|
+
if (resolvedCaptureWhen === "nested") {
|
|
4336
|
+
let hasParent = false;
|
|
4337
|
+
try {
|
|
4338
|
+
hasParent = getSpanStack().length > 0;
|
|
4339
|
+
} catch (setupError) {
|
|
4340
|
+
if (getReplayContext()) {
|
|
4341
|
+
throw setupError;
|
|
4342
|
+
}
|
|
4343
|
+
warnOnce(
|
|
4344
|
+
`withSpan-setup:${traceFunctionKey}`,
|
|
4345
|
+
`tracing setup failed for "${traceFunctionKey}"; running it untraced. The function still runs and returns normally; no span is recorded.`
|
|
4346
|
+
);
|
|
4347
|
+
return fn.apply(this, args);
|
|
4348
|
+
}
|
|
4349
|
+
if (!hasParent) {
|
|
4350
|
+
return fn.apply(this, args);
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
4321
4353
|
let newStack;
|
|
4322
4354
|
let executeWithContext;
|
|
4323
4355
|
let registeredTraceId;
|