@bitfab/sdk 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
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
getCurrentReplayBranch,
|
|
15
15
|
getCurrentSpan,
|
|
16
16
|
getCurrentTrace
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LRWH3H5T.js";
|
|
18
18
|
import {
|
|
19
19
|
BITFAB_PROGRESS_PREFIX,
|
|
20
20
|
BitfabError,
|
|
21
21
|
reportReplayProgress
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-DPV6PBWE.js";
|
|
23
23
|
export {
|
|
24
24
|
BITFAB_PROGRESS_PREFIX,
|
|
25
25
|
Bitfab,
|
package/dist/node.cjs
CHANGED
|
@@ -549,8 +549,11 @@ __export(replay_exports, {
|
|
|
549
549
|
replay: () => replay,
|
|
550
550
|
reportReplayProgress: () => reportReplayProgress
|
|
551
551
|
});
|
|
552
|
+
function dbBranchEnabled(dbBranch) {
|
|
553
|
+
return dbBranch !== void 0 && dbBranch !== false;
|
|
554
|
+
}
|
|
552
555
|
function resolveDbBranchSettings(dbBranch) {
|
|
553
|
-
if (!dbBranch) {
|
|
556
|
+
if (!dbBranch || dbBranch === true) {
|
|
554
557
|
return void 0;
|
|
555
558
|
}
|
|
556
559
|
const { minCu, maxCu, warmupSql } = dbBranch;
|
|
@@ -819,7 +822,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
819
822
|
options?.name,
|
|
820
823
|
codeChangeDescription,
|
|
821
824
|
codeChangeFiles,
|
|
822
|
-
options?.dbBranch
|
|
825
|
+
dbBranchEnabled(options?.dbBranch),
|
|
823
826
|
// includeDbBranchLease
|
|
824
827
|
options?.experimentGroupId,
|
|
825
828
|
options?.datasetId,
|
|
@@ -842,7 +845,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
842
845
|
mockStrategy,
|
|
843
846
|
resolvedOverrides,
|
|
844
847
|
replayedTraceIds[index],
|
|
845
|
-
options?.dbBranch
|
|
848
|
+
dbBranchEnabled(options?.dbBranch),
|
|
846
849
|
resolveDbBranchSettings(options?.dbBranch),
|
|
847
850
|
options?.adaptInputs
|
|
848
851
|
)
|
|
@@ -1019,7 +1022,7 @@ registerAsyncLocalStorageClass(
|
|
|
1019
1022
|
);
|
|
1020
1023
|
|
|
1021
1024
|
// src/version.generated.ts
|
|
1022
|
-
var __version__ = "0.33.
|
|
1025
|
+
var __version__ = "0.33.5";
|
|
1023
1026
|
|
|
1024
1027
|
// src/constants.ts
|
|
1025
1028
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -4318,6 +4321,38 @@ var Bitfab = class {
|
|
|
4318
4321
|
() => wrappedFn.apply(this, args)
|
|
4319
4322
|
);
|
|
4320
4323
|
}
|
|
4324
|
+
const captureWhen = options.captureWhen === void 0 ? "always" : options.captureWhen;
|
|
4325
|
+
const resolvedCaptureWhen = captureWhen === "always" || captureWhen === "nested" ? captureWhen : "always";
|
|
4326
|
+
if (resolvedCaptureWhen !== captureWhen) {
|
|
4327
|
+
let invalidValue;
|
|
4328
|
+
try {
|
|
4329
|
+
invalidValue = String(captureWhen);
|
|
4330
|
+
} catch {
|
|
4331
|
+
invalidValue = "<unprintable>";
|
|
4332
|
+
}
|
|
4333
|
+
warnOnce(
|
|
4334
|
+
`invalid-capture-when:${traceFunctionKey}`,
|
|
4335
|
+
`unknown captureWhen value "${invalidValue}"; defaulting to "always". Valid values: "always", "nested".`
|
|
4336
|
+
);
|
|
4337
|
+
}
|
|
4338
|
+
if (resolvedCaptureWhen === "nested") {
|
|
4339
|
+
let hasParent = false;
|
|
4340
|
+
try {
|
|
4341
|
+
hasParent = getSpanStack().length > 0;
|
|
4342
|
+
} catch (setupError) {
|
|
4343
|
+
if (getReplayContext()) {
|
|
4344
|
+
throw setupError;
|
|
4345
|
+
}
|
|
4346
|
+
warnOnce(
|
|
4347
|
+
`withSpan-setup:${traceFunctionKey}`,
|
|
4348
|
+
`tracing setup failed for "${traceFunctionKey}"; running it untraced. The function still runs and returns normally; no span is recorded.`
|
|
4349
|
+
);
|
|
4350
|
+
return fn.apply(this, args);
|
|
4351
|
+
}
|
|
4352
|
+
if (!hasParent) {
|
|
4353
|
+
return fn.apply(this, args);
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
4321
4356
|
let newStack;
|
|
4322
4357
|
let executeWithContext;
|
|
4323
4358
|
let registeredTraceId;
|