bitfab 0.54.11 → 0.54.13
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.cjs +0 -19
- package/dist/autoTrace.cjs.map +1 -1
- package/dist/autoTrace.d.cts +1 -3
- package/dist/autoTrace.d.ts +1 -3
- package/dist/autoTrace.js +1 -5
- package/dist/{chunk-G4LWALQ7.js → chunk-FZNRSEMN.js} +2 -2
- package/dist/{chunk-2C7M3Y3H.js → chunk-KPALXSAF.js} +3 -3
- package/dist/{chunk-MEJOPEKV.js → chunk-Q7HDNYYY.js} +65 -60
- package/dist/chunk-Q7HDNYYY.js.map +1 -0
- package/dist/{chunk-EGWJYCNT.js → chunk-RCHSYWKI.js} +2 -19
- package/dist/chunk-RCHSYWKI.js.map +1 -0
- package/dist/{chunk-RUBVHBIK.js → chunk-VW7MA7DS.js} +2 -8
- package/dist/{chunk-RUBVHBIK.js.map → chunk-VW7MA7DS.js.map} +1 -1
- package/dist/{chunk-FMUJONTQ.js → chunk-YKOD4GWI.js} +2 -9
- package/dist/{chunk-FMUJONTQ.js.map → chunk-YKOD4GWI.js.map} +1 -1
- package/dist/{http-AXPT27DO.js → http-42KAFBUN.js} +2 -2
- package/dist/{http-JQN2LHHF.js → http-7PF6XCJR.js} +2 -2
- package/dist/index.cjs +59 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -21
- package/dist/index.d.ts +20 -21
- package/dist/index.js +4 -4
- package/dist/node.cjs +59 -73
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +4 -4
- package/dist/{replay-DOG4KV7I.js → replay-5RHBDIEK.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-EGWJYCNT.js.map +0 -1
- package/dist/chunk-MEJOPEKV.js.map +0 -1
- /package/dist/{chunk-G4LWALQ7.js.map → chunk-FZNRSEMN.js.map} +0 -0
- /package/dist/{chunk-2C7M3Y3H.js.map → chunk-KPALXSAF.js.map} +0 -0
- /package/dist/{http-AXPT27DO.js.map → http-42KAFBUN.js.map} +0 -0
- /package/dist/{http-JQN2LHHF.js.map → http-7PF6XCJR.js.map} +0 -0
- /package/dist/{replay-DOG4KV7I.js.map → replay-5RHBDIEK.js.map} +0 -0
package/dist/autoTrace.cjs
CHANGED
|
@@ -23,10 +23,8 @@ __export(autoTrace_exports, {
|
|
|
23
23
|
__bitfabAutoSpan: () => __bitfabAutoSpan,
|
|
24
24
|
__bitfabAutoTraceActive: () => __bitfabAutoTraceActive,
|
|
25
25
|
__bitfabAutoWrap: () => __bitfabAutoWrap,
|
|
26
|
-
__setBitfabAutoTraceCapturePolicy: () => __setBitfabAutoTraceCapturePolicy,
|
|
27
26
|
clearAutoTraceNodeConfiguration: () => clearAutoTraceNodeConfiguration,
|
|
28
27
|
currentAutoTraceEntries: () => currentAutoTraceEntries,
|
|
29
|
-
getAutoTraceCapturePolicy: () => getAutoTraceCapturePolicy,
|
|
30
28
|
invokeThroughAutoTraceEntries: () => invokeThroughAutoTraceEntries,
|
|
31
29
|
runWithAutoTraceEntry: () => runWithAutoTraceEntry,
|
|
32
30
|
runWithAutoTraceNodeConfiguration: () => runWithAutoTraceNodeConfiguration,
|
|
@@ -267,30 +265,13 @@ function currentAutoTraceScope() {
|
|
|
267
265
|
initializeAutoTraceStorage();
|
|
268
266
|
return autoTraceState.storage?.getStore() ?? autoTraceState.browserScope;
|
|
269
267
|
}
|
|
270
|
-
function __setBitfabAutoTraceCapturePolicy(client, traceFunctionKey, functionIds) {
|
|
271
|
-
const policies = autoTraceState.capturePolicies.get(client) ?? /* @__PURE__ */ new Map();
|
|
272
|
-
if (functionIds === void 0) {
|
|
273
|
-
policies.delete(traceFunctionKey);
|
|
274
|
-
if (policies.size === 0) {
|
|
275
|
-
autoTraceState.capturePolicies.delete(client);
|
|
276
|
-
}
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
policies.set(traceFunctionKey, new Set(functionIds));
|
|
280
|
-
autoTraceState.capturePolicies.set(client, policies);
|
|
281
|
-
}
|
|
282
|
-
function getAutoTraceCapturePolicy(client, traceFunctionKey) {
|
|
283
|
-
return autoTraceState.capturePolicies.get(client)?.get(traceFunctionKey);
|
|
284
|
-
}
|
|
285
268
|
// Annotate the CommonJS export names for ESM import in node:
|
|
286
269
|
0 && (module.exports = {
|
|
287
270
|
__bitfabAutoSpan,
|
|
288
271
|
__bitfabAutoTraceActive,
|
|
289
272
|
__bitfabAutoWrap,
|
|
290
|
-
__setBitfabAutoTraceCapturePolicy,
|
|
291
273
|
clearAutoTraceNodeConfiguration,
|
|
292
274
|
currentAutoTraceEntries,
|
|
293
|
-
getAutoTraceCapturePolicy,
|
|
294
275
|
invokeThroughAutoTraceEntries,
|
|
295
276
|
runWithAutoTraceEntry,
|
|
296
277
|
runWithAutoTraceNodeConfiguration,
|
package/dist/autoTrace.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/autoTrace.ts","../src/asyncStorage.ts","../src/captureSuppression.ts"],"sourcesContent":["import {\n type AsyncLocalStorageLike,\n createAsyncLocalStorage,\n} from \"./asyncStorage.js\"\nimport { isCaptureSuppressed } from \"./captureSuppression.js\"\n\nexport interface AutoTraceFunctionDefinition {\n id: string\n name: string\n file: string\n line: number\n column: number\n async?: boolean\n wrapper?: boolean\n}\n\nexport interface AutoTraceNodeConfiguration {\n functionName: string\n name?: string\n type?: \"llm\" | \"agent\" | \"function\" | \"guardrail\" | \"handoff\" | \"custom\"\n capture: boolean\n testRunId?: string\n mockOnReplay?: boolean\n // biome-ignore lint/suspicious/noExplicitAny: node finalizers receive the configured function's result, whose type is owned by the caller\n finalize?: (result: any) => unknown | Promise<unknown>\n}\n\nexport interface NestedTraceLink {\n traceFunctionKey: string\n traceId?: string\n rootSpanId?: string\n}\n\nexport interface AutoTraceEntry {\n context: AutoTraceContext\n depth: number\n spanStack: unknown\n}\n\nexport interface AutoTraceContext {\n readonly traceFunctionKey: string\n invoke<T>(\n definition: AutoTraceFunctionDefinition,\n inputs: unknown[],\n fn: () => T,\n entry: AutoTraceEntry,\n nodeConfiguration?: AutoTraceNodeConfiguration,\n ): T\n invokeNestedRoot<T>(\n name: string,\n functionName: string,\n inputs: unknown[],\n fn: () => T,\n entry: AutoTraceEntry,\n link: NestedTraceLink | undefined,\n ): T\n}\n\ninterface AutoTraceScope {\n entries: readonly AutoTraceEntry[]\n nodeConfiguration?: AutoTraceNodeConfiguration\n}\n\ninterface AutoTraceState {\n storage: AsyncLocalStorageLike<AutoTraceScope> | null\n browserScope: AutoTraceScope | undefined\n capturePolicies: WeakMap<object, Map<string, ReadonlySet<string>>>\n activeRoots: number\n}\n\ninterface AutoTraceGlobal {\n __bitfabAutoTraceStateV4?: AutoTraceState\n}\n\ninterface AutoTraceAsyncGenerator {\n next(value?: unknown): Promise<IteratorResult<unknown, unknown>>\n return(value?: unknown): Promise<IteratorResult<unknown, unknown>>\n throw(error?: unknown): Promise<IteratorResult<unknown, unknown>>\n [Symbol.asyncIterator](): AutoTraceAsyncGenerator\n}\n\nconst autoTraceGlobal = globalThis as unknown as AutoTraceGlobal\nconst autoTraceState: AutoTraceState =\n autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {\n storage: null,\n browserScope: undefined,\n capturePolicies: new WeakMap(),\n activeRoots: 0,\n }\nautoTraceGlobal.__bitfabAutoTraceStateV4 = autoTraceState\n\nfunction initializeAutoTraceStorage(): void {\n autoTraceState.storage ??= createAsyncLocalStorage<AutoTraceScope>()\n}\n\nfunction runWithAutoTraceScope<T>(scope: AutoTraceScope, fn: () => T): T {\n initializeAutoTraceStorage()\n if (autoTraceState.storage) {\n return autoTraceState.storage.run(scope, fn)\n }\n\n const previous = autoTraceState.browserScope\n autoTraceState.browserScope = scope\n try {\n return fn()\n } finally {\n autoTraceState.browserScope = previous\n }\n}\n\nexport function currentAutoTraceEntries(): readonly AutoTraceEntry[] {\n return currentAutoTraceScope()?.entries ?? []\n}\n\nfunction replaceEntry(\n entries: readonly AutoTraceEntry[],\n previous: AutoTraceEntry,\n updated: AutoTraceEntry,\n): readonly AutoTraceEntry[] {\n return entries.map((entry) => (entry === previous ? updated : entry))\n}\n\nexport function runWithAutoTraceEntry<T>(\n previous: AutoTraceEntry,\n updated: AutoTraceEntry,\n fn: () => T,\n): T {\n const result = runWithAutoTraceScope(\n { entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },\n fn,\n )\n if (isAutoTraceAsyncGenerator(result)) {\n return wrapAutoTraceEntryAsyncGenerator(previous, updated, result) as T\n }\n return result\n}\n\nfunction wrapAutoTraceEntryAsyncGenerator(\n previous: AutoTraceEntry,\n updated: AutoTraceEntry,\n source: AutoTraceAsyncGenerator,\n): AutoTraceAsyncGenerator {\n const step = (\n method: \"next\" | \"return\" | \"throw\",\n value?: unknown,\n ): Promise<IteratorResult<unknown, unknown>> =>\n runWithAutoTraceScope(\n { entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },\n () => source[method](value),\n )\n const wrapped: AutoTraceAsyncGenerator = {\n next: (value) => step(\"next\", value),\n return: (value) => step(\"return\", value),\n throw: (error) => step(\"throw\", error),\n [Symbol.asyncIterator]: () => wrapped,\n }\n return wrapped\n}\n\nexport function clearAutoTraceNodeConfiguration<T>(fn: () => T): T {\n return runWithAutoTraceScope({ entries: currentAutoTraceEntries() }, fn)\n}\n\nexport function runWithAutoTraceNodeConfiguration<T>(\n nodeConfiguration: AutoTraceNodeConfiguration,\n fn: () => T,\n): T {\n const scope = currentAutoTraceScope()\n if (!scope || scope.entries.length === 0) {\n return fn()\n }\n\n const result = runWithAutoTraceScope({ ...scope, nodeConfiguration }, fn)\n if (isAutoTraceAsyncGenerator(result)) {\n return wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, result) as T\n }\n return result\n}\n\nexport function runWithAutoTraceRootContext<T>(\n context: AutoTraceContext,\n spanStack: unknown,\n fn: () => T,\n): T {\n autoTraceState.activeRoots += 1\n const entries = [\n ...currentAutoTraceEntries(),\n { context, depth: 0, spanStack },\n ]\n let result: T\n try {\n result = runWithAutoTraceScope({ entries }, fn)\n } catch (error) {\n autoTraceState.activeRoots -= 1\n throw error\n }\n\n if (isAutoTraceAsyncGenerator(result)) {\n autoTraceState.activeRoots -= 1\n return wrapAutoTraceAsyncGenerator(context, spanStack, result) as T\n }\n\n if (result instanceof Promise) {\n return result.finally(() => {\n autoTraceState.activeRoots -= 1\n }) as T\n }\n\n autoTraceState.activeRoots -= 1\n return result\n}\n\nexport function invokeThroughAutoTraceEntries<T>(\n entries: readonly AutoTraceEntry[],\n step: (entry: AutoTraceEntry, next: () => T) => T,\n fn: () => T,\n): T {\n let run = fn\n for (let index = entries.length - 1; index >= 0; index -= 1) {\n const entry = entries[index] as AutoTraceEntry\n const next = run\n run = () => step(entry, next)\n }\n return run()\n}\n\nfunction isAutoTraceAsyncGenerator(\n value: unknown,\n): value is AutoTraceAsyncGenerator {\n if (value === null || typeof value !== \"object\") {\n return false\n }\n const candidate = value as Record<PropertyKey, unknown>\n return (\n typeof candidate.next === \"function\" &&\n typeof candidate.return === \"function\" &&\n typeof candidate.throw === \"function\" &&\n typeof candidate[Symbol.asyncIterator] === \"function\"\n )\n}\n\nfunction wrapAutoTraceAsyncGenerator(\n context: AutoTraceContext,\n spanStack: unknown,\n source: AutoTraceAsyncGenerator,\n): AutoTraceAsyncGenerator {\n const step = (\n method: \"next\" | \"return\" | \"throw\",\n value?: unknown,\n ): Promise<IteratorResult<unknown, unknown>> =>\n runWithAutoTraceRootContext(context, spanStack, () => source[method](value))\n const wrapped: AutoTraceAsyncGenerator = {\n next: (value) => step(\"next\", value),\n return: (value) => step(\"return\", value),\n throw: (error) => step(\"throw\", error),\n [Symbol.asyncIterator]: () => wrapped,\n }\n return wrapped\n}\n\nfunction wrapAutoTraceNodeAsyncGenerator(\n nodeConfiguration: AutoTraceNodeConfiguration,\n source: AutoTraceAsyncGenerator,\n): AutoTraceAsyncGenerator {\n const step = (\n method: \"next\" | \"return\" | \"throw\",\n value?: unknown,\n ): Promise<IteratorResult<unknown, unknown>> =>\n runWithAutoTraceNodeConfiguration(nodeConfiguration, () =>\n source[method](value),\n )\n const wrapped: AutoTraceAsyncGenerator = {\n next: (value) => step(\"next\", value),\n return: (value) => step(\"return\", value),\n throw: (error) => step(\"throw\", error),\n [Symbol.asyncIterator]: () => wrapped,\n }\n return wrapped\n}\n\nfunction shareFinalize(\n configuration: AutoTraceNodeConfiguration,\n): AutoTraceNodeConfiguration {\n const finalize = configuration.finalize\n if (finalize === undefined) {\n return configuration\n }\n let settled: Promise<unknown> | undefined\n return {\n ...configuration,\n finalize: (result: unknown) => {\n settled ??= Promise.resolve().then(() => finalize(result))\n return settled\n },\n }\n}\n\nexport function __bitfabAutoSpan<T>(\n definition: AutoTraceFunctionDefinition,\n inputs: unknown[],\n fn: () => T,\n): T {\n const scope = currentAutoTraceScope()\n if (!scope || scope.entries.length === 0 || isCaptureSuppressed()) {\n return fn()\n }\n const nameParts = definition.name.split(\".\")\n const simpleName = nameParts[nameParts.length - 1]\n const nodeConfiguration =\n simpleName === scope.nodeConfiguration?.functionName\n ? shareFinalize(scope.nodeConfiguration)\n : undefined\n return invokeThroughAutoTraceEntries(\n scope.entries,\n (entry, next) =>\n entry.context.invoke(definition, inputs, next, entry, nodeConfiguration),\n fn,\n )\n}\n\n/**\n * Preserve a function's original call arguments for transform cases where\n * parameter bindings discard them, such as destructured arrow parameters.\n *\n * This helper is internal transform/runtime protocol. The proxy preserves the\n * target's callability, arity, async identity, and non-constructibility while\n * only allocating a trace closure beneath an active automatic trace root.\n *\n * @experimental The automatic tracing protocol may change.\n */\nexport function __bitfabAutoWrap<T extends (...args: never[]) => unknown>(\n definition: AutoTraceFunctionDefinition,\n fn: T,\n): T {\n if (fn.name === \"\") {\n const nameParts = definition.name.split(\".\")\n const inferredName = nameParts[nameParts.length - 1]\n if (inferredName !== undefined) {\n Object.defineProperty(fn, \"name\", {\n configurable: true,\n value: inferredName,\n })\n }\n }\n\n const target = fn as unknown as (...args: unknown[]) => unknown\n return new Proxy(target, {\n apply(callTarget, thisArg, args) {\n if (!__bitfabAutoTraceActive()) {\n return Reflect.apply(callTarget, thisArg, args)\n }\n return __bitfabAutoSpan(definition, args, () =>\n Reflect.apply(callTarget, thisArg, args),\n )\n },\n }) as unknown as T\n}\n\n/**\n * Return whether the current call is inside an automatic trace root.\n *\n * Build transforms use this before allocating function metadata, captured\n * inputs, or an invocation closure. It is internal transform/runtime protocol,\n * not a supported application API.\n *\n * @experimental The automatic tracing protocol may change.\n */\nexport function __bitfabAutoTraceActive(): boolean {\n if (autoTraceState.activeRoots === 0 || isCaptureSuppressed()) {\n return false\n }\n return currentAutoTraceEntries().length > 0\n}\n\nfunction currentAutoTraceScope(): AutoTraceScope | undefined {\n initializeAutoTraceStorage()\n return autoTraceState.storage?.getStore() ?? autoTraceState.browserScope\n}\n\nexport function __setBitfabAutoTraceCapturePolicy(\n client: object,\n traceFunctionKey: string,\n functionIds: Iterable<string> | undefined,\n): void {\n const policies = autoTraceState.capturePolicies.get(client) ?? new Map()\n if (functionIds === undefined) {\n policies.delete(traceFunctionKey)\n if (policies.size === 0) {\n autoTraceState.capturePolicies.delete(client)\n }\n return\n }\n policies.set(traceFunctionKey, new Set(functionIds))\n autoTraceState.capturePolicies.set(client, policies)\n}\n\nexport function getAutoTraceCapturePolicy(\n client: object,\n traceFunctionKey: string,\n): ReadonlySet<string> | undefined {\n return autoTraceState.capturePolicies.get(client)?.get(traceFunctionKey)\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","interface CaptureSuppressionState {\n depth: number\n}\n\ninterface CaptureSuppressionGlobal {\n __bitfabCaptureSuppressionV1?: CaptureSuppressionState\n}\n\nconst suppressionGlobal = globalThis as unknown as CaptureSuppressionGlobal\nconst suppressionState: CaptureSuppressionState =\n suppressionGlobal.__bitfabCaptureSuppressionV1 ?? { depth: 0 }\nsuppressionGlobal.__bitfabCaptureSuppressionV1 = suppressionState\n\nexport function isCaptureSuppressed(): boolean {\n return suppressionState.depth > 0\n}\n\nexport function runWithCaptureSuppressed<T>(fn: () => T): T {\n suppressionState.depth += 1\n try {\n return fn()\n } finally {\n suppressionState.depth -= 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmCA,IAAI,yBACF;AACF,IAAI,WAAW;AAUR,SAAS,+BACd,KACM;AACN,MAAI,CAAC,wBAAwB;AAC3B,6BAAyB;AAAA,EAC3B;AACA,aAAW;AACb;AAoBO,IAAM,qBACX,OAAO,YAAY,eAAe,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhD;AAAA;AAAA,IAEE,CAAC,QAAQ,aAAa,EAAE,KAAK,GAAG;AAAA,IAE/B;AAAA,IACC,CAAC,QAEK;AACJ,qCAA+B,IAAI,iBAAiB;AAAA,IACt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I;AAAA,MAChD;AACA,aAAO;AAAA,QAAiB;AAAA,QAAY;AAAA,QAAM,MACxC,QAAQ,MAAM,YAAY,SAAS,IAAI;AAAA,MACzC;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAWO,SAAS,0BAAmC;AACjD,MAAI,eAAe,gBAAgB,KAAK,oBAAoB,GAAG;AAC7D,WAAO;AAAA,EACT;AACA,SAAO,wBAAwB,EAAE,SAAS;AAC5C;AAEA,SAAS,wBAAoD;AAC3D,6BAA2B;AAC3B,SAAO,eAAe,SAAS,SAAS,KAAK,eAAe;AAC9D;AAEO,SAAS,kCACd,QACA,kBACA,aACM;AACN,QAAM,WAAW,eAAe,gBAAgB,IAAI,MAAM,KAAK,oBAAI,IAAI;AACvE,MAAI,gBAAgB,QAAW;AAC7B,aAAS,OAAO,gBAAgB;AAChC,QAAI,SAAS,SAAS,GAAG;AACvB,qBAAe,gBAAgB,OAAO,MAAM;AAAA,IAC9C;AACA;AAAA,EACF;AACA,WAAS,IAAI,kBAAkB,IAAI,IAAI,WAAW,CAAC;AACnD,iBAAe,gBAAgB,IAAI,QAAQ,QAAQ;AACrD;AAEO,SAAS,0BACd,QACA,kBACiC;AACjC,SAAO,eAAe,gBAAgB,IAAI,MAAM,GAAG,IAAI,gBAAgB;AACzE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/autoTrace.ts","../src/asyncStorage.ts","../src/captureSuppression.ts"],"sourcesContent":["import {\n type AsyncLocalStorageLike,\n createAsyncLocalStorage,\n} from \"./asyncStorage.js\"\nimport { isCaptureSuppressed } from \"./captureSuppression.js\"\n\nexport interface AutoTraceFunctionDefinition {\n id: string\n name: string\n file: string\n line: number\n column: number\n async?: boolean\n wrapper?: boolean\n}\n\nexport interface AutoTraceNodeConfiguration {\n functionName: string\n name?: string\n type?: \"llm\" | \"agent\" | \"function\" | \"guardrail\" | \"handoff\" | \"custom\"\n capture: boolean\n testRunId?: string\n mockOnReplay?: boolean\n // biome-ignore lint/suspicious/noExplicitAny: node finalizers receive the configured function's result, whose type is owned by the caller\n finalize?: (result: any) => unknown | Promise<unknown>\n}\n\nexport interface NestedTraceLink {\n traceFunctionKey: string\n traceId?: string\n rootSpanId?: string\n}\n\nexport interface AutoTraceEntry {\n context: AutoTraceContext\n depth: number\n spanStack: unknown\n}\n\nexport interface AutoTraceContext {\n readonly traceFunctionKey: string\n invoke<T>(\n definition: AutoTraceFunctionDefinition,\n inputs: unknown[],\n fn: () => T,\n entry: AutoTraceEntry,\n nodeConfiguration?: AutoTraceNodeConfiguration,\n ): T\n invokeNestedRoot<T>(\n name: string,\n functionName: string,\n inputs: unknown[],\n fn: () => T,\n entry: AutoTraceEntry,\n link: NestedTraceLink | undefined,\n ): T\n}\n\ninterface AutoTraceScope {\n entries: readonly AutoTraceEntry[]\n nodeConfiguration?: AutoTraceNodeConfiguration\n}\n\ninterface AutoTraceState {\n storage: AsyncLocalStorageLike<AutoTraceScope> | null\n browserScope: AutoTraceScope | undefined\n // Older SDK copies read this field when sharing the process-wide V4 state.\n capturePolicies: WeakMap<object, Map<string, ReadonlySet<string>>>\n activeRoots: number\n}\n\ninterface AutoTraceGlobal {\n __bitfabAutoTraceStateV4?: AutoTraceState\n}\n\ninterface AutoTraceAsyncGenerator {\n next(value?: unknown): Promise<IteratorResult<unknown, unknown>>\n return(value?: unknown): Promise<IteratorResult<unknown, unknown>>\n throw(error?: unknown): Promise<IteratorResult<unknown, unknown>>\n [Symbol.asyncIterator](): AutoTraceAsyncGenerator\n}\n\nconst autoTraceGlobal = globalThis as unknown as AutoTraceGlobal\nconst autoTraceState: AutoTraceState =\n autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {\n storage: null,\n browserScope: undefined,\n capturePolicies: new WeakMap(),\n activeRoots: 0,\n }\nautoTraceGlobal.__bitfabAutoTraceStateV4 = autoTraceState\n\nfunction initializeAutoTraceStorage(): void {\n autoTraceState.storage ??= createAsyncLocalStorage<AutoTraceScope>()\n}\n\nfunction runWithAutoTraceScope<T>(scope: AutoTraceScope, fn: () => T): T {\n initializeAutoTraceStorage()\n if (autoTraceState.storage) {\n return autoTraceState.storage.run(scope, fn)\n }\n\n const previous = autoTraceState.browserScope\n autoTraceState.browserScope = scope\n try {\n return fn()\n } finally {\n autoTraceState.browserScope = previous\n }\n}\n\nexport function currentAutoTraceEntries(): readonly AutoTraceEntry[] {\n return currentAutoTraceScope()?.entries ?? []\n}\n\nfunction replaceEntry(\n entries: readonly AutoTraceEntry[],\n previous: AutoTraceEntry,\n updated: AutoTraceEntry,\n): readonly AutoTraceEntry[] {\n return entries.map((entry) => (entry === previous ? updated : entry))\n}\n\nexport function runWithAutoTraceEntry<T>(\n previous: AutoTraceEntry,\n updated: AutoTraceEntry,\n fn: () => T,\n): T {\n const result = runWithAutoTraceScope(\n { entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },\n fn,\n )\n if (isAutoTraceAsyncGenerator(result)) {\n return wrapAutoTraceEntryAsyncGenerator(previous, updated, result) as T\n }\n return result\n}\n\nfunction wrapAutoTraceEntryAsyncGenerator(\n previous: AutoTraceEntry,\n updated: AutoTraceEntry,\n source: AutoTraceAsyncGenerator,\n): AutoTraceAsyncGenerator {\n const step = (\n method: \"next\" | \"return\" | \"throw\",\n value?: unknown,\n ): Promise<IteratorResult<unknown, unknown>> =>\n runWithAutoTraceScope(\n { entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },\n () => source[method](value),\n )\n const wrapped: AutoTraceAsyncGenerator = {\n next: (value) => step(\"next\", value),\n return: (value) => step(\"return\", value),\n throw: (error) => step(\"throw\", error),\n [Symbol.asyncIterator]: () => wrapped,\n }\n return wrapped\n}\n\nexport function clearAutoTraceNodeConfiguration<T>(fn: () => T): T {\n return runWithAutoTraceScope({ entries: currentAutoTraceEntries() }, fn)\n}\n\nexport function runWithAutoTraceNodeConfiguration<T>(\n nodeConfiguration: AutoTraceNodeConfiguration,\n fn: () => T,\n): T {\n const scope = currentAutoTraceScope()\n if (!scope || scope.entries.length === 0) {\n return fn()\n }\n\n const result = runWithAutoTraceScope({ ...scope, nodeConfiguration }, fn)\n if (isAutoTraceAsyncGenerator(result)) {\n return wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, result) as T\n }\n return result\n}\n\nexport function runWithAutoTraceRootContext<T>(\n context: AutoTraceContext,\n spanStack: unknown,\n fn: () => T,\n): T {\n autoTraceState.activeRoots += 1\n const entries = [\n ...currentAutoTraceEntries(),\n { context, depth: 0, spanStack },\n ]\n let result: T\n try {\n result = runWithAutoTraceScope({ entries }, fn)\n } catch (error) {\n autoTraceState.activeRoots -= 1\n throw error\n }\n\n if (isAutoTraceAsyncGenerator(result)) {\n autoTraceState.activeRoots -= 1\n return wrapAutoTraceAsyncGenerator(context, spanStack, result) as T\n }\n\n if (result instanceof Promise) {\n return result.finally(() => {\n autoTraceState.activeRoots -= 1\n }) as T\n }\n\n autoTraceState.activeRoots -= 1\n return result\n}\n\nexport function invokeThroughAutoTraceEntries<T>(\n entries: readonly AutoTraceEntry[],\n step: (entry: AutoTraceEntry, next: () => T) => T,\n fn: () => T,\n): T {\n let run = fn\n for (let index = entries.length - 1; index >= 0; index -= 1) {\n const entry = entries[index] as AutoTraceEntry\n const next = run\n run = () => step(entry, next)\n }\n return run()\n}\n\nfunction isAutoTraceAsyncGenerator(\n value: unknown,\n): value is AutoTraceAsyncGenerator {\n if (value === null || typeof value !== \"object\") {\n return false\n }\n const candidate = value as Record<PropertyKey, unknown>\n return (\n typeof candidate.next === \"function\" &&\n typeof candidate.return === \"function\" &&\n typeof candidate.throw === \"function\" &&\n typeof candidate[Symbol.asyncIterator] === \"function\"\n )\n}\n\nfunction wrapAutoTraceAsyncGenerator(\n context: AutoTraceContext,\n spanStack: unknown,\n source: AutoTraceAsyncGenerator,\n): AutoTraceAsyncGenerator {\n const step = (\n method: \"next\" | \"return\" | \"throw\",\n value?: unknown,\n ): Promise<IteratorResult<unknown, unknown>> =>\n runWithAutoTraceRootContext(context, spanStack, () => source[method](value))\n const wrapped: AutoTraceAsyncGenerator = {\n next: (value) => step(\"next\", value),\n return: (value) => step(\"return\", value),\n throw: (error) => step(\"throw\", error),\n [Symbol.asyncIterator]: () => wrapped,\n }\n return wrapped\n}\n\nfunction wrapAutoTraceNodeAsyncGenerator(\n nodeConfiguration: AutoTraceNodeConfiguration,\n source: AutoTraceAsyncGenerator,\n): AutoTraceAsyncGenerator {\n const step = (\n method: \"next\" | \"return\" | \"throw\",\n value?: unknown,\n ): Promise<IteratorResult<unknown, unknown>> =>\n runWithAutoTraceNodeConfiguration(nodeConfiguration, () =>\n source[method](value),\n )\n const wrapped: AutoTraceAsyncGenerator = {\n next: (value) => step(\"next\", value),\n return: (value) => step(\"return\", value),\n throw: (error) => step(\"throw\", error),\n [Symbol.asyncIterator]: () => wrapped,\n }\n return wrapped\n}\n\nfunction shareFinalize(\n configuration: AutoTraceNodeConfiguration,\n): AutoTraceNodeConfiguration {\n const finalize = configuration.finalize\n if (finalize === undefined) {\n return configuration\n }\n let settled: Promise<unknown> | undefined\n return {\n ...configuration,\n finalize: (result: unknown) => {\n settled ??= Promise.resolve().then(() => finalize(result))\n return settled\n },\n }\n}\n\nexport function __bitfabAutoSpan<T>(\n definition: AutoTraceFunctionDefinition,\n inputs: unknown[],\n fn: () => T,\n): T {\n const scope = currentAutoTraceScope()\n if (!scope || scope.entries.length === 0 || isCaptureSuppressed()) {\n return fn()\n }\n const nameParts = definition.name.split(\".\")\n const simpleName = nameParts[nameParts.length - 1]\n const nodeConfiguration =\n simpleName === scope.nodeConfiguration?.functionName\n ? shareFinalize(scope.nodeConfiguration)\n : undefined\n return invokeThroughAutoTraceEntries(\n scope.entries,\n (entry, next) =>\n entry.context.invoke(definition, inputs, next, entry, nodeConfiguration),\n fn,\n )\n}\n\n/**\n * Preserve a function's original call arguments for transform cases where\n * parameter bindings discard them, such as destructured arrow parameters.\n *\n * This helper is internal transform/runtime protocol. The proxy preserves the\n * target's callability, arity, async identity, and non-constructibility while\n * only allocating a trace closure beneath an active automatic trace root.\n *\n * @experimental The automatic tracing protocol may change.\n */\nexport function __bitfabAutoWrap<T extends (...args: never[]) => unknown>(\n definition: AutoTraceFunctionDefinition,\n fn: T,\n): T {\n if (fn.name === \"\") {\n const nameParts = definition.name.split(\".\")\n const inferredName = nameParts[nameParts.length - 1]\n if (inferredName !== undefined) {\n Object.defineProperty(fn, \"name\", {\n configurable: true,\n value: inferredName,\n })\n }\n }\n\n const target = fn as unknown as (...args: unknown[]) => unknown\n return new Proxy(target, {\n apply(callTarget, thisArg, args) {\n if (!__bitfabAutoTraceActive()) {\n return Reflect.apply(callTarget, thisArg, args)\n }\n return __bitfabAutoSpan(definition, args, () =>\n Reflect.apply(callTarget, thisArg, args),\n )\n },\n }) as unknown as T\n}\n\n/**\n * Return whether the current call is inside an automatic trace root.\n *\n * Build transforms use this before allocating function metadata, captured\n * inputs, or an invocation closure. It is internal transform/runtime protocol,\n * not a supported application API.\n *\n * @experimental The automatic tracing protocol may change.\n */\nexport function __bitfabAutoTraceActive(): boolean {\n if (autoTraceState.activeRoots === 0 || isCaptureSuppressed()) {\n return false\n }\n return currentAutoTraceEntries().length > 0\n}\n\nfunction currentAutoTraceScope(): AutoTraceScope | undefined {\n initializeAutoTraceStorage()\n return autoTraceState.storage?.getStore() ?? autoTraceState.browserScope\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","interface CaptureSuppressionState {\n depth: number\n}\n\ninterface CaptureSuppressionGlobal {\n __bitfabCaptureSuppressionV1?: CaptureSuppressionState\n}\n\nconst suppressionGlobal = globalThis as unknown as CaptureSuppressionGlobal\nconst suppressionState: CaptureSuppressionState =\n suppressionGlobal.__bitfabCaptureSuppressionV1 ?? { depth: 0 }\nsuppressionGlobal.__bitfabCaptureSuppressionV1 = suppressionState\n\nexport function isCaptureSuppressed(): boolean {\n return suppressionState.depth > 0\n}\n\nexport function runWithCaptureSuppressed<T>(fn: () => T): T {\n suppressionState.depth += 1\n try {\n return fn()\n } finally {\n suppressionState.depth -= 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmCA,IAAI,yBACF;AACF,IAAI,WAAW;AAUR,SAAS,+BACd,KACM;AACN,MAAI,CAAC,wBAAwB;AAC3B,6BAAyB;AAAA,EAC3B;AACA,aAAW;AACb;AAoBO,IAAM,qBACX,OAAO,YAAY,eAAe,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhD;AAAA;AAAA,IAEE,CAAC,QAAQ,aAAa,EAAE,KAAK,GAAG;AAAA,IAE/B;AAAA,IACC,CAAC,QAEK;AACJ,qCAA+B,IAAI,iBAAiB;AAAA,IACtD;AAAA,EACF,EACC,MAAM,MAAM;AAAA,EAAC,CAAC;AAAA,IACjB,QAAQ,QAAQ,GACpB,KAAK,MAAM;AACX,aAAW;AACb,CAAC;AAMM,SAAS,0BAA8D;AAC5E,SAAO,yBACF,IAAI,uBAAuB,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D,MAAI,eAAe,gBAAgB,KAAK,oBAAoB,GAAG;AAC7D,WAAO;AAAA,EACT;AACA,SAAO,wBAAwB,EAAE,SAAS;AAC5C;AAEA,SAAS,wBAAoD;AAC3D,6BAA2B;AAC3B,SAAO,eAAe,SAAS,SAAS,KAAK,eAAe;AAC9D;","names":[]}
|
package/dist/autoTrace.d.cts
CHANGED
|
@@ -59,7 +59,5 @@ declare function __bitfabAutoWrap<T extends (...args: never[]) => unknown>(defin
|
|
|
59
59
|
* @experimental The automatic tracing protocol may change.
|
|
60
60
|
*/
|
|
61
61
|
declare function __bitfabAutoTraceActive(): boolean;
|
|
62
|
-
declare function __setBitfabAutoTraceCapturePolicy(client: object, traceFunctionKey: string, functionIds: Iterable<string> | undefined): void;
|
|
63
|
-
declare function getAutoTraceCapturePolicy(client: object, traceFunctionKey: string): ReadonlySet<string> | undefined;
|
|
64
62
|
|
|
65
|
-
export { type AutoTraceContext, type AutoTraceEntry, type AutoTraceFunctionDefinition, type AutoTraceNodeConfiguration, type NestedTraceLink, __bitfabAutoSpan, __bitfabAutoTraceActive, __bitfabAutoWrap,
|
|
63
|
+
export { type AutoTraceContext, type AutoTraceEntry, type AutoTraceFunctionDefinition, type AutoTraceNodeConfiguration, type NestedTraceLink, __bitfabAutoSpan, __bitfabAutoTraceActive, __bitfabAutoWrap, clearAutoTraceNodeConfiguration, currentAutoTraceEntries, invokeThroughAutoTraceEntries, runWithAutoTraceEntry, runWithAutoTraceNodeConfiguration, runWithAutoTraceRootContext };
|
package/dist/autoTrace.d.ts
CHANGED
|
@@ -59,7 +59,5 @@ declare function __bitfabAutoWrap<T extends (...args: never[]) => unknown>(defin
|
|
|
59
59
|
* @experimental The automatic tracing protocol may change.
|
|
60
60
|
*/
|
|
61
61
|
declare function __bitfabAutoTraceActive(): boolean;
|
|
62
|
-
declare function __setBitfabAutoTraceCapturePolicy(client: object, traceFunctionKey: string, functionIds: Iterable<string> | undefined): void;
|
|
63
|
-
declare function getAutoTraceCapturePolicy(client: object, traceFunctionKey: string): ReadonlySet<string> | undefined;
|
|
64
62
|
|
|
65
|
-
export { type AutoTraceContext, type AutoTraceEntry, type AutoTraceFunctionDefinition, type AutoTraceNodeConfiguration, type NestedTraceLink, __bitfabAutoSpan, __bitfabAutoTraceActive, __bitfabAutoWrap,
|
|
63
|
+
export { type AutoTraceContext, type AutoTraceEntry, type AutoTraceFunctionDefinition, type AutoTraceNodeConfiguration, type NestedTraceLink, __bitfabAutoSpan, __bitfabAutoTraceActive, __bitfabAutoWrap, clearAutoTraceNodeConfiguration, currentAutoTraceEntries, invokeThroughAutoTraceEntries, runWithAutoTraceEntry, runWithAutoTraceNodeConfiguration, runWithAutoTraceRootContext };
|
package/dist/autoTrace.js
CHANGED
|
@@ -2,24 +2,20 @@ import {
|
|
|
2
2
|
__bitfabAutoSpan,
|
|
3
3
|
__bitfabAutoTraceActive,
|
|
4
4
|
__bitfabAutoWrap,
|
|
5
|
-
__setBitfabAutoTraceCapturePolicy,
|
|
6
5
|
clearAutoTraceNodeConfiguration,
|
|
7
6
|
currentAutoTraceEntries,
|
|
8
|
-
getAutoTraceCapturePolicy,
|
|
9
7
|
invokeThroughAutoTraceEntries,
|
|
10
8
|
runWithAutoTraceEntry,
|
|
11
9
|
runWithAutoTraceNodeConfiguration,
|
|
12
10
|
runWithAutoTraceRootContext
|
|
13
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RCHSYWKI.js";
|
|
14
12
|
import "./chunk-VCRFFCLY.js";
|
|
15
13
|
export {
|
|
16
14
|
__bitfabAutoSpan,
|
|
17
15
|
__bitfabAutoTraceActive,
|
|
18
16
|
__bitfabAutoWrap,
|
|
19
|
-
__setBitfabAutoTraceCapturePolicy,
|
|
20
17
|
clearAutoTraceNodeConfiguration,
|
|
21
18
|
currentAutoTraceEntries,
|
|
22
|
-
getAutoTraceCapturePolicy,
|
|
23
19
|
invokeThroughAutoTraceEntries,
|
|
24
20
|
runWithAutoTraceEntry,
|
|
25
21
|
runWithAutoTraceNodeConfiguration,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
replayContextReady,
|
|
7
7
|
runWithReplayContext,
|
|
8
8
|
warnOnce
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YKOD4GWI.js";
|
|
10
10
|
import {
|
|
11
11
|
runWithCaptureSuppressed
|
|
12
12
|
} from "./chunk-VCRFFCLY.js";
|
|
@@ -1257,4 +1257,4 @@ export {
|
|
|
1257
1257
|
sleepForReplayPersistence,
|
|
1258
1258
|
replay
|
|
1259
1259
|
};
|
|
1260
|
-
//# sourceMappingURL=chunk-
|
|
1260
|
+
//# sourceMappingURL=chunk-FZNRSEMN.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BitfabError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VW7MA7DS.js";
|
|
4
4
|
|
|
5
5
|
// src/codeChange.ts
|
|
6
6
|
var NUL = String.fromCharCode(0);
|
|
@@ -207,7 +207,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
207
207
|
sessionId: seedCase.sessionId
|
|
208
208
|
})
|
|
209
209
|
);
|
|
210
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
210
|
+
const { flushTraces: flushTraces2 } = await import("./http-7PF6XCJR.js");
|
|
211
211
|
await flushTraces2(3e4);
|
|
212
212
|
return { pipeline, traceFunctionKey, traceIds };
|
|
213
213
|
}
|
|
@@ -744,4 +744,4 @@ export {
|
|
|
744
744
|
runRegistryMain,
|
|
745
745
|
runIfEntrypoint
|
|
746
746
|
};
|
|
747
|
-
//# sourceMappingURL=chunk-
|
|
747
|
+
//# sourceMappingURL=chunk-KPALXSAF.js.map
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__bitfabAutoTraceActive,
|
|
3
|
-
__setBitfabAutoTraceCapturePolicy,
|
|
4
3
|
clearAutoTraceNodeConfiguration,
|
|
5
4
|
currentAutoTraceEntries,
|
|
6
|
-
getAutoTraceCapturePolicy,
|
|
7
5
|
invokeThroughAutoTraceEntries,
|
|
8
6
|
runWithAutoTraceEntry,
|
|
9
7
|
runWithAutoTraceNodeConfiguration,
|
|
10
8
|
runWithAutoTraceRootContext
|
|
11
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-RCHSYWKI.js";
|
|
12
10
|
import {
|
|
13
11
|
NO_MOCK_OVERRIDE,
|
|
14
12
|
createIntegrationFixtureContext,
|
|
@@ -19,13 +17,12 @@ import {
|
|
|
19
17
|
serializeValue,
|
|
20
18
|
toJsonSafe,
|
|
21
19
|
toJsonSafeReport
|
|
22
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-FZNRSEMN.js";
|
|
23
21
|
import {
|
|
24
22
|
BitfabError,
|
|
25
23
|
DEFAULT_SERVICE_URL,
|
|
26
24
|
HttpClient,
|
|
27
25
|
MixedTracingError,
|
|
28
|
-
PolicyRefresh,
|
|
29
26
|
ROOT_TRACE_FUNCTION_KEY_FIELD,
|
|
30
27
|
SimulationPlan,
|
|
31
28
|
callerTraceMetadata,
|
|
@@ -36,7 +33,7 @@ import {
|
|
|
36
33
|
recordCallerTraceMetadata,
|
|
37
34
|
retireTraceMetadata,
|
|
38
35
|
warnOnce
|
|
39
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-YKOD4GWI.js";
|
|
40
37
|
import {
|
|
41
38
|
__privateAdd,
|
|
42
39
|
__privateGet,
|
|
@@ -2653,18 +2650,42 @@ var RIVET_TOP_LEVEL_EFFECTS = [
|
|
|
2653
2650
|
"broadcast",
|
|
2654
2651
|
"saveState",
|
|
2655
2652
|
"sleep",
|
|
2656
|
-
"destroy"
|
|
2653
|
+
"destroy",
|
|
2654
|
+
"step",
|
|
2655
|
+
"tryStep",
|
|
2656
|
+
"try",
|
|
2657
|
+
"loop",
|
|
2658
|
+
"sleepUntil",
|
|
2659
|
+
"rollbackCheckpoint",
|
|
2660
|
+
"join",
|
|
2661
|
+
"race",
|
|
2662
|
+
"removed",
|
|
2663
|
+
"getVersion"
|
|
2657
2664
|
];
|
|
2658
2665
|
var TOP_LEVEL_UNAVAILABLE_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
2659
2666
|
"conn",
|
|
2660
2667
|
"conns",
|
|
2661
|
-
"log",
|
|
2662
2668
|
"request",
|
|
2663
2669
|
"actorRuntimeSocket",
|
|
2664
2670
|
"keepAwake",
|
|
2665
2671
|
"waitUntil",
|
|
2666
2672
|
"client"
|
|
2667
2673
|
]);
|
|
2674
|
+
var replayLog = () => void 0;
|
|
2675
|
+
var replayLogger = {
|
|
2676
|
+
level: "silent",
|
|
2677
|
+
msgPrefix: void 0,
|
|
2678
|
+
fatal: replayLog,
|
|
2679
|
+
trace: replayLog,
|
|
2680
|
+
silent: replayLog,
|
|
2681
|
+
debug: replayLog,
|
|
2682
|
+
info: replayLog,
|
|
2683
|
+
warn: replayLog,
|
|
2684
|
+
error: replayLog,
|
|
2685
|
+
child: () => replayLogger,
|
|
2686
|
+
bindings: () => ({}),
|
|
2687
|
+
isLevelEnabled: () => false
|
|
2688
|
+
};
|
|
2668
2689
|
var SYNC_VOID_EFFECTS = /* @__PURE__ */ new Set([
|
|
2669
2690
|
"broadcast",
|
|
2670
2691
|
"sleep",
|
|
@@ -2694,16 +2715,28 @@ function snapshotContext(context) {
|
|
|
2694
2715
|
"state",
|
|
2695
2716
|
"vars",
|
|
2696
2717
|
"actorId",
|
|
2718
|
+
"workflowId",
|
|
2697
2719
|
"name",
|
|
2698
2720
|
"key",
|
|
2699
|
-
"region"
|
|
2700
|
-
"aborted"
|
|
2721
|
+
"region"
|
|
2701
2722
|
]) {
|
|
2702
2723
|
const value = readProperty(source, property);
|
|
2703
2724
|
if (value !== void 0) {
|
|
2704
2725
|
snapshot[property] = value;
|
|
2705
2726
|
}
|
|
2706
2727
|
}
|
|
2728
|
+
const aborted = readProperty(source, "aborted");
|
|
2729
|
+
if (typeof aborted === "boolean") {
|
|
2730
|
+
snapshot.aborted = aborted;
|
|
2731
|
+
} else {
|
|
2732
|
+
const abortSignal = readProperty(source, "abortSignal");
|
|
2733
|
+
if (isRecord2(abortSignal)) {
|
|
2734
|
+
const signalAborted = readProperty(abortSignal, "aborted");
|
|
2735
|
+
if (typeof signalAborted === "boolean") {
|
|
2736
|
+
snapshot.aborted = signalAborted;
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2707
2740
|
return snapshot;
|
|
2708
2741
|
}
|
|
2709
2742
|
function unavailableCapability(path) {
|
|
@@ -2795,7 +2828,8 @@ var BitfabRivetIntegration = class {
|
|
|
2795
2828
|
}
|
|
2796
2829
|
/**
|
|
2797
2830
|
* Adapt a traced function into a Rivet handler whose first argument is the
|
|
2798
|
-
* live actor context. The context is not added to the traced
|
|
2831
|
+
* live actor or workflow context. The context is not added to the traced
|
|
2832
|
+
* root's inputs.
|
|
2799
2833
|
*/
|
|
2800
2834
|
bind(fn) {
|
|
2801
2835
|
const integration = this;
|
|
@@ -2806,7 +2840,8 @@ var BitfabRivetIntegration = class {
|
|
|
2806
2840
|
/**
|
|
2807
2841
|
* Return the current Rivet context proxy. In production it delegates to the
|
|
2808
2842
|
* bound live context. During replay it hydrates recorded actor state and
|
|
2809
|
-
* intercepts supported effects without requiring a live Rivet actor
|
|
2843
|
+
* intercepts supported effects without requiring a live Rivet actor or
|
|
2844
|
+
* workflow.
|
|
2810
2845
|
*/
|
|
2811
2846
|
getContext() {
|
|
2812
2847
|
const replay = getReplayContext();
|
|
@@ -2890,6 +2925,12 @@ var BitfabRivetIntegration = class {
|
|
|
2890
2925
|
if (property === "setPreventSleep" && replay) {
|
|
2891
2926
|
return (_preventSleep) => void 0;
|
|
2892
2927
|
}
|
|
2928
|
+
if (property === "isEvicted" && replay) {
|
|
2929
|
+
return () => replayTarget.abortSignal?.aborted === true;
|
|
2930
|
+
}
|
|
2931
|
+
if (property === "log" && replay) {
|
|
2932
|
+
return replayLogger;
|
|
2933
|
+
}
|
|
2893
2934
|
if (replay && typeof property === "string" && TOP_LEVEL_UNAVAILABLE_CAPABILITIES.has(property)) {
|
|
2894
2935
|
throw unavailableCapability(property);
|
|
2895
2936
|
}
|
|
@@ -3063,7 +3104,7 @@ var BitfabRivetIntegration = class {
|
|
|
3063
3104
|
return { ...value, complete };
|
|
3064
3105
|
}
|
|
3065
3106
|
queueCallIsCompletable(effect, args) {
|
|
3066
|
-
const options = effect === "queue.waitForNames" ? args[1] : args[0];
|
|
3107
|
+
const options = effect === "queue.waitForNames" || (effect === "queue.next" || effect === "queue.nextBatch") && typeof args[0] === "string" ? args[1] : args[0];
|
|
3067
3108
|
return isRecord2(options) && options.completable === true;
|
|
3068
3109
|
}
|
|
3069
3110
|
createQueueIterator(queue, options) {
|
|
@@ -4031,8 +4072,6 @@ function readBooleanEnv(name) {
|
|
|
4031
4072
|
var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
|
|
4032
4073
|
var DEFAULT_AUTO_TRACE_MAX_SPANS = 500;
|
|
4033
4074
|
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
4034
|
-
var AUTO_TRACE_POLICY_REFRESH_MS = 6e4;
|
|
4035
|
-
var AUTO_TRACE_POLICY_RETRY_MS = 1e4;
|
|
4036
4075
|
function spanOwnerName(receiver) {
|
|
4037
4076
|
if (typeof receiver === "function") {
|
|
4038
4077
|
return receiver.name !== "" ? receiver.name : void 0;
|
|
@@ -4065,7 +4104,6 @@ var Bitfab = class {
|
|
|
4065
4104
|
constructor(config) {
|
|
4066
4105
|
/** Gate the empty-key warning to fire at most once. */
|
|
4067
4106
|
this.apiKeyWarned = false;
|
|
4068
|
-
this.autoTracePolicyRefreshes = /* @__PURE__ */ new Map();
|
|
4069
4107
|
/**
|
|
4070
4108
|
* Mock overrides registered via {@link Bitfab.registerMockOverride}, applied
|
|
4071
4109
|
* to every `replay` on this client (after any per-call `mockOverride`). In
|
|
@@ -4114,12 +4152,12 @@ var Bitfab = class {
|
|
|
4114
4152
|
*
|
|
4115
4153
|
* Build instrumentation turns repository functions called beneath this
|
|
4116
4154
|
* method into nested spans that capture inputs, outputs, and errors by
|
|
4117
|
-
* default.
|
|
4118
|
-
*
|
|
4155
|
+
* default. Source exclusions and sim-plan capture-off decisions are explicit
|
|
4156
|
+
* opt-outs from that default.
|
|
4119
4157
|
* Without a compatible build transform, this still records the decorated
|
|
4120
4158
|
* method as a normal rich root span but cannot discover child calls.
|
|
4121
4159
|
*
|
|
4122
|
-
* @param traceFunctionKey - Groups traces and their capture
|
|
4160
|
+
* @param traceFunctionKey - Groups traces and their capture controls.
|
|
4123
4161
|
* @param options - Root presentation, subtree bounds, and exclusions.
|
|
4124
4162
|
* @experimental Automatic child-call instrumentation is experimental.
|
|
4125
4163
|
*/
|
|
@@ -4277,11 +4315,6 @@ var Bitfab = class {
|
|
|
4277
4315
|
traceFunctionKey,
|
|
4278
4316
|
spanOptions,
|
|
4279
4317
|
function(...args) {
|
|
4280
|
-
const capturePolicy = getAutoTraceCapturePolicy(
|
|
4281
|
-
self,
|
|
4282
|
-
traceFunctionKey
|
|
4283
|
-
);
|
|
4284
|
-
self.refreshAutoTraceCapturePolicy(traceFunctionKey);
|
|
4285
4318
|
self.simulationPlan.refresh();
|
|
4286
4319
|
let spansUsed = 0;
|
|
4287
4320
|
let truncated = false;
|
|
@@ -4361,7 +4394,7 @@ var Bitfab = class {
|
|
|
4361
4394
|
surface: "opt-out",
|
|
4362
4395
|
instrumentation: "trace",
|
|
4363
4396
|
functionId: definition.id,
|
|
4364
|
-
captureContent:
|
|
4397
|
+
captureContent: true,
|
|
4365
4398
|
autoTraceDefinition: definition,
|
|
4366
4399
|
...nodeConfiguration?.testRunId !== void 0 && {
|
|
4367
4400
|
testRunId: nodeConfiguration.testRunId
|
|
@@ -4460,34 +4493,6 @@ var Bitfab = class {
|
|
|
4460
4493
|
applySimulationPlan(payload, submit) {
|
|
4461
4494
|
this.simulationPlan.send(payload, rootTraceFunctionKeyOf(payload), submit);
|
|
4462
4495
|
}
|
|
4463
|
-
refreshAutoTraceCapturePolicy(traceFunctionKey) {
|
|
4464
|
-
const state2 = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
|
|
4465
|
-
this.autoTracePolicyRefreshes.set(traceFunctionKey, state2);
|
|
4466
|
-
state2.run(
|
|
4467
|
-
() => this.httpClient.getAutoTracePolicy(
|
|
4468
|
-
traceFunctionKey,
|
|
4469
|
-
AUTO_TRACE_PROTOCOL
|
|
4470
|
-
),
|
|
4471
|
-
(policy) => {
|
|
4472
|
-
if (policy.protocol !== AUTO_TRACE_PROTOCOL) {
|
|
4473
|
-
state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
|
|
4474
|
-
return;
|
|
4475
|
-
}
|
|
4476
|
-
const functionIds = Array.isArray(policy.functionIds) ? policy.functionIds.filter(
|
|
4477
|
-
(id) => typeof id === "string" && id.startsWith(`${AUTO_TRACE_PROTOCOL}:`)
|
|
4478
|
-
).slice(0, DEFAULT_AUTO_TRACE_MAX_SPANS) : [];
|
|
4479
|
-
__setBitfabAutoTraceCapturePolicy(
|
|
4480
|
-
this,
|
|
4481
|
-
traceFunctionKey,
|
|
4482
|
-
policy.revision === null ? void 0 : functionIds
|
|
4483
|
-
);
|
|
4484
|
-
state2.hold(AUTO_TRACE_POLICY_REFRESH_MS);
|
|
4485
|
-
},
|
|
4486
|
-
() => {
|
|
4487
|
-
state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
|
|
4488
|
-
}
|
|
4489
|
-
);
|
|
4490
|
-
}
|
|
4491
4496
|
/**
|
|
4492
4497
|
* Flush and permanently close this client's tracing resources: its pending
|
|
4493
4498
|
* requests and the single span-transport worker shared by its decorators and
|
|
@@ -4790,9 +4795,9 @@ var Bitfab = class {
|
|
|
4790
4795
|
});
|
|
4791
4796
|
}
|
|
4792
4797
|
/**
|
|
4793
|
-
* Get the first-class Rivet actor-context integration for an
|
|
4794
|
-
* root. The integration binds context and records effect
|
|
4795
|
-
* creates another root.
|
|
4798
|
+
* Get the first-class Rivet actor/workflow-context integration for an
|
|
4799
|
+
* existing trace root. The integration binds context and records effect
|
|
4800
|
+
* spans; it never creates another root.
|
|
4796
4801
|
*
|
|
4797
4802
|
* @param traceFunctionKey - Key used by the enclosing `withTrace()` root
|
|
4798
4803
|
* @param options - Explicit per-context-path replay mocking policy
|
|
@@ -5894,7 +5899,7 @@ var Bitfab = class {
|
|
|
5894
5899
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
5895
5900
|
} finally {
|
|
5896
5901
|
try {
|
|
5897
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
5902
|
+
const { flushTraces: flushTraces2 } = await import("./http-42KAFBUN.js");
|
|
5898
5903
|
await flushTraces2(3e4);
|
|
5899
5904
|
} finally {
|
|
5900
5905
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -5953,7 +5958,7 @@ var Bitfab = class {
|
|
|
5953
5958
|
`Function is wrapped with trace function key '${wrappedKey}' but replay was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to replay it under the explicit key.`
|
|
5954
5959
|
);
|
|
5955
5960
|
}
|
|
5956
|
-
const { replay: doReplay } = await import("./replay-
|
|
5961
|
+
const { replay: doReplay } = await import("./replay-5RHBDIEK.js");
|
|
5957
5962
|
return doReplay(
|
|
5958
5963
|
this.httpClient,
|
|
5959
5964
|
this.serviceUrl,
|
|
@@ -6273,7 +6278,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
6273
6278
|
sessionId: seedCase.sessionId
|
|
6274
6279
|
})
|
|
6275
6280
|
);
|
|
6276
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
6281
|
+
const { flushTraces: flushTraces2 } = await import("./http-42KAFBUN.js");
|
|
6277
6282
|
await flushTraces2(3e4);
|
|
6278
6283
|
return { pipeline, traceFunctionKey, traceIds };
|
|
6279
6284
|
}
|
|
@@ -6312,4 +6317,4 @@ export {
|
|
|
6312
6317
|
reseedFromRegistry,
|
|
6313
6318
|
seedFromRegistry
|
|
6314
6319
|
};
|
|
6315
|
-
//# sourceMappingURL=chunk-
|
|
6320
|
+
//# sourceMappingURL=chunk-Q7HDNYYY.js.map
|