@bitfab/sdk 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
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __typeError = (msg) => {
|
|
9
|
+
throw TypeError(msg);
|
|
10
|
+
};
|
|
8
11
|
var __esm = (fn, res) => function __init() {
|
|
9
12
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
13
|
};
|
|
@@ -29,6 +32,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
32
|
mod
|
|
30
33
|
));
|
|
31
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
36
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
37
|
+
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);
|
|
38
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
32
39
|
|
|
33
40
|
// src/asyncStorage.ts
|
|
34
41
|
function registerAsyncLocalStorageClass(cls) {
|
|
@@ -535,10 +542,11 @@ function resolveDbBranchSettings(dbBranch) {
|
|
|
535
542
|
if (!dbBranch) {
|
|
536
543
|
return void 0;
|
|
537
544
|
}
|
|
545
|
+
const { minCu, maxCu, warmupSql } = dbBranch;
|
|
538
546
|
const settings = {
|
|
539
|
-
...
|
|
540
|
-
...
|
|
541
|
-
...
|
|
547
|
+
...minCu === void 0 ? {} : { minCu },
|
|
548
|
+
...maxCu === void 0 ? {} : { maxCu },
|
|
549
|
+
...warmupSql === void 0 ? {} : { warmupSql }
|
|
542
550
|
};
|
|
543
551
|
return Object.keys(settings).length === 0 ? void 0 : settings;
|
|
544
552
|
}
|
|
@@ -602,9 +610,9 @@ function buildMockTree(rootNode) {
|
|
|
602
610
|
}
|
|
603
611
|
return { spans };
|
|
604
612
|
}
|
|
605
|
-
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId,
|
|
606
|
-
const lease =
|
|
607
|
-
const leaseError =
|
|
613
|
+
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId, includeDbBranchLease, adaptInputs) {
|
|
614
|
+
const lease = includeDbBranchLease ? serverItem.dbBranchLease : void 0;
|
|
615
|
+
const leaseError = includeDbBranchLease ? serverItem.dbBranchLeaseError : void 0;
|
|
608
616
|
let inputs = [];
|
|
609
617
|
let originalOutput;
|
|
610
618
|
let result;
|
|
@@ -787,7 +795,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
787
795
|
options?.name,
|
|
788
796
|
codeChangeDescription,
|
|
789
797
|
codeChangeFiles,
|
|
790
|
-
options?.
|
|
798
|
+
options?.dbBranch !== void 0,
|
|
791
799
|
// includeDbBranchLease
|
|
792
800
|
options?.experimentGroupId,
|
|
793
801
|
options?.datasetId,
|
|
@@ -810,7 +818,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
810
818
|
mockStrategy,
|
|
811
819
|
resolvedOverrides,
|
|
812
820
|
replayedTraceIds[index],
|
|
813
|
-
options?.
|
|
821
|
+
options?.dbBranch !== void 0,
|
|
814
822
|
options?.adaptInputs
|
|
815
823
|
)
|
|
816
824
|
);
|
|
@@ -967,11 +975,11 @@ __export(node_exports, {
|
|
|
967
975
|
BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
|
|
968
976
|
BitfabVercelAiHandler: () => BitfabVercelAiHandler,
|
|
969
977
|
DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
|
|
970
|
-
ReplayEnvironment: () => ReplayEnvironment,
|
|
971
978
|
SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
|
|
972
979
|
__version__: () => __version__,
|
|
973
980
|
finalizers: () => finalizers,
|
|
974
981
|
flushTraces: () => flushTraces,
|
|
982
|
+
getCurrentReplayBranch: () => getCurrentReplayBranch,
|
|
975
983
|
getCurrentSpan: () => getCurrentSpan,
|
|
976
984
|
getCurrentTrace: () => getCurrentTrace,
|
|
977
985
|
reportReplayProgress: () => reportReplayProgress
|
|
@@ -986,7 +994,7 @@ registerAsyncLocalStorageClass(
|
|
|
986
994
|
);
|
|
987
995
|
|
|
988
996
|
// src/version.generated.ts
|
|
989
|
-
var __version__ = "0.
|
|
997
|
+
var __version__ = "0.33.0";
|
|
990
998
|
|
|
991
999
|
// src/constants.ts
|
|
992
1000
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1789,7 +1797,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1789
1797
|
}
|
|
1790
1798
|
}
|
|
1791
1799
|
// ── hook callbacks ───────────────────────────────────────────
|
|
1792
|
-
async preToolUseHook(inputData, toolUseId,
|
|
1800
|
+
async preToolUseHook(inputData, toolUseId, _context2) {
|
|
1793
1801
|
try {
|
|
1794
1802
|
const sid = inputData.tool_use_id ?? toolUseId ?? randomUuid();
|
|
1795
1803
|
const toolName = inputData.tool_name ?? "tool";
|
|
@@ -1801,7 +1809,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1801
1809
|
}
|
|
1802
1810
|
return {};
|
|
1803
1811
|
}
|
|
1804
|
-
async postToolUseHook(inputData, toolUseId,
|
|
1812
|
+
async postToolUseHook(inputData, toolUseId, _context2) {
|
|
1805
1813
|
try {
|
|
1806
1814
|
const sid = inputData.tool_use_id ?? toolUseId ?? "";
|
|
1807
1815
|
const toolResponse = inputData.tool_response;
|
|
@@ -1810,7 +1818,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1810
1818
|
}
|
|
1811
1819
|
return {};
|
|
1812
1820
|
}
|
|
1813
|
-
async postToolUseFailureHook(inputData, toolUseId,
|
|
1821
|
+
async postToolUseFailureHook(inputData, toolUseId, _context2) {
|
|
1814
1822
|
try {
|
|
1815
1823
|
const sid = inputData.tool_use_id ?? toolUseId ?? "";
|
|
1816
1824
|
const error = String(inputData.error ?? "Unknown error");
|
|
@@ -1819,7 +1827,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1819
1827
|
}
|
|
1820
1828
|
return {};
|
|
1821
1829
|
}
|
|
1822
|
-
async subagentStartHook(inputData, _toolUseId,
|
|
1830
|
+
async subagentStartHook(inputData, _toolUseId, _context2) {
|
|
1823
1831
|
try {
|
|
1824
1832
|
const agentId = inputData.agent_id ?? randomUuid();
|
|
1825
1833
|
const agentType = inputData.agent_type ?? "subagent";
|
|
@@ -1837,7 +1845,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1837
1845
|
}
|
|
1838
1846
|
return {};
|
|
1839
1847
|
}
|
|
1840
|
-
async subagentStopHook(inputData, _toolUseId,
|
|
1848
|
+
async subagentStopHook(inputData, _toolUseId, _context2) {
|
|
1841
1849
|
try {
|
|
1842
1850
|
const agentId = inputData.agent_id ?? "";
|
|
1843
1851
|
const spanId = this.activeSubagentSpans.get(agentId);
|
|
@@ -3077,103 +3085,46 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
3077
3085
|
|
|
3078
3086
|
// src/client.ts
|
|
3079
3087
|
init_randomUuid();
|
|
3080
|
-
init_replayContext();
|
|
3081
3088
|
|
|
3082
|
-
// src/
|
|
3083
|
-
|
|
3084
|
-
var
|
|
3085
|
-
/**
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
this
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
get providerConsoleUrl() {
|
|
3100
|
-
return this.require().providerConsoleUrl;
|
|
3089
|
+
// src/replayBranch.ts
|
|
3090
|
+
var _url, _context;
|
|
3091
|
+
var ReplayBranch = class {
|
|
3092
|
+
/** @internal Built by `getCurrentReplayBranch()`; never constructed by callers. */
|
|
3093
|
+
constructor(lease, traceId, context) {
|
|
3094
|
+
// Genuine JS private fields, not TypeScript `private`: these must be
|
|
3095
|
+
// non-enumerable so neither the connection string nor the whole replay
|
|
3096
|
+
// context can ride along into a log line or a serialized payload.
|
|
3097
|
+
__privateAdd(this, _url);
|
|
3098
|
+
__privateAdd(this, _context);
|
|
3099
|
+
this.expiresAt = lease.expiresAt;
|
|
3100
|
+
this.providerConsoleUrl = lease.providerConsoleUrl;
|
|
3101
|
+
this.readOnly = lease.readOnly;
|
|
3102
|
+
this.region = lease.region;
|
|
3103
|
+
this.traceId = traceId;
|
|
3104
|
+
__privateSet(this, _url, lease.databaseUrl);
|
|
3105
|
+
__privateSet(this, _context, context);
|
|
3101
3106
|
}
|
|
3102
3107
|
/**
|
|
3103
|
-
*
|
|
3104
|
-
*
|
|
3105
|
-
*
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
*
|
|
3112
|
-
* region, so a replay runner elsewhere pays that round trip on every query.
|
|
3113
|
-
*/
|
|
3114
|
-
get region() {
|
|
3115
|
-
return this.require().region;
|
|
3116
|
-
}
|
|
3117
|
-
/** The historical trace ID that produced the input for this replay item. */
|
|
3118
|
-
get traceId() {
|
|
3119
|
-
return this.require().traceId;
|
|
3120
|
-
}
|
|
3121
|
-
/** True when read inside a replay item that has a resolved branch. */
|
|
3122
|
-
get active() {
|
|
3123
|
-
return this.read() !== null;
|
|
3124
|
-
}
|
|
3125
|
-
/** Non-throwing variant for callers that handle the inactive case. */
|
|
3126
|
-
snapshot() {
|
|
3127
|
-
const snapshot = this.read();
|
|
3128
|
-
if (snapshot) {
|
|
3129
|
-
this.markAccessed();
|
|
3130
|
-
}
|
|
3131
|
-
return snapshot;
|
|
3132
|
-
}
|
|
3133
|
-
/**
|
|
3134
|
-
* Record on the replay context that customer code obtained the branch
|
|
3135
|
-
* URL. Only `databaseUrl` and `snapshot()` count - `active`, `readOnly`
|
|
3136
|
-
* and friends inspect the lease without exposing the connection string,
|
|
3137
|
-
* so they don't prove the replayed code could have connected to the
|
|
3138
|
-
* branch.
|
|
3108
|
+
* Connection string for this item's branch. Point your database client at it
|
|
3109
|
+
* instead of the live database for the duration of the replayed call.
|
|
3110
|
+
*
|
|
3111
|
+
* Reading it records on the trace that the replayed code obtained the branch
|
|
3112
|
+
* URL, which is what separates "a branch was provisioned" from "the branch
|
|
3113
|
+
* was actually used". The other fields inspect the lease without exposing the
|
|
3114
|
+
* connection string, so they deliberately do not record anything. That is
|
|
3115
|
+
* also why this is a getter and not a plain field: the URL is absent from
|
|
3116
|
+
* `JSON.stringify(branch)` and from logging the object.
|
|
3139
3117
|
*/
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
ctx.dbSnapshotAccessed = true;
|
|
3144
|
-
}
|
|
3145
|
-
}
|
|
3146
|
-
read() {
|
|
3147
|
-
const ctx = getReplayContext();
|
|
3148
|
-
if (!ctx?.dbBranchLease) {
|
|
3149
|
-
return null;
|
|
3150
|
-
}
|
|
3151
|
-
const traceId = ctx.sourceBitfabTraceId ?? ctx.inputSourceTraceId;
|
|
3152
|
-
if (!traceId) {
|
|
3153
|
-
return null;
|
|
3154
|
-
}
|
|
3155
|
-
const lease = ctx.dbBranchLease;
|
|
3156
|
-
return {
|
|
3157
|
-
databaseUrl: lease.databaseUrl,
|
|
3158
|
-
expiresAt: lease.expiresAt,
|
|
3159
|
-
providerConsoleUrl: lease.providerConsoleUrl,
|
|
3160
|
-
readOnly: lease.readOnly,
|
|
3161
|
-
region: lease.region,
|
|
3162
|
-
traceId
|
|
3163
|
-
};
|
|
3164
|
-
}
|
|
3165
|
-
require() {
|
|
3166
|
-
const snapshot = this.read();
|
|
3167
|
-
if (!snapshot) {
|
|
3168
|
-
throw new Error(
|
|
3169
|
-
"ReplayEnvironment accessed outside of a replay item. Pass it to bitfab.replay({ environment }) and only read it inside the replayed function."
|
|
3170
|
-
);
|
|
3171
|
-
}
|
|
3172
|
-
return snapshot;
|
|
3118
|
+
get databaseUrl() {
|
|
3119
|
+
__privateGet(this, _context).dbSnapshotAccessed = true;
|
|
3120
|
+
return __privateGet(this, _url);
|
|
3173
3121
|
}
|
|
3174
3122
|
};
|
|
3123
|
+
_url = new WeakMap();
|
|
3124
|
+
_context = new WeakMap();
|
|
3175
3125
|
|
|
3176
3126
|
// src/client.ts
|
|
3127
|
+
init_replayContext();
|
|
3177
3128
|
init_serialize();
|
|
3178
3129
|
|
|
3179
3130
|
// src/tracing.ts
|
|
@@ -3770,6 +3721,17 @@ function getCurrentSpan() {
|
|
|
3770
3721
|
}
|
|
3771
3722
|
};
|
|
3772
3723
|
}
|
|
3724
|
+
function getCurrentReplayBranch() {
|
|
3725
|
+
const ctx = getReplayContext();
|
|
3726
|
+
if (!ctx?.dbBranchLease) {
|
|
3727
|
+
return null;
|
|
3728
|
+
}
|
|
3729
|
+
const traceId = ctx.sourceBitfabTraceId ?? ctx.inputSourceTraceId;
|
|
3730
|
+
if (!traceId) {
|
|
3731
|
+
return null;
|
|
3732
|
+
}
|
|
3733
|
+
return new ReplayBranch(ctx.dbBranchLease, traceId, ctx);
|
|
3734
|
+
}
|
|
3773
3735
|
function getCurrentTrace() {
|
|
3774
3736
|
const stack = getSpanStack();
|
|
3775
3737
|
const current = stack[stack.length - 1];
|
|
@@ -4844,12 +4806,6 @@ var Bitfab = class {
|
|
|
4844
4806
|
);
|
|
4845
4807
|
}
|
|
4846
4808
|
};
|
|
4847
|
-
/**
|
|
4848
|
-
* Per-trace environment for `replay({ environment })`. Construct one,
|
|
4849
|
-
* pass it to replay, and read `env.databaseUrl` inside the replayed
|
|
4850
|
-
* function to pick up the per-trace branch URL.
|
|
4851
|
-
*/
|
|
4852
|
-
Bitfab.ReplayEnvironment = ReplayEnvironment;
|
|
4853
4809
|
var BitfabFunction = class {
|
|
4854
4810
|
constructor(client, traceFunctionKey) {
|
|
4855
4811
|
this.client = client;
|
|
@@ -5061,11 +5017,11 @@ assertAsyncStorageRegistered();
|
|
|
5061
5017
|
BitfabOpenAITracingProcessor,
|
|
5062
5018
|
BitfabVercelAiHandler,
|
|
5063
5019
|
DEFAULT_SERVICE_URL,
|
|
5064
|
-
ReplayEnvironment,
|
|
5065
5020
|
SUPPORTED_PROVIDERS,
|
|
5066
5021
|
__version__,
|
|
5067
5022
|
finalizers,
|
|
5068
5023
|
flushTraces,
|
|
5024
|
+
getCurrentReplayBranch,
|
|
5069
5025
|
getCurrentSpan,
|
|
5070
5026
|
getCurrentTrace,
|
|
5071
5027
|
reportReplayProgress
|