@bitfab/sdk 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/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) {
|
|
@@ -531,11 +538,11 @@ __export(replay_exports, {
|
|
|
531
538
|
replay: () => replay,
|
|
532
539
|
reportReplayProgress: () => reportReplayProgress
|
|
533
540
|
});
|
|
534
|
-
function resolveDbBranchSettings(
|
|
535
|
-
if (!
|
|
541
|
+
function resolveDbBranchSettings(dbBranch) {
|
|
542
|
+
if (!dbBranch) {
|
|
536
543
|
return void 0;
|
|
537
544
|
}
|
|
538
|
-
const { minCu, maxCu, warmupSql } =
|
|
545
|
+
const { minCu, maxCu, warmupSql } = dbBranch;
|
|
539
546
|
const settings = {
|
|
540
547
|
...minCu === void 0 ? {} : { minCu },
|
|
541
548
|
...maxCu === void 0 ? {} : { maxCu },
|
|
@@ -603,9 +610,9 @@ function buildMockTree(rootNode) {
|
|
|
603
610
|
}
|
|
604
611
|
return { spans };
|
|
605
612
|
}
|
|
606
|
-
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId,
|
|
607
|
-
const lease =
|
|
608
|
-
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;
|
|
609
616
|
let inputs = [];
|
|
610
617
|
let originalOutput;
|
|
611
618
|
let result;
|
|
@@ -788,12 +795,12 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
788
795
|
options?.name,
|
|
789
796
|
codeChangeDescription,
|
|
790
797
|
codeChangeFiles,
|
|
791
|
-
options?.
|
|
798
|
+
options?.dbBranch !== void 0,
|
|
792
799
|
// includeDbBranchLease
|
|
793
800
|
options?.experimentGroupId,
|
|
794
801
|
options?.datasetId,
|
|
795
802
|
options?.graderIds,
|
|
796
|
-
resolveDbBranchSettings(options?.
|
|
803
|
+
resolveDbBranchSettings(options?.dbBranch)
|
|
797
804
|
);
|
|
798
805
|
const mockStrategy = options?.mock ?? "marked";
|
|
799
806
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
@@ -811,7 +818,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
811
818
|
mockStrategy,
|
|
812
819
|
resolvedOverrides,
|
|
813
820
|
replayedTraceIds[index],
|
|
814
|
-
options?.
|
|
821
|
+
options?.dbBranch !== void 0,
|
|
815
822
|
options?.adaptInputs
|
|
816
823
|
)
|
|
817
824
|
);
|
|
@@ -968,11 +975,11 @@ __export(node_exports, {
|
|
|
968
975
|
BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
|
|
969
976
|
BitfabVercelAiHandler: () => BitfabVercelAiHandler,
|
|
970
977
|
DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
|
|
971
|
-
ReplayEnvironment: () => ReplayEnvironment,
|
|
972
978
|
SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
|
|
973
979
|
__version__: () => __version__,
|
|
974
980
|
finalizers: () => finalizers,
|
|
975
981
|
flushTraces: () => flushTraces,
|
|
982
|
+
getCurrentReplayBranch: () => getCurrentReplayBranch,
|
|
976
983
|
getCurrentSpan: () => getCurrentSpan,
|
|
977
984
|
getCurrentTrace: () => getCurrentTrace,
|
|
978
985
|
reportReplayProgress: () => reportReplayProgress
|
|
@@ -987,7 +994,7 @@ registerAsyncLocalStorageClass(
|
|
|
987
994
|
);
|
|
988
995
|
|
|
989
996
|
// src/version.generated.ts
|
|
990
|
-
var __version__ = "0.
|
|
997
|
+
var __version__ = "0.33.0";
|
|
991
998
|
|
|
992
999
|
// src/constants.ts
|
|
993
1000
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1790,7 +1797,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1790
1797
|
}
|
|
1791
1798
|
}
|
|
1792
1799
|
// ── hook callbacks ───────────────────────────────────────────
|
|
1793
|
-
async preToolUseHook(inputData, toolUseId,
|
|
1800
|
+
async preToolUseHook(inputData, toolUseId, _context2) {
|
|
1794
1801
|
try {
|
|
1795
1802
|
const sid = inputData.tool_use_id ?? toolUseId ?? randomUuid();
|
|
1796
1803
|
const toolName = inputData.tool_name ?? "tool";
|
|
@@ -1802,7 +1809,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1802
1809
|
}
|
|
1803
1810
|
return {};
|
|
1804
1811
|
}
|
|
1805
|
-
async postToolUseHook(inputData, toolUseId,
|
|
1812
|
+
async postToolUseHook(inputData, toolUseId, _context2) {
|
|
1806
1813
|
try {
|
|
1807
1814
|
const sid = inputData.tool_use_id ?? toolUseId ?? "";
|
|
1808
1815
|
const toolResponse = inputData.tool_response;
|
|
@@ -1811,7 +1818,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1811
1818
|
}
|
|
1812
1819
|
return {};
|
|
1813
1820
|
}
|
|
1814
|
-
async postToolUseFailureHook(inputData, toolUseId,
|
|
1821
|
+
async postToolUseFailureHook(inputData, toolUseId, _context2) {
|
|
1815
1822
|
try {
|
|
1816
1823
|
const sid = inputData.tool_use_id ?? toolUseId ?? "";
|
|
1817
1824
|
const error = String(inputData.error ?? "Unknown error");
|
|
@@ -1820,7 +1827,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1820
1827
|
}
|
|
1821
1828
|
return {};
|
|
1822
1829
|
}
|
|
1823
|
-
async subagentStartHook(inputData, _toolUseId,
|
|
1830
|
+
async subagentStartHook(inputData, _toolUseId, _context2) {
|
|
1824
1831
|
try {
|
|
1825
1832
|
const agentId = inputData.agent_id ?? randomUuid();
|
|
1826
1833
|
const agentType = inputData.agent_type ?? "subagent";
|
|
@@ -1838,7 +1845,7 @@ var BitfabClaudeAgentHandler = class {
|
|
|
1838
1845
|
}
|
|
1839
1846
|
return {};
|
|
1840
1847
|
}
|
|
1841
|
-
async subagentStopHook(inputData, _toolUseId,
|
|
1848
|
+
async subagentStopHook(inputData, _toolUseId, _context2) {
|
|
1842
1849
|
try {
|
|
1843
1850
|
const agentId = inputData.agent_id ?? "";
|
|
1844
1851
|
const spanId = this.activeSubagentSpans.get(agentId);
|
|
@@ -3078,106 +3085,46 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
3078
3085
|
|
|
3079
3086
|
// src/client.ts
|
|
3080
3087
|
init_randomUuid();
|
|
3081
|
-
init_replayContext();
|
|
3082
3088
|
|
|
3083
|
-
// src/
|
|
3084
|
-
|
|
3085
|
-
var
|
|
3086
|
-
|
|
3087
|
-
|
|
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);
|
|
3088
3106
|
}
|
|
3089
3107
|
/**
|
|
3090
|
-
*
|
|
3091
|
-
*
|
|
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.
|
|
3092
3117
|
*/
|
|
3093
3118
|
get databaseUrl() {
|
|
3094
|
-
|
|
3095
|
-
this
|
|
3096
|
-
return snapshot.databaseUrl;
|
|
3097
|
-
}
|
|
3098
|
-
/** When the per-trace branch URL stops being valid. ISO-8601. */
|
|
3099
|
-
get expiresAt() {
|
|
3100
|
-
return this.require().expiresAt;
|
|
3101
|
-
}
|
|
3102
|
-
/** Deep link to the branch in the provider console, if available. */
|
|
3103
|
-
get providerConsoleUrl() {
|
|
3104
|
-
return this.require().providerConsoleUrl;
|
|
3105
|
-
}
|
|
3106
|
-
/**
|
|
3107
|
-
* True if the branch is read-only. Customer code can use this to skip
|
|
3108
|
-
* write operations during replay when the provider returned a read-only
|
|
3109
|
-
* lease.
|
|
3110
|
-
*/
|
|
3111
|
-
get readOnly() {
|
|
3112
|
-
return this.require().readOnly;
|
|
3113
|
-
}
|
|
3114
|
-
/**
|
|
3115
|
-
* The branch's region, e.g. `aws-us-east-1`. A compute runs in its project's
|
|
3116
|
-
* region, so a replay runner elsewhere pays that round trip on every query.
|
|
3117
|
-
*/
|
|
3118
|
-
get region() {
|
|
3119
|
-
return this.require().region;
|
|
3120
|
-
}
|
|
3121
|
-
/** The historical trace ID that produced the input for this replay item. */
|
|
3122
|
-
get traceId() {
|
|
3123
|
-
return this.require().traceId;
|
|
3124
|
-
}
|
|
3125
|
-
/** True when read inside a replay item that has a resolved branch. */
|
|
3126
|
-
get active() {
|
|
3127
|
-
return this.read() !== null;
|
|
3128
|
-
}
|
|
3129
|
-
/** Non-throwing variant for callers that handle the inactive case. */
|
|
3130
|
-
snapshot() {
|
|
3131
|
-
const snapshot = this.read();
|
|
3132
|
-
if (snapshot) {
|
|
3133
|
-
this.markAccessed();
|
|
3134
|
-
}
|
|
3135
|
-
return snapshot;
|
|
3136
|
-
}
|
|
3137
|
-
/**
|
|
3138
|
-
* Record on the replay context that customer code obtained the branch
|
|
3139
|
-
* URL. Only `databaseUrl` and `snapshot()` count - `active`, `readOnly`
|
|
3140
|
-
* and friends inspect the lease without exposing the connection string,
|
|
3141
|
-
* so they don't prove the replayed code could have connected to the
|
|
3142
|
-
* branch.
|
|
3143
|
-
*/
|
|
3144
|
-
markAccessed() {
|
|
3145
|
-
const ctx = getReplayContext();
|
|
3146
|
-
if (ctx?.dbBranchLease) {
|
|
3147
|
-
ctx.dbSnapshotAccessed = true;
|
|
3148
|
-
}
|
|
3149
|
-
}
|
|
3150
|
-
read() {
|
|
3151
|
-
const ctx = getReplayContext();
|
|
3152
|
-
if (!ctx?.dbBranchLease) {
|
|
3153
|
-
return null;
|
|
3154
|
-
}
|
|
3155
|
-
const traceId = ctx.sourceBitfabTraceId ?? ctx.inputSourceTraceId;
|
|
3156
|
-
if (!traceId) {
|
|
3157
|
-
return null;
|
|
3158
|
-
}
|
|
3159
|
-
const lease = ctx.dbBranchLease;
|
|
3160
|
-
return {
|
|
3161
|
-
databaseUrl: lease.databaseUrl,
|
|
3162
|
-
expiresAt: lease.expiresAt,
|
|
3163
|
-
providerConsoleUrl: lease.providerConsoleUrl,
|
|
3164
|
-
readOnly: lease.readOnly,
|
|
3165
|
-
region: lease.region,
|
|
3166
|
-
traceId
|
|
3167
|
-
};
|
|
3168
|
-
}
|
|
3169
|
-
require() {
|
|
3170
|
-
const snapshot = this.read();
|
|
3171
|
-
if (!snapshot) {
|
|
3172
|
-
throw new Error(
|
|
3173
|
-
"ReplayEnvironment accessed outside of a replay item. Pass it to bitfab.replay({ environment }) and only read it inside the replayed function."
|
|
3174
|
-
);
|
|
3175
|
-
}
|
|
3176
|
-
return snapshot;
|
|
3119
|
+
__privateGet(this, _context).dbSnapshotAccessed = true;
|
|
3120
|
+
return __privateGet(this, _url);
|
|
3177
3121
|
}
|
|
3178
3122
|
};
|
|
3123
|
+
_url = new WeakMap();
|
|
3124
|
+
_context = new WeakMap();
|
|
3179
3125
|
|
|
3180
3126
|
// src/client.ts
|
|
3127
|
+
init_replayContext();
|
|
3181
3128
|
init_serialize();
|
|
3182
3129
|
|
|
3183
3130
|
// src/tracing.ts
|
|
@@ -3774,6 +3721,17 @@ function getCurrentSpan() {
|
|
|
3774
3721
|
}
|
|
3775
3722
|
};
|
|
3776
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
|
+
}
|
|
3777
3735
|
function getCurrentTrace() {
|
|
3778
3736
|
const stack = getSpanStack();
|
|
3779
3737
|
const current = stack[stack.length - 1];
|
|
@@ -4848,12 +4806,6 @@ var Bitfab = class {
|
|
|
4848
4806
|
);
|
|
4849
4807
|
}
|
|
4850
4808
|
};
|
|
4851
|
-
/**
|
|
4852
|
-
* Per-trace environment for `replay({ environment })`. Construct one,
|
|
4853
|
-
* pass it to replay, and read `env.databaseUrl` inside the replayed
|
|
4854
|
-
* function to pick up the per-trace branch URL.
|
|
4855
|
-
*/
|
|
4856
|
-
Bitfab.ReplayEnvironment = ReplayEnvironment;
|
|
4857
4809
|
var BitfabFunction = class {
|
|
4858
4810
|
constructor(client, traceFunctionKey) {
|
|
4859
4811
|
this.client = client;
|
|
@@ -5065,11 +5017,11 @@ assertAsyncStorageRegistered();
|
|
|
5065
5017
|
BitfabOpenAITracingProcessor,
|
|
5066
5018
|
BitfabVercelAiHandler,
|
|
5067
5019
|
DEFAULT_SERVICE_URL,
|
|
5068
|
-
ReplayEnvironment,
|
|
5069
5020
|
SUPPORTED_PROVIDERS,
|
|
5070
5021
|
__version__,
|
|
5071
5022
|
finalizers,
|
|
5072
5023
|
flushTraces,
|
|
5024
|
+
getCurrentReplayBranch,
|
|
5073
5025
|
getCurrentSpan,
|
|
5074
5026
|
getCurrentTrace,
|
|
5075
5027
|
reportReplayProgress
|