bitfab 0.32.0 → 0.33.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-YZZO475T.js → chunk-7UHJ67MH.js} +55 -106
- package/dist/chunk-7UHJ67MH.js.map +1 -0
- package/dist/{chunk-NMNVPON4.js → chunk-ADUWXWWI.js} +21 -10
- package/dist/chunk-ADUWXWWI.js.map +1 -0
- package/dist/index.cjs +67 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +214 -105
- package/dist/index.d.ts +214 -105
- package/dist/index.js +4 -4
- package/dist/node.cjs +67 -115
- 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 +4 -4
- package/dist/{replay-DJWVOJUR.js → replay-EQPISJKC.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-NMNVPON4.js.map +0 -1
- package/dist/chunk-YZZO475T.js.map +0 -1
- /package/dist/{replay-DJWVOJUR.js.map → replay-EQPISJKC.js.map} +0 -0
package/dist/node.cjs
CHANGED
|
@@ -14,6 +14,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
14
14
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
15
15
|
var __getProtoOf = Object.getPrototypeOf;
|
|
16
16
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __typeError = (msg) => {
|
|
18
|
+
throw TypeError(msg);
|
|
19
|
+
};
|
|
17
20
|
var __esm = (fn, res) => function __init() {
|
|
18
21
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
19
22
|
};
|
|
@@ -38,6 +41,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
41
|
mod
|
|
39
42
|
));
|
|
40
43
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
44
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
45
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
46
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
47
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
41
48
|
|
|
42
49
|
// src/asyncStorage.ts
|
|
43
50
|
function registerAsyncLocalStorageClass(cls) {
|
|
@@ -540,11 +547,11 @@ __export(replay_exports, {
|
|
|
540
547
|
replay: () => replay,
|
|
541
548
|
reportReplayProgress: () => reportReplayProgress
|
|
542
549
|
});
|
|
543
|
-
function resolveDbBranchSettings(
|
|
544
|
-
if (!
|
|
550
|
+
function resolveDbBranchSettings(dbBranch) {
|
|
551
|
+
if (!dbBranch) {
|
|
545
552
|
return void 0;
|
|
546
553
|
}
|
|
547
|
-
const { minCu, maxCu, warmupSql } =
|
|
554
|
+
const { minCu, maxCu, warmupSql } = dbBranch;
|
|
548
555
|
const settings = {
|
|
549
556
|
...minCu === void 0 ? {} : { minCu },
|
|
550
557
|
...maxCu === void 0 ? {} : { maxCu },
|
|
@@ -612,9 +619,9 @@ function buildMockTree(rootNode) {
|
|
|
612
619
|
}
|
|
613
620
|
return { spans };
|
|
614
621
|
}
|
|
615
|
-
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId,
|
|
616
|
-
const lease =
|
|
617
|
-
const leaseError =
|
|
622
|
+
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId, includeDbBranchLease, adaptInputs) {
|
|
623
|
+
const lease = includeDbBranchLease ? serverItem.dbBranchLease : void 0;
|
|
624
|
+
const leaseError = includeDbBranchLease ? serverItem.dbBranchLeaseError : void 0;
|
|
618
625
|
let inputs = [];
|
|
619
626
|
let originalOutput;
|
|
620
627
|
let result;
|
|
@@ -797,12 +804,12 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
797
804
|
options?.name,
|
|
798
805
|
codeChangeDescription,
|
|
799
806
|
codeChangeFiles,
|
|
800
|
-
options?.
|
|
807
|
+
options?.dbBranch !== void 0,
|
|
801
808
|
// includeDbBranchLease
|
|
802
809
|
options?.experimentGroupId,
|
|
803
810
|
options?.datasetId,
|
|
804
811
|
options?.graderIds,
|
|
805
|
-
resolveDbBranchSettings(options?.
|
|
812
|
+
resolveDbBranchSettings(options?.dbBranch)
|
|
806
813
|
);
|
|
807
814
|
const mockStrategy = options?.mock ?? "marked";
|
|
808
815
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
@@ -820,7 +827,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
820
827
|
mockStrategy,
|
|
821
828
|
resolvedOverrides,
|
|
822
829
|
replayedTraceIds[index],
|
|
823
|
-
options?.
|
|
830
|
+
options?.dbBranch !== void 0,
|
|
824
831
|
options?.adaptInputs
|
|
825
832
|
)
|
|
826
833
|
);
|
|
@@ -977,11 +984,11 @@ __export(node_exports, {
|
|
|
977
984
|
BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
|
|
978
985
|
BitfabVercelAiHandler: () => BitfabVercelAiHandler,
|
|
979
986
|
DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
|
|
980
|
-
ReplayEnvironment: () => ReplayEnvironment,
|
|
981
987
|
SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
|
|
982
988
|
__version__: () => __version__,
|
|
983
989
|
finalizers: () => finalizers,
|
|
984
990
|
flushTraces: () => flushTraces,
|
|
991
|
+
getCurrentReplayBranch: () => getCurrentReplayBranch,
|
|
985
992
|
getCurrentSpan: () => getCurrentSpan,
|
|
986
993
|
getCurrentTrace: () => getCurrentTrace,
|
|
987
994
|
reportReplayProgress: () => reportReplayProgress
|
|
@@ -996,7 +1003,7 @@ registerAsyncLocalStorageClass(
|
|
|
996
1003
|
);
|
|
997
1004
|
|
|
998
1005
|
// src/version.generated.ts
|
|
999
|
-
var __version__ = "0.
|
|
1006
|
+
var __version__ = "0.33.1";
|
|
1000
1007
|
|
|
1001
1008
|
// src/constants.ts
|
|
1002
1009
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1387,7 +1394,7 @@ var HttpClient = class {
|
|
|
1387
1394
|
if (dbBranchSettings !== void 0) {
|
|
1388
1395
|
payload.dbBranchSettings = dbBranchSettings;
|
|
1389
1396
|
}
|
|
1390
|
-
const timeout = includeDbBranchLease ?
|
|
1397
|
+
const timeout = includeDbBranchLease ? 3e5 : 3e4;
|
|
1391
1398
|
return this.request("/api/sdk/replay/start", payload, {
|
|
1392
1399
|
timeout
|
|
1393
1400
|
});
|
|
@@ -1799,7 +1806,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1799
1806
|
}
|
|
1800
1807
|
}
|
|
1801
1808
|
// ── hook callbacks ───────────────────────────────────────────
|
|
1802
|
-
async preToolUseHook(inputData, toolUseId,
|
|
1809
|
+
async preToolUseHook(inputData, toolUseId, _context2) {
|
|
1803
1810
|
try {
|
|
1804
1811
|
const sid = inputData.tool_use_id ?? toolUseId ?? randomUuid();
|
|
1805
1812
|
const toolName = inputData.tool_name ?? "tool";
|
|
@@ -1811,7 +1818,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1811
1818
|
}
|
|
1812
1819
|
return {};
|
|
1813
1820
|
}
|
|
1814
|
-
async postToolUseHook(inputData, toolUseId,
|
|
1821
|
+
async postToolUseHook(inputData, toolUseId, _context2) {
|
|
1815
1822
|
try {
|
|
1816
1823
|
const sid = inputData.tool_use_id ?? toolUseId ?? "";
|
|
1817
1824
|
const toolResponse = inputData.tool_response;
|
|
@@ -1820,7 +1827,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1820
1827
|
}
|
|
1821
1828
|
return {};
|
|
1822
1829
|
}
|
|
1823
|
-
async postToolUseFailureHook(inputData, toolUseId,
|
|
1830
|
+
async postToolUseFailureHook(inputData, toolUseId, _context2) {
|
|
1824
1831
|
try {
|
|
1825
1832
|
const sid = inputData.tool_use_id ?? toolUseId ?? "";
|
|
1826
1833
|
const error = String(inputData.error ?? "Unknown error");
|
|
@@ -1829,7 +1836,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1829
1836
|
}
|
|
1830
1837
|
return {};
|
|
1831
1838
|
}
|
|
1832
|
-
async subagentStartHook(inputData, _toolUseId,
|
|
1839
|
+
async subagentStartHook(inputData, _toolUseId, _context2) {
|
|
1833
1840
|
try {
|
|
1834
1841
|
const agentId = inputData.agent_id ?? randomUuid();
|
|
1835
1842
|
const agentType = inputData.agent_type ?? "subagent";
|
|
@@ -1847,7 +1854,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1847
1854
|
}
|
|
1848
1855
|
return {};
|
|
1849
1856
|
}
|
|
1850
|
-
async subagentStopHook(inputData, _toolUseId,
|
|
1857
|
+
async subagentStopHook(inputData, _toolUseId, _context2) {
|
|
1851
1858
|
try {
|
|
1852
1859
|
const agentId = inputData.agent_id ?? "";
|
|
1853
1860
|
const spanId = this.activeSubagentSpans.get(agentId);
|
|
@@ -3087,106 +3094,46 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
3087
3094
|
|
|
3088
3095
|
// src/client.ts
|
|
3089
3096
|
init_randomUuid();
|
|
3090
|
-
init_replayContext();
|
|
3091
3097
|
|
|
3092
|
-
// src/
|
|
3093
|
-
|
|
3094
|
-
var
|
|
3095
|
-
|
|
3096
|
-
|
|
3098
|
+
// src/replayBranch.ts
|
|
3099
|
+
var _url, _context;
|
|
3100
|
+
var ReplayBranch = class {
|
|
3101
|
+
/** @internal Built by `getCurrentReplayBranch()`; never constructed by callers. */
|
|
3102
|
+
constructor(lease, traceId, context) {
|
|
3103
|
+
// Genuine JS private fields, not TypeScript `private`: these must be
|
|
3104
|
+
// non-enumerable so neither the connection string nor the whole replay
|
|
3105
|
+
// context can ride along into a log line or a serialized payload.
|
|
3106
|
+
__privateAdd(this, _url);
|
|
3107
|
+
__privateAdd(this, _context);
|
|
3108
|
+
this.expiresAt = lease.expiresAt;
|
|
3109
|
+
this.providerConsoleUrl = lease.providerConsoleUrl;
|
|
3110
|
+
this.readOnly = lease.readOnly;
|
|
3111
|
+
this.region = lease.region;
|
|
3112
|
+
this.traceId = traceId;
|
|
3113
|
+
__privateSet(this, _url, lease.databaseUrl);
|
|
3114
|
+
__privateSet(this, _context, context);
|
|
3097
3115
|
}
|
|
3098
3116
|
/**
|
|
3099
|
-
*
|
|
3100
|
-
*
|
|
3117
|
+
* Connection string for this item's branch. Point your database client at it
|
|
3118
|
+
* instead of the live database for the duration of the replayed call.
|
|
3119
|
+
*
|
|
3120
|
+
* Reading it records on the trace that the replayed code obtained the branch
|
|
3121
|
+
* URL, which is what separates "a branch was provisioned" from "the branch
|
|
3122
|
+
* was actually used". The other fields inspect the lease without exposing the
|
|
3123
|
+
* connection string, so they deliberately do not record anything. That is
|
|
3124
|
+
* also why this is a getter and not a plain field: the URL is absent from
|
|
3125
|
+
* `JSON.stringify(branch)` and from logging the object.
|
|
3101
3126
|
*/
|
|
3102
3127
|
get databaseUrl() {
|
|
3103
|
-
|
|
3104
|
-
this
|
|
3105
|
-
return snapshot.databaseUrl;
|
|
3106
|
-
}
|
|
3107
|
-
/** When the per-trace branch URL stops being valid. ISO-8601. */
|
|
3108
|
-
get expiresAt() {
|
|
3109
|
-
return this.require().expiresAt;
|
|
3110
|
-
}
|
|
3111
|
-
/** Deep link to the branch in the provider console, if available. */
|
|
3112
|
-
get providerConsoleUrl() {
|
|
3113
|
-
return this.require().providerConsoleUrl;
|
|
3114
|
-
}
|
|
3115
|
-
/**
|
|
3116
|
-
* True if the branch is read-only. Customer code can use this to skip
|
|
3117
|
-
* write operations during replay when the provider returned a read-only
|
|
3118
|
-
* lease.
|
|
3119
|
-
*/
|
|
3120
|
-
get readOnly() {
|
|
3121
|
-
return this.require().readOnly;
|
|
3122
|
-
}
|
|
3123
|
-
/**
|
|
3124
|
-
* The branch's region, e.g. `aws-us-east-1`. A compute runs in its project's
|
|
3125
|
-
* region, so a replay runner elsewhere pays that round trip on every query.
|
|
3126
|
-
*/
|
|
3127
|
-
get region() {
|
|
3128
|
-
return this.require().region;
|
|
3129
|
-
}
|
|
3130
|
-
/** The historical trace ID that produced the input for this replay item. */
|
|
3131
|
-
get traceId() {
|
|
3132
|
-
return this.require().traceId;
|
|
3133
|
-
}
|
|
3134
|
-
/** True when read inside a replay item that has a resolved branch. */
|
|
3135
|
-
get active() {
|
|
3136
|
-
return this.read() !== null;
|
|
3137
|
-
}
|
|
3138
|
-
/** Non-throwing variant for callers that handle the inactive case. */
|
|
3139
|
-
snapshot() {
|
|
3140
|
-
const snapshot = this.read();
|
|
3141
|
-
if (snapshot) {
|
|
3142
|
-
this.markAccessed();
|
|
3143
|
-
}
|
|
3144
|
-
return snapshot;
|
|
3145
|
-
}
|
|
3146
|
-
/**
|
|
3147
|
-
* Record on the replay context that customer code obtained the branch
|
|
3148
|
-
* URL. Only `databaseUrl` and `snapshot()` count - `active`, `readOnly`
|
|
3149
|
-
* and friends inspect the lease without exposing the connection string,
|
|
3150
|
-
* so they don't prove the replayed code could have connected to the
|
|
3151
|
-
* branch.
|
|
3152
|
-
*/
|
|
3153
|
-
markAccessed() {
|
|
3154
|
-
const ctx = getReplayContext();
|
|
3155
|
-
if (ctx?.dbBranchLease) {
|
|
3156
|
-
ctx.dbSnapshotAccessed = true;
|
|
3157
|
-
}
|
|
3158
|
-
}
|
|
3159
|
-
read() {
|
|
3160
|
-
const ctx = getReplayContext();
|
|
3161
|
-
if (!ctx?.dbBranchLease) {
|
|
3162
|
-
return null;
|
|
3163
|
-
}
|
|
3164
|
-
const traceId = ctx.sourceBitfabTraceId ?? ctx.inputSourceTraceId;
|
|
3165
|
-
if (!traceId) {
|
|
3166
|
-
return null;
|
|
3167
|
-
}
|
|
3168
|
-
const lease = ctx.dbBranchLease;
|
|
3169
|
-
return {
|
|
3170
|
-
databaseUrl: lease.databaseUrl,
|
|
3171
|
-
expiresAt: lease.expiresAt,
|
|
3172
|
-
providerConsoleUrl: lease.providerConsoleUrl,
|
|
3173
|
-
readOnly: lease.readOnly,
|
|
3174
|
-
region: lease.region,
|
|
3175
|
-
traceId
|
|
3176
|
-
};
|
|
3177
|
-
}
|
|
3178
|
-
require() {
|
|
3179
|
-
const snapshot = this.read();
|
|
3180
|
-
if (!snapshot) {
|
|
3181
|
-
throw new Error(
|
|
3182
|
-
"ReplayEnvironment accessed outside of a replay item. Pass it to bitfab.replay({ environment }) and only read it inside the replayed function."
|
|
3183
|
-
);
|
|
3184
|
-
}
|
|
3185
|
-
return snapshot;
|
|
3128
|
+
__privateGet(this, _context).dbSnapshotAccessed = true;
|
|
3129
|
+
return __privateGet(this, _url);
|
|
3186
3130
|
}
|
|
3187
3131
|
};
|
|
3132
|
+
_url = new WeakMap();
|
|
3133
|
+
_context = new WeakMap();
|
|
3188
3134
|
|
|
3189
3135
|
// src/client.ts
|
|
3136
|
+
init_replayContext();
|
|
3190
3137
|
init_serialize();
|
|
3191
3138
|
|
|
3192
3139
|
// src/tracing.ts
|
|
@@ -3783,6 +3730,17 @@ function getCurrentSpan() {
|
|
|
3783
3730
|
}
|
|
3784
3731
|
};
|
|
3785
3732
|
}
|
|
3733
|
+
function getCurrentReplayBranch() {
|
|
3734
|
+
const ctx = getReplayContext();
|
|
3735
|
+
if (!ctx?.dbBranchLease) {
|
|
3736
|
+
return null;
|
|
3737
|
+
}
|
|
3738
|
+
const traceId = ctx.sourceBitfabTraceId ?? ctx.inputSourceTraceId;
|
|
3739
|
+
if (!traceId) {
|
|
3740
|
+
return null;
|
|
3741
|
+
}
|
|
3742
|
+
return new ReplayBranch(ctx.dbBranchLease, traceId, ctx);
|
|
3743
|
+
}
|
|
3786
3744
|
function getCurrentTrace() {
|
|
3787
3745
|
const stack = getSpanStack();
|
|
3788
3746
|
const current = stack[stack.length - 1];
|
|
@@ -4857,12 +4815,6 @@ var Bitfab = class {
|
|
|
4857
4815
|
);
|
|
4858
4816
|
}
|
|
4859
4817
|
};
|
|
4860
|
-
/**
|
|
4861
|
-
* Per-trace environment for `replay({ environment })`. Construct one,
|
|
4862
|
-
* pass it to replay, and read `env.databaseUrl` inside the replayed
|
|
4863
|
-
* function to pick up the per-trace branch URL.
|
|
4864
|
-
*/
|
|
4865
|
-
Bitfab.ReplayEnvironment = ReplayEnvironment;
|
|
4866
4818
|
var BitfabFunction = class {
|
|
4867
4819
|
constructor(client, traceFunctionKey) {
|
|
4868
4820
|
this.client = client;
|
|
@@ -5074,11 +5026,11 @@ assertAsyncStorageRegistered();
|
|
|
5074
5026
|
BitfabOpenAITracingProcessor,
|
|
5075
5027
|
BitfabVercelAiHandler,
|
|
5076
5028
|
DEFAULT_SERVICE_URL,
|
|
5077
|
-
ReplayEnvironment,
|
|
5078
5029
|
SUPPORTED_PROVIDERS,
|
|
5079
5030
|
__version__,
|
|
5080
5031
|
finalizers,
|
|
5081
5032
|
flushTraces,
|
|
5033
|
+
getCurrentReplayBranch,
|
|
5082
5034
|
getCurrentSpan,
|
|
5083
5035
|
getCurrentTrace,
|
|
5084
5036
|
reportReplayProgress
|