@bitfab/sdk 0.65.4 → 0.65.6
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/autoTrace-CQw0qMBt.cjs +396 -0
- package/dist/autoTrace-CQw0qMBt.cjs.map +1 -0
- package/dist/autoTrace-O40k8f5M.js +271 -0
- package/dist/autoTrace-O40k8f5M.js.map +1 -0
- package/dist/autoTrace.cjs +15 -353
- package/dist/autoTrace.d.cts +48 -44
- package/dist/autoTrace.d.ts +48 -44
- package/dist/autoTrace.js +1 -28
- package/dist/babelPlugin-C70OxrqA.js +209 -0
- package/dist/babelPlugin-C70OxrqA.js.map +1 -0
- package/dist/babelPlugin-Nta4-VcL.cjs +232 -0
- package/dist/babelPlugin-Nta4-VcL.cjs.map +1 -0
- package/dist/http-lnqCEnB1.js +2154 -0
- package/dist/http-lnqCEnB1.js.map +1 -0
- package/dist/index-CFOLQ1IF.d.cts +4410 -0
- package/dist/index-CFOLQ1IF.d.ts +4410 -0
- package/dist/index.cjs +48 -12504
- package/dist/index.d.cts +2 -4443
- package/dist/index.d.ts +2 -4443
- package/dist/index.js +3 -96
- package/dist/loaderRuntime-0huddOOP.d.ts +12 -0
- package/dist/loaderRuntime-CslfDFO7.d.cts +12 -0
- package/dist/node.cjs +56 -12520
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +2 -1
- package/dist/node.d.ts +2 -1
- package/dist/node.js +10 -105
- package/dist/node.js.map +1 -1
- package/dist/registryCommand-Di8x0YoJ.js +1111 -0
- package/dist/registryCommand-Di8x0YoJ.js.map +1 -0
- package/dist/replayCli.js +49 -87
- package/dist/replayCli.js.map +1 -1
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/seedCli.js +10 -24
- package/dist/seedCli.js.map +1 -1
- package/dist/src-BungStQw.js +6015 -0
- package/dist/src-BungStQw.js.map +1 -0
- package/dist/src-FFSCRXpz.cjs +8438 -0
- package/dist/src-FFSCRXpz.cjs.map +1 -0
- package/dist/transform/babel.cjs +5 -422
- package/dist/transform/babel.d.cts +16 -16
- package/dist/transform/babel.d.ts +16 -16
- package/dist/transform/babel.js +1 -7
- package/dist/transform/bun.cjs +9 -478
- package/dist/transform/bun.cjs.map +1 -1
- package/dist/transform/bun.d.cts +5 -7
- package/dist/transform/bun.d.ts +5 -7
- package/dist/transform/bun.js +6 -11
- package/dist/transform/bun.js.map +1 -1
- package/dist/transform/esbuild.cjs +9 -478
- package/dist/transform/esbuild.cjs.map +1 -1
- package/dist/transform/esbuild.d.cts +5 -7
- package/dist/transform/esbuild.d.ts +5 -7
- package/dist/transform/esbuild.js +6 -11
- package/dist/transform/esbuild.js.map +1 -1
- package/dist/transform/loaderRuntime.cjs +85 -532
- package/dist/transform/loaderRuntime.cjs.map +1 -1
- package/dist/transform/loaderRuntime.d.cts +2 -12
- package/dist/transform/loaderRuntime.d.ts +2 -12
- package/dist/transform/loaderRuntime.js +56 -98
- package/dist/transform/loaderRuntime.js.map +1 -1
- package/dist/transform/nest.cjs +12 -481
- package/dist/transform/nest.cjs.map +1 -1
- package/dist/transform/nest.d.cts +8 -9
- package/dist/transform/nest.d.ts +8 -9
- package/dist/transform/nest.js +9 -14
- package/dist/transform/nest.js.map +1 -1
- package/dist/transform/next.cjs +56 -528
- package/dist/transform/next.cjs.map +1 -1
- package/dist/transform/next.d.cts +25 -25
- package/dist/transform/next.d.ts +24 -24
- package/dist/transform/next.js +52 -60
- package/dist/transform/next.js.map +1 -1
- package/dist/transform/nodeLoader.js +260 -506
- package/dist/transform/nodeLoader.js.map +1 -1
- package/dist/transform/register.js +4 -1
- package/dist/transform/register.js.map +1 -1
- package/dist/transform/rolldown.cjs +9 -478
- package/dist/transform/rolldown.cjs.map +1 -1
- package/dist/transform/rolldown.d.cts +5 -7
- package/dist/transform/rolldown.d.ts +5 -7
- package/dist/transform/rolldown.js +6 -11
- package/dist/transform/rolldown.js.map +1 -1
- package/dist/transform/rollup.cjs +9 -478
- package/dist/transform/rollup.cjs.map +1 -1
- package/dist/transform/rollup.d.cts +5 -7
- package/dist/transform/rollup.d.ts +5 -7
- package/dist/transform/rollup.js +6 -11
- package/dist/transform/rollup.js.map +1 -1
- package/dist/transform/rsbuild.cjs +9 -478
- package/dist/transform/rsbuild.cjs.map +1 -1
- package/dist/transform/rsbuild.d.cts +5 -7
- package/dist/transform/rsbuild.d.ts +5 -7
- package/dist/transform/rsbuild.js +6 -11
- package/dist/transform/rsbuild.js.map +1 -1
- package/dist/transform/rspack.cjs +9 -478
- package/dist/transform/rspack.cjs.map +1 -1
- package/dist/transform/rspack.d.cts +5 -7
- package/dist/transform/rspack.d.ts +5 -7
- package/dist/transform/rspack.js +6 -11
- package/dist/transform/rspack.js.map +1 -1
- package/dist/transform/swc.cjs +18 -486
- package/dist/transform/swc.cjs.map +1 -1
- package/dist/transform/swc.d.cts +15 -14
- package/dist/transform/swc.d.ts +15 -14
- package/dist/transform/swc.js +14 -32
- package/dist/transform/swc.js.map +1 -1
- package/dist/transform/unplugin.cjs +20 -476
- package/dist/transform/unplugin.cjs.map +1 -1
- package/dist/transform/unplugin.d.cts +4 -6
- package/dist/transform/unplugin.d.ts +4 -6
- package/dist/transform/unplugin.js +19 -8
- package/dist/transform/unplugin.js.map +1 -1
- package/dist/transform/vite.cjs +9 -478
- package/dist/transform/vite.cjs.map +1 -1
- package/dist/transform/vite.d.cts +5 -7
- package/dist/transform/vite.d.ts +5 -7
- package/dist/transform/vite.js +6 -11
- package/dist/transform/vite.js.map +1 -1
- package/dist/transform/webpack.cjs +9 -478
- package/dist/transform/webpack.cjs.map +1 -1
- package/dist/transform/webpack.d.cts +5 -7
- package/dist/transform/webpack.d.ts +5 -7
- package/dist/transform/webpack.js +6 -11
- package/dist/transform/webpack.js.map +1 -1
- package/dist/transform-BcyUocwm.js +36 -0
- package/dist/transform-BcyUocwm.js.map +1 -0
- package/dist/transform-BjxHGGKc.cjs +47 -0
- package/dist/transform-BjxHGGKc.cjs.map +1 -0
- package/dist/transformOptions-BsjCELkh.d.cts +11 -0
- package/dist/transformOptions-BsjCELkh.d.ts +11 -0
- package/package.json +5 -5
- package/dist/autoTrace.cjs.map +0 -1
- package/dist/autoTrace.js.map +0 -1
- package/dist/chunk-27B3UBSS.js +0 -2547
- package/dist/chunk-27B3UBSS.js.map +0 -1
- package/dist/chunk-B2M4KELA.js +0 -1912
- package/dist/chunk-B2M4KELA.js.map +0 -1
- package/dist/chunk-I233ERUH.js +0 -2979
- package/dist/chunk-I233ERUH.js.map +0 -1
- package/dist/chunk-ISU6FQKY.js +0 -6877
- package/dist/chunk-ISU6FQKY.js.map +0 -1
- package/dist/chunk-MT36GJMW.js +0 -106
- package/dist/chunk-MT36GJMW.js.map +0 -1
- package/dist/chunk-PTCLRG4E.js +0 -28
- package/dist/chunk-PTCLRG4E.js.map +0 -1
- package/dist/chunk-QRNHRY7F.js +0 -270
- package/dist/chunk-QRNHRY7F.js.map +0 -1
- package/dist/chunk-R6M54SPO.js +0 -1176
- package/dist/chunk-R6M54SPO.js.map +0 -1
- package/dist/chunk-SOP5AFMH.js +0 -2060
- package/dist/chunk-SOP5AFMH.js.map +0 -1
- package/dist/chunk-YVJAOGHE.js +0 -45
- package/dist/chunk-YVJAOGHE.js.map +0 -1
- package/dist/chunk-ZG6SHKEF.js +0 -404
- package/dist/chunk-ZG6SHKEF.js.map +0 -1
- package/dist/http-LL3JD2JE.js +0 -24
- package/dist/http-LL3JD2JE.js.map +0 -1
- package/dist/http-QZDTQC3C.js +0 -23
- package/dist/http-QZDTQC3C.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/replay-636XZIS2.js +0 -29
- package/dist/replay-636XZIS2.js.map +0 -1
- package/dist/replay-S4DNF4VR.js +0 -28
- package/dist/replay-S4DNF4VR.js.map +0 -1
- package/dist/transform/babel.cjs.map +0 -1
- package/dist/transform/babel.js.map +0 -1
- package/dist/transformOptions-Df2_Chtc.d.cts +0 -10
- package/dist/transformOptions-Df2_Chtc.d.ts +0 -10
package/dist/autoTrace.cjs
CHANGED
|
@@ -1,354 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/autoTrace.ts
|
|
21
|
-
var autoTrace_exports = {};
|
|
22
|
-
__export(autoTrace_exports, {
|
|
23
|
-
__bitfabAutoSpan: () => __bitfabAutoSpan,
|
|
24
|
-
__bitfabAutoTraceActive: () => __bitfabAutoTraceActive,
|
|
25
|
-
__bitfabAutoWrap: () => __bitfabAutoWrap,
|
|
26
|
-
_resetAutoTraceTransformDetection: () => _resetAutoTraceTransformDetection,
|
|
27
|
-
clearAutoTraceNodeConfiguration: () => clearAutoTraceNodeConfiguration,
|
|
28
|
-
currentAutoTraceEntries: () => currentAutoTraceEntries,
|
|
29
|
-
invokeThroughAutoTraceEntries: () => invokeThroughAutoTraceEntries,
|
|
30
|
-
runAsAutoTraceRootFunction: () => runAsAutoTraceRootFunction,
|
|
31
|
-
runWithAutoTraceEntry: () => runWithAutoTraceEntry,
|
|
32
|
-
runWithAutoTraceNodeConfiguration: () => runWithAutoTraceNodeConfiguration,
|
|
33
|
-
runWithAutoTraceRootContext: () => runWithAutoTraceRootContext
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
34
4
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// The join trick hides "node:async_hooks" from static analysis so
|
|
48
|
-
// bundlers that ban Node.js built-ins don't fail at build time.
|
|
49
|
-
// webpackIgnore tells webpack/turbopack to emit a native import()
|
|
50
|
-
// so Node.js can resolve the module at runtime.
|
|
51
|
-
import(
|
|
52
|
-
/* webpackIgnore: true */
|
|
53
|
-
["node", "async_hooks"].join(":")
|
|
54
|
-
).then(
|
|
55
|
-
(mod) => {
|
|
56
|
-
registerAsyncLocalStorageClass(mod.AsyncLocalStorage);
|
|
57
|
-
}
|
|
58
|
-
).catch(() => {
|
|
59
|
-
})
|
|
60
|
-
) : Promise.resolve()).then(() => {
|
|
61
|
-
initDone = true;
|
|
62
|
-
});
|
|
63
|
-
function createAsyncLocalStorage() {
|
|
64
|
-
return AsyncLocalStorageClass ? new AsyncLocalStorageClass() : null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// src/captureSuppression.ts
|
|
68
|
-
var suppressionGlobal = globalThis;
|
|
69
|
-
var suppressionState = suppressionGlobal.__bitfabCaptureSuppressionV1 ?? { depth: 0 };
|
|
70
|
-
suppressionGlobal.__bitfabCaptureSuppressionV1 = suppressionState;
|
|
71
|
-
function isCaptureSuppressed() {
|
|
72
|
-
return suppressionState.depth > 0;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// src/warnOnce.ts
|
|
76
|
-
var warned = /* @__PURE__ */ new Set();
|
|
77
|
-
function warn(message) {
|
|
78
|
-
try {
|
|
79
|
-
console.warn(`[bitfab] ${message}`);
|
|
80
|
-
} catch {
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function warnOnce(key, message) {
|
|
84
|
-
if (warned.has(key)) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
warned.add(key);
|
|
88
|
-
warn(message);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// src/autoTrace.ts
|
|
92
|
-
var autoTraceGlobal = globalThis;
|
|
93
|
-
var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {
|
|
94
|
-
storage: null,
|
|
95
|
-
browserScope: void 0,
|
|
96
|
-
capturePolicies: /* @__PURE__ */ new WeakMap(),
|
|
97
|
-
activeRoots: 0
|
|
98
|
-
};
|
|
99
|
-
autoTraceGlobal.__bitfabAutoTraceStateV4 = autoTraceState;
|
|
100
|
-
function initializeAutoTraceStorage() {
|
|
101
|
-
autoTraceState.storage ?? (autoTraceState.storage = createAsyncLocalStorage());
|
|
102
|
-
}
|
|
103
|
-
function runWithAutoTraceScope(scope, fn) {
|
|
104
|
-
initializeAutoTraceStorage();
|
|
105
|
-
if (autoTraceState.storage) {
|
|
106
|
-
return autoTraceState.storage.run(scope, fn);
|
|
107
|
-
}
|
|
108
|
-
const previous = autoTraceState.browserScope;
|
|
109
|
-
autoTraceState.browserScope = scope;
|
|
110
|
-
try {
|
|
111
|
-
return fn();
|
|
112
|
-
} finally {
|
|
113
|
-
autoTraceState.browserScope = previous;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function currentAutoTraceEntries() {
|
|
117
|
-
return currentAutoTraceScope()?.entries ?? [];
|
|
118
|
-
}
|
|
119
|
-
function replaceEntry(entries, previous, updated) {
|
|
120
|
-
return entries.map((entry) => entry === previous ? updated : entry);
|
|
121
|
-
}
|
|
122
|
-
function runWithAutoTraceEntry(previous, updated, fn) {
|
|
123
|
-
const result = runWithAutoTraceScope(
|
|
124
|
-
{ entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },
|
|
125
|
-
fn
|
|
126
|
-
);
|
|
127
|
-
if (isAutoTraceAsyncGenerator(result)) {
|
|
128
|
-
return wrapAutoTraceEntryAsyncGenerator(previous, updated, result);
|
|
129
|
-
}
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
132
|
-
function wrapAutoTraceEntryAsyncGenerator(previous, updated, source) {
|
|
133
|
-
const step = (method, value) => runWithAutoTraceScope(
|
|
134
|
-
{ entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },
|
|
135
|
-
() => source[method](value)
|
|
136
|
-
);
|
|
137
|
-
const wrapped = {
|
|
138
|
-
next: (value) => step("next", value),
|
|
139
|
-
return: (value) => step("return", value),
|
|
140
|
-
throw: (error) => step("throw", error),
|
|
141
|
-
[Symbol.asyncIterator]: () => wrapped
|
|
142
|
-
};
|
|
143
|
-
return wrapped;
|
|
144
|
-
}
|
|
145
|
-
function clearAutoTraceNodeConfiguration(fn) {
|
|
146
|
-
return runWithAutoTraceScope({ entries: currentAutoTraceEntries() }, fn);
|
|
147
|
-
}
|
|
148
|
-
function runWithAutoTraceNodeConfiguration(nodeConfiguration, fn) {
|
|
149
|
-
const scope = currentAutoTraceScope();
|
|
150
|
-
if (!scope || scope.entries.length === 0) {
|
|
151
|
-
return fn();
|
|
152
|
-
}
|
|
153
|
-
const result = runWithAutoTraceScope({ ...scope, nodeConfiguration }, fn);
|
|
154
|
-
if (isAutoTraceAsyncGenerator(result)) {
|
|
155
|
-
return wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, result);
|
|
156
|
-
}
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
function runAsAutoTraceRootFunction(functionName, fn) {
|
|
160
|
-
const scope = currentAutoTraceScope();
|
|
161
|
-
if (!scope || scope.entries.length === 0 || functionName === "") {
|
|
162
|
-
return fn();
|
|
163
|
-
}
|
|
164
|
-
const rootFunction = {
|
|
165
|
-
name: functionName,
|
|
166
|
-
entering: true
|
|
167
|
-
};
|
|
168
|
-
try {
|
|
169
|
-
return runWithAutoTraceScope({ ...scope, rootFunction }, fn);
|
|
170
|
-
} finally {
|
|
171
|
-
rootFunction.entering = false;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function isRootFunctionEntry(scope, simpleName) {
|
|
175
|
-
const rootFunction = scope.rootFunction;
|
|
176
|
-
if (rootFunction === void 0 || !rootFunction.entering) {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
rootFunction.entering = false;
|
|
180
|
-
return rootFunction.name === simpleName;
|
|
181
|
-
}
|
|
182
|
-
var SUBTREE_TRACING_DOCS_URL = "https://docs.bitfab.ai/typescript-sdk#experimental-subtree-tracing";
|
|
183
|
-
function noteTransformedModule() {
|
|
184
|
-
autoTraceGlobal.__bitfab_auto_trace_transformed_v1__ = true;
|
|
185
|
-
}
|
|
186
|
-
function transformInstalled() {
|
|
187
|
-
return autoTraceGlobal.__bitfab_auto_trace_transformed_v1__ === true;
|
|
188
|
-
}
|
|
189
|
-
function runsOnNode() {
|
|
190
|
-
return typeof process !== "undefined" && Boolean(process.versions?.node);
|
|
191
|
-
}
|
|
192
|
-
function closeAutoTraceRoot() {
|
|
193
|
-
autoTraceState.activeRoots -= 1;
|
|
194
|
-
}
|
|
195
|
-
function settleAutoTraceRoot(context) {
|
|
196
|
-
closeAutoTraceRoot();
|
|
197
|
-
if (transformInstalled() || !runsOnNode()) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
warnOnce(
|
|
201
|
-
"auto-trace-transform-missing",
|
|
202
|
-
`trace root "${context.traceFunctionKey}" recorded only its own span. No module in this build was compiled by @bitfab/sdk/transform, so calls beneath the root were not discovered. Add the SDK's transform adapter to the server build: ${SUBTREE_TRACING_DOCS_URL}`
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
function runWithAutoTraceRootContext(context, spanStack, fn) {
|
|
206
|
-
autoTraceState.activeRoots += 1;
|
|
207
|
-
const entries = [
|
|
208
|
-
...currentAutoTraceEntries(),
|
|
209
|
-
{ context, depth: 0, spanStack }
|
|
210
|
-
];
|
|
211
|
-
let result;
|
|
212
|
-
try {
|
|
213
|
-
result = runWithAutoTraceScope({ entries }, fn);
|
|
214
|
-
} catch (error) {
|
|
215
|
-
settleAutoTraceRoot(context);
|
|
216
|
-
throw error;
|
|
217
|
-
}
|
|
218
|
-
if (isAutoTraceAsyncGenerator(result)) {
|
|
219
|
-
closeAutoTraceRoot();
|
|
220
|
-
return wrapAutoTraceAsyncGenerator(context, spanStack, result);
|
|
221
|
-
}
|
|
222
|
-
if (result instanceof Promise) {
|
|
223
|
-
return result.finally(() => {
|
|
224
|
-
settleAutoTraceRoot(context);
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
settleAutoTraceRoot(context);
|
|
228
|
-
return result;
|
|
229
|
-
}
|
|
230
|
-
function invokeThroughAutoTraceEntries(entries, step, fn) {
|
|
231
|
-
let run = fn;
|
|
232
|
-
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
233
|
-
const entry = entries[index];
|
|
234
|
-
const next = run;
|
|
235
|
-
run = () => step(entry, next);
|
|
236
|
-
}
|
|
237
|
-
return run();
|
|
238
|
-
}
|
|
239
|
-
function isAutoTraceAsyncGenerator(value) {
|
|
240
|
-
if (value === null || typeof value !== "object") {
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
const candidate = value;
|
|
244
|
-
return typeof candidate.next === "function" && typeof candidate.return === "function" && typeof candidate.throw === "function" && typeof candidate[Symbol.asyncIterator] === "function";
|
|
245
|
-
}
|
|
246
|
-
function wrapAutoTraceAsyncGenerator(context, spanStack, source) {
|
|
247
|
-
const step = (method, value) => runWithAutoTraceRootContext(context, spanStack, () => source[method](value));
|
|
248
|
-
const wrapped = {
|
|
249
|
-
next: (value) => step("next", value),
|
|
250
|
-
return: (value) => step("return", value),
|
|
251
|
-
throw: (error) => step("throw", error),
|
|
252
|
-
[Symbol.asyncIterator]: () => wrapped
|
|
253
|
-
};
|
|
254
|
-
return wrapped;
|
|
255
|
-
}
|
|
256
|
-
function wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, source) {
|
|
257
|
-
const step = (method, value) => runWithAutoTraceNodeConfiguration(
|
|
258
|
-
nodeConfiguration,
|
|
259
|
-
() => source[method](value)
|
|
260
|
-
);
|
|
261
|
-
const wrapped = {
|
|
262
|
-
next: (value) => step("next", value),
|
|
263
|
-
return: (value) => step("return", value),
|
|
264
|
-
throw: (error) => step("throw", error),
|
|
265
|
-
[Symbol.asyncIterator]: () => wrapped
|
|
266
|
-
};
|
|
267
|
-
return wrapped;
|
|
268
|
-
}
|
|
269
|
-
function shareFinalize(configuration) {
|
|
270
|
-
const finalize = configuration.finalize;
|
|
271
|
-
if (finalize === void 0) {
|
|
272
|
-
return configuration;
|
|
273
|
-
}
|
|
274
|
-
let settled;
|
|
275
|
-
return {
|
|
276
|
-
...configuration,
|
|
277
|
-
finalize: (result) => {
|
|
278
|
-
settled ?? (settled = Promise.resolve().then(() => finalize(result)));
|
|
279
|
-
return settled;
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
function __bitfabAutoSpan(definition, inputs, fn) {
|
|
284
|
-
noteTransformedModule();
|
|
285
|
-
const scope = currentAutoTraceScope();
|
|
286
|
-
if (!scope || scope.entries.length === 0 || isCaptureSuppressed()) {
|
|
287
|
-
return fn();
|
|
288
|
-
}
|
|
289
|
-
const nameParts = definition.name.split(".");
|
|
290
|
-
const simpleName = nameParts[nameParts.length - 1];
|
|
291
|
-
if (isRootFunctionEntry(scope, simpleName)) {
|
|
292
|
-
return fn();
|
|
293
|
-
}
|
|
294
|
-
const nodeConfiguration = simpleName === scope.nodeConfiguration?.functionName ? shareFinalize(scope.nodeConfiguration) : void 0;
|
|
295
|
-
return invokeThroughAutoTraceEntries(
|
|
296
|
-
scope.entries,
|
|
297
|
-
(entry, next) => entry.context.invoke(definition, inputs, next, entry, nodeConfiguration),
|
|
298
|
-
fn
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
function __bitfabAutoWrap(definition, fn) {
|
|
302
|
-
noteTransformedModule();
|
|
303
|
-
if (fn.name === "") {
|
|
304
|
-
const nameParts = definition.name.split(".");
|
|
305
|
-
const inferredName = nameParts[nameParts.length - 1];
|
|
306
|
-
if (inferredName !== void 0) {
|
|
307
|
-
Object.defineProperty(fn, "name", {
|
|
308
|
-
configurable: true,
|
|
309
|
-
value: inferredName
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
const target = fn;
|
|
314
|
-
return new Proxy(target, {
|
|
315
|
-
apply(callTarget, thisArg, args) {
|
|
316
|
-
if (!__bitfabAutoTraceActive()) {
|
|
317
|
-
return Reflect.apply(callTarget, thisArg, args);
|
|
318
|
-
}
|
|
319
|
-
return __bitfabAutoSpan(
|
|
320
|
-
definition,
|
|
321
|
-
args,
|
|
322
|
-
() => Reflect.apply(callTarget, thisArg, args)
|
|
323
|
-
);
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
function __bitfabAutoTraceActive() {
|
|
328
|
-
if (autoTraceState.activeRoots === 0 || isCaptureSuppressed()) {
|
|
329
|
-
return false;
|
|
330
|
-
}
|
|
331
|
-
return currentAutoTraceEntries().length > 0;
|
|
332
|
-
}
|
|
333
|
-
function currentAutoTraceScope() {
|
|
334
|
-
initializeAutoTraceStorage();
|
|
335
|
-
return autoTraceState.storage?.getStore() ?? autoTraceState.browserScope;
|
|
336
|
-
}
|
|
337
|
-
function _resetAutoTraceTransformDetection() {
|
|
338
|
-
autoTraceGlobal.__bitfab_auto_trace_transformed_v1__ = void 0;
|
|
339
|
-
}
|
|
340
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
341
|
-
0 && (module.exports = {
|
|
342
|
-
__bitfabAutoSpan,
|
|
343
|
-
__bitfabAutoTraceActive,
|
|
344
|
-
__bitfabAutoWrap,
|
|
345
|
-
_resetAutoTraceTransformDetection,
|
|
346
|
-
clearAutoTraceNodeConfiguration,
|
|
347
|
-
currentAutoTraceEntries,
|
|
348
|
-
invokeThroughAutoTraceEntries,
|
|
349
|
-
runAsAutoTraceRootFunction,
|
|
350
|
-
runWithAutoTraceEntry,
|
|
351
|
-
runWithAutoTraceNodeConfiguration,
|
|
352
|
-
runWithAutoTraceRootContext
|
|
353
|
-
});
|
|
354
|
-
//# sourceMappingURL=autoTrace.cjs.map
|
|
5
|
+
const require_autoTrace = require("./autoTrace-CQw0qMBt.cjs");
|
|
6
|
+
exports.__bitfabAutoSpan = require_autoTrace.__bitfabAutoSpan;
|
|
7
|
+
exports.__bitfabAutoTraceActive = require_autoTrace.__bitfabAutoTraceActive;
|
|
8
|
+
exports.__bitfabAutoWrap = require_autoTrace.__bitfabAutoWrap;
|
|
9
|
+
exports._resetAutoTraceTransformDetection = require_autoTrace._resetAutoTraceTransformDetection;
|
|
10
|
+
exports.clearAutoTraceNodeConfiguration = require_autoTrace.clearAutoTraceNodeConfiguration;
|
|
11
|
+
exports.currentAutoTraceEntries = require_autoTrace.currentAutoTraceEntries;
|
|
12
|
+
exports.invokeThroughAutoTraceEntries = require_autoTrace.invokeThroughAutoTraceEntries;
|
|
13
|
+
exports.runAsAutoTraceRootFunction = require_autoTrace.runAsAutoTraceRootFunction;
|
|
14
|
+
exports.runWithAutoTraceEntry = require_autoTrace.runWithAutoTraceEntry;
|
|
15
|
+
exports.runWithAutoTraceNodeConfiguration = require_autoTrace.runWithAutoTraceNodeConfiguration;
|
|
16
|
+
exports.runWithAutoTraceRootContext = require_autoTrace.runWithAutoTraceRootContext;
|
package/dist/autoTrace.d.cts
CHANGED
|
@@ -1,47 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
//#region src/autoTrace.d.ts
|
|
2
|
+
export interface AutoTraceFunctionDefinition {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
file: string;
|
|
6
|
+
line: number;
|
|
7
|
+
column: number;
|
|
8
|
+
async?: boolean;
|
|
9
|
+
wrapper?: boolean;
|
|
9
10
|
}
|
|
10
|
-
interface AutoTraceNodeConfiguration {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
export interface AutoTraceNodeConfiguration {
|
|
12
|
+
functionName: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
type?: "llm" | "agent" | "function" | "guardrail" | "handoff" | "custom";
|
|
15
|
+
capture: boolean;
|
|
16
|
+
experimentId?: string;
|
|
17
|
+
/** @deprecated Use experimentId. */
|
|
18
|
+
testRunId?: string;
|
|
19
|
+
mockOnReplay?: boolean;
|
|
20
|
+
replayReusable?: boolean;
|
|
21
|
+
finalize?: (result: any) => unknown | Promise<unknown>;
|
|
21
22
|
}
|
|
22
|
-
interface NestedTraceLink {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export interface NestedTraceLink {
|
|
24
|
+
traceFunctionKey: string;
|
|
25
|
+
traceId?: string;
|
|
26
|
+
rootSpanId?: string;
|
|
26
27
|
}
|
|
27
|
-
interface
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
spanStack: unknown;
|
|
28
|
+
export interface SpanDetails {
|
|
29
|
+
contexts: Record<string, unknown>[];
|
|
30
|
+
prompt?: string;
|
|
31
31
|
}
|
|
32
|
-
interface
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
export interface AutoTraceEntry {
|
|
33
|
+
context: AutoTraceContext;
|
|
34
|
+
depth: number;
|
|
35
|
+
spanStack: unknown;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
declare function
|
|
43
|
-
declare function
|
|
44
|
-
declare function
|
|
37
|
+
export interface AutoTraceContext {
|
|
38
|
+
readonly traceFunctionKey: string;
|
|
39
|
+
invoke<T>(definition: AutoTraceFunctionDefinition, inputs: unknown[], fn: () => T, entry: AutoTraceEntry, spanDetails: SpanDetails, nodeConfiguration?: AutoTraceNodeConfiguration): T;
|
|
40
|
+
invokeNestedRoot<T>(name: string, functionName: string, inputs: unknown[], fn: () => T, entry: AutoTraceEntry, link: NestedTraceLink | undefined, spanDetails: SpanDetails): T;
|
|
41
|
+
}
|
|
42
|
+
export declare function currentAutoTraceEntries(): readonly AutoTraceEntry[];
|
|
43
|
+
export declare function runWithAutoTraceEntry<T>(previous: AutoTraceEntry, updated: AutoTraceEntry, fn: () => T): T;
|
|
44
|
+
export declare function clearAutoTraceNodeConfiguration<T>(fn: () => T): T;
|
|
45
|
+
export declare function runWithAutoTraceNodeConfiguration<T>(nodeConfiguration: AutoTraceNodeConfiguration, fn: () => T): T;
|
|
46
|
+
export declare function runAsAutoTraceRootFunction<T>(functionName: string, fn: () => T): T;
|
|
47
|
+
export declare function runWithAutoTraceRootContext<T>(context: AutoTraceContext, spanStack: unknown, fn: () => T): T;
|
|
48
|
+
export declare function invokeThroughAutoTraceEntries<T>(entries: readonly AutoTraceEntry[], step: (entry: AutoTraceEntry, next: () => T) => T, fn: () => T): T;
|
|
49
|
+
export declare function __bitfabAutoSpan<T>(definition: AutoTraceFunctionDefinition, inputs: unknown[], fn: () => T): T;
|
|
45
50
|
/**
|
|
46
51
|
* Preserve a function's original call arguments for transform cases where
|
|
47
52
|
* parameter bindings discard them, such as destructured arrow parameters.
|
|
@@ -52,7 +57,7 @@ declare function __bitfabAutoSpan<T>(definition: AutoTraceFunctionDefinition, in
|
|
|
52
57
|
*
|
|
53
58
|
* @experimental The automatic tracing protocol may change.
|
|
54
59
|
*/
|
|
55
|
-
declare function __bitfabAutoWrap<T extends (...args: never[]) => unknown>(definition: AutoTraceFunctionDefinition, fn: T): T;
|
|
60
|
+
export declare function __bitfabAutoWrap<T extends (...args: never[]) => unknown>(definition: AutoTraceFunctionDefinition, fn: T): T;
|
|
56
61
|
/**
|
|
57
62
|
* Return whether the current call is inside an automatic trace root.
|
|
58
63
|
*
|
|
@@ -62,7 +67,6 @@ declare function __bitfabAutoWrap<T extends (...args: never[]) => unknown>(defin
|
|
|
62
67
|
*
|
|
63
68
|
* @experimental The automatic tracing protocol may change.
|
|
64
69
|
*/
|
|
65
|
-
declare function __bitfabAutoTraceActive(): boolean;
|
|
66
|
-
declare function _resetAutoTraceTransformDetection(): void;
|
|
67
|
-
|
|
68
|
-
export { type AutoTraceContext, type AutoTraceEntry, type AutoTraceFunctionDefinition, type AutoTraceNodeConfiguration, type NestedTraceLink, __bitfabAutoSpan, __bitfabAutoTraceActive, __bitfabAutoWrap, _resetAutoTraceTransformDetection, clearAutoTraceNodeConfiguration, currentAutoTraceEntries, invokeThroughAutoTraceEntries, runAsAutoTraceRootFunction, runWithAutoTraceEntry, runWithAutoTraceNodeConfiguration, runWithAutoTraceRootContext };
|
|
70
|
+
export declare function __bitfabAutoTraceActive(): boolean;
|
|
71
|
+
export declare function _resetAutoTraceTransformDetection(): void;
|
|
72
|
+
//#endregion
|
package/dist/autoTrace.d.ts
CHANGED
|
@@ -1,47 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
//#region src/autoTrace.d.ts
|
|
2
|
+
export interface AutoTraceFunctionDefinition {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
file: string;
|
|
6
|
+
line: number;
|
|
7
|
+
column: number;
|
|
8
|
+
async?: boolean;
|
|
9
|
+
wrapper?: boolean;
|
|
9
10
|
}
|
|
10
|
-
interface AutoTraceNodeConfiguration {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
export interface AutoTraceNodeConfiguration {
|
|
12
|
+
functionName: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
type?: "llm" | "agent" | "function" | "guardrail" | "handoff" | "custom";
|
|
15
|
+
capture: boolean;
|
|
16
|
+
experimentId?: string;
|
|
17
|
+
/** @deprecated Use experimentId. */
|
|
18
|
+
testRunId?: string;
|
|
19
|
+
mockOnReplay?: boolean;
|
|
20
|
+
replayReusable?: boolean;
|
|
21
|
+
finalize?: (result: any) => unknown | Promise<unknown>;
|
|
21
22
|
}
|
|
22
|
-
interface NestedTraceLink {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export interface NestedTraceLink {
|
|
24
|
+
traceFunctionKey: string;
|
|
25
|
+
traceId?: string;
|
|
26
|
+
rootSpanId?: string;
|
|
26
27
|
}
|
|
27
|
-
interface
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
spanStack: unknown;
|
|
28
|
+
export interface SpanDetails {
|
|
29
|
+
contexts: Record<string, unknown>[];
|
|
30
|
+
prompt?: string;
|
|
31
31
|
}
|
|
32
|
-
interface
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
export interface AutoTraceEntry {
|
|
33
|
+
context: AutoTraceContext;
|
|
34
|
+
depth: number;
|
|
35
|
+
spanStack: unknown;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
declare function
|
|
43
|
-
declare function
|
|
44
|
-
declare function
|
|
37
|
+
export interface AutoTraceContext {
|
|
38
|
+
readonly traceFunctionKey: string;
|
|
39
|
+
invoke<T>(definition: AutoTraceFunctionDefinition, inputs: unknown[], fn: () => T, entry: AutoTraceEntry, spanDetails: SpanDetails, nodeConfiguration?: AutoTraceNodeConfiguration): T;
|
|
40
|
+
invokeNestedRoot<T>(name: string, functionName: string, inputs: unknown[], fn: () => T, entry: AutoTraceEntry, link: NestedTraceLink | undefined, spanDetails: SpanDetails): T;
|
|
41
|
+
}
|
|
42
|
+
export declare function currentAutoTraceEntries(): readonly AutoTraceEntry[];
|
|
43
|
+
export declare function runWithAutoTraceEntry<T>(previous: AutoTraceEntry, updated: AutoTraceEntry, fn: () => T): T;
|
|
44
|
+
export declare function clearAutoTraceNodeConfiguration<T>(fn: () => T): T;
|
|
45
|
+
export declare function runWithAutoTraceNodeConfiguration<T>(nodeConfiguration: AutoTraceNodeConfiguration, fn: () => T): T;
|
|
46
|
+
export declare function runAsAutoTraceRootFunction<T>(functionName: string, fn: () => T): T;
|
|
47
|
+
export declare function runWithAutoTraceRootContext<T>(context: AutoTraceContext, spanStack: unknown, fn: () => T): T;
|
|
48
|
+
export declare function invokeThroughAutoTraceEntries<T>(entries: readonly AutoTraceEntry[], step: (entry: AutoTraceEntry, next: () => T) => T, fn: () => T): T;
|
|
49
|
+
export declare function __bitfabAutoSpan<T>(definition: AutoTraceFunctionDefinition, inputs: unknown[], fn: () => T): T;
|
|
45
50
|
/**
|
|
46
51
|
* Preserve a function's original call arguments for transform cases where
|
|
47
52
|
* parameter bindings discard them, such as destructured arrow parameters.
|
|
@@ -52,7 +57,7 @@ declare function __bitfabAutoSpan<T>(definition: AutoTraceFunctionDefinition, in
|
|
|
52
57
|
*
|
|
53
58
|
* @experimental The automatic tracing protocol may change.
|
|
54
59
|
*/
|
|
55
|
-
declare function __bitfabAutoWrap<T extends (...args: never[]) => unknown>(definition: AutoTraceFunctionDefinition, fn: T): T;
|
|
60
|
+
export declare function __bitfabAutoWrap<T extends (...args: never[]) => unknown>(definition: AutoTraceFunctionDefinition, fn: T): T;
|
|
56
61
|
/**
|
|
57
62
|
* Return whether the current call is inside an automatic trace root.
|
|
58
63
|
*
|
|
@@ -62,7 +67,6 @@ declare function __bitfabAutoWrap<T extends (...args: never[]) => unknown>(defin
|
|
|
62
67
|
*
|
|
63
68
|
* @experimental The automatic tracing protocol may change.
|
|
64
69
|
*/
|
|
65
|
-
declare function __bitfabAutoTraceActive(): boolean;
|
|
66
|
-
declare function _resetAutoTraceTransformDetection(): void;
|
|
67
|
-
|
|
68
|
-
export { type AutoTraceContext, type AutoTraceEntry, type AutoTraceFunctionDefinition, type AutoTraceNodeConfiguration, type NestedTraceLink, __bitfabAutoSpan, __bitfabAutoTraceActive, __bitfabAutoWrap, _resetAutoTraceTransformDetection, clearAutoTraceNodeConfiguration, currentAutoTraceEntries, invokeThroughAutoTraceEntries, runAsAutoTraceRootFunction, runWithAutoTraceEntry, runWithAutoTraceNodeConfiguration, runWithAutoTraceRootContext };
|
|
70
|
+
export declare function __bitfabAutoTraceActive(): boolean;
|
|
71
|
+
export declare function _resetAutoTraceTransformDetection(): void;
|
|
72
|
+
//#endregion
|
package/dist/autoTrace.js
CHANGED
|
@@ -1,28 +1 @@
|
|
|
1
|
-
|
|
2
|
-
__bitfabAutoSpan,
|
|
3
|
-
__bitfabAutoTraceActive,
|
|
4
|
-
__bitfabAutoWrap,
|
|
5
|
-
_resetAutoTraceTransformDetection,
|
|
6
|
-
clearAutoTraceNodeConfiguration,
|
|
7
|
-
currentAutoTraceEntries,
|
|
8
|
-
invokeThroughAutoTraceEntries,
|
|
9
|
-
runAsAutoTraceRootFunction,
|
|
10
|
-
runWithAutoTraceEntry,
|
|
11
|
-
runWithAutoTraceNodeConfiguration,
|
|
12
|
-
runWithAutoTraceRootContext
|
|
13
|
-
} from "./chunk-QRNHRY7F.js";
|
|
14
|
-
import "./chunk-MT36GJMW.js";
|
|
15
|
-
export {
|
|
16
|
-
__bitfabAutoSpan,
|
|
17
|
-
__bitfabAutoTraceActive,
|
|
18
|
-
__bitfabAutoWrap,
|
|
19
|
-
_resetAutoTraceTransformDetection,
|
|
20
|
-
clearAutoTraceNodeConfiguration,
|
|
21
|
-
currentAutoTraceEntries,
|
|
22
|
-
invokeThroughAutoTraceEntries,
|
|
23
|
-
runAsAutoTraceRootFunction,
|
|
24
|
-
runWithAutoTraceEntry,
|
|
25
|
-
runWithAutoTraceNodeConfiguration,
|
|
26
|
-
runWithAutoTraceRootContext
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=autoTrace.js.map
|
|
1
|
+
export { t as __bitfabAutoSpan, n as __bitfabAutoTraceActive, r as __bitfabAutoWrap, i as _resetAutoTraceTransformDetection, a as clearAutoTraceNodeConfiguration, o as currentAutoTraceEntries, s as invokeThroughAutoTraceEntries, c as runAsAutoTraceRootFunction, l as runWithAutoTraceEntry, u as runWithAutoTraceNodeConfiguration, d as runWithAutoTraceRootContext } from "./autoTrace-O40k8f5M.js";
|