bitfab 0.33.3 → 0.33.5
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-HWQB73HK.js → chunk-DPV6PBWE.js} +7 -4
- package/dist/chunk-DPV6PBWE.js.map +1 -0
- package/dist/{chunk-NIFTE3J4.js → chunk-LRWH3H5T.js} +36 -4
- package/dist/{chunk-NIFTE3J4.js.map → chunk-LRWH3H5T.js.map} +1 -1
- package/dist/index.cjs +39 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -9
- package/dist/index.d.ts +24 -9
- package/dist/index.js +2 -2
- package/dist/node.cjs +39 -4
- 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 +2 -2
- package/dist/{replay-4Y23OZYE.js → replay-SRQI4QMY.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-HWQB73HK.js.map +0 -1
- /package/dist/{replay-4Y23OZYE.js.map → replay-SRQI4QMY.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -752,8 +752,9 @@ type MockStrategy = "none" | "all" | "marked";
|
|
|
752
752
|
/**
|
|
753
753
|
* How the DB-snapshot branch each replay item runs against is sized and warmed.
|
|
754
754
|
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
755
|
+
* Every field is optional, so this object is only worth passing when you want
|
|
756
|
+
* to override the mirror project's own sizing. To branch with those defaults,
|
|
757
|
+
* pass `dbBranch: true` instead of an empty object.
|
|
757
758
|
*/
|
|
758
759
|
interface DbBranchOptions {
|
|
759
760
|
/**
|
|
@@ -826,17 +827,17 @@ interface ReplayOptions {
|
|
|
826
827
|
mockOverride?: MockOverride | MockOverride[];
|
|
827
828
|
/**
|
|
828
829
|
* Run each item against a database branch restored to the state its source
|
|
829
|
-
* trace saw.
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
* `getCurrentReplayBranch()`.
|
|
830
|
+
* trace saw. Pass `true` to branch with the mirror project's own sizing, or a
|
|
831
|
+
* {@link DbBranchOptions} object to tune how each branch is sized and warmed.
|
|
832
|
+
* `false` and omission leave branching off. Inside `fn`, read the resolved
|
|
833
|
+
* branch with `getCurrentReplayBranch()`.
|
|
833
834
|
*
|
|
834
835
|
* Items whose source trace carried no DB snapshot reference get no branch and
|
|
835
836
|
* run against the live database. An item whose branch was requested but could
|
|
836
837
|
* not be resolved fails instead of running, so a replay never silently
|
|
837
838
|
* reports a result that did not use the historical data you asked for.
|
|
838
839
|
*/
|
|
839
|
-
dbBranch?: DbBranchOptions;
|
|
840
|
+
dbBranch?: DbBranchOptions | boolean;
|
|
840
841
|
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
841
842
|
experimentGroupId?: string;
|
|
842
843
|
/**
|
|
@@ -1419,6 +1420,12 @@ interface BitfabConfig {
|
|
|
1419
1420
|
* - custom: Application-specific tracing (default)
|
|
1420
1421
|
*/
|
|
1421
1422
|
type SpanType = "llm" | "agent" | "function" | "guardrail" | "handoff" | "custom";
|
|
1423
|
+
/**
|
|
1424
|
+
* Controls when a span is captured.
|
|
1425
|
+
* - always: Capture the span even when it becomes the root of a new trace.
|
|
1426
|
+
* - nested: Capture the span only when another Bitfab span is already active.
|
|
1427
|
+
*/
|
|
1428
|
+
type CaptureWhen = "always" | "nested";
|
|
1422
1429
|
/**
|
|
1423
1430
|
* Options for configuring span behavior.
|
|
1424
1431
|
*/
|
|
@@ -1432,6 +1439,14 @@ interface SpanOptions {
|
|
|
1432
1439
|
* The type of span. Defaults to "custom" if not specified.
|
|
1433
1440
|
*/
|
|
1434
1441
|
type?: SpanType;
|
|
1442
|
+
/**
|
|
1443
|
+
* Controls whether this span may start a new trace. Defaults to "always".
|
|
1444
|
+
*
|
|
1445
|
+
* Use "nested" for reusable helpers that should appear inside an existing
|
|
1446
|
+
* trace but should run untraced when called on their own.
|
|
1447
|
+
* Unknown values warn once and default to "always".
|
|
1448
|
+
*/
|
|
1449
|
+
captureWhen?: CaptureWhen;
|
|
1435
1450
|
/**
|
|
1436
1451
|
* When true, replay will reuse this span's historical output instead of
|
|
1437
1452
|
* executing the wrapped function. Read by the "marked" replay strategy;
|
|
@@ -1968,7 +1983,7 @@ declare class BitfabFunction {
|
|
|
1968
1983
|
/**
|
|
1969
1984
|
* SDK version from package.json (injected at build time)
|
|
1970
1985
|
*/
|
|
1971
|
-
declare const __version__ = "0.33.
|
|
1986
|
+
declare const __version__ = "0.33.5";
|
|
1972
1987
|
|
|
1973
1988
|
/**
|
|
1974
1989
|
* Constants for the Bitfab SDK.
|
|
@@ -2036,4 +2051,4 @@ declare const finalizers: {
|
|
|
2036
2051
|
readableStream: typeof readableStream;
|
|
2037
2052
|
};
|
|
2038
2053
|
|
|
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 };
|
|
2054
|
+
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
|
@@ -752,8 +752,9 @@ type MockStrategy = "none" | "all" | "marked";
|
|
|
752
752
|
/**
|
|
753
753
|
* How the DB-snapshot branch each replay item runs against is sized and warmed.
|
|
754
754
|
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
755
|
+
* Every field is optional, so this object is only worth passing when you want
|
|
756
|
+
* to override the mirror project's own sizing. To branch with those defaults,
|
|
757
|
+
* pass `dbBranch: true` instead of an empty object.
|
|
757
758
|
*/
|
|
758
759
|
interface DbBranchOptions {
|
|
759
760
|
/**
|
|
@@ -826,17 +827,17 @@ interface ReplayOptions {
|
|
|
826
827
|
mockOverride?: MockOverride | MockOverride[];
|
|
827
828
|
/**
|
|
828
829
|
* Run each item against a database branch restored to the state its source
|
|
829
|
-
* trace saw.
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
* `getCurrentReplayBranch()`.
|
|
830
|
+
* trace saw. Pass `true` to branch with the mirror project's own sizing, or a
|
|
831
|
+
* {@link DbBranchOptions} object to tune how each branch is sized and warmed.
|
|
832
|
+
* `false` and omission leave branching off. Inside `fn`, read the resolved
|
|
833
|
+
* branch with `getCurrentReplayBranch()`.
|
|
833
834
|
*
|
|
834
835
|
* Items whose source trace carried no DB snapshot reference get no branch and
|
|
835
836
|
* run against the live database. An item whose branch was requested but could
|
|
836
837
|
* not be resolved fails instead of running, so a replay never silently
|
|
837
838
|
* reports a result that did not use the historical data you asked for.
|
|
838
839
|
*/
|
|
839
|
-
dbBranch?: DbBranchOptions;
|
|
840
|
+
dbBranch?: DbBranchOptions | boolean;
|
|
840
841
|
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
841
842
|
experimentGroupId?: string;
|
|
842
843
|
/**
|
|
@@ -1419,6 +1420,12 @@ interface BitfabConfig {
|
|
|
1419
1420
|
* - custom: Application-specific tracing (default)
|
|
1420
1421
|
*/
|
|
1421
1422
|
type SpanType = "llm" | "agent" | "function" | "guardrail" | "handoff" | "custom";
|
|
1423
|
+
/**
|
|
1424
|
+
* Controls when a span is captured.
|
|
1425
|
+
* - always: Capture the span even when it becomes the root of a new trace.
|
|
1426
|
+
* - nested: Capture the span only when another Bitfab span is already active.
|
|
1427
|
+
*/
|
|
1428
|
+
type CaptureWhen = "always" | "nested";
|
|
1422
1429
|
/**
|
|
1423
1430
|
* Options for configuring span behavior.
|
|
1424
1431
|
*/
|
|
@@ -1432,6 +1439,14 @@ interface SpanOptions {
|
|
|
1432
1439
|
* The type of span. Defaults to "custom" if not specified.
|
|
1433
1440
|
*/
|
|
1434
1441
|
type?: SpanType;
|
|
1442
|
+
/**
|
|
1443
|
+
* Controls whether this span may start a new trace. Defaults to "always".
|
|
1444
|
+
*
|
|
1445
|
+
* Use "nested" for reusable helpers that should appear inside an existing
|
|
1446
|
+
* trace but should run untraced when called on their own.
|
|
1447
|
+
* Unknown values warn once and default to "always".
|
|
1448
|
+
*/
|
|
1449
|
+
captureWhen?: CaptureWhen;
|
|
1435
1450
|
/**
|
|
1436
1451
|
* When true, replay will reuse this span's historical output instead of
|
|
1437
1452
|
* executing the wrapped function. Read by the "marked" replay strategy;
|
|
@@ -1968,7 +1983,7 @@ declare class BitfabFunction {
|
|
|
1968
1983
|
/**
|
|
1969
1984
|
* SDK version from package.json (injected at build time)
|
|
1970
1985
|
*/
|
|
1971
|
-
declare const __version__ = "0.33.
|
|
1986
|
+
declare const __version__ = "0.33.5";
|
|
1972
1987
|
|
|
1973
1988
|
/**
|
|
1974
1989
|
* Constants for the Bitfab SDK.
|
|
@@ -2036,4 +2051,4 @@ declare const finalizers: {
|
|
|
2036
2051
|
readableStream: typeof readableStream;
|
|
2037
2052
|
};
|
|
2038
2053
|
|
|
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 };
|
|
2054
|
+
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
|
@@ -23,12 +23,12 @@ import {
|
|
|
23
23
|
getCurrentReplayBranch,
|
|
24
24
|
getCurrentSpan,
|
|
25
25
|
getCurrentTrace
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-LRWH3H5T.js";
|
|
27
27
|
import {
|
|
28
28
|
BITFAB_PROGRESS_PREFIX,
|
|
29
29
|
BitfabError,
|
|
30
30
|
reportReplayProgress
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-DPV6PBWE.js";
|
|
32
32
|
export {
|
|
33
33
|
BITFAB_PROGRESS_PREFIX,
|
|
34
34
|
Bitfab,
|
package/dist/node.cjs
CHANGED
|
@@ -558,8 +558,11 @@ __export(replay_exports, {
|
|
|
558
558
|
replay: () => replay,
|
|
559
559
|
reportReplayProgress: () => reportReplayProgress
|
|
560
560
|
});
|
|
561
|
+
function dbBranchEnabled(dbBranch) {
|
|
562
|
+
return dbBranch !== void 0 && dbBranch !== false;
|
|
563
|
+
}
|
|
561
564
|
function resolveDbBranchSettings(dbBranch) {
|
|
562
|
-
if (!dbBranch) {
|
|
565
|
+
if (!dbBranch || dbBranch === true) {
|
|
563
566
|
return void 0;
|
|
564
567
|
}
|
|
565
568
|
const { minCu, maxCu, warmupSql } = dbBranch;
|
|
@@ -828,7 +831,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
828
831
|
options?.name,
|
|
829
832
|
codeChangeDescription,
|
|
830
833
|
codeChangeFiles,
|
|
831
|
-
options?.dbBranch
|
|
834
|
+
dbBranchEnabled(options?.dbBranch),
|
|
832
835
|
// includeDbBranchLease
|
|
833
836
|
options?.experimentGroupId,
|
|
834
837
|
options?.datasetId,
|
|
@@ -851,7 +854,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
851
854
|
mockStrategy,
|
|
852
855
|
resolvedOverrides,
|
|
853
856
|
replayedTraceIds[index],
|
|
854
|
-
options?.dbBranch
|
|
857
|
+
dbBranchEnabled(options?.dbBranch),
|
|
855
858
|
resolveDbBranchSettings(options?.dbBranch),
|
|
856
859
|
options?.adaptInputs
|
|
857
860
|
)
|
|
@@ -1028,7 +1031,7 @@ registerAsyncLocalStorageClass(
|
|
|
1028
1031
|
);
|
|
1029
1032
|
|
|
1030
1033
|
// src/version.generated.ts
|
|
1031
|
-
var __version__ = "0.33.
|
|
1034
|
+
var __version__ = "0.33.5";
|
|
1032
1035
|
|
|
1033
1036
|
// src/constants.ts
|
|
1034
1037
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -4327,6 +4330,38 @@ var Bitfab = class {
|
|
|
4327
4330
|
() => wrappedFn.apply(this, args)
|
|
4328
4331
|
);
|
|
4329
4332
|
}
|
|
4333
|
+
const captureWhen = options.captureWhen === void 0 ? "always" : options.captureWhen;
|
|
4334
|
+
const resolvedCaptureWhen = captureWhen === "always" || captureWhen === "nested" ? captureWhen : "always";
|
|
4335
|
+
if (resolvedCaptureWhen !== captureWhen) {
|
|
4336
|
+
let invalidValue;
|
|
4337
|
+
try {
|
|
4338
|
+
invalidValue = String(captureWhen);
|
|
4339
|
+
} catch {
|
|
4340
|
+
invalidValue = "<unprintable>";
|
|
4341
|
+
}
|
|
4342
|
+
warnOnce(
|
|
4343
|
+
`invalid-capture-when:${traceFunctionKey}`,
|
|
4344
|
+
`unknown captureWhen value "${invalidValue}"; defaulting to "always". Valid values: "always", "nested".`
|
|
4345
|
+
);
|
|
4346
|
+
}
|
|
4347
|
+
if (resolvedCaptureWhen === "nested") {
|
|
4348
|
+
let hasParent = false;
|
|
4349
|
+
try {
|
|
4350
|
+
hasParent = getSpanStack().length > 0;
|
|
4351
|
+
} catch (setupError) {
|
|
4352
|
+
if (getReplayContext()) {
|
|
4353
|
+
throw setupError;
|
|
4354
|
+
}
|
|
4355
|
+
warnOnce(
|
|
4356
|
+
`withSpan-setup:${traceFunctionKey}`,
|
|
4357
|
+
`tracing setup failed for "${traceFunctionKey}"; running it untraced. The function still runs and returns normally; no span is recorded.`
|
|
4358
|
+
);
|
|
4359
|
+
return fn.apply(this, args);
|
|
4360
|
+
}
|
|
4361
|
+
if (!hasParent) {
|
|
4362
|
+
return fn.apply(this, args);
|
|
4363
|
+
}
|
|
4364
|
+
}
|
|
4330
4365
|
let newStack;
|
|
4331
4366
|
let executeWithContext;
|
|
4332
4367
|
let registeredTraceId;
|