bitfab 0.30.2 → 0.31.0
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-FLVQ7Q3I.js → chunk-6UJ3E3H5.js} +20 -2
- package/dist/chunk-6UJ3E3H5.js.map +1 -0
- package/dist/{chunk-CPEQSNVE.js → chunk-A7K5JOBV.js} +16 -5
- package/dist/chunk-A7K5JOBV.js.map +1 -0
- package/dist/index.cjs +32 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -2
- package/dist/index.d.ts +37 -2
- package/dist/index.js +2 -2
- package/dist/node.cjs +32 -3
- 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-YJI2SUSN.js → replay-JVURNX5Y.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-CPEQSNVE.js.map +0 -1
- package/dist/chunk-FLVQ7Q3I.js.map +0 -1
- /package/dist/{replay-YJI2SUSN.js.map → replay-JVURNX5Y.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -646,6 +646,7 @@ interface ReplayEnvironmentSnapshot {
|
|
|
646
646
|
expiresAt: string;
|
|
647
647
|
providerConsoleUrl?: string;
|
|
648
648
|
readOnly?: boolean;
|
|
649
|
+
region?: string;
|
|
649
650
|
traceId: string;
|
|
650
651
|
}
|
|
651
652
|
declare class ReplayEnvironment {
|
|
@@ -664,6 +665,11 @@ declare class ReplayEnvironment {
|
|
|
664
665
|
* lease.
|
|
665
666
|
*/
|
|
666
667
|
get readOnly(): boolean | undefined;
|
|
668
|
+
/**
|
|
669
|
+
* The branch's region, e.g. `aws-us-east-1`. A compute runs in its project's
|
|
670
|
+
* region, so a replay runner elsewhere pays that round trip on every query.
|
|
671
|
+
*/
|
|
672
|
+
get region(): string | undefined;
|
|
667
673
|
/** The historical trace ID that produced the input for this replay item. */
|
|
668
674
|
get traceId(): string;
|
|
669
675
|
/** True when read inside a replay item that has a resolved branch. */
|
|
@@ -692,6 +698,33 @@ declare class ReplayEnvironment {
|
|
|
692
698
|
*/
|
|
693
699
|
|
|
694
700
|
type MockStrategy = "none" | "all" | "marked";
|
|
701
|
+
/**
|
|
702
|
+
* Per-lease settings for the DB-snapshot branch a replay item runs against.
|
|
703
|
+
* Only read when `environment` is set, since that is what turns branching on.
|
|
704
|
+
*/
|
|
705
|
+
interface DbBranchOptions {
|
|
706
|
+
/**
|
|
707
|
+
* Autoscaling floor for the branch's compute, in Neon Compute Units (0.25 to
|
|
708
|
+
* 56). Omit to keep the mirror project's own default. Raise it when the
|
|
709
|
+
* mirror is provisioned smaller than the database it stands in for, so
|
|
710
|
+
* replay latency reflects your code rather than a cold, undersized branch.
|
|
711
|
+
*/
|
|
712
|
+
minCu?: number;
|
|
713
|
+
/**
|
|
714
|
+
* Autoscaling ceiling for the branch's compute, in Neon Compute Units.
|
|
715
|
+
* Setting it equal to `minCu` pins the size, which keeps items comparable:
|
|
716
|
+
* otherwise a later item can run against an endpoint that has already
|
|
717
|
+
* scaled up and post a better number for the same code.
|
|
718
|
+
*/
|
|
719
|
+
maxCu?: number;
|
|
720
|
+
/**
|
|
721
|
+
* SQL that warms the branch's cache. The server appends it to the branch's
|
|
722
|
+
* readiness check, so it runs BEFORE your function sees the lease and its
|
|
723
|
+
* time is not charged to the replayed call. Invalid SQL fails the lease
|
|
724
|
+
* rather than silently leaving the branch cold.
|
|
725
|
+
*/
|
|
726
|
+
warmupSql?: string;
|
|
727
|
+
}
|
|
695
728
|
interface ReplayOptions {
|
|
696
729
|
/**
|
|
697
730
|
* Maximum number of traces to replay (1-100, default 5). Ignored when
|
|
@@ -740,6 +773,8 @@ interface ReplayOptions {
|
|
|
740
773
|
* environment to pick up the per-trace branch URL.
|
|
741
774
|
*/
|
|
742
775
|
environment?: ReplayEnvironment;
|
|
776
|
+
/** Compute size and cache warm-up for the per-item DB snapshot branch. */
|
|
777
|
+
dbBranch?: DbBranchOptions;
|
|
743
778
|
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
744
779
|
experimentGroupId?: string;
|
|
745
780
|
/**
|
|
@@ -1808,7 +1843,7 @@ declare class BitfabFunction {
|
|
|
1808
1843
|
/**
|
|
1809
1844
|
* SDK version from package.json (injected at build time)
|
|
1810
1845
|
*/
|
|
1811
|
-
declare const __version__ = "0.
|
|
1846
|
+
declare const __version__ = "0.31.0";
|
|
1812
1847
|
|
|
1813
1848
|
/**
|
|
1814
1849
|
* Constants for the Bitfab SDK.
|
|
@@ -1876,4 +1911,4 @@ declare const finalizers: {
|
|
|
1876
1911
|
readableStream: typeof readableStream;
|
|
1877
1912
|
};
|
|
1878
1913
|
|
|
1879
|
-
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 DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, 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, getCurrentSpan, getCurrentTrace, reportReplayProgress };
|
|
1914
|
+
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, ReplayEnvironment, type ReplayEnvironmentSnapshot, 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, getCurrentSpan, getCurrentTrace, reportReplayProgress };
|
package/dist/index.d.ts
CHANGED
|
@@ -646,6 +646,7 @@ interface ReplayEnvironmentSnapshot {
|
|
|
646
646
|
expiresAt: string;
|
|
647
647
|
providerConsoleUrl?: string;
|
|
648
648
|
readOnly?: boolean;
|
|
649
|
+
region?: string;
|
|
649
650
|
traceId: string;
|
|
650
651
|
}
|
|
651
652
|
declare class ReplayEnvironment {
|
|
@@ -664,6 +665,11 @@ declare class ReplayEnvironment {
|
|
|
664
665
|
* lease.
|
|
665
666
|
*/
|
|
666
667
|
get readOnly(): boolean | undefined;
|
|
668
|
+
/**
|
|
669
|
+
* The branch's region, e.g. `aws-us-east-1`. A compute runs in its project's
|
|
670
|
+
* region, so a replay runner elsewhere pays that round trip on every query.
|
|
671
|
+
*/
|
|
672
|
+
get region(): string | undefined;
|
|
667
673
|
/** The historical trace ID that produced the input for this replay item. */
|
|
668
674
|
get traceId(): string;
|
|
669
675
|
/** True when read inside a replay item that has a resolved branch. */
|
|
@@ -692,6 +698,33 @@ declare class ReplayEnvironment {
|
|
|
692
698
|
*/
|
|
693
699
|
|
|
694
700
|
type MockStrategy = "none" | "all" | "marked";
|
|
701
|
+
/**
|
|
702
|
+
* Per-lease settings for the DB-snapshot branch a replay item runs against.
|
|
703
|
+
* Only read when `environment` is set, since that is what turns branching on.
|
|
704
|
+
*/
|
|
705
|
+
interface DbBranchOptions {
|
|
706
|
+
/**
|
|
707
|
+
* Autoscaling floor for the branch's compute, in Neon Compute Units (0.25 to
|
|
708
|
+
* 56). Omit to keep the mirror project's own default. Raise it when the
|
|
709
|
+
* mirror is provisioned smaller than the database it stands in for, so
|
|
710
|
+
* replay latency reflects your code rather than a cold, undersized branch.
|
|
711
|
+
*/
|
|
712
|
+
minCu?: number;
|
|
713
|
+
/**
|
|
714
|
+
* Autoscaling ceiling for the branch's compute, in Neon Compute Units.
|
|
715
|
+
* Setting it equal to `minCu` pins the size, which keeps items comparable:
|
|
716
|
+
* otherwise a later item can run against an endpoint that has already
|
|
717
|
+
* scaled up and post a better number for the same code.
|
|
718
|
+
*/
|
|
719
|
+
maxCu?: number;
|
|
720
|
+
/**
|
|
721
|
+
* SQL that warms the branch's cache. The server appends it to the branch's
|
|
722
|
+
* readiness check, so it runs BEFORE your function sees the lease and its
|
|
723
|
+
* time is not charged to the replayed call. Invalid SQL fails the lease
|
|
724
|
+
* rather than silently leaving the branch cold.
|
|
725
|
+
*/
|
|
726
|
+
warmupSql?: string;
|
|
727
|
+
}
|
|
695
728
|
interface ReplayOptions {
|
|
696
729
|
/**
|
|
697
730
|
* Maximum number of traces to replay (1-100, default 5). Ignored when
|
|
@@ -740,6 +773,8 @@ interface ReplayOptions {
|
|
|
740
773
|
* environment to pick up the per-trace branch URL.
|
|
741
774
|
*/
|
|
742
775
|
environment?: ReplayEnvironment;
|
|
776
|
+
/** Compute size and cache warm-up for the per-item DB snapshot branch. */
|
|
777
|
+
dbBranch?: DbBranchOptions;
|
|
743
778
|
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
744
779
|
experimentGroupId?: string;
|
|
745
780
|
/**
|
|
@@ -1808,7 +1843,7 @@ declare class BitfabFunction {
|
|
|
1808
1843
|
/**
|
|
1809
1844
|
* SDK version from package.json (injected at build time)
|
|
1810
1845
|
*/
|
|
1811
|
-
declare const __version__ = "0.
|
|
1846
|
+
declare const __version__ = "0.31.0";
|
|
1812
1847
|
|
|
1813
1848
|
/**
|
|
1814
1849
|
* Constants for the Bitfab SDK.
|
|
@@ -1876,4 +1911,4 @@ declare const finalizers: {
|
|
|
1876
1911
|
readableStream: typeof readableStream;
|
|
1877
1912
|
};
|
|
1878
1913
|
|
|
1879
|
-
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 DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type ProviderDefinition, ReplayEnvironment, type ReplayEnvironmentSnapshot, 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, getCurrentSpan, getCurrentTrace, reportReplayProgress };
|
|
1914
|
+
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, ReplayEnvironment, type ReplayEnvironmentSnapshot, 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, getCurrentSpan, getCurrentTrace, reportReplayProgress };
|
package/dist/index.js
CHANGED
|
@@ -23,12 +23,12 @@ import {
|
|
|
23
23
|
flushTraces,
|
|
24
24
|
getCurrentSpan,
|
|
25
25
|
getCurrentTrace
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-A7K5JOBV.js";
|
|
27
27
|
import {
|
|
28
28
|
BITFAB_PROGRESS_PREFIX,
|
|
29
29
|
BitfabError,
|
|
30
30
|
reportReplayProgress
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-6UJ3E3H5.js";
|
|
32
32
|
export {
|
|
33
33
|
BITFAB_PROGRESS_PREFIX,
|
|
34
34
|
Bitfab,
|
package/dist/node.cjs
CHANGED
|
@@ -540,6 +540,17 @@ __export(replay_exports, {
|
|
|
540
540
|
replay: () => replay,
|
|
541
541
|
reportReplayProgress: () => reportReplayProgress
|
|
542
542
|
});
|
|
543
|
+
function resolveDbBranchSettings(dbBranch) {
|
|
544
|
+
if (!dbBranch) {
|
|
545
|
+
return void 0;
|
|
546
|
+
}
|
|
547
|
+
const settings = {
|
|
548
|
+
...dbBranch.minCu === void 0 ? {} : { minCu: dbBranch.minCu },
|
|
549
|
+
...dbBranch.maxCu === void 0 ? {} : { maxCu: dbBranch.maxCu },
|
|
550
|
+
...dbBranch.warmupSql === void 0 ? {} : { warmupSql: dbBranch.warmupSql }
|
|
551
|
+
};
|
|
552
|
+
return Object.keys(settings).length === 0 ? void 0 : settings;
|
|
553
|
+
}
|
|
543
554
|
function reportReplayProgress(progress) {
|
|
544
555
|
const stderr = typeof process !== "undefined" ? process.stderr : void 0;
|
|
545
556
|
if (!stderr) {
|
|
@@ -602,6 +613,7 @@ function buildMockTree(rootNode) {
|
|
|
602
613
|
}
|
|
603
614
|
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId, environment, adaptInputs) {
|
|
604
615
|
const lease = environment ? serverItem.dbBranchLease : void 0;
|
|
616
|
+
const leaseError = environment ? serverItem.dbBranchLeaseError : void 0;
|
|
605
617
|
let inputs = [];
|
|
606
618
|
let originalOutput;
|
|
607
619
|
let result;
|
|
@@ -610,6 +622,11 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
610
622
|
const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
|
|
611
623
|
const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
|
|
612
624
|
try {
|
|
625
|
+
if (leaseError) {
|
|
626
|
+
throw new BitfabError(
|
|
627
|
+
`Replay requested a database branch for trace ${originalTraceId} but it could not be resolved (${leaseError.code}): ${leaseError.message}. The function was not run, because replaying it against the live database would produce a result that looks valid but did not use the historical data you asked for.`
|
|
628
|
+
);
|
|
629
|
+
}
|
|
613
630
|
const span = await httpClient.getExternalSpan(originalSpanId);
|
|
614
631
|
const spanData = span.rawData?.span_data ?? {};
|
|
615
632
|
inputs = deserializeInputs(spanData);
|
|
@@ -783,7 +800,8 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
783
800
|
// includeDbBranchLease
|
|
784
801
|
options?.experimentGroupId,
|
|
785
802
|
options?.datasetId,
|
|
786
|
-
options?.graderIds
|
|
803
|
+
options?.graderIds,
|
|
804
|
+
resolveDbBranchSettings(options?.dbBranch)
|
|
787
805
|
);
|
|
788
806
|
const mockStrategy = options?.mock ?? "marked";
|
|
789
807
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
@@ -977,7 +995,7 @@ registerAsyncLocalStorageClass(
|
|
|
977
995
|
);
|
|
978
996
|
|
|
979
997
|
// src/version.generated.ts
|
|
980
|
-
var __version__ = "0.
|
|
998
|
+
var __version__ = "0.31.0";
|
|
981
999
|
|
|
982
1000
|
// src/constants.ts
|
|
983
1001
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1336,7 +1354,7 @@ var HttpClient = class {
|
|
|
1336
1354
|
* Start a replay session by fetching historical traces.
|
|
1337
1355
|
* Blocking call - creates a test run and returns lightweight item references.
|
|
1338
1356
|
*/
|
|
1339
|
-
async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId, graderIds) {
|
|
1357
|
+
async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId, graderIds, dbBranchSettings) {
|
|
1340
1358
|
const payload = { traceFunctionKey };
|
|
1341
1359
|
if (limit !== void 0) {
|
|
1342
1360
|
payload.limit = limit;
|
|
@@ -1365,6 +1383,9 @@ var HttpClient = class {
|
|
|
1365
1383
|
if (graderIds !== void 0) {
|
|
1366
1384
|
payload.graderIds = graderIds;
|
|
1367
1385
|
}
|
|
1386
|
+
if (dbBranchSettings !== void 0) {
|
|
1387
|
+
payload.dbBranchSettings = dbBranchSettings;
|
|
1388
|
+
}
|
|
1368
1389
|
const timeout = includeDbBranchLease ? 18e4 : 3e4;
|
|
1369
1390
|
return this.request("/api/sdk/replay/start", payload, {
|
|
1370
1391
|
timeout
|
|
@@ -3095,6 +3116,13 @@ var ReplayEnvironment = class {
|
|
|
3095
3116
|
get readOnly() {
|
|
3096
3117
|
return this.require().readOnly;
|
|
3097
3118
|
}
|
|
3119
|
+
/**
|
|
3120
|
+
* The branch's region, e.g. `aws-us-east-1`. A compute runs in its project's
|
|
3121
|
+
* region, so a replay runner elsewhere pays that round trip on every query.
|
|
3122
|
+
*/
|
|
3123
|
+
get region() {
|
|
3124
|
+
return this.require().region;
|
|
3125
|
+
}
|
|
3098
3126
|
/** The historical trace ID that produced the input for this replay item. */
|
|
3099
3127
|
get traceId() {
|
|
3100
3128
|
return this.require().traceId;
|
|
@@ -3139,6 +3167,7 @@ var ReplayEnvironment = class {
|
|
|
3139
3167
|
expiresAt: lease.expiresAt,
|
|
3140
3168
|
providerConsoleUrl: lease.providerConsoleUrl,
|
|
3141
3169
|
readOnly: lease.readOnly,
|
|
3170
|
+
region: lease.region,
|
|
3142
3171
|
traceId
|
|
3143
3172
|
};
|
|
3144
3173
|
}
|