bitfab 0.32.0 → 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-NMNVPON4.js → chunk-ADUWXWWI.js} +21 -10
- package/dist/chunk-ADUWXWWI.js.map +1 -0
- package/dist/{chunk-YZZO475T.js → chunk-HPLLGCTO.js} +54 -105
- package/dist/chunk-HPLLGCTO.js.map +1 -0
- package/dist/index.cjs +66 -114
- 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 +66 -114
- 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/index.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/errors.ts
|
|
43
50
|
var BitfabError;
|
|
@@ -533,11 +540,11 @@ __export(replay_exports, {
|
|
|
533
540
|
replay: () => replay,
|
|
534
541
|
reportReplayProgress: () => reportReplayProgress
|
|
535
542
|
});
|
|
536
|
-
function resolveDbBranchSettings(
|
|
537
|
-
if (!
|
|
543
|
+
function resolveDbBranchSettings(dbBranch) {
|
|
544
|
+
if (!dbBranch) {
|
|
538
545
|
return void 0;
|
|
539
546
|
}
|
|
540
|
-
const { minCu, maxCu, warmupSql } =
|
|
547
|
+
const { minCu, maxCu, warmupSql } = dbBranch;
|
|
541
548
|
const settings = {
|
|
542
549
|
...minCu === void 0 ? {} : { minCu },
|
|
543
550
|
...maxCu === void 0 ? {} : { maxCu },
|
|
@@ -605,9 +612,9 @@ function buildMockTree(rootNode) {
|
|
|
605
612
|
}
|
|
606
613
|
return { spans };
|
|
607
614
|
}
|
|
608
|
-
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId,
|
|
609
|
-
const lease =
|
|
610
|
-
const leaseError =
|
|
615
|
+
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId, includeDbBranchLease, adaptInputs) {
|
|
616
|
+
const lease = includeDbBranchLease ? serverItem.dbBranchLease : void 0;
|
|
617
|
+
const leaseError = includeDbBranchLease ? serverItem.dbBranchLeaseError : void 0;
|
|
611
618
|
let inputs = [];
|
|
612
619
|
let originalOutput;
|
|
613
620
|
let result;
|
|
@@ -790,12 +797,12 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
790
797
|
options?.name,
|
|
791
798
|
codeChangeDescription,
|
|
792
799
|
codeChangeFiles,
|
|
793
|
-
options?.
|
|
800
|
+
options?.dbBranch !== void 0,
|
|
794
801
|
// includeDbBranchLease
|
|
795
802
|
options?.experimentGroupId,
|
|
796
803
|
options?.datasetId,
|
|
797
804
|
options?.graderIds,
|
|
798
|
-
resolveDbBranchSettings(options?.
|
|
805
|
+
resolveDbBranchSettings(options?.dbBranch)
|
|
799
806
|
);
|
|
800
807
|
const mockStrategy = options?.mock ?? "marked";
|
|
801
808
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
@@ -813,7 +820,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
813
820
|
mockStrategy,
|
|
814
821
|
resolvedOverrides,
|
|
815
822
|
replayedTraceIds[index],
|
|
816
|
-
options?.
|
|
823
|
+
options?.dbBranch !== void 0,
|
|
817
824
|
options?.adaptInputs
|
|
818
825
|
)
|
|
819
826
|
);
|
|
@@ -970,11 +977,11 @@ __export(index_exports, {
|
|
|
970
977
|
BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
|
|
971
978
|
BitfabVercelAiHandler: () => BitfabVercelAiHandler,
|
|
972
979
|
DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
|
|
973
|
-
ReplayEnvironment: () => ReplayEnvironment,
|
|
974
980
|
SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
|
|
975
981
|
__version__: () => __version__,
|
|
976
982
|
finalizers: () => finalizers,
|
|
977
983
|
flushTraces: () => flushTraces,
|
|
984
|
+
getCurrentReplayBranch: () => getCurrentReplayBranch,
|
|
978
985
|
getCurrentSpan: () => getCurrentSpan,
|
|
979
986
|
getCurrentTrace: () => getCurrentTrace,
|
|
980
987
|
reportReplayProgress: () => reportReplayProgress
|
|
@@ -982,7 +989,7 @@ __export(index_exports, {
|
|
|
982
989
|
module.exports = __toCommonJS(index_exports);
|
|
983
990
|
|
|
984
991
|
// src/version.generated.ts
|
|
985
|
-
var __version__ = "0.
|
|
992
|
+
var __version__ = "0.33.0";
|
|
986
993
|
|
|
987
994
|
// src/constants.ts
|
|
988
995
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1785,7 +1792,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1785
1792
|
}
|
|
1786
1793
|
}
|
|
1787
1794
|
// ── hook callbacks ───────────────────────────────────────────
|
|
1788
|
-
async preToolUseHook(inputData, toolUseId,
|
|
1795
|
+
async preToolUseHook(inputData, toolUseId, _context2) {
|
|
1789
1796
|
try {
|
|
1790
1797
|
const sid = inputData.tool_use_id ?? toolUseId ?? randomUuid();
|
|
1791
1798
|
const toolName = inputData.tool_name ?? "tool";
|
|
@@ -1797,7 +1804,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1797
1804
|
}
|
|
1798
1805
|
return {};
|
|
1799
1806
|
}
|
|
1800
|
-
async postToolUseHook(inputData, toolUseId,
|
|
1807
|
+
async postToolUseHook(inputData, toolUseId, _context2) {
|
|
1801
1808
|
try {
|
|
1802
1809
|
const sid = inputData.tool_use_id ?? toolUseId ?? "";
|
|
1803
1810
|
const toolResponse = inputData.tool_response;
|
|
@@ -1806,7 +1813,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1806
1813
|
}
|
|
1807
1814
|
return {};
|
|
1808
1815
|
}
|
|
1809
|
-
async postToolUseFailureHook(inputData, toolUseId,
|
|
1816
|
+
async postToolUseFailureHook(inputData, toolUseId, _context2) {
|
|
1810
1817
|
try {
|
|
1811
1818
|
const sid = inputData.tool_use_id ?? toolUseId ?? "";
|
|
1812
1819
|
const error = String(inputData.error ?? "Unknown error");
|
|
@@ -1815,7 +1822,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1815
1822
|
}
|
|
1816
1823
|
return {};
|
|
1817
1824
|
}
|
|
1818
|
-
async subagentStartHook(inputData, _toolUseId,
|
|
1825
|
+
async subagentStartHook(inputData, _toolUseId, _context2) {
|
|
1819
1826
|
try {
|
|
1820
1827
|
const agentId = inputData.agent_id ?? randomUuid();
|
|
1821
1828
|
const agentType = inputData.agent_type ?? "subagent";
|
|
@@ -1833,7 +1840,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1833
1840
|
}
|
|
1834
1841
|
return {};
|
|
1835
1842
|
}
|
|
1836
|
-
async subagentStopHook(inputData, _toolUseId,
|
|
1843
|
+
async subagentStopHook(inputData, _toolUseId, _context2) {
|
|
1837
1844
|
try {
|
|
1838
1845
|
const agentId = inputData.agent_id ?? "";
|
|
1839
1846
|
const spanId = this.activeSubagentSpans.get(agentId);
|
|
@@ -3073,106 +3080,46 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
3073
3080
|
|
|
3074
3081
|
// src/client.ts
|
|
3075
3082
|
init_randomUuid();
|
|
3076
|
-
init_replayContext();
|
|
3077
3083
|
|
|
3078
|
-
// src/
|
|
3079
|
-
|
|
3080
|
-
var
|
|
3081
|
-
|
|
3082
|
-
|
|
3084
|
+
// src/replayBranch.ts
|
|
3085
|
+
var _url, _context;
|
|
3086
|
+
var ReplayBranch = class {
|
|
3087
|
+
/** @internal Built by `getCurrentReplayBranch()`; never constructed by callers. */
|
|
3088
|
+
constructor(lease, traceId, context) {
|
|
3089
|
+
// Genuine JS private fields, not TypeScript `private`: these must be
|
|
3090
|
+
// non-enumerable so neither the connection string nor the whole replay
|
|
3091
|
+
// context can ride along into a log line or a serialized payload.
|
|
3092
|
+
__privateAdd(this, _url);
|
|
3093
|
+
__privateAdd(this, _context);
|
|
3094
|
+
this.expiresAt = lease.expiresAt;
|
|
3095
|
+
this.providerConsoleUrl = lease.providerConsoleUrl;
|
|
3096
|
+
this.readOnly = lease.readOnly;
|
|
3097
|
+
this.region = lease.region;
|
|
3098
|
+
this.traceId = traceId;
|
|
3099
|
+
__privateSet(this, _url, lease.databaseUrl);
|
|
3100
|
+
__privateSet(this, _context, context);
|
|
3083
3101
|
}
|
|
3084
3102
|
/**
|
|
3085
|
-
*
|
|
3086
|
-
*
|
|
3103
|
+
* Connection string for this item's branch. Point your database client at it
|
|
3104
|
+
* instead of the live database for the duration of the replayed call.
|
|
3105
|
+
*
|
|
3106
|
+
* Reading it records on the trace that the replayed code obtained the branch
|
|
3107
|
+
* URL, which is what separates "a branch was provisioned" from "the branch
|
|
3108
|
+
* was actually used". The other fields inspect the lease without exposing the
|
|
3109
|
+
* connection string, so they deliberately do not record anything. That is
|
|
3110
|
+
* also why this is a getter and not a plain field: the URL is absent from
|
|
3111
|
+
* `JSON.stringify(branch)` and from logging the object.
|
|
3087
3112
|
*/
|
|
3088
3113
|
get databaseUrl() {
|
|
3089
|
-
|
|
3090
|
-
this
|
|
3091
|
-
return snapshot.databaseUrl;
|
|
3092
|
-
}
|
|
3093
|
-
/** When the per-trace branch URL stops being valid. ISO-8601. */
|
|
3094
|
-
get expiresAt() {
|
|
3095
|
-
return this.require().expiresAt;
|
|
3096
|
-
}
|
|
3097
|
-
/** Deep link to the branch in the provider console, if available. */
|
|
3098
|
-
get providerConsoleUrl() {
|
|
3099
|
-
return this.require().providerConsoleUrl;
|
|
3100
|
-
}
|
|
3101
|
-
/**
|
|
3102
|
-
* True if the branch is read-only. Customer code can use this to skip
|
|
3103
|
-
* write operations during replay when the provider returned a read-only
|
|
3104
|
-
* lease.
|
|
3105
|
-
*/
|
|
3106
|
-
get readOnly() {
|
|
3107
|
-
return this.require().readOnly;
|
|
3108
|
-
}
|
|
3109
|
-
/**
|
|
3110
|
-
* The branch's region, e.g. `aws-us-east-1`. A compute runs in its project's
|
|
3111
|
-
* region, so a replay runner elsewhere pays that round trip on every query.
|
|
3112
|
-
*/
|
|
3113
|
-
get region() {
|
|
3114
|
-
return this.require().region;
|
|
3115
|
-
}
|
|
3116
|
-
/** The historical trace ID that produced the input for this replay item. */
|
|
3117
|
-
get traceId() {
|
|
3118
|
-
return this.require().traceId;
|
|
3119
|
-
}
|
|
3120
|
-
/** True when read inside a replay item that has a resolved branch. */
|
|
3121
|
-
get active() {
|
|
3122
|
-
return this.read() !== null;
|
|
3123
|
-
}
|
|
3124
|
-
/** Non-throwing variant for callers that handle the inactive case. */
|
|
3125
|
-
snapshot() {
|
|
3126
|
-
const snapshot = this.read();
|
|
3127
|
-
if (snapshot) {
|
|
3128
|
-
this.markAccessed();
|
|
3129
|
-
}
|
|
3130
|
-
return snapshot;
|
|
3131
|
-
}
|
|
3132
|
-
/**
|
|
3133
|
-
* Record on the replay context that customer code obtained the branch
|
|
3134
|
-
* URL. Only `databaseUrl` and `snapshot()` count - `active`, `readOnly`
|
|
3135
|
-
* and friends inspect the lease without exposing the connection string,
|
|
3136
|
-
* so they don't prove the replayed code could have connected to the
|
|
3137
|
-
* branch.
|
|
3138
|
-
*/
|
|
3139
|
-
markAccessed() {
|
|
3140
|
-
const ctx = getReplayContext();
|
|
3141
|
-
if (ctx?.dbBranchLease) {
|
|
3142
|
-
ctx.dbSnapshotAccessed = true;
|
|
3143
|
-
}
|
|
3144
|
-
}
|
|
3145
|
-
read() {
|
|
3146
|
-
const ctx = getReplayContext();
|
|
3147
|
-
if (!ctx?.dbBranchLease) {
|
|
3148
|
-
return null;
|
|
3149
|
-
}
|
|
3150
|
-
const traceId = ctx.sourceBitfabTraceId ?? ctx.inputSourceTraceId;
|
|
3151
|
-
if (!traceId) {
|
|
3152
|
-
return null;
|
|
3153
|
-
}
|
|
3154
|
-
const lease = ctx.dbBranchLease;
|
|
3155
|
-
return {
|
|
3156
|
-
databaseUrl: lease.databaseUrl,
|
|
3157
|
-
expiresAt: lease.expiresAt,
|
|
3158
|
-
providerConsoleUrl: lease.providerConsoleUrl,
|
|
3159
|
-
readOnly: lease.readOnly,
|
|
3160
|
-
region: lease.region,
|
|
3161
|
-
traceId
|
|
3162
|
-
};
|
|
3163
|
-
}
|
|
3164
|
-
require() {
|
|
3165
|
-
const snapshot = this.read();
|
|
3166
|
-
if (!snapshot) {
|
|
3167
|
-
throw new Error(
|
|
3168
|
-
"ReplayEnvironment accessed outside of a replay item. Pass it to bitfab.replay({ environment }) and only read it inside the replayed function."
|
|
3169
|
-
);
|
|
3170
|
-
}
|
|
3171
|
-
return snapshot;
|
|
3114
|
+
__privateGet(this, _context).dbSnapshotAccessed = true;
|
|
3115
|
+
return __privateGet(this, _url);
|
|
3172
3116
|
}
|
|
3173
3117
|
};
|
|
3118
|
+
_url = new WeakMap();
|
|
3119
|
+
_context = new WeakMap();
|
|
3174
3120
|
|
|
3175
3121
|
// src/client.ts
|
|
3122
|
+
init_replayContext();
|
|
3176
3123
|
init_serialize();
|
|
3177
3124
|
|
|
3178
3125
|
// src/tracing.ts
|
|
@@ -3769,6 +3716,17 @@ function getCurrentSpan() {
|
|
|
3769
3716
|
}
|
|
3770
3717
|
};
|
|
3771
3718
|
}
|
|
3719
|
+
function getCurrentReplayBranch() {
|
|
3720
|
+
const ctx = getReplayContext();
|
|
3721
|
+
if (!ctx?.dbBranchLease) {
|
|
3722
|
+
return null;
|
|
3723
|
+
}
|
|
3724
|
+
const traceId = ctx.sourceBitfabTraceId ?? ctx.inputSourceTraceId;
|
|
3725
|
+
if (!traceId) {
|
|
3726
|
+
return null;
|
|
3727
|
+
}
|
|
3728
|
+
return new ReplayBranch(ctx.dbBranchLease, traceId, ctx);
|
|
3729
|
+
}
|
|
3772
3730
|
function getCurrentTrace() {
|
|
3773
3731
|
const stack = getSpanStack();
|
|
3774
3732
|
const current = stack[stack.length - 1];
|
|
@@ -4843,12 +4801,6 @@ var Bitfab = class {
|
|
|
4843
4801
|
);
|
|
4844
4802
|
}
|
|
4845
4803
|
};
|
|
4846
|
-
/**
|
|
4847
|
-
* Per-trace environment for `replay({ environment })`. Construct one,
|
|
4848
|
-
* pass it to replay, and read `env.databaseUrl` inside the replayed
|
|
4849
|
-
* function to pick up the per-trace branch URL.
|
|
4850
|
-
*/
|
|
4851
|
-
Bitfab.ReplayEnvironment = ReplayEnvironment;
|
|
4852
4804
|
var BitfabFunction = class {
|
|
4853
4805
|
constructor(client, traceFunctionKey) {
|
|
4854
4806
|
this.client = client;
|
|
@@ -5056,11 +5008,11 @@ init_replay();
|
|
|
5056
5008
|
BitfabOpenAITracingProcessor,
|
|
5057
5009
|
BitfabVercelAiHandler,
|
|
5058
5010
|
DEFAULT_SERVICE_URL,
|
|
5059
|
-
ReplayEnvironment,
|
|
5060
5011
|
SUPPORTED_PROVIDERS,
|
|
5061
5012
|
__version__,
|
|
5062
5013
|
finalizers,
|
|
5063
5014
|
flushTraces,
|
|
5015
|
+
getCurrentReplayBranch,
|
|
5064
5016
|
getCurrentSpan,
|
|
5065
5017
|
getCurrentTrace,
|
|
5066
5018
|
reportReplayProgress
|