bitfab 0.52.4 → 0.52.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +2 -0
  2. package/dist/autoTrace.cjs +84 -34
  3. package/dist/autoTrace.cjs.map +1 -1
  4. package/dist/autoTrace.d.cts +19 -4
  5. package/dist/autoTrace.d.ts +19 -4
  6. package/dist/autoTrace.js +9 -3
  7. package/dist/{chunk-HKTODDFP.js → chunk-5KVK733P.js} +3 -3
  8. package/dist/chunk-5KVK733P.js.map +1 -0
  9. package/dist/{chunk-U2D7ACC4.js → chunk-DRTHTSHO.js} +110 -13
  10. package/dist/chunk-DRTHTSHO.js.map +1 -0
  11. package/dist/{chunk-ZUD7OFYB.js → chunk-E5BLYL5X.js} +81 -34
  12. package/dist/chunk-E5BLYL5X.js.map +1 -0
  13. package/dist/{chunk-IG3CPSRQ.js → chunk-GJKU7VWG.js} +2 -2
  14. package/dist/{chunk-IG3CPSRQ.js.map → chunk-GJKU7VWG.js.map} +1 -1
  15. package/dist/{chunk-34B7PVAM.js → chunk-NXC6NYIY.js} +3 -2
  16. package/dist/{chunk-34B7PVAM.js.map → chunk-NXC6NYIY.js.map} +1 -1
  17. package/dist/{chunk-AUROMI67.js → chunk-P26KVTI5.js} +371 -46
  18. package/dist/chunk-P26KVTI5.js.map +1 -0
  19. package/dist/{http-F3AXLOJT.js → http-ER2NMEKI.js} +2 -2
  20. package/dist/{http-RFNQ7LSU.js → http-MGES3ZVX.js} +2 -2
  21. package/dist/index.cjs +561 -104
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +10 -2
  24. package/dist/index.d.ts +10 -2
  25. package/dist/index.js +4 -4
  26. package/dist/node.cjs +561 -104
  27. package/dist/node.cjs.map +1 -1
  28. package/dist/node.d.cts +1 -1
  29. package/dist/node.d.ts +1 -1
  30. package/dist/node.js +4 -4
  31. package/dist/{replay-ZOTYMBMD.js → replay-5XES2LBL.js} +3 -3
  32. package/dist/replayCli.js +2 -2
  33. package/dist/seedCli.js +2 -2
  34. package/package.json +1 -1
  35. package/dist/chunk-AUROMI67.js.map +0 -1
  36. package/dist/chunk-HKTODDFP.js.map +0 -1
  37. package/dist/chunk-U2D7ACC4.js.map +0 -1
  38. package/dist/chunk-ZUD7OFYB.js.map +0 -1
  39. /package/dist/{http-F3AXLOJT.js.map → http-ER2NMEKI.js.map} +0 -0
  40. /package/dist/{http-RFNQ7LSU.js.map → http-MGES3ZVX.js.map} +0 -0
  41. /package/dist/{replay-ZOTYMBMD.js.map → replay-5XES2LBL.js.map} +0 -0
