@bitfab/sdk 0.26.1 → 0.27.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-SJFOTDP3.js → chunk-PFV4MPNS.js} +88 -14
- package/dist/chunk-PFV4MPNS.js.map +1 -0
- package/dist/{replay-KYGI6LJY.js → chunk-RNTDM6WM.js} +286 -10
- package/dist/chunk-RNTDM6WM.js.map +1 -0
- package/dist/index.cjs +180 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -6
- package/dist/index.d.ts +43 -6
- package/dist/index.js +8 -4
- package/dist/node.cjs +180 -52
- 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 +8 -4
- package/dist/node.js.map +1 -1
- package/dist/replay-66KNEAMO.js +11 -0
- package/dist/replay-66KNEAMO.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-26MUT4IP.js +0 -242
- package/dist/chunk-26MUT4IP.js.map +0 -1
- package/dist/chunk-SJFOTDP3.js.map +0 -1
- package/dist/replay-KYGI6LJY.js.map +0 -1
package/dist/node.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ActiveSpanContext, AdaptContext, AdaptInputsFn, AllowedEnvVars, BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, BitfabConfig, BitfabError, BitfabFunction, BitfabLangChainCallbackHandler, BitfabLangChainCallbackHandler as BitfabLangGraphCallbackHandler, BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, CodeChangeFile, CurrentSpan, CurrentTrace, DEFAULT_SERVICE_URL, DbSnapshotConfig, DbSnapshotProvider, DbSnapshotRef, DetachedTrace, MockStrategy, ProviderDefinition, ReplayEnvironment, ReplayEnvironmentSnapshot, ReplayItem, ReplayOptions, ReplayProgress, ReplayResult, SUPPORTED_PROVIDERS, SpanOptions, SpanType, TokenUsage, TraceResponse, TracingProcessor, VercelCallParams, VercelGenerateResult, VercelStreamResult, WrapBAMLOptions, WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace } from './index.cjs';
|
|
1
|
+
export { ActiveSpanContext, AdaptContext, AdaptInputsFn, AllowedEnvVars, BITFAB_PROGRESS_PREFIX, BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, BitfabConfig, BitfabError, BitfabFunction, BitfabLangChainCallbackHandler, BitfabLangChainCallbackHandler as BitfabLangGraphCallbackHandler, BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, CodeChangeFile, CurrentSpan, CurrentTrace, DEFAULT_SERVICE_URL, DbSnapshotConfig, DbSnapshotProvider, DbSnapshotRef, DetachedTrace, MockStrategy, ProviderDefinition, ReplayEnvironment, ReplayEnvironmentSnapshot, ReplayItem, ReplayOptions, ReplayProgress, ReplayResult, SUPPORTED_PROVIDERS, SpanOptions, SpanType, TokenUsage, TraceResponse, TracingProcessor, VercelCallParams, VercelGenerateResult, VercelStreamResult, WrapBAMLOptions, WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace, reportReplayProgress } from './index.cjs';
|
package/dist/node.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ActiveSpanContext, AdaptContext, AdaptInputsFn, AllowedEnvVars, BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, BitfabConfig, BitfabError, BitfabFunction, BitfabLangChainCallbackHandler, BitfabLangChainCallbackHandler as BitfabLangGraphCallbackHandler, BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, CodeChangeFile, CurrentSpan, CurrentTrace, DEFAULT_SERVICE_URL, DbSnapshotConfig, DbSnapshotProvider, DbSnapshotRef, DetachedTrace, MockStrategy, ProviderDefinition, ReplayEnvironment, ReplayEnvironmentSnapshot, ReplayItem, ReplayOptions, ReplayProgress, ReplayResult, SUPPORTED_PROVIDERS, SpanOptions, SpanType, TokenUsage, TraceResponse, TracingProcessor, VercelCallParams, VercelGenerateResult, VercelStreamResult, WrapBAMLOptions, WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace } from './index.js';
|
|
1
|
+
export { ActiveSpanContext, AdaptContext, AdaptInputsFn, AllowedEnvVars, BITFAB_PROGRESS_PREFIX, BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, BitfabConfig, BitfabError, BitfabFunction, BitfabLangChainCallbackHandler, BitfabLangChainCallbackHandler as BitfabLangGraphCallbackHandler, BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, CodeChangeFile, CurrentSpan, CurrentTrace, DEFAULT_SERVICE_URL, DbSnapshotConfig, DbSnapshotProvider, DbSnapshotRef, DetachedTrace, MockStrategy, ProviderDefinition, ReplayEnvironment, ReplayEnvironmentSnapshot, ReplayItem, ReplayOptions, ReplayProgress, ReplayResult, SUPPORTED_PROVIDERS, SpanOptions, SpanType, TokenUsage, TraceResponse, TracingProcessor, VercelCallParams, VercelGenerateResult, VercelStreamResult, WrapBAMLOptions, WrappedBamlFn, __version__, finalizers, flushTraces, getCurrentSpan, getCurrentTrace, reportReplayProgress } from './index.js';
|
package/dist/node.js
CHANGED
|
@@ -14,12 +14,14 @@ import {
|
|
|
14
14
|
flushTraces,
|
|
15
15
|
getCurrentSpan,
|
|
16
16
|
getCurrentTrace
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-PFV4MPNS.js";
|
|
18
18
|
import {
|
|
19
|
+
BITFAB_PROGRESS_PREFIX,
|
|
19
20
|
BitfabError,
|
|
20
21
|
assertAsyncStorageRegistered,
|
|
21
|
-
registerAsyncLocalStorageClass
|
|
22
|
-
|
|
22
|
+
registerAsyncLocalStorageClass,
|
|
23
|
+
reportReplayProgress
|
|
24
|
+
} from "./chunk-RNTDM6WM.js";
|
|
23
25
|
|
|
24
26
|
// src/asyncStorageNode.ts
|
|
25
27
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -30,6 +32,7 @@ registerAsyncLocalStorageClass(
|
|
|
30
32
|
// src/node.ts
|
|
31
33
|
assertAsyncStorageRegistered();
|
|
32
34
|
export {
|
|
35
|
+
BITFAB_PROGRESS_PREFIX,
|
|
33
36
|
Bitfab,
|
|
34
37
|
BitfabClaudeAgentHandler,
|
|
35
38
|
BitfabError,
|
|
@@ -46,6 +49,7 @@ export {
|
|
|
46
49
|
finalizers,
|
|
47
50
|
flushTraces,
|
|
48
51
|
getCurrentSpan,
|
|
49
|
-
getCurrentTrace
|
|
52
|
+
getCurrentTrace,
|
|
53
|
+
reportReplayProgress
|
|
50
54
|
};
|
|
51
55
|
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asyncStorageNode.ts","../src/node.ts"],"sourcesContent":["/**\n * Synchronous AsyncLocalStorage registration for Node.js.\n *\n * This module is a side-effect-only import: it registers the Node.js\n * AsyncLocalStorage class into the shared registry so span nesting\n * works immediately — no async gap, no microtask delay.\n *\n * It is imported by `node.ts` (the Node.js-specific entry point) as\n * the FIRST import, before `index.ts` or `client.ts` are evaluated.\n *\n * This file must ONLY be imported in Node.js environments (not browsers).\n * It uses a static `import` of `node:async_hooks`, which will fail in\n * browser bundlers. The `node.ts` entry point is conditionally selected\n * via package.json `exports` conditions, so browsers never see this file.\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\"\nimport type { AsyncLocalStorageLike } from \"./asyncStorage.js\"\nimport { registerAsyncLocalStorageClass } from \"./asyncStorage.js\"\n\nregisterAsyncLocalStorageClass(\n AsyncLocalStorage as unknown as new () => AsyncLocalStorageLike<unknown>,\n)\n","/**\n * Node.js-specific entry point for the Bitfab SDK.\n *\n * Selected automatically via package.json `exports` conditions when the\n * consumer's runtime or bundler supports the \"node\" condition (Node.js,\n * most server-side bundlers).\n *\n * This entry point differs from the default (`index.ts`) in one way:\n * it synchronously registers Node.js's `AsyncLocalStorage` before any\n * other SDK code evaluates. This eliminates the async initialization\n * gap that the default entry point has (where the first span might\n * execute before the dynamic import of `node:async_hooks` resolves).\n *\n * The default entry point (`index.ts`) is used for browsers and other\n * environments where `node:async_hooks` is unavailable. There, span\n * nesting degrades gracefully to a shared stack (correct for sequential\n * async, but not for concurrent Promise.all patterns).\n */\n\n// ⚠️ IMPORT ORDER MATTERS\n// asyncStorageNode MUST be imported before index.js.\n// It registers the AsyncLocalStorage class synchronously during module\n// evaluation. index.js (via client.ts) reads from that registration at\n// span creation time. If this import is moved after index.js or removed,\n// span nesting silently degrades to the browser fallback (flat spans).\nimport \"./asyncStorageNode.js\"\n\nexport * from \"./index.js\"\n\n// Verify registration succeeded. This turns a silent degradation into a\n// loud error if someone reorders the imports above or if asyncStorageNode.ts\n// fails to register for any reason. Only runs in the Node.js entry point\n// where we know node:async_hooks must be available.\nimport { assertAsyncStorageRegistered } from \"./asyncStorage.js\"\n\nassertAsyncStorageRegistered()\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/asyncStorageNode.ts","../src/node.ts"],"sourcesContent":["/**\n * Synchronous AsyncLocalStorage registration for Node.js.\n *\n * This module is a side-effect-only import: it registers the Node.js\n * AsyncLocalStorage class into the shared registry so span nesting\n * works immediately — no async gap, no microtask delay.\n *\n * It is imported by `node.ts` (the Node.js-specific entry point) as\n * the FIRST import, before `index.ts` or `client.ts` are evaluated.\n *\n * This file must ONLY be imported in Node.js environments (not browsers).\n * It uses a static `import` of `node:async_hooks`, which will fail in\n * browser bundlers. The `node.ts` entry point is conditionally selected\n * via package.json `exports` conditions, so browsers never see this file.\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\"\nimport type { AsyncLocalStorageLike } from \"./asyncStorage.js\"\nimport { registerAsyncLocalStorageClass } from \"./asyncStorage.js\"\n\nregisterAsyncLocalStorageClass(\n AsyncLocalStorage as unknown as new () => AsyncLocalStorageLike<unknown>,\n)\n","/**\n * Node.js-specific entry point for the Bitfab SDK.\n *\n * Selected automatically via package.json `exports` conditions when the\n * consumer's runtime or bundler supports the \"node\" condition (Node.js,\n * most server-side bundlers).\n *\n * This entry point differs from the default (`index.ts`) in one way:\n * it synchronously registers Node.js's `AsyncLocalStorage` before any\n * other SDK code evaluates. This eliminates the async initialization\n * gap that the default entry point has (where the first span might\n * execute before the dynamic import of `node:async_hooks` resolves).\n *\n * The default entry point (`index.ts`) is used for browsers and other\n * environments where `node:async_hooks` is unavailable. There, span\n * nesting degrades gracefully to a shared stack (correct for sequential\n * async, but not for concurrent Promise.all patterns).\n */\n\n// ⚠️ IMPORT ORDER MATTERS\n// asyncStorageNode MUST be imported before index.js.\n// It registers the AsyncLocalStorage class synchronously during module\n// evaluation. index.js (via client.ts) reads from that registration at\n// span creation time. If this import is moved after index.js or removed,\n// span nesting silently degrades to the browser fallback (flat spans).\nimport \"./asyncStorageNode.js\"\n\nexport * from \"./index.js\"\n\n// Verify registration succeeded. This turns a silent degradation into a\n// loud error if someone reorders the imports above or if asyncStorageNode.ts\n// fails to register for any reason. Only runs in the Node.js entry point\n// where we know node:async_hooks must be available.\nimport { assertAsyncStorageRegistered } from \"./asyncStorage.js\"\n\nassertAsyncStorageRegistered()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,SAAS,yBAAyB;AAIlC;AAAA,EACE;AACF;;;ACaA,6BAA6B;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
package/dist/chunk-26MUT4IP.js
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
// src/errors.ts
|
|
2
|
-
var BitfabError = class extends Error {
|
|
3
|
-
constructor(message, url) {
|
|
4
|
-
super(message);
|
|
5
|
-
this.url = url;
|
|
6
|
-
this.name = "BitfabError";
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// src/warnOnce.ts
|
|
11
|
-
var warned = /* @__PURE__ */ new Set();
|
|
12
|
-
function warnOnce(key, message) {
|
|
13
|
-
if (warned.has(key)) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
warned.add(key);
|
|
17
|
-
try {
|
|
18
|
-
console.warn(`[bitfab] ${message}`);
|
|
19
|
-
} catch {
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// src/randomUuid.ts
|
|
24
|
-
function randomUuid() {
|
|
25
|
-
const globalCrypto = globalThis.crypto;
|
|
26
|
-
if (typeof globalCrypto?.randomUUID === "function") {
|
|
27
|
-
try {
|
|
28
|
-
return globalCrypto.randomUUID();
|
|
29
|
-
} catch {
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
warnOnce(
|
|
33
|
-
"crypto-unavailable",
|
|
34
|
-
"global crypto.randomUUID is unavailable; using a non-cryptographic fallback for trace/span ids. Tracing works normally (ids are correlation-only, not security-sensitive)."
|
|
35
|
-
);
|
|
36
|
-
return fallbackUuidV4();
|
|
37
|
-
}
|
|
38
|
-
function fallbackUuidV4() {
|
|
39
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (char) => {
|
|
40
|
-
const rand = Math.random() * 16 | 0;
|
|
41
|
-
const value = char === "x" ? rand : rand & 3 | 8;
|
|
42
|
-
return value.toString(16);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/serialize.ts
|
|
47
|
-
import superjson from "superjson";
|
|
48
|
-
var MAX_SERIALIZED_BYTES = 512e3;
|
|
49
|
-
var MAX_FRAMEWORK_SERIALIZED_BYTES = 2e6;
|
|
50
|
-
function describeValue(value) {
|
|
51
|
-
try {
|
|
52
|
-
const ctorName = value?.constructor?.name;
|
|
53
|
-
if (ctorName && ctorName !== "Object") {
|
|
54
|
-
return ctorName;
|
|
55
|
-
}
|
|
56
|
-
} catch {
|
|
57
|
-
}
|
|
58
|
-
return typeof value;
|
|
59
|
-
}
|
|
60
|
-
function unserializableStub(value, reason) {
|
|
61
|
-
warnOnce(
|
|
62
|
-
`serialize:${reason.replace(/\d+/g, "N")}`,
|
|
63
|
-
`a value could not be fully serialized for a span (${reason}); it was replaced with a placeholder. The span still ships, but its captured input/output is incomplete.`
|
|
64
|
-
);
|
|
65
|
-
let summary;
|
|
66
|
-
try {
|
|
67
|
-
summary = `<unserializable: ${describeValue(value)} (${reason})>`;
|
|
68
|
-
} catch {
|
|
69
|
-
summary = `<unserializable (${reason})>`;
|
|
70
|
-
}
|
|
71
|
-
return { json: summary };
|
|
72
|
-
}
|
|
73
|
-
function serializeValue(value) {
|
|
74
|
-
try {
|
|
75
|
-
const { json, meta } = superjson.serialize(value);
|
|
76
|
-
let size;
|
|
77
|
-
try {
|
|
78
|
-
size = JSON.stringify(json).length;
|
|
79
|
-
} catch {
|
|
80
|
-
return unserializableStub(value, "stringify_failed_after_superjson");
|
|
81
|
-
}
|
|
82
|
-
if (size > MAX_SERIALIZED_BYTES) {
|
|
83
|
-
return unserializableStub(value, `too_large_${size}_bytes`);
|
|
84
|
-
}
|
|
85
|
-
return meta ? { json, meta } : { json };
|
|
86
|
-
} catch {
|
|
87
|
-
try {
|
|
88
|
-
return { json: JSON.parse(JSON.stringify(value)) };
|
|
89
|
-
} catch {
|
|
90
|
-
return unserializableStub(value, "json_stringify_failed");
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function deserializeValue(serialized) {
|
|
95
|
-
if (serialized.meta === void 0) {
|
|
96
|
-
return serialized.json;
|
|
97
|
-
}
|
|
98
|
-
return superjson.deserialize({
|
|
99
|
-
json: serialized.json,
|
|
100
|
-
meta: serialized.meta
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
var MAX_SAFE_DEPTH = 6;
|
|
104
|
-
function toJsonSafe(value) {
|
|
105
|
-
const safe = toJsonSafeInner(value, 0, /* @__PURE__ */ new WeakSet());
|
|
106
|
-
try {
|
|
107
|
-
const size = JSON.stringify(safe)?.length ?? 0;
|
|
108
|
-
if (size > MAX_FRAMEWORK_SERIALIZED_BYTES) {
|
|
109
|
-
warnOnce(
|
|
110
|
-
"toJsonSafe:too_large",
|
|
111
|
-
`a framework payload exceeded ${MAX_FRAMEWORK_SERIALIZED_BYTES} bytes and was replaced with a placeholder so the span still ships. The captured state for this span is incomplete.`
|
|
112
|
-
);
|
|
113
|
-
return `<unserializable: too_large_${size}_bytes>`;
|
|
114
|
-
}
|
|
115
|
-
} catch {
|
|
116
|
-
}
|
|
117
|
-
return safe;
|
|
118
|
-
}
|
|
119
|
-
function toJsonSafeInner(value, depth, seen) {
|
|
120
|
-
if (value === null || value === void 0) {
|
|
121
|
-
return value;
|
|
122
|
-
}
|
|
123
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
124
|
-
return value;
|
|
125
|
-
}
|
|
126
|
-
const className = value?.constructor?.name ?? typeof value;
|
|
127
|
-
if (depth > MAX_SAFE_DEPTH) {
|
|
128
|
-
return `<${className}>`;
|
|
129
|
-
}
|
|
130
|
-
if (typeof value !== "object") {
|
|
131
|
-
try {
|
|
132
|
-
return String(value);
|
|
133
|
-
} catch {
|
|
134
|
-
return `<${className}>`;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (seen.has(value)) {
|
|
138
|
-
return `<cycle ${className}>`;
|
|
139
|
-
}
|
|
140
|
-
seen.add(value);
|
|
141
|
-
let result;
|
|
142
|
-
if (Array.isArray(value)) {
|
|
143
|
-
result = value.map((item) => toJsonSafeInner(item, depth + 1, seen));
|
|
144
|
-
} else if (typeof value.toJSON === "function") {
|
|
145
|
-
try {
|
|
146
|
-
result = toJsonSafeInner(
|
|
147
|
-
value.toJSON(),
|
|
148
|
-
depth + 1,
|
|
149
|
-
seen
|
|
150
|
-
);
|
|
151
|
-
} catch {
|
|
152
|
-
result = `<${className}>`;
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
try {
|
|
156
|
-
const obj = {};
|
|
157
|
-
for (const [k, v] of Object.entries(value)) {
|
|
158
|
-
if (!k.startsWith("_")) {
|
|
159
|
-
obj[k] = toJsonSafeInner(v, depth + 1, seen);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
result = obj;
|
|
163
|
-
} catch {
|
|
164
|
-
result = `<${className}>`;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
seen.delete(value);
|
|
168
|
-
return result;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// src/asyncStorage.ts
|
|
172
|
-
var AsyncLocalStorageClass = null;
|
|
173
|
-
var initDone = false;
|
|
174
|
-
function registerAsyncLocalStorageClass(cls) {
|
|
175
|
-
if (!AsyncLocalStorageClass) {
|
|
176
|
-
AsyncLocalStorageClass = cls;
|
|
177
|
-
}
|
|
178
|
-
initDone = true;
|
|
179
|
-
}
|
|
180
|
-
function assertAsyncStorageRegistered() {
|
|
181
|
-
if (!AsyncLocalStorageClass) {
|
|
182
|
-
console.warn(
|
|
183
|
-
"Bitfab: AsyncLocalStorage not available \u2014 nested span context will not propagate."
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
var asyncStorageReady = (typeof process !== "undefined" && process.versions?.node ? (
|
|
188
|
-
// The join trick hides "node:async_hooks" from static analysis so
|
|
189
|
-
// bundlers that ban Node.js built-ins don't fail at build time.
|
|
190
|
-
// webpackIgnore tells webpack/turbopack to emit a native import()
|
|
191
|
-
// so Node.js can resolve the module at runtime.
|
|
192
|
-
import(
|
|
193
|
-
/* webpackIgnore: true */
|
|
194
|
-
["node", "async_hooks"].join(":")
|
|
195
|
-
).then(
|
|
196
|
-
(mod) => {
|
|
197
|
-
registerAsyncLocalStorageClass(mod.AsyncLocalStorage);
|
|
198
|
-
}
|
|
199
|
-
).catch(() => {
|
|
200
|
-
})
|
|
201
|
-
) : Promise.resolve()).then(() => {
|
|
202
|
-
initDone = true;
|
|
203
|
-
});
|
|
204
|
-
function isAsyncStorageInitDone() {
|
|
205
|
-
return initDone;
|
|
206
|
-
}
|
|
207
|
-
function createAsyncLocalStorage() {
|
|
208
|
-
return AsyncLocalStorageClass ? new AsyncLocalStorageClass() : null;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// src/replayContext.ts
|
|
212
|
-
var replayContextStorage = null;
|
|
213
|
-
var replayContextReady = asyncStorageReady.then(() => {
|
|
214
|
-
replayContextStorage = createAsyncLocalStorage();
|
|
215
|
-
});
|
|
216
|
-
function getReplayContext() {
|
|
217
|
-
return replayContextStorage?.getStore() ?? null;
|
|
218
|
-
}
|
|
219
|
-
function runWithReplayContext(ctx, fn) {
|
|
220
|
-
if (replayContextStorage) {
|
|
221
|
-
return replayContextStorage.run(ctx, fn);
|
|
222
|
-
}
|
|
223
|
-
return fn();
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export {
|
|
227
|
-
BitfabError,
|
|
228
|
-
warnOnce,
|
|
229
|
-
randomUuid,
|
|
230
|
-
serializeValue,
|
|
231
|
-
deserializeValue,
|
|
232
|
-
toJsonSafe,
|
|
233
|
-
registerAsyncLocalStorageClass,
|
|
234
|
-
assertAsyncStorageRegistered,
|
|
235
|
-
asyncStorageReady,
|
|
236
|
-
isAsyncStorageInitDone,
|
|
237
|
-
createAsyncLocalStorage,
|
|
238
|
-
replayContextReady,
|
|
239
|
-
getReplayContext,
|
|
240
|
-
runWithReplayContext
|
|
241
|
-
};
|
|
242
|
-
//# sourceMappingURL=chunk-26MUT4IP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/warnOnce.ts","../src/randomUuid.ts","../src/serialize.ts","../src/asyncStorage.ts","../src/replayContext.ts"],"sourcesContent":["/**\n * Shared error type for Bitfab SDK runtime errors. Lives in its own\n * module to avoid import cycles between `http.ts` and modules that need\n * to throw structured errors (e.g. `dbSnapshot.ts` validation).\n */\n\nexport class BitfabError extends Error {\n constructor(\n message: string,\n public readonly url?: string,\n ) {\n super(message)\n this.name = \"BitfabError\"\n }\n}\n","/**\n * Emit a `console.warn` at most once per distinct `key` for the life of the\n * process.\n *\n * The SDK must NEVER crash a host app, so every failure on the user's path\n * degrades silently (a span is dropped, a call runs untraced, a payload is\n * stubbed). Silent is safe but undebuggable: a user who suddenly has no traces,\n * or sees `<unserializable>` in a span, has no signal as to why. A one-time\n * warning per distinct issue restores that signal without spamming the console\n * from a hot path.\n *\n * Keys should identify the specific degradation (e.g. include the traced\n * function key) so each distinct issue warns once, not just the first one seen.\n */\nconst warned = new Set<string>()\n\nexport function warnOnce(key: string, message: string): void {\n if (warned.has(key)) {\n return\n }\n warned.add(key)\n try {\n console.warn(`[bitfab] ${message}`)\n } catch {\n // Logging must never crash the host app (e.g. a closed/replaced console).\n }\n}\n\n/** Test-only: clear the dedup set so a warning can fire again. */\nexport function _resetWarnOnce(): void {\n warned.clear()\n}\n","/**\n * Generate a UUID v4 without assuming a global `crypto`.\n *\n * `crypto.randomUUID()` is the fast path and exists in every mainstream modern\n * runtime (Node >= 19, all browsers, Deno, Vercel edge, Cloudflare Workers).\n * But the SDK must NEVER crash a host app, and a few runtimes it can legitimately\n * run in lack a global `crypto` or `crypto.randomUUID` (Node < 19 without a\n * polyfill, older React Native, some sandboxes). There, an unguarded\n * `crypto.randomUUID()` throws on the user's call path. This helper falls back\n * to a `Math.random()`-based v4 string instead.\n *\n * The fallback is NOT cryptographically secure. That is fine: trace and span\n * IDs only need to be unique enough to correlate the spans of one trace; they\n * are never security-sensitive.\n */\nimport { warnOnce } from \"./warnOnce.js\"\n\nexport function randomUuid(): string {\n const globalCrypto = (\n globalThis as { crypto?: { randomUUID?: () => string } }\n ).crypto\n if (typeof globalCrypto?.randomUUID === \"function\") {\n try {\n return globalCrypto.randomUUID()\n } catch {\n // Fall through to the manual generator below.\n }\n }\n warnOnce(\n \"crypto-unavailable\",\n \"global crypto.randomUUID is unavailable; using a non-cryptographic fallback for trace/span ids. Tracing works normally (ids are correlation-only, not security-sensitive).\",\n )\n return fallbackUuidV4()\n}\n\n/**\n * RFC 4122 version 4 layout filled from `Math.random()`. Used only when a usable\n * global `crypto.randomUUID` is unavailable.\n */\nfunction fallbackUuidV4(): string {\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (char) => {\n const rand = (Math.random() * 16) | 0\n const value = char === \"x\" ? rand : (rand & 0x3) | 0x8\n return value.toString(16)\n })\n}\n","/**\n * Serialization utilities for Bitfab SDK.\n *\n * This module provides serialization with type metadata preservation,\n * using superjson for handling special JavaScript types like Date, Map,\n * Set, BigInt, undefined, etc.\n */\n\nimport superjson from \"superjson\"\nimport { warnOnce } from \"./warnOnce.js\"\n\n/**\n * Serialized value with JSON data and optional superjson meta for type preservation.\n *\n * The json field contains the JSON-serializable data.\n * The meta field (if present) contains superjson type information for deserializing\n * special types like Date, Map, Set, BigInt, etc.\n */\nexport interface SerializedValue {\n json: unknown\n meta?: unknown\n}\n\n// Cap on serialized payload size. superjson can succeed on values like SDK\n// client instances (OpenAI, etc.) and produce hundreds of KB to MB of useless\n// internal state. Anything beyond this is replaced with a stub so the span\n// still ships and the trace isn't dropped server-side.\nconst MAX_SERIALIZED_BYTES = 512_000\n\n// A higher cap for the framework-capture path (toJsonSafe). Agent/graph states\n// (LangGraph, Claude Agent SDK) are legitimately larger than a single\n// function's args/return, so this ceiling preserves real detail while still\n// bounding the payload so the wire-side JSON.stringify can't blow up or get the\n// span rejected server-side.\nconst MAX_FRAMEWORK_SERIALIZED_BYTES = 2_000_000\n\nfunction describeValue(value: unknown): string {\n try {\n const ctorName = (value as { constructor?: { name?: string } })?.constructor\n ?.name\n if (ctorName && ctorName !== \"Object\") {\n return ctorName\n }\n } catch {\n // Property access on `value` can throw (Proxy, poisoned getter).\n }\n return typeof value\n}\n\nfunction unserializableStub(value: unknown, reason: string): SerializedValue {\n // Normalize the byte count out of the key so a too_large warning dedups\n // across differently-sized payloads instead of warning once per size.\n warnOnce(\n `serialize:${reason.replace(/\\d+/g, \"N\")}`,\n `a value could not be fully serialized for a span (${reason}); it was replaced with a placeholder. The span still ships, but its captured input/output is incomplete.`,\n )\n let summary: string\n try {\n summary = `<unserializable: ${describeValue(value)} (${reason})>`\n } catch {\n summary = `<unserializable (${reason})>`\n }\n return { json: summary }\n}\n\n/**\n * Serialize a value using superjson for trace storage.\n *\n * Handles arbitrary JavaScript values including:\n * - Date, RegExp, Error\n * - Map, Set\n * - BigInt\n * - undefined (in objects/arrays)\n * - Circular references\n *\n * Guarantees:\n * - Never throws. Pathological inputs (SDK clients, proxies, poisoned\n * getters, circular graphs that defeat superjson) return a stub string.\n * - Never returns a payload larger than MAX_SERIALIZED_BYTES; oversized\n * inputs are replaced with a stub. Without this the wire-side\n * `JSON.stringify` in http.ts can produce a request that times out or\n * gets rejected, leaving a trace with zero spans.\n *\n * @param value - Any JavaScript value to serialize\n * @returns SerializedValue with 'json' field containing the data.\n * If type metadata is needed for reconstruction, includes 'meta' field.\n *\n * @example\n * ```typescript\n * const result = serializeValue(new Date('2024-01-15T10:30:00Z'))\n * // result.json contains the ISO string\n * // result.meta contains type info for Date reconstruction\n * ```\n */\nexport function serializeValue(value: unknown): SerializedValue {\n try {\n const { json, meta } = superjson.serialize(value)\n\n let size: number\n try {\n size = JSON.stringify(json).length\n } catch {\n return unserializableStub(value, \"stringify_failed_after_superjson\")\n }\n if (size > MAX_SERIALIZED_BYTES) {\n return unserializableStub(value, `too_large_${size}_bytes`)\n }\n\n return meta ? { json, meta } : { json }\n } catch {\n try {\n return { json: JSON.parse(JSON.stringify(value)) }\n } catch {\n return unserializableStub(value, \"json_stringify_failed\")\n }\n }\n}\n\n/**\n * Deserialize a value that was serialized with serializeValue.\n *\n * @param serialized - A SerializedValue object with 'json' and optional 'meta'\n * @returns The reconstructed JavaScript value\n *\n * @example\n * ```typescript\n * const serialized = serializeValue(new Date('2024-01-15'))\n * const date = deserializeValue(serialized)\n * // date is a Date object\n * ```\n */\nexport function deserializeValue(serialized: SerializedValue): unknown {\n if (serialized.meta === undefined) {\n // No metadata, return as-is\n return serialized.json\n }\n\n // Use superjson to deserialize with type reconstruction\n // Cast json to the expected superjson type\n type SuperJSONResult = Parameters<typeof superjson.deserialize>[0]\n return superjson.deserialize({\n json: serialized.json as SuperJSONResult[\"json\"],\n meta: serialized.meta as SuperJSONResult[\"meta\"],\n })\n}\n\nconst MAX_SAFE_DEPTH = 6\n\n/**\n * Convert any value to JSON-safe primitives, never throwing.\n *\n * Produces plain objects/arrays/scalars, recursing through `toJSON()` and\n * own-enumerable properties so no raw non-serializable value (a class, a\n * BigInt-bearing object) survives into a span payload. Cycles collapse to a\n * `<cycle ...>` marker; depth is capped.\n *\n * This is the single shared \"safe serialize\" used by the framework\n * integrations that capture raw objects (LangGraph, Claude Agent SDK). Keeping\n * the recurse-the-dump logic here, in one place, is what stops a new\n * integration from reintroducing the \"dump without recursing\" bug — see\n * `serializationInvariant.test.ts`.\n */\nexport function toJsonSafe(value: unknown): unknown {\n const safe = toJsonSafeInner(value, 0, new WeakSet())\n // Cap output size for parity with serializeValue. A multi-MB framework\n // payload (a large LangGraph state, a long message history) would otherwise\n // be JSON.stringify'd synchronously on the user's thread in http.ts and may\n // be rejected server-side, leaving a trace with zero spans. Stub it instead\n // so the span still ships. toJsonSafeInner produces only plain\n // objects/arrays/scalars/strings, so JSON.stringify here cannot throw; the\n // try is belt-and-suspenders.\n try {\n const size = JSON.stringify(safe)?.length ?? 0\n if (size > MAX_FRAMEWORK_SERIALIZED_BYTES) {\n warnOnce(\n \"toJsonSafe:too_large\",\n `a framework payload exceeded ${MAX_FRAMEWORK_SERIALIZED_BYTES} bytes and was replaced with a placeholder so the span still ships. The captured state for this span is incomplete.`,\n )\n return `<unserializable: too_large_${size}_bytes>`\n }\n } catch {\n // Keep the recursed value; the http-layer sanitizer is the final backstop.\n }\n return safe\n}\n\nfunction toJsonSafeInner(\n value: unknown,\n depth: number,\n seen: WeakSet<object>,\n): unknown {\n if (value === null || value === undefined) {\n return value\n }\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n return value\n }\n\n const className =\n (value as { constructor?: { name?: string } })?.constructor?.name ??\n typeof value\n if (depth > MAX_SAFE_DEPTH) {\n return `<${className}>`\n }\n\n // Non-object composites (bigint, function, symbol) stringify directly.\n if (typeof value !== \"object\") {\n try {\n return String(value)\n } catch {\n return `<${className}>`\n }\n }\n\n if (seen.has(value as object)) {\n return `<cycle ${className}>`\n }\n seen.add(value as object)\n\n let result: unknown\n if (Array.isArray(value)) {\n result = value.map((item) => toJsonSafeInner(item, depth + 1, seen))\n } else if (typeof (value as Record<string, unknown>).toJSON === \"function\") {\n // Recurse toJSON() output: it can still hold non-serializable values (e.g.\n // a LangChain tool whose schema is a class) that would otherwise survive\n // into the span payload and crash the wire-side JSON.stringify.\n try {\n result = toJsonSafeInner(\n (value as { toJSON(): unknown }).toJSON(),\n depth + 1,\n seen,\n )\n } catch {\n result = `<${className}>`\n }\n } else {\n try {\n const obj: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(value)) {\n if (!k.startsWith(\"_\")) {\n obj[k] = toJsonSafeInner(v, depth + 1, seen)\n }\n }\n result = obj\n } catch {\n result = `<${className}>`\n }\n }\n\n // Backtrack: keep only ancestors on the current path in `seen`, so a shared\n // (DAG) reference under sibling keys is serialized again rather than stubbed\n // as a false cycle. Real cycles (an ancestor referencing itself) are still\n // caught above.\n seen.delete(value as object)\n return result\n}\n","/**\n * Shared AsyncLocalStorage loader.\n *\n * Provides two ways to initialize AsyncLocalStorage:\n *\n * 1. **Synchronous registration** (preferred for Node.js):\n * `asyncStorageNode.ts` calls `registerAsyncLocalStorageClass()` at module\n * evaluation time, so the class is available immediately — no async gap.\n * The `node.ts` entry point imports it before anything else.\n *\n * 2. **Async dynamic import** (fallback for the default entry point):\n * Loads `node:async_hooks` via a bundler-safe dynamic import. This is used\n * by the default `index.ts` entry point so the SDK works in browsers\n * (where the import silently fails) and in Node.js when imported via the\n * default entry point.\n *\n * ## Why the dynamic import looks like this\n *\n * We need to handle three environments:\n *\n * 1. **Pure Node.js** — `import(\"node:async_hooks\")` works natively.\n * 2. **Webpack/Turbopack (Next.js server)** — The bundler processes\n * `import()` calls at build time. The `webpackIgnore` magic comment tells\n * webpack (and turbopack) to emit a native `import()` call instead of\n * trying to resolve it, so Node.js handles it at runtime.\n * 3. **Browsers / Edge** — The `process.versions?.node` guard prevents\n * execution entirely. If it somehow runs, `.catch(() => {})` swallows\n * the failure.\n */\n\nexport interface AsyncLocalStorageLike<T> {\n getStore(): T | undefined\n run<R>(store: T, fn: () => R): R\n}\n\nlet AsyncLocalStorageClass: (new () => AsyncLocalStorageLike<unknown>) | null =\n null\nlet initDone = false\n\n/**\n * Register the AsyncLocalStorage class synchronously.\n *\n * Called by `asyncStorageNode.ts` at module evaluation time so the class\n * is available before any span is created — no async gap, no race condition.\n *\n * Safe to call multiple times; subsequent calls are no-ops.\n */\nexport function registerAsyncLocalStorageClass(\n cls: new () => AsyncLocalStorageLike<unknown>,\n): void {\n if (!AsyncLocalStorageClass) {\n AsyncLocalStorageClass = cls\n }\n initDone = true\n}\n\n/**\n * Assert that AsyncLocalStorage was registered successfully.\n *\n * Called by `node.ts` after importing `asyncStorageNode.ts` to catch\n * import-order bugs at startup rather than silently degrading to the\n * browser fallback (flat spans with no nesting).\n *\n * This should ONLY be called from the Node.js entry point where we\n * know `node:async_hooks` must be available.\n */\nexport function assertAsyncStorageRegistered(): void {\n if (!AsyncLocalStorageClass) {\n console.warn(\n \"Bitfab: AsyncLocalStorage not available — nested span context will not propagate.\",\n )\n }\n}\n\nexport const asyncStorageReady: Promise<void> = (\n typeof process !== \"undefined\" && process.versions?.node\n ? // The join trick hides \"node:async_hooks\" from static analysis so\n // bundlers that ban Node.js built-ins don't fail at build time.\n // webpackIgnore tells webpack/turbopack to emit a native import()\n // so Node.js can resolve the module at runtime.\n import(\n /* webpackIgnore: true */\n [\"node\", \"async_hooks\"].join(\":\")\n )\n .then(\n (mod: {\n AsyncLocalStorage: new () => AsyncLocalStorageLike<unknown>\n }) => {\n registerAsyncLocalStorageClass(mod.AsyncLocalStorage)\n },\n )\n .catch(() => {})\n : Promise.resolve()\n).then(() => {\n initDone = true\n})\n\nexport function isAsyncStorageInitDone(): boolean {\n return initDone\n}\n\nexport function createAsyncLocalStorage<T>(): AsyncLocalStorageLike<T> | null {\n return AsyncLocalStorageClass\n ? (new AsyncLocalStorageClass() as AsyncLocalStorageLike<T>)\n : null\n}\n","/**\n * Replay context propagation via AsyncLocalStorage.\n *\n * When set, the withSpan wrapper injects testRunId into the span payload\n * so that new spans created during replay are linked to the test run.\n * Optionally carries a mock tree so child spans can return historical\n * outputs instead of executing.\n */\n\nimport {\n type AsyncLocalStorageLike,\n asyncStorageReady,\n createAsyncLocalStorage,\n} from \"./asyncStorage.js\"\n\n/** A single span entry in the mock tree with its historical output. */\nexport interface MockSpan {\n sourceSpanId: string\n output: unknown\n outputMeta?: unknown\n}\n\n/**\n * Per-item DB branch resolved by the Bitfab service from the source\n * trace's `dbSnapshotRef`. Carried on the replay context so that\n * customer code reads `databaseUrl` through `ReplayEnvironment`, and so\n * the process-isolated replay runner can materialize it into a `.env`\n * overlay file before customer code initializes its DB client.\n *\n * `neonBranchId` is the literal Neon branch id; passing it to\n * `releaseDbBranchLease` deletes that branch.\n */\nexport interface DbBranchLease {\n neonBranchId: string\n /** Env var name the customer's app reads, e.g. \"DATABASE_URL\". */\n envKey: string\n databaseUrl: string\n expiresAt: string\n /**\n * The instant the branch was pinned to (the source trace's wall clock).\n * Echoed back in `db_snapshot_usage` on the replayed trace's completion.\n */\n snapshotTimestamp?: string\n providerConsoleUrl?: string\n readOnly?: boolean\n}\n\n/**\n * Pre-built lookup table of historical span outputs.\n * Keys are `${traceFunctionKey}:${spanName}:${callIndex}` so that repeated\n * calls with the same (key, name) are matched by call order, but spans\n * sharing only the traceFunctionKey (different name) do not collide.\n */\nexport interface MockTree {\n spans: Map<string, MockSpan>\n}\n\nexport interface ReplayContext {\n testRunId: string\n traceId?: string\n inputSourceSpanId?: string\n /**\n * External trace ID from `external_traces.id`. Used for span-chain\n * lookup against the source platform's trace tree (Braintrust, etc.).\n * NOT the same as the Bitfab `traceId` — see `sourceBitfabTraceId`.\n */\n inputSourceTraceId?: string\n /**\n * The Bitfab `traces.id` of the historical trace that produced this\n * replay item's input. This is what customer-facing surfaces (e.g.\n * `ReplayEnvironment.traceId`) should expose, since it's the ID the\n * customer sees in the Bitfab dashboard.\n */\n sourceBitfabTraceId?: string\n mockTree?: MockTree\n callCounters?: Map<string, number>\n mockStrategy?: \"none\" | \"all\" | \"marked\"\n dbBranchLease?: DbBranchLease\n /**\n * Set to true by `ReplayEnvironment` the first time customer code\n * actually obtains `databaseUrl` for this item (via the getter or\n * `snapshot()`). Reported on the trace completion inside\n * `db_snapshot_usage` so the server can distinguish \"branch was\n * provisioned and exposed\" from \"branch URL was actually consumed\".\n * Any future consumption path that hands the URL to customer code by\n * other means (e.g. a process-isolated runner writing an env overlay)\n * must also set this.\n */\n dbSnapshotAccessed?: boolean\n /**\n * Collector for the replay item's trace-persistence work. When present,\n * the root span's send path pushes a promise that resolves only after\n * every span upload AND the trace completion have been sent (registered\n * synchronously at send time, so the replay runner can await it after\n * the wrapped fn resolves). This is what lets replay guarantee traces\n * are persisted server-side before `completeReplay` builds the\n * trace-ID mapping. Absent outside replay, where sends stay\n * fire-and-forget.\n */\n pendingPersistence?: Promise<unknown>[]\n}\n\nlet replayContextStorage: AsyncLocalStorageLike<ReplayContext | null> | null =\n null\n\nexport const replayContextReady: Promise<void> = asyncStorageReady.then(() => {\n replayContextStorage = createAsyncLocalStorage<ReplayContext | null>()\n})\n\n/** Get the current replay context, if any. */\nexport function getReplayContext(): ReplayContext | null {\n return replayContextStorage?.getStore() ?? null\n}\n\n/** Run a function within a replay context. */\nexport function runWithReplayContext<T>(ctx: ReplayContext, fn: () => T): T {\n if (replayContextStorage) {\n return replayContextStorage.run(ctx, fn)\n }\n return fn()\n}\n"],"mappings":";AAMO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YACE,SACgB,KAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACAA,IAAM,SAAS,oBAAI,IAAY;AAExB,SAAS,SAAS,KAAa,SAAuB;AAC3D,MAAI,OAAO,IAAI,GAAG,GAAG;AACnB;AAAA,EACF;AACA,SAAO,IAAI,GAAG;AACd,MAAI;AACF,YAAQ,KAAK,YAAY,OAAO,EAAE;AAAA,EACpC,QAAQ;AAAA,EAER;AACF;;;ACTO,SAAS,aAAqB;AACnC,QAAM,eACJ,WACA;AACF,MAAI,OAAO,cAAc,eAAe,YAAY;AAClD,QAAI;AACF,aAAO,aAAa,WAAW;AAAA,IACjC,QAAQ;AAAA,IAER;AAAA,EACF;AACA;AAAA,IACE;AAAA,IACA;AAAA,EACF;AACA,SAAO,eAAe;AACxB;AAMA,SAAS,iBAAyB;AAChC,SAAO,uCAAuC,QAAQ,SAAS,CAAC,SAAS;AACvE,UAAM,OAAQ,KAAK,OAAO,IAAI,KAAM;AACpC,UAAM,QAAQ,SAAS,MAAM,OAAQ,OAAO,IAAO;AACnD,WAAO,MAAM,SAAS,EAAE;AAAA,EAC1B,CAAC;AACH;;;ACrCA,OAAO,eAAe;AAmBtB,IAAM,uBAAuB;AAO7B,IAAM,iCAAiC;AAEvC,SAAS,cAAc,OAAwB;AAC7C,MAAI;AACF,UAAM,WAAY,OAA+C,aAC7D;AACJ,QAAI,YAAY,aAAa,UAAU;AACrC,aAAO;AAAA,IACT;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO,OAAO;AAChB;AAEA,SAAS,mBAAmB,OAAgB,QAAiC;AAG3E;AAAA,IACE,aAAa,OAAO,QAAQ,QAAQ,GAAG,CAAC;AAAA,IACxC,qDAAqD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