/** * Soft-detection adapter for Langfuse observability (Node.js). * * The module first attempts to detect an active trace reader from optional * Langfuse packages at module load. If no supported package is installed, or * if no active trace is available, it falls back to AsyncLocalStorage so * callers can still thread a trace ID explicitly with withLangfuseTrace(). * * Usage: * import { withLangfuseTrace } from "keel-sdk/integrations/langfuse"; * * const trace = langfuse.trace({ name: "my-agent" }); * const response = await withLangfuseTrace(trace.id, async () => { * return await openai.chat.completions.create({ ... }); * }); * * The Keel provider wrapper reads the trace ID automatically — no other * changes required. withLangfuseTrace remains the explicit fallback when no * supported Langfuse context package is installed. */ /** * Run `fn` with `traceId` set as the active Langfuse trace for the current * async context. Keel provider wrappers inside `fn` will automatically attach * the trace_id to their permit requests and usage reports. */ export declare function withLangfuseTrace(traceId: string, fn: () => T): T; /** * Returns the current active Langfuse trace ID from an installed Langfuse * tracing package when available, else falls back to the trace ID that was set * for the current async context via withLangfuseTrace(). * * This is called by Keel provider wrappers at permit-acquisition time. * Callers do not need to call this directly. */ export declare function getCurrentLangfuseTraceId(): string | undefined; export declare function mergeLangfuseOperationMetadata(operationMetadata: Record | undefined, traceId: string | undefined): Record | undefined; export declare function waitForLangfuseDetection(): Promise;