package/README.md CHANGED
@@ -263,6 +263,8 @@ When `executeLocally: false`, the SDK:
263
263
  - `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, etc.: LLM provider API keys (required for local execution)
264
264
  - `BITFAB_OTEL_MAX_REQUEST_BYTES`: request-size target for exports (positive integer up to `3000000`)
265
265
  - `BITFAB_OTEL_EXPORT_CONCURRENCY`: concurrent direct requests per export window (`1`-`64`, default `32`)
266
+ - `BITFAB_COMMIT_SHA`: the commit recorded as `commit_ref.sha` on every root trace, for a container built without a deploy platform's build variables or a git checkout
267
+ - `BITFAB_DISABLE_COMMIT_REF`: set to send no `commit_ref` at all
266
268
 
267
269
  ## Testing
268
270
 
@@ -24,8 +24,11 @@ __export(autoTrace_exports, {
24
24
  __bitfabAutoTraceActive: () => __bitfabAutoTraceActive,
25
25
  __bitfabAutoWrap: () => __bitfabAutoWrap,
26
26
  __setBitfabAutoTraceCapturePolicy: () => __setBitfabAutoTraceCapturePolicy,
27
+ clearAutoTraceNodeConfiguration: () => clearAutoTraceNodeConfiguration,
28
+ currentAutoTraceEntries: () => currentAutoTraceEntries,
27
29
  getAutoTraceCapturePolicy: () => getAutoTraceCapturePolicy,
28
- runWithAutoTraceContext: () => runWithAutoTraceContext,
30
+ invokeThroughAutoTraceEntries: () => invokeThroughAutoTraceEntries,
31
+ runWithAutoTraceEntry: () => runWithAutoTraceEntry,
29
32
  runWithAutoTraceNodeConfiguration: () => runWithAutoTraceNodeConfiguration,
30
33
  runWithAutoTraceRootContext: () => runWithAutoTraceRootContext
31
34
  });
@@ -63,19 +66,18 @@ function createAsyncLocalStorage() {
63
66
 
64
67
  // src/autoTrace.ts
65
68
  var autoTraceGlobal = globalThis;
66
- var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV3 ?? {
69
+ var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {
67
70
  storage: null,
68
71
  browserScope: void 0,
69
72
  capturePolicies: /* @__PURE__ */ new WeakMap(),
70
73
  activeRoots: 0
71
74
  };
72
- autoTraceGlobal.__bitfabAutoTraceStateV3 = autoTraceState;
75
+ autoTraceGlobal.__bitfabAutoTraceStateV4 = autoTraceState;
73
76
  function initializeAutoTraceStorage() {
74
77
  autoTraceState.storage ?? (autoTraceState.storage = createAsyncLocalStorage());
75
78
  }
76
- function runWithAutoTraceContext(context, fn, depth = 0) {
79
+ function runWithAutoTraceScope(scope, fn) {
77
80
  initializeAutoTraceStorage();
78
- const scope = { context, depth };
79
81
  if (autoTraceState.storage) {
80
82
  return autoTraceState.storage.run(scope, fn);
81
83
  }
@@ -87,41 +89,65 @@ function runWithAutoTraceContext(context, fn, depth = 0) {
87
89
  autoTraceState.browserScope = previous;
88
90
  }
89
91
  }
92
+ function currentAutoTraceEntries() {
93
+ return currentAutoTraceScope()?.entries ?? [];
94
+ }
95
+ function replaceEntry(entries, previous, updated) {
96
+ return entries.map((entry) => entry === previous ? updated : entry);
97
+ }
98
+ function runWithAutoTraceEntry(previous, updated, fn) {
99
+ const result = runWithAutoTraceScope(
100
+ { entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },
101
+ fn
102
+ );
103
+ if (isAutoTraceAsyncGenerator(result)) {
104
+ return wrapAutoTraceEntryAsyncGenerator(previous, updated, result);
105
+ }
106
+ return result;
107
+ }
108
+ function wrapAutoTraceEntryAsyncGenerator(previous, updated, source) {
109
+ const step = (method, value) => runWithAutoTraceScope(
110
+ { entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },
111
+ () => source[method](value)
112
+ );
113
+ const wrapped = {
114
+ next: (value) => step("next", value),
115
+ return: (value) => step("return", value),
116
+ throw: (error) => step("throw", error),
117
+ [Symbol.asyncIterator]: () => wrapped
118
+ };
119
+ return wrapped;
120
+ }
121
+ function clearAutoTraceNodeConfiguration(fn) {
122
+ return runWithAutoTraceScope({ entries: currentAutoTraceEntries() }, fn);
123
+ }
90
124
  function runWithAutoTraceNodeConfiguration(nodeConfiguration, fn) {
91
125
  const scope = currentAutoTraceScope();
92
- if (!scope) {
126
+ if (!scope || scope.entries.length === 0) {
93
127
  return fn();
94
128
  }
95
- const configuredScope = { ...scope, nodeConfiguration };
96
- let result;
97
- if (autoTraceState.storage) {
98
- result = autoTraceState.storage.run(configuredScope, fn);
99
- } else {
100
- const previous = autoTraceState.browserScope;
101
- autoTraceState.browserScope = configuredScope;
102
- try {
103
- result = fn();
104
- } finally {
105
- autoTraceState.browserScope = previous;
106
- }
107
- }
129
+ const result = runWithAutoTraceScope({ ...scope, nodeConfiguration }, fn);
108
130
  if (isAutoTraceAsyncGenerator(result)) {
109
131
  return wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, result);
110
132
  }
111
133
  return result;
112
134
  }
113
- function runWithAutoTraceRootContext(context, fn) {
135
+ function runWithAutoTraceRootContext(context, spanStack, fn) {
114
136
  autoTraceState.activeRoots += 1;
137
+ const entries = [
138
+ ...currentAutoTraceEntries(),
139
+ { context, depth: 0, spanStack }
140
+ ];
115
141
  let result;
116
142
  try {
117
- result = runWithAutoTraceContext(context, fn);
143
+ result = runWithAutoTraceScope({ entries }, fn);
118
144
  } catch (error) {
119
145
  autoTraceState.activeRoots -= 1;
120
146
  throw error;
121
147
  }
122
148
  if (isAutoTraceAsyncGenerator(result)) {
123
149
  autoTraceState.activeRoots -= 1;
124
- return wrapAutoTraceAsyncGenerator(context, result);
150
+ return wrapAutoTraceAsyncGenerator(context, spanStack, result);
125
151
  }
126
152
  if (result instanceof Promise) {
127
153
  return result.finally(() => {
@@ -131,6 +157,15 @@ function runWithAutoTraceRootContext(context, fn) {
131
157
  autoTraceState.activeRoots -= 1;
132
158
  return result;
133
159
  }
160
+ function invokeThroughAutoTraceEntries(entries, step, fn) {
161
+ let run = fn;
162
+ for (let index = entries.length - 1; index >= 0; index -= 1) {
163
+ const entry = entries[index];
164
+ const next = run;
165
+ run = () => step(entry, next);
166
+ }
167
+ return run();
168
+ }
134
169
  function isAutoTraceAsyncGenerator(value) {
135
170
  if (value === null || typeof value !== "object") {
136
171
  return false;
@@ -138,8 +173,8 @@ function isAutoTraceAsyncGenerator(value) {
138
173
  const candidate = value;
139
174
  return typeof candidate.next === "function" && typeof candidate.return === "function" && typeof candidate.throw === "function" && typeof candidate[Symbol.asyncIterator] === "function";
140
175
  }
141
- function wrapAutoTraceAsyncGenerator(context, source) {
142
- const step = (method, value) => runWithAutoTraceRootContext(context, () => source[method](value));
176
+ function wrapAutoTraceAsyncGenerator(context, spanStack, source) {
177
+ const step = (method, value) => runWithAutoTraceRootContext(context, spanStack, () => source[method](value));
143
178
  const wrapped = {
144
179
  next: (value) => step("next", value),
145
180
  return: (value) => step("return", value),
@@ -161,20 +196,32 @@ function wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, source) {
161
196
  };
162
197
  return wrapped;
163
198
  }
199
+ function shareFinalize(configuration) {
200
+ const finalize = configuration.finalize;
201
+ if (finalize === void 0) {
202
+ return configuration;
203
+ }
204
+ let settled;
205
+ return {
206
+ ...configuration,
207
+ finalize: (result) => {
208
+ settled ?? (settled = Promise.resolve().then(() => finalize(result)));
209
+ return settled;
210
+ }
211
+ };
212
+ }
164
213
  function __bitfabAutoSpan(definition, inputs, fn) {
165
214
  const scope = currentAutoTraceScope();
166
- if (!scope) {
215
+ if (!scope || scope.entries.length === 0) {
167
216
  return fn();
168
217
  }
169
218
  const nameParts = definition.name.split(".");
170
219
  const simpleName = nameParts[nameParts.length - 1];
171
- const nodeConfiguration = simpleName === scope.nodeConfiguration?.functionName ? scope.nodeConfiguration : void 0;
172
- return scope.context.invoke(
173
- definition,
174
- inputs,
175
- fn,
176
- scope.depth,
177
- nodeConfiguration
220
+ const nodeConfiguration = simpleName === scope.nodeConfiguration?.functionName ? shareFinalize(scope.nodeConfiguration) : void 0;
221
+ return invokeThroughAutoTraceEntries(
222
+ scope.entries,
223
+ (entry, next) => entry.context.invoke(definition, inputs, next, entry, nodeConfiguration),
224
+ fn
178
225
  );
179
226
  }
180
227
  function __bitfabAutoWrap(definition, fn) {
@@ -206,7 +253,7 @@ function __bitfabAutoTraceActive() {
206
253
  if (autoTraceState.activeRoots === 0) {
207
254
  return false;
208
255
  }
209
- return currentAutoTraceScope() !== void 0;
256
+ return currentAutoTraceEntries().length > 0;
210
257
  }
211
258
  function currentAutoTraceScope() {
212
259
  initializeAutoTraceStorage();
@@ -233,8 +280,11 @@ function getAutoTraceCapturePolicy(client, traceFunctionKey) {
233
280
  __bitfabAutoTraceActive,
234
281
  __bitfabAutoWrap,
235
282
  __setBitfabAutoTraceCapturePolicy,
283
+ clearAutoTraceNodeConfiguration,
284
+ currentAutoTraceEntries,
236
285
  getAutoTraceCapturePolicy,
237
- runWithAutoTraceContext,
286
+ invokeThroughAutoTraceEntries,
287
+ runWithAutoTraceEntry,
238
288
  runWithAutoTraceNodeConfiguration,
239
289
  runWithAutoTraceRootContext
240
290
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/autoTrace.ts","../src/asyncStorage.ts"],"sourcesContent":["import {\n type AsyncLocalStorageLike,\n createAsyncLocalStorage,\n} from \"./asyncStorage.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 AutoTraceContext {\n invoke<T>(\n definition: AutoTraceFunctionDefinition,\n inputs: unknown[],\n fn: () => T,\n depth: number,\n nodeConfiguration?: AutoTraceNodeConfiguration,\n ): T\n}\n\ninterface AutoTraceScope {\n context: AutoTraceContext\n depth: number\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 __bitfabAutoTraceStateV3?: 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.__bitfabAutoTraceStateV3 ?? {\n storage: null,\n browserScope: undefined,\n capturePolicies: new WeakMap(),\n activeRoots: 0,\n }\nautoTraceGlobal.__bitfabAutoTraceStateV3 = autoTraceState\n\nfunction initializeAutoTraceStorage(): void {\n autoTraceState.storage ??= createAsyncLocalStorage<AutoTraceScope>()\n}\n\nexport function runWithAutoTraceContext<T>(\n context: AutoTraceContext,\n fn: () => T,\n depth = 0,\n): T {\n initializeAutoTraceStorage()\n const scope = { context, depth }\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 runWithAutoTraceNodeConfiguration<T>(\n nodeConfiguration: AutoTraceNodeConfiguration,\n fn: () => T,\n): T {\n const scope = currentAutoTraceScope()\n if (!scope) {\n return fn()\n }\n\n const configuredScope = { ...scope, nodeConfiguration }\n let result: T\n if (autoTraceState.storage) {\n result = autoTraceState.storage.run(configuredScope, fn)\n } else {\n const previous = autoTraceState.browserScope\n autoTraceState.browserScope = configuredScope\n try {\n result = fn()\n } finally {\n autoTraceState.browserScope = previous\n }\n }\n\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 fn: () => T,\n): T {\n autoTraceState.activeRoots += 1\n let result: T\n try {\n result = runWithAutoTraceContext(context, 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, 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\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 source: AutoTraceAsyncGenerator,\n): AutoTraceAsyncGenerator {\n const step = (\n method: \"next\" | \"return\" | \"throw\",\n value?: unknown,\n ): Promise<IteratorResult<unknown, unknown>> =>\n runWithAutoTraceRootContext(context, () => 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\nexport function __bitfabAutoSpan<T>(\n definition: AutoTraceFunctionDefinition,\n inputs: unknown[],\n fn: () => T,\n): T {\n const scope = currentAutoTraceScope()\n if (!scope) {\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 ? scope.nodeConfiguration\n : undefined\n return scope.context.invoke(\n definition,\n inputs,\n fn,\n scope.depth,\n nodeConfiguration,\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) {\n return false\n }\n return currentAutoTraceScope() !== undefined\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"],"mappings":";;;;;;;;;;;;;;;;;;;;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,IAC5B;AACN;;;AD7CA,IAAM,kBAAkB;AACxB,IAAM,iBACJ,gBAAgB,4BAA4B;AAAA,EAC1C,SAAS;AAAA,EACT,cAAc;AAAA,EACd,iBAAiB,oBAAI,QAAQ;AAAA,EAC7B,aAAa;AACf;AACF,gBAAgB,2BAA2B;AAE3C,SAAS,6BAAmC;AAC1C,iBAAe,YAAf,eAAe,UAAY,wBAAwC;AACrE;AAEO,SAAS,wBACd,SACA,IACA,QAAQ,GACL;AACH,6BAA2B;AAC3B,QAAM,QAAQ,EAAE,SAAS,MAAM;AAC/B,MAAI,eAAe,SAAS;AAC1B,WAAO,eAAe,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3C,UAAM,eAAe,UAAU,UAAU,SAAS,CAAC;AACnD,QAAI,iBAAiB,QAAW;AAC9B,aAAO,eAAe,IAAI,QAAQ;AAAA,QAChC,cAAc;AAAA,QACd,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,SAAS;AACf,SAAO,IAAI,MAAM,QAAQ;AAAA,IACvB,MAAM,YAAY,SAAS,MAAM;AAC/B,UAAI,CAAC,wBAAwB,GAAG;AAC9B,eAAO,QAAQ,MAAM,YAAY,SAAS,IAAI;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,GAAG;AACpC,WAAO;AAAA,EACT;AACA,SAAO,sBAAsB,MAAM;AACrC;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"],"sourcesContent":["import {\n type AsyncLocalStorageLike,\n createAsyncLocalStorage,\n} from \"./asyncStorage.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) {\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) {\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"],"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,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0BAAmC;AACjD,MAAI,eAAe,gBAAgB,GAAG;AACpC,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":[]}
@@ -16,12 +16,27 @@ interface AutoTraceNodeConfiguration {
16
16
  mockOnReplay?: boolean;
17
17
  finalize?: (result: any) => unknown | Promise<unknown>;
18
18
  }
19
+ interface NestedTraceLink {
20
+ traceFunctionKey: string;
21
+ traceId?: string;
22
+ rootSpanId?: string;
23
+ }
24
+ interface AutoTraceEntry {
25
+ context: AutoTraceContext;
26
+ depth: number;
27
+ spanStack: unknown;
28
+ }
19
29
  interface AutoTraceContext {
20
- invoke<T>(definition: AutoTraceFunctionDefinition, inputs: unknown[], fn: () => T, depth: number, nodeConfiguration?: AutoTraceNodeConfiguration): T;
30
+ readonly traceFunctionKey: string;
31
+ invoke<T>(definition: AutoTraceFunctionDefinition, inputs: unknown[], fn: () => T, entry: AutoTraceEntry, nodeConfiguration?: AutoTraceNodeConfiguration): T;
32
+ invokeNestedRoot<T>(name: string, functionName: string, inputs: unknown[], fn: () => T, entry: AutoTraceEntry, link: NestedTraceLink | undefined): T;
21
33
  }
22
- declare function runWithAutoTraceContext<T>(context: AutoTraceContext, fn: () => T, depth?: number): T;
34
+ declare function currentAutoTraceEntries(): readonly AutoTraceEntry[];
35
+ declare function runWithAutoTraceEntry<T>(previous: AutoTraceEntry, updated: AutoTraceEntry, fn: () => T): T;
36
+ declare function clearAutoTraceNodeConfiguration<T>(fn: () => T): T;
23
37
  declare function runWithAutoTraceNodeConfiguration<T>(nodeConfiguration: AutoTraceNodeConfiguration, fn: () => T): T;
24
- declare function runWithAutoTraceRootContext<T>(context: AutoTraceContext, fn: () => T): T;
38
+ declare function runWithAutoTraceRootContext<T>(context: AutoTraceContext, spanStack: unknown, fn: () => T): T;
39
+ declare function invokeThroughAutoTraceEntries<T>(entries: readonly AutoTraceEntry[], step: (entry: AutoTraceEntry, next: () => T) => T, fn: () => T): T;
25
40
  declare function __bitfabAutoSpan<T>(definition: AutoTraceFunctionDefinition, inputs: unknown[], fn: () => T): T;
26
41
  /**
27
42
  * Preserve a function's original call arguments for transform cases where
@@ -47,4 +62,4 @@ declare function __bitfabAutoTraceActive(): boolean;
47
62
  declare function __setBitfabAutoTraceCapturePolicy(client: object, traceFunctionKey: string, functionIds: Iterable<string> | undefined): void;
48
63
  declare function getAutoTraceCapturePolicy(client: object, traceFunctionKey: string): ReadonlySet<string> | undefined;
49
64
 
50
- export { type AutoTraceContext, type AutoTraceFunctionDefinition, type AutoTraceNodeConfiguration, __bitfabAutoSpan, __bitfabAutoTraceActive, __bitfabAutoWrap, __setBitfabAutoTraceCapturePolicy, getAutoTraceCapturePolicy, runWithAutoTraceContext, runWithAutoTraceNodeConfiguration, runWithAutoTraceRootContext };
65
+ export { type AutoTraceContext, type AutoTraceEntry, type AutoTraceFunctionDefinition, type AutoTraceNodeConfiguration, type NestedTraceLink, __bitfabAutoSpan, __bitfabAutoTraceActive, __bitfabAutoWrap, __setBitfabAutoTraceCapturePolicy, clearAutoTraceNodeConfiguration, currentAutoTraceEntries, getAutoTraceCapturePolicy, invokeThroughAutoTraceEntries, runWithAutoTraceEntry, runWithAutoTraceNodeConfiguration, runWithAutoTraceRootContext };
@@ -16,12 +16,27 @@ interface AutoTraceNodeConfiguration {
16
16
  mockOnReplay?: boolean;
17
17
  finalize?: (result: any) => unknown | Promise<unknown>;
18
18
  }
19
+ interface NestedTraceLink {
20
+ traceFunctionKey: string;
21
+ traceId?: string;
22
+ rootSpanId?: string;
23
+ }
24
+ interface AutoTraceEntry {
25
+ context: AutoTraceContext;
26
+ depth: number;
27
+ spanStack: unknown;
28
+ }
19
29
  interface AutoTraceContext {
20
- invoke<T>(definition: AutoTraceFunctionDefinition, inputs: unknown[], fn: () => T, depth: number, nodeConfiguration?: AutoTraceNodeConfiguration): T;
30
+ readonly traceFunctionKey: string;
31
+ invoke<T>(definition: AutoTraceFunctionDefinition, inputs: unknown[], fn: () => T, entry: AutoTraceEntry, nodeConfiguration?: AutoTraceNodeConfiguration): T;
32
+ invokeNestedRoot<T>(name: string, functionName: string, inputs: unknown[], fn: () => T, entry: AutoTraceEntry, link: NestedTraceLink | undefined): T;
21
33
  }
22
- declare function runWithAutoTraceContext<T>(context: AutoTraceContext, fn: () => T, depth?: number): T;
34
+ declare function currentAutoTraceEntries(): readonly AutoTraceEntry[];
35
+ declare function runWithAutoTraceEntry<T>(previous: AutoTraceEntry, updated: AutoTraceEntry, fn: () => T): T;
36
+ declare function clearAutoTraceNodeConfiguration<T>(fn: () => T): T;
23
37
  declare function runWithAutoTraceNodeConfiguration<T>(nodeConfiguration: AutoTraceNodeConfiguration, fn: () => T): T;
24
- declare function runWithAutoTraceRootContext<T>(context: AutoTraceContext, fn: () => T): T;
38
+ declare function runWithAutoTraceRootContext<T>(context: AutoTraceContext, spanStack: unknown, fn: () => T): T;
39
+ declare function invokeThroughAutoTraceEntries<T>(entries: readonly AutoTraceEntry[], step: (entry: AutoTraceEntry, next: () => T) => T, fn: () => T): T;
25
40
  declare function __bitfabAutoSpan<T>(definition: AutoTraceFunctionDefinition, inputs: unknown[], fn: () => T): T;
26
41
  /**
27
42
  * Preserve a function's original call arguments for transform cases where
@@ -47,4 +62,4 @@ declare function __bitfabAutoTraceActive(): boolean;
47
62
  declare function __setBitfabAutoTraceCapturePolicy(client: object, traceFunctionKey: string, functionIds: Iterable<string> | undefined): void;
48
63
  declare function getAutoTraceCapturePolicy(client: object, traceFunctionKey: string): ReadonlySet<string> | undefined;
49
64
 
50
- export { type AutoTraceContext, type AutoTraceFunctionDefinition, type AutoTraceNodeConfiguration, __bitfabAutoSpan, __bitfabAutoTraceActive, __bitfabAutoWrap, __setBitfabAutoTraceCapturePolicy, getAutoTraceCapturePolicy, runWithAutoTraceContext, runWithAutoTraceNodeConfiguration, runWithAutoTraceRootContext };
65
+ export { type AutoTraceContext, type AutoTraceEntry, type AutoTraceFunctionDefinition, type AutoTraceNodeConfiguration, type NestedTraceLink, __bitfabAutoSpan, __bitfabAutoTraceActive, __bitfabAutoWrap, __setBitfabAutoTraceCapturePolicy, clearAutoTraceNodeConfiguration, currentAutoTraceEntries, getAutoTraceCapturePolicy, invokeThroughAutoTraceEntries, runWithAutoTraceEntry, runWithAutoTraceNodeConfiguration, runWithAutoTraceRootContext };
package/dist/autoTrace.js CHANGED
@@ -3,19 +3,25 @@ import {
3
3
  __bitfabAutoTraceActive,
4
4
  __bitfabAutoWrap,
5
5
  __setBitfabAutoTraceCapturePolicy,
6
+ clearAutoTraceNodeConfiguration,
7
+ currentAutoTraceEntries,
6
8
  getAutoTraceCapturePolicy,
7
- runWithAutoTraceContext,
9
+ invokeThroughAutoTraceEntries,
10
+ runWithAutoTraceEntry,
8
11
  runWithAutoTraceNodeConfiguration,
9
12
  runWithAutoTraceRootContext
10
- } from "./chunk-ZUD7OFYB.js";
13
+ } from "./chunk-E5BLYL5X.js";
11
14
  import "./chunk-H6LZRFMN.js";
12
15
  export {
13
16
  __bitfabAutoSpan,
14
17
  __bitfabAutoTraceActive,
15
18
  __bitfabAutoWrap,
16
19
  __setBitfabAutoTraceCapturePolicy,
20
+ clearAutoTraceNodeConfiguration,
21
+ currentAutoTraceEntries,
17
22
  getAutoTraceCapturePolicy,
18
- runWithAutoTraceContext,
23
+ invokeThroughAutoTraceEntries,
24
+ runWithAutoTraceEntry,
19
25
  runWithAutoTraceNodeConfiguration,
20
26
  runWithAutoTraceRootContext
21
27
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BitfabError
3
- } from "./chunk-IG3CPSRQ.js";
3
+ } from "./chunk-GJKU7VWG.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-F3AXLOJT.js");
210
+ const { flushTraces: flushTraces2 } = await import("./http-ER2NMEKI.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-HKTODDFP.js.map
747
+ //# sourceMappingURL=chunk-5KVK733P.js.map