bitfab 0.31.1 → 0.33.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-6UJ3E3H5.js → chunk-ADUWXWWI.js} +21 -9
- package/dist/chunk-ADUWXWWI.js.map +1 -0
- package/dist/{chunk-CEUTWQHG.js → chunk-HPLLGCTO.js} +55 -103
- package/dist/chunk-HPLLGCTO.js.map +1 -0
- package/dist/index.cjs +67 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +206 -86
- package/dist/index.d.ts +206 -86
- package/dist/index.js +4 -4
- package/dist/node.cjs +67 -111
- 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-JVURNX5Y.js → replay-EQPISJKC.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-6UJ3E3H5.js.map +0 -1
- package/dist/chunk-CEUTWQHG.js.map +0 -1
- /package/dist/{replay-JVURNX5Y.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) {
|
|
@@ -544,10 +551,11 @@ function resolveDbBranchSettings(dbBranch) {
|
|
|
544
551
|
if (!dbBranch) {
|
|
545
552
|
return void 0;
|
|
546
553
|
}
|
|
554
|
+
const { minCu, maxCu, warmupSql } = dbBranch;
|
|
547
555
|
const settings = {
|
|
548
|
-
...
|
|
549
|
-
...
|
|
550
|
-
...
|
|
556
|
+
...minCu === void 0 ? {} : { minCu },
|
|
557
|
+
...maxCu === void 0 ? {} : { maxCu },
|
|
558
|
+
...warmupSql === void 0 ? {} : { warmupSql }
|
|
551
559
|
};
|
|
552
560
|
return Object.keys(settings).length === 0 ? void 0 : settings;
|
|
553
561
|
}
|
|
@@ -611,9 +619,9 @@ function buildMockTree(rootNode) {
|
|
|
611
619
|
}
|
|
612
620
|
return { spans };
|
|
613
621
|
}
|
|
614
|
-
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId,
|
|
615
|
-
const lease =
|
|
616
|
-
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;
|
|
617
625
|
let inputs = [];
|
|
618
626
|
let originalOutput;
|
|
619
627
|
let result;
|
|
@@ -796,7 +804,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
796
804
|
options?.name,
|
|
797
805
|
codeChangeDescription,
|
|
798
806
|
codeChangeFiles,
|
|
799
|
-
options?.
|
|
807
|
+
options?.dbBranch !== void 0,
|
|
800
808
|
// includeDbBranchLease
|
|
801
809
|
options?.experimentGroupId,
|
|
802
810
|
options?.datasetId,
|
|
@@ -819,7 +827,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
819
827
|
mockStrategy,
|
|
820
828
|
resolvedOverrides,
|
|
821
829
|
replayedTraceIds[index],
|
|
822
|
-
options?.
|
|
830
|
+
options?.dbBranch !== void 0,
|
|
823
831
|
options?.adaptInputs
|
|
824
832
|
)
|
|
825
833
|
);
|
|
@@ -976,11 +984,11 @@ __export(node_exports, {
|
|
|
976
984
|
BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
|
|
977
985
|
BitfabVercelAiHandler: () => BitfabVercelAiHandler,
|
|
978
986
|
DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
|
|
979
|
-
ReplayEnvironment: () => ReplayEnvironment,
|
|
980
987
|
SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
|
|
981
988
|
__version__: () => __version__,
|
|
982
989
|
finalizers: () => finalizers,
|
|
983
990
|
flushTraces: () => flushTraces,
|
|
991
|
+
getCurrentReplayBranch: () => getCurrentReplayBranch,
|
|
984
992
|
getCurrentSpan: () => getCurrentSpan,
|
|
985
993
|
getCurrentTrace: () => getCurrentTrace,
|
|
986
994
|
reportReplayProgress: () => reportReplayProgress
|
|
@@ -995,7 +1003,7 @@ registerAsyncLocalStorageClass(
|
|
|
995
1003
|
);
|
|
996
1004
|
|
|
997
1005
|
// src/version.generated.ts
|
|
998
|
-
var __version__ = "0.
|
|
1006
|
+
var __version__ = "0.33.0";
|
|
999
1007
|
|
|
1000
1008
|
// src/constants.ts
|
|
1001
1009
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1798,7 +1806,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1798
1806
|
}
|
|
1799
1807
|
}
|
|
1800
1808
|
// ── hook callbacks ───────────────────────────────────────────
|
|
1801
|
-
async preToolUseHook(inputData, toolUseId,
|
|
1809
|
+
async preToolUseHook(inputData, toolUseId, _context2) {
|
|
1802
1810
|
try {
|
|
1803
1811
|
const sid = inputData.tool_use_id ?? toolUseId ?? randomUuid();
|
|
1804
1812
|
const toolName = inputData.tool_name ?? "tool";
|
|
@@ -1810,7 +1818,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1810
1818
|
}
|
|
1811
1819
|
return {};
|
|
1812
1820
|
}
|
|
1813
|
-
async postToolUseHook(inputData, toolUseId,
|
|
1821
|
+
async postToolUseHook(inputData, toolUseId, _context2) {
|
|
1814
1822
|
try {
|
|
1815
1823
|
const sid = inputData.tool_use_id ?? toolUseId ?? "";
|
|
1816
1824
|
const toolResponse = inputData.tool_response;
|
|
@@ -1819,7 +1827,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1819
1827
|
}
|
|
1820
1828
|
return {};
|
|
1821
1829
|
}
|
|
1822
|
-
async postToolUseFailureHook(inputData, toolUseId,
|
|
1830
|
+
async postToolUseFailureHook(inputData, toolUseId, _context2) {
|
|
1823
1831
|
try {
|
|
1824
1832
|
const sid = inputData.tool_use_id ?? toolUseId ?? "";
|
|
1825
1833
|
const error = String(inputData.error ?? "Unknown error");
|
|
@@ -1828,7 +1836,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1828
1836
|
}
|
|
1829
1837
|
return {};
|
|
1830
1838
|
}
|
|
1831
|
-
async subagentStartHook(inputData, _toolUseId,
|
|
1839
|
+
async subagentStartHook(inputData, _toolUseId, _context2) {
|
|
1832
1840
|
try {
|
|
1833
1841
|
const agentId = inputData.agent_id ?? randomUuid();
|
|
1834
1842
|
const agentType = inputData.agent_type ?? "subagent";
|
|
@@ -1846,7 +1854,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1846
1854
|
}
|
|
1847
1855
|
return {};
|
|
1848
1856
|
}
|
|
1849
|
-
async subagentStopHook(inputData, _toolUseId,
|
|
1857
|
+
async subagentStopHook(inputData, _toolUseId, _context2) {
|
|
1850
1858
|
try {
|
|
1851
1859
|
const agentId = inputData.agent_id ?? "";
|
|
1852
1860
|
const spanId = this.activeSubagentSpans.get(agentId);
|
|
@@ -3086,103 +3094,46 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
3086
3094
|
|
|
3087
3095
|
// src/client.ts
|
|
3088
3096
|
init_randomUuid();
|
|
3089
|
-
init_replayContext();
|
|
3090
3097
|
|
|
3091
|
-
// src/
|
|
3092
|
-
|
|
3093
|
-
var
|
|
3094
|
-
/**
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
this
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
get providerConsoleUrl() {
|
|
3109
|
-
return this.require().providerConsoleUrl;
|
|
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);
|
|
3110
3115
|
}
|
|
3111
3116
|
/**
|
|
3112
|
-
*
|
|
3113
|
-
*
|
|
3114
|
-
*
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
*
|
|
3121
|
-
* region, so a replay runner elsewhere pays that round trip on every query.
|
|
3122
|
-
*/
|
|
3123
|
-
get region() {
|
|
3124
|
-
return this.require().region;
|
|
3125
|
-
}
|
|
3126
|
-
/** The historical trace ID that produced the input for this replay item. */
|
|
3127
|
-
get traceId() {
|
|
3128
|
-
return this.require().traceId;
|
|
3129
|
-
}
|
|
3130
|
-
/** True when read inside a replay item that has a resolved branch. */
|
|
3131
|
-
get active() {
|
|
3132
|
-
return this.read() !== null;
|
|
3133
|
-
}
|
|
3134
|
-
/** Non-throwing variant for callers that handle the inactive case. */
|
|
3135
|
-
snapshot() {
|
|
3136
|
-
const snapshot = this.read();
|
|
3137
|
-
if (snapshot) {
|
|
3138
|
-
this.markAccessed();
|
|
3139
|
-
}
|
|
3140
|
-
return snapshot;
|
|
3141
|
-
}
|
|
3142
|
-
/**
|
|
3143
|
-
* Record on the replay context that customer code obtained the branch
|
|
3144
|
-
* URL. Only `databaseUrl` and `snapshot()` count - `active`, `readOnly`
|
|
3145
|
-
* and friends inspect the lease without exposing the connection string,
|
|
3146
|
-
* so they don't prove the replayed code could have connected to the
|
|
3147
|
-
* branch.
|
|
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.
|
|
3148
3126
|
*/
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
ctx.dbSnapshotAccessed = true;
|
|
3153
|
-
}
|
|
3154
|
-
}
|
|
3155
|
-
read() {
|
|
3156
|
-
const ctx = getReplayContext();
|
|
3157
|
-
if (!ctx?.dbBranchLease) {
|
|
3158
|
-
return null;
|
|
3159
|
-
}
|
|
3160
|
-
const traceId = ctx.sourceBitfabTraceId ?? ctx.inputSourceTraceId;
|
|
3161
|
-
if (!traceId) {
|
|
3162
|
-
return null;
|
|
3163
|
-
}
|
|
3164
|
-
const lease = ctx.dbBranchLease;
|
|
3165
|
-
return {
|
|
3166
|
-
databaseUrl: lease.databaseUrl,
|
|
3167
|
-
expiresAt: lease.expiresAt,
|
|
3168
|
-
providerConsoleUrl: lease.providerConsoleUrl,
|
|
3169
|
-
readOnly: lease.readOnly,
|
|
3170
|
-
region: lease.region,
|
|
3171
|
-
traceId
|
|
3172
|
-
};
|
|
3173
|
-
}
|
|
3174
|
-
require() {
|
|
3175
|
-
const snapshot = this.read();
|
|
3176
|
-
if (!snapshot) {
|
|
3177
|
-
throw new Error(
|
|
3178
|
-
"ReplayEnvironment accessed outside of a replay item. Pass it to bitfab.replay({ environment }) and only read it inside the replayed function."
|
|
3179
|
-
);
|
|
3180
|
-
}
|
|
3181
|
-
return snapshot;
|
|
3127
|
+
get databaseUrl() {
|
|
3128
|
+
__privateGet(this, _context).dbSnapshotAccessed = true;
|
|
3129
|
+
return __privateGet(this, _url);
|
|
3182
3130
|
}
|
|
3183
3131
|
};
|
|
3132
|
+
_url = new WeakMap();
|
|
3133
|
+
_context = new WeakMap();
|
|
3184
3134
|
|
|
3185
3135
|
// src/client.ts
|
|
3136
|
+
init_replayContext();
|
|
3186
3137
|
init_serialize();
|
|
3187
3138
|
|
|
3188
3139
|
// src/tracing.ts
|
|
@@ -3779,6 +3730,17 @@ function getCurrentSpan() {
|
|
|
3779
3730
|
}
|
|
3780
3731
|
};
|
|
3781
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
|
+
}
|
|
3782
3744
|
function getCurrentTrace() {
|
|
3783
3745
|
const stack = getSpanStack();
|
|
3784
3746
|
const current = stack[stack.length - 1];
|
|
@@ -4853,12 +4815,6 @@ var Bitfab = class {
|
|
|
4853
4815
|
);
|
|
4854
4816
|
}
|
|
4855
4817
|
};
|
|
4856
|
-
/**
|
|
4857
|
-
* Per-trace environment for `replay({ environment })`. Construct one,
|
|
4858
|
-
* pass it to replay, and read `env.databaseUrl` inside the replayed
|
|
4859
|
-
* function to pick up the per-trace branch URL.
|
|
4860
|
-
*/
|
|
4861
|
-
Bitfab.ReplayEnvironment = ReplayEnvironment;
|
|
4862
4818
|
var BitfabFunction = class {
|
|
4863
4819
|
constructor(client, traceFunctionKey) {
|
|
4864
4820
|
this.client = client;
|
|
@@ -5070,11 +5026,11 @@ assertAsyncStorageRegistered();
|
|
|
5070
5026
|
BitfabOpenAITracingProcessor,
|
|
5071
5027
|
BitfabVercelAiHandler,
|
|
5072
5028
|
DEFAULT_SERVICE_URL,
|
|
5073
|
-
ReplayEnvironment,
|
|
5074
5029
|
SUPPORTED_PROVIDERS,
|
|
5075
5030
|
__version__,
|
|
5076
5031
|
finalizers,
|
|
5077
5032
|
flushTraces,
|
|
5033
|
+
getCurrentReplayBranch,
|
|
5078
5034
|
getCurrentSpan,
|
|
5079
5035
|
getCurrentTrace,
|
|
5080
5036
|
reportReplayProgress
|